t2-model-skinner/docs/_next/static/chunks/e4e6678c9c61c198.js
2025-10-19 09:44:44 -07:00

1 line
453 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,88174,(t,e,i)=>{var n=t.i(67034),r=r||{version:"5.5.2"};if(i.fabric=r,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?r.document=document:r.document=document.implementation.createHTMLDocument(""),r.window=window;else{var s=new({}).JSDOM(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;r.document=s.document,r.jsdomImplForWrapper=void 0,r.nodeCanvas=void 0,r.window=s,DOMParser=r.window.DOMParser}function o(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var s=i.height-n.height;r.drawImage(i,0,s,n.width,n.height,0,0,n.width,n.height)}function a(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,s=n*r*4,o=new Uint8Array(this.imageBuffer,0,s),a=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,o);var l=new ImageData(a,n,r);i.putImageData(l,0,0)}r.isTouchSupported="ontouchstart"in r.window||"ontouchstart"in r.document||r.window&&r.window.navigator&&r.window.navigator.maxTouchPoints>0,r.isLikelyNode=void 0!==n.Buffer&&"undefined"==typeof window,r.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],r.DPI=96,r.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",r.commaWsp="(?:\\s+,?\\s*|,\\s*)",r.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/ig,r.reNonWord=/[ \n\.,;!\?\-]/,r.fontPaths={},r.iMatrix=[1,0,0,1,0,0],r.svgNS="http://www.w3.org/2000/svg",r.perfLimitSizeTotal=2097152,r.maxCacheSideLimit=4096,r.minCacheSideLimit=256,r.charWidthsCache={},r.textureSize=2048,r.disableStyleCopyPaste=!1,r.enableGLFiltering=!0,r.devicePixelRatio=r.window.devicePixelRatio||r.window.webkitDevicePixelRatio||r.window.mozDevicePixelRatio||1,r.browserShadowBlurConstant=1,r.arcToSegmentsCache={},r.boundsOfCurveCache={},r.cachesBoundsOfCurve=!0,r.forceGLPutImageData=!1,r.initFilterBackend=function(){return r.enableGLFiltering&&r.isWebglSupported&&r.isWebglSupported(r.textureSize)?(console.log("max texture size: "+r.maxTextureSize),new r.WebglFilterBackend({tileSize:r.textureSize})):r.Canvas2dFilterBackend?new r.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=r),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:r.util.array.fill(i,!1)}}function e(t,e){var i=(function(){e.apply(this,arguments),this.off(t,i)}).bind(this);this.on(t,i)}r.Observable={fire:function(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n<r;n++)i[n]&&i[n].call(this,e||{});return this.__eventListeners[t]=i.filter(function(t){return!1!==t}),this},on:function(t,e){if(this.__eventListeners||(this.__eventListeners={}),1==arguments.length)for(var i in t)this.on(i,t[i]);else this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e);return this},once:function(t,i){if(1==arguments.length)for(var n in t)e.call(this,n,t[n]);else e.call(this,t,i);return this},off:function(e,i){if(!this.__eventListeners)return this;if(0==arguments.length)for(e in this.__eventListeners)t.call(this,e);else if(1==arguments.length&&"object"==typeof arguments[0])for(var n in e)t.call(this,n,e[n]);else t.call(this,e,i);return this}}}(),r.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var t=0,e=arguments.length;t<e;t++)this._onObjectAdded(arguments[t]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(t,e,i){var n=this._objects;return i?n[e]=t:n.splice(e,0,t),this._onObjectAdded&&this._onObjectAdded(t),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var t,e=this._objects,i=!1,n=0,r=arguments.length;n<r;n++)t=e.indexOf(arguments[n]),-1!==t&&(i=!0,e.splice(t,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[n]));return this.renderOnAddRemove&&i&&this.requestRenderAll(),this},forEachObject:function(t,e){for(var i=this.getObjects(),n=0,r=i.length;n<r;n++)t.call(e,i[n],n,i);return this},getObjects:function(t){return void 0===t?this._objects.concat():this._objects.filter(function(e){return e.type===t})},item:function(t){return this._objects[t]},isEmpty:function(){return 0===this._objects.length},size:function(){return this._objects.length},contains:function(t,e){return this._objects.indexOf(t)>-1||!!e&&this._objects.some(function(e){return"function"==typeof e.contains&&e.contains(t,!0)})},complexity:function(){return this._objects.reduce(function(t,e){return t+(e.complexity?e.complexity():0)},0)}},r.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof r.Gradient||this.set(e,new r.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof r.Pattern?i&&i():this.set(e,new r.Pattern(t,i))},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},function(t){var e=Math.sqrt,i=Math.atan2,n=Math.pow,s=Math.PI/180,o=Math.PI/2;r.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/o){case 1:case 3:return 0;case 2:return -1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/o){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return -1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*s},radiansToDegrees:function(t){return t/s},rotatePoint:function(t,e,i){var n=new r.Point(t.x-e.x,t.y-e.y),s=r.util.rotateVector(n,i);return new r.Point(s.x,s.y).addEquals(e)},rotateVector:function(t,e){var i=r.util.sin(e),n=r.util.cos(e);return{x:t.x*n-t.y*i,y:t.x*i+t.y*n}},createVector:function(t,e){return new r.Point(e.x-t.x,e.y-t.y)},calcAngleBetweenVectors:function(t,e){return Math.acos((t.x*e.x+t.y*e.y)/(Math.hypot(t.x,t.y)*Math.hypot(e.x,e.y)))},getHatVector:function(t){return new r.Point(t.x,t.y).multiply(1/Math.hypot(t.x,t.y))},getBisector:function(t,e,i){var n=r.util.createVector(t,e),s=r.util.createVector(t,i),o=r.util.calcAngleBetweenVectors(n,s),a=r.util.calcAngleBetweenVectors(r.util.rotateVector(n,o),s);return{vector:r.util.getHatVector(r.util.rotateVector(n,o*(0===a?1:-1)/2)),angle:o}},projectStrokeOnPoints:function(t,e,i){var n=[],s=e.strokeWidth/2,o=e.strokeUniform?new r.Point(1/e.scaleX,1/e.scaleY):new r.Point(1,1),a=function(t){var e=s/Math.hypot(t.x,t.y);return new r.Point(t.x*e*o.x,t.y*e*o.y)};return t.length<=1||t.forEach(function(l,c){var h,u,f=new r.Point(l.x,l.y);0===c?(u=t[c+1],h=i?a(r.util.createVector(u,f)).addEquals(f):t[t.length-1]):c===t.length-1?(h=t[c-1],u=i?a(r.util.createVector(h,f)).addEquals(f):t[0]):(h=t[c-1],u=t[c+1]);var d,g,p=r.util.getBisector(f,h,u),m=p.vector,y=p.angle;if("miter"===e.strokeLineJoin&&(d=-s/Math.sin(y/2),Math.hypot((g=new r.Point(m.x*d*o.x,m.y*d*o.y)).x,g.y)/s<=e.strokeMiterLimit)){n.push(f.add(g)),n.push(f.subtract(g));return}d=-s*Math.SQRT2,g=new r.Point(m.x*d*o.x,m.y*d*o.y),n.push(f.add(g)),n.push(f.subtract(g))}),n},transformPoint:function(t,e,i){return i?new r.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new r.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i<t.length;i++)t[i]=r.util.transformPoint(t[i],e);var n=[t[0].x,t[1].x,t[2].x,t[3].x],s=r.util.array.min(n),o=r.util.array.max(n),a=[t[0].y,t[1].y,t[2].y,t[3].y],l=r.util.array.min(a);return{left:s,top:l,width:o-s,height:r.util.array.max(a)-l}},invertTransform:function(t){var e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0]],n=r.util.transformPoint({x:t[4],y:t[5]},i,!0);return i[4]=-n.x,i[5]=-n.y,i},toFixed:function(t,e){return parseFloat(Number(t).toFixed(e))},parseUnit:function(t,e){var i=/\D{0,2}$/.exec(t),n=parseFloat(t);switch(!e&&(e=r.Text.DEFAULT_SVG_FONT_SIZE),i[0]){case"mm":return n*r.DPI/25.4;case"cm":return n*r.DPI/2.54;case"in":return n*r.DPI;case"pt":return n*r.DPI/72;case"pc":return n*r.DPI/72*12;case"em":return n*e;default:return n}},falseFunction:function(){return!1},getKlass:function(t,e){return t=r.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),r.util.resolveNamespace(e)[t]},getSvgAttributes:function(t){var e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":e=e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":e=e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":e=e.concat(["offset","stop-color","stop-opacity"])}return e},resolveNamespace:function(e){if(!e)return r;var i,n=e.split("."),s=n.length,o=t||r.window;for(i=0;i<s;++i)o=o[n[i]];return o},loadImage:function(t,e,i,n){if(!t){e&&e.call(i,t);return}var s=r.util.createImage(),o=function(){e&&e.call(i,s,!1),s=s.onload=s.onerror=null};s.onload=o,s.onerror=function(){r.log("Error loading "+s.src),e&&e.call(i,null,!0),s=s.onload=s.onerror=null},0!==t.indexOf("data")&&null!=n&&(s.crossOrigin=n),"data:image/svg"===t.substring(0,14)&&(s.onload=null,r.util.loadImageInDom(s,o)),s.src=t},loadImageInDom:function(t,e){var i=r.document.createElement("div");i.style.width=i.style.height="1px",i.style.left=i.style.top="-100%",i.style.position="absolute",i.appendChild(t),r.document.querySelector("body").appendChild(i),t.onload=function(){e(),i.parentNode.removeChild(i),i=null}},enlivenObjects:function(t,e,i,n){var s=[],o=0,a=(t=t||[]).length;function l(){++o===a&&e&&e(s.filter(function(t){return t}))}if(!a){e&&e(s);return}t.forEach(function(t,e){if(!t||!t.type)return void l();r.util.getKlass(t.type,i).fromObject(t,function(i,r){r||(s[e]=i),n&&n(t,i,r),l()})})},enlivenObjectEnlivables:function(t,e,i){var n=r.Object.ENLIVEN_PROPS.filter(function(e){return!!t[e]});r.util.enlivenObjects(n.map(function(e){return t[e]}),function(t){var r={};n.forEach(function(i,n){r[i]=t[n],e&&(e[i]=t[n])}),i&&i(r)})},enlivenPatterns:function(t,e){function i(){++s===o&&e&&e(n)}var n=[],s=0,o=(t=t||[]).length;if(!o){e&&e(n);return}t.forEach(function(t,e){t&&t.source?new r.Pattern(t,function(t){n[e]=t,i()}):(n[e]=t,i())})},groupSVGElements:function(t,e,i){var n;return t&&1===t.length?(void 0!==i&&(t[0].sourcePath=i),t[0]):(e&&(e.width&&e.height?e.centerPoint={x:e.width/2,y:e.height/2}:(delete e.width,delete e.height)),n=new r.Group(t,e),void 0!==i&&(n.sourcePath=i),n)},populateWithProperties:function(t,e,i){if(i&&Array.isArray(i))for(var n=0,r=i.length;n<r;n++)i[n]in t&&(e[i[n]]=t[i[n]])},createCanvasElement:function(){return r.document.createElement("canvas")},copyCanvasElement:function(t){var e=r.util.createCanvasElement();return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e},toDataURL:function(t,e,i){return t.toDataURL("image/"+e,i)},createImage:function(){return r.document.createElement("img")},multiplyTransformMatrices:function(t,e,i){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]]},qrDecompose:function(t){var r=i(t[1],t[0]),o=n(t[0],2)+n(t[1],2),a=e(o),l=(t[0]*t[3]-t[2]*t[1])/a;return{angle:r/s,scaleX:a,scaleY:l,skewX:i(t[0]*t[2]+t[1]*t[3],o)/s,skewY:0,translateX:t[4],translateY:t[5]}},calcRotateMatrix:function(t){if(!t.angle)return r.iMatrix.concat();var e=r.util.degreesToRadians(t.angle),i=r.util.cos(e),n=r.util.sin(e);return[i,n,-n,i,0,0]},calcDimensionsMatrix:function(t){var e=void 0===t.scaleX?1:t.scaleX,i=void 0===t.scaleY?1:t.scaleY,n=[t.flipX?-e:e,0,0,t.flipY?-i:i,0,0],s=r.util.multiplyTransformMatrices,o=r.util.degreesToRadians;return t.skewX&&(n=s(n,[1,0,Math.tan(o(t.skewX)),1],!0)),t.skewY&&(n=s(n,[1,Math.tan(o(t.skewY)),0,1],!0)),n},composeMatrix:function(t){var e=[1,0,0,1,t.translateX||0,t.translateY||0],i=r.util.multiplyTransformMatrices;return t.angle&&(e=i(e,r.util.calcRotateMatrix(t))),(1!==t.scaleX||1!==t.scaleY||t.skewX||t.skewY||t.flipX||t.flipY)&&(e=i(e,r.util.calcDimensionsMatrix(t))),e},resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},saveObjectTransform:function(t){return{scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}},isTransparent:function(t,e,i,n){n>0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,s=!0,o=t.getImageData(e,i,2*n||1,2*n||1),a=o.data.length;for(r=3;r<a&&!1!=(s=o.data[r]<=0);r+=4);return o=null,s},parsePreserveAspectRatioAttribute:function(t){var e,i="meet",n="Mid",r=t.split(" ");return r&&r.length&&("meet"!==(i=r.pop())&&"slice"!==i?(e=i,i="meet"):r.length&&(e=r.pop())),{meetOrSlice:i,alignX:n="none"!==e?e.slice(1,4):"none",alignY:"none"!==e?e.slice(5,8):"none"}},clearFabricFontCache:function(t){(t=(t||"").toLowerCase())?r.charWidthsCache[t]&&delete r.charWidthsCache[t]:r.charWidthsCache={}},limitDimsByArea:function(t,e){var i=Math.sqrt(e*t),n=Math.floor(e/i);return{x:Math.floor(i),y:n}},capValue:function(t,e,i){return Math.max(t,Math.min(e,i))},findScaleToFit:function(t,e){return Math.min(e.width/t.width,e.height/t.height)},findScaleToCover:function(t,e){return Math.max(e.width/t.width,e.height/t.height)},matrixToSVG:function(t){return"matrix("+t.map(function(t){return r.util.toFixed(t,r.Object.NUM_FRACTION_DIGITS)}).join(" ")+")"},removeTransformFromObject:function(t,e){var i=r.util.invertTransform(e),n=r.util.multiplyTransformMatrices(i,t.calcOwnMatrix());r.util.applyTransformToObject(t,n)},addTransformToObject:function(t,e){r.util.applyTransformToObject(t,r.util.multiplyTransformMatrices(e,t.calcOwnMatrix()))},applyTransformToObject:function(t,e){var i=r.util.qrDecompose(e),n=new r.Point(i.translateX,i.translateY);t.flipX=!1,t.flipY=!1,t.set("scaleX",i.scaleX),t.set("scaleY",i.scaleY),t.skewX=i.skewX,t.skewY=i.skewY,t.angle=i.angle,t.setPositionByOrigin(n,"center","center")},sizeAfterTransform:function(t,e,i){var n=t/2,s=e/2,o=r.util.calcDimensionsMatrix(i),a=r.util.makeBoundingBoxFromPoints([{x:-n,y:-s},{x:n,y:-s},{x:-n,y:s},{x:n,y:s}],o);return{x:a.width,y:a.height}},mergeClipPaths:function(t,e){var i=t,n=e;i.inverted&&!n.inverted&&(i=e,n=t),r.util.applyTransformToObject(n,r.util.multiplyTransformMatrices(r.util.invertTransform(i.calcTransformMatrix()),n.calcTransformMatrix()));var s=i.inverted&&n.inverted;return s&&(i.inverted=n.inverted=!1),new r.Group([i],{clipPath:n,inverted:s})},hasStyleChanged:function(t,e,i){return i=i||!1,t.fill!==e.fill||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth||t.fontSize!==e.fontSize||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||i&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},stylesToArray:function(t,e){for(var t=r.util.object.clone(t,!0),i=e.split("\n"),n=-1,s={},o=[],a=0;a<i.length;a++){if(!t[a]){n+=i[a].length;continue}for(var l=0;l<i[a].length;l++){n++;var c=t[a][l];c&&Object.keys(c).length>0&&(r.util.hasStyleChanged(s,c,!0)?o.push({start:n,end:n+1,style:c}):o[o.length-1].end++),s=c||{}}}return o},stylesFromArray:function(t,e){if(!Array.isArray(t))return t;for(var i=e.split("\n"),n=-1,r=0,s={},o=0;o<i.length;o++)for(var a=0;a<i[o].length;a++)n++,t[r]&&t[r].start<=n&&n<t[r].end&&(s[o]=s[o]||{},s[o][a]=Object.assign({},t[r].style),n===t[r].end-1&&r++);return s}}}(i),function(){var t=Array.prototype.join,e={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},i={m:"l",M:"L"};function n(t,e,i,n){var r=Math.atan2(e,t),s=Math.atan2(n,i);return s>=r?s-r:2*Math.PI-(r-s)}function s(t,e,i,n){return Math.sqrt((i-t)*(i-t)+(n-e)*(n-e))}function o(t,e,i){var n,r,o={x:e,y:i},a=0;for(r=1;r<=100;r+=1)n=t(r/100),a+=s(o.x,o.y,n.x,n.y),o=n;return a}function a(t){for(var e,i,n,r,a=0,l=t.length,c=0,h=0,u=0,f=0,d=[],g=0;g<l;g++){switch(n={x:c,y:h,command:(e=t[g])[0]},e[0]){case"M":n.length=0,u=c=e[1],f=h=e[2];break;case"L":n.length=s(c,h,e[1],e[2]),c=e[1],h=e[2];break;case"C":i=function(t,e,i,n,r,s,o,a){return function(l){var c=l*l*l,h=3*l*l*(1-l),u=3*l*(1-l)*(1-l),f=(1-l)*(1-l)*(1-l);return{x:o*c+r*h+i*u+t*f,y:a*c+s*h+n*u+e*f}}}(c,h,e[1],e[2],e[3],e[4],e[5],e[6]),r=function(t,e,i,n,r,s,o,a){return function(l){var c=1-l;return Math.atan2(3*c*c*(n-e)+6*c*l*(s-n)+3*l*l*(a-s),3*c*c*(i-t)+6*c*l*(r-i)+3*l*l*(o-r))}}(c,h,e[1],e[2],e[3],e[4],e[5],e[6]),n.iterator=i,n.angleFinder=r,n.length=o(i,c,h),c=e[5],h=e[6];break;case"Q":i=function(t,e,i,n,r,s){return function(o){var a=o*o,l=2*o*(1-o),c=(1-o)*(1-o);return{x:r*a+i*l+t*c,y:s*a+n*l+e*c}}}(c,h,e[1],e[2],e[3],e[4]),r=function(t,e,i,n,r,s){return function(o){var a=1-o;return Math.atan2(2*a*(n-e)+2*o*(s-n),2*a*(i-t)+2*o*(r-i))}}(c,h,e[1],e[2],e[3],e[4]),n.iterator=i,n.angleFinder=r,n.length=o(i,c,h),c=e[3],h=e[4];break;case"Z":case"z":n.destX=u,n.destY=f,n.length=s(c,h,u,f),c=u,h=f}a+=n.length,d.push(n)}return d.push({length:a,x:c,y:h}),d}r.util.joinPath=function(t){return t.map(function(t){return t.join(" ")}).join(" ")},r.util.parsePath=function(t){var n,s,o,a,l,c=[],h=[],u=r.rePathCommand,f="[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?\\s*",d="("+f+")"+r.commaWsp,g="([01])"+r.commaWsp+"?",p=RegExp(d+"?"+d+"?"+d+g+g+d+"?("+f+")","g");if(!t||!t.match)return c;l=t.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi);for(var m,y=0,b=l.length;y<b;y++){a=(n=l[y]).slice(1).trim(),h.length=0;var x,_=n.charAt(0);if(m=[_],"a"===_.toLowerCase())for(;x=p.exec(a);)for(var C=1;C<x.length;C++)h.push(x[C]);else for(;o=u.exec(a);)h.push(o[0]);for(var C=0,S=h.length;C<S;C++)isNaN(s=parseFloat(h[C]))||m.push(s);var w=e[_.toLowerCase()],T=i[_]||_;if(m.length-1>w)for(var O=1,k=m.length;O<k;O+=w)c.push([_].concat(m.slice(O,O+w))),_=T;else c.push(m)}return c},r.util.makePathSimpler=function(t){var e,i,s,o,a,l,c=0,h=0,u=t.length,f=0,d=0,g=[];for(i=0;i<u;++i){switch(s=!1,(e=t[i].slice(0))[0]){case"l":e[0]="L",e[1]+=c,e[2]+=h;case"L":c=e[1],h=e[2];break;case"h":e[1]+=c;case"H":e[0]="L",e[2]=h,c=e[1];break;case"v":e[1]+=h;case"V":e[0]="L",h=e[1],e[1]=c,e[2]=h;break;case"m":e[0]="M",e[1]+=c,e[2]+=h;case"M":c=e[1],h=e[2],f=e[1],d=e[2];break;case"c":e[0]="C",e[1]+=c,e[2]+=h,e[3]+=c,e[4]+=h,e[5]+=c,e[6]+=h;case"C":a=e[3],l=e[4],c=e[5],h=e[6];break;case"s":e[0]="S",e[1]+=c,e[2]+=h,e[3]+=c,e[4]+=h;case"S":"C"===o?(a=2*c-a,l=2*h-l):(a=c,l=h),c=e[3],h=e[4],e[0]="C",e[5]=e[3],e[6]=e[4],e[3]=e[1],e[4]=e[2],e[1]=a,e[2]=l,a=e[3],l=e[4];break;case"q":e[0]="Q",e[1]+=c,e[2]+=h,e[3]+=c,e[4]+=h;case"Q":a=e[1],l=e[2],c=e[3],h=e[4];break;case"t":e[0]="T",e[1]+=c,e[2]+=h;case"T":"Q"===o?(a=2*c-a,l=2*h-l):(a=c,l=h),e[0]="Q",c=e[1],h=e[2],e[1]=a,e[2]=l,e[3]=c,e[4]=h;break;case"a":e[0]="A",e[6]+=c,e[7]+=h;case"A":s=!0,g=g.concat(function(t,e,i){for(var s=i[1],o=i[2],a=i[3],l=i[4],c=i[5],h=function(t,e,i,s,o,a,l){var c=Math.PI,h=l*c/180,u=r.util.sin(h),f=r.util.cos(h),d=0,g=0,p=-f*t*.5-u*e*.5,m=-f*e*.5+u*t*.5,y=(i=Math.abs(i))*i,b=(s=Math.abs(s))*s,x=m*m,_=p*p,C=y*b-y*x-b*_,S=0;if(C<0){var w=Math.sqrt(1-C/(y*b));i*=w,s*=w}else S=(o===a?-1:1)*Math.sqrt(C/(y*x+b*_));var T=S*i*m/s,O=-S*s*p/i,k=f*T-u*O+.5*t,E=u*T+f*O+.5*e,j=n(1,0,(p-T)/i,(m-O)/s),M=n((p-T)/i,(m-O)/s,(-p-T)/i,(-m-O)/s);0===a&&M>0?M-=2*c:1===a&&M<0&&(M+=2*c);for(var P=Math.ceil(Math.abs(M/c*2)),A=[],D=M/P,F=8/3*Math.sin(D/4)*Math.sin(D/4)/Math.sin(D/2),R=j+D,L=0;L<P;L++)A[L]=function(t,e,i,n,s,o,a,l,c,h,u){var f=r.util.cos(t),d=r.util.sin(t),g=r.util.cos(e),p=r.util.sin(e),m=i*s*g-n*o*p+a,y=n*s*g+i*o*p+l;return["C",h+c*(-i*s*d-n*o*f),u+c*(-n*s*d+i*o*f),m+c*(i*s*p+n*o*g),y+c*(n*s*p-i*o*g),m,y]}(j,R,f,u,i,s,k,E,F,d,g),d=A[L][5],g=A[L][6],j=R,R+=D;return A}(i[6]-t,i[7]-e,s,o,l,c,a),u=0,f=h.length;u<f;u++)h[u][1]+=t,h[u][2]+=e,h[u][3]+=t,h[u][4]+=e,h[u][5]+=t,h[u][6]+=e;return h}(c,h,e)),c=e[6],h=e[7];break;case"z":case"Z":c=f,h=d}s||g.push(e),o=e[0]}return g},r.util.getSmoothPathFromPoints=function(t,e){var i,n=[],s=new r.Point(t[0].x,t[0].y),o=new r.Point(t[1].x,t[1].y),a=t.length,l=1,c=0,h=a>2;for(e=e||0,h&&(l=t[2].x<o.x?-1:+(t[2].x!==o.x),c=t[2].y<o.y?-1:+(t[2].y!==o.y)),n.push(["M",s.x-l*e,s.y-c*e]),i=1;i<a;i++){if(!s.eq(o)){var u=s.midPointFrom(o);n.push(["Q",s.x,s.y,u.x,u.y])}s=t[i],i+1<t.length&&(o=t[i+1])}return h&&(l=s.x>t[i-2].x?1:s.x===t[i-2].x?0:-1,c=s.y>t[i-2].y?1:s.y===t[i-2].y?0:-1),n.push(["L",s.x+l*e,s.y+c*e]),n},r.util.getPathSegmentsInfo=a,r.util.getBoundsOfCurve=function(e,i,n,s,o,a,l,c){if(r.cachesBoundsOfCurve&&(h=t.call(arguments),r.boundsOfCurveCache[h]))return r.boundsOfCurveCache[h];var h,u,f,d,g,p,m,y,b,x=Math.sqrt,_=Math.min,C=Math.max,S=Math.abs,w=[],T=[[],[]];f=6*e-12*n+6*o,u=-3*e+9*n-9*o+3*l,d=3*n-3*e;for(var O=0;O<2;++O){if(O>0&&(f=6*i-12*s+6*a,u=-3*i+9*s-9*a+3*c,d=3*s-3*i),1e-12>S(u)){if(1e-12>S(f))continue;0<(g=-d/f)&&g<1&&w.push(g);continue}!((y=f*f-4*d*u)<0)&&(0<(p=(-f+(b=x(y)))/(2*u))&&p<1&&w.push(p),0<(m=(-f-b)/(2*u))&&m<1&&w.push(m))}for(var k,E,j,M=w.length,P=M;M--;)k=(j=1-(g=w[M]))*j*j*e+3*j*j*g*n+3*j*g*g*o+g*g*g*l,T[0][M]=k,E=j*j*j*i+3*j*j*g*s+3*j*g*g*a+g*g*g*c,T[1][M]=E;T[0][P]=e,T[1][P]=i,T[0][P+1]=l,T[1][P+1]=c;var A=[{x:_.apply(null,T[0]),y:_.apply(null,T[1])},{x:C.apply(null,T[0]),y:C.apply(null,T[1])}];return r.cachesBoundsOfCurve&&(r.boundsOfCurveCache[h]=A),A},r.util.getPointOnPath=function(t,e,i){i||(i=a(t));for(var n=0;e-i[n].length>0&&n<i.length-2;)e-=i[n].length,n++;var o,l=i[n],c=e/l.length,h=l.command,u=t[n];switch(h){case"M":return{x:l.x,y:l.y,angle:0};case"Z":case"z":return(o=new r.Point(l.x,l.y).lerp(new r.Point(l.destX,l.destY),c)).angle=Math.atan2(l.destY-l.y,l.destX-l.x),o;case"L":return(o=new r.Point(l.x,l.y).lerp(new r.Point(u[1],u[2]),c)).angle=Math.atan2(u[2]-l.y,u[1]-l.x),o;case"C":case"Q":return function(t,e){for(var i,n,r,o=0,a=0,l=t.iterator,c={x:t.x,y:t.y},h=.01,u=t.angleFinder;a<e&&h>1e-4;)i=l(o),r=o,(n=s(c.x,c.y,i.x,i.y))+a>e?(o-=h,h/=2):(c=i,o+=h,a+=n);return i.angle=u(r),i}(l,e)}},r.util.transformPath=function(t,e,i){return i&&(e=r.util.multiplyTransformMatrices(e,[1,0,0,1,-i.x,-i.y])),t.map(function(t){for(var i=t.slice(0),n={},s=1;s<t.length-1;s+=2)n.x=t[s],n.y=t[s+1],n=r.util.transformPoint(n,e),i[s]=n.x,i[s+1]=n.y;return i})}}(),function(){var t=Array.prototype.slice;function e(t,e,i){if(t&&0!==t.length){var n=t.length-1,r=e?t[n][e]:t[n];if(e)for(;n--;)i(t[n][e],r)&&(r=t[n][e]);else for(;n--;)i(t[n],r)&&(r=t[n]);return r}}r.util.array={fill:function(t,e){for(var i=t.length;i--;)t[i]=e;return t},invoke:function(e,i){for(var n=t.call(arguments,2),r=[],s=0,o=e.length;s<o;s++)r[s]=n.length?e[s][i].apply(e[s],n):e[s][i].call(e[s]);return r},min:function(t,i){return e(t,i,function(t,e){return t<e})},max:function(t,i){return e(t,i,function(t,e){return t>=e})}}}(),function(){function t(e,i,n){if(n)if(!r.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var s=0,o=i.length;s<o;s++)e[s]=t({},i[s],n)}else if(i&&"object"==typeof i)for(var a in i)"canvas"===a||"group"===a?e[a]=null:i.hasOwnProperty(a)&&(e[a]=t({},i[a],n));else e=i;else for(var a in i)e[a]=i[a];return e}r.util.object={extend:t,clone:function(e,i){return t({},e,i)}},r.util.object.extend(r.util,r.Observable)}(),r.util.string={camelize:function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},graphemeSplit:function(t){var e,i=0,n=[];for(i=0;i<t.length;i++)!1!==(e=function(t,e){var i=t.charCodeAt(e);if(isNaN(i))return"";if(i<55296||i>57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}(t,i))&&n.push(e);return n}},function(){var t=Array.prototype.slice,e=function(){},i=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),n=function(t,e,n){for(var r in e)r in t.prototype&&"function"==typeof t.prototype[r]&&(e[r]+"").indexOf("callSuper")>-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function s(){}function o(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}r.util.createClass=function(){var i=null,r=t.call(arguments,0);function a(){this.initialize.apply(this,arguments)}"function"==typeof r[0]&&(i=r.shift()),a.superclass=i,a.subclasses=[],i&&(s.prototype=i.prototype,a.prototype=new s,i.subclasses.push(a));for(var l=0,c=r.length;l<c;l++)n(a,r[l],i);return a.prototype.initialize||(a.prototype.initialize=e),a.prototype.constructor=a,a.prototype.callSuper=o,a}}(),function(){var t=!!r.document.createElement("div").attachEvent,e=["touchstart","touchmove","touchend"];r.util.addListener=function(e,i,n,r){e&&e.addEventListener(i,n,!t&&r)},r.util.removeListener=function(e,i,n,r){e&&e.removeEventListener(i,n,!t&&r)},r.util.getPointer=function(t){var e,i=t.target,n=r.util.getScrollLeftTop(i),s=(e=t.changedTouches)&&e[0]?e[0]:t;return{x:s.clientX+n.left,y:s.clientY+n.top}},r.util.isTouchEvent=function(t){return e.indexOf(t.type)>-1||"touch"===t.pointerType}}(),function(){var t=r.document.createElement("div"),e="string"==typeof t.style.opacity,i="string"==typeof t.style.filter,n=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,s=function(t){return t};e?s=function(t,e){return t.style.opacity=e,t}:i&&(s=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),n.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(n,e)):i.filter+=" alpha(opacity="+100*e+")",t}),r.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?s(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)if("opacity"===n)s(t,e[n]);else{var r="float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n;i.setProperty(r,e[n])}return t}}(),function(){var t,e,i,n,s=Array.prototype.slice,o=function(t){return s.call(t,0)};try{n=o(r.document.childNodes)instanceof Array}catch(t){}function a(t,e){var i=r.document.createElement(t);for(var n in e)"class"===n?i.className=e[n]:"for"===n?i.htmlFor=e[n]:i.setAttribute(n,e[n]);return i}function l(t){for(var e=0,i=0,n=r.document.documentElement,s=r.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===r.document?(e=s.scrollLeft||n.scrollLeft||0,i=s.scrollTop||n.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}n||(o=function(t){for(var e=Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),i=r.document.defaultView&&r.document.defaultView.getComputedStyle?function(t,e){var i=r.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},e="userSelect"in(t=r.document.documentElement.style)?"userSelect":"MozUserSelect"in t?"MozUserSelect":"WebkitUserSelect"in t?"WebkitUserSelect":"KhtmlUserSelect"in t?"KhtmlUserSelect":"",r.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=r.util.falseFunction),e?t.style[e]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},r.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),e?t.style[e]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},r.util.setImageSmoothing=function(t,e){t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=e},r.util.getById=function(t){return"string"==typeof t?r.document.getElementById(t):t},r.util.toArray=o,r.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},r.util.makeElement=a,r.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=a(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},r.util.getScrollLeftTop=l,r.util.getElementOffset=function(t){var e,n,r=t&&t.ownerDocument,s={left:0,top:0},o={left:0,top:0},a={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return o;for(var c in a)o[a[c]]+=parseInt(i(t,c),10)||0;return e=r.documentElement,void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect()),n=l(t),{left:s.left+n.left-(e.clientLeft||0)+o.left,top:s.top+n.top-(e.clientTop||0)+o.top}},r.util.getNodeCanvas=function(t){var e=r.jsdomImplForWrapper(t);return e._canvas||e._image},r.util.cleanUpJsdomNode=function(t){if(r.isLikelyNode){var e=r.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}r.util.request=function(e,i){i||(i={});var n,s,o=i.method?i.method.toUpperCase():"GET",a=i.onComplete||function(){},l=new r.window.XMLHttpRequest,c=i.body||i.parameters;return l.onreadystatechange=function(){4===l.readyState&&(a(l),l.onreadystatechange=t)},"GET"===o&&(c=null,"string"==typeof i.parameters&&(n=e,s=i.parameters,e=n+(/\?/.test(n)?"&":"?")+s)),l.open(o,e,!0),("POST"===o||"PUT"===o)&&l.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),l.send(c),l}}(),r.log=console.log,r.warn=console.warn,function(){var t=r.util.object.extend,e=r.util.object.clone,i=[];function n(){return!1}function s(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}r.util.object.extend(i,{cancelAll:function(){var t=this.splice(0);return t.forEach(function(t){t.cancel()}),t},cancelByCanvas:function(t){if(!t)return[];var e=this.filter(function(e){return"object"==typeof e.target&&e.target.canvas===t});return e.forEach(function(t){t.cancel()}),e},cancelByTarget:function(t){var e=this.findAnimationsByTarget(t);return e.forEach(function(t){t.cancel()}),e},findAnimationIndex:function(t){return this.indexOf(this.findAnimation(t))},findAnimation:function(t){return this.find(function(e){return e.cancel===t})},findAnimationsByTarget:function(t){return t?this.filter(function(e){return e.target===t}):[]}});var o=r.window.requestAnimationFrame||r.window.webkitRequestAnimationFrame||r.window.mozRequestAnimationFrame||r.window.oRequestAnimationFrame||r.window.msRequestAnimationFrame||function(t){return r.window.setTimeout(t,1e3/60)},a=r.window.cancelAnimationFrame||r.window.clearTimeout;function l(){return o.apply(r.window,arguments)}r.util.animate=function(i){i||(i={});var o,a=!1,c=function(){var t=r.runningAnimations.indexOf(o);return t>-1&&r.runningAnimations.splice(t,1)[0]};return o=t(e(i),{cancel:function(){return a=!0,c()},currentValue:"startValue"in i?i.startValue:0,completionRate:0,durationRate:0}),r.runningAnimations.push(o),l(function(t){var e,r=t||+new Date,h=i.duration||500,u=r+h,f=i.onChange||n,d=i.abort||n,g=i.onComplete||n,p=i.easing||s,m="startValue"in i&&i.startValue.length>0,y="startValue"in i?i.startValue:0,b="endValue"in i?i.endValue:100,x=i.byValue||(m?y.map(function(t,e){return b[e]-y[e]}):b-y);i.onStart&&i.onStart(),function t(i){var n=(e=i||+new Date)>u?h:e-r,s=n/h,_=m?y.map(function(t,e){return p(n,y[e],x[e],h)}):p(n,y,x,h),C=m?Math.abs((_[0]-y[0])/x[0]):Math.abs((_-y)/x);if(o.currentValue=m?_.slice():_,o.completionRate=C,o.durationRate=s,!a){if(d(_,C,s))return void c();if(e>u){o.currentValue=m?b.slice():b,o.completionRate=1,o.durationRate=1,f(m?b.slice():b,1,1),g(b,1,1),c();return}f(_,C,s),l(t)}}(r)}),o.cancel},r.util.requestAnimFrame=l,r.util.cancelAnimFrame=function(){return a.apply(r.window,arguments)},r.runningAnimations=i}(),function(){function t(t,e,i){var n="rgba("+parseInt(t[0]+i*(e[0]-t[0]),10)+","+parseInt(t[1]+i*(e[1]-t[1]),10)+","+parseInt(t[2]+i*(e[2]-t[2]),10);return n+(","+(t&&e?parseFloat(t[3]+i*(e[3]-t[3])):1)+")")}r.util.animateColor=function(e,i,n,s){var o=new r.Color(e).getSource(),a=new r.Color(i).getSource(),l=s.onComplete,c=s.onChange;return s=s||{},r.util.animate(r.util.object.extend(s,{duration:n||500,startValue:o,endValue:a,byValue:a,easing:function(e,i,n,r){return t(i,n,s.colorEasing?s.colorEasing(e,r):1-Math.cos(e/r*(Math.PI/2)))},onComplete:function(e,i,n){if(l)return l(t(a,a,0),i,n)},onChange:function(e,i,n){if(c){if(Array.isArray(e))return c(t(e,e,0),i,n);c(e,i,n)}}}))}}(),function(){function t(t,e,i,n){return t<Math.abs(e)?(t=e,n=i/4):n=0===e&&0===t?i/(2*Math.PI)*Math.asin(1):i/(2*Math.PI)*Math.asin(e/t),{a:t,c:e,p:i,s:n}}function e(t,e,i){return t.a*Math.pow(2,10*(e-=1))*Math.sin((e*i-t.s)*(2*Math.PI)/t.p)}function i(t,e,i,r){return i-n(r-t,0,i,r)+e}function n(t,e,i,n){return(t/=n)<1/2.75?7.5625*t*t*i+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e}r.util.ease={easeInQuad:function(t,e,i,n){return i*(t/=n)*t+e},easeOutQuad:function(t,e,i,n){return-i*(t/=n)*(t-2)+e},easeInOutQuad:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,n){return i*(t/=n)*t*t+e},easeOutCubic:function(t,e,i,n){return i*((t=t/n-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,n){return i*(t/=n)*t*t*t+e},easeOutQuart:function(t,e,i,n){return-i*((t=t/n-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,n){return i*(t/=n)*t*t*t*t+e},easeOutQuint:function(t,e,i,n){return i*((t=t/n-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,n){return i*Math.sin(t/n*(Math.PI/2))+e},easeInOutSine:function(t,e,i,n){return-i/2*(Math.cos(Math.PI*t/n)-1)+e},easeInExpo:function(t,e,i,n){return 0===t?e:i*Math.pow(2,10*(t/n-1))+e},easeOutExpo:function(t,e,i,n){return t===n?e+i:i*(-Math.pow(2,-10*t/n)+1)+e},easeInOutExpo:function(t,e,i,n){return 0===t?e:t===n?e+i:(t/=n/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(-Math.pow(2,-10*--t)+2)+e},easeInCirc:function(t,e,i,n){return-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOutCirc:function(t,e,i,n){return i*Math.sqrt(1-(t=t/n-1)*t)+e},easeInOutCirc:function(t,e,i,n){return(t/=n/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(i,n,r,s){var o=0;return 0===i?n:1==(i/=s)?n+r:(o||(o=.3*s),-e(t(r,r,o,1.70158),i,s)+n)},easeOutElastic:function(e,i,n,r){var s=0;if(0===e)return i;if(1==(e/=r))return i+n;s||(s=.3*r);var o=t(n,n,s,1.70158);return o.a*Math.pow(2,-10*e)*Math.sin((e*r-o.s)*(2*Math.PI)/o.p)+o.c+i},easeInOutElastic:function(i,n,r,s){var o=0;if(0===i)return n;if(2==(i/=s/2))return n+r;o||(o=.3*1.5*s);var a=t(r,r,o,1.70158);return i<1?-.5*e(a,i,s)+n:a.a*Math.pow(2,-10*(i-=1))*Math.sin((i*s-a.s)*(2*Math.PI)/a.p)*.5+a.c+n},easeInBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),i*(t/=n)*t*((r+1)*t-r)+e},easeOutBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},easeInOutBack:function(t,e,i,n,r){return(void 0===r&&(r=1.70158),(t/=n/2)<1)?i/2*(t*t*(((r*=1.525)+1)*t-r))+e:i/2*((t-=2)*t*(((r*=1.525)+1)*t+r)+2)+e},easeInBounce:i,easeOutBounce:n,easeInOutBounce:function(t,e,r,s){return t<s/2?.5*i(2*t,0,r,s)+e:.5*n(2*t-s,0,r,s)+.5*r+e}}}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,s=e.util.parseUnit,o=e.util.multiplyTransformMatrices,a={cx:"left",x:"left",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"},l={stroke:"strokeOpacity",fill:"fillOpacity"},c="font-size",h="clip-path";function u(t){return RegExp("^("+t.join("|")+")\\b","i")}function f(t,e){var i,n,r,s,o=[];for(r=0,s=e.length;r<s;r++)i=e[r],n=t.getElementsByTagName(i),o=o.concat(Array.prototype.slice.call(n));return o}function d(t,e){var i,n,r=t.nodeName,s=t.getAttribute("class"),o=t.getAttribute("id");if(i=RegExp("^"+r,"i"),e=e.replace(i,""),o&&e.length&&(i=RegExp("#"+o+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")),s&&e.length)for(n=(s=s.split(" ")).length;n--;)i=RegExp("\\."+s[n]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"");return 0===e.length}function g(t,e){if(t.getElementById&&(i=t.getElementById(e)),i)return i;var i,n,r,s,o=t.getElementsByTagName("*");for(r=0,s=o.length;r<s;r++)if(e===(n=o[r]).getAttribute("id"))return n}e.svgValidTagNamesRegEx=u(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),e.svgViewBoxElementsRegEx=u(["symbol","image","marker","pattern","view","svg"]),e.svgInvalidAncestorsRegEx=u(["pattern","defs","symbol","metadata","clipPath","mask","desc"]),e.svgValidParentsRegEx=u(["symbol","g","a","svg","clipPath","defs"]),e.cssRules={},e.gradientDefs={},e.clipPaths={},e.parseTransformAttribute=function(){function t(t,i,n){t[n]=Math.tan(e.util.degreesToRadians(i[0]))}var i=e.iMatrix,n=e.reNum,r=e.commaWsp,s="(?:(rotate)\\s*\\(\\s*("+n+")(?:"+r+"("+n+")"+r+"("+n+"))?\\s*\\))",o="(?:(scale)\\s*\\(\\s*("+n+")(?:"+r+"("+n+"))?\\s*\\))",a="(?:(translate)\\s*\\(\\s*("+n+")(?:"+r+"("+n+"))?\\s*\\))",l="(?:"+("(?:(matrix)\\s*\\(\\s*("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n)+")\\s*\\))|"+a+"|"+o+"|"+s+"|(?:(skewX)\\s*\\(\\s*("+n+")\\s*\\))|(?:(skewY)\\s*\\(\\s*("+n+")\\s*\\)))",c=RegExp("^\\s*(?:"+("(?:"+l+"(?:"+r+"*"+l)+")*)?)\\s*$"),h=RegExp(l,"g");return function(n){var r=i.concat(),s=[];if(!n||n&&!c.test(n))return r;n.replace(h,function(n){var o,a,c,h,u,f,d,g,p,m=new RegExp(l).exec(n).filter(function(t){return!!t}),y=m[1],b=m.slice(2).map(parseFloat);switch(y){case"translate":(o=r)[4]=b[0],2===b.length&&(o[5]=b[1]);break;case"rotate":b[0]=e.util.degreesToRadians(b[0]),a=r,c=e.util.cos(b[0]),h=e.util.sin(b[0]),u=0,f=0,3===b.length&&(u=b[1],f=b[2]),a[0]=c,a[1]=h,a[2]=-h,a[3]=c,a[4]=u-(c*u-h*f),a[5]=f-(h*u+c*f);break;case"scale":d=r,g=b[0],p=2===b.length?b[1]:b[0],d[0]=g,d[3]=p;break;case"skewX":t(r,b,2);break;case"skewY":t(r,b,1);break;case"matrix":r=b}s.push(r.concat()),r=i.concat()});for(var o=s[0];s.length>1;)s.shift(),o=e.util.multiplyTransformMatrices(o,s[0]);return o}}();var p=RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function m(t){if(!e.svgViewBoxElementsRegEx.test(t.nodeName))return{};var i,n,r,o,a=t.getAttribute("viewBox"),l=1,c=1,h=0,u=0,f=t.getAttribute("width"),d=t.getAttribute("height"),g=t.getAttribute("x")||0,m=t.getAttribute("y")||0,y=t.getAttribute("preserveAspectRatio")||"",b=!a||!(a=a.match(p)),x=!f||!d||"100%"===f||"100%"===d,_=b&&x,C={},S="",w=0,T=0;if(C.width=0,C.height=0,C.toBeParsed=_,b&&(g||m)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(S=" translate("+s(g)+" "+s(m)+") ",r=(t.getAttribute("transform")||"")+S,t.setAttribute("transform",r),t.removeAttribute("x"),t.removeAttribute("y")),_)return C;if(b)return C.width=s(f),C.height=s(d),C;if(h=-parseFloat(a[1]),u=-parseFloat(a[2]),i=parseFloat(a[3]),n=parseFloat(a[4]),C.minX=h,C.minY=u,C.viewBoxWidth=i,C.viewBoxHeight=n,x?(C.width=i,C.height=n):(C.width=s(f),C.height=s(d),l=C.width/i,c=C.height/n),"none"!==(y=e.util.parsePreserveAspectRatioAttribute(y)).alignX&&("meet"===y.meetOrSlice&&(c=l=l>c?c:l),"slice"===y.meetOrSlice&&(c=l=l>c?l:c),w=C.width-i*l,T=C.height-n*l,"Mid"===y.alignX&&(w/=2),"Mid"===y.alignY&&(T/=2),"Min"===y.alignX&&(w=0),"Min"===y.alignY&&(T=0)),1===l&&1===c&&0===h&&0===u&&0===g&&0===m)return C;if((g||m)&&"#document"!==t.parentNode.nodeName&&(S=" translate("+s(g)+" "+s(m)+") "),r=S+" matrix("+l+" 0 0 "+c+" "+(h*l+w)+" "+(u*c+T)+") ","svg"===t.nodeName){for(o=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)o.appendChild(t.firstChild);t.appendChild(o)}else(o=t).removeAttribute("x"),o.removeAttribute("y"),r=o.getAttribute("transform")+r;return o.setAttribute("transform",r),C}e.parseSVGDocument=function(t,i,r,s){if(t){!function(t){for(var i=f(t,["use","svg:use"]),n=0;i.length&&n<i.length;){var r=i[n],s=r.getAttribute("xlink:href")||r.getAttribute("href");if(null===s)return;var o,a,l,c,h=s.slice(1),u=r.getAttribute("x")||0,d=r.getAttribute("y")||0,p=g(t,h).cloneNode(!0),y=(p.getAttribute("transform")||"")+" translate("+u+", "+d+")",b=i.length,x=e.svgNS;if(m(p),/^svg$/i.test(p.nodeName)){var _=p.ownerDocument.createElementNS(x,"g");for(a=0,c=(l=p.attributes).length;a<c;a++)o=l.item(a),_.setAttributeNS(x,o.nodeName,o.nodeValue);for(;p.firstChild;)_.appendChild(p.firstChild);p=_}for(a=0,c=(l=r.attributes).length;a<c;a++)"x"!==(o=l.item(a)).nodeName&&"y"!==o.nodeName&&"xlink:href"!==o.nodeName&&"href"!==o.nodeName&&("transform"===o.nodeName?y=o.nodeValue+" "+y:p.setAttribute(o.nodeName,o.nodeValue));p.setAttribute("transform",y),p.setAttribute("instantiated_by_use","1"),p.removeAttribute("id"),r.parentNode.replaceChild(p,r),i.length===b&&n++}}(t);var o,a,l=e.Object.__uid++,c=m(t),h=e.util.toArray(t.getElementsByTagName("*"));if(c.crossOrigin=s&&s.crossOrigin,c.svgUid=l,0===h.length&&e.isLikelyNode){h=t.selectNodes('//*[name(.)!="svg"]');var u=[];for(o=0,a=h.length;o<a;o++)u[o]=h[o];h=u}var d=h.filter(function(t){return m(t),e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))&&!function(t,e){for(;t&&(t=t.parentNode);)if(t.nodeName&&e.test(t.nodeName.replace("svg:",""))&&!t.getAttribute("instantiated_by_use"))return!0;return!1}(t,e.svgInvalidAncestorsRegEx)});if(!d||d&&!d.length){i&&i([],{});return}var p={};h.filter(function(t){return"clipPath"===t.nodeName.replace("svg:","")}).forEach(function(t){p[t.getAttribute("id")]=e.util.toArray(t.getElementsByTagName("*")).filter(function(t){return e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))})}),e.gradientDefs[l]=e.getGradientDefs(t),e.cssRules[l]=e.getCSSRules(t),e.clipPaths[l]=p,e.parseElements(d,function(t,n){i&&(i(t,c,n,h),delete e.gradientDefs[l],delete e.cssRules[l],delete e.clipPaths[l])},n(c),r,s)}};var y=RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+e.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+e.reNum+"))?\\s+(.*)");i(e,{parseFontDeclaration:function(t,e){var i=t.match(y);if(i){var n=i[1],r=i[3],o=i[4],a=i[5],l=i[6];n&&(e.fontStyle=n),r&&(e.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),o&&(e.fontSize=s(o)),l&&(e.fontFamily=l),a&&(e.lineHeight="normal"===a?1:a)}},getGradientDefs:function(t){var e,i=f(t,["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"]),n=0,r={};for(n=i.length;n--;)(e=i[n]).getAttribute("xlink:href")&&function t(e,i){var n="xlink:href",r=g(e,i.getAttribute(n).slice(1));if(r&&r.getAttribute(n)&&t(e,r),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach(function(t){r&&!i.hasAttribute(t)&&r.hasAttribute(t)&&i.setAttribute(t,r.getAttribute(t))}),!i.children.length)for(var s=r.cloneNode(!0);s.firstChild;)i.appendChild(s.firstChild);i.removeAttribute(n)}(t,e),r[e.getAttribute("id")]=e;return r},parseAttributes:function(t,n,u){if(t){var f,g,p,m={};void 0===u&&(u=t.getAttribute("svgUid")),t.parentNode&&e.svgValidParentsRegEx.test(t.parentNode.nodeName)&&(m=e.parseAttributes(t.parentNode,n,u));var y=n.reduce(function(e,i){return(f=t.getAttribute(i))&&(e[i]=f),e},{}),b=i(function(t,i){var n={};for(var r in e.cssRules[i])if(function(t,e){var i,n=!0;return(i=d(t,e.pop()))&&e.length&&(n=function(t,e){for(var i,n=!0;t.parentNode&&1===t.parentNode.nodeType&&e.length;)n&&(i=e.pop()),n=d(t=t.parentNode,i);return 0===e.length}(t,e)),i&&n&&0===e.length}(t,r.split(" ")))for(var s in e.cssRules[i][r])n[s]=e.cssRules[i][r][s];return n}(t,u),e.parseStyleAttribute(t));y=i(y,b),b[h]&&t.setAttribute(h,b[h]),g=p=m.fontSize||e.Text.DEFAULT_SVG_FONT_SIZE,y[c]&&(y[c]=g=s(y[c],p));var x,_,C={};for(var S in y)_=function(t,i,n,r){var a,l=Array.isArray(i);if(("fill"===t||"stroke"===t)&&"none"===i)i="";else if("strokeUniform"===t)return"non-scaling-stroke"===i;else if("strokeDashArray"===t)i="none"===i?null:i.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)i=n&&n.transformMatrix?o(n.transformMatrix,e.parseTransformAttribute(i)):e.parseTransformAttribute(i);else if("visible"===t)i="none"!==i&&"hidden"!==i,n&&!1===n.visible&&(i=!1);else if("opacity"===t)i=parseFloat(i),n&&void 0!==n.opacity&&(i*=n.opacity);else if("textAnchor"===t)i="start"===i?"left":"end"===i?"right":"center";else if("charSpacing"===t)a=s(i,r)/r*1e3;else if("paintFirst"===t){var c=i.indexOf("fill"),h=i.indexOf("stroke"),i="fill";c>-1&&h>-1&&h<c?i="stroke":-1===c&&h>-1&&(i="stroke")}else{if("href"===t||"xlink:href"===t||"font"===t)return i;if("imageSmoothing"===t)return"optimizeQuality"===i;a=l?i.map(s):s(i,r)}return!l&&isNaN(a)?i:a}(x=S in a?a[S]:S,y[S],m,g),C[x]=_;C&&C.font&&e.parseFontDeclaration(C.font,C);var w=i(m,C);return e.svgValidParentsRegEx.test(t.nodeName)?w:function(t){for(var i in l)if(void 0!==t[l[i]]&&""!==t[i]){if(void 0===t[i]){if(!e.Object.prototype[i])continue;t[i]=e.Object.prototype[i]}if(0!==t[i].indexOf("url(")){var n=new e.Color(t[i]);t[i]=n.setAlpha(r(n.getAlpha()*t[l[i]],2)).toRgba()}}return t}(w)}},parseElements:function(t,i,n,r,s){new e.ElementsParser(t,i,n,r,s).parse()},parseStyleAttribute:function(t){var e,i,n,r,s={},o=t.getAttribute("style");if(!o)return s;if("string"==typeof o)o.replace(/;\s*$/,"").split(";").forEach(function(t){var n=t.split(":");e=n[0].trim().toLowerCase(),i=n[1].trim(),s[e]=i});else{for(var a in o)void 0!==o[a]&&(n=a.toLowerCase(),r=o[a],s[n]=r)}return s},parsePointsAttribute:function(t){if(!t)return null;t=(t=t.replace(/,/g," ").trim()).split(/\s+/);var e,i,n=[];for(e=0,i=t.length;e<i;e+=2)n.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return n},getCSSRules:function(t){var i,n,r=t.getElementsByTagName("style"),s={};for(i=0,n=r.length;i<n;i++){var o=r[i].textContent;""!==(o=o.replace(/\/\*[\s\S]*?\*\//g,"")).trim()&&o.split("}").filter(function(t){return t.trim()}).forEach(function(t){var r=t.split("{"),o={},a=r[1].trim().split(";").filter(function(t){return t.trim()});for(i=0,n=a.length;i<n;i++){var l=a[i].split(":"),c=l[0].trim(),h=l[1].trim();o[c]=h}(t=r[0].trim()).split(",").forEach(function(t){""!==(t=t.replace(/^svg/i,"").trim())&&(s[t]?e.util.object.extend(s[t],o):s[t]=e.util.object.clone(o))})})}return s},loadSVGFromURL:function(t,i,n,r){t=t.replace(/^\n\s*/,"").trim(),new e.util.request(t,{method:"get",onComplete:function(t){var s=t.responseXML;if(!s||!s.documentElement)return i&&i(null),!1;e.parseSVGDocument(s.documentElement,function(t,e,n,r){i&&i(t,e,n,r)},n,r)}})},loadSVGFromString:function(t,i,n,r){var s=new e.window.DOMParser().parseFromString(t.trim(),"text/xml");e.parseSVGDocument(s.documentElement,function(t,e,n,r){i(t,e,n,r)},n,r)}})}(i),r.ElementsParser=function(t,e,i,n,r,s){this.elements=t,this.callback=e,this.options=i,this.reviver=n,this.svgUid=i&&i.svgUid||0,this.parsingOptions=r,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=s},function(t){t.parse=function(){this.instances=Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},t.createObjects=function(){var t=this;this.elements.forEach(function(e,i){e.setAttribute("svgUid",t.svgUid),t.createObject(e,i)})},t.findTag=function(t){return r[r.util.string.capitalize(t.tagName.replace("svg:",""))]},t.createObject=function(t,e){var i=this.findTag(t);if(i&&i.fromElement)try{i.fromElement(t,this.createCallback(e,t),this.options)}catch(t){r.log(t)}else this.checkIfDone()},t.createCallback=function(t,e){var i=this;return function(n){var s;i.resolveGradient(n,e,"fill"),i.resolveGradient(n,e,"stroke"),n instanceof r.Image&&n._originalElement&&(s=n.parsePreserveAspectRatioAttribute(e)),n._removeTransformMatrix(s),i.resolveClipPath(n,e),i.reviver&&i.reviver(e,n),i.instances[t]=n,i.checkIfDone()}},t.extractPropertyDefinition=function(t,e,i){var n=t[e],s=this.regexUrl;if(s.test(n)){s.lastIndex=0;var o=s.exec(n)[1];return s.lastIndex=0,r[i][this.svgUid][o]}},t.resolveGradient=function(t,e,i){var n=this.extractPropertyDefinition(t,i,"gradientDefs");if(n){var s=e.getAttribute(i+"-opacity"),o=r.Gradient.fromElement(n,t,s,this.options);t.set(i,o)}},t.createClipPathCallback=function(t,e){return function(t){t._removeTransformMatrix(),t.fillRule=t.clipRule,e.push(t)}},t.resolveClipPath=function(t,e){var i,n,s,o,a,l=this.extractPropertyDefinition(t,"clipPath","clipPaths");if(l){s=[],n=r.util.invertTransform(t.calcTransformMatrix());for(var c=l[0].parentNode,h=e;h.parentNode&&h.getAttribute("clip-path")!==t.clipPath;)h=h.parentNode;h.parentNode.appendChild(c);for(var u=0;u<l.length;u++)i=l[u],this.findTag(i).fromElement(i,this.createClipPathCallback(t,s),this.options);l=1===s.length?s[0]:new r.Group(s),o=r.util.multiplyTransformMatrices(n,l.calcTransformMatrix()),l.clipPath&&this.resolveClipPath(l,h);var a=r.util.qrDecompose(o);l.flipX=!1,l.flipY=!1,l.set("scaleX",a.scaleX),l.set("scaleY",a.scaleY),l.angle=a.angle,l.skewX=a.skewX,l.skewY=0,l.setPositionByOrigin({x:a.translateX,y:a.translateY},"center","center"),t.clipPath=l}else delete t.clipPath},t.checkIfDone=function(){0==--this.numElements&&(this.instances=this.instances.filter(function(t){return null!=t}),this.callback(this.instances,this.elements))}}(r.ElementsParser.prototype),function(t){"use strict";var e=t.fabric||(t.fabric={});if(e.Point)return e.warn("fabric.Point is already defined");function i(t,e){this.x=t,this.y=e}e.Point=i,i.prototype={type:"point",constructor:i,add:function(t){return new i(this.x+t.x,this.y+t.y)},addEquals:function(t){return this.x+=t.x,this.y+=t.y,this},scalarAdd:function(t){return new i(this.x+t,this.y+t)},scalarAddEquals:function(t){return this.x+=t,this.y+=t,this},subtract:function(t){return new i(this.x-t.x,this.y-t.y)},subtractEquals:function(t){return this.x-=t.x,this.y-=t.y,this},scalarSubtract:function(t){return new i(this.x-t,this.y-t)},scalarSubtractEquals:function(t){return this.x-=t,this.y-=t,this},multiply:function(t){return new i(this.x*t,this.y*t)},multiplyEquals:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return new i(this.x/t,this.y/t)},divideEquals:function(t){return this.x/=t,this.y/=t,this},eq:function(t){return this.x===t.x&&this.y===t.y},lt:function(t){return this.x<t.x&&this.y<t.y},lte:function(t){return this.x<=t.x&&this.y<=t.y},gt:function(t){return this.x>t.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={});if(e.Intersection)return e.warn("fabric.Intersection is already defined");function i(t){this.status=t,this.points=[]}e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,n,r,s){var o,a=(s.x-r.x)*(t.y-r.y)-(s.y-r.y)*(t.x-r.x),l=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),c=(s.y-r.y)*(n.x-t.x)-(s.x-r.x)*(n.y-t.y);if(0!==c){var h=a/c,u=l/c;0<=h&&h<=1&&0<=u&&u<=1?(o=new i("Intersection")).appendPoint(new e.Point(t.x+h*(n.x-t.x),t.y+h*(n.y-t.y))):o=new i}else o=new i(0===a||0===l?"Coincident":"Parallel");return o},e.Intersection.intersectLinePolygon=function(t,e,n){var r,s,o,a,l=new i,c=n.length;for(a=0;a<c;a++)r=n[a],s=n[(a+1)%c],o=i.intersectLineLine(t,e,r,s),l.appendPoints(o.points);return l.points.length>0&&(l.status="Intersection"),l},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,s=t.length;for(n=0;n<s;n++){var o=t[n],a=t[(n+1)%s],l=i.intersectLinePolygon(o,a,e);r.appendPoints(l.points)}return r.points.length>0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var s=n.min(r),o=n.max(r),a=new e.Point(o.x,s.y),l=new e.Point(s.x,o.y),c=i.intersectLinePolygon(s,a,t),h=i.intersectLinePolygon(a,o,t),u=i.intersectLinePolygon(o,l,t),f=i.intersectLinePolygon(l,s,t),d=new i;return d.appendPoints(c.points),d.appendPoints(h.points),d.appendPoints(u.points),d.appendPoints(f.points),d.points.length>0&&(d.status="Intersection"),d}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={});if(e.Color)return e.warn("fabric.Color is already defined.");function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function n(t,e,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?t+(e-t)*6*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,n){t/=255,i/=255,n/=255;var r,s,o,a=e.util.array.max([t,i,n]),l=e.util.array.min([t,i,n]);if(o=(a+l)/2,a===l)r=s=0;else{var c=a-l;switch(s=o>.5?c/(2-a-l):c/(a+l),a){case t:r=(i-n)/c+6*(i<n);break;case i:r=(n-t)/c+2;break;case n:r=(t-i)/c+4}r/=6}return[Math.round(360*r),Math.round(100*s),Math.round(100*o)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+e[0]+","+e[1]+"%,"+e[2]+"%)"},toHsla:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+e[0]+","+e[1]+"%,"+e[2]+"%,"+t[3]+")"},toHex:function(){var t,e,i,n=this.getSource();return t=1===(t=n[0].toString(16)).length?"0"+t:t,e=1===(e=n[1].toString(16)).length?"0"+e:e,i=1===(i=n[2].toString(16)).length?"0"+i:i,t.toUpperCase()+e.toUpperCase()+i.toUpperCase()},toHexa:function(){var t;return t=1===(t=(t=Math.round(255*this.getSource()[3])).toString(16)).length?"0"+t:t,this.toHex()+t.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var e=this.getSource();return e[3]=t,this.setSource(e),this},toGrayscale:function(){var t=this.getSource(),e=parseInt((.3*t[0]+.59*t[1]+.11*t[2]).toFixed(0),10),i=t[3];return this.setSource([e,e,e,i]),this},toBlackWhite:function(t){var e=this.getSource(),i=(.3*e[0]+.59*e[1]+.11*e[2]).toFixed(0),n=e[3];return t=t||127,i=Number(i)<Number(t)?0:255,this.setSource([i,i,i,n]),this},overlayWith:function(t){t instanceof i||(t=new i(t));var e,n=[],r=this.getAlpha(),s=this.getSource(),o=t.getSource();for(e=0;e<3;e++)n.push(Math.round(.5*s[e]+.5*o[e]));return n[3]=r,this.setSource(n),this}},e.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i,e.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i,e.Color.reHex=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,e.Color.colorNameMap={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"},e.Color.fromRgb=function(t){return i.fromSource(i.sourceFromRgb(t))},e.Color.sourceFromRgb=function(t){var e=t.match(i.reRGBa);if(e){var n=parseInt(e[1],10)/(/%$/.test(e[1])?100:1)*(/%$/.test(e[1])?255:1),r=parseInt(e[2],10)/(/%$/.test(e[2])?100:1)*(/%$/.test(e[2])?255:1),s=parseInt(e[3],10)/(/%$/.test(e[3])?100:1)*(/%$/.test(e[3])?255:1);return[parseInt(n,10),parseInt(r,10),parseInt(s,10),e[4]?parseFloat(e[4]):1]}},e.Color.fromRgba=i.fromRgb,e.Color.fromHsl=function(t){return i.fromSource(i.sourceFromHsl(t))},e.Color.sourceFromHsl=function(t){var e=t.match(i.reHSLa);if(e){var r,s,o,a=(parseFloat(e[1])%360+360)%360/360,l=parseFloat(e[2])/(/%$/.test(e[2])?100:1),c=parseFloat(e[3])/(/%$/.test(e[3])?100:1);if(0===l)r=s=o=c;else{var h=c<=.5?c*(l+1):c+l-c*l,u=2*c-h;r=n(u,h,a+1/3),s=n(u,h,a),o=n(u,h,a-1/3)}return[Math.round(255*r),Math.round(255*s),Math.round(255*o),e[4]?parseFloat(e[4]):1]}},e.Color.fromHsla=i.fromHsl,e.Color.fromHex=function(t){return i.fromSource(i.sourceFromHex(t))},e.Color.sourceFromHex=function(t){if(t.match(i.reHex)){var e=t.slice(t.indexOf("#")+1),n=3===e.length||4===e.length,r=8===e.length||4===e.length,s=n?e.charAt(0)+e.charAt(0):e.substring(0,2),o=n?e.charAt(1)+e.charAt(1):e.substring(2,4),a=n?e.charAt(2)+e.charAt(2):e.substring(4,6),l=r?n?e.charAt(3)+e.charAt(3):e.substring(6,8):"FF";return[parseInt(s,16),parseInt(o,16),parseInt(a,16),parseFloat((parseInt(l,16)/255).toFixed(2))]}},e.Color.fromSource=function(t){var e=new i;return e.setSource(t),e}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=["e","se","s","sw","w","nw","n","ne","e"],n=["ns","nesw","ew","nwse"],r={},s="left",o="right",a="bottom",l="center",c={top:a,bottom:"top",left:o,right:s,center:l},h=e.util.radiansToDegrees,u=Math.sign||function(t){return(t>0)-(t<0)||+t};function f(t,e){return Math.round((t.angle+h(Math.atan2(e.y,e.x))+360)%360/45)}function d(t,i){var n=i.transform.target,r=n.canvas,s=e.util.object.clone(i);s.target=n,r&&r.fire("object:"+t,s),n.fire(t,i)}function g(t,e){var i=e.canvas,n=t[i.uniScaleKey];return i.uniformScaling&&!n||!i.uniformScaling&&n}function p(t){return t.originX===l&&t.originY===l}function m(t,e,i){var n=t.lockScalingX,r=t.lockScalingY;return!!n&&!!r||!e&&(!!n||!!r)&&!!i||!!n&&"x"===e||!!r&&"y"===e||!1}function y(t,e,i,n){return{e:t,transform:e,pointer:{x:i,y:n}}}function b(t){return function(e,i,n,r){var s=i.target,o=s.getCenterPoint(),a=s.translateToOriginPoint(o,i.originX,i.originY),l=t(e,i,n,r);return s.setPositionByOrigin(a,i.originX,i.originY),l}}function x(t,e){return function(i,n,r,s){var o=e(i,n,r,s);return o&&d(t,y(i,n,r,s)),o}}function _(t,i,n,r,s){var o=t.target,a=o.controls[t.corner],l=o.canvas.getZoom(),c=o.padding/l,h=o.toLocalPoint(new e.Point(r,s),i,n);return h.x>=c&&(h.x-=c),h.x<=-c&&(h.x+=c),h.y>=c&&(h.y-=c),h.y<=c&&(h.y+=c),h.x-=a.offsetX,h.y-=a.offsetY,h}function C(t){return t.flipX!==t.flipY}function S(t,e,i,n,r){if(0!==t[e]){var s=r/t._getTransformedDimensions()[n]*t[i];t.set(i,s)}}function w(t,e,i,n){var r,l=e.target,c=l._getTransformedDimensions(0,l.skewY),u=Math.abs(2*_(e,e.originX,e.originY,i,n).x)-c.x,f=l.skewX;u<2?r=0:(r=h(Math.atan2(u/l.scaleX,c.y/l.scaleY)),e.originX===s&&e.originY===a&&(r=-r),e.originX===o&&"top"===e.originY&&(r=-r),C(l)&&(r=-r));var d=f!==r;if(d){var g=l._getTransformedDimensions().y;l.set("skewX",r),S(l,"skewY","scaleY","y",g)}return d}function T(t,e,i,n){var r,l=e.target,c=l._getTransformedDimensions(l.skewX,0),u=Math.abs(2*_(e,e.originX,e.originY,i,n).y)-c.y,f=l.skewY;u<2?r=0:(r=h(Math.atan2(u/l.scaleY,c.x/l.scaleX)),e.originX===s&&e.originY===a&&(r=-r),e.originX===o&&"top"===e.originY&&(r=-r),C(l)&&(r=-r));var d=f!==r;if(d){var g=l._getTransformedDimensions().x;l.set("skewY",r),S(l,"skewX","scaleX","x",g)}return d}function O(t,e,i,n,r){r=r||{};var s,o,a,l,h,f,d=e.target,y=d.lockScalingX,b=d.lockScalingY,x=r.by,C=g(t,d),S=m(d,x,C),w=e.gestureScale;if(S)return!1;if(w)o=e.scaleX*w,a=e.scaleY*w;else{if(s=_(e,e.originX,e.originY,i,n),h="y"!==x?u(s.x):1,f="x"!==x?u(s.y):1,e.signX||(e.signX=h),e.signY||(e.signY=f),d.lockScalingFlip&&(e.signX!==h||e.signY!==f))return!1;if(l=d._getTransformedDimensions(),C&&!x){var T=Math.abs(s.x)+Math.abs(s.y),O=e.original,k=T/(Math.abs(l.x*O.scaleX/d.scaleX)+Math.abs(l.y*O.scaleY/d.scaleY));o=O.scaleX*k,a=O.scaleY*k}else o=Math.abs(s.x*d.scaleX/l.x),a=Math.abs(s.y*d.scaleY/l.y);p(e)&&(o*=2,a*=2),e.signX!==h&&"y"!==x&&(e.originX=c[e.originX],o*=-1,e.signX=h),e.signY!==f&&"x"!==x&&(e.originY=c[e.originY],a*=-1,e.signY=f)}var E=d.scaleX,j=d.scaleY;return x?("x"===x&&d.set("scaleX",o),"y"===x&&d.set("scaleY",a)):(y||d.set("scaleX",o),b||d.set("scaleY",a)),E!==d.scaleX||j!==d.scaleY}r.scaleCursorStyleHandler=function(t,e,n){var r=g(t,n),s="";return(0!==e.x&&0===e.y?s="x":0===e.x&&0!==e.y&&(s="y"),m(n,s,r))?"not-allowed":i[f(n,e)]+"-resize"},r.skewCursorStyleHandler=function(t,e,i){return 0!==e.x&&i.lockSkewingY||0!==e.y&&i.lockSkewingX?"not-allowed":n[f(i,e)%4]+"-resize"},r.scaleSkewCursorStyleHandler=function(t,e,i){return t[i.canvas.altActionKey]?r.skewCursorStyleHandler(t,e,i):r.scaleCursorStyleHandler(t,e,i)},r.rotationWithSnapping=x("rotating",b(function(t,e,i,n){var r=e.target,s=r.translateToOriginPoint(r.getCenterPoint(),e.originX,e.originY);if(r.lockRotation)return!1;var o=Math.atan2(e.ey-s.y,e.ex-s.x),a=h(Math.atan2(n-s.y,i-s.x)-o+e.theta),l=!0;if(r.snapAngle>0){var c=r.snapAngle,u=r.snapThreshold||c,f=Math.ceil(a/c)*c,d=Math.floor(a/c)*c;Math.abs(a-d)<u?a=d:Math.abs(a-f)<u&&(a=f)}return a<0&&(a=360+a),a%=360,l=r.angle!==a,r.angle=a,l})),r.scalingEqually=x("scaling",b(function(t,e,i,n){return O(t,e,i,n)})),r.scalingX=x("scaling",b(function(t,e,i,n){return O(t,e,i,n,{by:"x"})})),r.scalingY=x("scaling",b(function(t,e,i,n){return O(t,e,i,n,{by:"y"})})),r.scalingYOrSkewingX=function(t,e,i,n){return t[e.target.canvas.altActionKey]?r.skewHandlerX(t,e,i,n):r.scalingY(t,e,i,n)},r.scalingXOrSkewingY=function(t,e,i,n){return t[e.target.canvas.altActionKey]?r.skewHandlerY(t,e,i,n):r.scalingX(t,e,i,n)},r.changeWidth=x("resizing",b(function(t,e,i,n){var r=e.target,s=_(e,e.originX,e.originY,i,n),o=r.strokeWidth/(r.strokeUniform?r.scaleX:1),a=p(e)?2:1,l=r.width,c=Math.abs(s.x*a/r.scaleX)-o;return r.set("width",Math.max(c,0)),l!==c})),r.skewHandlerX=function(t,e,i,n){var r,a=e.target,c=a.skewX,h=e.originY;return!a.lockSkewingX&&(0===c?r=_(e,l,l,i,n).x>0?s:o:(c>0&&(r="top"===h?s:o),c<0&&(r="top"===h?o:s),C(a)&&(r=r===s?o:s)),e.originX=r,x("skewing",b(w))(t,e,i,n))},r.skewHandlerY=function(t,e,i,n){var r,o=e.target,c=o.skewY,h=e.originX;return!o.lockSkewingY&&(0===c?r=_(e,l,l,i,n).y>0?"top":a:(c>0&&(r=h===s?"top":a),c<0&&(r=h===s?a:"top"),C(o)&&(r="top"===r?a:"top")),e.originY=r,x("skewing",b(T))(t,e,i,n))},r.dragHandler=function(t,e,i,n){var r=e.target,s=i-e.offsetX,o=n-e.offsetY,a=!r.get("lockMovementX")&&r.left!==s,l=!r.get("lockMovementY")&&r.top!==o;return a&&r.set("left",s),l&&r.set("top",o),(a||l)&&d("moving",y(t,e,i,n)),a||l},r.scaleOrSkewActionName=function(t,e,i){var n=t[i.canvas.altActionKey];return 0===e.x?n?"skewX":"scaleY":0===e.y?n?"skewY":"scaleX":void 0},r.rotationStyleHandler=function(t,e,i){return i.lockRotation?"not-allowed":e.cursorStyle},r.fireEvent=d,r.wrapWithFixedAnchor=b,r.wrapWithFireEvent=x,r.getLocalPoint=_,e.controlsUtils=r}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians,n=e.controlsUtils;n.renderCircleControl=function(t,e,i,n,r){n=n||{};var s,o=this.sizeX||n.cornerSize||r.cornerSize,a=this.sizeY||n.cornerSize||r.cornerSize,l=void 0!==n.transparentCorners?n.transparentCorners:r.transparentCorners,c=!l&&(n.cornerStrokeColor||r.cornerStrokeColor),h=e,u=i;t.save(),t.fillStyle=n.cornerColor||r.cornerColor,t.strokeStyle=n.cornerStrokeColor||r.cornerStrokeColor,o>a?(s=o,t.scale(1,a/o),u=i*o/a):a>o?(s=a,t.scale(o/a,1),h=e*a/o):s=o,t.lineWidth=1,t.beginPath(),t.arc(h,u,s/2,0,2*Math.PI,!1),t[l?"stroke":"fill"](),c&&t.stroke(),t.restore()},n.renderSquareControl=function(t,e,n,r,s){r=r||{};var o=this.sizeX||r.cornerSize||s.cornerSize,a=this.sizeY||r.cornerSize||s.cornerSize,l=void 0!==r.transparentCorners?r.transparentCorners:s.transparentCorners,c=!l&&(r.cornerStrokeColor||s.cornerStrokeColor),h=o/2,u=a/2;t.save(),t.fillStyle=r.cornerColor||s.cornerColor,t.strokeStyle=r.cornerStrokeColor||s.cornerStrokeColor,t.lineWidth=1,t.translate(e,n),t.rotate(i(s.angle)),t[(l?"stroke":"fill")+"Rect"](-h,-u,o,a),c&&t.strokeRect(-h,-u,o,a),t.restore()}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Control=function(t){for(var e in t)this[e]=t[e]},e.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(t,e){return e.cursorStyle},getActionName:function(t,e){return e.actionName},getVisibility:function(t,e){var i=t._controlsVisibility;return i&&void 0!==i[e]?i[e]:this.visible},setVisibility:function(t){this.visible=t},positionHandler:function(t,i){return e.util.transformPoint({x:this.x*t.x+this.offsetX,y:this.y*t.y+this.offsetY},i)},calcCornerCoords:function(t,i,n,r,s){var o,a,l,c,h=s?this.touchSizeX:this.sizeX,u=s?this.touchSizeY:this.sizeY;if(h&&u&&h!==u){var f=Math.atan2(u,h),d=Math.sqrt(h*h+u*u)/2,g=f-e.util.degreesToRadians(t),p=Math.PI/2-f-e.util.degreesToRadians(t);o=d*e.util.cos(g),a=d*e.util.sin(g),l=d*e.util.cos(p),c=d*e.util.sin(p)}else{d=.7071067812*(h&&u?h:i);var g=e.util.degreesToRadians(45-t);o=l=d*e.util.cos(g),a=c=d*e.util.sin(g)}return{tl:{x:n-c,y:r-l},tr:{x:n+o,y:r-a},bl:{x:n-o,y:r+a},br:{x:n+c,y:r+l}}},render:function(t,i,n,r,s){"circle"===((r=r||{}).cornerStyle||s.cornerStyle)?e.controlsUtils.renderCircleControl.call(this,t,i,n,r,s):e.controlsUtils.renderSquareControl.call(this,t,i,n,r,s)}}}(i),function(){var t=r.util.object.clone;r.Gradient=r.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(t){t||(t={}),t.coords||(t.coords={});var e,i=this;Object.keys(t).forEach(function(e){i[e]=t[e]}),this.id?this.id+="_"+r.Object.__uid++:this.id=r.Object.__uid++,e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice()},addColorStop:function(t){for(var e in t){var i=new r.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return r.util.populateWithProperties(this,e,t),e},toSVG:function(e,i){var n,s,o,a,l=t(this.coords,!0),i=i||{},c=t(this.colorStops,!0),h=l.r1>l.r2,u=this.gradientTransform?this.gradientTransform.concat():r.iMatrix.concat(),f=-this.offsetX,d=-this.offsetY,g=!!i.additionalTransform,p="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(c.sort(function(t,e){return t.offset-e.offset}),"objectBoundingBox"===p?(f/=e.width,d/=e.height):(f+=e.width/2,d+=e.height/2),"path"===e.type&&"percentage"!==this.gradientUnits&&(f-=e.pathOffset.x,d-=e.pathOffset.y),u[4]-=f,u[5]-=d,a='id="SVGID_'+this.id+'" gradientUnits="'+p+'"'+(' gradientTransform="'+(g?i.additionalTransform+" ":"")+r.util.matrixToSVG(u))+'" ',"linear"===this.type?o=["<linearGradient ",a,' x1="',l.x1,'" y1="',l.y1,'" x2="',l.x2,'" y2="',l.y2,'">\n']:"radial"===this.type&&(o=["<radialGradient ",a,' cx="',h?l.x1:l.x2,'" cy="',h?l.y1:l.y2,'" r="',h?l.r1:l.r2,'" fx="',h?l.x2:l.x1,'" fy="',h?l.y2:l.y1,'">\n']),"radial"===this.type){if(h)for((c=c.concat()).reverse(),n=0,s=c.length;n<s;n++)c[n].offset=1-c[n].offset;var m=Math.min(l.r1,l.r2);if(m>0){var y=m/Math.max(l.r1,l.r2);for(n=0,s=c.length;n<s;n++)c[n].offset+=y*(1-c[n].offset)}}for(n=0,s=c.length;n<s;n++){var b=c[n];o.push("<stop ",'offset="',100*b.offset+"%",'" style="stop-color:',b.color,void 0!==b.opacity?";stop-opacity: "+b.opacity:";",'"/>\n')}return o.push("linear"===this.type?"</linearGradient>\n":"</radialGradient>\n"),o.join("")},toLive:function(t){var e,i,n,s=r.util.object.clone(this.coords);if(this.type){for("linear"===this.type?e=t.createLinearGradient(s.x1,s.y1,s.x2,s.y2):"radial"===this.type&&(e=t.createRadialGradient(s.x1,s.y1,s.r1,s.x2,s.y2,s.r2)),i=0,n=this.colorStops.length;i<n;i++){var o=this.colorStops[i].color,a=this.colorStops[i].opacity,l=this.colorStops[i].offset;void 0!==a&&(o=new r.Color(o).setAlpha(a).toRgba()),e.addColorStop(l,o)}return e}}}),r.util.object.extend(r.Gradient,{fromElement:function(t,e,i,n){var s,o,a,l,c,h,u=parseFloat(i)/(/%$/.test(i)?100:1);isNaN(u=u<0?0:u>1?1:u)&&(u=1);var f,d,g,p,m=t.getElementsByTagName("stop"),y="userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage",b=t.getAttribute("gradientTransform")||"",x=[],_=0,C=0;for("linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?(f="linear",d={x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}):(f="radial",d={x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}),g=m.length;g--;)x.push(function(t,e){var i,n,s,o,a=t.getAttribute("style"),l=t.getAttribute("offset")||0;if(l=(l=parseFloat(l)/(/%$/.test(l)?100:1))<0?0:l>1?1:l,a){var c=a.split(/\s*;\s*/);for(""===c[c.length-1]&&c.pop(),o=c.length;o--;){var h=c[o].split(/\s*:\s*/),u=h[0].trim(),f=h[1].trim();"stop-color"===u?i=f:"stop-opacity"===u&&(s=f)}}return i||(i=t.getAttribute("stop-color")||"rgb(0,0,0)"),s||(s=t.getAttribute("stop-opacity")),n=(i=new r.Color(i)).getAlpha(),s=(isNaN(parseFloat(s))?1:parseFloat(s))*(n*e),{offset:l,color:i.toRgb(),opacity:s}}(m[g],u));return p=r.parseTransformAttribute(b),s=0,o=d,a=n,l=y,Object.keys(o).forEach(function(t){"Infinity"===(c=o[t])?h=1:"-Infinity"===c?h=0:(h=parseFloat(o[t],10),"string"==typeof c&&/^(\d+\.\d+)%|(\d+)%$/.test(c)&&(h*=.01,"pixels"===l&&(("x1"===t||"x2"===t||"r2"===t)&&(h*=a.viewBoxWidth||a.width),("y1"===t||"y2"===t)&&(h*=a.viewBoxHeight||a.height)))),o[t]=h}),"pixels"===y&&(_=-e.left,C=-e.top),new r.Gradient({id:t.getAttribute("id"),type:f,coords:d,colorStops:x,gradientUnits:y,gradientTransform:p,offsetX:_,offsetY:C})}})}(),function(){"use strict";var t=r.util.toFixed;r.Pattern=r.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(t,e){if(t||(t={}),this.id=r.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source){e&&e(this);return}var i=this;this.source=r.util.createImage(),r.util.loadImage(t.source,function(t,n){i.source=t,e&&e(i,n)},null,this.crossOrigin)},toObject:function(e){var i,n,s=r.Object.NUM_FRACTION_DIGITS;return"string"==typeof this.source.src?i=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(i=this.source.toDataURL()),n={type:"pattern",source:i,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:t(this.offsetX,s),offsetY:t(this.offsetY,s),patternTransform:this.patternTransform?this.patternTransform.concat():null},r.util.populateWithProperties(this,n,e),n},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,n=e.height/t.height,r=this.offsetX/t.width,s=this.offsetY/t.height,o="";return("repeat-x"===this.repeat||"no-repeat"===this.repeat)&&(n=1,s&&(n+=Math.abs(s))),("repeat-y"===this.repeat||"no-repeat"===this.repeat)&&(i=1,r&&(i+=Math.abs(r))),e.src?o=e.src:e.toDataURL&&(o=e.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+r+'" y="'+s+'" width="'+i+'" height="'+n+'">\n<image x="0" y="0" width="'+e.width+'" height="'+e.height+'" xlink:href="'+o+'"></image>\n</pattern>\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e=this.source;return e&&(void 0===e.src||e.complete&&0!==e.naturalWidth&&0!==e.naturalHeight)?t.createPattern(e,this.repeat):""}})}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.toFixed;if(e.Shadow)return e.warn("fabric.Shadow is already defined.");e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(t){for(var i in"string"==typeof t&&(t=this._parseShadow(t)),t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),n=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseFloat(n[1],10)||0,offsetY:parseFloat(n[2],10)||0,blur:parseFloat(n[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var n=40,r=40,s=e.Object.NUM_FRACTION_DIGITS,o=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),a=new e.Color(this.color);return t.width&&t.height&&(n=100*i((Math.abs(o.x)+this.blur)/t.width,s)+20,r=100*i((Math.abs(o.y)+this.blur)/t.height,s)+20),t.flipX&&(o.x*=-1),t.flipY&&(o.y*=-1),'<filter id="SVGID_'+this.id+'" y="-'+r+'%" height="'+(100+2*r)+'%" x="-'+n+'%" width="'+(100+2*n)+'%" >\n <feGaussianBlur in="SourceAlpha" stdDeviation="'+i(this.blur?this.blur/2:0,s)+'"></feGaussianBlur>\n <feOffset dx="'+i(o.x,s)+'" dy="'+i(o.y,s)+'" result="oBlur" ></feOffset>\n <feFlood flood-color="'+a.toRgb()+'" flood-opacity="'+a.getAlpha()+'"/>\n <feComposite in2="oBlur" operator="in" />\n <feMerge>\n <feMergeNode></feMergeNode>\n <feMergeNode in="SourceGraphic"></feMergeNode>\n </feMerge>\n</filter>\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach(function(e){this[e]!==i[e]&&(t[e]=this[e])},this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/}(i),function(){"use strict";if(r.StaticCanvas)return r.warn("fabric.StaticCanvas is already defined.");var t=r.util.object.extend,e=r.util.getElementOffset,i=r.util.removeFromArray,n=r.util.toFixed,s=r.util.transformPoint,o=r.util.invertTransform,a=r.util.getNodeCanvas,l=r.util.createCanvasElement,c=Error("Could not initialize `canvas` element");r.StaticCanvas=r.util.createClass(r.CommonMethods,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:r.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(t,e){var i=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return r.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,r.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var t=r.devicePixelRatio;this.__initRetinaScaling(t,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(t,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(t,e,i){e.setAttribute("width",this.width*t),e.setAttribute("height",this.height*t),i.scale(t,t)},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},__setBgOverlayImage:function(t,e,i,n){return"string"==typeof e?r.util.loadImage(e,function(e,s){if(e){var o=new r.Image(e,n);this[t]=o,o.canvas=this}i&&i(e,s)},this,n&&n.crossOrigin):(n&&e.setOptions(n),this[t]=e,e&&(e.canvas=this),i&&i(e,!1)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(){var t=l();if(!t||(t.style||(t.style={}),void 0===t.getContext))throw c;return t},_initOptions:function(t){var e=this.lowerCanvasEl;this._setOptions(t),this.width=this.width||parseInt(e.width,10)||0,this.height=this.height||parseInt(e.height,10)||0,this.lowerCanvasEl.style&&(e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){t&&t.getContext?this.lowerCanvasEl=t:this.lowerCanvasEl=r.util.getById(t)||this._createCanvasElement(),r.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;for(var n in e=e||{},t)i=t[n],e.cssOnly||(this._setBackstoreDimension(n,t[n]),i+="px",this.hasLostContext=!0),e.backstoreOnly||this._setCssDimension(n,i);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),e.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i,n,r=this._activeObject,s=this.backgroundImage,o=this.overlayImage;for(i=0,this.viewportTransform=t,n=this._objects.length;i<n;i++)(e=this._objects[i]).group||e.setCoords(!0);return r&&r.setCoords(),s&&s.setCoords(!0),o&&o.setCoords(!0),this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll(),this},zoomToPoint:function(t,e){var i=t,n=this.viewportTransform.slice(0);t=s(t,o(this.viewportTransform)),n[0]=e,n[3]=e;var r=s(t,n);return n[4]+=i.x-r.x,n[5]+=i.y-r.y,this.setViewportTransform(n)},setZoom:function(t){return this.zoomToPoint(new r.Point(0,0),t),this},absolutePan:function(t){var e=this.viewportTransform.slice(0);return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)},relativePan:function(t){return this.absolutePan(new r.Point(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},_onObjectAdded:function(t){this.stateful&&t.setupState(),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added")},_onObjectRemoved:function(t){this.fire("object:removed",{target:t}),t.fire("removed"),delete t.canvas},clearContext:function(t){return t.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this.remove.apply(this,this.getObjects()),this.backgroundImage=null,this.overlayImage=null,this.backgroundColor="",this.overlayColor="",this._hasITextHandlers&&(this.off("mouse:up",this._mouseUpITextHandler),this._iTextInstances=null,this._hasITextHandlers=!1),this.clearContext(this.contextContainer),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll(),this},renderAll:function(){var t=this.contextContainer;return this.renderCanvas(t,this._objects),this},renderAndReset:function(){this.isRendering=0,this.renderAll()},requestRenderAll:function(){return this.isRendering||(this.isRendering=r.util.requestAnimFrame(this.renderAndResetBound)),this},calcViewportBoundaries:function(){var t={},e=this.width,i=this.height,n=o(this.viewportTransform);return t.tl=s({x:0,y:0},n),t.br=s({x:e,y:i},n),t.tr=new r.Point(t.br.x,t.tl.y),t.bl=new r.Point(t.tl.x,t.br.y),this.vptCoords=t,t},cancelRequestedRender:function(){this.isRendering&&(r.util.cancelAnimFrame(this.isRendering),this.isRendering=0)},renderCanvas:function(t,e){var i=this.viewportTransform,n=this.clipPath;this.cancelRequestedRender(),this.calcViewportBoundaries(),this.clearContext(t),r.util.setImageSmoothing(t,this.imageSmoothingEnabled),this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),n&&(n.canvas=this,n.shouldCache(),n._transformDone=!0,n.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t)),this._renderOverlay(t),this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),this.fire("after:render",{ctx:t})},drawClipPathOnCanvas:function(t){var e=this.viewportTransform,i=this.clipPath;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t.globalCompositeOperation="destination-in",i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},_renderObjects:function(t,e){var i,n;for(i=0,n=e.length;i<n;++i)e[i]&&e[i].render(t)},_renderBackgroundOrOverlay:function(t,e){var i=this[e+"Color"],n=this[e+"Image"],r=this.viewportTransform,s=this[e+"Vpt"];if(i||n){if(i){t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=i.toLive?i.toLive(t,this):i,s&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);var o=i.gradientTransform||i.patternTransform;o&&t.transform(o[0],o[1],o[2],o[3],o[4],o[5]),t.fill(),t.restore()}if(n){t.save();var a=this.skipOffscreen;this.skipOffscreen=s,s&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),n.render(t),this.skipOffscreen=a,t.restore()}}},_renderBackground:function(t){this._renderBackgroundOrOverlay(t,"background")},_renderOverlay:function(t){this._renderBackgroundOrOverlay(t,"overlay")},getCenter:function(){return{top:this.height/2,left:this.width/2}},getCenterPoint:function(){return new r.Point(this.width/2,this.height/2)},centerObjectH:function(t){return this._centerObject(t,new r.Point(this.getCenterPoint().x,t.getCenterPoint().y))},centerObjectV:function(t){return this._centerObject(t,new r.Point(t.getCenterPoint().x,this.getCenterPoint().y))},centerObject:function(t){var e=this.getCenterPoint();return this._centerObject(t,e)},viewportCenterObject:function(t){var e=this.getVpCenter();return this._centerObject(t,e)},viewportCenterObjectH:function(t){var e=this.getVpCenter();return this._centerObject(t,new r.Point(e.x,t.getCenterPoint().y)),this},viewportCenterObjectV:function(t){var e=this.getVpCenter();return this._centerObject(t,new r.Point(t.getCenterPoint().x,e.y))},getVpCenter:function(){return s(this.getCenterPoint(),o(this.viewportTransform))},_centerObject:function(t,e){return t.setPositionByOrigin(e,"center","center"),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll(),this},toDatalessJSON:function(t){return this.toDatalessObject(t)},toObject:function(t){return this._toObjectMethod("toObject",t)},toDatalessObject:function(t){return this._toObjectMethod("toDatalessObject",t)},_toObjectMethod:function(e,i){var n=this.clipPath,s={version:r.version,objects:this._toObjects(e,i)};return n&&!n.excludeFromExport&&(s.clipPath=this._toObject(this.clipPath,e,i)),t(s,this.__serializeBgOverlay(e,i)),r.util.populateWithProperties(this,s,i),s},_toObjects:function(t,e){return this._objects.filter(function(t){return!t.excludeFromExport}).map(function(i){return this._toObject(i,t,e)},this)},_toObject:function(t,e,i){this.includeDefaultValues||(n=t.includeDefaultValues,t.includeDefaultValues=!1);var n,r=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=n),r},__serializeBgOverlay:function(t,e){var i={},n=this.backgroundImage,r=this.overlayImage,s=this.backgroundColor,o=this.overlayColor;return s&&s.toObject?s.excludeFromExport||(i.background=s.toObject(e)):s&&(i.background=s),o&&o.toObject?o.excludeFromExport||(i.overlay=o.toObject(e)):o&&(i.overlay=o),n&&!n.excludeFromExport&&(i.backgroundImage=this._toObject(n,t,e)),r&&!r.excludeFromExport&&(i.overlayImage=this._toObject(r,t,e)),i},svgViewportTransformation:!0,toSVG:function(t,e){t||(t={}),t.reviver=e;var i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'+this.clipPath.clipPathId+')" >\n'),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("</g>\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(t,e){var i,s=e.width||this.width,o=e.height||this.height,a='viewBox="0 0 '+this.width+" "+this.height+'" ',l=r.Object.NUM_FRACTION_DIGITS;e.viewBox?a='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(a='viewBox="'+n(-(i=this.viewportTransform)[4]/i[0],l)+" "+n(-i[5]/i[3],l)+" "+n(this.width/i[0],l)+" "+n(this.height/i[3],l)+'" '),t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',s,'" ','height="',o,'" ',a,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",r.version,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"</defs>\n")},createSVGClipPathMarkup:function(t){var e=this.clipPath;return e?(e.clipPathId="CLIPPATH_"+r.Object.__uid++,'<clipPath id="'+e.clipPathId+'" >\n'+this.clipPath.toClipPathSVG(t.reviver)+"</clipPath>\n"):""},createSVGRefElementsMarkup:function(){var t=this;return["background","overlay"].map(function(e){var i=t[e+"Color"];if(i&&i.toLive){var n=t[e+"Vpt"],s=t.viewportTransform,o={width:t.width/(n?s[0]:1),height:t.height/(n?s[3]:1)};return i.toSVG(o,{additionalTransform:n?r.util.matrixToSVG(s):""})}}).join("")},createSVGFontFacesMarkup:function(){var t,e,i,n,s,o,a,l,c="",h={},u=r.fontPaths,f=[];for(this._objects.forEach(function t(e){f.push(e),e._objects&&e._objects.forEach(t)}),a=0,l=f.length;a<l;a++)if((e=(t=f[a]).fontFamily,-1!==t.type.indexOf("text")&&!h[e]&&u[e])&&(h[e]=!0,t.styles))for(s in i=t.styles)for(o in n=i[s])!h[e=n[o].fontFamily]&&u[e]&&(h[e]=!0);for(var d in h)c+=" @font-face {\n font-family: '"+d+"';\n src: url('"+u[d]+"');\n }\n";return c&&(c=' <style type="text/css"><![CDATA[\n'+c+"]]></style>\n"),c},_setSVGObjects:function(t,e){var i,n,r,s=this._objects;for(n=0,r=s.length;n<r;n++)(i=s[n]).excludeFromExport||this._setSVGObject(t,i,e)},_setSVGObject:function(t,e,i){t.push(e.toSVG(i))},_setSVGBgOverlayImage:function(t,e,i){this[e]&&!this[e].excludeFromExport&&this[e].toSVG&&t.push(this[e].toSVG(i))},_setSVGBgOverlayColor:function(t,e){var i=this[e+"Color"],n=this.viewportTransform,s=this.width,o=this.height;if(i)if(i.toLive){var a=i.repeat,l=r.util.invertTransform(n),c=this[e+"Vpt"]?r.util.matrixToSVG(l):"";t.push('<rect transform="'+c+" translate(",s/2,",",o/2,')"',' x="',i.offsetX-s/2,'" y="',i.offsetY-o/2,'" ','width="',"repeat-y"===a||"no-repeat"===a?i.source.width:s,'" height="',"repeat-x"===a||"no-repeat"===a?i.source.height:o,'" fill="url(#SVGID_'+i.id+')"',"></rect>\n")}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',"></rect>\n")},sendToBack:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(e=(r=s._objects).length;e--;)n=r[e],i(this._objects,n),this._objects.unshift(n);else i(this._objects,t),this._objects.unshift(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(t){if(!t)return this;var e,n,r,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(e=0,r=s._objects;e<r.length;e++)n=r[e],i(this._objects,n),this._objects.push(n);else i(this._objects,t),this._objects.push(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},sendBackwards:function(t,e){if(!t)return this;var n,r,s,o,a,l=this._activeObject,c=0;if(t===l&&"activeSelection"===t.type)for(n=0,a=l._objects;n<a.length;n++)r=a[n],(s=this._objects.indexOf(r))>0+c&&(o=s-1,i(this._objects,r),this._objects.splice(o,0,r)),c++;else 0!==(s=this._objects.indexOf(t))&&(o=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(t,e,i){var n,r;if(i){for(n=e,r=e-1;r>=0;--r)if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e-1;return n},bringForward:function(t,e){if(!t)return this;var n,r,s,o,a,l=this._activeObject,c=0;if(t===l&&"activeSelection"===t.type)for(n=(a=l._objects).length;n--;)r=a[n],(s=this._objects.indexOf(r))<this._objects.length-1-c&&(o=s+1,i(this._objects,r),this._objects.splice(o,0,r)),c++;else(s=this._objects.indexOf(t))!==this._objects.length-1&&(o=this._findNewUpperIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewUpperIndex:function(t,e,i){var n,r,s;if(i){for(n=e,r=e+1,s=this._objects.length;r<s;++r)if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e+1;return n},moveTo:function(t,e){return i(this._objects,t),this._objects.splice(e,0,t),this.renderOnAddRemove&&this.requestRenderAll()},dispose:function(){return this.isRendering&&(r.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject(function(t){t.dispose&&t.dispose()}),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),r.util.setStyle(this.lowerCanvasEl,this._originalCanvasStyle),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),r.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this._objects.length+" }>"}}),t(r.StaticCanvas.prototype,r.Observable),t(r.StaticCanvas.prototype,r.Collection),t(r.StaticCanvas.prototype,r.DataURLExporter),t(r.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=l();if(!e||!e.getContext)return null;var i=e.getContext("2d");return i&&"setLineDash"===t?void 0!==i.setLineDash:null}}),r.StaticCanvas.prototype.toJSON=r.StaticCanvas.prototype.toObject,r.isLikelyNode&&(r.StaticCanvas.prototype.createPNGStream=function(){var t=a(this.lowerCanvasEl);return t&&t.createPNGStream()},r.StaticCanvas.prototype.createJPEGStream=function(t){var e=a(this.lowerCanvasEl);return e&&e.createJPEGStream(t)})}(),r.BaseBrush=r.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(t){var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},_setShadow:function(){if(this.shadow){var t=this.canvas,e=this.shadow,i=t.contextTop,n=t.getZoom();t&&t._isRetinaScaling()&&(n*=r.devicePixelRatio),i.shadowColor=e.color,i.shadowBlur=e.blur*n,i.shadowOffsetX=e.offsetX*n,i.shadowOffsetY=e.offsetY*n}},needsFullRender:function(){return 1>new r.Color(this.color).getAlpha()||!!this.shadow},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0},_isOutSideCanvas:function(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}),r.PencilBrush=r.util.createClass(r.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(t){this.canvas=t,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(t,e,i){var n=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,n.x,n.y),n},onMouseDown:function(t,e){this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],this._prepareForDrawing(t),this._captureDrawingPath(t),this._render())},onMouseMove:function(t,e){if(this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],!(!0===this.limitedToCanvasSize&&this._isOutSideCanvas(t))&&this._captureDrawingPath(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var i=this._points,n=i.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(r,i[n-2],i[n-1],!0),r.stroke(),r.restore()}},onMouseUp:function(t){return!this.canvas._isMainEvent(t.e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(t){var e=new r.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(t){var e=new r.Point(t.x,t.y);return this._addPoint(e)},_render:function(t){var e,i,n=this._points[0],s=this._points[1];if(t=t||this.canvas.contextTop,this._saveAndTransform(t),t.beginPath(),2===this._points.length&&n.x===s.x&&n.y===s.y){var o=this.width/1e3;n=new r.Point(n.x,n.y),s=new r.Point(s.x,s.y),n.x-=o,s.x+=o}for(t.moveTo(n.x,n.y),e=1,i=this._points.length;e<i;e++)this._drawSegment(t,n,s),n=this._points[e],s=this._points[e+1];t.lineTo(n.x,n.y),t.stroke(),t.restore()},convertPointsToSVGPath:function(t){var e=this.width/1e3;return r.util.getSmoothPathFromPoints(t,e)},_isEmptySVGPath:function(t){return"M 0 0 Q 0 0 0 0 L 0 0"===r.util.joinPath(t)},createPath:function(t){var e=new r.Path(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,e.shadow=new r.Shadow(this.shadow)),e},decimatePoints:function(t,e){if(t.length<=2)return t;var i,n=Math.pow(e/this.canvas.getZoom(),2),r=t.length-1,s=t[0],o=[s];for(i=1;i<r-1;i++)Math.pow(s.x-t[i].x,2)+Math.pow(s.y-t[i].y,2)>=n&&o.push(s=t[i]);return o.push(t[r]),o},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var t=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(t))return void this.canvas.requestRenderAll();var e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}),r.CircleBrush=r.util.createClass(r.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()},dot:function(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},_render:function(){var t,e,i=this.canvas.contextTop,n=this.points;for(this._saveAndTransform(i),t=0,e=n.length;t<e;t++)this.dot(i,n[t]);i.restore()},onMouseMove:function(t){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(t)||(this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(t),this._render()):this.drawDot(t))},onMouseUp:function(){var t,e,i=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;var n=[];for(t=0,e=this.points.length;t<e;t++){var s=this.points[t],o=new r.Circle({radius:s.radius,left:s.x,top:s.y,originX:"center",originY:"center",fill:s.fill});this.shadow&&(o.shadow=new r.Shadow(this.shadow)),n.push(o)}var a=new r.Group(n);a.canvas=this.canvas,this.canvas.fire("before:path:created",{path:a}),this.canvas.add(a),this.canvas.fire("path:created",{path:a}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=i,this.canvas.requestRenderAll()},addPoint:function(t){var e=new r.Point(t.x,t.y),i=r.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,n=new r.Color(this.color).setAlpha(r.util.getRandomInt(0,100)/100).toRgba();return e.radius=i,e.fill=n,this.points.push(e),e}}),r.SprayBrush=r.util.createClass(r.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(t){this.canvas=t,this.sprayChunks=[]},onMouseDown:function(t){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(t),this.render(this.sprayChunkPoints)},onMouseMove:function(t){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(t)||(this.addSprayChunk(t),this.render(this.sprayChunkPoints))},onMouseUp:function(){var t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var e=[],i=0,n=this.sprayChunks.length;i<n;i++)for(var s=this.sprayChunks[i],o=0,a=s.length;o<a;o++){var l=new r.Rect({width:s[o].width,height:s[o].width,left:s[o].x+1,top:s[o].y+1,originX:"center",originY:"center",fill:this.color});e.push(l)}this.optimizeOverlapping&&(e=this._getOptimizedRects(e));var c=new r.Group(e);this.shadow&&c.set("shadow",new r.Shadow(this.shadow)),this.canvas.fire("before:path:created",{path:c}),this.canvas.add(c),this.canvas.fire("path:created",{path:c}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=t,this.canvas.requestRenderAll()},_getOptimizedRects:function(t){var e,i,n,r={};for(i=0,n=t.length;i<n;i++)r[e=t[i].left+""+t[i].top]||(r[e]=t[i]);var s=[];for(e in r)s.push(r[e]);return s},render:function(t){var e,i,n=this.canvas.contextTop;for(n.fillStyle=this.color,this._saveAndTransform(n),e=0,i=t.length;e<i;e++){var r=t[e];void 0!==r.opacity&&(n.globalAlpha=r.opacity),n.fillRect(r.x,r.y,r.width,r.width)}n.restore()},_render:function(){var t,e,i=this.canvas.contextTop;for(i.fillStyle=this.color,this._saveAndTransform(i),t=0,e=this.sprayChunks.length;t<e;t++)this.render(this.sprayChunks[t]);i.restore()},addSprayChunk:function(t){this.sprayChunkPoints=[];var e,i,n,s,o=this.width/2;for(s=0;s<this.density;s++){e=r.util.getRandomInt(t.x-o,t.x+o),i=r.util.getRandomInt(t.y-o,t.y+o),n=this.dotWidthVariance?r.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth;var a=new r.Point(e,i);a.width=n,this.randomOpacity&&(a.opacity=r.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(a)}this.sprayChunks.push(this.sprayChunkPoints)}}),r.PatternBrush=r.util.createClass(r.PencilBrush,{getPatternSrc:function(){var t=r.util.createCanvasElement(),e=t.getContext("2d");return t.width=t.height=25,e.fillStyle=this.color,e.beginPath(),e.arc(10,10,10,0,2*Math.PI,!1),e.closePath(),e.fill(),t},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(t){return t.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(t){this.callSuper("_setBrushStyles",t),t.strokeStyle=this.getPattern(t)},createPath:function(t){var e=this.callSuper("createPath",t),i=e._getLeftTopCoords().scalarAdd(e.strokeWidth/2);return e.stroke=new r.Pattern({source:this.source||this.getPatternSrcFunction(),offsetX:-i.x,offsetY:-i.y}),e}}),function(){var t=r.util.getPointer,e=r.util.degreesToRadians,i=r.util.isTouchEvent;for(var n in r.Canvas=r.util.createClass(r.StaticCanvas,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e),this._initInteractive(),this._createCacheCanvas()},uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",interactive:!0,selection:!0,selectionKey:"shiftKey",altSelectionKey:null,selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,preserveObjectStacking:!1,snapAngle:0,snapThreshold:null,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,targets:[],enablePointerEvents:!1,_hoveredTarget:null,_hoveredTargets:[],_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=r.PencilBrush&&new r.PencilBrush(this),this.calcOffset()},_chooseObjectsToRender:function(){var t,e,i,n=this.getActiveObjects();if(n.length>0&&!this.preserveObjectStacking){e=[],i=[];for(var r=0,s=this._objects.length;r<s;r++)t=this._objects[r],-1===n.indexOf(t)?e.push(t):i.push(t);n.length>1&&(this._activeObject._objects=i),e.push.apply(e,i)}else e=this._objects;return e},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),n=r.util.invertTransform(i),s=this.restorePointerVpt(e);return r.util.transformPoint(s,n)},isTargetTransparent:function(t,e,i){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var n=this._normalizePointer(t,{x:e,y:i}),s=Math.max(t.cacheTranslationX+n.x*t.zoomX,0),o=Math.max(t.cacheTranslationY+n.y*t.zoomY,0),a=r.util.isTransparent(t._cacheContext,Math.round(s),Math.round(o),this.targetFindTolerance);return a}var l=this.contextCache,c=t.selectionBackgroundColor,h=this.viewportTransform;t.selectionBackgroundColor="",this.clearContext(l),l.save(),l.transform(h[0],h[1],h[2],h[3],h[4],h[5]),t.render(l),l.restore(),t.selectionBackgroundColor=c;var a=r.util.isTransparent(l,e,i,this.targetFindTolerance);return a},_isSelectionKeyPressed:function(t){return Array.isArray(this.selectionKey)?!!this.selectionKey.find(function(e){return!0===t[e]}):t[this.selectionKey]},_shouldClearSelection:function(t,e){var i=this.getActiveObjects(),n=this._activeObject;return!e||e&&n&&i.length>1&&-1===i.indexOf(e)&&n!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&n&&n!==e},_shouldCenterTransform:function(t,e,i){var n;if(t)return"scale"===e||"scaleX"===e||"scaleY"===e||"resizing"===e?n=this.centeredScaling||t.centeredScaling:"rotate"===e&&(n=this.centeredRotation||t.centeredRotation),n?!i:i},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":("mr"===e||"tr"===e||"br"===e)&&(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":("bl"===e||"mb"===e||"br"===e)&&(i.y="top"),i},_getActionFromCorner:function(t,e,i,n){if(!e||!t)return"drag";var r=n.controls[e];return r.getActionName(i,r,n)},_setupCurrentTransform:function(t,i,n){if(i){var s=this.getPointer(t),o=i.__corner,a=i.controls[o],l=n&&o?a.getActionHandler(t,i,a):r.controlsUtils.dragHandler,c=this._getActionFromCorner(n,o,t,i),h=this._getOriginFromCorner(i,o),u=t[this.centeredKey],f={target:i,action:c,actionHandler:l,corner:o,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:s.x-i.left,offsetY:s.y-i.top,originX:h.x,originY:h.y,ex:s.x,ey:s.y,lastX:s.x,lastY:s.y,theta:e(i.angle),width:i.width*i.scaleX,shiftKey:t.shiftKey,altKey:u,original:r.util.saveObjectTransform(i)};this._shouldCenterTransform(i,c,u)&&(f.originX="center",f.originY="center"),f.original.originX=h.x,f.original.originY=h.y,this._currentTransform=f,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var e=this._groupSelector,i=new r.Point(e.ex,e.ey),n=r.util.transformPoint(i,this.viewportTransform),s=new r.Point(e.ex+e.left,e.ey+e.top),o=r.util.transformPoint(s,this.viewportTransform),a=Math.min(n.x,o.x),l=Math.min(n.y,o.y),c=Math.max(n.x,o.x),h=Math.max(n.y,o.y),u=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(a,l,c-a,h-l)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,a+=u,l+=u,c-=u,h-=u,r.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(a,l,c-a,h-l))},findTarget:function(t,e){if(!this.skipTargetFind){var n,r,s=this.getPointer(t,!0),o=this._activeObject,a=this.getActiveObjects(),l=i(t),c=a.length>1&&!e||1===a.length;if(this.targets=[],c&&o._findTargetCorner(s,l)||a.length>1&&!e&&o===this._searchPossibleTargets([o],s))return o;if(1===a.length&&o===this._searchPossibleTargets([o],s))if(!this.preserveObjectStacking)return o;else n=o,r=this.targets,this.targets=[];var h=this._searchPossibleTargets(this._objects,s);return t[this.altSelectionKey]&&h&&n&&h!==n&&(h=n,this.targets=r),h}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&e.containsPoint(t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;else if(!this.isTargetTransparent(e,i.x,i.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,n,s=t.length;s--;){var o=t[s],a=o.group?this._normalizePointer(o.group,e):e;if(this._checkTarget(a,o,e)){(i=t[s]).subTargetCheck&&i instanceof r.Group&&(n=this._searchPossibleTargets(i._objects,e))&&this.targets.push(n);break}}return i},restorePointerVpt:function(t){return r.util.transformPoint(t,r.util.invertTransform(this.viewportTransform))},getPointer:function(e,i){if(this._absolutePointer&&!i)return this._absolutePointer;if(this._pointer&&i)return this._pointer;var n,r=t(e),s=this.upperCanvasEl,o=s.getBoundingClientRect(),a=o.width||0,l=o.height||0;(!a||!l)&&("top"in o&&"bottom"in o&&(l=Math.abs(o.top-o.bottom)),"right"in o&&"left"in o&&(a=Math.abs(o.right-o.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,i||(r=this.restorePointerVpt(r));var c=this.getRetinaScaling();return 1!==c&&(r.x/=c,r.y/=c),n=0===a||0===l?{width:1,height:1}:{width:s.width/a,height:s.height/l},{x:r.x*n.width,y:r.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),e=this.lowerCanvasEl,i=this.upperCanvasEl;i?i.className="":(i=this._createCanvasElement(),this.upperCanvasEl=i),r.util.addClass(i,"upper-canvas "+t),this.wrapperEl.appendChild(i),this._copyCanvasStyle(e,i),this._applyCanvasStyle(i),this.contextTop=i.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=r.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),r.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),r.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.width||t.width,i=this.height||t.height;r.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=e,t.height=i,r.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;if(t)if("activeSelection"===t.type&&t._objects)return t._objects.slice(0);else return[t];return[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,e){var i=!1,n=this.getActiveObjects(),r=[],s=[];t.forEach(function(t){-1===n.indexOf(t)&&(i=!0,t.fire("deselected",{e:e,target:t}),s.push(t))}),n.forEach(function(n){-1===t.indexOf(n)&&(i=!0,n.fire("selected",{e:e,target:n}),r.push(n))}),t.length>0&&n.length>0?i&&this.fire("selection:updated",{e:e,selected:r,deselected:s}):n.length>0?this.fire("selection:created",{e:e,selected:r}):t.length>0&&this.fire("selection:cleared",{e:e,deselected:s})},setActiveObject:function(t,e){var i=this.getActiveObjects();return this._setActiveObject(t,e),this._fireSelectionEvents(i,e),this},_setActiveObject:function(t,e){return!(this._activeObject===t||!this._discardActiveObject(e,t)||t.onSelect({e:e}))&&(this._activeObject=t,!0)},_discardActiveObject:function(t,e){var i=this._activeObject;if(i){if(i.onDeselect({e:t,object:e}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var e=this.getActiveObjects(),i=this.getActiveObject();return e.length&&this.fire("before:selection:cleared",{target:i,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(e,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach((function(t){r.util.cleanUpJsdomNode(this[t]),this[t]=void 0}).bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,r.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this._activeObject;e&&e._renderControls(t)},_toObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(t),r=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,n),r},_realizeGroupTransformOnObject:function(t){if(!t.group||"activeSelection"!==t.group.type||this._activeObject!==t.group)return null;var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach(function(i){e[i]=t[i]}),r.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(e);this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,n)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),r.StaticCanvas.prototype.setViewportTransform.call(this,t)}}),r.StaticCanvas)"prototype"!==n&&(r.Canvas[n]=r.StaticCanvas[n])}(),function(){var t=r.util.addListener,e=r.util.removeListener,i={passive:!1};function n(t,e){return t.button&&t.button===e-1}r.util.object.extend(r.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(t,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(t,e){var n=this.upperCanvasEl,s=this._getEventPrefix();t(r.window,"resize",this._onResize),t(n,s+"down",this._onMouseDown),t(n,s+"move",this._onMouseMove,i),t(n,s+"out",this._onMouseOut),t(n,s+"enter",this._onMouseEnter),t(n,"wheel",this._onMouseWheel),t(n,"contextmenu",this._onContextMenu),t(n,"dblclick",this._onDoubleClick),t(n,"dragover",this._onDragOver),t(n,"dragenter",this._onDragEnter),t(n,"dragleave",this._onDragLeave),t(n,"drop",this._onDrop),this.enablePointerEvents||t(n,"touchstart",this._onTouchStart,i),"undefined"!=typeof eventjs&&e in eventjs&&(eventjs[e](n,"gesture",this._onGesture),eventjs[e](n,"drag",this._onDrag),eventjs[e](n,"orientation",this._onOrientationChange),eventjs[e](n,"shake",this._onShake),eventjs[e](n,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(e,"remove");var t=this._getEventPrefix();e(r.document,t+"up",this._onMouseUp),e(r.document,"touchend",this._onTouchEnd,i),e(r.document,t+"move",this._onMouseMove,i),e(r.document,"touchmove",this._onMouseMove,i)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t});var i=this;this._hoveredTargets.forEach(function(e){i.fire("mouse:out",{target:e,e:t}),e&&e.fire("mouseout",{e:t})}),this._hoveredTargets=[]},_onMouseEnter:function(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onDragOver:function(t){t.preventDefault();var e=this._simpleEventHandler("dragover",t);this._fireEnterLeaveEvents(e,t)},_onDrop:function(t){return this._simpleEventHandler("drop:before",t),this._simpleEventHandler("drop",t)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onDoubleClick:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData(t)},getPointerId:function(t){var e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1},_isMainEvent:function(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)},_onTouchStart:function(n){n.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(n)),this.__onMouseDown(n),this._resetTransformEventData();var s=this.upperCanvasEl,o=this._getEventPrefix();t(r.document,"touchend",this._onTouchEnd,i),t(r.document,"touchmove",this._onMouseMove,i),e(s,o+"down",this._onMouseDown)},_onMouseDown:function(n){this.__onMouseDown(n),this._resetTransformEventData();var s=this.upperCanvasEl,o=this._getEventPrefix();e(s,o+"move",this._onMouseMove,i),t(r.document,o+"up",this._onMouseUp),t(r.document,o+"move",this._onMouseMove,i)},_onTouchEnd:function(n){if(!(n.touches.length>0)){this.__onMouseUp(n),this._resetTransformEventData(),this.mainTouchId=null;var s=this._getEventPrefix();e(r.document,"touchend",this._onTouchEnd,i),e(r.document,"touchmove",this._onMouseMove,i);var o=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(function(){t(o.upperCanvasEl,s+"down",o._onMouseDown),o._willAddMouseDown=0},400)}},_onMouseUp:function(n){this.__onMouseUp(n),this._resetTransformEventData();var s=this.upperCanvasEl,o=this._getEventPrefix();this._isMainEvent(n)&&(e(r.document,o+"up",this._onMouseUp),e(r.document,o+"move",this._onMouseMove,i),t(s,o+"move",this._onMouseMove,i))},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t){var e=this._activeObject;return!!e!=!!t||!!e&&!!t&&e!==t||(e&&e.isEditing,!1)},__onMouseUp:function(t){var e,i,s,o=this._currentTransform,a=this._groupSelector,l=!1,c=!a||0===a.left&&0===a.top;if(this._cacheTransformEventData(t),s=this._target,this._handleEvent(t,"up:before"),n(t,3)){this.fireRightClick&&this._handleEvent(t,"up",3,c);return}if(n(t,2)){this.fireMiddleClick&&this._handleEvent(t,"up",2,c),this._resetTransformEventData();return}if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(this._isMainEvent(t)){if(o&&(this._finalizeCurrentTransform(t),l=o.actionPerformed),!c){var h=s===this._activeObject;this._maybeGroupObjects(t),l||(l=this._shouldRender(s)||!h&&s===this._activeObject)}if(s){if(e=s._findTargetCorner(this.getPointer(t,!0),r.util.isTouchEvent(t)),s.selectable&&s!==this._activeObject&&"up"===s.activeOn)this.setActiveObject(s,t),l=!0;else{var u=s.controls[e],f=u&&u.getMouseUpHandler(t,s,u);f&&(i=this.getPointer(t),f(t,o,i.x,i.y))}s.isMoving=!1}if(o&&(o.target!==s||o.corner!==e)){var d=o.target&&o.target.controls[o.corner],g=d&&d.getMouseUpHandler(t,s,u);i=i||this.getPointer(t),g&&g(t,o,i.x,i.y)}this._setCursorFromEvent(t,s),this._handleEvent(t,"up",1,c),this._groupSelector=null,this._currentTransform=null,s&&(s.__corner=0),l?this.requestRenderAll():c||this.renderTop()}},_simpleEventHandler:function(t,e){var i=this.findTarget(e),n=this.targets,r={e:e,target:i,subTargets:n};if(this.fire(t,r),i&&i.fire(t,r),!n)return i;for(var s=0;s<n.length;s++)n[s].fire(t,r);return i},_handleEvent:function(t,e,i,n){var r=this._target,s=this.targets||[],o={e:t,target:r,subTargets:s,button:i||1,isClick:n||!1,pointer:this._pointer,absolutePointer:this._absolutePointer,transform:this._currentTransform};"up"===e&&(o.currentTarget=this.findTarget(t),o.currentSubTargets=this.targets),this.fire("mouse:"+e,o),r&&r.fire("mouse"+e,o);for(var a=0;a<s.length;a++)s[a].fire("mouse"+e,o)},_finalizeCurrentTransform:function(t){var e=this._currentTransform,i=e.target,n={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),(e.actionPerformed||this.stateful&&i.hasStateChanged())&&this._fire("modified",n)},_onMouseDownInDrawingMode:function(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&this.discardActiveObject(t).requestRenderAll();var e=this.getPointer(t);this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down")},_onMouseMoveInDrawingMode:function(t){if(this._isCurrentlyDrawing){var e=this.getPointer(t);this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")},_onMouseUpInDrawingMode:function(t){var e=this.getPointer(t);this._isCurrentlyDrawing=this.freeDrawingBrush.onMouseUp({e:t,pointer:e}),this._handleEvent(t,"up")},__onMouseDown:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"down:before");var e=this._target;if(n(t,3)){this.fireRightClick&&this._handleEvent(t,"down",3);return}if(n(t,2)){this.fireMiddleClick&&this._handleEvent(t,"down",2);return}if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(this._isMainEvent(t)&&!this._currentTransform){var i=this._pointer;this._previousPointer=i;var s=this._shouldRender(e),o=this._shouldGroup(t,e);if(this._shouldClearSelection(t,e)?this.discardActiveObject(t):o&&(this._handleGrouping(t,e),e=this._activeObject),!this.selection||e&&(e.selectable||e.isEditing||e===this._activeObject)||(this._groupSelector={ex:this._absolutePointer.x,ey:this._absolutePointer.y,top:0,left:0}),e){var a=e===this._activeObject;e.selectable&&"down"===e.activeOn&&this.setActiveObject(e,t);var l=e._findTargetCorner(this.getPointer(t,!0),r.util.isTouchEvent(t));if(e.__corner=l,e===this._activeObject&&(l||!o)){this._setupCurrentTransform(t,e,a);var c=e.controls[l],i=this.getPointer(t),h=c&&c.getMouseDownHandler(t,e,c);h&&h(t,this._currentTransform,i.x,i.y)}}this._handleEvent(t,"down"),(s||o)&&this.requestRenderAll()}},_resetTransformEventData:function(){this._target=null,this._pointer=null,this._absolutePointer=null},_cacheTransformEventData:function(t){this._resetTransformEventData(),this._pointer=this.getPointer(t,!0),this._absolutePointer=this.restorePointerVpt(this._pointer),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)||null},_beforeTransform:function(t){var e=this._currentTransform;this.stateful&&e.target.saveState(),this.fire("before:transform",{e:t,transform:e})},__onMouseMove:function(t){if(this._handleEvent(t,"move:before"),this._cacheTransformEventData(t),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(this._isMainEvent(t)){var e,i,n=this._groupSelector;n?(n.left=(i=this._absolutePointer).x-n.ex,n.top=i.y-n.ey,this.renderTop()):this._currentTransform?this._transformObject(t):(e=this.findTarget(t)||null,this._setCursorFromEvent(t,e),this._fireOverOutEvents(e,t)),this._handleEvent(t,"move"),this._resetTransformEventData()}},_fireOverOutEvents:function(t,e){var i=this._hoveredTarget,n=this._hoveredTargets,r=this.targets,s=Math.max(n.length,r.length);this.fireSyntheticInOutEvents(t,e,{oldTarget:i,evtOut:"mouseout",canvasEvtOut:"mouse:out",evtIn:"mouseover",canvasEvtIn:"mouse:over"});for(var o=0;o<s;o++)this.fireSyntheticInOutEvents(r[o],e,{oldTarget:n[o],evtOut:"mouseout",evtIn:"mouseover"});this._hoveredTarget=t,this._hoveredTargets=this.targets.concat()},_fireEnterLeaveEvents:function(t,e){var i=this._draggedoverTarget,n=this._hoveredTargets,r=this.targets,s=Math.max(n.length,r.length);this.fireSyntheticInOutEvents(t,e,{oldTarget:i,evtOut:"dragleave",evtIn:"dragenter"});for(var o=0;o<s;o++)this.fireSyntheticInOutEvents(r[o],e,{oldTarget:n[o],evtOut:"dragleave",evtIn:"dragenter"});this._draggedoverTarget=t},fireSyntheticInOutEvents:function(t,e,i){var n,r,s,o=i.oldTarget,a=o!==t,l=i.canvasEvtIn,c=i.canvasEvtOut;a&&(n={e:e,target:t,previousTarget:o},r={e:e,target:o,nextTarget:t}),s=t&&a,o&&a&&(c&&this.fire(c,r),o.fire(i.evtOut,r)),s&&(l&&this.fire(l,n),t.fire(i.evtIn,n))},__onMouseWheel:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()},_transformObject:function(t){var e=this.getPointer(t),i=this._currentTransform;i.reset=!1,i.shiftKey=t.shiftKey,i.altKey=t[this.centeredKey],this._performTransformAction(t,i,e),i.actionPerformed&&this.requestRenderAll()},_performTransformAction:function(t,e,i){var n=i.x,r=i.y,s=e.action,o=!1,a=e.actionHandler;a&&(o=a(t,e,n,r)),"drag"===s&&o&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||o},_fire:r.controlsUtils.fireEvent,_setCursorFromEvent:function(t,e){if(!e)return this.setCursor(this.defaultCursor),!1;var i=e.hoverCursor||this.hoverCursor,n=this._activeObject&&"activeSelection"===this._activeObject.type?this._activeObject:null,r=(!n||!n.contains(e))&&e._findTargetCorner(this.getPointer(t,!0));r?this.setCursor(this.getCornerCursor(r,e,t)):(e.subTargetCheck&&this.targets.concat().reverse().map(function(t){i=t.hoverCursor||i}),this.setCursor(i))},getCornerCursor:function(t,e,i){var n=e.controls[t];return n.cursorStyleHandler(i,n,e)}})}(),function(){var t=Math.min,e=Math.max;r.util.object.extend(r.Canvas.prototype,{_shouldGroup:function(t,e){var i=this._activeObject;return i&&this._isSelectionKeyPressed(t)&&e&&e.selectable&&this.selection&&(i!==e||"activeSelection"===i.type)&&!e.onSelect({e:t})},_handleGrouping:function(t,e){var i=this._activeObject;if(!i.__corner){if(e===i&&(!(e=this.findTarget(t,!0))||!e.selectable))return;i&&"activeSelection"===i.type?this._updateActiveSelection(e,t):this._createActiveSelection(e,t)}},_updateActiveSelection:function(t,e){var i=this._activeObject,n=i._objects.slice(0);i.contains(t)?(i.removeWithUpdate(t),this._hoveredTarget=t,this._hoveredTargets=this.targets.concat(),1===i.size()&&this._setActiveObject(i.item(0),e)):(i.addWithUpdate(t),this._hoveredTarget=i,this._hoveredTargets=this.targets.concat()),this._fireSelectionEvents(n,e)},_createActiveSelection:function(t,e){var i=this.getActiveObjects(),n=this._createGroup(t);this._hoveredTarget=n,this._setActiveObject(n,e),this._fireSelectionEvents(i,e)},_createGroup:function(t){var e=this._objects,i=e.indexOf(this._activeObject)<e.indexOf(t)?[this._activeObject,t]:[t,this._activeObject];return this._activeObject.isEditing&&this._activeObject.exitEditing(),new r.ActiveSelection(i,{canvas:this})},_groupSelectedObjects:function(t){var e,i=this._collectObjects(t);1===i.length?this.setActiveObject(i[0],t):i.length>1&&(e=new r.ActiveSelection(i.reverse(),{canvas:this}),this.setActiveObject(e,t))},_collectObjects:function(i){for(var n,s=[],o=this._groupSelector.ex,a=this._groupSelector.ey,l=o+this._groupSelector.left,c=a+this._groupSelector.top,h=new r.Point(t(o,l),t(a,c)),u=new r.Point(e(o,l),e(a,c)),f=!this.selectionFullyContained,d=o===l&&a===c,g=this._objects.length;g--&&!((n=this._objects[g])&&n.selectable&&n.visible&&(f&&n.intersectsWithRect(h,u,!0)||n.isContainedWithinRect(h,u,!0)||f&&n.containsPoint(h,null,!0)||f&&n.containsPoint(u,null,!0))&&(s.push(n),d)););return s.length>1&&(s=s.filter(function(t){return!t.onSelect({e:i})})),s},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t),this.setCursor(this.defaultCursor),this._groupSelector=null}})}(),r.util.object.extend(r.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,n=(t.multiplier||1)*(t.enableRetinaScaling?this.getRetinaScaling():1),s=this.toCanvasElement(n,t);return r.util.toDataURL(s,e,i)},toCanvasElement:function(t,e){t=t||1;var i=((e=e||{}).width||this.width)*t,n=(e.height||this.height)*t,s=this.getZoom(),o=this.width,a=this.height,l=s*t,c=this.viewportTransform,h=(c[4]-(e.left||0))*t,u=(c[5]-(e.top||0))*t,f=this.interactive,d=this.enableRetinaScaling,g=r.util.createCanvasElement(),p=this.contextTop;return g.width=i,g.height=n,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=[l,0,0,l,h,u],this.width=i,this.height=n,this.calcViewportBoundaries(),this.renderCanvas(g.getContext("2d"),this._objects),this.viewportTransform=c,this.width=o,this.height=a,this.calcViewportBoundaries(),this.interactive=f,this.enableRetinaScaling=d,this.contextTop=p,g}}),r.util.object.extend(r.StaticCanvas.prototype,{loadFromJSON:function(t,e,i){if(t){var n="string"==typeof t?JSON.parse(t):r.util.object.clone(t),s=this,o=n.clipPath,a=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete n.clipPath,this._enlivenObjects(n.objects,function(t){s.clear(),s._setBgOverlay(n,function(){o?s._enlivenObjects([o],function(i){s.clipPath=i[0],s.__setupCanvas.call(s,n,t,a,e)}):s.__setupCanvas.call(s,n,t,a,e)})},i),this}},__setupCanvas:function(t,e,i,n){var r=this;e.forEach(function(t,e){r.insertAt(t,e)}),this.renderOnAddRemove=i,delete t.objects,delete t.backgroundImage,delete t.overlayImage,delete t.background,delete t.overlay,this._setOptions(t),this.renderAll(),n&&n()},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(!t.backgroundImage&&!t.overlayImage&&!t.background&&!t.overlay){e&&e();return}var n=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,n),this.__setBgOverlay("overlayImage",t.overlayImage,i,n),this.__setBgOverlay("backgroundColor",t.background,i,n),this.__setBgOverlay("overlayColor",t.overlay,i,n)},__setBgOverlay:function(t,e,i,n){var s=this;if(!e){i[t]=!0,n&&n();return}"backgroundImage"===t||"overlayImage"===t?r.util.enlivenObjects([e],function(e){s[t]=e[0],i[t]=!0,n&&n()}):this["set"+r.util.string.capitalize(t,!0)](e,function(){i[t]=!0,n&&n()})},_enlivenObjects:function(t,e,i){if(!t||0===t.length){e&&e([]);return}r.util.enlivenObjects(t,function(t){e&&e(t)},null,i)},_toDataURL:function(t,e){this.clone(function(i){e(i.toDataURL(t))})},_toDataURLWithMultiplier:function(t,e,i){this.clone(function(n){i(n.toDataURLWithMultiplier(t,e))})},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData(function(e){e.loadFromJSON(i,function(){t&&t(e)})})},cloneWithoutData:function(t){var e=r.util.createCanvasElement();e.width=this.width,e.height=this.height;var i=new r.Canvas(e);this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,function(){i.renderAll(),t&&t(i)}),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,s=e.util.string.capitalize,o=e.util.degreesToRadians,a=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:a,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(t){t&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,n=t.width,r=t.height,s=e.maxCacheSideLimit,o=e.minCacheSideLimit;if(n<=s&&r<=s&&n*r<=i)return n<o&&(t.width=o),r<o&&(t.height=o),t;var a=e.util.limitDimsByArea(n/r,i),l=e.util.capValue,c=l(o,a.x,s),h=l(o,a.y,s);return n>c&&(t.zoomX/=n/c,t.width=c,t.capped=!0),r>h&&(t.zoomY/=r/h,t.height=h,t.capped=!0),t},_getCacheCanvasDimensions:function(){var t=this.getTotalObjectScaling(),e=this._getTransformedDimensions(0,0),i=e.x*t.scaleX/this.scaleX,n=e.y*t.scaleY/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(n+2),zoomX:t.scaleX,zoomY:t.scaleY,x:i,y:n}},_updateCacheCanvas:function(){var t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){var e=t._currentTransform.target,i=t._currentTransform.action;if(this===e&&i.slice&&"scale"===i.slice(0,5))return!1}var n,r,s=this._cacheCanvas,o=this._limitCacheSize(this._getCacheCanvasDimensions()),a=o.width,l=o.height,c=o.zoomX,h=o.zoomY,u=a!==this.cacheWidth||l!==this.cacheHeight,f=this.zoomX!==c||this.zoomY!==h;return(!!u||!!f)&&(u?(s.width=a,s.height=l):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,s.width,s.height)),n=o.x/2,r=o.y/2,this.cacheTranslationX=Math.round(s.width/2-n)+n,this.cacheTranslationY=Math.round(s.height/2-r)+r,this.cacheWidth=a,this.cacheHeight=l,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(c,h),this.zoomX=c,this.zoomY=h,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t){var e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,n={type:this.type,version:e.version,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.angle,i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};return this.clipPath&&!this.clipPath.excludeFromExport&&(n.clipPath=this.clipPath.toObject(t),n.clipPath.inverted=this.clipPath.inverted,n.clipPath.absolutePositioned=this.clipPath.absolutePositioned),e.util.populateWithProperties(this,n,t),this.includeDefaultValues||(n=this._removeDefaultValues(n)),n},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach(function(e){"left"!==e&&"top"!==e&&(t[e]===i[e]&&delete t[e],Array.isArray(t[e])&&Array.isArray(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e])}),t},toString:function(){return"#<fabric."+s(this.type)+">"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var t=e.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(t.scaleX),scaleY:Math.abs(t.scaleY)}},getTotalObjectScaling:function(){var t=this.getObjectScaling(),e=t.scaleX,i=t.scaleY;if(this.canvas){var n=this.canvas.getZoom(),r=this.canvas.getRetinaScaling();e*=n*r,i*=n*r}return{scaleX:e,scaleY:i}},getObjectOpacity:function(){var t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t},_set:function(t,i){var n="scaleX"===t||"scaleY"===t,r=this[t]!==i,s=!1;return n&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,r&&(s=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(t)>-1?(this.dirty=!0,s&&this.group.set("dirty",!0)):s&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible},render:function(t){!this.isNotVisible()&&(!this.canvas||!this.canvas.skipOffscreen||this.group||this.isOnScreen())&&(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(t),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),t.restore())},renderCache:function(t){t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,t.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!!("stroke"===this.paintFirst&&this.hasFill()&&this.hasStroke())&&"object"==typeof this.shadow||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(t,i){if(t.save(),i.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",i.absolutePositioned){var n=e.util.invertTransform(this.calcTransformMatrix());t.transform(n[0],n[1],n[2],n[3],n[4],n[5])}i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},drawObject:function(t,e){var i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath),this.fill=i,this.stroke=n},_drawClipPath:function(t,e){e&&(e.canvas=this.canvas,e.shouldCache(),e._transformDone=!0,e.renderCache({forClipping:!0}),this.drawClipPathOnCache(t,e))},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity},_setStrokeStyles:function(t,e){var i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,i.toLive?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)},_setFillStyles:function(t,e){var i=e.fill;i&&(i.toLive?(t.fillStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,e.fill)):t.fillStyle=i)},_setClippingProperties:function(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"},_setLineDash:function(t,e){e&&0!==e.length&&(1&e.length&&e.push.apply(e,e),t.setLineDash(e))},_renderControls:function(t,i){var n,r,s,a=this.getViewportTransform(),l=this.calcTransformMatrix();r=void 0!==(i=i||{}).hasBorders?i.hasBorders:this.hasBorders,s=void 0!==i.hasControls?i.hasControls:this.hasControls,l=e.util.multiplyTransformMatrices(a,l),n=e.util.qrDecompose(l),t.save(),t.translate(n.translateX,n.translateY),t.lineWidth=+this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(n.angle-=180),t.rotate(o(this.group?n.angle:this.angle)),i.forActiveSelection||this.group?r&&this.drawBordersInGroup(t,n,i):r&&this.drawBorders(t,i),s&&this.drawControls(t,i),t.restore()},_setShadow:function(t){if(this.shadow){var i,n=this.shadow,r=this.canvas,s=r&&r.viewportTransform[0]||1,o=r&&r.viewportTransform[3]||1;i=n.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),r&&r._isRetinaScaling()&&(s*=e.devicePixelRatio,o*=e.devicePixelRatio),t.shadowColor=n.color,t.shadowBlur=n.blur*e.browserShadowBlurConstant*(s+o)*(i.scaleX+i.scaleY)/4,t.shadowOffsetX=n.offsetX*s*i.scaleX,t.shadowOffsetY=n.offsetY*o*i.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=e.gradientTransform||e.patternTransform,n=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,n,r):t.transform(1,0,0,1,n,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:n,offsetY:r}},_renderPaintInOrder:function(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))},_render:function(){},_renderFill:function(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform&&this.group){var e=this.getObjectScaling();t.scale(1/e.scaleX,1/e.scaleY)}else this.strokeUniform&&t.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}},_applyPatternForTransformedGradient:function(t,i){var n,r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=e.util.createCanvasElement(),o=this.canvas.getRetinaScaling(),a=r.x/this.scaleX/o,l=r.y/this.scaleY/o;s.width=Math.ceil(a),s.height=Math.ceil(l),(n=s.getContext("2d")).beginPath(),n.moveTo(0,0),n.lineTo(a,0),n.lineTo(a,l),n.lineTo(0,l),n.closePath(),n.translate(a/2,l/2),n.scale(r.zoomX/this.scaleX/o,r.zoomY/this.scaleY/o),this._applyPatternGradientTransform(n,i),n.fillStyle=i.toLive(t),n.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(o*this.scaleX/r.zoomX,o*this.scaleY/r.zoomY),t.strokeStyle=n.createPattern(s,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var t=e.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",t.scaleX),this.set("scaleY",t.scaleY),this.angle=t.angle,this.skewX=t.skewX,this.skewY=0}},_removeTransformMatrix:function(t){var i=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),i=e.util.transformPoint(i,this.transformMatrix)),this.transformMatrix=null,t&&(this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this.cropX=t.cropX,this.cropY=t.cropY,i.x+=t.offsetLeft,i.y+=t.offsetTop,this.width=t.width,this.height=t.height),this.setPositionByOrigin(i,"center","center")},clone:function(t,i){var n=this.toObject(i);this.constructor.fromObject?this.constructor.fromObject(n,t):e.Object._fromObject("Object",n,t)},cloneAsImage:function(t,i){var n=this.toCanvasElement(i);return t&&t(new e.Image(n)),this},toCanvasElement:function(t){t||(t={});var i=e.util,n=i.saveObjectTransform(this),r=this.group,s=this.shadow,o=Math.abs,a=(t.multiplier||1)*(t.enableRetinaScaling?e.devicePixelRatio:1);delete this.group,t.withoutTransform&&i.resetObjectTransform(this),t.withoutShadow&&(this.shadow=null);var l,c,h,u,f=e.util.createCanvasElement(),d=this.getBoundingRect(!0,!0),g=this.shadow,p={x:0,y:0};g&&(c=g.blur,l=g.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),p.x=2*Math.round(o(g.offsetX)+c)*o(l.scaleX),p.y=2*Math.round(o(g.offsetY)+c)*o(l.scaleY)),h=d.width+p.x,u=d.height+p.y,f.width=Math.ceil(h),f.height=Math.ceil(u);var m=new e.StaticCanvas(f,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===t.format&&(m.backgroundColor="#fff"),this.setPositionByOrigin(new e.Point(m.width/2,m.height/2),"center","center");var y=this.canvas;m.add(this);var b=m.toCanvasElement(a||1,t);return this.shadow=s,this.set("canvas",y),r&&(this.group=r),this.set(n).setCoords(),m._objects=[],m.dispose(),m=null,b},toDataURL:function(t){return t||(t={}),e.util.toDataURL(this.toCanvasElement(t),t.format||"png",t.quality||1)},isType:function(t){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},rotate:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var n=new e.Point(i.x,i.y),r=this._getLeftTopCoords();return this.angle&&(n=e.util.rotatePoint(n,r,o(-this.angle))),{x:n.x-r.x,y:n.y-r.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){e.runningAnimations&&e.runningAnimations.cancelByTarget(this)}}),e.util.createAccessors&&e.util.createAccessors(e.Object),i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object.ENLIVEN_PROPS=["clipPath"],e.Object._fromObject=function(t,i,r,s){var o=e[t];i=n(i,!0),e.util.enlivenPatterns([i.fill,i.stroke],function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]),e.util.enlivenObjectEnlivables(i,i,function(){var t=s?new o(i[s],i):new o(i);r&&r(t)})})},e.Object.__uid=0)}(i),function(){var t=r.util.degreesToRadians,e={left:-.5,center:0,right:.5},i={top:-.5,center:0,bottom:.5};r.util.object.extend(r.Object.prototype,{translateToGivenOrigin:function(t,n,s,o,a){var l,c,h,u=t.x,f=t.y;return"string"==typeof n?n=e[n]:n-=.5,"string"==typeof o?o=e[o]:o-=.5,l=o-n,"string"==typeof s?s=i[s]:s-=.5,"string"==typeof a?a=i[a]:a-=.5,c=a-s,(l||c)&&(h=this._getTransformedDimensions(),u=t.x+l*h.x,f=t.y+c*h.y),new r.Point(u,f)},translateToCenterPoint:function(e,i,n){var s=this.translateToGivenOrigin(e,i,n,"center","center");return this.angle?r.util.rotatePoint(s,e,t(this.angle)):s},translateToOriginPoint:function(e,i,n){var s=this.translateToGivenOrigin(e,"center","center",i,n);return this.angle?r.util.rotatePoint(s,e,t(this.angle)):s},getCenterPoint:function(){var t=new r.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(e,i,n){var s,o,a=this.getCenterPoint();return s=void 0!==i&&void 0!==n?this.translateToGivenOrigin(a,"center","center",i,n):new r.Point(this.left,this.top),o=new r.Point(e.x,e.y),this.angle&&(o=r.util.rotatePoint(o,a,-t(this.angle))),o.subtractEquals(s)},setPositionByOrigin:function(t,e,i){var n=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(n,this.originX,this.originY);this.set("left",r.x),this.set("top",r.y)},adjustPosition:function(i){var n,s,o=t(this.angle),a=this.getScaledWidth(),l=r.util.cos(o)*a,c=r.util.sin(o)*a;n="string"==typeof this.originX?e[this.originX]:this.originX-.5,s="string"==typeof i?e[i]:i-.5,this.left+=l*(s-n),this.top+=c*(s-n),this.setCoords(),this.originX=i},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}})}(),function(){var t=r.util,e=t.degreesToRadians,i=t.multiplyTransformMatrices,n=t.transformPoint;t.object.extend(r.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(t,e){return e?t?this.calcACoords():this.calcLineCoords():(this.aCoords&&this.lineCoords||this.setCoords(!0),t?this.aCoords:this.lineCoords)},getCoords:function(t,e){var i;return i=this._getCoords(t,e),[new r.Point(i.tl.x,i.tl.y),new r.Point(i.tr.x,i.tr.y),new r.Point(i.br.x,i.br.y),new r.Point(i.bl.x,i.bl.y)]},intersectsWithRect:function(t,e,i,n){var s=this.getCoords(i,n);return"Intersection"===r.Intersection.intersectPolygonRectangle(s,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===r.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var n=this.getCoords(e,i),r=e?t.aCoords:t.lineCoords,s=0,o=t._getImageLines(r);s<4;s++)if(!t.containsPoint(n[s],o))return!1;return!0},isContainedWithinRect:function(t,e,i,n){var r=this.getBoundingRect(i,n);return r.left>=t.x&&r.left+r.width<=e.x&&r.top>=t.y&&r.top+r.height<=e.y},containsPoint:function(t,e,i,n){var r=this._getCoords(i,n),e=e||this._getImageLines(r),s=this._findCrossPoints(t,e);return 0!==s&&s%2==1},isOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!(this.getCoords(!0,t).some(function(t){return t.x<=i.x&&t.x>=e.x&&t.y<=i.y&&t.y>=e.y})||this.intersectsWithRect(e,i,!0,t))||this._containsCenterOfCanvas(e,i,t)},_containsCenterOfCanvas:function(t,e,i){var n={x:(t.x+e.x)/2,y:(t.y+e.y)/2};return!!this.containsPoint(n,null,!0,i)},isPartiallyOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.intersectsWithRect(e,i,!0,t)||this.getCoords(!0,t).every(function(t){return(t.x>=i.x||t.x<=e.x)&&(t.y>=i.y||t.y<=e.y)})&&this._containsCenterOfCanvas(e,i,t)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,n,r,s=0;for(var o in e)if((!((r=e[o]).o.y<t.y)||!(r.d.y<t.y))&&(!(r.o.y>=t.y)||!(r.d.y>=t.y))&&(r.o.x===r.d.x&&r.o.x>=t.x?n=r.o.x:(i=(r.d.y-r.o.y)/(r.d.x-r.o.x),n=-(t.y-0*t.x-(r.o.y-i*r.o.x))/(0-i)),n>=t.x&&(s+=1),2===s))break;return s},getBoundingRect:function(e,i){var n=this.getCoords(e,i);return t.makeBoundingBoxFromPoints(n)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){if(Math.abs(t)<this.minScaleLimit)if(t<0)return-this.minScaleLimit;else return this.minScaleLimit;return 0===t?1e-4:t},scale:function(t){return this._set("scaleX",t),this._set("scaleY",t),this.setCoords()},scaleToWidth:function(t,e){var i=this.getBoundingRect(e).width/this.getScaledWidth();return this.scale(t/this.width/i)},scaleToHeight:function(t,e){var i=this.getBoundingRect(e).height/this.getScaledHeight();return this.scale(t/this.height/i)},calcLineCoords:function(){var i=this.getViewportTransform(),r=this.padding,s=e(this.angle),o=t.cos(s),a=t.sin(s),l=o*r,c=a*r,h=l+c,u=l-c,f=this.calcACoords(),d={tl:n(f.tl,i),tr:n(f.tr,i),bl:n(f.bl,i),br:n(f.br,i)};return r&&(d.tl.x-=u,d.tl.y-=h,d.tr.x+=h,d.tr.y-=u,d.bl.x-=h,d.bl.y+=u,d.br.x+=u,d.br.y+=h),d},calcOCoords:function(){var t=this._calcRotateMatrix(),e=this._calcTranslateMatrix(),n=this.getViewportTransform(),r=i(n,e),s=i(r,t),s=i(s,[1/n[0],0,0,1/n[3],0,0]),o=this._calculateCurrentDimensions(),a={};return this.forEachControl(function(t,e,i){a[e]=t.positionHandler(o,s,i)}),a},calcACoords:function(){var t=this._calcRotateMatrix(),e=i(this._calcTranslateMatrix(),t),r=this._getTransformedDimensions(),s=r.x/2,o=r.y/2;return{tl:n({x:-s,y:-o},e),tr:n({x:s,y:-o},e),bl:n({x:-s,y:o},e),br:n({x:s,y:o},e)}},setCoords:function(t){return this.aCoords=this.calcACoords(),this.lineCoords=this.group?this.aCoords:this.calcLineCoords(),t||(this.oCoords=this.calcOCoords(),this._setCornerCoords&&this._setCornerCoords()),this},_calcRotateMatrix:function(){return t.calcRotateMatrix(this)},_calcTranslateMatrix:function(){var t=this.getCenterPoint();return[1,0,0,1,t.x,t.y]},transformMatrixKey:function(t){var e="";return!t&&this.group&&(e=this.group.transformMatrixKey(t)+"_"),e+this.top+"_"+this.left+"_"+this.scaleX+"_"+this.scaleY+"_"+this.skewX+"_"+this.skewY+"_"+this.angle+"_"+this.originX+"_"+this.originY+"_"+this.width+"_"+this.height+"_"+this.strokeWidth+this.flipX+this.flipY},calcTransformMatrix:function(t){var e=this.calcOwnMatrix();if(t||!this.group)return e;var n=this.transformMatrixKey(t),r=this.matrixCache||(this.matrixCache={});return r.key===n?r.value:(this.group&&(e=i(this.group.calcTransformMatrix(!1),e)),r.key=n,r.value=e,e)},calcOwnMatrix:function(){var e=this.transformMatrixKey(!0),i=this.ownMatrixCache||(this.ownMatrixCache={});if(i.key===e)return i.value;var n=this._calcTranslateMatrix(),r={angle:this.angle,translateX:n[4],translateY:n[5],scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY};return i.key=e,i.value=t.composeMatrix(r),i.value},_getNonTransformedDimensions:function(){var t=this.strokeWidth;return{x:this.width+t,y:this.height+t}},_getTransformedDimensions:function(e,i){void 0===e&&(e=this.skewX),void 0===i&&(i=this.skewY);var n,r,s,o=0===e&&0===i;if(this.strokeUniform?(r=this.width,s=this.height):(r=(n=this._getNonTransformedDimensions()).x,s=n.y),o)return this._finalizeDimensions(r*this.scaleX,s*this.scaleY);var a=t.sizeAfterTransform(r,s,{scaleX:this.scaleX,scaleY:this.scaleY,skewX:e,skewY:i});return this._finalizeDimensions(a.x,a.y)},_finalizeDimensions:function(t,e){return this.strokeUniform?{x:t+this.strokeWidth,y:e+this.strokeWidth}:{x:t,y:e}},_calculateCurrentDimensions:function(){var t=this.getViewportTransform();return n(this._getTransformedDimensions(),t,!0).scalarAdd(2*this.padding)}})}(),r.util.object.extend(r.Object.prototype,{sendToBack:function(){return this.group?r.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas&&this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?r.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas&&this.canvas.bringToFront(this),this},sendBackwards:function(t){return this.group?r.StaticCanvas.prototype.sendBackwards.call(this.group,this,t):this.canvas&&this.canvas.sendBackwards(this,t),this},bringForward:function(t){return this.group?r.StaticCanvas.prototype.bringForward.call(this.group,this,t):this.canvas&&this.canvas.bringForward(this,t),this},moveTo:function(t){return this.group&&"activeSelection"!==this.group.type?r.StaticCanvas.prototype.moveTo.call(this.group,this,t):this.canvas&&this.canvas.moveTo(this,t),this}}),function(){function t(t,e){if(!e)return t+": none; ";if(e.toLive)return t+": url(#SVGID_"+e.id+"); ";var i=new r.Color(e),n=t+": "+i.toRgb()+"; ",s=i.getAlpha();return 1!==s&&(n+=t+"-opacity: "+s.toString()+"; "),n}var e=r.util.toFixed;r.util.object.extend(r.Object.prototype,{getSvgStyles:function(e){var i=this.fillRule?this.fillRule:"nonzero",n=this.strokeWidth?this.strokeWidth:"0",r=this.strokeDashArray?this.strokeDashArray.join(" "):"none",s=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=void 0!==this.opacity?this.opacity:"1",h=this.visible?"":" visibility: hidden;",u=e?"":this.getSvgFilter(),f=t("fill",this.fill);return t("stroke",this.stroke)+"stroke-width: "+n+"; stroke-dasharray: "+r+"; stroke-linecap: "+o+"; stroke-dashoffset: "+s+"; stroke-linejoin: "+a+"; stroke-miterlimit: "+l+"; "+f+"fill-rule: "+i+"; opacity: "+c+";"+u+h},getSvgSpanStyles:function(e,i){var n=e.fontFamily?"font-family: "+(-1===e.fontFamily.indexOf("'")&&-1===e.fontFamily.indexOf('"')?"'"+e.fontFamily+"'":e.fontFamily)+"; ":"",r=e.strokeWidth?"stroke-width: "+e.strokeWidth+"; ":"",n=n,s=e.fontSize?"font-size: "+e.fontSize+"px; ":"",o=e.fontStyle?"font-style: "+e.fontStyle+"; ":"",a=e.fontWeight?"font-weight: "+e.fontWeight+"; ":"",l=e.fill?t("fill",e.fill):"",c=e.stroke?t("stroke",e.stroke):"",h=this.getSvgTextDecoration(e);return h&&(h="text-decoration: "+h+"; "),[c,r,n,s,o,a,h,l,e.deltaY?"baseline-shift: "+-e.deltaY+"; ":"",i?"white-space: pre; ":""].join("")},getSvgTextDecoration:function(t){return["overline","underline","line-through"].filter(function(e){return t[e.replace("-","")]}).join(" ")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgCommons:function(){return[this.id?'id="'+this.id+'" ':"",this.clipPath?'clip-path="url(#'+this.clipPath.clipPathId+')" ':""].join("")},getSvgTransform:function(t,e){var i=t?this.calcTransformMatrix():this.calcOwnMatrix();return'transform="'+r.util.matrixToSVG(i)+(e||"")+'" '},_setSVGBg:function(t){if(this.backgroundColor){var i=r.Object.NUM_FRACTION_DIGITS;t.push(" <rect ",this._getFillAttributes(this.backgroundColor),' x="',e(-this.width/2,i),'" y="',e(-this.height/2,i),'" width="',e(this.width,i),'" height="',e(this.height,i),'"></rect>\n')}},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})},toClipPathSVG:function(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})},_createBaseClipPathSVGMarkup:function(t,e){var i=(e=e||{}).reviver,n=e.additionalTransform||"",r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,i?i(t.join("")):t.join("")},_createBaseSVGMarkup:function(t,e){var i,n,s=(e=e||{}).noStyle,o=e.reviver,a=s?"":'style="'+this.getSvgStyles()+'" ',l=e.withShadow?'style="'+this.getSvgFilter()+'" ':"",c=this.clipPath,h=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",u=c&&c.absolutePositioned,f=this.stroke,d=this.fill,g=this.shadow,p=[],m=t.indexOf("COMMON_PARTS"),y=e.additionalTransform;return c&&(c.clipPathId="CLIPPATH_"+r.Object.__uid++,n='<clipPath id="'+c.clipPathId+'" >\n'+c.toClipPathSVG(o)+"</clipPath>\n"),u&&p.push("<g ",l,this.getSvgCommons()," >\n"),p.push("<g ",this.getSvgTransform(!1),u?"":l+this.getSvgCommons()," >\n"),i=""+a+h+(s?"":this.addPaintOrder())+" "+(y?'transform="'+y+'" ':""),t[m]=i,d&&d.toLive&&p.push(d.toSVG(this)),f&&f.toLive&&p.push(f.toSVG(this)),g&&p.push(g.toSVG(this)),c&&p.push(n),p.push(t.join("")),p.push("</g>\n"),u&&p.push("</g>\n"),o?o(p.join("")):p.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var t=r.util.object.extend,e="stateProperties";function i(e,i,n){var r={};n.forEach(function(t){r[t]=e[t]}),t(e[i],r,!0)}r.util.object.extend(r.Object.prototype,{hasStateChanged:function(t){var i="_"+(t=t||e);return Object.keys(this[i]).length<this[t].length||!function t(e,i,n){if(e===i)return!0;if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(var r=0,s=e.length;r<s;r++)if(!t(e[r],i[r]))return!1;return!0}if(e&&"object"==typeof e){var o,a=Object.keys(e);if(!i||"object"!=typeof i||!n&&a.length!==Object.keys(i).length)return!1;for(var r=0,s=a.length;r<s;r++)if("canvas"!==(o=a[r])&&"group"!==o&&!t(e[o],i[o]))return!1;return!0}}(this[i],this,!0)},saveState:function(t){var n=t&&t.propertySet||e,r="_"+n;return this[r]?(i(this,r,this[n]),t&&t.stateProperties&&i(this,r,t.stateProperties),this):this.setupState(t)},setupState:function(t){var i=(t=t||{}).propertySet||e;return t.propertySet=i,this["_"+i]={},this.saveState(t),this}})}(),function(){var t=r.util.degreesToRadians;r.util.object.extend(r.Object.prototype,{_findTargetCorner:function(t,e){if(!this.hasControls||this.group||!this.canvas||this.canvas._activeObject!==this)return!1;var i,n,r,s=t.x,o=t.y,a=Object.keys(this.oCoords),l=a.length-1;for(this.__corner=0;l>=0;l--)if(r=a[l],this.isControlVisible(r)&&(n=this._getImageLines(e?this.oCoords[r].touchCorner:this.oCoords[r].corner),0!==(i=this._findCrossPoints({x:s,y:o},n))&&i%2==1))return this.__corner=r,r;return!1},forEachControl:function(t){for(var e in this.controls)t(this.controls[e],e,this)},_setCornerCoords:function(){var t=this.oCoords;for(var e in t){var i=this.controls[e];t[e].corner=i.calcCornerCoords(this.angle,this.cornerSize,t[e].x,t[e].y,!1),t[e].touchCorner=i.calcCornerCoords(this.angle,this.touchCornerSize,t[e].x,t[e].y,!0)}},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;e.save();var i=this.getCenterPoint(),n=this._calculateCurrentDimensions(),r=this.canvas.viewportTransform;return e.translate(i.x,i.y),e.scale(1/r[0],1/r[3]),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore(),this},drawBorders:function(t,e){e=e||{};var i=this._calculateCurrentDimensions(),n=this.borderScaleFactor,r=i.x+n,s=i.y+n,o=void 0!==e.hasControls?e.hasControls:this.hasControls,a=!1;return t.save(),t.strokeStyle=e.borderColor||this.borderColor,this._setLineDash(t,e.borderDashArray||this.borderDashArray),t.strokeRect(-r/2,-s/2,r,s),o&&(t.beginPath(),this.forEachControl(function(e,i,n){e.withConnection&&e.getVisibility(n,i)&&(a=!0,t.moveTo(e.x*r,e.y*s),t.lineTo(e.x*r+e.offsetX,e.y*s+e.offsetY))}),a&&t.stroke()),t.restore(),this},drawBordersInGroup:function(t,e,i){i=i||{};var n=r.util.sizeAfterTransform(this.width,this.height,e),s=this.strokeWidth,o=this.strokeUniform,a=this.borderScaleFactor,l=n.x+s*(o?this.canvas.getZoom():e.scaleX)+a,c=n.y+s*(o?this.canvas.getZoom():e.scaleY)+a;return t.save(),this._setLineDash(t,i.borderDashArray||this.borderDashArray),t.strokeStyle=i.borderColor||this.borderColor,t.strokeRect(-l/2,-c/2,l,c),t.restore(),this},drawControls:function(t,e){e=e||{},t.save();var i,n,s=1;return this.canvas&&(s=this.canvas.getRetinaScaling()),t.setTransform(s,0,0,s,0,0),t.strokeStyle=t.fillStyle=e.cornerColor||this.cornerColor,this.transparentCorners||(t.strokeStyle=e.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(t,e.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(i=this.group.calcTransformMatrix()),this.forEachControl(function(s,o,a){n=a.oCoords[o],s.getVisibility(a,o)&&(i&&(n=r.util.transformPoint(n,i)),s.render(t,n.x,n.y,e,a))}),t.restore(),this},isControlVisible:function(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)},setControlVisible:function(t,e){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e,this},setControlsVisibility:function(t){for(var e in t||(t={}),t)this.setControlVisible(e,t[e]);return this},onDeselect:function(){},onSelect:function(){}})}(),r.util.object.extend(r.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,s=e.onChange||i,o=this;return r.util.animate({target:this,startValue:t.left,endValue:this.getCenterPoint().x,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),o.requestRenderAll(),s()},onComplete:function(){t.setCoords(),n()}})},fxCenterObjectV:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,s=e.onChange||i,o=this;return r.util.animate({target:this,startValue:t.top,endValue:this.getCenterPoint().y,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),o.requestRenderAll(),s()},onComplete:function(){t.setCoords(),n()}})},fxRemove:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,s=e.onChange||i,o=this;return r.util.animate({target:this,startValue:t.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){t.set("opacity",e),o.requestRenderAll(),s()},onComplete:function(){o.remove(t),n()}})}}),r.util.object.extend(r.Object.prototype,{animate:function(){if(!arguments[0]||"object"!=typeof arguments[0])return this._animate.apply(this,arguments);var t,e,i=[],n=[];for(t in arguments[0])i.push(t);for(var r=0,s=i.length;r<s;r++)t=i[r],e=r!==s-1,n.push(this._animate(t,arguments[0][t],arguments[1],e));return n},_animate:function(t,e,i,n){var s,o=this;e=e.toString(),i=i?r.util.object.clone(i):{},~t.indexOf(".")&&(s=t.split("."));var a=o.colorProperties.indexOf(t)>-1||s&&o.colorProperties.indexOf(s[1])>-1,l=s?this.get(s[0])[s[1]]:this.get(t);"from"in i||(i.from=l),a||(e=~e.indexOf("=")?l+parseFloat(e.replace("=","")):parseFloat(e));var c={target:this,startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(t,e,n){return i.abort.call(o,t,e,n)},onChange:function(e,r,a){s?o[s[0]][s[1]]=e:o.set(t,e),!n&&i.onChange&&i.onChange(e,r,a)},onComplete:function(t,e,r){!n&&(o.setCoords(),i.onComplete&&i.onComplete(t,e,r))}};return a?r.util.animateColor(c.startValue,c.endValue,c.duration,c):r.util.animate(c)}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r={x1:1,x2:1,y1:1,y2:1};if(e.Line)return e.warn("fabric.Line is already defined");function s(t,e){var i=t.origin,n=t.axis1,r=t.axis2,s=t.dimension,o=e.nearest,a=e.center,l=e.farthest;return function(){switch(this.get(i)){case o:return Math.min(this.get(n),this.get(r));case a:return Math.min(this.get(n),this.get(r))+.5*this.get(s);case l:return Math.max(this.get(n),this.get(r))}}}e.Line=e.util.createClass(e.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:e.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(t,e){t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),void 0!==r[t]&&this._setWidthHeight(),this},_getLeftToOriginX:s({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:s({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t){t.beginPath();var e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;var i=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(t){return i(this.callSuper("toObject",t),this.calcLinePoints())},_getNonTransformedDimensions:function(){var t=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,n=e*this.height*.5;return{x1:i,x2:-(t*this.width*.5),y1:n,y2:-(e*this.height*.5)}},_toSVG:function(){var t=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="',t.x1,'" y1="',t.y1,'" x2="',t.x2,'" y2="',t.y2,'" />\n']}}),e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),e.Line.fromElement=function(t,n,r){r=r||{};var s=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),o=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];n(new e.Line(o,i(s,r)))},e.Line.fromObject=function(t,i){var r=n(t,!0);r.points=[t.x1,t.y1,t.x2,t.y2],e.Object._fromObject("Line",r,function(t){delete t.points,i&&i(t)},"points")}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians;if(e.Circle)return e.warn("fabric.Circle is already defined.");e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:e.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=(this.endAngle-this.startAngle)%360;if(0===n)t=["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',this.radius,'" />\n'];else{var r=i(this.startAngle),s=i(this.endAngle),o=this.radius,a=e.util.cos(r)*o,l=e.util.sin(r)*o,c=e.util.cos(s)*o,h=e.util.sin(s)*o;t=['<path d="M '+a+" "+l," A "+o+" "+o," 0 ",+(n>180?"1":"0")+" 1"," "+c+" "+h,'" ',"COMMON_PARTS"," />\n"]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,i(this.startAngle),i(this.endAngle),!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),e.Circle.fromElement=function(t,i){var n,r=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in(n=r)&&n.radius>=0))throw Error("value of `r` attribute is required and can not be negative");r.left=(r.left||0)-r.radius,r.top=(r.top||0)-r.radius,i(new e.Circle(r))},e.Circle.fromObject=function(t,i){e.Object._fromObject("Circle",t,i)}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={});if(e.Triangle)return e.warn("fabric.Triangle is already defined");e.Triangle=e.util.createClass(e.Object,{type:"triangle",width:100,height:100,_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)},_toSVG:function(){var t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',[-t+" "+e,"0 "+-e,t+" "+e].join(","),'" />']}}),e.Triangle.fromObject=function(t,i){return e.Object._fromObject("Triangle",t,i)}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=2*Math.PI;if(e.Ellipse)return e.warn("fabric.Ellipse is already defined.");e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" ','rx="',this.rx,'" ry="',this.ry,'" />\n']},_render:function(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,i,!1),t.restore(),this._renderPaintInOrder(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,i(new e.Ellipse(n))},e.Ellipse.fromObject=function(t,i){e.Object._fromObject("Ellipse",t,i)}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;if(e.Rect)return e.warn("fabric.Rect is already defined");e.Rect=e.util.createClass(e.Object,{stateProperties:e.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t){var e=this.rx?Math.min(this.rx,this.width/2):0,i=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,r=this.height,s=-this.width/2,o=-this.height/2,a=0!==e||0!==i;t.beginPath(),t.moveTo(s+e,o),t.lineTo(s+n-e,o),a&&t.bezierCurveTo(s+n-.4477152502*e,o,s+n,o+.4477152502*i,s+n,o+i),t.lineTo(s+n,o+r-i),a&&t.bezierCurveTo(s+n,o+r-.4477152502*i,s+n-.4477152502*e,o+r,s+n-e,o+r),t.lineTo(s+e,o+r),a&&t.bezierCurveTo(s+.4477152502*e,o+r,s,o+r-.4477152502*i,s,o+r-i),t.lineTo(s,o+i),a&&t.bezierCurveTo(s,o+.4477152502*i,s+.4477152502*e,o,s+e,o),t.closePath(),this._renderPaintInOrder(t)},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["<rect ","COMMON_PARTS",'x="',-this.width/2,'" y="',-this.height/2,'" rx="',this.rx,'" ry="',this.ry,'" width="',this.width,'" height="',this.height,'" />\n']}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,n,r){if(!t)return n(null);r=r||{};var s=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);s.left=s.left||0,s.top=s.top||0,s.height=s.height||0,s.width=s.width||0;var o=new e.Rect(i(r?e.util.object.clone(r):{},s));o.visible=o.visible&&o.width>0&&o.height>0,n(o)},e.Rect.fromObject=function(t,i){return e.Object._fromObject("Rect",t,i)}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.array.min,r=e.util.array.max,s=e.util.toFixed,o=e.util.projectStrokeOnPoints;if(e.Polyline)return e.warn("fabric.Polyline is already defined");e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:e.Object.prototype.cacheProperties.concat("points"),initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._setPositionDimensions(e)},_projectStrokeOnPoints:function(){return o(this.points,this,!0)},_setPositionDimensions:function(t){var e,i=this._calcDimensions(t),n=this.exactBoundingBox?this.strokeWidth:0;this.width=i.width-n,this.height=i.height-n,t.fromSVG||(e=this.translateToGivenOrigin({x:i.left-this.strokeWidth/2+n/2,y:i.top-this.strokeWidth/2+n/2},"left","top",this.originX,this.originY)),void 0===t.left&&(this.left=t.fromSVG?i.left:e.x),void 0===t.top&&(this.top=t.fromSVG?i.top:e.y),this.pathOffset={x:i.left+this.width/2+n/2,y:i.top+this.height/2+n/2}},_calcDimensions:function(){var t=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,e=n(t,"x")||0,i=n(t,"y")||0;return{left:e,top:i,width:(r(t,"x")||0)-e,height:(r(t,"y")||0)-i}},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},_toSVG:function(){for(var t=[],i=this.pathOffset.x,n=this.pathOffset.y,r=e.Object.NUM_FRACTION_DIGITS,o=0,a=this.points.length;o<a;o++)t.push(s(this.points[o].x-i,r),",",s(this.points[o].y-n,r)," ");return["<"+this.type+" ","COMMON_PARTS",'points="',t.join(""),'" />\n']},commonRender:function(t){var e,i=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(!i||isNaN(this.points[i-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-n,this.points[0].y-r);for(var s=0;s<i;s++)e=this.points[s],t.lineTo(e.x-n,e.y-r);return!0},_render:function(t){this.commonRender(t)&&this._renderPaintInOrder(t)},complexity:function(){return this.get("points").length}}),e.Polyline.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polyline.fromElementGenerator=function(t){return function(n,r,s){if(!n)return r(null);s||(s={});var o=e.parsePointsAttribute(n.getAttribute("points")),a=e.parseAttributes(n,e[t].ATTRIBUTE_NAMES);a.fromSVG=!0,r(new e[t](o,i(a,s)))}},e.Polyline.fromElement=e.Polyline.fromElementGenerator("Polyline"),e.Polyline.fromObject=function(t,i){return e.Object._fromObject("Polyline",t,i,"points")}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.projectStrokeOnPoints;if(e.Polygon)return e.warn("fabric.Polygon is already defined");e.Polygon=e.util.createClass(e.Polyline,{type:"polygon",_projectStrokeOnPoints:function(){return i(this.points,this)},_render:function(t){this.commonRender(t)&&(t.closePath(),this._renderPaintInOrder(t))}}),e.Polygon.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polygon.fromElement=e.Polyline.fromElementGenerator("Polygon"),e.Polygon.fromObject=function(t,i){e.Object._fromObject("Polygon",t,i,"points")}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.array.min,n=e.util.array.max,r=e.util.object.extend,s=e.util.object.clone,o=e.util.toFixed;if(e.Path)return e.warn("fabric.Path is already defined");e.Path=e.util.createClass(e.Object,{type:"path",path:null,cacheProperties:e.Object.prototype.cacheProperties.concat("path","fillRule"),stateProperties:e.Object.prototype.stateProperties.concat("path"),initialize:function(t,e){e=s(e||{}),delete e.path,this.callSuper("initialize",e),this._setPath(t||[],e)},_setPath:function(t,i){this.path=e.util.makePathSimpler(Array.isArray(t)?t:e.util.parsePath(t)),e.Polyline.prototype._setPositionDimensions.call(this,i||{})},_renderPathCommands:function(t){var e,i=0,n=0,r=0,s=0,o=0,a=0,l=-this.pathOffset.x,c=-this.pathOffset.y;t.beginPath();for(var h=0,u=this.path.length;h<u;++h)switch((e=this.path[h])[0]){case"L":r=e[1],s=e[2],t.lineTo(r+l,s+c);break;case"M":r=e[1],s=e[2],i=r,n=s,t.moveTo(r+l,s+c);break;case"C":r=e[5],s=e[6],o=e[3],a=e[4],t.bezierCurveTo(e[1]+l,e[2]+c,o+l,a+c,r+l,s+c);break;case"Q":t.quadraticCurveTo(e[1]+l,e[2]+c,e[3]+l,e[4]+c),r=e[3],s=e[4],o=e[1],a=e[2];break;case"z":case"Z":r=i,s=n,t.closePath()}},_render:function(t){this._renderPathCommands(t),this._renderPaintInOrder(t)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(t){return r(this.callSuper("toObject",t),{path:this.path.map(function(t){return t.slice()})})},toDatalessObject:function(t){var e=this.toObject(["sourcePath"].concat(t));return e.sourcePath&&delete e.path,e},_toSVG:function(){return["<path ","COMMON_PARTS",'d="',e.util.joinPath(this.path),'" stroke-linecap="round" ',"/>\n"]},_getOffsetTransform:function(){var t=e.Object.NUM_FRACTION_DIGITS;return" translate("+o(-this.pathOffset.x,t)+", "+o(-this.pathOffset.y,t)+")"},toClipPathSVG:function(t){var e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},toSVG:function(t){var e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var t,r,s=[],o=[],a=0,l=0,c=0,h=0,u=0,f=this.path.length;u<f;++u){switch((t=this.path[u])[0]){case"L":c=t[1],h=t[2],r=[];break;case"M":c=t[1],h=t[2],a=c,l=h,r=[];break;case"C":r=e.util.getBoundsOfCurve(c,h,t[1],t[2],t[3],t[4],t[5],t[6]),c=t[5],h=t[6];break;case"Q":r=e.util.getBoundsOfCurve(c,h,t[1],t[2],t[1],t[2],t[3],t[4]),c=t[3],h=t[4];break;case"z":case"Z":c=a,h=l}r.forEach(function(t){s.push(t.x),o.push(t.y)}),s.push(c),o.push(h)}var d=i(s)||0,g=i(o)||0;return{left:d,top:g,width:(n(s)||0)-d,height:(n(o)||0)-g}}}),e.Path.fromObject=function(t,i){if("string"==typeof t.sourcePath){var n=t.sourcePath;e.loadSVGFromURL(n,function(n){var r=n[0];r.setOptions(t),t.clipPath?e.util.enlivenObjects([t.clipPath],function(t){r.clipPath=t[0],i&&i(r)}):i&&i(r)})}else e.Object._fromObject("Path",t,i,"path")},e.Path.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(["d"]),e.Path.fromElement=function(t,i,n){var s=e.parseAttributes(t,e.Path.ATTRIBUTE_NAMES);s.fromSVG=!0,i(new e.Path(s.d,r(s,n)))}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.array.min,n=e.util.array.max;e.Group||(e.Group=e.util.createClass(e.Object,e.Collection,{type:"group",strokeWidth:0,subTargetCheck:!1,cacheProperties:[],useSetOnGroup:!1,initialize:function(t,e,i){e=e||{},this._objects=[],i&&this.callSuper("initialize",e),this._objects=t||[];for(var n=this._objects.length;n--;)this._objects[n].group=this;if(i)this._updateObjectsACoords();else{var r=e&&e.centerPoint;void 0!==e.originX&&(this.originX=e.originX),void 0!==e.originY&&(this.originY=e.originY),r||this._calcBounds(),this._updateObjectsCoords(r),delete e.centerPoint,this.callSuper("initialize",e)}this.setCoords()},_updateObjectsACoords:function(){for(var t=this._objects.length;t--;)this._objects[t].setCoords(!0)},_updateObjectsCoords:function(t){for(var t=t||this.getCenterPoint(),e=this._objects.length;e--;)this._updateObjectCoords(this._objects[e],t)},_updateObjectCoords:function(t,e){var i=t.left,n=t.top;t.set({left:i-e.x,top:n-e.y}),t.group=this,t.setCoords(!0)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(t){var i=!!this.group;return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(i&&e.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,i?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,i){var n=this._objects.length;if(this.useSetOnGroup)for(;n--;)this._objects[n].setOnGroup(t,i);if("canvas"===t)for(;n--;)this._objects[n]._set(t,i);e.Object.prototype._set.call(this,t,i)},toObject:function(t){var i=this.includeDefaultValues,n=this._objects.filter(function(t){return!t.excludeFromExport}).map(function(e){var n=e.includeDefaultValues;e.includeDefaultValues=i;var r=e.toObject(t);return e.includeDefaultValues=n,r}),r=e.Object.prototype.toObject.call(this,t);return r.objects=n,r},toDatalessObject:function(t){var i,n=this.sourcePath;if(n)i=n;else{var r=this.includeDefaultValues;i=this._objects.map(function(e){var i=e.includeDefaultValues;e.includeDefaultValues=r;var n=e.toDatalessObject(t);return e.includeDefaultValues=i,n})}var s=e.Object.prototype.toDatalessObject.call(this,t);return s.objects=i,s},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=e.Object.prototype.shouldCache.call(this);if(t){for(var i=0,n=this._objects.length;i<n;i++)if(this._objects[i].willDrawShadow())return this.ownCaching=!1,!1}return t},willDrawShadow:function(){if(e.Object.prototype.willDrawShadow.call(this))return!0;for(var t=0,i=this._objects.length;t<i;t++)if(this._objects[t].willDrawShadow())return!0;return!1},isOnACache:function(){return this.ownCaching||this.group&&this.group.isOnACache()},drawObject:function(t){for(var e=0,i=this._objects.length;e<i;e++)this._objects[e].render(t);this._drawClipPath(t,this.clipPath)},isCacheDirty:function(t){if(this.callSuper("isCacheDirty",t))return!0;if(!this.statefullCache)return!1;for(var e=0,i=this._objects.length;e<i;e++)if(this._objects[e].isCacheDirty(!0)){if(this._cacheCanvas){var n=this.cacheWidth/this.zoomX,r=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-n/2,-r/2,n,r)}return!0}return!1},_restoreObjectsState:function(){var t=this.calcOwnMatrix();return this._objects.forEach(function(i){e.util.addTransformToObject(i,t),delete i.group,i.setCoords()}),this},destroy:function(){return this._objects.forEach(function(t){t.set("dirty",!0)}),this._restoreObjectsState()},dispose:function(){this.callSuper("dispose"),this.forEachObject(function(t){t.dispose&&t.dispose()}),this._objects=[]},toActiveSelection:function(){if(this.canvas){var t=this._objects,i=this.canvas;this._objects=[];var n=this.toObject();delete n.objects;var r=new e.ActiveSelection([]);return r.set(n),r.type="activeSelection",i.remove(this),t.forEach(function(t){t.group=r,t.dirty=!0,i.add(t)}),r.canvas=i,r._objects=t,i._activeObject=r,r.setCoords(),r}},ungroupOnCanvas:function(){return this._restoreObjectsState()},setObjectsCoords:function(){return this.forEachObject(function(t){t.setCoords(!0)}),this},_calcBounds:function(t){for(var e,i,n,r,s=[],o=[],a=["tr","br","bl","tl"],l=0,c=this._objects.length,h=a.length;l<c;++l){for(r=0,n=(e=this._objects[l]).calcACoords();r<h;r++)i=a[r],s.push(n[i].x),o.push(n[i].y);e.aCoords=n}this._getBounds(s,o,t)},_getBounds:function(t,r,s){var o=new e.Point(i(t),i(r)),a=new e.Point(n(t),n(r)),l=o.y||0,c=o.x||0,h=a.x-o.x||0,u=a.y-o.y||0;this.width=h,this.height=u,s||this.setPositionByOrigin({x:c,y:l},"left","top")},_toSVG:function(t){for(var e=["<g ","COMMON_PARTS"," >\n"],i=0,n=this._objects.length;i<n;i++)e.push(" ",this._objects[i].toSVG(t));return e.push("</g>\n"),e},getSvgStyles:function(){var t=void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")},toClipPathSVG:function(t){for(var e=[],i=0,n=this._objects.length;i<n;i++)e.push(" ",this._objects[i].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}}),e.Group.fromObject=function(t,i){var n=t.objects,r=e.util.object.clone(t,!0);if(delete r.objects,"string"==typeof n)return void e.loadSVGFromURL(n,function(s){var o=e.util.groupSVGElements(s,t,n),a=r.clipPath;delete r.clipPath,o.set(r),a?e.util.enlivenObjects([a],function(t){o.clipPath=t[0],i&&i(o)}):i&&i(o)});e.util.enlivenObjects(n,function(n){e.util.enlivenObjectEnlivables(t,r,function(){i&&i(new e.Group(n,r,!0))})})})}(i),function(t){"use strict";var e=t.fabric||(t.fabric={});e.ActiveSelection||(e.ActiveSelection=e.util.createClass(e.Group,{type:"activeSelection",initialize:function(t,i){i=i||{},this._objects=t||[];for(var n=this._objects.length;n--;)this._objects[n].group=this;i.originX&&(this.originX=i.originX),i.originY&&(this.originY=i.originY),this._calcBounds(),this._updateObjectsCoords(),e.Object.prototype.initialize.call(this,i),this.setCoords()},toGroup:function(){var t=this._objects.concat();this._objects=[];var i=e.Object.prototype.toObject.call(this),n=new e.Group([]);if(delete i.type,n.set(i),t.forEach(function(t){t.canvas.remove(t),t.group=n}),n._objects=t,!this.canvas)return n;var r=this.canvas;return r.add(n),r._activeObject=n,n.setCoords(),n},onDeselect:function(){return this.destroy(),!1},toString:function(){return"#<fabric.ActiveSelection: ("+this.complexity()+")>"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,void 0===(i=i||{}).hasControls&&(i.hasControls=!1),i.forActiveSelection=!0;for(var n=0,r=this._objects.length;n<r;n++)this._objects[n]._renderControls(t,i);this.callSuper("_renderControls",t,e),t.restore()}}),e.ActiveSelection.fromObject=function(t,i){e.util.enlivenObjects(t.objects,function(n){delete t.objects,i&&i(new e.ActiveSelection(n,t,!0))})})}(i),function(t){"use strict";var e=r.util.object.extend;if(t.fabric||(t.fabric={}),t.fabric.Image)return r.warn("fabric.Image is already defined.");r.Image=r.util.createClass(r.Object,{type:"image",strokeWidth:0,srcFromAttribute:!1,_lastScaleX:1,_lastScaleY:1,_filterScalingX:1,_filterScalingY:1,minimumScaleTrigger:.5,stateProperties:r.Object.prototype.stateProperties.concat("cropX","cropY"),cacheProperties:r.Object.prototype.cacheProperties.concat("cropX","cropY"),cacheKey:"",cropX:0,cropY:0,imageSmoothing:!0,initialize:function(t,e){e||(e={}),this.filters=[],this.cacheKey="texture"+r.Object.__uid++,this.callSuper("initialize",e),this._initElement(t,e)},getElement:function(){return this._element||{}},setElement:function(t,e){return this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._element=t,this._originalElement=t,this._initConfig(e),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters(),this},removeTexture:function(t){var e=r.filterBackend;e&&e.evictCachesForKey&&e.evictCachesForKey(t)},dispose:function(){this.callSuper("dispose"),this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._cacheContext=void 0,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((function(t){r.util.cleanUpJsdomNode(this[t]),this[t]=void 0}).bind(this))},getCrossOrigin:function(){return this._originalElement&&(this._originalElement.crossOrigin||null)},getOriginalSize:function(){var t=this.getElement();return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}},_stroke:function(t){if(this.stroke&&0!==this.strokeWidth){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}},toObject:function(t){var i=[];this.filters.forEach(function(t){t&&i.push(t.toObject())});var n=e(this.callSuper("toObject",["cropX","cropY"].concat(t)),{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:i});return this.resizeFilter&&(n.resizeFilter=this.resizeFilter.toObject()),n},hasCrop:function(){return this.cropX||this.cropY||this.width<this._element.width||this.height<this._element.height},_toSVG:function(){var t,e=[],i=[],n=this._element,s=-this.width/2,o=-this.height/2,a="",l="";if(!n)return[];if(this.hasCrop()){var c=r.Object.__uid++;e.push('<clipPath id="imageCrop_'+c+'">\n',' <rect x="'+s+'" y="'+o+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l='" image-rendering="optimizeSpeed'),i.push(" <image ","COMMON_PARTS",'xlink:href="',this.getSvgSrc(!0),'" x="',s-this.cropX,'" y="',o-this.cropY,'" width="',n.width||n.naturalWidth,'" height="',n.height||n.height,l,'"',a,"></image>\n"),this.stroke||this.strokeDashArray){var h=this.fill;this.fill=null,t=[" <rect ",'x="',s,'" y="',o,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>\n'],this.fill=h}return"fill"!==this.paintFirst?e.concat(t,i):e.concat(i,t)},getSrc:function(t){var e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src"):e.src:this.src||""},setSrc:function(t,e,i){return r.util.loadImage(t,function(t,n){this.setElement(t,i),this._setWidthHeight(),e&&e(this,n)},this,i&&i.crossOrigin),this},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},applyResizeFilters:function(){var t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),n=i.scaleX,s=i.scaleY,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||n>e&&s>e){this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,this._lastScaleY=s;return}r.filterBackend||(r.filterBackend=r.initFilterBackend());var a=r.util.createCanvasElement(),l=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,c=o.width,h=o.height;a.width=c,a.height=h,this._element=a,this._lastScaleX=t.scaleX=n,this._lastScaleY=t.scaleY=s,r.filterBackend.applyFilters([t],o,c,h,this._element,l),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height},applyFilters:function(t){if(t=(t=t||this.filters||[]).filter(function(t){return t&&!t.isNeutralState()}),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===t.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var e=this._originalElement,i=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(this._element===this._originalElement){var s=r.util.createCanvasElement();s.width=i,s.height=n,this._element=s,this._filteredEl=s}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,n),this._lastScaleX=1,this._lastScaleY=1;return r.filterBackend||(r.filterBackend=r.initFilterBackend()),r.filterBackend.applyFilters(t,this._originalElement,i,n,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),this},_render:function(t){r.util.setImageSmoothing(t,this.imageSmoothing),!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)},drawCacheOnCanvas:function(t){r.util.setImageSmoothing(t,this.imageSmoothing),r.Object.prototype.drawCacheOnCanvas.call(this,t)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(t){var e=this._element;if(e){var i=this._filterScalingX,n=this._filterScalingY,r=this.width,s=this.height,o=Math.min,a=Math.max,l=a(this.cropX,0),c=a(this.cropY,0),h=e.naturalWidth||e.width,u=e.naturalHeight||e.height,f=l*i,d=c*n,g=o(r*i,h-f),p=o(s*n,u-d),m=-r/2,y=-s/2,b=o(r,h/i-l),x=o(s,u/n-c);e&&t.drawImage(e,f,d,g,p,m,y,b,x)}},_needsResize:function(){var t=this.getTotalObjectScaling();return t.scaleX!==this._lastScaleX||t.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(t,e){this.setElement(r.util.getById(t),e),r.util.addClass(this.getElement(),r.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t)},_initFilters:function(t,e){t&&t.length?r.util.enlivenObjects(t,function(t){e&&e(t)},"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){t||(t={});var e=this.getElement();this.width=t.width||e.naturalWidth||e.width||0,this.height=t.height||e.naturalHeight||e.height||0},parsePreserveAspectRatioAttribute:function(){var t,e=r.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),i=this._element.width,n=this._element.height,s=1,o=1,a=0,l=0,c=0,h=0,u=this.width,f=this.height,d={width:u,height:f};return e&&("none"!==e.alignX||"none"!==e.alignY)?("meet"===e.meetOrSlice&&(t=(u-i*(s=o=r.util.findScaleToFit(this._element,d)))/2,"Min"===e.alignX&&(a=-t),"Max"===e.alignX&&(a=t),t=(f-n*o)/2,"Min"===e.alignY&&(l=-t),"Max"===e.alignY&&(l=t)),"slice"===e.meetOrSlice&&(t=i-u/(s=o=r.util.findScaleToCover(this._element,d)),"Mid"===e.alignX&&(c=t/2),"Max"===e.alignX&&(c=t),t=n-f/o,"Mid"===e.alignY&&(h=t/2),"Max"===e.alignY&&(h=t),i=u/s,n=f/o)):(s=u/i,o=f/n),{width:i,height:n,scaleX:s,scaleY:o,offsetLeft:a,offsetTop:l,cropX:c,cropY:h}}}),r.Image.CSS_CANVAS="canvas-img",r.Image.prototype.getSvgSrc=r.Image.prototype.getSrc,r.Image.fromObject=function(t,e){var i=r.util.object.clone(t);r.util.loadImage(i.src,function(t,n){if(n){e&&e(null,!0);return}r.Image.prototype._initFilters.call(i,i.filters,function(n){i.filters=n||[],r.Image.prototype._initFilters.call(i,[i.resizeFilter],function(n){i.resizeFilter=n[0],r.util.enlivenObjectEnlivables(i,i,function(){e(new r.Image(t,i),!1)})})})},null,i.crossOrigin)},r.Image.fromURL=function(t,e,i){r.util.loadImage(t,function(t,n){e&&e(new r.Image(t,i),n)},null,i&&i.crossOrigin)},r.Image.ATTRIBUTE_NAMES=r.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),r.Image.fromElement=function(t,i,n){var s=r.parseAttributes(t,r.Image.ATTRIBUTE_NAMES);r.Image.fromURL(s["xlink:href"],i,e(n?r.util.object.clone(n):{},s))}}(i),r.util.object.extend(r.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.angle%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,n=t.onChange||e,s=this;return r.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){s.rotate(t),n()},onComplete:function(){s.setCoords(),i()}})}}),r.util.object.extend(r.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.requestRenderAllBound})}}),function(){"use strict";function t(t){t&&t.tileSize&&(this.tileSize=t.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}r.isWebglSupported=function(t){if(r.isLikelyNode)return!1;t=t||r.WebglFilterBackend.prototype.tileSize;var e=document.createElement("canvas"),i=e.getContext("webgl")||e.getContext("experimental-webgl"),n=!1;if(i){r.maxTextureSize=i.getParameter(i.MAX_TEXTURE_SIZE),n=r.maxTextureSize>=t;for(var s=["highp","mediump","lowp"],o=0;o<3;o++)if(function(t,e){var i=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(i,"precision "+e+" float;\nvoid main(){}"),t.compileShader(i),!!t.getShaderParameter(i,t.COMPILE_STATUS)}(i,s[o])){r.webGlPrecision=s[o];break}}return this.isSupported=n,n},r.WebglFilterBackend=t,t.prototype={tileSize:2048,resources:{},setupGLContext:function(t,e){this.dispose(),this.createWebGLCanvas(t,e),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(t,e)},chooseFastestCopyGLTo2DMethod:function(t,e){var i,n,s,l=void 0!==window.performance;try{new ImageData(1,1),s=!0}catch(t){s=!1}var c="undefined"!=typeof ArrayBuffer,h="undefined"!=typeof Uint8ClampedArray;if(l&&s&&c&&h){var u=r.util.createCanvasElement(),f=new ArrayBuffer(t*e*4);if(r.forceGLPutImageData){this.imageBuffer=f,this.copyGLTo2D=a;return}var d={imageBuffer:f,destinationWidth:t,destinationHeight:e,targetCanvas:u};u.width=t,u.height=e,i=window.performance.now(),o.call(d,this.gl,d),n=window.performance.now()-i,i=window.performance.now(),a.call(d,this.gl,d),n>window.performance.now()-i?(this.imageBuffer=f,this.copyGLTo2D=a):this.copyGLTo2D=o}},createWebGLCanvas:function(t,e){var i=r.util.createCanvasElement();i.width=t,i.height=e;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},s=i.getContext("webgl",n);s||(s=i.getContext("experimental-webgl",n)),s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)},applyFilters:function(t,e,i,n,r,s){var o,a,l,c,h,u,f,d=this.gl;s&&(f=this.getCachedTexture(s,e));var g={originalWidth:e.width||e.originalWidth,originalHeight:e.height||e.originalHeight,sourceWidth:i,sourceHeight:n,destinationWidth:i,destinationHeight:n,context:d,sourceTexture:this.createTexture(d,i,n,!f&&e),targetTexture:this.createTexture(d,i,n),originalTexture:f||this.createTexture(d,i,n,!f&&e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},p=d.createFramebuffer();return d.bindFramebuffer(d.FRAMEBUFFER,p),t.forEach(function(t){t&&t.applyTo(g)}),l=(a=(o=g).targetCanvas).width,c=a.height,h=o.destinationWidth,u=o.destinationHeight,(l!==h||c!==u)&&(a.width=h,a.height=u),this.copyGLTo2D(d,g),d.bindTexture(d.TEXTURE_2D,null),d.deleteTexture(g.sourceTexture),d.deleteTexture(g.targetTexture),d.deleteFramebuffer(p),r.getContext("2d").setTransform(1,0,0,1,0,0),g},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(t,e,i,n,r){var s=t.createTexture();return t.bindTexture(t.TEXTURE_2D,s),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r||t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r||t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),s},getCachedTexture:function(t,e){if(this.textureCache[t])return this.textureCache[t];var i=this.createTexture(this.gl,e.width,e.height,e);return this.textureCache[t]=i,i},evictCachesForKey:function(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])},copyGLTo2D:o,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var t=this.gl,e={renderer:"",vendor:""};if(!t)return e;var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var n=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);n&&(e.renderer=n.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}}(),!function(){"use strict";var t=function(){};function e(){}r.Canvas2dFilterBackend=e,e.prototype={evictCachesForKey:t,dispose:t,clearWebGLCaches:t,resources:{},applyFilters:function(t,e,i,n,r){var s=r.getContext("2d");s.drawImage(e,0,0,i,n);var o=s.getImageData(0,0,i,n),a=s.getImageData(0,0,i,n),l={sourceWidth:i,sourceHeight:n,imageData:o,originalEl:e,originalImageData:a,canvasEl:r,ctx:s,filterBackend:this};return t.forEach(function(t){t.applyTo(l)}),(l.imageData.width!==i||l.imageData.height!==n)&&(r.width=l.imageData.width,r.height=l.imageData.height),s.putImageData(l.imageData,0,0),l}}}(),r.Image=r.Image||{},r.Image.filters=r.Image.filters||{},r.Image.filters.BaseFilter=r.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},createProgram:function(t,e,i){e=e||this.fragmentSource,i=i||this.vertexSource,"highp"!==r.webGlPrecision&&(e=e.replace(/precision highp float/g,"precision "+r.webGlPrecision+" float"));var n=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw Error("Vertex shader compile error for "+this.type+": "+t.getShaderInfoLog(n));var s=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(s,e),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw Error("Fragment shader compile error for "+this.type+": "+t.getShaderInfoLog(s));var o=t.createProgram();if(t.attachShader(o,n),t.attachShader(o,s),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))throw Error('Shader link error for "${this.type}" '+t.getProgramInfoLog(o));var a=this.getAttributeLocations(t,o),l=this.getUniformLocations(t,o)||{};return l.uStepW=t.getUniformLocation(o,"uStepW"),l.uStepH=t.getUniformLocation(o,"uStepH"),{program:o,attributeLocations:a,uniformLocations:l}},getAttributeLocations:function(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(t,e,i){var n=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)},_setupFrameBuffer:function(t){var e,i,n=t.context;t.passes>1?(e=t.destinationWidth,i=t.destinationHeight,(t.sourceWidth!==e||t.sourceHeight!==i)&&(n.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(n,e,i)),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t.targetTexture,0)):(n.bindFramebuffer(n.FRAMEBUFFER,null),n.finish())},_swapTextures:function(t){t.passes--,t.pass++;var e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e},isNeutralState:function(){var t=this.mainParameter,e=r.Image.filters[this.type].prototype;if(!t)return!1;if(!Array.isArray(e[t]))return e[t]===this[t];for(var i=e[t].length;i--;)if(this[t][i]!==e[t][i])return!1;return!0},applyTo:function(t){t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},retrieveShader:function(t){return t.programCache.hasOwnProperty(this.type)||(t.programCache[this.type]=this.createProgram(t.context)),t.programCache[this.type]},applyToWebGL:function(t){var e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)},unbindAdditionalTexture:function(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(t){this[this.mainParameter]=t},sendUniformData:function(){},createHelpLayer:function(t){if(!t.helpLayer){var e=document.createElement("canvas");e.width=t.sourceWidth,e.height=t.sourceHeight,t.helpLayer=e}},toObject:function(){var t={type:this.type},e=this.mainParameter;return e&&(t[e]=this[e]),t},toJSON:function(){return this.toObject()}}),r.Image.filters.BaseFilter.fromObject=function(t,e){var i=new r.Image.filters[t.type](t);return e&&e(i),i},function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.ColorMatrix=(0,e.util.createClass)(i.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var e,i,n,r,s,o=t.imageData.data,a=o.length,l=this.matrix,c=this.colorsOnly;for(s=0;s<a;s+=4)e=o[s],i=o[s+1],n=o[s+2],c?(o[s]=e*l[0]+i*l[1]+n*l[2]+255*l[4],o[s+1]=e*l[5]+i*l[6]+n*l[7]+255*l[9],o[s+2]=e*l[10]+i*l[11]+n*l[12]+255*l[14]):(r=o[s+3],o[s]=e*l[0]+i*l[1]+n*l[2]+r*l[3]+255*l[4],o[s+1]=e*l[5]+i*l[6]+n*l[7]+r*l[8]+255*l[9],o[s+2]=e*l[10]+i*l[11]+n*l[12]+r*l[13]+255*l[14],o[s+3]=e*l[15]+i*l[16]+n*l[17]+r*l[18]+255*l[19])},getUniformLocations:function(t,e){return{uColorMatrix:t.getUniformLocation(e,"uColorMatrix"),uConstants:t.getUniformLocation(e,"uConstants")}},sendUniformData:function(t,e){var i=this.matrix,n=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],r=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,n),t.uniform4fv(e.uConstants,r)}}),e.Image.filters.ColorMatrix.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Brightness=(0,e.util.createClass)(i.BaseFilter,{type:"Brightness",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBrightness;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += uBrightness;\ngl_FragColor = color;\n}",brightness:0,mainParameter:"brightness",applyTo2d:function(t){if(0!==this.brightness){var e,i=t.imageData.data,n=i.length,r=Math.round(255*this.brightness);for(e=0;e<n;e+=4)i[e]=i[e]+r,i[e+1]=i[e+1]+r,i[e+2]=i[e+2]+r}},getUniformLocations:function(t,e){return{uBrightness:t.getUniformLocation(e,"uBrightness")}},sendUniformData:function(t,e){t.uniform1f(e.uBrightness,this.brightness)}}),e.Image.filters.Brightness.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.Image.filters;n.Convolute=(0,e.util.createClass)(n.BaseFilter,{type:"Convolute",opaque:!1,matrix:[0,0,0,0,1,0,0,0,0],fragmentSource:{Convolute_3_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_3_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_5_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_5_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_7_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_7_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_9_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_9_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}"},retrieveShader:function(t){var e=Math.sqrt(this.matrix.length),i=this.type+"_"+e+"_"+ +!!this.opaque,n=this.fragmentSource[i];return t.programCache.hasOwnProperty(i)||(t.programCache[i]=this.createProgram(t.context,n)),t.programCache[i]},applyTo2d:function(t){var e,i,n,r,s,o,a,l,c,h,u,f,d,g=t.imageData,p=g.data,m=this.matrix,y=Math.round(Math.sqrt(m.length)),b=Math.floor(y/2),x=g.width,_=g.height,C=t.ctx.createImageData(x,_),S=C.data,w=+!!this.opaque;for(u=0;u<_;u++)for(h=0;h<x;h++){for(d=0,s=(u*x+h)*4,e=0,i=0,n=0,r=0;d<y;d++)for(f=0;f<y;f++)a=u+d-b,o=h+f-b,a<0||a>=_||o<0||o>=x||(l=(a*x+o)*4,c=m[d*y+f],e+=p[l]*c,i+=p[l+1]*c,n+=p[l+2]*c,w||(r+=p[l+3]*c));S[s]=e,S[s+1]=i,S[s+2]=n,w?S[s+3]=p[s+3]:S[s+3]=r}t.imageData=C},getUniformLocations:function(t,e){return{uMatrix:t.getUniformLocation(e,"uMatrix"),uOpaque:t.getUniformLocation(e,"uOpaque"),uHalfSize:t.getUniformLocation(e,"uHalfSize"),uSize:t.getUniformLocation(e,"uSize")}},sendUniformData:function(t,e){t.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Grayscale=(0,e.util.createClass)(i.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(t){var e,i,n=t.imageData.data,r=n.length,s=this.mode;for(e=0;e<r;e+=4)"average"===s?i=(n[e]+n[e+1]+n[e+2])/3:"lightness"===s?i=(Math.min(n[e],n[e+1],n[e+2])+Math.max(n[e],n[e+1],n[e+2]))/2:"luminosity"===s&&(i=.21*n[e]+.72*n[e+1]+.07*n[e+2]),n[e]=i,n[e+1]=i,n[e+2]=i},retrieveShader:function(t){var e=this.type+"_"+this.mode;if(!t.programCache.hasOwnProperty(e)){var i=this.fragmentSource[this.mode];t.programCache[e]=this.createProgram(t.context,i)}return t.programCache[e]},getUniformLocations:function(t,e){return{uMode:t.getUniformLocation(e,"uMode")}},sendUniformData:function(t,e){t.uniform1i(e.uMode,1)},isNeutralState:function(){return!1}}),e.Image.filters.Grayscale.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Invert=(0,e.util.createClass)(i.BaseFilter,{type:"Invert",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uInvert;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nif (uInvert == 1) {\ngl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n} else {\ngl_FragColor = color;\n}\n}",invert:!0,mainParameter:"invert",applyTo2d:function(t){var e,i=t.imageData.data,n=i.length;for(e=0;e<n;e+=4)i[e]=255-i[e],i[e+1]=255-i[e+1],i[e+2]=255-i[e+2]},isNeutralState:function(){return!this.invert},getUniformLocations:function(t,e){return{uInvert:t.getUniformLocation(e,"uInvert")}},sendUniformData:function(t,e){t.uniform1i(e.uInvert,this.invert)}}),e.Image.filters.Invert.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.Image.filters;n.Noise=(0,e.util.createClass)(n.BaseFilter,{type:"Noise",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uStepH;\nuniform float uNoise;\nuniform float uSeed;\nvarying vec2 vTexCoord;\nfloat rand(vec2 co, float seed, float vScale) {\nreturn fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n}\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\ngl_FragColor = color;\n}",mainParameter:"noise",noise:0,applyTo2d:function(t){if(0!==this.noise){var e,i,n=t.imageData.data,r=n.length,s=this.noise;for(e=0,r=n.length;e<r;e+=4)i=(.5-Math.random())*s,n[e]+=i,n[e+1]+=i,n[e+2]+=i}},getUniformLocations:function(t,e){return{uNoise:t.getUniformLocation(e,"uNoise"),uSeed:t.getUniformLocation(e,"uSeed")}},sendUniformData:function(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())},toObject:function(){return i(this.callSuper("toObject"),{noise:this.noise})}}),e.Image.filters.Noise.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Pixelate=(0,e.util.createClass)(i.BaseFilter,{type:"Pixelate",blocksize:4,mainParameter:"blocksize",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBlocksize;\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nfloat blockW = uBlocksize * uStepW;\nfloat blockH = uBlocksize * uStepW;\nint posX = int(vTexCoord.x / blockW);\nint posY = int(vTexCoord.y / blockH);\nfloat fposX = float(posX);\nfloat fposY = float(posY);\nvec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\nvec4 color = texture2D(uTexture, squareCoords);\ngl_FragColor = color;\n}",applyTo2d:function(t){var e,i,n,r,s,o,a,l,c,h,u,f=t.imageData,d=f.data,g=f.height,p=f.width;for(i=0;i<g;i+=this.blocksize)for(n=0;n<p;n+=this.blocksize)for(r=d[e=4*i*p+4*n],s=d[e+1],o=d[e+2],a=d[e+3],h=Math.min(i+this.blocksize,g),u=Math.min(n+this.blocksize,p),l=i;l<h;l++)for(c=n;c<u;c++)d[e=4*l*p+4*c]=r,d[e+1]=s,d[e+2]=o,d[e+3]=a},isNeutralState:function(){return 1===this.blocksize},getUniformLocations:function(t,e){return{uBlocksize:t.getUniformLocation(e,"uBlocksize"),uStepW:t.getUniformLocation(e,"uStepW"),uStepH:t.getUniformLocation(e,"uStepH")}},sendUniformData:function(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}),e.Image.filters.Pixelate.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.Image.filters;n.RemoveColor=(0,e.util.createClass)(n.BaseFilter,{type:"RemoveColor",color:"#FFFFFF",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\nif(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\ngl_FragColor.a = 0.0;\n}\n}",distance:.02,useAlpha:!1,applyTo2d:function(t){var i,n,r,s,o=t.imageData.data,a=255*this.distance,l=new e.Color(this.color).getSource(),c=[l[0]-a,l[1]-a,l[2]-a],h=[l[0]+a,l[1]+a,l[2]+a];for(i=0;i<o.length;i+=4)n=o[i],r=o[i+1],s=o[i+2],n>c[0]&&r>c[1]&&s>c[2]&&n<h[0]&&r<h[1]&&s<h[2]&&(o[i+3]=0)},getUniformLocations:function(t,e){return{uLow:t.getUniformLocation(e,"uLow"),uHigh:t.getUniformLocation(e,"uHigh")}},sendUniformData:function(t,i){var n=new e.Color(this.color).getSource(),r=parseFloat(this.distance),s=[0+n[0]/255-r,0+n[1]/255-r,0+n[2]/255-r,1],o=[n[0]/255+r,n[1]/255+r,n[2]/255+r,1];t.uniform4fv(i.uLow,s),t.uniform4fv(i.uHigh,o)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color,distance:this.distance})}}),e.Image.filters.RemoveColor.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass,r={Brownie:[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0],Vintage:[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0],Kodachrome:[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0],Technicolor:[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0],Polaroid:[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],Sepia:[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0],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]};for(var s in r)i[s]=n(i.ColorMatrix,{type:s,matrix:r[s],mainParameter:!1,colorsOnly:!0}),e.Image.filters[s].fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric,i=e.Image.filters;i.BlendColor=(0,e.util.createClass)(i.BaseFilter,{type:"BlendColor",color:"#F95C63",mode:"multiply",alpha:1,fragmentSource:{multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",diff:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"if (uColor.r < 0.5) {\ngl_FragColor.r *= 2.0 * uColor.r;\n} else {\ngl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n}\nif (uColor.g < 0.5) {\ngl_FragColor.g *= 2.0 * uColor.g;\n} else {\ngl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n}\nif (uColor.b < 0.5) {\ngl_FragColor.b *= 2.0 * uColor.b;\n} else {\ngl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n}\n",tint:"gl_FragColor.rgb *= (1.0 - uColor.a);\ngl_FragColor.rgb += uColor.rgb;\n"},buildSource:function(t){return"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ngl_FragColor = color;\nif (color.a > 0.0) {\n"+this.fragmentSource[t]+"}\n}"},retrieveShader:function(t){var e,i=this.type+"_"+this.mode;return t.programCache.hasOwnProperty(i)||(e=this.buildSource(this.mode),t.programCache[i]=this.createProgram(t.context,e)),t.programCache[i]},applyTo2d:function(t){var i,n,r,s,o,a,l,c=t.imageData.data,h=c.length,u=1-this.alpha;i=(l=new e.Color(this.color).getSource())[0]*this.alpha,n=l[1]*this.alpha,r=l[2]*this.alpha;for(var f=0;f<h;f+=4)switch(s=c[f],o=c[f+1],a=c[f+2],this.mode){case"multiply":c[f]=s*i/255,c[f+1]=o*n/255,c[f+2]=a*r/255;break;case"screen":c[f]=255-(255-s)*(255-i)/255,c[f+1]=255-(255-o)*(255-n)/255,c[f+2]=255-(255-a)*(255-r)/255;break;case"add":c[f]=s+i,c[f+1]=o+n,c[f+2]=a+r;break;case"diff":case"difference":c[f]=Math.abs(s-i),c[f+1]=Math.abs(o-n),c[f+2]=Math.abs(a-r);break;case"subtract":c[f]=s-i,c[f+1]=o-n,c[f+2]=a-r;break;case"darken":c[f]=Math.min(s,i),c[f+1]=Math.min(o,n),c[f+2]=Math.min(a,r);break;case"lighten":c[f]=Math.max(s,i),c[f+1]=Math.max(o,n),c[f+2]=Math.max(a,r);break;case"overlay":c[f]=i<128?2*s*i/255:255-2*(255-s)*(255-i)/255,c[f+1]=n<128?2*o*n/255:255-2*(255-o)*(255-n)/255,c[f+2]=r<128?2*a*r/255:255-2*(255-a)*(255-r)/255;break;case"exclusion":c[f]=i+s-2*i*s/255,c[f+1]=n+o-2*n*o/255,c[f+2]=r+a-2*r*a/255;break;case"tint":c[f]=i+s*u,c[f+1]=n+o*u,c[f+2]=r+a*u}},getUniformLocations:function(t,e){return{uColor:t.getUniformLocation(e,"uColor")}},sendUniformData:function(t,i){var n=new e.Color(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,t.uniform4fv(i.uColor,n)},toObject:function(){return{type:this.type,color:this.color,mode:this.mode,alpha:this.alpha}}}),e.Image.filters.BlendColor.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric,i=e.Image.filters;i.BlendImage=(0,e.util.createClass)(i.BaseFilter,{type:"BlendImage",image:null,mode:"multiply",alpha:1,vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nuniform mat3 uTransformMatrix;\nvoid main() {\nvTexCoord = aPosition;\nvTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:{multiply:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.rgba *= color2.rgba;\ngl_FragColor = color;\n}",mask:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.a = color2.a;\ngl_FragColor = color;\n}"},retrieveShader:function(t){var e=this.type+"_"+this.mode,i=this.fragmentSource[this.mode];return t.programCache.hasOwnProperty(e)||(t.programCache[e]=this.createProgram(t.context,i)),t.programCache[e]},applyToWebGL:function(t){var e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),this.callSuper("applyToWebGL",t),this.unbindAdditionalTexture(e,e.TEXTURE1)},createTexture:function(t,e){return t.getCachedTexture(e.cacheKey,e._element)},calculateMatrix:function(){var t=this.image,e=t._element.width,i=t._element.height;return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]},applyTo2d:function(t){var i,n,r,s,o,a,l,c,h,u,f,d=t.imageData,g=t.filterBackend.resources,p=d.data,m=p.length,y=d.width,b=d.height,x=this.image;g.blendImage||(g.blendImage=e.util.createCanvasElement()),u=(h=g.blendImage).getContext("2d"),h.width!==y||h.height!==b?(h.width=y,h.height=b):u.clearRect(0,0,y,b),u.setTransform(x.scaleX,0,0,x.scaleY,x.left,x.top),u.drawImage(x._element,0,0,y,b),f=u.getImageData(0,0,y,b).data;for(var _=0;_<m;_+=4)switch(o=p[_],a=p[_+1],l=p[_+2],c=p[_+3],i=f[_],n=f[_+1],r=f[_+2],s=f[_+3],this.mode){case"multiply":p[_]=o*i/255,p[_+1]=a*n/255,p[_+2]=l*r/255,p[_+3]=c*s/255;break;case"mask":p[_+3]=s}},getUniformLocations:function(t,e){return{uTransformMatrix:t.getUniformLocation(e,"uTransformMatrix"),uImage:t.getUniformLocation(e,"uImage")}},sendUniformData:function(t,e){var i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)},toObject:function(){return{type:this.type,image:this.image&&this.image.toObject(),mode:this.mode,alpha:this.alpha}}}),e.Image.filters.BlendImage.fromObject=function(t,i){e.Image.fromObject(t.image,function(n){var r=e.util.object.clone(t);r.image=n,i(new e.Image.filters.BlendImage(r))})}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=Math.pow,n=Math.floor,r=Math.sqrt,s=Math.abs,o=Math.round,a=Math.sin,l=Math.ceil,c=e.Image.filters;c.Resize=(0,e.util.createClass)(c.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3,getUniformLocations:function(t,e){return{uDelta:t.getUniformLocation(e,"uDelta"),uTaps:t.getUniformLocation(e,"uTaps")}},sendUniformData:function(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)},retrieveShader:function(t){var e=this.getFilterWindow(),i=this.type+"_"+e;if(!t.programCache.hasOwnProperty(i)){var n=this.generateShader(e);t.programCache[i]=this.createProgram(t.context,n)}return t.programCache[i]},getFilterWindow:function(){var t=this.tempScale;return Math.ceil(this.lanczosLobes/t)},getTaps:function(){for(var t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),n=Array(i),r=1;r<=i;r++)n[r-1]=t(r*e);return n},generateShader:function(t){for(var e=Array(t),i=this.fragmentSourceTOP,n=1;n<=t;n++)e[n-1]=n+".0 * uDelta";return i+="uniform float uTaps["+t+"];\n",i+="void main() {\n",i+=" vec4 color = texture2D(uTexture, vTexCoord);\n",i+=" float sum = 1.0;\n",e.forEach(function(t,e){i+=" color += texture2D(uTexture, vTexCoord + "+t+") * uTaps["+e+"];\n",i+=" color += texture2D(uTexture, vTexCoord - "+t+") * uTaps["+e+"];\n",i+=" sum += 2.0 * uTaps["+e+"];\n"}),i+=" gl_FragColor = color / sum;\n",i+="}"},fragmentSourceTOP:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\n",applyTo:function(t){t.webgl?(t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t),t.sourceHeight=t.destinationHeight):this.applyTo2d(t)},isNeutralState:function(){return 1===this.scaleX&&1===this.scaleY},lanczosCreate:function(t){return function(e){if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;var i=(e*=Math.PI)/t;return a(e)/e*a(i)/i}},applyTo2d:function(t){var e=t.imageData,i=this.scaleX,n=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/n;var r,s=e.width,a=e.height,l=o(s*i),c=o(a*n);"sliceHack"===this.resizeType?r=this.sliceByTwo(t,s,a,l,c):"hermite"===this.resizeType?r=this.hermiteFastResize(t,s,a,l,c):"bilinear"===this.resizeType?r=this.bilinearFiltering(t,s,a,l,c):"lanczos"===this.resizeType&&(r=this.lanczosResize(t,s,a,l,c)),t.imageData=r},sliceByTwo:function(t,i,r,s,o){var a,l,c=t.imageData,h=!1,u=!1,f=.5*i,d=.5*r,g=e.filterBackend.resources,p=0,m=0,y=i,b=0;for(g.sliceByTwo||(g.sliceByTwo=document.createElement("canvas")),((a=g.sliceByTwo).width<1.5*i||a.height<r)&&(a.width=1.5*i,a.height=r),(l=a.getContext("2d")).clearRect(0,0,1.5*i,r),l.putImageData(c,0,0),s=n(s),o=n(o);!h||!u;)i=f,r=d,s<n(.5*f)?f=n(.5*f):(f=s,h=!0),o<n(.5*d)?d=n(.5*d):(d=o,u=!0),l.drawImage(a,p,m,i,r,y,b,f,d),p=y,m=b,b+=d;return l.getImageData(p,m,s,o)},lanczosResize:function(t,e,o,a,c){var h=t.imageData.data,u=t.ctx.createImageData(a,c),f=u.data,d=this.lanczosCreate(this.lanczosLobes),g=this.rcpScaleX,p=this.rcpScaleY,m=2/this.rcpScaleX,y=2/this.rcpScaleY,b=l(g*this.lanczosLobes/2),x=l(p*this.lanczosLobes/2),_={},C={},S={};return function t(l){var w,T,O,k,E,j,M,P,A,D,F;for(w=0,C.x=(l+.5)*g,S.x=n(C.x);w<c;w++){for(C.y=(w+.5)*p,S.y=n(C.y),E=0,j=0,M=0,P=0,A=0,T=S.x-b;T<=S.x+b;T++)if(!(T<0)&&!(T>=e)){_[D=n(1e3*s(T-C.x))]||(_[D]={});for(var R=S.y-x;R<=S.y+x;R++)R<0||R>=o||(F=n(1e3*s(R-C.y)),_[D][F]||(_[D][F]=d(r(i(D*m,2)+i(F*y,2))/1e3)),(O=_[D][F])>0&&(k=(R*e+T)*4,E+=O,j+=O*h[k],M+=O*h[k+1],P+=O*h[k+2],A+=O*h[k+3]))}f[k=(w*a+l)*4]=j/E,f[k+1]=M/E,f[k+2]=P/E,f[k+3]=A/E}return++l<a?t(l):u}(0)},bilinearFiltering:function(t,e,i,r,s){var o,a,l,c,h,u,f,d,g,p,m,y=0,b=this.rcpScaleX,x=this.rcpScaleY,_=4*(e-1),C=t.imageData.data,S=t.ctx.createImageData(r,s),w=S.data;for(h=0;h<s;h++)for(u=0;u<r;u++)for(g=0,l=n(b*u),c=n(x*h),f=b*u-l,d=x*h-c,m=4*(c*e+l);g<4;g++)o=C[m+g],a=C[m+4+g],p=o*(1-f)*(1-d)+a*f*(1-d)+C[m+_+g]*d*(1-f)+C[m+_+4+g]*f*d,w[y++]=p;return S},hermiteFastResize:function(t,e,i,o,a){for(var c=this.rcpScaleX,h=this.rcpScaleY,u=l(c/2),f=l(h/2),d=t.imageData.data,g=t.ctx.createImageData(o,a),p=g.data,m=0;m<a;m++)for(var y=0;y<o;y++){for(var b=(y+m*o)*4,x=0,_=0,C=0,S=0,w=0,T=0,O=0,k=(m+.5)*h,E=n(m*h);E<(m+1)*h;E++)for(var j=s(k-(E+.5))/f,M=(y+.5)*c,P=j*j,A=n(y*c);A<(y+1)*c;A++){var D=s(M-(A+.5))/u,F=r(P+D*D);F>1&&F<-1||(x=2*F*F*F-3*F*F+1)>0&&(O+=x*d[(D=4*(A+E*e))+3],C+=x,d[D+3]<255&&(x=x*d[D+3]/250),S+=x*d[D],w+=x*d[D+1],T+=x*d[D+2],_+=x)}p[b]=S/_,p[b+1]=w/_,p[b+2]=T/_,p[b+3]=O/C}return g},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Contrast=(0,e.util.createClass)(i.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(0!==this.contrast){var e,i,n=t.imageData.data,i=n.length,r=Math.floor(255*this.contrast),s=259*(r+255)/(255*(259-r));for(e=0;e<i;e+=4)n[e]=s*(n[e]-128)+128,n[e+1]=s*(n[e+1]-128)+128,n[e+2]=s*(n[e+2]-128)+128}},getUniformLocations:function(t,e){return{uContrast:t.getUniformLocation(e,"uContrast")}},sendUniformData:function(t,e){t.uniform1f(e.uContrast,this.contrast)}}),e.Image.filters.Contrast.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Saturation=(0,e.util.createClass)(i.BaseFilter,{type:"Saturation",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uSaturation;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat rgMax = max(color.r, color.g);\nfloat rgbMax = max(rgMax, color.b);\ncolor.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\ncolor.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\ncolor.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\ngl_FragColor = color;\n}",saturation:0,mainParameter:"saturation",applyTo2d:function(t){if(0!==this.saturation){var e,i,n=t.imageData.data,r=n.length,s=-this.saturation;for(e=0;e<r;e+=4)i=Math.max(n[e],n[e+1],n[e+2]),n[e]+=i!==n[e]?(i-n[e])*s:0,n[e+1]+=i!==n[e+1]?(i-n[e+1])*s:0,n[e+2]+=i!==n[e+2]?(i-n[e+2])*s:0}},getUniformLocations:function(t,e){return{uSaturation:t.getUniformLocation(e,"uSaturation")}},sendUniformData:function(t,e){t.uniform1f(e.uSaturation,-this.saturation)}}),e.Image.filters.Saturation.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Vibrance=(0,e.util.createClass)(i.BaseFilter,{type:"Vibrance",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uVibrance;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat max = max(color.r, max(color.g, color.b));\nfloat avg = (color.r + color.g + color.b) / 3.0;\nfloat amt = (abs(max - avg) * 2.0) * uVibrance;\ncolor.r += max != color.r ? (max - color.r) * amt : 0.00;\ncolor.g += max != color.g ? (max - color.g) * amt : 0.00;\ncolor.b += max != color.b ? (max - color.b) * amt : 0.00;\ngl_FragColor = color;\n}",vibrance:0,mainParameter:"vibrance",applyTo2d:function(t){if(0!==this.vibrance){var e,i,n,r=t.imageData.data,s=r.length,o=-this.vibrance;for(e=0;e<s;e+=4)n=2*Math.abs((i=Math.max(r[e],r[e+1],r[e+2]))-(r[e]+r[e+1]+r[e+2])/3)/255*o,r[e]+=i!==r[e]?(i-r[e])*n:0,r[e+1]+=i!==r[e+1]?(i-r[e+1])*n:0,r[e+2]+=i!==r[e+2]?(i-r[e+2])*n:0}},getUniformLocations:function(t,e){return{uVibrance:t.getUniformLocation(e,"uVibrance")}},sendUniformData:function(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}}),e.Image.filters.Vibrance.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Blur=(0,e.util.createClass)(i.BaseFilter,{type:"Blur",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\nconst float nSamples = 15.0;\nvec3 v3offset = vec3(12.9898, 78.233, 151.7182);\nfloat random(vec3 scale) {\nreturn fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n}\nvoid main() {\nvec4 color = vec4(0.0);\nfloat total = 0.0;\nfloat offset = random(v3offset);\nfor (float t = -nSamples; t <= nSamples; t++) {\nfloat percent = (t + offset - 0.5) / nSamples;\nfloat weight = 1.0 - abs(percent);\ncolor += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\ntotal += weight;\n}\ngl_FragColor = color / total;\n}",blur:0,mainParameter:"blur",applyTo:function(t){t.webgl?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},applyTo2d:function(t){t.imageData=this.simpleBlur(t)},simpleBlur:function(t){var i,n,r=t.filterBackend.resources,s=t.imageData.width,o=t.imageData.height;r.blurLayer1||(r.blurLayer1=e.util.createCanvasElement(),r.blurLayer2=e.util.createCanvasElement()),i=r.blurLayer1,n=r.blurLayer2,(i.width!==s||i.height!==o)&&(n.width=i.width=s,n.height=i.height=o);var a,l,c,h,u=i.getContext("2d"),f=n.getContext("2d"),d=.06*this.blur*.5;for(u.putImageData(t.imageData,0,0),f.clearRect(0,0,s,o),h=-15;h<=15;h++)a=(Math.random()-.5)/4,c=d*(l=h/15)*s+a,f.globalAlpha=1-Math.abs(l),f.drawImage(i,c,a),u.drawImage(n,0,0),f.globalAlpha=1,f.clearRect(0,0,n.width,n.height);for(h=-15;h<=15;h++)a=(Math.random()-.5)/4,c=d*(l=h/15)*o+a,f.globalAlpha=1-Math.abs(l),f.drawImage(i,a,c),u.drawImage(n,0,0),f.globalAlpha=1,f.clearRect(0,0,n.width,n.height);t.ctx.drawImage(i,0,0);var g=t.ctx.getImageData(0,0,i.width,i.height);return u.globalAlpha=1,u.clearRect(0,0,i.width,i.height),g},getUniformLocations:function(t,e){return{delta:t.getUniformLocation(e,"uDelta")}},sendUniformData:function(t,e){var i=this.chooseRightDelta();t.uniform2fv(e.delta,i)},chooseRightDelta:function(){var t,e=1,i=[0,0];return this.horizontal?this.aspectRatio>1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),t=e*this.blur*.12,this.horizontal?i[0]=t:i[1]=t,i}}),i.Blur.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Gamma=(0,e.util.createClass)(i.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],i.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var e,i=t.imageData.data,n=this.gamma,r=i.length,s=1/n[0],o=1/n[1],a=1/n[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),e=0,r=256;e<r;e++)this.rVals[e]=255*Math.pow(e/255,s),this.gVals[e]=255*Math.pow(e/255,o),this.bVals[e]=255*Math.pow(e/255,a);for(e=0,r=i.length;e<r;e+=4)i[e]=this.rVals[i[e]],i[e+1]=this.gVals[i[e+1]],i[e+2]=this.bVals[i[e+2]]},getUniformLocations:function(t,e){return{uGamma:t.getUniformLocation(e,"uGamma")}},sendUniformData:function(t,e){t.uniform3fv(e.uGamma,this.gamma)}}),e.Image.filters.Gamma.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.Composed=(0,e.util.createClass)(i.BaseFilter,{type:"Composed",subFilters:[],initialize:function(t){this.callSuper("initialize",t),this.subFilters=this.subFilters.slice(0)},applyTo:function(t){t.passes+=this.subFilters.length-1,this.subFilters.forEach(function(e){e.applyTo(t)})},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{subFilters:this.subFilters.map(function(t){return t.toObject()})})},isNeutralState:function(){return!this.subFilters.some(function(t){return!t.isNeutralState()})}}),e.Image.filters.Composed.fromObject=function(t,i){var n=(t.subFilters||[]).map(function(t){return new e.Image.filters[t.type](t)}),r=new e.Image.filters.Composed({subFilters:n});return i&&i(r),r}}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters;i.HueRotation=(0,e.util.createClass)(i.ColorMatrix,{type:"HueRotation",rotation:0,mainParameter:"rotation",calculateMatrix:function(){var t=this.rotation*Math.PI,i=e.util.cos(t),n=e.util.sin(t),r=1/3,s=Math.sqrt(1/3)*n,o=1-i;this.matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this.matrix[0]=i+o/3,this.matrix[1]=r*o-s,this.matrix[2]=r*o+s,this.matrix[5]=r*o+s,this.matrix[6]=i+r*o,this.matrix[7]=r*o-s,this.matrix[10]=r*o-s,this.matrix[11]=r*o+s,this.matrix[12]=i+r*o},isNeutralState:function(t){return this.calculateMatrix(),i.BaseFilter.prototype.isNeutralState.call(this,t)},applyTo:function(t){this.calculateMatrix(),i.BaseFilter.prototype.applyTo.call(this,t)}}),e.Image.filters.HueRotation.fromObject=e.Image.filters.BaseFilter.fromObject}(i),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.clone;if(e.Text)return e.warn("fabric.Text is already defined");var n="fontFamily fontWeight fontSize text underline overline linethrough textAlign fontStyle lineHeight textBackgroundColor charSpacing styles direction path pathStartOffset pathSide pathAlign".split(" ");e.Text=e.util.createClass(e.Object,{_dimensionAffectingProps:["fontSize","fontWeight","fontFamily","fontStyle","lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:"left",fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stateProperties:e.Object.prototype.stateProperties.concat(n),cacheProperties:e.Object.prototype.cacheProperties.concat(n),stroke:null,shadow:null,path:null,pathStartOffset:0,pathSide:"left",pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,styles:null,_measuringContext:null,deltaY:0,direction:"ltr",_styleProperties:["stroke","strokeWidth","fill","fontFamily","fontSize","fontWeight","fontStyle","underline","overline","linethrough","deltaY","textBackgroundColor"],__charBounds:[],CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,initialize:function(t,e){this.styles=e&&e.styles||{},this.text=t,this.__skipDimension=!0,this.callSuper("initialize",e),this.path&&this.setPathInfo(),this.__skipDimension=!1,this.initDimensions(),this.setCoords(),this.setupState({propertySet:"_dimensionAffectingProps"})},setPathInfo:function(){var t=this.path;t&&(t.segmentsInfo=e.util.getPathSegmentsInfo(t.path))},getMeasuringContext:function(){return e._measuringContext||(e._measuringContext=this.canvas&&this.canvas.contextCache||e.util.createCanvasElement().getContext("2d")),e._measuringContext},_splitText:function(){var t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t},initDimensions:function(){if(!this.__skipDimension){if(this._splitText(),this._clearCache(),this.path){var t=1.1*this.getHeightOfLine(0);this.width=this.path.width+t,this.height=this.path.height+t}else this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight();-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.saveState({propertySet:"_dimensionAffectingProps"})}},enlargeSpaces:function(){for(var t,e,i,n,r,s,o,a=0,l=this._textLines.length;a<l;a++)if(!("justify"!==this.textAlign&&(a===l-1||this.isEndOfWrapping(a)))&&(n=0,r=this._textLines[a],(e=this.getLineWidth(a))<this.width&&(o=this.textLines[a].match(this._reSpacesAndTabs)))){i=o.length,t=(this.width-e)/i;for(var c=0,h=r.length;c<=h;c++)s=this.__charBounds[a][c],this._reSpaceAndTab.test(r[c])?(s.width+=t,s.kernedWidth+=t,s.left+=n,n+=t):s.left+=n}},isEndOfWrapping:function(t){return t===this._textLines.length-1},missingNewlineOffset:function(){return 1},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){var e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom"}t.font=this._getFontDeclaration(e,i)},calcTextWidth:function(){for(var t=this.getLineWidth(0),e=1,i=this._textLines.length;e<i;e++){var n=this.getLineWidth(e);n>t&&(t=n)}return t},_renderTextLine:function(t,e,i,n,r,s){this._renderChars(t,e,i,n,r,s)},_renderTextLinesBackground:function(t){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var e,i,n,r,s,o,a,l=t.fillStyle,c=this._getLeftOffset(),h=this._getTopOffset(),u=0,f=0,d=this.path,g=0,p=this._textLines.length;g<p;g++){if(e=this.getHeightOfLine(g),!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",g)){h+=e;continue}n=this._textLines[g],i=this._getLineLeftOffset(g),f=0,u=0,r=this.getValueOfPropertyAt(g,0,"textBackgroundColor");for(var m=0,y=n.length;m<y;m++)s=this.__charBounds[g][m],o=this.getValueOfPropertyAt(g,m,"textBackgroundColor"),d?(t.save(),t.translate(s.renderLeft,s.renderTop),t.rotate(s.angle),t.fillStyle=o,o&&t.fillRect(-s.width/2,-e/this.lineHeight*(1-this._fontSizeFraction),s.width,e/this.lineHeight),t.restore()):o!==r?(a=c+i+u,"rtl"===this.direction&&(a=this.width-a-f),t.fillStyle=r,r&&t.fillRect(a,h,f,e/this.lineHeight),u=s.left,f=s.width,r=o):f+=s.kernedWidth;o&&!d&&(a=c+i+u,"rtl"===this.direction&&(a=this.width-a-f),t.fillStyle=o,t.fillRect(a,h,f,e/this.lineHeight)),h+=e}t.fillStyle=l,this._removeShadow(t)}},getFontCache:function(t){var i=t.fontFamily.toLowerCase();e.charWidthsCache[i]||(e.charWidthsCache[i]={});var n=e.charWidthsCache[i],r=t.fontStyle.toLowerCase()+"_"+(t.fontWeight+"").toLowerCase();return n[r]||(n[r]={}),n[r]},_measureChar:function(t,e,i,n){var r,s,o,a,l=this.getFontCache(e),c=this._getFontDeclaration(e),h=this._getFontDeclaration(n),u=i+t,f=c===h,d=e.fontSize/this.CACHE_FONT_SIZE;if(i&&void 0!==l[i]&&(o=l[i]),void 0!==l[t]&&(a=r=l[t]),f&&void 0!==l[u]&&(a=(s=l[u])-o),void 0===r||void 0===o||void 0===s){var g=this.getMeasuringContext();this._setTextStyles(g,e,!0)}return void 0===r&&(a=r=g.measureText(t).width,l[t]=r),void 0===o&&f&&i&&(o=g.measureText(i).width,l[i]=o),f&&void 0===s&&(s=g.measureText(u).width,l[u]=s,a=s-o),{width:r*d,kernedWidth:a*d}},getHeightOfChar:function(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")},measureLine:function(t){var e=this._measureLine(t);return 0!==this.charSpacing&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e},_measureLine:function(t){var i,n,r,s,o,a,l=0,c=this._textLines[t],h=Array(c.length),u=0,f=this.path,d="right"===this.pathSide;for(i=0,this.__charBounds[t]=h;i<c.length;i++)n=c[i],s=this._getGraphemeBox(n,t,i,r),h[i]=s,l+=s.kernedWidth,r=n;if(h[i]={left:s?s.left+s.width:0,width:0,kernedWidth:0,height:this.fontSize},f){switch(a=f.segmentsInfo[f.segmentsInfo.length-1].length,o=e.util.getPointOnPath(f.path,0,f.segmentsInfo),o.x+=f.pathOffset.x,o.y+=f.pathOffset.y,this.textAlign){case"left":u=d?a-l:0;break;case"center":u=(a-l)/2;break;case"right":u=d?0:a-l}for(u+=this.pathStartOffset*(d?-1:1),i=d?c.length-1:0;d?i>=0:i<c.length;d?i--:i++)s=h[i],u>a?u%=a:u<0&&(u+=a),this._setGraphemeOnPath(u,s,o),u+=s.kernedWidth}return{width:l,numOfSpaces:0}},_setGraphemeOnPath:function(t,i,n){var r=t+i.kernedWidth/2,s=this.path,o=e.util.getPointOnPath(s.path,r,s.segmentsInfo);i.renderLeft=o.x-n.x,i.renderTop=o.y-n.y,i.angle=o.angle+("right"===this.pathSide?Math.PI:0)},_getGraphemeBox:function(t,e,i,n,r){var s,o=this.getCompleteStyleDeclaration(e,i),a=n?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,n,a),c=l.kernedWidth,h=l.width;0!==this.charSpacing&&(h+=s=this._getWidthOfCharSpacing(),c+=s);var u={width:h,left:0,height:o.fontSize,kernedWidth:c,deltaY:o.deltaY};if(i>0&&!r){var f=this.__charBounds[e][i-1];u.left=f.left+f.width+l.kernedWidth-l.width}return u},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var e=this._textLines[t],i=this.getHeightOfChar(t,0),n=1,r=e.length;n<r;n++)i=Math.max(this.getHeightOfChar(t,n),i);return this.__lineHeights[t]=i*this.lineHeight*this._fontSizeMult},calcTextHeight:function(){for(var t,e=0,i=0,n=this._textLines.length;i<n;i++)t=this.getHeightOfLine(i),e+=i===n-1?t/this.lineHeight:t;return e},_getLeftOffset:function(){return"ltr"===this.direction?-this.width/2:this.width/2},_getTopOffset:function(){return-this.height/2},_renderTextCommon:function(t,e){t.save();for(var i=0,n=this._getLeftOffset(),r=this._getTopOffset(),s=0,o=this._textLines.length;s<o;s++){var a=this.getHeightOfLine(s),l=a/this.lineHeight,c=this._getLineLeftOffset(s);this._renderTextLine(e,t,this._textLines[s],n+c,r+i+l,s),i+=a}t.restore()},_renderTextFill:function(t){(this.fill||this.styleHas("fill"))&&this._renderTextCommon(t,"fillText")},_renderTextStroke:function(t){(!this.stroke||0===this.strokeWidth)&&this.isEmptyStyles()||(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())},_renderChars:function(t,i,n,r,s,o){var a,l,c,h,u,f=this.getHeightOfLine(o),d=-1!==this.textAlign.indexOf("justify"),g="",p=0,m=this.path,y=!d&&0===this.charSpacing&&this.isEmptyStyles(o)&&!m,b="ltr"===this.direction,x="ltr"===this.direction?1:-1,_=i.canvas.getAttribute("dir");if(i.save(),_!==this.direction&&(i.canvas.setAttribute("dir",b?"ltr":"rtl"),i.direction=b?"ltr":"rtl",i.textAlign=b?"left":"right"),s-=f*this._fontSizeFraction/this.lineHeight,y){this._renderChar(t,i,o,0,n.join(""),r,s,f),i.restore();return}for(var C=0,S=n.length-1;C<=S;C++)h=C===S||this.charSpacing||m,g+=n[C],c=this.__charBounds[o][C],0===p?(r+=x*(c.kernedWidth-c.width),p+=c.width):p+=c.kernedWidth,d&&!h&&this._reSpaceAndTab.test(n[C])&&(h=!0),h||(a=a||this.getCompleteStyleDeclaration(o,C),l=this.getCompleteStyleDeclaration(o,C+1),h=e.util.hasStyleChanged(a,l,!1)),h&&(m?(i.save(),i.translate(c.renderLeft,c.renderTop),i.rotate(c.angle),this._renderChar(t,i,o,C,g,-p/2,0,f),i.restore()):(u=r,this._renderChar(t,i,o,C,g,u,s,f)),g="",a=l,r+=x*p,p=0);i.restore()},_applyPatternGradientTransformText:function(t){var i,n=e.util.createCanvasElement(),r=this.width+this.strokeWidth,s=this.height+this.strokeWidth;return n.width=r,n.height=s,(i=n.getContext("2d")).beginPath(),i.moveTo(0,0),i.lineTo(r,0),i.lineTo(r,s),i.lineTo(0,s),i.closePath(),i.translate(r/2,s/2),i.fillStyle=t.toLive(i),this._applyPatternGradientTransform(i,t),i.fill(),i.createPattern(n,"no-repeat")},handleFiller:function(t,e,i){var n,r;if(i.toLive)if("percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform)return n=-this.width/2,r=-this.height/2,t.translate(n,r),t[e]=this._applyPatternGradientTransformText(i),{offsetX:n,offsetY:r};else return t[e]=i.toLive(t,this),this._applyPatternGradientTransform(t,i);return t[e]=i,{offsetX:0,offsetY:0}},_setStrokeStyles:function(t,e){return t.lineWidth=e.strokeWidth,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",e.stroke)},_setFillStyles:function(t,e){return this.handleFiller(t,"fillStyle",e.fill)},_renderChar:function(t,e,i,n,r,s,o){var a,l,c=this._getStyleDeclaration(i,n),h=this.getCompleteStyleDeclaration(i,n),u="fillText"===t&&h.fill,f="strokeText"===t&&h.stroke&&h.strokeWidth;(f||u)&&(e.save(),u&&(a=this._setFillStyles(e,h)),f&&(l=this._setStrokeStyles(e,h)),e.font=this._getFontDeclaration(h),c&&c.textBackgroundColor&&this._removeShadow(e),c&&c.deltaY&&(o+=c.deltaY),u&&e.fillText(r,s-a.offsetX,o-a.offsetY),f&&e.strokeText(r,s-l.offsetX,o-l.offsetY),e.restore())},setSuperscript:function(t,e){return this._setScript(t,e,this.superscript)},setSubscript:function(t,e){return this._setScript(t,e,this.subscript)},_setScript:function(t,e,i){var n=this.get2DCursorLocation(t,!0),r=this.getValueOfPropertyAt(n.lineIndex,n.charIndex,"fontSize"),s=this.getValueOfPropertyAt(n.lineIndex,n.charIndex,"deltaY"),o={fontSize:r*i.size,deltaY:s+r*i.baseline};return this.setSelectionStyles(o,t,e),this},_getLineLeftOffset:function(t){var e,i=this.getLineWidth(t),n=this.width-i,r=this.textAlign,s=this.direction,o=0,e=this.isEndOfWrapping(t);return"justify"!==r&&("justify-center"!==r||e)&&("justify-right"!==r||e)&&("justify-left"!==r||e)?("center"===r&&(o=n/2),"right"===r&&(o=n),"justify-center"===r&&(o=n/2),"justify-right"===r&&(o=n),"rtl"===s&&(o-=n),o):0},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]},_shouldClearDimensionCache:function(){var t=this._forceClearCache;return t||(t=this.hasStateChanged("_dimensionAffectingProps")),t&&(this.dirty=!0,this._forceClearCache=!1),t},getLineWidth:function(t){if(void 0!==this.__lineWidths[t])return this.__lineWidths[t];var e=this.measureLine(t).width;return this.__lineWidths[t]=e,e},_getWidthOfCharSpacing:function(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0},getValueOfPropertyAt:function(t,e,i){var n=this._getStyleDeclaration(t,e);return n&&void 0!==n[i]?n[i]:this[i]},_renderTextDecoration:function(t,e){if(this[e]||this.styleHas(e)){t.save(),("overline"===e||"linethrough"===e)&&this._removeShadow(t);for(var i,n,r,s,o,a,l,c,h,u,f,d,g,p,m,y,b=this._getLeftOffset(),x=this._getTopOffset(),_=this.path,C=this._getWidthOfCharSpacing(),S=this.offsets[e],w=0,T=this._textLines.length;w<T;w++){if(i=this.getHeightOfLine(w),!this[e]&&!this.styleHas(e,w)){x+=i;continue}l=this._textLines[w],p=i/this.lineHeight,s=this._getLineLeftOffset(w),u=0,f=0,c=this.getValueOfPropertyAt(w,0,e),y=this.getValueOfPropertyAt(w,0,"fill"),h=x+p*(1-this._fontSizeFraction),n=this.getHeightOfChar(w,0),o=this.getValueOfPropertyAt(w,0,"deltaY");for(var O=0,k=l.length;O<k;O++)if(d=this.__charBounds[w][O],g=this.getValueOfPropertyAt(w,O,e),m=this.getValueOfPropertyAt(w,O,"fill"),r=this.getHeightOfChar(w,O),a=this.getValueOfPropertyAt(w,O,"deltaY"),_&&g&&m)t.save(),t.fillStyle=y,t.translate(d.renderLeft,d.renderTop),t.rotate(d.angle),t.fillRect(-d.kernedWidth/2,S*r+a,d.kernedWidth,this.fontSize/15),t.restore();else if((g!==c||m!==y||r!==n||a!==o)&&f>0){var E=b+s+u;"rtl"===this.direction&&(E=this.width-E-f),c&&y&&(t.fillStyle=y,t.fillRect(E,h+S*n+o,f,this.fontSize/15)),u=d.left,f=d.width,c=g,y=m,n=r,o=a}else f+=d.kernedWidth;var E=b+s+u;"rtl"===this.direction&&(E=this.width-E-f),t.fillStyle=m,g&&m&&t.fillRect(E,h+S*n+o,f-C,this.fontSize/15),x+=i}t.restore()}},_getFontDeclaration:function(t,i){var n=t||this,r=this.fontFamily,s=e.Text.genericFonts.indexOf(r.toLowerCase())>-1,o=void 0===r||r.indexOf("'")>-1||r.indexOf(",")>-1||r.indexOf('"')>-1||s?n.fontFamily:'"'+n.fontFamily+'"';return[e.isLikelyNode?n.fontWeight:n.fontStyle,e.isLikelyNode?n.fontStyle:n.fontWeight,i?this.CACHE_FONT_SIZE+"px":n.fontSize+"px",o].join(" ")},render:function(t){this.visible&&(!this.canvas||!this.canvas.skipOffscreen||this.group||this.isOnScreen())&&(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t))},_splitTextIntoLines:function(t){for(var i=t.split(this._reNewline),n=Array(i.length),r=["\n"],s=[],o=0;o<i.length;o++)n[o]=e.util.string.graphemeSplit(i[o]),s=s.concat(n[o],r);return s.pop(),{_unwrappedLines:n,lines:i,graphemeText:s,graphemeLines:n}},toObject:function(t){var i=n.concat(t),r=this.callSuper("toObject",i);return r.styles=e.util.stylesToArray(this.styles,this.text),r.path&&(r.path=this.path.toObject()),r},set:function(t,e){this.callSuper("set",t,e);var i=!1,n=!1;if("object"==typeof t)for(var r in t)"path"===r&&this.setPathInfo(),i=i||-1!==this._dimensionAffectingProps.indexOf(r),n=n||"path"===r;else i=-1!==this._dimensionAffectingProps.indexOf(t),n="path"===t;return n&&this.setPathInfo(),i&&(this.initDimensions(),this.setCoords()),this},complexity:function(){return 1}}),e.Text.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(" ")),e.Text.DEFAULT_SVG_FONT_SIZE=16,e.Text.fromElement=function(t,n,r){if(!t)return n(null);var s=e.parseAttributes(t,e.Text.ATTRIBUTE_NAMES),o=s.textAnchor||"left";if((r=e.util.object.extend(r?i(r):{},s)).top=r.top||0,r.left=r.left||0,s.textDecoration){var a=s.textDecoration;-1!==a.indexOf("underline")&&(r.underline=!0),-1!==a.indexOf("overline")&&(r.overline=!0),-1!==a.indexOf("line-through")&&(r.linethrough=!0),delete r.textDecoration}"dx"in s&&(r.left+=s.dx),"dy"in s&&(r.top+=s.dy),"fontSize"in r||(r.fontSize=e.Text.DEFAULT_SVG_FONT_SIZE);var l="";"textContent"in t?l=t.textContent:"firstChild"in t&&null!==t.firstChild&&"data"in t.firstChild&&null!==t.firstChild.data&&(l=t.firstChild.data),l=l.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var c=r.strokeWidth;r.strokeWidth=0;var h=new e.Text(l,r),u=h.getScaledHeight()/h.height,f=(h.height+h.strokeWidth)*h.lineHeight-h.height,d=h.getScaledHeight()+f*u,g=0;"center"===o&&(g=h.getScaledWidth()/2),"right"===o&&(g=h.getScaledWidth()),h.set({left:h.left-g,top:h.top-(d-h.fontSize*(.07+h._fontSizeFraction))/h.lineHeight,strokeWidth:void 0!==c?c:1}),n(h)},e.Text.fromObject=function(t,n){var r=i(t),s=t.path;return delete r.path,e.Object._fromObject("Text",r,function(i){i.styles=e.util.stylesFromArray(t.styles,t.text),s?e.Object._fromObject("Path",s,function(t){i.set("path",t),n(i)},"path"):n(i)},"text")},e.Text.genericFonts=["sans-serif","serif","cursive","fantasy","monospace"],e.util.createAccessors&&e.util.createAccessors(e.Text)}(i),r.util.object.extend(r.Text.prototype,{isEmptyStyles:function(t){if(!this.styles||void 0!==t&&!this.styles[t])return!0;var e=void 0===t?this.styles:{line:this.styles[t]};for(var i in e)for(var n in e[i])for(var r in e[i][n])return!1;return!0},styleHas:function(t,e){if(!this.styles||!t||""===t||void 0!==e&&!this.styles[e])return!1;var i=void 0===e?this.styles:{0:this.styles[e]};for(var n in i)for(var r in i[n])if(void 0!==i[n][r][t])return!0;return!1},cleanStyle:function(t){if(!this.styles||!t||""===t)return!1;var e,i,n,r=this.styles,s=0,o=!0,a=0;for(var l in r){for(var c in e=0,r[l]){var n=r[l][c],h=n.hasOwnProperty(t);s++,h?(i?n[t]!==i&&(o=!1):i=n[t],n[t]===this[t]&&delete n[t]):o=!1,0!==Object.keys(n).length?e++:delete r[l][c]}0===e&&delete r[l]}for(var u=0;u<this._textLines.length;u++)a+=this._textLines[u].length;o&&s===a&&(this[t]=i,this.removeStyle(t))},removeStyle:function(t){if(this.styles&&t&&""!==t){var e,i,n,r=this.styles;for(i in r){for(n in e=r[i])delete e[n][t],0===Object.keys(e[n]).length&&delete e[n];0===Object.keys(e).length&&delete r[i]}}},_extendStyles:function(t,e){var i=this.get2DCursorLocation(t);this._getLineStyle(i.lineIndex)||this._setLineStyle(i.lineIndex),this._getStyleDeclaration(i.lineIndex,i.charIndex)||this._setStyleDeclaration(i.lineIndex,i.charIndex,{}),r.util.object.extend(this._getStyleDeclaration(i.lineIndex,i.charIndex),e)},get2DCursorLocation:function(t,e){void 0===t&&(t=this.selectionStart);for(var i=e?this._unwrappedTextLines:this._textLines,n=i.length,r=0;r<n;r++){if(t<=i[r].length)return{lineIndex:r,charIndex:t};t-=i[r].length+this.missingNewlineOffset(r,e)}return{lineIndex:r-1,charIndex:i[r-1].length<t?i[r-1].length:t}},getSelectionStyles:function(t,e,i){void 0===t&&(t=this.selectionStart||0),void 0===e&&(e=this.selectionEnd||t);for(var n=[],r=t;r<e;r++)n.push(this.getStyleAtPosition(r,i));return n},getStyleAtPosition:function(t,e){var i=this.get2DCursorLocation(t);return(e?this.getCompleteStyleDeclaration(i.lineIndex,i.charIndex):this._getStyleDeclaration(i.lineIndex,i.charIndex))||{}},setSelectionStyles:function(t,e,i){void 0===e&&(e=this.selectionStart||0),void 0===i&&(i=this.selectionEnd||e);for(var n=e;n<i;n++)this._extendStyles(n,t);return this._forceClearCache=!0,this},_getStyleDeclaration:function(t,e){var i=this.styles&&this.styles[t];return i?i[e]:null},getCompleteStyleDeclaration:function(t,e){for(var i,n=this._getStyleDeclaration(t,e)||{},r={},s=0;s<this._styleProperties.length;s++)r[i=this._styleProperties[s]]=void 0===n[i]?this[i]:n[i];return r},_setStyleDeclaration:function(t,e,i){this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){delete this.styles[t][e]},_getLineStyle:function(t){return!!this.styles[t]},_setLineStyle:function(t){this.styles[t]={}},_deleteLineStyle:function(t){delete this.styles[t]}}),function(){function t(t){t.textDecoration&&(t.textDecoration.indexOf("underline")>-1&&(t.underline=!0),t.textDecoration.indexOf("line-through")>-1&&(t.linethrough=!0),t.textDecoration.indexOf("overline")>-1&&(t.overline=!0),delete t.textDecoration)}r.IText=r.util.createClass(r.Text,r.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(t,e){this.callSuper("initialize",t,e),this.initBehavior()},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(t){this.clearContextTop(),this.callSuper("render",t),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t)},clearContextTop:function(t){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var e=this.canvas.contextTop,i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e),this._clearTextArea(e),t||e.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this._getCursorBoundaries(),e=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(t,e):this.renderSelection(t,e),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},_getCursorBoundaries:function(t){void 0===t&&(t=this.selectionStart);var e=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t);return{left:e,top:i,leftOffset:n.left,topOffset:n.top}},_getCursorBoundariesOffsets:function(t){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var e,i,n,r,s=0,o=0,a=this.get2DCursorLocation(t);n=a.charIndex,i=a.lineIndex;for(var l=0;l<i;l++)s+=this.getHeightOfLine(l);e=this._getLineLeftOffset(i);var c=this.__charBounds[i][n];return c&&(o=c.left),0!==this.charSpacing&&n===this._textLines[i].length&&(o-=this._getWidthOfCharSpacing()),r={top:s,left:e+(o>0?o:0)},"rtl"===this.direction&&(r.left*=-1),this.cursorOffsetCache=r,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),n=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,s=this.getValueOfPropertyAt(n,r,"fontSize"),o=this.scaleX*this.canvas.getZoom(),a=this.cursorWidth/o,l=t.topOffset,c=this.getValueOfPropertyAt(n,r,"deltaY");l+=(1-this._fontSizeFraction)*this.getHeightOfLine(n)/this.lineHeight-s*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(t,e),e.fillStyle=this.cursorColor||this.getValueOfPropertyAt(n,r,"fill"),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+t.leftOffset-a/2,l+t.top+c,a,s)},renderSelection:function(t,e){for(var i=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,n=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,r=-1!==this.textAlign.indexOf("justify"),s=this.get2DCursorLocation(i),o=this.get2DCursorLocation(n),a=s.lineIndex,l=o.lineIndex,c=s.charIndex<0?0:s.charIndex,h=o.charIndex<0?0:o.charIndex,u=a;u<=l;u++){var f=this._getLineLeftOffset(u)||0,d=this.getHeightOfLine(u),g=0,p=0,m=0;if(u===a&&(p=this.__charBounds[a][c].left),u>=a&&u<l)m=r&&!this.isEndOfWrapping(u)?this.width:this.getLineWidth(u)||5;else if(u===l)if(0===h)m=this.__charBounds[l][h].left;else{var y=this._getWidthOfCharSpacing();m=this.__charBounds[l][h-1].left+this.__charBounds[l][h-1].width-y}g=d,(this.lineHeight<1||u===l&&this.lineHeight>1)&&(d/=this.lineHeight);var b=t.left+f+p,x=m-p,_=d,C=0;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",_=1,C=d):e.fillStyle=this.selectionColor,"rtl"===this.direction&&(b=this.width-b-x),e.fillRect(b,t.top+t.topOffset+C,x,_),t.topOffset+=g}},getCurrentCharFontSize:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")},getCurrentCharColor:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fill")},_getCurrentCharIndex:function(){var t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}}),r.IText.fromObject=function(e,i){var n=r.util.stylesFromArray(e.styles,e.text),s=Object.assign({},e,{styles:n});if(delete s.path,t(s),s.styles)for(var o in s.styles)for(var a in s.styles[o])t(s.styles[o][a]);r.Object._fromObject("IText",s,function(t){e.path?r.Object._fromObject("Path",e.path,function(e){t.set("path",e),i(t)},"path"):i(t)},"text")}}(),function(){var t=r.util.object.clone;r.util.object.extend(r.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var t=this;this.on("added",function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))})},initRemovedHandler:function(){var t=this;this.on("removed",function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],r.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))})},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach(function(t){t.__isMousedown=!1})},t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,n){var r;return r={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){r.isAborted||t[n]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return r.isAborted}}),r},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout(function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout(function(){e._tick()},i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState,e=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&e&&e.clearContext(e.contextTop||e.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e},findLineBoundaryLeft:function(t){for(var e=0,i=t-1;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e},searchWordBoundary:function(t,e){for(var i=this._text,n=this._reSpace.test(i[t])?t-1:t,s=i[n],o=r.reNonWord;!o.test(s)&&n>0&&n<i.length;)n+=e,s=i[n];return o.test(s)&&(n+=+(1!==e)),n},selectWord:function(t){t=t||this.selectionStart;var e=this.searchWordBoundary(t,-1),i=this.searchWordBoundary(t,1);this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()},selectLine:function(t){t=t||this.selectionStart;var e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);return this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this},enterEditing:function(t){if(!this.isEditing&&this.editable)return this.canvas&&(this.canvas.calcOffset(),this.exitEditingOnOthers(this.canvas)),this.isEditing=!0,this.initHiddenTextarea(t),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this.canvas.requestRenderAll()),this},exitEditingOnOthers:function(t){t._iTextInstances&&t._iTextInstances.forEach(function(t){t.selected=!1,t.isEditing&&t.exitEditing()})},initMouseMoveHandler:function(){this.canvas.on("mouse:move",this.mouseMoveHandler)},mouseMoveHandler:function(t){if(this.__isMousedown&&this.isEditing){document.activeElement!==this.hiddenTextarea&&this.hiddenTextarea.focus();var e=this.getSelectionStartFromPointer(t.e),i=this.selectionStart,n=this.selectionEnd;(e===this.__selectionStartOnMouseDown&&i!==n||i!==e&&n!==e)&&(e>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),(this.selectionStart!==i||this.selectionEnd!==n)&&(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(t,e,i){var n=i.slice(0,t),s=r.util.string.graphemeSplit(n).length;if(t===e)return{selectionStart:s,selectionEnd:s};var o=i.slice(t,e);return{selectionStart:s,selectionEnd:s+r.util.string.graphemeSplit(o).length}},fromGraphemeToStringSelection:function(t,e,i){var n=i.slice(0,t).join("").length;return t===e?{selectionStart:n,selectionEnd:n}:{selectionStart:n,selectionEnd:n+i.slice(t,e).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var t=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),n=i.lineIndex,s=i.charIndex,o=this.getValueOfPropertyAt(n,s,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.calcTransformMatrix(),c={x:e.left+a,y:e.top+e.topOffset+o},h=this.canvas.getRetinaScaling(),u=this.canvas.upperCanvasEl,f=u.width/h,d=u.height/h,g=f-o,p=d-o,m=u.clientWidth/f,y=u.clientHeight/d;return c=r.util.transformPoint(c,l),c=r.util.transformPoint(c,this.canvas.viewportTransform),c.x*=m,c.y*=y,c.x<0&&(c.x=0),c.x>g&&(c.x=g),c.y<0&&(c.y=0),c.y>p&&(c.y=p),c.x+=this.canvas._offset.left,c.y+=this.canvas._offset.top,{left:c.x+"px",top:c.y+"px",fontSize:o+"px",charHeight:o}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text,e=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},removeStyleFromTo:function(t,e){var i,n,r=this.get2DCursorLocation(t,!0),s=this.get2DCursorLocation(e,!0),o=r.lineIndex,a=r.charIndex,l=s.lineIndex,c=s.charIndex;if(o!==l){if(this.styles[o])for(i=a;i<this._unwrappedTextLines[o].length;i++)delete this.styles[o][i];if(this.styles[l])for(i=c;i<this._unwrappedTextLines[l].length;i++)(n=this.styles[l][i])&&(this.styles[o]||(this.styles[o]={}),this.styles[o][a+i-c]=n);for(i=o+1;i<=l;i++)delete this.styles[i];this.shiftLineStyles(l,o-l)}else if(this.styles[o]){n=this.styles[o];var h,u,f=c-a;for(i=a;i<c;i++)delete n[i];for(u in this.styles[o])(h=parseInt(u,10))>=c&&(n[h-f]=n[u],delete n[u])}},shiftLineStyles:function(e,i){var n=t(this.styles);for(var r in this.styles){var s=parseInt(r,10);s>e&&(this.styles[s+i]=n[s],n[s-i]||delete this.styles[s])}},restartCursorIfNeeded:function(){(!this._currentTickState||this._currentTickState.isAborted||!this._currentTickCompleteState||this._currentTickCompleteState.isAborted)&&this.initDelayedCursor()},insertNewlineStyleObject:function(e,i,n,r){var s,o={},a=!1,l=this._unwrappedTextLines[e].length,c=l===i;for(var h in n||(n=1),this.shiftLineStyles(e,n),this.styles[e]&&(s=this.styles[e][0===i?i:i-1]),this.styles[e]){var u=parseInt(h,10);u>=i&&(a=!0,o[u-i]=this.styles[e][h],c&&0===i||delete this.styles[e][h])}var f=!1;for(a&&!c&&(this.styles[e+n]=o,f=!0),(f||l>i)&&n--;n>0;)r&&r[n-1]?this.styles[e+n]={0:t(r[n-1])}:s?this.styles[e+n]={0:t(s)}:delete this.styles[e+n],n--;this._forceClearCache=!0},insertCharStyleObject:function(e,i,n,r){this.styles||(this.styles={});var s=this.styles[e],o=s?t(s):{};for(var a in n||(n=1),o){var l=parseInt(a,10);l>=i&&(s[l+n]=o[l],o[l-n]||delete s[l])}if(this._forceClearCache=!0,r){for(;n--;)Object.keys(r[n]).length&&(this.styles[e]||(this.styles[e]={}),this.styles[e][i+n]=t(r[n]));return}if(s)for(var c=s[i?i-1:1];c&&n--;)this.styles[e][i+n]=t(c)},insertNewStyleBlock:function(t,e,i){for(var n=this.get2DCursorLocation(e,!0),r=[0],s=0,o=0;o<t.length;o++)"\n"===t[o]?r[++s]=0:r[s]++;r[0]>0&&(this.insertCharStyleObject(n.lineIndex,n.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),s&&this.insertNewlineStyleObject(n.lineIndex,n.charIndex+r[0],s);for(var o=1;o<s;o++)r[o]>0?this.insertCharStyleObject(n.lineIndex+o,0,r[o],i):i&&this.styles[n.lineIndex+o]&&i[0]&&(this.styles[n.lineIndex+o][0]=i[0]),i=i&&i.slice(r[o]+1);r[o]>0&&this.insertCharStyleObject(n.lineIndex+o,0,r[o],i)},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?"right"===this._selectionDirection?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection="right":"left"===this._selectionDirection&&(this._selectionDirection="right",this.selectionStart=e),this.selectionEnd=i)},setSelectionInBoundaries:function(){var t=this.text.length;this.selectionStart>t?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}})}(),r.util.object.extend(r.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(t){if(this.canvas){this.__newClickTime=+new Date;var e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))},tripleClickHandler:function(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(t){this.canvas&&this.editable&&(!t.e.button||1===t.e.button)&&(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(t.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(t){this.canvas&&this.editable&&(!t.e.button||1===t.e.button)&&(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(t){if(this.__isMousedown=!1,this.editable&&!this.group&&(!t.transform||!t.transform.actionPerformed)&&(!t.e.button||1===t.e.button)){if(this.canvas){var e=this.canvas._activeObject;if(e&&e!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,n,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e,i=this.getLocalPointer(t),n=0,r=0,s=0,o=0,a=0,l=0,c=this._textLines.length;l<c;l++)if(s<=i.y)s+=this.getHeightOfLine(l)*this.scaleY,a=l,l>0&&(o+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));else break;r=this._getLineLeftOffset(a)*this.scaleX,e=this._textLines[a],"rtl"===this.direction&&(i.x=this.width*this.scaleX-i.x+r);for(var h=0,u=e.length;h<u;h++)if(n=r,(r+=this.__charBounds[a][h].kernedWidth*this.scaleX)<=i.x)o++;else break;return this._getNewSelectionStartFromOffset(i,n,r,o,u)},_getNewSelectionStartFromOffset:function(t,e,i,n,r){var s=t.x-e,o=i-t.x,a=n+(o>s||o<0?0:1);return this.flipX&&(a=r-a),a>this._text.length&&(a=this._text.length),a}}),r.util.object.extend(r.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=r.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: "+t.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):r.document.body.appendChild(this.hiddenTextarea),r.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),r.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),r.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),r.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),r.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),r.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),r.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),r.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),r.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(r.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing){var e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(t){if(!this.isEditing||this._copyDone||this.inCompositionMode){this._copyDone=!1;return}t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(t){var e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),this.isEditing){var i,n,s,o,a,l=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,c=this._text.length,h=l.length,u=h-c,f=this.selectionStart,d=this.selectionEnd,g=f!==d;if(""===this.hiddenTextarea.value){this.styles={},this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll());return}var p=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=f>p.selectionStart;g?(i=this._text.slice(f,d),u+=d-f):h<c&&(i=m?this._text.slice(d+u,d):this._text.slice(f,f-u)),n=l.slice(p.selectionEnd-u,p.selectionEnd),i&&i.length&&(n.length&&(s=this.getSelectionStyles(f,f+1,!1),s=n.map(function(){return s[0]})),g?(o=f,a=d):m?(o=d-i.length,a=d):(o=d,a=d+i.length),this.removeStyleFromTo(o,a)),n.length&&(e&&n.join("")===r.copiedText&&!r.disableStyleCopyPaste&&(s=r.copiedTextStyle),this.insertNewStyleBlock(n,f,s)),this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())}},onCompositionStart:function(){this.inCompositionMode=!0},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(t){this.compositionStart=t.target.selectionStart,this.compositionEnd=t.target.selectionEnd,this.updateTextareaPosition()},copy:function(){this.selectionStart!==this.selectionEnd&&(r.copiedText=this.getSelectedText(),r.disableStyleCopyPaste?r.copiedTextStyle=null:r.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0)},paste:function(){this.fromPaste=!0},_getClipboardData:function(t){return t&&t.clipboardData||r.window.clipboardData},_getWidthBeforeCursor:function(t,e){var i,n=this._getLineLeftOffset(t);return e>0&&(n+=(i=this.__charBounds[t][e-1]).left+i.width),n},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;var s=n.charIndex,o=this._getWidthBeforeCursor(r,s),a=this._getIndexOnLine(r+1,o);return this._textLines[r].slice(s).length+a+1+this.missingNewlineOffset(r)},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;var s=n.charIndex,o=this._getWidthBeforeCursor(r,s),a=this._getIndexOnLine(r-1,o),l=this._textLines[r].slice(0,s),c=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+a-l.length+(1-c)},_getIndexOnLine:function(t,e){for(var i,n,r=this._textLines[t],s=this._getLineLeftOffset(t),o=0,a=0,l=r.length;a<l;a++)if((s+=i=this.__charBounds[t][a].width)>e){n=!0;var c=Math.abs(s-i-e);o=Math.abs(s-e)<c?a:a-1;break}return n||(o=r.length-1),o},moveCursorDown:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){(0!==this.selectionStart||0!==this.selectionEnd)&&this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){(0!==this.selectionStart||0!==this.selectionEnd)&&this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var n;if(t.altKey)n=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;n=this["findLineBoundary"+i](this[e])}if(void 0!==n&&this[e]!==n)return this[e]=n,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t,e){void 0===e&&(e=t+1),this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(t,e,i,n){void 0===n&&(n=i),n>i&&this.removeStyleFromTo(i,n);var s=r.util.string.graphemeSplit(t);this.insertNewStyleBlock(s,i,e),this._text=[].concat(this._text.slice(0,i),s,this._text.slice(n)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var t=r.util.toFixed,e=r.util.radiansToDegrees,i=r.util.calcRotateMatrix,n=r.util.transformPoint,s=/ +/g;r.util.object.extend(r.Text.prototype,{_toSVG:function(){var t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)},toSVG:function(t){var e=this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0}),i=this.path;return i?e+i._createBaseSVGMarkup(i._toSVG(),{reviver:t,withShadow:!0}):e},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(t){var e=this.getSvgTextDecoration(this);return[t.textBgRects.join(""),' <text xml:space="preserve" ',this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",e?'text-decoration="'+e+'" ':"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",t.textSpans.join(""),"</text>\n"]},_getSVGTextAndBg:function(t,e){var i,n=[],r=[],s=t;this._setSVGBg(r);for(var o=0,a=this._textLines.length;o<a;o++)i=this._getLineLeftOffset(o),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(r,o,e+i,s),this._setSVGTextLineText(n,o,e+i,s),s+=this.getHeightOfLine(o);return{textSpans:n,textBgRects:r}},_createTextCharSpan:function(o,a,l,c,h){var u=o!==o.trim()||o.match(s),f=this.getSvgSpanStyles(a,u),d=a.deltaY,g="",p=r.Object.NUM_FRACTION_DIGITS,m="";if(d&&(g=' dy="'+t(d,p)+'" '),void 0!==h.renderLeft){var y=h.angle;m=' rotate="'+t(e(y),r.Object.NUM_FRACTION_DIGITS)+'" ';var b=h.width/2,x=i({angle:e(y)});x[4]=h.renderLeft,x[5]=h.renderTop;var _=n({x:-b,y:0},x);l=_.x,c=_.y}return'<tspan x="'+t(l,p)+'" y="'+t(c,p)+'" '+g+(f?'style="'+f+'"':"")+m+">"+r.util.string.escapeXml(o)+"</tspan>"},_setSVGTextLineText:function(t,e,i,n){var s,o,a,l,c,h=this.getHeightOfLine(e),u=-1!==this.textAlign.indexOf("justify"),f="",d=0,g=this._textLines[e];n+=h*(1-this._fontSizeFraction)/this.lineHeight;for(var p=0,m=g.length-1;p<=m;p++)c=p===m||this.charSpacing||this.path,f+=g[p],a=this.__charBounds[e][p],0===d?(i+=a.kernedWidth-a.width,d+=a.width):d+=a.kernedWidth,u&&!c&&this._reSpaceAndTab.test(g[p])&&(c=!0),c||(s=s||this.getCompleteStyleDeclaration(e,p),o=this.getCompleteStyleDeclaration(e,p+1),c=r.util.hasStyleChanged(s,o,!0)),c&&(l=this._getStyleDeclaration(e,p)||{},t.push(this._createTextCharSpan(f,l,i,n,a)),f="",s=o,i+=d,d=0)},_pushTextBgRect:function(e,i,n,s,o,a){var l=r.Object.NUM_FRACTION_DIGITS;e.push(" <rect ",this._getFillAttributes(i),' x="',t(n,l),'" y="',t(s,l),'" width="',t(o,l),'" height="',t(a,l),'"></rect>\n')},_setSVGTextLineBg:function(t,e,i,n){for(var r,s,o=this._textLines[e],a=this.getHeightOfLine(e)/this.lineHeight,l=0,c=0,h=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),u=0,f=o.length;u<f;u++)r=this.__charBounds[e][u],(s=this.getValueOfPropertyAt(e,u,"textBackgroundColor"))!==h?(h&&this._pushTextBgRect(t,h,i+c,n,l,a),c=r.left,l=r.width,h=s):l+=r.kernedWidth;s&&this._pushTextBgRect(t,s,i+c,n,l,a)},_getFillAttributes:function(t){var e=t&&"string"==typeof t?new r.Color(t):"";return e&&e.getSource()&&1!==e.getAlpha()?'opacity="'+e.getAlpha()+'" fill="'+e.setAlpha(1).toRgb()+'"':'fill="'+t+'"'},_getSVGLineTopOffset:function(t){for(var e=0,i=0,n=0;n<t;n++)e+=this.getHeightOfLine(n);return i=this.getHeightOfLine(n),{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}},getSvgStyles:function(t){return r.Object.prototype.getSvgStyles.call(this,t)+" white-space: pre;"}})}(),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Textbox=e.util.createClass(e.IText,e.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingFlip:!0,noScaleCache:!1,_dimensionAffectingProps:e.Text.prototype._dimensionAffectingProps.concat("width"),_wordJoiners:/[ \t\r]/,splitByGrapheme:!1,initDimensions:function(){this.__skipDimension||(this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(t){for(var e=0,i=0,n=0,r={},s=0;s<t.graphemeLines.length;s++)"\n"===t.graphemeText[n]&&s>0?(i=0,n++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[n])&&s>0&&(i++,n++),r[s]={line:e,offset:i},n+=t.graphemeLines[s].length,i+=t.graphemeLines[s].length;return r},styleHas:function(t,i){if(this._styleMap&&!this.isWrapping){var n=this._styleMap[i];n&&(i=n.line)}return e.Text.prototype.styleHas.call(this,t,i)},isEmptyStyles:function(t){if(!this.styles)return!0;var e,i,n=0,r=!1,s=this._styleMap[t],o=this._styleMap[t+1];for(var a in s&&(t=s.line,n=s.offset),o&&(r=o.line===t,e=o.offset),i=void 0===t?this.styles:{line:this.styles[t]})for(var l in i[a])if(l>=n&&(!r||l<e))for(var c in i[a][l])return!1;return!0},_getStyleDeclaration:function(t,e){if(this._styleMap&&!this.isWrapping){var i=this._styleMap[t];if(!i)return null;t=i.line,e=i.offset+e}return this.callSuper("_getStyleDeclaration",t,e)},_setStyleDeclaration:function(t,e,i){var n=this._styleMap[t];t=n.line,e=n.offset+e,this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){var i=this._styleMap[t];t=i.line,e=i.offset+e,delete this.styles[t][e]},_getLineStyle:function(t){var e=this._styleMap[t];return!!this.styles[e.line]},_setLineStyle:function(t){var e=this._styleMap[t];this.styles[e.line]={}},_wrapText:function(t,e){var i,n=[];for(i=0,this.isWrapping=!0;i<t.length;i++)n=n.concat(this._wrapLine(t[i],i,e));return this.isWrapping=!1,n},_measureWord:function(t,e,i){var n,r=0;i=i||0;for(var s=0,o=t.length;s<o;s++)r+=this._getGraphemeBox(t[s],e,s+i,n,!0).kernedWidth,n=t[s];return r},_wrapLine:function(t,i,n,r){var s=0,o=this.splitByGrapheme,a=[],l=[],c=o?e.util.string.graphemeSplit(t):t.split(this._wordJoiners),h="",u=0,f=o?"":" ",d=0,g=0,p=0,m=!0,y=this._getWidthOfCharSpacing(),r=r||0;0===c.length&&c.push([]),n-=r;for(var b=0;b<c.length;b++)h=o?c[b]:e.util.string.graphemeSplit(c[b]),d=this._measureWord(h,i,u),u+=h.length,(s+=g+d-y)>n&&!m?(a.push(l),l=[],s=d,m=!0):s+=y,m||o||l.push(f),l=l.concat(h),g=o?0:this._measureWord([f],i,u),u++,m=!1,d>p&&(p=d);return b&&a.push(l),p+r>this.dynamicMinWidth&&(this.dynamicMinWidth=p-y+r),a},isEndOfWrapping:function(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line},missingNewlineOffset:function(t,e){return this.splitByGrapheme&&!e?+!!this.isEndOfWrapping(t):1},_splitTextIntoLines:function(t){for(var i=e.Text.prototype._splitTextIntoLines.call(this,t),n=this._wrapText(i.lines,this.width),r=Array(n.length),s=0;s<n.length;s++)r[s]=n[s].join("");return i.lines=r,i.graphemeLines=n,i},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var t={};for(var e in this._styleMap)this._textLines[e]&&(t[this._styleMap[e].line]=1);for(var e in this.styles)t[e]||delete this.styles[e]},toObject:function(t){return this.callSuper("toObject",["minWidth","splitByGrapheme"].concat(t))}}),e.Textbox.fromObject=function(t,i){var n=e.util.stylesFromArray(t.styles,t.text),r=Object.assign({},t,{styles:n});return delete r.path,e.Object._fromObject("Textbox",r,function(n){t.path?e.Object._fromObject("Path",t.path,function(t){n.set("path",t),i(n)},"path"):i(n)},"text")}}(i),function(){var t=r.controlsUtils,e=t.scaleSkewCursorStyleHandler,i=t.scaleCursorStyleHandler,n=t.scalingEqually,s=t.scalingYOrSkewingX,o=t.scalingXOrSkewingY,a=t.scaleOrSkewActionName,l=r.Object.prototype.controls;if(l.ml=new r.Control({x:-.5,y:0,cursorStyleHandler:e,actionHandler:o,getActionName:a}),l.mr=new r.Control({x:.5,y:0,cursorStyleHandler:e,actionHandler:o,getActionName:a}),l.mb=new r.Control({x:0,y:.5,cursorStyleHandler:e,actionHandler:s,getActionName:a}),l.mt=new r.Control({x:0,y:-.5,cursorStyleHandler:e,actionHandler:s,getActionName:a}),l.tl=new r.Control({x:-.5,y:-.5,cursorStyleHandler:i,actionHandler:n}),l.tr=new r.Control({x:.5,y:-.5,cursorStyleHandler:i,actionHandler:n}),l.bl=new r.Control({x:-.5,y:.5,cursorStyleHandler:i,actionHandler:n}),l.br=new r.Control({x:.5,y:.5,cursorStyleHandler:i,actionHandler:n}),l.mtr=new r.Control({x:0,y:-.5,actionHandler:t.rotationWithSnapping,cursorStyleHandler:t.rotationStyleHandler,offsetY:-40,withConnection:!0,actionName:"rotate"}),r.Textbox){var c=r.Textbox.prototype.controls={};c.mtr=l.mtr,c.tr=l.tr,c.br=l.br,c.tl=l.tl,c.bl=l.bl,c.mt=l.mt,c.mb=l.mb,c.mr=new r.Control({x:.5,y:0,actionHandler:t.changeWidth,cursorStyleHandler:e,actionName:"resizing"}),c.ml=new r.Control({x:-.5,y:0,actionHandler:t.changeWidth,cursorStyleHandler:e,actionName:"resizing"})}}()},43794,(t,e,i)=>{!function(){"use strict";var i={}.hasOwnProperty;function n(){for(var t=[],e=0;e<arguments.length;e++){var r=arguments[e];if(r){var s=typeof r;if("string"===s||"number"===s)t.push(r);else if(Array.isArray(r)){if(r.length){var o=n.apply(null,r);o&&t.push(o)}}else if("object"===s){if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]")){t.push(r.toString());continue}for(var a in r)i.call(r,a)&&r[a]&&t.push(a)}}}return t.join(" ")}if(e.exports)n.default=n,e.exports=n;else if("function"==typeof define&&"object"==typeof define.amd&&define.amd)void 0!==n&&t.v(n);else window.classNames=n}()},79702,t=>{t.v(t.b(["static/chunks/9338a92aac995757.js","static/chunks/a55df98dcb3b60ad.js","static/chunks/turbopack-95cb340f669027bc.js"]))},67585,(t,e,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"BailoutToCSR",{enumerable:!0,get:function(){return r}});let n=t.r(32061);function r(t){let{reason:e,children:i}=t;if("undefined"==typeof window)throw Object.defineProperty(new n.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return i}},9885,(t,e,i)=>{"use strict";function n(t){return t.split("/").map(t=>encodeURIComponent(t)).join("/")}Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"encodeURIPath",{enumerable:!0,get:function(){return n}})},52157,(t,e,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"PreloadChunks",{enumerable:!0,get:function(){return a}});let n=t.r(43476),r=t.r(74080),s=t.r(63599),o=t.r(9885);function a(t){let{moduleIds:e}=t;if("undefined"!=typeof window)return null;let i=s.workAsyncStorage.getStore();if(void 0===i)return null;let a=[];if(i.reactLoadableManifest&&e){let t=i.reactLoadableManifest;for(let i of e){if(!t[i])continue;let e=t[i].files;a.push(...e)}}return 0===a.length?null:(0,n.jsx)(n.Fragment,{children:a.map(t=>{let e=i.assetPrefix+"/_next/"+(0,o.encodeURIPath)(t);return t.endsWith(".css")?(0,n.jsx)("link",{precedence:"dynamic",href:e,rel:"stylesheet",as:"style"},t):((0,r.preload)(e,{as:"script",fetchPriority:"low"}),null)})})}},69093,(t,e,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"default",{enumerable:!0,get:function(){return c}});let n=t.r(43476),r=t.r(71645),s=t.r(67585),o=t.r(52157);function a(t){return{default:t&&"default"in t?t.default:t}}let l={loader:()=>Promise.resolve(a(()=>null)),loading:null,ssr:!0},c=function(t){let e={...l,...t},i=(0,r.lazy)(()=>e.loader().then(a)),c=e.loading;function h(t){let a=c?(0,n.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,l=!e.ssr||!!e.loading,h=l?r.Suspense:r.Fragment,u=e.ssr?(0,n.jsxs)(n.Fragment,{children:["undefined"==typeof window?(0,n.jsx)(o.PreloadChunks,{moduleIds:e.modules}):null,(0,n.jsx)(i,{...t})]}):(0,n.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,n.jsx)(i,{...t})});return(0,n.jsx)(h,{...l?{fallback:a}:{},children:u})}return h.displayName="LoadableComponent",h}},70703,(t,e,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"default",{enumerable:!0,get:function(){return r}});let n=t.r(55682)._(t.r(69093));function r(t,e){var i;let r={};"function"==typeof t&&(r.loader=t);let s={...r,...e};return(0,n.default)({...s,modules:null==(i=s.loadableGenerated)?void 0:i.modules})}("function"==typeof i.default||"object"==typeof i.default&&null!==i.default)&&void 0===i.default.__esModule&&(Object.defineProperty(i.default,"__esModule",{value:!0}),Object.assign(i.default,i),e.exports=i.default)},52683,t=>{"use strict";let e;t.s(["default",()=>so],52683);var i,n,r,s,o,a,l,c,h,u,f,d,g,p,m,y,b,x,_,C,S,w,T,O,k,E,j,M,P,A,D,F,R,L,I=t.i(43476),B=t.i(71645),N=t.i(88174);let U=B.default.createContext(null);U.displayName="CanvasContext";let W=function(t){var e;let i=(0,B.useContext)(U);if(!i)throw Error("No CanvasContext.Provider");return void 0===t?i:null==t?{}:null!=(e=i.canvases[t])?e:{}},H=B.default.createContext(null);function X(){let t=(0,B.useContext)(H);if(!t)throw Error("No ToolsContext.Provider");return t}H.displayName="ToolsContext";let z=Math.min,Y=Math.max,G=Math.round,V=Math.floor,q=t=>({x:t,y:t}),K={left:"right",right:"left",bottom:"top",top:"bottom"},Q={start:"end",end:"start"};function J(t,e){return"function"==typeof t?t(e):t}function $(t){return t.split("-")[0]}function Z(t){return t.split("-")[1]}function tt(t){return"y"===t?"height":"width"}let te=new Set(["top","bottom"]);function ti(t){return te.has($(t))?"y":"x"}function tn(t){return"x"===ti(t)?"y":"x"}function tr(t){return t.replace(/start|end/g,t=>Q[t])}let ts=["left","right"],to=["right","left"],ta=["top","bottom"],tl=["bottom","top"];function tc(t){return t.replace(/left|right|bottom|top/g,t=>K[t])}function th(t){let{x:e,y:i,width:n,height:r}=t;return{width:n,height:r,top:i,left:e,right:e+n,bottom:i+r,x:e,y:i}}function tu(t,e,i){let n,{reference:r,floating:s}=t,o=ti(e),a=tn(e),l=tt(a),c=$(e),h="y"===o,u=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,d=r[l]/2-s[l]/2;switch(c){case"top":n={x:u,y:r.y-s.height};break;case"bottom":n={x:u,y:r.y+r.height};break;case"right":n={x:r.x+r.width,y:f};break;case"left":n={x:r.x-s.width,y:f};break;default:n={x:r.x,y:r.y}}switch(Z(e)){case"start":n[a]-=d*(i&&h?-1:1);break;case"end":n[a]+=d*(i&&h?-1:1)}return n}let tf=async(t,e,i)=>{let{placement:n="bottom",strategy:r="absolute",middleware:s=[],platform:o}=i,a=s.filter(Boolean),l=await (null==o.isRTL?void 0:o.isRTL(e)),c=await o.getElementRects({reference:t,floating:e,strategy:r}),{x:h,y:u}=tu(c,n,l),f=n,d={},g=0;for(let i=0;i<a.length;i++){let{name:s,fn:p}=a[i],{x:m,y:y,data:b,reset:x}=await p({x:h,y:u,initialPlacement:n,placement:f,strategy:r,middlewareData:d,rects:c,platform:o,elements:{reference:t,floating:e}});h=null!=m?m:h,u=null!=y?y:u,d={...d,[s]:{...d[s],...b}},x&&g<=50&&(g++,"object"==typeof x&&(x.placement&&(f=x.placement),x.rects&&(c=!0===x.rects?await o.getElementRects({reference:t,floating:e,strategy:r}):x.rects),{x:h,y:u}=tu(c,f,l)),i=-1)}return{x:h,y:u,placement:f,strategy:r,middlewareData:d}};async function td(t,e){var i,n;void 0===e&&(e={});let{x:r,y:s,platform:o,rects:a,elements:l,strategy:c}=t,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:g=0}=J(e,t),p="number"!=typeof(n=g)?{top:0,right:0,bottom:0,left:0,...n}:{top:n,right:n,bottom:n,left:n},m=l[d?"floating"===f?"reference":"floating":f],y=th(await o.getClippingRect({element:null==(i=await (null==o.isElement?void 0:o.isElement(m)))||i?m:m.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(l.floating)),boundary:h,rootBoundary:u,strategy:c})),b="floating"===f?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,x=await (null==o.getOffsetParent?void 0:o.getOffsetParent(l.floating)),_=await (null==o.isElement?void 0:o.isElement(x))&&await (null==o.getScale?void 0:o.getScale(x))||{x:1,y:1},C=th(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:x,strategy:c}):b);return{top:(y.top-C.top+p.top)/_.y,bottom:(C.bottom-y.bottom+p.bottom)/_.y,left:(y.left-C.left+p.left)/_.x,right:(C.right-y.right+p.right)/_.x}}let tg=new Set(["left","top"]);async function tp(t,e){let{placement:i,platform:n,elements:r}=t,s=await (null==n.isRTL?void 0:n.isRTL(r.floating)),o=$(i),a=Z(i),l="y"===ti(i),c=tg.has(o)?-1:1,h=s&&l?-1:1,u=J(e,t),{mainAxis:f,crossAxis:d,alignmentAxis:g}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&"number"==typeof g&&(d="end"===a?-1*g:g),l?{x:d*h,y:f*c}:{x:f*c,y:d*h}}function tv(){return"undefined"!=typeof window}function tm(t){return tx(t)?(t.nodeName||"").toLowerCase():"#document"}function ty(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function tb(t){var e;return null==(e=(tx(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function tx(t){return!!tv()&&(t instanceof Node||t instanceof ty(t).Node)}function t_(t){return!!tv()&&(t instanceof Element||t instanceof ty(t).Element)}function tC(t){return!!tv()&&(t instanceof HTMLElement||t instanceof ty(t).HTMLElement)}function tS(t){return!!tv()&&"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof ty(t).ShadowRoot)}let tw=new Set(["inline","contents"]);function tT(t){let{overflow:e,overflowX:i,overflowY:n,display:r}=tL(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+i)&&!tw.has(r)}let tO=new Set(["table","td","th"]),tk=[":popover-open",":modal"];function tE(t){return tk.some(e=>{try{return t.matches(e)}catch(t){return!1}})}let tj=["transform","translate","scale","rotate","perspective"],tM=["transform","translate","scale","rotate","perspective","filter"],tP=["paint","layout","strict","content"];function tA(t){let e=tD(),i=t_(t)?tL(t):t;return tj.some(t=>!!i[t]&&"none"!==i[t])||!!i.containerType&&"normal"!==i.containerType||!e&&!!i.backdropFilter&&"none"!==i.backdropFilter||!e&&!!i.filter&&"none"!==i.filter||tM.some(t=>(i.willChange||"").includes(t))||tP.some(t=>(i.contain||"").includes(t))}function tD(){return"undefined"!=typeof CSS&&!!CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")}let tF=new Set(["html","body","#document"]);function tR(t){return tF.has(tm(t))}function tL(t){return ty(t).getComputedStyle(t)}function tI(t){return t_(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function tB(t){if("html"===tm(t))return t;let e=t.assignedSlot||t.parentNode||tS(t)&&t.host||tb(t);return tS(e)?e.host:e}function tN(t,e,i){var n;void 0===e&&(e=[]),void 0===i&&(i=!0);let r=function t(e){let i=tB(e);return tR(i)?e.ownerDocument?e.ownerDocument.body:e.body:tC(i)&&tT(i)?i:t(i)}(t),s=r===(null==(n=t.ownerDocument)?void 0:n.body),o=ty(r);if(s){let t=tU(o);return e.concat(o,o.visualViewport||[],tT(r)?r:[],t&&i?tN(t):[])}return e.concat(r,tN(r,[],i))}function tU(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function tW(t){let e=tL(t),i=parseFloat(e.width)||0,n=parseFloat(e.height)||0,r=tC(t),s=r?t.offsetWidth:i,o=r?t.offsetHeight:n,a=G(i)!==s||G(n)!==o;return a&&(i=s,n=o),{width:i,height:n,$:a}}function tH(t){return t_(t)?t:t.contextElement}function tX(t){let e=tH(t);if(!tC(e))return q(1);let i=e.getBoundingClientRect(),{width:n,height:r,$:s}=tW(e),o=(s?G(i.width):i.width)/n,a=(s?G(i.height):i.height)/r;return o&&Number.isFinite(o)||(o=1),a&&Number.isFinite(a)||(a=1),{x:o,y:a}}let tz=q(0);function tY(t){let e=ty(t);return tD()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:tz}function tG(t,e,i,n){var r;void 0===e&&(e=!1),void 0===i&&(i=!1);let s=t.getBoundingClientRect(),o=tH(t),a=q(1);e&&(n?t_(n)&&(a=tX(n)):a=tX(t));let l=(void 0===(r=i)&&(r=!1),n&&(!r||n===ty(o))&&r)?tY(o):q(0),c=(s.left+l.x)/a.x,h=(s.top+l.y)/a.y,u=s.width/a.x,f=s.height/a.y;if(o){let t=ty(o),e=n&&t_(n)?ty(n):n,i=t,r=tU(i);for(;r&&n&&e!==i;){let t=tX(r),e=r.getBoundingClientRect(),n=tL(r),s=e.left+(r.clientLeft+parseFloat(n.paddingLeft))*t.x,o=e.top+(r.clientTop+parseFloat(n.paddingTop))*t.y;c*=t.x,h*=t.y,u*=t.x,f*=t.y,c+=s,h+=o,r=tU(i=ty(r))}}return th({width:u,height:f,x:c,y:h})}function tV(t,e){let i=tI(t).scrollLeft;return e?e.left+i:tG(tb(t)).left+i}function tq(t,e){let i=t.getBoundingClientRect();return{x:i.left+e.scrollLeft-tV(t,i),y:i.top+e.scrollTop}}let tK=new Set(["absolute","fixed"]);function tQ(t,e,i){let n;if("viewport"===e)n=function(t,e){let i=ty(t),n=tb(t),r=i.visualViewport,s=n.clientWidth,o=n.clientHeight,a=0,l=0;if(r){s=r.width,o=r.height;let t=tD();(!t||t&&"fixed"===e)&&(a=r.offsetLeft,l=r.offsetTop)}let c=tV(n);if(c<=0){let t=n.ownerDocument,e=t.body,i=getComputedStyle(e),r="CSS1Compat"===t.compatMode&&parseFloat(i.marginLeft)+parseFloat(i.marginRight)||0,o=Math.abs(n.clientWidth-e.clientWidth-r);o<=25&&(s-=o)}else c<=25&&(s+=c);return{width:s,height:o,x:a,y:l}}(t,i);else if("document"===e)n=function(t){let e=tb(t),i=tI(t),n=t.ownerDocument.body,r=Y(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),s=Y(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),o=-i.scrollLeft+tV(t),a=-i.scrollTop;return"rtl"===tL(n).direction&&(o+=Y(e.clientWidth,n.clientWidth)-r),{width:r,height:s,x:o,y:a}}(tb(t));else if(t_(e))n=function(t,e){let i=tG(t,!0,"fixed"===e),n=i.top+t.clientTop,r=i.left+t.clientLeft,s=tC(t)?tX(t):q(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y;return{width:o,height:a,x:r*s.x,y:n*s.y}}(e,i);else{let i=tY(t);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return th(n)}function tJ(t){return"static"===tL(t).position}function t$(t,e){if(!tC(t)||"fixed"===tL(t).position)return null;if(e)return e(t);let i=t.offsetParent;return tb(t)===i&&(i=i.ownerDocument.body),i}function tZ(t,e){var i;let n=ty(t);if(tE(t))return n;if(!tC(t)){let e=tB(t);for(;e&&!tR(e);){if(t_(e)&&!tJ(e))return e;e=tB(e)}return n}let r=t$(t,e);for(;r&&(i=r,tO.has(tm(i)))&&tJ(r);)r=t$(r,e);return r&&tR(r)&&tJ(r)&&!tA(r)?n:r||function(t){let e=tB(t);for(;tC(e)&&!tR(e);){if(tA(e))return e;if(tE(e))break;e=tB(e)}return null}(t)||n}let t0=async function(t){let e=this.getOffsetParent||tZ,i=this.getDimensions,n=await i(t.floating);return{reference:function(t,e,i){let n=tC(e),r=tb(e),s="fixed"===i,o=tG(t,!0,s,e),a={scrollLeft:0,scrollTop:0},l=q(0);if(n||!n&&!s)if(("body"!==tm(e)||tT(r))&&(a=tI(e)),n){let t=tG(e,!0,s,e);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}else r&&(l.x=tV(r));s&&!n&&r&&(l.x=tV(r));let c=!r||n||s?q(0):tq(r,a);return{x:o.left+a.scrollLeft-l.x-c.x,y:o.top+a.scrollTop-l.y-c.y,width:o.width,height:o.height}}(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}},t1={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:i,offsetParent:n,strategy:r}=t,s="fixed"===r,o=tb(n),a=!!e&&tE(e.floating);if(n===o||a&&s)return i;let l={scrollLeft:0,scrollTop:0},c=q(1),h=q(0),u=tC(n);if((u||!u&&!s)&&(("body"!==tm(n)||tT(o))&&(l=tI(n)),tC(n))){let t=tG(n);c=tX(n),h.x=t.x+n.clientLeft,h.y=t.y+n.clientTop}let f=!o||u||s?q(0):tq(o,l);return{width:i.width*c.x,height:i.height*c.y,x:i.x*c.x-l.scrollLeft*c.x+h.x+f.x,y:i.y*c.y-l.scrollTop*c.y+h.y+f.y}},getDocumentElement:tb,getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:n,strategy:r}=t,s=[..."clippingAncestors"===i?tE(e)?[]:function(t,e){let i=e.get(t);if(i)return i;let n=tN(t,[],!1).filter(t=>t_(t)&&"body"!==tm(t)),r=null,s="fixed"===tL(t).position,o=s?tB(t):t;for(;t_(o)&&!tR(o);){let e=tL(o),i=tA(o);i||"fixed"!==e.position||(r=null),(s?!i&&!r:!i&&"static"===e.position&&!!r&&tK.has(r.position)||tT(o)&&!i&&function t(e,i){let n=tB(e);return!(n===i||!t_(n)||tR(n))&&("fixed"===tL(n).position||t(n,i))}(t,o))?n=n.filter(t=>t!==o):r=e,o=tB(o)}return e.set(t,n),n}(e,this._c):[].concat(i),n],o=s[0],a=s.reduce((t,i)=>{let n=tQ(e,i,r);return t.top=Y(n.top,t.top),t.right=z(n.right,t.right),t.bottom=z(n.bottom,t.bottom),t.left=Y(n.left,t.left),t},tQ(e,o,r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:tZ,getElementRects:t0,getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){let{width:e,height:i}=tW(t);return{width:e,height:i}},getScale:tX,isElement:t_,isRTL:function(t){return"rtl"===tL(t).direction}};function t2(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function t5(t,e,i,n){let r;void 0===n&&(n={});let{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:c=!1}=n,h=tH(t),u=s||o?[...h?tN(h):[],...tN(e)]:[];u.forEach(t=>{s&&t.addEventListener("scroll",i,{passive:!0}),o&&t.addEventListener("resize",i)});let f=h&&l?function(t,e){let i,n=null,r=tb(t);function s(){var t;clearTimeout(i),null==(t=n)||t.disconnect(),n=null}return!function o(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),s();let c=t.getBoundingClientRect(),{left:h,top:u,width:f,height:d}=c;if(a||e(),!f||!d)return;let g=V(u),p=V(r.clientWidth-(h+f)),m={rootMargin:-g+"px "+-p+"px "+-V(r.clientHeight-(u+d))+"px "+-V(h)+"px",threshold:Y(0,z(1,l))||1},y=!0;function b(e){let n=e[0].intersectionRatio;if(n!==l){if(!y)return o();n?o(!1,n):i=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==n||t2(c,t.getBoundingClientRect())||o(),y=!1}try{n=new IntersectionObserver(b,{...m,root:r.ownerDocument})}catch(t){n=new IntersectionObserver(b,m)}n.observe(t)}(!0),s}(h,i):null,d=-1,g=null;a&&(g=new ResizeObserver(t=>{let[n]=t;n&&n.target===h&&g&&(g.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var t;null==(t=g)||t.observe(e)})),i()}),h&&!c&&g.observe(h),g.observe(e));let p=c?tG(t):null;return c&&function e(){let n=tG(t);p&&!t2(p,n)&&i(),p=n,r=requestAnimationFrame(e)}(),i(),()=>{var t;u.forEach(t=>{s&&t.removeEventListener("scroll",i),o&&t.removeEventListener("resize",i)}),null==f||f(),null==(t=g)||t.disconnect(),g=null,c&&cancelAnimationFrame(r)}}var t4=t.i(74080),t3="undefined"!=typeof document?B.useLayoutEffect:function(){};function t9(t,e){let i,n,r;if(t===e)return!0;if(typeof t!=typeof e)return!1;if("function"==typeof t&&t.toString()===e.toString())return!0;if(t&&e&&"object"==typeof t){if(Array.isArray(t)){if((i=t.length)!==e.length)return!1;for(n=i;0!=n--;)if(!t9(t[n],e[n]))return!1;return!0}if((i=(r=Object.keys(t)).length)!==Object.keys(e).length)return!1;for(n=i;0!=n--;)if(!({}).hasOwnProperty.call(e,r[n]))return!1;for(n=i;0!=n--;){let i=r[n];if(("_owner"!==i||!t.$$typeof)&&!t9(t[i],e[i]))return!1}return!0}return t!=t&&e!=e}function t6(t){return"undefined"==typeof window?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function t8(t,e){let i=t6(t);return Math.round(e*i)/i}function t7(t){let e=B.useRef(t);return t3(()=>{e.current=t}),e}let et=(t,e)=>({...function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var i,n;let{x:r,y:s,placement:o,middlewareData:a}=e,l=await tp(e,t);return o===(null==(i=a.offset)?void 0:i.placement)&&null!=(n=a.arrow)&&n.alignmentOffset?{}:{x:r+l.x,y:s+l.y,data:{...l,placement:o}}}}}(t),options:[t,e]}),ee=(t,e)=>({...function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var i,n,r,s,o;let{placement:a,middlewareData:l,rects:c,initialPlacement:h,platform:u,elements:f}=e,{mainAxis:d=!0,crossAxis:g=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:b=!0,...x}=J(t,e);if(null!=(i=l.arrow)&&i.alignmentOffset)return{};let _=$(a),C=ti(h),S=$(h)===h,w=await (null==u.isRTL?void 0:u.isRTL(f.floating)),T=p||(S||!b?[tc(h)]:function(t){let e=tc(t);return[tr(t),e,tr(e)]}(h)),O="none"!==y;!p&&O&&T.push(...function(t,e,i,n){let r=Z(t),s=function(t,e,i){switch(t){case"top":case"bottom":if(i)return e?to:ts;return e?ts:to;case"left":case"right":return e?ta:tl;default:return[]}}($(t),"start"===i,n);return r&&(s=s.map(t=>t+"-"+r),e&&(s=s.concat(s.map(tr)))),s}(h,b,y,w));let k=[h,...T],E=await td(e,x),j=[],M=(null==(n=l.flip)?void 0:n.overflows)||[];if(d&&j.push(E[_]),g){let t=function(t,e,i){void 0===i&&(i=!1);let n=Z(t),r=tn(t),s=tt(r),o="x"===r?n===(i?"end":"start")?"right":"left":"start"===n?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=tc(o)),[o,tc(o)]}(a,c,w);j.push(E[t[0]],E[t[1]])}if(M=[...M,{placement:a,overflows:j}],!j.every(t=>t<=0)){let t=((null==(r=l.flip)?void 0:r.index)||0)+1,e=k[t];if(e&&("alignment"!==g||C===ti(e)||M.every(t=>ti(t.placement)!==C||t.overflows[0]>0)))return{data:{index:t,overflows:M},reset:{placement:e}};let i=null==(s=M.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:s.placement;if(!i)switch(m){case"bestFit":{let t=null==(o=M.filter(t=>{if(O){let e=ti(t.placement);return e===C||"y"===e}return!0}).map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:o[0];t&&(i=t);break}case"initialPlacement":i=h}if(a!==i)return{reset:{placement:i}}}return{}}}}(t),options:[t,e]});t.i(47167);var ei='input:not([inert]),select:not([inert]),textarea:not([inert]),a[href]:not([inert]),button:not([inert]),[tabindex]:not(slot):not([inert]),audio[controls]:not([inert]),video[controls]:not([inert]),[contenteditable]:not([contenteditable="false"]):not([inert]),details>summary:first-of-type:not([inert]),details:not([inert])',en="undefined"==typeof Element,er=en?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,es=!en&&Element.prototype.getRootNode?function(t){var e;return null==t||null==(e=t.getRootNode)?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},eo=function t(e,i){void 0===i&&(i=!0);var n,r=null==e||null==(n=e.getAttribute)?void 0:n.call(e,"inert");return""===r||"true"===r||i&&e&&t(e.parentNode)},ea=function(t){var e,i=null==t||null==(e=t.getAttribute)?void 0:e.call(t,"contenteditable");return""===i||"true"===i},el=function(t,e,i){if(eo(t))return[];var n=Array.prototype.slice.apply(t.querySelectorAll(ei));return e&&er.call(t,ei)&&n.unshift(t),n=n.filter(i)},ec=function t(e,i,n){for(var r=[],s=Array.from(e);s.length;){var o=s.shift();if(!eo(o,!1))if("SLOT"===o.tagName){var a=o.assignedElements(),l=t(a.length?a:o.children,!0,n);n.flatten?r.push.apply(r,l):r.push({scopeParent:o,candidates:l})}else{er.call(o,ei)&&n.filter(o)&&(i||!e.includes(o))&&r.push(o);var c=o.shadowRoot||"function"==typeof n.getShadowRoot&&n.getShadowRoot(o),h=!eo(c,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(o));if(c&&h){var u=t(!0===c?o.children:c.children,!0,n);n.flatten?r.push.apply(r,u):r.push({scopeParent:o,candidates:u})}else s.unshift.apply(s,o.children)}}return r},eh=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},eu=function(t){if(!t)throw Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||ea(t))&&!eh(t)?0:t.tabIndex},ef=function(t,e){var i=eu(t);return i<0&&e&&!eh(t)?0:i},ed=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},eg=function(t){return"INPUT"===t.tagName},ep=function(t,e){for(var i=0;i<t.length;i++)if(t[i].checked&&t[i].form===e)return t[i]},ev=function(t){if(!t.name)return!0;var e,i=t.form||es(t),n=function(t){return i.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=n(window.CSS.escape(t.name));else try{e=n(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var r=ep(e,t.form);return!r||r===t},em=function(t){return eg(t)&&"radio"===t.type&&!ev(t)},ey=function(t){var e,i,n,r,s,o,a,l=t&&es(t),c=null==(e=l)?void 0:e.host,h=!1;if(l&&l!==t)for(h=!!(null!=(i=c)&&null!=(n=i.ownerDocument)&&n.contains(c)||null!=t&&null!=(r=t.ownerDocument)&&r.contains(t));!h&&c;)h=!!(null!=(o=c=null==(s=l=es(c))?void 0:s.host)&&null!=(a=o.ownerDocument)&&a.contains(c));return h},eb=function(t){var e=t.getBoundingClientRect(),i=e.width,n=e.height;return 0===i&&0===n},ex=function(t,e){var i=e.displayCheck,n=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var r=er.call(t,"details>summary:first-of-type")?t.parentElement:t;if(er.call(r,"details:not([open]) *"))return!0;if(i&&"full"!==i&&"legacy-full"!==i){if("non-zero-area"===i)return eb(t)}else{if("function"==typeof n){for(var s=t;t;){var o=t.parentElement,a=es(t);if(o&&!o.shadowRoot&&!0===n(o))return eb(t);t=t.assignedSlot?t.assignedSlot:o||a===t.ownerDocument?o:a.host}t=s}if(ey(t))return!t.getClientRects().length;if("legacy-full"!==i)return!0}return!1},e_=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var i=0;i<e.children.length;i++){var n=e.children.item(i);if("LEGEND"===n.tagName)return!!er.call(e,"fieldset[disabled] *")||!n.contains(t)}return!0}e=e.parentElement}return!1},eC=function(t,e){return!(e.disabled||eo(e)||eg(e)&&"hidden"===e.type||ex(e,t)||"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(t){return"SUMMARY"===t.tagName})||e_(e))},eS=function(t,e){return!(em(e)||0>eu(e))&&!!eC(t,e)},ew=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!isNaN(e)||!!(e>=0)},eT=function t(e){var i=[],n=[];return e.forEach(function(e,r){var s=!!e.scopeParent,o=s?e.scopeParent:e,a=ef(o,s),l=s?t(e.candidates):o;0===a?s?i.push.apply(i,l):i.push(o):n.push({documentOrder:r,tabIndex:a,item:e,isScope:s,content:l})}),n.sort(ed).reduce(function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t},[]).concat(i)},eO=function(t,e){return eT((e=e||{}).getShadowRoot?ec([t],e.includeContainer,{filter:eS.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:ew}):el(t,e.includeContainer,eS.bind(null,e)))},ek=function(t,e){return(e=e||{}).getShadowRoot?ec([t],e.includeContainer,{filter:eC.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):el(t,e.includeContainer,eC.bind(null,e))},eE=function(t,e){if(e=e||{},!t)throw Error("No node provided");return!1!==er.call(t,ei)&&eS(e,t)};function ej(){let t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(t=>{let{brand:e,version:i}=t;return e+"/"+i}).join(" "):navigator.userAgent}function eM(){let t=/android/i;return t.test(function(){let t=navigator.userAgentData;return null!=t&&t.platform?t.platform:navigator.platform}())||t.test(ej())}let eP="data-floating-ui-focusable";function eA(t){let e=t.activeElement;for(;(null==(i=e)||null==(i=i.shadowRoot)?void 0:i.activeElement)!=null;){var i;e=e.shadowRoot.activeElement}return e}function eD(t,e){if(!t||!e)return!1;let i=null==e.getRootNode?void 0:e.getRootNode();if(t.contains(e))return!0;if(i&&tS(i)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function eF(t){return"composedPath"in t?t.composedPath()[0]:t.target}function eR(t,e){return null!=e&&("composedPath"in t?t.composedPath().includes(e):null!=t.target&&e.contains(t.target))}function eL(t){return(null==t?void 0:t.ownerDocument)||document}function eI(t){return tC(t)&&t.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function eB(t){return!!t&&"combobox"===t.getAttribute("role")&&eI(t)}function eN(t){return t?t.hasAttribute(eP)?t:t.querySelector("["+eP+"]")||t:null}function eU(t,e,i){return void 0===i&&(i=!0),t.filter(t=>{var n;return t.parentId===e&&(!i||(null==(n=t.context)?void 0:n.open))}).flatMap(e=>[e,...eU(t,e.id,i)])}function eW(t,e){var i;let n=[],r=null==(i=t.find(t=>t.id===e))?void 0:i.parentId;for(;r;){let e=t.find(t=>t.id===r);r=null==e?void 0:e.parentId,e&&(n=n.concat(e))}return n}function eH(t){t.preventDefault(),t.stopPropagation()}function eX(t,e){let i=["mouse","pen"];return e||i.push("",void 0),i.includes(t)}var ez="undefined"!=typeof document?B.useLayoutEffect:function(){};function eY(t){let e=B.useRef(t);return ez(()=>{e.current=t}),e}let eG={...B}.useInsertionEffect||(t=>t());function eV(t){let e=B.useRef(()=>{});return eG(()=>{e.current=t}),B.useCallback(function(){for(var t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];return null==e.current?void 0:e.current(...i)},[])}let eq=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function eK(t,e){let i=eO(t,eq()),n=i.length;if(0===n)return;let r=eA(eL(t)),s=i.indexOf(r);return i[-1===s?1===e?0:n-1:s+e]}function eQ(t,e){let i=e||t.currentTarget,n=t.relatedTarget;return!n||!eD(i,n)}let eJ="active",e$="selected",eZ={...B},e0=!1,e1=0,e2=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+e1++,e5=eZ.useId||function(){let[t,e]=B.useState(()=>e0?e2():void 0);return ez(()=>{null==t&&e(e2())},[]),B.useEffect(()=>{e0=!0},[]),t},e4=B.createContext(null),e3=B.createContext(null),e9=()=>{var t;return(null==(t=B.useContext(e4))?void 0:t.id)||null},e6=()=>B.useContext(e3);function e8(t){return"data-floating-ui-"+t}let e7=0;function it(t,e){void 0===e&&(e={});let{preventScroll:i=!1,cancelPrevious:n=!0,sync:r=!1}=e;n&&cancelAnimationFrame(e7);let s=()=>null==t?void 0:t.focus({preventScroll:i});r?s():e7=requestAnimationFrame(s)}let ie={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function ii(t){return"inert"===t?ie.inert:"aria-hidden"===t?ie["aria-hidden"]:ie.none}let ir=new WeakSet,is={},io=0,ia=t=>t&&(t.host||ia(t.parentNode));function il(t,e,i){var n;void 0===e&&(e=!1),void 0===i&&(i=!1);let r=((null==(n=t[0])?void 0:n.ownerDocument)||document).body;return function(t,e,i,n){let r="data-floating-ui-inert",s=n?"inert":i?"aria-hidden":null,o=t.map(t=>{if(e.contains(t))return t;let i=ia(t);return e.contains(i)?i:null}).filter(t=>null!=t),a=new Set,l=new Set(o),c=[];is[r]||(is[r]=new WeakMap);let h=is[r];return o.forEach(function t(e){!(!e||a.has(e))&&(a.add(e),e.parentNode&&t(e.parentNode))}),function t(e){!e||l.has(e)||[].forEach.call(e.children,e=>{if("script"!==tm(e))if(a.has(e))t(e);else{let t=s?e.getAttribute(s):null,i=null!==t&&"false"!==t,n=ii(s),o=(n.get(e)||0)+1,a=(h.get(e)||0)+1;n.set(e,o),h.set(e,a),c.push(e),1===o&&i&&ir.add(e),1===a&&e.setAttribute(r,""),!i&&s&&e.setAttribute(s,"inert"===s?"":"true")}})}(e),a.clear(),io++,()=>{c.forEach(t=>{let e=ii(s),i=(e.get(t)||0)-1,n=(h.get(t)||0)-1;e.set(t,i),h.set(t,n),i||(!ir.has(t)&&s&&t.removeAttribute(s),ir.delete(t)),n||t.removeAttribute(r)}),--io||(ie.inert=new WeakMap,ie["aria-hidden"]=new WeakMap,ie.none=new WeakMap,ir=new WeakSet,is={})}}(t.concat(Array.from(r.querySelectorAll('[aria-live],[role="status"],output'))),r,e,i)}let ic={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},ih=B.forwardRef(function(t,e){let[i,n]=B.useState();ez(()=>{/apple/i.test(navigator.vendor)&&n("button")},[]);let r={ref:e,tabIndex:0,role:i,"aria-hidden":!i||void 0,[e8("focus-guard")]:"",style:ic};return(0,I.jsx)("span",{...t,...r})}),iu=B.createContext(null);function id(t){return B.useMemo(()=>e=>{t.forEach(t=>{t&&(t.current=e)})},t)}let ig=[];function ip(){ig=ig.filter(t=>t.isConnected)}function iv(){return ip(),ig[ig.length-1]}function im(t,e){var i;if(!e.current.includes("floating")&&!(null!=(i=t.getAttribute("role"))&&i.includes("dialog")))return;let n=eq(),r=ek(t,n).filter(t=>{let e=t.getAttribute("data-tabindex")||"";return eE(t,n)||t.hasAttribute("data-tabindex")&&!e.startsWith("-")}),s=t.getAttribute("tabindex");e.current.includes("floating")||0===r.length?"0"!==s&&t.setAttribute("tabindex","0"):("-1"!==s||t.hasAttribute("data-tabindex")&&"-1"!==t.getAttribute("data-tabindex"))&&(t.setAttribute("tabindex","-1"),t.setAttribute("data-tabindex","-1"))}let iy=B.forwardRef(function(t,e){return(0,I.jsx)("button",{...t,type:"button",ref:e,tabIndex:-1,style:ic})});function ib(t){let{context:e,children:i,disabled:n=!1,order:r=["content"],guards:s=!0,initialFocus:o=0,returnFocus:a=!0,restoreFocus:l=!1,modal:c=!0,visuallyHiddenDismiss:h=!1,closeOnFocusOut:u=!0,outsideElementsInert:f=!1,getInsideElements:d=()=>[]}=t,{open:g,onOpenChange:p,events:m,dataRef:y,elements:{domReference:b,floating:x}}=e,_=eV(()=>{var t;return null==(t=y.current.floatingContext)?void 0:t.nodeId}),C=eV(d),S="number"==typeof o&&o<0,w=eB(b)&&S,T="undefined"!=typeof HTMLElement&&"inert"in HTMLElement.prototype,O=!T||s,k=!O||T&&f,E=eY(r),j=eY(o),M=eY(a),P=e6(),A=B.useContext(iu),D=B.useRef(null),F=B.useRef(null),R=B.useRef(!1),L=B.useRef(!1),N=B.useRef(-1),U=B.useRef(-1),W=null!=A,H=eN(x),X=eV(function(t){return void 0===t&&(t=H),t?eO(t,eq()):[]}),z=eV(t=>{let e=X(t);return E.current.map(t=>b&&"reference"===t?b:H&&"floating"===t?H:e).filter(Boolean).flat()});B.useEffect(()=>{if(n||!c)return;function t(t){if("Tab"===t.key){eD(H,eA(eL(H)))&&0===X().length&&!w&&eH(t);let e=z(),i=eF(t);"reference"===E.current[0]&&i===b&&(eH(t),t.shiftKey?it(e[e.length-1]):it(e[1])),"floating"===E.current[1]&&i===H&&t.shiftKey&&(eH(t),it(e[0]))}}let e=eL(H);return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}},[n,b,H,c,E,w,X,z]),B.useEffect(()=>{if(!n&&x)return x.addEventListener("focusin",t),()=>{x.removeEventListener("focusin",t)};function t(t){let e=eF(t),i=X().indexOf(e);-1!==i&&(N.current=i)}},[n,x,X]),B.useEffect(()=>{if(n||!u)return;function t(){L.current=!0,setTimeout(()=>{L.current=!1})}function e(t){let e=t.relatedTarget,i=t.currentTarget,n=eF(t);queueMicrotask(()=>{let r=_(),s=!(eD(b,e)||eD(x,e)||eD(e,x)||eD(null==A?void 0:A.portalNode,e)||null!=e&&e.hasAttribute(e8("focus-guard"))||P&&(eU(P.nodesRef.current,r).find(t=>{var i,n;return eD(null==(i=t.context)?void 0:i.elements.floating,e)||eD(null==(n=t.context)?void 0:n.elements.domReference,e)})||eW(P.nodesRef.current,r).find(t=>{var i,n,r;return[null==(i=t.context)?void 0:i.elements.floating,eN(null==(n=t.context)?void 0:n.elements.floating)].includes(e)||(null==(r=t.context)?void 0:r.elements.domReference)===e})));if(i===b&&H&&im(H,E),l&&i!==b&&!(null!=n&&n.isConnected)&&eA(eL(H))===eL(H).body){tC(H)&&H.focus();let t=N.current,e=X(),i=e[t]||e[e.length-1]||H;tC(i)&&i.focus()}if(y.current.insideReactTree){y.current.insideReactTree=!1;return}(w||!c)&&e&&s&&!L.current&&e!==iv()&&(R.current=!0,p(!1,t,"focus-out"))})}let i=!!(!P&&A);function r(){-1!==U.current&&(clearTimeout(U.current),U.current=-1),y.current.insideReactTree=!0,U.current=window.setTimeout(()=>{y.current.insideReactTree=!1})}if(x&&tC(b))return b.addEventListener("focusout",e),b.addEventListener("pointerdown",t),x.addEventListener("focusout",e),i&&x.addEventListener("focusout",r,!0),()=>{b.removeEventListener("focusout",e),b.removeEventListener("pointerdown",t),x.removeEventListener("focusout",e),i&&x.removeEventListener("focusout",r,!0)}},[n,b,x,H,c,P,A,p,u,l,X,w,_,E,y]);let Y=B.useRef(null),G=B.useRef(null),V=id([Y,null==A?void 0:A.beforeInsideRef]),q=id([G,null==A?void 0:A.afterInsideRef]);function K(t){return!n&&h&&c?(0,I.jsx)(iy,{ref:"start"===t?D:F,onClick:t=>p(!1,t.nativeEvent),children:"string"==typeof h?h:"Dismiss"}):null}B.useEffect(()=>{var t,e;if(n||!x)return;let i=Array.from((null==A||null==(t=A.portalNode)?void 0:t.querySelectorAll("["+e8("portal")+"]"))||[]),r=[x,null==(e=(P?eW(P.nodesRef.current,_()):[]).find(t=>{var e;return eB((null==(e=t.context)?void 0:e.elements.domReference)||null)}))||null==(e=e.context)?void 0:e.elements.domReference,...i,...C(),D.current,F.current,Y.current,G.current,null==A?void 0:A.beforeOutsideRef.current,null==A?void 0:A.afterOutsideRef.current,E.current.includes("reference")||w?b:null].filter(t=>null!=t),s=c||w?il(r,!k,k):il(r);return()=>{s()}},[n,b,x,c,E,A,w,O,k,P,_,C]),ez(()=>{if(n||!tC(H))return;let t=eA(eL(H));queueMicrotask(()=>{let e=z(H),i=j.current,n=("number"==typeof i?e[i]:i.current)||H,r=eD(H,t);S||r||!g||it(n,{preventScroll:n===H})})},[n,g,H,S,z,j]),ez(()=>{var t;if(n||!H)return;let e=eL(H);function i(t){let{reason:e,event:i,nested:n}=t;if(["hover","safe-polygon"].includes(e)&&"mouseleave"===i.type&&(R.current=!0),"outside-press"===e)if(n)R.current=!1;else if(0===i.mozInputSource&&i.isTrusted||(eM()&&i.pointerType?"click"===i.type&&1===i.buttons:0===i.detail&&!i.pointerType)||!ej().includes("jsdom/")&&(!eM()&&0===i.width&&0===i.height||eM()&&1===i.width&&1===i.height&&0===i.pressure&&0===i.detail&&"mouse"===i.pointerType||i.width<1&&i.height<1&&0===i.pressure&&0===i.detail&&"touch"===i.pointerType))R.current=!1;else{let t=!1;document.createElement("div").focus({get preventScroll(){return t=!0,!1}}),t?R.current=!1:R.current=!0}}t=eA(e),ip(),t&&"body"!==tm(t)&&(ig.push(t),ig.length>20&&(ig=ig.slice(-20))),m.on("openchange",i);let r=e.createElement("span");return r.setAttribute("tabindex","-1"),r.setAttribute("aria-hidden","true"),Object.assign(r.style,ic),W&&b&&b.insertAdjacentElement("afterend",r),()=>{m.off("openchange",i);let t=eA(e),n=eD(x,t)||P&&eU(P.nodesRef.current,_(),!1).some(e=>{var i;return eD(null==(i=e.context)?void 0:i.elements.floating,t)}),s=function(){if("boolean"==typeof M.current){let t=b||iv();return t&&t.isConnected?t:r}return M.current.current||r}();queueMicrotask(()=>{let i=function(t){let e=eq();return eE(t,e)?t:eO(t,e)[0]||t}(s);M.current&&!R.current&&tC(i)&&(i===t||t===e.body||n)&&i.focus({preventScroll:!0}),r.remove()})}},[n,x,H,M,y,m,P,W,b,_]),B.useEffect(()=>(queueMicrotask(()=>{R.current=!1}),()=>{queueMicrotask(ip)}),[n]),ez(()=>{if(!n&&A)return A.setFocusManagerState({modal:c,closeOnFocusOut:u,open:g,onOpenChange:p,domReference:b}),()=>{A.setFocusManagerState(null)}},[n,A,c,g,p,u,b]),ez(()=>{!n&&H&&im(H,E)},[n,H,E]);let Q=!n&&O&&(!c||!w)&&(W||c);return(0,I.jsxs)(I.Fragment,{children:[Q&&(0,I.jsx)(ih,{"data-type":"inside",ref:V,onFocus:t=>{var e;if(c){let t=z();it("reference"===r[0]?t[0]:t[t.length-1])}else if(null!=A&&A.preserveTabOrder&&A.portalNode)if(R.current=!1,eQ(t,A.portalNode)){let t=eK(eL(b).body,1)||b;null==t||t.focus()}else null==(e=A.beforeOutsideRef.current)||e.focus()}}),!w&&K("start"),i,K("end"),Q&&(0,I.jsx)(ih,{"data-type":"inside",ref:q,onFocus:t=>{var e;if(c)it(z()[0]);else if(null!=A&&A.preserveTabOrder&&A.portalNode)if(u&&(R.current=!0),eQ(t,A.portalNode)){let t=eK(eL(b).body,-1)||b;null==t||t.focus()}else null==(e=A.afterOutsideRef.current)||e.focus()}})]})}function ix(t){return tC(t.target)&&"BUTTON"===t.target.tagName}function i_(t,e){void 0===e&&(e={});let{open:i,onOpenChange:n,dataRef:r,elements:{domReference:s}}=t,{enabled:o=!0,event:a="click",toggle:l=!0,ignoreMouse:c=!1,keyboardHandlers:h=!0,stickIfOpen:u=!0}=e,f=B.useRef(),d=B.useRef(!1),g=B.useMemo(()=>({onPointerDown(t){f.current=t.pointerType},onMouseDown(t){let e=f.current;0===t.button&&"click"!==a&&(eX(e,!0)&&c||(i&&l&&(!r.current.openEvent||!u||"mousedown"===r.current.openEvent.type)?n(!1,t.nativeEvent,"click"):(t.preventDefault(),n(!0,t.nativeEvent,"click"))))},onClick(t){let e=f.current;if("mousedown"===a&&f.current){f.current=void 0;return}eX(e,!0)&&c||(i&&l&&(!r.current.openEvent||!u||"click"===r.current.openEvent.type)?n(!1,t.nativeEvent,"click"):n(!0,t.nativeEvent,"click"))},onKeyDown(t){f.current=void 0,!(t.defaultPrevented||!h||ix(t))&&(" "!==t.key||eI(s)||(t.preventDefault(),d.current=!0),tC(t.target)&&"A"===t.target.tagName||"Enter"!==t.key||(i&&l?n(!1,t.nativeEvent,"click"):n(!0,t.nativeEvent,"click")))},onKeyUp(t){!(t.defaultPrevented||!h||ix(t)||eI(s))&&" "===t.key&&d.current&&(d.current=!1,i&&l?n(!1,t.nativeEvent,"click"):n(!0,t.nativeEvent,"click"))}}),[r,s,a,c,h,n,i,u,l]);return B.useMemo(()=>o?{reference:g}:{},[o,g])}let iC={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},iS={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},iw=t=>{var e,i;return{escapeKey:"boolean"==typeof t?t:null!=(e=null==t?void 0:t.escapeKey)&&e,outsidePress:"boolean"==typeof t?t:null==(i=null==t?void 0:t.outsidePress)||i}};function iT(t,e){void 0===e&&(e={});let{open:i,onOpenChange:n,elements:r,dataRef:s}=t,{enabled:o=!0,escapeKey:a=!0,outsidePress:l=!0,outsidePressEvent:c="pointerdown",referencePress:h=!1,referencePressEvent:u="pointerdown",ancestorScroll:f=!1,bubbles:d,capture:g}=e,p=e6(),m=eV("function"==typeof l?l:()=>!1),y="function"==typeof l?m:l,b=B.useRef(!1),{escapeKey:x,outsidePress:_}=iw(d),{escapeKey:C,outsidePress:S}=iw(g),w=B.useRef(!1),T=eV(t=>{var e;if(!i||!o||!a||"Escape"!==t.key||w.current)return;let r=null==(e=s.current.floatingContext)?void 0:e.nodeId,l=p?eU(p.nodesRef.current,r):[];if(!x&&(t.stopPropagation(),l.length>0)){let t=!0;if(l.forEach(e=>{var i;if(null!=(i=e.context)&&i.open&&!e.context.dataRef.current.__escapeKeyBubbles){t=!1;return}}),!t)return}n(!1,"nativeEvent"in t?t.nativeEvent:t,"escape-key")}),O=eV(t=>{var e;let i=()=>{var e;T(t),null==(e=eF(t))||e.removeEventListener("keydown",i)};null==(e=eF(t))||e.addEventListener("keydown",i)}),k=eV(t=>{var e;let i=s.current.insideReactTree;s.current.insideReactTree=!1;let o=b.current;if(b.current=!1,"click"===c&&o||i||"function"==typeof y&&!y(t))return;let a=eF(t),l="["+e8("inert")+"]",h=eL(r.floating).querySelectorAll(l),u=t_(a)?a:null;for(;u&&!tR(u);){let t=tB(u);if(tR(t)||!t_(t))break;u=t}if(h.length&&t_(a)&&!a.matches("html,body")&&!eD(a,r.floating)&&Array.from(h).every(t=>!eD(u,t)))return;if(tC(a)&&M){let e=tR(a),i=tL(a),n=/auto|scroll/,r=e||n.test(i.overflowX),s=e||n.test(i.overflowY),o=r&&a.clientWidth>0&&a.scrollWidth>a.clientWidth,l=s&&a.clientHeight>0&&a.scrollHeight>a.clientHeight,c="rtl"===i.direction,h=l&&(c?t.offsetX<=a.offsetWidth-a.clientWidth:t.offsetX>a.clientWidth),u=o&&t.offsetY>a.clientHeight;if(h||u)return}let f=null==(e=s.current.floatingContext)?void 0:e.nodeId,d=p&&eU(p.nodesRef.current,f).some(e=>{var i;return eR(t,null==(i=e.context)?void 0:i.elements.floating)});if(eR(t,r.floating)||eR(t,r.domReference)||d)return;let g=p?eU(p.nodesRef.current,f):[];if(g.length>0){let t=!0;if(g.forEach(e=>{var i;if(null!=(i=e.context)&&i.open&&!e.context.dataRef.current.__outsidePressBubbles){t=!1;return}}),!t)return}n(!1,t,"outside-press")}),E=eV(t=>{var e;let i=()=>{var e;k(t),null==(e=eF(t))||e.removeEventListener(c,i)};null==(e=eF(t))||e.addEventListener(c,i)});B.useEffect(()=>{if(!i||!o)return;s.current.__escapeKeyBubbles=x,s.current.__outsidePressBubbles=_;let t=-1;function e(t){n(!1,t,"ancestor-scroll")}function l(){window.clearTimeout(t),w.current=!0}function h(){t=window.setTimeout(()=>{w.current=!1},5*!!tD())}let u=eL(r.floating);a&&(u.addEventListener("keydown",C?O:T,C),u.addEventListener("compositionstart",l),u.addEventListener("compositionend",h)),y&&u.addEventListener(c,S?E:k,S);let d=[];return f&&(t_(r.domReference)&&(d=tN(r.domReference)),t_(r.floating)&&(d=d.concat(tN(r.floating))),!t_(r.reference)&&r.reference&&r.reference.contextElement&&(d=d.concat(tN(r.reference.contextElement)))),(d=d.filter(t=>{var e;return t!==(null==(e=u.defaultView)?void 0:e.visualViewport)})).forEach(t=>{t.addEventListener("scroll",e,{passive:!0})}),()=>{a&&(u.removeEventListener("keydown",C?O:T,C),u.removeEventListener("compositionstart",l),u.removeEventListener("compositionend",h)),y&&u.removeEventListener(c,S?E:k,S),d.forEach(t=>{t.removeEventListener("scroll",e)}),window.clearTimeout(t)}},[s,r,a,y,c,i,n,f,o,x,_,T,C,O,k,S,E]),B.useEffect(()=>{s.current.insideReactTree=!1},[s,y,c]);let j=B.useMemo(()=>({onKeyDown:T,...h&&{[iC[u]]:t=>{n(!1,t.nativeEvent,"reference-press")},..."click"!==u&&{onClick(t){n(!1,t.nativeEvent,"reference-press")}}}}),[T,n,h,u]),M=B.useMemo(()=>({onKeyDown:T,onMouseDown(){b.current=!0},onMouseUp(){b.current=!0},[iS[c]]:()=>{s.current.insideReactTree=!0}}),[T,c,s]);return B.useMemo(()=>o?{reference:j,floating:M}:{},[o,j,M])}function iO(t){void 0===t&&(t={});let{nodeId:e}=t,i=function(t){let{open:e=!1,onOpenChange:i,elements:n}=t,r=e5(),s=B.useRef({}),[o]=B.useState(()=>(function(){let t=new Map;return{emit(e,i){var n;null==(n=t.get(e))||n.forEach(t=>t(i))},on(e,i){t.has(e)||t.set(e,new Set),t.get(e).add(i)},off(e,i){var n;null==(n=t.get(e))||n.delete(i)}}})()),a=null!=e9(),[l,c]=B.useState(n.reference),h=eV((t,e,n)=>{s.current.openEvent=t?e:void 0,o.emit("openchange",{open:t,event:e,reason:n,nested:a}),null==i||i(t,e,n)}),u=B.useMemo(()=>({setPositionReference:c}),[]),f=B.useMemo(()=>({reference:l||n.reference||null,floating:n.floating||null,domReference:n.reference}),[l,n.reference,n.floating]);return B.useMemo(()=>({dataRef:s,open:e,onOpenChange:h,elements:f,events:o,floatingId:r,refs:u}),[e,h,f,o,r,u])}({...t,elements:{reference:null,floating:null,...t.elements}}),n=t.rootContext||i,r=n.elements,[s,o]=B.useState(null),[a,l]=B.useState(null),c=(null==r?void 0:r.domReference)||s,h=B.useRef(null),u=e6();ez(()=>{c&&(h.current=c)},[c]);let f=function(t){void 0===t&&(t={});let{placement:e="bottom",strategy:i="absolute",middleware:n=[],platform:r,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[h,u]=B.useState({x:0,y:0,strategy:i,placement:e,middlewareData:{},isPositioned:!1}),[f,d]=B.useState(n);t9(f,n)||d(n);let[g,p]=B.useState(null),[m,y]=B.useState(null),b=B.useCallback(t=>{t!==S.current&&(S.current=t,p(t))},[]),x=B.useCallback(t=>{t!==w.current&&(w.current=t,y(t))},[]),_=s||g,C=o||m,S=B.useRef(null),w=B.useRef(null),T=B.useRef(h),O=null!=l,k=t7(l),E=t7(r),j=t7(c),M=B.useCallback(()=>{if(!S.current||!w.current)return;let t={placement:e,strategy:i,middleware:f};E.current&&(t.platform=E.current),((t,e,i)=>{let n=new Map,r={platform:t1,...i},s={...r.platform,_c:n};return tf(t,e,{...r,platform:s})})(S.current,w.current,t).then(t=>{let e={...t,isPositioned:!1!==j.current};P.current&&!t9(T.current,e)&&(T.current=e,t4.flushSync(()=>{u(e)}))})},[f,e,i,E,j]);t3(()=>{!1===c&&T.current.isPositioned&&(T.current.isPositioned=!1,u(t=>({...t,isPositioned:!1})))},[c]);let P=B.useRef(!1);t3(()=>(P.current=!0,()=>{P.current=!1}),[]),t3(()=>{if(_&&(S.current=_),C&&(w.current=C),_&&C){if(k.current)return k.current(_,C,M);M()}},[_,C,M,k,O]);let A=B.useMemo(()=>({reference:S,floating:w,setReference:b,setFloating:x}),[b,x]),D=B.useMemo(()=>({reference:_,floating:C}),[_,C]),F=B.useMemo(()=>{let t={position:i,left:0,top:0};if(!D.floating)return t;let e=t8(D.floating,h.x),n=t8(D.floating,h.y);return a?{...t,transform:"translate("+e+"px, "+n+"px)",...t6(D.floating)>=1.5&&{willChange:"transform"}}:{position:i,left:e,top:n}},[i,a,D.floating,h.x,h.y]);return B.useMemo(()=>({...h,update:M,refs:A,elements:D,floatingStyles:F}),[h,M,A,D,F])}({...t,elements:{...r,...a&&{reference:a}}}),d=B.useCallback(t=>{let e=t_(t)?{getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>t.getClientRects(),contextElement:t}:t;l(e),f.refs.setReference(e)},[f.refs]),g=B.useCallback(t=>{(t_(t)||null===t)&&(h.current=t,o(t)),(t_(f.refs.reference.current)||null===f.refs.reference.current||null!==t&&!t_(t))&&f.refs.setReference(t)},[f.refs]),p=B.useMemo(()=>({...f.refs,setReference:g,setPositionReference:d,domReference:h}),[f.refs,g,d]),m=B.useMemo(()=>({...f.elements,domReference:c}),[f.elements,c]),y=B.useMemo(()=>({...f,...n,refs:p,elements:m,nodeId:e}),[f,p,m,e,n]);return ez(()=>{n.dataRef.current.floatingContext=y;let t=null==u?void 0:u.nodesRef.current.find(t=>t.id===e);t&&(t.context=y)}),B.useMemo(()=>({...f,context:y,refs:p,elements:m}),[f,p,m,y])}function ik(t,e,i){let n=new Map,r="item"===i,s=t;if(r&&t){let{[eJ]:e,[e$]:i,...n}=t;s=n}return{..."floating"===i&&{tabIndex:-1,"data-floating-ui-focusable":""},...s,...e.map(e=>{let n=e?e[i]:null;return"function"==typeof n?t?n(t):null:n}).concat(t).reduce((t,e)=>(e&&Object.entries(e).forEach(e=>{let[i,s]=e;if(!(r&&[eJ,e$].includes(i)))if(0===i.indexOf("on")){if(n.has(i)||n.set(i,[]),"function"==typeof s){var o;null==(o=n.get(i))||o.push(s),t[i]=function(){for(var t,e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return null==(t=n.get(i))?void 0:t.map(t=>t(...r)).find(t=>void 0!==t)}}}else t[i]=s}),t),{})}}function iE(t){void 0===t&&(t=[]);let e=t.map(t=>null==t?void 0:t.reference),i=t.map(t=>null==t?void 0:t.floating),n=t.map(t=>null==t?void 0:t.item),r=B.useCallback(e=>ik(e,t,"reference"),e),s=B.useCallback(e=>ik(e,t,"floating"),i),o=B.useCallback(e=>ik(e,t,"item"),n);return B.useMemo(()=>({getReferenceProps:r,getFloatingProps:s,getItemProps:o}),[r,s,o])}let ij=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function iM(t,e){var i,n;void 0===e&&(e={});let{open:r,elements:s,floatingId:o}=t,{enabled:a=!0,role:l="dialog"}=e,c=e5(),h=(null==(i=s.domReference)?void 0:i.id)||c,u=B.useMemo(()=>{var t;return(null==(t=eN(s.floating))?void 0:t.id)||o},[s.floating,o]),f=null!=(n=ij.get(l))?n:l,d=null!=e9(),g=B.useMemo(()=>"tooltip"===f||"label"===l?{["aria-"+("label"===l?"labelledby":"describedby")]:r?u:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":"alertdialog"===f?"dialog":f,"aria-controls":r?u:void 0,..."listbox"===f&&{role:"combobox"},..."menu"===f&&{id:h},..."menu"===f&&d&&{role:"menuitem"},..."select"===l&&{"aria-autocomplete":"none"},..."combobox"===l&&{"aria-autocomplete":"list"}},[f,u,d,r,h,l]),p=B.useMemo(()=>{let t={id:u,...f&&{role:f}};return"tooltip"===f||"label"===l?t:{...t,..."menu"===f&&{"aria-labelledby":h}}},[f,u,h,l]),m=B.useCallback(t=>{let{active:e,selected:i}=t,n={role:"option",...e&&{id:u+"-fui-option"}};switch(l){case"select":case"combobox":return{...n,"aria-selected":i}}return{}},[u,l]);return B.useMemo(()=>a?{reference:g,floating:p,item:m}:{},[a,g,p,m])}var iP=t.i(40141);function iA(t){return(0,iP.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6Z"},child:[]}]})(t)}function iD(t){return(0,iP.GenIcon)({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M5 2a1 1 0 011 1v1h1a1 1 0 010 2H6v1a1 1 0 01-2 0V6H3a1 1 0 010-2h1V3a1 1 0 011-1zm0 10a1 1 0 011 1v1h1a1 1 0 110 2H6v1a1 1 0 11-2 0v-1H3a1 1 0 110-2h1v-1a1 1 0 011-1zM12 2a1 1 0 01.967.744L14.146 7.2 17.5 9.134a1 1 0 010 1.732l-3.354 1.935-1.18 4.455a1 1 0 01-1.933 0L9.854 12.8 6.5 10.866a1 1 0 010-1.732l3.354-1.935 1.18-4.455A1 1 0 0112 2z",clipRule:"evenodd"},child:[]}]})(t)}var iF=t.i(11152);function iR(t){return(0,iP.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M123.193 29.635L121 406.18l84.31-82.836 65.87 159.02 67.5-27.96-65.87-159.02L391 294.342z"},child:[]}]})(t)}function iL(t){return(0,iP.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M149.9 302.2c-39.1 0-70.7 31-70.7 69.3 0 30.3-27.3 46.2-47.2 46.2C53.7 446 90.7 464 126.3 464c52.1 0 94.3-41.4 94.3-92.4 0-38.4-31.6-69.4-70.7-69.4zM473.1 85.7l-31.6-31c-9.2-9-24-9-33.2 0L197 261.8l64.8 63.5 211.2-207c9.3-9 9.3-23.6.1-32.6z"},child:[]}]})(t)}function iI(t){return(0,iP.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M96 448h106.7V64H96v384zM309.3 64v384H416V64H309.3z"},child:[]}]})(t)}function iB(t){return(0,iP.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M96 52v408l320-204L96 52z"},child:[]}]})(t)}function iN(t){return(0,iP.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M11.904 16c1.777-3.219 2.076-8.13-4.904-7.966v3.966l-6-6 6-6v3.881c8.359-0.218 9.29 7.378 4.904 12.119z"},child:[]}]})(t)}function iU(t){return(0,iP.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M9 3.881v-3.881l6 6-6 6v-3.966c-6.98-0.164-6.681 4.747-4.904 7.966-4.386-4.741-3.455-12.337 4.904-12.119z"},child:[]}]})(t)}function iW(t){return(0,iP.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M8 0c-4.418 0-8 3.582-8 8s3.582 8 8 8 8-3.582 8-8-3.582-8-8-8zM2 8c0-3.314 2.686-6 6-6v12c-3.314 0-6-2.686-6-6z"},child:[]}]})(t)}function iH(t){return(0,iP.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M8 4c-2.209 0-4 1.791-4 4s1.791 4 4 4 4-1.791 4-4-1.791-4-4-4zM8 10.5v-5c1.379 0 2.5 1.122 2.5 2.5s-1.121 2.5-2.5 2.5zM8 13c0.552 0 1 0.448 1 1v1c0 0.552-0.448 1-1 1s-1-0.448-1-1v-1c0-0.552 0.448-1 1-1zM8 3c-0.552 0-1-0.448-1-1v-1c0-0.552 0.448-1 1-1s1 0.448 1 1v1c0 0.552-0.448 1-1 1zM15 7c0.552 0 1 0.448 1 1s-0.448 1-1 1h-1c-0.552 0-1-0.448-1-1s0.448-1 1-1h1zM3 8c0 0.552-0.448 1-1 1h-1c-0.552 0-1-0.448-1-1s0.448-1 1-1h1c0.552 0 1 0.448 1 1zM12.95 11.536l0.707 0.707c0.39 0.39 0.39 1.024 0 1.414s-1.024 0.39-1.414 0l-0.707-0.707c-0.39-0.39-0.39-1.024 0-1.414s1.024-0.39 1.414 0zM3.050 4.464l-0.707-0.707c-0.391-0.391-0.391-1.024 0-1.414s1.024-0.391 1.414 0l0.707 0.707c0.391 0.391 0.391 1.024 0 1.414s-1.024 0.391-1.414 0zM12.95 4.464c-0.39 0.391-1.024 0.391-1.414 0s-0.39-1.024 0-1.414l0.707-0.707c0.39-0.391 1.024-0.391 1.414 0s0.39 1.024 0 1.414l-0.707 0.707zM3.050 11.536c0.39-0.39 1.024-0.39 1.414 0s0.391 1.024 0 1.414l-0.707 0.707c-0.391 0.39-1.024 0.39-1.414 0s-0.391-1.024 0-1.414l0.707-0.707z"},child:[]}]})(t)}function iX(t){return(0,iP.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M15.5 6h-5.5v-5.5c0-0.276-0.224-0.5-0.5-0.5h-3c-0.276 0-0.5 0.224-0.5 0.5v5.5h-5.5c-0.276 0-0.5 0.224-0.5 0.5v3c0 0.276 0.224 0.5 0.5 0.5h5.5v5.5c0 0.276 0.224 0.5 0.5 0.5h3c0.276 0 0.5-0.224 0.5-0.5v-5.5h5.5c0.276 0 0.5-0.224 0.5-0.5v-3c0-0.276-0.224-0.5-0.5-0.5z"},child:[]}]})(t)}let iz=B.default.createContext(null);function iY(){let t=(0,B.useContext)(iz);if(!t)throw Error("No WarriorContext.Provider");return t}iz.displayName="WarriorContext";let iG="undefined"!=typeof window&&window.document&&window.document.createElement?B.useLayoutEffect:B.useEffect,iV=(t,e)=>{let i=B.useRef(!0);iG(()=>t(i.current),e),iG(()=>(i.current=!1,()=>{i.current=!0}),[])},iq=function(t){let e=B.useRef();return e.current=t,B.useCallback(function(){for(var t,i=arguments.length,n=Array(i),r=0;r<i;r++)n[r]=arguments[r];return null==(t=e.current)?void 0:t.call(e,...n)},[])},iK={},iQ=[];function iJ(t,e){}function i$(t,e){}function iZ(t,e,i){e||iK[i]||(t(!1,i),iK[i]=!0)}function i0(t,e){iZ(iJ,t,e)}i0.preMessage=t=>{iQ.push(t)},i0.resetWarned=function(){iK={}},i0.noteOnce=function(t,e){iZ(i$,t,e)};let i1=function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=new Set;return function t(e,r){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=n.has(e);if(i0(!o,"Warning: There may be circular references"),o)return!1;if(e===r)return!0;if(i&&s>1)return!1;n.add(e);let a=s+1;if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let i=0;i<e.length;i++)if(!t(e[i],r[i],a))return!1;return!0}if(e&&r&&"object"==typeof e&&"object"==typeof r){let i=Object.keys(e);return i.length===Object.keys(r).length&&i.every(i=>t(e[i],r[i],a))}return!1}(t,e)};var i2=t.i(43794);function i5(t,e,i,n){let r=(e-i)/(n-i),s={};switch(t){case"rtl":s.right="".concat(100*r,"%"),s.transform="translateX(50%)";break;case"btt":s.bottom="".concat(100*r,"%"),s.transform="translateY(50%)";break;case"ttb":s.top="".concat(100*r,"%"),s.transform="translateY(-50%)";break;default:s.left="".concat(100*r,"%"),s.transform="translateX(-50%)"}return s}function i4(t,e){return Array.isArray(t)?t[e]:t}let i3={MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,QUESTION_MARK:63,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,WIN_IME:229,isTextModifyingKeyEvent:function(t){let{keyCode:e}=t;if(t.altKey&&!t.ctrlKey||t.metaKey||e>=i3.F1&&e<=i3.F12)return!1;switch(e){case i3.ALT:case i3.CAPS_LOCK:case i3.CONTEXT_MENU:case i3.CTRL:case i3.DOWN:case i3.END:case i3.ESC:case i3.HOME:case i3.INSERT:case i3.LEFT:case i3.MAC_FF_META:case i3.META:case i3.NUMLOCK:case i3.NUM_CENTER:case i3.PAGE_DOWN:case i3.PAGE_UP:case i3.PAUSE:case i3.PRINT_SCREEN:case i3.RIGHT:case i3.SHIFT:case i3.UP:case i3.WIN_KEY:case i3.WIN_KEY_RIGHT:return!1;default:return!0}},isCharacterKey:function(t){if(t>=i3.ZERO&&t<=i3.NINE||t>=i3.NUM_ZERO&&t<=i3.NUM_MULTIPLY||t>=i3.A&&t<=i3.Z||-1!==window.navigator.userAgent.indexOf("WebKit")&&0===t)return!0;switch(t){case i3.SPACE:case i3.QUESTION_MARK:case i3.NUM_PLUS:case i3.NUM_MINUS:case i3.NUM_PERIOD:case i3.NUM_DIVISION:case i3.SEMICOLON:case i3.DASH:case i3.EQUALS:case i3.COMMA:case i3.PERIOD:case i3.SLASH:case i3.APOSTROPHE:case i3.SINGLE_QUOTE:case i3.OPEN_SQUARE_BRACKET:case i3.BACKSLASH:case i3.CLOSE_SQUARE_BRACKET:return!0;default:return!1}}},i9=B.createContext({min:0,max:0,direction:"ltr",step:1,includedStart:0,includedEnd:0,tabIndex:0,keyboard:!0,styles:{},classNames:{}}),i6=B.createContext({});function i8(){return(i8=Object.assign.bind()).apply(this,arguments)}let i7=B.forwardRef((t,e)=>{let{prefixCls:i,value:n,valueIndex:r,onStartMove:s,onDelete:o,style:a,render:l,dragging:c,draggingDelete:h,onOffsetChange:u,onChangeComplete:f,onFocus:d,onMouseEnter:g,...p}=t,{min:m,max:y,direction:b,disabled:x,keyboard:_,range:C,tabIndex:S,ariaLabelForHandle:w,ariaLabelledByForHandle:T,ariaRequired:O,ariaValueTextFormatterForHandle:k,styles:E,classNames:j}=B.useContext(i9),M="".concat(i,"-handle"),P=t=>{x||s(t,r)},A=i5(b,n,m,y),D={};if(null!==r){var F;D={tabIndex:x?null:i4(S,r),role:"slider","aria-valuemin":m,"aria-valuemax":y,"aria-valuenow":n,"aria-disabled":x,"aria-label":i4(w,r),"aria-labelledby":i4(T,r),"aria-required":i4(O,r),"aria-valuetext":null==(F=i4(k,r))?void 0:F(n),"aria-orientation":"ltr"===b||"rtl"===b?"horizontal":"vertical",onMouseDown:P,onTouchStart:P,onFocus:t=>{null==d||d(t,r)},onMouseEnter:t=>{g(t,r)},onKeyDown:t=>{if(!x&&_){let e=null;switch(t.which||t.keyCode){case i3.LEFT:e="ltr"===b||"btt"===b?-1:1;break;case i3.RIGHT:e="ltr"===b||"btt"===b?1:-1;break;case i3.UP:e="ttb"!==b?1:-1;break;case i3.DOWN:e="ttb"!==b?-1:1;break;case i3.HOME:e="min";break;case i3.END:e="max";break;case i3.PAGE_UP:e=2;break;case i3.PAGE_DOWN:e=-2;break;case i3.BACKSPACE:case i3.DELETE:null==o||o(r)}null!==e&&(t.preventDefault(),u(e,r))}},onKeyUp:t=>{switch(t.which||t.keyCode){case i3.LEFT:case i3.RIGHT:case i3.UP:case i3.DOWN:case i3.HOME:case i3.END:case i3.PAGE_UP:case i3.PAGE_DOWN:null==f||f()}}}}let R=B.createElement("div",i8({ref:e,className:(0,i2.default)(M,{["".concat(M,"-").concat(r+1)]:null!==r&&C,["".concat(M,"-dragging")]:c,["".concat(M,"-dragging-delete")]:h},j.handle),style:{...A,...a,...E.handle}},D,p));return l&&(R=l(R,{index:r,prefixCls:i,value:n,dragging:c,draggingDelete:h})),R});function nt(){return(nt=Object.assign.bind()).apply(this,arguments)}let ne=B.forwardRef((t,e)=>{let{prefixCls:i,style:n,onStartMove:r,onOffsetChange:s,values:o,handleRender:a,activeHandleRender:l,draggingIndex:c,draggingDelete:h,onFocus:u,...f}=t,d=B.useRef({}),[g,p]=B.useState(!1),[m,y]=B.useState(-1),b=t=>{y(t),p(!0)};B.useImperativeHandle(e,()=>({focus:t=>{var e;null==(e=d.current[t])||e.focus()},hideHelp:()=>{(0,t4.flushSync)(()=>{p(!1)})}}));let x={prefixCls:i,onStartMove:r,onOffsetChange:s,render:a,onFocus:(t,e)=>{b(e),null==u||u(t)},onMouseEnter:(t,e)=>{b(e)},...f};return B.createElement(B.Fragment,null,o.map((t,e)=>{let i=c===e;return B.createElement(i7,nt({ref:t=>{t?d.current[e]=t:delete d.current[e]},dragging:i,draggingDelete:i&&h,style:i4(n,e),key:e,value:t,valueIndex:e},x))}),l&&g&&B.createElement(i7,nt({key:"a11y"},x,{value:o[m],valueIndex:null,dragging:-1!==c,draggingDelete:h,render:l,style:{pointerEvents:"none"},tabIndex:null,"aria-hidden":!0})))}),ni=t=>{let{prefixCls:e,style:i,children:n,value:r,onClick:s}=t,{min:o,max:a,direction:l,includedStart:c,includedEnd:h,included:u}=B.useContext(i9),f="".concat(e,"-text"),d=i5(l,r,o,a);return B.createElement("span",{className:(0,i2.default)(f,{["".concat(f,"-active")]:u&&c<=r&&r<=h}),style:{...d,...i},onMouseDown:t=>{t.stopPropagation()},onClick:()=>{s(r)}},n)},nn=t=>{let{prefixCls:e,marks:i,onClick:n}=t,r="".concat(e,"-mark");return i.length?B.createElement("div",{className:r},i.map(t=>{let{value:e,style:i,label:s}=t;return B.createElement(ni,{key:e,prefixCls:r,style:i,value:e,onClick:n},s)})):null},nr=t=>{let{prefixCls:e,value:i,style:n,activeStyle:r}=t,{min:s,max:o,direction:a,included:l,includedStart:c,includedEnd:h}=B.useContext(i9),u="".concat(e,"-dot"),f=l&&c<=i&&i<=h,d={...i5(a,i,s,o),..."function"==typeof n?n(i):n};return f&&(d={...d,..."function"==typeof r?r(i):r}),B.createElement("span",{className:(0,i2.default)(u,{["".concat(u,"-active")]:f}),style:d})},ns=t=>{let{prefixCls:e,marks:i,dots:n,style:r,activeStyle:s}=t,{min:o,max:a,step:l}=B.useContext(i9),c=B.useMemo(()=>{let t=new Set;if(i.forEach(e=>{t.add(e.value)}),n&&null!==l){let e=o;for(;e<=a;)t.add(e),e+=l}return Array.from(t)},[o,a,l,n,i]);return B.createElement("div",{className:"".concat(e,"-step")},c.map(t=>B.createElement(nr,{prefixCls:e,key:t,value:t,style:r,activeStyle:s})))},no=t=>{let{prefixCls:e,style:i,start:n,end:r,index:s,onStartMove:o,replaceCls:a}=t,{direction:l,min:c,max:h,disabled:u,range:f,classNames:d}=B.useContext(i9),g="".concat(e,"-track"),p=(n-c)/(h-c),m=(r-c)/(h-c),y=t=>{!u&&o&&o(t,-1)},b={};switch(l){case"rtl":b.right="".concat(100*p,"%"),b.width="".concat(100*m-100*p,"%");break;case"btt":b.bottom="".concat(100*p,"%"),b.height="".concat(100*m-100*p,"%");break;case"ttb":b.top="".concat(100*p,"%"),b.height="".concat(100*m-100*p,"%");break;default:b.left="".concat(100*p,"%"),b.width="".concat(100*m-100*p,"%")}let x=a||(0,i2.default)(g,{["".concat(g,"-").concat(s+1)]:null!==s&&f,["".concat(e,"-track-draggable")]:o},d.track);return B.createElement("div",{className:x,style:{...b,...i},onMouseDown:y,onTouchStart:y})},na=t=>{let{prefixCls:e,style:i,values:n,startPoint:r,onStartMove:s}=t,{included:o,range:a,min:l,styles:c,classNames:h}=B.useContext(i9),u=B.useMemo(()=>{if(!a){if(0===n.length)return[];let t=null!=r?r:l,e=n[0];return[{start:Math.min(t,e),end:Math.max(t,e)}]}let t=[];for(let e=0;e<n.length-1;e+=1)t.push({start:n[e],end:n[e+1]});return t},[n,a,r,l]);if(!o)return null;let f=(null==u?void 0:u.length)&&(h.tracks||c.tracks)?B.createElement(no,{index:null,prefixCls:e,start:u[0].start,end:u[u.length-1].end,replaceCls:(0,i2.default)(h.tracks,"".concat(e,"-tracks")),style:c.tracks}):null;return B.createElement(B.Fragment,null,f,u.map((t,n)=>{let{start:r,end:o}=t;return B.createElement(no,{index:n,prefixCls:e,style:{...i4(i,n),...c.track},start:r,end:o,key:n,onStartMove:s})}))};function nl(t){let e="targetTouches"in t?t.targetTouches[0]:t;return{pageX:e.pageX,pageY:e.pageY}}let nc=function(t,e,i,n,r,s,o,a,l,c,h){let[u,f]=B.useState(null),[d,g]=B.useState(-1),[p,m]=B.useState(!1),[y,b]=B.useState(i),[x,_]=B.useState(i),C=B.useRef(null),S=B.useRef(null),w=B.useRef(null),{onDragStart:T,onDragChange:O}=B.useContext(i6);iV(()=>{-1===d&&b(i)},[i,d]),B.useEffect(()=>()=>{document.removeEventListener("mousemove",C.current),document.removeEventListener("mouseup",S.current),w.current&&(w.current.removeEventListener("touchmove",C.current),w.current.removeEventListener("touchend",S.current))},[]);let k=(t,e,i)=>{void 0!==e&&f(e),b(t);let n=t;i&&(n=t.filter((t,e)=>e!==d)),o(n),O&&O({rawValues:t,deleteIndex:i?d:-1,draggingIndex:d,draggingValue:e})},E=iq((t,e,i)=>{if(-1===t){let t=x[0],i=x[x.length-1],o=e*(r-n);o=Math.min(o=Math.max(o,n-t),r-i),o=s(t+o)-t,k(x.map(t=>t+o))}else{let s=[...y];s[t]=x[t];let o=l(s,(r-n)*e,t,"dist");k(o.values,o.value,i)}});return[d,u,p,B.useMemo(()=>{let t=[...i].sort((t,e)=>t-e),e=[...y].sort((t,e)=>t-e),n={};e.forEach(t=>{n[t]=(n[t]||0)+1}),t.forEach(t=>{n[t]=(n[t]||0)-1});let r=+!!c;return Object.values(n).reduce((t,e)=>t+Math.abs(e),0)<=r?y:i},[i,y,c]),(n,r,s)=>{n.stopPropagation();let o=s||i,l=o[r];g(r),f(l),_(o),b(o),m(!1);let{pageX:u,pageY:d}=nl(n),p=!1;T&&T({rawValues:o,draggingIndex:r,draggingValue:l});let x=i=>{let n,s;i.preventDefault();let{pageX:o,pageY:a}=nl(i),l=o-u,f=a-d,{width:g,height:b}=t.current.getBoundingClientRect();switch(e){case"btt":n=-f/b,s=l;break;case"ttb":n=f/b,s=l;break;case"rtl":n=-l/g,s=f;break;default:n=l/g,s=f}m(p=!!c&&Math.abs(s)>130&&h<y.length),E(r,n,p)},O=t=>{t.preventDefault(),document.removeEventListener("mouseup",O),document.removeEventListener("mousemove",x),w.current&&(w.current.removeEventListener("touchmove",C.current),w.current.removeEventListener("touchend",S.current)),C.current=null,S.current=null,w.current=null,a(p),g(-1),m(!1)};document.addEventListener("mouseup",O),document.addEventListener("mousemove",x),n.currentTarget.addEventListener("touchend",O),n.currentTarget.addEventListener("touchmove",x),C.current=x,S.current=O,w.current=n.currentTarget}]},nh=B.forwardRef((t,e)=>{let{prefixCls:i="rc-slider",className:n,style:r,classNames:s,styles:o,id:a,disabled:l=!1,keyboard:c=!0,autoFocus:h,onFocus:u,onBlur:f,min:d=0,max:g=100,step:p=1,value:m,defaultValue:y,range:b,count:x,onChange:_,onBeforeChange:C,onAfterChange:S,onChangeComplete:w,allowCross:T=!0,pushable:O=!1,reverse:k,vertical:E,included:j=!0,startPoint:M,trackStyle:P,handleStyle:A,railStyle:D,dotStyle:F,activeDotStyle:R,marks:L,dots:I,handleRender:N,activeHandleRender:U,track:W,tabIndex:H=0,ariaLabelForHandle:X,ariaLabelledByForHandle:z,ariaRequired:Y,ariaValueTextFormatterForHandle:G}=t,V=B.useRef(null),q=B.useRef(null),K=B.useMemo(()=>E?k?"ttb":"btt":k?"rtl":"ltr",[k,E]),[Q,J,$,Z,tt]=function(t){return(0,B.useMemo)(()=>{if(!0===t||!t)return[!!t,!1,!1,0];let{editable:e,draggableTrack:i,minCount:n,maxCount:r}=t;return[!0,e,!e&&i,n||0,r]},[t])}(b),te=B.useMemo(()=>isFinite(d)?d:0,[d]),ti=B.useMemo(()=>isFinite(g)?g:100,[g]),tn=B.useMemo(()=>null!==p&&p<=0?1:p,[p]),tr=B.useMemo(()=>"boolean"==typeof O?!!O&&tn:O>=0&&O,[O,tn]),ts=B.useMemo(()=>Object.keys(L||{}).map(t=>{let e=L[t],i={value:Number(t)};return e&&"object"==typeof e&&!B.isValidElement(e)&&("label"in e||"style"in e)?(i.style=e.style,i.label=e.label):i.label=e,i}).filter(t=>{let{label:e}=t;return e||"number"==typeof e}).sort((t,e)=>t.value-e.value),[L]),[to,ta]=function(t,e,i,n,r,s){let o=B.useCallback(i=>Math.max(t,Math.min(e,i)),[t,e]),a=B.useCallback(n=>{if(null!==i){let r=t+Math.round((o(n)-t)/i)*i,s=t=>(String(t).split(".")[1]||"").length,a=Math.max(s(i),s(e),s(t)),l=Number(r.toFixed(a));return t<=l&&l<=e?l:null}return null},[i,t,e,o]),l=B.useCallback(r=>{let s=o(r),l=n.map(t=>t.value);null!==i&&l.push(a(r)),l.push(t,e);let c=l[0],h=e-t;return l.forEach(t=>{let e=Math.abs(s-t);e<=h&&(c=t,h=e)}),c},[t,e,n,i,o,a]),c=function(r,s,o){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit";if("number"==typeof s){let h,u=r[o],f=u+s,d=[];n.forEach(t=>{d.push(t.value)}),d.push(t,e),d.push(a(u));let g=s>0?1:-1;"unit"===l?d.push(a(u+g*i)):d.push(a(f)),d=d.filter(t=>null!==t).filter(t=>s<0?t<=u:t>=u),"unit"===l&&(d=d.filter(t=>t!==u));let p="unit"===l?u:f,m=Math.abs((h=d[0])-p);if(d.forEach(t=>{let e=Math.abs(t-p);e<m&&(h=t,m=e)}),void 0===h)return s<0?t:e;if("dist"===l)return h;if(Math.abs(s)>1){let t=[...r];return t[o]=h,c(t,s-g,o,l)}return h}return"min"===s?t:"max"===s?e:void 0},h=function(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit",r=t[i],s=c(t,e,i,n);return{value:s,changed:s!==r}},u=t=>null===s&&0===t||"number"==typeof s&&t<s;return[l,function(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit",o=t.map(l),a=o[i],f=c(o,e,i,n);if(o[i]=f,!1===r){let t=s||0;i>0&&o[i-1]!==a&&(o[i]=Math.max(o[i],o[i-1]+t)),i<o.length-1&&o[i+1]!==a&&(o[i]=Math.min(o[i],o[i+1]-t))}else if("number"==typeof s||null===s){for(let t=i+1;t<o.length;t+=1){let e=!0;for(;u(o[t]-o[t-1])&&e;)({value:o[t],changed:e}=h(o,1,t))}for(let t=i;t>0;t-=1){let e=!0;for(;u(o[t]-o[t-1])&&e;)({value:o[t-1],changed:e}=h(o,-1,t-1))}for(let t=o.length-1;t>0;t-=1){let e=!0;for(;u(o[t]-o[t-1])&&e;)({value:o[t-1],changed:e}=h(o,-1,t-1))}for(let t=0;t<o.length-1;t+=1){let e=!0;for(;u(o[t+1]-o[t])&&e;)({value:o[t+1],changed:e}=h(o,1,t+1))}}return{value:o[i],values:o}}]}(te,ti,tn,ts,T,tr),[tl,tc]=function(t,e){let[i,n]=(0,B.useState)(t),r=void 0!==e?e:i;return iV(t=>{t||n(e)},[e]),[r,n]}(y,m),th=B.useMemo(()=>{let t=null==tl?[]:Array.isArray(tl)?tl:[tl],[e=te]=t,i=null===tl?[]:[e];if(Q){if(i=[...t],x||void 0===tl){let t=x>=0?x+1:2;for(i=i.slice(0,t);i.length<t;){var n;i.push(null!=(n=i[i.length-1])?n:te)}}i.sort((t,e)=>t-e)}return i.forEach((t,e)=>{i[e]=to(t)}),i},[tl,Q,te,x,to]),tu=t=>Q?t:t[0],tf=iq(t=>{let e=[...t].sort((t,e)=>t-e);_&&!i1(e,th,!0)&&_(tu(e)),tc(e)}),td=iq(t=>{t&&V.current.hideHelp();let e=tu(th);null==S||S(e),i0(!S,"[rc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead."),null==w||w(e)}),[tg,tp,tv,tm,ty]=nc(q,K,th,te,ti,to,tf,td,ta,J,Z),tb=(t,e)=>{if(!l){let r=[...th],s=0,o=0,a=ti-te;th.forEach((e,i)=>{let n=Math.abs(t-e);n<=a&&(a=n,s=i),e<t&&(o=i)});let l=s;J&&0!==a&&(!tt||th.length<tt)?(r.splice(o+1,0,t),l=o+1):r[s]=t,Q&&!th.length&&void 0===x&&r.push(t);let c=tu(r);if(null==C||C(c),tf(r),e){var i,n;null==(n=document.activeElement)||null==(i=n.blur)||i.call(n),V.current.focus(l),ty(e,l,r)}else null==S||S(c),i0(!S,"[rc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead."),null==w||w(c)}},[tx,t_]=B.useState(null);B.useEffect(()=>{if(null!==tx){let t=th.indexOf(tx);t>=0&&V.current.focus(t)}t_(null)},[tx]);let tC=B.useMemo(()=>(!$||null!==tn)&&$,[$,tn]),tS=iq((t,e)=>{ty(t,e),null==C||C(tu(th))}),tw=-1!==tg;B.useEffect(()=>{if(!tw){let t=th.lastIndexOf(tp);V.current.focus(t)}},[tw]);let tT=B.useMemo(()=>[...tm].sort((t,e)=>t-e),[tm]),[tO,tk]=B.useMemo(()=>Q?[tT[0],tT[tT.length-1]]:[te,tT[0]],[tT,Q,te]);B.useImperativeHandle(e,()=>({focus:()=>{V.current.focus(0)},blur:()=>{var t;let{activeElement:e}=document;(null==(t=q.current)?void 0:t.contains(e))&&(null==e||e.blur())}})),B.useEffect(()=>{h&&V.current.focus(0)},[]);let tE=B.useMemo(()=>({min:te,max:ti,direction:K,disabled:l,keyboard:c,step:tn,included:j,includedStart:tO,includedEnd:tk,range:Q,tabIndex:H,ariaLabelForHandle:X,ariaLabelledByForHandle:z,ariaRequired:Y,ariaValueTextFormatterForHandle:G,styles:o||{},classNames:s||{}}),[te,ti,K,l,c,tn,j,tO,tk,Q,H,X,z,Y,G,o,s]);return B.createElement(i9.Provider,{value:tE},B.createElement("div",{ref:q,className:(0,i2.default)(i,n,{["".concat(i,"-disabled")]:l,["".concat(i,"-vertical")]:E,["".concat(i,"-horizontal")]:!E,["".concat(i,"-with-marks")]:ts.length}),style:r,onMouseDown:t=>{let e;t.preventDefault();let{width:i,height:n,left:r,top:s,bottom:o,right:a}=q.current.getBoundingClientRect(),{clientX:l,clientY:c}=t;switch(K){case"btt":e=(o-c)/n;break;case"ttb":e=(c-s)/n;break;case"rtl":e=(a-l)/i;break;default:e=(l-r)/i}tb(to(te+e*(ti-te)),t)},id:a},B.createElement("div",{className:(0,i2.default)("".concat(i,"-rail"),null==s?void 0:s.rail),style:{...D,...null==o?void 0:o.rail}}),!1!==W&&B.createElement(na,{prefixCls:i,style:P,values:th,startPoint:M,onStartMove:tC?tS:void 0}),B.createElement(ns,{prefixCls:i,marks:ts,dots:I,style:F,activeStyle:R}),B.createElement(ne,{ref:V,prefixCls:i,style:A,values:tm,draggingIndex:tg,draggingDelete:tv,onStartMove:tS,onOffsetChange:(t,e)=>{if(!l){let i=ta(th,t,e);null==C||C(tu(th)),tf(i.values),t_(i.value)}},onFocus:u,onBlur:f,handleRender:N,activeHandleRender:U,onChangeComplete:td,onDelete:J?t=>{if(l||!J||th.length<=Z)return;let e=[...th];e.splice(t,1),null==C||C(tu(e)),tf(e);let i=Math.max(0,t-1);V.current.hideHelp(),V.current.focus(i)}:void 0}),B.createElement(nn,{prefixCls:i,marks:ts,onClick:tb})))}),nu={track:{height:8,background:"#03fccf"},handle:{width:20,height:20,marginTop:-6,borderColor:"#03fccf",background:"rgb(5, 69, 76)",opacity:1},rail:{height:8,border:"1px solid #555",background:"rgba(255, 255, 255, 0.3)"}};function nf(t){return(0,I.jsx)(nh,{...t,styles:{...nu,...t.styles}})}let nd=t.i(29947).default,{materials:ng}=nd;function np(){var t;let e=(0,B.useRef)(null),i=(0,B.useRef)(null),[n,r]=(0,B.useState)("vl2"),{activeCanvas:s,backgroundColor:o,setBackgroundColor:a,selectedObjects:l,lockedObjects:c,lockSelection:h,unlockSelection:u,bringForward:f,sendBackward:d,duplicate:g,deleteSelection:p,undo:m,redo:y,canUndo:b,canRedo:x,copyToMetallic:_,brushColor:C,setBrushColor:S,brushSize:w,setBrushSize:T,hueRotate:O,setHueRotate:k,saturation:E,setSaturation:j,brightness:M,setBrightness:P,contrast:A,setContrast:D,opacity:F,setOpacity:R,layerMode:L,setLayerMode:U,activeCanvasType:H,addImages:z,exportSkin:Y,selectedExportMaterials:G,setSelectedExportMaterials:V}=X(),{actualModel:q}=iY(),K=ng[q],{canvas:Q,isDrawingMode:J,setDrawingMode:$}=W(s),[Z,tt]=(0,B.useState)(!1),te=Z?"⌘":"Ctrl ",[ti,tn]=(0,B.useState)(!1),{refs:tr,floatingStyles:ts,context:to}=iO({open:ti,onOpenChange:tn,placement:"bottom-end",middleware:[ee(),et(10)],whileElementsMounted:t5}),ta=i_(to),tl=iT(to),tc=iM(to);(0,B.useEffect)(()=>{ti&&$(!0)},[ti,$]);let{getReferenceProps:th,getFloatingProps:tu}=iE([ta,tl,tc]),[tf,td]=(0,B.useState)(!1),{refs:tg,floatingStyles:tp,context:tv}=iO({open:tf,onOpenChange:td,placement:"bottom-end",middleware:[ee(),et(10)],whileElementsMounted:t5}),tm=i_(tv),{getReferenceProps:ty,getFloatingProps:tb}=iE([tm,iT(tv),iM(tv)]),[tx,t_]=(0,B.useState)(!1),{refs:tC,floatingStyles:tS,context:tw}=iO({open:tx,onOpenChange:t_,placement:"bottom-end",middleware:[ee(),et(10)],whileElementsMounted:t5}),tT=i_(tw),{getReferenceProps:tO,getFloatingProps:tk}=iE([tT,iT(tw),iM(tw)]),tE=!!l.length&&l.every(t=>c.has(t)),tj=l.length>0,tM=l.filter(t=>t instanceof N.fabric.Image).length>0,tP=t=>{a(t.target.value)};return(0,B.useEffect)(()=>{try{let t=localStorage.getItem("exportFileType");switch(t){case"vl2":case"png":r(t)}}catch(t){}},[]),(0,B.useEffect)(()=>{navigator.platform&&navigator.platform.startsWith("Mac")?tt(!0):navigator.userAgent.match(/\(Macintosh;/)&&tt(!0)},[]),(0,I.jsxs)("div",{className:"CanvasTools",children:[(0,I.jsxs)("div",{className:"CanvasBackgroundColor",children:[(0,I.jsx)("input",{className:"ColorSwatch",type:"radio",name:"backgroundColor",id:"canvasBackgroundColorBlack",value:"black",checked:"black"===o,onChange:tP}),(0,I.jsx)("label",{htmlFor:"canvasBackgroundColorBlack",children:(0,I.jsx)("span",{className:"HiddenLabel",children:"Black"})}),(0,I.jsx)("input",{className:"ColorSwatch",type:"radio",name:"backgroundColor",id:"canvasBackgroundColorMagenta",value:"magenta",checked:"magenta"===o,onChange:tP}),(0,I.jsx)("label",{htmlFor:"canvasBackgroundColorMagenta",children:(0,I.jsx)("span",{className:"HiddenLabel",children:"Magenta"})}),(0,I.jsx)("input",{className:"ColorSwatch",type:"radio",name:"backgroundColor",id:"canvasBackgroundColorWhite",value:"white",checked:"white"===o,onChange:tP}),(0,I.jsx)("label",{htmlFor:"canvasBackgroundColorWhite",children:(0,I.jsx)("span",{className:"HiddenLabel",children:"White"})})]}),(0,I.jsxs)("div",{className:"Buttons",children:["metallic"===H?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"ButtonGroup",children:[(0,I.jsx)("button",{className:"ButtonGroup",type:"button","data-active":J?void 0:"","aria-label":"Select Mode",title:"Select Mode (S)",onClick:()=>{$(!1)},children:(0,I.jsx)(iR,{})}),(0,I.jsx)("button",{className:"ButtonGroup",type:"button","data-active":J?"":void 0,"aria-label":"Paint Mode",title:"Paint Mode (P)",ref:tr.setReference,...th(),children:(0,I.jsx)(iL,{})})]}),ti?(0,I.jsx)(ib,{context:to,modal:!1,children:(0,I.jsx)("div",{className:"BrushToolsPopup",ref:tr.setFloating,style:ts,...tu(),children:(0,I.jsxs)("div",{className:"Fields",children:[(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsx)("label",{children:"Metallic Amount"}),(0,I.jsx)("div",{className:"SliderContainer",children:(0,I.jsx)(nf,{min:0,max:255,value:C,onChange:t=>{Array.isArray(t)&&(t=t[0]),S(t)},styles:{track:{display:"none"},handle:{width:20,height:20,marginTop:-6,borderColor:"rgb(20, 105, 241)",background:"rgb(".concat(C,", ").concat(C,", ").concat(C,")"),opacity:1},rail:{height:8,border:"1px solid #555",background:"linear-gradient(to right, black 0%, white 100%)"}}})})]}),(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsx)("label",{children:"Brush Size"}),(0,I.jsx)("div",{className:"SliderContainer",children:(0,I.jsx)(nf,{min:1,max:50,value:w,onChange:t=>{Array.isArray(t)&&(t=t[0]),T(t)}})})]})]})})}):null]}):null,(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("input",{ref:i,onChange:async t=>{z([await new Promise((e,i)=>{var n;let r=null==(n=t.target.files)?void 0:n[0];if(r){let t=new FileReader;t.addEventListener("load",t=>{var i;e(null==(i=t.target)?void 0:i.result)}),t.readAsDataURL(r)}else i(Error("No input file provided."))})])},type:"file",accept:".png, image/png",hidden:!0}),(0,I.jsx)("button",{type:"button","aria-label":"Add Image",title:"Add Image",onClick:()=>{i.current&&i.current.click()},children:(0,I.jsx)(iX,{style:{fontSize:14}})}),(0,I.jsx)("button",{type:"button","data-active":tf?"":void 0,"aria-label":"Filters",title:"Filters",disabled:tj&&!tM,ref:tg.setReference,...ty(),children:(0,I.jsx)(iW,{})}),tf?(0,I.jsx)(ib,{context:tv,modal:!1,children:(0,I.jsx)("div",{className:"BrushToolsPopup",ref:tg.setFloating,style:tp,...tb(),children:(0,I.jsxs)("div",{className:"Fields",children:[(0,I.jsxs)("div",{className:"Field ApplyTo",children:[(0,I.jsx)("label",{children:"Layer:"}),(0,I.jsx)("ul",{children:l.length?(0,I.jsxs)("li",{children:[(0,I.jsx)("input",{type:"radio",name:"FilterLayer",value:"SelectedLayer",id:"FilterLayer-SelectedLayer",checked:"SelectedLayer"===L,onChange:()=>{U("SelectedLayer")}}),(0,I.jsxs)("label",{htmlFor:"FilterLayer-SelectedLayer",children:["selected (",l.length.toLocaleString(),")"]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("li",{children:[(0,I.jsx)("input",{type:"radio",name:"FilterLayer",value:"BaseLayer",id:"FilterLayer-BaseLayer",checked:"BaseLayer"===L,onChange:()=>{U("BaseLayer")}})," ",(0,I.jsx)("label",{htmlFor:"FilterLayer-BaseLayer",children:"base"})]}),(0,I.jsxs)("li",{children:[(0,I.jsx)("input",{type:"radio",name:"FilterLayer",value:"AllLayers",id:"FilterLayer-AllLayers",checked:"AllLayers"===L,onChange:()=>{U("AllLayers")}}),(0,I.jsxs)("label",{htmlFor:"FilterLayer-AllLayers",children:["all (",null!=(t=null==Q?void 0:Q._objects.filter(t=>t instanceof N.fabric.Image).length.toLocaleString())?t:0,")"]})]})]})})]}),"color"===H?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsxs)("label",{children:["Hue:"," ",(0,I.jsx)("strong",{children:null==O?"MULTIPLE VALUES":(0,I.jsxs)(I.Fragment,{children:[Math.round(180*O),"°"]})})]}),(0,I.jsx)("div",{className:"SliderContainer",children:(0,I.jsx)(nf,{min:-180,max:180,startPoint:0,value:Math.round((null!=O?O:0)*180),onChange:t=>{Array.isArray(t)&&(t=t[0]),k(t/180)}})})]}),(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsxs)("label",{children:["Saturation:"," ",(0,I.jsx)("strong",{children:null==E?"MULTIPLE VALUES":"".concat(Math.round(100*E+100),"%")})]}),(0,I.jsx)("div",{className:"SliderContainer",children:(0,I.jsx)(nf,{min:-100,max:100,startPoint:0,value:Math.round((null!=E?E:0)*100),onChange:t=>{Array.isArray(t)&&(t=t[0]),j(t/100)}})})]})]}):null,(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsxs)("label",{children:["Brightness:"," ",(0,I.jsx)("strong",{children:null==M?"MULTIPLE VALUES":"".concat(Math.round(100*M+100),"%")})]}),(0,I.jsx)("div",{className:"SliderContainer",children:(0,I.jsx)(nf,{min:-100,max:100,startPoint:0,value:Math.round((null!=M?M:0)*100),onChange:t=>{Array.isArray(t)&&(t=t[0]),P(t/100)}})})]}),(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsxs)("label",{children:["Contrast:"," ",(0,I.jsx)("strong",{children:null==A?"MULTIPLE VALUES":"".concat(Math.round(100*A+100),"%")})]}),(0,I.jsx)("div",{className:"SliderContainer",children:(0,I.jsx)(nf,{min:-100,max:100,startPoint:0,value:Math.round((null!=A?A:0)*100),onChange:t=>{Array.isArray(t)&&(t=t[0]),D(t/100)}})})]}),(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsxs)("label",{children:["Opacity:"," ",(0,I.jsx)("strong",{children:null==A?"MULTIPLE VALUES":"".concat(Math.round((null!=F?F:1)*100),"%")})]}),(0,I.jsx)("div",{className:"SliderContainer",children:(0,I.jsx)(nf,{min:0,max:100,startPoint:0,value:Math.round((null!=F?F:1)*100),onChange:t=>{Array.isArray(t)&&(t=t[0]),R(t/100)}})})]})]})})}):null,(0,I.jsx)("button",{type:"button","aria-label":tE?"Unlock":"Lock",title:tE?"Unlock (L)":"Lock (L)",onClick:tE?u:h,"data-locked":tE?"":void 0,disabled:!tj,children:tE?(0,I.jsx)(iF.FaUnlock,{style:{fontSize:14}}):(0,I.jsx)(iF.FaLock,{style:{fontSize:14}})}),(0,I.jsxs)("div",{className:"ButtonGroup",children:[(0,I.jsx)("button",{type:"button","aria-label":"Bring Forward",title:"Bring Forward (F)",onClick:f,disabled:!tj,children:(0,I.jsx)(iF.FaArrowUp,{})}),(0,I.jsx)("button",{type:"button","aria-label":"Send Backward",title:"Send Backward (B)",onClick:d,disabled:!tj,children:(0,I.jsx)(iF.FaArrowDown,{})})]}),(0,I.jsx)("button",{type:"button","aria-label":"Duplicate",title:"Duplicate (D)",onClick:g,disabled:!tj,children:(0,I.jsx)(iA,{})}),(0,I.jsx)("button",{type:"button","aria-label":"Delete",title:"Delete (Backspace)",onClick:p,disabled:tE||!tj,children:(0,I.jsx)(iF.FaTrashAlt,{})}),(0,I.jsxs)("div",{className:"ButtonGroup",children:[(0,I.jsx)("button",{type:"button","aria-label":"Undo",title:"Undo (".concat(te,"Z)"),onClick:m,disabled:!b,children:(0,I.jsx)(iN,{})}),(0,I.jsx)("button",{type:"button","aria-label":"Redo",title:"Redo (".concat(Z?"".concat("⇧").concat(te,"Z)"):"".concat(te," Y"),")"),onClick:y,disabled:!x,children:(0,I.jsx)(iU,{})})]}),"color"===H?(0,I.jsxs)("button",{type:"button",className:"MetallicButton","aria-label":"Copy to Metallic",title:"Copy to Metallic",onClick:_,children:[(0,I.jsx)(iD,{})," ",(0,I.jsx)("span",{className:"ButtonLabel",children:"Metal"})]}):null]})]}),(0,I.jsxs)("div",{className:"Export",children:[(0,I.jsx)("input",{ref:e,type:"text",name:"CustomSkinName",placeholder:"Skin Name",size:12}),(0,I.jsxs)("button",{className:"ExportOptionsButton",type:"button","data-active":tx?"":void 0,"aria-label":"Export Options",title:"Export Options",ref:tC.setReference,...tO(),children:[".",n,(0,I.jsx)(iF.FaAngleDown,{})]}),tx?(0,I.jsx)(ib,{context:tw,modal:!1,children:(0,I.jsx)("div",{className:"ExportOptionsPopup",ref:tC.setFloating,style:tS,...tk(),children:(0,I.jsxs)("div",{className:"Fields",children:[(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsx)("label",{children:"Export Materials"}),(0,I.jsx)("ul",{className:"ExportOptionsList",children:K.map((t,e)=>t&&!1!==t.selectable&&!t.hidden?(0,I.jsxs)("li",{children:[(0,I.jsx)("input",{id:"MaterialSelect-".concat(t.name),type:"checkbox",checked:!1!==G[e],onChange:t=>{V(i=>{let n=i.slice();return n[e]=t.target.checked,n})}}),(0,I.jsx)("label",{htmlFor:"MaterialSelect-".concat(t.name),children:t.label})]},t.name):null)})]}),(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsx)("label",{htmlFor:"ExportFormat",children:"Export Format"}),(0,I.jsxs)("select",{id:"ExportFormat",value:n,onChange:t=>{r(t.target.value);try{localStorage.setItem("exportFileType",t.target.value)}catch(t){}},children:[(0,I.jsx)("option",{value:"png",children:".png"}),(0,I.jsx)("option",{value:"vl2",children:".vl2"})]})]})]})})}):null,(0,I.jsx)("button",{type:"button",onClick:()=>{Y({name:e.current?e.current.value:"",format:n})},children:"Export"})]})]})}function nv(){return(0,I.jsxs)("footer",{className:"AppFooter",children:[(0,I.jsx)("a",{href:"https://github.com/exogen/t2-model-skinner",className:"IconLink",children:(0,I.jsx)(iF.FaGithub,{size:32})}),(0,I.jsxs)("div",{className:"Sponsor",children:[(0,I.jsx)("a",{href:"https://github.com/sponsors/exogen",target:"_blank",rel:"noreferrer",children:"Support this project"})," ",(0,I.jsx)("span",{className:"Separator",children:"or"})," ",(0,I.jsx)("a",{href:"https://www.buymeacoffee.com/mosswood",target:"_blank",rel:"noreferrer",children:(0,I.jsx)("img",{src:"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png",alt:"Buy Me A Coffee",width:145,height:40})})]})]})}async function nm(t){let e=new Promise(e=>N.fabric.Image.fromURL(t,e,{crossOrigin:"anonymous"}));return await e}var ny=t.i(55519);function nb(){let e=(0,B.useRef)(null),i=(0,B.useRef)(null),n=(0,B.useMemo)(()=>({async combineColorAndAlphaImageUrls(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];let r=i.current;return await (null==r?void 0:r.combineColorAndAlphaImageUrls(...e))},async removeAlphaFromArrayBuffer(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];let r=i.current;return await (null==r?void 0:r.removeAlphaFromArrayBuffer(...e))},async convertArrayBufferAlphaToGrayscale(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];let r=i.current;return await (null==r?void 0:r.convertArrayBufferAlphaToGrayscale(...e))},async convertGrayscaleImageUrlToMetallicRoughness(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];let r=await i.current;return null==r?void 0:r.convertGrayscaleImageUrlToMetallicRoughness(...e)}}),[]);return(0,B.useEffect)(()=>{let n=new Worker(t.r(79702)),r=ny.wrap(n);return e.current=n,i.current=r,()=>{r[ny.releaseProxy](),i.current=null,n.terminate()}},[]),n}function nx(){return{canvasPadding:64,basePath:"/t2-model-skinner"}}var n_=t.i(54826);let{materials:nC}=nd,nS=[512,512];function nw(e){var i,n;let{children:r}=e,{actualModel:s,selectedModelType:o}=iY(),[a,l]=(0,B.useState)(0),[c,h]=(0,B.useState)(0),[u,f]=(0,B.useState)(1),d=nC[s],g=null!=(i=d[a])?i:null,p=null!=(n=g.frameCount)?n:1,m=p>1,[y,b]=(0,B.useState)([]),x=(0,B.useMemo)(()=>{var t;let[e,i]=null!=(t=g.size)?t:nS;return[e*u,i*u]},[g.size,u]),_=0!==g.metallicFactor||1!==g.roughnessFactor,[C,S]=(0,B.useState)("color");_||"metallic"!==C||S("color"),c>=p&&h(0),(0,B.useEffect)(()=>{try{let t=localStorage.getItem("sizeMultiplier");switch(t){case"1":case"2":case"4":f(+t)}}catch(t){}},[]),(0,B.useEffect)(()=>{b(d.map(t=>!!(t&&!1!==t.selectable&&!t.hidden)))},[d]),(0,B.useEffect)(()=>{h(0)},[g]);let[w,T]=(0,B.useState)("magenta"),[O,k]=(0,B.useState)(()=>new Set),[E,j]=(0,B.useState)(200),[M,P]=(0,B.useState)(10),[A,D]=(0,B.useState)(()=>new Map),[F,R]=(0,B.useState)(()=>[]),L=g?"".concat(g.name,":").concat(C,":").concat(c,":").concat(u):null,U=g?"".concat(g.name,":metallic:").concat(c,":").concat(u):null,{canvases:X}=W(),{canvas:z,notifyChange:Y,undo:G,redo:V,canUndo:q,canRedo:K}=W(L),{canvas:Q,setDrawingMode:J}=W(U),{combineColorAndAlphaImageUrls:$}=nb(),{canvasPadding:Z}=nx(),[tt,te]=(0,B.useState)(()=>[]),[ti,tn]=(0,B.useState)("BaseLayer");F.length?"SelectedLayer"!==ti&&tn("SelectedLayer"):"SelectedLayer"===ti&&tn("BaseLayer");let tr=(0,B.useCallback)((t,e)=>{var i,n,r;let s=[],o=new Map(A),a=F;for(let l of("AllLayers"===ti?a=null!=(i=null==z?void 0:z._objects)?i:[]:"BaseLayer"===ti&&(a=null!=(n=null==z?void 0:z._objects.slice(0,1))?n:[]),a))if(l instanceof N.fabric.Image){let i={...null!=(r=A.get(l))?r:{},[t]:e};o.set(l,i),s.push([l,i])}D(o),te(s)},[z,ti,A,F]),ts=t=>{var e,i;let n=+("Opacity"===t),r=F;if("AllLayers"===ti?r=null!=(e=null==z?void 0:z._objects)?e:[]:"BaseLayer"===ti&&(r=null!=(i=null==z?void 0:z._objects.slice(0,1))?i:[]),!(r=r.filter(t=>t instanceof N.fabric.Image)).length)return[n,e=>tr(t,e)];{let e=e=>{var i,s;return null!=(s=(null!=(i=A.get(r[e]))?i:{})[t])?s:n},i=e(0);return r.slice(1).every((t,n)=>e(n+1)===i)?[i,e=>tr(t,e)]:[null,e=>tr(t,e)]}},[to,ta]=ts("HueRotation"),[tl,tc]=ts("Saturation"),[th,tu]=ts("Brightness"),[tf,td]=ts("Contrast"),[tg,tp]=ts("Opacity");(0,B.useEffect)(()=>{if(tt.length){for(let[t,e]of tt)if(t instanceof N.fabric.Image){if(t.filters=[],"metallic"===C){let e=new N.fabric.Image.filters.Grayscale;t.filters.push(e)}for(let i in e){let n=e[i];if(null!=n)switch(i){case"HueRotation":t.filters.push(new N.fabric.Image.filters.HueRotation({rotation:n}));break;case"Saturation":t.filters.push(new N.fabric.Image.filters.Saturation({saturation:n}));break;case"Brightness":t.filters.push(new N.fabric.Image.filters.Brightness({brightness:n}));break;case"Contrast":t.filters.push(new N.fabric.Image.filters.Contrast({contrast:n}));break;case"Opacity":t.opacity=n}}t.applyFilters()}te([]),Y&&Y()}},[tt,C,Y]);let tv=(0,B.useCallback)(()=>{F.length&&k(t=>{let e=new Set(t);for(let t of F)e.add(t),t.lockMovementX=!0,t.lockMovementY=!0,t.lockScalingX=!0,t.lockScalingY=!0,t.lockRotation=!0;return e})},[F]),tm=(0,B.useCallback)(()=>{F.length&&k(t=>{let e=new Set(t);for(let t of F)e.delete(t),t.lockMovementX=!1,t.lockMovementY=!1,t.lockScalingX=!1,t.lockScalingY=!1,t.lockRotation=!1;return e})},[F]),ty=(0,B.useCallback)(async()=>{let t=z.getActiveObject();t&&(z.bringForward(t,!0),Y())},[z,Y]),tb=(0,B.useCallback)(async()=>{let t=z.getActiveObject();if(t){if(z._objects[0]===t||z._objects[1]===t)return;z.sendBackwards(t,!0),Y()}},[z,Y]),tx=(0,B.useCallback)(async t=>{let e;for(let i of t){let t=await nm(i);if(!t.width||!t.height)throw Error("Zero-height image");let n=t.width/x[0],r=t.height/x[1];if(n>1||r>1){let e;t.scaleX=e=n>r?1/n:1/r,t.scaleY=e}if("metallic"===C){t.filters||(t.filters=[]);let e=new N.fabric.Image.filters.Grayscale;t.filters.push(e),t.applyFilters()}Q&&J(!1),z.centerObject(t),z.add(t),e=t}e&&z.setActiveObject(e)},[x,C,Q,z,J]),t_=(0,B.useCallback)(async()=>{let t=z.getActiveObject();if(t){var e,i;let n=await new Promise(e=>t.clone(e));n.set({top:(null!=(e=n.top)?e:0)+20,left:(null!=(i=n.left)?i:0)+20,evented:!0}),"activeSelection"===n.type&&(n.canvas=z,n.forEachObject(t=>{z.add(t)}),n.setCoords()),z.discardActiveObject(),z.add(n),z.setActiveObject(n)}},[z]),tC=(0,B.useCallback)(async()=>{let t=z.getActiveObjects();z.discardActiveObject(),z.remove(...t),z.requestRenderAll()},[z]),tS=(0,B.useCallback)(async()=>{if("color"===C&&Q){let t=z.toDataURL({top:Z,left:Z,width:x[0],height:x[1]}),e=await nm(t);e.filters||(e.filters=[]);let i=new N.fabric.Image.filters.Grayscale;e.filters.push(i),e.applyFilters(),Q.centerObject(e),Q.add(e),Q.setActiveObject(e),J(!1),S("metallic")}},[Q,z,C,Z,J,x]),tw=(0,B.useCallback)(async e=>{let{format:i,name:n=""}=e,{savePngFile:r,saveZipFile:a,createZipFile:l}=await t.A(91135);n=n.trim()||"MyCustomSkin";let c=await Promise.all(d.filter((t,e)=>!1!==y[e]).map(t=>{var e;let i=null!=(e=t.frameCount)?e:1;return Array(i).fill(null).map(async(e,r)=>{var a,l,c,h;let f,d,g=null==(a=X["".concat(t.name,":color:").concat(r,":").concat(u)])?void 0:a.canvas,p=null==(l=X["".concat(t.name,":metallic:").concat(r,":").concat(u)])?void 0:l.canvas,m=null!=(c=t.size)?c:nS,y=[m[0]*u,m[1]*u],b=g.toDataURL({top:Z,left:Z,width:y[0],height:y[1]});if(p){let t=p.toDataURL({top:Z,left:Z,width:y[0],height:y[1]});f=await $({colorImageUrl:b,metallicImageUrl:t})}else f=b;switch(o){case"player":d="".concat(n,".").concat(s,".png");break;case"weapon":case"vehicle":if(t){let e=null!=(h=t.file)?h:t.name;if(i>1){let t=e.match(/^(.+)(\d\d)$/);if(t){let e=t[1];d="".concat(e).concat(r.toString().padStart(2,"0"),".png")}else throw Error("Unexpected animation filename")}else d="".concat(e,".png")}else d="weapon"===o?"weapon_".concat(s,".png"):"".concat(s,".png");break;default:throw Error("Unknown model type")}return{imageUrl:f,filename:d}})}).flat());switch(i){case"png":c.forEach(t=>{let{imageUrl:e,filename:i}=t;r(e,i)});break;case"vl2":{let t=l(await Promise.all(c.map(async t=>({data:await (0,n_.imageUrlToArrayBuffer)(t.imageUrl),name:t.filename})))),e=s.replace(/(?:^([a-z])|_([a-z]))/g,(t,e,i)=>(e||i).toUpperCase()),i="",r=u>1?"-@".concat(u,"x"):"";switch(o){case"player":i="zPlayerSkin-".concat(n).concat(r,".vl2");break;case"weapon":i="zWeapon".concat(e,"-").concat(n).concat(r,".vl2");break;case"vehicle":i="z".concat(e,"-").concat(n).concat(r,".vl2")}await a(t,i)}}},[d,y,X,u,Z,o,$,s]),tT=(0,B.useMemo)(()=>({activeCanvas:L,activeCanvasType:C,setActiveCanvasType:S,backgroundColor:w,setBackgroundColor:T,lockedObjects:O,setLockedObjects:k,brushColor:E,setBrushColor:j,brushSize:M,setBrushSize:P,hueRotate:to,setHueRotate:ta,saturation:tl,setSaturation:tc,brightness:th,setBrightness:tu,contrast:tf,setContrast:td,opacity:tg,setOpacity:tp,layerMode:ti,setLayerMode:tn,selectedObjects:F,lockSelection:tv,unlockSelection:tm,bringForward:ty,sendBackward:tb,addImages:tx,duplicate:t_,deleteSelection:tC,undo:G,redo:V,canUndo:q,canRedo:K,copyToMetallic:tS,exportSkin:tw,selectedMaterialIndex:a,setSelectedMaterialIndex:l,textureSize:x,hasMetallic:_,selectedFrameIndex:c,setSelectedFrameIndex:h,hasAnimation:m,frameCount:p,sizeMultiplier:u,setSizeMultiplier:f,selectedExportMaterials:y,setSelectedExportMaterials:b}),[L,C,w,O,E,M,to,ta,tl,tc,th,tu,tf,td,tg,tp,ti,F,tv,tm,ty,tb,tx,t_,tC,G,V,q,K,tS,tw,a,x,_,c,m,p,u,y]);return(0,B.useEffect)(()=>{if(z){let t=()=>{R(z.getActiveObjects())};return z.on("selection:cleared",t),z.on("selection:updated",t),z.on("selection:created",t),t(),()=>{z.off("selection:cleared",t),z.off("selection:updated",t),z.off("selection:created",t)}}},[z]),(0,B.useEffect)(()=>{Q&&(Q.freeDrawingBrush.width=M)},[Q,M]),(0,B.useEffect)(()=>{Q&&(Q.freeDrawingBrush.color="rgb(".concat(E,", ").concat(E,", ").concat(E,")"))},[Q,E]),(0,I.jsx)(H.Provider,{value:tT,children:r})}function nT(){let{backgroundColor:t,textureSize:e}=X(),{canvasPadding:i}=nx();return e?(0,I.jsx)("div",{className:"CanvasBackdrop",style:{backgroundColor:t,top:i,width:e[0],height:e[1]}}):null}function nO(t){let{children:e}=t,[i,n]=(0,B.useState)({}),r=(0,B.useCallback)((t,e)=>{n(i=>({...i,[t]:e}))},[]),s=(0,B.useCallback)(t=>{n(e=>{let{[t]:i,...n}=e;return n})},[]),o=(0,B.useMemo)(()=>({canvases:i,registerCanvas:r,unregisterCanvas:s}),[i,r,s]);return(0,I.jsx)(U.Provider,{value:o,children:e})}function nk(t){let{children:e}=t,i=(0,B.useRef)(null),{activeCanvas:n,activeCanvasType:r,bringForward:s,sendBackward:o,duplicate:a,deleteSelection:l,addImages:c,undo:h,redo:u}=X(),{canvas:f,notifyChange:d,setDrawingMode:g}=W(n),p=async function(){let{top:t=0,left:e=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(let r of f.getActiveObjects()){var i,n;r.top=(null!=(i=r.top)?i:0)+t,r.left=(null!=(n=r.left)?n:0)+e}d()};return(0,I.jsx)("div",{className:"CanvasInteractions",tabIndex:0,ref:i,onDrop:async t=>{t.preventDefault(),i.current&&i.current.focus();let{items:e}=t.dataTransfer,n=Array.from(e).filter(t=>"file"===t.kind&&t.type.match(/^image\//)),r=await Promise.all(n.map(async t=>{let e=t.getAsFile();if(!e)throw Error("Not a file.");let i=new FileReader;return await new Promise((t,n)=>{i.onload=async e=>{e.target&&"string"==typeof e.target.result?t(e.target.result):n(Error("Failed to load image data."))},i.readAsDataURL(e)})}).filter(Boolean));await c(r)},onKeyDown:async t=>{let e=t.target;if("INPUT"!==e.nodeName&&"TEXTAREA"!==e.nodeName){if(t.ctrlKey||t.metaKey)switch(t.key){case"z":if(t.altKey)return;if(t.shiftKey){t.preventDefault(),u();return}t.preventDefault(),h();return;case"y":if(t.altKey||t.shiftKey)return;t.preventDefault(),u();return}if(!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey)switch(t.key){case"Backspace":case"Delete":t.preventDefault(),await l();break;case"ArrowLeft":t.preventDefault(),await p({left:-1});break;case"ArrowRight":t.preventDefault(),await p({left:1});break;case"ArrowUp":t.preventDefault(),await p({top:-1});break;case"ArrowDown":t.preventDefault(),await p({top:1});break;case"d":t.preventDefault(),await a();break;case"f":t.preventDefault(),await s();break;case"b":t.preventDefault(),await o();break;case"p":"metallic"===r&&(t.preventDefault(),g(!0));break;case"s":"metallic"===r&&(t.preventDefault(),g(!1))}}},children:e})}function nE(){let{activeCanvasType:t,setActiveCanvasType:e,hasMetallic:i,hasAnimation:n,frameCount:r,selectedFrameIndex:s,setSelectedFrameIndex:o,sizeMultiplier:a,setSizeMultiplier:l}=X();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"CanvasToggle",children:[(0,I.jsx)("button",{type:"button","data-selected":"color"===t?"":void 0,onClick:()=>{e("color")},children:"Color"}),i?(0,I.jsx)("button",{type:"button","data-selected":"metallic"===t?"":void 0,onClick:()=>{e("metallic")},children:"Metallic"}):null]}),(0,I.jsxs)("div",{className:"CanvasToggle",style:{display:"none"},children:[(0,I.jsx)("button",{type:"button","data-selected":1===a?"":void 0,onClick:()=>{l(1)},children:"1×"}),(0,I.jsx)("button",{type:"button","data-selected":2===a?"":void 0,onClick:()=>{l(2)},children:"2×"}),(0,I.jsx)("button",{type:"button","data-selected":4===a?"":void 0,onClick:()=>{l(4)},children:"4×"})]}),n?(0,I.jsxs)("div",{className:"FrameSelector",children:[(0,I.jsx)("button",{type:"button",onClick:()=>{o(t=>(r+t-1)%r)},children:(0,I.jsx)(iF.FaChevronLeft,{})}),(0,I.jsxs)("span",{className:"FrameInfo",children:[s+1," / ",r]}),(0,I.jsx)("button",{type:"button",onClick:()=>{o(t=>(t+1)%r)},children:(0,I.jsx)(iF.FaChevronRight,{})})]}):null]})}function nj(t){return(0,iP.GenIcon)({tag:"svg",attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M1 2a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1zM1 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1zM1 12a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1z"},child:[]}]})(t)}var nM=t.i(71315);let nP=nd.materials,nA=/^(\.|__MACOSX)/;async function nD(t){let e=await nM.default.loadAsync(t);return(await Promise.all(Object.entries(e.files).map(async t=>{let[e,i]=t;if(!nA.test(e)&&/\.png$/i.exec(e)){let t=await i.async("base64");return{path:e,imageUrl:"data:image/png;base64,".concat(t)}}}))).filter(t=>!!t)}async function nF(t){return new Promise((e,i)=>{let n=new FileReader;n.addEventListener("load",t=>{var n;"string"==typeof(null==(n=t.target)?void 0:n.result)?e(t.target.result):i()}),n.addEventListener("error",t=>{i()}),n.readAsDataURL(t)})}async function nR(t){return(await Promise.all(Array.from(t).map(async t=>{var e;if(nA.test(t.name))return null;switch((e=t).name.match(/\.png$/i)?"png":e.name.match(/\.zip$/i)?"zip":e.name.match(/\.vl2$/i)?"vl2":void 0){case"zip":case"vl2":{let e=t.name.match(/^(.+)\.(zip|vl2)$/i),i=e?e[1]:t.name;return(await nD(t)).map(e=>({...e,path:"".concat(t.name,"/").concat(e.path),name:i}))}case"png":return{path:t.name,imageUrl:await nF(t),name:null};default:return null}}))).flat().filter(t=>!!t)}async function nL(t){var i=await nR(t);let n=new Map;return i.forEach(t=>{let i=function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e||(e=function(){let t=new Map;for(let e in nP)nP[e].forEach((i,n)=>{let r;if(i.fileSuffix?r=i.fileSuffix:!1!==i.selectable&&!0!==i.hidden&&(i.file||i.name)&&(r=i.file||i.name),r){var s;let o=null!=(s=t.get(r))?s:[];o.push({modelName:e,material:i,index:n}),t.set(r,o)}});return t}());let n=t.split("/").slice(-1)[0],r=n.match(/^(.+)\.(PNG|png)$/);if(r){let s=r[1],o=s.split(".");if(o.length>1){let i=".".concat(o[o.length-1]),a=e.get(i);if(a)return{path:t,basename:n,nameWithoutExtension:s,extension:r[2],skinName:o.slice(0,o.length-1).join("."),models:a}}else{let a=function(t){let i=/^(.+[^\d])(\d{2,})$/.exec(t);if(i){var n;let t=i[1],r=i[2],s=parseInt(r,10),o="".concat(t).concat("0".padStart(r.length,"0"));return(null!=(n=e.get(o))?n:[]).filter(t=>"number"==typeof t.material.frameCount).map(t=>({...t,frameIndex:s}))}return[]}(o[0]);if(a.length)return{path:t,basename:n,nameWithoutExtension:s,extension:r[2],skinName:i,models:a};{let a=e.get(o[0]);if(a)return{path:t,basename:n,nameWithoutExtension:s,extension:r[2],skinName:i,models:a}}}}return null}(t.path,t.name);i&&i.models.forEach(e=>{var r,s,o,a,l;let c=null!=(r=n.get(e.modelName))?r:new Map,h=null!=(s=c.get(i.skinName))?s:{name:i.skinName,isComplete:null,materials:new Map},u=null!=(o=e.material.file)?o:e.material.name,f=null!=(a=h.materials.get(u))?a:[];f[null!=(l=e.frameIndex)?l:0]=t.imageUrl,h.materials.set(u,f),c.set(i.skinName,h),n.set(e.modelName,c)})}),n.forEach((t,e)=>{let i=nP[e].filter(t=>!1!==t.selectable&&!0!==t.hidden&&!0!==t.optional);t.forEach(t=>{t.isComplete=i.every(e=>{var i;return t.materials.has(null!=(i=e.file)?i:e.name)})})}),n}var nI=t.i(15768);let{defaultSkins:nB,modelDefaults:nN}=nd,nU={},nW=new Map;function nH(){var t,e,i,n,r,s;let{selectedModel:o,setSelectedModel:a,selectedModelType:l,setSelectedModelType:c,selectedSkin:h,setSelectedSkin:u,setSelectedSkinType:f,actualModel:d,setSelectedAnimation:g,setAnimationPaused:p,importedSkins:m,addImportedSkins:y}=iY(),{setSelectedMaterialIndex:b}=X(),[x,_]=(0,B.useState)(nU),[C,S]=(0,B.useState)(nU),[w,T]=(0,B.useState)(null),O=(0,B.useRef)(null),[k,E]=(0,nI.default)(),j=Array.from((null!=(s=m.get(d))?s:nW).values()).filter(t=>t.isComplete);E&&(x!==k.customSkins||C!==k.newSkins)&&(_(k.customSkins),S(k.newSkins));let M=null!=h?h:"";return h&&w&&(M="".concat(w,"/").concat(h)),(0,I.jsxs)("div",{className:"Toolbar",children:[(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsx)("label",{htmlFor:"ModelSelect",children:"Model"}),(0,I.jsxs)("select",{id:"ModelSelect",value:o,onChange:t=>{var e,i,n,r;let s=t.target.selectedOptions[0].parentNode,o=t.target.value,l="hfemale"===o?"hmale":o,{modelType:d}=s.dataset;if(!d)throw Error("No data-model-type found");let m=h&&((null==(e=nB[l])?void 0:e.includes(h))||(null==(i=x[l])?void 0:i.includes(h)))||!1,y=!1;h&&"new"===w&&m&&(y=null==(n=C[l])?void 0:n.includes(h)),g(null),p(!1),c(d),a(o),b(0),m||(u(null!=(r=nN[l])?r:null),f("default")),y||T(null)},children:[(0,I.jsxs)("optgroup",{label:"Players","data-model-type":"player",children:[(0,I.jsx)("option",{value:"lmale",children:"Human Male • Light"}),(0,I.jsx)("option",{value:"mmale",children:"Human Male • Medium"}),(0,I.jsx)("option",{value:"hmale",children:"Human Male • Heavy"}),(0,I.jsx)("option",{value:"lfemale",children:"Human Female • Light"}),(0,I.jsx)("option",{value:"mfemale",children:"Human Female • Medium"}),(0,I.jsx)("option",{value:"hfemale",children:"Human Female • Heavy"}),(0,I.jsx)("option",{value:"lbioderm",children:"Bioderm • Light"}),(0,I.jsx)("option",{value:"mbioderm",children:"Bioderm • Medium"}),(0,I.jsx)("option",{value:"hbioderm",children:"Bioderm • Heavy"})]}),(0,I.jsxs)("optgroup",{label:"Weapons","data-model-type":"weapon",children:[(0,I.jsx)("option",{value:"disc",children:"Disc Launcher"}),(0,I.jsx)("option",{value:"chaingun",children:"Chaingun"}),(0,I.jsx)("option",{value:"grenade_launcher",children:"Grenade Launcher"}),(0,I.jsx)("option",{value:"sniper",children:"Laser Rifle"}),(0,I.jsx)("option",{value:"plasmathrower",children:"Plasma Cannon"}),(0,I.jsx)("option",{value:"energy",children:"Blaster"}),(0,I.jsx)("option",{value:"shocklance",children:"Shocklance"}),(0,I.jsx)("option",{value:"elf",children:"ELF Projector"}),(0,I.jsx)("option",{value:"missile",children:"Missile Launcher"}),(0,I.jsx)("option",{value:"mortar",children:"Mortar"}),(0,I.jsx)("option",{value:"repair",children:"Repair Pack"}),(0,I.jsx)("option",{value:"targeting",children:"Targeting Laser"}),(0,I.jsx)("option",{value:"mine",children:"Mine"})]}),(0,I.jsxs)("optgroup",{label:"Vehicles","data-model-type":"vehicle",children:[(0,I.jsx)("option",{value:"vehicle_grav_scout",children:"Wildcat Grav Cycle"}),(0,I.jsx)("option",{value:"vehicle_grav_tank",children:"Beowulf Assault Tank"}),(0,I.jsx)("option",{value:"vehicle_land_mpbbase",children:"Jericho Mobile Point Base"}),(0,I.jsx)("option",{value:"vehicle_air_scout",children:"Shrike Scout Fighter"}),(0,I.jsx)("option",{value:"vehicle_air_bomber",children:"Thundersword Bomber"}),(0,I.jsx)("option",{value:"vehicle_air_hapc",children:"HAVOC Gunship Transport"})]})]})]}),(0,I.jsxs)("div",{className:"Field",children:[(0,I.jsx)("label",{htmlFor:"SkinSelect",children:"Skin"}),(0,I.jsxs)("div",{className:"Buttons",children:[(0,I.jsxs)("select",{id:"SkinSelect",value:M,onChange:t=>{var e,i;let n=t.target.selectedOptions[0].parentNode,r=t.target.value&&null!=(e=n.dataset.skinType)?e:null,s=t.target.value.split("/");u(null!=(i=s.slice(-1)[0])?i:null),f(r),s.length>1?T(s[0]):T(null)},children:[(0,I.jsx)("option",{value:"",children:"Select a skin…"}),"player"===l?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("optgroup",{label:"Default Skins","data-skin-type":"default",children:null==(t=nB[d])?void 0:t.map(t=>(0,I.jsx)("option",{value:t,children:t},t))}),j.length?(0,I.jsx)("optgroup",{label:"Imported Skins","data-skin-type":"import",children:j.map(t=>{var e,i;return(0,I.jsx)("option",{value:"import/".concat(null!=(e=t.name)?e:"__untitled__"),children:t.name||"Untitled Imported Skin"},"import/".concat(null!=(i=t.name)?i:"__untitled__"))})}):null,(null==(e=C[d])?void 0:e.length)?(0,I.jsx)("optgroup",{label:"New Skins ✨","data-skin-type":"custom",children:null==(i=C[d])?void 0:i.map(t=>(0,I.jsxs)("option",{value:"new/".concat(t),children:[t," ✨"]},"new/".concat(t)))}):null,(0,I.jsx)("optgroup",{label:"Custom Skins","data-skin-type":"custom",children:x===nU?(0,I.jsx)("option",{value:"",children:"Loading…"},"loading"):null==(n=x[d])?void 0:n.map(t=>(0,I.jsx)("option",{value:t,children:t},t))})]}):null,"weapon"===l||"vehicle"===l?(0,I.jsxs)(I.Fragment,{children:[nN[d]?(0,I.jsx)("optgroup",{label:"Default Skins","data-skin-type":"default",children:(0,I.jsx)("option",{value:nN[d],children:"Default"})}):null,j.length?(0,I.jsx)("optgroup",{label:"Imported Skins","data-skin-type":"import",children:j.map(t=>{var e,i;return(0,I.jsx)("option",{value:"import/".concat(null!=(e=t.name)?e:"__untitled__"),children:t.name||"Untitled Imported Skin"},"import/".concat(null!=(i=t.name)?i:"__untitled__"))})}):null,(null==(r=x[d])?void 0:r.length)?(0,I.jsx)("optgroup",{label:"Custom Skins","data-skin-type":"custom",children:x[d].map(t=>(0,I.jsx)("option",{value:t,children:t},t))}):null]}):null]}),(0,I.jsx)("button",{type:"button","aria-label":"Load Skin",title:"Load a Skin",onClick:()=>{O.current&&O.current.click()},children:(0,I.jsx)(iF.FaFolderOpen,{style:{fontSize:18}})}),(0,I.jsx)("input",{ref:O,onChange:async t=>{var e,i,n;let r=await nL(null!=(e=t.target.files)?e:[]);y(r);let s=r.get(d);if(s){let t=Array.from(s.values()).filter(t=>t.isComplete);if(t.length){let e=t[0];f("import"),T("import"),u(null!=(i=e.name)?i:"__untitled__"),b(0),g(null);return}}for(let[t,e]of Array.from(r.entries()))for(let i of Array.from(e.values()))if(i.isComplete){a(t),c(function(t){switch(t){case"lmale":case"mmale":case"hmale":case"lfemale":case"mfemale":case"hfemale":case"lbioderm":case"mbioderm":case"hbioderm":return"player";case"disc":case"chaingun":case"grenade_launcher":case"sniper":case"plasmathrower":case"energy":case"shocklance":case"elf":case"missile":case"mortar":case"repair":case"targeting":return"weapon";case"vehicle_grav_scout":case"vehicle_grav_tank":case"vehicle_land_mpbbase":case"vehicle_air_scout":case"vehicle_air_bomber":case"vehicle_air_hapc":return"vehicle";default:throw Error("Unknown model")}}(t)),f("import"),T("import"),u(null!=(n=i.name)?n:"__untitled__"),b(0),g(null);break}},type:"file",accept:".png, image/png, .vl2, .zip, application/zip, application/zip-compressed",multiple:!0,hidden:!0})]})]}),(0,I.jsx)("div",{className:"Field GalleryField",children:(0,I.jsxs)("a",{href:"gallery/",target:"_blank",className:"GalleryLink",title:"Open skin gallery",children:[(0,I.jsx)("span",{className:"FieldLabel",children:"Gallery"}),(0,I.jsx)(nj,{})]})})]})}var nX=t.i(18566);let{materials:nz,modelDefaults:nY,defaultSkins:nG}=nd,nV="https://exogen.github.io/t2-skins/skins",nq=new Map;function nK(t,e){if(e<2)return[t];let i=t.match(/^(.+)(\d\d)$/);if(i){let t=i[1];return Array(e).fill(null).map((e,i)=>"".concat(t).concat(i.toString().padStart(2,"0")))}throw Error("Did not match expected frame format")}function nQ(t){let{basePath:e,actualModel:i,selectedModelType:n,selectedSkin:r,selectedSkinType:s}=t,o=nz[i];if(r&&"import"===s){let t=nq.get(i);if(t){let e="__untitled__"===r?null:r,i=t.get(e);if(i&&i.isComplete)return Object.fromEntries(i.materials)}throw Error("No skin found")}switch(n){case"player":switch(s){case"default":return{base:["".concat(e,"/textures/").concat(r,".").concat(i,".png")]};case"custom":return{base:["".concat(nV,"/").concat(r,".").concat(i,".png")]}}break;case"weapon":case"vehicle":return o.reduce((t,i)=>{if(i){var n,o,a,l,c;let h=null!=(n=i.frameCount)?n:1;switch(s){case"default":!1!==i.hasDefault&&(t[null!=(o=i.file)?o:i.name]=nK(null!=(a=i.file)?a:i.name,h).map(t=>"".concat(e,"/textures/").concat(t,".png")));break;case"custom":t[null!=(l=i.file)?l:i.name]=nK(null!=(c=i.file)?c:i.name,h).map(t=>"".concat(nV,"/").concat(r,"/").concat(t,".png"))}}return t},{})}return{}}function nJ(t){var e,i;let{children:n}=t,r=(0,nX.useRouter)(),s=(0,nX.usePathname)(),o=(0,nX.useSearchParams)(),[a,l]=(0,B.useState)(!1),[c,h]=(0,B.useState)("lmale"),[u,f]=(0,B.useState)("player"),[d,g]=(0,B.useState)("Blood Eagle"),[p,m]=(0,B.useState)("default"),[y,b]=(0,B.useState)(null),[x,_]=(0,B.useState)(!1),[C,S]=(0,B.useState)(!1),{basePath:w}=nx(),T="hfemale"===c?"hmale":c,O="".concat(w,"/").concat(T).concat(y?".anim":"",".glb"),[k,E]=(0,B.useState)(nq),j=(0,B.useCallback)(t=>{let e=new Map(nq.entries());t.forEach((t,i)=>{var n;let r=null!=(n=e.get(i))?n:new Map;t.forEach((t,e)=>{r.set(e,t)}),e.set(i,r)}),E(nq=e)},[]),[M,P]=(0,B.useState)(()=>nQ({basePath:w,actualModel:T,selectedModelType:u,selectedSkin:d,selectedSkinType:p})),A=(0,B.useMemo)(()=>nQ({basePath:w,actualModel:T,selectedModelType:u,selectedSkin:nY[T],selectedSkinType:"default"}),[T,w,u]),D=(0,B.useMemo)(()=>({selectedModel:c,setSelectedModel:h,selectedModelType:u,setSelectedModelType:f,actualModel:T,selectedModelUrl:O,animationPaused:x,setAnimationPaused:_,selectedSkin:d,setSelectedSkin:g,selectedSkinType:p,setSelectedSkinType:m,selectedAnimation:y,setSelectedAnimation:b,skinImageUrls:M,setSkinImageUrls:P,defaultSkinImageUrls:A,slowModeEnabled:C,setSlowModeEnabled:S,importedSkins:k,addImportedSkins:j}),[c,h,u,f,T,O,x,_,d,g,p,m,y,b,M,P,A,C,k,j]);if(!a){let t=o.get("m"),n=o.get("s");if("string"==typeof t){let r=function(t){switch(t){case"lmale":case"mmale":case"hmale":case"lfemale":case"mfemale":case"hfemale":case"lbioderm":case"mbioderm":case"hbioderm":return"player";case"disc":case"chaingun":case"grenade_launcher":case"sniper":case"plasmathrower":case"energy":case"shocklance":case"elf":case"missile":case"mortar":case"repair":case"targeting":case"mine":return"weapon";case"vehicle_grav_scout":case"vehicle_grav_tank":case"vehicle_land_mpbbase":case"vehicle_air_scout":case"vehicle_air_bomber":case"vehicle_air_hapc":return"vehicle";default:return null}}(t);if(r&&(h(t),f(r),"string"==typeof n)){let r=n===nY[e="hfemale"===t?"hmale":t]||(null==(i=nG[e])?void 0:i.includes(n))?"default":"custom";g(n),m(r)}}l(!0)}return(0,B.useEffect)(()=>{if(!d)return;let t=o.get("m"),e=o.get("s");if(t!==c||e!==d){let t=new URLSearchParams(o);t.set("m",c),t.set("s",d);let e="".concat(s,"?").concat(t);r.replace(e,{scroll:!1})}},[s,r,o,c,d]),(0,B.useEffect)(()=>{if(d)try{let t=nQ({basePath:w,actualModel:T,selectedModelType:u,selectedSkin:d,selectedSkinType:p});P(t)}catch(t){m("default"),g(nY[T])}},[T,w,u,d,p]),(0,I.jsx)(iz.Provider,{value:D,children:n})}var n$=t.i(70703);let nZ=B.default.createContext(null);function n0(){let t=(0,B.useContext)(nZ);if(!t)throw Error("No EnvironmentContext.Provider");return t}nZ.displayName="EnvironmentContext";let n1=B.default.createContext(null);function n2(){let t=(0,B.useContext)(n1);if(!t)throw Error("No SkinContext.Provider");return t}n1.displayName="SkinContext";var n5=t.i(63871);function n4(t){let{material:e,materialDef:i,textureType:n,imageUrl:r,frameRef:s,onReady:o}=t,{modelViewer:a}=(0,n5.default)(),{basePath:l}=nx(),{slowModeEnabled:c}=iY();(0,B.useEffect)(()=>{let t,h=!1;return(async()=>{if(!i||i.hidden)if("metallicRoughnessTexture"===n){o&&o();return}else e.setAlphaMode("BLEND"),e.pbrMetallicRoughness.setBaseColorFactor([0,0,0,0]),o&&o();else{let{alphaMode:u,alphaCutoff:f,baseColorFactor:d,emissiveFactor:g,emissiveTexture:p=!1,metallicFactor:m=1,roughnessFactor:y=1,frameCount:b=1,frameTimings:x}=i,_=null!=r?r:Array(b).fill("".concat(l,"/white.png"));if(_.some(t=>!t))return;switch(n){case"baseColorTexture":d&&e.pbrMetallicRoughness.setBaseColorFactor(d),u&&e.setAlphaMode(u),f&&e.setAlphaCutoff(f),g&&e.setEmissiveFactor(g);break;case"metallicRoughnessTexture":e.pbrMetallicRoughness.setMetallicFactor(m),e.pbrMetallicRoughness.setRoughnessFactor(y),0===m&&1===y&&(_=Array(b).fill("".concat(l,"/green.png")))}let C=await Promise.all(_.map(t=>a.createTexture(t)));if(!h){let i="baseColorTexture"===n,r=s.current,a=()=>{let s=C[r.frameIndex];if(e.pbrMetallicRoughness[n].setTexture(s),i&&p&&e.emissiveTexture.setTexture(s),i&&(r.frameProgress+=c?.05:1),b>1){var o;let e=null!=(o=null==x?void 0:x[r.frameIndex])?o:1;i&&r.frameProgress>=e&&(r.frameIndex=(r.frameIndex+1)%b,r.frameProgress=0),t=requestAnimationFrame(a)}};a(0),o&&o()}}})(),()=>{h=!0,null!=t&&cancelAnimationFrame(t)}},[l,a,e,i,n,r,s,c,o])}function n3(t){var e,i;let{material:n,materialDef:r,onReady:s}=t,{getSkinImages:o}=n2(),{colorImageUrl:a,metallicImageUrl:l}=null!=(i=o(null!=(e=null==r?void 0:r.file)?e:n.name))?i:{},c=(0,B.useRef)({frameIndex:0,frameProgress:0});return n4({material:n,materialDef:r,textureType:"baseColorTexture",imageUrl:a,frameRef:c}),n4({material:n,materialDef:r,textureType:"metallicRoughnessTexture",imageUrl:l,frameRef:c}),null}let{materials:n9}=nd;function n6(){let{actualModel:t}=iY(),{model:e}=(0,n5.default)(),i=n9[t];return(0,I.jsx)(I.Fragment,{children:e.materials.map((t,e)=>{let n=i[e];return(0,I.jsx)(n3,{material:t,materialDef:n},t.name)})})}let n8=(0,n$.default)(()=>t.A(22143),{loadableGenerated:{modules:[66641]},ssr:!1}),{cameraOverrides:n7}=nd;function rt(){var t,e,i,n;let{selectedModel:r,selectedModelUrl:s,selectedModelType:o,selectedAnimation:a,animationPaused:l,slowModeEnabled:c}=iY(),{environmentImageUrl:h,showEnvironment:u,exposure:f}=n0();return(0,I.jsx)(n8,{modelUrl:s,environmentImageUrl:h,showEnvironment:u,animationName:a,animationPaused:l,timeScale:c?.05:.5,cameraOrbit:null!=(n=null==(t=n7[r])?void 0:t.orbit)?n:"weapon"===o?"315deg 70deg 105%":void 0,cameraTarget:null==(e=n7[r])?void 0:e.target,fieldOfView:null==(i=n7[r])?void 0:i.fov,exposure:f,children:(0,I.jsx)(n6,{})})}function re(){let{selectedEnvironment:t,setSelectedEnvironment:e}=n0();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("label",{htmlFor:"EnvMapSelect",children:"Environment"}),(0,I.jsxs)("select",{id:"EnvMapSelect",value:null!=t?t:"",onChange:t=>{e(t.target.value||null)},children:[(0,I.jsx)("option",{value:"",children:"Default"}),(0,I.jsx)("option",{value:"clarens_night_02_1k.hdr",children:"Clarens Night"}),(0,I.jsx)("option",{value:"dry_cracked_lake_1k.hdr",children:"Dry Cracked Lake"}),(0,I.jsx)("option",{value:"fouriesburg_mountain_midday_1k.hdr",children:"Fouriesburg Mountain"}),(0,I.jsx)("option",{value:"goegap_1k.hdr",children:"Goegap"}),(0,I.jsx)("option",{value:"hilly_terrain_01_1k.hdr",children:"Hilly Terrain"}),(0,I.jsx)("option",{value:"kloofendal_48d_partly_cloudy_puresky_1k.hdr",children:"Kloofendal Partly Cloudy"}),(0,I.jsx)("option",{value:"kloppenheim_06_puresky_1k.hdr",children:"Kloppenheim"}),(0,I.jsx)("option",{value:"lilienstein_1k.hdr",children:"Lilienstein"}),(0,I.jsx)("option",{value:"spruit_sunrise_1k_HDR.hdr",children:"Spruit Sunrise"}),(0,I.jsx)("option",{value:"umhlanga_sunrise_1k.hdr",children:"Umhlanga Sunrise"})]})]})}function ri(){let{exposure:t,setExposure:e}=n0();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("label",{htmlFor:"EnvExposure",children:(0,I.jsx)(iH,{size:16})}),(0,I.jsx)("input",{"aria-label":"Exposure",id:"EnvExposure",type:"range",min:.2,max:2.2,step:.1,value:t,onChange:t=>{e(parseFloat(t.target.value))}})]})}let{animations:rn,animationLabels:rr,animationLabelOverrides:rs}=nd;function ro(){let{actualModel:t,selectedModelType:e,selectedAnimation:i,setSelectedAnimation:n,animationPaused:r,setAnimationPaused:s,slowModeEnabled:o,setSlowModeEnabled:a}=iY(),l=(0,B.useMemo)(()=>{var i;return[..."player"===e?rn.global:[],...null!=(i=rn[t])?i:[]]},[t,e]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"LabelWithControls",children:[(0,I.jsx)("label",{children:"Animation"}),(0,I.jsxs)("div",{className:"AnimationSpeed",children:[(0,I.jsx)("input",{type:"checkbox",id:"SlowDownCheckbox",checked:o,onChange:t=>{a(t.target.checked)}})," ",(0,I.jsx)("label",{htmlFor:"SlowDownCheckbox",children:"Slow?"})]})]}),(0,I.jsxs)("div",{className:"Buttons",children:[(0,I.jsxs)("select",{value:null!=i?i:"",onChange:t=>{n(t.target.value||null),s(!1)},children:[(0,I.jsx)("option",{value:"",children:"None"}),l.map(e=>{var i,n;let r=null!=(n=null==(i=rs[t])?void 0:i[e])?n:rr[e];return(0,I.jsx)("option",{value:e,children:null!=r?r:e},e)})]}),(0,I.jsx)("button",{type:"button",disabled:!i,onClick:()=>{s(t=>!t)},children:r||!i?(0,I.jsx)(iB,{}):(0,I.jsx)(iI,{})})]})]})}function ra(t){let{children:e}=t,[i,n]=(0,B.useState)(null),[r,s]=(0,B.useState)(!1),[o,a]=(0,B.useState)(1),{basePath:l}=nx(),c=(0,B.useMemo)(()=>{let t=i?"".concat(l,"/").concat(i):null;return{selectedEnvironment:i,setSelectedEnvironment:n,showEnvironment:r,setShowEnvironment:s,exposure:o,setExposure:a,environmentImageUrl:t}},[l,i,r,o]);return(0,I.jsx)(nZ.Provider,{value:c,children:e})}function rl(t){let{children:e}=t,[i,n]=(0,B.useState)({}),r=(0,B.useMemo)(()=>({setSkinImages(t,e){n(i=>({...i,[t]:e}))},setColorImageUrl(t,e,i){n(n=>{var r,s;let o=Array.from(null!=(s=null==(r=n[t])?void 0:r.colorImageUrl)?s:[]);return o[i]=e,{...n,[t]:{...n[t],colorImageUrl:o}}})},setMetallicImageUrl(t,e,i){n(n=>{var r,s;let o=Array.from(null!=(s=null==(r=n[t])?void 0:r.metallicImageUrl)?s:[]);return o[i]=e,{...n,[t]:{...n[t],metallicImageUrl:o}}})}}),[]),s=(0,B.useMemo)(()=>({materialSkins:i,getSkinImages:t=>i[t],getColorImageUrl(t,e){var n;return null==(n=i[t].colorImageUrl)?void 0:n[e]},getMetallicImageUrl(t,e){var n;return null==(n=i[t].metallicImageUrl)?void 0:n[e]},...r}),[i,r]);return(0,I.jsx)(n1.Provider,{value:s,children:e})}let{materials:rc}=nd;function rh(){let{actualModel:t}=iY(),{selectedMaterialIndex:e,setSelectedMaterialIndex:i}=X(),n=rc[t];return(0,I.jsx)("select",{value:e,onChange:t=>{i(parseInt(t.target.value,10))},children:n.map((t,e)=>{var i;return t&&!t.hidden&&!1!==t.selectable?(0,I.jsx)("option",{value:e,children:null!=(i=t.label)?i:t.name},t.name):null})})}function ru(t){let{canvasId:e,onChange:i,baseImageUrl:n,textureSize:r,defaultDrawingMode:s=!1}=t,o=(0,B.useRef)(null),[a,l]=(0,B.useState)(null),{activeCanvas:c}=X(),{canvasPadding:h}=nx(),{registerCanvas:u,unregisterCanvas:f}=W(),[d,g]=(0,B.useState)(s),p=(0,B.useRef)(null),m=(0,B.useRef)(!0),[y,b]=(0,B.useState)(()=>[]),[x,_]=(0,B.useState)(()=>[]),C=y.length>1,S=x.length>0,w=(0,B.useCallback)(t=>{let e=p.current;e&&e(t)},[]),T=(0,B.useCallback)(async()=>{if(a&&y.length>1){let[t,e]=y.slice(-2);m.current=!1,a.renderOnAddRemove=!1,a.clear(),a.loadFromJSON(t,()=>{a.renderAll(),m.current=!0,a.renderOnAddRemove=!0}),b(t=>t.slice(0,-1)),_(t=>[e,...t])}},[a,y]),O=(0,B.useCallback)(()=>{if(a&&x.length>0){let t=x[0];m.current=!1,a.renderOnAddRemove=!1,a.clear(),a.loadFromJSON(t,()=>{a.renderAll(),m.current=!0,a.renderOnAddRemove=!0}),b(e=>[...e,t]),_(t=>t.slice(1))}},[a,x]);(0,B.useEffect)(()=>{p.current=i},[i]);let k=c===e;return(0,B.useEffect)(()=>{let t;N.fabric.Object.prototype.set({transparentCorners:!1,borderColor:"#8afff1",cornerSize:9,cornerStyle:"circle",cornerColor:"#8afff1",cornerStrokeColor:"#1c9f7c",strokeWidth:10,perPixelTargetFind:!0});let e=new N.fabric.Canvas(o.current,{preserveObjectStacking:!0,targetFindTolerance:2}),i=!1,n=()=>{w(e)};return e.on("object:modified",n),e.on("object:added",n),e.on("object:removed",n),e.on("after:render",()=>{!i&&m.current&&(clearTimeout(t),t=setTimeout(()=>{let t=(()=>{i=!0;let t=e.toDatalessJSON(["lockMovementX","lockMovementY","lockRotation","lockScalingX","lockScalingY","selectable","hoverCursor","moveCursor"]);return i=!1,t})();b(e=>{if(0===e.length)return[t];let i=e[e.length-1];return JSON.stringify(t)===JSON.stringify(i)?e:[...e.slice(-5),t]}),_([])},250))}),l(e),()=>{clearTimeout(t),l(null),e.dispose()}},[w]),(0,B.useEffect)(()=>{a&&(a.isDrawingMode=d,d&&(a.discardActiveObject(),a.requestRenderAll()))},[a,d]),(0,B.useEffect)(()=>{a&&k&&a.calcOffset()},[a,k]),(0,B.useEffect)(()=>{if(a)return u(e,{canvas:a,notifyChange:()=>{a.renderAll(),w(a)},undo:T,redo:O,canUndo:C,canRedo:S,isDrawingMode:d,setDrawingMode:g}),()=>{f(e)}},[a,u,f,e,w,d,g,T,O,C,S]),(0,B.useEffect)(()=>{if(a&&r&&(m.current=!1,a.clear(),n)){let t=!1;return(async()=>{let e=await nm(n);if(!t){if(!e.width||!e.height)throw Error("Zero-height image");e.selectable=!1,e.lockMovementX=!0,e.lockMovementY=!0,e.lockScalingX=!0,e.lockScalingY=!0,e.lockRotation=!0,e.hoverCursor="default",e.moveCursor="default";let[t,i]=r,n=e.width===t?1:t/e.width,s=e.height===i?1:i/e.height;(1!==n||1!==s)&&(e.scaleX=n,e.scaleY=s),a.centerObject(e),a.add(e)}m.current=!0,a.requestRenderAll()})(),()=>{t=!0}}},[a,n,r]),(0,I.jsx)("div",{className:"CanvasContainer","data-active":k?"true":"false",children:(0,I.jsx)("canvas",{width:r[0]+2*h,height:r[1]+2*h,ref:o})})}let rf=B.default.createContext(null);function rd(){let t=(0,B.useContext)(rf);if(!t)throw Error("ImageLoaderContext.Provider not found!");return t}rf.displayName="ImageLoaderContext";let rg=[512,512];function rp(t){var e,i,n,r;let{materialDef:s,frameIndex:o=0}=t,{skinImageUrls:a,defaultSkinImageUrls:l}=iY(),c=null==(e=a[null!=(n=s.file)?n:s.name])?void 0:e[o],h=null==(i=l[null!=(r=s.file)?r:s.name])?void 0:i[o],{setColorImageUrl:u}=n2(),{canvasPadding:f}=nx(),[d,g]=(0,B.useState)(null),{removeAlphaFromArrayBuffer:p}=nb(),{loadImage:m}=rd(),{sizeMultiplier:y}=X(),b=(0,B.useMemo)(()=>{var t;let[e,i]=null!=(t=s.size)?t:rg;return[e*y,i*y]},[s.size,y]),x=(0,B.useCallback)(async t=>{var e;let i=t.toDataURL({top:f,left:f,width:b[0],height:b[1]});u(null!=(e=s.file)?e:s.name,i,o)},[b,f,u,s,o]);(0,B.useEffect)(()=>{if(c){let t=!1;return(async()=>{let e;try{e=await m(c)}catch(t){if(!1===s.hasDefault)return;e=await m(h)}let i=await p(e);t||g(i)})(),()=>{t=!0}}g(null)},[s,c,h,p,m]);let _="".concat(s.name,":color:").concat(o,":").concat(y);return b?(0,I.jsx)(ru,{canvasId:_,canvasType:"color",onChange:x,baseImageUrl:d,textureSize:b},_):null}let rv=[512,512];function rm(t){var e,i,n,r;let{materialDef:s,frameIndex:o=0}=t,{skinImageUrls:a,defaultSkinImageUrls:l}=iY(),c=null==(e=a[null!=(n=s.file)?n:s.name])?void 0:e[o],h=null==(i=l[null!=(r=s.file)?r:s.name])?void 0:i[o],{setMetallicImageUrl:u}=n2(),{canvasPadding:f}=nx(),[d,g]=(0,B.useState)(null),p=(0,B.useRef)(0),{convertGrayscaleImageUrlToMetallicRoughness:m,convertArrayBufferAlphaToGrayscale:y}=nb(),{loadImage:b}=rd(),{sizeMultiplier:x}=X(),_=(0,B.useMemo)(()=>{var t;let[e,i]=null!=(t=s.size)?t:rv;return[e*x,i*x]},[s.size,x]),C=(0,B.useCallback)(async t=>{let e;p.current+=1;let i=t.toDataURL({top:f,left:f,width:_[0],height:_[1]});try{e=await m(i)}finally{p.current-=1}if(0===p.current){var n;u(null!=(n=s.file)?n:s.name,e,o)}},[_,f,u,m,s,o]);(0,B.useEffect)(()=>{if(c){let t=!1;return(async()=>{let e;try{e=await b(c)}catch(t){if(!1===s.hasDefault)return;e=await b(h)}let i=await y(e);t||g(i)})(),()=>{t=!0}}g(null)},[s,c,h,_,y,b]);let S="".concat(s.name,":metallic:").concat(o,":").concat(x);return _?(0,I.jsx)(ru,{canvasId:S,canvasType:"metallic",onChange:C,baseImageUrl:d,textureSize:_,defaultDrawingMode:!0},S):null}let{materials:ry}=nd;function rb(){let{actualModel:t}=iY(),e=ry[t];return(0,I.jsx)(I.Fragment,{children:e.map(e=>{var i;if(!e)return null;let n=0!==e.metallicFactor||1!==e.roughnessFactor,r=Array(null!=(i=e.frameCount)?i:1).fill(null);return(0,I.jsxs)(B.default.Fragment,{children:[r.map((t,i)=>(0,I.jsx)(rp,{materialDef:e,frameIndex:i},"color:".concat(i))),n?r.map((t,i)=>(0,I.jsx)(rm,{materialDef:e,frameIndex:i},"metallic:".concat(i))):null]},"".concat(t,"-").concat(e.name))})})}var rx=B.createContext(void 0),r_=t=>{let{client:e,children:i}=t;return B.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,I.jsx)(rx.Provider,{value:e,children:i})};function rC(t){let{children:e}=t,i=(t=>{let e=B.useContext(rx);if(t)return t;if(!e)throw Error("No QueryClient set, use QueryClientProvider to set one");return e})(),n=(0,B.useMemo)(()=>({loadImage:async t=>t.startsWith("data:")?(0,n_.imageUrlToArrayBuffer)(t):await i.fetchQuery({queryKey:[t]})}),[i]);return(0,I.jsx)(rf.Provider,{value:n,children:e})}function rS(t,e,i){if(!e.has(t))throw TypeError("attempted to "+i+" private field on non-instance");return e.get(t)}function rw(t,e){var i=rS(t,e,"get");return i.get?i.get.call(t):i.value}function rT(t,e){if(e.has(t))throw TypeError("Cannot initialize the same private elements twice on an object")}function rO(t,e,i){rT(t,e),e.set(t,i)}function rk(t,e,i){var n=rS(t,e,"set");if(n.set)n.set.call(t,i);else{if(!n.writable)throw TypeError("attempted to set read only private field");n.value=i}return i}function rE(t,e){var i=rS(t,e,"update");if(i.set){if(!i.get)throw TypeError("attempted to read set only private field");return"__destrWrapper"in i||(i.__destrWrapper={set value(v){i.set.call(t,v)},get value(){return i.get.call(t)}}),i.__destrWrapper}if(!i.writable)throw TypeError("attempted to set read only private field");return i}var rj={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},rM=new(i=new WeakMap,n=new WeakMap,class{setTimeoutProvider(t){rk(this,i,t)}setTimeout(t,e){return rw(this,i).setTimeout(t,e)}clearTimeout(t){rw(this,i).clearTimeout(t)}setInterval(t,e){return rw(this,i).setInterval(t,e)}clearInterval(t){rw(this,i).clearInterval(t)}constructor(){rO(this,i,{writable:!0,value:rj}),rO(this,n,{writable:!0,value:!1})}}),rP="undefined"==typeof window||"Deno"in globalThis;function rA(){}function rD(t,e){return"function"==typeof t?t(e):t}function rF(t,e){let{type:i="all",exact:n,fetchStatus:r,predicate:s,queryKey:o,stale:a}=t;if(o){if(n){if(e.queryHash!==rL(o,e.options))return!1}else if(!rB(e.queryKey,o))return!1}if("all"!==i){let t=e.isActive();if("active"===i&&!t||"inactive"===i&&t)return!1}return("boolean"!=typeof a||e.isStale()===a)&&(!r||r===e.state.fetchStatus)&&(!s||!!s(e))}function rR(t,e){let{exact:i,status:n,predicate:r,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(i){if(rI(e.options.mutationKey)!==rI(s))return!1}else if(!rB(e.options.mutationKey,s))return!1}return(!n||e.state.status===n)&&(!r||!!r(e))}function rL(t,e){return((null==e?void 0:e.queryKeyHashFn)||rI)(t)}function rI(t){return JSON.stringify(t,(t,e)=>rW(e)?Object.keys(e).sort().reduce((t,i)=>(t[i]=e[i],t),{}):e)}function rB(t,e){return t===e||typeof t==typeof e&&!!t&&!!e&&"object"==typeof t&&"object"==typeof e&&Object.keys(e).every(i=>rB(t[i],e[i]))}var rN=Object.prototype.hasOwnProperty;function rU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function rW(t){if(!rH(t))return!1;let e=t.constructor;if(void 0===e)return!0;let i=e.prototype;return!!rH(i)&&!!i.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(t)===Object.prototype}function rH(t){return"[object Object]"===Object.prototype.toString.call(t)}function rX(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=[...t,e];return i&&n.length>i?n.slice(1):n}function rz(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=[e,...t];return i&&n.length>i?n.slice(0,-1):n}var rY=Symbol();function rG(t,e){return!t.queryFn&&(null==e?void 0:e.initialPromise)?()=>e.initialPromise:t.queryFn&&t.queryFn!==rY?t.queryFn:()=>Promise.reject(Error("Missing queryFn: '".concat(t.queryHash,"'")))}function rV(t,e,i){if(!e.has(t))throw TypeError("attempted to get private field on non-instance");return i}function rq(t,e){rT(t,e),e.add(t)}var rK=function(t){setTimeout(t,0)},rQ=function(){let t=[],e=0,i=t=>{t()},n=t=>{t()},r=rK,s=n=>{e?t.push(n):r(()=>{i(n)})};return{batch:s=>{let o;e++;try{o=s()}finally{--e||(()=>{let e=t;t=[],e.length&&r(()=>{n(()=>{e.forEach(t=>{i(t)})})})})()}return o},batchCalls:t=>function(){for(var e=arguments.length,i=Array(e),n=0;n<e;n++)i[n]=arguments[n];s(()=>{t(...i)})},schedule:s,setNotifyFunction:t=>{i=t},setBatchNotifyFunction:t=>{n=t},setScheduler:t=>{r=t}}}(),rJ=class{subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}},r$=new(r=new WeakMap,s=new WeakMap,o=new WeakMap,class extends rJ{onSubscribe(){rw(this,s)||this.setEventListener(rw(this,o))}onUnsubscribe(){var t;this.hasListeners()||(null==(t=rw(this,s))||t.call(this),rk(this,s,void 0))}setEventListener(t){var e;rk(this,o,t),null==(e=rw(this,s))||e.call(this),rk(this,s,t(t=>{"boolean"==typeof t?this.setFocused(t):this.onFocus()}))}setFocused(t){rw(this,r)!==t&&(rk(this,r,t),this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){var t;return"boolean"==typeof rw(this,r)?rw(this,r):(null==(t=globalThis.document)?void 0:t.visibilityState)!=="hidden"}constructor(){super(),rO(this,r,{writable:!0,value:void 0}),rO(this,s,{writable:!0,value:void 0}),rO(this,o,{writable:!0,value:void 0}),rk(this,o,t=>{if(!rP&&window.addEventListener){let e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}})}}),rZ=new(a=new WeakMap,l=new WeakMap,c=new WeakMap,class extends rJ{onSubscribe(){rw(this,l)||this.setEventListener(rw(this,c))}onUnsubscribe(){var t;this.hasListeners()||(null==(t=rw(this,l))||t.call(this),rk(this,l,void 0))}setEventListener(t){var e;rk(this,c,t),null==(e=rw(this,l))||e.call(this),rk(this,l,t(this.setOnline.bind(this)))}setOnline(t){rw(this,a)!==t&&(rk(this,a,t),this.listeners.forEach(e=>{e(t)}))}isOnline(){return rw(this,a)}constructor(){super(),rO(this,a,{writable:!0,value:!0}),rO(this,l,{writable:!0,value:void 0}),rO(this,c,{writable:!0,value:void 0}),rk(this,c,t=>{if(!rP&&window.addEventListener){let e=()=>t(!0),i=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",i)}}})}});function r0(t){return Math.min(1e3*2**t,3e4)}function r1(t){return(null!=t?t:"online")!=="online"||rZ.isOnline()}var r2=class extends Error{constructor(t){super("CancelledError"),this.revert=null==t?void 0:t.revert,this.silent=null==t?void 0:t.silent}};function r5(t){let e,i=!1,n=0,r=function(){let t,e,i=new Promise((i,n)=>{t=i,e=n});function n(t){Object.assign(i,t),delete i.resolve,delete i.reject}return i.status="pending",i.catch(()=>{}),i.resolve=e=>{n({status:"fulfilled",value:e}),t(e)},i.reject=t=>{n({status:"rejected",reason:t}),e(t)},i}(),s=()=>r$.isFocused()&&("always"===t.networkMode||rZ.isOnline())&&t.canRun(),o=()=>r1(t.networkMode)&&t.canRun(),a=t=>{"pending"===r.status&&(null==e||e(),r.resolve(t))},l=t=>{"pending"===r.status&&(null==e||e(),r.reject(t))},c=()=>new Promise(i=>{var n;e=t=>{("pending"!==r.status||s())&&i(t)},null==(n=t.onPause)||n.call(t)}).then(()=>{if(e=void 0,"pending"===r.status){var i;null==(i=t.onContinue)||i.call(t)}}),h=()=>{let e;if("pending"!==r.status)return;let o=0===n?t.initialPromise:void 0;try{e=null!=o?o:t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(a).catch(e=>{var o,a,u;if("pending"!==r.status)return;let f=null!=(a=t.retry)?a:3*!rP,d=null!=(u=t.retryDelay)?u:r0,g="function"==typeof d?d(n,e):d,p=!0===f||"number"==typeof f&&n<f||"function"==typeof f&&f(n,e);if(i||!p)return void l(e);n++,null==(o=t.onFail)||o.call(t,n,e),new Promise(t=>{rM.setTimeout(t,g)}).then(()=>s()?void 0:c()).then(()=>{i?l(e):h()})})};return{promise:r,status:()=>r.status,cancel:e=>{if("pending"===r.status){var i;let n=new r2(e);l(n),null==(i=t.onCancel)||i.call(t,n)}},continue:()=>(null==e||e(),r),cancelRetry:()=>{i=!0},continueRetry:()=>{i=!1},canStart:o,start:()=>(o()?h():c().then(h),r)}}var r4=(h=new WeakMap,class{destroy(){this.clearGcTimeout()}scheduleGc(){var t;this.clearGcTimeout(),"number"==typeof(t=this.gcTime)&&t>=0&&t!==1/0&&rk(this,h,rM.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,null!=t?t:rP?1/0:3e5)}clearGcTimeout(){rw(this,h)&&(rM.clearTimeout(rw(this,h)),rk(this,h,void 0))}constructor(){rO(this,h,{writable:!0,value:void 0})}}),r3=(u=new WeakMap,f=new WeakMap,d=new WeakMap,g=new WeakMap,p=new WeakMap,m=new WeakMap,y=new WeakMap,b=new WeakSet,class extends r4{get meta(){return this.options.meta}get promise(){var t;return null==(t=rw(this,p))?void 0:t.promise}setOptions(t){if(this.options={...rw(this,m),...t},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let t=r9(this.options);void 0!==t.data&&(this.setData(t.data,{updatedAt:t.dataUpdatedAt,manual:!0}),rk(this,u,t))}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||rw(this,d).remove(this)}setData(t,e){var i,n;let r=(i=this.state.data,"function"==typeof(n=this.options).structuralSharing?n.structuralSharing(i,t):!1!==n.structuralSharing?function t(e,i){if(e===i)return e;let n=rU(e)&&rU(i);if(!n&&!(rW(e)&&rW(i)))return i;let r=(n?e:Object.keys(e)).length,s=n?i:Object.keys(i),o=s.length,a=n?Array(o):{},l=0;for(let c=0;c<o;c++){let o=n?c:s[c],h=e[o],u=i[o];if(h===u){a[o]=h,(n?c<r:rN.call(e,o))&&l++;continue}if(null===h||null===u||"object"!=typeof h||"object"!=typeof u){a[o]=u;continue}let f=t(h,u);a[o]=f,f===h&&l++}return r===o&&l===r?e:a}(i,t):t);return rV(this,b,r6).call(this,{data:r,type:"success",dataUpdatedAt:null==e?void 0:e.updatedAt,manual:null==e?void 0:e.manual}),r}setState(t,e){rV(this,b,r6).call(this,{type:"setState",state:t,setStateOptions:e})}cancel(t){var e,i;let n=null==(e=rw(this,p))?void 0:e.promise;return null==(i=rw(this,p))||i.cancel(t),n?n.then(rA).catch(rA):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(rw(this,u))}isActive(){return this.observers.some(t=>{var e;return!1!==(e=t.options.enabled,"function"==typeof e?e(this):e)})}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===rY||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(t=>"static"===rD(t.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return void 0===this.state.data||"static"!==t&&(!!this.state.isInvalidated||!Math.max(this.state.dataUpdatedAt+(t||0)-Date.now(),0))}onFocus(){var t;let e=this.observers.find(t=>t.shouldFetchOnWindowFocus());null==e||e.refetch({cancelRefetch:!1}),null==(t=rw(this,p))||t.continue()}onOnline(){var t;let e=this.observers.find(t=>t.shouldFetchOnReconnect());null==e||e.refetch({cancelRefetch:!1}),null==(t=rw(this,p))||t.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),rw(this,d).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(rw(this,p)&&(rw(this,y)?rw(this,p).cancel({revert:!0}):rw(this,p).cancelRetry()),this.scheduleGc()),rw(this,d).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||rV(this,b,r6).call(this,{type:"invalidate"})}async fetch(t,e){var i,n,r,s,o,a,l,c,h,u,m,x;if("idle"!==this.state.fetchStatus&&(null==(i=rw(this,p))?void 0:i.status())!=="rejected"){if(void 0!==this.state.data&&(null==e?void 0:e.cancelRefetch))this.cancel({silent:!0});else if(rw(this,p))return rw(this,p).continueRetry(),rw(this,p).promise}if(t&&this.setOptions(t),!this.options.queryFn){let t=this.observers.find(t=>t.options.queryFn);t&&this.setOptions(t.options)}let _=new AbortController,C=t=>{Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(rk(this,y,!0),_.signal)})},S=()=>{let t=rG(this.options,e),i=(()=>{let t={client:rw(this,g),queryKey:this.queryKey,meta:this.meta};return C(t),t})();return(rk(this,y,!1),this.options.persister)?this.options.persister(t,i,this):t(i)},w=(()=>{let t={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:rw(this,g),state:this.state,fetchFn:S};return C(t),t})();null==(n=this.options.behavior)||n.onFetch(w,this),rk(this,f,this.state),("idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(r=w.fetchOptions)?void 0:r.meta))&&rV(this,b,r6).call(this,{type:"fetch",meta:null==(s=w.fetchOptions)?void 0:s.meta}),rk(this,p,r5({initialPromise:null==e?void 0:e.initialPromise,fn:w.fetchFn,onCancel:t=>{t instanceof r2&&t.revert&&this.setState({...rw(this,f),fetchStatus:"idle"}),_.abort()},onFail:(t,e)=>{rV(this,b,r6).call(this,{type:"failed",failureCount:t,error:e})},onPause:()=>{rV(this,b,r6).call(this,{type:"pause"})},onContinue:()=>{rV(this,b,r6).call(this,{type:"continue"})},retry:w.options.retry,retryDelay:w.options.retryDelay,networkMode:w.options.networkMode,canRun:()=>!0}));try{let t=await rw(this,p).start();if(void 0===t)throw Error("".concat(this.queryHash," data is undefined"));return this.setData(t),null==(o=(a=rw(this,d).config).onSuccess)||o.call(a,t,this),null==(l=(c=rw(this,d).config).onSettled)||l.call(c,t,this.state.error,this),t}catch(t){if(t instanceof r2){if(t.silent)return rw(this,p).promise;else if(t.revert){if(void 0===this.state.data)throw t;return this.state.data}}throw rV(this,b,r6).call(this,{type:"error",error:t}),null==(h=(u=rw(this,d).config).onError)||h.call(u,t,this),null==(m=(x=rw(this,d).config).onSettled)||m.call(x,this.state.data,t,this),t}finally{this.scheduleGc()}}constructor(t){var e;super(),rq(this,b),rO(this,u,{writable:!0,value:void 0}),rO(this,f,{writable:!0,value:void 0}),rO(this,d,{writable:!0,value:void 0}),rO(this,g,{writable:!0,value:void 0}),rO(this,p,{writable:!0,value:void 0}),rO(this,m,{writable:!0,value:void 0}),rO(this,y,{writable:!0,value:void 0}),rk(this,y,!1),rk(this,m,t.defaultOptions),this.setOptions(t.options),this.observers=[],rk(this,g,t.client),rk(this,d,rw(this,g).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,rk(this,u,r9(this.options)),this.state=null!=(e=t.state)?e:rw(this,u),this.scheduleGc()}});function r9(t){let e="function"==typeof t.initialData?t.initialData():t.initialData,i=void 0!==e,n=i?"function"==typeof t.initialDataUpdatedAt?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:i?null!=n?n:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:i?"success":"pending",fetchStatus:"idle"}}function r6(t){let e=e=>{var i,n,r;switch(t.type){case"failed":return{...e,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...e,fetchStatus:"paused"};case"continue":return{...e,fetchStatus:"fetching"};case"fetch":return{...e,...(r=e.data,{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:r1(this.options.networkMode)?"fetching":"paused",...void 0===r&&{error:null,status:"pending"}}),fetchMeta:null!=(i=t.meta)?i:null};case"success":let s={...e,data:t.data,dataUpdateCount:e.dataUpdateCount+1,dataUpdatedAt:null!=(n=t.dataUpdatedAt)?n:Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return rk(this,f,t.manual?s:void 0),s;case"error":let o=t.error;return{...e,error:o,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}};this.state=e(this.state),rQ.batch(()=>{this.observers.forEach(t=>{t.onQueryUpdate()}),rw(this,d).notify({query:this,type:"updated",action:t})})}var r8=(x=new WeakMap,class extends rJ{build(t,e,i){var n;let r=e.queryKey,s=null!=(n=e.queryHash)?n:rL(r,e),o=this.get(s);return o||(o=new r3({client:t,queryKey:r,queryHash:s,options:t.defaultQueryOptions(e),state:i,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){rw(this,x).has(t.queryHash)||(rw(this,x).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=rw(this,x).get(t.queryHash);e&&(t.destroy(),e===t&&rw(this,x).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){rQ.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return rw(this,x).get(t)}getAll(){return[...rw(this,x).values()]}find(t){let e={exact:!0,...t};return this.getAll().find(t=>rF(e,t))}findAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.getAll();return Object.keys(t).length>0?e.filter(e=>rF(t,e)):e}notify(t){rQ.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){rQ.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){rQ.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}constructor(t={}){super(),rO(this,x,{writable:!0,value:void 0}),this.config=t,rk(this,x,new Map)}}),r7=(_=new WeakMap,C=new WeakMap,S=new WeakMap,w=new WeakMap,T=new WeakSet,class extends r4{setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){rw(this,C).includes(t)||(rw(this,C).push(t),this.clearGcTimeout(),rw(this,S).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){rk(this,C,rw(this,C).filter(e=>e!==t)),this.scheduleGc(),rw(this,S).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){rw(this,C).length||("pending"===this.state.status?this.scheduleGc():rw(this,S).remove(this))}continue(){var t,e;return null!=(e=null==(t=rw(this,w))?void 0:t.continue())?e:this.execute(this.state.variables)}async execute(t){var e,i,n,r,s,o,a,l,c,h,u,f,d,g,p,m,y,b,x,C,O;let k=()=>{rV(this,T,st).call(this,{type:"continue"})},E={client:rw(this,_),meta:this.options.meta,mutationKey:this.options.mutationKey};rk(this,w,r5({fn:()=>this.options.mutationFn?this.options.mutationFn(t,E):Promise.reject(Error("No mutationFn found")),onFail:(t,e)=>{rV(this,T,st).call(this,{type:"failed",failureCount:t,error:e})},onPause:()=>{rV(this,T,st).call(this,{type:"pause"})},onContinue:k,retry:null!=(e=this.options.retry)?e:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>rw(this,S).canRun(this)}));let j="pending"===this.state.status,M=!rw(this,w).canStart();try{if(j)k();else{rV(this,T,st).call(this,{type:"pending",variables:t,isPaused:M}),await (null==(h=(u=rw(this,S).config).onMutate)?void 0:h.call(u,t,this,E));let e=await (null==(f=(d=this.options).onMutate)?void 0:f.call(d,t,E));e!==this.state.context&&rV(this,T,st).call(this,{type:"pending",context:e,variables:t,isPaused:M})}let e=await rw(this,w).start();return await (null==(i=(n=rw(this,S).config).onSuccess)?void 0:i.call(n,e,t,this.state.context,this,E)),await (null==(r=(s=this.options).onSuccess)?void 0:r.call(s,e,t,this.state.context,E)),await (null==(o=(a=rw(this,S).config).onSettled)?void 0:o.call(a,e,null,this.state.variables,this.state.context,this,E)),await (null==(l=(c=this.options).onSettled)?void 0:l.call(c,e,null,t,this.state.context,E)),rV(this,T,st).call(this,{type:"success",data:e}),e}catch(e){try{throw await (null==(g=(p=rw(this,S).config).onError)?void 0:g.call(p,e,t,this.state.context,this,E)),await (null==(m=(y=this.options).onError)?void 0:m.call(y,e,t,this.state.context,E)),await (null==(b=(x=rw(this,S).config).onSettled)?void 0:b.call(x,void 0,e,this.state.variables,this.state.context,this,E)),await (null==(C=(O=this.options).onSettled)?void 0:C.call(O,void 0,e,t,this.state.context,E)),e}finally{rV(this,T,st).call(this,{type:"error",error:e})}}finally{rw(this,S).runNext(this)}}constructor(t){super(),rq(this,T),rO(this,_,{writable:!0,value:void 0}),rO(this,C,{writable:!0,value:void 0}),rO(this,S,{writable:!0,value:void 0}),rO(this,w,{writable:!0,value:void 0}),rk(this,_,t.client),this.mutationId=t.mutationId,rk(this,S,t.mutationCache),rk(this,C,[]),this.state=t.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(t.options),this.scheduleGc()}});function st(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"pending":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}})(this.state),rQ.batch(()=>{rw(this,C).forEach(e=>{e.onMutationUpdate(t)}),rw(this,S).notify({mutation:this,type:"updated",action:t})})}var se=(O=new WeakMap,k=new WeakMap,E=new WeakMap,class extends rJ{build(t,e,i){let n=new r7({client:t,mutationCache:this,mutationId:++rE(this,E).value,options:t.defaultMutationOptions(e),state:i});return this.add(n),n}add(t){rw(this,O).add(t);let e=si(t);if("string"==typeof e){let i=rw(this,k).get(e);i?i.push(t):rw(this,k).set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(rw(this,O).delete(t)){let e=si(t);if("string"==typeof e){let i=rw(this,k).get(e);if(i)if(i.length>1){let e=i.indexOf(t);-1!==e&&i.splice(e,1)}else i[0]===t&&rw(this,k).delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=si(t);if("string"!=typeof e)return!0;{let i=rw(this,k).get(e),n=null==i?void 0:i.find(t=>"pending"===t.state.status);return!n||n===t}}runNext(t){let e=si(t);if("string"!=typeof e)return Promise.resolve();{var i,n;let r=null==(i=rw(this,k).get(e))?void 0:i.find(e=>e!==t&&e.state.isPaused);return null!=(n=null==r?void 0:r.continue())?n:Promise.resolve()}}clear(){rQ.batch(()=>{rw(this,O).forEach(t=>{this.notify({type:"removed",mutation:t})}),rw(this,O).clear(),rw(this,k).clear()})}getAll(){return Array.from(rw(this,O))}find(t){let e={exact:!0,...t};return this.getAll().find(t=>rR(e,t))}findAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.getAll().filter(e=>rR(t,e))}notify(t){rQ.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(t=>t.state.isPaused);return rQ.batch(()=>Promise.all(t.map(t=>t.continue().catch(rA))))}constructor(t={}){super(),rO(this,O,{writable:!0,value:void 0}),rO(this,k,{writable:!0,value:void 0}),rO(this,E,{writable:!0,value:void 0}),this.config=t,rk(this,O,new Set),rk(this,k,new Map),rk(this,E,0)}});function si(t){var e;return null==(e=t.options.scope)?void 0:e.id}function sn(t){return{onFetch:(e,i)=>{var n,r,s,o,a;let l=e.options,c=null==(s=e.fetchOptions)||null==(r=s.meta)||null==(n=r.fetchMore)?void 0:n.direction,h=(null==(o=e.state.data)?void 0:o.pages)||[],u=(null==(a=e.state.data)?void 0:a.pageParams)||[],f={pages:[],pageParams:[]},d=0,g=async()=>{let i=!1,n=rG(e.options,e.fetchOptions),r=async(t,r,s)=>{if(i)return Promise.reject();if(null==r&&t.pages.length)return Promise.resolve(t);let o=(()=>{let t={client:e.client,queryKey:e.queryKey,pageParam:r,direction:s?"backward":"forward",meta:e.options.meta};return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(e.signal.aborted?i=!0:e.signal.addEventListener("abort",()=>{i=!0}),e.signal)}),t})(),a=await n(o),{maxPages:l}=e.options,c=s?rz:rX;return{pages:c(t.pages,a,l),pageParams:c(t.pageParams,r,l)}};if(c&&h.length){let t="backward"===c,e={pages:h,pageParams:u},i=(t?function(t,e){var i;let{pages:n,pageParams:r}=e;return n.length>0?null==(i=t.getPreviousPageParam)?void 0:i.call(t,n[0],n,r[0],r):void 0}:sr)(l,e);f=await r(e,i,t)}else{let e=null!=t?t:h.length;do{var s;let t=0===d?null!=(s=u[0])?s:l.initialPageParam:sr(l,f);if(d>0&&null==t)break;f=await r(f,t),d++}while(d<e)}return f};e.options.persister?e.fetchFn=()=>{var t,n;return null==(t=(n=e.options).persister)?void 0:t.call(n,g,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},i)}:e.fetchFn=g}}}function sr(t,e){let{pages:i,pageParams:n}=e,r=i.length-1;return i.length>0?t.getNextPageParam(i[r],i,n[r],n):void 0}let ss=new(j=new WeakMap,M=new WeakMap,P=new WeakMap,A=new WeakMap,D=new WeakMap,F=new WeakMap,R=new WeakMap,L=new WeakMap,class{mount(){rE(this,F).value++,1===rw(this,F)&&(rk(this,R,r$.subscribe(async t=>{t&&(await this.resumePausedMutations(),rw(this,j).onFocus())})),rk(this,L,rZ.subscribe(async t=>{t&&(await this.resumePausedMutations(),rw(this,j).onOnline())})))}unmount(){var t,e;rE(this,F).value--,0===rw(this,F)&&(null==(t=rw(this,R))||t.call(this),rk(this,R,void 0),null==(e=rw(this,L))||e.call(this),rk(this,L,void 0))}isFetching(t){return rw(this,j).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return rw(this,M).findAll({...t,status:"pending"}).length}getQueryData(t){var e;let i=this.defaultQueryOptions({queryKey:t});return null==(e=rw(this,j).get(i.queryHash))?void 0:e.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),i=rw(this,j).build(this,e),n=i.state.data;return void 0===n?this.fetchQuery(t):(t.revalidateIfStale&&i.isStaleByTime(rD(e.staleTime,i))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return rw(this,j).findAll(t).map(t=>{let{queryKey:e,state:i}=t;return[e,i.data]})}setQueryData(t,e,i){let n=this.defaultQueryOptions({queryKey:t}),r=rw(this,j).get(n.queryHash),s=null==r?void 0:r.state.data,o="function"==typeof e?e(s):e;if(void 0!==o)return rw(this,j).build(this,n).setData(o,{...i,manual:!0})}setQueriesData(t,e,i){return rQ.batch(()=>rw(this,j).findAll(t).map(t=>{let{queryKey:n}=t;return[n,this.setQueryData(n,e,i)]}))}getQueryState(t){var e;let i=this.defaultQueryOptions({queryKey:t});return null==(e=rw(this,j).get(i.queryHash))?void 0:e.state}removeQueries(t){let e=rw(this,j);rQ.batch(()=>{e.findAll(t).forEach(t=>{e.remove(t)})})}resetQueries(t,e){let i=rw(this,j);return rQ.batch(()=>(i.findAll(t).forEach(t=>{t.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={revert:!0,...e};return Promise.all(rQ.batch(()=>rw(this,j).findAll(t).map(t=>t.cancel(i)))).then(rA).catch(rA)}invalidateQueries(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return rQ.batch(()=>{var i,n;return(rw(this,j).findAll(t).forEach(t=>{t.invalidate()}),(null==t?void 0:t.refetchType)==="none")?Promise.resolve():this.refetchQueries({...t,type:null!=(n=null!=(i=null==t?void 0:t.refetchType)?i:null==t?void 0:t.type)?n:"active"},e)})}refetchQueries(t){var e;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={...i,cancelRefetch:null==(e=i.cancelRefetch)||e};return Promise.all(rQ.batch(()=>rw(this,j).findAll(t).filter(t=>!t.isDisabled()&&!t.isStatic()).map(t=>{let e=t.fetch(void 0,n);return n.throwOnError||(e=e.catch(rA)),"paused"===t.state.fetchStatus?Promise.resolve():e}))).then(rA)}fetchQuery(t){let e=this.defaultQueryOptions(t);void 0===e.retry&&(e.retry=!1);let i=rw(this,j).build(this,e);return i.isStaleByTime(rD(e.staleTime,i))?i.fetch(e):Promise.resolve(i.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(rA).catch(rA)}fetchInfiniteQuery(t){return t.behavior=sn(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(rA).catch(rA)}ensureInfiniteQueryData(t){return t.behavior=sn(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return rZ.isOnline()?rw(this,M).resumePausedMutations():Promise.resolve()}getQueryCache(){return rw(this,j)}getMutationCache(){return rw(this,M)}getDefaultOptions(){return rw(this,P)}setDefaultOptions(t){rk(this,P,t)}setQueryDefaults(t,e){rw(this,A).set(rI(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...rw(this,A).values()],i={};return e.forEach(e=>{rB(t,e.queryKey)&&Object.assign(i,e.defaultOptions)}),i}setMutationDefaults(t,e){rw(this,D).set(rI(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...rw(this,D).values()],i={};return e.forEach(e=>{rB(t,e.mutationKey)&&Object.assign(i,e.defaultOptions)}),i}defaultQueryOptions(t){if(t._defaulted)return t;let e={...rw(this,P).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=rL(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.throwOnError&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===rY&&(e.enabled=!1),e}defaultMutationOptions(t){return(null==t?void 0:t._defaulted)?t:{...rw(this,P).mutations,...(null==t?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){rw(this,j).clear(),rw(this,M).clear()}constructor(t={}){rO(this,j,{writable:!0,value:void 0}),rO(this,M,{writable:!0,value:void 0}),rO(this,P,{writable:!0,value:void 0}),rO(this,A,{writable:!0,value:void 0}),rO(this,D,{writable:!0,value:void 0}),rO(this,F,{writable:!0,value:void 0}),rO(this,R,{writable:!0,value:void 0}),rO(this,L,{writable:!0,value:void 0}),rk(this,j,t.queryCache||new r8),rk(this,M,t.mutationCache||new se),rk(this,P,t.defaultOptions||{}),rk(this,A,new Map),rk(this,D,new Map),rk(this,F,0)}})({defaultOptions:{queries:{queryFn:async function(t){let{queryKey:e}=t,[i]=e;return(0,n_.imageUrlToArrayBuffer)(i)},staleTime:1/0,gcTime:6e4,refetchOnWindowFocus:!1,refetchOnReconnect:!1}}});function so(){return(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(r_,{client:ss,children:(0,I.jsx)("main",{children:(0,I.jsx)(rC,{children:(0,I.jsx)(B.Suspense,{children:(0,I.jsx)(nJ,{children:(0,I.jsx)(ra,{children:(0,I.jsxs)(rl,{children:[(0,I.jsxs)("div",{className:"Viewport",children:[(0,I.jsxs)("div",{className:"ModelTools",children:[(0,I.jsx)("div",{className:"Field",children:(0,I.jsx)(re,{})}),(0,I.jsx)("div",{className:"Field SliderField",children:(0,I.jsx)(ri,{})}),(0,I.jsx)("div",{className:"Field",children:(0,I.jsx)(ro,{})})]}),(0,I.jsx)(rt,{})]}),(0,I.jsx)(nO,{children:(0,I.jsx)(nw,{children:(0,I.jsxs)(nk,{children:[(0,I.jsx)(nH,{}),(0,I.jsxs)("div",{className:"CanvasViewport",children:[(0,I.jsxs)("div",{className:"CanvasSelector",children:[(0,I.jsx)(nE,{}),(0,I.jsx)(rh,{})]}),(0,I.jsx)(nT,{}),(0,I.jsx)(rb,{})]}),(0,I.jsx)(np,{}),(0,I.jsx)(nv,{})]})})})]})})})})})})})})}}]);