440 lines
292 KiB
JavaScript
440 lines
292 KiB
JavaScript
|
|
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e){return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e){var t=function(e,t){if(n(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||`default`);if(n(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return n(t)==`symbol`?t:t+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=class{constructor(){i(this,`browserShadowBlurConstant`,1),i(this,`DPI`,96),i(this,`devicePixelRatio`,typeof window<`u`?window.devicePixelRatio:1),i(this,`perfLimitSizeTotal`,2097152),i(this,`maxCacheSideLimit`,4096),i(this,`minCacheSideLimit`,256),i(this,`disableStyleCopyPaste`,!1),i(this,`enableGLFiltering`,!0),i(this,`textureSize`,4096),i(this,`forceGLPutImageData`,!1),i(this,`cachesBoundsOfCurve`,!1),i(this,`fontPaths`,{}),i(this,`NUM_FRACTION_DIGITS`,4)}};const o=new class extends a{constructor(e){super(),this.configure(e)}configure(e={}){Object.assign(this,e)}addFonts(e={}){this.fontPaths={...this.fontPaths,...e}}removeFonts(e=[]){e.forEach(e=>{delete this.fontPaths[e]})}clearFonts(){this.fontPaths={}}restoreDefaults(e){let t=new a,n=(e==null?void 0:e.reduce((e,n)=>(e[n]=t[n],e),{}))||t;this.configure(n)}},s=(e,...t)=>console[e](`fabric`,...t);var c=class extends Error{constructor(e,t){super(`fabric: ${e}`,t)}},l=class extends c{constructor(e){super(`${e} 'options.signal' is in 'aborted' state`)}},u=class{},d=class extends u{testPrecision(e,t){let n=`precision ${t} float;\nvoid main(){}`,r=e.createShader(e.FRAGMENT_SHADER);return!!r&&(e.shaderSource(r,n),e.compileShader(r),!!e.getShaderParameter(r,e.COMPILE_STATUS))}queryWebGL(e){let t=e.getContext(`webgl`);t&&(this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.GLPrecision=[`highp`,`mediump`,`lowp`].find(e=>this.testPrecision(t,e)),t.getExtension(`WEBGL_lose_context`).loseContext(),s(`log`,`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(e){return!!this.maxTextureSize&&this.maxTextureSize>=e}};const f={};let p;const m=e=>{p=e},h=()=>p||(p={document,window,isTouchSupported:`ontouchstart`in window||`ontouchstart`in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new d,dispose(){},copyPasteData:f}),g=()=>h().document,_=()=>h().window,v=()=>{var e;return Math.max((e=o.devicePixelRatio)==null?_().devicePixelRatio:e,1)},y=new class{constructor(){i(this,`boundsOfCurveCache`,{}),this.charWidthsCache=new Map}getFontCache({fontFamily:e,fontStyle:t,fontWeight:n}){e=e.toLowerCase();let r=this.charWidthsCache;r.has(e)||r.set(e,new Map);let i=r.get(e),a=`${t.toLowerCase()}_${(n+``).toLowerCase()}`;return i.has(a)||i.set(a,new Map),i.get(a)}clearFontCache(e){e?this.charWidthsCache.delete((e||``).toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(e){let{perfLimitSizeTotal:t}=o,n=Math.sqrt(t*e);return[Math.floor(n),Math.floor(t/n)]}},b=`7.4.0`;function x(){}const S=Math.PI/2,C=Math.PI/4,w=2*Math.PI,ee=Math.PI/180,T=Object.freeze([1,0,0,1,0,0]),E=`center`,D=`left`,O=`bottom`,k=`right`,te=`none`,ne=/\r?\n/,re=`moving`,ie=`scaling`,ae=`rotating`,oe=`rotate`,A=`skewing`,se=`resizing`,ce=`modifyPoly`,le=`changed`,ue=`scale`,de=`scaleX`,fe=`scaleY`,pe=`skewX`,me=`skewY`,j=`fill`,he=`stroke`,ge=`modified`,_e=`normal`,ve=`json`,M=new class{constructor(){this[ve]=new Map,this.svg=new Map}has(e){return this[ve].has(e)}getClass(e){let t=this[ve].get(e);if(!t)throw new c(`No class registered for ${e}`);return t}setClass(e,t){t?this[ve].set(t,e):(this[ve].set(e.type,e),this[ve].set(e.type.toLowerCase(),e))}getSVGClass(e){return this.svg.get(e)}setSVGClass(e,t){this.svg.set(t==null?e.type.toLowerCase():t,e)}},ye=new class extends
|
||
|
|
Resulting to default behavior: removing object from previous canvas and adding to new canvas`),e.canvas.remove(e)),e._set(`canvas`,this),e.setCoords(),this.fire(`object:added`,{target:e}),e.fire(`added`,{target:this})}_onObjectRemoved(e){e._set(`canvas`,void 0),this.fire(`object:removed`,{target:e}),e.fire(`removed`,{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?v():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}_setDimensionsImpl(e,{cssOnly:t=!1,backstoreOnly:n=!1}={}){if(!t){let t={width:this.width,height:this.height,...e};this.elements.setDimensions(t,this.getRetinaScaling()),this.hasLostContext=!0,this.width=t.width,this.height=t.height}n||this.elements.setCSSDimensions(e),this.calcOffset()}setDimensions(e,t){this._setDimensionsImpl(e,t),t&&t.cssOnly||this.requestRenderAll()}getZoom(){return Be(this.viewportTransform)}setViewportTransform(e){this.viewportTransform=e,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(e,t){let n=e,r=[...this.viewportTransform],i=L(e,R(r));r[0]=t,r[3]=t;let a=L(i,r);r[4]+=n.x-a.x,r[5]+=n.y-a.y,this.setViewportTransform(r)}setZoom(e){this.zoomToPoint(new N(0,0),e)}absolutePan(e){let t=[...this.viewportTransform];return t[4]=-e.x,t[5]=-e.y,this.setViewportTransform(t)}relativePan(e){return this.absolutePan(new N(-e.x-this.viewportTransform[4],-e.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(e){e.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=Oe(()=>this.renderAndReset()))}calcViewportBoundaries(){let e=this.width,t=this.height,n=R(this.viewportTransform),r=L({x:0,y:0},n),i=L({x:e,y:t},n),a=r.min(i),o=r.max(i);return this.vptCoords={tl:a,tr:new N(o.x,a.y),bl:new N(a.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(ke(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(e){}renderCanvas(e,t){if(this.destroyed)return;let n=this.viewportTransform,r=this.clipPath;this.calcViewportBoundaries(),this.clearContext(e),e.imageSmoothingEnabled=this.imageSmoothingEnabled,e.patternQuality=this.patternQuality,this.fire(`before:render`,{ctx:e}),this._renderBackground(e),e.save(),e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this._renderObjects(e,t),e.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(e),r&&(r._set(`canvas`,this),r.shouldCache(),r._transformDone=!0,r.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(e,r)),this._renderOverlay(e),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(e),this.fire(`after:render`,{ctx:e}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(e,t){let n=this.viewportTransform;e.save(),e.transform(...n),e.globalCompositeOperation=`destination-in`,t.transform(e),e.scale(1/t.zoomX,1/t.zoomY),e.drawImage(t._cacheCanvas,-t.cacheTranslationX,-t.cacheTranslationY),e.restore()}_renderObjects(e,t){for(let n=0,r=t.length;n<r;++n)t[n]&&t[n].render(e)}_renderBackgroundOrOverlay(e,t){let n=this[`${t}Color`],r=this[`${t}Image`],i=this.viewportTransform,a=this[`${t}Vpt`];if(!n&&!r)return;let o=V(n);if(n){if(e.save(),e.beginPath(),e.moveTo(0,0),e.lineTo(this.width,0),e.lineTo(this.width,this.height),e.lineTo(0,this.height),e.closePath(),e.fillStyle=o?n.toLive(e):n,a&&e.transform(...i),o){e.transform(1,0,0,1,n.offsetX||0,n.offsetY||0);let t=n.gradientTransform||n.patternTransform;t&&e.transfor
|
||
|
|
`),this._setSVGBgOverlayColor(n,`overlay`),this._setSVGBgOverlayImage(n,`overlayImage`,t),n.push(`</svg>`),n.join(``)}_setSVGPreamble(e,t){t.suppressPreamble||e.push(`<?xml version="1.0" encoding="`,t.encoding||`UTF-8`,`" standalone="no" ?>
|
||
|
|
`,`<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" `,`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||
|
|
`)}_setSVGHeader(e,t){let n=t.width||`${this.width}`,r=t.height||`${this.height}`,i=o.NUM_FRACTION_DIGITS,a=t.viewBox,s;if(a)s=`viewBox="${a.x} ${a.y} ${a.width} ${a.height}" `;else if(this.svgViewportTransformation){let e=this.viewportTransform;s=`viewBox="${B(-e[4]/e[0],i)} ${B(-e[5]/e[3],i)} ${B(this.width/e[0],i)} ${B(this.height/e[3],i)}" `}else s=`viewBox="0 0 ${this.width} ${this.height}" `;e.push(`<svg `,`xmlns="http://www.w3.org/2000/svg" `,`xmlns:xlink="http://www.w3.org/1999/xlink" `,`version="1.1" `,`width="`,n,`" `,`height="`,r,`" `,s,`xml:space="preserve">
|
||
|
|
`,`<desc>Created with Fabric.js `,b,`</desc>
|
||
|
|
`,`<defs>
|
||
|
|
`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(t),`</defs>
|
||
|
|
`)}createSVGClipPathMarkup(e){let t=this.clipPath;return t?(t.clipPathId=`CLIPPATH_${je()}`,`<clipPath id="${t.clipPathId}" >\n${t.toClipPathSVG(e.reviver)}</clipPath>\n`):``}createSVGRefElementsMarkup(){return[`background`,`overlay`].map(e=>{let t=this[`${e}Color`];if(V(t)){let n=this[`${e}Vpt`],r=this.viewportTransform,i={isType:()=>!1,width:this.width/(n?r[0]:1),height:this.height/(n?r[3]:1)};return t.toSVG(i,{additionalTransform:n?nt(r):``})}}).join(``)}createSVGFontFacesMarkup(){let e=[],t={},n=o.fontPaths;this._objects.forEach(function t(n){e.push(n),Te(n)&&n._objects.forEach(t)}),e.forEach(e=>{if(!(r=e)||typeof r._renderText!=`function`)return;var r;let{styles:i,fontFamily:a}=e;!t[a]&&n[a]&&(t[a]=!0,i&&Object.values(i).forEach(e=>{Object.values(e).forEach(({fontFamily:e=``})=>{!t[e]&&n[e]&&(t[e]=!0)})}))});let r=Object.keys(t).map(e=>`\t\t@font-face {\n\t\t\tfont-family: '${e}';\n\t\t\tsrc: url('${n[e]}');\n\t\t}\n`).join(``);return r?`\t<style type="text/css"><![CDATA[\n${r}]]></style>\n`:``}_setSVGObjects(e,t){this.forEachObject(n=>{n.excludeFromExport||this._setSVGObject(e,n,t)})}_setSVGObject(e,t,n){e.push(t.toSVG(n))}_setSVGBgOverlayImage(e,t,n){let r=this[t];r&&!r.excludeFromExport&&r.toSVG&&e.push(r.toSVG(n))}_setSVGBgOverlayColor(e,t){let n=this[`${t}Color`];if(n)if(V(n)){let r=n.repeat||``,i=this.width,a=this.height,o=this[`${t}Vpt`]?nt(R(this.viewportTransform)):``;e.push(`<rect transform="${o} translate(${i/2},${a/2})" x="${n.offsetX-i/2}" y="${n.offsetY-a/2}" width="${r!==`repeat-y`&&r!==`no-repeat`||!it(n)?i:n.source.width}" height="${r!==`repeat-x`&&r!==`no-repeat`||!it(n)?a:n.source.height}" fill="url(#SVGID_${n.id})"></rect>\n`)}else e.push(`<rect x="0" y="0" width="100%" height="100%" `,`fill="`,n,`"`,`></rect>
|
||
|
|
`)}loadFromJSON(e,t,{signal:n}={}){if(!e)return Promise.reject(new c("`json` is undefined"));let{objects:r=[],...i}=typeof e==`string`?JSON.parse(e):e,{backgroundImage:a,background:o,overlayImage:s,overlay:l,clipPath:u}=i,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Qe(r,{reviver:t,signal:n}),$e({backgroundImage:a,backgroundColor:o,overlayImage:s,overlayColor:l,clipPath:u},{signal:n})]).then(([e,t])=>(this.clear(),this.add(...e),this.set(i),this.set(t),this.renderOnAddRemove=d,this))}clone(e){let t=this.toObject(e);return this.cloneWithoutData().loadFromJSON(t)}cloneWithoutData(){let e=F(this);return new this.constructor(e)}toDataURL(e={}){let{format:t=`png`,quality:n=1,multiplier:r=1,enableRetinaScaling:i=!1}=e,a=r*(i?this.getRetinaScaling():1);return Pe(this.toCanvasElement(a,e),t,n)}toBlob(e={}){let{format:t=`png`,quality:n=1,multiplier:r=1,enableRetinaScaling:i=!1}=e,a=r*(i?this.getRetinaScaling():1);return Fe(this.toCanvasElement(a,e),t,n)}toCanvasElement(e=1,{width:t,height:n,left:r,top:i,filter:a}={}){let o=(t||this.width)*e,s=(n||this.height)*e,c=this.getZoom(),l=this.width,u=this.height,d=this.skipControlsDrawing,f=c*e,p=this.viewportTransform,m=[f,0,0,f,(p[4]-(r||0))*e,(p[5]-(i||0))*e],h=this.enableRetinaScaling,g=F({width:o,height:s}),_=a?this._objects.filter(e=>a(e)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=m,this.width=o,this.height=s,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(g.getContext(`2d`),_),this.viewportTransform=p,this.width=l,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=h,this.skipControlsDrawing=d,g}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),ye.cancelByCanvas(this),this.disposed=!0,new Promise((e,t)=>{let n=()=>{this.destroy(),e(!0)};n.kill=t,this.__cleanupTask&&this.__cleanupTask.kill(`aborted`),this.destroyed?e(!1):this.nextRenderHandle?this.__cleanupTask=n:n()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(e=>e.dispose()),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return`#<Canvas (${this.complexity()}): { objects: ${this._objects.length} }>`}};i(yt,`ownDefaults`,ft);const bt=[`touchstart`,`touchmove`,`touchend`],xt=e=>{let t=ot(e.target),n=function(e){let t=e.changedTouches;return t&&t[0]?t[0]:e}(e);return new N(n.clientX+t.left,n.clientY+t.top)},St=e=>bt.includes(e.type)||e.pointerType===`touch`,Ct=e=>{e.preventDefault(),e.stopPropagation()},wt=e=>{let t=0,n=0,r=0,i=0;for(let a=0,o=e.length;a<o;a++){let{x:o,y:s}=e[a];(o>r||!a)&&(r=o),(o<t||!a)&&(t=o),(s>i||!a)&&(i=s),(s<n||!a)&&(n=s)}return{left:t,top:n,width:r-t,height:i-n}},Tt=(e,t)=>{Dt(e,z(R(t),e.calcOwnMatrix()))},Et=(e,t)=>Dt(e,z(t,e.calcOwnMatrix())),Dt=(e,t)=>{let{translateX:n,translateY:r,scaleX:i,scaleY:a,...o}=He(t),s=new N(n,r);e.flipX=!1,e.flipY=!1,Object.assign(e,o),e.set({scaleX:i,scaleY:a}),e.setPositionByOrigin(s,E,E)},Ot=e=>{e.scaleX=1,e.scaleY=1,e.skewX=0,e.skewY=0,e.flipX=!1,e.flipY=!1,e.rotate(0)},kt=e=>({scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,angle:e.angle,left:e.left,flipX:e.flipX,flipY:e.flipY,top:e.top}),At=(e,t,n)=>{let r=e/2,i=t/2,a=wt([new N(-r,-i),new N(r,-i),new N(-r,i),new N(r,i)].map(e=>e.transform(n)));return new N(a.width,a.height)},jt=(e=T,t=T)=>z(R(t),e),Mt=(e,t=T,n=T)=>e.transform(jt(t,n)),Nt=(e,t=T,n=T)=>e.transform(jt(t,n),!0),Pt=(e,t,n)=>{let r=jt(t,n);return Dt(e,z(r,e.calcOwnMatrix())),r},Ft={left:-.5,top:-.5,center:0,bottom:.5,right:.5},W=e=>typeof e==`string`?Ft[e]:e-.5,It=new N(1,0),Lt=new N,Rt=(e,t)=>e.rotate(t),zt=(e,t)=>new N(t).subtract(e),Bt=e=>e.distanceFrom(Lt),Vt=(e,t)=>Math.atan2(Gt(e,t),Kt(e,t)),Ht=e=>Vt(It,e),Ut=e=>e.eq(Lt)?e:e.scalarDivide(Bt(e)),Wt=(e,t=!0)=>Ut(new N(-e.y,e.x).scalarMultiply(t?1:-1)),Gt=(e,t)=>e.x*t.y-e.y*t.x,Kt=(e,t)=>e.x*t.x+e.y*t.y,qt=(e,t,n)=>{if(e.eq(t)||e.eq(n))return!0;let r=Gt(t,n),i=Gt(
|
||
|
|
`),p.push(`<g `,this.getSvgTransform(!1),l?``:o+this.getSvgCommons(),` >
|
||
|
|
`),e[m]=[a,c,t?``:this.addPaintOrder(),` `,i?`transform="${i}" `:``].join(``),V(d)&&p.push(d.toSVG(this)),V(u)&&p.push(u.toSVG(this)),f&&p.push(f.toSVG(this)),s&&p.push(h),p.push(e.join(``)),p.push(`</g>
|
||
|
|
`),l&&p.push(`</g>
|
||
|
|
`),n?n(p.join(``)):p.join(``)}addPaintOrder(){return this.paintFirst===`fill`?``:` paint-order="${U(this.paintFirst)}" `}};function _n(e){return RegExp(`^(`+e.join(`|`)+`)\\b`,`i`)}const vn=`textDecorationThickness`,yn=`textDecorationColor`,bn=[`fontSize`,`fontWeight`,`fontFamily`,`fontStyle`],xn=[`underline`,`overline`,`linethrough`],Sn=[...bn,`lineHeight`,`text`,`charSpacing`,`textAlign`,`styles`,`path`,`pathStartOffset`,`pathSide`,`pathAlign`],Cn=[...Sn,...xn,`textBackgroundColor`,`direction`,vn,yn],wn=[...bn,...xn,he,`strokeWidth`,j,`deltaY`,`textBackgroundColor`,vn,yn],Tn={_reNewline:ne,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:_e,fontFamily:`Times New Roman`,underline:!1,overline:!1,linethrough:!1,textAlign:D,fontStyle:_e,lineHeight:1.16,textBackgroundColor:``,stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:D,pathAlign:`baseline`,charSpacing:0,deltaY:0,direction:`ltr`,CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[vn]:66.667},En=`justify`,Dn=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?`,On=String.raw`(?:\s*,?\s+|\s*,\s*)`,kn=`http://www.w3.org/2000/svg`,An=RegExp(`(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*(`+Dn+`(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|`+Dn+`))?\\s+(.*)`),jn={cx:D,x:D,r:`radius`,cy:`top`,y:`top`,display:`visible`,visibility:`visible`,transform:`transformMatrix`,"fill-opacity":`fillOpacity`,"fill-rule":`fillRule`,"font-family":`fontFamily`,"font-size":`fontSize`,"font-style":`fontStyle`,"font-weight":`fontWeight`,"letter-spacing":`charSpacing`,"paint-order":`paintFirst`,"stroke-dasharray":`strokeDashArray`,"stroke-dashoffset":`strokeDashOffset`,"stroke-linecap":`strokeLineCap`,"stroke-linejoin":`strokeLineJoin`,"stroke-miterlimit":`strokeMiterLimit`,"stroke-opacity":`strokeOpacity`,"stroke-width":`strokeWidth`,"text-decoration":`textDecoration`,"text-anchor":`textAnchor`,opacity:`opacity`,"clip-path":`clipPath`,"clip-rule":`clipRule`,"vector-effect":`strokeUniform`,"image-rendering":`imageSmoothing`,"text-decoration-thickness":vn,"text-decoration-color":yn},Mn=`font-size`,Nn=`clip-path`,Pn=_n([`path`,`circle`,`polygon`,`polyline`,`ellipse`,`rect`,`line`,`image`,`text`]),Fn=_n([`symbol`,`image`,`marker`,`pattern`,`view`,`svg`]),In=_n([`symbol`,`g`,`a`,`svg`,`clipPath`,`defs`]),Ln=new RegExp(String.raw`^\s*(${Dn})${On}(${Dn})${On}(${Dn})${On}(${Dn})\s*$`),Rn=`(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?`,zn=RegExp(`(?:\\s|^)`+Rn+Rn+`(`+Dn+`?(?:px)?)?(?:\\s?|$)(?:$|\\s)`);var Bn=class e{constructor(t={}){let n=typeof t==`string`?e.parseShadow(t):t;Object.assign(this,e.ownDefaults,n),this.id=je()}static parseShadow(e){let t=e.trim(),[,n=0,r=0,i=0]=(zn.exec(t)||[]).map(e=>parseFloat(e)||0);return{color:(t.replace(zn,``)||`rgb(0,0,0)`).trim(),offsetX:n,offsetY:r,blur:i}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join(`px `)}toSVG(e){let t=Rt(new N(this.offsetX,this.offsetY),I(-e.angle)),n=o.NUM_FRACTION_DIGITS,r=new G(this.color),i=40,a=40;return e.width&&e.height&&(i=100*B((Math.abs(t.x)+this.blur)/e.width,n)+20,a=100*B((Math.abs(t.y)+this.blur)/e.height,n)+20),e.flipX&&(t.x*=-1),e.flipY&&(t.y*=-1),`<filter id="SVGID_${U(this.id)}" y="-${a}%" height="${100+2*a}%" x="-${i}%" width="${100+2*i}%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="${B(this.blur?this.blur/2:0,n)}"></feGaussianBlur>\n\t<feOffset dx="${B(t.x,n)}" dy="${B(t.y,n)}" result="oBlur" ></feOffset>\n\t<feFlood flood-color="${r.toRgb()}" flood-opacity="${r.getAlpha()}"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n`}toObject(){let t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},n=e.o
|
||
|
|
`),r=[],i=-1,a={};e=Ti(e);for(let t=0;t<n.length;t++){let o=gt(n[t]);if(e[t])for(let n=0;n<o.length;n++){i++;let o=e[t][n];o&&Object.keys(o).length>0&&(Ei(a,o,!0)?r.push({start:i,end:i+1,style:o}):r[r.length-1].end++),a=o||{}}else i+=o.length,a={}}return r},Oi=(e,t)=>{if(!Array.isArray(e))return Ti(e);let n=t.split(ne),r={},i=-1,a=0;for(let t=0;t<n.length;t++){let o=gt(n[t]);for(let n=0;n<o.length;n++)i++,e[a]&&e[a].start<=i&&i<e[a].end&&(r[t]=r[t]||{},r[t][n]={...e[a].style},i===e[a].end-1&&a++)}return r},ki=[`display`,`transform`,j,`fill-opacity`,`fill-rule`,`opacity`,he,`stroke-dasharray`,`stroke-linecap`,`stroke-dashoffset`,`stroke-linejoin`,`stroke-miterlimit`,`stroke-opacity`,`stroke-width`,`id`,`paint-order`,`vector-effect`,`instantiated_by_use`,`clip-path`];function Ai(e,t){let n=e.nodeName,r=e.getAttribute(`class`),i=e.getAttribute(`id`),a=`(?![a-zA-Z\\-]+)`,o;if(o=RegExp(`^`+n,`i`),t=t.replace(o,``),i&&t.length&&(o=RegExp(`#`+i+a,`i`),t=t.replace(o,``)),r&&t.length){let e=r.split(` `);for(let n=e.length;n--;)o=RegExp(`\\.`+e[n]+a,`i`),t=t.replace(o,``)}return t.length===0}function ji(e,t){let n=!0,r=Ai(e,t.pop());return r&&t.length&&(n=function(e,t){let n,r=!0;for(;e.parentElement&&e.parentElement.nodeType===1&&t.length;)r&&(n=t.pop()),r=Ai(e=e.parentElement,n);return t.length===0}(e,t)),r&&n&&t.length===0}function Mi(e,t={}){let n={};for(let r in t)ji(e,r.split(` `))&&(n={...n,...t[r]});return n}const Ni=e=>{var t;return(t=jn[e])==null?e:t},Pi=RegExp(`(${Dn})`,`gi`),Y=`(${Dn})`,Fi=String.raw`(skewX)\(${Y}\)`,Ii=String.raw`(skewY)\(${Y}\)`,Li=String.raw`(rotate)\(${Y}(?: ${Y} ${Y})?\)`,Ri=String.raw`(scale)\(${Y}(?: ${Y})?\)`,zi=String.raw`(translate)\(${Y}(?: ${Y})?\)`,Bi=`(?:${String.raw`(matrix)\(${Y} ${Y} ${Y} ${Y} ${Y} ${Y}\)`}|${zi}|${Li}|${Ri}|${Fi}|${Ii})`,Vi=`(?:${Bi}*)`,Hi=String.raw`^\s*(?:${Vi}?)\s*$`,Ui=new RegExp(Hi),Wi=new RegExp(Bi),Gi=new RegExp(Bi,`g`);function Ki(e){let t=[];if(!(e=(e=>on(e.replace(Pi,` $1 `).replace(/,/gi,` `)))(e).replace(/\s*([()])\s*/gi,`$1`))||e&&!Ui.test(e))return[...T];for(let n of e.matchAll(Gi)){let e=Wi.exec(n[0]);if(!e)continue;let r=T,[,i,...a]=e.filter(e=>!!e),[o,s,c,l,u,d]=a.map(e=>parseFloat(e));switch(i){case`translate`:r=Ue(o,s);break;case oe:r=We({angle:o},{x:s,y:c});break;case ue:r=Ge(o,s);break;case pe:r=qe(o);break;case me:r=Je(o);break;case`matrix`:r=[o,s,c,l,u,d]}t.push(r)}return Re(t)}function qi(e,t,n,r){let i=Array.isArray(t),a,o=t;if(e!==`fill`&&e!==`stroke`||t!==`none`){if(e===`strokeUniform`)return t===`non-scaling-stroke`;if(e===`strokeDashArray`)o=t===`none`?null:t.replace(/,/g,` `).split(/\s+/).map(parseFloat);else if(e===`transformMatrix`)o=n&&n.transformMatrix?z(n.transformMatrix,Ki(t)):Ki(t);else if(e===`visible`)o=t!==`none`&&t!==`hidden`,n&&!1===n.visible&&(o=!1);else if(e===`opacity`)o=parseFloat(t),n&&n.opacity!==void 0&&(o*=n.opacity);else if(e===`textAnchor`)o=t===`start`?D:t===`end`?k:E;else if(e===`charSpacing`||e===`textDecorationThickness`)a=K(t,r)/r*1e3;else if(e===`paintFirst`){let e=t.indexOf(j),n=t.indexOf(he);o=j,(e>-1&&n>-1&&n<e||e===-1&&n>-1)&&(o=he)}else{if(e===`href`||e===`xlink:href`||e===`font`||e===`id`)return t;if(e===`imageSmoothing`)return t===`optimizeQuality`;a=i?t.map(K):K(t,r)}}else o=``;return!i&&isNaN(a)?o:a}function Ji(e,t){e.replace(/;\s*$/,``).split(`;`).forEach(e=>{if(!e)return;let[n,r]=e.split(`:`);t[n.trim().toLowerCase()]=r.trim()})}function Yi(e){let t={},n=e.getAttribute(`style`);return n&&(typeof n==`string`?Ji(n,t):function(e,t){Object.entries(e).forEach(([e,n])=>{n!==void 0&&(t[e.toLowerCase()]=n)})}(n,t)),t}const Xi={stroke:`strokeOpacity`,fill:`fillOpacity`};function Zi(e,t,n){if(!e)return{};let r,i={},a=16;e.parentNode&&In.test(e.parentNode.nodeName)&&(i=Zi(e.parentElement,t,n),i.fontSize&&(r=a=K(i.fontSize)));let o={...t.reduce((t,n)=>{let r=e.getAttribute(n);return r&&(t[n]=r),t},{}),...Mi(e,n),...Yi(e)};o[`clip-path`]&&e.setAttribute(Nn,o[Nn]),o[`font-size`]&&(r=K(o[Mn],a),o[Mn]=`${r}`);let s={};for(let e in o){let t=Ni(e);s[t]=qi(t,o[e],i,r)}s&&s.font&&function(e,t){let n=e.match(An);if(!n)r
|
||
|
|
`],n=this._createSVGBgRect(e);n&&t.push(` `,n);for(let n=0;n<this._objects.length;n++)t.push(` `,this._objects[n].toSVG(e));return t.push(`</g>
|
||
|
|
`),t}getSvgStyles(){let e=this.opacity!==void 0&&this.opacity!==1?`opacity: ${U(this.opacity)};`:``,t=this.visible?``:` visibility: hidden;`;return[e,this.getSvgFilter(),t].join(``)}toClipPathSVG(e){let t=[],n=this._createSVGBgRect(e);n&&t.push(` `,n);for(let n=0;n<this._objects.length;n++)t.push(` `,this._objects[n].toClipPathSVG(e));return this._createBaseClipPathSVGMarkup(t,{reviver:e})}static fromObject({type:e,objects:t=[],layoutManager:n,...r},i){return Promise.all([Qe(t,i),$e(r,i)]).then(([e,t])=>{let i=new this(e,{...r,...t,layoutManager:new sa});return i.layoutManager=n?new(M.getClass(n.type))(new(M.getClass(n.strategy))):new oa,i.layoutManager.subscribeTargets({type:ea,target:i,targets:i.getObjects()}),i.setCoords(),i})}};i(ca,`type`,`Group`),i(ca,`ownDefaults`,{strokeWidth:0,subTargetCheck:!1,interactive:!1}),M.setClass(ca);const la=(e,t)=>e&&e.length===1?e[0]:new ca(e,t),ua=(e,t)=>Math.min(t.width/e.width,t.height/e.height),da=(e,t)=>Math.max(t.width/e.width,t.height/e.height),fa=`\\s*,?\\s*`,pa=`${fa}(${Dn})`,ma=`${pa}${pa}${pa}${fa}([01])${fa}([01])${pa}${pa}`,ha={m:`l`,M:`L`},ga=(e,t,n,r,i,a,o,s,c,l,u)=>{let d=Se(e),f=Ce(e),p=Se(t),m=Ce(t),h=n*i*p-r*a*m+o,g=r*i*p+n*a*m+s;return[`C`,l+c*(-n*i*f-r*a*d),u+c*(-r*i*f+n*a*d),h+c*(n*i*m+r*a*p),g+c*(r*i*m-n*a*p),h,g]},_a=(e,t,n,r)=>{let i=Math.atan2(t,e),a=Math.atan2(r,n);return a>=i?a-i:2*Math.PI-(i-a)};function va(e,t,n,r,i,a,s,c){let l;if(o.cachesBoundsOfCurve&&(l=[...arguments].join(),y.boundsOfCurveCache[l]))return y.boundsOfCurveCache[l];let u=Math.sqrt,d=Math.abs,f=[],p=[[0,0],[0,0]],m=6*e-12*n+6*i,h=-3*e+9*n-9*i+3*s,g=3*n-3*e;for(let e=0;e<2;++e){if(e>0&&(m=6*t-12*r+6*a,h=-3*t+9*r-9*a+3*c,g=3*r-3*t),d(h)<1e-12){if(d(m)<1e-12)continue;let e=-g/m;0<e&&e<1&&f.push(e);continue}let n=m*m-4*g*h;if(n<0)continue;let i=u(n),o=(-m+i)/(2*h);0<o&&o<1&&f.push(o);let s=(-m-i)/(2*h);0<s&&s<1&&f.push(s)}let _=f.length,v=_,b=Sa(e,t,n,r,i,a,s,c);for(;_--;){let{x:e,y:t}=b(f[_]);p[0][_]=e,p[1][_]=t}p[0][v]=e,p[1][v]=t,p[0][v+1]=s,p[1][v+1]=c;let x=[new N(Math.min(...p[0]),Math.min(...p[1])),new N(Math.max(...p[0]),Math.max(...p[1]))];return o.cachesBoundsOfCurve&&(y.boundsOfCurveCache[l]=x),x}const ya=(e,t,[n,r,i,a,o,s,c,l])=>{let u=((e,t,n,r,i,a,o)=>{if(n===0||r===0)return[];let s=0,c=0,l=0,u=Math.PI,d=o*ee,f=Ce(d),p=Se(d),m=.5*(-p*e-f*t),h=.5*(-p*t+f*e),g=n**2,_=r**2,v=h**2,y=m**2,b=g*_-g*v-_*y,x=Math.abs(n),S=Math.abs(r);if(b<0){let e=Math.sqrt(1-b/(g*_));x*=e,S*=e}else l=(i===a?-1:1)*Math.sqrt(b/(g*v+_*y));let C=l*x*h/S,w=-l*S*m/x,T=p*C-f*w+.5*e,E=f*C+p*w+.5*t,D=_a(1,0,(m-C)/x,(h-w)/S),O=_a((m-C)/x,(h-w)/S,(-m-C)/x,(-h-w)/S);a===0&&O>0?O-=2*u:a===1&&O<0&&(O+=2*u);let k=Math.ceil(Math.abs(O/u*2)),te=[],ne=O/k,re=8/3*Math.sin(ne/4)*Math.sin(ne/4)/Math.sin(ne/2),ie=D+ne;for(let e=0;e<k;e++)te[e]=ga(D,ie,p,f,x,S,T,E,re,s,c),s=te[e][5],c=te[e][6],D=ie,ie+=ne;return te})(c-e,l-t,r,i,o,s,a);for(let n=0,r=u.length;n<r;n++)u[n][1]+=e,u[n][2]+=t,u[n][3]+=e,u[n][4]+=t,u[n][5]+=e,u[n][6]+=t;return u},ba=e=>{let t=0,n=0,r=0,i=0,a=[],o,s=0,c=0;for(let l of e){let e=[...l],u;switch(e[0]){case`l`:e[1]+=t,e[2]+=n;case`L`:t=e[1],n=e[2],u=[`L`,t,n];break;case`h`:e[1]+=t;case`H`:t=e[1],u=[`L`,t,n];break;case`v`:e[1]+=n;case`V`:n=e[1],u=[`L`,t,n];break;case`m`:e[1]+=t,e[2]+=n;case`M`:t=e[1],n=e[2],r=e[1],i=e[2],u=[`M`,t,n];break;case`c`:e[1]+=t,e[2]+=n,e[3]+=t,e[4]+=n,e[5]+=t,e[6]+=n;case`C`:s=e[3],c=e[4],t=e[5],n=e[6],u=[`C`,e[1],e[2],s,c,t,n];break;case`s`:e[1]+=t,e[2]+=n,e[3]+=t,e[4]+=n;case`S`:o===`C`?(s=2*t-s,c=2*n-c):(s=t,c=n),t=e[3],n=e[4],u=[`C`,s,c,e[1],e[2],t,n],s=u[3],c=u[4];break;case`q`:e[1]+=t,e[2]+=n,e[3]+=t,e[4]+=n;case`Q`:s=e[1],c=e[2],t=e[3],n=e[4],u=[`Q`,s,c,t,n];break;case`t`:e[1]+=t,e[2]+=n;case`T`:o===`Q`?(s=2*t-s,c=2*n-c):(s=t,c=n),t=e[1],n=e[2],u=[`Q`,s,c,t,n];break;case`a`:e[6]+=t,e[7]+=n;case`A`:ya(t,n,e).forEach(e=>a.push(e)),t=e[6],n=e[7];break;case`z`:case`Z`:t=r,n=i,u=[`Z`]}u?(a.push(u),o=u[0]):o=``}return a},xa=(e,t,n,r)=>Math.sqrt((n-e)**2+(r-t)**2),Sa=(e,t,n,r,i,a,o,s)=>c=>{let l=c**3,u=(e=>3*e**2*(1-e))(c),d=(e=>3*e*(1-e)**2)(c),f=(e=>(1-e)**3)(c);return new
|
||
|
|
`)}else if(this.type===`radial`){let{x1:e,y1:t,x2:r,y2:i,r1:o,r2:s}=this.coords,c=u(e),d=u(t),f=u(r),p=u(i),m=u(o),h=u(s),g=m>h;n.push(`<radialGradient `,l,` cx="`,g?c:f,`" cy="`,g?d:p,`" r="`,g?m:h,`" fx="`,g?f:c,`" fy="`,g?p:d,`">
|
||
|
|
`),g&&(a.reverse(),a.forEach(e=>{e.offset=1-e.offset}));let _=Math.min(m,h);if(_>0){let e=_/Math.max(m,h);a.forEach(t=>{t.offset+=e*(1-t.offset)})}}return a.forEach(({color:e,offset:t})=>{let r=String(e),i=nn(r)?r:new G(r).toRgba();n.push(`<stop offset="${100*t}%" style="stop-color:${U(i)};"/>\n`)}),n.push(this.type===`linear`?`</linearGradient>`:`</radialGradient>`,`
|
||
|
|
`),n.join(``)}toLive(e){let{x1:t,y1:n,x2:r,y2:i,r1:a,r2:o}=this.coords,s=this.type===`linear`?e.createLinearGradient(t,n,r,i):e.createRadialGradient(t,n,a,r,i,o);return this.colorStops.forEach(({color:e,offset:t})=>{s.addColorStop(t,e)}),s}static async fromObject(e){let{colorStops:t,gradientTransform:n}=e;return new this({...e,colorStops:t?t.map(e=>({...e})):void 0,gradientTransform:n?[...n]:void 0})}static fromElement(e,t,n){let r=Eo(e),i=t._findCenterFromElement();return new this({id:e.getAttribute(`id`)||void 0,type:To(e),coords:Oo(e,{width:n.viewBoxWidth||n.width,height:n.viewBoxHeight||n.height}),colorStops:wo(e,n.opacity),gradientUnits:r,gradientTransform:Ki(e.getAttribute(`gradientTransform`)||``),...r===`pixels`?{offsetX:t.width/2-i.x,offsetY:t.height/2-i.y}:{offsetX:0,offsetY:0}})}};i(ko,`type`,`Gradient`),M.setClass(ko,`gradient`),M.setClass(ko,`linear`),M.setClass(ko,`radial`);var Ao=class{get type(){return`pattern`}set type(e){s(`warn`,`Setting type has no effect`,e)}constructor(e){i(this,`repeat`,`repeat`),i(this,`offsetX`,0),i(this,`offsetY`,0),i(this,`crossOrigin`,``),this.id=je(),Object.assign(this,e)}isImageSource(){return!!this.source&&typeof this.source.src==`string`}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():``}toLive(e){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?e.createPattern(this.source,this.repeat):null}toObject(e=[]){let{repeat:t,crossOrigin:n}=this;return{...et(this,e),type:`pattern`,source:this.sourceToString(),repeat:t,crossOrigin:n,offsetX:B(this.offsetX,o.NUM_FRACTION_DIGITS),offsetY:B(this.offsetY,o.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null}}toSVG({width:e,height:t}){let{source:n,repeat:r,id:i}=this,a=vo(this.offsetX/e,0),o=vo(this.offsetY/t,0),s=r===`repeat-y`||r===`no-repeat`?1+Math.abs(a||0):vo(n.width/e,0),c=r===`repeat-x`||r===`no-repeat`?1+Math.abs(o||0):vo(n.height/t,0);return[`<pattern id="SVGID_${U(i)}" x="${a}" y="${o}" width="${s}" height="${c}">`,`<image x="0" y="0" width="${n.width}" height="${n.height}" xlink:href="${U(this.sourceToString())}"></image>`,`</pattern>`,``].join(`
|
||
|
|
`)}static async fromObject({type:e,source:t,patternTransform:n,...r},i){let a=await Ze(t,{...i,crossOrigin:r.crossOrigin});return new this({...r,patternTransform:n&&n.slice(0),source:a})}};i(Ao,`type`,`Pattern`),M.setClass(Ao),M.setClass(Ao,`pattern`);var jo=class{constructor(e){i(this,`color`,`rgb(0, 0, 0)`),i(this,`width`,1),i(this,`shadow`,null),i(this,`strokeLineCap`,`round`),i(this,`strokeLineJoin`,`round`),i(this,`strokeMiterLimit`,10),i(this,`strokeDashArray`,null),i(this,`limitedToCanvasSize`,!1),this.canvas=e}_setBrushStyles(e){e.strokeStyle=this.color,e.lineWidth=this.width,e.lineCap=this.strokeLineCap,e.miterLimit=this.strokeMiterLimit,e.lineJoin=this.strokeLineJoin,e.setLineDash(this.strokeDashArray||[])}_saveAndTransform(e){let t=this.canvas.viewportTransform;e.save(),e.transform(t[0],t[1],t[2],t[3],t[4],t[5])}needsFullRender(){return new G(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;let e=this.canvas,t=this.shadow,n=e.contextTop,r=e.getZoom()*e.getRetinaScaling();n.shadowColor=t.color,n.shadowBlur=t.blur*r,n.shadowOffsetX=t.offsetX*r,n.shadowOffsetY=t.offsetY*r}_resetShadow(){let e=this.canvas.contextTop;e.shadowColor=``,e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0}_isOutSideCanvas(e){return e.x<0||e.x>this.canvas.getWidth()||e.y<0||e.y>this.canvas.getHeight()}},Mo=class e extends J{constructor(t,{path:n,left:r,top:i,...a}={}){super(),Object.assign(this,e.ownDefaults),this.setOptions(a),this._setPath(t||[],!0),typeof r==`number`&&this.set(`left`,r),typeof i==`number`&&this.set(`top`,i)}_setPath(e,t){this.path=ba(Array.isArray(e)?e:La(e)),this.setBoundingBox(t)}_findCenterFromElement(){let e=this._calcBoundsFromPath();return new N(e.left+e.width/2,e.top+e.height/2)}_renderPathCommands(e){let t=-this.pathOffset.x,n=-this.pathOffset.y;e.beginPath();for(let r of this.path)switch(r[0]){case`L`:e.lineTo(r[1]+t,r[2]+n);break;case`M`:e.moveTo(r[1]+t,r[2]+n);break;case`C`:e.bezierCurveTo(r[1]+t,r[2]+n,r[3]+t,r[4]+n,r[5]+t,r[6]+n);break;case`Q`:e.quadraticCurveTo(r[1]+t,r[2]+n,r[3]+t,r[4]+n);break;case`Z`:e.closePath()}}_render(e){this._renderPathCommands(e),this._renderPaintInOrder(e)}toString(){return`#<Path (${this.complexity()}): { "top": ${this.top}, "left": ${this.left} }>`}toObject(e=[]){return{...super.toObject(e),path:this.path.map(e=>e.slice())}}toDatalessObject(e=[]){let t=this.toObject(e);return this.sourcePath&&(delete t.path,t.sourcePath=this.sourcePath),t}_toSVG(){return[`<path `,`COMMON_PARTS`,`d="${Va(this.path,o.NUM_FRACTION_DIGITS)}" stroke-linecap="round" />\n`]}_getOffsetTransform(){let e=o.NUM_FRACTION_DIGITS;return` translate(${B(-this.pathOffset.x,e)}, ${B(-this.pathOffset.y,e)})`}toClipPathSVG(e){let t=this._getOffsetTransform();return` `+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}toSVG(e){let t=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(e){let{width:t,height:n,pathOffset:r}=this._calcDimensions();this.set({width:t,height:n,pathOffset:r}),e&&this.setPositionByOrigin(r,`center`,`center`)}_calcBoundsFromPath(){let e=[],t=0,n=0,r=0,i=0;for(let a of this.path)switch(a[0]){case`L`:r=a[1],i=a[2],e.push({x:t,y:n},{x:r,y:i});break;case`M`:r=a[1],i=a[2],t=r,n=i;break;case`C`:e.push(...va(r,i,a[1],a[2],a[3],a[4],a[5],a[6])),r=a[5],i=a[6];break;case`Q`:e.push(...va(r,i,a[1],a[2],a[1],a[2],a[3],a[4])),r=a[3],i=a[4];break;case`Z`:r=t,i=n}return wt(e)}_calcDimensions(){let e=this._calcBoundsFromPath();return{...e,pathOffset:new N(e.left+e.width/2,e.top+e.height/2)}}static fromObject(e){return this._fromObject(e,{extraParam:`path`})}static async fromElement(e,t,n){let{d:r,...i}=Zi(e,this.ATTRIBUTE_NAMES,n);return new this(r,{...i,...t,left:void 0,top:void 0})}};i(Mo,`type`,`Path`),i(Mo,`cacheProperties`,[...Un,`path`,`fillRule`]),i(Mo,`ATTRIBUTE_NAMES`,[...ki,`d`]),M.setClass(Mo),M.setSVGClass(Mo);var No=class e extends jo{constructor(e){super(e),i(this,`decimate`,.4
|
||
|
|
`];{let i=I(t),a=I(n),o=Se(i)*e,s=Ce(i)*e,c=Se(a)*e,l=Ce(a)*e;return[`<path d="M ${o} ${s} A ${e} ${e} 0 ${+(r>180)} ${+!this.counterClockwise} ${c} ${l}" `,`COMMON_PARTS`,` />
|
||
|
|
`]}}static async fromElement(e,t,n){let{left:r=0,top:i=0,radius:a=0,...o}=Zi(e,this.ATTRIBUTE_NAMES,n);return new this({...o,radius:a,left:r-a,top:i-a})}static fromObject(e){return super._fromObject(e)}};i(Fo,`type`,`Circle`),i(Fo,`cacheProperties`,[...Un,...Po]),i(Fo,`ownDefaults`,{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),i(Fo,`ATTRIBUTE_NAMES`,[`cx`,`cy`,`r`,...ki]),M.setClass(Fo),M.setSVGClass(Fo);var Io=class extends jo{constructor(e){super(e),i(this,`width`,10),this.points=[]}drawDot(e){let t=this.addPoint(e),n=this.canvas.contextTop;this._saveAndTransform(n),this.dot(n,t),n.restore()}dot(e,t){e.fillStyle=t.fill,e.beginPath(),e.arc(t.x,t.y,t.radius,0,2*Math.PI,!1),e.closePath(),e.fill()}onMouseDown(e){this.points=[],this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(e)}_render(){let e=this.canvas.contextTop,t=this.points;this._saveAndTransform(e);for(let n=0;n<t.length;n++)this.dot(e,t[n]);e.restore()}onMouseMove(e){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(e)||(this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(e),this._render()):this.drawDot(e))}onMouseUp(){let e=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;let t=[];for(let e=0;e<this.points.length;e++){let n=this.points[e],r=new Fo({radius:n.radius,left:n.x,top:n.y,originX:E,originY:E,fill:n.fill});this.shadow&&(r.shadow=new Bn(this.shadow)),t.push(r)}let n=new ca(t,{canvas:this.canvas});this.canvas.fire(`before:path:created`,{path:n}),this.canvas.add(n),this.canvas.fire(`path:created`,{path:n}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=e,this.canvas.requestRenderAll()}addPoint({x:e,y:t}){let n={x:e,y:t,radius:Ua(Math.max(0,this.width-20),this.width+20)/2,fill:new G(this.color).setAlpha(Ua(0,100)/100).toRgba()};return this.points.push(n),n}},Lo=class extends jo{constructor(e){super(e),i(this,`width`,10),i(this,`density`,20),i(this,`dotWidth`,1),i(this,`dotWidthVariance`,1),i(this,`randomOpacity`,!1),i(this,`optimizeOverlapping`,!0),this.sprayChunks=[],this.sprayChunk=[]}onMouseDown(e){this.sprayChunks=[],this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(e),this.renderChunck(this.sprayChunk)}onMouseMove(e){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(e)||(this.addSprayChunk(e),this.renderChunck(this.sprayChunk))}onMouseUp(){let e=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;let t=[];for(let e=0;e<this.sprayChunks.length;e++){let n=this.sprayChunks[e];for(let e=0;e<n.length;e++){let r=n[e],i=new $i({width:r.width,height:r.width,left:r.x+1,top:r.y+1,originX:E,originY:E,fill:this.color});t.push(i)}}let n=new ca(this.optimizeOverlapping?function(e){let t={},n=[];for(let r,i=0;i<e.length;i++)r=`${e[i].left}${e[i].top}`,t[r]||(t[r]=!0,n.push(e[i]));return n}(t):t,{objectCaching:!0,subTargetCheck:!1,interactive:!1});this.shadow&&n.set(`shadow`,new Bn(this.shadow)),this.canvas.fire(`before:path:created`,{path:n}),this.canvas.add(n),this.canvas.fire(`path:created`,{path:n}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=e,this.canvas.requestRenderAll()}renderChunck(e){let t=this.canvas.contextTop;t.fillStyle=this.color,this._saveAndTransform(t);for(let n=0;n<e.length;n++){let r=e[n];t.globalAlpha=r.opacity,t.fillRect(r.x,r.y,r.width,r.width)}t.restore()}_render(){let e=this.canvas.contextTop;e.fillStyle=this.color,this._saveAndTransform(e);for(let e=0;e<this.sprayChunks.length;e++)this.renderChunck(this.sprayChunks[e]);e.restore()}addSprayChunk(e){this.sprayChunk=[];let t=this.width/2;for(let n=0;n<this.density;n++)this.sprayChunk.push({x:Ua(e.x-t,e.x+t),y:Ua(e.y-t,e.y+t),width:this.dotWidthVariance?Ua(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth,opacity:this.randomOpacity?Ua(0,100)/100:1});this.sprayChunks.push(this.sprayChunk)}},Ro=class extends No{constructor(e){super(e)}getPatternSrc(){let e=P(),t=e.getContext(`2d`);return e.width=e.height
|
||
|
|
`],i=[];for(let e=0;e<t.length;e++)n[e]=this.graphemeSplit(t[e]),i=i.concat(n[e],r);return i.pop(),{_unwrappedLines:n,lines:t,graphemeText:i,graphemeLines:n}}toObject(e=[]){return{...super.toObject([...Cn,...e]),styles:Di(this.styles,this.text),...this.path?{path:this.path.toObject()}:{}}}set(e,t){let{textLayoutProperties:n}=this.constructor;super.set(e,t);let r=!1,i=!1;if(typeof e==`object`)for(let t in e)t===`path`&&this.setPathInfo(),r=r||n.includes(t),i=i||t===`path`;else r=n.includes(e),i=e===`path`;return i&&this.setPathInfo(),r&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,n,r){let i=Zi(t,e.ATTRIBUTE_NAMES,r),{textAnchor:a=D,textDecoration:o=``,dx:s=0,dy:c=0,top:l=0,left:u=0,fontSize:d=16,strokeWidth:f=1,...p}={...n,...i},m=new this(on(t.textContent||``).trim(),{left:u+s,top:l+c,underline:o.includes(`underline`),overline:o.includes(`overline`),linethrough:o.includes(`line-through`),strokeWidth:0,fontSize:d,...p}),h=m.getScaledHeight()/m.height,g=((m.height+m.strokeWidth)*m.lineHeight-m.height)*h,_=m.getScaledHeight()+g,v=0;return a===`center`&&(v=m.getScaledWidth()/2),a===`right`&&(v=m.getScaledWidth()),m.set({left:m.left-v,top:m.top-(_-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:f}),m}static fromObject(e){return this._fromObject({...e,styles:Oi(e.styles||{},e.text)},{extraParam:`text`})}};i(Q,`textLayoutProperties`,Sn),i(Q,`cacheProperties`,[...Un,...Cn]),i(Q,`ownDefaults`,Tn),i(Q,`type`,`Text`),i(Q,`genericFonts`,[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`ui-rounded`,`math`,`emoji`,`fangsong`]),i(Q,`ATTRIBUTE_NAMES`,ki.concat(`x`,`y`,`dx`,`dy`,`font-family`,`font-style`,`font-weight`,`font-size`,`letter-spacing`,`text-decoration`,`text-decoration-thickness`,`text-decoration-color`,`text-anchor`)),vi(Q,[class extends gn{_toSVG(){let e=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(e.textTop,e.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(e){let t=this._createBaseSVGMarkup(this._toSVG(),{reviver:e,noStyle:!0,withShadow:!0}),n=this.path;return n?t+n._createBaseSVGMarkup(n._toSVG(),{reviver:e,withShadow:!0,additionalTransform:nt(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg({textBgRects:e,textSpans:t}){let n=this.getSvgTextDecoration(this);return[e.join(``),` <text xml:space="preserve" `,`font-family="${U(this.fontFamily.replace(Yo,`'`))}" `,`font-size="${U(this.fontSize)}" `,this.fontStyle?`font-style="${U(this.fontStyle)}" `:``,this.fontWeight?`font-weight="${U(this.fontWeight)}" `:``,n?`text-decoration="${n}" `:``,this.direction===`rtl`?`direction="rtl" `:``,`style="`,this.getSvgStyles(!0),`"`,this.addPaintOrder(),` >`,t.join(``),`</text>
|
||
|
|
`]}_getSVGTextAndBg(e,t){let n=[],r=[],i,a=e;this.backgroundColor&&r.push(Xo(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let e=0,o=this._textLines.length;e<o;e++)i=this._getLineLeftOffset(e),this.direction===`rtl`&&(i+=this.width),(this.textBackgroundColor||this.styleHas(`textBackgroundColor`,e))&&this._setSVGTextLineBg(r,e,t+i,a),this._setSVGTextLineText(n,e,t+i,a),a+=this.getHeightOfLine(e);return{textSpans:n,textBgRects:r}}_createTextCharSpan(e,t,n,r,i){let a=o.NUM_FRACTION_DIGITS,s=this.getSvgSpanStyles(t,e!==e.trim()||!!e.match(Jo)),c=s?`style="${s}"`:``,l=t.deltaY,u=l?` dy="${B(l,a)}" `:``,{angle:d,renderLeft:f,renderTop:p,width:m}=i,h=``;if(f!==void 0){let e=m/2;d&&(h=` rotate="${B(Ie(d),a)}"`);let t=We({angle:Ie(d)});t[4]=f,t[5]=p;let i=new N(-e,0).transform(t);n=i.x,r=i.y}return`<tspan x="${B(n,a)}" y="${B(r,a)}" ${u}${h}${c}>${U(e)}</tspan>`}_setSVGTextLineText(e,t,n,r){let i=this.getHeightOfLine(t),a=this.textAlign.includes(En),o=this._textLines[t],s,c,l,u,d,f=``,p=0;r+=i*(1-this._fontSizeFraction)/this.lineHeight;for(let i=0,m=o.length-1;i<=m;i++)d=i===m||this.charSpacing||this.path,f+=o[i],l=this.__charBounds[t][i],p===0?(n+=l.kernedWidth-l.width,p+=l.width):p+=l.kernedWidth,a&&!d&&this._reSpaceAndTab.test(o[i])&&(d=!0),d||(s=s||this.getCompleteStyleDeclaration(t,i),c=this.getCompleteStyleDeclaration(t,i+1),d=Ei(s,c,!0)),d&&(u=this._getStyleDeclaration(t,i),e.push(this._createTextCharSpan(f,u,n,r,l)),f=``,s=c,this.direction===`rtl`?n-=p:n+=p,p=0)}_setSVGTextLineBg(e,t,n,r){let i=this._textLines[t],a=this.getHeightOfLine(t)/this.lineHeight,o,s=0,c=0,l=this.getValueOfPropertyAt(t,0,`textBackgroundColor`);for(let u=0;u<i.length;u++){let{left:i,width:d,kernedWidth:f}=this.__charBounds[t][u];o=this.getValueOfPropertyAt(t,u,`textBackgroundColor`),o===l?s+=f:(l&&e.push(Xo(l,n+c,r,s,a)),c=i,s=d,l=o)}o&&e.push(Xo(l,n+c,r,s,a))}getSvgStyles(e){let t=nn(this.textDecorationColor)?` text-decoration-color: ${U(this[yn])};`:``;return`${super.getSvgStyles(e)} text-decoration-thickness: ${B(this.textDecorationThickness*this.getObjectScaling().y/10,o.NUM_FRACTION_DIGITS)}%;${t} white-space: pre;`}getSvgSpanStyles(e,t){let{fontFamily:n,strokeWidth:r,stroke:i,fill:a,fontSize:s,fontStyle:c,fontWeight:l,textDecorationThickness:u,textDecorationColor:d,linethrough:f,overline:p,underline:m}=e,h=this.getSvgTextDecoration({underline:m==null?this.underline:m,overline:p==null?this.overline:p,linethrough:f==null?this.linethrough:f}),g=u||this.textDecorationThickness,_=d||this.textDecorationColor,v=rn(r),y=an(n),b=rn(s),x=an(c),S=rn(l)||an(l),C=an(_);return[i?hn(he,i):``,v?`stroke-width: ${U(v)}; `:``,y?`font-family: ${y.includes(`'`)||y.includes(`"`)?U(y):`'${U(y)}'`}; `:``,b?`font-size: ${U(b)}px; `:``,x?`font-style: ${U(x)}; `:``,S?`font-weight: ${U(S)}; `:``,h?`text-decoration: ${h}; text-decoration-thickness: ${B(g*this.getObjectScaling().y/10,o.NUM_FRACTION_DIGITS)}%;${C?` text-decoration-color: ${U(C)};`:``} `:``,a?hn(j,a):``,t?`white-space: pre; `:``].join(``)}getSvgTextDecoration(e){return[`overline`,`underline`,`line-through`].filter(t=>e[t.replace(`-`,``)]).join(` `)}}]),M.setClass(Q),M.setSVGClass(Q);var Qo=class{constructor(e){i(this,`target`,void 0),i(this,`__mouseDownInPlace`,!1),i(this,`__dragStartFired`,!1),i(this,`__isDraggingOver`,!1),i(this,`__dragStartSelection`,void 0),i(this,`__dragImageDisposer`,void 0),i(this,`_dispose`,void 0),this.target=e;let t=[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=()=>{t.forEach(e=>e()),this._dispose=void 0}}isPointerOverSelection(e){let t=this.target,n=t.getSelectionStartFromPointer(e);return t.isEditing&&n>=t.selectionStart&&n<=t.selectionEnd&&t.selectionStart<t.selectionEnd}start(e){return this.__mouseDownInPlace=this.isPointerOverSelection(e)}isActive(){return this.__mouseDownInPlace}end(e){l
|
||
|
|
`?(o++,i[o]=0):i[o]++;for(i[0]>0&&(this.insertCharStyleObject(r.lineIndex,r.charIndex,i[0],n),n=n&&n.slice(i[0]+1)),o&&this.insertNewlineStyleObject(r.lineIndex,r.charIndex+i[0],o),a=1;a<o;a++)i[a]>0?this.insertCharStyleObject(r.lineIndex+a,0,i[a],n):n&&this.styles[r.lineIndex+a]&&n[0]&&(this.styles[r.lineIndex+a][0]=n[0]),n=n&&n.slice(i[a]+1);i[a]>0&&this.insertCharStyleObject(r.lineIndex+a,0,i[a],n)}removeChars(e,t=e+1){this.removeStyleFromTo(e,t),this._text.splice(e,t-e),this.text=this._text.join(``),this.set(`dirty`,!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(e,t,n,r=n){r>n&&this.removeStyleFromTo(n,r);let i=this.graphemeSplit(e);this.insertNewStyleBlock(i,n,t),this._text=[...this._text.slice(0,n),...i,...this._text.slice(r)],this.text=this._text.join(``),this.set(`dirty`,!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(e,t,n){n<=e?(t===e?this._selectionDirection=D:this._selectionDirection===`right`&&(this._selectionDirection=D,this.selectionEnd=e),this.selectionStart=n):n>e&&n<t?this._selectionDirection===`right`?this.selectionEnd=n:this.selectionStart=n:(t===e?this._selectionDirection=k:this._selectionDirection===`left`&&(this._selectionDirection=k,this.selectionStart=t),this.selectionEnd=n)}},ts=class extends es{initHiddenTextarea(){let e=this.canvas&&H(this.canvas.getElement())||g(),t=e.createElement(`textarea`);Object.entries({autocapitalize:`off`,autocorrect:`off`,autocomplete:`off`,spellcheck:`false`,"data-fabric":`textarea`,wrap:`off`,name:`fabricTextarea`}).map(([e,n])=>t.setAttribute(e,n));let{top:n,left:r,fontSize:i}=this._calcTextareaPosition();t.style.cssText=`position: absolute; top: ${n}; left: ${r}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${i};`,(this.hiddenTextareaContainer||e.body).appendChild(t),Object.entries({blur:`blur`,keydown:`onKeyDown`,keyup:`onKeyUp`,input:`onInput`,copy:`copy`,cut:`copy`,paste:`paste`,compositionstart:`onCompositionStart`,compositionupdate:`onCompositionUpdate`,compositionend:`onCompositionEnd`}).map(([e,n])=>t.addEventListener(e,this[n].bind(this))),this.hiddenTextarea=t}blur(){this.abortCursorAnimation()}onKeyDown(e){if(!this.isEditing)return;let t=this.direction===`rtl`?this.keysMapRtl:this.keysMap;if(e.keyCode in t)this[t[e.keyCode]](e);else{if(!(e.keyCode in this.ctrlKeysMapDown)||!e.ctrlKey&&!e.metaKey)return;this[this.ctrlKeysMapDown[e.keyCode]](e)}e.stopImmediatePropagation(),e.preventDefault(),e.keyCode>=33&&e.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(e){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:e.keyCode in this.ctrlKeysMapUp&&(e.ctrlKey||e.metaKey)&&(this[this.ctrlKeysMapUp[e.keyCode]](e),e.stopImmediatePropagation(),e.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(e){let t=this.fromPaste,{value:n,selectionStart:r,selectionEnd:i}=this.hiddenTextarea;if(this.fromPaste=!1,e&&e.stopPropagation(),!this.isEditing)return;let a=()=>{this.updateFromTextArea(),this.fire(le),this.canvas&&(this.canvas.fire(`text:changed`,{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value===``)return this.styles={},void a();let s=this._splitTextIntoLines(n).graphemeText,c=this._text.length,l=s.length,u=this.selectionStart,d=this.selectionEnd,f=u!==d,p,m,g,_,v=l-c,y=this.fromStringToGraphemeSelection(r,i,n),b=u>y.selectionStart;f?(m=this._text.slice(u,d),v+=d-u):l<c&&(m=b?this._text.slice(d+v,d):this._text.slice(u,u-v));let x=s.slice(y.selectionEnd-v,y.selectionEnd);if(m&&m.length&&(x.length&&(p=this.getSelectionStyles(u,u+1,!1),p=x.map(()=>p[0])),f?(g=u,_=d):b?(g=d-m.length,_=d):(g=d,_=d+m.length),this.removeStyleFromTo(g,_)),x.length){let{copyPasteData:e}=h();t&&x.join(``)===e.copiedText&&!o.disableStyleCopyPaste&&(p=e.copiedTextStyle),this.insertNewStyleBlock(x,u,p)}a()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onComposit
|
||
|
|
`&&a>0?(n=0,r++,t++):!this.splitByGrapheme&&this._reSpaceAndTab.test(e.graphemeText[r])&&a>0&&(n++,r++),i[a]={line:t,offset:n},r+=e.graphemeLines[a].length,n+=e.graphemeLines[a].length;return i}styleHas(e,t){if(this._styleMap&&!this.isWrapping){let e=this._styleMap[t];e&&(t=e.line)}return super.styleHas(e,t)}isEmptyStyles(e){if(!this.styles)return!0;let t,n,r=0,i=!1,a=this._styleMap[e],o=this._styleMap[e+1];a&&(e=a.line,r=a.offset),o&&(t=o.line,i=t===e,n=o.offset);let s=e===void 0?this.styles:{line:this.styles[e]};for(let e in s)for(let t in s[e]){let a=parseInt(t,10);if(a>=r&&(!i||a<n))for(let n in s[e][t])return!1}return!0}_getStyleDeclaration(e,t){if(this._styleMap&&!this.isWrapping){let n=this._styleMap[e];if(!n)return{};e=n.line,t=n.offset+t}return super._getStyleDeclaration(e,t)}_setStyleDeclaration(e,t,n){let r=this._styleMap[e];super._setStyleDeclaration(r.line,r.offset+t,n)}_deleteStyleDeclaration(e,t){let n=this._styleMap[e];super._deleteStyleDeclaration(n.line,n.offset+t)}_getLineStyle(e){let t=this._styleMap[e];return!!this.styles[t.line]}_setLineStyle(e){let t=this._styleMap[e];super._setLineStyle(t.line)}_wrapText(e,t){this.isWrapping=!0;let n=this.getGraphemeDataForRender(e),r=[];for(let e=0;e<n.wordsData.length;e++)r.push(...this._wrapLine(e,t,n));return this.isWrapping=!1,r}getGraphemeDataForRender(e){let t=this.splitByGrapheme,n=t?``:` `,r=0;return{wordsData:e.map((e,i)=>{let a=0,o=t?this.graphemeSplit(e):this.wordSplit(e);return o.length===0?[{word:[],width:0}]:o.map(e=>{let o=t?[e]:this.graphemeSplit(e),s=this._measureWord(o,i,a);return r=Math.max(s,r),a+=o.length+n.length,{word:o,width:s}})}),largestWordWidth:r}}_measureWord(e,t,n=0){let r,i=0;for(let a=0,o=e.length;a<o;a++)i+=this._getGraphemeBox(e[a],t,a+n,r,!0).kernedWidth,r=e[a];return i}wordSplit(e){return e.split(this._wordJoiners)}_wrapLine(e,t,{largestWordWidth:n,wordsData:r},i=0){let a=this._getWidthOfCharSpacing(),o=this.splitByGrapheme,s=[],c=o?``:` `,l=0,u=[],d=0,f=0,p=!0;t-=i;let m=Math.max(t,n,this.dynamicMinWidth),h=r[e],g;for(g=0;g<h.length;g++){let{word:t,width:n}=h[g];d+=t.length,l+=f+n-a,l>m&&!p?(s.push(u),u=[],l=n,p=!0):l+=a,p||o||u.push(c),u=u.concat(t),f=o?0:this._measureWord([c],e,d),d++,p=!1}return g&&s.push(u),n+i>this.dynamicMinWidth&&(this.dynamicMinWidth=n-a+i),s}isEndOfWrapping(e){return!this._styleMap[e+1]||this._styleMap[e+1].line!==this._styleMap[e].line}missingNewlineOffset(e,t){return this.splitByGrapheme&&!t?+!!this.isEndOfWrapping(e):1}_splitTextIntoLines(e){let t=super._splitTextIntoLines(e),n=this._wrapText(t.lines,this.width),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=n[e].join(``);return t.lines=r,t.graphemeLines=n,t}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){let e=new Map;for(let t in this._styleMap){let n=parseInt(t,10);if(this._textLines[n]){let n=this._styleMap[t].line;e.set(`${n}`,!0)}}for(let t in this.styles)e.has(t)||delete this.styles[t]}toObject(e=[]){return super.toObject([`minWidth`,`splitByGrapheme`,...e])}};i(fs,`type`,`Textbox`),i(fs,`textLayoutProperties`,[...ds.textLayoutProperties,`width`]),i(fs,`ownDefaults`,{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),M.setClass(fs);var ps=class extends ra{shouldPerformLayout(e){return!!e.target.clipPath&&super.shouldPerformLayout(e)}shouldLayoutClipPath(){return!1}calcLayoutResult(e,t){let{target:n}=e,{clipPath:r,group:i}=n;if(!r||!this.shouldPerformLayout(e))return;let{width:a,height:o}=wt(na(n,r)),s=new N(a,o);if(r.absolutePositioned)return{center:Mt(r.getRelativeCenterPoint(),void 0,i?i.calcTransformMatrix():void 0),size:s};{let i=r.getRelativeCenterPoint().transform(n.calcOwnMatrix(),!0);if(this.shouldPerformLayout(e)){let{center:n=new N,correction:r=new N}=this.calcBoundingBox(t,e)||{};return{center:n.add(i),correction:r.subtract(i),size:s}}return{center:n.getRelativeCenterPoint().add(i),size:s}}}};i(ps,`type`,`clip-path`),M.setClass(ps);var ms=class extends ra{getInitialSize({target:e},{size:t}){return new N(e.width||t.x,e.height||
|
||
|
|
`,` <rect x="`+n+`" y="`+r+`" width="`+U(this.width)+`" height="`+U(this.height)+`" />
|
||
|
|
`,`</clipPath>
|
||
|
|
`),o=` clip-path="url(#imageCrop_`+e+`)" `}if(this.imageSmoothing||(s=` image-rendering="optimizeSpeed"`),e.push(` <image `,`COMMON_PARTS`,`xlink:href="${U(this.getSrc(!0))}" x="${n-this.cropX}" y="${r-this.cropY}" width="${t.width||t.naturalWidth}" height="${t.height||t.naturalHeight}"${s}${o}></image>\n`),this.stroke||this.strokeDashArray){let e=this.fill;this.fill=null,a=[`\t<rect x="${n}" y="${r}" width="${U(this.width)}" height="${U(this.height)}" style="${this.getSvgStyles()}" />\n`],this.fill=e}return i=this.paintFirst===`fill`?i.concat(e,a):i.concat(a,e),i}getSrc(e){let t=e?this._element:this._originalElement;return t?t.toDataURL?t.toDataURL():this.srcFromAttribute?t.getAttribute(`src`)||``:t.src:this.src||``}getSvgSrc(e){return this.getSrc(e)}setSrc(e,{crossOrigin:t,signal:n}={}){return Ze(e,{crossOrigin:t,signal:n}).then(e=>{t!==void 0&&this.set({crossOrigin:t}),this.setElement(e)})}toString(){return`#<Image: { src: "${this.getSrc()}" }>`}applyResizeFilters(){let e=this.resizeFilter,t=this.minimumScaleTrigger,n=this.getTotalObjectScaling(),r=n.x,i=n.y,a=this._filteredEl||this._originalElement;if(this.group&&this.set(`dirty`,!0),!e||r>t&&i>t)return this._element=a,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=r,void(this._lastScaleY=i);let o=F(a),{width:s,height:c}=a;this._element=o,this._lastScaleX=e.scaleX=r,this._lastScaleY=e.scaleY=i,xs().applyFilters([e],a,s,c,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(e=this.filters||[]){if(e=e.filter(e=>e&&!e.isNeutralState()),this.set(`dirty`,!0),this.removeTexture(`${this.cacheKey}_filtered`),e.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);let t=this._originalElement,n=t.naturalWidth||t.width,r=t.naturalHeight||t.height;if(this._element===this._originalElement){let e=F({width:n,height:r});this._element=e,this._filteredEl=e}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext(`2d`).clearRect(0,0,n,r),this._lastScaleX=1,this._lastScaleY=1);xs().applyFilters(e,this._originalElement,n,r,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height)}_render(e){e.imageSmoothingEnabled=this.imageSmoothing,!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(e),this._renderPaintInOrder(e)}drawCacheOnCanvas(e){e.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(e)}shouldCache(){return this.needsItsOwnCache()}_renderFill(e){let t=this._element;if(!t)return;let n=this._filterScalingX,r=this._filterScalingY,i=this.width,a=this.height,o=Math.max(this.cropX,0),s=Math.max(this.cropY,0),c=t.naturalWidth||t.width,l=t.naturalHeight||t.height,u=o*n,d=s*r,f=Math.min(i*n,c-u),p=Math.min(a*r,l-d),m=-i/2,h=-a/2,g=Math.min(i,c/n-o),_=Math.min(a,l/r-s);t&&e.drawImage(t,u,d,f,p,m,h,g,_)}_needsResize(){let e=this.getTotalObjectScaling();return e.x!==this._lastScaleX||e.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight({width:e,height:t}={}){let n=this.getOriginalSize();this.width=e||n.width,this.height=t||n.height}parsePreserveAspectRatioAttribute(){let e=mn(this.preserveAspectRatio||``),t=this.width,n=this.height,r={width:t,height:n},i,a=this._element.width,o=this._element.height,s=1,c=1,l=0,u=0,d=0,f=0;return!e||e.alignX===`none`&&e.alignY===`none`?(s=t/a,c=n/o):(e.meetOrSlice===`meet`&&(s=c=ua(this._element,r),i=(t-a*s)/2,e.alignX===`Min`&&(l=-i),e.alignX===`Max`&&(l=i),i=(n-o*c)/2,e.alignY===`Min`&&(u=-i),e.alignY===`Max`&&(u=i)),e.meetOrSlice===`slice`&&(s=c=da(this._element,r),i=a-t/s,e.alignX===`Mid`&&(d=i/2),e.alignX===`Max`&&(d=i),i=o-n/c,e.alignY===`Mid`&&(f=i/2),e.alignY===`Max`&&(f=i),a=t/s,o=n/c)),{width:a,height:o,scaleX:s,scaleY:c,offsetLeft:l,o
|
||
|
|
attribute vec2 aPosition;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vTexCoord = aPosition;
|
||
|
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
||
|
|
}`}createProgram(e,t=this.getFragmentSource(),n=this.getVertexSource()){let{WebGLProbe:{GLPrecision:r=`highp`}}=h();r!==`highp`&&(t=t.replace(Us,Vs.replace(`highp`,r)));let i=e.createShader(e.VERTEX_SHADER),a=e.createShader(e.FRAGMENT_SHADER),o=e.createProgram();if(!i||!a||!o)throw new c(`Vertex, fragment shader or program creation error`);if(e.shaderSource(i,n),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw new c(`Vertex shader compile error for ${this.type}: ${e.getShaderInfoLog(i)}`);if(e.shaderSource(a,t),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS))throw new c(`Fragment shader compile error for ${this.type}: ${e.getShaderInfoLog(a)}`);if(e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new c(`Shader link error for "${this.type}" ${e.getProgramInfoLog(o)}`);let s=this.getUniformLocations(e,o)||{};return s.uStepW=e.getUniformLocation(o,`uStepW`),s.uStepH=e.getUniformLocation(o,`uStepH`),{program:o,attributeLocations:this.getAttributeLocations(e,o),uniformLocations:s}}getAttributeLocations(e,t){return{aPosition:e.getAttribLocation(t,`aPosition`)}}getUniformLocations(e,t){let n=this.constructor.uniformLocations,r={};for(let i=0;i<n.length;i++)r[n[i]]=e.getUniformLocation(t,n[i]);return r}sendAttributeData(e,t,n){let r=t.aPosition,i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(r),e.vertexAttribPointer(r,2,e.FLOAT,!1,0,0),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW)}_setupFrameBuffer(e){let t=e.context;if(e.passes>1){let n=e.destinationWidth,r=e.destinationHeight;e.sourceWidth===n&&e.sourceHeight===r||(t.deleteTexture(e.targetTexture),e.targetTexture=e.filterBackend.createTexture(t,n,r)),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e.targetTexture,0)}else t.bindFramebuffer(t.FRAMEBUFFER,null),t.finish()}_swapTextures(e){e.passes--,e.pass++;let t=e.targetTexture;e.targetTexture=e.sourceTexture,e.sourceTexture=t}isNeutralState(e){return!1}applyTo(e){zs(e)?(this._setupFrameBuffer(e),this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d(e){}getCacheKey(){return this.type}retrieveShader(e){let t=this.getCacheKey();return e.programCache[t]||(e.programCache[t]=this.createProgram(e.context)),e.programCache[t]}applyToWebGL(e){let t=e.context,n=this.retrieveShader(e);e.pass===0&&e.originalTexture?t.bindTexture(t.TEXTURE_2D,e.originalTexture):t.bindTexture(t.TEXTURE_2D,e.sourceTexture),t.useProgram(n.program),this.sendAttributeData(t,n.attributeLocations,e.aPosition),t.uniform1f(n.uniformLocations.uStepW,1/e.sourceWidth),t.uniform1f(n.uniformLocations.uStepH,1/e.sourceHeight),this.sendUniformData(t,n.uniformLocations),t.viewport(0,0,e.destinationWidth,e.destinationHeight),t.drawArrays(t.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(e,t,n){e.activeTexture(n),e.bindTexture(e.TEXTURE_2D,t),e.activeTexture(e.TEXTURE0)}unbindAdditionalTexture(e,t){e.activeTexture(t),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE0)}sendUniformData(e,t){}createHelpLayer(e){if(!e.helpLayer){let{sourceWidth:t,sourceHeight:n}=e;e.helpLayer=F({width:t,height:n})}}toObject(){let e=Object.keys(this.constructor.defaults||{});return{type:this.type,...e.reduce((e,t)=>(e[t]=this[t],e),{})}}toJSON(){return this.toObject()}static async fromObject({type:e,...t},n){return new this(t)}};i($,`type`,`BaseFilter`),i($,`uniformLocations`,[]);const Ws={multiply:`gl_FragColor.rgb *= uColor.rgb;
|
||
|
|
`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
|
||
|
|
`,add:`gl_FragColor.rgb += uColor.rgb;
|
||
|
|
`,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
|
||
|
|
`,subtract:`gl_FragColor.rgb -= uColor.rgb;
|
||
|
|
`,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
|
||
|
|
`,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
|
||
|
|
`,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
|
||
|
|
`,overlay:`
|
||
|
|
if (uColor.r < 0.5) {
|
||
|
|
gl_FragColor.r *= 2.0 * uColor.r;
|
||
|
|
} else {
|
||
|
|
gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
|
||
|
|
}
|
||
|
|
if (uColor.g < 0.5) {
|
||
|
|
gl_FragColor.g *= 2.0 * uColor.g;
|
||
|
|
} else {
|
||
|
|
gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
|
||
|
|
}
|
||
|
|
if (uColor.b < 0.5) {
|
||
|
|
gl_FragColor.b *= 2.0 * uColor.b;
|
||
|
|
} else {
|
||
|
|
gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
|
||
|
|
}
|
||
|
|
`,tint:`
|
||
|
|
gl_FragColor.rgb *= (1.0 - uColor.a);
|
||
|
|
gl_FragColor.rgb += uColor.rgb;
|
||
|
|
`};var Gs=class extends ${getCacheKey(){return`${this.type}_${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 ${Ws[this.mode]}\n }\n }\n `}applyTo2d({imageData:{data:e}}){let t=new G(this.color).getSource(),n=this.alpha,r=t[0]*n,i=t[1]*n,a=t[2]*n,o=1-n;for(let t=0;t<e.length;t+=4){let n=e[t],s=e[t+1],c=e[t+2],l,u,d;switch(this.mode){case`multiply`:l=n*r/255,u=s*i/255,d=c*a/255;break;case`screen`:l=255-(255-n)*(255-r)/255,u=255-(255-s)*(255-i)/255,d=255-(255-c)*(255-a)/255;break;case`add`:l=n+r,u=s+i,d=c+a;break;case`difference`:l=Math.abs(n-r),u=Math.abs(s-i),d=Math.abs(c-a);break;case`subtract`:l=n-r,u=s-i,d=c-a;break;case`darken`:l=Math.min(n,r),u=Math.min(s,i),d=Math.min(c,a);break;case`lighten`:l=Math.max(n,r),u=Math.max(s,i),d=Math.max(c,a);break;case`overlay`:l=r<128?2*n*r/255:255-2*(255-n)*(255-r)/255,u=i<128?2*s*i/255:255-2*(255-s)*(255-i)/255,d=a<128?2*c*a/255:255-2*(255-c)*(255-a)/255;break;case`exclusion`:l=r+n-2*r*n/255,u=i+s-2*i*s/255,d=a+c-2*a*c/255;break;case`tint`:l=r+n*o,u=i+s*o,d=a+c*o}e[t]=l,e[t+1]=u,e[t+2]=d}}sendUniformData(e,t){let n=new G(this.color).getSource();n[0]=this.alpha*n[0]/255,n[1]=this.alpha*n[1]/255,n[2]=this.alpha*n[2]/255,n[3]=this.alpha,e.uniform4fv(t.uColor,n)}};i(Gs,`defaults`,{color:`#F95C63`,mode:`multiply`,alpha:1}),i(Gs,`type`,`BlendColor`),i(Gs,`uniformLocations`,[`uColor`]),M.setClass(Gs);const Ks={multiply:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform sampler2D uImage;
|
||
|
|
uniform vec4 uColor;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
varying vec2 vTexCoord2;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
vec4 color2 = texture2D(uImage, vTexCoord2);
|
||
|
|
color.rgba *= color2.rgba;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`,mask:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform sampler2D uImage;
|
||
|
|
uniform vec4 uColor;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
varying vec2 vTexCoord2;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
vec4 color2 = texture2D(uImage, vTexCoord2);
|
||
|
|
color.a = color2.a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`};var qs=class extends ${getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return Ks[this.mode]}getVertexSource(){return`
|
||
|
|
attribute vec2 aPosition;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
varying vec2 vTexCoord2;
|
||
|
|
uniform mat3 uTransformMatrix;
|
||
|
|
void main() {
|
||
|
|
vTexCoord = aPosition;
|
||
|
|
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
||
|
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
||
|
|
}
|
||
|
|
`}applyToWebGL(e){let t=e.context,n=this.createTexture(e.filterBackend,this.image);this.bindAdditionalTexture(t,n,t.TEXTURE1),super.applyToWebGL(e),this.unbindAdditionalTexture(t,t.TEXTURE1)}createTexture(e,t){return e.getCachedTexture(t.cacheKey,t.getElement())}calculateMatrix(){let e=this.image,{width:t,height:n}=e.getElement();return[1/e.scaleX,0,0,0,1/e.scaleY,0,-e.left/t,-e.top/n,1]}applyTo2d({imageData:{data:e,width:t,height:n},filterBackend:{resources:r}}){let i=this.image;r.blendImage||(r.blendImage=P());let a=r.blendImage,o=a.getContext(`2d`);a.width!==t||a.height!==n?(a.width=t,a.height=n):o.clearRect(0,0,t,n),o.setTransform(i.scaleX,0,0,i.scaleY,i.left,i.top),o.drawImage(i.getElement(),0,0,t,n);let s=o.getImageData(0,0,t,n).data;for(let t=0;t<e.length;t+=4){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3],o=s[t],c=s[t+1],l=s[t+2],u=s[t+3];switch(this.mode){case`multiply`:e[t]=n*o/255,e[t+1]=r*c/255,e[t+2]=i*l/255,e[t+3]=a*u/255;break;case`mask`:e[t+3]=u}}}sendUniformData(e,t){let n=this.calculateMatrix();e.uniform1i(t.uImage,1),e.uniformMatrix3fv(t.uTransformMatrix,!1,n)}toObject(){return{...super.toObject(),image:this.image&&this.image.toObject()}}static async fromObject({type:e,image:t,...n},r){return ws.fromObject(t,r).then(e=>new this({...n,image:e}))}};i(qs,`type`,`BlendImage`),i(qs,`defaults`,{mode:`multiply`,alpha:1}),i(qs,`uniformLocations`,[`uTransformMatrix`,`uImage`]),M.setClass(qs);var Js=class extends ${getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform vec2 uDelta;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
const float nSamples = 15.0;
|
||
|
|
vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
|
||
|
|
float random(vec3 scale) {
|
||
|
|
/* use the fragment position for a different seed per-pixel */
|
||
|
|
return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
|
||
|
|
}
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0.0);
|
||
|
|
float totalC = 0.0;
|
||
|
|
float totalA = 0.0;
|
||
|
|
float offset = random(v3offset);
|
||
|
|
for (float t = -nSamples; t <= nSamples; t++) {
|
||
|
|
float percent = (t + offset - 0.5) / nSamples;
|
||
|
|
vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);
|
||
|
|
float weight = 1.0 - abs(percent);
|
||
|
|
float alpha = weight * sample.a;
|
||
|
|
color.rgb += sample.rgb * alpha;
|
||
|
|
color.a += alpha;
|
||
|
|
totalA += weight;
|
||
|
|
totalC += alpha;
|
||
|
|
}
|
||
|
|
gl_FragColor.rgb = color.rgb / totalC;
|
||
|
|
gl_FragColor.a = color.a / totalA;
|
||
|
|
}
|
||
|
|
`}applyTo(e){zs(e)?(this.aspectRatio=e.sourceWidth/e.sourceHeight,e.passes++,this._setupFrameBuffer(e),this.horizontal=!0,this.applyToWebGL(e),this._swapTextures(e),this._setupFrameBuffer(e),this.horizontal=!1,this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)}applyTo2d({imageData:{data:e,width:t,height:n}}){this.aspectRatio=t/n,this.horizontal=!0;let r=this.getBlurValue()*t,i=new Uint8ClampedArray(e),a=4*t;for(let t=0;t<e.length;t+=4){let n=0,o=0,s=0,c=0,l=0,u=t-t%a,d=u+a;for(let i=-14;i<15;i++){let a=i/15,f=4*Math.floor(r*a),p=1-Math.abs(a),m=t+f;m<u?m=u:m>d&&(m=d);let h=e[m+3]*p;n+=e[m]*h,o+=e[m+1]*h,s+=e[m+2]*h,c+=h,l+=p}i[t]=n/c,i[t+1]=o/c,i[t+2]=s/c,i[t+3]=c/l}this.horizontal=!1,r=this.getBlurValue()*n;for(let t=0;t<i.length;t+=4){let n=0,o=0,s=0,c=0,l=0,u=t%a,d=i.length-a+u;for(let e=-14;e<15;e++){let f=e/15,p=Math.floor(r*f)*a,m=1-Math.abs(f),h=t+p;h<u?h=u:h>d&&(h=d);let g=i[h+3]*m;n+=i[h]*g,o+=i[h+1]*g,s+=i[h+2]*g,c+=g,l+=m}e[t]=n/c,e[t+1]=o/c,e[t+2]=s/c,e[t+3]=c/l}}sendUniformData(e,t){let n=this.chooseRightDelta();e.uniform2fv(t.uDelta,n)}isNeutralState(){return this.blur===0}getBlurValue(){let e=1,{horizontal:t,aspectRatio:n}=this;return t?n>1&&(e=1/n):n<1&&(e=n),e*this.blur*.12}chooseRightDelta(){let e=this.getBlurValue();return this.horizontal?[e,0]:[0,e]}};i(Js,`type`,`Blur`),i(Js,`defaults`,{blur:0}),i(Js,`uniformLocations`,[`uDelta`]),M.setClass(Js);var Ys=class extends ${getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uBrightness;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
color.rgb += uBrightness;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`}applyTo2d({imageData:{data:e}}){let t=Math.round(255*this.brightness);for(let n=0;n<e.length;n+=4)e[n]+=t,e[n+1]+=t,e[n+2]+=t}isNeutralState(){return this.brightness===0}sendUniformData(e,t){e.uniform1f(t.uBrightness,this.brightness)}};i(Ys,`type`,`Brightness`),i(Ys,`defaults`,{brightness:0}),i(Ys,`uniformLocations`,[`uBrightness`]),M.setClass(Ys);const Xs={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};var Zs=class extends ${getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
uniform mat4 uColorMatrix;
|
||
|
|
uniform vec4 uConstants;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
color *= uColorMatrix;
|
||
|
|
color += uConstants;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`}applyTo2d(e){let t=e.imageData.data,n=this.matrix,r=this.colorsOnly;for(let e=0;e<t.length;e+=4){let i=t[e],a=t[e+1],o=t[e+2];if(t[e]=i*n[0]+a*n[1]+o*n[2]+255*n[4],t[e+1]=i*n[5]+a*n[6]+o*n[7]+255*n[9],t[e+2]=i*n[10]+a*n[11]+o*n[12]+255*n[14],!r){let r=t[e+3];t[e]+=r*n[3],t[e+1]+=r*n[8],t[e+2]+=r*n[13],t[e+3]=i*n[15]+a*n[16]+o*n[17]+r*n[18]+255*n[19]}}}sendUniformData(e,t){let n=this.matrix,r=[n[0],n[1],n[2],n[3],n[5],n[6],n[7],n[8],n[10],n[11],n[12],n[13],n[15],n[16],n[17],n[18]],i=[n[4],n[9],n[14],n[19]];e.uniformMatrix4fv(t.uColorMatrix,!1,r),e.uniform4fv(t.uConstants,i)}toObject(){return{...super.toObject(),matrix:[...this.matrix]}}};function Qs(e,t){var n;let r=(i(n=class extends Zs{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},`type`,e),i(n,`defaults`,{colorsOnly:!1,matrix:t}),n);return M.setClass(r,e),r}i(Zs,`type`,`ColorMatrix`),i(Zs,`defaults`,Xs),i(Zs,`uniformLocations`,[`uColorMatrix`,`uConstants`]),M.setClass(Zs);const $s=Qs(`Brownie`,[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),ec=Qs(`Vintage`,[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),tc=Qs(`Kodachrome`,[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),nc=Qs(`Technicolor`,[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),rc=Qs(`Polaroid`,[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),ic=Qs(`Sepia`,[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),ac=Qs(`BlackWhite`,[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]);var oc=class extends ${constructor(e={}){super(e),this.subFilters=e.subFilters||[]}applyTo(e){zs(e)&&(e.passes+=this.subFilters.length-1),this.subFilters.forEach(t=>{t.applyTo(e)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(e=>e.toObject())}}isNeutralState(){return!this.subFilters.some(e=>!e.isNeutralState())}static fromObject(e,t){return Promise.all((e.subFilters||[]).map(e=>M.getClass(e.type).fromObject(e,t))).then(e=>new this({subFilters:e}))}};i(oc,`type`,`Composed`),M.setClass(oc);var sc=class extends ${getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uContrast;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
|
||
|
|
color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`}isNeutralState(){return this.contrast===0}applyTo2d({imageData:{data:e}}){let t=Math.floor(255*this.contrast),n=259*(t+255)/(255*(259-t));for(let t=0;t<e.length;t+=4)e[t]=n*(e[t]-128)+128,e[t+1]=n*(e[t+1]-128)+128,e[t+2]=n*(e[t+2]-128)+128}sendUniformData(e,t){e.uniform1f(t.uContrast,this.contrast)}};i(sc,`type`,`Contrast`),i(sc,`defaults`,{contrast:0}),i(sc,`uniformLocations`,[`uContrast`]),M.setClass(sc);const cc={Convolute_3_1:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[9];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 0);
|
||
|
|
for (float h = 0.0; h < 3.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 3.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
|
||
|
|
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`,Convolute_3_0:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[9];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 1);
|
||
|
|
for (float h = 0.0; h < 3.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 3.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
|
||
|
|
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.a = alpha;
|
||
|
|
}
|
||
|
|
`,Convolute_5_1:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[25];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 0);
|
||
|
|
for (float h = 0.0; h < 5.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 5.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
||
|
|
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`,Convolute_5_0:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[25];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 1);
|
||
|
|
for (float h = 0.0; h < 5.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 5.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
||
|
|
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.a = alpha;
|
||
|
|
}
|
||
|
|
`,Convolute_7_1:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[49];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 0);
|
||
|
|
for (float h = 0.0; h < 7.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 7.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
||
|
|
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`,Convolute_7_0:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[49];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 1);
|
||
|
|
for (float h = 0.0; h < 7.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 7.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
||
|
|
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.a = alpha;
|
||
|
|
}
|
||
|
|
`,Convolute_9_1:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[81];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 0);
|
||
|
|
for (float h = 0.0; h < 9.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 9.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
||
|
|
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`,Convolute_9_0:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[81];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 1);
|
||
|
|
for (float h = 0.0; h < 9.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 9.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
||
|
|
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.a = alpha;
|
||
|
|
}
|
||
|
|
`};var lc=class extends ${getCacheKey(){return`${this.type}_${Math.sqrt(this.matrix.length)}_${+!!this.opaque}`}getFragmentSource(){return cc[this.getCacheKey()]}applyTo2d(e){let t=e.imageData,n=t.data,r=this.matrix,i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=t.width,s=t.height,c=e.ctx.createImageData(o,s),l=c.data,u=+!!this.opaque,d,f,p,m,h,g,_,v,y,b,x,S,C;for(x=0;x<s;x++)for(b=0;b<o;b++){for(h=4*(x*o+b),d=0,f=0,p=0,m=0,C=0;C<i;C++)for(S=0;S<i;S++)_=x+C-a,g=b+S-a,_<0||_>=s||g<0||g>=o||(v=4*(_*o+g),y=r[C*i+S],d+=n[v]*y,f+=n[v+1]*y,p+=n[v+2]*y,u||(m+=n[v+3]*y));l[h]=d,l[h+1]=f,l[h+2]=p,l[h+3]=u?n[h+3]:m}e.imageData=c}sendUniformData(e,t){e.uniform1fv(t.uMatrix,this.matrix)}toObject(){return{...super.toObject(),opaque:this.opaque,matrix:[...this.matrix]}}};i(lc,`type`,`Convolute`),i(lc,`defaults`,{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),i(lc,`uniformLocations`,[`uMatrix`,`uOpaque`,`uHalfSize`,`uSize`]),M.setClass(lc);const uc=`Gamma`;var dc=class extends ${getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform vec3 uGamma;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
vec3 correction = (1.0 / uGamma);
|
||
|
|
color.r = pow(color.r, correction.r);
|
||
|
|
color.g = pow(color.g, correction.g);
|
||
|
|
color.b = pow(color.b, correction.b);
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.rgb *= color.a;
|
||
|
|
}
|
||
|
|
`}constructor(e={}){super(e),this.gamma=e.gamma||this.constructor.defaults.gamma.concat()}applyTo2d({imageData:{data:e}}){let t=this.gamma,n=1/t[0],r=1/t[1],i=1/t[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});let a=this.rgbValues;for(let e=0;e<256;e++)a.r[e]=255*(e/255)**n,a.g[e]=255*(e/255)**r,a.b[e]=255*(e/255)**i;for(let t=0;t<e.length;t+=4)e[t]=a.r[e[t]],e[t+1]=a.g[e[t+1]],e[t+2]=a.b[e[t+2]]}sendUniformData(e,t){e.uniform3fv(t.uGamma,this.gamma)}isNeutralState(){let{gamma:e}=this;return e[0]===1&&e[1]===1&&e[2]===1}toObject(){return{type:uc,gamma:this.gamma.concat()}}};i(dc,`type`,uc),i(dc,`defaults`,{gamma:[1,1,1]}),i(dc,`uniformLocations`,[`uGamma`]),M.setClass(dc);const fc={average:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
float average = (color.r + color.b + color.g) / 3.0;
|
||
|
|
gl_FragColor = vec4(average, average, average, color.a);
|
||
|
|
}
|
||
|
|
`,lightness:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform int uMode;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 col = texture2D(uTexture, vTexCoord);
|
||
|
|
float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
|
||
|
|
gl_FragColor = vec4(average, average, average, col.a);
|
||
|
|
}
|
||
|
|
`,luminosity:`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform int uMode;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 col = texture2D(uTexture, vTexCoord);
|
||
|
|
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
|
||
|
|
gl_FragColor = vec4(average, average, average, col.a);
|
||
|
|
}
|
||
|
|
`};var pc=class extends ${applyTo2d({imageData:{data:e}}){for(let t,n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2];switch(this.mode){case`average`:t=(r+i+a)/3;break;case`lightness`:t=(Math.min(r,i,a)+Math.max(r,i,a))/2;break;case`luminosity`:t=.21*r+.72*i+.07*a}e[n+2]=e[n+1]=e[n]=t}}getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return fc[this.mode]}sendUniformData(e,t){e.uniform1i(t.uMode,1)}isNeutralState(){return!1}};i(pc,`type`,`Grayscale`),i(pc,`defaults`,{mode:`average`}),i(pc,`uniformLocations`,[`uMode`]),M.setClass(pc);const mc={...Xs,rotation:0};var hc=class extends Zs{calculateMatrix(){let e=this.rotation*Math.PI,t=Se(e),n=Ce(e),r=1/3,i=Math.sqrt(r)*n,a=1-t;this.matrix=[t+a/3,r*a-i,r*a+i,0,0,r*a+i,t+r*a,r*a-i,0,0,r*a-i,r*a+i,t+r*a,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(e){this.calculateMatrix(),super.applyTo(e)}toObject(){return{type:this.type,rotation:this.rotation}}};i(hc,`type`,`HueRotation`),i(hc,`defaults`,mc),M.setClass(hc);var gc=class extends ${applyTo2d({imageData:{data:e}}){for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2],this.alpha&&(e[t+3]=255-e[t+3])}getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform int uInvert;
|
||
|
|
uniform int uAlpha;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
if (uInvert == 1) {
|
||
|
|
if (uAlpha == 1) {
|
||
|
|
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);
|
||
|
|
} else {
|
||
|
|
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
`}isNeutralState(){return!this.invert}sendUniformData(e,t){e.uniform1i(t.uInvert,Number(this.invert)),e.uniform1i(t.uAlpha,Number(this.alpha))}};i(gc,`type`,`Invert`),i(gc,`defaults`,{alpha:!1,invert:!0}),i(gc,`uniformLocations`,[`uInvert`,`uAlpha`]),M.setClass(gc);var _c=class extends ${getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uStepH;
|
||
|
|
uniform float uNoise;
|
||
|
|
uniform float uSeed;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
float rand(vec2 co, float seed, float vScale) {
|
||
|
|
return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
|
||
|
|
}
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`}applyTo2d({imageData:{data:e}}){let t=this.noise;for(let n=0;n<e.length;n+=4){let r=(.5-Math.random())*t;e[n]+=r,e[n+1]+=r,e[n+2]+=r}}sendUniformData(e,t){e.uniform1f(t.uNoise,this.noise/255),e.uniform1f(t.uSeed,Math.random())}isNeutralState(){return this.noise===0}};i(_c,`type`,`Noise`),i(_c,`defaults`,{noise:0}),i(_c,`uniformLocations`,[`uNoise`,`uSeed`]),M.setClass(_c);var vc=class extends ${applyTo2d({imageData:{data:e,width:t,height:n}}){for(let r=0;r<n;r+=this.blocksize)for(let i=0;i<t;i+=this.blocksize){let a=4*r*t+4*i,o=e[a],s=e[a+1],c=e[a+2],l=e[a+3];for(let a=r;a<Math.min(r+this.blocksize,n);a++)for(let n=i;n<Math.min(i+this.blocksize,t);n++){let r=4*a*t+4*n;e[r]=o,e[r+1]=s,e[r+2]=c,e[r+3]=l}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uBlocksize;
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
float blockW = uBlocksize * uStepW;
|
||
|
|
float blockH = uBlocksize * uStepH;
|
||
|
|
int posX = int(vTexCoord.x / blockW);
|
||
|
|
int posY = int(vTexCoord.y / blockH);
|
||
|
|
float fposX = float(posX);
|
||
|
|
float fposY = float(posY);
|
||
|
|
vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
|
||
|
|
vec4 color = texture2D(uTexture, squareCoords);
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`}sendUniformData(e,t){e.uniform1f(t.uBlocksize,this.blocksize)}};i(vc,`type`,`Pixelate`),i(vc,`defaults`,{blocksize:4}),i(vc,`uniformLocations`,[`uBlocksize`]),M.setClass(vc);var yc=class extends ${getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform vec4 uLow;
|
||
|
|
uniform vec4 uHigh;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
gl_FragColor = texture2D(uTexture, vTexCoord);
|
||
|
|
if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
|
||
|
|
gl_FragColor.a = 0.0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
`}applyTo2d({imageData:{data:e}}){let t=255*this.distance,n=new G(this.color).getSource(),r=[n[0]-t,n[1]-t,n[2]-t],i=[n[0]+t,n[1]+t,n[2]+t];for(let t=0;t<e.length;t+=4){let n=e[t],a=e[t+1],o=e[t+2];n>r[0]&&a>r[1]&&o>r[2]&&n<i[0]&&a<i[1]&&o<i[2]&&(e[t+3]=0)}}sendUniformData(e,t){let n=new G(this.color).getSource(),r=this.distance,i=[0+n[0]/255-r,0+n[1]/255-r,0+n[2]/255-r,1],a=[n[0]/255+r,n[1]/255+r,n[2]/255+r,1];e.uniform4fv(t.uLow,i),e.uniform4fv(t.uHigh,a)}};i(yc,`type`,`RemoveColor`),i(yc,`defaults`,{color:`#FFFFFF`,distance:.02,useAlpha:!1}),i(yc,`uniformLocations`,[`uLow`,`uHigh`]),M.setClass(yc);var bc=class extends ${sendUniformData(e,t){e.uniform2fv(t.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),e.uniform1fv(t.uTaps,this.taps)}getFilterWindow(){let e=this.tempScale;return Math.ceil(this.lanczosLobes/e)}getCacheKey(){let e=this.getFilterWindow();return`${this.type}_${e}`}getFragmentSource(){let e=this.getFilterWindow();return this.generateShader(e)}getTaps(){let e=this.lanczosCreate(this.lanczosLobes),t=this.tempScale,n=this.getFilterWindow(),r=Array(n);for(let i=1;i<=n;i++)r[i-1]=e(i*t);return r}generateShader(e){let t=Array(e);for(let n=1;n<=e;n++)t[n-1]=`${n}.0 * uDelta`;return`\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${e}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${t.map((e,t)=>`\n color += texture2D(uTexture, vTexCoord + ${e}) * uTaps[${t}] + texture2D(uTexture, vTexCoord - ${e}) * uTaps[${t}];\n sum += 2.0 * uTaps[${t}];\n `).join(`
|
||
|
|
`)}\n gl_FragColor = color / sum;\n }\n `}applyToForWebgl(e){e.passes++,this.width=e.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=e.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),e.destinationWidth=this.dW,super.applyTo(e),e.sourceWidth=e.destinationWidth,this.height=e.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),e.destinationHeight=this.dH,super.applyTo(e),e.sourceHeight=e.destinationHeight}applyTo(e){zs(e)?this.applyToForWebgl(e):this.applyTo2d(e)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(e){return t=>{if(t>=e||t<=-e)return 0;if(t<1.1920929e-7&&t>-1.1920929e-7)return 1;let n=(t*=Math.PI)/e;return Math.sin(t)/t*Math.sin(n)/n}}applyTo2d(e){let t=e.imageData,n=this.scaleX,r=this.scaleY;this.rcpScaleX=1/n,this.rcpScaleY=1/r;let i=t.width,a=t.height,o=Math.round(i*n),s=Math.round(a*r),c;c=this.resizeType===`sliceHack`?this.sliceByTwo(e,i,a,o,s):this.resizeType===`hermite`?this.hermiteFastResize(e,i,a,o,s):this.resizeType===`bilinear`?this.bilinearFiltering(e,i,a,o,s):this.resizeType===`lanczos`?this.lanczosResize(e,i,a,o,s):new ImageData(o,s),e.imageData=c}sliceByTwo(e,t,n,r,i){let a=e.imageData,o=.5,s=!1,c=!1,l=t*o,u=n*o,d=e.filterBackend.resources,f=0,p=0,m=t,h=0;d.sliceByTwo||(d.sliceByTwo=P());let g=d.sliceByTwo;(g.width<1.5*t||g.height<n)&&(g.width=1.5*t,g.height=n);let _=g.getContext(`2d`);for(_.clearRect(0,0,1.5*t,n),_.putImageData(a,0,0),r=Math.floor(r),i=Math.floor(i);!s||!c;)t=l,n=u,r<Math.floor(l*o)?l=Math.floor(l*o):(l=r,s=!0),i<Math.floor(u*o)?u=Math.floor(u*o):(u=i,c=!0),_.drawImage(g,f,p,t,n,m,h,l,u),f=m,p=h,h+=u;return _.getImageData(f,p,r,i)}lanczosResize(e,t,n,r,i){let a=e.imageData.data,o=e.ctx.createImageData(r,i),s=o.data,c=this.lanczosCreate(this.lanczosLobes),l=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,f=2/this.rcpScaleY,p=Math.ceil(l*this.lanczosLobes/2),m=Math.ceil(u*this.lanczosLobes/2),h={},g={x:0,y:0},_={x:0,y:0};return function e(v){let y,b,x,S,C,w,ee,T,E,D,O;for(g.x=(v+.5)*l,_.x=Math.floor(g.x),y=0;y<i;y++){for(g.y=(y+.5)*u,_.y=Math.floor(g.y),C=0,w=0,ee=0,T=0,E=0,b=_.x-p;b<=_.x+p;b++)if(!(b<0||b>=t)){D=Math.floor(1e3*Math.abs(b-g.x)),h[D]||(h[D]={});for(let e=_.y-m;e<=_.y+m;e++)e<0||e>=n||(O=Math.floor(1e3*Math.abs(e-g.y)),h[D][O]||(h[D][O]=c(Math.sqrt((D*d)**2+(O*f)**2)/1e3)),x=h[D][O],x>0&&(S=4*(e*t+b),C+=x,w+=x*a[S],ee+=x*a[S+1],T+=x*a[S+2],E+=x*a[S+3]))}S=4*(y*r+v),s[S]=w/C,s[S+1]=ee/C,s[S+2]=T/C,s[S+3]=E/C}return++v<r?e(v):o}(0)}bilinearFiltering(e,t,n,r,i){let a,o,s,c,l,u,d,f,p,m,h,g,_,v=0,y=this.rcpScaleX,b=this.rcpScaleY,x=4*(t-1),S=e.imageData.data,C=e.ctx.createImageData(r,i),w=C.data;for(d=0;d<i;d++)for(f=0;f<r;f++)for(l=Math.floor(y*f),u=Math.floor(b*d),p=y*f-l,m=b*d-u,_=4*(u*t+l),h=0;h<4;h++)a=S[_+h],o=S[_+4+h],s=S[_+x+h],c=S[_+x+4+h],g=a*(1-p)*(1-m)+o*p*(1-m)+s*m*(1-p)+c*p*m,w[v++]=g;return C}hermiteFastResize(e,t,n,r,i){let a=this.rcpScaleX,o=this.rcpScaleY,s=Math.ceil(a/2),c=Math.ceil(o/2),l=e.imageData.data,u=e.ctx.createImageData(r,i),d=u.data;for(let e=0;e<i;e++)for(let n=0;n<r;n++){let i=4*(n+e*r),u,f=0,p=0,m=0,h=0,g=0,_=0,v=(e+.5)*o;for(let r=Math.floor(e*o);r<(e+1)*o;r++){let e=Math.abs(v-(r+.5))/c,i=(n+.5)*a,o=e*e;for(let e=Math.floor(n*a);e<(n+1)*a;e++){let n=Math.abs(i-(e+.5))/s,a=Math.sqrt(o+n*n);a>1&&a<-1||(u=2*a*a*a-3*a*a+1,u>0&&(n=4*(e+r*t),_+=u*l[n+3],p+=u,l[n+3]<255&&(u=u*l[n+3]/250),m+=u*l[n],h+=u*l[n+1],g+=u*l[n+2],f+=u))}}d[i]=m/f,d[i+1]=h/f,d[i+2]=g/f,d[i+3]=_/p}return u}};i(bc,`type`,`Resize`),i(bc,`defaults`,{resizeType:`hermite`,scaleX:1,scaleY:1,lanczosLobes:3}),i(bc,`uniformLocations`,[`uDelta`,`uTaps`]),M.setClass(bc);var xc=class extends ${getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uSaturation;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
float rgMax = max(color.r, color.g);
|
||
|
|
float rgbMax = max(rgMax, color.b);
|
||
|
|
color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
|
||
|
|
color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
|
||
|
|
color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`}applyTo2d({imageData:{data:e}}){let t=-this.saturation;for(let n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2],o=Math.max(r,i,a);e[n]+=o===r?0:(o-r)*t,e[n+1]+=o===i?0:(o-i)*t,e[n+2]+=o===a?0:(o-a)*t}}sendUniformData(e,t){e.uniform1f(t.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}};i(xc,`type`,`Saturation`),i(xc,`defaults`,{saturation:0}),i(xc,`uniformLocations`,[`uSaturation`]),M.setClass(xc);var Sc=class extends ${getFragmentSource(){return`
|
||
|
|
precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uVibrance;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
float max = max(color.r, max(color.g, color.b));
|
||
|
|
float avg = (color.r + color.g + color.b) / 3.0;
|
||
|
|
float amt = (abs(max - avg) * 2.0) * uVibrance;
|
||
|
|
color.r += max != color.r ? (max - color.r) * amt : 0.00;
|
||
|
|
color.g += max != color.g ? (max - color.g) * amt : 0.00;
|
||
|
|
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
`}applyTo2d({imageData:{data:e}}){let t=-this.vibrance;for(let n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2],o=Math.max(r,i,a),s=(r+i+a)/3,c=2*Math.abs(o-s)/255*t;e[n]+=o===r?0:(o-r)*c,e[n+1]+=o===i?0:(o-i)*c,e[n+2]+=o===a?0:(o-a)*c}}sendUniformData(e,t){e.uniform1f(t.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}};i(Sc,`type`,`Vibrance`),i(Sc,`defaults`,{vibrance:0}),i(Sc,`uniformLocations`,[`uVibrance`]),M.setClass(Sc);var Cc=t({BaseFilter:()=>$,BlackWhite:()=>ac,BlendColor:()=>Gs,BlendImage:()=>qs,Blur:()=>Js,Brightness:()=>Ys,Brownie:()=>$s,ColorMatrix:()=>Zs,Composed:()=>oc,Contrast:()=>sc,Convolute:()=>lc,Gamma:()=>dc,Grayscale:()=>pc,HueRotation:()=>hc,Invert:()=>gc,Kodachrome:()=>tc,Noise:()=>_c,Pixelate:()=>vc,Polaroid:()=>rc,RemoveColor:()=>yc,Resize:()=>bc,Saturation:()=>xc,Sepia:()=>ic,Technicolor:()=>nc,Vibrance:()=>Sc,Vintage:()=>ec});export{gs as ActiveSelection,jo as BaseBrush,Ir as BaseFabricObject,ho as Canvas,_s as Canvas2dFilterBackend,qa as CanvasDOMManager,Fo as Circle,Io as CircleBrush,ps as ClipPathLayout,G as Color,q as Control,Uo as Ellipse,ws as FabricImage,ws as Image,J as FabricObject,J as Object,Q as FabricText,Q as Text,ia as FitContentLayout,ms as FixedLayout,ko as Gradient,ca as Group,ds as IText,_i as InteractiveFabricObject,Pr as Intersection,oa as LayoutManager,ra as LayoutStrategy,Bo as Line,be as Observable,Mo as Path,Ao as Pattern,Ro as PatternBrush,No as PencilBrush,N as Point,Ko as Polygon,Go as Polyline,$i as Rect,Bn as Shadow,Lo as SprayBrush,yt as StaticCanvas,dt as StaticCanvasDOMManager,fs as Textbox,Vo as Triangle,vs as WebGLFilterBackend,y as cache,M as classRegistry,o as config,co as controlsUtils,Ee as createCollectionMixin,Cc as filters,h as getEnv,g as getFabricDocument,_ as getFabricWindow,xs as getFilterBackend,T as iMatrix,bs as initFilterBackend,Bs as isPutImageFaster,zs as isWebGLPipelineState,Ls as loadSVGFromString,Rs as loadSVGFromURL,Is as parseSVGDocument,ye as runningAnimations,m as setEnv,Ss as setFilterBackend,Ga as util,b as version};
|
||
|
|
//# sourceMappingURL=index.min.mjs.map
|