zakeke-configurator-react 0.1.310 → 0.1.312
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/globals1.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach(function(t){_defineProperty(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function _defineProperty(e,t,i){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==typeof t?t:String(t)}function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}!function(){"use strict";var e=function(t){if(!(this instanceof e))return new e(t);if(this.version=1,this.support=!("undefined"==typeof File||"undefined"==typeof Blob||"undefined"==typeof FileList||!Blob.prototype.webkitSlice&&!Blob.prototype.mozSlice&&!Blob.prototype.slice),!this.support)return!1;var i=this;i.files=[],i.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,fileParameterName:"file",chunkNumberParameterName:"resumableChunkNumber",chunkSizeParameterName:"resumableChunkSize",currentChunkSizeParameterName:"resumableCurrentChunkSize",totalSizeParameterName:"resumableTotalSize",typeParameterName:"resumableType",identifierParameterName:"resumableIdentifier",fileNameParameterName:"resumableFilename",relativePathParameterName:"resumableRelativePath",totalChunksParameterName:"resumableTotalChunks",dragOverClass:"dragover",throttleProgressCallbacks:.5,query:{},headers:{},preprocess:null,preprocessFile:null,method:"multipart",uploadMethod:"POST",testMethod:"GET",prioritizeFirstAndLastChunk:!1,target:"/",testTarget:null,parameterNamespace:"",testChunks:!0,generateUniqueIdentifier:null,getTarget:null,maxChunkRetries:100,chunkRetryInterval:void 0,permanentErrors:[400,401,403,404,409,415,500,501],maxFiles:void 0,withCredentials:!1,xhrTimeout:0,clearInput:!0,chunkFormat:"blob",setChunkTypeFromFile:!1,maxFilesErrorCallback:function(e,t){var n=i.getOpt("maxFiles");alert("Please upload no more than "+n+" file"+(1===n?"":"s")+" at a time.")},minFileSize:1,minFileSizeErrorCallback:function(e,t){alert(e.fileName||e.name+"is too small, please upload files larger than "+n.formatSize(i.getOpt("minFileSize"))+".File size:"+e.size+" - File type:"+e.type+" - File object type:"+typeof e)},maxFileSize:void 0,maxFileSizeErrorCallback:function(e,t){alert(e.fileName||e.name+" is too large, please upload files less than "+n.formatSize(i.getOpt("maxFileSize"))+".")},fileType:[],fileTypeErrorCallback:function(e,t){alert(e.fileName||e.name+" has type not allowed, please upload files of type "+i.getOpt("fileType")+".")}},i.opts=t||{},i.getOpt=function(t){var i=this;if(t instanceof Array){var a={};return n.each(t,function(e){a[e]=i.getOpt(e)}),a}if(i instanceof u){if(void 0!==i.opts[t])return i.opts[t];i=i.fileObj}if(i instanceof c){if(void 0!==i.opts[t])return i.opts[t];i=i.resumableObj}if(i instanceof e)return void 0!==i.opts[t]?i.opts[t]:i.defaults[t]},i.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var i=0;i<e.length;i++)if(e[i]===t)return i;return-1},i.events=[],i.on=function(e,t){i.events.push(e.toLowerCase(),t)},i.fire=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);var n=e[0].toLowerCase();for(t=0;t<=i.events.length;t+=2)i.events[t]==n&&i.events[t+1].apply(i,e.slice(1)),"catchall"==i.events[t]&&i.events[t+1].apply(null,e);"fileerror"==n&&i.fire("error",e[2],e[1]),"fileprogress"==n&&i.fire("progress")};var n={stopEvent:function(e){e.stopPropagation(),e.preventDefault()},each:function(e,t){if(void 0!==e.length){for(var i=0;i<e.length;i++)if(!1===t(e[i]))return}else for(i in e)if(!1===t(i,e[i]))return},generateUniqueIdentifier:function(e,t){var n=i.getOpt("generateUniqueIdentifier");if("function"==typeof n)return n(e,t);var a=e.webkitRelativePath||e.relativePath||e.fileName||e.name;return e.size+"-"+a.replace(/[^0-9a-zA-Z_-]/gim,"")},contains:function(e,t){var i=!1;return n.each(e,function(e){return e!=t||(i=!0,!1)}),i},formatSize:function(e){return e<1024?e+" bytes":e<1048576?(e/1024).toFixed(0)+" KB":e<1073741824?(e/1024/1024).toFixed(1)+" MB":(e/1024/1024/1024).toFixed(1)+" GB"},getTarget:function(e,t){var n=i.getOpt("target");if("test"===e&&i.getOpt("testTarget")&&(n="/"===i.getOpt("testTarget")?i.getOpt("target"):i.getOpt("testTarget")),"function"==typeof n)return n(t);var a=n.indexOf("?")<0?"?":"&",r=t.join("&");return r&&(n=n+a+r),n}},a=function(e){e.currentTarget.classList.remove(i.getOpt("dragOverClass")),n.stopEvent(e),e.dataTransfer&&e.dataTransfer.items?h(e.dataTransfer.items,e):e.dataTransfer&&e.dataTransfer.files&&h(e.dataTransfer.files,e)},r=function(e){e.currentTarget.classList.remove(i.getOpt("dragOverClass"))},o=function(e){e.preventDefault();var t=e.dataTransfer;i.indexOf(t.types,"Files")>=0?(e.stopPropagation(),t.dropEffect="copy",t.effectAllowed="copy",e.currentTarget.classList.add(i.getOpt("dragOverClass"))):(t.dropEffect="none",t.effectAllowed="none")};function s(e,t,i,n){var a;return e.isFile?e.file(function(e){e.relativePath=t+e.name,i.push(e),n()}):(e.isDirectory?a=e:e instanceof File&&i.push(e),"function"==typeof e.webkitGetAsEntry&&(a=e.webkitGetAsEntry()),a&&a.isDirectory?function(e,t,i,n){var a=e.createReader(),r=[];!function e(){a.readEntries(function(a){if(a.length)return r=r.concat(a),e();l(r.map(function(e){return s.bind(null,e,t,i)}),n)})}()}(a,t+a.name+"/",i,n):("function"==typeof e.getAsFile&&(e=e.getAsFile())instanceof File&&(e.relativePath=t+e.name,i.push(e)),void n()))}function l(e,t){if(!e||0===e.length)return t();e[0](function(){l(e.slice(1),t)})}function h(e,t){if(e.length){i.fire("beforeAdd");var n=[];l(Array.prototype.map.call(e,function(e){var t=e;return"function"==typeof e.webkitGetAsEntry&&(t=e.webkitGetAsEntry()),s.bind(null,t,"",n)}),function(){n.length&&d(n,t)})}}var d=function(e,t){var a=0,r=i.getOpt(["maxFiles","minFileSize","maxFileSize","maxFilesErrorCallback","minFileSizeErrorCallback","maxFileSizeErrorCallback","fileType","fileTypeErrorCallback"]);if(void 0!==r.maxFiles&&r.maxFiles<e.length+i.files.length){if(1!==r.maxFiles||1!==i.files.length||1!==e.length)return r.maxFilesErrorCallback(e,a++),!1;i.removeFile(i.files[0])}var o=[],s=[],l=e.length,h=function(){if(!--l){if(!o.length&&!s.length)return;window.setTimeout(function(){i.fire("filesAdded",o,s)},0)}};n.each(e,function(e){var l=e.name,d=e.type;if(r.fileType.length>0){var u=!1;for(var g in r.fileType){r.fileType[g]=r.fileType[g].replace(/\s/g,"").toLowerCase();var f=(r.fileType[g].match(/^[^.][^/]+$/)?".":"")+r.fileType[g];if(l.substr(-1*f.length).toLowerCase()===f||-1!==f.indexOf("/")&&(-1!==f.indexOf("*")&&d.substr(0,f.indexOf("*"))===f.substr(0,f.indexOf("*"))||d===f)){u=!0;break}}if(!u)return r.fileTypeErrorCallback(e,a++),!0}if(void 0!==r.minFileSize&&e.size<r.minFileSize)return r.minFileSizeErrorCallback(e,a++),!0;if(void 0!==r.maxFileSize&&e.size>r.maxFileSize)return r.maxFileSizeErrorCallback(e,a++),!0;function p(n){i.getFromUniqueIdentifier(n)?s.push(e):function(){e.uniqueIdentifier=n;var a=new c(i,e,n);i.files.push(a),o.push(a),a.container=void 0!==t?t.srcElement:null,window.setTimeout(function(){i.fire("fileAdded",a,t)},0)}(),h()}var m=n.generateUniqueIdentifier(e,t);m&&"function"==typeof m.then?m.then(function(e){p(e)},function(){h()}):p(m)})};function c(e,t,i){var a=this;a.opts={},a.getOpt=e.getOpt,a._prevProgress=0,a.resumableObj=e,a.file=t,a.fileName=t.fileName||t.name,a.size=t.size,a.relativePath=t.relativePath||t.webkitRelativePath||a.fileName,a.uniqueIdentifier=i,a._pause=!1,a.container="",a.preprocessState=0;var r=void 0!==i,o=function(e,t){switch(e){case"progress":a.resumableObj.fire("fileProgress",a,t);break;case"error":a.abort(),r=!0,a.chunks=[],a.resumableObj.fire("fileError",a,t);break;case"success":if(r)return;a.resumableObj.fire("fileProgress",a,t),a.isComplete()&&a.resumableObj.fire("fileSuccess",a,t);break;case"retry":a.resumableObj.fire("fileRetry",a)}};return a.chunks=[],a.abort=function(){var e=0;n.each(a.chunks,function(t){"uploading"==t.status()&&(t.abort(),e++)}),e>0&&a.resumableObj.fire("fileProgress",a)},a.cancel=function(){var e=a.chunks;a.chunks=[],n.each(e,function(e){"uploading"==e.status()&&(e.abort(),a.resumableObj.uploadNextChunk())}),a.resumableObj.removeFile(a),a.resumableObj.fire("fileProgress",a)},a.retry=function(){a.bootstrap();var e=!1;a.resumableObj.on("chunkingComplete",function(){e||a.resumableObj.upload(),e=!0})},a.bootstrap=function(){a.abort(),r=!1,a.chunks=[],a._prevProgress=0;for(var e=a.getOpt("forceChunkSize")?Math.ceil:Math.floor,t=Math.max(e(a.file.size/a.getOpt("chunkSize")),1),i=0;i<t;i++)!function(e){window.setTimeout(function(){a.chunks.push(new u(a.resumableObj,a,e,o)),a.resumableObj.fire("chunkingProgress",a,e/t)},0)}(i);window.setTimeout(function(){a.resumableObj.fire("chunkingComplete",a)},0)},a.progress=function(){if(r)return 1;var e=0,t=!1;return n.each(a.chunks,function(i){"error"==i.status()&&(t=!0),e+=i.progress(!0)}),e=t?1:e>.99999?1:e,e=Math.max(a._prevProgress,e),a._prevProgress=e,e},a.isUploading=function(){var e=!1;return n.each(a.chunks,function(t){if("uploading"==t.status())return e=!0,!1}),e},a.isComplete=function(){var e=!1;return 1!==a.preprocessState&&(n.each(a.chunks,function(t){var i=t.status();if("pending"==i||"uploading"==i||1===t.preprocessState)return e=!0,!1}),!e)},a.pause=function(e){a._pause=void 0===e?!a._pause:e},a.isPaused=function(){return a._pause},a.preprocessFinished=function(){a.preprocessState=2,a.upload()},a.upload=function(){var e=!1;if(!1===a.isPaused()){var t=a.getOpt("preprocessFile");if("function"==typeof t)switch(a.preprocessState){case 0:return a.preprocessState=1,t(a),!0;case 1:return!0}n.each(a.chunks,function(t){if("pending"==t.status()&&1!==t.preprocessState)return t.send(),e=!0,!1})}return e},a.markChunksCompleted=function(e){if(a.chunks&&!(a.chunks.length<=e))for(var t=0;t<e;t++)a.chunks[t].markComplete=!0},a.resumableObj.fire("chunkingStart",a),a.bootstrap(),this}function u(e,t,i,a){var r=this;r.opts={},r.getOpt=e.getOpt,r.resumableObj=e,r.fileObj=t,r.fileObjSize=t.size,r.fileObjType=t.file.type,r.offset=i,r.callback=a,r.lastProgressCallback=new Date,r.tested=!1,r.retries=0,r.pendingRetry=!1,r.preprocessState=0,r.markComplete=!1;var o=r.getOpt("chunkSize");return r.loaded=0,r.startByte=r.offset*o,r.endByte=Math.min(r.fileObjSize,(r.offset+1)*o),r.fileObjSize-r.endByte<o&&!r.getOpt("forceChunkSize")&&(r.endByte=r.fileObjSize),r.xhr=null,r.test=function(){r.xhr=new XMLHttpRequest;var e=function(e){r.tested=!0;var t=r.status();"success"==t?(r.callback(t,r.message()),r.resumableObj.uploadNextChunk()):r.send()};r.xhr.addEventListener("load",e,!1),r.xhr.addEventListener("error",e,!1),r.xhr.addEventListener("timeout",e,!1);var t=[],i=r.getOpt("parameterNamespace"),a=r.getOpt("query");"function"==typeof a&&(a=a(r.fileObj,r)),n.each(a,function(e,n){t.push([encodeURIComponent(i+e),encodeURIComponent(n)].join("="))}),t=t.concat([["chunkNumberParameterName",r.offset+1],["chunkSizeParameterName",r.getOpt("chunkSize")],["currentChunkSizeParameterName",r.endByte-r.startByte],["totalSizeParameterName",r.fileObjSize],["typeParameterName",r.fileObjType],["identifierParameterName",r.fileObj.uniqueIdentifier],["fileNameParameterName",r.fileObj.fileName],["relativePathParameterName",r.fileObj.relativePath],["totalChunksParameterName",r.fileObj.chunks.length]].filter(function(e){return r.getOpt(e[0])}).map(function(e){return[i+r.getOpt(e[0]),encodeURIComponent(e[1])].join("=")})),r.xhr.open(r.getOpt("testMethod"),n.getTarget("test",t)),r.xhr.timeout=r.getOpt("xhrTimeout"),r.xhr.withCredentials=r.getOpt("withCredentials");var o=r.getOpt("headers");"function"==typeof o&&(o=o(r.fileObj,r)),n.each(o,function(e,t){r.xhr.setRequestHeader(e,t)}),r.xhr.send(null)},r.preprocessFinished=function(){r.preprocessState=2,r.send()},r.send=function(){var e=r.getOpt("preprocess");if("function"==typeof e)switch(r.preprocessState){case 0:return r.preprocessState=1,void e(r);case 1:return}if(!r.getOpt("testChunks")||r.tested){r.xhr=new XMLHttpRequest,r.xhr.upload.addEventListener("progress",function(e){new Date-r.lastProgressCallback>1e3*r.getOpt("throttleProgressCallbacks")&&(r.callback("progress"),r.lastProgressCallback=new Date),r.loaded=e.loaded||0},!1),r.loaded=0,r.pendingRetry=!1,r.callback("progress");var t=function(e){var t=r.status();if("success"==t||"error"==t)r.callback(t,r.message()),r.resumableObj.uploadNextChunk();else{r.callback("retry",r.message()),r.abort(),r.retries++;var i=r.getOpt("chunkRetryInterval");void 0!==i?(r.pendingRetry=!0,setTimeout(r.send,i)):r.send()}};r.xhr.addEventListener("load",t,!1),r.xhr.addEventListener("error",t,!1),r.xhr.addEventListener("timeout",t,!1);var i=[["chunkNumberParameterName",r.offset+1],["chunkSizeParameterName",r.getOpt("chunkSize")],["currentChunkSizeParameterName",r.endByte-r.startByte],["totalSizeParameterName",r.fileObjSize],["typeParameterName",r.fileObjType],["identifierParameterName",r.fileObj.uniqueIdentifier],["fileNameParameterName",r.fileObj.fileName],["relativePathParameterName",r.fileObj.relativePath],["totalChunksParameterName",r.fileObj.chunks.length]].filter(function(e){return r.getOpt(e[0])}).reduce(function(e,t){return e[r.getOpt(t[0])]=t[1],e},{}),a=r.getOpt("query");"function"==typeof a&&(a=a(r.fileObj,r)),n.each(a,function(e,t){i[e]=t});var o=r.fileObj.file.slice?"slice":r.fileObj.file.mozSlice?"mozSlice":r.fileObj.file.webkitSlice?"webkitSlice":"slice",s=r.fileObj.file[o](r.startByte,r.endByte,r.getOpt("setChunkTypeFromFile")?r.fileObj.file.type:""),l=null,h=[],d=r.getOpt("parameterNamespace");if("octet"===r.getOpt("method"))l=s,n.each(i,function(e,t){h.push([encodeURIComponent(d+e),encodeURIComponent(t)].join("="))});else if(l=new FormData,n.each(i,function(e,t){l.append(d+e,t),h.push([encodeURIComponent(d+e),encodeURIComponent(t)].join("="))}),"blob"==r.getOpt("chunkFormat"))l.append(d+r.getOpt("fileParameterName"),s,r.fileObj.fileName);else if("base64"==r.getOpt("chunkFormat")){var c=new FileReader;c.onload=function(e){l.append(d+r.getOpt("fileParameterName"),c.result),r.xhr.send(l)},c.readAsDataURL(s)}var u=n.getTarget("upload",h),g=r.getOpt("uploadMethod");r.xhr.open(g,u),"octet"===r.getOpt("method")&&r.xhr.setRequestHeader("Content-Type","application/octet-stream"),r.xhr.timeout=r.getOpt("xhrTimeout"),r.xhr.withCredentials=r.getOpt("withCredentials");var f=r.getOpt("headers");"function"==typeof f&&(f=f(r.fileObj,r)),n.each(f,function(e,t){r.xhr.setRequestHeader(e,t)}),"blob"==r.getOpt("chunkFormat")&&r.xhr.send(l)}else r.test()},r.abort=function(){r.xhr&&r.xhr.abort(),r.xhr=null},r.status=function(){return r.pendingRetry?"uploading":r.markComplete?"success":r.xhr?r.xhr.readyState<4?"uploading":200==r.xhr.status||201==r.xhr.status?"success":n.contains(r.getOpt("permanentErrors"),r.xhr.status)||r.retries>=r.getOpt("maxChunkRetries")?"error":(r.abort(),"pending"):"pending"},r.message=function(){return r.xhr?r.xhr.responseText:""},r.progress=function(e){void 0===e&&(e=!1);var t=e?(r.endByte-r.startByte)/r.fileObjSize:1;if(r.pendingRetry)return 0;switch(r.xhr&&r.xhr.status||r.markComplete||(t*=.95),r.status()){case"success":case"error":return 1*t;case"pending":return 0*t;default:return r.loaded/(r.endByte-r.startByte)*t}},this}return i.uploadNextChunk=function(){var e=!1;if(i.getOpt("prioritizeFirstAndLastChunk")&&(n.each(i.files,function(t){return t.chunks.length&&"pending"==t.chunks[0].status()&&0===t.chunks[0].preprocessState?(t.chunks[0].send(),e=!0,!1):t.chunks.length>1&&"pending"==t.chunks[t.chunks.length-1].status()&&0===t.chunks[t.chunks.length-1].preprocessState?(t.chunks[t.chunks.length-1].send(),e=!0,!1):void 0}),e))return!0;if(n.each(i.files,function(t){if(e=t.upload())return!1}),e)return!0;var t=!1;return n.each(i.files,function(e){if(!e.isComplete())return t=!0,!1}),t||i.fire("complete"),!1},i.assignBrowse=function(e,t){void 0===e.length&&(e=[e]),n.each(e,function(e){var n;"INPUT"===e.tagName&&"file"===e.type?n=e:((n=document.createElement("input")).setAttribute("type","file"),n.style.display="none",e.addEventListener("click",function(){n.style.opacity=0,n.style.display="block",n.focus(),n.click(),n.style.display="none"},!1),e.appendChild(n));var a=i.getOpt("maxFiles");void 0===a||1!=a?n.setAttribute("multiple","multiple"):n.removeAttribute("multiple"),t?n.setAttribute("webkitdirectory","webkitdirectory"):n.removeAttribute("webkitdirectory");var r=i.getOpt("fileType");void 0!==r&&r.length>=1?n.setAttribute("accept",r.map(function(e){return(e=e.replace(/\s/g,"").toLowerCase()).match(/^[^.][^/]+$/)&&(e="."+e),e}).join(",")):n.removeAttribute("accept"),n.addEventListener("change",function(e){d(e.target.files,e),i.getOpt("clearInput")&&(e.target.value="")},!1)})},i.assignDrop=function(e){void 0===e.length&&(e=[e]),n.each(e,function(e){e.addEventListener("dragover",o,!1),e.addEventListener("dragenter",o,!1),e.addEventListener("dragleave",r,!1),e.addEventListener("drop",a,!1)})},i.unAssignDrop=function(e){void 0===e.length&&(e=[e]),n.each(e,function(e){e.removeEventListener("dragover",o),e.removeEventListener("dragenter",o),e.removeEventListener("dragleave",r),e.removeEventListener("drop",a)})},i.isUploading=function(){var e=!1;return n.each(i.files,function(t){if(t.isUploading())return e=!0,!1}),e},i.upload=function(){if(!i.isUploading()){i.fire("uploadStart");for(var e=1;e<=i.getOpt("simultaneousUploads");e++)i.uploadNextChunk()}},i.pause=function(){n.each(i.files,function(e){e.abort()}),i.fire("pause")},i.cancel=function(){i.fire("beforeCancel");for(var e=i.files.length-1;e>=0;e--)i.files[e].cancel();i.fire("cancel")},i.progress=function(){var e=0,t=0;return n.each(i.files,function(i){e+=i.progress()*i.size,t+=i.size}),t>0?e/t:0},i.addFile=function(e,t){d([e],t)},i.addFiles=function(e,t){d(e,t)},i.removeFile=function(e){for(var t=i.files.length-1;t>=0;t--)i.files[t]===e&&i.files.splice(t,1)},i.getFromUniqueIdentifier=function(e){var t=!1;return n.each(i.files,function(i){i.uniqueIdentifier==e&&(t=i)}),t},i.getSize=function(){var e=0;return n.each(i.files,function(t){e+=t.size}),e},i.handleDropEvent=function(e){a(e)},i.handleChangeEvent=function(e){d(e.target.files,e),e.target.value=""},i.updateQuery=function(e){i.opts.query=e},this};"undefined"!=typeof module?(module.exports=e,module.exports.Resumable=e):"function"==typeof define&&define.amd?define(function(){return e}):window.Resumable=e}(),function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e:e(jQuery)}(function(e){var t,i,n=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],a="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],r=Array.prototype.slice;if(e.event.fixHooks)for(var o=n.length;o;)e.event.fixHooks[n[--o]]=e.event.mouseHooks;var s=e.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var t=a.length;t;)this.addEventListener(a[--t],l,!1);else this.onmousewheel=l;e.data(this,"mousewheel-line-height",s.getLineHeight(this)),e.data(this,"mousewheel-page-height",s.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var t=a.length;t;)this.removeEventListener(a[--t],l,!1);else this.onmousewheel=null;e.removeData(this,"mousewheel-line-height"),e.removeData(this,"mousewheel-page-height")},getLineHeight:function(t){var i=e(t),n=i["offsetParent"in e.fn?"offsetParent":"parent"]();return n.length||(n=e("body")),parseInt(n.css("fontSize"),10)||parseInt(i.css("fontSize"),10)||16},getPageHeight:function(t){return e(t).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};function l(n){var a,o=n||window.event,l=r.call(arguments,1),c=0,u=0,g=0,f=0,p=0;if((n=e.event.fix(o)).type="mousewheel","detail"in o&&(g=-1*o.detail),"wheelDelta"in o&&(g=o.wheelDelta),"wheelDeltaY"in o&&(g=o.wheelDeltaY),"wheelDeltaX"in o&&(u=-1*o.wheelDeltaX),"axis"in o&&o.axis===o.HORIZONTAL_AXIS&&(u=-1*g,g=0),c=0===g?u:g,"deltaY"in o&&(c=g=-1*o.deltaY),"deltaX"in o&&(u=o.deltaX,0===g&&(c=-1*u)),0!==g||0!==u){if(1===o.deltaMode){var m=e.data(this,"mousewheel-line-height");c*=m,g*=m,u*=m}else if(2===o.deltaMode){var v=e.data(this,"mousewheel-page-height");c*=v,g*=v,u*=v}if(a=Math.max(Math.abs(g),Math.abs(u)),(!i||a<i)&&(i=a,d(o,a)&&(i/=40)),d(o,a)&&(c/=40,u/=40,g/=40),c=Math[c>=1?"floor":"ceil"](c/i),u=Math[u>=1?"floor":"ceil"](u/i),g=Math[g>=1?"floor":"ceil"](g/i),s.settings.normalizeOffset&&this.getBoundingClientRect){var I=this.getBoundingClientRect();f=n.clientX-I.left,p=n.clientY-I.top}return n.deltaX=u,n.deltaY=g,n.deltaFactor=i,n.offsetX=f,n.offsetY=p,n.deltaMode=0,l.unshift(n,c,u,g),t&&clearTimeout(t),t=setTimeout(h,200),(e.event.dispatch||e.event.handle).apply(this,l)}}function h(){i=null}function d(e,t){return s.settings.adjustOldDeltas&&"mousewheel"===e.type&&t%120==0}e.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})}),function(){function e(e,t,i){return e.call.apply(e.bind,arguments)}function t(e,t,i){if(!e)throw Error();if(2<arguments.length){var n=Array.prototype.slice.call(arguments,2);return function(){var i=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(i,n),e.apply(t,i)}}return function(){return e.apply(t,arguments)}}function i(n,a,r){return(i=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?e:t).apply(null,arguments)}var n=Date.now||function(){return+new Date};function a(e,t){this.a=e,this.o=t||e,this.c=this.o.document}var r=!!window.FontFace;function o(e,t,i,n){if(t=e.c.createElement(t),i)for(var a in i)i.hasOwnProperty(a)&&("style"==a?t.style.cssText=i[a]:t.setAttribute(a,i[a]));return n&&t.appendChild(e.c.createTextNode(n)),t}function s(e,t,i){(e=e.c.getElementsByTagName(t)[0])||(e=document.documentElement),e.insertBefore(i,e.lastChild)}function l(e){e.parentNode&&e.parentNode.removeChild(e)}function h(e,t,i){t=t||[],i=i||[];for(var n=e.className.split(/\s+/),a=0;a<t.length;a+=1){for(var r=!1,o=0;o<n.length;o+=1)if(t[a]===n[o]){r=!0;break}r||n.push(t[a])}for(t=[],a=0;a<n.length;a+=1){for(r=!1,o=0;o<i.length;o+=1)if(n[a]===i[o]){r=!0;break}r||t.push(n[a])}e.className=t.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function d(e,t){for(var i=e.className.split(/\s+/),n=0,a=i.length;n<a;n++)if(i[n]==t)return!0;return!1}function c(e,t,i){function n(){d&&a&&l&&(d(h),d=null)}t=o(e,"link",{rel:"stylesheet",href:t,media:"all"});var a=!1,l=!0,h=null,d=i||null;r?(t.onload=function(){a=!0,n()},t.onerror=function(){a=!0,h=Error("Stylesheet failed to load"),n()}):setTimeout(function(){a=!0,n()},0),s(e,"head",t)}function u(e,t,i,n){var a=e.c.getElementsByTagName("head")[0];if(a){var r=o(e,"script",{src:t}),s=!1;return r.onload=r.onreadystatechange=function(){s||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(s=!0,i&&i(null),r.onload=r.onreadystatechange=null,"HEAD"==r.parentNode.tagName&&a.removeChild(r))},a.appendChild(r),setTimeout(function(){s||(s=!0,i&&i(Error("Script load timeout")))},n||5e3),r}return null}function g(){this.a=0,this.c=null}function f(e){return e.a++,function(){e.a--,m(e)}}function p(e,t){e.c=t,m(e)}function m(e){0==e.a&&e.c&&(e.c(),e.c=null)}function v(e){this.a=e||"-"}function I(e,t){this.c=e,this.f=4,this.a="n";var i=(t||"n4").match(/^([nio])([1-9])$/i);i&&(this.a=i[1],this.f=parseInt(i[2],10))}function y(e){var t=[];e=e.split(/,\s*/);for(var i=0;i<e.length;i++){var n=e[i].replace(/["]/g,"");-1!=n.indexOf(" ")||/^\d/.test(n)?t.push('"'+n+'"'):t.push(n)}return t.join(",")}function C(e){return e.a+e.f}function M(e){var t="normal";return"o"===e.a?t="oblique":"i"===e.a&&(t="italic"),t}function x(e){var t=4,i="n",n=null;return e&&((n=e.match(/(normal|oblique|italic)/i))&&n[1]&&(i=n[1].substr(0,1).toLowerCase()),(n=e.match(/([1-9]00|normal|bold)/i))&&n[1]&&(/bold/i.test(n[1])?t=7:/[1-9]00/.test(n[1])&&(t=parseInt(n[1].substr(0,1),10)))),i+t}function S(e,t){this.c=e,this.f=e.o.document.documentElement,this.h=t,this.a=new v("-"),this.j=!1!==t.events,this.g=!1!==t.classes}function b(e){if(e.g){var t=d(e.f,e.a.c("wf","active")),i=[],n=[e.a.c("wf","loading")];t||i.push(e.a.c("wf","inactive")),h(e.f,i,n)}w(e,"inactive")}function w(e,t,i){e.j&&e.h[t]&&(i?e.h[t](i.c,C(i)):e.h[t]())}function A(){this.c={}}function P(e,t){this.c=e,this.f=t,this.a=o(this.c,"span",{"aria-hidden":"true"},this.f)}function D(e){s(e.c,"body",e.a)}function k(e){return"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+y(e.c)+";font-style:"+M(e)+";font-weight:"+e.f+"00;"}function _(e,t,i,n,a,r){this.g=e,this.j=t,this.a=n,this.c=i,this.f=a||3e3,this.h=r||void 0}function T(e,t,i,n,a,r,o){this.v=e,this.B=t,this.c=i,this.a=n,this.s=o||"BESbswy",this.f={},this.w=a||3e3,this.u=r||null,this.m=this.j=this.h=this.g=null,this.g=new P(this.c,this.s),this.h=new P(this.c,this.s),this.j=new P(this.c,this.s),this.m=new P(this.c,this.s),e=k(e=new I(this.a.c+",serif",C(this.a))),this.g.a.style.cssText=e,e=k(e=new I(this.a.c+",sans-serif",C(this.a))),this.h.a.style.cssText=e,e=k(e=new I("serif",C(this.a))),this.j.a.style.cssText=e,e=k(e=new I("sans-serif",C(this.a))),this.m.a.style.cssText=e,D(this.g),D(this.h),D(this.j),D(this.m)}v.prototype.c=function(e){for(var t=[],i=0;i<arguments.length;i++)t.push(arguments[i].replace(/[\W_]+/g,"").toLowerCase());return t.join(this.a)},_.prototype.start=function(){var e=this.c.o.document,t=this,i=n(),a=new Promise(function(a,r){!function o(){n()-i>=t.f?r():e.fonts.load(function(e){return M(e)+" "+e.f+"00 300px "+y(e.c)}(t.a),t.h).then(function(e){1<=e.length?a():setTimeout(o,25)},function(){r()})}()}),r=null,o=new Promise(function(e,i){r=setTimeout(i,t.f)});Promise.race([o,a]).then(function(){r&&(clearTimeout(r),r=null),t.g(t.a)},function(){t.j(t.a)})};var z={D:"serif",C:"sans-serif"},O=null;function B(){if(null===O){var e=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);O=!!e&&(536>parseInt(e[1],10)||536===parseInt(e[1],10)&&11>=parseInt(e[2],10))}return O}function E(e,t,i){for(var n in z)if(z.hasOwnProperty(n)&&t===e.f[z[n]]&&i===e.f[z[n]])return!0;return!1}function R(e){var t,a=e.g.a.offsetWidth,r=e.h.a.offsetWidth;(t=a===e.f.serif&&r===e.f["sans-serif"])||(t=B()&&E(e,a,r)),t?n()-e.A>=e.w?B()&&E(e,a,r)&&(null===e.u||e.u.hasOwnProperty(e.a.c))?F(e,e.v):F(e,e.B):function(e){setTimeout(i(function(){R(this)},e),50)}(e):F(e,e.v)}function F(e,t){setTimeout(i(function(){l(this.g.a),l(this.h.a),l(this.j.a),l(this.m.a),t(this.a)},e),0)}function L(e,t,i){this.c=e,this.a=t,this.f=0,this.m=this.j=!1,this.s=i}T.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=n(),R(this)};var G=null;function U(e){0==--e.f&&e.j&&(e.m?((e=e.a).g&&h(e.f,[e.a.c("wf","active")],[e.a.c("wf","loading"),e.a.c("wf","inactive")]),w(e,"active")):b(e.a))}function j(e){this.j=e,this.a=new A,this.h=0,this.f=this.g=!0}function N(e,t,n,a,r){var o=0==--e.h;(e.f||e.g)&&setTimeout(function(){var e=r||null,s=a||{};if(0===n.length&&o)b(t.a);else{t.f+=n.length,o&&(t.j=o);var l,d=[];for(l=0;l<n.length;l++){var c=n[l],u=s[c.c],g=t.a,f=c;if(g.g&&h(g.f,[g.a.c("wf",f.c,C(f).toString(),"loading")]),w(g,"fontloading",f),g=null,null===G)if(window.FontFace){f=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent);var p=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);G=f?42<parseInt(f[1],10):!p}else G=!1;g=G?new _(i(t.g,t),i(t.h,t),t.c,c,t.s,u):new T(i(t.g,t),i(t.h,t),t.c,c,t.s,e,u),d.push(g)}for(l=0;l<d.length;l++)d[l].start()}},0)}function W(e,t){this.c=e,this.a=t}function Z(e,t){this.c=e,this.a=t}function H(e,t){this.c=e||V,this.a=[],this.f=[],this.g=t||""}L.prototype.g=function(e){var t=this.a;t.g&&h(t.f,[t.a.c("wf",e.c,C(e).toString(),"active")],[t.a.c("wf",e.c,C(e).toString(),"loading"),t.a.c("wf",e.c,C(e).toString(),"inactive")]),w(t,"fontactive",e),this.m=!0,U(this)},L.prototype.h=function(e){var t=this.a;if(t.g){var i=d(t.f,t.a.c("wf",e.c,C(e).toString(),"active")),n=[],a=[t.a.c("wf",e.c,C(e).toString(),"loading")];i||n.push(t.a.c("wf",e.c,C(e).toString(),"inactive")),h(t.f,n,a)}w(t,"fontinactive",e),U(this)},j.prototype.load=function(e){this.c=new a(this.j,e.context||this.j),this.g=!1!==e.events,this.f=!1!==e.classes,function(e,t,i){var n=[],a=i.timeout;!function(e){e.g&&h(e.f,[e.a.c("wf","loading")]),w(e,"loading")}(t);var n=function(e,t,i){var n,a=[];for(n in t)if(t.hasOwnProperty(n)){var r=e.c[n];r&&a.push(r(t[n],i))}return a}(e.a,i,e.c),r=new L(e.c,t,a);for(e.h=n.length,t=0,i=n.length;t<i;t++)n[t].load(function(t,i,n){N(e,r,t,i,n)})}(this,new S(this.c,e),e)},W.prototype.load=function(e){var t=this,i=t.a.projectId,n=t.a.version;if(i){var a=t.c.o;u(this.c,(t.a.api||"https://fast.fonts.net/jsapi")+"/"+i+".js"+(n?"?v="+n:""),function(n){n?e([]):(a["__MonotypeConfiguration__"+i]=function(){return t.a},function t(){if(a["__mti_fntLst"+i]){var n,r=a["__mti_fntLst"+i](),o=[];if(r)for(var s=0;s<r.length;s++){var l=r[s].fontfamily;null!=r[s].fontStyle&&null!=r[s].fontWeight?(n=r[s].fontStyle+r[s].fontWeight,o.push(new I(l,n))):o.push(new I(l))}e(o)}else setTimeout(function(){t()},50)}())}).id="__MonotypeAPIScript__"+i}else e([])},Z.prototype.load=function(e){var t,i,n=this.a.urls||[],a=this.a.families||[],r=this.a.testStrings||{},o=new g;for(t=0,i=n.length;t<i;t++)c(this.c,n[t],f(o));var s=[];for(t=0,i=a.length;t<i;t++)if((n=a[t].split(":"))[1])for(var l=n[1].split(","),h=0;h<l.length;h+=1)s.push(new I(n[0],l[h]));else s.push(new I(n[0]));p(o,function(){e(s,r)})};var V="https://fonts.googleapis.com/css";function q(e){this.f=e,this.a=[],this.c={}}var J={latin:"BESbswy","latin-ext":"çöüğş",cyrillic:"йяЖ",greek:"αβΣ",khmer:"កខគ",Hanuman:"កខគ"},Q={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},K={i:"i",italic:"i",n:"n",normal:"n"},Y=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;function X(e,t){this.c=e,this.a=t}var $={Arimo:!0,Cousine:!0,Tinos:!0};function ee(e,t){this.c=e,this.a=t}function te(e,t){this.c=e,this.f=t,this.a=[]}X.prototype.load=function(e){var t=new g,i=this.c,n=new H(this.a.api,this.a.text),a=this.a.families;!function(e,t){for(var i=t.length,n=0;n<i;n++){var a=t[n].split(":");3==a.length&&e.f.push(a.pop());var r="";2==a.length&&""!=a[1]&&(r=":"),e.a.push(a.join(r))}}(n,a);var r=new q(a);!function(e){for(var t=e.f.length,i=0;i<t;i++){var n=e.f[i].split(":"),a=n[0].replace(/\+/g," "),r=["n4"];if(2<=n.length){var o;if(o=[],s=n[1])for(var s,l=(s=s.split(",")).length,h=0;h<l;h++){var d;if((d=s[h]).match(/^[\w-]+$/))if(null==(u=Y.exec(d.toLowerCase())))d="";else{if(d=null==(d=u[2])||""==d?"n":K[d],null==(u=u[1])||""==u)u="4";else var c=Q[u],u=c||(isNaN(u)?"4":u.substr(0,1));d=[d,u].join("")}else d="";d&&o.push(d)}0<o.length&&(r=o),3==n.length&&(o=[],0<(n=(n=n[2])?n.split(","):o).length&&(n=J[n[0]])&&(e.c[a]=n))}for(e.c[a]||(n=J[a])&&(e.c[a]=n),n=0;n<r.length;n+=1)e.a.push(new I(a,r[n]))}}(r),c(i,function(e){if(0==e.a.length)throw Error("No fonts to load!");if(-1!=e.c.indexOf("kit="))return e.c;for(var t=e.a.length,i=[],n=0;n<t;n++)i.push(e.a[n].replace(/ /g,"+"));return t=e.c+"?family="+i.join("%7C"),0<e.f.length&&(t+="&subset="+e.f.join(",")),0<e.g.length&&(t+="&text="+encodeURIComponent(e.g)),t}(n),f(t)),p(t,function(){e(r.a,r.c,$)})},ee.prototype.load=function(e){var t=this.a.id,i=this.c.o;t?u(this.c,(this.a.api||"https://use.typekit.net")+"/"+t+".js",function(t){if(t)e([]);else if(i.Typekit&&i.Typekit.config&&i.Typekit.config.fn){t=i.Typekit.config.fn;for(var n=[],a=0;a<t.length;a+=2)for(var r=t[a],o=t[a+1],s=0;s<o.length;s++)n.push(new I(r,o[s]));try{i.Typekit.load({events:!1,classes:!1,async:!0})}catch(e){}e(n)}},2e3):e([])},te.prototype.load=function(e){var t=this.f.id,i=this.c.o,n=this;t?(i.__webfontfontdeckmodule__||(i.__webfontfontdeckmodule__={}),i.__webfontfontdeckmodule__[t]=function(t,i){for(var a=0,r=i.fonts.length;a<r;++a){var o=i.fonts[a];n.a.push(new I(o.name,x("font-weight:"+o.weight+";font-style:"+o.style)))}e(n.a)},u(this.c,(this.f.api||"https://f.fontdeck.com/s/css/js/")+function(e){return e.o.location.hostname||e.a.location.hostname}(this.c)+"/"+t+".js",function(t){t&&e([])})):e([])};var ie=new j(window);ie.a.c.custom=function(e,t){return new Z(t,e)},ie.a.c.fontdeck=function(e,t){return new te(t,e)},ie.a.c.monotype=function(e,t){return new W(t,e)},ie.a.c.typekit=function(e,t){return new ee(t,e)},ie.a.c.google=function(e,t){return new X(t,e)};var ne={load:i(ie.load,ie)};"function"==typeof define&&define.amd?define(function(){return ne}):"undefined"!=typeof module&&module.exports?module.exports=ne:(window.WebFont=ne,window.WebFontConfig&&ie.load(window.WebFontConfig))}(),function(e,t){"object"==typeof exports&&typeof module<"u"?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=typeof globalThis<"u"?globalThis:e||self).ZakekeResizableCanvas={})}(this,function(e){"use strict";var t=Object.defineProperty,i=(e,i,n)=>(((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n),n),n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var a={exports:{}};const r=function(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var i=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),i}(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var o;o=a,function(e,t){var i=(e=e||r).window,n=e.document,a=new function(){var e=/^(statics|enumerable|beans|preserve)$/,i=[],n=i.slice,a=Object.create,r=Object.getOwnPropertyDescriptor,o=Object.defineProperty,s=i.forEach||function(e,t){for(var i=0,n=this.length;i<n;i++)e.call(t,this[i],i,this)},l=Object.assign||function(e){for(var t=1,i=arguments.length;t<i;t++){var n=arguments[t];for(var a in n)n.hasOwnProperty(a)&&(e[a]=n[a])}return e},h=function(e,t,i){if(e){var n=r(e,"length");(n&&"number"==typeof n.value?s:function(e,t){for(var i in this)this.hasOwnProperty(i)&&e.call(t,this[i],i,this)}).call(e,t,i=i||e)}return i};function d(t,i,n,a,s){var l={};function h(e,h){"string"==typeof(h=h||(h=r(i,e))&&(h.get?h:h.value))&&"#"===h[0]&&(h=t[h.substring(1)]||h);var d,u="function"==typeof h,g=h,f=s||u&&!h.base?h&&h.get?e in t:t[e]:null;(!s||!f)&&(u&&f&&(h.base=f),u&&!1!==a&&(d=e.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(l[d[3].toLowerCase()+d[4]]=d[2]),(!g||u||!g.get||"function"!=typeof g.get||!c.isPlainObject(g))&&(g={value:g,writable:!0}),(r(t,e)||{configurable:!0}).configurable&&(g.configurable=!0,g.enumerable=null!=n?n:!d),o(t,e,g))}if(i){for(var d in i)i.hasOwnProperty(d)&&!e.test(d)&&h(d);for(var d in l){var u=l[d],g=t["set"+u],f=t["get"+u]||g&&t["is"+u];f&&(!0===a||0===f.length)&&h(d,{get:f,set:g})}}return t}function c(){for(var e=0,t=arguments.length;e<t;e++){var i=arguments[e];i&&l(this,i)}return this}return d(c,{inject:function(e){if(e){var t=!0===e.statics?e:e.statics,i=e.beans,n=e.preserve;t!==e&&d(this.prototype,e,e.enumerable,i,n),d(this,t,null,i,n)}for(var a=1,r=arguments.length;a<r;a++)this.inject(arguments[a]);return this},extend:function(){for(var e,t,i,n=this,r=0,s=arguments.length;r<s&&(!e||!t);r++)i=arguments[r],e=e||i.initialize,t=t||i.prototype;return t=(e=e||function(){n.apply(this,arguments)}).prototype=t||a(this.prototype),o(t,"constructor",{value:e,writable:!0,configurable:!0}),d(e,this),arguments.length&&this.inject.apply(e,arguments),e.base=n,e}}).inject({enumerable:!1,initialize:c,set:c,inject:function(){for(var e=0,t=arguments.length;e<t;e++){var i=arguments[e];i&&d(this,i,i.enumerable,i.beans,i.preserve)}return this},extend:function(){var e=a(this);return e.inject.apply(e,arguments)},each:function(e,t){return h(this,e,t)},clone:function(){return new this.constructor(this)},statics:{set:l,each:h,create:a,define:o,describe:r,clone:function(e){return l(new e.constructor,e)},isPlainObject:function(e){var t=null!=e&&e.constructor;return t&&(t===Object||t===c||"Object"===t.name)},pick:function(e,i){return e!==t?e:i},slice:function(e,t,i){return n.call(e,t,i)}}})};o.exports=a,a.inject({enumerable:!1,toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+a.each(this,function(e,t){if(!/^_/.test(t)){var i=typeof e;this.push(t+": "+("number"===i?c.instance.number(e):"string"===i?"'"+e+"'":e))}},[]).join(", ")+" }"},getClassName:function(){return this._class||""},importJSON:function(e){return a.importJSON(e,this)},exportJSON:function(e){return a.exportJSON(this,e)},toJSON:function(){return a.serialize(this)},set:function(e,t){return e&&a.filter(this,e,t,this._prioritize),this}},{beans:!1,statics:{exports:{},extend:function e(){var t=e.base.apply(this,arguments),i=t.prototype._class;return i&&!a.exports[i]&&(a.exports[i]=t),t},equals:function(e,t){if(e===t)return!0;if(e&&e.equals)return e.equals(t);if(t&&t.equals)return t.equals(e);if(e&&t&&"object"==typeof e&&"object"==typeof t){if(Array.isArray(e)&&Array.isArray(t)){if((i=e.length)!==t.length)return!1;for(;i--;)if(!a.equals(e[i],t[i]))return!1}else{var i,n=Object.keys(e);if((i=n.length)!==Object.keys(t).length)return!1;for(;i--;){var r=n[i];if(!t.hasOwnProperty(r)||!a.equals(e[r],t[r]))return!1}}return!0}return!1},read:function(e,i,n,r){if(this===a){var o=this.peek(e,i);return e.__index++,o}var s=this.prototype,l=s._readIndex,h=i||l&&e.__index||0,d=e.length,c=e[h];if(r=r||d-h,c instanceof this||n&&n.readNull&&null==c&&r<=1)return l&&(e.__index=h+1),c&&n&&n.clone?c.clone():c;if(c=a.create(s),l&&(c.__read=!0),c=c.initialize.apply(c,h>0||h+r<d?a.slice(e,h,h+r):e)||c,l){e.__index=h+c.__read;var u=c.__filtered;u&&(e.__filtered=u,c.__filtered=t),c.__read=t}return c},peek:function(e,t){return e[e.__index=t||e.__index||0]},remain:function(e){return e.length-(e.__index||0)},readList:function(e,t,i,n){for(var a,r=[],o=t||0,s=n?o+n:e.length,l=o;l<s;l++)r.push(Array.isArray(a=e[l])?this.read(a,0,i):this.read(e,l,i,1));return r},readNamed:function(e,i,n,r,o){var s=this.getNamed(e,i),l=s!==t;if(l){var h=e.__filtered;if(!h){var d=this.getSource(e);(h=e.__filtered=a.create(d)).__unfiltered=d}h[i]=t}return this.read(l?[s]:e,n,r,o)},readSupported:function(e,i){var n=this.getSource(e),a=this,r=!1;return n&&Object.keys(n).forEach(function(n){if(n in i){var o=a.readNamed(e,n);o!==t&&(i[n]=o),r=!0}}),r},getSource:function(e){var i=e.__source;if(i===t){var n=1===e.length&&e[0];i=e.__source=n&&a.isPlainObject(n)?n:null}return i},getNamed:function(e,t){var i=this.getSource(e);if(i)return t?i[t]:e.__filtered||i},hasNamed:function(e,t){return!!this.getNamed(e,t)},filter:function(e,i,n,a){var r;function o(a){if(!(n&&a in n||r&&a in r)){var o=i[a];o!==t&&(e[a]=o)}}if(a){for(var s,l={},h=0,d=a.length;h<d;h++)(s=a[h])in i&&(o(s),l[s]=!0);r=l}return Object.keys(i.__unfiltered||i).forEach(o),e},isPlainValue:function(e,t){return a.isPlainObject(e)||Array.isArray(e)||t&&"string"==typeof e},serialize:function(e,t,i,n){t=t||{};var r,o=!n;if(o&&(t.formatter=new c(t.precision),n={length:0,definitions:{},references:{},add:function(e,t){var i="#"+e._id,n=this.references[i];if(!n){this.length++;var a=t.call(e),r=e._class;r&&a[0]!==r&&a.unshift(r),this.definitions[i]=a,n=this.references[i]=[i]}return n}}),e&&e._serialize){r=e._serialize(t,n);var s=e._class;s&&!e._compactSerialize&&(o||!i)&&r[0]!==s&&r.unshift(s)}else if(Array.isArray(e)){r=[];for(var l=0,h=e.length;l<h;l++)r[l]=a.serialize(e[l],t,i,n)}else if(a.isPlainObject(e)){r={};var d=Object.keys(e);for(l=0,h=d.length;l<h;l++){var u=d[l];r[u]=a.serialize(e[u],t,i,n)}}else r="number"==typeof e?t.formatter.number(e,t.precision):e;return o&&n.length>0?[["dictionary",n.definitions],r]:r},deserialize:function(e,t,i,n,r){var o=e,s=!i,l=s&&e&&e.length&&"dictionary"===e[0][0];if(i=i||{},Array.isArray(e)){var h=e[0],d="dictionary"===h;if(1==e.length&&/^#/.test(h))return i.dictionary[h];o=[];for(var c=(h=a.exports[h])?1:0,u=e.length;c<u;c++)o.push(a.deserialize(e[c],t,i,d,l));if(h){var g=o;o=t?t(h,g,s||r):new h(g)}}else if(a.isPlainObject(e))for(var f in o={},n&&(i.dictionary=o),e)o[f]=a.deserialize(e[f],t,i);return l?o[1]:o},exportJSON:function(e,t){var i=a.serialize(e,t);return t&&0==t.asString?i:JSON.stringify(i)},importJSON:function(e,t){return a.deserialize("string"==typeof e?JSON.parse(e):e,function(e,i,n){var r=n&&t&&t.constructor===e,o=r?t:a.create(e.prototype);if(1===i.length&&o instanceof S&&(r||!(o instanceof w))){var s=i[0];a.isPlainObject(s)&&(s.insert=!1,r&&(i=i.concat([S.INSERT])))}return(r?o.set:e).apply(o,i),r&&(t=null),o})},push:function(e,t){var i=t.length;if(i<4096)e.push.apply(e,t);else{var n=e.length;e.length+=i;for(var a=0;a<i;a++)e[n+a]=t[a]}return e},splice:function(e,i,n,r){var o=i&&i.length,s=n===t;(n=s?e.length:n)>e.length&&(n=e.length);for(var l=0;l<o;l++)i[l]._index=n+l;if(s)return a.push(e,i),[];var h=[n,r];i&&a.push(h,i);for(var d=e.splice.apply(e,h),c=(l=0,d.length);l<c;l++)d[l]._index=t;for(l=n+o,c=e.length;l<c;l++)e[l]._index=l;return d},capitalize:function(e){return e.replace(/\b[a-z]/g,function(e){return e.toUpperCase()})},camelize:function(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})},hyphenate:function(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}}});var s={on:function(e,t){if("string"!=typeof e)a.each(e,function(e,t){this.on(t,e)},this);else{var i=this._eventTypes,n=i&&i[e],r=this._callbacks=this._callbacks||{};-1===(r=r[e]=r[e]||[]).indexOf(t)&&(r.push(t),n&&n.install&&1===r.length&&n.install.call(this,e))}return this},off:function(e,t){if("string"==typeof e){var i,n=this._eventTypes,r=n&&n[e],o=this._callbacks&&this._callbacks[e];return o&&(!t||-1!==(i=o.indexOf(t))&&1===o.length?(r&&r.uninstall&&r.uninstall.call(this,e),delete this._callbacks[e]):-1!==i&&o.splice(i,1)),this}a.each(e,function(e,t){this.off(t,e)},this)},once:function(e,t){return this.on(e,function i(){t.apply(this,arguments),this.off(e,i)})},emit:function(e,t){var i=this._callbacks&&this._callbacks[e];if(!i)return!1;var n=a.slice(arguments,1),r=t&&t.target&&!t.currentTarget;i=i.slice(),r&&(t.currentTarget=this);for(var o=0,s=i.length;o<s;o++)if(0==i[o].apply(this,n)){t&&t.stop&&t.stop();break}return r&&delete t.currentTarget,!0},responds:function(e){return!(!this._callbacks||!this._callbacks[e])},attach:"#on",detach:"#off",fire:"#emit",_installEvents:function(e){var t=this._eventTypes,i=this._callbacks,n=e?"install":"uninstall";if(t)for(var a in i)if(i[a].length>0){var r=t[a],o=r&&r[n];o&&o.call(this,a)}},statics:{inject:function e(t){var i=t._events;if(i){var n={};a.each(i,function(e,i){var r="string"==typeof e,o=r?e:i,s=a.capitalize(o),l=o.substring(2).toLowerCase();n[l]=r?{}:e,o="_"+o,t["get"+s]=function(){return this[o]},t["set"+s]=function(e){var t=this[o];t&&this.off(l,t),e&&this.on(l,e),this[o]=e}}),t._eventTypes=n}return e.base.apply(this,arguments)}}},l=a.extend({_class:"PaperScope",initialize:function t(){le=this,this.settings=new a({applyMatrix:!0,insertItems:!0,handleSize:4,hitTolerance:0}),this.project=null,this.projects=[],this.tools=[],this._id=t._id++,t._scopes[this._id]=this;var i=t.prototype;if(!this.support){var n=ae.getContext(1,1)||{};i.support={nativeDash:"setLineDash"in n||"mozDash"in n,nativeBlendModes:re.nativeModes},ae.release(n)}if(!this.agent){var r=e.navigator.userAgent.toLowerCase(),o=(/(darwin|win|mac|linux|freebsd|sunos)/.exec(r)||[])[0],s="darwin"===o?"mac":o,l=i.agent=i.browser={platform:s};s&&(l[s]=!0),r.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom|node|jsdom)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:v?([.\d]+))?/g,function(e,t,i,n,a){if(!l.chrome){var r="opera"===t?n:/^(node|trident)$/.test(t)?a:i;l.version=r,l.versionNumber=parseFloat(r),t={trident:"msie",jsdom:"node"}[t]||t,l.name=t,l[t]=!0}}),l.chrome&&delete l.webkit,l.atom&&delete l.chrome}},version:"0.12.17",getView:function(){var e=this.project;return e&&e._view},getPaper:function(){return this},execute:function(e,t){var i=le.PaperScript.execute(e,this,t);return J.updateFocus(),i},install:function(e){var t=this;for(var i in a.each(["project","view","tool"],function(i){a.define(e,i,{configurable:!0,get:function(){return t[i]}})}),this)!/^_/.test(i)&&this[i]&&(e[i]=this[i])},setup:function(e){return le=this,this.project=new x(e),this},createCanvas:function(e,t){return ae.getCanvas(e,t)},activate:function(){le=this},clear:function(){for(var e=this.projects,t=this.tools,i=e.length-1;i>=0;i--)e[i].remove();for(i=t.length-1;i>=0;i--)t[i].remove()},remove:function(){this.clear(),delete l._scopes[this._id]},statics:new function(){function e(e){return e+="Attribute",function(t,i){return t[e](i)||t[e]("data-paper-"+i)}}return{_scopes:{},_id:0,get:function(e){return this._scopes[e]||null},getAttribute:e("get"),hasAttribute:e("has")}}}),h=a.extend(s,{initialize:function(e){this._scope=le,this._index=this._scope[this._list].push(this)-1,(e||!this._scope[this._reference])&&this.activate()},activate:function(){if(!this._scope)return!1;var e=this._scope[this._reference];return e&&e!==this&&e.emit("deactivate"),this._scope[this._reference]=this,this.emit("activate",e),!0},isActive:function(){return this._scope[this._reference]===this},remove:function(){return null!=this._index&&(a.splice(this._scope[this._list],null,this._index,1),this._scope[this._reference]==this&&(this._scope[this._reference]=null),this._scope=null,!0)},getView:function(){return this._scope.getView()}}),d={findItemBoundsCollisions:function(e,t,i){function n(e){for(var t=new Array(e.length),i=0;i<e.length;i++){var n=e[i].getBounds();t[i]=[n.left,n.top,n.right,n.bottom]}return t}var a=n(e),r=t&&t!==e?n(t):a;return this.findBoundsCollisions(a,r,i||0)},findCurveBoundsCollisions:function(e,t,i,n){function a(e){for(var t=Math.min,i=Math.max,n=new Array(e.length),a=0;a<e.length;a++){var r=e[a];n[a]=[t(r[0],r[2],r[4],r[6]),t(r[1],r[3],r[5],r[7]),i(r[0],r[2],r[4],r[6]),i(r[1],r[3],r[5],r[7])]}return n}var r=a(e),o=t&&t!==e?a(t):r;if(n){for(var s=this.findBoundsCollisions(r,o,i||0,!1,!0),l=this.findBoundsCollisions(r,o,i||0,!0,!0),h=[],d=0,c=s.length;d<c;d++)h[d]={hor:s[d],ver:l[d]};return h}return this.findBoundsCollisions(r,o,i||0)},findBoundsCollisions:function(e,t,i,n,a){var r=!t||e===t,o=r?e:e.concat(t),s=e.length,l=o.length;function h(e,t,i){for(var n=0,a=e.length;n<a;){var r=a+n>>>1;o[e[r]][t]<i?n=r+1:a=r}return n-1}for(var d=n?1:0,c=d+2,u=n?0:1,g=u+2,f=new Array(l),p=0;p<l;p++)f[p]=p;f.sort(function(e,t){return o[e][d]-o[t][d]});var m=[],v=new Array(s);for(p=0;p<l;p++){var I=f[p],y=o[I],C=r?I:I-s,M=I<s,x=r||!M,S=M?[]:null;if(m.length){var b=h(m,c,y[d]-i)+1;if(m.splice(0,b),r&&a){S=S.concat(m);for(var w=0;w<m.length;w++)v[D=m[w]].push(C)}else{var A=y[g],P=y[u];for(w=0;w<m.length;w++){var D=m[w],k=o[D],_=D<s,T=r||D>=s;(a||(M&&T||x&&_)&&A>=k[u]-i&&P<=k[g]+i)&&(M&&T&&S.push(r?D:D-s),x&&_&&v[D].push(C))}}}if(M&&(e===t&&S.push(I),v[I]=S),m.length){var z=h(m,c,y[c]);m.splice(z+1,0,I)}else m.push(I)}for(p=0;p<v.length;p++){var O=v[p];O&&O.sort(function(e,t){return e-t})}return v}},c=a.extend({initialize:function(e){this.precision=a.pick(e,5),this.multiplier=Math.pow(10,this.precision)},number:function(e){return this.precision<16?Math.round(e*this.multiplier)/this.multiplier:e},pair:function(e,t,i){return this.number(e)+(i||",")+this.number(t)},point:function(e,t){return this.number(e.x)+(t||",")+this.number(e.y)},size:function(e,t){return this.number(e.width)+(t||",")+this.number(e.height)},rectangle:function(e,t){return this.point(e,t)+(t||",")+this.size(e,t)}});c.instance=new c;var u=new function(){var e=[[.5773502691896257],[0,.7745966692414834],[.33998104358485626,.8611363115940526],[0,.5384693101056831,.906179845938664],[.2386191860831969,.6612093864662645,.932469514203152],[0,.4058451513773972,.7415311855993945,.9491079123427585],[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],[0,.3242534234038089,.6133714327005904,.8360311073266358,.9681602395076261],[.14887433898163122,.4333953941292472,.6794095682990244,.8650633666889845,.9739065285171717],[0,.26954315595234496,.5190961292068118,.7301520055740494,.8870625997680953,.978228658146057],[.1252334085114689,.3678314989981802,.5873179542866175,.7699026741943047,.9041172563704749,.9815606342467192],[0,.2304583159551348,.44849275103644687,.6423493394403402,.8015780907333099,.9175983992229779,.9841830547185881],[.10805494870734367,.31911236892788974,.5152486363581541,.6872929048116855,.827201315069765,.9284348836635735,.9862838086968123],[0,.20119409399743451,.3941513470775634,.5709721726085388,.7244177313601701,.8482065834104272,.937273392400706,.9879925180204854],[.09501250983763744,.2816035507792589,.45801677765722737,.6178762444026438,.755404408355003,.8656312023878318,.9445750230732326,.9894009349916499]],t=[[1],[.8888888888888888,.5555555555555556],[.6521451548625461,.34785484513745385],[.5688888888888889,.47862867049936647,.23692688505618908],[.46791393457269104,.3607615730481386,.17132449237917036],[.4179591836734694,.3818300505051189,.27970539148927664,.1294849661688697],[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626],[.3302393550012598,.31234707704000286,.26061069640293544,.1806481606948574,.08127438836157441],[.29552422471475287,.26926671930999635,.21908636251598204,.1494513491505806,.06667134430868814],[.2729250867779006,.26280454451024665,.23319376459199048,.18629021092773426,.1255803694649046,.05566856711617366],[.24914704581340277,.2334925365383548,.20316742672306592,.16007832854334622,.10693932599531843,.04717533638651183],[.2325515532308739,.22628318026289723,.2078160475368885,.17814598076194574,.13887351021978725,.09212149983772845,.04048400476531588],[.2152638534631578,.2051984637212956,.18553839747793782,.15720316715819355,.12151857068790319,.08015808715976021,.03511946033175186],[.2025782419255613,.19843148532711158,.1861610000155622,.16626920581699392,.13957067792615432,.10715922046717194,.07036604748810812,.03075324199611727],[.1894506104550685,.18260341504492358,.16915651939500254,.14959598881657674,.12462897125553388,.09515851168249279,.062253523938647894,.027152459411754096]],i=Math.abs,n=Math.sqrt,a=Math.pow,r=Math.log2||function(e){return Math.log(e)*Math.LOG2E},o=1e-12,s=1.12e-16;function l(e,t,i){return e<t?t:e>i?i:e}function h(e,t,n){function a(e){var t=134217729*e,i=e-t+t;return[i,e-i]}var r=t*t-e*n,o=t*t+e*n;if(3*i(r)<o){var s=a(e),l=a(t),h=a(n),d=t*t,c=e*n;r=d-c+(l[0]*l[0]-d+2*l[0]*l[1]+l[1]*l[1]-(s[0]*h[0]-c+s[0]*h[1]+s[1]*h[0]+s[1]*h[1]))}return r}function d(){var e=Math.max.apply(Math,arguments);return e&&(e<1e-8||e>1e8)?a(2,-Math.round(r(e))):0}return{EPSILON:o,MACHINE_EPSILON:s,CURVETIME_EPSILON:1e-8,GEOMETRIC_EPSILON:1e-7,TRIGONOMETRIC_EPSILON:1e-8,ANGULAR_EPSILON:1e-5,KAPPA:4*(n(2)-1)/3,isZero:function(e){return e>=-o&&e<=o},isMachineZero:function(e){return e>=-s&&e<=s},clamp:l,integrate:function(i,n,a,r){for(var o=e[r-2],s=t[r-2],l=.5*(a-n),h=l+n,d=0,c=r+1>>1,u=1&r?s[d++]*i(h):0;d<c;){var g=l*o[d];u+=s[d++]*(i(h+g)+i(h-g))}return l*u},findRoot:function(e,t,n,a,r,o,s){for(var h=0;h<o;h++){var d=e(n),c=d/t(n),u=n-c;if(i(c)<s){n=u;break}d>0?(r=n,n=u<=a?.5*(a+r):u):(a=n,n=u>=r?.5*(a+r):u)}return l(n,a,r)},solveQuadratic:function(e,t,a,r,c,u){var g,f=1/0;if(i(e)<o){if(i(t)<o)return i(a)<o?-1:0;g=-a/t}else{var p=h(e,t*=-.5,a);if(p&&i(p)<s){var m=d(i(e),i(t),i(a));m&&(p=h(e*=m,t*=m,a*=m))}if(p>=-s){var v=p<0?0:n(p),I=t+(t<0?-v:v);0===I?f=-(g=a/e):(g=I/e,f=a/I)}}var y=0,C=null==c,M=c-o,x=u+o;return isFinite(g)&&(C||g>M&&g<x)&&(r[y++]=C?g:l(g,c,u)),f!==g&&isFinite(f)&&(C||f>M&&f<x)&&(r[y++]=C?f:l(f,c,u)),y},solveCubic:function(e,t,r,h,c,g,f){var p,m,v,I,y,C=d(i(e),i(t),i(r),i(h));function M(i){var n=e*(p=i);I=(n+(m=n+t))*p+(v=m*p+r),y=v*p+h}if(C&&(e*=C,t*=C,r*=C,h*=C),i(e)<o)e=t,m=r,v=h,p=1/0;else if(i(h)<o)m=t,v=r,p=0;else{M(-t/e/3);var x=y/e,S=a(i(x),1/3),b=x<0?-1:1,w=-I/e,A=w>0?1.324717957244746*Math.max(S,n(w)):S,P=p-b*A;if(P!==p){do{M(P),P=0===I?p:p-y/I/(1+s)}while(b*P>b*p);i(e)*p*p>i(h/p)&&(m=((v=-h/p)-r)/p)}}var D=u.solveQuadratic(e,m,v,c,g,f),k=null==g;return isFinite(p)&&(0===D||D>0&&p!==c[0]&&p!==c[1])&&(k||p>g-o&&p<f+o)&&(c[D++]=k?p:l(p,g,f)),D}}},g={_id:1,_pools:{},get:function(e){if(e){var t=this._pools[e];return t||(t=this._pools[e]={_id:1}),t._id++}return this._id++}},f=a.extend({_class:"Point",_readIndex:!0,initialize:function(e,t){var i=typeof e,n=this.__read,a=0;if("number"===i){var r="number"==typeof t;this._set(e,r?t:e),n&&(a=r?2:1)}else if("undefined"===i||null===e)this._set(0,0),n&&(a=null===e?1:0);else{var o="string"===i?e.split(/[\s,]+/)||[]:e;a=1,Array.isArray(o)?this._set(+o[0],+(o.length>1?o[1]:o[0])):"x"in o?this._set(o.x||0,o.y||0):"width"in o?this._set(o.width||0,o.height||0):"angle"in o?(this._set(o.length||0,0),this.setAngle(o.angle||0)):(this._set(0,0),a=0)}return n&&(this.__read=a),this},set:"#initialize",_set:function(e,t){return this.x=e,this.y=t,this},equals:function(e){return this===e||e&&(this.x===e.x&&this.y===e.y||Array.isArray(e)&&this.x===e[0]&&this.y===e[1])||!1},clone:function(){return new f(this.x,this.y)},toString:function(){var e=c.instance;return"{ x: "+e.number(this.x)+", y: "+e.number(this.y)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.x),t.number(this.y)]},getLength:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},setLength:function(e){if(this.isZero()){var t=this._angle||0;this._set(Math.cos(t)*e,Math.sin(t)*e)}else{var i=e/this.getLength();u.isZero(i)&&this.getAngle(),this._set(this.x*i,this.y*i)}},getAngle:function(){return 180*this.getAngleInRadians.apply(this,arguments)/Math.PI},setAngle:function(e){this.setAngleInRadians.call(this,e*Math.PI/180)},getAngleInDegrees:"#getAngle",setAngleInDegrees:"#setAngle",getAngleInRadians:function(){if(arguments.length){var e=f.read(arguments),t=this.getLength()*e.getLength();if(u.isZero(t))return NaN;var i=this.dot(e)/t;return Math.acos(i<-1?-1:i>1?1:i)}return this.isZero()?this._angle||0:this._angle=Math.atan2(this.y,this.x)},setAngleInRadians:function(e){if(this._angle=e,!this.isZero()){var t=this.getLength();this._set(Math.cos(e)*t,Math.sin(e)*t)}},getQuadrant:function(){return this.x>=0?this.y>=0?1:4:this.y>=0?2:3}},{beans:!1,getDirectedAngle:function(){var e=f.read(arguments);return 180*Math.atan2(this.cross(e),this.dot(e))/Math.PI},getDistance:function(){var e=arguments,t=f.read(e),i=t.x-this.x,n=t.y-this.y,r=i*i+n*n;return a.read(e)?r:Math.sqrt(r)},normalize:function(e){e===t&&(e=1);var i=this.getLength(),n=0!==i?e/i:0,a=new f(this.x*n,this.y*n);return n>=0&&(a._angle=this._angle),a},rotate:function(e,t){if(0===e)return this.clone();e=e*Math.PI/180;var i=t?this.subtract(t):this,n=Math.sin(e),a=Math.cos(e);return i=new f(i.x*a-i.y*n,i.x*n+i.y*a),t?i.add(t):i},transform:function(e){return e?e._transformPoint(this):this},add:function(){var e=f.read(arguments);return new f(this.x+e.x,this.y+e.y)},subtract:function(){var e=f.read(arguments);return new f(this.x-e.x,this.y-e.y)},multiply:function(){var e=f.read(arguments);return new f(this.x*e.x,this.y*e.y)},divide:function(){var e=f.read(arguments);return new f(this.x/e.x,this.y/e.y)},modulo:function(){var e=f.read(arguments);return new f(this.x%e.x,this.y%e.y)},negate:function(){return new f(-this.x,-this.y)},isInside:function(){return I.read(arguments).contains(this)},isClose:function(){var e=arguments,t=f.read(e),i=a.read(e);return this.getDistance(t)<=i},isCollinear:function(){var e=f.read(arguments);return f.isCollinear(this.x,this.y,e.x,e.y)},isColinear:"#isCollinear",isOrthogonal:function(){var e=f.read(arguments);return f.isOrthogonal(this.x,this.y,e.x,e.y)},isZero:function(){var e=u.isZero;return e(this.x)&&e(this.y)},isNaN:function(){return isNaN(this.x)||isNaN(this.y)},isInQuadrant:function(e){return this.x*(e>1&&e<4?-1:1)>=0&&this.y*(e>2?-1:1)>=0},dot:function(){var e=f.read(arguments);return this.x*e.x+this.y*e.y},cross:function(){var e=f.read(arguments);return this.x*e.y-this.y*e.x},project:function(){var e=f.read(arguments),t=e.isZero()?0:this.dot(e)/e.dot(e);return new f(e.x*t,e.y*t)},statics:{min:function(){var e=arguments,t=f.read(e),i=f.read(e);return new f(Math.min(t.x,i.x),Math.min(t.y,i.y))},max:function(){var e=arguments,t=f.read(e),i=f.read(e);return new f(Math.max(t.x,i.x),Math.max(t.y,i.y))},random:function(){return new f(Math.random(),Math.random())},isCollinear:function(e,t,i,n){return Math.abs(e*n-t*i)<=1e-8*Math.sqrt((e*e+t*t)*(i*i+n*n))},isOrthogonal:function(e,t,i,n){return Math.abs(e*i+t*n)<=1e-8*Math.sqrt((e*e+t*t)*(i*i+n*n))}}},a.each(["round","ceil","floor","abs"],function(e){var t=Math[e];this[e]=function(){return new f(t(this.x),t(this.y))}},{})),p=f.extend({initialize:function(e,t,i,n){this._x=e,this._y=t,this._owner=i,this._setter=n},_set:function(e,t,i){return this._x=e,this._y=t,i||this._owner[this._setter](this),this},getX:function(){return this._x},setX:function(e){this._x=e,this._owner[this._setter](this)},getY:function(){return this._y},setY:function(e){this._y=e,this._owner[this._setter](this)},isSelected:function(){return!!(this._owner._selection&this._getSelection())},setSelected:function(e){this._owner._changeSelection(this._getSelection(),e)},_getSelection:function(){return"setPosition"===this._setter?4:0}}),m=a.extend({_class:"Size",_readIndex:!0,initialize:function(e,t){var i=typeof e,n=this.__read,a=0;if("number"===i){var r="number"==typeof t;this._set(e,r?t:e),n&&(a=r?2:1)}else if("undefined"===i||null===e)this._set(0,0),n&&(a=null===e?1:0);else{var o="string"===i?e.split(/[\s,]+/)||[]:e;a=1,Array.isArray(o)?this._set(+o[0],+(o.length>1?o[1]:o[0])):"width"in o?this._set(o.width||0,o.height||0):"x"in o?this._set(o.x||0,o.y||0):(this._set(0,0),a=0)}return n&&(this.__read=a),this},set:"#initialize",_set:function(e,t){return this.width=e,this.height=t,this},equals:function(e){return e===this||e&&(this.width===e.width&&this.height===e.height||Array.isArray(e)&&this.width===e[0]&&this.height===e[1])||!1},clone:function(){return new m(this.width,this.height)},toString:function(){var e=c.instance;return"{ width: "+e.number(this.width)+", height: "+e.number(this.height)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.width),t.number(this.height)]},add:function(){var e=m.read(arguments);return new m(this.width+e.width,this.height+e.height)},subtract:function(){var e=m.read(arguments);return new m(this.width-e.width,this.height-e.height)},multiply:function(){var e=m.read(arguments);return new m(this.width*e.width,this.height*e.height)},divide:function(){var e=m.read(arguments);return new m(this.width/e.width,this.height/e.height)},modulo:function(){var e=m.read(arguments);return new m(this.width%e.width,this.height%e.height)},negate:function(){return new m(-this.width,-this.height)},isZero:function(){var e=u.isZero;return e(this.width)&&e(this.height)},isNaN:function(){return isNaN(this.width)||isNaN(this.height)},statics:{min:function(e,t){return new m(Math.min(e.width,t.width),Math.min(e.height,t.height))},max:function(e,t){return new m(Math.max(e.width,t.width),Math.max(e.height,t.height))},random:function(){return new m(Math.random(),Math.random())}}},a.each(["round","ceil","floor","abs"],function(e){var t=Math[e];this[e]=function(){return new m(t(this.width),t(this.height))}},{})),v=m.extend({initialize:function(e,t,i,n){this._width=e,this._height=t,this._owner=i,this._setter=n},_set:function(e,t,i){return this._width=e,this._height=t,i||this._owner[this._setter](this),this},getWidth:function(){return this._width},setWidth:function(e){this._width=e,this._owner[this._setter](this)},getHeight:function(){return this._height},setHeight:function(e){this._height=e,this._owner[this._setter](this)}}),I=a.extend({_class:"Rectangle",_readIndex:!0,beans:!0,initialize:function(e,i,n,r){var o,s=arguments,l=typeof e;if("number"===l?(this._set(e,i,n,r),o=4):"undefined"===l||null===e?(this._set(0,0,0,0),o=null===e?1:0):1===s.length&&(Array.isArray(e)?(this._set.apply(this,e),o=1):e.x!==t||e.width!==t?(this._set(e.x||0,e.y||0,e.width||0,e.height||0),o=1):e.from===t&&e.to===t&&(this._set(0,0,0,0),a.readSupported(s,this)&&(o=1))),o===t){var h,d,c=f.readNamed(s,"from"),u=a.peek(s),g=c.x,p=c.y;if(u&&u.x!==t||a.hasNamed(s,"to")){var v=f.readNamed(s,"to");h=v.x-g,d=v.y-p,h<0&&(g=v.x,h=-h),d<0&&(p=v.y,d=-d)}else{var I=m.read(s);h=I.width,d=I.height}this._set(g,p,h,d),o=s.__index}var y=s.__filtered;return y&&(this.__filtered=y),this.__read&&(this.__read=o),this},set:"#initialize",_set:function(e,t,i,n){return this.x=e,this.y=t,this.width=i,this.height=n,this},clone:function(){return new I(this.x,this.y,this.width,this.height)},equals:function(e){var t=a.isPlainValue(e)?I.read(arguments):e;return t===this||t&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height||!1},toString:function(){var e=c.instance;return"{ x: "+e.number(this.x)+", y: "+e.number(this.y)+", width: "+e.number(this.width)+", height: "+e.number(this.height)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.x),t.number(this.y),t.number(this.width),t.number(this.height)]},getPoint:function(e){return new(e?f:p)(this.x,this.y,this,"setPoint")},setPoint:function(){var e=f.read(arguments);this.x=e.x,this.y=e.y},getSize:function(e){return new(e?m:v)(this.width,this.height,this,"setSize")},_fw:1,_fh:1,setSize:function(){var e=m.read(arguments),t=this._sx,i=this._sy,n=e.width,a=e.height;t&&(this.x+=(this.width-n)*t),i&&(this.y+=(this.height-a)*i),this.width=n,this.height=a,this._fw=this._fh=1},getLeft:function(){return this.x},setLeft:function(e){if(!this._fw){var t=e-this.x;this.width-=.5===this._sx?2*t:t}this.x=e,this._sx=this._fw=0},getTop:function(){return this.y},setTop:function(e){if(!this._fh){var t=e-this.y;this.height-=.5===this._sy?2*t:t}this.y=e,this._sy=this._fh=0},getRight:function(){return this.x+this.width},setRight:function(e){if(!this._fw){var t=e-this.x;this.width=.5===this._sx?2*t:t}this.x=e-this.width,this._sx=1,this._fw=0},getBottom:function(){return this.y+this.height},setBottom:function(e){if(!this._fh){var t=e-this.y;this.height=.5===this._sy?2*t:t}this.y=e-this.height,this._sy=1,this._fh=0},getCenterX:function(){return this.x+this.width/2},setCenterX:function(e){this._fw||.5===this._sx?this.x=e-this.width/2:(this._sx&&(this.x+=2*(e-this.x)*this._sx),this.width=2*(e-this.x)),this._sx=.5,this._fw=0},getCenterY:function(){return this.y+this.height/2},setCenterY:function(e){this._fh||.5===this._sy?this.y=e-this.height/2:(this._sy&&(this.y+=2*(e-this.y)*this._sy),this.height=2*(e-this.y)),this._sy=.5,this._fh=0},getCenter:function(e){return new(e?f:p)(this.getCenterX(),this.getCenterY(),this,"setCenter")},setCenter:function(){var e=f.read(arguments);return this.setCenterX(e.x),this.setCenterY(e.y),this},getArea:function(){return this.width*this.height},isEmpty:function(){return 0===this.width||0===this.height},contains:function(e){return e&&e.width!==t||4===(Array.isArray(e)?e:arguments).length?this._containsRectangle(I.read(arguments)):this._containsPoint(f.read(arguments))},_containsPoint:function(e){var t=e.x,i=e.y;return t>=this.x&&i>=this.y&&t<=this.x+this.width&&i<=this.y+this.height},_containsRectangle:function(e){var t=e.x,i=e.y;return t>=this.x&&i>=this.y&&t+e.width<=this.x+this.width&&i+e.height<=this.y+this.height},intersects:function(){var e=I.read(arguments),t=a.read(arguments)||0;return e.x+e.width>this.x-t&&e.y+e.height>this.y-t&&e.x<this.x+this.width+t&&e.y<this.y+this.height+t},intersect:function(){var e=I.read(arguments),t=Math.max(this.x,e.x),i=Math.max(this.y,e.y),n=Math.min(this.x+this.width,e.x+e.width),a=Math.min(this.y+this.height,e.y+e.height);return new I(t,i,n-t,a-i)},unite:function(){var e=I.read(arguments),t=Math.min(this.x,e.x),i=Math.min(this.y,e.y),n=Math.max(this.x+this.width,e.x+e.width),a=Math.max(this.y+this.height,e.y+e.height);return new I(t,i,n-t,a-i)},include:function(){var e=f.read(arguments),t=Math.min(this.x,e.x),i=Math.min(this.y,e.y),n=Math.max(this.x+this.width,e.x),a=Math.max(this.y+this.height,e.y);return new I(t,i,n-t,a-i)},expand:function(){var e=m.read(arguments),t=e.width,i=e.height;return new I(this.x-t/2,this.y-i/2,this.width+t,this.height+i)},scale:function(e,i){return this.expand(this.width*e-this.width,this.height*(i===t?e:i)-this.height)}},a.each([["Top","Left"],["Top","Right"],["Bottom","Left"],["Bottom","Right"],["Left","Center"],["Top","Center"],["Right","Center"],["Bottom","Center"]],function(e,t){var i=e.join(""),n=/^[RL]/.test(i);t>=4&&(e[1]+=n?"Y":"X");var a=e[n?0:1],r=e[n?1:0],o="get"+a,s="get"+r,l="set"+a,h="set"+r,d="set"+i;this["get"+i]=function(e){return new(e?f:p)(this[o](),this[s](),this,d)},this[d]=function(){var e=f.read(arguments);this[l](e.x),this[h](e.y)}},{beans:!0})),y=I.extend({initialize:function(e,t,i,n,a,r){this._set(e,t,i,n,!0),this._owner=a,this._setter=r},_set:function(e,t,i,n,a){return this._x=e,this._y=t,this._width=i,this._height=n,a||this._owner[this._setter](this),this}},new function(){var e=I.prototype;return a.each(["x","y","width","height"],function(e){var t=a.capitalize(e),i="_"+e;this["get"+t]=function(){return this[i]},this["set"+t]=function(e){this[i]=e,this._dontNotify||this._owner[this._setter](this)}},a.each(["Point","Size","Center","Left","Top","Right","Bottom","CenterX","CenterY","TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],function(t){var i="set"+t;this[i]=function(){this._dontNotify=!0,e[i].apply(this,arguments),this._dontNotify=!1,this._owner[this._setter](this)}},{isSelected:function(){return!!(2&this._owner._selection)},setSelected:function(e){var t=this._owner;t._changeSelection&&t._changeSelection(2,e)}}))}),C=a.extend({_class:"Matrix",initialize:function e(t,i){var n=arguments,a=n.length,r=!0;if(a>=6?this._set.apply(this,n):1===a||2===a?t instanceof e?this._set(t._a,t._b,t._c,t._d,t._tx,t._ty,i):Array.isArray(t)?this._set.apply(this,i?t.concat([i]):t):r=!1:a?r=!1:this.reset(),!r)throw new Error("Unsupported matrix parameters");return this},set:"#initialize",_set:function(e,t,i,n,a,r,o){return this._a=e,this._b=t,this._c=i,this._d=n,this._tx=a,this._ty=r,o||this._changed(),this},_serialize:function(e,t){return a.serialize(this.getValues(),e,!0,t)},_changed:function(){var e=this._owner;e&&(e._applyMatrix?e.transform(null,!0):e._changed(25))},clone:function(){return new C(this._a,this._b,this._c,this._d,this._tx,this._ty)},equals:function(e){return e===this||e&&this._a===e._a&&this._b===e._b&&this._c===e._c&&this._d===e._d&&this._tx===e._tx&&this._ty===e._ty},toString:function(){var e=c.instance;return"[["+[e.number(this._a),e.number(this._c),e.number(this._tx)].join(", ")+"], ["+[e.number(this._b),e.number(this._d),e.number(this._ty)].join(", ")+"]]"},reset:function(e){return this._a=this._d=1,this._b=this._c=this._tx=this._ty=0,e||this._changed(),this},apply:function(e,t){var i=this._owner;return!!i&&(i.transform(null,a.pick(e,!0),t),this.isIdentity())},translate:function(){var e=f.read(arguments),t=e.x,i=e.y;return this._tx+=t*this._a+i*this._c,this._ty+=t*this._b+i*this._d,this._changed(),this},scale:function(){var e=arguments,t=f.read(e),i=f.read(e,0,{readNull:!0});return i&&this.translate(i),this._a*=t.x,this._b*=t.x,this._c*=t.y,this._d*=t.y,i&&this.translate(i.negate()),this._changed(),this},rotate:function(e){e*=Math.PI/180;var t=f.read(arguments,1),i=t.x,n=t.y,a=Math.cos(e),r=Math.sin(e),o=i-i*a+n*r,s=n-i*r-n*a,l=this._a,h=this._b,d=this._c,c=this._d;return this._a=a*l+r*d,this._b=a*h+r*c,this._c=-r*l+a*d,this._d=-r*h+a*c,this._tx+=o*l+s*d,this._ty+=o*h+s*c,this._changed(),this},shear:function(){var e=arguments,t=f.read(e),i=f.read(e,0,{readNull:!0});i&&this.translate(i);var n=this._a,a=this._b;return this._a+=t.y*this._c,this._b+=t.y*this._d,this._c+=t.x*n,this._d+=t.x*a,i&&this.translate(i.negate()),this._changed(),this},skew:function(){var e=arguments,t=f.read(e),i=f.read(e,0,{readNull:!0}),n=Math.PI/180,a=new f(Math.tan(t.x*n),Math.tan(t.y*n));return this.shear(a,i)},append:function(e,t){if(e){var i=this._a,n=this._b,a=this._c,r=this._d,o=e._a,s=e._c,l=e._b,h=e._d,d=e._tx,c=e._ty;this._a=o*i+l*a,this._c=s*i+h*a,this._b=o*n+l*r,this._d=s*n+h*r,this._tx+=d*i+c*a,this._ty+=d*n+c*r,t||this._changed()}return this},prepend:function(e,t){if(e){var i=this._a,n=this._b,a=this._c,r=this._d,o=this._tx,s=this._ty,l=e._a,h=e._c,d=e._b,c=e._d,u=e._tx,g=e._ty;this._a=l*i+h*n,this._c=l*a+h*r,this._b=d*i+c*n,this._d=d*a+c*r,this._tx=l*o+h*s+u,this._ty=d*o+c*s+g,t||this._changed()}return this},appended:function(e){return this.clone().append(e)},prepended:function(e){return this.clone().prepend(e)},invert:function(){var e=this._a,t=this._b,i=this._c,n=this._d,a=this._tx,r=this._ty,o=e*n-t*i,s=null;return o&&!isNaN(o)&&isFinite(a)&&isFinite(r)&&(this._a=n/o,this._b=-t/o,this._c=-i/o,this._d=e/o,this._tx=(i*r-n*a)/o,this._ty=(t*a-e*r)/o,s=this),s},inverted:function(){return this.clone().invert()},concatenate:"#append",preConcatenate:"#prepend",chain:"#appended",_shiftless:function(){return new C(this._a,this._b,this._c,this._d,0,0)},_orNullIfIdentity:function(){return this.isIdentity()?null:this},isIdentity:function(){return 1===this._a&&0===this._b&&0===this._c&&1===this._d&&0===this._tx&&0===this._ty},isInvertible:function(){var e=this._a*this._d-this._c*this._b;return e&&!isNaN(e)&&isFinite(this._tx)&&isFinite(this._ty)},isSingular:function(){return!this.isInvertible()},transform:function(e,t,i){return arguments.length<3?this._transformPoint(f.read(arguments)):this._transformCoordinates(e,t,i)},_transformPoint:function(e,t,i){var n=e.x,a=e.y;return t||(t=new f),t._set(n*this._a+a*this._c+this._tx,n*this._b+a*this._d+this._ty,i)},_transformCoordinates:function(e,t,i){for(var n=0,a=2*i;n<a;n+=2){var r=e[n],o=e[n+1];t[n]=r*this._a+o*this._c+this._tx,t[n+1]=r*this._b+o*this._d+this._ty}return t},_transformCorners:function(e){var t=e.x,i=e.y,n=t+e.width,a=i+e.height,r=[t,i,n,i,n,a,t,a];return this._transformCoordinates(r,r,4)},_transformBounds:function(e,t,i){for(var n=this._transformCorners(e),a=n.slice(0,2),r=a.slice(),o=2;o<8;o++){var s=n[o],l=1&o;s<a[l]?a[l]=s:s>r[l]&&(r[l]=s)}return t||(t=new I),t._set(a[0],a[1],r[0]-a[0],r[1]-a[1],i)},inverseTransform:function(){return this._inverseTransform(f.read(arguments))},_inverseTransform:function(e,t,i){var n=this._a,a=this._b,r=this._c,o=this._d,s=this._tx,l=this._ty,h=n*o-a*r,d=null;if(h&&!isNaN(h)&&isFinite(s)&&isFinite(l)){var c=e.x-this._tx,u=e.y-this._ty;t||(t=new f),d=t._set((c*o-u*r)/h,(u*n-c*a)/h,i)}return d},decompose:function(){var e,t,i,n=this._a,a=this._b,r=this._c,o=this._d,s=n*o-a*r,l=Math.sqrt,h=Math.atan2,d=180/Math.PI;if(0!==n||0!==a){var c=l(n*n+a*a);e=Math.acos(n/c)*(a>0?1:-1),t=[c,s/c],i=[h(n*r+a*o,c*c),0]}else if(0!==r||0!==o){var u=l(r*r+o*o);e=Math.asin(r/u)*(o>0?1:-1),t=[s/u,u],i=[0,h(n*r+a*o,u*u)]}else e=0,i=t=[0,0];return{translation:this.getTranslation(),rotation:e*d,scaling:new f(t),skewing:new f(i[0]*d,i[1]*d)}},getValues:function(){return[this._a,this._b,this._c,this._d,this._tx,this._ty]},getTranslation:function(){return new f(this._tx,this._ty)},getScaling:function(){return this.decompose().scaling},getRotation:function(){return this.decompose().rotation},applyToContext:function(e){this.isIdentity()||e.transform(this._a,this._b,this._c,this._d,this._tx,this._ty)}},a.each(["a","b","c","d","tx","ty"],function(e){var t=a.capitalize(e),i="_"+e;this["get"+t]=function(){return this[i]},this["set"+t]=function(e){this[i]=e,this._changed()}},{})),M=a.extend({_class:"Line",initialize:function(e,t,i,n,a){var r=!1;arguments.length>=4?(this._px=e,this._py=t,this._vx=i,this._vy=n,r=a):(this._px=e.x,this._py=e.y,this._vx=t.x,this._vy=t.y,r=i),r||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new f(this._px,this._py)},getVector:function(){return new f(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(e,t){return M.intersect(this._px,this._py,this._vx,this._vy,e._px,e._py,e._vx,e._vy,!0,t)},getSide:function(e,t){return M.getSide(this._px,this._py,this._vx,this._vy,e.x,e.y,!0,t)},getDistance:function(e){return Math.abs(this.getSignedDistance(e))},getSignedDistance:function(e){return M.getSignedDistance(this._px,this._py,this._vx,this._vy,e.x,e.y,!0)},isCollinear:function(e){return f.isCollinear(this._vx,this._vy,e._vx,e._vy)},isOrthogonal:function(e){return f.isOrthogonal(this._vx,this._vy,e._vx,e._vy)},statics:{intersect:function(e,t,i,n,a,r,o,s,l,h){l||(i-=e,n-=t,o-=a,s-=r);var d=i*s-n*o;if(!u.isMachineZero(d)){var c=e-a,g=t-r,p=(o*g-s*c)/d,m=(i*g-n*c)/d,v=-1e-12,I=1+1e-12;if(h||v<p&&p<I&&v<m&&m<I)return h||(p=p<=0?0:p>=1?1:p),new f(e+p*i,t+p*n)}},getSide:function(e,t,i,n,a,r,o,s){o||(i-=e,n-=t);var l=a-e,h=l*n-(r-t)*i;return!s&&u.isMachineZero(h)&&(h=(l*i+l*i)/(i*i+n*n))>=0&&h<=1&&(h=0),h<0?-1:h>0?1:0},getSignedDistance:function(e,t,i,n,a,r,o){return o||(i-=e,n-=t),0===i?n>0?a-e:e-a:0===n?i<0?r-t:t-r:((a-e)*n-(r-t)*i)/(n>i?n*Math.sqrt(1+i*i/(n*n)):i*Math.sqrt(1+n*n/(i*i)))},getDistance:function(e,t,i,n,a,r,o){return Math.abs(M.getSignedDistance(e,t,i,n,a,r,o))}}}),x=h.extend({_class:"Project",_list:"projects",_reference:"project",_compactSerialize:!0,initialize:function(e){h.call(this,!0),this._children=[],this._namedChildren={},this._activeLayer=null,this._currentStyle=new H(null,null,this),this._view=J.create(this,e||ae.getCanvas(1,1)),this._selectionItems={},this._selectionCount=0,this._updateVersion=0},_serialize:function(e,t){return a.serialize(this._children,e,!0,t)},_changed:function(e,t){if(1&e){var i=this._view;i&&(i._needsUpdate=!0,!i._requested&&i._autoUpdate&&i.requestUpdate())}var n=this._changes;if(n&&t){var a=this._changesById,r=t._id,o=a[r];o?o.flags|=e:n.push(a[r]={item:t,flags:e})}},clear:function(){for(var e=this._children,t=e.length-1;t>=0;t--)e[t].remove()},isEmpty:function(){return!this._children.length},remove:function e(){return!!e.base.call(this)&&(this._view&&this._view.remove(),!0)},getView:function(){return this._view},getCurrentStyle:function(){return this._currentStyle},setCurrentStyle:function(e){this._currentStyle.set(e)},getIndex:function(){return this._index},getOptions:function(){return this._scope.settings},getLayers:function(){return this._children},getActiveLayer:function(){return this._activeLayer||new w({project:this,insert:!0})},getSymbolDefinitions:function(){var e=[],t={};return this.getItems({class:D,match:function(i){var n=i._definition,a=n._id;return t[a]||(t[a]=!0,e.push(n)),!1}}),e},getSymbols:"getSymbolDefinitions",getSelectedItems:function(){var e=this._selectionItems,t=[];for(var i in e){var n=e[i],a=n._selection;1&a&&n.isInserted()?t.push(n):a||this._updateSelection(n)}return t},_updateSelection:function(e){var t=e._id,i=this._selectionItems;e._selection?i[t]!==e&&(this._selectionCount++,i[t]=e):i[t]===e&&(this._selectionCount--,delete i[t])},selectAll:function(){for(var e=this._children,t=0,i=e.length;t<i;t++)e[t].setFullySelected(!0)},deselectAll:function(){var e=this._selectionItems;for(var t in e)e[t].setFullySelected(!1)},addLayer:function(e){return this.insertLayer(t,e)},insertLayer:function(e,t){if(t instanceof w){t._remove(!1,!0),a.splice(this._children,[t],e,0),t._setProject(this,!0);var i=t._name;i&&t.setName(i),this._changes&&t._changed(5),this._activeLayer||(this._activeLayer=t)}else t=null;return t},_insertItem:function(e,i,n){return i=this.insertLayer(e,i)||(this._activeLayer||this._insertItem(t,new w(S.NO_INSERT),!0)).insertChild(e,i),n&&i.activate&&i.activate(),i},getItems:function(e){return S._getItems(this,e)},getItem:function(e){return S._getItems(this,e,null,null,!0)[0]||null},importJSON:function(e){this.activate();var t=this._activeLayer;return a.importJSON(e,t&&t.isEmpty()&&t)},removeOn:function(e){var t=this._removeSets;if(t){"mouseup"===e&&(t.mousedrag=null);var i=t[e];if(i){for(var n in i){var a=i[n];for(var r in t){var o=t[r];o&&o!=i&&delete o[a._id]}a.remove()}t[e]=null}}},draw:function(e,t,i){this._updateVersion++,e.save(),t.applyToContext(e);for(var n=this._children,r=new a({offset:new f(0,0),pixelRatio:i,viewMatrix:t.isIdentity()?null:t,matrices:[new C],updateMatrix:!0}),o=0,s=n.length;o<s;o++)n[o].draw(e,r);if(e.restore(),this._selectionCount>0){e.save(),e.strokeWidth=1;var l=this._selectionItems,h=this._scope.settings.handleSize,d=this._updateVersion;for(var c in l)l[c]._drawSelection(e,t,h,l,d);e.restore()}}}),S=a.extend(s,{statics:{extend:function e(t){return t._serializeFields&&(t._serializeFields=a.set({},this.prototype._serializeFields,t._serializeFields)),e.base.apply(this,arguments)},INSERT:{insert:!0},NO_INSERT:{insert:!1}},_class:"Item",_name:null,_applyMatrix:!0,_canApplyMatrix:!0,_canScaleStroke:!1,_pivot:null,_visible:!0,_blendMode:"normal",_opacity:1,_locked:!1,_guide:!1,_clipMask:!1,_selection:0,_selectBounds:!0,_selectChildren:!1,_serializeFields:{name:null,applyMatrix:null,matrix:new C,pivot:null,visible:!0,blendMode:"normal",opacity:1,locked:!1,guide:!1,clipMask:!1,selected:!1,data:{}},_prioritize:["applyMatrix"]},new function(){var e=["onMouseDown","onMouseUp","onMouseDrag","onClick","onDoubleClick","onMouseMove","onMouseEnter","onMouseLeave"];return a.each(e,function(e){this._events[e]={install:function(e){this.getView()._countItemEvent(e,1)},uninstall:function(e){this.getView()._countItemEvent(e,-1)}}},{_events:{onFrame:{install:function(){this.getView()._animateItem(this,!0)},uninstall:function(){this.getView()._animateItem(this,!1)}},onLoad:{},onError:{}},statics:{_itemHandlers:e}})},{initialize:function(){},_initialize:function(e,i){var n=e&&a.isPlainObject(e),r=n&&!0===e.internal,o=this._matrix=new C,s=n&&e.project||le.project,l=le.settings;return this._id=r?null:g.get(),this._parent=this._index=null,this._applyMatrix=this._canApplyMatrix&&l.applyMatrix,i&&o.translate(i),o._owner=this,this._style=new H(s._currentStyle,this,s),r||n&&0==e.insert||!l.insertItems&&(!n||1!=e.insert)?this._setProject(s):(n&&e.parent||s)._insertItem(t,this,!0),n&&e!==S.NO_INSERT&&e!==S.INSERT&&this.set(e,{internal:!0,insert:!0,project:!0,parent:!0}),n},_serialize:function(e,t){var i={},n=this;function r(r){for(var o in r){var s=n[o];a.equals(s,"leading"===o?1.2*r.fontSize:r[o])||(i[o]=a.serialize(s,e,"data"!==o,t))}}return r(this._serializeFields),this instanceof b||r(this._style._defaults),[this._class,i]},_changed:function(e){var i=this._symbol,n=this._parent||i,a=this._project;8&e&&(this._bounds=this._position=this._decomposed=t),16&e&&(this._globalMatrix=t),n&&72&e&&S._clearBoundsCache(n),2&e&&S._clearBoundsCache(this),a&&a._changed(e,this),i&&i._changed(e)},getId:function(){return this._id},getName:function(){return this._name},setName:function(e){if(this._name&&this._removeNamed(),e===+e+"")throw new Error("Names consisting only of numbers are not supported.");var i=this._getOwner();if(e&&i){var n=i._children,a=i._namedChildren;(a[e]=a[e]||[]).push(this),e in n||(n[e]=this)}this._name=e||t,this._changed(256)},getStyle:function(){return this._style},setStyle:function(e){this.getStyle().set(e)}},a.each(["locked","visible","blendMode","opacity","guide"],function(e){var t=a.capitalize(e),i="_"+e,n={locked:256,visible:265};this["get"+t]=function(){return this[i]},this["set"+t]=function(t){t!=this[i]&&(this[i]=t,this._changed(n[e]||257))}},{}),{beans:!0,getSelection:function(){return this._selection},setSelection:function(e){if(e!==this._selection){this._selection=e;var t=this._project;t&&(t._updateSelection(this),this._changed(257))}},_changeSelection:function(e,t){var i=this._selection;this.setSelection(t?i|e:i&~e)},isSelected:function(){if(this._selectChildren)for(var e=this._children,t=0,i=e.length;t<i;t++)if(e[t].isSelected())return!0;return!!(1&this._selection)},setSelected:function(e){if(this._selectChildren)for(var t=this._children,i=0,n=t.length;i<n;i++)t[i].setSelected(e);this._changeSelection(1,e)},isFullySelected:function(){var e=this._children,t=!!(1&this._selection);if(e&&t){for(var i=0,n=e.length;i<n;i++)if(!e[i].isFullySelected())return!1;return!0}return t},setFullySelected:function(e){var t=this._children;if(t)for(var i=0,n=t.length;i<n;i++)t[i].setFullySelected(e);this._changeSelection(1,e)},isClipMask:function(){return this._clipMask},setClipMask:function(e){this._clipMask!=(e=!!e)&&(this._clipMask=e,e&&(this.setFillColor(null),this.setStrokeColor(null)),this._changed(257),this._parent&&this._parent._changed(2048))},getData:function(){return this._data||(this._data={}),this._data},setData:function(e){this._data=e},getPosition:function(e){var t=e?f:p,i=this._position||(this._position=this._getPositionFromBounds());return new t(i.x,i.y,this,"setPosition")},setPosition:function(){this.translate(f.read(arguments).subtract(this.getPosition(!0)))},_getPositionFromBounds:function(e){return this._pivot?this._matrix._transformPoint(this._pivot):(e||this.getBounds()).getCenter(!0)},getPivot:function(){var e=this._pivot;return e?new p(e.x,e.y,this,"setPivot"):null},setPivot:function(){this._pivot=f.read(arguments,0,{clone:!0,readNull:!0}),this._position=t}},a.each({getStrokeBounds:{stroke:!0},getHandleBounds:{handle:!0},getInternalBounds:{internal:!0}},function(e,t){this[t]=function(t){return this.getBounds(t,e)}},{beans:!0,getBounds:function(e,t){var i=t||e instanceof C,n=a.set({},i?t:e,this._boundsOptions);(!n.stroke||this.getStrokeScaling())&&(n.cacheItem=this);var r=this._getCachedBounds(i&&e,n).rect;return arguments.length?r:new y(r.x,r.y,r.width,r.height,this,"setBounds")},setBounds:function(){var e=I.read(arguments),t=this.getBounds(),i=this._matrix,n=new C,a=e.getCenter();n.translate(a),(e.width!=t.width||e.height!=t.height)&&(i.isInvertible()||(i.set(i._backup||(new C).translate(i.getTranslation())),t=this.getBounds()),n.scale(0!==t.width?e.width/t.width:0,0!==t.height?e.height/t.height:0)),a=t.getCenter(),n.translate(-a.x,-a.y),this.transform(n)},_getBounds:function(e,t){var i=this._children;return i&&i.length?(S._updateBoundsCache(this,t.cacheItem),S._getBounds(i,e,t)):new I},_getBoundsCacheKey:function(e,t){return[e.stroke?1:0,e.handle?1:0,t?1:0].join("")},_getCachedBounds:function(e,t,i){e=e&&e._orNullIfIdentity();var n=t.internal&&!i,a=t.cacheItem,r=n?null:this._matrix._orNullIfIdentity(),o=a&&(!e||e.equals(r))&&this._getBoundsCacheKey(t,n),s=this._bounds;if(S._updateBoundsCache(this._parent||this._symbol,a),o&&s&&o in s)return{rect:(u=s[o]).rect.clone(),nonscaling:u.nonscaling};var l=this._getBounds(e||r,t),h=l.rect||l,d=this._style,c=l.nonscaling||d.hasStroke()&&!d.getStrokeScaling();if(o){s||(this._bounds=s={});var u=s[o]={rect:h.clone(),nonscaling:c,internal:n}}return{rect:h,nonscaling:c}},_getStrokeMatrix:function(e,t){var i=this.getStrokeScaling()?null:t&&t.internal?this:this._parent||this._symbol&&this._symbol._item,n=i?i.getViewMatrix().invert():e;return n&&n._shiftless()},statics:{_updateBoundsCache:function(e,t){if(e&&t){var i=t._id,n=e._boundsCache=e._boundsCache||{ids:{},list:[]};n.ids[i]||(n.list.push(t),n.ids[i]=t)}},_clearBoundsCache:function(e){var i=e._boundsCache;if(i){e._bounds=e._position=e._boundsCache=t;for(var n=0,a=i.list,r=a.length;n<r;n++){var o=a[n];o!==e&&(o._bounds=o._position=t,o._boundsCache&&S._clearBoundsCache(o))}}},_getBounds:function(e,t,i){var n=1/0,a=-n,r=n,o=a,s=!1;i=i||{};for(var l=0,h=e.length;l<h;l++){var d=e[l];if(d._visible&&!d.isEmpty(!0)){var c=d._getCachedBounds(t&&t.appended(d._matrix),i,!0),u=c.rect;n=Math.min(u.x,n),r=Math.min(u.y,r),a=Math.max(u.x+u.width,a),o=Math.max(u.y+u.height,o),c.nonscaling&&(s=!0)}}return{rect:isFinite(n)?new I(n,r,a-n,o-r):new I,nonscaling:s}}}}),{beans:!0,_decompose:function(){return this._applyMatrix?null:this._decomposed||(this._decomposed=this._matrix.decompose())},getRotation:function(){var e=this._decompose();return e?e.rotation:0},setRotation:function(e){var t=this.getRotation();if(null!=t&&null!=e){var i=this._decomposed;this.rotate(e-t),i&&(i.rotation=e,this._decomposed=i)}},getScaling:function(){var e=this._decompose(),t=e&&e.scaling;return new p(t?t.x:1,t?t.y:1,this,"setScaling")},setScaling:function(){var e=this.getScaling(),t=f.read(arguments,0,{clone:!0,readNull:!0});if(e&&t&&!e.equals(t)){var i=this.getRotation(),n=this._decomposed,a=new C,r=u.isZero;if(r(e.x)||r(e.y))a.translate(n.translation),i&&a.rotate(i),a.scale(t.x,t.y),this._matrix.set(a);else{var o=this.getPosition(!0);a.translate(o),i&&a.rotate(i),a.scale(t.x/e.x,t.y/e.y),i&&a.rotate(-i),a.translate(o.negate()),this.transform(a)}n&&(n.scaling=t,this._decomposed=n)}},getMatrix:function(){return this._matrix},setMatrix:function(){var e=this._matrix;e.set.apply(e,arguments)},getGlobalMatrix:function(e){var t=this._globalMatrix;if(t)for(var i=this._parent,n=[];i;){if(!i._globalMatrix){t=null;for(var a=0,r=n.length;a<r;a++)n[a]._globalMatrix=null;break}n.push(i),i=i._parent}return t||(t=this._globalMatrix=this._matrix.clone(),(i=this._parent)&&t.prepend(i.getGlobalMatrix(!0))),e?t:t.clone()},getViewMatrix:function(){return this.getGlobalMatrix().prepend(this.getView()._matrix)},getApplyMatrix:function(){return this._applyMatrix},setApplyMatrix:function(e){(this._applyMatrix=this._canApplyMatrix&&!!e)&&this.transform(null,!0)},getTransformContent:"#getApplyMatrix",setTransformContent:"#setApplyMatrix"},{getProject:function(){return this._project},_setProject:function(e,t){if(this._project!==e){this._project&&this._installEvents(!1),this._project=e;for(var i=this._children,n=0,a=i&&i.length;n<a;n++)i[n]._setProject(e);t=!0}t&&this._installEvents(!0)},getView:function(){return this._project._view},_installEvents:function e(t){e.base.call(this,t);for(var i=this._children,n=0,a=i&&i.length;n<a;n++)i[n]._installEvents(t)},getLayer:function(){for(var e=this;e=e._parent;)if(e instanceof w)return e;return null},getParent:function(){return this._parent},setParent:function(e){return e.addChild(this)},_getOwner:"#getParent",getChildren:function(){return this._children},setChildren:function(e){this.removeChildren(),this.addChildren(e)},getFirstChild:function(){return this._children&&this._children[0]||null},getLastChild:function(){return this._children&&this._children[this._children.length-1]||null},getNextSibling:function(){var e=this._getOwner();return e&&e._children[this._index+1]||null},getPreviousSibling:function(){var e=this._getOwner();return e&&e._children[this._index-1]||null},getIndex:function(){return this._index},equals:function(e){return e===this||e&&this._class===e._class&&this._style.equals(e._style)&&this._matrix.equals(e._matrix)&&this._locked===e._locked&&this._visible===e._visible&&this._blendMode===e._blendMode&&this._opacity===e._opacity&&this._clipMask===e._clipMask&&this._guide===e._guide&&this._equals(e)||!1},_equals:function(e){return a.equals(this._children,e._children)},clone:function(e){var i=new this.constructor(S.NO_INSERT),n=this._children,r=a.pick(e?e.insert:t,e===t||!0===e),o=a.pick(e?e.deep:t,!0);n&&i.copyAttributes(this),(!n||o)&&i.copyContent(this),n||i.copyAttributes(this),r&&i.insertAbove(this);var s=this._name,l=this._parent;if(s&&l){n=l._children;for(var h=s,d=1;n[s];)s=h+" "+d++;s!==h&&i.setName(s)}return i},copyContent:function(e){for(var t=e._children,i=0,n=t&&t.length;i<n;i++)this.addChild(t[i].clone(!1),!0)},copyAttributes:function(e,t){this.setStyle(e._style);for(var i=["_locked","_visible","_blendMode","_opacity","_clipMask","_guide"],n=0,r=i.length;n<r;n++){var o=i[n];e.hasOwnProperty(o)&&(this[o]=e[o])}t||this._matrix.set(e._matrix,!0),this.setApplyMatrix(e._applyMatrix),this.setPivot(e._pivot),this.setSelection(e._selection);var s=e._data,l=e._name;this._data=s?a.clone(s):null,l&&this.setName(l)},rasterize:function(e,i){var n,r,o;a.isPlainObject(e)?(n=e.resolution,r=e.insert,o=e.raster):(n=e,r=i),o||(o=new P(S.NO_INSERT));var s=this.getStrokeBounds(),l=(n||this.getView().getResolution())/72,h=s.getTopLeft().floor(),d=s.getBottomRight().ceil(),c=new m(d.subtract(h)),u=c.multiply(l);if(o.setSize(u,!0),!u.isZero()){var g=o.getContext(!0),f=(new C).scale(l).translate(h.negate());g.save(),f.applyToContext(g),this.draw(g,new a({matrices:[f]})),g.restore()}return o._matrix.set((new C).translate(h.add(c.divide(2))).scale(1/l)),(r===t||r)&&o.insertAbove(this),o},contains:function(){var e=this._matrix;return e.isInvertible()&&!!this._contains(e._inverseTransform(f.read(arguments)))},_contains:function(e){var t=this._children;if(t){for(var i=t.length-1;i>=0;i--)if(t[i].contains(e))return!0;return!1}return e.isInside(this.getInternalBounds())},isInside:function(){return I.read(arguments).contains(this.getBounds())},_asPathItem:function(){return new R.Rectangle({rectangle:this.getInternalBounds(),matrix:this._matrix,insert:!1})},intersects:function(e,t){return e instanceof S&&this._asPathItem().getIntersections(e._asPathItem(),null,t,!0).length>0}},new function(){function e(){var e=arguments;return this._hitTest(f.read(e),_.getOptions(e))}function t(){var e=arguments,t=f.read(e),i=_.getOptions(e),n=[];return this._hitTest(t,new a({all:n},i)),n}function i(e,t,i,n){var a=this._children;if(a)for(var r=a.length-1;r>=0;r--){var o=a[r],s=o!==n&&o._hitTest(e,t,i);if(s&&!t.all)return s}return null}return x.inject({hitTest:e,hitTestAll:t,_hitTest:i}),{hitTest:e,hitTestAll:t,_hitTestChildren:i}},{_hitTest:function(e,t,i){if(this._locked||!this._visible||this._guide&&!t.guides||this.isEmpty())return null;var n=this._matrix,r=i?i.appended(n):this.getGlobalMatrix().prepend(this.getView()._matrix),o=Math.max(t.tolerance,1e-12),s=t._tolerancePadding=new m(R._getStrokePadding(o,n._shiftless().invert()));if(!(e=n._inverseTransform(e))||!this._children&&!this.getBounds({internal:!0,stroke:!0,handle:!0}).expand(s.multiply(2))._containsPoint(e))return null;var l,h,d=!(t.guides&&!this._guide||t.selected&&!this.isSelected()||t.type&&t.type!==a.hyphenate(this._class)||t.class&&!(this instanceof t.class)),c=t.match,u=this;function g(e){return e&&c&&!c(e)&&(e=null),e&&t.all&&t.all.push(e),e}function f(t,i){var n=i?l["get"+i]():u.getPosition();if(e.subtract(n).divide(s).length<=1)return new _(t,u,{name:i?a.hyphenate(i):t,point:n})}var p=t.position,v=t.center,I=t.bounds;if(d&&this._parent&&(p||v||I)){if((v||I)&&(l=this.getInternalBounds()),!(h=p&&f("position")||v&&f("center","Center"))&&I)for(var y=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],C=0;C<8&&!h;C++)h=f("bounds",y[C]);h=g(h)}return h||(h=this._hitTestChildren(e,t,r)||d&&g(this._hitTestSelf(e,t,r,this.getStrokeScaling()?null:r._shiftless().invert()))||null),h&&h.point&&(h.point=n.transform(h.point)),h},_hitTestSelf:function(e,t){if(t.fill&&this.hasFill()&&this._contains(e))return new _("fill",this)},matches:function(e,t){var i=typeof e;if("object"===i){for(var n in e)if(e.hasOwnProperty(n)&&!this.matches(n,e[n]))return!1;return!0}if("function"===i)return e(this);if("match"===e)return t(this);var r=/^(empty|editable)$/.test(e)?this["is"+a.capitalize(e)]():"type"===e?a.hyphenate(this._class):this[e];if("class"===e){if("function"==typeof t)return this instanceof t;r=this._class}if("function"==typeof t)return!!t(r);if(t){if(t.test)return t.test(r);if(a.isPlainObject(t))return function e(t,i){for(var n in t)if(t.hasOwnProperty(n)){var r=t[n],o=i[n];if(a.isPlainObject(r)&&a.isPlainObject(o)){if(!e(r,o))return!1}else if(!a.equals(r,o))return!1}return!0}(t,r)}return a.equals(r,t)},getItems:function(e){return S._getItems(this,e,this._matrix)},getItem:function(e){return S._getItems(this,e,this._matrix,null,!0)[0]||null},statics:{_getItems:function e(t,i,n,r,o){if(!r){var s="object"==typeof i&&i,l=s&&s.overlapping,h=s&&s.inside,d=(y=l||h)&&I.read([y]);r={items:[],recursive:s&&!1!==s.recursive,inside:!!h,overlapping:!!l,rect:d,path:l&&new R.Rectangle({rectangle:d,insert:!1})},s&&(i=a.filter({},i,{recursive:!0,inside:!0,overlapping:!0}))}var c=t._children,u=r.items;n=(d=r.rect)&&(n||new C);for(var g=0,f=c&&c.length;g<f;g++){var p=c[g],m=n&&n.appended(p._matrix),v=!0;if(d){var y=p.getBounds(m);if(!d.intersects(y))continue;d.contains(y)||r.overlapping&&(y.contains(d)||r.path.intersects(p,m))||(v=!1)}if(v&&p.matches(i)&&(u.push(p),o)||(!1!==r.recursive&&e(p,i,m,r,o),o&&u.length>0))break}return u}}},{importJSON:function(e){var t=a.importJSON(e,this);return t!==this?this.addChild(t):t},addChild:function(e){return this.insertChild(t,e)},insertChild:function(e,t){var i=t?this.insertChildren(e,[t]):null;return i&&i[0]},addChildren:function(e){return this.insertChildren(this._children.length,e)},insertChildren:function(e,t){var i=this._children;if(i&&t&&t.length>0){for(var n={},r=(t=a.slice(t)).length-1;r>=0;r--){var o=(d=t[r])&&d._id;!d||n[o]?t.splice(r,1):(d._remove(!1,!0),n[o]=!0)}a.splice(i,t,e,0);for(var s=this._project,l=s._changes,h=(r=0,t.length);r<h;r++){var d,c=(d=t[r])._name;d._parent=this,d._setProject(s,!0),c&&d.setName(c),l&&d._changed(5)}this._changed(11)}else t=null;return t},_insertItem:"#insertChild",_insertAt:function(e,t){var i=e&&e._getOwner(),n=e!==this&&i?this:null;return n&&(n._remove(!1,!0),i._insertItem(e._index+t,n)),n},insertAbove:function(e){return this._insertAt(e,1)},insertBelow:function(e){return this._insertAt(e,0)},sendToBack:function(){var e=this._getOwner();return e?e._insertItem(0,this):null},bringToFront:function(){var e=this._getOwner();return e?e._insertItem(t,this):null},appendTop:"#addChild",appendBottom:function(e){return this.insertChild(0,e)},moveAbove:"#insertAbove",moveBelow:"#insertBelow",addTo:function(e){return e._insertItem(t,this)},copyTo:function(e){return this.clone(!1).addTo(e)},reduce:function(e){var t=this._children;if(t&&1===t.length){var i=t[0].reduce(e);return this._parent?(i.insertAbove(this),this.remove()):i.remove(),i}return this},_removeNamed:function(){var e=this._getOwner();if(e){var t=e._children,i=e._namedChildren,n=this._name,a=i[n],r=a?a.indexOf(this):-1;-1!==r&&(t[n]==this&&delete t[n],a.splice(r,1),a.length?t[n]=a[0]:delete i[n])}},_remove:function(e,t){var i=this._getOwner(),n=this._project,r=this._index;return this._style&&this._style._dispose(),!!i&&(this._name&&this._removeNamed(),null!=r&&(n._activeLayer===this&&(n._activeLayer=this.getNextSibling()||this.getPreviousSibling()),a.splice(i._children,null,r,1)),this._installEvents(!1),e&&n._changes&&this._changed(5),t&&i._changed(11,this),this._parent=null,!0)},remove:function(){return this._remove(!0,!0)},replaceWith:function(e){var t=e&&e.insertBelow(this);return t&&this.remove(),t},removeChildren:function(e,t){if(!this._children)return null;e=e||0,t=a.pick(t,this._children.length);for(var i=a.splice(this._children,null,e,t-e),n=i.length-1;n>=0;n--)i[n]._remove(!0,!1);return i.length>0&&this._changed(11),i},clear:"#removeChildren",reverseChildren:function(){if(this._children){this._children.reverse();for(var e=0,t=this._children.length;e<t;e++)this._children[e]._index=e;this._changed(11)}},isEmpty:function(e){var t=this._children,i=t?t.length:0;if(e){for(var n=0;n<i;n++)if(!t[n].isEmpty(e))return!1;return!0}return!i},isEditable:function(){for(var e=this;e;){if(!e._visible||e._locked)return!1;e=e._parent}return!0},hasFill:function(){return this.getStyle().hasFill()},hasStroke:function(){return this.getStyle().hasStroke()},hasShadow:function(){return this.getStyle().hasShadow()},_getOrder:function(e){function t(e){var t=[];do{t.unshift(e)}while(e=e._parent);return t}for(var i=t(this),n=t(e),a=0,r=Math.min(i.length,n.length);a<r;a++)if(i[a]!=n[a])return i[a]._index<n[a]._index?1:-1;return 0},hasChildren:function(){return this._children&&this._children.length>0},isInserted:function(){return!!this._parent&&this._parent.isInserted()},isAbove:function(e){return-1===this._getOrder(e)},isBelow:function(e){return 1===this._getOrder(e)},isParent:function(e){return this._parent===e},isChild:function(e){return e&&e._parent===this},isDescendant:function(e){for(var t=this;t=t._parent;)if(t===e)return!0;return!1},isAncestor:function(e){return!!e&&e.isDescendant(this)},isSibling:function(e){return this._parent===e._parent},isGroupedWith:function(e){for(var t=this._parent;t;){if(t._parent&&/^(Group|Layer|CompoundPath)$/.test(t._class)&&e.isDescendant(t))return!0;t=t._parent}return!1}},a.each(["rotate","scale","shear","skew"],function(e){var t="rotate"===e;this[e]=function(){var i=arguments,n=(t?a:f).read(i),r=f.read(i,0,{readNull:!0});return this.transform((new C)[e](n,r||this.getPosition(!0)))}},{translate:function(){var e=new C;return this.transform(e.translate.apply(e,arguments))},transform:function(e,t,i){var n=this._matrix,a=e&&!e.isIdentity(),r=i&&this._canApplyMatrix||this._applyMatrix&&(a||!n.isIdentity()||t&&this._children);if(!a&&!r)return this;if(a){!e.isInvertible()&&n.isInvertible()&&(n._backup=n.getValues()),n.prepend(e,!0);var o=this._style,s=o.getFillColor(!0),l=o.getStrokeColor(!0);s&&s.transform(e),l&&l.transform(e)}if(r&&(r=this._transformContent(n,t,i))){var h=this._pivot;h&&n._transformPoint(h,h,!0),n.reset(!0),i&&this._canApplyMatrix&&(this._applyMatrix=!0)}var d=this._bounds,c=this._position;(a||r)&&this._changed(25);var u=a&&d&&e.decompose();if(u&&u.skewing.isZero()&&u.rotation%90==0){for(var g in d){var f=d[g];if(f.nonscaling)delete d[g];else if(r||!f.internal){var p=f.rect;e._transformBounds(p,p)}}this._bounds=d;var m=d[this._getBoundsCacheKey(this._boundsOptions||{})];m&&(this._position=this._getPositionFromBounds(m.rect))}else a&&c&&this._pivot&&(this._position=e._transformPoint(c,c));return this},_transformContent:function(e,t,i){var n=this._children;if(n){for(var a=0,r=n.length;a<r;a++)n[a].transform(e,t,i);return!0}},globalToLocal:function(){return this.getGlobalMatrix(!0)._inverseTransform(f.read(arguments))},localToGlobal:function(){return this.getGlobalMatrix(!0)._transformPoint(f.read(arguments))},parentToLocal:function(){return this._matrix._inverseTransform(f.read(arguments))},localToParent:function(){return this._matrix._transformPoint(f.read(arguments))},fitBounds:function(e,t){e=I.read(arguments);var i=this.getBounds(),n=i.height/i.width,a=e.height/e.width,r=(t?n>a:n<a)?e.width/i.width:e.height/i.height,o=new I(new f,new m(i.width*r,i.height*r));o.setCenter(e.getCenter()),this.setBounds(o)}}),{_setStyles:function(e,t,i){var n=this._style,a=this._matrix;if(n.hasFill()&&(e.fillStyle=n.getFillColor().toCanvasStyle(e,a)),n.hasStroke()){e.strokeStyle=n.getStrokeColor().toCanvasStyle(e,a),e.lineWidth=n.getStrokeWidth();var r=n.getStrokeJoin(),o=n.getStrokeCap(),s=n.getMiterLimit();if(r&&(e.lineJoin=r),o&&(e.lineCap=o),s&&(e.miterLimit=s),le.support.nativeDash){var l=n.getDashArray(),h=n.getDashOffset();l&&l.length&&("setLineDash"in e?(e.setLineDash(l),e.lineDashOffset=h):(e.mozDash=l,e.mozDashOffset=h))}}if(n.hasShadow()){var d=t.pixelRatio||1,c=i._shiftless().prepend((new C).scale(d,d)),u=c.transform(new f(n.getShadowBlur(),0)),g=c.transform(this.getShadowOffset());e.shadowColor=n.getShadowColor().toCanvasStyle(e),e.shadowBlur=u.getLength(),e.shadowOffsetX=g.x,e.shadowOffsetY=g.y}},draw:function(e,t,i){if(this._updateVersion=this._project._updateVersion,this._visible&&0!==this._opacity){var n=t.matrices,a=t.viewMatrix,r=this._matrix,o=n[n.length-1].appended(r);if(o.isInvertible()){a=a?a.appended(o):o,n.push(o),t.updateMatrix&&(this._globalMatrix=o);var s,l,h,d=this._blendMode,c=u.clamp(this._opacity,0,1),g="normal"===d,f=re.nativeModes[d],p=g&&1===c||t.dontStart||t.clip||(f||g&&c<1)&&this._canComposite(),m=t.pixelRatio||1;if(!p){var v=this.getStrokeBounds(a);if(!v.width||!v.height)return void n.pop();h=t.offset,l=t.offset=v.getTopLeft().floor(),s=e,e=ae.getContext(v.getSize().ceil().add(1).multiply(m)),1!==m&&e.scale(m,m)}e.save();var I=i?i.appended(r):this._canScaleStroke&&!this.getStrokeScaling(!0)&&a,y=!p&&t.clipItem,C=!I||y;if(p?(e.globalAlpha=c,f&&(e.globalCompositeOperation=d)):C&&e.translate(-l.x,-l.y),C&&(p?r:a).applyToContext(e),y&&t.clipItem.draw(e,t.extend({clip:!0})),I){e.setTransform(m,0,0,m,0,0);var M=t.offset;M&&e.translate(-M.x,-M.y)}this._draw(e,t,a,I),e.restore(),n.pop(),t.clip&&!t.dontFinish&&e.clip(this.getFillRule()),p||(re.process(d,e,s,c,l.subtract(h).multiply(m)),ae.release(e),t.offset=h)}}},_isUpdated:function(e){var t=this._parent;if(t instanceof F)return t._isUpdated(e);var i=this._updateVersion===e;return!i&&t&&t._visible&&t._isUpdated(e)&&(this._updateVersion=e,i=!0),i},_drawSelection:function(e,t,i,n,a){var r=this._selection,o=1&r,s=2&r||o&&this._selectBounds,l=4&r;if(this._drawSelected||(o=!1),(o||s||l)&&this._isUpdated(a)){var h,d=this.getSelectedColor(!0)||(h=this.getLayer())&&h.getSelectedColor(!0),c=t.appended(this.getGlobalMatrix(!0)),u=i/2;if(e.strokeStyle=e.fillStyle=d?d.toCanvasStyle(e):"#009dec",o&&this._drawSelected(e,c,n),l){var g=this.getPosition(!0),f=this._parent,p=f?f.localToGlobal(g):g,m=p.x,v=p.y;e.beginPath(),e.arc(m,v,u,0,2*Math.PI,!0),e.stroke();for(var I=[[0,-1],[1,0],[0,1],[-1,0]],y=u,C=i+1,M=0;M<4;M++){var x=I[M],S=x[0],b=x[1];e.moveTo(m+S*y,v+b*y),e.lineTo(m+S*C,v+b*C),e.stroke()}}if(s){var w=c._transformCorners(this.getInternalBounds());for(e.beginPath(),M=0;M<8;M++)e[M?"lineTo":"moveTo"](w[M],w[++M]);for(e.closePath(),e.stroke(),M=0;M<8;M++)e.fillRect(w[M]-u,w[++M]-u,i,i)}}},_canComposite:function(){return!1}},a.each(["down","drag","up","move"],function(e){this["removeOn"+a.capitalize(e)]=function(){var t={};return t[e]=!0,this.removeOn(t)}},{removeOn:function(e){for(var t in e)if(e[t]){var i="mouse"+t,n=this._project,a=n._removeSets=n._removeSets||{};a[i]=a[i]||{},a[i][this._id]=this}return this}}),{tween:function(e,t,i){i||(i=t,t=e,e=null,i||(i=t,t=null));var n=i&&i.easing,a=i&&i.start,r=null!=i&&("number"==typeof i?i:i.duration),o=new ie(this,e,t,r,n,a);return r&&this.on("frame",function e(t){o._handleFrame(1e3*t.time),o.running||this.off("frame",e)}),o},tweenTo:function(e,t){return this.tween(null,e,t)},tweenFrom:function(e,t){return this.tween(e,null,t)}}),b=S.extend({_class:"Group",_selectBounds:!1,_selectChildren:!0,_serializeFields:{children:[]},initialize:function(e){this._children=[],this._namedChildren={},this._initialize(e)||this.addChildren(Array.isArray(e)?e:arguments)},_changed:function e(i){e.base.call(this,i),2050&i&&(this._clipItem=t)},_getClipItem:function(){var e=this._clipItem;if(e===t){e=null;for(var i=this._children,n=0,a=i.length;n<a;n++)if(i[n]._clipMask){e=i[n];break}this._clipItem=e}return e},isClipped:function(){return!!this._getClipItem()},setClipped:function(e){var t=this.getFirstChild();t&&t.setClipMask(e)},_getBounds:function e(t,i){var n=this._getClipItem();return n?n._getCachedBounds(n._matrix.prepended(t),a.set({},i,{stroke:!1})):e.base.call(this,t,i)},_hitTestChildren:function e(t,i,n){var a=this._getClipItem();return(!a||a.contains(t))&&e.base.call(this,t,i,n,a)},_draw:function(e,t){var i=t.clip,n=!i&&this._getClipItem();t=t.extend({clipItem:n,clip:!1}),i?(e.beginPath(),t.dontStart=t.dontFinish=!0):n&&n.draw(e,t.extend({clip:!0}));for(var a=this._children,r=0,o=a.length;r<o;r++){var s=a[r];s!==n&&s.draw(e,t)}}}),w=b.extend({_class:"Layer",initialize:function(){b.apply(this,arguments)},_getOwner:function(){return this._parent||null!=this._index&&this._project},isInserted:function e(){return this._parent?e.base.call(this):null!=this._index},activate:function(){this._project._activeLayer=this},_hitTestSelf:function(){}}),A=S.extend({_class:"Shape",_applyMatrix:!1,_canApplyMatrix:!1,_canScaleStroke:!0,_serializeFields:{type:null,size:null,radius:null},initialize:function(e,t){this._initialize(e,t)},_equals:function(e){return this._type===e._type&&this._size.equals(e._size)&&a.equals(this._radius,e._radius)},copyContent:function(e){this.setType(e._type),this.setSize(e._size),this.setRadius(e._radius)},getType:function(){return this._type},setType:function(e){this._type=e},getShape:"#getType",setShape:"#setType",getSize:function(){var e=this._size;return new v(e.width,e.height,this,"setSize")},setSize:function(){var e=m.read(arguments);if(this._size){if(!this._size.equals(e)){var t=this._type,i=e.width,n=e.height;"rectangle"===t?this._radius.set(m.min(this._radius,e.divide(2).abs())):"circle"===t?(i=n=(i+n)/2,this._radius=i/2):"ellipse"===t&&this._radius._set(i/2,n/2),this._size._set(i,n),this._changed(9)}}else this._size=e.clone()},getRadius:function(){var e=this._radius;return"circle"===this._type?e:new v(e.width,e.height,this,"setRadius")},setRadius:function(e){var t=this._type;if("circle"===t){if(e===this._radius)return;var i=2*e;this._radius=e,this._size._set(i,i)}else if(e=m.read(arguments),this._radius){if(this._radius.equals(e))return;this._radius.set(e),"rectangle"===t?(i=m.max(this._size,e.multiply(2)),this._size.set(i)):"ellipse"===t&&this._size._set(2*e.width,2*e.height)}else this._radius=e.clone();this._changed(9)},isEmpty:function(){return!1},toPath:function(e){var i=new(R[a.capitalize(this._type)])({center:new f,size:this._size,radius:this._radius,insert:!1});return i.copyAttributes(this),le.settings.applyMatrix&&i.setApplyMatrix(!0),(e===t||e)&&i.insertAbove(this),i},toShape:"#clone",_asPathItem:function(){return this.toPath(!1)},_draw:function(e,t,i,n){var a=this._style,r=a.hasFill(),o=a.hasStroke(),s=t.dontFinish||t.clip,l=!n;if(r||o||s){var h=this._type,d=this._radius,c="circle"===h;if(t.dontStart||e.beginPath(),l&&c)e.arc(0,0,d,0,2*Math.PI,!0);else{var u=c?d:d.width,g=c?d:d.height,f=this._size,p=f.width,m=f.height;if(l&&"rectangle"===h&&0===u&&0===g)e.rect(-p/2,-m/2,p,m);else{var v=p/2,I=m/2,y=.44771525016920644,C=u*y,M=g*y,x=[-v,-I+g,-v,-I+M,-v+C,-I,-v+u,-I,v-u,-I,v-C,-I,v,-I+M,v,-I+g,v,I-g,v,I-M,v-C,I,v-u,I,-v+u,I,-v+C,I,-v,I-M,-v,I-g];n&&n.transform(x,x,32),e.moveTo(x[0],x[1]),e.bezierCurveTo(x[2],x[3],x[4],x[5],x[6],x[7]),v!==u&&e.lineTo(x[8],x[9]),e.bezierCurveTo(x[10],x[11],x[12],x[13],x[14],x[15]),I!==g&&e.lineTo(x[16],x[17]),e.bezierCurveTo(x[18],x[19],x[20],x[21],x[22],x[23]),v!==u&&e.lineTo(x[24],x[25]),e.bezierCurveTo(x[26],x[27],x[28],x[29],x[30],x[31])}}e.closePath()}!s&&(r||o)&&(this._setStyles(e,t,i),r&&(e.fill(a.getFillRule()),e.shadowColor="rgba(0,0,0,0)"),o&&e.stroke())},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_getBounds:function(e,t){var i=new I(this._size).setCenter(0,0),n=this._style,a=t.stroke&&n.hasStroke()&&n.getStrokeWidth();return e&&(i=e._transformBounds(i)),a?i.expand(R._getStrokePadding(a,this._getStrokeMatrix(e,t))):i}},new function(){function e(e,t,i){var n=e._radius;if(!n.isZero())for(var a=e._size.divide(2),r=1;r<=4;r++){var o=new f(r>1&&r<4?-1:1,r>2?-1:1),s=o.multiply(a),l=s.subtract(o.multiply(n));if(new I(i?s.add(o.multiply(i)):s,l).contains(t))return{point:l,quadrant:r}}}function t(e,t,i,n){var a=e.divide(t);return(!n||a.isInQuadrant(n))&&a.subtract(a.normalize()).multiply(t).divide(i).length<=1}return{_contains:function t(i){if("rectangle"===this._type){var n=e(this,i);return n?i.subtract(n.point).divide(this._radius).getLength()<=1:t.base.call(this,i)}return i.divide(this.size).getLength()<=.5},_hitTestSelf:function i(n,a,r,o){var s=!1,l=this._style,h=a.stroke&&l.hasStroke(),d=a.fill&&l.hasFill();if(h||d){var c=this._type,u=this._radius,g=h?l.getStrokeWidth()/2:0,f=a._tolerancePadding.add(R._getStrokePadding(g,!l.getStrokeScaling()&&o));if("rectangle"===c){var p=f.multiply(2),m=e(this,n,p);if(m)s=t(n.subtract(m.point),u,f,m.quadrant);else{var v=new I(this._size).setCenter(0,0),y=v.expand(p),C=v.expand(p.negate());s=y._containsPoint(n)&&!C._containsPoint(n)}}else s=t(n,u,f)}return s?new _(h?"stroke":"fill",this):i.base.apply(this,arguments)}}},{statics:new function(){function e(e,t,i,n,r){var o=a.create(A.prototype);return o._type=e,o._size=i,o._radius=n,o._initialize(a.getNamed(r),t),o}return{Circle:function(){var t=arguments,i=f.readNamed(t,"center"),n=a.readNamed(t,"radius");return e("circle",i,new m(2*n),n,t)},Rectangle:function(){var t=arguments,i=I.readNamed(t,"rectangle"),n=m.min(m.readNamed(t,"radius"),i.getSize(!0).divide(2));return e("rectangle",i.getCenter(!0),i.getSize(!0),n,t)},Ellipse:function(){var t=arguments,i=A._readEllipse(t),n=i.radius;return e("ellipse",i.center,n.multiply(2),n,t)},_readEllipse:function(e){var t,i;if(a.hasNamed(e,"radius"))t=f.readNamed(e,"center"),i=m.readNamed(e,"radius");else{var n=I.readNamed(e,"rectangle");t=n.getCenter(!0),i=n.getSize(!0).divide(2)}return{center:t,radius:i}}}}}),P=S.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!1,handle:!1},_serializeFields:{crossOrigin:null,source:null},_prioritize:["crossOrigin"],_smoothing:"low",beans:!0,initialize:function(e,i){if(!this._initialize(e,i!==t&&f.read(arguments))){var a,r=typeof e,o="string"===r?n.getElementById(e):"object"===r?e:null;if(o&&o!==S.NO_INSERT)if(o.getContext||null!=o.naturalHeight)a=o;else if(o){var s=m.read(arguments);s.isZero()||(a=ae.getCanvas(s))}a?this.setImage(a):this.setSource(e)}this._size||(this._size=new m,this._loaded=!1)},_equals:function(e){return this.getSource()===e.getSource()},copyContent:function(e){var t=e._image,i=e._canvas;if(t)this._setImage(t);else if(i){var n=ae.getCanvas(e._size);n.getContext("2d").drawImage(i,0,0),this._setImage(n)}this._crossOrigin=e._crossOrigin},getSize:function(){var e=this._size;return new v(e?e.width:0,e?e.height:0,this,"setSize")},setSize:function(e,t){var i=m.read(arguments);if(i.equals(this._size))t&&this.clear();else if(i.width>0&&i.height>0){var n=!t&&this.getElement();this._setImage(ae.getCanvas(i)),n&&this.getContext(!0).drawImage(n,0,0,i.width,i.height)}else this._canvas&&ae.release(this._canvas),this._size=i.clone()},getWidth:function(){return this._size?this._size.width:0},setWidth:function(e){this.setSize(e,this.getHeight())},getHeight:function(){return this._size?this._size.height:0},setHeight:function(e){this.setSize(this.getWidth(),e)},getLoaded:function(){return this._loaded},isEmpty:function(){var e=this._size;return!e||0===e.width&&0===e.height},getResolution:function(){var e=this._matrix,t=new f(0,0).transform(e),i=new f(1,0).transform(e).subtract(t),n=new f(0,1).transform(e).subtract(t);return new m(72/i.getLength(),72/n.getLength())},getPpi:"#getResolution",getImage:function(){return this._image},setImage:function(e){var t=this;function i(e){var i=t.getView(),n=e&&e.type||"load";i&&t.responds(n)&&(le=i._scope,t.emit(n,new K(e)))}this._setImage(e),this._loaded?setTimeout(i,0):e&&q.add(e,{load:function(n){t._setImage(e),i(n)},error:i})},_setImage:function(e){this._canvas&&ae.release(this._canvas),e&&e.getContext?(this._image=null,this._canvas=e,this._loaded=!0):(this._image=e,this._canvas=null,this._loaded=!!(e&&e.src&&e.complete)),this._size=new m(e?e.naturalWidth||e.width:0,e?e.naturalHeight||e.height:0),this._context=null,this._changed(1033)},getCanvas:function(){if(!this._canvas){var e=ae.getContext(this._size);try{this._image&&e.drawImage(this._image,0,0),this._canvas=e.canvas}catch(t){ae.release(e)}}return this._canvas},setCanvas:"#setImage",getContext:function(e){return this._context||(this._context=this.getCanvas().getContext("2d")),e&&(this._image=null,this._changed(1025)),this._context},setContext:function(e){this._context=e},getSource:function(){var e=this._image;return e&&e.src||this.toDataURL()},setSource:function(t){var i=new e.Image,n=this._crossOrigin;n&&(i.crossOrigin=n),t&&(i.src=t),this.setImage(i)},getCrossOrigin:function(){var e=this._image;return e&&e.crossOrigin||this._crossOrigin||""},setCrossOrigin:function(e){this._crossOrigin=e;var t=this._image;t&&(t.crossOrigin=e)},getSmoothing:function(){return this._smoothing},setSmoothing:function(e){this._smoothing="string"==typeof e?e:e?"low":"off",this._changed(257)},getElement:function(){return this._canvas||this._loaded&&this._image}},{beans:!1,getSubCanvas:function(){var e=I.read(arguments),t=ae.getContext(e.getSize());return t.drawImage(this.getCanvas(),e.x,e.y,e.width,e.height,0,0,e.width,e.height),t.canvas},getSubRaster:function(){var e=I.read(arguments),t=new P(S.NO_INSERT);return t._setImage(this.getSubCanvas(e)),t.translate(e.getCenter().subtract(this.getSize().divide(2))),t._matrix.prepend(this._matrix),t.insertAbove(this),t},toDataURL:function(){var e=this._image,t=e&&e.src;if(/^data:/.test(t))return t;var i=this.getCanvas();return i?i.toDataURL.apply(i,arguments):null},drawImage:function(e){var t=f.read(arguments,1);this.getContext(!0).drawImage(e,t.x,t.y)},getAverageColor:function(e){var t,i;if(e?e instanceof E?(i=e,t=e.getBounds()):"object"==typeof e&&("width"in e?t=new I(e):"x"in e&&(t=new I(e.x-.5,e.y-.5,1,1))):t=this.getBounds(),!t)return null;var n=Math.min(t.width,32),r=Math.min(t.height,32),o=P._sampleContext;o?o.clearRect(0,0,33,33):o=P._sampleContext=ae.getContext(new m(32)),o.save();var s=(new C).scale(n/t.width,r/t.height).translate(-t.x,-t.y);s.applyToContext(o),i&&i.draw(o,new a({clip:!0,matrices:[s]})),this._matrix.applyToContext(o);var l=this.getElement(),h=this._size;l&&o.drawImage(l,-h.width/2,-h.height/2),o.restore();for(var d=o.getImageData(.5,.5,Math.ceil(n),Math.ceil(r)).data,c=[0,0,0],u=0,g=0,f=d.length;g<f;g+=4){var p=d[g+3];u+=p,p/=255,c[0]+=d[g]*p,c[1]+=d[g+1]*p,c[2]+=d[g+2]*p}for(g=0;g<3;g++)c[g]/=u;return u?N.read(c):null},getPixel:function(){var e=f.read(arguments),t=this.getContext().getImageData(e.x,e.y,1,1).data;return new N("rgb",[t[0]/255,t[1]/255,t[2]/255],t[3]/255)},setPixel:function(){var e=arguments,t=f.read(e),i=N.read(e),n=i._convert("rgb"),a=i._alpha,r=this.getContext(!0),o=r.createImageData(1,1),s=o.data;s[0]=255*n[0],s[1]=255*n[1],s[2]=255*n[2],s[3]=null!=a?255*a:255,r.putImageData(o,t.x,t.y)},clear:function(){var e=this._size;this.getContext(!0).clearRect(0,0,e.width+1,e.height+1)},createImageData:function(){var e=m.read(arguments);return this.getContext().createImageData(e.width,e.height)},getImageData:function(){var e=I.read(arguments);return e.isEmpty()&&(e=new I(this._size)),this.getContext().getImageData(e.x,e.y,e.width,e.height)},putImageData:function(e){var t=f.read(arguments,1);this.getContext(!0).putImageData(e,t.x,t.y)},setImageData:function(e){this.setSize(e),this.getContext(!0).putImageData(e,0,0)},_getBounds:function(e,t){var i=new I(this._size).setCenter(0,0);return e?e._transformBounds(i):i},_hitTestSelf:function(e){if(this._contains(e)){var t=this;return new _("pixel",t,{offset:e.add(t._size.divide(2)).round(),color:{get:function(){return t.getPixel(this.offset)}}})}},_draw:function(e,t,i){var n=this.getElement();if(n&&n.width>0&&n.height>0){e.globalAlpha=u.clamp(this._opacity,0,1),this._setStyles(e,t,i);var a=this._smoothing,r="off"===a;V.setPrefixed(e,r?"imageSmoothingEnabled":"imageSmoothingQuality",!r&&a),e.drawImage(n,-this._size.width/2,-this._size.height/2)}},_canComposite:function(){return!0}}),D=S.extend({_class:"SymbolItem",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!0},_serializeFields:{symbol:null},initialize:function(e,i){this._initialize(e,i!==t&&f.read(arguments,1))||this.setDefinition(e instanceof k?e:new k(e))},_equals:function(e){return this._definition===e._definition},copyContent:function(e){this.setDefinition(e._definition)},getDefinition:function(){return this._definition},setDefinition:function(e){this._definition=e,this._changed(9)},getSymbol:"#getDefinition",setSymbol:"#setDefinition",isEmpty:function(){return this._definition._item.isEmpty()},_getBounds:function(e,t){var i=this._definition._item;return i._getCachedBounds(i._matrix.prepended(e),t)},_hitTestSelf:function(e,t,i){var n=t.extend({all:!1}),a=this._definition._item._hitTest(e,n,i);return a&&(a.item=this),a},_draw:function(e,t){this._definition._item.draw(e,t)}}),k=a.extend({_class:"SymbolDefinition",initialize:function(e,t){this._id=g.get(),this.project=le.project,e&&this.setItem(e,t)},_serialize:function(e,t){return t.add(this,function(){return a.serialize([this._class,this._item],e,!1,t)})},_changed:function(e){8&e&&S._clearBoundsCache(this),1&e&&this.project._changed(e)},getItem:function(){return this._item},setItem:function(e,t){e._symbol&&(e=e.clone()),this._item&&(this._item._symbol=null),this._item=e,e.remove(),e.setSelected(!1),t||e.setPosition(new f),e._symbol=this,this._changed(9)},getDefinition:"#getItem",setDefinition:"#setItem",place:function(e){return new D(this,e)},clone:function(){return new k(this._item.clone(!1))},equals:function(e){return e===this||e&&this._item.equals(e._item)||!1}}),_=a.extend({_class:"HitResult",initialize:function(e,t,i){this.type=e,this.item=t,i&&this.inject(i)},statics:{getOptions:function(e){var t=e&&a.read(e);return new a({type:null,tolerance:le.settings.hitTolerance,fill:!t,stroke:!t,segments:!t,handles:!1,ends:!1,position:!1,center:!1,bounds:!1,guides:!1,selected:!1},t)}}}),T=a.extend({_class:"Segment",beans:!0,_selection:0,initialize:function(e,i,n,a,r,o){var s,l,h,d,c=arguments.length;c>0&&(null==e||"object"==typeof e?1===c&&e&&"point"in e?(s=e.point,l=e.handleIn,h=e.handleOut,d=e.selection):(s=e,l=i,h=n,d=a):(s=[e,i],l=n!==t?[n,a]:null,h=r!==t?[r,o]:null)),new z(s,this,"_point"),new z(l,this,"_handleIn"),new z(h,this,"_handleOut"),d&&this.setSelection(d)},_serialize:function(e,t){var i=this._point,n=this._selection,r=n||this.hasHandles()?[i,this._handleIn,this._handleOut]:i;return n&&r.push(n),a.serialize(r,e,!0,t)},_changed:function(e){var t=this._path;if(t){var i,n=t._curves,a=this._index;n&&((!e||e===this._point||e===this._handleIn)&&(i=a>0?n[a-1]:t._closed?n[n.length-1]:null)&&i._changed(),(!e||e===this._point||e===this._handleOut)&&(i=n[a])&&i._changed()),t._changed(41)}},getPoint:function(){return this._point},setPoint:function(){this._point.set(f.read(arguments))},getHandleIn:function(){return this._handleIn},setHandleIn:function(){this._handleIn.set(f.read(arguments))},getHandleOut:function(){return this._handleOut},setHandleOut:function(){this._handleOut.set(f.read(arguments))},hasHandles:function(){return!this._handleIn.isZero()||!this._handleOut.isZero()},isSmooth:function(){var e=this._handleIn,t=this._handleOut;return!e.isZero()&&!t.isZero()&&e.isCollinear(t)},clearHandles:function(){this._handleIn._set(0,0),this._handleOut._set(0,0)},getSelection:function(){return this._selection},setSelection:function(e){var t=this._selection,i=this._path;this._selection=e=e||0,i&&e!==t&&(i._updateSelection(this,t,e),i._changed(257))},_changeSelection:function(e,t){var i=this._selection;this.setSelection(t?i|e:i&~e)},isSelected:function(){return!!(7&this._selection)},setSelected:function(e){this._changeSelection(7,e)},getIndex:function(){return this._index!==t?this._index:null},getPath:function(){return this._path||null},getCurve:function(){var e=this._path,t=this._index;return e?(t>0&&!e._closed&&t===e._segments.length-1&&t--,e.getCurves()[t]||null):null},getLocation:function(){var e=this.getCurve();return e?new B(e,this===e._segment1?0:1):null},getNext:function(){var e=this._path&&this._path._segments;return e&&(e[this._index+1]||this._path._closed&&e[0])||null},smooth:function(e,i,n){var a=e||{},r=a.type,o=a.factor,s=this.getPrevious(),l=this.getNext(),h=(s||this)._point,d=this._point,c=(l||this)._point,u=h.getDistance(d),g=d.getDistance(c);if(r&&"catmull-rom"!==r){if("geometric"!==r)throw new Error("Smoothing method '"+r+"' not supported.");if(s&&l){var p=h.subtract(c),m=o===t?.4:o,v=m*u/(u+g);i||this.setHandleIn(p.multiply(v)),n||this.setHandleOut(p.multiply(v-m))}}else{var I=o===t?.5:o,y=Math.pow(u,I),C=y*y,M=Math.pow(g,I),x=M*M;if(!i&&s){var S=2*x+3*M*y+C,b=3*M*(M+y);this.setHandleIn(0!==b?new f((x*h._x+S*d._x-C*c._x)/b-d._x,(x*h._y+S*d._y-C*c._y)/b-d._y):new f)}!n&&l&&(S=2*C+3*y*M+x,b=3*y*(y+M),this.setHandleOut(0!==b?new f((C*c._x+S*d._x-x*h._x)/b-d._x,(C*c._y+S*d._y-x*h._y)/b-d._y):new f))}},getPrevious:function(){var e=this._path&&this._path._segments;return e&&(e[this._index-1]||this._path._closed&&e[e.length-1])||null},isFirst:function(){return!this._index},isLast:function(){var e=this._path;return e&&this._index===e._segments.length-1||!1},reverse:function(){var e=this._handleIn,t=this._handleOut,i=e.clone();e.set(t),t.set(i)},reversed:function(){return new T(this._point,this._handleOut,this._handleIn)},remove:function(){return!!this._path&&!!this._path.removeSegment(this._index)},clone:function(){return new T(this._point,this._handleIn,this._handleOut)},equals:function(e){return e===this||e&&this._class===e._class&&this._point.equals(e._point)&&this._handleIn.equals(e._handleIn)&&this._handleOut.equals(e._handleOut)||!1},toString:function(){var e=["point: "+this._point];return this._handleIn.isZero()||e.push("handleIn: "+this._handleIn),this._handleOut.isZero()||e.push("handleOut: "+this._handleOut),"{ "+e.join(", ")+" }"},transform:function(e){this._transformCoordinates(e,new Array(6),!0),this._changed()},interpolate:function(e,t,i){var n=1-i,a=i,r=e._point,o=t._point,s=e._handleIn,l=t._handleIn,h=t._handleOut,d=e._handleOut;this._point._set(n*r._x+a*o._x,n*r._y+a*o._y,!0),this._handleIn._set(n*s._x+a*l._x,n*s._y+a*l._y,!0),this._handleOut._set(n*d._x+a*h._x,n*d._y+a*h._y,!0),this._changed()},_transformCoordinates:function(e,t,i){var n=this._point,a=i&&this._handleIn.isZero()?null:this._handleIn,r=i&&this._handleOut.isZero()?null:this._handleOut,o=n._x,s=n._y,l=2;return t[0]=o,t[1]=s,a&&(t[l++]=a._x+o,t[l++]=a._y+s),r&&(t[l++]=r._x+o,t[l++]=r._y+s),e&&(e._transformCoordinates(t,t,l/2),o=t[0],s=t[1],i?(n._x=o,n._y=s,l=2,a&&(a._x=t[l++]-o,a._y=t[l++]-s),r&&(r._x=t[l++]-o,r._y=t[l++]-s)):(a||(t[l++]=o,t[l++]=s),r||(t[l++]=o,t[l++]=s))),t}}),z=f.extend({initialize:function(e,i,n){var a,r,o;if(e)if((a=e[0])!==t)r=e[1];else{var s=e;(a=s.x)===t&&(a=(s=f.read(arguments)).x),r=s.y,o=s.selected}else a=r=0;this._x=a,this._y=r,this._owner=i,i[n]=this,o&&this.setSelected(!0)},_set:function(e,t){return this._x=e,this._y=t,this._owner._changed(this),this},getX:function(){return this._x},setX:function(e){this._x=e,this._owner._changed(this)},getY:function(){return this._y},setY:function(e){this._y=e,this._owner._changed(this)},isZero:function(){var e=u.isZero;return e(this._x)&&e(this._y)},isSelected:function(){return!!(this._owner._selection&this._getSelection())},setSelected:function(e){this._owner._changeSelection(this._getSelection(),e)},_getSelection:function(){var e=this._owner;return this===e._point?1:this===e._handleIn?2:this===e._handleOut?4:0}}),O=a.extend({_class:"Curve",beans:!0,initialize:function(e,t,i,n,a,r,o,s){var l,h,d,c,u,g,f=arguments.length;3===f?(this._path=e,l=t,h=i):f?1===f?"segment1"in e?(l=new T(e.segment1),h=new T(e.segment2)):"point1"in e?(d=e.point1,u=e.handle1,g=e.handle2,c=e.point2):Array.isArray(e)&&(d=[e[0],e[1]],c=[e[6],e[7]],u=[e[2]-e[0],e[3]-e[1]],g=[e[4]-e[6],e[5]-e[7]]):2===f?(l=new T(e),h=new T(t)):4===f?(d=e,u=t,g=i,c=n):8===f&&(d=[e,t],c=[o,s],u=[i-e,n-t],g=[a-o,r-s]):(l=new T,h=new T),this._segment1=l||new T(d,null,u),this._segment2=h||new T(c,g,null)},_serialize:function(e,t){return a.serialize(this.hasHandles()?[this.getPoint1(),this.getHandle1(),this.getHandle2(),this.getPoint2()]:[this.getPoint1(),this.getPoint2()],e,!0,t)},_changed:function(){this._length=this._bounds=t},clone:function(){return new O(this._segment1,this._segment2)},toString:function(){var e=["point1: "+this._segment1._point];return this._segment1._handleOut.isZero()||e.push("handle1: "+this._segment1._handleOut),this._segment2._handleIn.isZero()||e.push("handle2: "+this._segment2._handleIn),e.push("point2: "+this._segment2._point),"{ "+e.join(", ")+" }"},classify:function(){return O.classify(this.getValues())},remove:function(){var e=!1;if(this._path){var t=this._segment2,i=t._handleOut;(e=t.remove())&&this._segment1._handleOut.set(i)}return e},getPoint1:function(){return this._segment1._point},setPoint1:function(){this._segment1._point.set(f.read(arguments))},getPoint2:function(){return this._segment2._point},setPoint2:function(){this._segment2._point.set(f.read(arguments))},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(){this._segment1._handleOut.set(f.read(arguments))},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(){this._segment2._handleIn.set(f.read(arguments))},getSegment1:function(){return this._segment1},getSegment2:function(){return this._segment2},getPath:function(){return this._path},getIndex:function(){return this._segment1._index},getNext:function(){var e=this._path&&this._path._curves;return e&&(e[this._segment1._index+1]||this._path._closed&&e[0])||null},getPrevious:function(){var e=this._path&&this._path._curves;return e&&(e[this._segment1._index-1]||this._path._closed&&e[e.length-1])||null},isFirst:function(){return!this._segment1._index},isLast:function(){var e=this._path;return e&&this._segment1._index===e._curves.length-1||!1},isSelected:function(){return this.getPoint1().isSelected()&&this.getHandle1().isSelected()&&this.getHandle2().isSelected()&&this.getPoint2().isSelected()},setSelected:function(e){this.getPoint1().setSelected(e),this.getHandle1().setSelected(e),this.getHandle2().setSelected(e),this.getPoint2().setSelected(e)},getValues:function(e){return O.getValues(this._segment1,this._segment2,e)},getPoints:function(){for(var e=this.getValues(),t=[],i=0;i<8;i+=2)t.push(new f(e[i],e[i+1]));return t}},{getLength:function(){return null==this._length&&(this._length=O.getLength(this.getValues(),0,1)),this._length},getArea:function(){return O.getArea(this.getValues())},getLine:function(){return new M(this._segment1._point,this._segment2._point)},getPart:function(e,t){return new O(O.getPart(this.getValues(),e,t))},getPartLength:function(e,t){return O.getLength(this.getValues(),e,t)},divideAt:function(e){return this.divideAtTime(e&&e.curve===this?e.time:this.getTimeAt(e))},divideAtTime:function(e,t){var i=null;if(e>=1e-8&&e<=1-1e-8){var n=O.subdivide(this.getValues(),e),a=n[0],r=n[1],o=t||this.hasHandles(),s=this._segment1,l=this._segment2,h=this._path;o&&(s._handleOut._set(a[2]-a[0],a[3]-a[1]),l._handleIn._set(r[4]-r[6],r[5]-r[7]));var d=a[6],c=a[7],u=new T(new f(d,c),o&&new f(a[4]-d,a[5]-c),o&&new f(r[2]-d,r[3]-c));h?(h.insert(s._index+1,u),i=this.getNext()):(this._segment2=u,this._changed(),i=new O(u,l))}return i},splitAt:function(e){var t=this._path;return t?t.splitAt(e):null},splitAtTime:function(e){return this.splitAt(this.getLocationAtTime(e))},divide:function(e,i){return this.divideAtTime(e===t?.5:i?e:this.getTimeAt(e))},split:function(e,i){return this.splitAtTime(e===t?.5:i?e:this.getTimeAt(e))},reversed:function(){return new O(this._segment2.reversed(),this._segment1.reversed())},clearHandles:function(){this._segment1._handleOut._set(0,0),this._segment2._handleIn._set(0,0)},statics:{getValues:function(e,t,i,n){var a=e._point,r=e._handleOut,o=t._handleIn,s=t._point,l=a.x,h=a.y,d=s.x,c=s.y,u=n?[l,h,l,h,d,c,d,c]:[l,h,l+r._x,h+r._y,d+o._x,c+o._y,d,c];return i&&i._transformCoordinates(u,u,4),u},subdivide:function(e,i){var n=e[0],a=e[1],r=e[2],o=e[3],s=e[4],l=e[5],h=e[6],d=e[7];i===t&&(i=.5);var c=1-i,u=c*n+i*r,g=c*a+i*o,f=c*r+i*s,p=c*o+i*l,m=c*s+i*h,v=c*l+i*d,I=c*u+i*f,y=c*g+i*p,C=c*f+i*m,M=c*p+i*v,x=c*I+i*C,S=c*y+i*M;return[[n,a,u,g,I,y,x,S],[x,S,C,M,m,v,h,d]]},getMonoCurves:function(e,t){var i=[],n=t?0:1,a=e[n+0],r=e[n+2],o=e[n+4],s=e[n+6];if(a>=r==r>=o&&r>=o==o>=s||O.isStraight(e))i.push(e);else{var l=3*(r-o)-a+s,h=2*(a+o)-4*r,d=r-a,c=[],g=u.solveQuadratic(l,h,d,c,1e-8,1-1e-8);if(g){c.sort();var f=c[0],p=O.subdivide(e,f);i.push(p[0]),g>1&&(f=(c[1]-f)/(1-f),p=O.subdivide(p[1],f),i.push(p[0])),i.push(p[1])}else i.push(e)}return i},solveCubic:function(e,t,i,n,a,r){var o=e[t],s=e[t+2],l=e[t+4],h=e[t+6],d=0;if(!(o<i&&h<i&&s<i&&l<i||o>i&&h>i&&s>i&&l>i)){var c=3*(s-o),g=3*(l-s)-c,f=h-o-c-g;d=u.solveCubic(f,g,c,o-i,n,a,r)}return d},getTimeOf:function(e,t){var i=new f(e[0],e[1]),n=new f(e[6],e[7]),a=1e-7;if(null===(t.isClose(i,1e-12)?0:t.isClose(n,1e-12)?1:null))for(var r=[t.x,t.y],o=[],s=0;s<2;s++)for(var l=O.solveCubic(e,s,r[s],o,0,1),h=0;h<l;h++){var d=o[h];if(t.isClose(O.getPoint(e,d),a))return d}return t.isClose(i,a)?0:t.isClose(n,a)?1:null},getNearestTime:function(e,t){if(O.isStraight(e)){var i=e[0],n=e[1],a=e[6]-i,r=e[7]-n,o=a*a+r*r;if(0===o)return 0;var s=((t.x-i)*a+(t.y-n)*r)/o;return s<1e-12?0:s>.999999999999?1:O.getTimeOf(e,new f(i+s*a,n+s*r))}var l=1/0,h=0;function d(i){if(i>=0&&i<=1){var n=t.getDistance(O.getPoint(e,i),!0);if(n<l)return l=n,h=i,!0}}for(var c=0;c<=100;c++)d(c/100);for(var u=.005;u>1e-8;)!d(h-u)&&!d(h+u)&&(u/=2);return h},getPart:function(e,t,i){var n=t>i;if(n){var a=t;t=i,i=a}return t>0&&(e=O.subdivide(e,t)[1]),i<1&&(e=O.subdivide(e,(i-t)/(1-t))[0]),n?[e[6],e[7],e[4],e[5],e[2],e[3],e[0],e[1]]:e},isFlatEnough:function(e,t){var i=e[0],n=e[1],a=e[2],r=e[3],o=e[4],s=e[5],l=e[6],h=e[7],d=3*a-2*i-l,c=3*r-2*n-h,u=3*o-2*l-i,g=3*s-2*h-n;return Math.max(d*d,u*u)+Math.max(c*c,g*g)<=16*t*t},getArea:function(e){var t=e[0],i=e[1],n=e[2],a=e[3],r=e[4],o=e[5],s=e[6],l=e[7];return 3*((l-i)*(n+r)-(s-t)*(a+o)+a*(t-r)-n*(i-o)+l*(r+t/3)-s*(o+i/3))/20},getBounds:function(e){for(var t=e.slice(0,2),i=t.slice(),n=[0,0],a=0;a<2;a++)O._addBounds(e[a],e[a+2],e[a+4],e[a+6],a,0,t,i,n);return new I(t[0],t[1],i[0]-t[0],i[1]-t[1])},_addBounds:function(e,t,i,n,a,r,o,s,l){function h(e,t){var i=e-t,n=e+t;i<o[a]&&(o[a]=i),n>s[a]&&(s[a]=n)}r/=2;var d=o[a]+r,c=s[a]-r;if(e<d||t<d||i<d||n<d||e>c||t>c||i>c||n>c)if(t<e!=t<n&&i<e!=i<n)h(e,0),h(n,0);else{var g=3*(t-i)-e+n,f=2*(e+i)-4*t,p=t-e,m=u.solveQuadratic(g,f,p,l);h(n,0);for(var v=0;v<m;v++){var I=l[v],y=1-I;1e-8<=I&&I<=1-1e-8&&h(y*y*y*e+3*y*y*I*t+3*y*I*I*i+I*I*I*n,r)}}}}},a.each(["getBounds","getStrokeBounds","getHandleBounds"],function(e){this[e]=function(){this._bounds||(this._bounds={});var t=this._bounds[e];return t||(t=this._bounds[e]=R[e]([this._segment1,this._segment2],!1,this._path)),t.clone()}},{}),a.each({isStraight:function(e,t,i,n){if(t.isZero()&&i.isZero())return!0;var a=n.subtract(e);if(a.isZero())return!1;if(a.isCollinear(t)&&a.isCollinear(i)){var r=new M(e,n);if(r.getDistance(e.add(t))<1e-7&&r.getDistance(n.add(i))<1e-7){var o=a.dot(a),s=a.dot(t)/o,l=a.dot(i)/o;return s>=0&&s<=1&&l<=0&&l>=-1}}return!1},isLinear:function(e,t,i,n){var a=n.subtract(e).divide(3);return t.equals(a)&&i.negate().equals(a)}},function(e,t){this[t]=function(t){var i=this._segment1,n=this._segment2;return e(i._point,i._handleOut,n._handleIn,n._point,t)},this.statics[t]=function(t,i){var n=t[0],a=t[1],r=t[6],o=t[7];return e(new f(n,a),new f(t[2]-n,t[3]-a),new f(t[4]-r,t[5]-o),new f(r,o),i)}},{statics:{},hasHandles:function(){return!this._segment1._handleOut.isZero()||!this._segment2._handleIn.isZero()},hasLength:function(e){return(!this.getPoint1().equals(this.getPoint2())||this.hasHandles())&&this.getLength()>(e||0)},isCollinear:function(e){return e&&this.isStraight()&&e.isStraight()&&this.getLine().isCollinear(e.getLine())},isHorizontal:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).y)<1e-8},isVertical:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).x)<1e-8}}),{beans:!1,getLocationAt:function(e,t){return this.getLocationAtTime(t?e:this.getTimeAt(e))},getLocationAtTime:function(e){return null!=e&&e>=0&&e<=1?new B(this,e):null},getTimeAt:function(e,t){return O.getTimeAt(this.getValues(),e,t)},getParameterAt:"#getTimeAt",getTimesWithTangent:function(){var e=f.read(arguments);return e.isZero()?[]:O.getTimesWithTangent(this.getValues(),e)},getOffsetAtTime:function(e){return this.getPartLength(0,e)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(f.read(arguments)))},getOffsetOf:function(){var e=this.getLocationOf.apply(this,arguments);return e?e.getOffset():null},getTimeOf:function(){return O.getTimeOf(this.getValues(),f.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var e=f.read(arguments),t=this.getValues(),i=O.getNearestTime(t,e),n=O.getPoint(t,i);return new B(this,i,n,null,e.getDistance(n))},getNearestPoint:function(){var e=this.getNearestLocation.apply(this,arguments);return e&&e.getPoint()}},new function(){var e=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return a.each(e,function(e){this[e+"At"]=function(t,i){var n=this.getValues();return O[e](n,i?t:O.getTimeAt(n,t))},this[e+"AtTime"]=function(t){return O[e](this.getValues(),t)}},{statics:{_evaluateMethods:e}})},new function(){function e(e){var t=e[0],i=e[1],n=e[2],a=e[3],r=e[4],o=e[5],s=e[6],l=e[7],h=9*(n-r)+3*(s-t),d=6*(t+r)-12*n,c=3*(n-t),u=9*(a-o)+3*(l-i),g=6*(i+o)-12*a,f=3*(a-i);return function(e){var t=(h*e+d)*e+c,i=(u*e+g)*e+f;return Math.sqrt(t*t+i*i)}}function i(e,t){return Math.max(2,Math.min(16,Math.ceil(32*Math.abs(t-e))))}function n(e,t,i,n){if(null==t||t<0||t>1)return null;var a=e[0],r=e[1],o=e[2],s=e[3],l=e[4],h=e[5],d=e[6],c=e[7],g=u.isZero;g(o-a)&&g(s-r)&&(o=a,s=r),g(l-d)&&g(h-c)&&(l=d,h=c);var p,m,v=3*(o-a),I=3*(l-o)-v,y=d-a-v-I,C=3*(s-r),M=3*(h-s)-C,x=c-r-C-M;if(0===i)p=0===t?a:1===t?d:((y*t+I)*t+v)*t+a,m=0===t?r:1===t?c:((x*t+M)*t+C)*t+r;else{var S=1e-8,b=1-S;if(t<S?(p=v,m=C):t>b?(p=3*(d-l),m=3*(c-h)):(p=(3*y*t+2*I)*t+v,m=(3*x*t+2*M)*t+C),n){0===p&&0===m&&(t<S||t>b)&&(p=l-o,m=h-s);var w=Math.sqrt(p*p+m*m);w&&(p/=w,m/=w)}if(3===i){l=6*y*t+2*I,h=6*x*t+2*M;var A=Math.pow(p*p+m*m,1.5);p=0!==A?(p*h-m*l)/A:0,m=0}}return 2===i?new f(m,-p):new f(p,m)}return{statics:{classify:function(e){var i=e[0],n=e[1],a=e[2],r=e[3],o=e[4],s=e[5],l=e[6],h=e[7],d=a*(n-h)+r*(l-i)+i*h-n*l,c=3*(o*(r-n)+s*(i-a)+a*n-r*i),g=c-d,f=g-d+(i*(h-s)+n*(o-l)+l*s-h*o),p=Math.sqrt(f*f+g*g+c*c),m=0!==p?1/p:0,v=u.isZero,I="serpentine";function y(e,i,n){var a=i!==t,r=a&&i>0&&i<1,o=a&&n>0&&n<1;return a&&(!(r||o)||"loop"===e&&!(r&&o))&&(e="arch",r=o=!1),{type:e,roots:r||o?r&&o?i<n?[i,n]:[n,i]:[r?i:n]:null}}if(g*=m,c*=m,v(f*=m))return v(g)?y(v(c)?"line":"quadratic"):y(I,c/(3*g));var C=3*g*g-4*f*c;if(v(C))return y("cusp",g/(2*f));var M=C>0?Math.sqrt(C/3):Math.sqrt(-C),x=2*f;return y(C>0?I:"loop",(g+M)/x,(g-M)/x)},getLength:function(n,a,r,o){if(a===t&&(a=0),r===t&&(r=1),O.isStraight(n)){var s=n;r<1&&(s=O.subdivide(s,r)[0],a/=r),a>0&&(s=O.subdivide(s,a)[1]);var l=s[6]-s[0],h=s[7]-s[1];return Math.sqrt(l*l+h*h)}return u.integrate(o||e(n),a,r,i(a,r))},getTimeAt:function(n,a,r){if(r===t&&(r=a<0?1:0),0===a)return r;var o=Math.abs,s=a>0,l=s?r:0,h=s?1:r,d=e(n),c=O.getLength(n,l,h,d),g=o(a)-c;if(o(g)<1e-12)return s?h:l;if(g>1e-12)return null;var f=a/c,p=0;return u.findRoot(function(e){return p+=u.integrate(d,r,e,i(r,e)),r=e,p-a},d,r+f,l,h,32,1e-12)},getPoint:function(e,t){return n(e,t,0,!1)},getTangent:function(e,t){return n(e,t,1,!0)},getWeightedTangent:function(e,t){return n(e,t,1,!1)},getNormal:function(e,t){return n(e,t,2,!0)},getWeightedNormal:function(e,t){return n(e,t,2,!1)},getCurvature:function(e,t){return n(e,t,3,!1).x},getPeaks:function(e){var t=e[0],i=e[1],n=e[2],a=e[3],r=e[4],o=e[5],s=3*n-t-3*r+e[6],l=3*t-6*n+3*r,h=-3*t+3*n,d=3*a-i-3*o+e[7],c=3*i-6*a+3*o,g=-3*i+3*a,f=[];return u.solveCubic(9*(s*s+d*d),9*(s*l+c*d),2*(l*l+c*c)+3*(h*s+g*d),h*l+c*g,f,1e-8,1-1e-8),f.sort()}}}},new function(){function e(e,t,i,n,a,r,o){var s=!o&&i.getPrevious()===a,l=!o&&i!==a&&i.getNext()===a,h=1e-8,d=1-h;if(null!==n&&n>=(s?h:0)&&n<=(l?d:1)&&null!==r&&r>=(l?h:0)&&r<=(s?d:1)){var c=new B(i,n,null,o),u=new B(a,r,null,o);c._intersection=u,u._intersection=c,(!t||t(c))&&B.insert(e,c,!0)}}function t(e,t,n,a){return e[0][1]<n?i(e,!0,n):t[0][1]>a?i(t,!1,a):e[0][0]}function i(e,t,i){for(var n=e[0][0],a=e[0][1],r=1,o=e.length;r<o;r++){var s=e[r][0],l=e[r][1];if(t?l>=i:l<=i)return l===i?s:n+(i-a)*(s-n)/(l-a);n=s,a=l}return null}function n(e,t,i,n,a){var r=u.isZero;if(r(n)&&r(a)){var o=O.getTimeOf(e,new f(t,i));return null===o?[]:[o]}for(var s=Math.atan2(-a,n),l=Math.sin(s),h=Math.cos(s),d=[],c=[],g=0;g<8;g+=2){var p=e[g]-t,m=e[g+1]-i;d.push(p*h-m*l,p*l+m*h)}return O.solveCubic(d,1,0,c,0,1),c}function a(i,a,r,s,l,h){var d=1e-12,c=Math.min,u=Math.max;if(u(i[0],i[2],i[4],i[6])+d>c(a[0],a[2],a[4],a[6])&&c(i[0],i[2],i[4],i[6])-d<u(a[0],a[2],a[4],a[6])&&u(i[1],i[3],i[5],i[7])+d>c(a[1],a[3],a[5],a[7])&&c(i[1],i[3],i[5],i[7])-d<u(a[1],a[3],a[5],a[7])){var g=o(i,a);if(g)for(var p=0;p<2;p++){var m=g[p];e(l,h,r,m[0],s,m[1],!0)}else{var v=O.isStraight(i),I=O.isStraight(a),y=v&&I,C=v&&!I,x=l.length;if((y?function(t,i,n,a,r,o){var s=M.intersect(t[0],t[1],t[6],t[7],i[0],i[1],i[6],i[7]);s&&e(r,o,n,O.getTimeOf(t,s),a,O.getTimeOf(i,s))}:v||I?function(t,i,a,r,o,s,l){for(var h=i[0],d=i[1],c=n(t,h,d,i[6]-h,i[7]-d),u=0,g=c.length;u<g;u++){var f=c[u],p=O.getPoint(t,f),m=O.getTimeOf(i,p);null!==m&&e(o,s,l?r:a,l?m:f,l?a:r,l?f:m)}}:function i(n,a,r,o,s,l,h,d,c,u,g,f,p){if(++c>=4096||++d>=40)return c;var m,v,I=a[0],y=a[1],C=a[6],x=a[7],S=M.getSignedDistance,b=S(I,y,C,x,a[2],a[3]),w=S(I,y,C,x,a[4],a[5]),A=b*w>0?.75:4/9,P=A*Math.min(0,b,w),D=A*Math.max(0,b,w),k=S(I,y,C,x,n[0],n[1]),_=S(I,y,C,x,n[2],n[3]),T=S(I,y,C,x,n[4],n[5]),z=S(I,y,C,x,n[6],n[7]),B=function(e,t,i,n){var a,r=[0,e],o=[1/3,t],s=[2/3,i],l=[1,n],h=t-(2*e+n)/3,d=i-(e+2*n)/3;if(h*d<0)a=[[r,o,l],[r,s,l]];else{var c=h/d;a=[c>=2?[r,o,l]:c<=.5?[r,s,l]:[r,o,s,l],[r,l]]}return(h||d)<0?a.reverse():a}(k,_,T,z),E=B[0],R=B[1];if(0===b&&0===w&&0===k&&0===_&&0===T&&0===z||null==(m=t(E,R,P,D))||null==(v=t(E.reverse(),R.reverse(),P,D)))return c;var F=u+(g-u)*m,L=u+(g-u)*v;if(Math.max(p-f,L-F)<1e-9){var G=(F+L)/2,U=(f+p)/2;e(s,l,h?o:r,h?U:G,h?r:o,h?G:U)}else{n=O.getPart(n,m,v);var j=p-f;if(v-m>.8)if(L-F>j)G=(F+L)/2,c=i(a,(N=O.subdivide(n,.5))[0],o,r,s,l,!h,d,c,f,p,F,G),c=i(a,N[1],o,r,s,l,!h,d,c,f,p,G,L);else{var N;U=(f+p)/2,c=i((N=O.subdivide(a,.5))[0],n,o,r,s,l,!h,d,c,f,U,F,L),c=i(N[1],n,o,r,s,l,!h,d,c,U,p,F,L)}else c=0===j||j>=1e-9?i(a,n,o,r,s,l,!h,d,c,f,p,F,L):i(n,a,r,o,s,l,h,d,c,F,L,f,p)}return c})(C?a:i,C?i:a,C?s:r,C?r:s,l,h,C,0,0,0,1,0,1),!y||l.length===x)for(p=0;p<4;p++){var S=p>>1,b=1&p,w=6*S,A=6*b,P=new f(i[w],i[w+1]),D=new f(a[A],a[A+1]);P.isClose(D,d)&&e(l,h,r,S,s,b)}}}return l}function r(t,i,n,a){var r=O.classify(t);if("loop"===r.type){var o=r.roots;e(n,a,i,o[0],i,o[1])}return n}function o(e,t){function i(e){var t=e[6]-e[0],i=e[7]-e[1];return t*t+i*i}var n=Math.abs,a=M.getDistance,r=1e-7,o=O.isStraight(e),s=O.isStraight(t),l=o&&s,h=i(e)<i(t),d=h?t:e,c=h?e:t,u=d[0],g=d[1],p=d[6]-u,m=d[7]-g;if(a(u,g,p,m,c[0],c[1],!0)<r&&a(u,g,p,m,c[6],c[7],!0)<r)!l&&a(u,g,p,m,d[2],d[3],!0)<r&&a(u,g,p,m,d[4],d[5],!0)<r&&a(u,g,p,m,c[2],c[3],!0)<r&&a(u,g,p,m,c[4],c[5],!0)<r&&(o=s=l=!0);else if(l)return null;if(o^s)return null;for(var v=[e,t],I=[],y=0;y<4&&I.length<2;y++){var C=1&y,x=1^C,S=y>>1,b=O.getTimeOf(v[C],new f(v[x][S?6:0],v[x][S?7:1]));if(null!=b){var w=C?[S,b]:[b,S];(!I.length||n(w[0]-I[0][0])>1e-8&&n(w[1]-I[0][1])>1e-8)&&I.push(w)}if(y>2&&!I.length)break}if(2!==I.length)I=null;else if(!l){var A=O.getPart(e,I[0][0],I[1][0]),P=O.getPart(t,I[0][1],I[1][1]);(n(P[2]-A[2])>r||n(P[3]-A[3])>r||n(P[4]-A[4])>r||n(P[5]-A[5])>r)&&(I=null)}return I}return{getIntersections:function(e){var t=this.getValues(),i=e&&e!==this&&e.getValues();return i?a(t,i,this,e,[]):r(t,this,[])},statics:{getOverlaps:o,getIntersections:function(e,t,i,n,o,s){var l=!t;l&&(t=e);for(var h=e.length,c=t.length,u=new Array(h),g=l?u:new Array(c),f=[],p=0;p<h;p++)u[p]=e[p].getValues(n);if(!l)for(p=0;p<c;p++)g[p]=t[p].getValues(o);for(var m=d.findCurveBoundsCollisions(u,g,1e-7),v=0;v<h;v++){var I=e[v],y=u[v];l&&r(y,I,f,i);var C=m[v];if(C)for(var M=0;M<C.length;M++){if(s&&f.length)return f;var x=C[M];if(!l||x>v){var S=t[x];a(y,g[x],I,S,f,i)}}}return f},getCurveLineIntersections:n,getTimesWithTangent:function(e,t){var i=e[0],n=e[1],a=e[2],r=e[3],o=e[4],s=e[5],l=e[6],h=e[7],d=t.normalize(),c=d.x,g=d.y,f=3*l-9*o+9*a-3*i,p=3*h-9*s+9*r-3*n,m=6*o-12*a+6*i,v=6*s-12*r+6*n,I=3*a-3*i,y=3*r-3*n,C=2*f*g-2*p*c,M=[];if(Math.abs(C)<u.CURVETIME_EPSILON){if(0!=(C=f*v-p*m)){var x=-(f*y-p*I)/C;x>=0&&x<=1&&M.push(x)}}else{var S=(m*m-4*f*I)*g*g+(-2*m*v+4*p*I+4*f*y)*c*g+(v*v-4*p*y)*c*c,b=m*g-v*c;if(S>=0&&0!=C){var w=Math.sqrt(S),A=-(b+w)/C,P=(-b+w)/C;A>=0&&A<=1&&M.push(A),P>=0&&P<=1&&M.push(P)}}return M}}}}),B=a.extend({_class:"CurveLocation",initialize:function(e,t,i,n,a){if(t>=.99999999){var r=e.getNext();r&&(t=0,e=r)}this._setCurve(e),this._time=t,this._point=i||e.getPointAtTime(t),this._overlap=n,this._distance=a,this._intersection=this._next=this._previous=null},_setPath:function(e){this._path=e,this._version=e?e._version:0},_setCurve:function(e){this._setPath(e._path),this._curve=e,this._segment=null,this._segment1=e._segment1,this._segment2=e._segment2},_setSegment:function(e){var t=e.getCurve();t?this._setCurve(t):(this._setPath(e._path),this._segment1=e,this._segment2=null),this._segment=e,this._time=e===this._segment1?0:1,this._point=e._point.clone()},getSegment:function(){var e=this._segment;if(!e){var t=this.getCurve(),i=this.getTime();0===i?e=t._segment1:1===i?e=t._segment2:null!=i&&(e=t.getPartLength(0,i)<t.getPartLength(i,1)?t._segment1:t._segment2),this._segment=e}return e},getCurve:function(){var e=this._path,t=this;function i(e){var i=e&&e.getCurve();if(i&&null!=(t._time=i.getTimeOf(t._point)))return t._setCurve(i),i}return e&&e._version!==this._version&&(this._time=this._offset=this._curveOffset=this._curve=null),this._curve||i(this._segment)||i(this._segment1)||i(this._segment2.getPrevious())},getPath:function(){var e=this.getCurve();return e&&e._path},getIndex:function(){var e=this.getCurve();return e&&e.getIndex()},getTime:function(){var e=this.getCurve(),t=this._time;return e&&null==t?this._time=e.getTimeOf(this._point):t},getParameter:"#getTime",getPoint:function(){return this._point},getOffset:function(){var e=this._offset;if(null==e){e=0;var t=this.getPath(),i=this.getIndex();if(t&&null!=i)for(var n=t.getCurves(),a=0;a<i;a++)e+=n[a].getLength();this._offset=e+=this.getCurveOffset()}return e},getCurveOffset:function(){var e=this._curveOffset;if(null==e){var t=this.getCurve(),i=this.getTime();this._curveOffset=e=null!=i&&t&&t.getPartLength(0,i)}return e},getIntersection:function(){return this._intersection},getDistance:function(){return this._distance},divide:function(){var e=this.getCurve(),t=e&&e.divideAtTime(this.getTime());return t&&this._setSegment(t._segment1),t},split:function(){var e=this.getCurve(),t=e._path,i=e&&e.splitAtTime(this.getTime());return i&&this._setSegment(t.getLastSegment()),i},equals:function(e,t){var i=this===e;if(!i&&e instanceof B){var n=this.getCurve(),a=e.getCurve(),r=n._path;if(r===a._path){var o=Math.abs,s=o(this.getOffset()-e.getOffset()),l=!t&&this._intersection,h=!t&&e._intersection;i=(s<1e-7||r&&o(r.getLength()-s)<1e-7)&&(!l&&!h||l&&h&&l.equals(h,!0))}}return i},toString:function(){var e=[],t=this.getPoint(),i=c.instance;t&&e.push("point: "+t);var n=this.getIndex();null!=n&&e.push("index: "+n);var a=this.getTime();return null!=a&&e.push("time: "+i.number(a)),null!=this._distance&&e.push("distance: "+i.number(this._distance)),"{ "+e.join(", ")+" }"},isTouching:function(){var e=this._intersection;if(e&&this.getTangent().isCollinear(e.getTangent())){var t=this.getCurve(),i=e.getCurve();return!(t.isStraight()&&i.isStraight()&&t.getLine().intersect(i.getLine()))}return!1},isCrossing:function(){var e=this._intersection;if(!e)return!1;var t=this.getTime(),i=e.getTime(),n=1e-8,a=1-n,r=t>=n&&t<=a,o=i>=n&&i<=a;if(r&&o)return!this.isTouching();var s=this.getCurve(),l=s&&t<n?s.getPrevious():s,h=e.getCurve(),d=h&&i<n?h.getPrevious():h;if(t>a&&(s=s.getNext()),i>a&&(h=h.getNext()),!(l&&s&&d&&h))return!1;var c=[];function u(e,t){var i=e.getValues(),n=O.classify(i).roots||O.getPeaks(i),a=n.length,r=O.getLength(i,t&&a?n[a-1]:0,!t&&a?n[0]:1);c.push(a?r:r/32)}function g(e,t,i){return t<i?e>t&&e<i:e>t||e<i}r||(u(l,!0),u(s,!1)),o||(u(d,!0),u(h,!1));var f=this.getPoint(),p=Math.min.apply(Math,c),m=r?s.getTangentAtTime(t):s.getPointAt(p).subtract(f),v=r?m.negate():l.getPointAt(-p).subtract(f),I=o?h.getTangentAtTime(i):h.getPointAt(p).subtract(f),y=o?I.negate():d.getPointAt(-p).subtract(f),C=v.getAngle(),M=m.getAngle(),x=y.getAngle(),S=I.getAngle();return!!(r?g(C,x,S)^g(M,x,S)&&g(C,S,x)^g(M,S,x):g(x,C,M)^g(S,C,M)&&g(x,M,C)^g(S,M,C))},hasOverlap:function(){return!!this._overlap}},a.each(O._evaluateMethods,function(e){var t=e+"At";this[e]=function(){var e=this.getCurve(),i=this.getTime();return null!=i&&e&&e[t](i,!0)}},{preserve:!0}),new function(){function e(e,t,i){var n=e.length,a=0,r=n-1;function o(i,a){for(var r=i+a;r>=-1&&r<=n;r+=a){var o=e[(r%n+n)%n];if(!t.getPoint().isClose(o.getPoint(),1e-7))break;if(t.equals(o))return o}return null}for(;a<=r;){var s,l=a+r>>>1,h=e[l];if(i&&(s=t.equals(h)?h:o(l,-1)||o(l,1)))return t._overlap&&(s._overlap=s._intersection._overlap=!0),s;var d=t.getPath(),c=h.getPath();(d!==c?d._id-c._id:t.getIndex()+t.getTime()-(h.getIndex()+h.getTime()))<0?r=l-1:a=l+1}return e.splice(a,0,t),t}return{statics:{insert:e,expand:function(t){for(var i=t.slice(),n=t.length-1;n>=0;n--)e(i,t[n]._intersection,!1);return i}}}}),E=S.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,beans:!0,initialize:function(){},statics:{create:function(e){var t,i,n;if(a.isPlainObject(e)?(i=e.segments,t=e.pathData):Array.isArray(e)?i=e:"string"==typeof e&&(t=e),i){var r=i[0];n=r&&Array.isArray(r[0])}else t&&(n=(t.match(/m/gi)||[]).length>1||/z\s*\S+/i.test(t));return new(n?F:R)(e)}},_asPathItem:function(){return this},isClockwise:function(){return this.getArea()>=0},setClockwise:function(e){this.isClockwise()!=(e=!!e)&&this.reverse()},setPathData:function(e){var t,i,n,a=e&&e.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),r=!1,o=new f,s=new f;function l(e,i){var n=+t[e];return r&&(n+=o[i]),n}function h(e){return new f(l(e,"x"),l(e+1,"y"))}this.clear();for(var d=0,c=a&&a.length;d<c;d++){var u=a[d],g=u[0],p=g.toLowerCase(),v=(t=u.match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g))&&t.length;switch(r=g===p,"z"===i&&!/[mz]/.test(p)&&this.moveTo(o),p){case"m":case"l":for(var I="m"===p,y=0;y<v;y+=2)this[I?"moveTo":"lineTo"](o=h(y)),I&&(s=o,I=!1);n=o;break;case"h":case"v":var C="h"===p?"x":"y";for(o=o.clone(),y=0;y<v;y++)o[C]=l(y,C),this.lineTo(o);n=o;break;case"c":for(y=0;y<v;y+=6)this.cubicCurveTo(h(y),n=h(y+2),o=h(y+4));break;case"s":for(y=0;y<v;y+=4)this.cubicCurveTo(/[cs]/.test(i)?o.multiply(2).subtract(n):o,n=h(y),o=h(y+2)),i=p;break;case"q":for(y=0;y<v;y+=4)this.quadraticCurveTo(n=h(y),o=h(y+2));break;case"t":for(y=0;y<v;y+=2)this.quadraticCurveTo(n=/[qt]/.test(i)?o.multiply(2).subtract(n):o,o=h(y)),i=p;break;case"a":for(y=0;y<v;y+=7)this.arcTo(o=h(y+5),new m(+t[y],+t[y+1]),+t[y+2],+t[y+4],+t[y+3]);break;case"z":this.closePath(1e-12),o=s}i=p}},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_contains:function(e){var t=e.isInside(this.getBounds({internal:!0,handle:!0}))?this._getWinding(e):{};return t.onPath||!!("evenodd"===this.getFillRule()?1&t.windingL||1&t.windingR:t.winding)},getIntersections:function(e,t,i,n){var a=this===e||!e,r=this._matrix._orNullIfIdentity(),o=a?r:(i||e._matrix)._orNullIfIdentity();return a||this.getBounds(r).intersects(e.getBounds(o),1e-12)?O.getIntersections(this.getCurves(),!a&&e.getCurves(),t,r,o,n):[]},getCrossings:function(e){return this.getIntersections(e,function(e){return e.isCrossing()})},getNearestLocation:function(){for(var e=f.read(arguments),t=this.getCurves(),i=1/0,n=null,a=0,r=t.length;a<r;a++){var o=t[a].getNearestLocation(e);o._distance<i&&(i=o._distance,n=o)}return n},getNearestPoint:function(){var e=this.getNearestLocation.apply(this,arguments);return e&&e.getPoint()},interpolate:function(e,t,i){var n=!this._children,a=n?"_segments":"_children",r=e[a],o=t[a],s=this[a];if(!r||!o||r.length!==o.length)throw new Error("Invalid operands in interpolate() call: "+e+", "+t);var l=s.length,h=o.length;if(l<h)for(var d=n?T:R,c=l;c<h;c++)this.add(new d);else l>h&&this[n?"removeSegments":"removeChildren"](h,l);for(c=0;c<h;c++)s[c].interpolate(r[c],o[c],i);n&&(this.setClosed(e._closed),this._changed(9))},compare:function(e){var t=!1;if(e){var i=this._children||[this],n=e._children?e._children.slice():[e],a=i.length,r=n.length,o=[],s=0;t=!0;for(var l=d.findItemBoundsCollisions(i,n,u.GEOMETRIC_EPSILON),h=a-1;h>=0&&t;h--){var c=i[h];t=!1;var g=l[h];if(g)for(var f=g.length-1;f>=0&&!t;f--)c.compare(n[g[f]])&&(o[g[f]]||(o[g[f]]=!0,s++),t=!0)}t=t&&s===r}return t}}),R=E.extend({_class:"Path",_serializeFields:{segments:[],closed:!1},initialize:function(e){this._closed=!1,this._segments=[],this._version=0;var i=arguments,n=Array.isArray(e)?"object"==typeof e[0]?e:i:!e||e.size!==t||e.x===t&&e.point===t?null:i;n&&n.length>0?this.setSegments(n):(this._curves=t,this._segmentSelection=0,!n&&"string"==typeof e&&(this.setPathData(e),e=null)),this._initialize(!n&&e)},_equals:function(e){return this._closed===e._closed&&a.equals(this._segments,e._segments)},copyContent:function(e){this.setSegments(e._segments),this._closed=e._closed},_changed:function e(i){if(e.base.call(this,i),8&i){if(this._length=this._area=t,32&i)this._version++;else if(this._curves)for(var n=0,a=this._curves.length;n<a;n++)this._curves[n]._changed()}else 64&i&&(this._bounds=t)},getStyle:function(){var e=this._parent;return(e instanceof F?e:this)._style},getSegments:function(){return this._segments},setSegments:function(e){var i=this.isFullySelected(),n=e&&e.length;if(this._segments.length=0,this._segmentSelection=0,this._curves=t,n){var a=e[n-1];"boolean"==typeof a&&(this.setClosed(a),n--),this._add(T.readList(e,0,{},n))}i&&this.setFullySelected(!0)},getFirstSegment:function(){return this._segments[0]},getLastSegment:function(){return this._segments[this._segments.length-1]},getCurves:function(){var e=this._curves,t=this._segments;if(!e){var i=this._countCurves();e=this._curves=new Array(i);for(var n=0;n<i;n++)e[n]=new O(this,t[n],t[n+1]||t[0])}return e},getFirstCurve:function(){return this.getCurves()[0]},getLastCurve:function(){var e=this.getCurves();return e[e.length-1]},isClosed:function(){return this._closed},setClosed:function(e){if(this._closed!=(e=!!e)){if(this._closed=e,this._curves){var t=this._curves.length=this._countCurves();e&&(this._curves[t-1]=new O(this,this._segments[t-1],this._segments[0]))}this._changed(41)}}},{beans:!0,getPathData:function(e,t){var i,n,a,r,o,s,l,h,d=this._segments,u=d.length,g=new c(t),f=new Array(6),p=!0,m=[];function v(t,d){if(t._transformCoordinates(e,f),i=f[0],n=f[1],p)m.push("M"+g.pair(i,n)),p=!1;else if(o=f[2],s=f[3],o===i&&s===n&&l===a&&h===r){if(!d){var c=i-a,u=n-r;m.push(0===c?"v"+g.number(u):0===u?"h"+g.number(c):"l"+g.pair(c,u))}}else m.push("c"+g.pair(l-a,h-r)+" "+g.pair(o-a,s-r)+" "+g.pair(i-a,n-r));a=i,r=n,l=f[4],h=f[5]}if(!u)return"";for(var I=0;I<u;I++)v(d[I]);return this._closed&&u>0&&(v(d[0],!0),m.push("z")),m.join("")},isEmpty:function(){return!this._segments.length},_transformContent:function(e){for(var t=this._segments,i=new Array(6),n=0,a=t.length;n<a;n++)t[n]._transformCoordinates(e,i,!0);return!0},_add:function(e,t){for(var i=this._segments,n=this._curves,r=e.length,o=null==t,s=(t=o?i.length:t,0);s<r;s++){var l=e[s];l._path&&(l=e[s]=l.clone()),l._path=this,l._index=t+s,l._selection&&this._updateSelection(l,0,l._selection)}if(o)a.push(i,e);else{i.splice.apply(i,[t,0].concat(e)),s=t+r;for(var h=i.length;s<h;s++)i[s]._index=s}if(n){var d=this._countCurves(),c=t>0&&t+r-1===d?t-1:t,u=c,g=Math.min(c+r,d);for(e._curves&&(n.splice.apply(n,[c,0].concat(e._curves)),u+=e._curves.length),s=u;s<g;s++)n.splice(s,0,new O(this,null,null));this._adjustCurves(c,g)}return this._changed(41),e},_adjustCurves:function(e,t){for(var i,n=this._segments,a=this._curves,r=e;r<t;r++)(i=a[r])._path=this,i._segment1=n[r],i._segment2=n[r+1]||n[0],i._changed();(i=a[this._closed&&!e?n.length-1:e-1])&&(i._segment2=n[e]||n[0],i._changed()),(i=a[t])&&(i._segment1=n[t],i._changed())},_countCurves:function(){var e=this._segments.length;return!this._closed&&e>0?e-1:e},add:function(e){var t=arguments;return t.length>1&&"number"!=typeof e?this._add(T.readList(t)):this._add([T.read(t)])[0]},insert:function(e,t){var i=arguments;return i.length>2&&"number"!=typeof t?this._add(T.readList(i,1),e):this._add([T.read(i,1)],e)[0]},addSegment:function(){return this._add([T.read(arguments)])[0]},insertSegment:function(e){return this._add([T.read(arguments,1)],e)[0]},addSegments:function(e){return this._add(T.readList(e))},insertSegments:function(e,t){return this._add(T.readList(t),e)},removeSegment:function(e){return this.removeSegments(e,e+1)[0]||null},removeSegments:function(e,t,i){e=e||0,t=a.pick(t,this._segments.length);var n=this._segments,r=this._curves,o=n.length,s=n.splice(e,t-e),l=s.length;if(!l)return s;for(var h=0;h<l;h++){var d=s[h];d._selection&&this._updateSelection(d,d._selection,0),d._index=d._path=null}h=e;for(var c=n.length;h<c;h++)n[h]._index=h;if(r){var u=e>0&&t===o+(this._closed?1:0)?e-1:e;for(h=(r=r.splice(u,l)).length-1;h>=0;h--)r[h]._path=null;i&&(s._curves=r.slice(1)),this._adjustCurves(u,u)}return this._changed(41),s},clear:"#removeSegments",hasHandles:function(){for(var e=this._segments,t=0,i=e.length;t<i;t++)if(e[t].hasHandles())return!0;return!1},clearHandles:function(){for(var e=this._segments,t=0,i=e.length;t<i;t++)e[t].clearHandles()},getLength:function(){if(null==this._length){for(var e=this.getCurves(),t=0,i=0,n=e.length;i<n;i++)t+=e[i].getLength();this._length=t}return this._length},getArea:function(){var e=this._area;if(null==e){var t=this._segments,i=this._closed;e=0;for(var n=0,a=t.length;n<a;n++){var r=n+1===a;e+=O.getArea(O.getValues(t[n],t[r?0:n+1],null,r&&!i))}this._area=e}return e},isFullySelected:function(){var e=this._segments.length;return this.isSelected()&&e>0&&this._segmentSelection===7*e},setFullySelected:function(e){e&&this._selectSegments(!0),this.setSelected(e)},setSelection:function e(t){1&t||this._selectSegments(!1),e.base.call(this,t)},_selectSegments:function(e){var t=this._segments,i=t.length,n=e?7:0;this._segmentSelection=n*i;for(var a=0;a<i;a++)t[a]._selection=n},_updateSelection:function(e,t,i){e._selection=i,(this._segmentSelection+=i-t)>0&&this.setSelected(!0)},divideAt:function(e){var t,i=this.getLocationAt(e);return i&&(t=i.getCurve().divideAt(i.getCurveOffset()))?t._segment1:null},splitAt:function(e){var t=this.getLocationAt(e),i=t&&t.index,n=t&&t.time;n>1-1e-8&&(i++,n=0);var a=this.getCurves();if(i>=0&&i<a.length){n>=1e-8&&a[i++].divideAtTime(n);var r,o=this.removeSegments(i,this._segments.length,!0);return this._closed?(this.setClosed(!1),r=this):((r=new R(S.NO_INSERT)).insertAbove(this),r.copyAttributes(this)),r._add(o,0),this.addSegment(o[0]),r}return null},split:function(e,i){var n,a=i===t?e:(n=this.getCurves()[e])&&n.getLocationAtTime(i);return null!=a?this.splitAt(a):null},join:function(e,t){var i=t||0;if(e&&e!==this){var n=e._segments,a=this.getLastSegment(),r=e.getLastSegment();if(!r)return this;a&&a._point.isClose(r._point,i)&&e.reverse();var o=e.getFirstSegment();if(a&&a._point.isClose(o._point,i))a.setHandleOut(o._handleOut),this._add(n.slice(1));else{var s=this.getFirstSegment();s&&s._point.isClose(o._point,i)&&e.reverse(),r=e.getLastSegment(),s&&s._point.isClose(r._point,i)?(s.setHandleIn(r._handleIn),this._add(n.slice(0,n.length-1),0)):this._add(n.slice())}e._closed&&this._add([n[0]]),e.remove()}var l=this.getFirstSegment(),h=this.getLastSegment();return l!==h&&l._point.isClose(h._point,i)&&(l.setHandleIn(h._handleIn),h.remove(),this.setClosed(!0)),this},reduce:function(e){for(var t=this.getCurves(),i=e&&e.simplify,n=i?1e-7:0,a=t.length-1;a>=0;a--){var r=t[a];!r.hasHandles()&&(!r.hasLength(n)||i&&r.isCollinear(r.getNext()))&&r.remove()}return this},reverse:function(){this._segments.reverse();for(var e=0,t=this._segments.length;e<t;e++){var i=this._segments[e],n=i._handleIn;i._handleIn=i._handleOut,i._handleOut=n,i._index=e}this._curves=null,this._changed(9)},flatten:function(e){for(var t=new L(this,e||.25,256,!0).parts,i=t.length,n=[],a=0;a<i;a++)n.push(new T(t[a].curve.slice(0,2)));!this._closed&&i>0&&n.push(new T(t[i-1].curve.slice(6))),this.setSegments(n)},simplify:function(e){var t=new G(this).fit(e||2.5);return t&&this.setSegments(t),!!t},smooth:function(e){var i=this,n=e||{},a=n.type||"asymmetric",r=this._segments,o=r.length,s=this._closed;function l(e,t){var n=e&&e.index;if(null!=n){var a=e.path;if(a&&a!==i)throw new Error(e._class+" "+n+" of "+a+" is not part of "+i);t&&e instanceof O&&n++}else n="number"==typeof e?e:t;return Math.min(n<0&&s?n%o:n<0?n+o:n,o-1)}var h=s&&n.from===t&&n.to===t,d=l(n.from,0),c=l(n.to,o-1);if(d>c)if(s)d-=o;else{var u=d;d=c,c=u}if(/^(?:asymmetric|continuous)$/.test(a)){var g="asymmetric"===a,f=Math.min,p=c-d+1,m=p-1,v=h?f(p,4):1,I=v,y=v,C=[];if(s||(I=f(1,d),y=f(1,o-c-1)),(m+=I+y)<=1)return;for(var M=0,x=d-I;M<=m;M++,x++)C[M]=r[(x<0?x+o:x)%o]._point;var S=C[0]._x+2*C[1]._x,b=C[0]._y+2*C[1]._y,w=2,A=m-1,P=[S],D=[b],k=[w],_=[],T=[];for(M=1;M<m;M++){var z=M<A,B=z?4:g?2:7,E=z?4:g?3:8,R=z?2:g?0:1,F=(z||g?1:2)/w;w=k[M]=B-F,S=P[M]=E*C[M]._x+R*C[M+1]._x-F*S,b=D[M]=E*C[M]._y+R*C[M+1]._y-F*b}for(_[A]=P[A]/k[A],T[A]=D[A]/k[A],M=m-2;M>=0;M--)_[M]=(P[M]-_[M+1])/k[M],T[M]=(D[M]-T[M+1])/k[M];_[m]=(3*C[m]._x-_[A])/2,T[m]=(3*C[m]._y-T[A])/2,M=I;var L=m-y;for(x=d;M<=L;M++,x++){var G=r[x<0?x+o:x],U=G._point,j=_[M]-U._x,N=T[M]-U._y;(h||M<L)&&G.setHandleOut(j,N),(h||M>I)&&G.setHandleIn(-j,-N)}}else for(M=d;M<=c;M++)r[M<0?M+o:M].smooth(n,!h&&M===d,!h&&M===c)},toShape:function(e){if(!this._closed)return null;var i,n,a,r,o,s,l,h=this._segments;function d(e,t){var i=h[e],n=i.getNext(),a=h[t],r=a.getNext();return i._handleOut.isZero()&&n._handleIn.isZero()&&a._handleOut.isZero()&&r._handleIn.isZero()&&n._point.subtract(i._point).isCollinear(r._point.subtract(a._point))}function c(e){var t=h[e],i=t.getNext(),n=t._handleOut,a=i._handleIn,r=.5522847498307936;if(n.isOrthogonal(a)){var o=t._point,s=i._point,l=new M(o,n,!0).intersect(new M(s,a,!0),!0);return l&&u.isZero(n.getLength()/l.subtract(o).getLength()-r)&&u.isZero(a.getLength()/l.subtract(s).getLength()-r)}return!1}function g(e,t){return h[e]._point.getDistance(h[t]._point)}if(!this.hasHandles()&&4===h.length&&d(0,2)&&d(1,3)&&(o=h[1],s=o.getPrevious(),l=o.getNext(),s._handleOut.isZero()&&o._handleIn.isZero()&&o._handleOut.isZero()&&l._handleIn.isZero()&&o._point.subtract(s._point).isOrthogonal(l._point.subtract(o._point)))?(i=A.Rectangle,n=new m(g(0,3),g(0,1)),r=h[1]._point.add(h[2]._point).divide(2)):8===h.length&&c(0)&&c(2)&&c(4)&&c(6)&&d(1,5)&&d(3,7)?(i=A.Rectangle,a=(n=new m(g(1,6),g(0,3))).subtract(new m(g(0,7),g(1,2))).divide(2),r=h[3]._point.add(h[4]._point).divide(2)):4===h.length&&c(0)&&c(1)&&c(2)&&c(3)&&(u.isZero(g(0,2)-g(1,3))?(i=A.Circle,a=g(0,2)/2):(i=A.Ellipse,a=new m(g(2,0)/2,g(3,1)/2)),r=h[1]._point),i){var f=this.getPosition(!0),p=new i({center:f,size:n,radius:a,insert:!1});return p.copyAttributes(this,!0),p._matrix.prepend(this._matrix),p.rotate(r.subtract(f).getAngle()+90),(e===t||e)&&p.insertAbove(this),p}return null},toPath:"#clone",compare:function e(t){if(!t||t instanceof F)return e.base.call(this,t);var i=this.getCurves(),n=t.getCurves(),a=i.length,r=n.length;if(!a||!r)return a==r;for(var o,s,l=i[0].getValues(),h=[],d=0,c=0,u=0;u<r;u++){var g=n[u].getValues();if(h.push(g),m=O.getOverlaps(l,g)){o=!u&&m[0][0]>0?r-1:u,s=m[0][1];break}}var f,p=Math.abs;for(g=h[o];l&&g;){var m;if((m=O.getOverlaps(l,g))&&p(m[0][0]-c)<1e-8){1===(c=m[1][0])&&(l=++d<a?i[d].getValues():null,c=0);var v=m[0][1];if(p(v-s)<1e-8){if(f||(f=[o,v]),1===(s=m[1][1])&&(++o>=r&&(o=0),g=h[o]||n[o].getValues(),s=0),!l)return f[0]===o&&f[1]===s;continue}}break}return!1},_hitTestSelf:function(e,t,i,n){var a,r,o,s,l,h,d=this,c=this.getStyle(),u=this._segments,g=u.length,f=this._closed,p=t._tolerancePadding,m=p,v=t.stroke&&c.hasStroke(),I=t.fill&&c.hasFill(),y=t.curves,C=v?c.getStrokeWidth()/2:I&&t.tolerance>0||y?0:null;function M(t,i){return e.subtract(t).divide(i).length<=1}function x(e,i,n){if(!t.selected||i.isSelected()){var a=e._point;if(i!==a&&(i=i.add(a)),M(i,m))return new _(n,d,{segment:e,point:i})}}function S(e,i){return(i||t.segments)&&x(e,e._point,"segment")||!i&&t.handles&&(x(e,e._handleIn,"handle-in")||x(e,e._handleOut,"handle-out"))}function b(e){s.add(e)}function w(t){var i,l=f||t._index>0&&t._index<g-1;return"round"===(l?a:r)?M(t._point,m):(s=new R({internal:!0,closed:!0}),l?t.isSmooth()||R._addBevelJoin(t,a,C,o,null,n,b,!0):"square"===r&&R._addSquareCap(t,r,C,null,n,b,!0),s.isEmpty()?void 0:s.contains(e)||(i=s.getNearestLocation(e))&&M(i.getPoint(),p))}if(null!==C&&(C>0?(a=c.getStrokeJoin(),r=c.getStrokeCap(),o=c.getMiterLimit(),m=m.add(R._getStrokePadding(C,n))):a=r="round"),!t.ends||t.segments||f){if(t.segments||t.handles)for(var A=0;A<g;A++)if(h=S(u[A]))return h}else if(h=S(u[0],!0)||S(u[g-1],!0))return h;if(null!==C){if(l=this.getNearestLocation(e)){var P=l.getTime();0===P||1===P&&g>1?w(l.getSegment())||(l=null):M(l.getPoint(),m)||(l=null)}if(!l&&"miter"===a&&g>1)for(A=0;A<g;A++){var D=u[A];if(e.getDistance(D._point)<=o*C&&w(D)){l=D.getLocation();break}}}return!l&&I&&this._contains(e)||l&&!v&&!y?new _("fill",this):l?new _(v?"stroke":"curve",this,{location:l,point:l.getPoint()}):null}},a.each(O._evaluateMethods,function(e){this[e+"At"]=function(t){var i=this.getLocationAt(t);return i&&i[e]()}},{beans:!1,getLocationOf:function(){for(var e=f.read(arguments),t=this.getCurves(),i=0,n=t.length;i<n;i++){var a=t[i].getLocationOf(e);if(a)return a}return null},getOffsetOf:function(){var e=this.getLocationOf.apply(this,arguments);return e?e.getOffset():null},getLocationAt:function(e){if("number"==typeof e){for(var t=this.getCurves(),i=0,n=0,a=t.length;n<a;n++){var r=i,o=t[n];if((i+=o.getLength())>e)return o.getLocationAt(e-r)}if(t.length>0&&e<=this.getLength())return new B(t[t.length-1],1)}else if(e&&e.getPath&&e.getPath()===this)return e;return null},getOffsetsWithTangent:function(){var e=f.read(arguments);if(e.isZero())return[];for(var t=[],i=0,n=this.getCurves(),a=0,r=n.length;a<r;a++){for(var o=n[a],s=o.getTimesWithTangent(e),l=0,h=s.length;l<h;l++){var d=i+o.getOffsetAtTime(s[l]);t.indexOf(d)<0&&t.push(d)}i+=o.length}return t}}),new function(){function e(e,t,i){var n,a,r,o,s,l,h,d,c=t._segments,u=c.length,g=new Array(6),f=!0;function p(t){if(i)t._transformCoordinates(i,g),n=g[0],a=g[1];else{var c=t._point;n=c._x,a=c._y}if(f)e.moveTo(n,a),f=!1;else{if(i)s=g[2],l=g[3];else{var u=t._handleIn;s=n+u._x,l=a+u._y}s===n&&l===a&&h===r&&d===o?e.lineTo(n,a):e.bezierCurveTo(h,d,s,l,n,a)}r=n,o=a,i?(h=g[4],d=g[5]):(u=t._handleOut,h=r+u._x,d=o+u._y)}for(var m=0;m<u;m++)p(c[m]);t._closed&&u>0&&p(c[0])}return{_draw:function(t,i,n,a){var r=i.dontStart,o=i.dontFinish||i.clip,s=this.getStyle(),l=s.hasFill(),h=s.hasStroke(),d=s.getDashArray(),c=!le.support.nativeDash&&h&&d&&d.length;function u(e){return d[(e%c+c)%c]}if(r||t.beginPath(),(l||h&&!c||o)&&(e(t,this,a),this._closed&&t.closePath()),!o&&(l||h)&&(this._setStyles(t,i,n),l&&(t.fill(s.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),h)){if(c){r||t.beginPath();for(var g,f=new L(this,.25,32,!1,a),p=f.length,m=-s.getDashOffset(),v=0;m>0;)m-=u(v--)+u(v--);for(;m<p;)g=m+u(v++),(m>0||g>0)&&f.drawPart(t,Math.max(m,0),Math.max(g,0)),m=g+u(v++)}t.stroke()}},_drawSelected:function(t,i){t.beginPath(),e(t,this,i),t.stroke(),function(e,t,i,n){if(!(n<=0))for(var a,r,o=n/2,s=n-2,l=o-1,h=new Array(6),d=0,c=t.length;d<c;d++){var u=t[d],g=u._selection;if(u._transformCoordinates(i,h),a=h[0],r=h[1],2&g&&p(2),4&g&&p(4),e.fillRect(a-o,r-o,n,n),s>0&&!(1&g)){var f=e.fillStyle;e.fillStyle="#ffffff",e.fillRect(a-l,r-l,s,s),e.fillStyle=f}}function p(t){var i=h[t],n=h[t+1];(a!=i||r!=n)&&(e.beginPath(),e.moveTo(a,r),e.lineTo(i,n),e.stroke(),e.beginPath(),e.arc(i,n,o,0,2*Math.PI,!0),e.fill())}}(t,this._segments,i,le.settings.handleSize)}}},new function(){function e(e){var t=e._segments;if(!t.length)throw new Error("Use a moveTo() command first");return t[t.length-1]}return{moveTo:function(){var e=this._segments;1===e.length&&this.removeSegment(0),e.length||this._add([new T(f.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new T(f.read(arguments))])},cubicCurveTo:function(){var t=arguments,i=f.read(t),n=f.read(t),a=f.read(t),r=e(this);r.setHandleOut(i.subtract(r._point)),this._add([new T(a,n.subtract(a))])},quadraticCurveTo:function(){var t=arguments,i=f.read(t),n=f.read(t),a=e(this)._point;this.cubicCurveTo(i.add(a.subtract(i).multiply(1/3)),i.add(n.subtract(i).multiply(1/3)),n)},curveTo:function(){var t=arguments,i=f.read(t),n=f.read(t),r=a.pick(a.read(t),.5),o=1-r,s=e(this)._point,l=i.subtract(s.multiply(o*o)).subtract(n.multiply(r*r)).divide(2*r*o);if(l.isNaN())throw new Error("Cannot put a curve through points with parameter = "+r);this.quadraticCurveTo(l,n)},arcTo:function(){var t,i,n,r,o=arguments,s=Math.abs,l=Math.sqrt,h=e(this),d=h._point,c=f.read(o),g=a.peek(o);if("boolean"==typeof(x=a.pick(g,!0)))var p=(b=d.add(c).divide(2)).add(b.subtract(d).rotate(x?-90:90));else if(a.remain(o)<=2)p=c,c=f.read(o);else if(!d.equals(c)){var v=m.read(o),I=u.isZero;if(I(v.width)||I(v.height))return this.lineTo(c);var y=a.read(o),x=!!a.read(o),S=!!a.read(o),b=d.add(c).divide(2),w=(q=d.subtract(b).rotate(-y)).x,A=q.y,P=s(v.width),D=s(v.height),k=P*P,_=D*D,z=w*w,O=A*A,B=l(z/k+O/_);if(B>1&&(k=(P*=B)*P,_=(D*=B)*D),s(B=(k*_-k*O-_*z)/(k*O+_*z))<1e-12&&(B=0),B<0)throw new Error("Cannot create an arc with the given arguments");t=new f(P*A/D,-D*w/P).multiply((S===x?-1:1)*l(B)).rotate(y).add(b),i=(n=(r=(new C).translate(t).rotate(y).scale(P,D))._inverseTransform(d)).getDirectedAngle(r._inverseTransform(c)),!x&&i>0?i-=360:x&&i<0&&(i+=360)}if(p){var E=new M(d.add(p).divide(2),p.subtract(d).rotate(90),!0),R=new M(p.add(c).divide(2),c.subtract(p).rotate(90),!0),F=new M(d,c),L=F.getSide(p);if(!(t=E.intersect(R,!0))){if(!L)return this.lineTo(c);throw new Error("Cannot create an arc with the given arguments")}i=(n=d.subtract(t)).getDirectedAngle(c.subtract(t));var G=F.getSide(t,!0);0===G?i=L*s(i):L===G&&(i+=i<0?360:-360)}if(i){for(var U=s(i),j=U>=360?4:Math.ceil((U-1e-5)/90),N=i/j,W=N*Math.PI/360,Z=4/3*Math.sin(W)/(1+Math.cos(W)),H=[],V=0;V<=j;V++){var q=c,J=null;if(V<j&&(J=n.rotate(90).multiply(Z),r?(q=r._transformPoint(n),J=r._transformPoint(n.add(J)).subtract(q)):q=t.add(n)),V){var Q=n.rotate(-90).multiply(Z);r&&(Q=r._transformPoint(n.add(Q)).subtract(q)),H.push(new T(q,Q,J))}else h.setHandleOut(J);n=n.rotate(N)}this._add(H)}},lineBy:function(){var t=f.read(arguments),i=e(this)._point;this.lineTo(i.add(t))},curveBy:function(){var t=arguments,i=f.read(t),n=f.read(t),r=a.read(t),o=e(this)._point;this.curveTo(o.add(i),o.add(n),r)},cubicCurveBy:function(){var t=arguments,i=f.read(t),n=f.read(t),a=f.read(t),r=e(this)._point;this.cubicCurveTo(r.add(i),r.add(n),r.add(a))},quadraticCurveBy:function(){var t=arguments,i=f.read(t),n=f.read(t),a=e(this)._point;this.quadraticCurveTo(a.add(i),a.add(n))},arcBy:function(){var t=arguments,i=e(this)._point,n=i.add(f.read(t)),r=a.pick(a.peek(t),!0);"boolean"==typeof r?this.arcTo(n,r):this.arcTo(n,i.add(f.read(t)))},closePath:function(e){this.setClosed(!0),this.join(this,e)}}},{_getBounds:function(e,t){var i=t.handle?"getHandleBounds":t.stroke?"getStrokeBounds":"getBounds";return R[i](this._segments,this._closed,this,e,t)},statics:{getBounds:function(e,t,i,n,a,r){var o=e[0];if(!o)return new I;var s=new Array(6),l=o._transformCoordinates(n,new Array(6)),h=l.slice(0,2),d=h.slice(),c=new Array(2);function u(e){e._transformCoordinates(n,s);for(var t=0;t<2;t++)O._addBounds(l[t],l[t+4],s[t+2],s[t],t,r?r[t]:0,h,d,c);var i=l;l=s,s=i}for(var g=1,f=e.length;g<f;g++)u(e[g]);return t&&u(o),new I(h[0],h[1],d[0]-h[0],d[1]-h[1])},getStrokeBounds:function(e,t,i,n,a){var r=i.getStyle(),o=r.hasStroke(),s=r.getStrokeWidth(),l=o&&i._getStrokeMatrix(n,a),h=o&&R._getStrokePadding(s,l),d=R.getBounds(e,t,i,n,a,h);if(!o)return d;var c=s/2,u=r.getStrokeJoin(),g=r.getStrokeCap(),f=r.getMiterLimit(),p=new I(new m(h));function v(e){d=d.include(e)}function y(e){d=d.unite(p.setCenter(e._point.transform(n)))}function C(e,t){"round"===t||e.isSmooth()?y(e):R._addBevelJoin(e,t,c,f,n,l,v)}function M(e,t){"round"===t?y(e):R._addSquareCap(e,t,c,n,l,v)}var x=e.length-(t?0:1);if(x>0){for(var S=1;S<x;S++)C(e[S],u);t?C(e[0],u):(M(e[0],g),M(e[e.length-1],g))}return d},_getStrokePadding:function(e,t){if(!t)return[e,e];var i=new f(e,0).transform(t),n=new f(0,e).transform(t),a=i.getAngleInRadians(),r=i.getLength(),o=n.getLength(),s=Math.sin(a),l=Math.cos(a),h=Math.tan(a),d=Math.atan2(o*h,r),c=Math.atan2(o,h*r);return[Math.abs(r*Math.cos(d)*l+o*Math.sin(d)*s),Math.abs(o*Math.sin(c)*l+r*Math.cos(c)*s)]},_addBevelJoin:function(e,t,i,n,a,r,o,s){var l=e.getCurve(),h=l.getPrevious(),d=l.getPoint1().transform(a),c=h.getNormalAtTime(1).multiply(i).transform(r),u=l.getNormalAtTime(0).multiply(i).transform(r),g=c.getDirectedAngle(u);if((g<0||g>=180)&&(c=c.negate(),u=u.negate()),s&&o(d),o(d.add(c)),"miter"===t){var p=new M(d.add(c),new f(-c.y,c.x),!0).intersect(new M(d.add(u),new f(-u.y,u.x),!0),!0);p&&d.getDistance(p)<=n*i&&o(p)}o(d.add(u))},_addSquareCap:function(e,t,i,n,a,r,o){var s=e._point.transform(n),l=e.getLocation(),h=l.getNormal().multiply(0===l.getTime()?i:-i).transform(a);"square"===t&&(o&&(r(s.subtract(h)),r(s.add(h))),s=s.add(h.rotate(-90))),r(s.add(h)),r(s.subtract(h))},getHandleBounds:function(e,t,i,n,a){var r,o,s=i.getStyle();if(a.stroke&&s.hasStroke()){var l=i._getStrokeMatrix(n,a),h=s.getStrokeWidth()/2,d=h;"miter"===s.getStrokeJoin()&&(d=h*s.getMiterLimit()),"square"===s.getStrokeCap()&&(d=Math.max(d,h*Math.SQRT2)),r=R._getStrokePadding(h,l),o=R._getStrokePadding(d,l)}for(var c=new Array(6),u=1/0,g=-u,f=u,p=g,m=0,v=e.length;m<v;m++){e[m]._transformCoordinates(n,c);for(var y=0;y<6;y+=2){var C=y?r:o,M=C?C[0]:0,x=C?C[1]:0,S=c[y],b=c[y+1],w=S-M,A=S+M,P=b-x,D=b+x;w<u&&(u=w),A>g&&(g=A),P<f&&(f=P),D>p&&(p=D)}}return new I(u,f,g-u,p-f)}}});R.inject({statics:new function(){var e=.5522847498307936,t=[new T([-1,0],[0,e],[0,-e]),new T([0,-1],[-e,0],[e,0]),new T([1,0],[0,-e],[0,e]),new T([0,1],[e,0],[-e,0])];function i(e,t,i){var n=a.getNamed(i),r=new R(n&&(1==n.insert?S.INSERT:0==n.insert?S.NO_INSERT:null));return r._add(e),r._closed=t,r.set(n,S.INSERT)}function n(e,n,a){for(var r=new Array(4),o=0;o<4;o++){var s=t[o];r[o]=new T(s._point.multiply(n).add(e),s._handleIn.multiply(n),s._handleOut.multiply(n))}return i(r,!0,a)}return{Line:function(){var e=arguments;return i([new T(f.readNamed(e,"from")),new T(f.readNamed(e,"to"))],!1,e)},Circle:function(){var e=arguments,t=f.readNamed(e,"center"),i=a.readNamed(e,"radius");return n(t,new m(i),e)},Rectangle:function(){var t,n=arguments,a=I.readNamed(n,"rectangle"),r=m.readNamed(n,"radius",0,{readNull:!0}),o=a.getBottomLeft(!0),s=a.getTopLeft(!0),l=a.getTopRight(!0),h=a.getBottomRight(!0);if(!r||r.isZero())t=[new T(o),new T(s),new T(l),new T(h)];else{var d=(r=m.min(r,a.getSize(!0).divide(2))).width,c=r.height,u=d*e,g=c*e;t=[new T(o.add(d,0),null,[-u,0]),new T(o.subtract(0,c),[0,g]),new T(s.add(0,c),null,[0,-g]),new T(s.add(d,0),[-u,0],null),new T(l.subtract(d,0),null,[u,0]),new T(l.add(0,c),[0,-g],null),new T(h.subtract(0,c),null,[0,g]),new T(h.subtract(d,0),[u,0])]}return i(t,!0,n)},RoundRectangle:"#Rectangle",Ellipse:function(){var e=arguments,t=A._readEllipse(e);return n(t.center,t.radius,e)},Oval:"#Ellipse",Arc:function(){var e=arguments,t=f.readNamed(e,"from"),i=f.readNamed(e,"through"),n=f.readNamed(e,"to"),r=a.getNamed(e),o=new R(r&&0==r.insert&&S.NO_INSERT);return o.moveTo(t),o.arcTo(i,n),o.set(r)},RegularPolygon:function(){for(var e=arguments,t=f.readNamed(e,"center"),n=a.readNamed(e,"sides"),r=a.readNamed(e,"radius"),o=360/n,s=n%3==0,l=new f(0,s?-r:r),h=s?-1:.5,d=new Array(n),c=0;c<n;c++)d[c]=new T(t.add(l.rotate((c+h)*o)));return i(d,!0,e)},Star:function(){for(var e=arguments,t=f.readNamed(e,"center"),n=2*a.readNamed(e,"points"),r=a.readNamed(e,"radius1"),o=a.readNamed(e,"radius2"),s=360/n,l=new f(0,-1),h=new Array(n),d=0;d<n;d++)h[d]=new T(t.add(l.rotate(s*d).multiply(d%2?o:r)));return i(h,!0,e)}}}});var F=E.extend({_class:"CompoundPath",_serializeFields:{children:[]},beans:!0,initialize:function(e){this._children=[],this._namedChildren={},this._initialize(e)||("string"==typeof e?this.setPathData(e):this.addChildren(Array.isArray(e)?e:arguments))},insertChildren:function e(t,i){var n=i,r=n[0];r&&"number"==typeof r[0]&&(n=[n]);for(var o=i.length-1;o>=0;o--){var s=n[o];n===i&&!(s instanceof R)&&(n=a.slice(n)),Array.isArray(s)?n[o]=new R({segments:s,insert:!1}):s instanceof F&&(n.splice.apply(n,[o,1].concat(s.removeChildren())),s.remove())}return e.base.call(this,t,n)},reduce:function e(t){for(var i=this._children,n=i.length-1;n>=0;n--)(a=i[n].reduce(t)).isEmpty()&&a.remove();var a;return i.length?e.base.call(this):((a=new R(S.NO_INSERT)).copyAttributes(this),a.insertAbove(this),this.remove(),a)},isClosed:function(){for(var e=this._children,t=0,i=e.length;t<i;t++)if(!e[t]._closed)return!1;return!0},setClosed:function(e){for(var t=this._children,i=0,n=t.length;i<n;i++)t[i].setClosed(e)},getFirstSegment:function(){var e=this.getFirstChild();return e&&e.getFirstSegment()},getLastSegment:function(){var e=this.getLastChild();return e&&e.getLastSegment()},getCurves:function(){for(var e=this._children,t=[],i=0,n=e.length;i<n;i++)a.push(t,e[i].getCurves());return t},getFirstCurve:function(){var e=this.getFirstChild();return e&&e.getFirstCurve()},getLastCurve:function(){var e=this.getLastChild();return e&&e.getLastCurve()},getArea:function(){for(var e=this._children,t=0,i=0,n=e.length;i<n;i++)t+=e[i].getArea();return t},getLength:function(){for(var e=this._children,t=0,i=0,n=e.length;i<n;i++)t+=e[i].getLength();return t},getPathData:function(e,t){for(var i=this._children,n=[],a=0,r=i.length;a<r;a++){var o=i[a],s=o._matrix;n.push(o.getPathData(e&&!s.isIdentity()?e.appended(s):e,t))}return n.join("")},_hitTestChildren:function e(t,i,n){return e.base.call(this,t,i.class===R||"path"===i.type?i:a.set({},i,{fill:!1}),n)},_draw:function(e,t,i,n){var a=this._children;if(a.length){t=t.extend({dontStart:!0,dontFinish:!0}),e.beginPath();for(var r=0,o=a.length;r<o;r++)a[r].draw(e,t,n);if(!t.clip){this._setStyles(e,t,i);var s=this._style;s.hasFill()&&(e.fill(s.getFillRule()),e.shadowColor="rgba(0,0,0,0)"),s.hasStroke()&&e.stroke()}}},_drawSelected:function(e,t,i){for(var n=this._children,a=0,r=n.length;a<r;a++){var o=n[a],s=o._matrix;i[o._id]||o._drawSelected(e,s.isIdentity()?t:t.appended(s))}}},new function(){function e(e,t){var i=e._children;if(t&&!i.length)throw new Error("Use a moveTo() command first");return i[i.length-1]}return a.each(["lineTo","cubicCurveTo","quadraticCurveTo","curveTo","arcTo","lineBy","cubicCurveBy","quadraticCurveBy","curveBy","arcBy"],function(t){this[t]=function(){var i=e(this,!0);i[t].apply(i,arguments)}},{moveTo:function(){var t=e(this),i=t&&t.isEmpty()?t:new R(S.NO_INSERT);i!==t&&this.addChild(i),i.moveTo.apply(i,arguments)},moveBy:function(){var t=e(this,!0),i=t&&t.getLastSegment(),n=f.read(arguments);this.moveTo(i?n.add(i._point):n)},closePath:function(t){e(this,!0).closePath(t)}})},a.each(["reverse","flatten","simplify","smooth"],function(e){this[e]=function(t){for(var i,n=this._children,a=0,r=n.length;a<r;a++)i=n[a][e](t)||i;return i}},{}));E.inject(new function(){var e=Math.min,i=Math.max,n=Math.abs,r={unite:{1:!0,2:!0},intersect:{2:!0},subtract:{1:!0},exclude:{1:!0,"-1":!0}};function o(e){return e._children||[e]}function s(e,t){var i=e.clone(!1).reduce({simplify:!0}).transform(null,!0,!0);if(t){for(var n=o(i),a=0,r=n.length;a<r;a++)!(e=n[a])._closed&&!e.isEmpty()&&(e.closePath(1e-12),e.getFirstSegment().setHandleIn(0,0),e.getLastSegment().setHandleOut(0,0));i=i.resolveCrossings().reorient("nonzero"===i.getFillRule(),!0)}return i}function l(e,t,i,n,a){var r=new F(S.NO_INSERT);return r.addChildren(e,!0),r=r.reduce({simplify:t}),a&&0==a.insert||r.insertAbove(n&&i.isSibling(n)&&i.getIndex()<n.getIndex()?n:i),r.copyAttributes(i,!0),r}function h(e){return e.hasOverlap()||e.isCrossing()}function c(e,t,i,n){if(n&&(0==n.trace||n.stroke)&&/^(subtract|intersect)$/.test(i))return g(e,t,i);var c=s(e,!0),u=t&&e!==t&&s(t,!0),f=r[i];f[i]=!0,u&&(f.subtract||f.exclude)^u.isClockwise()^c.isClockwise()&&u.reverse();var p,I=v(B.expand(c.getIntersections(u,h))),M=o(c),x=u&&o(u),S=[],b=[];function w(e){for(var t=0,i=e.length;t<i;t++){var n=e[t];a.push(S,n._segments),a.push(b,n.getCurves()),n._overlapsOnly=!0}}function A(e){for(var t=[],i=0,n=e&&e.length;i<n;i++)t.push(b[e[i]]);return t}if(I.length){w(M),x&&w(x);for(var P=new Array(b.length),D=0,k=b.length;D<k;D++)P[D]=b[D].getValues();var _=d.findCurveBoundsCollisions(P,P,0,!0),T={};for(D=0;D<b.length;D++){var z=b[D],O=z._path._id;(T[O]=T[O]||{})[z.getIndex()]={hor:A(_[D].hor),ver:A(_[D].ver)}}for(D=0,k=I.length;D<k;D++)y(I[D]._segment,c,u,T,f);for(D=0,k=S.length;D<k;D++){var E=S[D],R=E._intersection;E._winding||y(E,c,u,T,f),R&&R._overlap||(E._path._overlapsOnly=!1)}p=C(S,f)}else p=m(x?M.concat(x):M.slice(),function(e){return!!f[e]});return l(p,!0,e,t,n)}function g(e,t,i){var n=s(e),a=s(t),r=n.getIntersections(a,h),o="subtract"===i,d="divide"===i,c={},u=[];function g(e){if(!c[e._id]&&(d||a.contains(e.getPointAt(e.getLength()/2))^o))return u.unshift(e),c[e._id]=!0}for(var f=r.length-1;f>=0;f--){var p=r[f].split();p&&(g(p)&&p.getFirstSegment().setHandleIn(0,0),n.getLastSegment().setHandleOut(0,0))}return g(n),l(u,!1,e,t)}function f(e,t){for(var i=e;i;){if(i===t)return;i=i._previous}for(;e._next&&e._next!==t;)e=e._next;if(!e._next){for(;t._previous;)t=t._previous;e._next=t,t._previous=e}}function p(e){for(var t=e.length-1;t>=0;t--)e[t].clearHandles()}function m(e,t,i){var r=e&&e.length;if(r){var o=a.each(e,function(e,t){this[e._id]={container:null,winding:e.isClockwise()?1:-1,index:t}},{}),s=e.slice().sort(function(e,t){return n(t.getArea())-n(e.getArea())}),l=s[0],h=d.findItemBoundsCollisions(s,null,u.GEOMETRIC_EPSILON);null==i&&(i=l.isClockwise());for(var c=0;c<r;c++){var g=s[c],f=o[g._id],p=0,m=h[c];if(m)for(var v=null,I=m.length-1;I>=0;I--)if(m[I]<c){v=v||g.getInteriorPoint();var y=s[m[I]];if(y.contains(v)){var C=o[y._id];p=C.winding,f.winding+=p,f.container=C.exclude?C.container:y;break}}if(t(f.winding)===t(p))f.exclude=!0,e[f.index]=null;else{var M=f.container;g.setClockwise(M?!M.isClockwise():i)}}}return e}function v(e,t,i){var n,a,r,o=t&&[],s=1e-8,l=!1,h=i||[],d=i&&{};function c(e){return e._path._id+"."+e._segment1._index}for(var u=(i&&i.length)-1;u>=0;u--)(g=i[u])._path&&(d[c(g)]=!0);for(u=e.length-1;u>=0;u--){var g,m,v=e[u],I=v._time,y=I,C=t&&!t(v);if((g=v._curve)&&(g!==a?(l=!g.hasHandles()||d&&d[c(g)],n=[],r=null,a=g):r>=s&&(I/=r)),C)n&&n.push(v);else{if(t&&o.unshift(v),r=y,I<s)m=g._segment1;else if(I>.99999999)m=g._segment2;else{var M=g.divideAtTime(I,!0);l&&h.push(g,M),m=M._segment1;for(var x=n.length-1;x>=0;x--){var S=n[x];S._time=(S._time-I)/(1-I)}}v._setSegment(m);var b=m._intersection,w=v._intersection;if(b){f(b,w);for(var A=b;A;)f(A._intersection,b),A=A._next}else m._intersection=w}}return i||p(h),o||e}function I(t,a,r,o,s){var l,h,d=Array.isArray(a)?a:a[r?"hor":"ver"],c=r?1:0,u=1^c,g=[t.x,t.y],f=g[c],p=g[u],m=1e-6,v=f-1e-9,y=f+1e-9,C=0,M=0,x=0,S=0,b=!1,w=!1,A=1,P=[];function D(n){var h=n[u+0],d=n[u+6];if(!(p<e(h,d)||p>i(h,d))){var g=n[c+0],C=n[c+2],M=n[c+4],w=n[c+6];if(h===d)return void((g<y&&w>v||w<y&&g>v)&&(b=!0));var D=p===h?0:p===d||v>i(g,C,M,w)||y<e(g,C,M,w)?1:O.solveCubic(n,u,p,P,0,1)>0?P[0]:1,k=0===D?g:1===D?w:O.getPoint(n,D)[r?"y":"x"],_=h>d?1:-1,T=l[u]>l[u+6]?1:-1,z=l[c+6];return p!==h?(k<v?x+=_:k>y?S+=_:b=!0,k>f-m&&k<f+m&&(A/=2)):(_!==T?g<v?x+=_:g>y&&(S+=_):g!=z&&(z<y&&k>y?(S+=_,b=!0):z>v&&k<v&&(x+=_,b=!0)),A/=4),l=n,!s&&k>v&&k<y&&0===O.getTangent(n,D)[r?"x":"y"]&&I(t,a,!r,o,!0)}}function k(t){var n=t[u+0],a=t[u+2],o=t[u+4],s=t[u+6];if(p<=i(n,a,o,s)&&p>=e(n,a,o,s))for(var l,h=t[c+0],d=t[c+2],g=t[c+4],f=t[c+6],m=v>i(h,d,g,f)||y<e(h,d,g,f)?[t]:O.getMonoCurves(t,r),I=0,C=m.length;I<C;I++)if(l=D(m[I]))return l}for(var _=0,T=d.length;_<T;_++){var z,B=d[_],E=B._path,R=B.getValues();if(!(_&&d[_-1]._path===E||(l=null,E._closed||(h=O.getValues(E.getLastCurve().getSegment2(),B.getSegment1(),null,!o),h[u]!==h[u+6]&&(l=h)),l))){l=R;for(var F=E.getLastCurve();F&&F!==B;){var L=F.getValues();if(L[u]!==L[u+6]){l=L;break}F=F.getPrevious()}}if(z=k(R))return z;if(_+1===T||d[_+1]._path!==E){if(h&&(z=k(h)))return z;b&&!x&&!S&&(x=S=E.isClockwise(o)^r?1:-1),C+=x,M+=S,x=S=0,b&&(w=!0,b=!1),h=null}}return C=n(C),M=n(M),{winding:i(C,M),windingL:C,windingR:M,quality:A,onPath:w}}function y(e,t,i,a,r){var o=[],s=e,l=0;do{if(y=e.getCurve()){var h=y.getLength();o.push({segment:e,curve:y,length:h}),l+=h}e=e.getNext()}while(e&&!e._intersection&&e!==s);for(var d=[.5,.25,.75],c={winding:0,quality:-1},g=0;g<d.length&&c.quality<.5;g++){h=l*d[g];for(var f=0,p=o.length;f<p;f++){var m=o[f],v=m.length;if(h<=v){var y,C=(y=m.curve)._path,M=C._parent,x=M instanceof F?M:C,S=u.clamp(y.getTimeAt(h),.001,.999),b=y.getPointAtTime(S),w=n(y.getTangentAtTime(S).y)<Math.SQRT1_2,A=null;if(r.subtract&&i){var P=(x===t?i:t)._getWinding(b,w,!0);if(x===t&&P.winding||x===i&&!P.winding){if(P.quality<1)continue;A={winding:0,quality:1}}}(A=A||I(b,a[C._id][y.getIndex()],w,!0)).quality>c.quality&&(c=A);break}h-=v}}for(f=o.length-1;f>=0;f--)o[f].segment._winding=c}function C(e,t){var i,n=[];function a(e){var i;return!(!e||e._visited||t&&(!t[(i=e._winding||{}).winding]||t.unite&&2===i.winding&&i.windingL&&i.windingR))}function r(e){if(e)for(var t=0,n=i.length;t<n;t++)if(e===i[t])return!0;return!1}function o(e){for(var t=e._segments,i=0,n=t.length;i<n;i++)t[i]._visited=!0}function s(e,t){var n=e._intersection,o=n,s=[];function l(n,o){for(;n&&n!==o;){var l=n._segment,h=l&&l._path;if(h){var d=l.getNext()||h.getFirstSegment(),c=d._intersection;l!==e&&(r(l)||r(d)||d&&a(l)&&(a(d)||c&&a(c._segment)))&&s.push(l),t&&i.push(l)}n=n._next}}if(t&&(i=[e]),n){for(l(n);n&&n._previous;)n=n._previous;l(n,o)}return s}e.sort(function(e,t){var i=e._intersection,n=t._intersection,a=!(!i||!i._overlap),r=!(!n||!n._overlap),o=e._path,s=t._path;return a^r?a?1:-1:!i^!n?i?1:-1:o!==s?o._id-s._id:e._index-t._index});for(var l=0,h=e.length;l<h;l++){var d,c,u,g=e[l],f=a(g),p=null,m=!1,v=!0,I=[];if(f&&g._path._overlapsOnly){var y=g._path,C=g._intersection._segment._path;y.compare(C)&&(y.getArea()&&n.push(y.clone(!1)),o(y),o(C),f=!1)}for(;f;){var M=!p,x=s(g,M),b=x.shift(),w=!(m=!M&&(r(g)||r(b)))&&b;if(M&&(p=new R(S.NO_INSERT),d=null),m){(g.isFirst()||g.isLast())&&(v=g._path._closed),g._visited=!0;break}if(w&&d&&(I.push(d),d=null),d||(w&&x.push(g),d={start:p._segments.length,crossings:x,visited:c=[],handleIn:u}),w&&(g=b),!a(g)){p.removeSegments(d.start);for(var A=0,P=c.length;A<P;A++)c[A]._visited=!1;c.length=0;do{(!(g=d&&d.crossings.shift())||!g._path)&&(g=null,(d=I.pop())&&(c=d.visited,u=d.handleIn))}while(d&&!a(g));if(!g)break}var D=g.getNext();p.add(new T(g._point,u,D&&g._handleOut)),g._visited=!0,c.push(g),g=D||g._path.getFirstSegment(),u=D&&D._handleIn}m&&(v&&(p.getFirstSegment().setHandleIn(u),p.setClosed(v)),0!==p.getArea()&&n.push(p))}return n}return{_getWinding:function(e,t,i){return I(e,this.getCurves(),t,i)},unite:function(e,t){return c(this,e,"unite",t)},intersect:function(e,t){return c(this,e,"intersect",t)},subtract:function(e,t){return c(this,e,"subtract",t)},exclude:function(e,t){return c(this,e,"exclude",t)},divide:function(e,t){return t&&(0==t.trace||t.stroke)?g(this,e,"divide"):l([this.subtract(e,t),this.intersect(e,t)],!0,this,e,t)},resolveCrossings:function(){var e=this._children,t=e||[this];function i(e,t){var i=e&&e._intersection;return i&&i._overlap&&i._path===t}var n=!1,r=!1,o=this.getIntersections(null,function(e){return e.hasOverlap()&&(n=!0)||e.isCrossing()&&(r=!0)}),s=n&&r&&[];if(o=B.expand(o),n)for(var l=v(o,function(e){return e.hasOverlap()},s),h=l.length-1;h>=0;h--){var d=l[h],c=d._path,u=d._segment,g=u.getPrevious(),f=u.getNext();i(g,c)&&i(f,c)&&(u.remove(),g._handleOut._set(0,0),f._handleIn._set(0,0),g!==u&&!g.getCurve().hasLength()&&(f._handleIn.set(g._handleIn),g.remove()))}r&&(v(o,n&&function(e){var t=e.getCurve(),i=e.getSegment(),n=e._intersection,a=n._curve,r=n._segment;if(t&&a&&t._path&&a._path)return!0;i&&(i._intersection=null),r&&(r._intersection=null)},s),s&&p(s),t=C(a.each(t,function(e){a.push(this,e._segments)},[])));var m,I=t.length;return I>1&&e?(t!==e&&this.setChildren(t),m=this):1===I&&!e&&(t[0]!==this&&this.setSegments(t[0].removeSegments()),m=this),m||((m=new F(S.NO_INSERT)).addChildren(t),(m=m.reduce()).copyAttributes(this),this.replaceWith(m)),m},reorient:function(e,i){var n=this._children;return n&&n.length?this.setChildren(m(this.removeChildren(),function(t){return!!(e?t:1&t)},i)):i!==t&&this.setClockwise(i),this},getInteriorPoint:function(){var t=this.getBounds().getCenter(!0);if(!this.contains(t)){for(var n=this.getCurves(),a=t.y,r=[],o=[],s=0,l=n.length;s<l;s++){var h=n[s].getValues(),d=h[1],c=h[3],u=h[5],g=h[7];if(a>=e(d,c,u,g)&&a<=i(d,c,u,g))for(var f=O.getMonoCurves(h),p=0,m=f.length;p<m;p++){var v=f[p],I=v[1],y=v[7];if(I!==y&&(a>=I&&a<=y||a>=y&&a<=I)){var C=a===I?v[0]:a===y?v[6]:1===O.solveCubic(v,1,a,o,0,1)?O.getPoint(v,o[0]).x:(v[0]+v[6])/2;r.push(C)}}}r.length>1&&(r.sort(function(e,t){return e-t}),t.x=(r[0]+r[1])/2)}return t}}});var L=a.extend({_class:"PathFlattener",initialize:function(e,t,i,n,a){var r,o=[],s=[],l=0,h=1/(i||32),d=e._segments,c=d[0];function u(e,i){var r=O.getValues(e,i,a);o.push(r),function e(i,a,r,o){if(!(o-r>h)||n&&O.isStraight(i)||O.isFlatEnough(i,t||.25)){var d=i[6]-i[0],c=i[7]-i[1],u=Math.sqrt(d*d+c*c);u>0&&(l+=u,s.push({offset:l,curve:i,index:a,time:o}))}else{var g=O.subdivide(i,.5),f=(r+o)/2;e(g[0],a,r,f),e(g[1],a,f,o)}}(r,e._index,0,1)}for(var g=1,f=d.length;g<f;g++)u(c,r=d[g]),c=r;e._closed&&u(r||c,d[0]),this.curves=o,this.parts=s,this.length=l,this.index=0},_get:function(e){for(var t,i=this.parts,n=i.length,a=this.index;t=a,a&&!(i[--a].offset<e););for(;t<n;t++){var r=i[t];if(r.offset>=e){this.index=t;var o=i[t-1],s=o&&o.index===r.index?o.time:0,l=o?o.offset:0;return{index:r.index,time:s+(r.time-s)*(e-l)/(r.offset-l)}}}return{index:i[n-1].index,time:1}},drawPart:function(e,t,i){for(var n=this._get(t),a=this._get(i),r=n.index,o=a.index;r<=o;r++){var s=O.getPart(this.curves[r],r===n.index?n.time:0,r===a.index?a.time:1);r===n.index&&e.moveTo(s[0],s[1]),e.bezierCurveTo.apply(e,s.slice(2))}}},a.each(O._evaluateMethods,function(e){this[e+"At"]=function(t){var i=this._get(t);return O[e](this.curves[i.index],i.time)}},{})),G=a.extend({initialize:function(e){for(var t,i=this.points=[],n=e._segments,a=e._closed,r=0,o=n.length;r<o;r++){var s=n[r].point;(!t||!t.equals(s))&&i.push(t=s.clone())}a&&(i.unshift(i[i.length-1]),i.push(i[1])),this.closed=a},fit:function(e){var t=this.points,i=t.length,n=null;return i>0&&(n=[new T(t[0])],i>1&&(this.fitCubic(n,e,0,i-1,t[1].subtract(t[0]),t[i-2].subtract(t[i-1])),this.closed&&(n.shift(),n.pop()))),n},fitCubic:function(e,t,i,n,a,r){var o=this.points;if(n-i!=1){for(var s,l=this.chordLengthParameterize(i,n),h=Math.max(t,t*t),d=!0,c=0;c<=4;c++){var u=this.generateBezier(i,n,l,a,r),g=this.findMaxError(i,n,u,l);if(g.error<t&&d)return void this.addCurve(e,u);if(s=g.index,g.error>=h)break;d=this.reparameterize(i,n,l,u),h=g.error}var f=o[s-1].subtract(o[s+1]);this.fitCubic(e,t,i,s,a,f),this.fitCubic(e,t,s,n,f.negate(),r)}else{var p=o[i],m=o[n],v=p.getDistance(m)/3;this.addCurve(e,[p,p.add(a.normalize(v)),m.add(r.normalize(v)),m])}},addCurve:function(e,t){e[e.length-1].setHandleOut(t[1].subtract(t[0])),e.push(new T(t[3],t[2].subtract(t[3])))},generateBezier:function(e,t,i,n,a){for(var r=1e-12,o=Math.abs,s=this.points,l=s[e],h=s[t],d=[[0,0],[0,0]],c=[0,0],u=0,g=t-e+1;u<g;u++){var f=i[u],p=1-f,m=3*f*p,v=p*p*p,I=m*p,y=m*f,C=f*f*f,M=n.normalize(I),x=a.normalize(y),S=s[e+u].subtract(l.multiply(v+I)).subtract(h.multiply(y+C));d[0][0]+=M.dot(M),d[0][1]+=M.dot(x),d[1][0]=d[0][1],d[1][1]+=x.dot(x),c[0]+=M.dot(S),c[1]+=x.dot(S)}var b,w,A=d[0][0]*d[1][1]-d[1][0]*d[0][1];if(o(A)>r){var P=d[0][0]*c[1]-d[1][0]*c[0];b=(c[0]*d[1][1]-c[1]*d[0][1])/A,w=P/A}else{var D=d[0][0]+d[0][1],k=d[1][0]+d[1][1];b=w=o(D)>r?c[0]/D:o(k)>r?c[1]/k:0}var _,T,z=h.getDistance(l),O=r*z;if(b<O||w<O)b=w=z/3;else{var B=h.subtract(l);_=n.normalize(b),T=a.normalize(w),_.dot(B)-T.dot(B)>z*z&&(b=w=z/3,_=T=null)}return[l,l.add(_||n.normalize(b)),h.add(T||a.normalize(w)),h]},reparameterize:function(e,t,i,n){for(var a=e;a<=t;a++)i[a-e]=this.findRoot(n,this.points[a],i[a-e]);a=1;for(var r=i.length;a<r;a++)if(i[a]<=i[a-1])return!1;return!0},findRoot:function(e,t,i){for(var n=[],a=[],r=0;r<=2;r++)n[r]=e[r+1].subtract(e[r]).multiply(3);for(r=0;r<=1;r++)a[r]=n[r+1].subtract(n[r]).multiply(2);var o=this.evaluate(3,e,i),s=this.evaluate(2,n,i),l=this.evaluate(1,a,i),h=o.subtract(t),d=s.dot(s)+h.dot(l);return u.isMachineZero(d)?i:i-h.dot(s)/d},evaluate:function(e,t,i){for(var n=t.slice(),a=1;a<=e;a++)for(var r=0;r<=e-a;r++)n[r]=n[r].multiply(1-i).add(n[r+1].multiply(i));return n[0]},chordLengthParameterize:function(e,t){for(var i=[0],n=e+1;n<=t;n++)i[n-e]=i[n-e-1]+this.points[n].getDistance(this.points[n-1]);n=1;for(var a=t-e;n<=a;n++)i[n]/=i[a];return i},findMaxError:function(e,t,i,n){for(var a=Math.floor((t-e+1)/2),r=0,o=e+1;o<t;o++){var s=this.evaluate(3,i,n[o-e]).subtract(this.points[o]),l=s.x*s.x+s.y*s.y;l>=r&&(r=l,a=o)}return{error:r,index:a}}}),U=S.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(e){this._content="",this._lines=[];var i=e&&a.isPlainObject(e)&&e.x===t&&e.y===t;this._initialize(i&&e,!i&&f.read(arguments))},_equals:function(e){return this._content===e._content},copyContent:function(e){this.setContent(e._content)},getContent:function(){return this._content},setContent:function(e){this._content=""+e,this._lines=this._content.split(/\r\n|\n|\r/gm),this._changed(521)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),j=U.extend({_class:"PointText",initialize:function(){U.apply(this,arguments)},getPoint:function(){var e=this._matrix.getTranslation();return new p(e.x,e.y,this,"setPoint")},setPoint:function(){var e=f.read(arguments);this.translate(e.subtract(this._matrix.getTranslation()))},_draw:function(e,t,i){if(this._content){this._setStyles(e,t,i);var n=this._lines,a=this._style,r=a.hasFill(),o=a.hasStroke(),s=a.getLeading(),l=e.shadowColor;e.font=a.getFontStyle(),e.textAlign=a.getJustification();for(var h=0,d=n.length;h<d;h++){e.shadowColor=l;var c=n[h];r&&(e.fillText(c,0,0),e.shadowColor="rgba(0,0,0,0)"),o&&e.strokeText(c,0,0),e.translate(0,s)}}},_getBounds:function(e,t){var i=this._style,n=this._lines,a=n.length,r=i.getJustification(),o=i.getLeading(),s=this.getView().getTextWidth(i.getFontStyle(),n),l=0;"left"!==r&&(l-=s/("center"===r?2:1));var h=new I(l,a?-.75*o:0,s,a*o);return e?e._transformBounds(h,h):h}}),N=a.extend(new function(){var e,t={gray:["gray"],rgb:["red","green","blue"],hsb:["hue","saturation","brightness"],hsl:["hue","saturation","lightness"],gradient:["gradient","origin","destination","highlight"]},n={},r={transparent:[0,0,0,0]},o=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]],s={"rgb-hsb":function(e,t,i){var n=Math.max(e,t,i),a=n-Math.min(e,t,i);return[0===a?0:60*(n==e?(t-i)/a+(t<i?6:0):n==t?(i-e)/a+2:(e-t)/a+4),0===n?0:a/n,n]},"hsb-rgb":function(e,t,i){var n,a=(e=(e/60%6+6)%6)-(n=Math.floor(e)),r=[i,i*(1-t),i*(1-t*a),i*(1-t*(1-a))];return[r[(n=o[n])[0]],r[n[1]],r[n[2]]]},"rgb-hsl":function(e,t,i){var n=Math.max(e,t,i),a=Math.min(e,t,i),r=n-a,o=0===r,s=(n+a)/2;return[o?0:60*(n==e?(t-i)/r+(t<i?6:0):n==t?(i-e)/r+2:(e-t)/r+4),o?0:s<.5?r/(n+a):r/(2-n-a),s]},"hsl-rgb":function(e,t,i){if(0===t)return[i,i,i];for(var n=[(e=(e/360%1+1)%1)+1/3,e,e-1/3],a=i<.5?i*(1+t):i+t-i*t,r=2*i-a,o=[],s=0;s<3;s++){var l=n[s];l<0&&(l+=1),l>1&&(l-=1),o[s]=6*l<1?r+6*(a-r)*l:2*l<1?a:3*l<2?r+(a-r)*(2/3-l)*6:r}return o},"rgb-gray":function(e,t,i){return[.2989*e+.587*t+.114*i]},"gray-rgb":function(e){return[e,e,e]},"gray-hsb":function(e){return[0,0,e]},"gray-hsl":function(e){return[0,0,e]},"gradient-rgb":function(){return[]},"rgb-gradient":function(){return[]}};return a.each(t,function(e,i){n[i]=[],a.each(e,function(e,r){var o=a.capitalize(e),s=/^(hue|saturation)$/.test(e),l=n[i][r]="gradient"===i?"gradient"===e?function(e){var t=this._components[0];return t!==(e=W.read(Array.isArray(e)?e:arguments,0,{readNull:!0}))&&(t&&t._removeOwner(this),e&&e._addOwner(this)),e}:function(){return f.read(arguments,0,{readNull:"highlight"===e,clone:!0})}:function(e){return null==e||isNaN(e)?0:+e};this["get"+o]=function(){return this._type===i||s&&/^hs[bl]$/.test(this._type)?this._components[r]:this._convert(i)[r]},this["set"+o]=function(e){this._type!==i&&!(s&&/^hs[bl]$/.test(this._type))&&(this._components=this._convert(i),this._properties=t[i],this._type=i),this._components[r]=l.call(this,e),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function o(s){var l,h,d,c,u=arguments,g=this.__read,f=0;Array.isArray(s)&&(s=(u=s)[0]);var p=null!=s&&typeof s;if("string"===p&&s in t&&(l=s,s=u[1],Array.isArray(s)?(h=s,d=u[2]):(g&&(f=1),u=a.slice(u,1),p=typeof s)),!h){if(c="number"===p?u:"object"===p&&null!=s.length?s:null){l||(l=c.length>=3?"rgb":"gray");var m=t[l].length;d=c[m],g&&(f+=c===arguments?m+(null!=d?1:0):1),c.length>m&&(c=a.slice(c,0,m))}else if("string"===p){var v=function(t){var n,a=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?$/i)||t.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])?$/i),o="rgb";if(a){var s=a[4]?4:3;n=new Array(s);for(var l=0;l<s;l++){var h=a[l+1];n[l]=parseInt(1==h.length?h+h:h,16)/255}}else if(a=t.match(/^(rgb|hsl)a?\((.*)\)$/)){o=a[1],n=a[2].trim().split(/[,\s]+/g);for(var d="hsl"===o,c=(l=0,Math.min(n.length,4));l<c;l++){var u=n[l];if(h=parseFloat(u),d)if(0===l){var g=u.match(/([a-z]*)$/)[1];h*={turn:360,rad:180/Math.PI,grad:.9}[g]||1}else l<3&&(h/=100);else l<3&&(h/=/%$/.test(u)?100:255);n[l]=h}}else{var f=r[t];if(!f)if(i){e||((e=ae.getContext(1,1,{willReadFrequently:!0})).globalCompositeOperation="copy"),e.fillStyle="rgba(0,0,0,0)",e.fillStyle=t,e.fillRect(0,0,1,1);var p=e.getImageData(0,0,1,1).data;f=r[t]=[p[0]/255,p[1]/255,p[2]/255]}else f=[0,0,0];n=f.slice()}return[o,n]}(s);l=v[0],4===(h=v[1]).length&&(d=h[3],h.length--)}else if("object"===p)if(s.constructor===o){if(l=s._type,h=s._components.slice(),d=s._alpha,"gradient"===l)for(var I=1,y=h.length;I<y;I++){var C=h[I];C&&(h[I]=C.clone())}}else if(s.constructor===W)l="gradient",c=u;else{var M=t[l="hue"in s?"lightness"in s?"hsl":"hsb":"gradient"in s||"stops"in s||"radial"in s?"gradient":"gray"in s?"gray":"rgb"],x=n[l];for(this._components=h=[],I=0,y=M.length;I<y;I++)null==(S=s[M[I]])&&!I&&"gradient"===l&&"stops"in s&&(S={stops:s.stops,radial:s.radial}),null!=(S=x[I].call(this,S))&&(h[I]=S);d=s.alpha}g&&l&&(f=1)}if(this._type=l||"rgb",!h)for(this._components=h=[],I=0,y=(x=n[this._type]).length;I<y;I++){var S;null!=(S=x[I].call(this,c&&c[I]))&&(h[I]=S)}return this._components=h,this._properties=t[this._type],this._alpha=d,g&&(this.__read=f),this},set:"#initialize",_serialize:function(e,t){var i=this.getComponents();return a.serialize(/^(gray|rgb)$/.test(this._type)?i:[this._type].concat(i),e,!0,t)},_changed:function(){this._canvasStyle=null,this._owner&&(this._setter?this._owner[this._setter](this):this._owner._changed(129))},_convert:function(e){var t;return this._type===e?this._components.slice():(t=s[this._type+"-"+e])?t.apply(this,this._components):s["rgb-"+e].apply(this,s[this._type+"-rgb"].apply(this,this._components))},convert:function(e){return new N(e,this._convert(e),this._alpha)},getType:function(){return this._type},setType:function(e){this._components=this._convert(e),this._properties=t[e],this._type=e},getComponents:function(){var e=this._components.slice();return null!=this._alpha&&e.push(this._alpha),e},getAlpha:function(){return null!=this._alpha?this._alpha:1},setAlpha:function(e){this._alpha=null==e?null:Math.min(Math.max(e,0),1),this._changed()},hasAlpha:function(){return null!=this._alpha},equals:function(e){var t=a.isPlainValue(e,!0)?N.read(arguments):e;return t===this||t&&this._class===t._class&&this._type===t._type&&this.getAlpha()===t.getAlpha()&&a.equals(this._components,t._components)||!1},toString:function(){for(var e=this._properties,t=[],i="gradient"===this._type,n=c.instance,a=0,r=e.length;a<r;a++){var o=this._components[a];null!=o&&t.push(e[a]+": "+(i?o:n.number(o)))}return null!=this._alpha&&t.push("alpha: "+n.number(this._alpha)),"{ "+t.join(", ")+" }"},toCSS:function(e){var t=this._convert("rgb"),i=e||null==this._alpha?1:this._alpha;function n(e){return Math.round(255*(e<0?0:e>1?1:e))}return t=[n(t[0]),n(t[1]),n(t[2])],i<1&&t.push(i<0?0:i),e?"#"+((1<<24)+(t[0]<<16)+(t[1]<<8)+t[2]).toString(16).slice(1):(4==t.length?"rgba(":"rgb(")+t.join(",")+")"},toCanvasStyle:function(e,t){if(this._canvasStyle)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var i,n=this._components,a=n[0],r=a._stops,o=n[1],s=n[2],l=n[3],h=t&&t.inverted();if(h&&(o=h._transformPoint(o),s=h._transformPoint(s),l&&(l=h._transformPoint(l))),a._radial){var d=s.getDistance(o);if(l){var c=l.subtract(o);c.getLength()>d&&(l=o.add(c.normalize(d-.1)))}var u=l||o;i=e.createRadialGradient(u.x,u.y,0,o.x,o.y,d)}else i=e.createLinearGradient(o.x,o.y,s.x,s.y);for(var g=0,f=r.length;g<f;g++){var p,m=r[g],v=m._offset;i.addColorStop(null!==(p=v)&&void 0!==p?p:g/(f-1),m._color.toCanvasStyle())}return this._canvasStyle=i},transform:function(e){if("gradient"===this._type){for(var t=this._components,i=1,n=t.length;i<n;i++){var a=t[i];e._transformPoint(a,a,!0)}this._changed()}},statics:{_types:t,random:function(){var e=Math.random;return new N(e(),e(),e())},_setOwner:function(e,t,i){return e&&(e._owner&&t&&e._owner!==t&&(e=e.clone()),!e._owner^!t&&(e._owner=t||null,e._setter=i||null)),e}}})},new function(){return a.each({add:function(e,t){return e+t},subtract:function(e,t){return e-t},multiply:function(e,t){return e*t},divide:function(e,t){return e/t}},function(e,t){this[t]=function(t){t=N.read(arguments);for(var i=this._type,n=this._components,a=t._convert(i),r=0,o=n.length;r<o;r++)a[r]=e(n[r],a[r]);return new N(i,a,null!=this._alpha?e(this._alpha,t.getAlpha()):null)}},{})}),W=a.extend({_class:"Gradient",initialize:function(e,t){this._id=g.get(),e&&a.isPlainObject(e)&&(this.set(e),e=t=null),null==this._stops&&this.setStops(e||["white","black"]),null==this._radial&&this.setRadial("string"==typeof t&&"radial"===t||t||!1)},_serialize:function(e,t){return t.add(this,function(){return a.serialize([this._stops,this._radial],e,!0,t)})},_changed:function(){for(var e=0,t=this._owners&&this._owners.length;e<t;e++)this._owners[e]._changed()},_addOwner:function(e){this._owners||(this._owners=[]),this._owners.push(e)},_removeOwner:function(e){var i=this._owners?this._owners.indexOf(e):-1;-1!=i&&(this._owners.splice(i,1),this._owners.length||(this._owners=t))},clone:function(){for(var e=[],t=0,i=this._stops.length;t<i;t++)e[t]=this._stops[t].clone();return new W(e,this._radial)},getStops:function(){return this._stops},setStops:function(e){if(e.length<2)throw new Error("Gradient stop list needs to contain at least two stops.");var i=this._stops;if(i)for(var n=0,a=i.length;n<a;n++)i[n]._owner=t;for(n=0,a=(i=this._stops=Z.readList(e,0,{clone:!0})).length;n<a;n++)i[n]._owner=this;this._changed()},getRadial:function(){return this._radial},setRadial:function(e){this._radial=e,this._changed()},equals:function(e){if(e===this)return!0;if(e&&this._class===e._class){var t=this._stops,i=e._stops,n=t.length;if(n===i.length){for(var a=0;a<n;a++)if(!t[a].equals(i[a]))return!1;return!0}}return!1}}),Z=a.extend({_class:"GradientStop",initialize:function(e,i){var n=e,a=i;"object"==typeof e&&i===t&&(Array.isArray(e)&&"number"!=typeof e[0]?(n=e[0],a=e[1]):("color"in e||"offset"in e||"rampPoint"in e)&&(n=e.color,a=e.offset||e.rampPoint||0)),this.setColor(n),this.setOffset(a)},clone:function(){return new Z(this._color.clone(),this._offset)},_serialize:function(e,t){var i=this._color,n=this._offset;return a.serialize(null==n?[i]:[i,n],e,!0,t)},_changed:function(){this._owner&&this._owner._changed(129)},getOffset:function(){return this._offset},setOffset:function(e){this._offset=e,this._changed()},getRampPoint:"#getOffset",setRampPoint:"#setOffset",getColor:function(){return this._color},setColor:function(){N._setOwner(this._color,null),this._color=N._setOwner(N.read(arguments,0),this,"setColor"),this._changed()},equals:function(e){return e===this||e&&this._class===e._class&&this._color.equals(e._color)&&this._offset==e._offset||!1}}),H=a.extend(new function(){var e={fillColor:null,fillRule:"nonzero",strokeColor:null,strokeWidth:1,strokeCap:"butt",strokeJoin:"miter",strokeScaling:!0,miterLimit:10,dashOffset:0,dashArray:[],shadowColor:null,shadowBlur:0,shadowOffset:new f,selectedColor:null},i=a.set({},e,{fontFamily:"sans-serif",fontWeight:"normal",fontSize:12,leading:null,justification:"left"}),n=a.set({},i,{fillColor:new N}),r={strokeWidth:193,strokeCap:193,strokeJoin:193,strokeScaling:201,miterLimit:193,fontFamily:9,fontWeight:9,fontSize:9,font:9,leading:9,justification:9},o={beans:!0},s={_class:"Style",beans:!0,initialize:function(t,a,r){this._values={},this._owner=a,this._project=a&&a._project||r||le.project,this._defaults=!a||a instanceof b?i:a instanceof U?n:e,t&&this.set(t)}};return a.each(i,function(e,i){var n=/Color$/.test(i),l="shadowOffset"===i,h=a.capitalize(i),d=r[i],c="set"+h,u="get"+h;s[c]=function(e){var t=this._owner,a=t&&t._children,r=a&&a.length>0&&!(t instanceof F);if(r)for(var o=0,s=a.length;o<s;o++)a[o]._style[c](e);if(("selectedColor"===i||!r)&&i in this._defaults){var l=this._values[i];l!==e&&(n&&(l&&(N._setOwner(l,null),l._canvasStyle=null),e&&e.constructor===N&&(e=N._setOwner(e,t,r&&c))),this._values[i]=e,t&&t._changed(d||129))}},s[u]=function(e){var r=this._owner,o=r&&r._children,s=o&&o.length>0&&!(r instanceof F);if(s&&!e)for(var h=0,d=o.length;h<d;h++){var g=o[h]._style[u]();if(h){if(!a.equals(p,g))return t}else p=g}else if(i in this._defaults){var p;if((p=this._values[i])===t)(p=this._defaults[i])&&p.clone&&(p=p.clone());else{var m=n?N:l?f:null;m&&(!p||p.constructor!==m)&&(this._values[i]=p=m.read([p],0,{readNull:!0,clone:!0}))}}return p&&n&&(p=N._setOwner(p,r,s&&c)),p},o[u]=function(e){return this._style[u](e)},o[c]=function(e){this._style[c](e)}}),a.each({Font:"FontFamily",WindingRule:"FillRule"},function(e,t){var i="get"+t,n="set"+t;s[i]=o[i]="#get"+e,s[n]=o[n]="#set"+e}),S.inject(o),s},{set:function(e){var t=e instanceof H,i=t?e._values:e;if(i)for(var n in i)if(n in this._defaults){var a=i[n];this[n]=a&&t&&a.clone?a.clone():a}},equals:function(e){function i(e,i,n){var r=e._values,o=i._values,s=i._defaults;for(var l in r){var h=r[l],d=o[l];if(!(n&&l in o||a.equals(h,d===t?s[l]:d)))return!1}return!0}return e===this||e&&this._class===e._class&&i(this,e)&&i(e,this,!0)||!1},_dispose:function(){var e;(e=this.getFillColor())&&(e._canvasStyle=null),(e=this.getStrokeColor())&&(e._canvasStyle=null),(e=this.getShadowColor())&&(e._canvasStyle=null)},hasFill:function(){var e=this.getFillColor();return!!e&&e.alpha>0},hasStroke:function(){var e=this.getStrokeColor();return!!e&&e.alpha>0&&this.getStrokeWidth()>0},hasShadow:function(){var e=this.getShadowColor();return!!e&&e.alpha>0&&(this.getShadowBlur()>0||!this.getShadowOffset().isZero())},getView:function(){return this._project._view},getFontStyle:function(){var e=this.getFontSize();return this.getFontWeight()+" "+e+(/[a-z]/i.test(e+"")?" ":"px ")+this.getFontFamily()},getFont:"#getFontFamily",setFont:"#setFontFamily",getLeading:function e(){var t=e.base.call(this),i=this.getFontSize();return/pt|em|%|px/.test(i)&&(i=this.getView().getPixelSize(i)),null!=t?t:1.2*i}}),V=new function(){function e(e,t,i,n){for(var a=["","webkit","moz","Moz","ms","o"],r=t[0].toUpperCase()+t.substring(1),o=0;o<6;o++){var s=a[o],l=s?s+r:t;if(l in e){if(!i)return e[l];e[l]=n;break}}}return{getStyles:function(e){var t=e&&9!==e.nodeType?e.ownerDocument:e,i=t&&t.defaultView;return i&&i.getComputedStyle(e,"")},getBounds:function(e,t){var i,n=e.ownerDocument,a=n.body,r=n.documentElement;try{i=e.getBoundingClientRect()}catch(e){i={left:0,top:0,width:0,height:0}}var o=i.left-(r.clientLeft||a.clientLeft||0),s=i.top-(r.clientTop||a.clientTop||0);if(!t){var l=n.defaultView;o+=l.pageXOffset||r.scrollLeft||a.scrollLeft,s+=l.pageYOffset||r.scrollTop||a.scrollTop}return new I(o,s,i.width,i.height)},getViewportBounds:function(e){var t=e.ownerDocument,i=t.defaultView,n=t.documentElement;return new I(0,0,i.innerWidth||n.clientWidth,i.innerHeight||n.clientHeight)},getOffset:function(e,t){return V.getBounds(e,t).getPoint()},getSize:function(e){return V.getBounds(e,!0).getSize()},isInvisible:function(e){return V.getSize(e).equals(new m(0,0))},isInView:function(e){return!V.isInvisible(e)&&V.getViewportBounds(e).intersects(V.getBounds(e,!0))},isInserted:function(e){return n.body.contains(e)},getPrefixed:function(t,i){return t&&e(t,i)},setPrefixed:function(t,i,n){if("object"==typeof i)for(var a in i)e(t,a,!0,i[a]);else e(t,i,!0,n)}}},q={add:function(e,t){if(e)for(var i in t)for(var a=t[i],r=i.split(/[\s,]+/g),o=0,s=r.length;o<s;o++){var l=r[o],h=e===n&&("touchstart"===l||"touchmove"===l)&&{passive:!1};e.addEventListener(l,a,h)}},remove:function(e,t){if(e)for(var i in t)for(var n=t[i],a=i.split(/[\s,]+/g),r=0,o=a.length;r<o;r++)e.removeEventListener(a[r],n,!1)},getPoint:function(e){var t=e.targetTouches?e.targetTouches.length?e.targetTouches[0]:e.changedTouches[0]:e;return new f(t.pageX||t.clientX+n.documentElement.scrollLeft,t.pageY||t.clientY+n.documentElement.scrollTop)},getTarget:function(e){return e.target||e.srcElement},getRelatedTarget:function(e){return e.relatedTarget||e.toElement},getOffset:function(e,t){return q.getPoint(e).subtract(V.getOffset(t||q.getTarget(e)))}};q.requestAnimationFrame=new function(){var e,t=V.getPrefixed(i,"requestAnimationFrame"),n=!1,a=[];function r(){var e=a;a=[];for(var i=0,o=e.length;i<o;i++)e[i]();(n=t&&a.length)&&t(r)}return function(i){a.push(i),t?n||(t(r),n=!0):e||(e=setInterval(r,1e3/60))}};var J=a.extend(s,{_class:"View",initialize:function e(t,a){function r(e){return a[e]||parseInt(a.getAttribute(e),10)}function o(){var e=V.getSize(a);return e.isNaN()||e.isZero()?new m(r("width"),r("height")):e}var s;if(i&&a){this._id=a.getAttribute("id"),null==this._id&&a.setAttribute("id",this._id="paper-view-"+e._id++),q.add(a,this._viewEvents);var h="none";if(V.setPrefixed(a.style,{userDrag:h,userSelect:h,touchCallout:h,contentZooming:h,tapHighlightColor:"rgba(0,0,0,0)"}),l.hasAttribute(a,"resize")){var d=this;q.add(i,this._windowEvents={resize:function(){d.setViewSize(o())}})}if(s=o(),l.hasAttribute(a,"stats")&&typeof Stats<"u"){this._stats=new Stats;var c=this._stats.domElement,u=c.style,g=V.getOffset(a);u.position="absolute",u.left=g.x+"px",u.top=g.y+"px",n.body.appendChild(c)}}else s=new m(a),a=null;this._project=t,this._scope=t._scope,this._element=a,this._pixelRatio||(this._pixelRatio=i&&i.devicePixelRatio||1),this._setElementSize(s.width,s.height),this._viewSize=s,e._views.push(this),e._viewsById[this._id]=this,(this._matrix=new C)._owner=this,e._focused||(e._focused=this),this._frameItems={},this._frameItemCount=0,this._itemEvents={native:{},virtual:{}},this._autoUpdate=!le.agent.node,this._needsUpdate=!1},remove:function(){if(!this._project)return!1;J._focused===this&&(J._focused=null),J._views.splice(J._views.indexOf(this),1),delete J._viewsById[this._id];var e=this._project;return e._view===this&&(e._view=null),q.remove(this._element,this._viewEvents),q.remove(i,this._windowEvents),this._element=this._project=null,this.off("frame"),this._animate=!1,this._frameItems={},!0},_events:a.each(S._itemHandlers.concat(["onResize","onKeyDown","onKeyUp"]),function(e){this[e]={}},{onFrame:{install:function(){this.play()},uninstall:function(){this.pause()}}}),_animate:!1,_time:0,_count:0,getAutoUpdate:function(){return this._autoUpdate},setAutoUpdate:function(e){this._autoUpdate=e,e&&this.requestUpdate()},update:function(){},draw:function(){this.update()},requestUpdate:function(){if(!this._requested){var e=this;q.requestAnimationFrame(function(){if(e._requested=!1,e._animate){e.requestUpdate();var t=e._element;(!V.getPrefixed(n,"hidden")||"true"===l.getAttribute(t,"keepalive"))&&V.isInView(t)&&e._handleFrame()}e._autoUpdate&&e.update()}),this._requested=!0}},play:function(){this._animate=!0,this.requestUpdate()},pause:function(){this._animate=!1},_handleFrame:function(){le=this._scope;var e=Date.now()/1e3,t=this._last?e-this._last:0;this._last=e,this.emit("frame",new a({delta:t,time:this._time+=t,count:this._count++})),this._stats&&this._stats.update()},_animateItem:function(e,t){var i=this._frameItems;t?(i[e._id]={item:e,time:0,count:0},1==++this._frameItemCount&&this.on("frame",this._handleFrameItems)):(delete i[e._id],0==--this._frameItemCount&&this.off("frame",this._handleFrameItems))},_handleFrameItems:function(e){for(var t in this._frameItems){var i=this._frameItems[t];i.item.emit("frame",new a(e,{time:i.time+=e.delta,count:i.count++}))}},_changed:function(){this._project._changed(4097),this._bounds=this._decomposed=t},getElement:function(){return this._element},getPixelRatio:function(){return this._pixelRatio},getResolution:function(){return 72*this._pixelRatio},getViewSize:function(){var e=this._viewSize;return new v(e.width,e.height,this,"setViewSize")},setViewSize:function(){var e=m.read(arguments),t=e.subtract(this._viewSize);t.isZero()||(this._setElementSize(e.width,e.height),this._viewSize.set(e),this._changed(),this.emit("resize",{size:e,delta:t}),this._autoUpdate&&this.update())},_setElementSize:function(e,t){var i=this._element;i&&(i.width!==e&&(i.width=e),i.height!==t&&(i.height=t))},getBounds:function(){return this._bounds||(this._bounds=this._matrix.inverted()._transformBounds(new I(new f,this._viewSize))),this._bounds},getSize:function(){return this.getBounds().getSize()},isVisible:function(){return V.isInView(this._element)},isInserted:function(){return V.isInserted(this._element)},getPixelSize:function(e){var t,i=this._element;if(i){var a=i.parentNode,r=n.createElement("div");r.style.fontSize=e,a.appendChild(r),t=parseFloat(V.getStyles(r).fontSize),a.removeChild(r)}else t=parseFloat(t);return t},getTextWidth:function(e,t){return 0}},a.each(["rotate","scale","shear","skew"],function(e){var t="rotate"===e;this[e]=function(){var i=arguments,n=(t?a:f).read(i),r=f.read(i,0,{readNull:!0});return this.transform((new C)[e](n,r||this.getCenter(!0)))}},{_decompose:function(){return this._decomposed||(this._decomposed=this._matrix.decompose())},translate:function(){var e=new C;return this.transform(e.translate.apply(e,arguments))},getCenter:function(){return this.getBounds().getCenter()},setCenter:function(){var e=f.read(arguments);this.translate(this.getCenter().subtract(e))},getZoom:function(){var e=this._decompose().scaling;return(e.x+e.y)/2},setZoom:function(e){this.transform((new C).scale(e/this.getZoom(),this.getCenter()))},getRotation:function(){return this._decompose().rotation},setRotation:function(e){var t=this.getRotation();null!=t&&null!=e&&this.rotate(e-t)},getScaling:function(){var e=this._decompose().scaling;return new p(e.x,e.y,this,"setScaling")},setScaling:function(){var e=this.getScaling(),t=f.read(arguments,0,{clone:!0,readNull:!0});e&&t&&this.scale(t.x/e.x,t.y/e.y)},getMatrix:function(){return this._matrix},setMatrix:function(){var e=this._matrix;e.set.apply(e,arguments)},transform:function(e){this._matrix.append(e)},scrollBy:function(){this.translate(f.read(arguments).negate())}}),{projectToView:function(){return this._matrix._transformPoint(f.read(arguments))},viewToProject:function(){return this._matrix._inverseTransform(f.read(arguments))},getEventPoint:function(e){return this.viewToProject(q.getOffset(e,this._element))}},{statics:{_views:[],_viewsById:{},_id:0,create:function(e,t){return n&&"string"==typeof t&&(t=n.getElementById(t)),new(i?Q:J)(e,t)}}},new function(){if(i){var e,t,a,r,o,s=!1,l=!1,h=i.navigator;h.pointerEnabled||h.msPointerEnabled?(a="pointerdown MSPointerDown",r="pointermove MSPointerMove",o="pointerup pointercancel MSPointerUp MSPointerCancel"):(a="touchstart",r="touchmove",o="touchend touchcancel","ontouchstart"in i&&h.userAgent.match(/mobile|tablet|ip(ad|hone|od)|android|silk/i)||(a+=" mousedown",r+=" mousemove",o+=" mouseup"));var d={},c={mouseout:function(e){var t=J._focused,i=q.getRelatedTarget(e);if(t&&(!i||"HTML"===i.nodeName)){var n=q.getOffset(e,t._element),a=n.x,r=Math.abs,o=r(a),s=o-(1<<25);n.x=r(s)<o?s*(a<0?-1:1):a,P(t,e,t.viewToProject(n))}},scroll:A};d[a]=function(e){var t=J._focused=w(e);s||(s=!0,t._handleMouseEvent("mousedown",e))},c[r]=function(i){var n=J._focused;if(!l){var a=w(i);a?n!==a&&(n&&P(n,i),e||(e=n),n=J._focused=t=a):t&&t===n&&(e&&!e.isInserted()&&(e=null),n=J._focused=e,e=null,A())}n&&P(n,i)},c[a]=function(){l=!0},c[o]=function(e){var t=J._focused;t&&s&&t._handleMouseEvent("mouseup",e),l=s=!1},q.add(n,c),q.add(i,{load:A});var u,g,f,p,m,v,I,y,C=!1,M=!1,x={doubleclick:"click",mousedrag:"mousemove"},S=!1,b={mousedown:{mousedown:1,mousedrag:1,click:1,doubleclick:1},mouseup:{mouseup:1,mousedrag:1,click:1,doubleclick:1},mousemove:{mousedrag:1,mousemove:1,mouseenter:1,mouseleave:1}};return{_viewEvents:d,_handleMouseEvent:function(e,t,i){var n=this._itemEvents,a=n.native[e],r="mousemove"===e,o=this._scope.tool,l=this;function h(e){return n.virtual[e]||l.responds(e)||o&&o.responds(e)}r&&s&&h("mousedrag")&&(e="mousedrag"),i||(i=this.getEventPoint(t));var d=this.getBounds().contains(i),c=a&&d&&l._project.hitTest(i,{tolerance:0,fill:!0,stroke:!0}),x=c&&c.item||null,b=!1,w={};if(w[e.substr(5)]=!0,a&&x!==p&&(p&&D(p,null,"mouseleave",t,i),x&&D(x,null,"mouseenter",t,i),p=x),S^d&&(D(this,null,d?"mouseenter":"mouseleave",t,i),b=!0),(d||w.drag)&&!i.equals(g)&&(k(this,x,r?e:"mousemove",t,i,g),b=!0),S=d,w.down&&d||w.up&&u){if(k(this,x,e,t,i,u),w.down){if(y=x===v&&Date.now()-I<300,f=v=x,!M&&x){for(var A=x;A&&!A.responds("mousedrag");)A=A._parent;A&&(m=x)}u=i}else w.up&&(!M&&x===f&&(I=Date.now(),k(this,x,y?"doubleclick":"click",t,i,u),y=!1),f=m=null);S=!1,b=!0}g=i,b&&o&&(C=o._handleMouseEvent(e,t,i,w)||C),!1!==t.cancelable&&(C&&!w.move||w.down&&h("mouseup"))&&t.preventDefault()},_handleKeyEvent:function(e,t,i,n){var a,r=this._scope,o=r.tool;function s(o){o.responds(e)&&(le=r,o.emit(e,a=a||new Y(e,t,i,n)))}this.isVisible()&&(s(this),o&&o.responds(e)&&s(o))},_countItemEvent:function(e,t){var i=this._itemEvents,n=i.native,a=i.virtual;for(var r in b)n[r]=(n[r]||0)+(b[r][e]||0)*t;a[e]=(a[e]||0)+t},statics:{updateFocus:A,_resetState:function(){s=l=C=S=!1,e=t=u=g=f=p=m=v=I=y=null}}}}function w(e){var t=q.getTarget(e);return t.getAttribute&&J._viewsById[t.getAttribute("id")]}function A(){var e=J._focused;if(!e||!e.isVisible())for(var i=0,n=J._views.length;i<n;i++)if((e=J._views[i]).isVisible()){J._focused=t=e;break}}function P(e,t,i){e._handleMouseEvent("mousemove",t,i)}function D(e,t,i,n,a,r,o){var s,l=!1;function h(e,i){if(e.responds(i)){if(s||(s=new $(i,n,a,t||e,r?a.subtract(r):null)),e.emit(i,s)&&(C=!0,s.prevented&&(M=!0),s.stopped))return l=!0}else{var o=x[i];if(o)return h(e,o)}}for(;e&&e!==o&&!h(e,i);)e=e._parent;return l}function k(e,t,i,n,a,r){return e._project.removeOn(i),M=C=!1,m&&D(m,null,i,n,a,r)||t&&t!==m&&!t.isDescendant(m)&&D(t,null,"mousedrag"===i?"mousemove":i,n,a,r,m)||D(e,m||t||e,i,n,a,r)}}),Q=J.extend({_class:"CanvasView",initialize:function(e,t){if(!(t instanceof i.HTMLCanvasElement)){var n=m.read(arguments,1);if(n.isZero())throw new Error("Cannot create CanvasView with the provided argument: "+a.slice(arguments,1));t=ae.getCanvas(n)}var r=this._context=t.getContext("2d");if(r.save(),this._pixelRatio=1,!/^off|false$/.test(l.getAttribute(t,"hidpi"))){var o=i.devicePixelRatio||1,s=V.getPrefixed(r,"backingStorePixelRatio")||1;this._pixelRatio=o/s}J.call(this,e,t),this._needsUpdate=!0},remove:function e(){return this._context.restore(),e.base.call(this)},_setElementSize:function e(t,i){var n=this._pixelRatio;if(e.base.call(this,t*n,i*n),1!==n){var a=this._element,r=this._context;if(!l.hasAttribute(a,"resize")){var o=a.style;o.width=t+"px",o.height=i+"px"}r.restore(),r.save(),r.scale(n,n)}},getContext:function(){return this._context},getPixelSize:function e(t){var i,n=le.agent;if(n&&n.firefox)i=e.base.call(this,t);else{var a=this._context,r=a.font;a.font=t+" serif",i=parseFloat(a.font),a.font=r}return i},getTextWidth:function(e,t){var i=this._context,n=i.font,a=0;i.font=e;for(var r=0,o=t.length;r<o;r++)a=Math.max(a,i.measureText(t[r]).width);return i.font=n,a},update:function(){if(!this._needsUpdate)return!1;var e=this._project,t=this._context,i=this._viewSize;return t.clearRect(0,0,i.width+1,i.height+1),e&&e.draw(t,this._matrix,this._pixelRatio),this._needsUpdate=!1,!0}}),K=a.extend({_class:"Event",initialize:function(e){this.event=e,this.type=e&&e.type},prevented:!1,stopped:!1,preventDefault:function(){this.prevented=!0,this.event.preventDefault()},stopPropagation:function(){this.stopped=!0,this.event.stopPropagation()},stop:function(){this.stopPropagation(),this.preventDefault()},getTimeStamp:function(){return this.event.timeStamp},getModifiers:function(){return X.modifiers}}),Y=K.extend({_class:"KeyEvent",initialize:function(e,t,i,n){this.type=e,this.event=t,this.key=i,this.character=n},toString:function(){return"{ type: '"+this.type+"', key: '"+this.key+"', character: '"+this.character+"', modifiers: "+this.getModifiers()+" }"}}),X=new function(){var e,r,o={"\t":"tab"," ":"space","\b":"backspace","":"delete",Spacebar:"space",Del:"delete",Win:"meta",Esc:"escape"},s={tab:"\t",space:" ",enter:"\r"},l={},h={},d=new a({shift:!1,control:!1,alt:!1,meta:!1,capsLock:!1,space:!1}).inject({option:{get:function(){return this.alt}},command:{get:function(){var e=le&&le.agent;return e&&e.mac?this.meta:this.control}}});function c(e){var i=e.key||e.keyIdentifier;return i=/^U\+/.test(i)?String.fromCharCode(parseInt(i.substr(2),16)):/^Arrow[A-Z]/.test(i)?i.substr(5):"Unidentified"===i||i===t?String.fromCharCode(e.keyCode):i,o[i]||(i.length>1?a.hyphenate(i):i.toLowerCase())}function u(t,i,n,r){var o,s=J._focused;if(l[i]=t,t?h[i]=n:delete h[i],i.length>1&&(o=a.camelize(i))in d){d[o]=t;var c=le&&le.agent;if("meta"===o&&c&&c.mac)if(t)e={};else{for(var g in e)g in h&&u(!1,g,e[g],r);e=null}}else t&&e&&(e[i]=n);s&&s._handleKeyEvent(t?"keydown":"keyup",r,i,n)}return q.add(n,{keydown:function(e){var t=c(e),i=le&&le.agent;t.length>1||i&&i.chrome&&(e.altKey||i.mac&&e.metaKey||!i.mac&&e.ctrlKey)?u(!0,t,s[t]||(t.length>1?"":t),e):r=t},keypress:function(e){if(r){var t=c(e),i=e.charCode,n=i>=32?String.fromCharCode(i):t.length>1?"":t;t!==r&&(t=n.toLowerCase()),u(!0,t,n,e),r=null}},keyup:function(e){var t=c(e);t in h&&u(!1,t,h[t],e)}}),q.add(i,{blur:function(e){for(var t in h)u(!1,t,h[t],e)}}),{modifiers:d,isDown:function(e){return!!l[e]}}},$=K.extend({_class:"MouseEvent",initialize:function(e,t,i,n,a){this.type=e,this.event=t,this.point=i,this.target=n,this.delta=a},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),ee=K.extend({_class:"ToolEvent",_item:null,initialize:function(e,t,i){this.tool=e,this.type=t,this.event=i},_choosePoint:function(e,t){return e||(t?t.clone():null)},getPoint:function(){return this._choosePoint(this._point,this.tool._point)},setPoint:function(e){this._point=e},getLastPoint:function(){return this._choosePoint(this._lastPoint,this.tool._lastPoint)},setLastPoint:function(e){this._lastPoint=e},getDownPoint:function(){return this._choosePoint(this._downPoint,this.tool._downPoint)},setDownPoint:function(e){this._downPoint=e},getMiddlePoint:function(){return!this._middlePoint&&this.tool._lastPoint?this.tool._point.add(this.tool._lastPoint).divide(2):this._middlePoint},setMiddlePoint:function(e){this._middlePoint=e},getDelta:function(){return!this._delta&&this.tool._lastPoint?this.tool._point.subtract(this.tool._lastPoint):this._delta},setDelta:function(e){this._delta=e},getCount:function(){return this.tool[/^mouse(down|up)$/.test(this.type)?"_downCount":"_moveCount"]},setCount:function(e){this.tool[/^mouse(down|up)$/.test(this.type)?"downCount":"count"]=e},getItem:function(){if(!this._item){var e=this.tool._scope.project.hitTest(this.getPoint());if(e){for(var t=e.item,i=t._parent;/^(Group|CompoundPath)$/.test(i._class);)t=i,i=i._parent;this._item=t}}return this._item},setItem:function(e){this._item=e},toString:function(){return"{ type: "+this.type+", point: "+this.getPoint()+", count: "+this.getCount()+", modifiers: "+this.getModifiers()+" }"}}),te=h.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onActivate","onDeactivate","onEditOptions","onKeyDown","onKeyUp"],initialize:function(e){h.call(this),this._moveCount=-1,this._downCount=-1,this.set(e)},getMinDistance:function(){return this._minDistance},setMinDistance:function(e){this._minDistance=e,null!=e&&null!=this._maxDistance&&e>this._maxDistance&&(this._maxDistance=e)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(e){this._maxDistance=e,null!=this._minDistance&&null!=e&&e<this._minDistance&&(this._minDistance=e)},getFixedDistance:function(){return this._minDistance==this._maxDistance?this._minDistance:null},setFixedDistance:function(e){this._minDistance=this._maxDistance=e},_handleMouseEvent:function(e,t,i,n){le=this._scope,n.drag&&!this.responds(e)&&(e="mousemove");var a=n.move||n.drag,r=this.responds(e),o=this.minDistance,s=this.maxDistance,l=!1,h=this;function d(e,t){var r=i,o=a?h._point:h._downPoint||r;if(a){if(h._moveCount>=0&&r.equals(o))return!1;if(o&&(null!=e||null!=t)){var s=r.subtract(o),l=s.getLength();if(l<(e||0))return!1;t&&(r=o.add(s.normalize(Math.min(l,t))))}h._moveCount++}return h._point=r,h._lastPoint=o||r,n.down&&(h._moveCount=-1,h._downPoint=r,h._downCount++),!0}function c(){r&&(l=h.emit(e,new ee(h,e,t))||l)}if(n.down)d(),c();else if(n.up)d(null,s),c();else if(r)for(;d(o,s);)c();return l}}),ie=a.extend(s,{_class:"Tween",statics:{easings:new a({linear:function(e){return e},easeInQuad:function(e){return e*e},easeOutQuad:function(e){return e*(2-e)},easeInOutQuad:function(e){return e<.5?2*e*e:2*(2-e)*e-1},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return--e*e*e+1},easeInOutCubic:function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1- --e*e*e*e},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1+--e*e*e*e*e},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e}})},initialize:function e(t,i,n,a,r,o){this.object=t;var s=typeof r,l="function"===s;this.type=l?s:"string"===s?r:"linear",this.easing=l?r:e.easings[this.type],this.duration=a,this.running=!1,this._then=null,this._startTime=null;var h=i||n;this._keys=h?Object.keys(h):[],this._parsedKeys=this._parseKeys(this._keys),this._from=h&&this._getState(i),this._to=h&&this._getState(n),!1!==o&&this.start()},then:function(e){return this._then=e,this},start:function(){return this._startTime=null,this.running=!0,this},stop:function(){return this.running=!1,this},update:function(e){if(this.running){e>=1&&(e=1,this.running=!1);for(var t=this.easing(e),i=this._keys,n=function(i){return"function"==typeof i?i(t,e):i},r=0,o=i&&i.length;r<o;r++){var s=i[r],l=n(this._from[s]),h=n(this._to[s]),d=l&&h&&l.__add&&h.__add?h.__subtract(l).__multiply(t).__add(l):(h-l)*t+l;this._setProperty(this._parsedKeys[s],d)}this.responds("update")&&this.emit("update",new a({progress:e,factor:t})),!this.running&&this._then&&this._then(this.object)}return this},_events:{onUpdate:{}},_handleFrame:function(e){var t=this._startTime,i=t?(e-t)/this.duration:0;t||(this._startTime=e),this.update(i)},_getState:function(e){for(var t=this._keys,i={},n=0,a=t.length;n<a;n++){var r,o=t[n],s=this._parsedKeys[o],l=this._getProperty(s);if(e){var h=this._resolveValue(l,e[o]);this._setProperty(s,h),r=(r=this._getProperty(s))&&r.clone?r.clone():r,this._setProperty(s,l)}else r=l&&l.clone?l.clone():l;i[o]=r}return i},_resolveValue:function(e,t){if(t){if(Array.isArray(t)&&2===t.length){var i=t[0];return i&&i.match&&i.match(/^[+\-\*\/]=/)?this._calculate(e,i[0],t[1]):t}if("string"==typeof t){var n=t.match(/^[+\-*/]=(.*)/);if(n){var a=JSON.parse(n[1].replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g,'"$2": '));return this._calculate(e,t[0],a)}}}return t},_calculate:function(e,t,i){return le.PaperScript.calculateBinary(e,t,i)},_parseKeys:function(e){for(var t={},i=0,n=e.length;i<n;i++){var a=e[i],r=a.replace(/\.([^.]*)/g,"/$1").replace(/\[['"]?([^'"\]]*)['"]?\]/g,"/$1");t[a]=r.split("/")}return t},_getProperty:function(e,t){for(var i=this.object,n=0,a=e.length-(t||0);n<a&&i;n++)i=i[e[n]];return i},_setProperty:function(e,t){var i=this._getProperty(e,1);i&&(i[e[e.length-1]]=t)}}),ne={request:function(t){var i=new e.XMLHttpRequest;return i.open((t.method||"get").toUpperCase(),t.url,a.pick(t.async,!0)),t.mimeType&&i.overrideMimeType(t.mimeType),i.onload=function(){var e=i.status;0===e||200===e?t.onLoad&&t.onLoad.call(i,i.responseText):i.onerror()},i.onerror=function(){var e=i.status,n='Could not load "'+t.url+'" (Status: '+e+")";if(!t.onError)throw new Error(n);t.onError(n,e)},i.send(null)}},ae=a.exports.CanvasProvider={canvases:[],getCanvas:function(e,t,a){if(!i)return null;var r,o=!0;"object"==typeof e&&(t=e.height,e=e.width),this.canvases.length?r=this.canvases.pop():(r=n.createElement("canvas"),o=!1);var s=r.getContext("2d",a||{});if(!s)throw new Error("Canvas "+r+" is unable to provide a 2D context.");return r.width===e&&r.height===t?o&&s.clearRect(0,0,e+1,t+1):(r.width=e,r.height=t),s.save(),r},getContext:function(e,t,i){var n=this.getCanvas(e,t,i);return n?n.getContext("2d",i||{}):null},release:function(e){var t=e&&e.canvas?e.canvas:e;t&&t.getContext&&(t.getContext("2d").restore(),this.canvases.push(t))}},re=new function(){var e,t,i,n,r,o,s,l,h,d,c,u=Math.min,g=Math.max,f=Math.abs;function p(e,t,i){return.2989*e+.587*t+.114*i}function m(e,t,i,n){var a=n-p(e,t,i),r=(n=p(h=e+a,d=t+a,c=i+a),u(h,d,c)),o=g(h,d,c);if(r<0){var s=n-r;h=n+(h-n)*n/s,d=n+(d-n)*n/s,c=n+(c-n)*n/s}if(o>255){var l=255-n,f=o-n;h=n+(h-n)*l/f,d=n+(d-n)*l/f,c=n+(c-n)*l/f}}function v(e,t,i){return g(e,t,i)-u(e,t,i)}function I(e,t,i,n){var a,r=[e,t,i],o=g(e,t,i),s=u(e,t,i);a=0===u(s=s===e?0:s===t?1:2,o=o===e?0:o===t?1:2)?1===g(s,o)?2:1:0,r[o]>r[s]?(r[a]=(r[a]-r[s])*n/(r[o]-r[s]),r[o]=n):r[a]=r[o]=0,r[s]=0,h=r[0],d=r[1],c=r[2]}var y={multiply:function(){h=r*e/255,d=o*t/255,c=s*i/255},screen:function(){h=r+e-r*e/255,d=o+t-o*t/255,c=s+i-s*i/255},overlay:function(){h=r<128?2*r*e/255:255-2*(255-r)*(255-e)/255,d=o<128?2*o*t/255:255-2*(255-o)*(255-t)/255,c=s<128?2*s*i/255:255-2*(255-s)*(255-i)/255},"soft-light":function(){var n=e*r/255;h=n+r*(255-(255-r)*(255-e)/255-n)/255,d=(n=t*o/255)+o*(255-(255-o)*(255-t)/255-n)/255,c=(n=i*s/255)+s*(255-(255-s)*(255-i)/255-n)/255},"hard-light":function(){h=e<128?2*e*r/255:255-2*(255-e)*(255-r)/255,d=t<128?2*t*o/255:255-2*(255-t)*(255-o)/255,c=i<128?2*i*s/255:255-2*(255-i)*(255-s)/255},"color-dodge":function(){h=0===r?0:255===e?255:u(255,255*r/(255-e)),d=0===o?0:255===t?255:u(255,255*o/(255-t)),c=0===s?0:255===i?255:u(255,255*s/(255-i))},"color-burn":function(){h=255===r?255:0===e?0:g(0,255-255*(255-r)/e),d=255===o?255:0===t?0:g(0,255-255*(255-o)/t),c=255===s?255:0===i?0:g(0,255-255*(255-s)/i)},darken:function(){h=r<e?r:e,d=o<t?o:t,c=s<i?s:i},lighten:function(){h=r>e?r:e,d=o>t?o:t,c=s>i?s:i},difference:function(){(h=r-e)<0&&(h=-h),(d=o-t)<0&&(d=-d),(c=s-i)<0&&(c=-c)},exclusion:function(){h=r+e*(255-r-r)/255,d=o+t*(255-o-o)/255,c=s+i*(255-s-s)/255},hue:function(){I(e,t,i,v(r,o,s)),m(h,d,c,p(r,o,s))},saturation:function(){I(r,o,s,v(e,t,i)),m(h,d,c,p(r,o,s))},luminosity:function(){m(r,o,s,p(e,t,i))},color:function(){m(e,t,i,p(r,o,s))},add:function(){h=u(r+e,255),d=u(o+t,255),c=u(s+i,255)},subtract:function(){h=g(r-e,0),d=g(o-t,0),c=g(s-i,0)},average:function(){h=(r+e)/2,d=(o+t)/2,c=(s+i)/2},negation:function(){h=255-f(255-e-r),d=255-f(255-t-o),c=255-f(255-i-s)}},C=this.nativeModes=a.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],function(e){this[e]=!0},{}),M=ae.getContext(1,1,{willReadFrequently:!0});M&&(a.each(y,function(e,t){var i="darken"===t,n=!1;M.save();try{M.fillStyle=i?"#300":"#a00",M.fillRect(0,0,1,1),M.globalCompositeOperation=t,M.globalCompositeOperation===t&&(M.fillStyle=i?"#a00":"#300",M.fillRect(0,0,1,1),n=M.getImageData(0,0,1,1).data[0]!==i?170:51)}catch(e){}M.restore(),C[t]=n}),ae.release(M)),this.process=function(a,u,g,f,p){var m=u.canvas,v="normal"===a;if(v||C[a])g.save(),g.setTransform(1,0,0,1,0,0),g.globalAlpha=f,v||(g.globalCompositeOperation=a),g.drawImage(m,p.x,p.y),g.restore();else{var I=y[a];if(!I)return;for(var M=g.getImageData(p.x,p.y,m.width,m.height),x=M.data,S=u.getImageData(0,0,m.width,m.height).data,b=0,w=x.length;b<w;b+=4){e=S[b],r=x[b],t=S[b+1],o=x[b+1],i=S[b+2],s=x[b+2],n=S[b+3],l=x[b+3],I();var A=n*f/255,P=1-A;x[b]=A*h+P*r,x[b+1]=A*d+P*o,x[b+2]=A*c+P*s,x[b+3]=n*f+P*l}g.putImageData(M,p.x,p.y)}}},oe=new function(){var e="http://www.w3.org/2000/svg",t="http://www.w3.org/2000/xmlns",i="http://www.w3.org/1999/xlink",a={href:i,xlink:t,xmlns:t+"/","xmlns:xlink":t+"/"};function r(e,t,i){for(var n in t){var r=t[n],o=a[n];"number"==typeof r&&i&&(r=i.number(r)),o?e.setAttributeNS(o,n,r):e.setAttribute(n,r)}return e}return{svg:e,xmlns:t,xlink:i,create:function(t,i,a){return r(n.createElementNS(e,t),i,a)},get:function(e,t){var i=a[t],n=i?e.getAttributeNS(i,t):e.getAttribute(t);return"null"===n?null:n},set:r}},se=a.each({fillColor:["fill","color"],fillRule:["fill-rule","string"],strokeColor:["stroke","color"],strokeWidth:["stroke-width","number"],strokeCap:["stroke-linecap","string"],strokeJoin:["stroke-linejoin","string"],strokeScaling:["vector-effect","lookup",{true:"none",false:"non-scaling-stroke"},function(e,t){return!t&&(e instanceof E||e instanceof A||e instanceof U)}],miterLimit:["stroke-miterlimit","number"],dashArray:["stroke-dasharray","array"],dashOffset:["stroke-dashoffset","number"],fontFamily:["font-family","string"],fontWeight:["font-weight","string"],fontSize:["font-size","number"],justification:["text-anchor","lookup",{left:"start",center:"middle",right:"end"}],opacity:["opacity","number"],blendMode:["mix-blend-mode","style"]},function(e,t){var i=a.capitalize(t),n=e[2];this[t]={type:e[1],property:t,attribute:e[0],toSVG:n,fromSVG:n&&a.each(n,function(e,t){this[e]=t},{}),exportFilter:e[3],get:"get"+i,set:"set"+i}},{});new function(){var t;function i(e,i,n){var r,o=new a,s=e.getTranslation();if(i&&(e.isInvertible()?(r=(e=e._shiftless())._inverseTransform(s),s=null):r=new f,o[n?"cx":"x"]=r.x,o[n?"cy":"y"]=r.y),!e.isIdentity()){var l=e.decompose();if(l){var h=[],d=l.rotation,c=l.scaling,g=l.skewing;s&&!s.isZero()&&h.push("translate("+t.point(s)+")"),d&&h.push("rotate("+t.number(d)+")"),(!u.isZero(c.x-1)||!u.isZero(c.y-1))&&h.push("scale("+t.point(c)+")"),g.x&&h.push("skewX("+t.number(g.x)+")"),g.y&&h.push("skewY("+t.number(g.y)+")"),o.transform=h.join(" ")}else o.transform="matrix("+e.getValues().join(",")+")"}return o}function n(e,n){for(var a=i(e._matrix),r=e._children,o=oe.create("g",a,t),s=0,l=r.length;s<l;s++){var h=r[s],c=m(h,n);if(c)if(h.isClipMask()){var u=oe.create("clipPath");u.appendChild(c),d(h,u,"clip"),oe.set(o,{"clip-path":"url(#"+u.id+")"})}else o.appendChild(c)}return o}function r(e){var n=e._type,a=e._radius,r=i(e._matrix,!0,"rectangle"!==n);if("rectangle"===n){n="rect";var o=e._size,s=o.width,l=o.height;r.x-=s/2,r.y-=l/2,r.width=s,r.height=l,a.isZero()&&(a=null)}return a&&("circle"===n?r.r=a:(r.rx=a.width,r.ry=a.height)),oe.create(n,r,t)}var o,s={Group:n,Layer:n,Raster:function(e,n){var a=i(e._matrix,!0),r=e.getSize(),o=e.getImage();return a.x-=r.width/2,a.y-=r.height/2,a.width=r.width,a.height=r.height,a.href=0==n.embedImages&&o&&o.src||e.toDataURL(),oe.create("image",a,t)},Path:function(e,n){var a=n.matchShapes;if(a){var o=e.toShape(!1);if(o)return r(o)}var s,l=e._segments,h=l.length,d=i(e._matrix);if(a&&h>=2&&!e.hasHandles())if(h>2){s=e._closed?"polygon":"polyline";for(var c=[],u=0;u<h;u++)c.push(t.point(l[u]._point));d.points=c.join(" ")}else{s="line";var g=l[0]._point,f=l[1]._point;d.set({x1:g.x,y1:g.y,x2:f.x,y2:f.y})}else s="path",d.d=e.getPathData(null,n.precision);return oe.create(s,d,t)},Shape:r,CompoundPath:function(e,n){var a=i(e._matrix),r=e.getPathData(null,n.precision);return r&&(a.d=r),oe.create("path",a,t)},SymbolItem:function(e,n){var a=i(e._matrix,!0),r=e._definition,o=h(r,"symbol"),s=r._item,l=s.getStrokeBounds();return o||((o=oe.create("symbol",{viewBox:t.rectangle(l)})).appendChild(m(s,n)),d(r,o,"symbol")),a.href="#"+o.id,a.x+=l.x,a.y+=l.y,a.width=l.width,a.height=l.height,a.overflow="visible",oe.create("use",a,t)},PointText:function(e){var n=oe.create("text",i(e._matrix,!0),t);return n.textContent=e._content,n}};function l(e,i,n){var r={},o=!n&&e.getParent(),s=[];return null!=e._name&&(r.id=e._name),a.each(se,function(i){var n=i.get,l=i.type,c=e[n]();if(i.exportFilter?i.exportFilter(e,c):!o||!a.equals(o[n](),c)){if("color"===l&&null!=c){var u=c.getAlpha();u<1&&(r[i.attribute+"-opacity"]=u)}"style"===l?s.push(i.attribute+": "+c):r[i.attribute]=null==c?"none":"color"===l?c.gradient?function(e){var i=h(e,"color");if(!i){var n,a=e.getGradient(),r=a._radial,o=e.getOrigin(),s=e.getDestination();if(r){n={cx:o.x,cy:o.y,r:o.getDistance(s)};var l=e.getHighlight();l&&(n.fx=l.x,n.fy=l.y)}else n={x1:o.x,y1:o.y,x2:s.x,y2:s.y};n.gradientUnits="userSpaceOnUse",i=oe.create((r?"radial":"linear")+"Gradient",n,t);for(var c=a._stops,u=0,g=c.length;u<g;u++){var f,p=c[u],m=p._color,v=m.getAlpha();n={offset:null!==(f=p._offset)&&void 0!==f?f:u/(g-1)},m&&(n["stop-color"]=m.toCSS(!0)),v<1&&(n["stop-opacity"]=v),i.appendChild(oe.create("stop",n,t))}d(e,i,"color")}return"url(#"+i.id+")"}(c):c.toCSS(!0):"array"===l?c.join(","):"lookup"===l?i.toSVG[c]:c}}),s.length&&(r.style=s.join(";")),1===r.opacity&&delete r.opacity,e._visible||(r.visibility="hidden"),oe.set(i,r,t)}function h(e,t){return o||(o={ids:{},svgs:{}}),e&&o.svgs[t+"-"+(e._id||e.__id||(e.__id=g.get("svg")))]}function d(e,t,i){o||h();var n=o.ids[i]=(o.ids[i]||0)+1;t.id=i+"-"+n,o.svgs[i+"-"+(e._id||e.__id)]=t}function p(t,i){var n=t,a=null;if(o){for(var r in n="svg"===t.nodeName.toLowerCase()&&t,o.svgs)a||(n||(n=oe.create("svg")).appendChild(t),a=n.insertBefore(oe.create("defs"),n.firstChild)),a.appendChild(o.svgs[r]);o=null}return i.asString?(new e.XMLSerializer).serializeToString(n):n}function m(e,t,i){var n=s[e._class],a=n&&n(e,t);if(a){var r=t.onExport;r&&(a=r(e,a,t)||a);var o=JSON.stringify(e._data);o&&"{}"!==o&&"null"!==o&&a.setAttribute("data-paper-data",o)}return a&&l(e,a,i)}function v(e){return e||(e={}),t=new c(e.precision),e}S.inject({exportSVG:function(e){return p(m(this,e=v(e),!0),e)}}),x.inject({exportSVG:function(e){e=v(e);var n=this._children,r=this.getView(),o=a.pick(e.bounds,"view"),s=e.matrix||"view"===o&&r._matrix,l=s&&C.read([s]),h="view"===o?new I([0,0],r.getViewSize()):"content"===o?S._getBounds(n,l,{stroke:!0}).rect:I.read([o],0,{readNull:!0}),d={version:"1.1",xmlns:oe.svg,"xmlns:xlink":oe.xlink};h&&(d.width=h.width,d.height=h.height,(h.x||0===h.x||h.y||0===h.y)&&(d.viewBox=t.rectangle(h)));var c=oe.create("svg",d,t),u=c;l&&!l.isIdentity()&&(u=c.appendChild(oe.create("g",i(l),t)));for(var g=0,f=n.length;g<f;g++)u.appendChild(m(n[g],e,!0));return p(c,e)}})},new function(){var r,o={};function s(e,t,i,n,a,o){var s=oe.get(e,t)||o,l=null==s?n?null:i?"":0:i?s:parseFloat(s);return/%\s*$/.test(s)?l/100*(a?1:r[/x|^width/.test(t)?"width":"height"]):l}function l(e,t,i,n,a,r,o){return t=s(e,t||"x",!1,n,a,r),i=s(e,i||"y",!1,n,a,o),!n||null!=t&&null!=i?new f(t,i):null}function h(e,t,i,n,a){return t=s(e,t||"width",!1,n,a),i=s(e,i||"height",!1,n,a),!n||null!=t&&null!=i?new m(t,i):null}function d(e,t,i){return"none"===e?null:"number"===t?parseFloat(e):"array"===t?e?e.split(/[\s,]+/g).map(parseFloat):[]:"color"===t?_(e)||e:"lookup"===t?i[e]:e}function c(e,t,i,n){var a=e.childNodes,r="clippath"===t,o="defs"===t,s=new b,l=s._project,h=l._currentStyle,d=[];if(!r&&!o&&(s=D(s,e,n),l._currentStyle=s._style.clone()),n)for(var c=e.querySelectorAll("defs"),u=0,g=c.length;u<g;u++)T(c[u],i,!1);for(u=0,g=a.length;u<g;u++){var f,p=a[u];1===p.nodeType&&!/^defs$/i.test(p.nodeName)&&(f=T(p,i,!1))&&!(f instanceof k)&&d.push(f)}return s.addChildren(d),r&&(s=D(s.reduce(),e,n)),l._currentStyle=h,(r||o)&&(s.remove(),s=null),s}function u(e,t){for(var i=e.getAttribute("points").match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g),n=[],a=0,r=i.length;a<r;a+=2)n.push(new f(parseFloat(i[a]),parseFloat(i[a+1])));var o=new R(n);return"polygon"===t&&o.closePath(),o}function g(e,t){var i,n=(s(e,"href",!0)||"").substring(1),a="radialgradient"===t;if(n)(i=o[n].getGradient())._radial^a&&((i=i.clone())._radial=a);else{for(var r=e.childNodes,h=[],d=0,c=r.length;d<c;d++){var u=r[d];1===u.nodeType&&h.push(D(new Z,u))}i=new W(h,a)}var g,f,p,m="userSpaceOnUse"!==s(e,"gradientUnits",!0);return a?(f=(g=l(e,"cx","cy",!1,m,"50%","50%")).add(s(e,"r",!1,!1,m,"50%"),0),p=l(e,"fx","fy",!0,m)):(g=l(e,"x1","y1",!1,m,"0%","0%"),f=l(e,"x2","y2",!1,m,"100%","0%")),D(new N(i,g,f,p),e)._scaleToBounds=m,null}var p={"#document":function(e,t,i,n){for(var a=e.childNodes,r=0,o=a.length;r<o;r++){var s=a[r];if(1===s.nodeType)return T(s,i,n)}},g:c,svg:c,clippath:c,polygon:u,polyline:u,path:function(e){return E.create(e.getAttribute("d"))},lineargradient:g,radialgradient:g,image:function(e){var t=new P(s(e,"href",!0));return t.on("load",function(){var t=h(e);this.setSize(t);var i=l(e).add(t.divide(2));this._matrix.append((new C).translate(i))}),t},symbol:function(e,t,i,n){return new k(c(e,t,i,n),!0)},defs:c,use:function(e){var t=(s(e,"href",!0)||"").substring(1),i=o[t],n=l(e);return i?i instanceof k?i.place(n):i.clone().translate(n):null},circle:function(e){return new A.Circle(l(e,"cx","cy"),s(e,"r"))},ellipse:function(e){return new A.Ellipse({center:l(e,"cx","cy"),radius:h(e,"rx","ry")})},rect:function(e){return new A.Rectangle(new I(l(e),h(e)),h(e,"rx","ry"))},line:function(e){return new R.Line(l(e,"x1","y1"),l(e,"x2","y2"))},text:function(e){var t=new j(l(e).add(l(e,"dx","dy")));return t.setContent(e.textContent.trim()||""),t},switch:c};function v(e,t,i,n){if(e.transform){for(var a=(n.getAttribute(i)||"").split(/\)\s*/g),r=new C,o=0,s=a.length;o<s;o++){var l=a[o];if(!l)break;for(var h=l.split(/\(\s*/),d=h[0],c=h[1].split(/[\s,]+/g),u=0,g=c.length;u<g;u++)c[u]=parseFloat(c[u]);switch(d){case"matrix":r.append(new C(c[0],c[1],c[2],c[3],c[4],c[5]));break;case"rotate":r.rotate(c[0],c[1]||0,c[2]||0);break;case"translate":r.translate(c[0],c[1]||0);break;case"scale":r.scale(c);break;case"skewX":r.skew(c[0],0);break;case"skewY":r.skew(0,c[0])}}e.transform(r)}}function y(e,t,i){var n="fill-opacity"===i?"getFillColor":"getStrokeColor",a=e[n]&&e[n]();a&&a.setAlpha(parseFloat(t))}var M=a.set(a.each(se,function(e){this[e.attribute]=function(t,i){if(t[e.set]&&(t[e.set](d(i,e.type,e.fromSVG)),"color"===e.type)){var n=t[e.get]();if(n&&n._scaleToBounds){var a=t.getBounds();n.transform((new C).translate(a.getPoint()).scale(a.getSize()))}}}},{}),{id:function(e,t){o[t]=e,e.setName&&e.setName(t)},"clip-path":function(e,t){var i=_(t);if(i){if((i=i.clone()).setClipMask(!0),!(e instanceof b))return new b(i,e);e.insertChild(0,i)}},gradientTransform:v,transform:v,"fill-opacity":y,"stroke-opacity":y,visibility:function(e,t){e.setVisible&&e.setVisible("visible"===t)},display:function(e,t){e.setVisible&&e.setVisible(null!==t)},"stop-color":function(e,t){e.setColor&&e.setColor(t)},"stop-opacity":function(e,t){e._color&&e._color.setAlpha(parseFloat(t))},offset:function(e,t){if(e.setOffset){var i=t.match(/(.*)%$/);e.setOffset(i?i[1]/100:parseFloat(t))}},viewBox:function(e,t,i,n,a){var r,o=new I(d(t,"array")),s=h(n,null,null,!0);if(e instanceof b){var l=s?s.divide(o.getSize()):1,c=(new C).scale(l).translate(o.getPoint().negate());r=e}else e instanceof k&&(s&&o.setSize(s),r=e._item);if(r){if("visible"!==w(n,"overflow",a)){var u=new A.Rectangle(o);u.setClipMask(!0),r.addChild(u)}c&&r.transform(c)}}});function w(e,i,n){var r=e.attributes[i],o=r&&r.value;if(!o&&e.style){var s=a.camelize(i);!(o=e.style[s])&&n.node[s]!==n.parent[s]&&(o=n.node[s])}return o?"none"===o?null:o:t}function D(e,i,n){var r=i.parentNode,o={node:V.getStyles(i)||{},parent:!n&&!/^defs$/i.test(r.tagName)&&V.getStyles(r)||{}};return a.each(M,function(n,a){var r=w(i,a,o);e=r!==t&&n(e,r,a,i,o)||e}),e}function _(e){var t=e&&e.match(/\((?:["'#]*)([^"')]+)/),n=t&&t[1],a=n&&o[i?n.replace(i.location.href.split("#")[0]+"#",""):n];return a&&a._scaleToBounds&&((a=a.clone())._scaleToBounds=!0),a}function T(e,t,i){var s,l,d,c=e.nodeName.toLowerCase(),u="#document"!==c,g=n.body;i&&u&&(r=le.getView().getSize(),r=h(e,null,null,!0)||r,s=oe.create("svg",{style:"stroke-width: 1px; stroke-miterlimit: 10"}),l=e.parentNode,d=e.nextSibling,s.appendChild(e),g.appendChild(s));var f=le.settings,m=f.applyMatrix,v=f.insertItems;f.applyMatrix=!1,f.insertItems=!1;var I=p[c],y=I&&I(e,c,t,i)||null;if(f.insertItems=v,f.applyMatrix=m,y){u&&!(y instanceof b)&&(y=D(y,e,i));var C=t.onImport,M=u&&e.getAttribute("data-paper-data");C&&(y=C(e,y,t)||y),t.expandShapes&&y instanceof A&&(y.remove(),y=y.toPath()),M&&(y._data=JSON.parse(M))}return s&&(g.removeChild(s),l&&(d?l.insertBefore(e,d):l.appendChild(e))),i&&(o={},y&&a.pick(t.applyMatrix,m)&&y.matrix.apply(!0,!0)),y}function z(i,a,r){if(!i)return null;a="function"==typeof a?{onLoad:a}:a||{};var o=le,s=null;function l(n){try{var l="object"==typeof n?n:(new e.DOMParser).parseFromString(n.trim(),"image/svg+xml");if(!l.nodeName)throw l=null,new Error("Unsupported SVG source: "+i);le=o,s=T(l,a,!0),(!a||!1!==a.insert)&&r._insertItem(t,s);var d=a.onLoad;d&&d(s,n)}catch(e){h(e)}}function h(e,t){var i=a.onError;if(!i)throw new Error(e);i(e,t)}if("string"!=typeof i||/^[\s\S]*</.test(i)){if(typeof File<"u"&&i instanceof File){var d=new FileReader;return d.onload=function(){l(d.result)},d.onerror=function(){h(d.error)},d.readAsText(i)}l(i)}else{var c=n.getElementById(i);c?l(c):ne.request({url:i,async:!0,onLoad:l,onError:h})}return s}S.inject({importSVG:function(e,t){return z(e,t,this)}}),x.inject({importSVG:function(e,t){return this.activate(),z(e,t,this)}})},a.exports.PaperScript=function(){var r,o,s,h,d=this,c=d.acorn;if(!c)try{c=require("acorn")}catch(e){}function u(e,t){return(d.acorn||c).parse(e,t)}c||(c=r=o={},s=this,h=function(e){var t,i,n,a;e.version="0.5.0",e.parse=function(e,a){return i=String(e),n=i.length,o(a),Ve(),function(e){v=I=s,t.locations&&(y=new He),C=x=null,M=[],Xe();var i=e||dt(),n=!0;for(e||(i.body=[]);u!==_;){var a=xt();i.body.push(a),n&>(a)&&st(!0),n=!1}return ut(i,"Program")}(t.program)};var r=e.defaultOptions={ecmaVersion:5,strictSemicolons:!1,allowTrailingCommas:!0,forbidReserved:!1,allowReturnOutsideFunction:!1,locations:!1,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null};function o(e){for(var i in t=e||{},r)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=r[i]);a=t.sourceFile||null}var s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S=e.getLineInfo=function(e,t){for(var i=1,n=0;;){Ne.lastIndex=n;var a=Ne.exec(e);if(!(a&&a.index<t))break;++i,n=a.index+a[0].length}return{line:i,column:t-n}};function b(e,t){var n=S(i,e);t+=" ("+n.line+":"+n.column+")";var a=new SyntaxError(t);throw a.pos=e,a.loc=n,a.raisedAt=s,a}e.tokenize=function(e,a){i=String(e),n=i.length,o(a),Ve();var r={};function v(e){return I=h,Xe(e),r.start=l,r.end=h,r.startLoc=d,r.endLoc=c,r.type=u,r.value=g,r}return v.jumpTo=function(e,n){if(s=e,t.locations){p=1,m=Ne.lastIndex=0;for(var a;(a=Ne.exec(i))&&a.index<e;)++p,m=a.index+a[0].length}f=n,Ke()},v};var w=[],A={type:"num"},P={type:"regexp"},D={type:"string"},k={type:"name"},_={type:"eof"},T={keyword:"break"},z={keyword:"case",beforeExpr:!0},O={keyword:"catch"},B={keyword:"continue"},E={keyword:"debugger"},R={keyword:"default"},F={keyword:"do",isLoop:!0},L={keyword:"else",beforeExpr:!0},G={keyword:"finally"},U={keyword:"for",isLoop:!0},j={keyword:"function"},N={keyword:"if"},W={keyword:"return",beforeExpr:!0},Z={keyword:"switch"},H={keyword:"throw",beforeExpr:!0},V={keyword:"try"},q={keyword:"var"},J={keyword:"while",isLoop:!0},Q={keyword:"with"},K={keyword:"new",beforeExpr:!0},Y={keyword:"this"},X={keyword:"null",atomValue:null},$={keyword:"true",atomValue:!0},ee={keyword:"false",atomValue:!1},te={keyword:"in",binop:7,beforeExpr:!0},ie={break:T,case:z,catch:O,continue:B,debugger:E,default:R,do:F,else:L,finally:G,for:U,function:j,if:N,return:W,switch:Z,throw:H,try:V,var:q,while:J,with:Q,null:X,true:$,false:ee,new:K,in:te,instanceof:{keyword:"instanceof",binop:7,beforeExpr:!0},this:Y,typeof:{keyword:"typeof",prefix:!0,beforeExpr:!0},void:{keyword:"void",prefix:!0,beforeExpr:!0},delete:{keyword:"delete",prefix:!0,beforeExpr:!0}},ne={type:"[",beforeExpr:!0},ae={type:"]"},re={type:"{",beforeExpr:!0},oe={type:"}"},se={type:"(",beforeExpr:!0},le={type:")"},he={type:",",beforeExpr:!0},de={type:";",beforeExpr:!0},ce={type:":",beforeExpr:!0},ue={type:"."},ge={type:"?",beforeExpr:!0},fe={binop:10,beforeExpr:!0},pe={isAssign:!0,beforeExpr:!0},me={isAssign:!0,beforeExpr:!0},ve={postfix:!0,prefix:!0,isUpdate:!0},Ie={prefix:!0,beforeExpr:!0},ye={binop:1,beforeExpr:!0},Ce={binop:2,beforeExpr:!0},Me={binop:3,beforeExpr:!0},xe={binop:4,beforeExpr:!0},Se={binop:5,beforeExpr:!0},be={binop:6,beforeExpr:!0},we={binop:7,beforeExpr:!0},Ae={binop:8,beforeExpr:!0},Pe={binop:9,prefix:!0,beforeExpr:!0},De={binop:10,beforeExpr:!0};for(var ke in e.tokTypes={bracketL:ne,bracketR:ae,braceL:re,braceR:oe,parenL:se,parenR:le,comma:he,semi:de,colon:ce,dot:ue,question:ge,slash:fe,eq:pe,name:k,eof:_,num:A,regexp:P,string:D},ie)e.tokTypes["_"+ke]=ie[ke];function _e(e){e=e.split(" ");var t="",i=[];e:for(var n=0;n<e.length;++n){for(var a=0;a<i.length;++a)if(i[a][0].length==e[n].length){i[a].push(e[n]);continue e}i.push([e[n]])}function r(e){if(1==e.length)return t+="return str === "+JSON.stringify(e[0])+";";t+="switch(str){";for(var i=0;i<e.length;++i)t+="case "+JSON.stringify(e[i])+":";t+="return true}return false;"}if(i.length>3){for(i.sort(function(e,t){return t.length-e.length}),t+="switch(str.length){",n=0;n<i.length;++n){var o=i[n];t+="case "+o[0].length+":",r(o)}t+="}"}else r(e);return new Function("str",t)}var Te,ze=_e("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"),Oe=_e("class enum extends super const export import"),Be=_e("implements interface let package private protected public static yield"),Ee=_e("eval arguments"),Re=_e("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"),Fe=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Le="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Ge=new RegExp("["+Le+"]"),Ue=new RegExp("["+Le+"̀-ͯ҃-֑҇-ׇֽֿׁׂׅׄؐ-ؚؠ-ىٲ-ۓۧ-ۨۻ-ۼܰ-݊ࠀ-ࠔࠛ-ࠣࠥ-ࠧࠩ-࠭ࡀ-ࡗࣤ-ࣾऀ-ःऺ-़ा-ॏ॑-ॗॢ-ॣ०-९ঁ-ঃ়া-ৄেৈৗয়-ৠਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢ-ૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୟ-ୠ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఁ-ఃె-ైొ-్ౕౖౢ-ౣ౦-౯ಂಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢ-ೣ೦-೯ംഃെ-ൈൗൢ-ൣ൦-൯ංඃ්ා-ුූෘ-ෟෲෳิ-ฺเ-ๅ๐-๙ິ-ູ່-ໍ໐-໙༘༙༠-༩༹༵༷ཁ-ཇཱ-྄྆-྇ྍ-ྗྙ-ྼ࿆က-ဩ၀-၉ၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟ᜎ-ᜐᜠ-ᜰᝀ-ᝐᝲᝳក-ឲ៝០-៩᠋-᠍᠐-᠙ᤠ-ᤫᤰ-᤻ᥑ-ᥭᦰ-ᧀᧈ-ᧉ᧐-᧙ᨀ-ᨕᨠ-ᩓ᩠-᩿᩼-᪉᪐-᪙ᭆ-ᭋ᭐-᭙᭫-᭳᮰-᮹᯦-᯳ᰀ-ᰢ᱀-᱉ᱛ-ᱽ᳐-᳒ᴀ-ᶾḁ-ἕ‿⁀⁔⃐-⃥⃜⃡-⃰ⶁ-ⶖⷠ-ⷿ〡-〨゙゚Ꙁ-ꙭꙴ-꙽ꚟ꛰-꛱ꟸ-ꠀ꠆ꠋꠣ-ꠧꢀ-ꢁꢴ-꣄꣐-꣙ꣳ-ꣷ꤀-꤉ꤦ-꤭ꤰ-ꥅꦀ-ꦃ꦳-꧀ꨀ-ꨧꩀ-ꩁꩌ-ꩍ꩐-꩙ꩻꫠ-ꫩꫲ-ꫳꯀ-ꯡ꯬꯭꯰-꯹ﬠ-ﬨ︀-️︠-︦︳︴﹍-﹏0-9_]"),je=/[\n\r\u2028\u2029]/,Ne=/\r\n|[\n\r\u2028\u2029]/g,We=e.isIdentifierStart=function(e){return e<65?36===e:e<91||(e<97?95===e:e<123||e>=170&&Ge.test(String.fromCharCode(e)))},Ze=e.isIdentifierChar=function(e){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||e>=170&&Ue.test(String.fromCharCode(e))))};function He(){this.line=p,this.column=s-m}function Ve(){p=1,s=m=0,f=!0,Ke()}function qe(e,i){h=s,t.locations&&(c=new He),u=e,Ke(),g=i,f=e.beforeExpr}function Je(){var e=t.onComment&&t.locations&&new He,n=s,a=i.indexOf("*/",s+=2);if(-1===a&&b(s-2,"Unterminated comment"),s=a+2,t.locations){Ne.lastIndex=n;for(var r;(r=Ne.exec(i))&&r.index<s;)++p,m=r.index+r[0].length}t.onComment&&t.onComment(!0,i.slice(n+2,a),n,s,e,t.locations&&new He)}function Qe(){for(var e=s,a=t.onComment&&t.locations&&new He,r=i.charCodeAt(s+=2);s<n&&10!==r&&13!==r&&8232!==r&&8233!==r;)++s,r=i.charCodeAt(s);t.onComment&&t.onComment(!1,i.slice(e+2,s),e,s,a,t.locations&&new He)}function Ke(){for(;s<n;){var e=i.charCodeAt(s);if(32===e)++s;else if(13===e)++s,10===(a=i.charCodeAt(s))&&++s,t.locations&&(++p,m=s);else if(10===e||8232===e||8233===e)++s,t.locations&&(++p,m=s);else if(e>8&&e<14)++s;else if(47===e){var a;if(42===(a=i.charCodeAt(s+1)))Je();else{if(47!==a)break;Qe()}}else if(160===e)++s;else{if(!(e>=5760&&Fe.test(String.fromCharCode(e))))break;++s}}}function Ye(e){switch(e){case 46:return function(){var e=i.charCodeAt(s+1);return e>=48&&e<=57?it(!0):(++s,qe(ue))}();case 40:return++s,qe(se);case 41:return++s,qe(le);case 59:return++s,qe(de);case 44:return++s,qe(he);case 91:return++s,qe(ne);case 93:return++s,qe(ae);case 123:return++s,qe(re);case 125:return++s,qe(oe);case 58:return++s,qe(ce);case 63:return++s,qe(ge);case 48:var a=i.charCodeAt(s+1);if(120===a||88===a)return function(){s+=2;var e=tt(16);return null==e&&b(l+2,"Expected hexadecimal number"),We(i.charCodeAt(s))&&b(s,"Identifier directly after number"),qe(A,e)}();case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return it(!1);case 34:case 39:return function(e){s++;for(var a="";;){s>=n&&b(l,"Unterminated string constant");var r=i.charCodeAt(s);if(r===e)return++s,qe(D,a);if(92===r){r=i.charCodeAt(++s);var o=/^[0-7]+/.exec(i.slice(s,s+3));for(o&&(o=o[0]);o&&parseInt(o,8)>255;)o=o.slice(0,-1);if("0"===o&&(o=null),++s,o)x&&b(s-2,"Octal literal in strict mode"),a+=String.fromCharCode(parseInt(o,8)),s+=o.length-1;else switch(r){case 110:a+="\n";break;case 114:a+="\r";break;case 120:a+=String.fromCharCode(nt(2));break;case 117:a+=String.fromCharCode(nt(4));break;case 85:a+=String.fromCharCode(nt(8));break;case 116:a+="\t";break;case 98:a+="\b";break;case 118:a+="\v";break;case 102:a+="\f";break;case 48:a+="\0";break;case 13:10===i.charCodeAt(s)&&++s;case 10:t.locations&&(m=s,++p);break;default:a+=String.fromCharCode(r)}}else(13===r||10===r||8232===r||8233===r)&&b(l,"Unterminated string constant"),a+=String.fromCharCode(r),++s}}(e);case 47:return function(){var e=i.charCodeAt(s+1);return f?(++s,et()):61===e?$e(me,2):$e(fe,1)}();case 37:case 42:return 61===i.charCodeAt(s+1)?$e(me,2):$e(De,1);case 124:case 38:return function(e){var t=i.charCodeAt(s+1);return t===e?$e(124===e?ye:Ce,2):61===t?$e(me,2):$e(124===e?Me:Se,1)}(e);case 94:return 61===i.charCodeAt(s+1)?$e(me,2):$e(xe,1);case 43:case 45:return function(e){var t=i.charCodeAt(s+1);return t===e?45==t&&62==i.charCodeAt(s+2)&&je.test(i.slice(I,s))?(s+=3,Qe(),Ke(),Xe()):$e(ve,2):61===t?$e(me,2):$e(Pe,1)}(e);case 60:case 62:return function(e){var t=i.charCodeAt(s+1),n=1;return t===e?(n=62===e&&62===i.charCodeAt(s+2)?3:2,61===i.charCodeAt(s+n)?$e(me,n+1):$e(Ae,n)):33==t&&60==e&&45==i.charCodeAt(s+2)&&45==i.charCodeAt(s+3)?(s+=4,Qe(),Ke(),Xe()):(61===t&&(n=61===i.charCodeAt(s+2)?3:2),$e(we,n))}(e);case 61:case 33:return function(e){return 61===i.charCodeAt(s+1)?$e(be,61===i.charCodeAt(s+2)?3:2):$e(61===e?pe:Ie,1)}(e);case 126:return $e(Ie,1)}return!1}function Xe(e){if(e?s=l+1:l=s,t.locations&&(d=new He),e)return et();if(s>=n)return qe(_);var a=i.charCodeAt(s);if(We(a)||92===a)return rt();var r=Ye(a);if(!1===r){var o=String.fromCharCode(a);if("\\"===o||Ge.test(o))return rt();b(s,"Unexpected character '"+o+"'")}return r}function $e(e,t){var n=i.slice(s,s+t);s+=t,qe(e,n)}function et(){for(var e,t,a=s;;){s>=n&&b(a,"Unterminated regular expression");var r=i.charAt(s);if(je.test(r)&&b(a,"Unterminated regular expression"),e)e=!1;else{if("["===r)t=!0;else if("]"===r&&t)t=!1;else if("/"===r&&!t)break;e="\\"===r}++s}var o=i.slice(a,s);++s;var l=at();l&&!/^[gmsiy]*$/.test(l)&&b(a,"Invalid regexp flag");try{var h=new RegExp(o,l)}catch(e){e instanceof SyntaxError&&b(a,e.message),b(e)}return qe(P,h)}function tt(e,t){for(var n=s,a=0,r=0,o=null!=t?t:1/0;r<o;++r){var l,h=i.charCodeAt(s);if((l=h>=97?h-97+10:h>=65?h-65+10:h>=48&&h<=57?h-48:1/0)>=e)break;++s,a=a*e+l}return s===n||null!=t&&s-n!==t?null:a}function it(e){var t=s,n=!1,a=48===i.charCodeAt(s);!e&&null===tt(10)&&b(t,"Invalid number"),46===i.charCodeAt(s)&&(++s,tt(10),n=!0);var r=i.charCodeAt(s);(69===r||101===r)&&((43===(r=i.charCodeAt(++s))||45===r)&&++s,null===tt(10)&&b(t,"Invalid number"),n=!0),We(i.charCodeAt(s))&&b(s,"Identifier directly after number");var o,l=i.slice(t,s);return n?o=parseFloat(l):a&&1!==l.length?/[89]/.test(l)||x?b(t,"Invalid number"):o=parseInt(l,8):o=parseInt(l,10),qe(A,o)}function nt(e){var t=tt(16,e);return null===t&&b(l,"Bad character escape sequence"),t}function at(){Te=!1;for(var e,t=!0,n=s;;){var a=i.charCodeAt(s);if(Ze(a))Te&&(e+=i.charAt(s)),++s;else{if(92!==a)break;Te||(e=i.slice(n,s)),Te=!0,117!=i.charCodeAt(++s)&&b(s,"Expecting Unicode escape sequence \\uXXXX"),++s;var r=nt(4),o=String.fromCharCode(r);o||b(s-1,"Invalid Unicode escape"),(t?We(r):Ze(r))||b(s-4,"Invalid Unicode escape"),e+=o}t=!1}return Te?e:i.slice(n,s)}function rt(){var e=at(),t=k;return!Te&&Re(e)&&(t=ie[e]),qe(t,e)}function ot(){v=l,I=h,y=c,Xe()}function st(e){if(x=e,s=l,t.locations)for(;s<m;)m=i.lastIndexOf("\n",m-2)+1,--p;Ke(),Xe()}function lt(){this.type=null,this.start=l,this.end=null}function ht(){this.start=d,this.end=null,null!==a&&(this.source=a)}function dt(){var e=new lt;return t.locations&&(e.loc=new ht),t.directSourceFile&&(e.sourceFile=t.directSourceFile),t.ranges&&(e.range=[l,0]),e}function ct(e){var i=new lt;return i.start=e.start,t.locations&&(i.loc=new ht,i.loc.start=e.loc.start),t.ranges&&(i.range=[e.range[0],0]),i}function ut(e,i){return e.type=i,e.end=I,t.locations&&(e.loc.end=y),t.ranges&&(e.range[1]=I),e}function gt(e){return t.ecmaVersion>=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"use strict"===e.expression.value}function ft(e){if(u===e)return ot(),!0}function pt(){return!t.strictSemicolons&&(u===_||u===oe||je.test(i.slice(I,l)))}function mt(){!ft(de)&&!pt()&&It()}function vt(e){u===e?ot():It()}function It(){b(l,"Unexpected token")}function yt(e){"Identifier"!==e.type&&"MemberExpression"!==e.type&&b(e.start,"Assigning to rvalue"),x&&"Identifier"===e.type&&Ee(e.name)&&b(e.start,"Assigning to "+e.name+" in strict mode")}var Ct={kind:"loop"},Mt={kind:"switch"};function xt(){(u===fe||u===me&&"/="==g)&&Xe(!0);var e=u,n=dt();switch(e){case T:case B:ot();var a=e===T;ft(de)||pt()?n.label=null:u!==k?It():(n.label=Rt(),mt());for(var r=0;r<M.length;++r){var o=M[r];if((null==n.label||o.name===n.label.name)&&(null!=o.kind&&(a||"loop"===o.kind)||n.label&&a))break}return r===M.length&&b(n.start,"Unsyntactic "+e.keyword),ut(n,a?"BreakStatement":"ContinueStatement");case E:return ot(),mt(),ut(n,"DebuggerStatement");case F:return ot(),M.push(Ct),n.body=xt(),M.pop(),vt(J),n.test=St(),mt(),ut(n,"DoWhileStatement");case U:if(ot(),M.push(Ct),vt(se),u===de)return wt(n,null);if(u===q){var s=dt();return ot(),Pt(s,!0),ut(s,"VariableDeclaration"),1===s.declarations.length&&ft(te)?At(n,s):wt(n,s)}return s=Dt(!1,!0),ft(te)?(yt(s),At(n,s)):wt(n,s);case j:return ot(),Bt(n,!0);case N:return ot(),n.test=St(),n.consequent=xt(),n.alternate=ft(L)?xt():null,ut(n,"IfStatement");case W:return!C&&!t.allowReturnOutsideFunction&&b(l,"'return' outside of function"),ot(),ft(de)||pt()?n.argument=null:(n.argument=Dt(),mt()),ut(n,"ReturnStatement");case Z:ot(),n.discriminant=St(),n.cases=[],vt(re),M.push(Mt);for(var h,d;u!=oe;)if(u===z||u===R){var c=u===z;h&&ut(h,"SwitchCase"),n.cases.push(h=dt()),h.consequent=[],ot(),c?h.test=Dt():(d&&b(v,"Multiple default clauses"),d=!0,h.test=null),vt(ce)}else h||It(),h.consequent.push(xt());return h&&ut(h,"SwitchCase"),ot(),M.pop(),ut(n,"SwitchStatement");case H:return ot(),je.test(i.slice(I,l))&&b(I,"Illegal newline after throw"),n.argument=Dt(),mt(),ut(n,"ThrowStatement");case V:if(ot(),n.block=bt(),n.handler=null,u===O){var f=dt();ot(),vt(se),f.param=Rt(),x&&Ee(f.param.name)&&b(f.param.start,"Binding "+f.param.name+" in strict mode"),vt(le),f.guard=null,f.body=bt(),n.handler=ut(f,"CatchClause")}return n.guardedHandlers=w,n.finalizer=ft(G)?bt():null,!n.handler&&!n.finalizer&&b(n.start,"Missing catch or finally clause"),ut(n,"TryStatement");case q:return ot(),Pt(n),mt(),ut(n,"VariableDeclaration");case J:return ot(),n.test=St(),M.push(Ct),n.body=xt(),M.pop(),ut(n,"WhileStatement");case Q:return x&&b(l,"'with' in strict mode"),ot(),n.object=St(),n.body=xt(),ut(n,"WithStatement");case re:return bt();case de:return ot(),ut(n,"EmptyStatement");default:var p=g,m=Dt();if(e===k&&"Identifier"===m.type&&ft(ce)){for(r=0;r<M.length;++r)M[r].name===p&&b(m.start,"Label '"+p+"' is already declared");var y=u.isLoop?"loop":u===Z?"switch":null;return M.push({name:p,kind:y}),n.body=xt(),M.pop(),n.label=m,ut(n,"LabeledStatement")}return n.expression=m,mt(),ut(n,"ExpressionStatement")}}function St(){vt(se);var e=Dt();return vt(le),e}function bt(e){var t,i=dt(),n=!0,a=!1;for(i.body=[],vt(re);!ft(oe);){var r=xt();i.body.push(r),n&&e&>(r)&&(t=a,st(a=!0)),n=!1}return a&&!t&&st(!1),ut(i,"BlockStatement")}function wt(e,t){return e.init=t,vt(de),e.test=u===de?null:Dt(),vt(de),e.update=u===le?null:Dt(),vt(le),e.body=xt(),M.pop(),ut(e,"ForStatement")}function At(e,t){return e.left=t,e.right=Dt(),vt(le),e.body=xt(),M.pop(),ut(e,"ForInStatement")}function Pt(e,t){for(e.declarations=[],e.kind="var";;){var i=dt();if(i.id=Rt(),x&&Ee(i.id.name)&&b(i.id.start,"Binding "+i.id.name+" in strict mode"),i.init=ft(pe)?Dt(!0,t):null,e.declarations.push(ut(i,"VariableDeclarator")),!ft(he))break}return e}function Dt(e,t){var i=kt(t);if(!e&&u===he){var n=ct(i);for(n.expressions=[i];ft(he);)n.expressions.push(kt(t));return ut(n,"SequenceExpression")}return i}function kt(e){var t=function(e){var t=function(e){return function e(t,i,n){var a=u.binop;if(null!=a&&(!n||u!==te)&&a>i){var r=ct(t);r.left=t,r.operator=g;var o=u;ot(),r.right=e(_t(),a,n);var s=ut(r,o===ye||o===Ce?"LogicalExpression":"BinaryExpression");return e(s,i,n)}return t}(_t(),-1,e)}(e);if(ft(ge)){var i=ct(t);return i.test=t,i.consequent=Dt(!0),vt(ce),i.alternate=Dt(!0,e),ut(i,"ConditionalExpression")}return t}(e);if(u.isAssign){var i=ct(t);return i.operator=g,i.left=t,ot(),i.right=kt(e),yt(t),ut(i,"AssignmentExpression")}return t}function _t(){if(u.prefix){var e=dt(),t=u.isUpdate;return e.operator=g,e.prefix=!0,f=!0,ot(),e.argument=_t(),t?yt(e.argument):x&&"delete"===e.operator&&"Identifier"===e.argument.type&&b(e.start,"Deleting local variable in strict mode"),ut(e,t?"UpdateExpression":"UnaryExpression")}for(var i=Tt(zt());u.postfix&&!pt();)(e=ct(i)).operator=g,e.prefix=!1,e.argument=i,yt(i),ot(),i=ut(e,"UpdateExpression");return i}function Tt(e,t){var i;return ft(ue)?((i=ct(e)).object=e,i.property=Rt(!0),i.computed=!1,Tt(ut(i,"MemberExpression"),t)):ft(ne)?((i=ct(e)).object=e,i.property=Dt(),i.computed=!0,vt(ae),Tt(ut(i,"MemberExpression"),t)):!t&&ft(se)?((i=ct(e)).callee=e,i.arguments=Et(le,!1),Tt(ut(i,"CallExpression"),t)):e}function zt(){switch(u){case Y:var e=dt();return ot(),ut(e,"ThisExpression");case k:return Rt();case A:case D:case P:return(e=dt()).value=g,e.raw=i.slice(l,h),ot(),ut(e,"Literal");case X:case $:case ee:return(e=dt()).value=u.atomValue,e.raw=u.keyword,ot(),ut(e,"Literal");case se:var n=d,a=l;ot();var r=Dt();return r.start=a,r.end=h,t.locations&&(r.loc.start=n,r.loc.end=c),t.ranges&&(r.range=[a,h]),vt(le),r;case ne:return e=dt(),ot(),e.elements=Et(ae,!0,!0),ut(e,"ArrayExpression");case re:return function(){var e=dt(),i=!0,n=!1;for(e.properties=[],ot();!ft(oe);){if(i)i=!1;else if(vt(he),t.allowTrailingCommas&&ft(oe))break;var a,r={key:Ot()},o=!1;if(ft(ce)?(r.value=Dt(!0),a=r.kind="init"):t.ecmaVersion>=5&&"Identifier"===r.key.type&&("get"===r.key.name||"set"===r.key.name)?(o=n=!0,a=r.kind=r.key.name,r.key=Ot(),u!==se&&It(),r.value=Bt(dt(),!1)):It(),"Identifier"===r.key.type&&(x||n))for(var s=0;s<e.properties.length;++s){var l=e.properties[s];if(l.key.name===r.key.name){var h=a==l.kind||o&&"init"===l.kind||"init"===a&&("get"===l.kind||"set"===l.kind);h&&!x&&"init"===a&&"init"===l.kind&&(h=!1),h&&b(r.key.start,"Redefinition of property")}}e.properties.push(r)}return ut(e,"ObjectExpression")}();case j:return e=dt(),ot(),Bt(e,!1);case K:return function(){var e=dt();return ot(),e.callee=Tt(zt(),!0),ft(se)?e.arguments=Et(le,!1):e.arguments=w,ut(e,"NewExpression")}();default:It()}}function Ot(){return u===A||u===D?zt():Rt(!0)}function Bt(e,t){u===k?e.id=Rt():t?It():e.id=null,e.params=[];var i=!0;for(vt(se);!ft(le);)i?i=!1:vt(he),e.params.push(Rt());var n=C,a=M;if(C=!0,M=[],e.body=bt(!0),C=n,M=a,x||e.body.body.length&>(e.body.body[0]))for(var r=e.id?-1:0;r<e.params.length;++r){var o=r<0?e.id:e.params[r];if((Be(o.name)||Ee(o.name))&&b(o.start,"Defining '"+o.name+"' in strict mode"),r>=0)for(var s=0;s<r;++s)o.name===e.params[s].name&&b(o.start,"Argument name clash in strict mode")}return ut(e,t?"FunctionDeclaration":"FunctionExpression")}function Et(e,i,n){for(var a=[],r=!0;!ft(e);){if(r)r=!1;else if(vt(he),i&&t.allowTrailingCommas&&ft(e))break;n&&u===he?a.push(null):a.push(Dt(!0))}return a}function Rt(e){var n=dt();return e&&"everywhere"==t.forbidReserved&&(e=!1),u===k?(!e&&(t.forbidReserved&&(3===t.ecmaVersion?ze:Oe)(g)||x&&Be(g))&&-1==i.slice(l,h).indexOf("\\")&&b(l,"The keyword '"+g+"' is reserved"),n.name=g):e&&u.keyword?n.name=u.keyword:It(),f=!1,ot(),ut(n,"Identifier")}},"object"==typeof r&&"object"==typeof o?h(r):"function"==typeof t&&t.amd?t(["exports"],h):h(s.acorn||(s.acorn={})),c.version||(c=null));var g={"+":"__add","-":"__subtract","*":"__multiply","/":"__divide","%":"__modulo","==":"__equals","!=":"__equals"},p={"-":"__negate","+":"__self"},v=a.each(["add","subtract","multiply","divide","modulo","equals","negate"],function(e){this["__"+e]="#"+e},{__self:function(){return this}});function I(e,t,i){var n=g[t];if(e&&e[n]){var a=e[n](i);return"!="===t?!a:a}switch(t){case"+":return e+i;case"-":return e-i;case"*":return e*i;case"/":return e/i;case"%":return e%i;case"==":return e==i;case"!=":return e!=i}}function y(e,t){var i=p[e];if(t&&t[i])return t[i]();switch(e){case"+":return+t;case"-":return-t}}function C(t,a){if(!t)return"";var r=[];function o(e){for(var t=0,i=r.length;t<i;t++){var n=r[t];if(n[0]>=e)break;e+=n[1]}return e}function s(e){return t.substring(o(e.range[0]),o(e.range[1]))}function l(e,i){for(var n=o(e.range[0]),a=o(e.range[1]),s=0,l=r.length-1;l>=0;l--)if(n>r[l][0]){s=l+1;break}r.splice(s,0,[n,i.length-a+n]),t=t.substring(0,n)+i+t.substring(a)}function h(e,i){switch(e.type){case"UnaryExpression":if(e.operator in p&&"Literal"!==e.argument.type){var n=s(e.argument);l(e,'$__("'+e.operator+'", '+n+")")}break;case"BinaryExpression":if(e.operator in g&&"Literal"!==e.left.type){var a=s(e.left),r=s(e.right),h=function(e,i){return t.substring(o(e.range[1]),o(i.range[0]))}(e.left,e.right),d=e.operator;l(e,"__$__("+a+","+h.replace(new RegExp("\\"+d),'"'+d+'"')+", "+r+")")}break;case"UpdateExpression":case"AssignmentExpression":var c=i&&i.type;if(!("ForStatement"===c||"BinaryExpression"===c&&/^[=!<>]/.test(i.operator)||"MemberExpression"===c&&i.computed))if("UpdateExpression"===e.type){var u=(n=s(e.argument))+" = "+(f="__$__("+n+', "'+e.operator[0]+'", 1)');e.prefix?u="("+u+")":("AssignmentExpression"===c||"VariableDeclarator"===c||"BinaryExpression"===c)&&(s(i.left||i.id)===n&&(u=f),u=n+"; "+u),l(e,u)}else if(/^.=$/.test(e.operator)&&"Literal"!==e.left.type){a=s(e.left),r=s(e.right);var f=a+" = __$__("+a+', "'+e.operator[0]+'", '+r+")";l(e,/^\(.*\)$/.test(s(e))?"("+f+")":f)}}}var d,c=(a=a||{}).url||"",f=a.sourceMaps,m=a.paperFeatures||{},v=a.source||t,I=a.offset||0,y=le.agent,C=y.versionNumber,M=!1,x=/\r\n|\n|\r/gm;if(f&&(y.chrome&&C>=30||y.webkit&&C>=537.76||y.firefox&&C>=23||y.node)){if(y.node)I-=2;else if(i&&c&&!i.location.href.indexOf(c)){var S=n.getElementsByTagName("html")[0].innerHTML;I=S.substr(0,S.indexOf(t)+1).match(x).length+1}var b=["AA"+function(e){var t="";for(e=(Math.abs(e)<<1)+(e<0?1:0);e||!t;){var i=31&e;(e>>=5)&&(i|=32),t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[i]}return t}((M=I>0&&!(y.chrome&&C>=36||y.safari&&C>=600||y.firefox&&C>=40||y.node))?0:I)+"A"];b.length=(t.match(x)||[]).length+1+(M?I:0),d={version:3,file:c,names:[],mappings:b.join(";AACA"),sourceRoot:"",sources:[c],sourcesContent:[v]}}return(!1!==m.operatorOverloading||!1!==m.moduleExports)&&function e(t,i,n){if(t){for(var a in t)if("range"!==a&&"loc"!==a){var r=t[a];if(Array.isArray(r))for(var o=0,d=r.length;o<d;o++)e(r[o],t,n);else r&&"object"==typeof r&&e(r,t,n)}!1!==n.operatorOverloading&&h(t,i),!1!==n.moduleExports&&function(e){switch(e.type){case"ExportDefaultDeclaration":l({range:[e.start,e.declaration.start]},"module.exports = ");break;case"ExportNamedDeclaration":var t=e.declaration,i=e.specifiers;if(t){var n=t.declarations;n&&(n.forEach(function(e){l(e,"module.exports."+s(e))}),l({range:[e.start,t.start+t.kind.length]},""))}else if(i){var a=i.map(function(e){var t=s(e);return"module.exports."+t+" = "+t+"; "}).join("");a&&l(e,a)}}}(t)}}(u(t,{ranges:!0,preserveParens:!0,sourceType:"module"}),null,m),d&&(M&&(t=new Array(I+1).join("\n")+t),/^(inline|both)$/.test(f)&&(t+="\n//# sourceMappingURL=data:application/json;base64,"+e.btoa(unescape(encodeURIComponent(JSON.stringify(d))))),t+="\n//# sourceURL="+(c||"paperscript")),{url:c,source:v,code:t,map:d}}function M(e,t,i){le=t;var r,o=t.getView(),s=/\btool\.\w+|\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/.test(e)&&!/\bnew\s+Tool\b/.test(e)?new te:null,l=s?s._events:[],h=["onFrame","onResize"].concat(l),d=[],c=[],u="object"==typeof e?e:C(e,i);function g(t,i){for(var n in t)(i||!/^_/.test(n))&&new RegExp("([\\b\\s\\W]|^)"+n.replace(/\$/g,"\\$")+"\\b").test(e)&&(d.push(n),c.push(t[n]))}e=u.code,g({__$__:I,$__:y,paper:t,tool:s},!0),g(t),e="var module = { exports: {} }; "+e,(M=a.each(h,function(t){new RegExp("\\s+"+t+"\\b").test(e)&&(d.push(t),this.push("module.exports."+t+" = "+t+";"))},[]).join("\n"))&&(e+="\n"+M),e+="\nreturn module.exports;";var p=le.agent;if(n&&(p.chrome||p.firefox&&p.versionNumber<40)){var m=n.createElement("script"),v=n.head||n.getElementsByTagName("head")[0];p.firefox&&(e="\n"+e),m.appendChild(n.createTextNode("document.__paperscript__ = function("+d+") {"+e+"\n}")),v.appendChild(m),r=n.__paperscript__,delete n.__paperscript__,v.removeChild(m)}else r=Function(d,e);var M,x=(M=r&&r.apply(t,c))||{};return a.each(l,function(e){var t=x[e];t&&(s[e]=t)}),o&&(x.onResize&&o.setOnResize(x.onResize),o.emit("resize",{size:o.size,delta:new f}),x.onFrame&&o.setOnFrame(x.onFrame),o.requestUpdate()),M}function x(e){if(/^text\/(?:x-|)paperscript$/.test(e.type)&&"true"!==l.getAttribute(e,"ignore")){var t=l.getAttribute(e,"canvas"),i=n.getElementById(t),a=e.src||e.getAttribute("data-src"),r=l.hasAttribute(e,"async"),o="data-paper-scope";if(!i)throw new Error('Unable to find canvas with id "'+t+'"');var s=l.get(i.getAttribute(o))||(new l).setup(i);return i.setAttribute(o,s._id),a?ne.request({url:a,async:r,mimeType:"text/plain",onLoad:function(e){M(e,s,a)}}):M(e.innerHTML,s,e.baseURI),e.setAttribute("data-paper-ignore","true"),s}}function S(){a.each(n&&n.getElementsByTagName("script"),x)}return f.inject(v),m.inject(v),N.inject(v),i&&("complete"===n.readyState?setTimeout(S):q.add(i,{load:S})),{compile:C,execute:M,load:function(e){return e?x(e):S()},parse:u,calculateBinary:I,calculateUnary:y}}.call(this);var le=new(l.inject(a.exports,{Base:a,Numerical:u,Key:X,DomEvent:q,DomElement:V,document:n,window:i,Symbol:k,PlacedSymbol:D}));return le.agent.node&&r(le),"function"==typeof t&&t.amd?t("paper",le):o&&(o.exports=le),le}.call(n,"object"==typeof self?self:null);const s=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(a.exports);e.Preview3DGenerator=class{constructor(){i(this,"_paperScope",new s.PaperScope),i(this,"_baseMaterial",null),i(this,"_borderMaterial",null);const e=document.createElement("canvas");e.width=1,e.height=1,this._paperScope.setup(new s.Size(1,1))}generatePreview3D(e,t){if(!e.columns||isNaN(e.columns)||e.columns<1||e.rows<1||!e.rows||isNaN(e.rows))throw new Error("Invalid columns or rows value. Columns and rows must be greater than 0 and must be a number.");console.log("Generating 3D preview for resizable canvas...",e),this._baseMaterial||(this._baseMaterial=new BABYLON.PBRMaterial("baseMaterial",t)),this._borderMaterial||(this._borderMaterial=new BABYLON.PBRMaterial("borderMaterial",t)),this._baseMaterial.albedoColor=new BABYLON.Color3(1,1,1),this._baseMaterial.metallic=0,this._baseMaterial.roughness=.5,this._borderMaterial.albedoColor=BABYLON.Color3.FromHexString(e.borderColor),this._borderMaterial.metallic=0,this._borderMaterial.roughness=.5,e.useCheckerTexture&&(this._baseMaterial.albedoTexture=new BABYLON.Texture("https://zakekecdn.blob.core.windows.net/cdn/Test/checker_texture.png",t),this._baseMaterial.albedoTexture.wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,this._baseMaterial.albedoTexture.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE,this._borderMaterial.albedoTexture=new BABYLON.Texture("https://zakekecdn.blob.core.windows.net/cdn/Test/checker_texture.png",t),this._borderMaterial.albedoTexture.wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,this._borderMaterial.albedoTexture.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE);const i=new BABYLON.Mesh("groupMesh",t),n=[],a=[],r=[];for(let i=0;i<e.columns;i++)for(let o=0;o<e.rows;o++){const[s,l,h]=this.generateCanvasMesh(e,t,i,o);n.push(s),a.push(l),r.push(h)}const o=BABYLON.Mesh.MergeMeshes(n,!0,!0,void 0,!1,!1),s=BABYLON.Mesh.MergeMeshes(a,!0,!0,void 0,!1,!1),l=BABYLON.Mesh.MergeMeshes(r,!0,!0,void 0,!1,!1);if(!o||!s||!l)return null;o.material=this._borderMaterial,s.material=this._baseMaterial,l.material=this._baseMaterial,o.parent=i,s.parent=i,l.parent=i,o.name="borders",s.name="back",l.name="front";const h=BABYLON.SceneSerializer.SerializeMesh(i,!1,!0);return null==i||i.dispose(),h}generateCanvasMesh(e,t,i,n){var a,r,o,s;const l=e.width/e.columns,h=e.height/e.rows,d=.1*l,c=BABYLON.MeshBuilder.CreateBox("borders",{width:l,height:h,depth:e.depth},t),u=BABYLON.MeshBuilder.CreatePlane("front",{width:l,height:h},t),g=BABYLON.MeshBuilder.CreatePlane("back",{width:l,height:h},t);c.position=new BABYLON.Vector3(l/2+i*(l+d),h/2+n*(h+d)),u.position=new BABYLON.Vector3(l/2+i*(l+d),h/2+n*(h+d),-e.depth/2),g.position=new BABYLON.Vector3(l/2+i*(l+d),h/2+n*(h+d),e.depth/2),g.rotate(BABYLON.Axis.X,Math.PI,BABYLON.Space.WORLD),g.rotate(BABYLON.Axis.Z,Math.PI,BABYLON.Space.WORLD),c.material=this._borderMaterial,g.material=this._borderMaterial,u.material=this._baseMaterial;const f=c.getVerticesData(BABYLON.VertexBuffer.NormalKind),p=c.getVerticesData(BABYLON.VertexBuffer.UVKind),m=u.getVerticesData(BABYLON.VertexBuffer.UVKind),v=g.getVerticesData(BABYLON.VertexBuffer.UVKind);if(e.borderRadius>0&&console.warn("Mirror canvas effect will not work for border radius > 0"),0===e.borderRadius){const t=e.depth/e.width,a=e.depth/e.height,r=Math.min(t,a),o=l/e.width,s=h/e.height;for(var I=0;I<p.length;I+=2){const t=Math.round(f[I/2*3]),a=Math.round(f[I/2*3+1]),l=Math.round(f[I/2*3+2]),h=1==t&&0==a&&0==l,d=0==t&&1==a&&0==l,c=0==t&&-1==a&&0==l;if(-1==t&&0==a&&0==l){var y=p[I],C=p[I+1];p[I]=C*r+o*i,p[I+1]=y*s+s*n}h&&(y=p[I],C=p[I+1],p[I]=C*r+(1-r)-o*(e.columns-1-i),p[I+1]=y*s+s*n),c&&(y=p[I],C=p[I+1],p[I]=C*o+o*i,p[I+1]=y*r+s*n),d&&(y=p[I],C=p[I+1],p[I]=(1-C)*o+o*i,p[I+1]=(1-y)*r+(1-r))}for(c.setVerticesData(BABYLON.VertexBuffer.UVKind,p),I=0;I<m.length;I+=2)y=m[I],C=m[I+1],m[I]=y*o+o*i,m[I+1]=C*s+s*n;for(u.setVerticesData(BABYLON.VertexBuffer.UVKind,m),I=0;I<v.length;I+=2)y=v[I],C=v[I+1],v[I]=y*o+o*(e.columns-1-i),v[I+1]=C*s+s*n;g.setVerticesData(BABYLON.VertexBuffer.UVKind,v)}u.isVisible=!1,g.isVisible=!1;const M=null!==(a=c.getVerticesData(BABYLON.VertexBuffer.PositionKind))&&void 0!==a?a:[],x=null!==(r=c.getVerticesData(BABYLON.VertexBuffer.NormalKind))&&void 0!==r?r:[],S=null!==(o=c.getVerticesData(BABYLON.VertexBuffer.UVKind))&&void 0!==o?o:[],b=null!==(s=c.getIndices())&&void 0!==s?s:[];return M.splice(0,24),x.splice(0,24),S.splice(0,16),b.splice(b.length-12,12),c.updateVerticesData(BABYLON.VertexBuffer.PositionKind,M),c.updateVerticesData(BABYLON.VertexBuffer.NormalKind,x),c.updateVerticesData(BABYLON.VertexBuffer.UVKind,S),c.updateIndices(b),[c,g,u]}},e.ProductAreaGenerator=class{constructor(){i(this,"_paperScope",new s.PaperScope),this._paperScope.setup(new s.Size(1,1))}generateArea(e){if(e.width<=0||e.height<=0)throw new Error("Width and height must be greater than 0");const t=new this._paperScope.Path.Rectangle({point:[0,0],size:[e.width,e.height],radius:e.borderRadius});return t.position=new this._paperScope.Point(0,0),t.remove(),{json:t.exportJSON(),svg:t.exportSVG({asString:!0})}}},e.ProductImageGenerator=class{constructor(){i(this,"_paperScope",new s.PaperScope),this._paperScope.setup(new s.Size(1,1))}generateImage(e){if(e.width<=0||e.height<=0)throw new Error("Width and height must be greater than 0");return{shape:this.createShape(e),splitColumns:this.createSplitColumns(e),measures:this.createMeasures(e)}}createShape(e){const t=new this._paperScope.Path.Rectangle({point:[0,0],size:[e.width,e.height],radius:e.shape.borderRadius,fillColor:e.shape.fillColor,strokeColor:e.shape.borderColor,strokeWidth:e.shape.borderWidth,shadowColor:e.shape.shadowColor,shadowBlur:e.shape.shadowBlur*e.scale,shadowOffset:new this._paperScope.Point(e.shape.shadowOffset.x*e.scale,e.shape.shadowOffset.y*e.scale)});return t.position=new this._paperScope.Point(0,0),t.remove(),{json:t.exportJSON(),svg:t.exportSVG({asString:!0})}}createSplitColumns(e){const t=new this._paperScope.Group,i=e.width/e.splitColumns.columns,n=e.height/e.splitColumns.rows;for(let n=1;n<e.splitColumns.columns;n++){const a=n*i,r=new this._paperScope.Path.Line({from:[a,0+e.splitColumns.marginVertical],to:[a,e.height-e.splitColumns.marginVertical],strokeColor:e.splitColumns.lineColor,strokeWidth:e.splitColumns.lineWidth,dashArray:e.splitColumns.lineDashArray,strokeScaling:!1});t.addChild(r)}for(let i=1;i<e.splitColumns.rows;i++){const a=i*n,r=new this._paperScope.Path.Line({from:[0+e.splitColumns.marginVertical,a],to:[e.width-e.splitColumns.marginVertical,a],strokeColor:e.splitColumns.lineColor,strokeWidth:e.splitColumns.lineWidth,dashArray:e.splitColumns.lineDashArray,strokeScaling:!1});t.addChild(r)}return t.position=new this._paperScope.Point(0,0),{json:t.exportJSON(),svg:t.exportSVG({asString:!0})}}createMeasures(e){var t,i,n,a,r,o;const s=new this._paperScope.Group,l=this.createArrow(e,new this._paperScope.Point(-e.width/2,-e.height/2-e.measures.widthDistance*e.scale),new this._paperScope.Point(+e.width/2,-e.height/2-e.measures.widthDistance*e.scale)),h=this.createArrow(e,new this._paperScope.Point(e.width/2+e.measures.heightDistance*e.scale,-e.height/2),new this._paperScope.Point(e.width/2+e.measures.heightDistance*e.scale,+e.height/2)),d=(e.measures.heightDistance+10)*e.scale,c=(e.measures.widthDistance+5)*e.scale,u=new this._paperScope.PointText({fillColor:e.measures.labelColor,fontFamily:null!==(t=e.measures.fontFamily)&&void 0!==t?t:"Courier New",fontWeight:null!==(i=e.measures.fontWeight)&&void 0!==i?i:"bold",fontSize:e.measures.labelFontSize*e.scale,justification:"center",position:[0,-e.height/2-c],content:e.measures.widthLabel}),g=new this._paperScope.PointText({fillColor:e.measures.labelColor,fontFamily:null!==(n=e.measures.fontFamily)&&void 0!==n?n:"Courier New",fontWeight:null!==(a=e.measures.fontWeight)&&void 0!==a?a:"bold",fontSize:e.measures.labelFontSize*e.scale,justification:"center",verticalLine:"base",position:[e.width/2+d,0],content:e.measures.heightLabel,rotation:-270}),f=new this._paperScope.PointText({fillColor:e.measures.labelColor,fontFamily:null!==(r=e.measures.fontFamily)&&void 0!==r?r:"Courier New",fontWeight:null!==(o=e.measures.fontWeight)&&void 0!==o?o:"bold",fontSize:e.measures.labelFontSize*e.scale,justification:"center",verticalLine:"base",position:[0-e.width/2-(e.measures.heightDistance+5)*e.scale,-e.height/2-c],content:e.measures.totalSizeLabel,rotation:-90});return f.bounds.y+=f.bounds.height/2+d,f.data.isTotalSizeLabel=!0,f.data.originalContent=f.content,f.data.originalY=f.bounds.y,s.addChild(u),s.addChild(g),s.addChild(l),s.addChild(h),s.addChild(f),{json:s.exportJSON(),svg:s.exportSVG({asString:!0})}}createArrow(e,t,i){const n=new this._paperScope.Group,a=i.subtract(t).angle,r={strokeColor:e.measures.lineColor,strokeWidth:e.measures.lineWidth,dashArray:e.measures.lineDashArray,strokeScaling:!1},o=new this._paperScope.Path.Line(_objectSpread({from:t,to:i},r)),s=new this._paperScope.Path.Line(_objectSpread({from:t,to:t.add(new this._paperScope.Point(-5*e.scale,-5*e.scale))},r)),l=new this._paperScope.Path.Line(_objectSpread({from:t,to:t.add(new this._paperScope.Point(-5*e.scale,5*e.scale))},r)),h=new this._paperScope.Path.Line(_objectSpread({from:i,to:i.add(new this._paperScope.Point(-5*e.scale,-5*e.scale))},r)),d=new this._paperScope.Path.Line(_objectSpread({from:i,to:i.add(new this._paperScope.Point(-5*e.scale,5*e.scale))},r));return s.rotate(a+180,t),l.rotate(a+180,t),h.rotate(a,i),d.rotate(a,i),n.addChild(o),n.addChild(s),n.addChild(l),n.addChild(h),n.addChild(d),n}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}),(MPlaza=MPlaza||{}).EmptyUUID="00000000-0000-0000-0000-000000000000",MPlaza.generateUUID=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:7&i|8).toString(16)})},MPlaza.getContrastYIQ=function(e,t,i){return(299*e+587*t+114*i)/1e3>=128?"black":"white"},MPlaza.getContrastYIQHex=function(e){return(299*parseInt(e.substr(0,2),16)+587*parseInt(e.substr(2,2),16)+114*parseInt(e.substr(4,2),16))/1e3>=128?"black":"white"},MPlaza.makeID=function(e){for(var t="",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=0;n<e;n++)t+=i.charAt(Math.floor(Math.random()*i.length));return t},MPlaza.cloudFlareApiUrl=function(){return"string"==typeof Zakeke.config.cloudFlareApiUrl&&null!==Zakeke.config.cloudFlareApiUrl&&""!==Zakeke.config.cloudFlareApiUrl.trim()?Zakeke.config.cloudFlareApiUrl:null},MPlaza.syncCloudflare=function(e,t,i){var n=function(e){void 0!==e._defaultUrl&&(e.url=e._defaultUrl),delete e.cloudflareUrl,delete e._defaultUrl},a=Backbone.sync;t.hasOwnProperty("retrySyncEngine")&&(a=t.retrySyncEngine);var r=0,o=t.stepsLimit||2;t.cloudflareUrl=MPlaza.cloudFlareApiUrl(),t._defaultUrl=t.url,t.url=function(){var e=t._defaultUrl();return"string"==typeof t.cloudflareUrl&&null!==t.cloudflareUrl&&""!==t.cloudflareUrl.trim()&&(e=e.replace(Zakeke.config.baseApiUrl,Zakeke.config.cloudFlareApiUrl)),e},"read"===e&&null!==t.cloudflareUrl||(n(t),o=1);var s=$.Deferred(),l=function(h,d,c){var u=_.extend({},i);++r>o?(n(t),i.error(h,d,c),s.reject(h,d,c)):(delete u.error,delete u.success,a(e,t,u).then(function(e,a,r){n(t),i.success(e,a,r),s.resolve(e,a,r)}).fail(function(e,i,a){n(t),l(e,i,a)}))};return l(),s.promise()},MPlaza.PricingModel={Simple:1,Advanced:2,RuleBased:3},MPlaza.PricingType={Undefined:1,Global:2,PerColor:3},MPlaza.PricingApplicationType={Undefined:1,Global:2,PerSide:3,PerArea:4},MPlaza.AttributeType={Options:1,Color:2,Number:3,String:4},MPlaza.LogicalOperator={AND:"AND",OR:"OR"},MPlaza.ComparisonOperator={Equal:"Equal",NotEqual:"NotEqual",In:"In",NotIn:"NotIn"},MPlaza.SceneElementType={None:0,Mesh:1,Material:2,Light:4,Camera:8,CameraLocation:16,SubMesh:32},MPlaza.SceneElementType.All=MPlaza.SceneElementType.Mesh|MPlaza.SceneElementType.Material|MPlaza.SceneElementType.Light|MPlaza.SceneElementType.Camera|MPlaza.SceneElementType.CameraLocation|MPlaza.SceneElementType.SubMesh,MPlaza.SceneActionType={Filter:1,ShowHideMesh:2,SetMeshMaterial:3,SetMaterialColor:4,SetCameraLocation:5,AdjustCamera:6,SetSubMeshMaterial:7,SetCameraPivot:8,ResetCameraPivot:9,EnableDiableZoom:10,SetMeshDesignMaterial:11,SetMeshDesignEffect:12},MPlaza.PaddingType={Start:1,End:2,StartEnd:3},MPlaza.AttributeOptionPreviewShape={Rectangle:1,Circle:2},MPlaza.AttributeGroupDirection={Horizontal:0,Vertical:1},MPlaza.DeviceType={Any:0,PC:1,Phone:2,Tablet:4},MPlaza.DeviceType.All=MPlaza.DeviceType.PC|MPlaza.DeviceType.Phone|MPlaza.DeviceType.Tablet,MPlaza.ExtensionFieldDataType={Money:1,Integer:2,Decimal:3},MPlaza.ExtensionFieldOperationType={None:1,Addition:2};var TempStateObjectInterface={tempState:null,initTempState:function(){this.tempState=this.clone(),this.callToTempStateChildren("initTempState")},applyTempState:function(){this.tempState&&this.set(this.tempState.attributes),this.callToTempStateChildren("applyTempState")},resetTempState:function(){this.tempState=null},childHasTempState:function(e){return!(!e||!e.hasOwnProperty("tempState"))},hasTempStateChildren:function(){return!!(this.tempStateChildren&&Array.isArray(this.tempStateChildren)&&this.tempStateChildren.length>0)},callToTempStateChildren:function(e){if(this.hasTempStateChildren()&&this.tempState)for(var t=0;t<this.tempStateChildren.length;t++){var i=this.tempState.get(this.tempStateChildren[t]);this.childHasTempState(i)&&e&&i[e]()}}};function MarvinColorModelConverter(){}function MarvinImage(e,t,i){this.image=null,this.canvas=null,this.ctx=null,this.data=null,this.colorModel=null==i?MarvinImage.COLOR_MODEL_RGB:i,null!=e&&this.create(e,t),i==MarvinImage.COLOR_MODEL_BINARY&&(this.arrBinaryColor=new Array(e*t))}function MarvinImageMask(e,t){this.width=e,this.height=t,this.arrMask=0!=e&&0!=t?MarvinJSUtils.createMatrix2D(width,height):null}function MarvinSegment(e,t,i,n){this.x1=e,this.x2=i,this.y1=t,this.y2=n,-1!=e&&-1!=t&&-1!=i&&-1!=n&&(this.width=i-e+1,this.height=n-t+1,this.area=this.width*this.height)}function MarvinColor(e,t,i){return this.red=e,this.green=t,this.blue=i,this}MPlaza.UserIdentity=Backbone.AssociatedModel.extend({defaults:{nominative:"",token:""},idAttribute:"userID",initialize:function(){},url:function(){return Zakeke.config.baseApiUrl+"login"},sync:MPlaza.syncCloudflare}),MPlaza.AttributeProposition=Backbone.AssociatedModel.extend({defaults:{attributeGuid:"",op:"Equal",value:""},initialize:function(){},relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.AttributePropositions=Backbone.Collection.extend({model:MPlaza.AttributeProposition,sync:MPlaza.syncCloudflare}),MPlaza.AttributeExpression=Backbone.AssociatedModel.extend({defaults:{op:"AND",propositions:null,expressions:null},initialize:function(){this.get("propositions")||this.set("propositions",[]),this.get("expressions")||this.set("expressions",[]),this.get("propositions").parentModel=this,this.get("expressions").parentModel=this},getAllAttributeGuids:function(){for(var e=[],t=function(t){var i=t.attributeGuid;Zakeke.arrayContains(e,i)||e.push(i)},i=function(e){for(var i=0;i<e.propositions.length;i++){var n=e.proposition[i];t(n)}},n=0;n<this.get("propositions").length;n++){var a=this.get("propositions")[n];t(a)}for(n=0;n<this.get("expressions").length;n++){i(this.get("expressions")[n])}return e},isEmpty:function(){return 0==this.get("propositions").length&&0==this.get("expressions").length},sync:MPlaza.syncCloudflare}),MPlaza.AttributeExpressions=Backbone.Collection.extend({model:MPlaza.AttributeExpression,sync:MPlaza.syncCloudflare}),MPlaza.AttributeSelectionColor=Backbone.AssociatedModel.extend({defaults:{selectionExpression:null,colorID:-1},idAttribute:"selectionID",sync:MPlaza.syncCloudflare}),MPlaza.AttributeSelectionColors=Backbone.Collection.extend({model:MPlaza.AttributeSelectionColor,getAttributeSelectionColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("selectionID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ComposerPricingPrice=Backbone.AssociatedModel.extend({defaults:{qtyFrom:0,qtyTo:null,price:0},idAttribute:"priceID",initialize:function(){},relations:[],getPricingID:function(){return this.collection&&this.collection.getPricingID?this.collection.getPricingID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ComposerPricingPrices=Backbone.Collection.extend({model:MPlaza.ComposerPricingPrice,getPricingID:function(){return this.parentModel&&this.parentModel.getPricingID?this.parentModel.getPricingID():null},sync:MPlaza.syncCloudflare}),MPlaza.ComposerPricing=Backbone.AssociatedModel.extend({defaults:{prices:[]},idAttribute:"pricingID",initialize:function(){var e=this;this.get("prices").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("prices").on("add",function(){e._fireEvent("change")}),this.get("prices").on("remove",function(){e._fireEvent("change")}),this.get("prices").on("change",function(){e._fireEvent("change")})},_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},relations:[{type:Backbone.Many,key:"prices",collectionType:MPlaza.ComposerPricingPrices}],url:function(){var e=Zakeke.config.baseApiUrl+"composerpricings";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},getPricingID:function(){return this.get("pricingID")},toString:function(){},getComposerPricingPriceForQuantity:function(e){for(var t=0;t<this.get("prices").length;t++){var i=this.get("prices").at(t);if(i.get("qtyFrom")<=e&&(!i.get("qtyTo")||e<i.get("qtyTo")))return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ComposerPricings=Backbone.Collection.extend({model:MPlaza.ComposerPricing,url:function(){return Zakeke.config.baseApiUrl+"composerpricings"},getComposerPricing:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("pricingID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.AttributePricing=Backbone.AssociatedModel.extend({defaults:{selectedOptionID:null,selectedOptionGuid:null,selectedValue:"",constraintExpression:null,price:0,pricingID:-1},idAttribute:"attributePricingID",initialize:function(){},resetIDs:function(){this.unset("attributePricingID")},relations:[{type:Backbone.One,key:"constraintExpression",relatedModel:MPlaza.AttributeExpression}],sync:MPlaza.syncCloudflare}),MPlaza.AttributePricings=Backbone.Collection.extend({model:MPlaza.AttributePricing,resetIDs:function(){for(var e=0;e<this.length;e++){this.at(e).resetIDs()}},sync:MPlaza.syncCloudflare}),MPlaza.AttributeSceneAction=Backbone.AssociatedModel.extend({defaults:{name:"",actionTypeID:MPlaza.SceneActionType.ShowHideMesh,sceneElementTypeID:MPlaza.SceneElementType.Mesh,selector:"",propertyName:"",value:"",execOrder:0,deviceTypes:MPlaza.DeviceType.Any},idAttribute:"actionID",initialize:function(){this.get("actionGuid")||this.set("actionGuid",MPlaza.generateUUID())},relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("actionID")},sync:MPlaza.syncCloudflare}),MPlaza.AttributeSceneActions=Backbone.Collection.extend({model:MPlaza.AttributeSceneAction,resetIDs:function(){for(var e=0;e<this.length;e++){this.at(e).resetIDs()}},comparator:function(e){return e.get("execOrder")},getActionByID:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("actionID")===e)return i}return null},getActionByGuid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("actionGuid")===e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.AttributeOptionExtensionField=Backbone.AssociatedModel.extend({defaults:{name:"",dataTypeID:MPlaza.ExtensionFieldDataType.Integer,operationTypeID:MPlaza.ExtensionFieldOperationType.Addition,label:"",formatString:"",value:""},idAttribute:"extensionFieldID",relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},resetIDs:function(){this.unset("extensionFieldID")},sync:MPlaza.syncCloudflare}),MPlaza.AttributeOptionExtensionFields=Backbone.Collection.extend({model:MPlaza.AttributeOptionExtensionField,resetIDs:function(){for(var e=0;e<this.length;e++){this.at(e).resetIDs()}},sync:MPlaza.syncCloudflare}),MPlaza.AttributeOption=Backbone.AssociatedModel.extend({defaults:{optionCode:"",tempImageFileKey:"",imageUrl:"",imageFileObjectID:-1,tempImageFileObjectID:-1,displayOrder:0,name:"",description:"",isDefault:!1,constraintExpression:null,actions:[],optionExtensionFields:[]},idAttribute:"optionID",initialize:function(){this.get("actions").parentModel=this,this.get("optionExtensionFields").parentModel=this,this.get("optionGuid")||this.set("optionGuid",MPlaza.generateUUID())},relations:[{type:Backbone.Many,key:"actions",collectionType:MPlaza.AttributeSceneActions},{type:Backbone.One,key:"constraintExpression",relatedModel:MPlaza.AttributeExpression},{type:Backbone.Many,key:"optionExtensionFields",collectionType:MPlaza.AttributeOptionExtensionFields}],resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("optionID"),this.set("optionGuid",MPlaza.generateUUID()),this.get("actions").resetIDs(),this.get("optionExtensionFields").resetIDs()},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getPricings:function(){var e=[],t=this.getParentModel();return t&&(e=t.getOptionPricings(this.get("optionGuid"))),e},addSimplePricing:function(e,t){var i=this.getParentModel();if(i){var n=new MPlaza.AttributePricing;return this.get("optionID")&&n.set("selectedOptionID",this.get("optionID")),n.set("selectedOptionGuid",this.get("optionGuid")),t&&t instanceof MPlaza.AttributeExpression&&n.set("constraintExpression",t),n.set("price",e),i.get("pricings").add(n),n}return null},addAdvancedPricing:function(e,t){var i=this.getParentModel();if(i&&e&&e instanceof MPlaza.ComposerPricing){var n=new MPlaza.AttributePricing;this.get("optionID")&&n.set("selectedOptionID",this.get("optionID")),n.set("selectedOptionGuid",this.get("optionGuid")),t&&t instanceof MPlaza.AttributeExpression&&n.set("constraintExpression",t),n.set("pricingID",e.get("pricingID")),i.get("pricings").add(n)}},removePricing:function(e){var t=this.getParentModel();t&&t.get("pricings").remove(e)},getActionByID:function(e){return this.get("actions").getActionByID(e)},getExtensionField:function(e){return this.get("extensionFields")&&this.get("extensionFields").filter(t=>t.extensionFieldID===e)[0]},getExtensionFields:function(){return this.get("extensionFields")},getActionByGuid:function(e){return this.get("actions").getActionByGuid(e)},sync:MPlaza.syncCloudflare}),MPlaza.AttributeOptions=Backbone.Collection.extend({model:MPlaza.AttributeOption,comparator:function(e){return e.get("displayOrder")},resetIDs:function(){for(var e=0;e<this.length;e++){this.at(e).resetIDs()}},sync:MPlaza.syncCloudflare}),MPlaza.Attribute=Backbone.AssociatedModel.extend({defaults:{attributeCode:"",attributeTypeID:MPlaza.AttributeType.Options,name:"",description:"",groupID:-1,groupGuid:MPlaza.EmptyUUID,stepID:-1,stepGuid:MPlaza.EmptyUUID,defaultValue:"",displayOrder:0,optionPreviewShapeID:MPlaza.AttributeOptionPreviewShape.Rectangle,options:[],preActions:[],valueActions:[],postActions:[],pricings:[],constraintExpression:null,meshSelector:"",cameraLocationID:null,hideOptionsLabel:!1},idAttribute:"attributeID",initialize:function(){this.get("attributeGuid")||this.set("attributeGuid",MPlaza.generateUUID()),this.get("options").parentModel=this,this.get("preActions").parentModel=this,this.get("valueActions").parentModel=this,this.get("postActions").parentModel=this,this.get("pricings").parentModel=this},relations:[{type:Backbone.Many,key:"options",collectionType:MPlaza.AttributeOptions},{type:Backbone.Many,key:"preActions",collectionType:MPlaza.AttributeSceneActions},{type:Backbone.Many,key:"valueActions",collectionType:MPlaza.AttributeSceneActions},{type:Backbone.Many,key:"postActions",collectionType:MPlaza.AttributeSceneActions},{type:Backbone.Many,key:"pricings",collectionType:MPlaza.AttributePricings},{type:Backbone.One,key:"constraintExpression",relatedModel:MPlaza.AttributeExpression}],getOption:function(e){return this.get("options").findWhere({optionID:e})},getOptionByGuid:function(e){return this.get("options").findWhere({optionGuid:e})},getOptionByCode:function(e){if(!e)return null;for(var t=0;t<this.get("options").length;t++){var i=this.get("options").at(t);if(i.get("optionCode")&&i.get("optionCode")===e)return i}return null},cloneAttribute:function(e){const t=[];for(let e=0;e<this.get("options").length;e++){const i=this.get("options").at(e),n=this.get("pricings").find(e=>e.get("selectedOptionGuid")===i.get("optionGuid"));n&&t.push({optionIndex:this.get("options").indexOf(i),pricingIndex:this.get("pricings").indexOf(n)})}var i=this.clone();void 0!==e&&i.set("name",e);for(var n=0;n<this.get("options").length;n++){var a=this.get("options").at(n),r=i.get("options").at(n);r.resetIDs(),r.set("tempImageFileObjectID",a.get("imageFileObjectID"))}i.resetIDs();for(const{optionIndex:e,pricingIndex:n}of t){const t=i.get("options").at(e),a=i.get("pricings").at(n);a.set("selectedOptionID",t.get("optionID")),a.set("selectedOptionGuid",t.get("optionGuid"))}return i},addClonedOption:function(e,t){var i=e.clone();void 0!==t&&i.set("name",t),i.resetIDs(),i.set("isDefault",!1),i.set("tempImageFileObjectID",e.get("imageFileObjectID")),this.get("options").add(i);const n=this.get("pricings").find(t=>t.get("selectedOptionGuid")===e.get("optionGuid"));if(n){const e=n.clone();e.resetIDs(),e.set("selectedOptionID",i.get("optionID")),e.set("selectedOptionGuid",i.get("optionGuid")),this.get("pricings").add(e)}return i},getOptionPricings:function(e){return this.get("pricings").where({selectedOptionGuid:e})},resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("attributeID"),this.set("attributeGuid",MPlaza.generateUUID()),this.get("options").resetIDs(),this.get("pricings").resetIDs()},sync:MPlaza.syncCloudflare}),MPlaza.Attributes=Backbone.Collection.extend({model:MPlaza.Attribute,getAttribute:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeID")===e)return i}return null},getAttributeByGuid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeGuid")===e)return i}return null},getAttributeByCode:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeCode")===e)return i}return null},comparator:function(e){return e.get("displayOrder")},sync:MPlaza.syncCloudflare}),MPlaza.AttributeGroup=Backbone.AssociatedModel.extend({defaults:{tempImageFileKey:"",imageUrl:"",name:"",displayOrder:0,sceneCameraLocationID:MPlaza.EmptyUUID,meshSelector:"",direction:0,attributesAlwaysOpened:!1},idAttribute:"groupID",initialize:function(){this.get("groupGuid")||this.set("groupGuid",MPlaza.generateUUID())},relations:[],resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("groupID"),this.set("groupGuid",MPlaza.generateUUID())},cloneGroup:function(e){var t=this.clone();return void 0!==e&&t.set("name",e),t.resetIDs(),t},sync:MPlaza.syncCloudflare}),MPlaza.AttributeGroups=Backbone.Collection.extend({model:MPlaza.AttributeGroup,sync:MPlaza.syncCloudflare}),MPlaza.AttributeStep=Backbone.AssociatedModel.extend({defaults:{groupID:-1,groupGuid:null,name:"",displayOrder:0},idAttribute:"stepID",initialize:function(){this.get("stepGuid")||this.set("stepGuid",MPlaza.generateUUID())},relations:[],resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("stepID"),this.set("stepGuid",MPlaza.generateUUID())},cloneStep:function(e){var t=this.clone();return void 0!==e&&t.set("name",e),t.resetIDs(),t},sync:MPlaza.syncCloudflare}),MPlaza.AttributeSteps=Backbone.Collection.extend({model:MPlaza.AttributeStep,comparator:function(e){return e.get("displayOrder")},sync:MPlaza.syncCloudflare}),MPlaza.CompositionCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:null,macroCategoryID:null},relations:[],resetIDs:function(){}}),MPlaza.CompositionCategories=Backbone.Collection.extend({model:MPlaza.CompositionCategory,sync:MPlaza.syncCloudflare}),MPlaza.FrontEndComposition=Backbone.AssociatedModel.extend({defaults:{compositionID:null,name:"",previewImageUrl:""},idAttribute:"compositionID",relations:[],resetIDs:function(){}}),MPlaza.FrontEndCompositions=Backbone.Collection.extend({model:MPlaza.FrontEndComposition,sync:MPlaza.syncCloudflare}),MPlaza.FrontEndCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:null,name:"",composition:MPlaza.FrontEndCompositions},idAttribute:"categoryID",relations:[{type:Backbone.Many,key:"composition",collectionType:MPlaza.FrontEndCompositions}],resetIDs:function(){}}),MPlaza.FrontEndCategories=Backbone.Collection.extend({model:MPlaza.FrontEndCategory,sync:MPlaza.syncCloudflare}),MPlaza.FrontEndMacroCategory=Backbone.AssociatedModel.extend({defaults:{macroCategoryID:null,name:"",category:MPlaza.FrontEndCategories},idAttribute:"macroCategoryID",relations:[{type:Backbone.Many,key:"category",collectionType:MPlaza.FrontEndCategories}],resetIDs:function(){}}),MPlaza.FrontEndMacroCategories=Backbone.Collection.extend({model:MPlaza.FrontEndMacroCategory,sync:MPlaza.syncCloudflare}),MPlaza.TemplateGroup=Backbone.AssociatedModel.extend({defaults:{templateGroupGuid:null,templateGroupID:-1,groupGuid:MPlaza.EmptyUUID,groupID:-1,stepGuid:MPlaza.EmptyUUID,name:"",displayOrder:0,stepID:-1,categories:[],compositions:[],macrocategories:[],macrocategory:[]},idAttribute:"templateGroupGuid",initialize:function(){this.get("templateGroupGuid")||this.set("templateGroupGuid",MPlaza.generateUUID())},relations:[{type:Backbone.Many,key:"categories",collectionType:MPlaza.CompositionCategories},{type:Backbone.Many,key:"macrocategory",collectionType:MPlaza.FrontEndMacroCategories}],resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("templateGroupID"),this.set("templateGroupGuid",MPlaza.generateUUID())},cloneTemplateGroup:function(e){var t=this.clone();return void 0!==e&&t.set("name",e),t.resetIDs(),t},sync:MPlaza.syncCloudflare}),MPlaza.TemplateGroups=Backbone.Collection.extend({model:MPlaza.TemplateGroup,sync:MPlaza.syncCloudflare}),MPlaza.AttributeSteps=Backbone.Collection.extend({model:MPlaza.AttributeStep,comparator:function(e){return e.get("displayOrder")},sync:MPlaza.syncCloudflare}),MPlaza.ExtensionField=Backbone.AssociatedModel.extend({defaults:{fieldID:null,name:"",dataTypeID:MPlaza.ExtensionFieldDataType.Integer,operationTypeID:MPlaza.ExtensionFieldOperationType.None,dataTypeName:"",operationTypeName:"",label:"",formatString:""},idAttribute:"fieldID",relations:[],resetIDs:function(){this.unset("fieldID")},url:function(){return null!==this.id?Zakeke.config.baseApiUrl+"extensionFields/"+this.id:Zakeke.config.baseApiUrl+"extensionFields/"},sync:MPlaza.syncCloudflare}),MPlaza.SellerSetting=Backbone.AssociatedModel.extend({defaults:{sellerID:null,minimumFractionDigits:2,isCompositionRecapEnabled:!1,isCompositionRecapVisibleFromStart:!1,canUserCloseCompositionRecap:!1,hotJarSiteID:null,googleTagManagerID:null},idAttribute:"sellerID",relations:[],resetIDs:function(){this.unset("sellerID")},url:function(){return Zakeke.config.baseApiUrl+"sellerSetting/"},sync:MPlaza.syncCloudflare}),MPlaza.ExtensionFields=Backbone.AssociatedModel.extend({model:MPlaza.ExtensionField,url:function(){return Zakeke.config.baseApiUrl+"extensionFields"},sync:MPlaza.syncCloudflare}),MPlaza.DiffuseConfig=Backbone.AssociatedModel.extend({defaults:{enabled:!0,blendMode:"normal",level:1},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.OpacityConfig=Backbone.AssociatedModel.extend({defaults:{enabled:!0},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.MeshDesignGeneralConfig=Backbone.AssociatedModel.extend({defaults:{showDesign:!0,desktopTextureResolutionWidth:null,desktopTextureResolutionHeight:null,mobileTextureResolutionWidth:null,mobileTextureResolutionHeight:null},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.InnerShadowConfig=Backbone.AssociatedModel.extend({defaults:{enabled:!1,color:"#000000",angle:135,distance:2,size:5},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.OuterShadowConfig=Backbone.AssociatedModel.extend({defaults:{enabled:!1,color:"#000000",angle:135,distance:2,size:5},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.NormalmapConfig=Backbone.AssociatedModel.extend({defaults:{showDesign:!0,showOnDesign:!0,showOnMesh:!0,bias:50,invertR:!1,invertG:!1,preBlurEnabled:!1,preBlur:1,postBlurEnabled:!1,postBlur:1,intensity:.5,bevel:!0},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.MeshDesignConfig=Backbone.AssociatedModel.extend({defaults:{general:null,diffuse:null,opacity:null,normalmap:null,innerShadow:null,outerShadow:null},initialize:function(){this.get("general")&&(this.get("general").parentModel=this),this.get("diffuse")&&(this.get("diffuse").parentModel=this),this.get("opacity")&&(this.get("opacity").parentModel=this),this.get("normalmap")&&(this.get("normalmap").parentModel=this),this.get("innerShadow")&&(this.get("innerShadow").parentModel=this),this.get("outerShadow")&&(this.get("outerShadow").parentModel=this)},relations:[{type:Backbone.One,key:"general",relatedModel:MPlaza.MeshDesignGeneralConfig},{type:Backbone.One,key:"diffuse",relatedModel:MPlaza.DiffuseConfig},{type:Backbone.One,key:"opacity",relatedModel:MPlaza.OpacityConfig},{type:Backbone.One,key:"normalmap",relatedModel:MPlaza.NormalmapConfig},{type:Backbone.One,key:"innerShadow",relatedModel:MPlaza.InnerShadowConfig},{type:Backbone.One,key:"outerShadow",relatedModel:MPlaza.OuterShadowConfig}],getParentModel:function(){return this.parentModel},toString:function(){},getGeneralConfig:function(){return this.get("general")&&this.get("general")instanceof MPlaza.MeshDesignGeneralConfig?this.get("general"):null},getOrCreateGeneralConfig:function(){var e=this.get("general");return e||(e=new MPlaza.MeshDesignGeneralConfig,this.set("general",e)),e},getShowDesign:function(){var e=this.getGeneralConfig();return!e||e.get("showDesign")},setShowDesign:function(e){this.getOrCreateGeneralConfig().set("showDesign",e)},getDesktopTextureResolutionWidth:function(){var e,t=this.getGeneralConfig();return t&&null!==(e=t.get("desktopTextureResolutionWidth"))&&void 0!==e?e:1024},setDesktopTextureResolutionWidth:function(e){this.getOrCreateGeneralConfig().set("desktopTextureResolutionWidth",e)},getDesktopTextureResolutionHeight:function(){var e,t=this.getGeneralConfig();return t&&null!==(e=t.get("desktopTextureResolutionHeight"))&&void 0!==e?e:1024},setDesktopTextureResolutionHeight:function(e){this.getOrCreateGeneralConfig().set("desktopTextureResolutionHeight",e)},getMobileTextureResolutionWidth:function(){var e,t=this.getGeneralConfig();return t&&null!==(e=t.get("mobileTextureResolutionWidth"))&&void 0!==e?e:1024},setMobileTextureResolutionWidth:function(e){this.getOrCreateGeneralConfig().set("mobileTextureResolutionWidth",e)},getMobileTextureResolutionHeight:function(){var e,t=this.getGeneralConfig();return t&&null!==(e=t.get("mobileTextureResolutionHeight"))&&void 0!==e?e:1024},setMobileTextureResolutionHeight:function(e){this.getOrCreateGeneralConfig().set("mobileTextureResolutionHeight",e)},getDiffuseConfig:function(){return this.get("diffuse")&&this.get("diffuse")instanceof MPlaza.DiffuseConfig?this.get("diffuse"):null},getOrCreateDiffuseConfing:function(){var e=this.get("diffuse");return e||(e=new MPlaza.DiffuseConfig,this.set("diffuse",e)),e},getDiffuseEnabled:function(){var e=this.getDiffuseConfig();return!e||e.get("enabled")},setDiffuseEnabled:function(e){this.getOrCreateDiffuseConfing().set("enabled",e)},getDiffuseBlendMode:function(){var e=this.getDiffuseConfig();return e&&e.get("blendMode")?e.get("blendMode"):"normal"},setDiffuseBlendMode:function(e){this.getOrCreateDiffuseConfing().set("blendMode",e)},getDiffuseLevel:function(){var e=this.getDiffuseConfig();return e&&null!=e.get("level")&&null!=e.get("level")?e.get("level"):1},setDiffuseLevel:function(e){this.getOrCreateDiffuseConfing().set("level",e)},getOpacityConfig:function(){return this.get("opacity")&&this.get("opacity")instanceof MPlaza.OpacityConfig?this.get("opacity"):null},getOrCreateOpacityConfig:function(){var e=this.get("opacity");return e||(e=new MPlaza.OpacityConfig,this.set("opacity",e)),e},getOpacityEnabled:function(){var e=this.getOpacityConfig();return!!e&&e.get("enabled")},setOpacityEnabled:function(e){this.getOrCreateOpacityConfig().set("enabled",e)},getNormalmapConfig:function(){return this.get("normalmap")&&this.get("normalmap")instanceof MPlaza.NormalmapConfig?this.get("normalmap"):null},getOrCreateNormalmapConfig:function(){var e=this.get("normalmap");return e||(e=new MPlaza.NormalmapConfig,this.set("normalmap",e)),e},getNormalmapEnabled:function(){var e=this.getNormalmapConfig();return!!e&&e.get("enabled")},setNormalmapEnabled:function(e){this.getOrCreateNormalmapConfig().set("enabled",e)},getInnerShadowConfig:function(){return this.get("innerShadow")&&this.get("innerShadow")instanceof MPlaza.InnerShadowConfig?this.get("innerShadow"):null},getOrCreateInnerShadowConfig:function(){var e=this.get("innerShadow");return e||(e=new MPlaza.InnerShadowConfig,this.set("innerShadow",e)),e},getInnerShadowEnabled:function(){var e=this.getInnerShadowConfig();return!!e&&e.get("enabled")},setInnerShadowEnabled:function(e){this.getOrCreateInnerShadowConfig().set("enabled",e)},getOuterShadowConfig:function(){return this.get("outerShadow")&&this.get("outerShadow")instanceof MPlaza.OuterShadowConfig?this.get("outerShadow"):null},getOrCreateOuterShadowConfig:function(){var e=this.get("outerShadow");return e||(e=new MPlaza.OuterShadowConfig,this.set("outerShadow",e)),e},getOuterShadowEnabled:function(){var e=this.getOuterShadowConfig();return!!e&&e.get("enabled")},setOuterShadowEnabled:function(e){this.getOrCreateOuterShadowConfig().set("enabled",e)},sync:MPlaza.syncCloudflare}),MPlaza.ModelSceneMeshSide=Backbone.AssociatedModel.extend({defaults:{meshID:"",subMeshID:0,sideID:-1,matrix:"",percWidth:1,percHeight:1,uvChannel:0,materialID:null,materialTexture:"",config:null,isResizable:!1},idAttribute:"key",initialize:function(){},relations:[{type:Backbone.One,key:"config",relatedModel:MPlaza.MeshDesignConfig}],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getConfig:function(){return this.get("config")},getOrCreateConfig:function(){var e=this.getConfig();return e||(e=new MPlaza.MeshDesignConfig,this.set("config",e)),e},sync:MPlaza.syncCloudflare}),MPlaza.ModelSceneMeshSides=Backbone.Collection.extend({model:MPlaza.ModelSceneMeshSide,sync:MPlaza.syncCloudflare}),MPlaza.ModelSceneMeshDesignEffect=Backbone.AssociatedModel.extend({defaults:{meshID:"",subMeshID:0,name:"",materialID:null,config:null,isDefault:!1},idAttribute:"effectID",initialize:function(){this.get("effectID")||this.set("effectID",MPlaza.generateUUID())},relations:[{type:Backbone.One,key:"config",relatedModel:MPlaza.MeshDesignConfig}],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getConfig:function(){return this.get("config")},getOrCreateConfig:function(){var e=this.getConfig();return e||(e=new MPlaza.MeshDesignConfig,this.set("config",e)),e},sync:MPlaza.syncCloudflare}),MPlaza.ModelSceneMeshDesignEffects=Backbone.Collection.extend({model:MPlaza.ModelSceneMeshDesignEffect,sync:MPlaza.syncCloudflare}),MPlaza.ModelScene=Backbone.AssociatedModel.extend({defaults:{sceneID:"",isDefault:!1,meshSides:[],meshDesignEffects:[],isResizable:!1},initialize:function(){var e=this;this.get("meshSides").parentModel=this,this.get("meshDesignEffects").parentModel=this,this.get("meshDesignEffects").on("change",function(){e.trigger("change")}),this.get("meshSides").on("change",function(){e.trigger("change")})},relations:[{type:Backbone.Many,key:"meshSides",collectionType:MPlaza.ModelSceneMeshSides},{type:Backbone.Many,key:"meshDesignEffects",collectionType:MPlaza.ModelSceneMeshDesignEffects}],isEffectForMesh:function(e,t,i){var n=this.get("meshDesignEffects");if(n)for(var a=0;a<n.length;a++){var r=n.at(a);if(r.get("meshID")===e&&r.get("subMeshID")===t&&r.get("effectID")===i)return!0}return!1},getMeshDesignEffect:function(e){var t=this.get("meshDesignEffects");if(t)for(var i=0;i<t.length;i++){var n=t.at(i);if(n.get("effectID")===e)return n}return null},getMeshDesignEffects:function(e,t){var i=this.get("meshDesignEffects");if(i)for(var n=0;n<i.length;n++){var a=i.at(n);if(a.get("meshID")==e&&a.get("subMeshID")==t)return a}return null},getDefaultDesignEffect:function(e,t){var i=this.get("meshDesignEffects");if(i)for(var n=0;n<i.length;n++){var a=i.at(n);if(a.get("meshID")==e&&a.get("subMeshID")==t&&a.get("isDefault"))return a}return null},sync:MPlaza.syncCloudflare}),MPlaza.ModelScenes=Backbone.Collection.extend({model:MPlaza.ModelScene,sync:MPlaza.syncCloudflare}),MPlaza.AttributeSelectionScript=function(){this.attributeID=-1,this.selectedValue="",this.actions=[]},MPlaza.DesignPrice=Backbone.AssociatedModel.extend({defaults:{qtyFrom:0,qtyTo:null,price:0,firstColorPrice:null},idAttribute:"priceID",initialize:function(){},relations:[],getPricingID:function(){return this.collection&&this.collection.getPricingID?this.collection.getPricingID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignPrices=Backbone.Collection.extend({model:MPlaza.DesignPrice,getPricingID:function(){return this.parentModel&&this.parentModel.getPricingID?this.parentModel.getPricingID():null},sync:MPlaza.syncCloudflare}),MPlaza.SetupPrice=Backbone.AssociatedModel.extend({defaults:{qtyFrom:0,qtyTo:null,price:0,firstColorPrice:null},idAttribute:"priceID",initialize:function(){},relations:[],getPricingID:function(){return this.collection&&this.collection.getPricingID?this.collection.getPricingID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.SetupPrices=Backbone.Collection.extend({model:MPlaza.SetupPrice,getPricingID:function(){return this.parentModel&&this.parentModel.getPricingID?this.parentModel.getPricingID():null},sync:MPlaza.syncCloudflare}),MPlaza.Pricing=Backbone.AssociatedModel.extend({defaults:{setupPriceTypeID:MPlaza.PricingType.Global,designPriceTypeID:MPlaza.PricingType.Global,setupPrices:[],designPrices:[]},idAttribute:"pricingID",initialize:function(){var e=this;this.get("setupPrices").parentModel=this,this.get("designPrices").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("setupPrices").on("add",function(){e._fireEvent("change")}),this.get("setupPrices").on("remove",function(){e._fireEvent("change")}),this.get("setupPrices").on("change",function(){e._fireEvent("change")}),this.get("designPrices").on("add",function(){e._fireEvent("change")}),this.get("designPrices").on("remove",function(){e._fireEvent("change")}),this.get("designPrices").on("change",function(){e._fireEvent("change")})},_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},relations:[{type:Backbone.Many,key:"setupPrices",collectionType:MPlaza.SetupPrices},{type:Backbone.Many,key:"designPrices",collectionType:MPlaza.DesignPrices}],url:function(){var e=Zakeke.config.baseApiUrl+"pricings";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},getPricingID:function(){return this.get("pricingID")},toString:function(){},getSetupPriceForQuantity:function(e){for(var t=0;t<this.get("setupPrices").length;t++){var i=this.get("setupPrices").at(t);if(i.get("qtyFrom")<=e&&(!i.get("qtyTo")||e<i.get("qtyTo")))return i}return null},getDesignPriceForQuantity:function(e){for(var t=0;t<this.get("designPrices").length;t++){var i=this.get("designPrices").at(t);if(i.get("qtyFrom")<=e&&(!i.get("qtyTo")||e<i.get("qtyTo")))return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.Pricings=Backbone.Collection.extend({model:MPlaza.Pricing,url:function(){return Zakeke.config.baseApiUrl+"pricings"},getPricing:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("pricingID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameterValue=Backbone.AssociatedModel.extend({defaults:{},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{name:this.get("name"),value:this.get("value")}},copyAttributes:function(e){this.set("name",e.get("name")),this.set("value",e.get("value"))},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameterValues=Backbone.Collection.extend({model:MPlaza.ImageEffectParameterValue,getValue:function(e){for(var t=0;t<this.length;t++)if(this.at(t).get("name").toLowerCase()===e.toLowerCase())return this.at(t).get("value")},getValueNumber:function(e){var t=this.getValue(e);if(t)return Number(t)},getValueInt:function(e){var t=this.getValue(e);if(t)return parseInt(t)},getValueFloat:function(e){var t=this.getValue(e);if(t)return parseFloat(t)},getValueBoolean:function(e){var t=this.getValue(e);if(t)return"true"===t.toLowerCase()},sync:MPlaza.syncCloudflare}),MPlaza.DesignEffect=Backbone.AssociatedModel.extend({defaults:{blendMode:"normal",enhancedBlendMode:!1,opacity:1,textColor:null,imageEffectTypeName:null,imageEffectParameterValues:[]},initialize:function(){this.get("imageEffectParameterValues").parentModel=this},relations:[{type:Backbone.Many,key:"imageEffectParameterValues",collectionType:MPlaza.ImageEffectParameterValues}],sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameterOption=Backbone.AssociatedModel.extend({defaults:{},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{nameKey:this.get("nameKey"),value:this.get("value")}},copyAttributes:function(e){this.set("nameKey",e.get("nameKey")),this.set("value",e.get("value"))},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameterOptions=Backbone.Collection.extend({model:MPlaza.ImageEffectParameterOption,sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameter=Backbone.AssociatedModel.extend({defaults:{name:"",options:[]},initialize:function(){},relations:[{type:Backbone.Many,key:"options",collectionType:MPlaza.ImageEffectParameterOptions}],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{name:this.get("name"),labelKey:this.get("labelKey"),type:this.get("type"),min:this.get("min"),max:this.get("max"),step:this.get("step"),required:this.get("required"),defaultValue:this.get("defaultValue"),displayOrder:this.get("displayOrder"),options:this.get("options").toJSON()}},copyAttributes:function(e){this.set("name",e.get("name")),this.set("labelKey",e.get("labelKey")),this.set("type",e.get("type")),this.set("min",e.get("min")),this.set("max",e.get("max")),this.set("step",e.get("step")),this.set("required",e.get("required")),this.set("defaultValue",e.get("defaultValue")),this.set("displayOrder",e.get("displayOrder"));for(var t=[],i=0;i<e.get("options").length;i++){var n=e.get("options").at(i),a=new MPlaza.ImageEffectParameterOption;a.copyAttributes(n),t.push(a)}this.set("options",t)},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameters=Backbone.Collection.extend({model:MPlaza.ImageEffectParameter,sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectType=Backbone.AssociatedModel.extend({defaults:{name:"",parameters:[]},idAttribute:"imageEffectTypeID",initialize:function(){this.get("parameters").parentModel=this},relations:[{type:Backbone.Many,key:"parameters",collectionType:MPlaza.ImageEffectParameters}],url:function(){var e=Zakeke.config.baseApiUrl+"imageeffects/types";return void 0!==this.id&&null!==this.id&&this.id>0&&(e=e+"/"+this.id),e},getImageEffectTypeID:function(){return this.get("imageEffectTypeID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectTypes=Backbone.Collection.extend({model:MPlaza.ImageEffectType,url:function(){return Zakeke.config.baseApiUrl+"imageeffects/types"},sync:MPlaza.syncCloudflare}),MPlaza.PrintTypeFont=Backbone.AssociatedModel.extend({defaults:{printTypeID:-1,fontFamilyID:-1,fontFamilyName:null},idAttribute:"fontFamilyID",initialize:function(){},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.PrintTypeFonts=Backbone.Collection.extend({model:MPlaza.PrintTypeFont,getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getFont:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("fontFamilyID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.PartPrintTypeRestriction=Backbone.AssociatedModel.extend({defaults:{disableTextColors:null,textColors:null,disableSellerImages:null,disableUserImages:null,useImagesFixedSize:null,canAddText:null,canChangeSvgColors:null,canUseImageFilters:null,uploadRestrictions:null,canIgnoreDPIWarning:null,canPreviewDesignsPDF:null,useCustomFonts:null,defaultFontFamilyID:null,fonts:[],showLayerButtons:null,showDuplicateButton:null,showFlipButtons:null,showImageProvider:null,canUseTextArt:null,imageEditingToolSettingsToExclude:null,imageInsertScalingUpload:null,imageInsertScalingCliparts:null,allowTextStroke:null,minTextStrokeWidth:null,maxTextStrokeWidth:null,canStretchImages:null},idAttribute:"partPrintTypeRestrictionID",initialize:function(){var e=this;this.get("fonts").url=function(){return e.url()+"/fonts"},this.get("fonts").parentModel=this},relations:[{type:Backbone.Many,key:"fonts",collectionType:MPlaza.PrintTypeFonts}],url:function(){var e=Zakeke.config.baseApiUrl+"partPrintTypeRestrictions";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getPartPrintTypeRestrictionID:function(){return this.get("partPrintTypeRestrictionID")},getParentModel:function(){return this.parentModel?this.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.PartPrintTypeOutputSettings=Backbone.AssociatedModel.extend({defaults:{width:0,height:0,partPrintTypeOutputSettingsID:-1,rows:0,columns:0,marginH:0,marginV:0,rotation:0,flowDirectionH:1,flowDirectionV:1,flowDirectionPriority:1},idAttribute:"partPrintTypeOutputSettingsID",sync:MPlaza.syncCloudflare}),MPlaza.PartPrintType=Backbone.AssociatedModel.extend({defaults:{isEnabled:!0,pricingID:-1,patID:MPlaza.PricingApplicationType.Global,partPrintTypeRestrictionID:null,dpi:null,restrictions:null,outputSettings:null},idAttribute:"printTypeID",initialize:function(){this.get("restrictions")&&(this.get("restrictions").parentModel=this),this.get("outputSettings")&&(this.get("outputSettings").parentModel=this)},relations:[{type:Backbone.One,key:"restrictions",relatedModel:MPlaza.PartPrintTypeRestriction},{type:Backbone.One,key:"outputSettings",relatedModel:MPlaza.PartPrintTypeOutputSettings}],url:function(){var e=Zakeke.config.baseApiUrl+"partprintTypes";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getPrintTypeID:function(){return this.get("printTypeID")},toString:function(){},setRestrictions:function(e){this.set("restrictions",e),e&&(this.get("restrictions").parentModel=this)},setOutputSettings:function(e){this.set("outputSettings",e),e&&(this.get("outputSettings").parentModel=this)},sync:MPlaza.syncCloudflare}),MPlaza.PartPrintTypes=Backbone.Collection.extend({model:MPlaza.PartPrintType,url:function(){return Zakeke.config.baseApiUrl+"partprinttypes"},getPrintType:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.AreaLayer=Backbone.AssociatedModel.extend({defaults:{name:"",json:"",svg:"",displayOrder:0,isVisibleInCanvas:!0,isVisibleInCart:!0,isVisibleInOutput:!0,showLabel:!0,isClipMask:!1},idAttribute:"layerID",initialize:function(){this.get("layerID")||this.set("layerID",MPlaza.generateUUID())},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.collection&&this.collection.getColorID?this.collection.getColorID():null},getSideID:function(){return this.collection&&this.collection.getSideID?this.collection.getSideID():null},getAreaID:function(){return this.collection&&this.collection.getAreaID?this.collection.getAreaID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getArea:function(){return this.getParentModel()},getSide:function(){var e=this.getArea();return e&&e instanceof MPlaza.Area?e.getSide():null},getColor:function(){var e=this.getSide();return e&&e instanceof MPlaza.Side?e.getParentModel():null},getModel:function(){var e=this.getColor();return e&&e instanceof MPlaza.Color?e.getParentModel():null},sync:MPlaza.syncCloudflare}),MPlaza.AreaLayers=Backbone.Collection.extend({model:MPlaza.AreaLayer,getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID?this.parentModel.getColorID():null},getSideID:function(){return this.parentModel&&this.parentModel.getSideID?this.parentModel.getSideID():null},getAreaID:function(){return this.parentModel&&this.parentModel.getAreaID?this.parentModel.getAreaID():null},sync:MPlaza.syncCloudflare}),MPlaza.AreaTextConstraints=Backbone.AssociatedModel.extend({defaults:{maxNumItems:-1,maxNumChars:-1,fitArea:!1,canMove:!0,canResize:!0,canRotate:!0,fixedDirection:0},initialize:function(){},url:function(){return""},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.AreaTemplateFile=Backbone.AssociatedModel.extend({defaults:{fileID:"",fileUrl:""},initialize:function(){},url:function(){return""},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.Area=Backbone.AssociatedModel.extend({defaults:{guid:"",name:"",path:"",pathSVG:"",boundsX:0,boundsY:0,boundsWidth:0,boundsHeight:0,clipOut:!0,screenPPI:0,textConstraints:null,templateFile:null,printTypes:[],layers:[]},idAttribute:"areaID",relations:[{type:Backbone.One,key:"textConstraints",relatedModel:MPlaza.AreaTextConstraints},{type:Backbone.One,key:"templateFile",relatedModel:MPlaza.AreaTemplateFile},{type:Backbone.Many,key:"printTypes",collectionType:MPlaza.PartPrintTypes},{type:Backbone.Many,key:"layers",collectionType:MPlaza.AreaLayers}],initialize:function(){this.get("guid")||this.set("guid",MPlaza.generateUUID()),this.get("textConstraints")&&(this.get("textConstraints").parentModel=this),this.get("templateFile")&&(this.get("templateFile").parentModel=this),this.get("layers")&&(this.get("layers").parentModel=this)},url:function(){var e=Zakeke.config.baseApiUrl+"areas";return this.collection&&this.collection.url&&(e=this.collection.url()),this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.collection&&this.collection.getColorID?this.collection.getColorID():null},getSideID:function(){return this.collection&&this.collection.getSideID?this.collection.getSideID():null},getAreaID:function(){return this.get("areaID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getPrintType:function(e){for(var t=0;t<this.get("printTypes").length;t++){var i=this.get("printTypes").at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},getSide:function(){return this.getParentModel()},getColor:function(){var e=this.getParentModel();return e&&e instanceof MPlaza.Side?e.getParentModel():null},getModel:function(){var e=this.getParentModel();if(e&&e instanceof MPlaza.Side){var t=e.getParentModel();if(t&&t instanceof MPlaza.Color)return t.getParentModel()}return null},sync:MPlaza.syncCloudflare}),MPlaza.Areas=Backbone.Collection.extend({model:MPlaza.Area,getArea:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("guid")==e)return i}return null},getAreaByID:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("areaID")==e)return i}return null},getMaxArea:function(){for(var e=0,t=null,i=0;i<this.length;i++){var n=this.at(i),a=new paper.Rectangle(n.get("boundsX"),n.get("boundsY"),n.get("boundsWidth"),n.get("boundsHeight")).area;e<a&&(e=a,t=n)}return t},url:function(){return Zakeke.config.baseApiUrl+"areas"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID?this.parentModel.getColorID():null},getSideID:function(){return this.parentModel&&this.parentModel.getSideID?this.parentModel.getSideID():null},sync:MPlaza.syncCloudflare}),MPlaza.Side=Backbone.AssociatedModel.extend({defaults:{name:"",code:"",ppcm:0,tempImageFileKey:"",imageUrl:"",colorable:!1,sortOrder:null,isDefault:!1,printTypes:[],areas:[],cameraLocationID:null},idAttribute:"sideID",initialize:function(){var e=this;this.get("areas").url=function(){return e.url()+"/areas"},this.get("areas").parentModel=this},relations:[{type:Backbone.Many,key:"areas",collectionType:MPlaza.Areas},{type:Backbone.Many,key:"printTypes",collectionType:MPlaza.PartPrintTypes}],url:function(){var e=Zakeke.config.baseApiUrl+"sides";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.collection&&this.collection.getColorID?this.collection.getColorID():null},getSideID:function(){return this.get("sideID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},findAreaByID:function(e){var t=this.get("areas");return t?t.findWhere({areaID:e}):null},findAreaByGuid:function(e){var t=this.get("areas");return t?t.findWhere({guid:e}):null},getPrintType:function(e){for(var t=0;t<this.get("printTypes").length;t++){var i=this.get("printTypes").at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},toString:function(){},getColor:function(){return this.getParentModel()},getModel:function(){var e=this.getParentModel();return e&&e instanceof MPlaza.Color?e.getParentModel():null},sync:MPlaza.syncCloudflare}),MPlaza.Sides=Backbone.Collection.extend({model:MPlaza.Side,url:function(){return Zakeke.config.baseApiUrl+"sides"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID?this.parentModel.getColorID():null},getSide:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("sideID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.CompliantColor=Backbone.AssociatedModel.extend({defaults:{},idAttribute:"colorCode",url:function(){var e=Zakeke.config.baseApiUrl+"compliantColors";return this.collection&&this.collection.url&&(e=this.collection.url()),this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){if(this.collection&&this.collection.getModelID)return this.collection.getModelID()},getColorID:function(){if(this.collection&&this.collection.getColorID)return this.collection.getColorID()},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.CompliantColors=Backbone.Collection.extend({model:MPlaza.CompliantColor,getCompliantColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorCode")==e)return i}return null},url:function(){return Zakeke.config.baseApiUrl+"compliantColors"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID()?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID()?this.parentModel.getColorID():null},sync:MPlaza.syncCloudflare}),MPlaza.Size=Backbone.AssociatedModel.extend({defaults:{name:"",genre:""},idAttribute:"sizeID",url:function(){var e=Zakeke.config.baseApiUrl+"sizes";return this.collection&&this.collection.url&&(e=this.collection.url()),this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){if(this.collection&&this.collection.getModelID)return this.collection.getModelID()},getColorID:function(){if(this.collection&&this.collection.getColorID)return this.collection.getColorID()},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.Sizes=Backbone.Collection.extend({model:MPlaza.Size,getSize:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("sizeID")==e)return i}return null},url:function(){return Zakeke.config.baseApiUrl+"sizes"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID?this.parentModel.getColorID():null},sync:MPlaza.syncCloudflare}),MPlaza.Color=Backbone.AssociatedModel.extend({defaults:{name:"",colorCode:"",colorHexCode:"",code:"",colorProviderCode:"",imageUrl:"",showSideImage:!1,position:0,sizes:[],compliantColors:[],printTypes:[],sides:[]},idAttribute:"colorID",initialize:function(){var e=this;this.get("sizes").url=function(){return e.url()+"/sizes"},this.get("compliantColors").url=function(){return e.url()+"/compliantColors"},this.get("sides").url=function(){return e.url()+"/sides"},this.get("sizes").parentModel=this,this.get("compliantColors").parentModel=this,this.get("sides").parentModel=this},relations:[{type:Backbone.Many,key:"sizes",collectionType:MPlaza.Sizes},{type:Backbone.Many,key:"compliantColors",collectionType:MPlaza.CompliantColors},{type:Backbone.Many,key:"sides",collectionType:MPlaza.Sides},{type:Backbone.Many,key:"printTypes",collectionType:MPlaza.PartPrintTypes}],url:function(){var e=Zakeke.config.baseApiUrl+"colors";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.get("colorID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},findSize:function(e){var t=this.get("sizes");return t?t.findWhere({sizeID:e}):null},findCompliantColor:function(e){return this.get("compliantColors")?sizes.findWhere({colorCode:e}):null},findSide:function(e){var t=this.get("sides");return t?t.findWhere({sideID:e}):null},getAreaWithGuid:function(e){for(var t=this.get("sides"),i=0;i<t.length;i++){var n=t.at(i).getArea(e);if(n)return n}return null},getPrintType:function(e){for(var t=0;t<this.get("printTypes").length;t++){var i=this.get("printTypes").at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},toString:function(){},getModel:function(){return this.getParentModel()},sync:MPlaza.syncCloudflare}),MPlaza.Colors=Backbone.Collection.extend({model:MPlaza.Color,url:function(){return Zakeke.config.baseApiUrl+"colors"},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},comparator:function(e){return e.get("position")},sync:MPlaza.syncCloudflare}),MPlaza.PrintType=Backbone.AssociatedModel.extend({defaults:{name:"",dpi:300,printTypeDPI:0,priceDeltaPerc:0,priceDeltaValue:0,price:0,textBasePrice:0,imageBasePrice:0,pricingID:-1,patID:MPlaza.PricingApplicationType.Global,disableTextColors:null,disableImageColors:null,disableSellerImages:null,disableUserImages:null,useImagesFixedSize:null,textColors:null,imageColors:null,canAddText:null,canChangeSvgColors:null,canUseImageFilters:null,uploadRestrictions:null,canIgnoreDPIWarning:null,useCustomFonts:null,printTypeFonts:[],printTypeDefaultFontFamilyID:null,fonts:[],defaultFontFamilyID:null,pantoneEnabled:!1,canPreviewDesignsPDF:null,outputTypeID:1,outputSettings:null,showLayerButtons:null,showDuplicateButton:null,showFlipButtons:null,showImageProvider:null,canUseTextArt:null,imageEditingToolSettingsToExclude:null,printTypeRestrictionsID:null,printTypeRestrictions:null,previewDesignEffect:null,outputDesignEffect:null,maxColors:null,paletteID:null,paletteColors:[],splitColorFiles:!1,layeredPdf:!1},idAttribute:"printTypeID",initialize:function(){var e=this;this.get("printTypeFonts").url=function(){return e.url()+"/printtypefonts"},this.get("fonts").url=function(){return e.url()+"/fonts"},this.get("printTypeFonts").parentModel=this,this.get("fonts").parentModel=this,this.get("printTypeRestrictions")&&(this.get("printTypeRestrictions").parentModel=this)},relations:[{type:Backbone.One,key:"printTypeRestrictions",relatedModel:MPlaza.PartPrintTypeRestriction},{type:Backbone.Many,key:"printTypeFonts",collectionType:MPlaza.PrintTypeFonts},{type:Backbone.Many,key:"fonts",collectionType:MPlaza.PrintTypeFonts},{type:Backbone.One,key:"outputSettings",relatedModel:MPlaza.PartPrintTypeOutputSettings},{type:Backbone.One,key:"previewDesignEffect",relatedModel:MPlaza.DesignEffect},{type:Backbone.One,key:"outputDesignEffect",relatedModel:MPlaza.DesignEffect}],url:function(){var e=Zakeke.config.baseApiUrl+"printTypes";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getPrintTypeID:function(){return this.get("printTypeID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},setOutputSettings:function(e){this.set("outputSettings",e),e&&(this.get("outputSettings").parentModel=this)},sync:MPlaza.syncCloudflare}),MPlaza.PrintTypes=Backbone.Collection.extend({model:MPlaza.PrintType,url:function(){return Zakeke.config.baseApiUrl+"printtypes"},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getPrintType:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.OptionsItem=Backbone.AssociatedModel.extend({defaults:{optionId:-1,modelID:-1,colorID:-1,sideID:null,optionsData:{}},idAttribute:"optionId",initialize:function(){},relations:[],getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.get("colorID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getModel:function(){return this.getParentModel()},sync:MPlaza.syncCloudflare}),MPlaza.ModelOptions=Backbone.Collection.extend({model:MPlaza.OptionsItem,url:function(){return Zakeke.config.baseApiUrl+"options"},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},sync:MPlaza.syncCloudflare}),MPlaza.PreviewColor=Backbone.AssociatedModel.extend({defaults:{color:"",hasTexture:!1,textureUrl:"",tempTextureFileKey:"",isCustomTexture:!1,refractionMode:null,reflectivity:null,opacity:null,opacityAffectCustomization:null,textureWidth:null,textureHeight:null,itemsPositionX:null,itemsPositionY:null,itemsScaleX:null,itemsScaleY:null},idAttribute:"colorID",initialize:function(){},url:function(){var e=Zakeke.config.baseApiUrl+"previewcolors";return this.collection&&this.collection.url&&(e=this.collection.url()),this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getPreviewModelID:function(){return this.collection&&this.collection.getPreviewModelID?this.collection.getPreviewModelID():null},getPartID:function(){return this.collection&&this.collection.getPartID?this.collection.getPartID():null},getColorID:function(){return this.get("colorID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.PreviewColors=Backbone.Collection.extend({model:MPlaza.PreviewColor,getPreviewColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},url:function(){return Zakeke.config.baseApiUrl+"previewcolors"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getPreviewModelID:function(){return this.parentModel&&this.parentModel.getPreviewModelID?this.parentModel.getPreviewModelID():null},getPartID:function(){return this.parentModel&&this.parentModel.getPartID?this.parentModel.getPartID():null},sync:MPlaza.syncCloudflare}),MPlaza.PreviewPart=Backbone.AssociatedModel.extend({defaults:{materialIndex:-1,sideID:-1,color:"",hasTexture:!1,textureWidth:0,textureHeight:0,textureUrl:"",tempTextureFileKey:"",reflectivity:0,opacity:1,opacityAffectCustomization:!0,itemsPositionX:0,itemsPositionY:0,itemsScaleX:0,itemsScaleY:0,refractionMode:!1,colors:[]},idAttribute:"partID",initialize:function(){var e=this;this.get("colors").url=function(){return e.url()+"/previewcolors"},this.get("colors").parentModel=this},relations:[{type:Backbone.Many,key:"colors",collectionType:MPlaza.PreviewColors}],url:function(){var e=Zakeke.config.baseApiUrl+"previewparts";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getPreviewModelID:function(){return this.collection&&this.collection.getPreviewModelID?this.collection.getPreviewModelID():null},getPartID:function(){return this.get("partID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},findColor:function(e){var t=this.get("colors");return t?t.findWhere({colorID:e}):null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.PreviewParts=Backbone.Collection.extend({model:MPlaza.PreviewPart,url:function(){return Zakeke.config.baseApiUrl+"previewparts"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getPreviewModelID:function(){return this.parentModel&&this.parentModel.getPreviewModelID?this.parentModel.getPreviewModelID():null},getPreviewPart:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("partID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.PreviewModel=Backbone.AssociatedModel.extend({defaults:{backface:!1,scale:1,tempModel3DFileKey:"",model3DUrl:"",parts:[]},idAttribute:"modelID",initialize:function(){var e=this;this.get("parts").url=function(){return e.url()+"/previewparts"},this.get("parts").parentModel=this},relations:[{type:Backbone.Many,key:"parts",collectionType:MPlaza.PreviewParts}],url:function(){var e=Zakeke.config.baseApiUrl+"previewmodels";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getPreviewModelID:function(){return this.get("modelID")},getParentModel:function(){return this.parentModel?this.parentModel:null},findPart:function(e){var t=this.get("parts");return t?t.findWhere({partID:e}):null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.QuantityRule=Backbone.AssociatedModel.extend({defaults:{minQuantity:null,maxQuantity:null,step:null},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptionMaterialAction=Backbone.AssociatedModel.extend({defaults:{actionGuid:"",meshID:""},initialize:function(){},relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptionMaterialActions=Backbone.Collection.extend({model:MPlaza.VariantOptionMaterialAction,getActionForMesh(e){for(var t=0;t<this.length;t++)if(this.at(t).get("meshID")===e)return this.at(t);return null},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptionMaterial=Backbone.AssociatedModel.extend({defaults:{optionMaterialID:"",variableMaterialID:"",actions:[]},initialize:function(){this.get("actions").parentModel=this},relations:[{type:Backbone.Many,key:"actions",collectionType:MPlaza.VariantOptionMaterialActions}],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptionMaterials=Backbone.Collection.extend({model:MPlaza.VariantOptionMaterial,sync:MPlaza.syncCloudflare}),MPlaza.VariantOption=Backbone.AssociatedModel.extend({defaults:{variantID:"",optionGuid:"",materials:[],meshes:[]},initialize:function(){this.get("materials").parentModel=this},relations:[{type:Backbone.Many,key:"materials",collectionType:MPlaza.VariantOptionMaterials}],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptions=Backbone.Collection.extend({model:MPlaza.VariantOption,getVariantOption(e){for(var t=0;t<this.length;t++)if(this.at(t).get("variantID")===e)return this.at(t);return null},sync:MPlaza.syncCloudflare}),MPlaza.VariableMaterial=Backbone.AssociatedModel.extend({defaults:{materialID:"",meshes:[]},initialize:function(){},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.VariableMaterials=Backbone.Collection.extend({model:MPlaza.VariableMaterial,getVariableMaterial(e){for(var t=0;t<this.length;t++)if(this.at(t).get("materialID")===e)return this.at(t);return null},sync:MPlaza.syncCloudflare}),MPlaza.VariantsAttributeOptions=Backbone.AssociatedModel.extend({defaults:{attributeGuid:"",variableMaterials:[],variantOptions:[]},initialize:function(){this.get("variableMaterials").parentModel=this,this.get("variantOptions").parentModel=this},relations:[{type:Backbone.Many,key:"variableMaterials",collectionType:MPlaza.VariableMaterials},{type:Backbone.Many,key:"variantOptions",collectionType:MPlaza.VariantOptions}],getParentModel:function(){return this.parentModel?this.parentModel:null},getOptionsMaterialIDs:function(){for(var e=[],t=0;t<this.get("variantOptions").length;t++)for(var i=this.get("variantOptions").at(t),n=0;n<i.get("materials").length;n++){var a=i.get("materials").at(n).get("optionMaterialID");-1===e.indexOf(a)&&e.push(a)}return e},setVariableMaterial:function(e,t){var i=this.get("variableMaterials").getVariableMaterial(e);i||((i=new MPlaza.VariableMaterial).set("materialID",e),this.get("variableMaterials").push(i)),i.set("meshes",t)},removeVariableMaterial:function(e){var t=this.get("variableMaterials").getVariableMaterial(e);t&&this.get("variableMaterials").remove(t)},getVariantOption:function(e){return this.get("variantOptions").getVariantOption(e)},sync:MPlaza.syncCloudflare}),MPlaza.Preview3D=Backbone.AssociatedModel.extend({defaults:{variantsAttributeOptions:null},initialize:function(){this.get("variantsAttributeOptions")&&(this.get("variantsAttributeOptions").parentModel=this)},relations:[{type:Backbone.One,key:"variantsAttributeOptions",relatedModel:MPlaza.VariantsAttributeOptions}],getParentModel:function(){return this.parentModel?this.parentModel:null},getVariantsAttributeOptions:function(){return this.get("variantsAttributeOptions")},getOrCreateVariantsAttributeOptions:function(){var e=this.getVariantsAttributeOptions();return e||(e=new MPlaza.VariantsAttributeOptions,this.set("variantsAttributeOptions",e)),e},sync:MPlaza.syncCloudflare}),MPlaza.Model=Backbone.AssociatedModel.extend({defaults:{name:"",description:"",code:"",statusID:1,tempSmallImageFileKey:"",smallImageUrl:"",tempLargeImageFileKey:"",largeImageUrl:"",price:0,variantIconCode:"",variantTypeName:"",pricingModelID:MPlaza.PricingModel.Simple,defaultDesignTemplateID:-1,loadFirstDesignTemplate:!1,showTemplateSelection:!1,printTypes:[],colors:[],options:[],preview3D:null,previewModel:null,pricings:[],composerPricings:[],scenes:[],attributeGroups:[],templateGroups:[],attributeSteps:[],attributes:[],attributeSelectionColors:[],backgroundColorRules:null,areaBackgroundRules:null,quoteRule:null,quantityRule:null,hasAdditionalFeeOnImagesProvider:!1,isShowSecondScreenEnabled:!1,environment:1},idAttribute:"modelID",_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},removeEventListener:function(e){this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&delete this._eventListeners[e]},initialize:function(){var e=this;this.get("printTypes").url=function(){return e.url()+"/printTypes"},this.get("colors").url=function(){return e.url()+"/colors"},this.get("options").url=function(){return e.url()+"/options"},this.get("printTypes").parentModel=this,this.get("colors").parentModel=this,this.get("options").parentModel=this,this.get("preview3D")&&(this.get("preview3D").parentModel=this),this.get("previewModel")&&(this.get("previewModel").parentModel=this),this.get("scenes").parentModel=this,this.get("attributeGroups").parentModel=this,this.get("templateGroups").parentModel=this,this.get("attributeSteps").parentModel=this,this.get("attributes").parentModel=this,this.get("attributeSelectionColors").parentModel=this,this.on("change",function(e){e.trigger("change")}),this.get("printTypes").on("change",function(){e._fireEvent("change")}),this.get("colors").on("change",function(){e._fireEvent("change")}),this.get("options").on("change",function(){e._fireEvent("change")}),this.get("scenes").on("change",function(){e._fireEvent("change")}),this.get("attributeGroups").on("change",function(){e._fireEvent("change")}),this.get("templateGroups").on("change",function(){e._fireEvent("change")}),this.get("attributeSteps").on("change",function(){e._fireEvent("change")}),this.get("attributes").on("change",function(){e._fireEvent("change")}),this.get("attributeSelectionColors").on("change",function(){e._fireEvent("change")}),this.get("pricings").on("change",function(){e._fireEvent("change")})},relations:[{type:Backbone.One,key:"preview3D",relatedModel:MPlaza.Preview3D},{type:Backbone.One,key:"previewModel",relatedModel:MPlaza.PreviewModel},{type:Backbone.One,key:"quantityRule",relatedModel:MPlaza.QuantityRule},{type:Backbone.Many,key:"printTypes",collectionType:MPlaza.PrintTypes},{type:Backbone.Many,key:"options",collectionType:MPlaza.ModelOptions},{type:Backbone.Many,key:"colors",collectionType:MPlaza.Colors},{type:Backbone.Many,key:"pricings",collectionType:MPlaza.Pricings},{type:Backbone.Many,key:"composerPricings",collectionType:MPlaza.ComposerPricings},{type:Backbone.Many,key:"scenes",collectionType:MPlaza.ModelScenes},{type:Backbone.Many,key:"attributeGroups",collectionType:MPlaza.AttributeGroups},{type:Backbone.Many,key:"templateGroups",collectionType:MPlaza.TemplateGroups},{type:Backbone.Many,key:"attributeSteps",collectionType:MPlaza.AttributeSteps},{type:Backbone.Many,key:"attributes",collectionType:MPlaza.Attributes},{type:Backbone.Many,key:"attributeSelectionColors",collectionType:MPlaza.AttributeSelectionColors}],url:function(){var e=Zakeke.config.baseApiUrl+"models";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){return this.get("modelID")},toString:function(){},getPreview3D:function(){return this.get("preview3D")},getOrCreatePreview3D:function(){var e=this.getPreview3D();return e||(e=new MPlaza.Preview3D,this.set("preview3D",e)),e},getModelPriceDeltaPerc:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("priceDeltaPerc")}return 0},getModelPriceDeltaValue:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("priceDeltaValue")}return 0},getModelPrice:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("price")}return 0},getModelTextBasePrice:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("textBasePrice")}return 0},getModelImageBasePrice:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("imageBasePrice")}return 0},getPrintType:function(e){var t=this.get("printTypes");return t?t.getPrintType(e):null},getDefaultSceneID:function(){for(var e=0;e<this.get("scenes").length;e++){var t=this.get("scenes").at(e);if(t.get("isDefault"))return t.get("sceneID")}return null},getAttributesByGroupID:function(e){for(var t=[],i=0;i<this.get("attributes").length;i++){var n=this.get("attributes").at(i);n.get("groupID")==e&&t.push(n)}return t},getAttributesWithoutGroup:function(){for(var e=[],t=0;t<this.get("attributes").length;t++){var i=this.get("attributes").at(t);i.get("groupID")<=0&&e.push(i)}return e},getTemplateGroupsWithoutGroup:function(){for(var e=[],t=0;t<this.get("templateGroups").length;t++){var i=this.get("templateGroups").at(t);i.get("groupID")<=0&&e.push(i)}return e},getAttribute:function(e){return this.get("attributes").getAttribute(e)},getAttributeByGuid:function(e){return this.get("attributes").getAttributeByGuid(e)},getOption:function(e){for(var t=0;t<this.get("attributes").length;t++){var i=this.get("attributes").at(t).get("options").findWhere({optionID:e});if(i)return i}return null},getOptionByGuid:function(e){for(var t=0;t<this.get("attributes").length;t++){var i=this.get("attributes").at(t).get("options").findWhere({optionGuid:e});if(i)return i}return null},getComposerPricing:function(e){for(var t=0;t<this.get("composerPricings").length;t++){var i=this.get("composerPricings").at(t);if(i.get("pricingID")==e)return i}return null},getModelSide:function(e,t){for(var i=0;i<this.get("colors").length;i++){var n=this.get("colors").at(i);if(n.get("colorID")==e)for(var a=0;a<n.get("sides").length;a++){var r=n.get("sides").at(a);if(r.get("sideID")==t)return r}}return null},getAttributeSelectionColor:function(e){return this.get("attributeSelectionColors").getAttributeSelectionColor(e)},setShowTemplateSelection(e){this.set("showTemplateSelection",e)},sync:MPlaza.syncCloudflare}),MPlaza.Models=Backbone.Collection.extend({model:MPlaza.Model,url:function(){return Zakeke.config.baseApiUrl+"models"},getModel:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("modelID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ColorMapping=Backbone.AssociatedModel.extend({defaults:{src:"",dest:""},initialize:function(){},copyAttributes:function(e){this.set("src",e.get("src")),this.set("dest",e.get("dest"))},toJSON:function(){return{src:this.get("src"),dest:this.get("dest")}},sync:MPlaza.syncCloudflare}),MPlaza.ColorMappings=Backbone.Collection.extend({model:MPlaza.ColorMapping,toJSON:function(){var e=[];return this.forEach(t=>e.push(t.toJSON())),e},sync:MPlaza.syncCloudflare}),MPlaza.ConnectorSetting=Backbone.AssociatedModel.extend({defaults:{key:"",settings:""},initialize:function(){},copyAttributes:function(e){this.set("key",e.get("key")),this.set("settings",e.get("settings"))},toJSON:function(){return{key:this.get("key"),settings:this.get("settings")}},sync:MPlaza.syncCloudflare}),MPlaza.ConnectorSettings=Backbone.Collection.extend({model:MPlaza.ConnectorSetting,toJSON:function(){var e=[];return this.forEach(t=>e.push(t.toJSON())),e},sync:MPlaza.syncCloudflare}),MPlaza.TextArtConfig=Backbone.AssociatedModel.extend({defaults:{},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{angleValue:this.get("angleValue"),curveValue:this.get("curveValue"),intensT:this.get("intensT"),intensB:this.get("intensB"),isTriangle:this.get("isTriangle"),isBridge:this.get("isBridge"),isTop:this.get("isTop"),isBottom:this.get("isBottom"),isMiddle:this.get("isMiddle")}},copyAttributes:function(e){this.set("angleValue",e.get("angleValue")),this.set("curveValue",e.get("curveValue")),this.set("intensT",e.get("intensT")),this.set("intensB",e.get("intensB")),this.set("isTriangle",e.get("isTriangle")),this.set("isBridge",e.get("isBridge")),this.set("isTop",e.get("isTop")),this.set("isBottom",e.get("isBottom")),this.set("isMiddle",e.get("isMiddle"))},sync:MPlaza.syncCloudflare}),MPlaza.TextArtControl=Backbone.AssociatedModel.extend({defaults:{},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{property:this.get("property"),labelKey:this.get("labelKey"),type:this.get("type"),min:this.get("min"),max:this.get("max"),step:this.get("step")}},copyAttributes:function(e){this.set("property",e.get("property")),this.set("labelKey",e.get("labelKey")),this.set("type",e.get("type")),this.set("min",e.get("min")),this.set("max",e.get("max")),this.set("step",e.get("step"))},sync:MPlaza.syncCloudflare}),MPlaza.TextArtControls=Backbone.Collection.extend({model:MPlaza.TextArtControl,sync:MPlaza.syncCloudflare}),MPlaza.TextArtType=Backbone.AssociatedModel.extend({defaults:{name:"",imageUrl:"",config:null,controls:[]},idAttribute:"textArtTypeID",initialize:function(){this.get("controls").parentModel=this,this.get("config")&&(this.get("config").parentModel=this)},relations:[{type:Backbone.One,key:"config",relatedModel:MPlaza.TextArtConfig},{type:Backbone.Many,key:"controls",collectionType:MPlaza.TextArtControls}],url:function(){var e=Zakeke.config.baseApiUrl+"textart/types";return void 0!==this.id&&null!==this.id&&this.id>0&&(e=e+"/"+this.id),e},getTextArtTypeID:function(){return this.get("textArtTypeID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.TextArtTypes=Backbone.Collection.extend({model:MPlaza.TextArtType,url:function(){return Zakeke.config.baseApiUrl+"textart/types"},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemColor=Backbone.AssociatedModel.extend({defaults:{imageID:-1,colorID:-1,colorCode:""},idAttribute:"key",initialize:function(){},getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getDesignItemID:function(){return this.collection&&this.collection.getDesignItemID?this.collection.getDesignItemID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemColors=Backbone.Collection.extend({model:MPlaza.DesignItemColor,getDesignItemColor:function(e,t){for(var i=0;i<this.length;i++){var n=this.at(i);if(n.get("imageID")==e&&n.get("colorID")==t)return n}return null},getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},getDesignItemID:function(){return this.parentModel&&this.parentModel.getDesignItemID?this.parentModel.getDesignItemID():null},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemArea=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,areaID:-1},idAttribute:"id",initialize:function(){},getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getDesignItemID:function(){return this.collection&&this.collection.getDesignItemID?this.collection.getDesignItemID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemAreas=Backbone.Collection.extend({model:MPlaza.DesignItemArea,getDesignItemArea:function(e,t,i,n){for(var a=0;a<this.length;a++){var r=this.at(a);if(r.get("modelID")==e&&r.get("colorID")==t&&r.get("sideID")==i&&r.get("areaID")==n)return r}return null},getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},getDesignItemID:function(){return this.parentModel&&this.parentModel.getDesignItemID?this.parentModel.getDesignItemID():null},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemConstraints=Backbone.AssociatedModel.extend({defaults:{itemID:-1,canMove:!0,canMoveX:!0,canMoveY:!0,canRotate:!0,canResize:!0,canDelete:!0,canEdit:!0,keepNrChars:!1,minNrChars:0,maxNrChars:0,paddingTypeID:MPlaza.PaddingType.Start,paddingString:"",canChangeFontFamily:!0,canChangeFontSize:!0,canChangeFontColor:!0,canChangeFontWeight:!0,canChangeFontItalic:!0,canChangeTextPathMode:!0,canChangeJustification:!0,canTransform:!0,canChangeSvgColors:!0,isAlwaysOnTop:!1,isPrintable:!0,keepInPreview:!0,mandatoryToEdit:!1,canSyncContent:!0,canSyncAlignment:!0,canSyncFontFamily:!0,canSyncFontStyle:!0,canSyncFontColor:!0,canSyncCurved:!0,canSyncTransforms:!1,canResizeTextBox:!0,canChangeTextBoxMode:!0,toUppercase:!1,canChangeTextBoxMode:!0,toUppercase:!1,canAddMask:!0,canReplaceMask:!0,canEditMask:!0,canDeleteMask:!0,canEditMaskedImage:!0,canChangeMaskStrokeColor:!0,canChangeMaskStrokeWidth:!0,canFillShape:!0,canReplaceShapeFilling:!0,canEditShapeFilling:!0,canDeleteShapeFilling:!0,canEditFilledShape:!0,canChangeShapeStrokeColor:!0,canChangeShapeStrokeWidth:!0,canChangeShapeFillColor:!0,canChangeLetterSpacing:!1,minLetterSpacing:null,maxLetterSpacing:null,canChangeLineSpacing:!1,minLineSpacing:null,maxLineSpacing:null,canChangeAdaptText:!0,canWrapTextOnAdaptText:!0,minFontSize:null,maxFontSize:null,canChangeVerticalAlignment:!0,canChangeShadowColor:!0,canChangeShadowBlur:!0,canChangeShadowDistance:!0,canChangeShadowAngle:!0,minShadowBlur:null,maxShadowBlur:null,minShadowDistance:null,maxShadowDistance:null,minShadowAngle:null,maxShadowAngle:null,canChangeTextStrokeColor:!0,canChangeTextStrokeWidth:!0,minTextStrokeWidth:null,maxTextStrokeWidth:null,canStretch:!0},idAttribute:"itemID",initialize:function(){},url:function(){return""},getDesignID:function(){return this.parentModel?this.parentModel.getDesignID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},copyAttributes:function(e){this.set("canMove",e.get("canMove")),this.set("canRotate",e.get("canRotate")),this.set("canResize",e.get("canResize")),this.set("canDelete",e.get("canDelete")),this.set("canEdit",e.get("canEdit")),this.set("keepNrChars",e.get("keepNrChars")),this.set("minNrChars",e.get("minNrChars")),this.set("maxNrChars",e.get("maxNrChars")),this.set("paddingTypeID",e.get("paddingTypeID")),this.set("paddingString",e.get("paddingString")),this.set("canChangeFontFamily",e.get("canChangeFontFamily")),this.set("canChangeFontSize",e.get("canChangeFontSize")),this.set("canChangeFontColor",e.get("canChangeFontColor")),this.set("canChangeFontWeight",e.get("canChangeFontWeight")),this.set("canChangeTextPathMode",e.get("canChangeTextPathMode")),this.set("canChangeJustification",e.get("canChangeJustification")),this.set("canTransform",e.get("canTransform")),this.set("canChangeSvgColors",e.get("canChangeSvgColors")),this.set("isAlwaysOnTop",e.get("isAlwaysOnTop")),this.set("isPrintable",e.get("isPrintable")),this.set("keepInPreview",e.get("keepInPreview")),this.set("mandatoryToEdit",e.get("mandatoryToEdit")),this.set("canSyncContent",e.get("canSyncContent")),this.set("canSyncAlignment",e.get("canSyncAlignment")),this.set("canSyncFontFamily",e.get("canSyncFontFamily")),this.set("canSyncFontStyle",e.get("canSyncFontStyle")),this.set("canSyncFontColor",e.get("canSyncFontColor")),this.set("canSyncCurved",e.get("canSyncCurved")),this.set("canSyncTransforms",e.get("canSyncTransforms")),this.set("canResizeTextBox",e.get("canResizeTextBox")),this.set("canChangeTextBoxMode",e.get("canChangeTextBoxMode")),this.set("toUppercase",e.get("toUppercase")),this.set("canAddMask",e.get("canAddMask")),this.set("canReplaceMask",e.get("canReplaceMask")),this.set("canEditMask",e.get("canEditMask")),this.set("canDeleteMask",e.get("canDeleteMask")),this.set("canEditMaskedImage",e.get("canEditMaskedImage")),this.set("canChangeMaskStrokeColor",e.get("canChangeMaskStrokeColor")),this.set("canChangeMaskStrokeWidth",e.get("canChangeMaskStrokeWidth")),this.set("canFillShape",e.get("canFillShape")),this.set("canReplaceShapeFilling",e.get("canReplaceShapeFilling")),this.set("canEditShapeFilling",e.get("canEditShapeFilling")),this.set("canDeleteShapeFilling",e.get("canDeleteShapeFilling")),this.set("canEditFilledShape",e.get("canEditFilledShape")),this.set("canChangeShapeStrokeColor",e.get("canChangeShapeStrokeColor")),this.set("canChangeShapeStrokeWidth",e.get("canChangeShapeStrokeWidth")),this.set("canChangeShapeFillColor",e.get("canChangeShapeFillColor")),this.set("canChangeLetterSpacing",e.get("canChangeLetterSpacing")),this.set("minLetterSpacing",e.get("minLetterSpacing")),this.set("maxLetterSpacing",e.get("maxLetterSpacing")),this.set("canChangeLineSpacing",e.get("canChangeLineSpacing")),this.set("minLineSpacing",e.get("minLineSpacing")),this.set("canChangeAdaptText",e.get("canChangeAdaptText")),this.set("canWrapTextOnAdaptText",e.get("canWrapTextOnAdaptText")),this.set("minFontSize",e.get("minFontSize")),this.set("maxFontSize",e.get("maxFontSize")),this.set("canChangeVerticalAlignment",e.get("canChangeVerticalAlignment")),this.set("canChangeShadowColor",e.get("canChangeShadowColor")),this.set("canChangeShadowBlur",e.get("canChangeShadowBlur")),this.set("canChangeShadowDistance",e.get("canChangeShadowDistance")),this.set("canChangeShadowAngle",e.get("canChangeShadowAngle")),this.set("minShadowBlur",e.get("minShadowBlur")),this.set("maxShadowBlur",e.get("maxShadowBlur")),this.set("minShadowDistance",e.get("minShadowDistance")),this.set("maxShadowDistance",e.get("maxShadowDistance")),this.set("minShadowAngle",e.get("minShadowAngle")),this.set("maxShadowAngle",e.get("maxShadowAngle")),this.set("canStretch",e.get("canStretch"))},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemTextArt=Backbone.AssociatedModel.extend({defaults:{itemID:-1,text:"",fontFamilyID:-1,fontFaceID:-1,textArtTypeID:-1,config:null},idAttribute:"itemID",initialize:function(){this.get("config")&&(this.get("config").parentModel=this)},relations:[{type:Backbone.One,key:"config",relatedModel:MPlaza.TextArtConfig}],url:function(){return""},getDesignID:function(){return this.parentModel?this.parentModel.getDesignID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},copyAttributes:function(e){if(this.set("text",e.get("text")),this.set("fontFamilyID",e.get("fontFamilyID")),this.set("fontFaceID",e.get("fontFaceID")),this.set("textArtTypeID",e.get("textArtTypeID")),this.unset("config"),e.get("config")){var t=e.get("config"),i=new MPlaza.TextArtConfig;i.set("itemID",this.get("itemID")),i.copyAttributes(t),this.set("config",i)}},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemShape=Backbone.AssociatedModel.extend({defaults:{itemID:-1,shapeID:-1,isMask:!0},idAttribute:"itemID",initialize:function(){},relations:[],url:function(){return""},getDesignID:function(){return this.parentModel?this.parentModel.getDesignID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},copyAttributes:function(e){this.set("shapeID",e.get("shapeID")),this.set("isMask",e.get("isMask"))},sync:MPlaza.syncCloudflare}),MPlaza.DesignItem=Backbone.AssociatedModel.extend({defaults:{name:"",index:0,json:"",svg:"",imageID:-1,imageType:"",imageFormat:"",imageWidth:0,imageHeight:0,imageDpiX:0,imageDpiY:0,imageFileSize:0,imageCustomerID:-1,imageVisitorID:-1,imagePrice:0,providerImageID:null,applyImagePriceForQuantity:null,imageIsMulticolor:!1,imageContainsRaster:!1,imagePreferredWidth:null,imagePreferredHeight:null,syncGuid:null,isChanged:!0,areas:[],colors:[],constraints:null,textArt:null,shape:null,colorMappings:[],overridePreview:"",connectorSettings:[]},resetColors:function(){this.set("colors",[])},copyAttributes:function(e){if(this.set("index",e.get("index")),this.set("name",e.get("name")),this.set("json",e.get("json")),this.set("svg",e.get("svg")),this.set("imageID",e.get("imageID")),this.set("imageType",e.get("imageType")),this.set("imageFormat",e.get("imageFormat")),this.set("imageWidth",e.get("imageWidth")),this.set("imageHeight",e.get("imageHeight")),this.set("imageDpiX",e.get("imageDpiX")),this.set("imageDpiY",e.get("imageDpiY")),this.set("imageFileSize",e.get("imageFileSize")),this.set("imageCustomerID",e.get("imageCustomerID")),this.set("imageVisitorID",e.get("imageVisitorID")),this.set("imagePrice",e.get("imagePrice")),this.set("applyImagePriceForQuantity",e.get("applyImagePriceForQuantity")),this.set("providerImageID",e.get("providerImageID")),this.set("imageIsMulticolor",e.get("imageIsMulticolor")),this.set("imageContainsRaster",e.get("imageContainsRaster")),this.set("imagePreferredWidth",e.get("imagePreferredWidth")),this.set("imagePreferredHeight",e.get("imagePreferredHeight")),this.set("isChanged",e.get("isChanged")),this.set("itemColors",[]),e.get("itemColors"))for(var t=0;t<e.get("itemColors").length;t++)this.get("itemColors").push(e.get("itemColors")[t]);if(this.unset("colorMappings"),this.set("colorMappings",new MPlaza.ColorMappings),e.get("colorMappings"))for(t=0;t<e.get("colorMappings").length;t++){var i=new MPlaza.ColorMapping;i.copyAttributes(e.get("colorMappings").at(t)),this.get("colorMappings").add(i)}if(this.unset("connectorSettings"),this.set("connectorSettings",new MPlaza.ConnectorSettings),e.get("connectorSettings"))for(t=0;t<e.get("connectorSettings").length;t++){var n=new MPlaza.ConnectorSetting;n.copyAttributes(e.get("connectorSettings").at(t)),this.get("connectorSettings").add(n)}this.set("syncGuid",e.get("syncGuid"));for(t=0;t<e.get("colors").length;t++){var a=e.get("colors").at(t),r=this.get("colors").find(e=>e.get("colorID")==a.get("colorID"));r||(r=new MPlaza.DesignItemColor,this.get("colors").add(r)),r.set("imageID",a.get("imageID")),r.set("colorID",a.get("colorID")),r.set("colorCode",a.get("colorCode"))}if(this.unset("constraints"),e.get("constraints")){var o=e.get("constraints"),s=new MPlaza.DesignItemConstraints;s.set("itemID",this.get("itemID")),s.copyAttributes(o),this.set("constraints",s)}if(this.unset("textArt"),e.get("textArt")){var l=e.get("textArt"),h=new MPlaza.DesignItemTextArt;h.set("itemID",this.get("itemID")),h.copyAttributes(l),this.set("textArt",h)}if(this.unset("shape"),e.get("shape")){var d=e.get("shape"),c=new MPlaza.DesignItemShape;c.set("itemID",this.get("itemID")),c.copyAttributes(d),this.set("shape",c)}},copyConstraints:function(e){if(this.unset("constraints"),e){var t=new MPlaza.DesignItemConstraints;t.set("itemID",this.get("itemID")),t.copyAttributes(e),this.set("constraints",t)}},copyTextArt:function(e){if(this.unset("textArt"),source.get("textArt")){var t=new MPlaza.DesignItemTextArt;t.set("itemID",this.get("itemID")),t.copyAttributes(e),this.set("textArt",t)}},copyShape:function(e){if(this.unset("shape"),source.get("shape")){var t=new MPlaza.DesignItemShape;t.set("itemID",this.get("itemID")),t.copyAttributes(e),this.set("shape",t)}},idAttribute:"itemGuid",initialize:function(){this.get("areas").parentModel=this,this.get("colors").parentModel=this,this.get("constraints")&&(this.get("constraints").parentModel=this),this.get("textArt")&&(this.get("textArt").parentModel=this),this.get("itemGuid")||this.set("itemGuid",MPlaza.generateUUID()),this.get("itemColors")||this.set("itemColors",[])},relations:[{type:Backbone.Many,key:"areas",collectionType:MPlaza.DesignItemAreas},{type:Backbone.Many,key:"colors",collectionType:MPlaza.DesignItemColors},{type:Backbone.One,key:"constraints",relatedModel:MPlaza.DesignItemConstraints},{type:Backbone.One,key:"textArt",relatedModel:MPlaza.DesignItemTextArt},{type:Backbone.One,key:"shape",relatedModel:MPlaza.DesignItemShape},{type:Backbone.Many,key:"colorMappings",collectionType:MPlaza.ColorMappings},{type:Backbone.Many,key:"connectorSettings",collectionType:MPlaza.ConnectorSettings}],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getDesignItemID:function(){return this.get("itemID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},findArea:function(e,t,i,n){var a=this.get("areas");return a?a.getDesignItemArea(e,t,i,n):null},findColor:function(e,t){var i=this.get("colors");return i?i.getDesignItemColor(e,t):null},toString:function(){},isOnSide:function(e){if(!(e&&e instanceof MPlaza.Side))return!1;for(var t=this.get("areas"),i=0;i<t.length;i++){var n=t.at(i);if(n.get("areaGuid")&&(!n.get("areaID")||n.get("areaID")<=0)){for(var a=0;a<e.get("areas").length;a++)if(e.get("areas").at(a).get("guid")==n.get("areaGuid"))return!0}else if(n.get("sideID")==e.getSideID())return!0}return!1},inOnArea:function(e){return!!(e||e instanceof MPlaza.Area)&&null!=this.findArea(e.getModelID(),e.getColorID(),e.getSideID(),e.getAreaID())},updateAreas:function(e){for(;this.get("areas").length>0;)this.get("areas").pop();for(var t=0;t<e.length;t++)this.addArea(e[t])},addArea:function(e){if(e&&e instanceof MPlaza.Area&&!this.findArea(e.getModelID(),e.getColorID(),e.getSideID(),e.getAreaID())){var t=new MPlaza.DesignItemArea;t.set("modelID",e.getModelID()),t.set("colorID",e.getColorID()),t.set("sideID",e.getSideID()),t.set("areaID",e.getAreaID()),t.set("areaGuid",e.get("guid")),this.get("areas").add(t)}},changeColor:function(e,t,i){if(e===this.get("imageID")){var n=this.findColor(e,t);n||((n=new MPlaza.DesignItemColor).set("imageID",e),n.set("colorID",t),this.get("colors").add(n)),n.set("colorCode",i)}},setConstraintsFromSource:function(e){this.unset("constraints");var t=new MPlaza.DesignItemConstraints;t.itemID=this.get("itemID"),t.copyAttributes(e),this.set("constraints",t)},setTextArtFromSource:function(e){this.unset("textArt");var t=new MPlaza.DesignItemTextArt;t.itemID=this.get("itemID"),t.copyAttributes(e),this.set("textArt",t)},isTextArt:function(){return null!==this.get("textArt")&&void 0!==this.get("textArt")},sync:MPlaza.syncCloudflare}),MPlaza.DesignItems=Backbone.Collection.extend({model:MPlaza.DesignItem,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},getDesignItemByGuid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("itemGuid")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignTemplateCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:-1,name:""},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignTemplateCategories=Backbone.Collection.extend({model:MPlaza.DesignTemplateCategory,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findCategory:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("categoryID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignTemplateColor=Backbone.AssociatedModel.extend({defaults:{colorID:-1,name:"",isDefault:!1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignTemplateColors=Backbone.Collection.extend({model:MPlaza.DesignTemplateColor,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignArea=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,areaID:-1,printTypeID:-1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignAreas=Backbone.Collection.extend({model:MPlaza.DesignArea,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findArea:function(e,t,i,n){for(var a=0;a<this.length;a++){var r=this.at(a);if(r.get("modelID")==e&&r.get("colorID")==t&&r.get("sideID")==i&&r.get("areaID")==n)return r}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignAreaGrid=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,areaID:-1,gridID:-1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignAreasGrids=Backbone.Collection.extend({model:MPlaza.DesignAreaGrid,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findAreaGrid:function(e,t,i,n,a){for(var r=0;r<this.length;r++){var o=this.at(r);if(o.get("modelID")==e&&o.get("colorID")==t&&o.get("sideID")==i&&o.get("areaID")==n&&o.get("gridID")==a)return o}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignSidePrintType=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,printTypeID:-1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignSidesPrintTypes=Backbone.Collection.extend({model:MPlaza.DesignSidePrintType,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findSidePrintType:function(e,t,i,n){for(var a=0;a<this.length;a++){var r=this.at(a);if(r.get("modelID")==e&&r.get("colorID")==t&&r.get("sideID")==i&&r.get("printTypeID")==n)return r}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignSide=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,fillColor:"",canAddText:!0,canAddImage:!0,canAddShape:!0,canMaskImages:!0,maxNrTexts:null,maxNrImages:null,maxNrShapes:null,canChangeSvgColors:!0,uploadRestrictions:null,disableSellerImages:!1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignSides=Backbone.Collection.extend({model:MPlaza.DesignSide,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findSide:function(e,t,i){for(var n=0;n<this.length;n++){var a=this.at(n);if(a.get("modelID")==e&&a.get("colorID")==t&&a.get("sideID")==i)return a}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignClientPreview=Backbone.AssociatedModel.extend({defaults:{sideID:-1,fileObjectID:-1,url:""},initialize:function(){},relations:[],sync:MPlaza.syncCloudflare}),MPlaza.DesignClientPreviews=Backbone.Collection.extend({model:MPlaza.DesignClientPreview,sync:MPlaza.syncCloudflare}),MPlaza.TextDesignElement=Backbone.AssociatedModel.extend({defaults:{},copyAttributes:function(e){var t=function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))};t("content"),t("strokeColor"),t("strokeWidth"),t("fillColor"),t("fontFamily"),t("fontSize"),t("fontWeight"),t("fontStyle"),t("fontStretch"),t("justification"),t("adaptText"),t("letterSpacing"),t("lineSpacing"),t("verticalAlignment"),t("shadowColor"),t("shadowBlur"),t("shadowBlur"),t("shadowBlur")}}),MPlaza.TextArtDesignElement=Backbone.AssociatedModel.extend({defaults:{},copyAttributes:function(e){!function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))}("content")}}),MPlaza.ImageDesignElement=Backbone.AssociatedModel.extend({defaults:{},copyAttributes:function(e){!function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))}("imageID")}}),MPlaza.ShapeDesignElement=Backbone.AssociatedModel.extend({defaults:{},copyAttributes:function(e){!function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))}("shapeID")}}),MPlaza.DesignElement=Backbone.AssociatedModel.extend({defaults:{tag:"",text:null,textArt:null,image:null,shape:null},initialize:function(){},relations:[{type:Backbone.One,key:"text",relatedModel:MPlaza.TextDesignElement},{type:Backbone.One,key:"textArt",relatedModel:MPlaza.TextArtDesignElement},{type:Backbone.One,key:"image",relatedModel:MPlaza.ImageDesignElement},{type:Backbone.One,key:"shape",relatedModel:MPlaza.ShapeDesignElement}],copyAttributes:function(e){if(function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))}("tag"),this.unset("text"),e.get("text")){var t=new MPlaza.TextDesignElement;t.copyAttributes(e.get("text")),this.set("text",t)}if(this.unset("textArt"),e.get("textArt")){var i=new MPlaza.TextArtDesignElement;i.copyAttributes(e.get("textArt")),this.set("textArt",i)}if(this.unset("image"),e.get("image")){var n=new MPlaza.ImageDesignElement;n.copyAttributes(e.get("image")),this.set("image",n)}if(this.unset("shape"),e.get("shape")){var a=new MPlaza.ShapeDesignElement;a.copyAttributes(e.get("shape")),this.set("shape",a)}}}),MPlaza.DesignElements=Backbone.Collection.extend({model:MPlaza.DesignElement}),MPlaza.DesignElementsDesc=Backbone.AssociatedModel.extend({defaults:{elements:[]},idAttribute:"id",initialize:function(){this.get("id")||this.set("id",MPlaza.generateUUID())},relations:[{type:Backbone.Many,key:"elements",collectionType:MPlaza.DesignElements}],copyAttributes:function(e){if(this.unset("elements"),null!==e.get("elements")&&void 0!==e.get("elements")){for(var t=[],i=0;i<e.get("elements").length;i++){var n=e.get("elements").at(i),a=new MPlaza.DesignElement;a.copyAttributes(n),t.push(a)}this.set("elements",t)}}}),MPlaza.DesignElementsDescs=Backbone.Collection.extend({model:MPlaza.DesignElementsDesc,getDescById:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.id===e)return i}return null}}),MPlaza.DesignOptionsItem=Backbone.AssociatedModel.extend({defaults:{colorID:-1,sideID:null,width:null,height:null,columns:1,rows:1},idAttribute:"optionId",initialize:function(){},relations:[]}),MPlaza.DesignOptions=Backbone.Collection.extend({model:MPlaza.DesignOptionsItem}),MPlaza.Design=Backbone.AssociatedModel.extend({defaults:{modelID:-1,modelName:"",pricingModelID:-1,modelPriceDeltaPerc:0,modelPriceDeltaValue:0,modelPrice:0,modelTextBasePrice:0,modelImageBasePrice:0,printTypeID:-1,description:"",info:"",isTemplate:!1,isDraft:!1,name:"",templateCode:"",parentTemplateId:null,templateDesignID:-1,customerID:-1,visitorID:-1,sells:0,finalPrice:0,tempPreviewImageData:null,tempPreviewImageUrl:"",canAddText:!0,canAddImage:!0,canAddShape:!0,canMaskImages:!0,maxNrTexts:null,maxNrImages:null,maxNrShapes:null,filterCode:"",canChangeSvgColors:!0,uploadRestrictions:null,disableSellerImages:!1,hasSyncEnabled:!1,pdSettings:-1,sides:[],sidesPrintTypes:[],areasGrids:[],areas:[],designItems:[],categories:[],colors:[],tags:[],clientPreviews:[],elementsDescs:[],options:[],canvasRotation:[]},idAttribute:"docID",initialize:function(){var e=this;this.get("sides").parentModel=this,this.get("sidesPrintTypes").parentModel=this,this.get("areasGrids")||this.set("areasGrids",new MPlaza.DesignAreasGrids),this.get("areasGrids").parentModel=this,this.get("areas").parentModel=this,this.get("designItems").parentModel=this,this.get("colors")||this.set("colors",new MPlaza.DesignTemplateColors),this.get("categories").parentModel=this,this.get("colors").parentModel=this,this.get("options")||this.set("options",new MPlaza.DesignOptions),this.get("options").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("designItems").on("add",function(){e._fireEvent("change")}),this.get("designItems").on("remove",function(){e._fireEvent("change")}),this.get("designItems").on("change",function(){e._fireEvent("change")}),this.get("categories").on("change",function(){e._fireEvent("change")}),this.get("colors").on("change",function(){e._fireEvent("change")}),this.get("clientPreviews").on("change",function(){e._fireEvent("change")}),this.get("sidesPrintTypes").on("change",function(){e._fireEvent("change")}),this.get("options").on("change",function(){e._fireEvent("change")})},_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},isEmpty:function(){return 0==this.get("designItems").length},relations:[{type:Backbone.Many,key:"sides",collectionType:MPlaza.DesignSides},{type:Backbone.Many,key:"sidesPrintTypes",collectionType:MPlaza.DesignSidesPrintTypes},{type:Backbone.Many,key:"areasGrids",collectionType:MPlaza.DesignAreasGrids},{type:Backbone.Many,key:"areas",collectionType:MPlaza.DesignAreas},{type:Backbone.Many,key:"designItems",collectionType:MPlaza.DesignItems},{type:Backbone.Many,key:"categories",collectionType:MPlaza.DesignTemplateCategories},{type:Backbone.Many,key:"colors",collectionType:MPlaza.DesignTemplateColors},{type:Backbone.Many,key:"clientPreviews",collectionType:MPlaza.DesignClientPreviews},{type:Backbone.Many,key:"elementsDescs",collectionType:MPlaza.DesignElementsDescs},{type:Backbone.Many,key:"options",collectionType:MPlaza.DesignOptions}],url:function(){var e=Zakeke.config.baseApiUrl+"proxydesigns";return null!=this.id&&null!=this.id&&(e=e+"/"+this.id),!0===this.attributes.isDraft&&(e+="/?draft=true"),e},getDesignID:function(){return this.get("designID")},toString:function(){},getDesignItems:function(){return this.get("designItems")},getSideDesignItems:function(e){for(var t=[],i=0;i<this.get("designItems").length;i++){var n=this.get("designItems").at(i);n.isOnSide(e)&&t.push(n)}return t.sort(function(e,t){return e.get("index")-t.get("index")}),t},getAreaDesignItems:function(e){var t=[];if(e&&e instanceof MPlaza.Area)for(var i=0;i<this.get("designItems").length;i++){var n=this.get("designItems").at(i);n.inOnArea(e)&&t.push(n)}return t.sort(function(e,t){return e.get("index")-t.get("index")}),t},getDesignItemsByTag:function(e){var t=[];for(let i=0;i<this.get("designItems").length;i++){const n=this.get("designItems").at(i);null!==n.get("tag")&&void 0!==n.get("tag")&&n.get("tag")===e&&t.push(n)}return t.sort(function(e,t){return e.get("index")-t.get("index")}),t},setModel:function(e){if(e&&e instanceof MPlaza.Model){this.set("modelID",e.get("modelID")),this.set("modelName",e.get("name")),this.set("pricingModelID",e.get("pricingModelID"));var t=this.get("printTypeID");this.set("modelPriceDeltaPerc",e.getModelPriceDeltaPerc(t)),this.set("modelPriceDeltaValue",e.getModelPriceDeltaValue(t)),this.set("modelPrice",e.getModelPrice(t)),this.set("modelTextBasePrice",e.getModelTextBasePrice(t)),this.set("modelImageBasePrice",e.getModelImageBasePrice(t))}},setPrintType:function(e){e&&e instanceof MPlaza.PrintType&&(this.set("printTypeID",e.get("printTypeID")||e.tempID),this.set("modelPriceDeltaPerc",e.get("priceDeltaPerc")),this.set("modelPriceDeltaValue",e.get("priceDeltaValue")),this.set("modelPrice",e.get("price")),this.set("modelTextBasePrice",e.get("textBasePrice")),this.set("modelImageBasePrice",e.get("imageBasePrice")))},cloneWithDifferentModel:function(e){var t=new MPlaza.Design;if(!(e&&e instanceof MPlaza.Model))return t;if(e.get("modelID")==this.get("modelID"))return this.clone();if(0==e.get("colors").length)return t;t.setModel(e);var i=e.get("printTypes").getPrintType(this.get("printTypeID"));!i&&e.get("printTypes").length>0&&(i=e.get("printTypes").at(0)),i?t.set("printTypeID",i.get("printTypeID")):t.set("printTypeID",-1);var n=e.get("colors").at(0);if(n)for(var a=0;a<this.get("designItems").length;a++){var r=this.get("designItems").at(a),o=new MPlaza.DesignItem;o.copyAttributes(r);for(var s=0;s<r.get("areas").length;s++){var l=r.get("areas").at(s),h=n.get("sides").getSide(l.get("sideID"));if(h){var d=h.get("areas").getAreaByID(l.get("areaID"));d&&o.addArea(d)}}o.get("areas").length>0&&t.get("designItems").add(o)}for(var c=0;c<this.get("categories").length;c++){var u=this.get("categories").at(c),g=new MPlaza.DesignTemplateCategory;g.set("categoryID",u.get("categoryID")),g.set("name",u.get("name")),t.get("categories").add(g)}for(c=0;c<this.get("colors").length;c++){var f=this.get("colors").at(c),p=new MPlaza.DesignTemplateColor;p.set("colorID",f.get("colorID")),p.set("name",f.get("name")),t.get("colors").add(p)}if(null!==this.get("elementsDescs")&&void 0!==this.get("elementsDescs")){var m=new MPlaza.DesignElementsDescs;for(c=0;c<this.get("elementsDescs").length;c++){var v=this.get("elementsDescs").at(c),I=new MPlaza.DesignElementsDesc;I.copyAttributes(v),m.push(I)}t.set("elementsDescs",m)}return t},changeColor:function(e){if(e){var t=[],i=[],n=[];for(let t of this.get("areasGrids").models)t.set("modelID",e.getModelID()),e.get("sides").find(e=>e.id==t.get("sideID"))&&t.set("colorID",e.getColorID());for(var a=0;a<this.get("sides").length;a++){var r=this.get("sides").at(a),o=null;if(r.get("modelID")==e.getModelID()){var s=e.get("sides").getSide(r.get("sideID"));s&&(o=s)}var l=null;let I=null;for(var h=0;h<this.get("sidesPrintTypes").length;h++){var d=this.get("sidesPrintTypes").at(h);d.get("modelID")==r.get("modelID")&&d.get("colorID")==r.get("colorID")&&d.get("sideID")==r.get("sideID")&&(l=d)}for(var c=0;c<this.get("areasGrids").length;c++){let e=this.get("areasGrids").at(c);e.get("modelID")==r.get("modelID")&&e.get("colorID")==r.get("colorID")&&e.get("sideID")==r.get("sideID")&&(I=e)}if(o){var u=null;for(var g of this.get("sides").models)g!==r&&g.get("modelID")===e.getModelID()&&g.get("colorID")===e.getColorID()&&g.get("sideID")===r.get("sideID")&&(u=g);u?t.push(r):r.set("colorID",e.get("colorID"));var f=null;for(var p of this.get("sidesPrintTypes").models)p!==l&&p.get("modelID")===e.getModelID()&&p.get("colorID")===e.getColorID()&&p.get("sideID")===r.get("sideID")&&(f=p);if(f&&l)i.push(l);else if(l)l.set("colorID",e.get("colorID"));else if(!f){var m=-1;m=o.get("printTypes").length>0?o.get("printTypes").at(0):e.getParentModel().get("printTypes").at(0);var v=new MPlaza.DesignSidePrintType;v.set("modelID",r.get("modelID")),v.set("colorID",r.get("colorID")),v.set("sideID",r.get("sideID")),v.set("printTypeID",m),this.get("sidesPrintTypes").add(v)}}else t.push(r),l&&i.push(l),I&&n.push(I)}for(var I of t)this.get("sides").remove(I);for(var y of i)this.get("sidesPrintTypes").remove(y);for(let e of n)this.get("areasGrids").remove(e);for(var C=[],M=0;M<this.get("designItems").length;M++){var x=this.get("designItems").at(M),S=[];for(h=0;h<x.get("areas").length;h++){var b=x.get("areas").at(h),w=!1;if(b.get("modelID")==e.getModelID())if(g=e.get("sides").getSide(b.get("sideID")))g.get("areas").getAreaByID(b.get("areaID"))&&(w=!0);w?b.set("colorID",e.get("colorID")):S.push(b)}S.length>0&&x.get("areas").remove(S),0==x.get("areas").length&&C.push(x)}C.length>0&&this.get("designItems").remove(C),this._fireEvent("change")}},addSide:function(e){if(e&&e instanceof MPlaza.Side&&!this.get("sides").findSide(e.getModelID(),e.getColorID(),e.getSideID())){var t=new MPlaza.DesignSide;t.set("modelID",area.getModelID()),t.set("colorID",area.getColorID()),t.set("sideID",area.getSideID()),this.get("sides").add(t)}},addSidePrintType:function(e,t){if(e&&t&&e instanceof MPlaza.Side&&t instanceof MPlaza.PartPrintType&&!this.get("sidesPrintTypes").findSidePrintType(e.getModelID(),e.getColorID(),e.getSideID(),t.getPrintTypeID())){var i=new MPlaza.DesignSidePrintType;i.set("modelID",e.getModelID()),i.set("colorID",e.getColorID()),i.set("sideID",e.getSideID()),i.set("printTypeID",t.getPrintTypeID()),this.get("sidesPrintTypes").add(i)}},addArea:function(e){if(e&&side instanceof MPlaza.Area&&!this.get("areas").findArea(e.getModelID(),e.getColorID(),e.getSideID(),e.getAreaID())){var t=new MPlaza.DesignArea;t.set("modelID",e.getModelID()),t.set("colorID",e.getColorID()),t.set("sideID",e.getSideID()),t.set("areaID",e.getAreaID()),t.set("areaGuid",e.get("guid")),this.get("areas").add(t)}},getDesignSide:function(e){if(e&&e instanceof MPlaza.Side)return this.get("sides").findSide(e.getModelID(),e.getColorID(),e.getSideID())},getDesignSidePrintType:function(e,t){if(e&&t&&e instanceof MPlaza.Side&&t instanceof MPlaza.PartPrintType)return this.get("sidesPrintTypes").findSide(e.getModelID(),e.getColorID(),e.getSideID(),t.getPrintTypeID())},getDesignArea:function(e){if(e&&e instanceof MPlaza.Area)return this.get("areas").findArea(e.getModelID(),e.getColorID(),e.getSideID(),e.getAreaID())},getSelectedPrintTypeForArea:function(e){if(!e)return this.get("printTypeID");var t=this.getDesignArea(e);return this.getSelectedPrintTypeForDesignArea(t,e.getSideID(),e.getColorID())},getSelectedPrintTypeForDesignArea:function(e,t,i){if(e&&e.get("printTypeID")&&e.get("printTypeID")>0)return parseInt(e.get("printTypeID"));for(var n=null,a=0;a<this.get("sidesPrintTypes").length;a++){var r=this.get("sidesPrintTypes").at(a);r.get("colorID")==i&&r.get("sideID")==t&&(n=r)}return n?parseInt(n.get("printTypeID")):parseInt(this.get("printTypeID"))},getImageDesignItems:function(e){for(var t=[],i=0;i<this.get("designItems").length;i++){var n=this.get("designItems").at(i);n.get("imageID")==e&&t.push(n)}return t},getDesignPrice:function(e,t=1){for(var i=0,n=this.get("customerID"),a=this.get("visitorID"),r=[],o=0;o<this.get("designItems").length;o++){var s=this.get("designItems").at(o);if(s.get("imageID")>0){i+=this.get("modelImageBasePrice");var l=s.get("imagePrice");l>0&&!r.find(e=>e.get("providerImageID")===s.get("providerImageID"))&&(s.get("providerImageID")&&r.push(s),e.get("hasAdditionalFeeOnImagesProvider")||(l=null==s.get("applyImagePriceForQuantity")||s.get("applyImagePriceForQuantity")?l:l/t),n>0?n!=s.get("imageCustomerID")&&(i+=l):a>0?a!=s.get("imageVisitorID")&&(i+=l):i+=l)}else i+=this.get("modelTextBasePrice")}return i*t},getPrice:function(){var e=this.get("modelFinalPrice");return Math.round(100*e)/100},getDesignPriceEx:function(e,t){if(counter={},e&&e instanceof MPlaza.Model&&t>0)for(var i=0;i<e.get("colors").length;i++)for(var n=e.get("colors").at(i),a=0;a<n.get("sides").length;a++)for(var r=n.get("sides").at(a),o=0;o<r.get("areas").length;o++){var s=r.get("areas").at(o),l=this.getAreaDesignItems(s).filter(function(e){var t=e.get("constraints");return!t||1==t.get("isPrintable")});l.length>0&&this.addAreaPrice(s,l,t,counter)}var h=0;for(var d in counter)if(counter.hasOwnProperty(d)){var c=counter[d];isNaN(c)||(h+=c)}return Math.round(100*h)/100},addAreaPrice:function(e,t,i,n){var a=this.getSelectedPrintTypeForArea(e),r=this.getAreaPricingRef(e,a),o=r.pricingApplicationType,s=e.getModel();if(s&&s instanceof MPlaza.Model&&s.get("pricings")){var l=0,h=0,d=r.pricingID>0?s.get("pricings").getPricing(r.pricingID):null;if(d&&d instanceof MPlaza.Pricing){var c=0;d.get("setupPriceTypeID")!=MPlaza.PricingType.PerColor&&d.get("designPriceTypeID")!=MPlaza.PricingType.PerColor||(c=this.getAreaColorsCount(e,t));var u=d.getSetupPriceForQuantity(i);if(u)if(d.get("setupPriceTypeID")==MPlaza.PricingType.PerColor){if(c>0){var g=c;null!=u.get("firstColorPrice")&&null!=u.get("firstColorPrice")&&(l+=u.get("firstColorPrice"),g--),l+=g*u.get("price")}}else d.get("setupPriceTypeID")==MPlaza.PricingType.Global&&(l+=u.get("price"));var f=d.getDesignPriceForQuantity(i);if(f)if(d.get("designPriceTypeID")==MPlaza.PricingType.PerColor){if(c>0){g=c;null!=f.get("firstColorPrice")&&null!=f.get("firstColorPrice")&&(h+=f.get("firstColorPrice")*i,g--),h+=g*f.get("price")*i}}else d.get("designPriceTypeID")==MPlaza.PricingType.Global&&(h+=f.get("price")*i)}var p=null;switch(o){case MPlaza.PricingApplicationType.Global:p=this.getModelCounterKey(e.getModel(),a);break;case MPlaza.PricingApplicationType.PerSide:p=this.getSideCounterKey(e.getSide(),a);break;case MPlaza.PricingApplicationType.PerArea:p=this.getAreaCounterKey(e,a)}null!=p&&(n[p]=l+h);for(var m=[],v=0;v<t.length;v++){var I=t[v];if(I.get("imageID")>0&&I.get("imagePrice")>0&&!m.find(e=>e.get("providerImageID")===I.get("providerImageID"))){m.push(I);var y=I.get("imagePrice");y=s.get("hasAdditionalFeeOnImagesProvider")?I.get("imagePrice")*i:null===I.get("applyImagePriceForQuantity")||I.get("applyImagePriceForQuantity")?I.get("imagePrice")*i:I.get("imagePrice");var C=this.getImageCounterKey(I.get("providerImageID"));if(!(C in n)){var M=y;n[C]=M+(n[C]||0)}}}}},getAreaPricingRef:function(e,t){var i=-1,n=MPlaza.PricingApplicationType.Undefined,a=e.getPrintType(t);if(a&&a.get("pricingID")>0)i=a.get("pricingID"),n=a.get("patID");else{var r=e.getParentModel(),o=r.getPrintType(t);if(o&&o.get("pricingID")>0)i=o.get("pricingID"),n=o.get("patID");else{var s=r.getParentModel(),l=s.getPrintType(t);if(l&&l.get("pricingID")>0)i=l.get("pricingID"),n=l.get("patID");else{var h=s.getParentModel().getPrintType(t);h&&h.get("pricingID")>0&&(i=h.get("pricingID"),n=h.get("patID"))}}}return{pricingID:i,pricingApplicationType:n}},getAreaColorsCount:function(e,t){for(var i={},n=0;n<t.length;n++)for(var a=t[n].get("itemColors"),r=0;r<a.length;r++)i[a[r]]=1+(i[a[r]]||0);return Object.keys(i).length},getModelCounterKey:function(e,t){return t+"_"+e.get("modelID")},getColorCounterKey:function(e,t){return t+"_"+e.getModelID()+"_"+e.get("colorID")},getSideCounterKey:function(e,t){return t+"_"+e.getModelID()+"_"+e.getColorID()+"_"+e.get("sideID")},getAreaCounterKey:function(e,t){return t+"_"+e.getModelID()+"_"+e.getColorID()+"_"+e.getSideID()+"_"+e.get("areaID")},getImageCounterKey:function(e){return"img_"+e},countTextItemsForColor:function(e,t){for(var i={},n=0,a=0;a<this.get("designItems").length;a++){var r=this.get("designItems").at(a),o=JSON.parse(r.get("json")),s=o.length>1&&o[1].data&&o[1].data.isAreaForBackground;if(r.get("imageID")<=0&&!s)for(var l=0;l<r.get("areas").length;l++){var h=r.get("areas").at(l);h.get("modelID")==e&&h.get("colorID")==t&&(i.hasOwnProperty(r.get("itemGuid"))||(n++,i[r.get("itemGuid")]=!0))}}return n},countTextItemsForSide:function(e,t,i){for(var n={},a=0,r=0;r<this.get("designItems").length;r++){var o=this.get("designItems").at(r),s=JSON.parse(o.get("json")),l=s.length>1&&s[1].data&&s[1].data.isAreaForBackground;if(o.get("imageID")<=0&&!l)for(var h=0;h<o.get("areas").length;h++){var d=o.get("areas").at(h);d.get("modelID")==e&&d.get("colorID")==t&&d.get("sideID")==i&&(n.hasOwnProperty(o.get("itemGuid"))||(a++,n[o.get("itemGuid")]=!0))}}return a},countImageItemsForColor:function(e,t){for(var i={},n=0,a=0;a<this.get("designItems").length;a++){var r=this.get("designItems").at(a);if(r.get("imageID")>0)for(var o=0;o<r.get("areas").length;o++){var s=r.get("areas").at(o);s.get("modelID")==e&&s.get("colorID")==t&&(i.hasOwnProperty(r.get("itemGuid"))||(n++,i[r.get("itemGuid")]=!0))}}return n},countImageItemsForSide:function(e,t,i){for(var n={},a=0,r=0;r<this.get("designItems").length;r++){var o=this.get("designItems").at(r);if(o.get("imageID")>0)for(var s=0;s<o.get("areas").length;s++){var l=o.get("areas").at(s);l.get("modelID")==e&&l.get("colorID")==t&&l.get("sideID")==i&&(n.hasOwnProperty(o.get("itemGuid"))||(a++,n[o.get("itemGuid")]=!0))}}return a},countShapeItemsForColor:function(e,t){for(var i={},n=0,a=0;a<this.get("designItems").length;a++){var r=this.get("designItems").at(a),o=r.get("shape");if(o&&!o.get("isMask"))for(var s=0;s<r.get("areas").length;s++){var l=r.get("areas").at(s);l.get("modelID")==e&&l.get("colorID")==t&&(i.hasOwnProperty(r.get("itemGuid"))||(n++,i[r.get("itemGuid")]=!0))}}return n},countShapeItemsForSide:function(e,t,i){for(var n={},a=0,r=0;r<this.get("designItems").length;r++){var o=this.get("designItems").at(r);if(o.get("imageID")>0){var s=o.get("shape");if(s&&!s.get("isMask"))for(var l=0;l<o.get("areas").length;l++){var h=o.get("areas").at(l);h.get("modelID")==e&&h.get("colorID")==t&&h.get("sideID")==i&&(n.hasOwnProperty(o.get("itemGuid"))||(a++,n[o.get("itemGuid")]=!0))}}}return a},getTextItemsFonts:function(){for(var e=[],t=0;t<this.get("designItems").length;t++){var i=this.get("designItems").at(t);if(i.get("imageID")<=0){var n=i.get("json"),a=JSON.parse(n)[1],r=a.fontFamily||(a.children&&a.children.length>0&&a.children[0].length>1?a.children[0][1].fontFamily:null);r=r.replace(/"/g,""),_.contains(e,r)||e.push(r)}}return e}}),MPlaza.Designs=Backbone.Collection.extend({model:MPlaza.Design,url:function(){return Zakeke.config.baseApiUrl+"designs"},getDesign:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("designID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ImageColor=Backbone.AssociatedModel.extend({defaults:{colorID:-1,code:""},initialize:function(){},relations:[],getImageID:function(){return this.collection&&this.collection.getImageID?this.collection.getImageID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ImageColors=Backbone.Collection.extend({model:MPlaza.ImageColor,getImageID:function(){return this.parentModel&&this.parentModel.getImageID?this.parentModel.getImageID():null},findColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},setupUrlForImageID:function(e){this.url=function(){return Zakeke.config.baseApiUrl+"images/"+e+"/colors"}},sync:MPlaza.syncCloudflare}),MPlaza.ImageAssignedCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:-1,name:""},initialize:function(){},relations:[],getImageID:function(){return this.collection&&this.collection.getImageID?this.collection.getImageID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ImageAssignedCategories=Backbone.Collection.extend({model:MPlaza.ImageAssignedCategory,getImageID:function(){return this.parentModel&&this.parentModel.getImageID?this.parentModel.getImageID():null},findCategory:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("categoryID")==e)return i}return null},setupUrlForImageID:function(e){this.url=function(){return Zakeke.config.baseApiUrl+"images/"+e+"/categories"}},sync:MPlaza.syncCloudflare}),MPlaza.Image=Backbone.AssociatedModel.extend({defaults:{imageID:-1,name:"",type:"",format:"",width:0,height:0,dpiX:0,dpiY:0,isMulticolor:!1,containsRaster:!1,isFilterApplied:!1,imageFileSize:0,sellerID:-1,visitorID:-1,customerID:-1,price:0,url:"",previewUrl:"",choiceUrl:"",preferredWidth:null,preferredHeight:null,colors:[],categories:[],selectionColors:"",sourceUrlImage:"",applyPriceForQuantity:null},idAttribute:"imageID",initialize:function(){var e=this;this.get("colors").parentModel=this,this.get("colors").url=function(){return e.url()+"/"+e.id+"/imagecolors"},this.get("categories").parentModel=this,this.get("categories").url=function(){return e.url()+"/"+e.id+"/categories"}},relations:[{type:Backbone.Many,key:"colors",collectionType:MPlaza.ImageColors},{type:Backbone.Many,key:"categories",collectionType:MPlaza.ImageAssignedCategories}],url:function(){var e=Zakeke.config.baseApiUrl+"images",t=this.getUrlId();return null!==t&&(e=e+"/"+t),e},getImageID:function(){return this.get("imageID")},toString:function(){},getUrlId:function(){return void 0!==this.id&&null!=this.id&&null!=this.id&&this.id>0?this.id:null},sync:function(e,t,i){return null===this.getUrlId()?MPlaza.syncCloudflare.call(this,e,t,i):Backbone.sync.call(this,e,t,i)}}),MPlaza.Images=Backbone.Collection.extend({model:MPlaza.Image,url:function(){return Zakeke.config.baseApiUrl+"images"},getImage:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("imageID")==e)return i}return null},sync:function(e,t,i){return void 0!==i&&void 0!==i.data&&void 0!==i.data.type&&"lib"===i.data.type?MPlaza.syncCloudflare.call(this,e,t,i):Backbone.sync.call(this,e,t,i)}}),MPlaza.BgImages=Backbone.Collection.extend({model:MPlaza.Image,url:function(){return Zakeke.config.baseApiUrl+"images?onlybackground=true"},getImage:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("imageID")==e)return i}return null}}),MPlaza.ImageFormatCount=Backbone.AssociatedModel.extend({defaults:{fileFormat:"",rastersCount:0,vectorsCount:0},idAttribute:"fileFormat",url:function(){return null},sync:MPlaza.syncCloudflare}),MPlaza.ImageFormatsCounts=Backbone.Collection.extend({model:MPlaza.ImageFormatCount,url:function(){return null},comparator:function(e){return e.get("fileFormat")},sync:MPlaza.syncCloudflare}),MPlaza.ImageCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:-1,name:"",imagesCount:0,imageFormatsCounts:[]},idAttribute:"categoryID",initialize:function(){this.get("imageFormatsCounts").parentModel=this},relations:[{type:Backbone.Many,key:"imageFormatsCounts",collectionType:MPlaza.ImageFormatsCounts}],url:function(){return null},sync:MPlaza.syncCloudflare}),MPlaza.ImageCategories=Backbone.Collection.extend({model:MPlaza.ImageCategory,url:function(){return null},comparator:function(e){return e.get("name")},sync:MPlaza.syncCloudflare}),MPlaza.ImageMacroCategory=Backbone.AssociatedModel.extend({defaults:{macroCategoryID:-1,name:"",onlyForBackgrounds:!1,imagesCount:0,categories:[]},idAttribute:"macroCategoryID",initialize:function(){this.get("categories").parentModel=this},relations:[{type:Backbone.Many,key:"categories",collectionType:MPlaza.ImageCategories}],url:function(){var e=Zakeke.config.baseApiUrl+"imagesMacroCategories";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},sync:MPlaza.syncCloudflare}),MPlaza.ImageMacroCategories=Backbone.Collection.extend({model:MPlaza.ImageMacroCategory,url:function(){return Zakeke.config.baseApiUrl+"imageMacroCategories"},comparator:function(e){return e.get("name")},sync:MPlaza.syncCloudflare}),MPlaza.ImageMacroCategoriesBackground=Backbone.Collection.extend({model:MPlaza.ImageMacroCategory,url:function(){return Zakeke.config.baseApiUrl+"imageMacroCategories?onlybackground=true"},comparator:function(e){return e.get("name")},sync:MPlaza.syncCloudflare}),MPlaza.ColorChange=Backbone.AssociatedModel.extend({defaults:{colorID:-1,code:""},initialize:function(){},relations:[],getImageID:function(){return this.collection&&this.collection.getImageID?this.collection.getImageID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ColorChanges=Backbone.Collection.extend({model:MPlaza.ColorChange,getImageID:function(){return this.parentModel&&this.parentModel.getImageID?this.parentModel.getImageID():null},findColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.RecoloredImage=Backbone.AssociatedModel.extend({defaults:{imageID:-1,colorChanges:[],versionKey:"",imageUrl:""},idAttribute:"imageID",initialize:function(){this.get("colorChanges").parentModel=this},relations:[{type:Backbone.Many,key:"colorChanges",collectionType:MPlaza.ColorChanges}],url:function(){var e=Zakeke.config.baseApiUrl+"recoloredimages";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},getImageID:function(){return this.get("imageID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DrawingItem=Backbone.Model.extend({defaults:{guid:null,info:""},initialize:function(){this.set("guid",MPlaza.generateUUID())}}),MPlaza.DrawingItems=Backbone.Collection.extend({model:MPlaza.DrawingItem,getDrawingItem:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("guid")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.CompositionItem=Backbone.AssociatedModel.extend({defaults:{attributeID:-1,attributeGuid:"",attributeTypeID:MPlaza.AttributeType.Options,attributeCode:"",attributeName:"",selectedOptionID:null,selectedOptionGuid:null,selectedOptionCode:"",selectedOptionName:null,selectedValue:null},copyAttributes:function(e){this.set("attributeID",e.get("attributeID")),this.set("attributeGuid",e.get("attributeGuid")),this.set("attributeTypeID",e.get("attributeTypeID")),this.set("attributeCode",e.get("attributeCode")),this.set("attributeName",e.get("attributeName")),this.set("selectedOptionID",e.get("selectedOptionID")),this.set("selectedOptionGuid",e.get("selectedOptionGuid")),this.set("selectedOptionCode",e.get("selectedOptionCode")),this.set("selectedOptionName",e.get("selectedOptionName")),this.set("selectedValue",e.get("selectedValue"))},idAttribute:"itemGuid",initialize:function(){this.get("itemGuid")||this.set("itemGuid",MPlaza.generateUUID())},getCompositionID:function(){return this.collection&&this.collection.getCompositionID?this.collection.getCompositionID():null},getCompositionItemID:function(){return this.get("itemID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.CompositionItems=Backbone.Collection.extend({model:MPlaza.CompositionItem,getCompositionID:function(){return this.parentModel&&this.parentModel.getCompositionID?this.parentModel.getCompositionID():null},getCompositionItem:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("itemID")==e)return i}return null},getCompositionItemByAttributeID:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeID")==e)return i}return null},getCompositionItemByAttributeGuid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeGuid")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.CompositionCategoryMapping=Backbone.AssociatedModel.extend({defaults:{categoryID:null,name:""},relations:[],resetIDs:function(){}}),MPlaza.CompositionCategoriesMapping=Backbone.Collection.extend({model:MPlaza.CompositionCategoryMapping,sync:MPlaza.syncCloudflare}),MPlaza.Composition=Backbone.AssociatedModel.extend({defaults:{name:"",designID:-1,designDocID:"",modelID:-1,modelName:"",modelPrice:0,customerID:-1,visitorID:-1,finalPrice:0,previewImageData:null,previewImageUrl:"",compositionItems:[],categories:[]},idAttribute:"docID",initialize:function(){var e=this;this.get("compositionItems").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("compositionItems").on("add",function(){e._fireEvent("change")}),this.get("compositionItems").on("remove",function(){e._fireEvent("change")}),this.get("compositionItems").on("change",function(){e._fireEvent("change")})},_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},isEmpty:function(){return 0==this.get("compositionItems").length},relations:[{type:Backbone.Many,key:"compositionItems",collectionType:MPlaza.CompositionItems},{type:Backbone.Many,key:"categories",collectionType:MPlaza.CompositionCategoriesMapping}],url:function(){var e=Zakeke.config.baseApiUrl+"proxycompositions";return null!=this.id&&null!=this.id&&(e=e+"/"+this.id),e},getCompositionID:function(){return this.get("compositionID")},toString:function(){},setModel:function(e){e&&e instanceof MPlaza.Model&&(this.set("modelID",e.get("modelID")),this.set("modelName",e.get("name")),this.set("modelPrice",e.getModelPrice(printTypeID)))},getCompositionItemByAttributeID:function(e){return this.get("compositionItems").getCompositionItemByAttributeID(e)},getCompositionItemByAttributeGuid:function(e){return this.get("compositionItems").getCompositionItemByAttributeGuid(e)},getPrice:function(e,t){for(var i=e.get("price"),n=0;n<this.get("compositionItems").length;n++){var a=this.get("compositionItems").at(n),r=(e.getAttribute(a.get("attributeID")),this.getAttributePricing(a,e));if(r)if(null!=r.get("pricingID")&&r.get("pricingID")>0){var o=e.getComposerPricing(r.get("pricingID"));if(o){var s=o.getComposerPricingPriceForQuantity(t);s&&(i+=s.get("price"))}}else i+=r.get("price")}return i*t},getAttributePricing:function(e,t){var i=null,n=t.getAttribute(e.get("attributeID"));if(e.get("attributeTypeID")==MPlaza.AttributeType.Options&&e.get("selectedOptionID"))for(var a=0;a<n.get("pricings").length;a++){if((o=n.get("pricings").at(a)).get("selectedOptionID")==e.get("selectedOptionID"))if(!(r=o.get("constraintExpression"))||this.evaluateAttributeExpression(r)){i=o;break}}else if(e.get("selectedValue"))for(a=0;a<n.get("pricings").length;a++){var r;if((o=n.get("pricings").at(a)).get("selectedValue")==e.get("selectedValue"))if(!(r=o.get("constraintExpression"))||this.evaluateAttributeExpression(r)){i=o;break}}if(!i)for(a=0;a<n.get("pricings").length;a++){var o;if(!(o=n.get("pricings").at(a)).get("selectedOptionID")&&!o.get("selectedValue")){i=o;break}}return i},evaluateAttributeExpression:function(e){if(!(e&&e instanceof MPlaza.AttributeExpression))return!1;for(var t=e.get("op"),i=t==MPlaza.LogicalOperator.AND,n=0;n<e.get("propositions").length;n++){var a=e.get("propositions")[n],r=this.evaluateAttributeProposition(a);if(t==MPlaza.LogicalOperator.AND){if(!(i=i&&r))return!1}else if(i=i||r)return!0}for(n=0;n<e.get("expressions").length;n++){var o=e.get("expressions")[n];r=this.evaluateChildAttributeExpression(o);if(t==MPlaza.LogicalOperator.AND){if(!(i=i&&r))return!1}else if(i=i||r)return!0}return i},evaluateChildAttributeExpression:function(e){for(var t=e.op,i=t==MPlaza.LogicalOperator.AND,n=0;n<e.propositions.length;n++){var a=e.propositions[n],r=this.evaluateAttributeProposition(a);if(t==MPlaza.LogicalOperator.AND){if(!(i=i&&r))return!1}else if(i=i||r)return!0}for(n=0;n<e.expressions.length;n++){var o=e.expressions[n];r=this.evaluateChildAttributeExpression(o);if(t==MPlaza.LogicalOperator.AND){if(!(i=i&&r))return!1}else if(i=i||r)return!0}return i},evaluateAttributeProposition:function(e){if(e&&e.hasOwnProperty("attributeGuid")&&e.hasOwnProperty("op")&&e.hasOwnProperty("value")){var t=e.attributeGuid,i=this.getCompositionItemByAttributeGuid(t);if(i){var n=i.get("selectedValue");i.get("attributeTypeID")==MPlaza.AttributeType.Options&&(n=i.get("selectedOptionGuid"));var a=!1;if(e.op==MPlaza.ComparisonOperator.Equal)a=n==e.value;else if(e.op==MPlaza.ComparisonOperator.NotEqual)a=n!=e.value;else if(e.op==MPlaza.ComparisonOperator.In||e.op==MPlaza.ComparisonOperator.NotIn){var r=e.value.split(";");a=e.op==MPlaza.ComparisonOperator.In?Zakeke.arrayContains(r,n):!Zakeke.arrayContains(r,n)}return a}}return!1}}),MPlaza.Compositions=Backbone.Collection.extend({model:MPlaza.Composition,url:function(){return Zakeke.config.baseApiUrl+"proxycompositions"},getComposition:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("compositionID")==e)return i}return null},getCompositionByDocID:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("docID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.TemplateCategory=Backbone.AssociatedModel.extend({defaults:{id:-1,name:"",isDummy:!1,displayOrder:0},url:function(){return null},sync:MPlaza.syncCloudflare}),MPlaza.TemplateCategories=Backbone.Collection.extend({model:MPlaza.TemplateCategory,url:function(){return null},sync:MPlaza.syncCloudflare}),MPlaza.TemplateMacroCategory=Backbone.AssociatedModel.extend({defaults:{id:-1,name:"",isDummy:!1,displayOrder:0,categories:[]},initialize:function(){this.get("categories").parentModel=this},relations:[{type:Backbone.Many,key:"categories",collectionType:MPlaza.TemplateCategories}],url:function(){var e=Zakeke.config.baseApiUrl+"designs/templatemacrocategories";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},sync:MPlaza.syncCloudflare}),MPlaza.TemplateMacroCategories=Backbone.Collection.extend({model:MPlaza.TemplateMacroCategory,url:function(){return Zakeke.config.baseApiUrl+"designs/templatemacrocategories"},sync:MPlaza.syncCloudflare}),MPlaza.Grid=Backbone.AssociatedModel.extend({defaults:{json:"",svg:"",name:"",sellerID:-1,isDeleted:!1},idAttribute:"gridID",initialize:function(){},relations:[],getGridRuleID:function(){return this.collection&&this.collection.getGridRuleID?this.collection.getGridRuleID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.Grids=Backbone.Collection.extend({model:MPlaza.Grid,getGridRuleID:function(){return this.parentModel&&this.parentModel.getGridRuleID?this.parentModel.getGridRuleID():null},findGrid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("gridID")==e)return i}return null},sync:MPlaza.syncCloudflare,comparator:function(e){return e.get("name")}}),MPlaza.GridRuleGridSideMapping=Backbone.AssociatedModel.extend({defaults:{gridRuleID:-1,gridID:-1,productID:null,sideID:null},initialize:function(){},relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.GridRuleGridSideMappings=Backbone.Collection.extend({model:MPlaza.GridRuleGridSideMapping,modelId:function(e){return e.gridID+"-"+e.productID+"-"+e.sideID},getGridRuleID:function(){return this.parentModel&&this.parentModel.getGridRuleID?this.parentModel.getGridRuleID():null},findAssociation:function(e,t,i,n){for(var a=0;a<this.length;a++){var r=this.at(a);if(r.get("gridRuleID")==e&&r.get("gridID")==t&&r.get("productID")==i&&r.get("sideID")==n)return r}return null},sync:MPlaza.syncCloudflare}),MPlaza.GridRule=Backbone.AssociatedModel.extend({defaults:{name:"",sellerID:-1,associations:[],grids:[]},idAttribute:"gridRuleID",initialize:function(){var e=this;this.get("associations").parentModel=this,this.get("grids").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("associations").on("add",function(){e._fireEvent("change")}),this.get("associations").on("remove",function(){e._fireEvent("change")}),this.get("associations").on("change",function(){e._fireEvent("change")})},relations:[{type:Backbone.Many,key:"associations",collectionType:MPlaza.GridRuleGridSideMappings},{type:Backbone.Many,key:"grids",collectionType:MPlaza.Grids}],url:function(){var e=Zakeke.config.baseApiUrl+"gridrules";return null!=this.id&&null!=this.id&&(e=e+"/"+this.id),e},getGridRuleID:function(){return this.get("gridRuleID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.GridRules=Backbone.Collection.extend({model:MPlaza.GridRule,url:function(){return Zakeke.config.baseApiUrl+"gridrules/"},findGridRule:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("gridRuleID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.Quote=Backbone.AssociatedModel.extend({defaults:{sellerID:-1,designDocID:"",compositionDocID:"",orderDocID:"",visitorID:-1,visitorCode:"",customerID:-1,customerCode:"",formData:"",subject:"",statusID:1,createdOn:null,amount:0,shippingAmount:0,additionalAmountLabel:"",additionalAmount:0,modelPrice:0,variantName:"",quantity:1,notifyEmailList:"",quoteRuleID:-1},idAttribute:"quoteID",initialize:function(){},relations:[],getQuoteID:function(){return this.collection&&this.collection.getQuoteID?this.collection.getQuoteID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},url:function(){var e=Zakeke.config.baseApiUrl+"quotes";return null!=this.id&&null!=this.id&&(e=e+"/"+this.id),e},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.Quotes=Backbone.Collection.extend({model:MPlaza.Quote,getQuoteID:function(){return this.parentModel&&this.parentModel.getQuoteID?this.parentModel.getQuoteID():null},findQuote:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("quoteID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignEffectTemplate=Backbone.AssociatedModel.extend({defaults:{name:"",sellerID:-1,previewDesignEffect:null,outputDesignEffect:null},idAttribute:"templateID",initialize:function(){},relations:[{type:Backbone.One,key:"previewDesignEffect",relatedModel:MPlaza.DesignEffect},{type:Backbone.One,key:"outputDesignEffect",relatedModel:MPlaza.DesignEffect}],url:function(){var e=Zakeke.config.baseApiUrl+"gridrules";return void 0!==this.id&&null!==this.id&&(e=e+"/"+this.id),e},getTemplateID:function(){return this.get("templateID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignEffectTemplates=Backbone.Collection.extend({model:MPlaza.DesignEffectTemplate,url:function(){return Zakeke.config.baseApiUrl+"designeffecttemplates/"},findTemplate:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("templateID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ShapeCategory=Backbone.AssociatedModel.extend({defaults:{name:"",imagesCount:0},idAttribute:"shapeCategoryID",initialize:function(){},relations:[],url:function(){var e=Zakeke.config.baseApiUrl+"shapeCategories";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},sync:MPlaza.syncCloudflare}),MPlaza.ShapeCategories=Backbone.Collection.extend({model:MPlaza.ShapeCategory,url:function(){return Zakeke.config.baseApiUrl+"shapeCategories"},comparator:function(e){return e.get("name")},sync:MPlaza.syncCloudflare}),MPlaza.ShapeAssignedCategory=Backbone.AssociatedModel.extend({defaults:{shapeCategoryID:-1,name:""},initialize:function(){},relations:[],getShapeID:function(){return this.collection&&this.collection.getShapeID?this.collection.getShapeID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ShapeAssignedCategories=Backbone.Collection.extend({model:MPlaza.ShapeAssignedCategory,getShapeID:function(){return this.parentModel&&this.parentModel.getShapeID?this.parentModel.getShapeID():null},findShapeCategory:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("shapeCategoryID")===e)return i}return null},setupUrlForShapeID:function(e){this.url=function(){return Zakeke.config.baseApiUrl+"shapes/"+e+"/categories"}},sync:MPlaza.syncCloudflare}),MPlaza.Shape=Backbone.AssociatedModel.extend({defaults:{name:"",tags:"",pathDataUrl:"",imageUrl:"",maskImageUrl:"",categories:[]},idAttribute:"shapeID",initialize:function(){var e=this;this.get("categories").parentModel=this,this.get("categories").url=function(){return e.url()+"/"+e.id+"/categories"},this.get("shapeGuid")||this.set("shapeGuid",MPlaza.generateUUID())},relations:[{type:Backbone.Many,key:"categories",collectionType:MPlaza.ShapeAssignedCategories}],url:function(){var e=Zakeke.config.baseApiUrl+"shapes";return void 0!==this.id&&null!==this.id&&this.id>0&&(e=e+"/"+this.id),e},getShapeID:function(){return this.get("shapeID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.Shapes=Backbone.Collection.extend({model:MPlaza.Shape,url:function(){return Zakeke.config.baseApiUrl+"shapes"},getShape:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("shapeID")===e)return i}return null},sync:MPlaza.syncCloudflare}),function(e){!function(e){var t=function(){function e(){this._topNode=void 0,this._count=0,this._changedEventListeners=[],this._enableChangedEvent=!0}return e.prototype.count=function(){return this._count},e.prototype.isEmpty=function(){return void 0===this._topNode},e.prototype.push=function(e){var t=new i(e,this._topNode);this._topNode=t,this._count++,this.fireChangedEventListener()},e.prototype.pop=function(){if(0!=this._count){var e=this._topNode;return this._topNode=e.previous,this._count--,this.fireChangedEventListener(),e.data}},e.prototype.peek=function(){return this._topNode.data},e.prototype.clear=function(){this._topNode&&this._count>0&&(this._topNode=void 0,this._count=0,this.fireChangedEventListener())},e.prototype.addChangedEventListener=function(e){this._changedEventListeners.push(e)},e.prototype.removeChangedEventListener=function(e){for(var t=0;t<this._changedEventListeners.length;t++)this._changedEventListeners[t]==e&&this._changedEventListeners.splice(t--,1)},e.prototype.fireChangedEventListener=function(){if(this._enableChangedEvent)for(var e=0;e<this._changedEventListeners.length;e++){(0,this._changedEventListeners[e])()}},e.prototype.getAllData=function(){for(var e=new Array(this._count),t=this._count-1,i=this._topNode;i;)e[t]=i.data,i=i.previous,t--;return e},e.prototype.getLastData=function(e){for(var t=this._topNode;t;){if(!e||e(t.data))return t.data;t=t.previous}return null},e.prototype.getAllDataAfter=function(e){for(var t=[],i=this._topNode;i&&i.data!=e;)t.push(i.data),i=i.previous;return t.reverse()},e.prototype.removeDataArray=function(e){var t=this;this._enableChangedEvent=!1,e.forEach(function(e){t.removeData(e)}),this._enableChangedEvent=!0,this.fireChangedEventListener()},e.prototype.removeData=function(e){var t=this.getNodeHavingData(e);t&&(this.removeNode(t),this.fireChangedEventListener())},e.prototype.getNodeHavingData=function(e){for(var t=this._topNode;t;){if(t.data==e)return t;t=t.previous}return null},e.prototype.removeNode=function(e){if(e)if(this._topNode==e)this._topNode=e.previous,this._count--;else{var t=this.getFollowingNode(e);t&&(t.previous=e.previous,this._count--)}},e.prototype.getFollowingNode=function(e){for(var t=this._topNode;t;){if(t.previous==e)return t;t=t.previous}},e}();e.Stack=t;var i=function(){return function(e,t){this.previous=t,this.data=e}}()}(e.Customizer||(e.Customizer={}))}(Zakeke||(Zakeke={})),MarvinColorModelConverter.rgbToBinary=function(e,t){for(var i=new MarvinImage(e.getWidth(),e.getHeight(),MarvinImage.COLOR_MODEL_BINARY),n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++){Math.ceil(.3*e.getIntComponent0(a,n)+.59*e.getIntComponent1(a,n)+.11*e.getIntComponent2(a,n))<=t?i.setBinaryColor(a,n,!0):i.setBinaryColor(a,n,!1)}return i},MarvinColorModelConverter.binaryToRgb=function(e){for(var t=new MarvinImage(e.getWidth(),e.getHeight(),MarvinImage.COLOR_MODEL_RGB),i=0;i<e.getHeight();i++)for(var n=0;n<e.getWidth();n++)e.getBinaryColor(n,i)?t.setIntColor(n,i,255,0,0,0):t.setIntColor(n,i,255,255,255,255);return t},MarvinColorModelConverter.rgbToHsv=function(e){for(var t,i,n,a=new Array(3*e.length),r=0;r<e.length;r++){t=(16711680&e[r])>>>16,i=(65280&e[r])>>>8,n=255&e[r],t/=255,i/=255,n/=255;var o,s,l,h=Math.max(Math.max(t,i),n),d=h-Math.min(Math.min(t,i),n);o=0!=d?h==t?i>=n?(i-n)/d*60:(i-n)/d*60+360:h==i?(n-t)/d*60+120:(t-i)/d*60+240:0,l=h,s=0!=d?d/l:0,a[3*r]=o,a[3*r+1]=s,a[3*r+2]=l}return a},MarvinColorModelConverter.hsvToRgb=function(e){for(var t=new Array(e.length/3),i=0,n=0;i<e.length;i+=3,n++){var a=e[i],r=e[i+1],o=e[i+2],s=Math.ceil(a/60%6),l=a/60-s,h=o*(1-r),d=o*(1-l*r),c=o*(1-(1-l)*r),u=0,g=0,f=0;switch(Math.ceil(s)){case 0:u=Math.ceil(255*o),g=Math.ceil(255*c),f=Math.ceil(255*h);break;case 1:u=Math.ceil(255*d),g=Math.ceil(255*o),f=Math.ceil(255*h);break;case 2:u=Math.ceil(255*h),g=Math.ceil(255*o),f=Math.ceil(255*c);break;case 3:u=Math.ceil(255*h),g=Math.ceil(255*d),f=Math.ceil(255*o);break;case 4:u=Math.ceil(255*c),g=Math.ceil(255*h),f=Math.ceil(255*o);break;case 5:u=Math.ceil(255*o),g=Math.ceil(255*h),f=Math.ceil(255*d)}t[n]=4278190080+(u<<16)+(g<<8)+f}return t},MarvinImage.COLOR_MODEL_RGB=0,MarvinImage.COLOR_MODEL_BINARY=1,MarvinImage.prototype.create=function(e,t){this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t,this.ctx=this.canvas.getContext("2d"),this.imageData=this.ctx.getImageData(0,0,e,t),this.width=e,this.height=t},MarvinImage.prototype.setDimension=function(e,t){this.create(e,t)},MarvinImage.prototype.load=function(e,t){this.onload=t,this.image=new Image;var i=this;this.image.onload=function(){i.callbackImageLoaded(i)},this.image.crossOrigin="anonymous",this.image.src=e},MarvinImage.prototype.callbackImageLoaded=function(e){e.width=e.image.width,e.height=e.image.height,e.canvas=document.createElement("canvas"),e.canvas.width=e.image.width,e.canvas.height=e.image.height,e.ctx=e.canvas.getContext("2d"),e.ctx.drawImage(e.image,0,0),this.imageData=e.ctx.getImageData(0,0,e.getWidth(),e.getHeight()),null!=e.onload&&e.onload()},MarvinImage.prototype.clone=function(){var e=new MarvinImage(this.getWidth(),this.getHeight(),this.colorModel);return MarvinImage.copyColorArray(this,e),e},MarvinImage.prototype.update=function(e){this.canvas.getContext("2d").putImageData(this.imageData,0,0)},MarvinImage.prototype.clear=function(e){for(var t=0;t<this.getHeight();t++)for(var i=0;i<this.getWidth();i++)this.setIntColor(i,t,e)},MarvinImage.prototype.getColorModel=function(){return this.colorModel},MarvinImage.prototype.getAlphaComponent=function(e,t){var i=4*(t*this.getWidth()+e);return this.imageData.data[i+3]},MarvinImage.prototype.setAlphaComponent=function(e,t,i){var n=4*(t*this.getWidth()+e);this.imageData.data[n+3]=i},MarvinImage.prototype.getIntComponent0=function(e,t){var i=4*(t*this.getWidth()+e);return this.imageData.data[i]},MarvinImage.prototype.getIntComponent1=function(e,t){var i=4*(t*this.getWidth()+e);return this.imageData.data[i+1]},MarvinImage.prototype.getIntComponent2=function(e,t){var i=4*(t*this.getWidth()+e);return this.imageData.data[i+2]},MarvinImage.prototype.setIntColor=function(e,t,i,n,a,r){null==n?this.setIntColor1(e,t,i):null==a&&null==r?this.setIntColor2(e,t,i,n):null==r?this.setIntColor3(e,t,i,n,a):this.setIntColor4(e,t,i,n,a,r)},MarvinImage.prototype.getIntColor=function(e,t){var i=4*(t*this.getWidth()+e);return 4294967296+(this.imageData.data[i+3]<<24)+(this.imageData.data[i]<<16)+(this.imageData.data[i+1]<<8)+this.imageData.data[i+2]},MarvinImage.prototype.setIntColor1=function(e,t,i){var n=(4278190080&i)>>>24,a=(16711680&i)>>16,r=(65280&i)>>8,o=255&i;this.setIntColor4(e,t,n,a,r,o)},MarvinImage.prototype.setBinaryColor=function(e,t,i){var n=t*this.getWidth()+e;this.arrBinaryColor[n]=i},MarvinImage.prototype.getBinaryColor=function(e,t){var i=t*this.getWidth()+e;return this.arrBinaryColor[i]},MarvinImage.copyColorArray=function(e,t){if(e.getColorModel()==t.getColorModel())switch(e.getColorModel()){case MarvinImage.COLOR_MODEL_RGB:for(var i=0;i<e.imageData.data.length;i++)t.imageData.data[i]=e.imageData.data[i];break;case MarvinImage.COLOR_MODEL_BINARY:for(i=0;i<e.arrBinaryColor.length;i++)t.arrBinaryColor[i]=e.arrBinaryColor[i]}},MarvinImage.prototype.drawRect=function(e,t,i,n,a){for(var r=e;r<e+i;r++)this.setIntColor(r,t,a),this.setIntColor(r,t+(n-1),a);for(r=t;r<t+n;r++)this.setIntColor(e,r,a),this.setIntColor(e+(i-1),r,a)},MarvinImage.prototype.fillRect=function(e,t,i,n,a){for(var r=e;r<e+i;r++)for(var o=t;o<t+n;o++)r<this.getWidth()&&o<this.getHeight()&&this.setIntColor(r,o,a)},MarvinImage.prototype.setColorToAlpha=function(e,t){for(var i=0;i<this.height;i++)for(var n=0;n<this.width;n++)(16777215&this.getIntColor(n,i))==(16777215&e)&&this.setAlphaComponent(n,i,t)},MarvinImage.prototype.setAlphaToColor=function(e){for(var t=0;t<this.height;t++)for(var i=0;i<this.width;i++)0==this.getAlphaComponent(i,t)&&this.setIntColor(i,t,4294967295)},MarvinImage.prototype.setIntColor2=function(e,t,i,n){var a=(16711680&n)>>16,r=(65280&n)>>8,o=255&n;this.setIntColor4(e,t,i,a,r,o)},MarvinImage.prototype.setIntColor3=function(e,t,i,n,a){this.setIntColor4(e,t,255,i,n,a)},MarvinImage.prototype.setIntColor4=function(e,t,i,n,a,r){var o=4*(t*this.getWidth()+e);this.imageData.data[o]=n,this.imageData.data[o+1]=a,this.imageData.data[o+2]=r,this.imageData.data[o+3]=i},MarvinImage.prototype.getWidth=function(){return this.width},MarvinImage.prototype.getHeight=function(){return this.height},MarvinImage.prototype.isValidPosition=function(e,t){return e>=0&&e<this.width&&t>=0&&t<this.height},MarvinImage.prototype.draw=function(e,t,i,n){null==t&&(t=0),null==i&&(i=0),e.getContext("2d").putImageData(this.imageData,t,i)},MarvinImage.prototype.toBlob=function(){return this.update(),MarvinImage.dataURItoBlob(this.canvas.toDataURL("image/png"))},MarvinImage.dataURItoBlob=function(e){var t;t=e.split(",")[0].indexOf("base64")>=0?atob(e.split(",")[1]):unescape(e.split(",")[1]);for(var i=e.split(",")[0].split(":")[1].split(";")[0],n=new Uint8Array(t.length),a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return new Blob([n],{type:i})},MarvinImageMask.prototype.getWidth=function(){return this.width},MarvinImageMask.prototype.getHeight=function(){return this.height},MarvinImageMask.prototype.addPixel=function(e,t){this.arrMask[e][t]=!0},MarvinImageMask.prototype.removePixel=function(e,t){this.arrMask[e][t]=!1},MarvinImageMask.prototype.clear=function(){if(null!=this.arrMask)for(var e=0;e<height;e++)for(var t=0;t<width;t++)this.arrMask[t][e]=!1},MarvinImageMask.prototype.getMask=function(){return this.arrMask},MarvinImageMask.prototype.addRectRegion=function(e,t,i,n){for(var a=e;a<e+i;a++)for(var r=t;r<t+n;r++)this.arrMask[a][r]=!0},MarvinImageMask.createNullMask=function(){return new MarvinImageMask(0,0)},MarvinImageMask.NULL_MASK=MarvinImageMask.createNullMask(),MarvinSegment.segmentMinDistance=function(e,t){for(var i,n,a=0;a<e.size()-1;a++)for(var r=a+1;r<e.size();r++)i=e[a],n=e[r],MarvinMath.euclidianDistance((i.x1+i.x2)/2,(i.y1+i.y2)/2,(n.x1+n.x2)/2,(n.y1+n.y2)/2)<t&&(e.splice(r,1),r--)},MarvinColor.prototype.setId=function(e){this.id=e},MarvinColor.prototype.getId=function(){return this.id},MarvinColor.prototype.setName=function(e){this.name=e},MarvinColor.prototype.getName=function(){return this.name};var MarvinJSUtils=new Object;MarvinJSUtils.createMatrix2D=function(e,t,i){for(var n=new Array(e),a=0;a<n.length;a++)n[a]=new Array(t),n[a].fill(i);return n},MarvinJSUtils.createMatrix3D=function(e,t,i,n){for(var a=new Array(e),r=0;r<a.length;r++){a[r]=new Array(t);for(var o=0;o<a[r].length;o++)a[r][o]=new Array(i),a[r][o].fill(n)}return a},MarvinJSUtils.createMatrix4D=function(e,t,i,n,a){for(var r=new Array(e),o=0;o<r.length;o++){r[o]=new Array(t);for(var s=0;s<r[o].length;s++){r[o][s]=new Array(i);for(var l=0;l<r[o][s].length;l++)r[o][s][l]=new Array(n),r[o][s][l].fill(a)}}return r};var MarvinMath=new Object;function DetermineFixedCameraBackground(){MarvinAbstractImagePlugin.super(this),this.load()}function DetermineSceneBackground(){MarvinAbstractImagePlugin.super(this),this.load()}function GaussianBlur(){MarvinAbstractImagePlugin.super(this),this.load()}function AlphaBoundary(){MarvinAbstractImagePlugin.super(this),this.load()}function AverageColor(){MarvinAbstractImagePlugin.super(this),this.load()}function BlackAndWhite(){MarvinAbstractImagePlugin.super(this),this.MAX_RLEVEL=.03,this.load()}function BrightnessAndContrast(){MarvinAbstractImagePlugin.super(this),this.load()}function ColorChannel(){MarvinAbstractImagePlugin.super(this),this.load()}function Emboss(){MarvinAbstractImagePlugin.super(this),this.load()}function GrayScale(){MarvinAbstractImagePlugin.super(this),this.load()}function Invert(){MarvinAbstractImagePlugin.super(this),this.load()}function Sepia(){MarvinAbstractImagePlugin.super(this),this.load()}function Thresholding(){MarvinAbstractImagePlugin.super(this),this.load(),this.threshold=null,this.thresholdRange=null,this.neighborhood=null,this.range=null}function ThresholdingNeighborhood(){MarvinAbstractImagePlugin.super(this),this.load()}function CombineByAlpha(){MarvinAbstractImagePlugin.super(this),this.load()}function MergePhotos(){MarvinAbstractImagePlugin.super(this),this.load()}function Convolution(){MarvinAbstractImagePlugin.super(this),this.load()}function Moravec(){MarvinAbstractImagePlugin.super(this),this.load()}function Prewitt(){MarvinAbstractImagePlugin.super(this),this.matrixPrewittX=[[1,0,-1],[1,0,-1],[1,0,-1]],this.matrixPrewittY=[[1,1,1],[0,0,0],[-1,-1,-1]],this.load()}function BoundaryFill(){MarvinAbstractImagePlugin.super(this),this.load()}function ErrorDiffusion(){MarvinAbstractImagePlugin.super(this),this.load()}MarvinMath.getTrueMatrix=function(e,t){for(var i=MarvinJSUtils.createMatrix2D(e,t),n=0;n<e;n++)for(var a=0;a<t;a++)i[n][a]=!0;return i},MarvinMath.scaleMatrix=function(e,t){for(var i=MarvinJSUtils.createMatrix2D(e.length,e.length),n=0;n<e.length;n++)for(var a=0;a<e.length;a++)i[n][a]=e[n][a]*t;return i},MarvinMath.euclideanDistance=function(e,t,i,n,a,r){return null!=r?MarvinMath.euclideanDistance3D(e,t,i,n,a,r):MarvinMath.euclideanDistance3D(e,t,i,n)},MarvinMath.euclideanDistance2D=function(e,t,i,n){var a=e-i,r=t-n;return Math.sqrt(a*a+r*r)},MarvinMath.euclideanDistance3D=function(e,t,i,n,a,r){var o=e-n,s=t-a,l=i-r;return Math.sqrt(o*o+s*s+l*l)},DetermineFixedCameraBackground.prototype.load=function(){this.initialized=!1},DetermineFixedCameraBackground.prototype.initialize=function(e){this.weights=this.weights=MarvinJSUtils.createMatrix4D(e.getWidth(),e.getHeight(),3,26,0),initialized=!0},DetermineFixedCameraBackground.prototype.process=function(e,t,i,n,a){this.initialized||this.initialize(e);for(var r=0;r<e.getHeight();r++)for(var o=0;o<e.getWidth();o++){var s=e.getIntComponent0(o,r),l=e.getIntComponent1(o,r),h=e.getIntComponent2(o,r);weights[o][r][0][s/10]++,weights[o][r][1][l/10]++,weights[o][r][2][h/10]++,t.setIntColor(o,r,255,this.getProbableColor(weights[o][r][0]),this.getProbableColor(weights[o][r][1]),this.getProbableColor(weights[o][r][2]))}},DetermineFixedCameraBackground.prototype.getProbableColor=function(e){for(var t=-1,i=0,n=0;n<e.length;n++)(-1==t||e[n]>t)&&(t=e[n],i=n);return 10*i},DetermineSceneBackground.prototype.load=function(){this.setAttribute("threshold",30)},DetermineSceneBackground.prototype.process=function(e,t){for(var i=this.getAttribute("threshold"),n=e[0],a=0;a<n.getHeight();a++)for(var r=0;r<n.getWidth();r++)t.setIntColor(r,a,this.getBackgroundPixel(r,a,e,i))},DetermineSceneBackground.prototype.getBackgroundPixel=function(e,t,i,n){var a=new Array;for(var r in i){var o=i[r],s=new Array(4);if(s[0]=o.getIntComponent0(e,t),s[1]=o.getIntComponent1(e,t),s[2]=o.getIntComponent2(e,t),s[3]=0,0==a.length)a.push(s);else{var l=!1;for(var h in a){var d=a[h];if(Math.abs(d[0]-s[0])<.3*n&&Math.abs(d[1]-s[1])<.3*n&&Math.abs(d[2]-s[2])<.3*n){d[0]=Math.floor((d[0]+s[0])/2),d[1]=Math.floor((d[1]+s[1])/2),d[2]=Math.floor((d[2]+s[2])/2),d[3]++,l=!0;break}}l||a.push(s)}}var c=-1,u=0;for(d=null,r=0;r<a.length;r++)d=a[r],(-1==c||d[3]>c)&&(c=d[3],u=r);return 4278190080+((d=a[u])[0]<<16)+(d[1]<<8)+d[2]},GaussianBlur.prototype.load=function(){this.RED=0,this.GREEN=1,this.BLUE=2,this.kernelMatrix=null,this.resultMatrix=null,this.appiledkernelMatrix=null,this.radius=null,this.setAttribute("radius",3)},GaussianBlur.prototype.process=function(e,t,i,n,a){this.radius=this.getAttribute("radius");var r,o=e.getWidth(),s=e.getHeight();this.kernelMatrix=this.getGaussianKernel(),this.resultMatrix=MarvinJSUtils.createMatrix3D(o,s,3,0),this.appiledkernelMatrix=MarvinJSUtils.createMatrix2D(o,s,0);for(var l=n.getMask(),h=0;h<o;h++)for(var d=0;d<s;d++)(null==l||l[h][d])&&(r=e.getIntColor(h,d),this.applyKernel(h,d,r,t));for(h=0;h<o;h++)for(d=0;d<s;d++)(null==l||l[h][d])&&(this.resultMatrix[h][d][this.RED]=this.resultMatrix[h][d][0]/this.appiledkernelMatrix[h][d]%256,this.resultMatrix[h][d][this.GREEN]=this.resultMatrix[h][d][1]/this.appiledkernelMatrix[h][d]%256,this.resultMatrix[h][d][this.BLUE]=this.resultMatrix[h][d][2]/this.appiledkernelMatrix[h][d]%256,t.setIntColor(h,d,e.getAlphaComponent(h,d),Math.floor(this.resultMatrix[h][d][0]),Math.floor(this.resultMatrix[h][d][1]),Math.floor(this.resultMatrix[h][d][2])))},GaussianBlur.prototype.getGaussianKernel=function(){for(var e,t,i,n=MarvinJSUtils.createMatrix2D(2*this.radius+1,2*this.radius+1),a=this.radius/3,r=1;r<=2*this.radius+1;r++)for(var o=1;o<=2*this.radius+1;o++)t=Math.abs(r-(this.radius+1)),i=Math.abs(o-(this.radius+1)),e=Math.sqrt(t*t+i*i),n[o-1][r-1]=1/(2*Math.PI*a*a)*Math.exp(-e*e/(2*a*a));return n},GaussianBlur.prototype.applyKernel=function(e,t,i,n){for(var a=t;a<t+2*this.radius;a++)for(var r=e;r<e+2*this.radius;r++)r-this.radius>=0&&r-this.radius<n.getWidth()&&a-this.radius>=0&&a-this.radius<n.getHeight()&&(this.resultMatrix[r-this.radius][a-this.radius][this.RED]+=((16711680&i)>>>16)*this.kernelMatrix[r-e][a-t],this.resultMatrix[r-this.radius][a-this.radius][this.GREEN]+=((65280&i)>>>8)*this.kernelMatrix[r-e][a-t],this.resultMatrix[r-this.radius][a-this.radius][this.BLUE]+=(255&i)*this.kernelMatrix[r-e][a-t],this.appiledkernelMatrix[r-this.radius][a-this.radius]+=this.kernelMatrix[r-e][a-t])},AlphaBoundary.prototype.load=function(){this.setAttribute("radius",5)},AlphaBoundary.prototype.process=function(e,t,i,n,a){for(var r=this.getAttribute("radius"),o=0;o<t.getHeight();o++)for(var s=0;s<t.getWidth();s++)this.alphaRadius(t,s,o,r)},AlphaBoundary.prototype.alphaRadius=function(e,t,i,n){for(var a,r=e.getAlphaComponent(t,i),o=0,s=0,l=Math.floor(n/2),h=i-l;h<i+l;h++)for(var d=t-l;d<t+l;d++)d>=0&&d<e.getWidth()&&h>=0&&h<e.getHeight()&&(o+=e.getAlphaComponent(d,h),s++);(a=Math.floor(o/s))<r&&e.setAlphaComponent(t,i,a)},AverageColor.prototype.load=function(){},AverageColor.prototype.process=function(e,t,i,n,a){for(var r=0,o=0,s=0,l=0;l<e.getWidth();l++)for(var h=0;h<e.getHeight();h++)r+=e.getIntComponent0(l,h),o+=e.getIntComponent1(l,h),s+=e.getIntComponent2(l,h);var d=e.getWidth()*e.getHeight();r=Math.round(r/d),o=Math.round(o/d),s=Math.round(s/d),null!=i&&i.set("averageColor",[r,o,s])},BlackAndWhite.prototype.load=function(){this.grayScale=new GrayScale,this.setAttribute("level",10)},BlackAndWhite.prototype.process=function(e,t,i,n,a){this.grayScale.process(e,t);for(var r,o=this.getAttribute("level"),s=o/100*this.MAX_RLEVEL,l=0,h=0;h<t.getHeight();h++)for(var d=0;d<t.getWidth();d++)r=(r=e.getIntComponent0(d,h))<=127?Math.max(r*(1-(127-r)*s),0):Math.min(r*(1+(r-127)*s),255),l++<1&&(console.log("gray:"+r),console.log("level:"+o),console.log("rlevel:"+s)),t.setIntColor(d,h,255,Math.floor(r),Math.floor(r),Math.floor(r))},BrightnessAndContrast.prototype.load=function(){this.setAttribute("brightness",0),this.setAttribute("contrast",0)},BrightnessAndContrast.prototype.process=function(e,t,i,n,a){var r,o,s,l=this.getAttribute("brightness"),h=this.getAttribute("contrast");h=Math.pow((127+h)/127,2);for(var d=0;d<e.getWidth();d++)for(var c=0;c<e.getHeight();c++)r=e.getIntComponent0(d,c),o=e.getIntComponent1(d,c),s=e.getIntComponent2(d,c),(r+=(1-r/255)*l)<0&&(r=0),r>255&&(r=255),(o+=(1-o/255)*l)<0&&(o=0),o>255&&(o=255),(s+=(1-s/255)*l)<0&&(s=0),s>255&&(s=255),t.setIntColor(d,c,e.getAlphaComponent(d,c),Math.floor(r),Math.floor(o),Math.floor(s));for(d=0;d<e.getWidth();d++)for(c=0;c<e.getHeight();c++)r=t.getIntComponent0(d,c),o=t.getIntComponent1(d,c),s=t.getIntComponent2(d,c),r/=255,r-=.5,r*=h,r+=.5,o/=255,o-=.5,o*=h,o+=.5,s/=255,s-=.5,s*=h,s+=.5,(r*=255)<0&&(r=0),r>255&&(r=255),(o*=255)<0&&(o=0),o>255&&(o=255),(s*=255)<0&&(s=0),s>255&&(s=255),t.setIntColor(d,c,e.getAlphaComponent(d,c),Math.floor(r),Math.floor(o),Math.floor(s))},ColorChannel.prototype.load=function(){this.setAttribute("red",0),this.setAttribute("green",0),this.setAttribute("blue",0)},ColorChannel.prototype.process=function(e,t,i,n,a){var r,o,s,l=this.getAttribute("red"),h=this.getAttribute("green"),d=this.getAttribute("blue"),c=1+Math.abs(l/100*2.5),u=1+Math.abs(h/100*2.5),g=1+Math.abs(d/100*2.5);c=l>0?c:1/c,u=h>0?u:1/u,g=d>0?g:1/g;for(var f=0;f<e.getHeight();f++)for(var p=0;p<e.getWidth();p++)r=e.getIntComponent0(p,f),o=e.getIntComponent1(p,f),s=e.getIntComponent2(p,f),r=Math.min(r*c,255),o=Math.min(o*u,255),s=Math.min(s*g,255),t.setIntColor(p,f,255,r,o,s)},Emboss.prototype.load=function(){},Emboss.prototype.process=function(e,t,i,n,a){for(var r=n.getMask(),o=0;o<e.getWidth();o++)for(var s=0;s<e.getHeight();s++)if(null==r||r[o][s]){var l=0,h=0,d=0;s>0&&o>0?(l=e.getIntComponent0(o,s)-e.getIntComponent0(o-1,s-1),h=e.getIntComponent1(o,s)-e.getIntComponent1(o-1,s-1),d=e.getIntComponent2(o,s)-e.getIntComponent2(o-1,s-1)):(l=0,h=0,d=0);var c=l;Math.abs(h)>Math.abs(c)&&(c=h),Math.abs(d)>Math.abs(c)&&(c=d);var u=Math.max(Math.min(128+c,255),0);t.setIntColor(o,s,255,u,u,u)}else t.setIntColor(o,s,255,e.getIntColor(o,s))},GrayScale.prototype.load=function(){},GrayScale.prototype.process=function(e,t,i,n,a){var r,o,s,l,h;null!=n&&(r=n.getMask());for(var d=0;d<e.getWidth();d++)for(var c=0;c<e.getHeight();c++)(null==r||r[d][c])&&(o=e.getIntComponent0(d,c),s=e.getIntComponent1(d,c),l=e.getIntComponent2(d,c),h=Math.ceil(.3*o+.59*s+.11*l),t.setIntColor(d,c,e.getAlphaComponent(d,c),h,h,h))},Invert.prototype.load=function(){},Invert.prototype.process=function(e,t,i,n,a){for(var r,o,s,l=n.getMask(),h=0;h<e.getWidth();h++)for(var d=0;d<e.getHeight();d++)(null==l||l[h][d])&&(r=255-e.getIntComponent0(h,d),o=255-e.getIntComponent1(h,d),s=255-e.getIntComponent2(h,d),t.setIntColor(h,d,e.getAlphaComponent(h,d),r,o,s))},Sepia.prototype.load=function(){this.setAttribute("txtValue","20"),this.setAttribute("intensity",20)},Sepia.prototype.process=function(e,t,i,n,a){var r,o,s,l;l=this.getAttribute("intensity");e.getWidth(),e.getHeight();for(var h=n.getMask(),d=0;d<e.getWidth();d++)for(var c=0;c<e.getHeight();c++)(null==h||h[d][c])&&(r=o=s=((r=e.getIntComponent0(d,c))+(o=e.getIntComponent1(d,c))+(s=e.getIntComponent2(d,c)))/3,r=this.truncate(r+2*l),o=this.truncate(o+l),t.setIntColor(d,c,e.getAlphaComponent(d,c),r,o,s))},Sepia.prototype.truncate=function(e){return e<0?0:e>255?255:e},Thresholding.prototype.load=function(){this.setAttribute("threshold",125),this.setAttribute("thresholdRange",-1),this.setAttribute("neighborhood",-1),this.setAttribute("range",-1),this.pluginGray=new GrayScale},Thresholding.prototype.process=function(e,t,i,n,a){this.threshold=this.getAttribute("threshold"),this.thresholdRange=this.getAttribute("thresholdRange"),this.neighborhood=this.getAttribute("neighborhood"),this.range=this.getAttribute("range"),-1==this.thresholdRange&&(this.thresholdRange=255-threshold),this.pluginGray.process(e,t,i,n,a);var r=n.getMask();-1==this.neighborhood&&-1==this.range?this.hardThreshold(e,t,r):this.contrastThreshold(e,t)},Thresholding.prototype.hardThreshold=function(e,t,i){for(var n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++)if(null==i||i[a][n]){var r=e.getIntComponent0(a,n);r<this.threshold||r>this.threshold+this.thresholdRange?t.setIntColor(a,n,e.getAlphaComponent(a,n),0,0,0):t.setIntColor(a,n,e.getAlphaComponent(a,n),255,255,255)}},Thresholding.prototype.contrastThreshold=function(e,t){this.range=1;for(var i=0;i<e.getWidth();i++)for(var n=0;n<e.getHeight();n++)checkNeighbors(i,n,neighborhood,neighborhood,e)?t.setIntColor(i,n,0,0,0):t.setIntColor(i,n,255,255,255)},Thresholding.prototype.checkNeighbors=function(e,t,i,n,a){var r,o=0;r=a.getIntComponent0(e,t);for(var s=0-i;s<=i;s++)for(var l=0-n;l<=n;l++)0==s&&0==l||r<getSafeColor(e+s,t+l,a)-range&&-1!=getSafeColor(e+s,t+l,a)&&o++;return o>i*n*.5},Thresholding.prototype.getSafeColor=function(e,t,i){return e>=0&&e<i.getWidth()&&t>=0&&t<i.getHeight()?i.getIntComponent0(e,t):-1},ThresholdingNeighborhood.prototype.load=function(){this.setAttribute("neighborhoodSide",10),this.setAttribute("samplingPixelDistance",1),this.setAttribute("thresholdPercentageOfAverage",1)},ThresholdingNeighborhood.prototype.process=function(e,t,i,n,a){for(var r=this.getAttribute("neighborhoodSide"),o=this.getAttribute("samplingPixelDistance"),s=this.getAttribute("thresholdPercentageOfAverage"),l=0;l<e.getHeight();l++)for(var h=0;h<e.getWidth();h++)this.theshold(e,t,h,l,s,r,o)},ThresholdingNeighborhood.prototype.theshold=function(e,t,i,n,a,r,o){for(var s=-1,l=-1,h=0,d=0,c=o,u=n-r/2;u<n+(c+r/2);u+=c)for(var g=i-r/2;g<i+r/2;g+=c)if(g>=0&&u>=0&&g<e.getWidth()&&u<e.getHeight()){var f=e.getIntComponent0(g,u);(-1==s||f<s)&&(s=f),(-1==l||f>l)&&(l=f),d+=f,h++}d/=h,(f=e.getIntComponent0(i,n))<d*a||l-s<=30?t.setIntColor(i,n,255,0,0,0):t.setIntColor(i,n,255,255,255,255)},CombineByAlpha.prototype.load=function(){this.setAttribute("x",0),this.setAttribute("y",0),this.setAttribute("imageOther",null)},CombineByAlpha.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("imageOther"),o=this.getAttribute("x"),s=this.getAttribute("y");if(null!=r)for(var l=0;l<e.getHeight();l++)for(var h=0;h<e.getWidth();h++){var d=h-o,c=l-s;if(d>=0&&d<r.getWidth()&&c>=0&&c<r.getHeight()){var u=r.getAlphaComponent(d,c);if(0!=u){var g=u/255,f=e.getIntComponent0(h,l),p=e.getIntComponent1(h,l),m=e.getIntComponent2(h,l),v=r.getIntComponent0(d,c),I=r.getIntComponent1(d,c),y=r.getIntComponent2(d,c),C=Math.floor(f*(1-g)+v*g),M=Math.floor(p*(1-g)+I*g),x=Math.floor(m*(1-g)+y*g);t.setIntColor(h,l,Math.max(e.getAlphaComponent(o,s),u),C,M,x)}else t.setIntColor(h,l,e.getIntColor(h,l))}else t.setIntColor(h,l,e.getIntColor(h,l))}},MergePhotos.prototype.load=function(){this.background=new DetermineSceneBackground,this.background.load(),this.setAttribute("threshold",30)},MergePhotos.prototype.process=function(e,t){if(e.length>0){var i=this.getAttribute("threshold");this.background.setAttribute("threshold",i);var n=e[0].clone();this.background.process(e,n),MarvinImage.copyColorArray(n,t),this.mergePhotos(e,t,n,i)}},MergePhotos.prototype.mergePhotos=function(e,t,i,n){for(var a in e){var r=e[a];this.mergePhotosSingle(r,t,i,n)}},MergePhotos.prototype.mergePhotosSingle=function(e,t,i,n){for(var a,r,o,s,l,h,d=0;d<e.getHeight();d++)for(var c=0;c<e.getWidth();c++)a=e.getIntComponent0(c,d),r=e.getIntComponent1(c,d),o=e.getIntComponent2(c,d),s=i.getIntComponent0(c,d),l=i.getIntComponent1(c,d),h=i.getIntComponent2(c,d),(Math.abs(a-s)>n||Math.abs(r-l)>n||Math.abs(o-h)>n)&&t.setIntColor(c,d,255,a,r,o)},Convolution.prototype.load=function(){this.setAttribute("matrix",null)},Convolution.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrix");if(null!=r&&r.length>0)for(var o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++)o>=r.length/2&&o<e.getHeight()-r.length/2&&s>=r[0].length/2&&s<e.getWidth()-r[0].length/2?this.applyMatrix(s,o,r,e,t):t.setIntColor(s,o,4278190080)},Convolution.prototype.applyMatrix=function(e,t,i,n,a){for(var r,o,s=0,l=0,h=0,d=Math.ceil(i[0].length/2),c=Math.ceil(i.length/2),u=0;u<i.length;u++)for(var g=0;g<i[0].length;g++)0!=i[u][g]&&(o=t+(u-c),(r=e+(g-d))>=0&&r<a.getWidth()&&o>=0&&o<a.getHeight()&&(s+=i[u][g]*n.getIntComponent0(r,o),l+=i[u][g]*n.getIntComponent1(r,o),h+=i[u][g]*n.getIntComponent2(r,o)));s=Math.abs(s),l=Math.abs(l),h=Math.abs(h),s+=a.getIntComponent0(e,t),l+=a.getIntComponent1(e,t),h+=a.getIntComponent2(e,t),s=Math.min(s,255),l=Math.min(l,255),h=Math.min(h,255),s=Math.max(s,0),l=Math.max(l,0),h=Math.max(h,0),a.setIntColor(e,t,n.getAlphaComponent(e,t),Math.floor(s),Math.floor(l),Math.floor(h))},Moravec.prototype.load=function(){this.setAttribute("matrixSize",3),this.setAttribute("threshold",0)},Moravec.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrixSize"),o=this.getAttribute("threshold"),s=new MarvinImage(e.getWidth(),e.getHeight());Marvin.grayScale(e,s);for(var l=MarvinJSUtils.createMatrix2D(s.getWidth(),s.getHeight(),0),h=MarvinJSUtils.createMatrix2D(s.getWidth(),s.getHeight(),0),d=0;d<s.getHeight();d++)for(var c=0;c<s.getWidth();c++)l[c][d]=this.c(c,d,r,s),l[c][d]<o&&(l[c][d]=0);for(c=0;c<l.length;c++)for(d=0;d<l[c].length;d++)h[c][d]=this.nonmax(c,d,r,l),h[c][d]>0&&(h[c][d]=1);null!=i&&i.set("cornernessMap",h)},Moravec.prototype.nonmax=function(e,t,i,n){var a=Math.floor(i/2);if(e-(a+1)>=0&&e+(a+1)<n.length&&t-(a+1)>=0&&t+(a+1)<n[0].length)for(var r=-a;r<=a;r++)for(var o=-a;o<=a;o++)if((0!=r||0!=o)&&n[e][t]<n[e+r][t+o])return 0;return n[e][t]},Moravec.directions=[[1,0],[-1,0],[0,1],[0,-1],[-1,-1],[1,-1],[-1,1],[1,1]],Moravec.prototype.c=function(e,t,i,n){var a,r=-1,o=Math.floor(i/2);if(e-(o+1)>=0&&e+(o+1)<n.getWidth()&&t-(o+1)>=0&&t+(o+1)<n.getHeight())for(var s=0;s<Moravec.directions.length;s++){a=0;for(var l=-o;l<=o;l++)for(var h=-o;h<=o;h++)a+=Math.pow(n.getIntComponent0(e+l,t+h)-n.getIntComponent0(e+l+Moravec.directions[s][0],t+h+Moravec.directions[s][1]),2);(-1==r||a<r)&&(r=a)}return r},Prewitt.prototype.load=function(){this.convolution=new Convolution,this.setAttribute("intensity",1)},Prewitt.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("intensity");1==r?(this.convolution.setAttribute("matrix",this.matrixPrewittX),this.convolution.process(e,t,null,n,this.previewMode),this.convolution.setAttribute("matrix",this.matrixPrewittY),this.convolution.process(e,t,null,n,this.previewMode)):(this.convolution.setAttribute("matrix",MarvinMath.scaleMatrix(this.matrixPrewittX,r)),this.convolution.process(e,t,null,n,a),this.convolution.setAttribute("matrix",MarvinMath.scaleMatrix(this.matrixPrewittY,r)),this.convolution.process(e,t,null,n,a))},BoundaryFill.prototype.load=function(){this.setAttribute("x",0),this.setAttribute("y",0),this.setAttribute("color",4294901760),this.setAttribute("tile",null),this.setAttribute("threshold",0)},BoundaryFill.prototype.process=function(e,t,i,n,a){var r,o,s,l=new Array,h=this.getAttribute("x"),d=this.getAttribute("y"),c=this.getAttribute("tile");if(this.threshold=this.getAttribute("threshold"),t.isValidPosition(h,d)){e.getIntColor(h,d);var u=e.getIntComponent0(h,d),g=e.getIntComponent1(h,d),f=e.getIntComponent2(h,d),p=this.getAttribute("color"),m=MarvinJSUtils.createMatrix2D(t.getWidth(),t.getHeight,!1);for(m[h][d]=!0,l.push(new MarvinPoint(h,d));l.length>0;){for(o=new MarvinPoint((r=l.splice(0,1)[0]).x,r.y),s=new MarvinPoint(r.x,r.y);o.x-1>=0&&this.match(e,o.x-1,o.y,u,g,f,this.threshold)&&!m[o.x-1][o.y];)o.x--;for(;s.x+1<e.getWidth()&&this.match(e,s.x+1,s.y,u,g,f,this.threshold)&&!m[s.x+1][s.y];)s.x++;for(var v=o.x;v<=s.x;v++)m[v][r.y]=!0,r.y-1>=0&&this.match(e,v,r.y-1,u,g,f,this.threshold)&&!m[v][r.y-1]&&l.push(new MarvinPoint(v,r.y-1)),r.y+1<t.getHeight()&&this.match(e,v,r.y+1,u,g,f,this.threshold)&&!m[v][r.y+1]&&l.push(new MarvinPoint(v,r.y+1))}if(null!=c);else for(var I=0;I<t.getHeight();I++)for(var y=0;y<t.getWidth();y++)m[y][I]&&t.setIntColor(y,I,p)}},BoundaryFill.prototype.match=function(e,t,i,n,a,r,o){return Math.abs(e.getIntComponent0(t,i)-n)+Math.abs(e.getIntComponent1(t,i)-a)+Math.abs(e.getIntComponent2(t,i)-r)<=o},ErrorDiffusion.prototype.load=function(){this.threshold=128},ErrorDiffusion.prototype.process=function(e,t,i,n,a){var r,o;Marvin.grayScale(e,t,i,n,a),null!=n&&(o=n.getMask());for(var s=0;s<t.getHeight();s++)for(var l=0;l<t.getWidth();l++){var h;if(null==o||o[l][s])(h=t.getIntComponent0(l,s))>this.threshold?(t.setIntColor(l,s,e.getAlphaComponent(l,s),255,255,255),r=-(255-h)):(t.setIntColor(l,s,e.getAlphaComponent(l,s),0,0,0),r=h),l+1<t.getWidth()&&(h=t.getIntComponent0(l+1,s),h+=Math.floor(.4375*r),h=this.getValidGray(h),t.setIntColor(l+1,s,e.getAlphaComponent(l+1,s),h,h,h),s+1<t.getHeight()&&(h=t.getIntComponent0(l+1,s+1),h+=Math.floor(.0625*r),h=this.getValidGray(h),t.setIntColor(l+1,s+1,e.getAlphaComponent(l+1,s+1),h,h,h))),s+1<t.getHeight()&&(h=t.getIntComponent0(l,s+1),h+=Math.floor(.3125*r),h=this.getValidGray(h),t.setIntColor(l,s+1,e.getAlphaComponent(l,s+1),h,h,h),l-1>=0&&(h=t.getIntComponent0(l-1,s+1),h+=Math.floor(.1875*r),h=this.getValidGray(h),t.setIntColor(l-1,s+1,e.getAlphaComponent(l-1,s+1),h,h,h)))}},ErrorDiffusion.prototype.getValidGray=function(e){return e<0?0:e>255?255:e};var MarvinAbstractImagePlugin=new Object;function Closing(){MarvinAbstractImagePlugin.super(this),this.load()}function Dilation(){MarvinAbstractImagePlugin.super(this),this.load()}function Erosion(){MarvinAbstractImagePlugin.super(this),this.load()}function FindTextRegions(){MarvinAbstractImagePlugin.super(this),this.load()}function IteratedFunctionSystem(){MarvinAbstractImagePlugin.super(this),this.load()}function Crop(){MarvinAbstractImagePlugin.super(this),this.load()}function FloodfillSegmentation(){MarvinAbstractImagePlugin.super(this),this.load()}function Scale(){MarvinAbstractImagePlugin.super(this),this.load()}function MarvinAttributes(){this.hashAttributes=new Object}function MarvinPoint(e,t){this.x=e,this.y=t}MarvinAbstractImagePlugin.super=function(e){e.attributes={},e.setAttribute=MarvinAbstractImagePlugin.setAttribute,e.getAttribute=MarvinAbstractImagePlugin.getAttribute},MarvinAbstractImagePlugin.setAttribute=function(e,t){this.attributes[e]=t},MarvinAbstractImagePlugin.getAttribute=function(e,t){return this.attributes[e]},Closing.prototype.load=function(){this.matrix=MarvinJSUtils.createMatrix2D(3,3,!0),this.setAttribute("matrix",3)},Closing.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrix");e.getColorModel()==MarvinImage.COLOR_MODEL_BINARY&&null!=r&&(Marvin.morphologicalDilation(e,t,r),MarvinImage.copyColorArray(t,e),Marvin.morphologicalErosion(e,t,r))},Dilation.prototype.load=function(){this.matrix=MarvinJSUtils.createMatrix2D(3,3,!0),this.setAttribute("matrix",3)},Dilation.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrix");if(e.getColorModel()==MarvinImage.COLOR_MODEL_BINARY&&null!=r){MarvinImage.copyColorArray(e,t);for(var o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++)this.applyMatrix(s,o,r,e,t)}},Dilation.prototype.applyMatrix=function(e,t,i,n,a){var r,o,s=i[0].length/2,l=i.length/2;if(n.getBinaryColor(e,t))for(var h=0;h<i.length;h++)for(var d=0;d<i.length;d++)h==l&&d==s||!i[h][d]||(o=t+(h-l),(r=e+(d-s))>0&&r<a.getWidth()&&o>0&&o<a.getHeight()&&a.setBinaryColor(r,o,!0))},Erosion.prototype.load=function(){this.matrix=MarvinJSUtils.createMatrix2D(3,3,!0),this.setAttribute("matrix",3)},Erosion.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrix");if(e.getColorModel()==MarvinImage.COLOR_MODEL_BINARY&&null!=r){MarvinImage.copyColorArray(e,t);for(var o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++)this.applyMatrix(s,o,r,e,t)}},Erosion.prototype.applyMatrix=function(e,t,i,n,a){var r,o,s=Math.floor(i[0].length/2),l=Math.floor(i.length/2);if(!n.getBinaryColor(e,t))for(var h=0;h<i.length;h++)for(var d=0;d<i[0].length;d++)h==l&&d==s||!i[h][d]||(o=t+(h-l),(r=e+(d-s))>=0&&r<a.getWidth()&&o>=0&&o<a.getHeight()&&a.setBinaryColor(r,o,!1))},FindTextRegions.prototype.load=function(){this.setAttribute("maxWhiteSpace",10),this.setAttribute("maxFontLineWidth",10),this.setAttribute("minTextWidth",30),this.setAttribute("grayScaleThreshold",127)},FindTextRegions.prototype.process=function(e,t,i,n,a){e=e.clone();var r=this.getAttribute("maxWhiteSpace"),o=this.getAttribute("maxFontLineWidth"),s=this.getAttribute("minTextWidth"),l=this.getAttribute("grayScaleThreshold");Marvin.thresholding(e,e,l);for(var h=[],d=0;d<e.getHeight();d++)h.push([]);for(var c,u=MarvinJSUtils.createMatrix2D(e.getWidth(),e.getHeight,!1),g=-1,f=0,p=0,m=0,v=0;v<e.getHeight();v++)for(var I=0;I<e.getWidth();I++)if(!u[I][v]){if(4294967295==(c=e.getIntColor(I,v))&&-1!=g&&(p++,m=0),4278190080==c&&(m++,-1==g&&(g=I),p=0),p>r||m>o||I==e.getWidth()-1){if(f>=s)(A=h[v]).push([g,v,g+f,v]);p=0,m=0,f=0,g=-1}-1!=g&&f++,u[I][v]=!0}for(v=0;v<e.getHeight()-2;v++)for(var y=h[v],C=v+1;C<=v+2;C++){var M=h[C];for(d=0;d<y.length;d++)for(var x=y[d],S=0;S<M.length;S++){var b=M[S];if(x[0]<=b[0]&&x[2]>=b[2]||x[0]>=b[0]&&x[0]<=b[2]||x[2]>=b[0]&&x[2]<=b[2]){x[0]=Math.min(x[0],b[0]),x[2]=Math.max(x[2],b[2]),x[3]=b[3],y.splice(d,1),d--,M.splice(S,1),M.push(x);break}}}var w=[];for(v=0;v<e.getHeight();v++){var A=h[v];for(var d in A){var P=A[d];w.push(new MarvinSegment(P[0],P[1],P[2],P[3]))}}i.set("matches",w)},IteratedFunctionSystem.prototype.load=function(){this.rules=[],this.EXAMPLE_RULES="0,0,0,0.16,0,0,0.01\n0.85,0.04,-0.04,0.85,0,1.6,0.85\n0.2,-0.26,0.23,0.22,0,1.6,0.07\n-0.15,0.28,0.26,0.24,0,0.44,0.07\n",this.setAttribute("rules",this.EXAMPLE_RULES),this.setAttribute("iterations",1e6)},IteratedFunctionSystem.prototype.process=function(e,t,i,n,a){this.loadRules();var r,o,s,l,h,d,c=this.getAttribute("iterations"),u=999999999,g=999999999,f=-999999999,p=-99999999,m=[0,0];t.clear(4294967295);for(var v=0;v<c;v++)d=this.getRule(),this.applyRule(m,d),(r=m[0])<u&&(u=r),r>f&&(f=r),(o=m[1])<g&&(g=o),o>p&&(p=o);var I=t.getWidth(),y=t.getHeight(),C=Math.abs(f-u),M=Math.abs(p-g);C>M?M*(h=I/C)>y&&(h*=y/(M*h)):C*(h=y/M)>I&&(h*=I/(C*h)),h*=.9,s=Math.floor(I/2-(u+C/2)*h),l=Math.floor(y-(y/2-(g+M/2)*h)),m[0]=0,m[1]=0;for(v=0;v<c;v++)d=this.getRule(),this.applyRule(m,d),r=Math.floor(m[0]*h+s),o=l-Math.floor(m[1]*h),r>=0&&r<I&&o>=0&&o<y&&t.setIntColor(Math.floor(r),Math.floor(o),255,0)},IteratedFunctionSystem.prototype.loadRules=function(){this.rules=[];for(var e=this.getAttribute("rules").split("\n"),t=0;t<e.length;t++)this.addRule(e[t])},IteratedFunctionSystem.prototype.addRule=function(e){var t=(e=e.replace(/ /g,"")).split(",");if(7==t.length){var i=new Object;i.a=parseFloat(t[0]),i.b=parseFloat(t[1]),i.c=parseFloat(t[2]),i.d=parseFloat(t[3]),i.e=parseFloat(t[4]),i.f=parseFloat(t[5]),i.probability=parseFloat(t[6]),this.rules.push(i)}},IteratedFunctionSystem.prototype.getRule=function(){var e,t=Math.random(),i=0;for(e=0;e<this.rules.length;e++)if(t<(i+=this.rules[e].probability))return this.rules[e];return 0!=e?this.rules[e-1]:this.rules[0]},IteratedFunctionSystem.prototype.applyRule=function(e,t){var i=t.a*e[0]+t.b*e[1]+t.e,n=t.c*e[0]+t.d*e[1]+t.f;e[0]=i,e[1]=n},Crop.prototype.load=function(){this.setAttribute("x",0),this.setAttribute("y",0),this.setAttribute("width",0),this.setAttribute("height",0)},Crop.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("x"),o=this.getAttribute("y"),s=this.getAttribute("width"),l=this.getAttribute("height");t.setDimension(s,l);for(var h=r;h<r+s;h++)for(var d=o;d<o+l;d++)t.setIntColor(h-r,d-o,e.getIntColor(h,d))},FloodfillSegmentation.prototype.load=function(){this.setAttribute("returnType","MarvinSegment")},FloodfillSegmentation.prototype.process=function(e,t,i,n,a){if(null!=i){var r=this.getAttribute("returnType"),o=e.clone(),s=this.floodfillSegmentation(e,o);switch(r){case"MarvinSegment":i.set("segments",s);break;case"MarvinBlobSegment":i.set("blobSegments",blobSegments(o,s))}}},FloodfillSegmentation.prototype.floodfillSegmentation=function(e,t){t.clear(4278190080);for(var i=1,n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++){if(0==(16777215&(l=t.getIntColor(a,n)))&&e.getAlphaComponent(a,n)>0){var r=4278190080|i++;Marvin.boundaryFill(e,t,a,n,r)}}var o,s=new Array(i-1);for(n=0;n<t.getHeight();n++)for(a=0;a<t.getWidth();a++){var l;16777215!=(l=16777215&t.getIntColor(a,n))&&l>0&&(null==(o=s[l-1])&&(o=new MarvinSegment,s[l-1]=o),(-1==o.x1||a<o.x1)&&(o.x1=a),(-1==o.x2||a>o.x2)&&(o.x2=a),o.width=o.x2-o.x1+1,(-1==o.y1||n<o.y1)&&(o.y1=n),(-1==o.y2||n>o.y2)&&(o.y2=n),o.height=o.y2-o.y1+1,o.area++)}return s},FloodfillSegmentation.prototype.blobSegments=function(e,t){for(var i,n,a=new Array(t.length),r=0;r<t.length;r++){n=t[r],i=4278190080+(r+1),a[r]=new MarvinBlobSegment(n.x1,n.y1);var o=new MarvinBlob(n.width,n.height);a[r].setBlob(o);for(var s=n.y1;s<=n.y2;s++)for(var l=n.x1;l<=n.x2;l++)e.getIntColor(l,s)==i&&o.setValue(l-n.x1,s-n.y1,!0)}return a},Scale.prototype.load=function(){this.setAttribute("newWidth",0),this.setAttribute("newHeight",0)},Scale.prototype.process=function(e,t,i,n,a){if(!a){var r=e.getWidth(),o=e.getHeight(),s=this.getAttribute("newWidth"),l=this.getAttribute("newHeight");t.getWidth()==s&&t.getHeight()==l||t.setDimension(s,l);for(var h,d,c=Math.floor((r<<16)/s),u=Math.floor((o<<16)/l),g=0;g<l;g++)for(var f=0;f<s;f++)h=Math.floor(f*c>>16),d=Math.floor(g*u>>16),t.setIntColor(f,g,e.getAlphaComponent(h,d),e.getIntColor(h,d))}},MarvinAttributes.prototype.set=function(e,t){this.hashAttributes[e]=t},MarvinAttributes.prototype.get=function(e,t){var i=this.hashAttributes[e];return null!=i?i:t},MarvinAttributes.prototype.clone=function(){var e=new MarvinAttributes;for(var t in this.hashAttributes)e.set(t,this.hashAttributes[t]);return e},MarvinPoint.prototype.setX=function(e){this.x=e},MarvinPoint.prototype.getX=function(){return this.x},MarvinPoint.prototype.setY=function(e){this.y=y},MarvinPoint.prototype.getY=function(){return this.y};var marvinLoadPluginMethods=function(e){Marvin.plugins=new Object,Marvin.plugins.alphaBoundary=new AlphaBoundary,Marvin.alphaBoundary=function(e,t,i){Marvin.plugins.alphaBoundary.setAttribute("radius",i),Marvin.plugins.alphaBoundary.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.averageColor=new AverageColor,Marvin.averageColor=function(e){var t=new MarvinAttributes;return Marvin.plugins.averageColor.process(e,null,t,MarvinImageMask.NULL_MASK,!1),t.get("averageColor")},Marvin.plugins.blackAndWhite=new BlackAndWhite,Marvin.blackAndWhite=function(e,t,i){Marvin.plugins.blackAndWhite.setAttribute("level",i),Marvin.plugins.blackAndWhite.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.boundaryFill=new BoundaryFill,Marvin.boundaryFill=function(e,t,i,n,a,r){Marvin.plugins.boundaryFill.setAttribute("x",i),Marvin.plugins.boundaryFill.setAttribute("y",n),Marvin.plugins.boundaryFill.setAttribute("color",a),null!=r&&Marvin.plugins.boundaryFill.setAttribute("threshold",r),Marvin.plugins.boundaryFill.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.brightnessAndContrast=new BrightnessAndContrast,Marvin.brightnessAndContrast=function(e,t,i,n){Marvin.plugins.brightnessAndContrast.setAttribute("brightness",i),Marvin.plugins.brightnessAndContrast.setAttribute("contrast",n),Marvin.plugins.brightnessAndContrast.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.colorChannel=new ColorChannel,Marvin.colorChannel=function(e,t,i,n,a){Marvin.plugins.colorChannel.setAttribute("red",i),Marvin.plugins.colorChannel.setAttribute("green",n),Marvin.plugins.colorChannel.setAttribute("blue",a),Marvin.plugins.colorChannel.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.crop=new Crop,Marvin.crop=function(e,t,i,n,a,r){Marvin.plugins.crop.setAttribute("x",i),Marvin.plugins.crop.setAttribute("y",n),Marvin.plugins.crop.setAttribute("width",a),Marvin.plugins.crop.setAttribute("height",r),Marvin.plugins.crop.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.combineByAlpha=new CombineByAlpha,Marvin.combineByAlpha=function(e,t,i,n,a){Marvin.plugins.combineByAlpha.setAttribute("imageOther",t),Marvin.plugins.combineByAlpha.setAttribute("x",n),Marvin.plugins.combineByAlpha.setAttribute("y",a),Marvin.plugins.combineByAlpha.process(e,i,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.emboss=new Emboss,Marvin.emboss=function(e,t){Marvin.plugins.emboss.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.halftoneErrorDiffusion=new ErrorDiffusion,Marvin.halftoneErrorDiffusion=function(e,t){Marvin.plugins.halftoneErrorDiffusion.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.findTextRegions=new FindTextRegions,Marvin.findTextRegions=function(e,t,i,n,a){var r=new MarvinAttributes;return Marvin.plugins.findTextRegions.setAttribute("maxWhiteSpace",Marvin.getValue(t,10)),Marvin.plugins.findTextRegions.setAttribute("maxFontLineWidth",Marvin.getValue(i,10)),Marvin.plugins.findTextRegions.setAttribute("minTextWidth",Marvin.getValue(n,30)),Marvin.plugins.findTextRegions.setAttribute("grayScaleThreshold",Marvin.getValue(a,127)),Marvin.plugins.findTextRegions.process(e,null,r,MarvinImageMask.NULL_MASK,!1),r.get("matches")},Marvin.plugins.floodfillSegmentation=new FloodfillSegmentation,Marvin.floodfillSegmentation=function(e){var t=new MarvinAttributes;return Marvin.plugins.floodfillSegmentation.setAttribute("returnType","MarvinSegment"),Marvin.plugins.floodfillSegmentation.process(e,null,t,MarvinImageMask.NULL_MASK,!1),t.get("segments")},Marvin.plugins.gaussianBlur=new GaussianBlur,Marvin.gaussianBlur=function(e,t,i){Marvin.plugins.gaussianBlur.setAttribute("radius",Marvin.getValue(i,3)),Marvin.plugins.gaussianBlur.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.invertColors=new Invert,Marvin.invertColors=function(e,t){Marvin.plugins.invertColors.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.iteratedFunctionSystem=new IteratedFunctionSystem,Marvin.iteratedFunctionSystem=function(e,t,i,n){Marvin.plugins.iteratedFunctionSystem.setAttribute("rules",i),Marvin.plugins.iteratedFunctionSystem.setAttribute("iterations",n),Marvin.plugins.iteratedFunctionSystem.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.grayScale=new GrayScale,Marvin.grayScale=function(e,t){Marvin.plugins.grayScale.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.mergePhotos=new MergePhotos,Marvin.mergePhotos=function(e,t,i){Marvin.plugins.mergePhotos.setAttribute("threshold",i),Marvin.plugins.mergePhotos.process(e,t)},Marvin.plugins.moravec=new Moravec,Marvin.moravec=function(e,t,i,n){var a=new MarvinAttributes;return Marvin.plugins.moravec.setAttribute("matrixSize",i),Marvin.plugins.moravec.setAttribute("threshold",n),Marvin.plugins.moravec.process(e,t,a,MarvinImageMask.NULL_MASK,!1),a.get("cornernessMap")},Marvin.plugins.morphologicalDilation=new Dilation,Marvin.morphologicalDilation=function(e,t,i){Marvin.plugins.morphologicalDilation.setAttribute("matrix",i),Marvin.plugins.morphologicalDilation.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.morphologicalErosion=new Erosion,Marvin.morphologicalErosion=function(e,t,i){Marvin.plugins.morphologicalErosion.setAttribute("matrix",i),Marvin.plugins.morphologicalErosion.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.morphologicalClosing=new Closing,Marvin.morphologicalClosing=function(e,t,i){Marvin.plugins.morphologicalClosing.setAttribute("matrix",i),Marvin.plugins.morphologicalClosing.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.prewitt=new Prewitt,Marvin.prewitt=function(e,t,i){Marvin.plugins.prewitt.setAttribute("intensity",Marvin.getValue(i,1)),Marvin.plugins.prewitt.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.scale=new Scale,Marvin.scale=function(e,t,i,n){if(null==n){var a=e.getHeight()/e.getWidth();n=Math.floor(a*i)}Marvin.plugins.scale.setAttribute("newWidth",i),Marvin.plugins.scale.setAttribute("newHeight",n),Marvin.plugins.scale.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.sepia=new Sepia,Marvin.sepia=function(e,t,i){Marvin.plugins.sepia.setAttribute("intensity",i),Marvin.plugins.sepia.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.thresholding=new Thresholding,Marvin.thresholding=function(e,t,i,n){Marvin.plugins.thresholding.setAttribute("threshold",i),Marvin.plugins.thresholding.setAttribute("thresholdRange",n),Marvin.plugins.thresholding.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.thresholdingNeighborhood=new ThresholdingNeighborhood,Marvin.thresholdingNeighborhood=function(e,t,i,n,a){Marvin.plugins.thresholdingNeighborhood.setAttribute("thresholdPercentageOfAverage",i),Marvin.plugins.thresholdingNeighborhood.setAttribute("neighborhoodSide",n),Marvin.plugins.thresholdingNeighborhood.setAttribute("samplingPixelDistance",a),Marvin.plugins.thresholdingNeighborhood.process(e,t,null,MarvinImageMask.NULL_MASK,!1)}},Marvin=new Object;Marvin.getValue=function(e,t){return null!=e?e:t},marvinLoadPluginMethods(),function(e){!function(e){var t;!function(e){e[e.None=0]="None",e[e.ErrorDiffusion=1]="ErrorDiffusion",e[e.Dithering=2]="Dithering"}(t=e.HalfoneType||(e.HalfoneType={}));var i=function(){function e(){}return e.greyScale=function(e,i,n,a){var r=this;return void 0===i&&(i=t.None),void 0===n&&(n=!1),void 0===a&&(a=null),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){var e=l.clone();Marvin.grayScale(l,e),i!=t.None?(i==t.ErrorDiffusion?r.errorDiffusion(e,e):i==t.Dithering&&r.dithering(e,e),n&&r.invertImageColors(e,e),a&&r.replaceBlack(e,a.red,a.green,a.blue)):(n&&r.invertImageColors(e,e),a&&r.overlayColorToImage(e,e,a.red,a.green,a.blue)),o(e.toBlob())})})},e.greyScalePlus=function(e,i,n,a){var r=this;return void 0===i&&(i=t.None),void 0===n&&(n=!1),void 0===a&&(a=null),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){var e=l.clone();Marvin.grayScale(l,e);for(var s=[0,0,0],h=0;h<e.getHeight();h++)for(var d=0;d<e.getWidth();d++){var c=l.getAlphaComponent(d,h),u=e.getIntComponent0(d,h),g=e.getIntComponent1(d,h),f=e.getIntComponent2(d,h);r.RGBtoHSB(u,g,f,s),s[1]=0;var p=r.HSBtoRGB(s[0],s[1],s[2]),m=r.numberToColor(p),v=r.overlayColorComponentValue(m.red,u),I=r.overlayColorComponentValue(m.green,g),y=r.overlayColorComponentValue(m.blue,f);e.setIntColor(d,h,c,v,I,y)}e.update(),i!=t.None?(i==t.ErrorDiffusion?r.errorDiffusion(e,e):i==t.Dithering&&r.dithering(e,e),n&&r.invertImageColors(e,e),a&&r.replaceBlack(e,a.red,a.green,a.blue)):(n&&r.invertImageColors(e,e),a&&r.overlayColorToImage(e,e,a.red,a.green,a.blue)),o(e.toBlob())})})},e.desaturate=function(e,i,n,a){var r=this;return void 0===i&&(i=t.None),void 0===n&&(n=!1),void 0===a&&(a=null),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){for(var e=l.clone(),s=[0,0,0],h=0;h<e.getHeight();h++)for(var d=0;d<e.getWidth();d++){var c=l.getAlphaComponent(d,h);r.RGBtoHSB(e.getIntComponent0(d,h),e.getIntComponent1(d,h),e.getIntComponent2(d,h),s),s[1]=0;var u=r.HSBtoRGB(s[0],s[1],s[2]),g=r.numberToColor(u);e.setIntColor(d,h,c,g.red,g.green,g.blue)}i!=t.None?(i==t.ErrorDiffusion?r.errorDiffusion(e,e):i==t.Dithering&&r.dithering(e,e),n&&r.invertImageColors(e,e),a&&r.replaceBlack(e,a.red,a.green,a.blue)):(n&&r.invertImageColors(e,e),a&&r.overlayColorToImage(e,e,a.red,a.green,a.blue)),o(e.toBlob())})})},e.blackAndWhite=function(e,i,n,a){var r=this;return void 0===i&&(i=t.None),void 0===n&&(n=!1),void 0===a&&(a=null),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){for(var e=l.clone(),s=0,h=0;h<e.getHeight();h++)for(var d=0;d<e.getWidth();d++){var c=l.getAlphaComponent(d,h);s=(s=l.getIntComponent0(d,h))<=127?Math.max(s*(1-.006*(127-s)),0):Math.min(s*(1+.006*(s-127)),255),e.setIntColor(d,h,c,s,s,s)}i!=t.None?(i==t.ErrorDiffusion?r.errorDiffusion(e,e):i==t.Dithering&&r.dithering(e,e),n&&r.invertImageColors(e,e),a&&r.replaceBlack(e,a.red,a.green,a.blue)):(n&&r.invertImageColors(e,e),a&&r.overlayColorToImage(e,e,a.red,a.green,a.blue)),o(e.toBlob())})})},e.thresholding=function(e,t,i,n){var a=this;return void 0===i&&(i=!1),void 0===n&&(n=null),null!=t&&null!=t||(t=160),new Promise(function(r,o){var s=new MarvinImage;s.load(e,function(){var e=s.clone();Marvin.thresholding(s,e,t),i&&a.invertImageColors(e,e),n&&a.replaceBlack(e,n.red,n.green,n.blue),r(e.toBlob())})})},e.thresholdingTransparentWhite=function(e,t,i,n){var a=this;return void 0===i&&(i=!1),void 0===n&&(n=null),null!=t&&null!=t||(t=160),new Promise(function(r,o){var s=new MarvinImage;s.load(e,function(){var e=s.clone();Marvin.thresholding(s,e,t),i&&a.invertImageColors(e,e),a.setWhiteTransparent(e),n&&a.replaceBlack(e,n.red,n.green,n.blue),r(e.toBlob())})})},e.thresholdingDarkAndLight=function(e,t,i,n,a){var r=this;return void 0===i&&(i=!1),null!=t&&null!=t||(t=160),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){var e=l.clone();Marvin.thresholding(l,e,t),i&&r.invertImageColors(e,e),r.replaceBlackAndWhite(e,n,a),r.setWhiteTransparent(e),o(e.toBlob())})})},e.halftoneErrorDiffusion=function(e){return new Promise(function(t,i){var n=new MarvinImage;n.load(e,function(){var e=n.clone();Marvin.halftoneErrorDiffusion(n,e),t(e.toBlob())})})},e.overlapColor=function(e,t,i){var n=t||{red:0,green:0,blue:0};return new Promise(function(t,a){var r=new MarvinImage;r.load(e,function(){for(var e=r.clone(),a=0;a<e.getHeight();a++)for(var o=0;o<e.getWidth();o++){var s=r.getAlphaComponent(o,a),l=r.getIntComponent0(o,a),h=r.getIntComponent1(o,a),d=r.getIntComponent2(o,a);i&&255==l&&255==h&&255==d&&(s=0),e.setIntColor(o,a,s,n.red,n.green,n.blue)}t(e.toBlob())})})},e.downloadImage=function(e,t){t=t||"test.png";var i=e.toBlob(),n=document.createElement("a");n.setAttribute("download",t);var a=URL.createObjectURL(i);n.href=a,n.setAttribute("target","_blank"),n.click(),URL.revokeObjectURL(a)},e.overlayColor=function(e,t){var i=this,n=t||{red:0,green:0,blue:0};return new Promise(function(t,a){var r=new MarvinImage;r.load(e,function(){for(var e=r.clone(),a=[0,0,0],o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++){var l=r.getAlphaComponent(s,o);i.RGBtoHSB(r.getIntComponent0(s,o),r.getIntComponent1(s,o),r.getIntComponent2(s,o),a),a[1]=0;var h=i.HSBtoRGB(a[0],a[1],a[2]),d=i.numberToColor(h),c=i.multiplyColorComponentValue(d.red,n.red),u=i.multiplyColorComponentValue(d.green,n.green),g=i.multiplyColorComponentValue(d.blue,n.blue);e.setIntColor(s,o,l,c,u,g)}t(e.toBlob())})})},e.overlayColorHard=function(e,t){var i=this,n=t||{red:0,green:0,blue:0};return new Promise(function(t,a){var r=new MarvinImage;r.load(e,function(){for(var e=r.clone(),a=0,o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++){var l=r.getAlphaComponent(s,o);a=(a=r.getIntComponent0(s,o))<=127?Math.max(a*(1-.006*(127-a)),0):Math.min(a*(1+.006*(a-127)),255);var h=i.multiplyColorComponentValue(a,n.red),d=i.multiplyColorComponentValue(a,n.green),c=i.multiplyColorComponentValue(a,n.blue);e.setIntColor(s,o,l,h,d,c)}t(e.toBlob())})})},e.edgeDetection2=function(e){return new Promise(function(t,i){var n=new MarvinImage;n.load(e,function(){var e=n.clone();e.clear(4278190080),Marvin.prewitt(n,e),Marvin.invertColors(e,e),Marvin.thresholding(e,e,200),t(e.toBlob())})})},e.multiplyColorComponentValue=function(e,t){var i=e*t/255;return i=i>255?255:i<0?0:Math.floor(i)},e.overlayColorComponentValue=function(e,t){var i=e/255,n=t/255,a=i<.5?2*i*n:1-2*(1-i)*(1-n);return Math.floor(255*a)},e.RGBtoHSB=function(e,t,i,n){null==n&&(n=[]);var a=0,r=0;if(e<t?(a=e,r=t):(a=t,r=e),i>r?r=i:i<a&&(a=i),n[2]=r/255,n[1]=0==r?0:(r-a)/r,0==n[1])n[0]=0;else{var o=6*(r-a);n[0]=e==r?(t-i)/o:t==r?1/3+(i-e)/o:2/3+(e-t)/o,n[0]<0&&n[0]++}return n},e.HSBtoRGB=function(e,t,i){if(0==t)return this.convert(i,i,i,0);var n=6*(e-=Math.floor(e)),a=6*e-n,r=i*(1-t),o=i*(1-t*a),s=i*(1-t*(1-a));switch(n){case 0:return this.convert(i,s,r,0);case 1:return this.convert(o,i,r,0);case 2:return this.convert(r,i,s,0);case 3:return this.convert(r,o,i,0);case 4:return this.convert(s,r,i,0);case 5:return this.convert(i,r,o,0)}},e.convert=function(e,t,i,n){var a=Math.round(255*e),r=Math.round(255*t),o=Math.round(255*i);return Math.round(255*n)<<24|a<<16|r<<8|o},e.numberToColor=function(e){return{red:(e&this.RED_MASK)>>16,green:(e&this.GREEN_MASK)>>8,blue:e&this.BLUE_MASK}},e.errorDiffusion=function(e,t){for(var i=0,n=0,a=0;a<t.getHeight();a++)for(var r=0;r<t.getWidth();r++)(i=t.getIntComponent0(r,a))>128?(t.setIntColor(r,a,e.getAlphaComponent(r,a),255,255,255),n=-(255-i)):(t.setIntColor(r,a,e.getAlphaComponent(r,a),0,0,0),n=i),r+1<t.getWidth()&&(i=t.getIntComponent0(r+1,a),i+=Math.floor(.4375*n),i=this.getValidGray(i),t.setIntColor(r+1,a,e.getAlphaComponent(r+1,a),i,i,i),a+1<t.getHeight()&&(i=t.getIntComponent0(r+1,a+1),i+=Math.floor(.0625*n),i=this.getValidGray(i),t.setIntColor(r+1,a+1,e.getAlphaComponent(r+1,a+1),i,i,i))),a+1<t.getHeight()&&(i=t.getIntComponent0(r,a+1),i+=Math.floor(.3125*n),i=this.getValidGray(i),t.setIntColor(r,a+1,e.getAlphaComponent(r,a+1),i,i,i),r-1>=0&&(i=t.getIntComponent0(r-1,a+1),i+=Math.floor(.1875*n),i=this.getValidGray(i),t.setIntColor(r-1,a+1,e.getAlphaComponent(r-1,a+1),i,i,i)))},e.dithering=function(e,t){for(var i=[167,200,230,216,181,94,72,193,242,232,36,52,222,167,200,181,126,210,94,72,232,153,111,36,52],n=0;n<e.getWidth();n+=5)for(var a=0;a<e.getHeight();a+=5)for(var r=void 0,o=void 0,s=0;s<25;s++)o=s/5,n+(r=s%5)<e.getWidth()&&a+o<e.getHeight()&&(255-e.getIntComponent0(n+r,a+o)>i[s]?t.setIntColor(n+r,a+o,e.getAlphaComponent(n+r,a+o),0,0,0):t.setIntColor(n+r,a+o,e.getAlphaComponent(n+r,a+o),255,255,255))},e.getValidGray=function(e){return e<0?0:e>255?255:e},e.replaceBlack=function(e,t,i,n){for(var a=0;a<e.getHeight();a++)for(var r=0;r<e.getWidth();r++){var o=e.getAlphaComponent(r,a),s=e.getIntComponent0(r,a),l=e.getIntComponent1(r,a),h=e.getIntComponent2(r,a);0==s&&0==l&&0==h&&(s=t,l=i,h=n),e.setIntColor(r,a,o,s,l,h)}},e.replaceBlackAndWhite=function(e,t,i){for(var n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++){var r=e.getAlphaComponent(a,n),o=e.getIntComponent0(a,n),s=e.getIntComponent1(a,n),l=e.getIntComponent2(a,n);0==o&&0==s&&0==l?(o=t.red,s=t.green,l=t.blue):255==o&&255==s&&255==l&&(o=i.red,s=i.green,l=i.blue),e.setIntColor(a,n,r,o,s,l)}},e.setWhiteTransparent=function(e){for(var t=0;t<e.getHeight();t++)for(var i=0;i<e.getWidth();i++){var n=e.getAlphaComponent(i,t),a=e.getIntComponent0(i,t),r=e.getIntComponent1(i,t),o=e.getIntComponent2(i,t);255==a&&255==r&&255==o&&(n=0),e.setIntColor(i,t,n,a,r,o)}},e.replaceColor=function(e,t,i){for(var n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++){var r=e.getAlphaComponent(a,n),o=e.getIntComponent0(a,n),s=e.getIntComponent1(a,n),l=e.getIntComponent2(a,n);o==t.red&&s==t.green&&l==t.blue&&(o=i.red,s=i.green,l=i.blue),e.setIntColor(a,n,r,o,s,l)}},e.overlayColorToImage=function(e,t,i,n,a){for(var r=0;r<t.getHeight();r++)for(var o=0;o<t.getWidth();o++){var s=e.getAlphaComponent(o,r),l=this.multiplyColorComponentValue(t.getIntComponent0(o,r),i),h=this.multiplyColorComponentValue(t.getIntComponent1(o,r),n),d=this.multiplyColorComponentValue(t.getIntComponent2(o,r),a);t.setIntColor(o,r,s,l,h,d)}t.update()},e.invertImageColors=function(e,t){Marvin.invertColors(e,t)},e.hexToRgb=function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null},e.componentToHex=function(e){var t=e.toString(16);return 1==t.length?"0"+t:t},e.rgbToHex=function(e,t,i){return"#"+this.componentToHex(e)+this.componentToHex(t)+this.componentToHex(i)},e.textToPalette=function(t,i){void 0===i&&(i=!1);var n=[];t&&t.split(",").forEach(function(t){if(t&&"null"!=t){var a=e.hexToRgb(t);a&&n.push([a.r,a.g,a.b])}else i&&n.push(null)});return n},e.paletteToText=function(e){var t="";if(e&&e.length>0)for(var i=0;i<e.length;i++){var n=e[i];t.length>0&&(t+=","),t+=this.rgbToHex(n[0],n[1],n[2])}return t},e.rgbToInt=function(e,t,i){return 255<<24|i<<16|t<<8|e},e.intToRgb=function(e){return[255&e,(65280&e)>>8,(16711680&e)>>16]},e.reduce=function(e,t,i,n){var a=this;return new Promise(function(r,o){var s=a.textToPalette(i),l=null;n&&(l=a.textToPalette(n,!0)),s&&l&&s.length!=l.length&&o("The replacement palette must contains the same colors of main palette");var h=new Image;h.addEventListener("load",function(){var e={colors:256,palette:[],paletteRep:void 0};null!=t&&null!=t&&(e.colors=t),s.length>0&&(e.colors=s.length,e.palette=s,l&&l.length==s.length&&(e.paletteRep=l));var i=new RgbQuant(e);if(0==s.length){i.sample(h);i.palette(!0)}var n=i.reduce(h,3),a=new Blob([n]);r(a)}),h.crossOrigin="Anonymous",h.src=e})},e.getImagePalette=function(e,t){var i=this,n=Math.min(256,t),a=n;return a<256&&(a=Math.min(256,a+10)),new Promise(function(t,r){var o=new Image;o.addEventListener("load",function(){var e=new RgbQuant({colors:a});e.sample(o);var r=e.palette(!0,!0),s=i.paletteToText(r).split(",").slice(0,n);s=s.filter(function(e,t,i){return i.indexOf(e)===t}),t(s)}),o.crossOrigin="Anonymous",o.src=e})},e.remapPalette=function(t,i){for(var n=[],a=0;a<i.length;a++){var r=e.hexToRgb(i[a]);r&&n.push([r.r,r.g,r.b])}var o={colors:256,palette:[]};n.length>0&&(o.colors=n.length,o.palette=n);var s=new RgbQuant(o),l={};for(a=0;a<t.length;a++){var h=t[a],d=e.hexToRgb(h),c=e.rgbToInt(d.r,d.g,d.b),u=s.nearestColor(c),g=e.intToRgb(u),f=e.rgbToHex(g[0],g[1],g[2]);l[h]=f}return l},e.remapColor=function(t,i){return e.remapPalette([t],i)[t]},e.RED_MASK=255<<16,e.GREEN_MASK=65280,e.BLUE_MASK=255,e}();e.ImageProcessor=i}(e.Customizer||(e.Customizer={}))}(Zakeke||(Zakeke={}));var MaskedImageSelectionMode,__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var a in t=arguments[i])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(a,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}l((n=n.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var i,n,a,r,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(o=0)),o;)try{if(i=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},__spreadArray=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,a=0,r=t.length;a<r;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))},_this_1=this,MPlaza=MPlaza||{},IS_IOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;String.prototype.padStart||(String.prototype.padStart=function(e,t){return e>>=0,t=String(t||" "),this.length>e?String(this):((e-=this.length)>t.length&&(t+=t.repeat(e/t.length)),t.slice(0,e)+String(this))}),String.prototype.padEnd||(String.prototype.padEnd=function(e,t){return e>>=0,t=String(t||" "),this.length>e?String(this):((e-=this.length)>t.length&&(t+=t.repeat(e/t.length)),String(this)+t.slice(0,e))}),String.prototype.padStartEnd||(String.prototype.padStartEnd=function(e,t){if(e>>=0,t=String(t||" "),this.length>e)return String(this);e-=this.length;var i=Math.floor(e/2),n=e%2>0?i+1:i,a=i,r=t;n>r.length&&(r+=r.repeat(n/r.length));var o=t;return a>o.length&&(o+=o.repeat(a/o.length)),r.slice(0,n)+String(this)+o.slice(0,a)}),MPlaza.EventMessages={DPIWarning:1,UploadLimit:2,AddToCartConfirmation:4,ItemsClippedWarning:7},MPlaza.CustomizerElementType={None:"none",Rectangle:"rectangle",Oval:"oval",Line:"line",Path:"pen",Free:"freeHand",Text:"text",Image:"image",TextArt:"textart",Shape:"shape"},MPlaza.CustomizerInteractionMode={None:"none",Select:"select",Create:"create",Move:"move",Rotate:"rotate",Resize:"resize",ResizeTop:"resizeTop",ResizeBottom:"resizeBottom",ResizeLeft:"resizeLeft",ResizeRight:"resizeRight",Delete:"delete",Edit:"edit",MoveTextOnPathFirstEnd:"moveTextOnPathFirstEnd",MoveTextOnPathMiddleEnd:"moveTextOnPathMiddleEnd",MoveTextOnPathLastEnd:"moveTextOnPathLastEnd",MoveTextAreaTopEnd:"moveTextAreaTopEnd",MoveTextAreaRightEnd:"moveTextAreaRightEnd",MoveTextAreaBottomEnd:"moveTextAreaBottomEnd",MoveTextAreaLeftEnd:"moveTextAreaLeftEnd"},function(e){e[e.Element=1]="Element",e[e.Raster=2]="Raster",e[e.Mask=3]="Mask"}(MaskedImageSelectionMode||(MaskedImageSelectionMode={})),MPlaza.PointingInfo=function(){return this.modifiers={option:!1,control:!1,shift:!1},this.point=void 0,this.delta=void 0,this};var getViewport=function(){var e="CSS1Compat"==document.compatMode;return{l:window.pageXOffset||(e?document.documentElement.scrollLeft:document.body.scrollLeft),t:window.pageYOffset||(e?document.documentElement.scrollTop:document.body.scrollTop),w:window.innerWidth||(e?document.documentElement.clientWidth:document.body.clientWidth),h:window.innerHeight||(e?document.documentElement.clientHeight:document.body.clientHeight)}};MPlaza.ItemInfo=function(e,t){this.designItem=e,this.item=t,this.elementType=MPlaza.CustomizerElementType.None,this.sideID=-1,this.itemGuid=MPlaza.EmptyUUID,this.constraints=[],e&&e instanceof MPlaza.DesignItem&&(this.itemGuid=e.get("itemGuid"))},MPlaza.TextItemInfo=function(e,t){MPlaza.ItemInfo.call(this,e,t),this.elementType=MPlaza.CustomizerElementType.Text,this.text="",this.strokeColor="black",this.strokeWidth=0,this.fillColor="black",this.fontFamily="Arial",this.fontSize=18,this.fontWeight="normal",this.fontStyle="normal",this.fontStretch="normal",this.justification="center",this.isTextOnPath=!1,this.isTextArea=!1,this.adaptText=!1,this.letterSpacing=0,this.lineSpacing=0,this.scaling=1,this.verticalAlignment="top",this.shadowColor=null,this.shadowBlur=0,this.shadowDistance=7,this.shadowAngle=45,this.__defineGetter__("totalFontSizePt",function(){return this.fontSize*this.scaling*4/3})},MPlaza.TextItemInfo.prototype=Object.create(MPlaza.ItemInfo.prototype),MPlaza.TextItemInfo.prototype.constructor=MPlaza.TextItemInfo,MPlaza.ImageItemInfo=function(e,t){MPlaza.ItemInfo.call(this,e,t),this.elementType=MPlaza.CustomizerElementType.Image,this.url="",this.deleted=!1,this.isMasked=!1,this.maskID=-1,this.maskStyle={strokeColor:void 0,strokeWidth:void 0,strokeCap:void 0,strokeJoin:void 0,dashArray:void 0,dashOffset:void 0}},MPlaza.ImageItemInfo.prototype=Object.create(MPlaza.ItemInfo.prototype),MPlaza.ImageItemInfo.prototype.constructor=MPlaza.ImageItemInfo,MPlaza.ShapeItemInfo=function(e,t){MPlaza.ItemInfo.call(this,e,t),this.elementType=MPlaza.CustomizerElementType.Shape,this.style={strokeColor:void 0,strokeWidth:void 0,strokeCap:void 0,strokeJoin:void 0,dashArray:void 0,dashOffset:void 0,fillColor:void 0},this.isImagePlaceholder=!1,this.fillerImageID=-1},MPlaza.ShapeItemInfo.prototype=Object.create(MPlaza.ItemInfo.prototype),MPlaza.ShapeItemInfo.prototype.constructor=MPlaza.ShapeItemInfo,MPlaza.TextArtItemInfo=function(e,t){MPlaza.ItemInfo.call(this,e,t),this.elementType=MPlaza.CustomizerElementType.TextArt,this.text="",this.fontFamilyID=-1,this.fontFaceID=-1,this.text="",this.textArtTypeID=-1,this.style={strokeColor:void 0,strokeWidth:void 0,strokeCap:void 0,strokeJoin:void 0,dashArray:void 0,dashOffset:void 0,fillColor:void 0,shadowColor:void 0,shadowBlur:void 0,shadowDistance:void 0,shadowAngle:void 0},this.config={angleValue:0,curveValue:0,intensT:0,intensB:0,isTriangle:!1,isBridge:!1,isTop:!1,isBottom:!1,isMiddle:!1}},MPlaza.TextArtItemInfo.prototype=Object.create(MPlaza.ItemInfo.prototype),MPlaza.TextArtItemInfo.prototype.constructor=MPlaza.TextArtItemInfo,MPlaza.Customizer=function(e,t,i,n){this.isViewer=e||!1,this.isMobile=t||!1,this.isConfigurator=n||!1,this.isCartPreview=!1,this.isResizableMode=!1,this.isImageScalingEnabled=!0,this.showSideImage=!0,this.fitToScreenMargin=this.isMobile?18:13,this.zoomPercentageIncrement=100,this.canvasID="mp-canvas-customizer_"+MPlaza.makeID(5),this.canvas=null,this.context=null,null!=i&&(this.canvas=i,this.context=this.canvas.getContext("2d")),this._paper=new paper.PaperScope,this.__defineGetter__("paper",function(){return paper=this._paper,this._paper}),this.__defineSetter__("viewMatrix",function(e){var t=new this.paper.Matrix(e);this.paper.view.matrix=t}),this.rasterLayer=null,this.zooming=!1,this.frozen=!1,this.tool=null,this.clipboard=null,this.selectionBounds=null,this.selectionBoundsShape=null,this.selectionMoveHandle=null,this.selectionRotateHandle=null,this.selectionResizeHandle=null,this.selectionDeleteHandle=null,this.selectionMaskMoveImage=null,this.selectionMaskMoveShape=null,this.selectionResizeTopHandle=null,this.selectionResizeBottomHandle=null,this.selectionResizeLeftHandle=null,this.selectionResizeRightHandle=null,this.selectionLateralResizeDimension=this.isMobile?12:8,this.drawSelectionBounds=0,this.model=null,this.grids=[],this.loadingCircles=[],this.interactionMode=MPlaza.CustomizerInteractionMode.None,this.elementType=MPlaza.CustomizerElementType.None,this.hammertime=null,this.hitItem=null,this.hitTestEnabled=!0,this.mouseStartPos=null,this.adjustmentDelta=null,this.originalPositions=null,this.element=null,this.pivot=null,this.corner=null,this.topCorner=null,this.bottomCorner=null,this.leftCorner=null,this.rightCorner=null,this.originalSize=null,this.originalCenter=null,this.originalScaleCenter=null,this.originalContent=null,this.originalMatrix=null,this.originalShape=null,this.originalAngle=null,this.itemsLayer=null,this.imageLayer=null,this.imageItem=null,this.imageWidth=500,this.imageHeight=516,this.mask=null,this.verticalCenterLine=null,this.verticalCenterLineSecondColor=null,this.horizontalCenterLine=null,this.horizontalCenterLineSecondColor=null,this.resizableSideImageItem=null,this.resizableMeasuresItem=null,this.resizableSplitColumnsItem=null,this.productImageGenerator=new ZakekeResizableCanvas.ProductImageGenerator,this.productAreaGenerator=new ZakekeResizableCanvas.ProductAreaGenerator,void 0!==i&&null!=i?this.setupCanvas():(this.createCanvas(),this.createDOMElement()),this.setupImageLayer(),this.lastPanPoint=new this.paper.Point(0,0),this.iconsBytes=null,this.masterGroup=null,this.snapCache=null,this.oldScale=1;getViewport();return this.isViewer||(this.iconsBytes={move:"iVBORw0KGgoAAAANSUhEUgAAAJIAAACSCAYAAACue5OOAAAACXBIWXMAAC4jAAAuIwF4pT92AAAOQElEQVR42u2dTUxT6RrH/2NMWlhIJwIpi9aaMBGjCQVXIMnQScYMK4+zmRk2Uq9rL4suXDFMV96EZNA1Y+sGrxssm+nEmwAmiCtpSTDUaEJtF5DK5LYuarvyLvp2LkOg53nP5/uenidpjHDO6aHn1//z9X588fnzZ7jmml475X4ErrkgueaC5Jqz7HS7fwDRmbkQgBD77/gJh4UA5I/5+Rr7N5+Ix/Lt/Dl+0S7BNgMmfOgVAjBo8NtsASgzwLIAsu0CmGNBYuCMH3qds+lW3jOo1gCknAqWo0CKzsyFAUwxcAYFvc33AFIAkol4LOuCJJbyTANQbFSdtodKWpCiM3NTTH2+dsiXegvAfCIeS7ogmQ+Pj6nPlITqQ7UKgHkGVdkFyRyApgF0tUlGLRVQQoNkNUAdXg+C/l7SsYX9Ej7V6i5QooPEYqBZM1zYhVAAwb4edPu6EPT3ovvLM+j2aeO0WqujsFdCYb+Eg3IFhb0PeJMvmgXUbCIem3dBoqfw80YF0R1eDwZCAQycb7yoiqPXCvsl5HaLjVe+aKR6bQGYTsRjay5IJ0M0C+BnI+AZHujH8MWvMHyxX4i/LbdbxGbuLTZ33uHP8kcjLnmfKVTZBenvKpSEziLi1fAloeBpBdV6ZhubuXd6leo9gCkR1Ml2kKIzc9MAftV6/lnfGVwbuYKxocvo9HqkSsuqtTo2d94itbqhV6V+ScRjs20JEsvIkgCuawVIiYxibOiyI3L99cw21jOv9QTqzwEodrk6W0BiriylJSNzGkDHub3F9AqK+x+0ZnbjdrRbLAcpOjOnMCXiyrc7vB4okVFcG7mCdrD1zDYW06taY6io1a0WS0FitaEE73nfjgxDiVyVLgYyIoZKrb7Af15uCh83WQZSdGZuHsA/ed3Y7RsTGDgfQDtbYb+EhaW0Fnf3KBGPTTkGpOjMXBLATVeF9FlqdQPLqxtCwmQ6SLwQdXg9uH1jQvhakJ3B+IPHKd7YyXSYTAWJF6KAvwd3JhXNfa92ip0eLKZ4SwWmwmQaSLwx0dXwJdz+fsKlhMMW0yu8gbhpMJkCEm929tNEpG3SejPKBL89/cP2bM5wkFid6Cn1+H/c+M6xxUUrYeKsORleZzIUJFaxXgOx2OhCZGyJ4N7DJzwwDRlZATcMJNY7y4LY9nAhsh2mCoCQUb05I+f+J50I0cJSGgtLaSnuNejvxd1bP6CDVnvrwv+nnIsBEhsKct2JEL3IvsaL7GupYLp9g5z9DrLBhPa7NhYXZZyWnTUhkrVEwZnNRfQOjjNCkUjR/9XwJakhAiCVMo0NXca3I8PkZ8hiXHtAYrKoOjw24O+R5pt8EkQywjQ58Q0uhEgN73NozNixHiTm0lQH6nd4Pbh760dHQCQjTHcmFZz1naEc+s/ozNy4HYpEml915ydFig4+FSLZYOr0enBnUjE0TDEMJNYCUZ139u3IsBRjiXghkg2moL8X1yOjJBenNYs7pQEiH0WNAv4eTE5841iIZINJiYwi4O+hHDqtJfDWokikefjtAJFsMBETni5q2KIZpEOLOkjv0oyCSCaYOFzcTbaAmWmKpKpGjdkeV9sKIplgUiKj1Cxu1hSQqGo0OREROkszCyKZYCKGHVyqxKNIqmp01ndG6D6a2RDJAtPwxX5qoXLWLJCkDbCtgkgWmBRarKRQMzgSSKxu1KWW7os688NqiGSAaeB8gKJKXWis12mYIqmqkagNWbsgkgEmoipNGwIS66kNyhgb2Q2R6DANnA9QipTnKD04iiKpSpuIaiQKRKLDRHx2qgxQdkdq2fHr8HqEU6NqrY6xocvk+9KxjAx3K6haqwtVHhkbukyZgaLoAom5tZbjsIcH+oWrG3V6PVyV9U6vV8d7eaVf5GJs6JLaRMuu6MyckojHUlpd2xSFaNfkNqJ7U/TESIpakC3Kt7FqzeLpjrznbl8XJejWBhIrj7d2a4LUjRaW0ijslaQDqbBXEiYAJ3iWLhbqcCuSYsCbt112Jms2RxQFRQtI42rZmlWr6DsVIpFg6vZ1UUYFjBsO0kAo4ELkMJgIqvQ1F0gsPuoSNT5yGkSiwDQQCqoec1KV+yRFCqtdMNjX60LkMJiIGXjYMJDsio+cDpHdMHV6PZQ46Vg2TmuJj5wGUbCvx5Zz1WACYPkM5aC/V21flBAPSCEDJFAaJRJ1QJ4dMAX7epHJveMOuE9ybedap4pnHAOR6+b4s/HjRk2eOuYg1UDbquWL2x0iO2Dq/pIkEmGKa1Mdo2tFxsYL0WJ6hdzFD/aZNwt4Mb2Cwh5tSEq1VhPOzRFFwkcBKUSJ7kVTIq3jiYw2EzdHtgyms74zagF3c5u0ljFSS5CI88dddyaxm9MSunDP/dczCMyFSM4AnOLaTony4bgQiQNTt4aiJLdrcyFyPkzdXxrj2lqCZHQx0oVIejdnv2tzIXIOTLaCVNgvuRQY+FnaOQbcVpDu3vrR9HJCO1jA34O7t360dVrYcSC13OTEyEH2nWzpZBcmuSE6CaSWWy8ZLZ8uTOJBxNO6EcK1uTCJqUSEXmFWN0haaHVhcpw7K1NAyre6gpnNURcmMSA6KFe4zznNC5JVbu7ew39zQRvw93ANIzHLeK5drdW4/0YrlEil838sI6e1vFFut2jqcFstME1OfCPEOgQ845xyu0X8K/FEKIiIapRXdW2UDeCsKHy5bs6emOjgvx+NAYlZSyytqki7MFkfWFOebSIeI7u2LFpMz83tFoGI2DETj61ntnFQ/qjp3G4T18+0IzsjFJy3qMG2KkhaonqRYVrPvNY8PPZCKGAKSHal+ARFOrZgfYrn4MNRvV0wtYObswuiaq1O+aLmDQPpL/dmU2nAyTDZWWwkPtM1MkiJeCyrFnDbAZLTYbK7Yp3LFyiBNh0kiirl8kXbPnAnwiRCF58gDlsn/aIVSCm1OMnOgWlOgkkEiA7KFUp8tKYFpDW1q27uvLP1ATgBJlHGExGfJT9IlDhpPbNt+4NowmTXwl96LNjXKwRE1GepZ8F2od3bYZhE3rVS9PsmurXlVr/UBZIoquSaJW4tpRkkJmUq7s2dTiS7PXv5SjdIp4kXuHnSLz/V6ljPbAu1J0m1Vje1N3fY3uSLiM7MSRVYH1Ujwvij5UQ8Vtbj2gAgaRDRbZ3NiQgRx7NTZUAVJFbJfN/qmOL+B9sq3TLAJCpEB+UKpVldaZWt8SgSAMyr+r/VDSGzIrthEhUiAEitbBjy7HlASqoF3W/yReFUyW6YRIbooFyhrruQNAwkFmipypuIqmQXTCJDBACLv69SDnt03GhIPYoEALOUDEZEVbIaJtEhyu0W1dbS5nJrXCAxMh+pHbfwVMw97q2CSXSIODzHc9YmMxYkqir9Wf4orIszGyYZIHr28hV1WPEsz3W5QKKq0rOXrywfims3TDJAVK3VqV/yR5RpaXoUCQCm1TK4T7U6Fpb+gMhmJEwyQAQ0Vsj7RJuTOMt7bW6QWAanGoS9yReFq3ibAZMsEG3uvKMG2PepmZpeRUIiHpuFSrUbAB6nV4Vf3k8PTLJAdFCuUJOgihY10gwSsymqnIqyv72RMMkCEQA8WExRXdqUWnPWcJBYMLasdlxx/wMWf18R/sPmgUkmiBaW0tRREM8pPTUzFKmpSqrp2Yvsa6FLAjwwyQTRemab2gapUD2MKSAxGSTdwPLqhhSjKVvBJBNEud0ifntKzpyntQTYRipScxTlfcqxixIE3yfBJBNEhf0SHjwme6nlRDyW1PuehixGmojHptFi8lzTPtXquPfwiXQwyQbRvYdPqMH1e70urWlffP782ZA/IDozF0Jjdq7qjigdXg/u3vrBlt26ea2ZcToQogqAcZ5+mumKxFQpD0ChHCubMjkQomZclDXq/Q1dZ5uVBKJOg8mBEP1iRFxkims74uaSaDHz5Kibm5yICDULRSbL7Rbx4HGKB6JHiXhsyuj7MAUkXpgA4KeJCK6NXHHJ4LD1zDZPig80io7jZtyLaVtIMOqXqcc/Tq9K0U4RxRaW0rwQbVFjWC122uS/dwqNFSwGKQe/yL5GYb+E299PSJHR2WEH5QoeLKZ4J39usQytbNZ9mebaDrk4HxoTB76mntPh9UCJjLqu7oht7rzDwtM0TzxkCUSWgKQ1ZgIaK8be/v47TfvQO8mqtToWltLU8UR/i4kAKGZDZClIWmFqd3Vaz2xjMb3Kq0KmZWdCgMRgmgbwK+95AX+PMPuNWJXWp1Y3tK7/fZ+1reBYkBhMChozOLl9ltPd3UG5gtTKhtbdxytoVKyTVt+3LSAxmMIMpkEt518NX8K10SuOye50AgQ0GrCKkW0PKUA6lNHN88ZNRxXq2sgVDF/sl9aFPXv5SksgfdiWoWOYrPQgGeHqmnaWbS4zNnRJeLdXZYuTPXv5irLIlZCuTEiQDqlTEsB1vde6EApg+GI/hi/2CwNVtVbH5s5bnmlBlNR+Su/IRseBdESd5gGcM+J6AX8PBs4HMDzwleUZX263iFy+iM2dt0YuQyiMCgkN0iF1mgbws9HXboLV7etC0N+LYF+v7vFG1Vodhb0SDsoVFPZLKOx90Lxtl1paD2DWzlhIKpAOARVCY8LeTbPf60KooVadXo/q4u+FvdJfzeU31uzJIpQbkw4kO4ASzJ4zBVoT/UalAKkNgXoEICkDQFKCdASoKfY65xB4KixrnRfZhTkKpGOyvCkjygY22TKAlGhZWNuBdCTTU9jrugzwMIDKTvj8HQPSCUo1zl6DNt/OFhojRdcArDkFnrYA6Ri1CjOowgBCJsL1Ho2JolkGTtaJ4LQlSC0ACwNoQuZjPx4nnt7MqMoMmrJdnXcXJNccY6fcj8A1FyTXXJBcc5b9D4O1t0lsiFUUAAAAAElFTkSuQmCC",rotate:"iVBORw0KGgoAAAANSUhEUgAAAJIAAACSCAYAAACue5OOAAAACXBIWXMAAC4jAAAuIwF4pT92AAAQUElEQVR42u2dTUwb1xbH/0WR+FiAqxBEFgZHIgookQJmBYkUiFQUusHJJg2LPkhRF5Ee5VV+alaUePGUSqiieVIWfUkMXdBmU8ymREQqVCKwCgaJKEZBwtiLWIQqdhZgVn0LX6cuBd8z4ztz74znSIi0DB4z/t3zdc8594M//vgDjjhSqJQ4j8ARByRHHJAcsZccK/YH0D886gHgYf/ZccglLvY9ecjP5tn3lWDAnyzm5/hBsTjbDJhm9tXB4KkXfJtVAFEAK+xrvlgAsy1IDBwfg6YDQJWkt7LFNNc8AyvqgKQ+PB0MHp8B2kak1poHMB4M+FcckNSBpxlAn+Lw5NNW4wyqqAOS+fC4GDhDAM7bZFH/xoAad0AyB6Ah9lUFe8oWgDEGVdIBSbzjPALgH0UUUacYUGNWAEppkHI00Ndm3O+4qxLVLpqiiyW2sZfeNw2oYMA/4oCkD6IhpoWEmrDyslLU1dag8ZQb1QycupM1qCgr1fV6O8kUdt6+QyyxjZ1kCrHXb7AejRtl8oaCAX/IAYkewo+JcqLLy0rR6HHD29SAupM1qKutMeXviCW2EdmMI7IZRziyIdop71MtylMGJGbGRgB8IcJEeZsacLHlnGng8GT55QaWX77CcmRDlEm8o5K5UwIkpoXGUUAeqLysFN7GBnS1tyoDDw+qZysvCn2pVaadVooepP7h0ZFCnOnjrkr4OtvhbTqt28+RJbvpfcwuPcdCeA2/J98V4oyPBAP+saIEiZmyeb2+0BmPG77OdjSectsi1l8IryE0t1gIUNNMOyWLBiS2rTGvJyKzG0CCgZJm6kwHqX94tA9AUK8Ju9hyDsUgs0vPEZpb1OOYpwD4ggH/vG1B6h8eHdMTlfV0tqOrrdVyPpAIH2ryl1/1OuX9Zu7bmQZS//DoODRucbhrT2DgWrfyUZjREtmM48HUjB5z9y+znHBTQNIDUU9nO3yd7XDkT+0UmnuGp0vLWn91Ihjw91keJK0QHXdVYrDXV/Ra6ChZfrmBB1MzWn0nw2EyFCStELU0NmDgWnfR+UJaZSeZwr3JEOKJN8rAZBhIWiH6qM2L3u7LDiXGOuKG+UyGgKQVos+uXimasF60hOYWMT23KD2aEw6SljxReVkpBm/4bJtcNEsWwmt4OPVEy690is4zCQWJbb7OUSG6ffO641TLgSkFoENkBlwYSKwcdgWEbQ8HIiVgWmUwCdmbE9n7H7IbRLvpfQzfn7AMSBdbzuGzq1eol59HpnQHyoDEtj5Iu/hWgujuo5+0hthWg6mHlTTLB6l/eNQH4v7ZZ1evOBCZBFMPfVdghFVjyAOJ1RSR1GOPRXburQ5RVnyd7bjQfJZyaZUIE1eoRhqn+EUtjQ2W2DezC0RZ6f34Mty1J0j+EqtUNR8kZtJ6eNdld/AdiMyXirJSDPb6UE7bcvqaRd7mgcRMGinVboW9MztClJVqVxUGrpIX8ripICHT/crt+LjR3am8c21niLLibWrAR21eyqWXmKUxHiSm/rgh4xmPG11trQ5EyjjfF3DcVUm5dMwUkEBooy4vK8XAtSsORIr5S0QTV6/H8dYEEtNG3F39rrZW8jAGByLzpPGUm5oSGGJ+MFm0TrXlkprt9rATRKGcMo0KNoSi+sNKpRdLvpQAoW28irkvZM1E3rRl2miTd91X/deVLQsRrYmyAyoaT2WGVFgFrNml5/hxhlukkQLgoW7qlojURmfYQy0Wc7aX3kc4soEfZ+bw72//h7uPHmMhvKY8SF1trRTHuwqZ2ZzifCRmL7m+kaomzSyfaD0ax8OpJ7j1n/8iNLeIXXMGcemM4kif1ZBQkKjhvqraKLIZN9Wx3kvvY3puEf5vv1dWQ11sOUfRSvWs4lUYSH2CCJci3qYGLaUVQoF6OPUEdx89RiyxbVWtJAYklumst6o2yl2BMmDKmjwV/SeiVrpE2YOjaCRuylz1DLYKMGW104OfZ5R7JiK00rFCnezsmD2rSPbBaem6+Kr/OnbT+4gltrGbThc0cPTZygvsJN9hsNenxGZ2V1srpZ2pjxe18xKSPkFEWxqmrNk+uGD0zoXMmLqfcPvmJ9JhqigrxYXms7xGy/r+4dHmfF0nJYWDdBZWFBFmztuUaTEf/fJz9HS2U+t+AADxxBvcm1Rj0rG36XTB5o0HUke+H7prT1hym0C0z1RRVgpfZ/t7oLRoJhV8Jm9TA2URdOgCiUVrVXYza0Y64Fmg7tz6lFriimcrL5SI5ryNXD/3fL7orUQvgYf5DA5MGamrrcHtm59Qd9oxOTMnPc9ENG8dwkGSbdZ20/vYSaaUhamirBQD17pJMO2l9zH5y5xkkBoMA+k8JZKRJbNLzzF8/wehK9mIPBMVpvVoXLqJa+GbN20gsWEQ+UNiT520P3gnmcI0m/gqevtBJkyTM3NSN3oJyqH+qIK3Er3+kUyNFPp18S9mwQowUXrM9thJAAqDdCQbR4HUzPOPZCXSdpKpvyXPrABT1meimGxZQuz4adYCkkfADQ2RhfCLI1ez6jDV1dZw80x76X2pvtIZj1soSHkd7bqTMkFay/sh5Jo9UTCJlK62Vm7y76jFYopWOsnNf3lIIFEmU8jSSJHNOHdoueqVCBVlpdz3uB6NC01taBFCSuc8VSO5+NTKAWk58irvz4+7Ki0xj5KilZZfbkh5bxQlcVjkVqLV0c6uKlkaycraKPf58bYkeH+rYRrpQ1I3bnPBGom6hyRadtP73LprK23Z8LYkIlFJIOncrSjRvprKpPyBsdfbXLNmpUoEHvR7greAtIieSgDNpk2aWeOs0EaP9WZ180LtnbfvpLwvPcGUZtMmM/S34vsqJNRWsfNEmGmTJTzn04ozu3lugsoNlpYFyY5ip4H1DkiS0wAOSI4Us3gckBwRIVEHJJUCCElJx6I2bXYKle3oQ2kGaedtStJDzR8qy8oCF6SRbJTSOAyk+fwfmJxsKy9zLWuTsxDhzQ8gbqAKFz2L0jKmjfdQ44k3lkrg8cAvLyuVtnf4O19ZzFNAShayigwDyVXFneWz/PKVZUDi1VbJ2jvUuxgPA2nFqJsZbd5kFs5rFV45rawCPV6VhZbwPynoZsKFV8MTT7yxhK+0EF7jjsGRVVtF8Y+CAT8fJMrJy7IiJMrUjNDcovIg8d6jzHZ4QhplVYuzvVXgzYyDiVOiuh6NC9VKO8mU8L+XNwRUZslw7DV3+m9SC0grBd7MMOlq5z/kyZlfxYH09p2p/XLlZaXUySCyNNK8MJDWJab262pruJWF8cQboTCZ2XzZ1dYqLaMdS2xTRhiuCAOJkgcxUijzoZ8uLQvtWDUDpnJCz5uRQvxMNYE0z72pRK3UeMpNGcEifICV0TDJ1EZEkFKHRWxHgsROxFnN94qyk3+9H3dyIzgjPnijYPrnDZ/00xMIyuFIBVOi55eyfojMLYlqVxXpwWc/eNXNnOyePKJ/JB4kFbRSV1srycRlp+6r7oDLFOJCCxkE0ob0BzBwrZvc/ft0aRnD9yeEBQp2gonwWW4d5R/lBYn5SdP5Xjkc2ZC+454dYEUdlh5PvME3wce4++ixEKDsAFMssU3Z8c87XZ5XRsLVSirMiM6MI76uafL+ejSOb4KPMXx/AgvhtYIWhNVhml0kbXbnBSnvmbZsfMnbfC9w3FWJ0S8/V2Zl3X30WNO5ILnirj2BxlNuVLuq3lcnxhLblPNf3+eBbt+8bqnKxt30Pvzffs97ZlvBgN+jGyQGUwhAT75rVDoQOZbYxoOfZ6QdxW41mBbCa5TDfb4LBvxDhZg2rkpTxbz91cx9QormjBCrmTlitcQ47wIuSMGAfxyZo7uPlMwZZOoU31eUlWKw14cb3Z2a/KZig4kyShHAKqW0iFqzzSVS9BBQEdLV1orArU+laKcsTCp3txC10RjlIipI3BdTTStlpdpVhcFeH77qv04Z/Sv43pXSBpNRtBGhiiNFcW3IILFE1LQVtVJWGk+5cfvmddy59SkuNJ813OS5a08ocUJkodqI5RO5ckzDvcd40duzlRfoam9VOmKpq615P4E/e5RoJEryFWwD0UJ4jVpTNkZ9TW74fyAVMA/gUr5rzngyK99qspNMYeftO0Si8fcHIGfyLGlNqQTVIdpN72P4/gRl4UwEA/4+6use0/g+RgDkzc5lj4uy2umS1a4qVLuq/pYPi2xmMuB2gAjItGwRte+IltfV1GkbDPjnAfzGu072cVEyxAoQxRLblKPZAeBOvg3agkFiMkQJfVU49NeB6K9C/ExSWnwj3SCx5NQE77pwZEOJMhMHoj+jNKKvN0KN1ArVSFmtxE0aPZiasbWJswpEGkzaajDgH9NzD10gMWK5ztheeh/3JkMORJKjNA2fwZDe++gea8PI5Tre69G40BJXByLtfhExSvuOBVPmgsSkj2LiRPeYORDRZHLmV4QjJD91S2u4LxQkFiKS3sDDqSeWr222EkQL4TU8XVomKwQ9DrZIjZQ1cdOUa61cjmoliCKbcUqxWlbuFGLShIGUY+K2KM636qUVVocoltjGvR/JzvVqMOAfEXFfISAxteijXJuN5KySFqg7WWMpiDTUrKdwyLlrekXTpi1P+odH+wAEqat8sNdnqcP6bAQRALRQKh+lgMRgGgPwBeVaK3Zd2ASiflZCDWVBYjCNA/iHA5M50ZkGxxogdITIdLYPyhA400xyfaav7/9gmzyTmRKaW9QK0YQREBmmkZhWciHTqXue+jsftXnR233ZIYQju6y6gphszIWoz6j3ZBhIemE643FjsNdnq0PxRPtDOhpADYXIcJD0wlReVoqBq93SZwapJrNLz8nt42ZCZApIemECgJbGBgxc6y567bSTTOHBz0/0DIE1BSLTQMqBaYwazeVqp97uTsvVgIt0qGeXnusZjGEaRKaClAMUOc900Hfq/bizaNIEkc04HkzN6G2TEp4nUg4kBlMfiBnwg3Kh+Sx8l9ttmxGPbMYRmlvUO8s8BcAnYhPWEiAxmJqRaQeud4AqGCAgk7fzae3+sDxIOX7TODgdvDygLracU2Y+k1ZZfrmB2aXnhZ6m8J1RiUZLgJQD1BAyBXK61ctxVyW62lpxseWc8lHeTjKFhfALLITXCm0VTyFTlCa9MF4JkBhMHqadLhX6Wi2NDfA2NcDbdFoZqHaSKSy/3MBCeE3UNLlpCKhstB1IIrVTrrhrT8DbdBqNHrep5m83vY/Y620sR14hshkXOYpwC8CQClpIaZByfCfNOSdqGqHu5AnU1dYc2utfCDSxxPb77wbMsMx2wI6pooWUB+lAZDcmwtxRAAMyw7GqP8yvDGOvt7Gb3tc8qaQAmUCmAzaq6melNEg5QHUwc3cJxSXKA2QpkA4ANVRIusAByAHpYIQ3hEz3il1S3FssalXSB7IlSAeg6kOmg8WqWmoCQEi1KKzoQDoQ6fUh02KjOlTTyGwPhayofWwN0iFQdeR8nZf8llaRqceat7rmKSqQ8oDVnPNVbyA0UWQOEZ6XsRPvgGQ+YM0AXAwsF/vfHYRfTeLP06az/06KbDh0QHKkKKXEeQSOOCA54oDkiL3k/xH7i8FYmXomAAAAAElFTkSuQmCC",resize:"iVBORw0KGgoAAAANSUhEUgAAAJMAAACSCAYAAABBufiwAAAACXBIWXMAAC4jAAAuIwF4pT92AAAO80lEQVR42u2dT0wbVx7Hv0WVMBzAVSAiBxNHIgKUSDHkFBIpGGmjOJc4XNJy2OAU9ZBDN7vySjl5XR9WWQltaVbqZZ3Y7IE2F3Av6yiVApEInIJBIsJRkfjjQxChqp0DMafswW9aLzUzb968efNsv6+EkJLxzHjeh9/v937v937z0YcPH6CkxEMN6hEoKZiUFExKtauP1SMAQpFxLwAvADcAX4VD3OR3vsL/zZHfy4lYOF/Pz/GjegrACTQ+8jNIADrJ+TIrADYBLBPQ6gaymoYpFBnXoNF+Wh26lS0C1hyAuUQsvKlgqg6AggScoA1Wh6f1SgFIJWLhZQWTfBZolPy0VtntbwGYIGBtKpicAchNrM9dAOdq5I/7BwDJRCycUjCJC6JHCUStqE1p1ipZTcF71cBEIIoCuFVHs+0CgWqiGqCSHibizqIA/iTiesfcLWhz/7/Ba3Y1Yr948Ltjt3d28b7Cv9sEVTQRC08omNhBitrhzppcjejsOI6eUx60EXg6TxxHs6uR6Xx7+QL2fnmH7Z1d7OUL2H7zFq83c3a5v7uyxlRSwhSKjA8CSPKa2je5GtHf04WeUx50njiOzo7jQr5HdiOH7Z1dZDdyyGTXeZ76OYBR2WZ/UsFEXNoEj7jomLsF/b1duNR3Vhg8RlpaW8fS2k9Yyq7zcI8FEktFFUyVrVHKikvTLNCVgfPSAKQH1nxmlYfFWgEQlMFKSQFTKDI+YSXAPuZuQdA/gP7e08xxj1Payxcwn3mFp4svrVirAomlknULE5nup8CYdOz2ehD0D6DnlKcm8gDzmVWkZhfwc/4d6ykmCVT5uoLJilurNYg4Q+WY23MEplBkfBRAgsWdjQSG0N/bhXpQanaB1f0VAAyKXkQWDlMoMp5kma1d9w8g6B9AvWm/eID4dJo1UA+JjKOEwsQCUrfXg7Hhq7/LStebshs5xGfSLK5PGFBCYGLNH30W8OPKhfNQ+s1KTf33GV4svzL70a9E5KNsh4mANGdmxnbM3YIvR4LS54qc0tLaOuIzabOx1GQiFh61875E7E5JmgGpr6cLsTu3FEg66u/twr3bN+HpaDfzsVtkrbM6LZPZGKleg2zBwbltMZRtMJkF6fMbV3Gp76wihEHx6bTZOMoWoGyBKRQZvwvga5pjm1yNuHf7pnJrFjWfWcXDmSdmPtLHOw/FHSayO2RGgSQ9UAUAPp6Z8gbOIPlIwK1AckCX+s7i8xtXaQ9vBZAis225YCI3lQTFWpsCSRqgzqGU/5POMk3QpAAUSNIBdYuslcoBE4mTqGZuIwG/AkkQUBd9Z6gNASkHchamMvdmqM8CfjX9F6ix4QD6eqgqLFppx9Buy0QVJ130nVHrbA4BRZkpv0xSOs7ARNzbdaPjPB3tGLk2pEbWATW7GjE2HEATXTlz1Iq7a7AAEpV7ayJfptpqs2tJnR3HMRLw2+7urHSOo9ocGfQPMAfc9x89tu2v9cuRoG2DN59ZxXzmlS3nvnf7JnNAvrS2TrOOdzkUGR9MxMJzQmAipvBvRsf19XRZipPs2BWrpSbsnkllN3IsdUe2x0+RbydpCuySKHXVE+LmojSDNnLNL9XDFJnjGhsOmJmaC4ufRgJUsetJltyTaZjIrhLDnFLQPyBVqa0TyVIZgerv7aJNF0yYXWphsUyGVsnT0S5VGsDJrLuMQI1c89PM7lpJXGwPTGQh97LhzQaGFEgSA9XmbqX9Y7cPJpqT95FuIwokuYG6cuE8jrlbDK2TmdiJGiYygzOMlWQJumVcUJYJqGZXI22JdJQ7TCj1kdTVRd8ZKYJumSsTZALqUt9ZGut0kqx0cIXJ0MUFh+TYDNBWoZWg0tGzbh6GhBom4jd1R6fb65FmAHM7b3H/0fcV+1A6LYbif9utE8XM7jrNmh2tZQpyIryugZINpPJgnAcDhjCRxJVuZcAxd4uU7W1kAWq/eID7jx5LCVLJOlHFcKOWYaIhUuY6JaeBKoH0vV3ddznFmK00WfFzRq6OC0xO9UuirNFBbuctHkylHAMpt/PW8FhPR7ujszzKMQwyw0Tj4vp6uhwJvLXpP23h/OvNHOLTaWlBunf7U0fTBpSB+KgVyzQoo1UqzyOZ2YnxYvmVEKBYQNKKB50Eqp/O1blthOm0YyCV/1XJApQZkErf5dPfVaE6BRTlWA7aApOno11oOa5eZtvM1h67gNrLF0yCdPPI5+cEUJQzcvMwEXN2TharRLNEYmYAeAO1ly8g8u1/TIFktNwjGqhmVyO6vR5bLJOhi+vxeqQBiWUAlrLr2MsXOA2EC23G61ym1w1FA0VhnY6Mm/Rg8nEyi8JAMjMA2nl5zUSbSfyjt0eNdQFaJFCUBsLH1TJ1e+UEiWYA7Koq0APK6jVFAWUlbtKDyat3ts4T7bZ/sdidP1oa8EoDYHd5SiWgeF1zbDggxDpR7AD2moVJ911vImqFeLig8v32ouqcDgM1diNQVc06KO61IkwfHzGTGxQx0KI0NhxAfDqN4NCAsEHVgMpu5Kru9RxtnxiO7WWWPJOjwTfPgXWir3izq7Eq3/PCOktvYAm+m1TfgJpWc5Px+FbyXkyWSTXrqm2xjm8Dy0xOSakSI0wwiUgLKDkrlvQAk5trdrnU0671uIlhjBvUY1PiJQWTkoJJScGkpGBSUlIwKSmYlBRMSgqmCtrU+1B2I6eeXI2LYjv7JheYlJTMwKSr7Z1d9ShrWKzjexRMui8Cfi9hEy0lftp/TzW+y7Qw5WvNOm3v7GI+syr8mnf+/i/h1xVhmRKxcJ4KJpqXsOz98q6qHs79R4/xcOaJsIHVrvm+eCD0ujxEsTH1udnUQMFpy8SjQVf5oAIQMrCHr8nruvvFAyFQbr8x3OKeNwvTstPpgaeLLy09vEqDajdQR11Tuy7rH6HWXcWuV4+ZTAssm4VpzuIFuYh14PUG1S6gjK4JlN6hZxYoM216BM3k5rhaJpFBuNmBpxlUO4BKPVswvOZ70iyV9tmJBMmEx1nmDpPITDjtwO8XDxCfTlOlL5pcjeg8wW+nDe3LlWmBEg0S5ZhuVZrJ6cKUiIU3AWzpnXVpbR0iZQSU+a5tfLeK03RCoQXKCZAAIGscvhwZ/jSwflCLm0S3RD4KKKdB4gmUUyAtra3TWHR7YCrdwE/C8yCHgTLbkNRqdxU7gXIKJBNjyQxTioZmJ6QBxdLZVkTTDbNAxafTpnpiOuTiVkj4Yx4mEmit6B2Tya471v3/4cwTRL6dZGqRLELNrkbE7tyiatKV23mLv/7z346BtLS2TvNWcV1PRVM1kJTR1WmieACOgHR4lifbe3oZxzBpFSZDV/d08aW0D8lpkKoBqP3iAc1LgrYSsfCyJZiIj1wxMtEyVhHIApLsQFEmbg2NCm1x3IShdVqQyzp1ez1SgSQzUJSeZYIXTCkYVBG8WH7Frac2H5BuSgeSppFrQ9I0TJvPrNLEnc/1ZnGmYCKzOkMzl3q2IMUDer2Zk7Z+SEtlyFKtmpqlGrMkzUFmasCjRgfIZJ1kLEhzMiFpIR1QSMTCfGEiZu55tVgn2YCSDSQAmEo/4xIrsVimqrNOsgAlI0iUsVLBNphIbbihdYpPP5HKvTgJlIwg7RcPMJWepbJKR5Wb8LBMVNbp9WbOsTU7mYCSEaRS0P2CZgJgyioxwURrnabSzxx/BbyTQMkK0vbOLn5cXOJulVgtE5V1+jn/DqnZF9JNzUUAJStIpRCE6oWNpq0ScMS7U2isUygyPgnglt5xPy4uob/ntHSvxng48wSX+s7aeo2RwJAt56V5e8DR7m2BFvC7Zq0SAHz04cMHphsLRca9KNWJ6xYHNbkaMf6XL6TNRteLshs5/CPxmObQlUQs7GO5BnN/JpJ3MnR374sHeDCVUqPp8OztwXfUYzDKeh1Lzb4SsfAEDCoKtNkdZdpeyQY9mErRLt98Y1RmYhtMZkj+YXah6ho41ILi02naDbNbNJ7GVpgIyX+mOXYqPat6OwnUfGaVpuhNU5Al6OZtmTR3Z5h7MrubVckaSA9nqFcivrLi3rjCpJENg5onDaj4dFq6hGYtaXtnl3a5BCjVKkV5XJcbTMREBmmOze28xf1H3yugbAKJps8CUYF2zERbJm2pJaSAqhqQBq3GSeViTlrqKRQZT8IgO67J09GOseGAelWrRS2trSM+kzZTwRmiLXpzFCYCVArAdZpj7dz7r4LtIwPuKO/7sPMNBaOgSGiWz/JUHsq8ptLPzII0aQdItlomYp3cKG0pPkf7mev+AQT9A4oSA2l9qDLZdbMgjdp1T7bCxApUt9eDL0eCanFYJ9B+MJWi2hovCiQhMLEC1eRqxNiNAPp7uxQ9ZXq6+BLf0eeQhIEkDCZWoADgDxf6EfRfrHsrtZcvID79hKUxrRCQhMJUBlSSdpanrFRJqdkFPF18ybJx8yu7gm3HYSqDKgnKPNThWGps+KqQZl0yKLuRQ3wmbTY2+vUx884jSQkTAWoUQILlsxd9ZxAcGqhZqLIbpfovxl7rWmZ7WfR9OwYTAcpH4qhWBZVliIBSXo/rEknVwFQWR6UAXGY9x0XfGVzqOyvdxgVazWdWMZ95ZfWtD98kYuG7Tn4Px2Eqg+ougK+tnMPT0Y4rF86jv/e09LO/vXwB85lXtNu0jdxakOZNXHUDU5nbm7BipTT19XShv7dLKrD28gUsra1jPrPKa0/dJBi3JdU8TIesVJQ1lqo0C+w55UEP+S1K+8UDZDdyyG5uI7uR47kpcwvAqAzWSHqYymKpCZYUAg1cnSfa0dlxHG3uVi6A7RcPsP1mF9s7u7/+tmFHbwGlbdtRGcdMWpjKoBokVuqy3dfq9paganO3oO0TfaO4/WYX+8UD7BeLoraBTwKI0rQDVDBJBJVkkh6iqoOpDqGqGoiqFqYyqLwEqiCvQF0CbaG0djkhywytLmA6FKgHUarsrFZrNQkglYiFq7opQ9XDVMFaBcmPzGAVUFpGShGI8rXw/GsKpgoWa5CANQjgpMO3tKIBJFt+SMHEDpeP/PbaCNgKgE2U+lfN1So8dQuTDmQ+AG4CmZv88yDFR/P47aXYm9pPNc2+FExK0qpBPQIlBZOSgkmpdvU/qa4Z7QH/pAsAAAAASUVORK5CYII=",remove:"iVBORw0KGgoAAAANSUhEUgAAAJIAAACSCAYAAACue5OOAAAACXBIWXMAAC4jAAAuIwF4pT92AAAKi0lEQVR42u2d73XiOhPGH+fc7+atALYCvBXgrQBuBXArgK0AtoLlVgCpIKQCnApwKsBUgKlg3g+Czd1NgsaWbEv2POfoZHePNzHSL/NHGkkBEUEkMtWDdIFIQBIJSKJ26a/O90AQ9ABE17/Fnzw1AJB98O/J9WsGoqzT3diZYFsBE1+hia5wDC3/lFcA+RWwFEDaFcDaC1IQDK7g3Fq/oTe5XMFKAOzaCla7QAqCCMDsCs7Q0bc8AdgB2IIoFZDcsjyza+t79vatgcpfkILgBs+oJb/UrwDWV/eXC0jVB8wLT61PkZhqDWDtE1B+gPQG0AJA2KGs+hHAyocA3W2Q6gYoDIEo4j2bZcDpVFdP/HDdQrkLkoqBVpW4sNFIATMYvH0dDMp9rzwH0lSBlaZv7XKpwuWtQLQWkPhZ2NZqED0eA3GsGtfimCpNgSR5a/bAegWwAFHi1LgRkTsNWBFAxi0MiaZToqcnckaHA9F8TtTvk5XPCKwJ6Lkydq4AFBGQGneua/Dcg2o6VcCbfeaMgFhAUhAtCMhLd2a/T7RcEp3P5J3OZ6LNxoaVWnUXJKBHwM4IoM2GWqOnJ6LRyASmtElX558raxtAf2q/NwEqJyDqBkhAXMqVhSHRz5/UGZm5vFm7QQJmpYNoH2MgGzHUclk+q2slSCqoLu7G9nvqvA4HouGwDEzbdoEEbAt3wnzeTSt0T+Ws07YdIBWFKAz9mAtq0joVj522foNUFKLhkOh4FFg4sdN47BRM7sREXQ2oTTSfOwOTG9nZcilQmEwTOJDNVTVPxP9gbZ5crHNWvNi6nfV5JrtlJGoXR8IuQttsgNkMIktlK3FcpFzlm81SFHsgqWrGBNxtQAJR0zBdAES2ynht7v3fCkQNK4pUEV3Icggh1FYouANSECwAjAUiR2DasfkYIgjslO5aWsmX7MzvbC5uPmvjloNMpzK47i6p5Ka1TGbBdhCsACz1BnSofHevJ66nbk0mwPMz58lnEE3qz9pUqn/Qh3ShyibKbvcRmSnPVdzE24NXekrAJNjmBWnbrUDUpHq9IsH39jqNU5NFUpsXN9rn5nNgvXa3k9dr9Rtra8AWC7c/6/fvnCd/gGhVfdamivYzVlGay4uw06mt/WX+JBS8WvCcgEH1WRt3E6PLlY1VQOQDTMcjd01uWy1IyhrlXndmlRD58Pn5UwKD6tJ/TrofhupAhapT/e1W/Zyia1G8VNhc43G5cwZWq+rfbTDgZHGPIJrZj5G41qiuLUNmmwndbXVov7dulYqk//ozivp9tzMXkVIcq6N9GPaxinmkmRNmWWRHvLGacueVeCCpeaO+1hrJqn4brdLCHkhijbpslWZ2QFInqI3EGnXWKvURBBNzkDimTSDyV7yx04Kkn0cKgkwbH53P9ZeIpKm9dTLXrETd4s0r/e/eqbp/aSCKtBBNp83UGdV1qGhXrNKPHxyrtC3r2vR2bzKRgRD3pnFtQZDi3s6QMHTHvSSJuDJTC//6eu+JC4h6xV2bytaG3lijb9/8BMmVc85nM129UoggiD+roLzn2vS/KuLW2iPeWE7KxEj3QQpDAalNGgzUJg2NI7YPkiu+XVRnvDYsBpKKj/oCkoD0ARtxEYsUWfmhojZmkJZBkgnB9qnX48RJA3sgjUbS6W2V3kBERUAaiDUSkIoE3A9Fo/NfqaKoqyDdkjENSB88JBapQ+IZCQZIOrcmFklAYoIEAanjKpG5PXDnCX4pDKWjuzANUFDFLZLER6IPpgAepE9E731SrLVZApKoEpXL2kQiY5BksVZkJdgWiZggZXf/h69F9iLHQBKJxLWJBCRRfUpT3RO5OUhFz20U+Sf9pteUA9J9HHlXEYjEtSG3QKzIZ728WHFtet+l96Gi9ro1pmvj3HEqcVKXA+1CwfZJQBKQPhVRygXpPikyu91e6Y3EKzfYBtS16xIjiUViG5kHbjD1my4XcW/dzdhSeyCJe2uneGOa8EFSmdtFQBKQTC2SPk7i35Mq8kX6MX397Ijk8iBdLhJ0t0l5rjuM9C4T5UEC1OV7oq5Yo5IgqUmnk7g3AcnUIgHA/e9+Ool7a4tb01/R+nzvComHsgT+0notA+G7eCHKXaPCudQmx70rSOu6DFmnIPBzEF04sN3CpTacCsmtNnuTWMlfJQkHortuzQ5IgNwe6bN4oYnWUuhdm3Ib9y+3AYD9vtlduOLaiivLgC9fdE/dvcymiEUCAD22YpX8E2/MWJE41yL1oMoHQmetklikKqwRAHzhVM0+MD9s7rxV0h9X556aPP2ON1aPrNJrFNvXpjdxLy/NLZv4eEpKU7dLJQnw+GjNrV2NDfEbsCVljD9v/T7R+Uy163gkCkPSvp9Lbb+nRjQacd4vKcJGUZAGrA5aLpvpoJ8//YFoPm+mjzYb7jvG1YGkYFqzXuRwaKajplP3IZpOm+mb85lrtZOiXJQBqUdArn2Z0Yga09OTcrGuARSGymo2pfGY+66Dolzw0v/3qfYKwFL73HLZbCaXJO6UBEdRs1e37nbA339znvwXRIvCSFDZeYwgyKC7ZRIADgc5m7tpZZkag8tFP4sNDHTraqbp/5+asVNcOXSi+WkGPUQAsCgDkRlI6v73f7XPnU7qTnlRM1osOLXYAPACoq0BD1S+qcA7c3pKoMvip/p5mQDbPNj+PVaKAexZz242Yp3qUpoCX79yn/4OIqNSV3OQFExrAHPWs02Xm3QFojjmxkXPIDJOJ+2ApGDS1ywBaqEySSSTcwOiE4CobIBtK2t7lxtAt80bUB8wjmX3SRXKcxU68CBSY2YBIrsgqXIDnokUmKqzRLwMDQD++ejArOZd25uLmwHYsJ4VN9eEOwNKzl7X5dpulmnLml+6WaavX2Xrd70QPdqGyHweybR2SeaZ6ponurW0qvGuDqQyME2nzRTF+aj5vDhEQM9PkMrANBw2V8vkg45H1UcOQVQPSGVgarpux1U9PZUpJ64covpAKgPTrTjueBSAzuciRWm1Q1QvSGVh6rp12mzKbmrY1gVR/SApmGalylT7/eZ2XTShw4G72+Ojtq57XOsHScEUs+q+P3N3bQ7Gj0fTDQyzJsa0GZDetjalRjsx2mShzAHKCIiaGs/mQHorjFsb7cwYjVQ246v2extbqHZ1xkPugfQG1KS0q/tvDLVc+pHlnc8qgTDfMpUTsHBhDN0A6c067azsHxsO1UC5BNX5rDKwcmn8x5sYDctjbTb7q//m1QMTqJNP+la+33CoFjUnk/orM2/76na7IuUd2qVuACvT0ljrw+YcSAqmHoAFOJswy4AVRb8304NU81ytwmeZ+pqmnFuGyugRBluGugfSG1ADACsA08p/1nCogOr19PVRWfZ2zVg1wPypFwAz7llFApILQLmll6sbS5wfIi9A6h5QzwDWPgDkJ0i/AzW7tn5L4LlAnZC2dtmFtQuk91neDMDYY+uzM9ouLSBZz/Qm1zb2Ah4FUCtO2GgPSB9bqvjamj7y9hXqgiDVWgJPN0B6b62iK1QRgEGFcJ2g7n1Nr+CkbQSnmyB9DlgE4AbZbVbyv3++p1tGlV+hyW1uOBSQRJ3Ug3SBSEASCUiidun/DlECl01FAtQAAAAASUVORK5CYII=",itemAlert:"iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3FpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQyIDc5LjE2MDkyNCwgMjAxNy8wNy8xMy0wMTowNjozOSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpkZmM5M2YyZi1hYzg1LTVlNGUtODE2Zi0yN2UzOTNjNTM0ZjgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RTk1OEVGRDQyRUI0MTFFOEJGQzRCQjY0RDUzNERGMzYiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RTk1OEVGRDMyRUI0MTFFOEJGQzRCQjY0RDUzNERGMzYiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOmFjYjg5M2U2LTllNTktYmY0ZS04MWVjLTM4NmQyOGQ1NjEwZiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpkZmM5M2YyZi1hYzg1LTVlNGUtODE2Zi0yN2UzOTNjNTM0ZjgiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz53t8IQAAACGUlEQVR42qyVz0sbQRTH36YhblAJCtYKHqonBW3soWB78VCKCkppBCFeevBWKCiekj/AnIT0klsPXhQKLbQWtIgXDyp4UgNtQcSDP1APkhYxDZrt9zvOxkXdTUJ88GFmZ998Z/btvDeGZVniYnUgCvrBE/AI5MAe2AbzYBac3jmbwjcwQQycWsWNPnEQvKlj2Ds2DIMDj9GdAx2Sz0tucUly3+flYmVN8scnys/3sEH8L7olMNAvgVcvMeDjcBoMQmO3oOcIRTNYZXuxlZaziZhc/vwlXvagvU2qpxLi7+wQHaLnui0Im2AZPOMuz96NiZXNSilmmKZUp5JXuxdZBz3g3Kffj1FU7bQMUfWP4Ms5nEsNraV2XI92BzENZfpeu35+1fCQav99+uwaltDCV8Y8g8dWnz5SIYbAK6bB8fcKN+NcalCLmhTu5RP/fqXm0OijcBd7PFKVmkMjTOFG9uxzWok5NBr9/B8gUHTS4WFZi1CYM2qZUV67/hOJFhWjhrYjhuK3WgFp6rmDp2GFp8+1xgaFf7DH3PeymtQHhZc5NBZKThBz9K1qsx+nS0oQu1bEwCTT8i9iWU5K2/Wi9susXYziIGHXiiTY4gsWFDqWI8o5WjSttcQWPgcRcMAqxdX5acWMPvTVlW0fvNFatwp9C7rf7qPQ33U1BfV1cz9Xk8tlOsKCoi/TJj3OhNrkkQIzbpfpfwEGAB0OebpeExhfAAAAAElFTkSuQmCC",itemAlertDark:"iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3FpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQyIDc5LjE2MDkyNCwgMjAxNy8wNy8xMy0wMTowNjozOSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpkZmM5M2YyZi1hYzg1LTVlNGUtODE2Zi0yN2UzOTNjNTM0ZjgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RjQzNTRGRTYyRUI0MTFFODlFNDdCODEyNTEzMUI5NkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RjQzNTRGRTUyRUI0MTFFODlFNDdCODEyNTEzMUI5NkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOmFjYjg5M2U2LTllNTktYmY0ZS04MWVjLTM4NmQyOGQ1NjEwZiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpkZmM5M2YyZi1hYzg1LTVlNGUtODE2Zi0yN2UzOTNjNTM0ZjgiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7DiQshAAACAklEQVR42qyVvS9DURjG3yuiDNLQwUcMNNKkidDFoB1qU4M/gIQJo1oQgsFnsGDEzMLCoDYkarDUx6KRxkBEaMQktdTz3JwrV7m3qp7kl3Puvec899xzz/u+WjqdFguVgU7QDhpBJXgHd+AG7IMt8PLjbBpnUAxGwUs6uzhmDJRk+mgZK64Fe6CB909OonJ0eCSxWEySyaQ+wOVyic/nk2BrUAIBv2iaxttXoAPcGkZm4xpwyjYej8viwpIkEgmxk9vtluGRIfF4PKK2qEW1n8bF4Bg0R6NRmZ6akVQqJb+Rw+GQiclx8fv9vDwDQfBWoJ4P0pQrzcWU4ljO4Vx6KC99xeVoE2idfb39lp8fag/pbWQ/Yrkt6xtr3PNXXhaoI+Xkj7Lb056ebh0rcS496EVPGrfxin8/X5k8QjT2sccjla9MHk00rmDPOKf5yORRUcgfC4qyTXp6es7pJTR+AKWMKLtVhwfCWc3oofTIrbhmj2FqJ6/Xq2Mnk8c5jQ/YY+zbidFF7GTyiBSq1DeLhOLkIbc6yzvbO1nzBpMSxADZMnLFKJhjWIYHBnMKaSNfrKwuG8loDMwbuWIZXPIBP5cDczHlHGV6pby+pM16Bg+o/mPavAetqrp8S/R1YPc/Ev1PpalElZt/LU2ZxbSLCUUV0yp1nwF1wSMFNq2K6YcAAwCfZ3CwpLDluwAAAABJRU5ErkJggg==",maskMoveShape:"iVBORw0KGgoAAAANSUhEUgAAAIIAAACCCAYAAACKAxD9AAAACXBIWXMAAC4jAAAuIwF4pT92AAAI3klEQVR42u2dvXMTRxjGH90w6jw2Yxq78dGYivgYqOxCR0WVQZmhSgqLSiXKX4D4C3J0uEIUScUMctIkFaeeDBJUoeHU2A1MpFGnRineUywJfZx0u3f77u4zo5E/5fPtT+8+7+67u4XRaARjdFbYAeAl+MkI1VEEg1TQDoSzghc3ths/7wAopXjFVvwcAohiSEILgnrvcD9+eCkbfF11YjjaAJqojnoWhGwb3wVQjh8lha6sA6AZQ9G2IMht/AqAIwb3tRtDEXDxGmqDcFYYN/5DxlG3BaCB6qhhQVgfgAqAOoADjfxYF0AjjhI9C8JyAOpxBNAJgFn1AQSqAaEGCHpGAFZA5AvCWcGPb8YRzFUXQA3VUdM8ECj/DwCcwmrSVFbyyjKcnDKByELwjUoA2rFP0jgiUBRoME8FtY0O2YBA4/9Nw8ygCDNZyco7OBlAUAPw3kKwtrYBvMFZIeAfEc4KDesFhHUVZZlpphwQyA+EhqeFotWJu4o2DxAsBLJ9gy8DBkcwBF6cGloI5PmGML7PioJAFxfGF2vFDAbHQmBhEOMRyBNEFgLensERAIGNBBpEhrRdQ5OtMdz3dYKhEb8pcwCBBotKLG/drgd8/5ae9dBR/KbMGAQqJOE7YngSTD/roVKa4WhnAwg8AC/Z3q5bFWAvDmR7JfpcHz2Jp/klZw3UD7XBdQKpuAP8FAHFCW877AO/usCwpwsMfQDeulPY60aEOjjPIp4E0xAA9LleXQSZR2ldA4WcJ2xvz74PHC6wNYenOmURY79QF981cO8SAOBRG9hdkul+7QCvPZ1gWKuLSBoReHcJt2vLIQDo+7drxnYRqyMCZQnv2d6OLZeiQTHB4OewT1FhEOkExA9Jyt2SRATeTuo4SAbB2Dgea2Ucqf0SjDo6CQxiie0t2PcBd82iafehbsbxAEAtbUTg/fbwG9n+nrqqrYoKzpJoUGFtEO/Vga0NL3/rgH5fL+NY28wsnhUitiBsucCPn9O/zm83dTKOfQDuokpoZ4k34BsN7jfUeh0GUcFZ2KdwlVu+mlRKq70SvZ4+qiQHgcYNeGYKxR3x6d9xQK+rSwZB3i9RROAbDdIYRHOMYyWZWTwr9MCxBnHXAx5JHAB9fQf42tYFhpuzcxDOnJSRZyGq7Klkvaaqa6u6Bp7OaLLqSJb0qmYqL+4aaOTpX5YGcbbqSJb0qma6M7kewmEfDU6CbCAAdKtmKi/qGnx2/8qyqiNZ0qeaaSEI/CJCXlPGekxVH01ORDmxP/DYZQtJqo6kparaVDP5sxGBV6zbcvMf5LlXp+vQDAReVZvHGRrEZcaRfxfBOCJsUnUkS/yrmY5mQeAz5axa9RD3aibaDxvO+AMWkjGplNqvsJ+UcscRgYfj2XKBu0/VvLa7TzkbR2YgqF4txLeayR+DoH7GILLqSJaYVzM5oAMy1ZWMqiOpaS27aqYSj65BRYOooXEsjF5A3fP+ZFcdyRK/aqbr15S+vGEP+OM+PxD41St4aoMwiHRbmay0WbSysiBYWRCsLAhWFgQrC4LVYl2zt0CAdj2afbwxZ9rmImSRBqs9sqiy3DJws0zPScrmBl3gMgQ+BCqOOl4vjF6gDdlnLqgw/n4R0iOtblWAu/V08x+XLeBdXcz1iFB1VLgGQP54qCoFJWlu/K5HNQciSuj3SnRexGULeFtRottwQOcxWa2KAo/ei19HsVeizUDzrWNoWRCS6H4D8CUeT1HcBh68yXOldc+CsErHQXZrK/2XecHQtiCs6g5uZ3wqgf8yj3USEYFQHYW21ecYw7zK4x40sy53+z8iAHQSudVYJzkuqct6D4Z4swxnkgorZLMNzyodnma1TqI1mT4CdJqrFUCDRSoom0G4tgVhnvZ9dSqmD0+z8ArhNAi0517XdgsV064nnI0INioAwJ6v1vXITSVbkzu1T4LQNBqC4o56C2nkgjDV3s5EGtEE7elvpm4ouAS0uC3TJywAwfSooOqydjmAdpbvxWxBMEWN2S9Mg0Ddg80e9FdzOQjWNJqg83nHBM8DITDy9nwxZpS9Me+L34JAtJwbB4KqK5gvQpGv1l10PPCidQ3mRQWxN1yMBsLtWn3RN+aDQDUKLeNg+KrYbPyl8GjQWA+EFfRoq38aal3PZ6G+fek/txgEE6NCpFDCNOyLvJ4uqqP6ZiCYGBUGEfDplRrX8lGoTVvZjstBoKhgVgbxrq5GNPggDITOMm+QNCIAdDRc36io8PF5/jCKS2cTnTCyGgQaVwiMiwp5ZRCXLZHdwqukVerJ9kcgo2FOpfOwR2sShxkHwkEX+FPY8rc+1jjeeZ2NMipmjSm0gd/97GAY9oG/yiK7hMpkBZI4EKj+/ZmFQcbf6dDfEbdvwvmioWQREcG8LmIMw2tPnmeIzkVD0N0kem+yh1IZppW0DSKC4e9n4qLDsA+Ej0V3B9Q+a3QJY12dDb2O6Pift4l/XoUDsETtY1TcAb6r0bmPmyyLG3SBTw0aJxA/4/kzqqONUo7NQCAYagB+gcka76O06y3fROOyRfUOF6HMYexXqI42NvSbg0AwNACcwoq05U7XPn5pZ1Xn0EF1lKrKNR0IBEOI+BQQq1zUAeBv4gvSmsV55tEuq89HfREQiAGBLsK3MPCFQFREsDDkB4GwwQdxezFbGNhCIBaEaRhatr2kGUNXNARisgabWmalFjYcNcwXBILBDjqJUarBovxBIBh80DK6bdueG+lxklIz9UEgGNwYhiPbronVjbuCTNbiZQPCFRB1AE9tG6/UcwB1WX4gfxAIBg+02MJGh/lRoLZuUQlPEKajQ816h/yigBogXHmHAMBDw9PCWlZeQE0QpjOLOsyaxcytG1AXBLOA6MZdQEOli1ILhGkgapp1GS0AgSoRgAcI0x6iBqp5OGDY+H3Q+EmQtwfgDcI0FOUYiDKDTOMcQFO18K8HCPOh8BWJFON3fhgD0ON2S3mC8G334ccPD9kMVHXjRm8DCFUP+2aAsNhsujOPnTUh6YIOvurFDR4BiHQ9A+s/810wc9nms20AAAAASUVORK5CYII=",maskMoveImage:"iVBORw0KGgoAAAANSUhEUgAAAIIAAACCCAYAAACKAxD9AAAACXBIWXMAAC4jAAAuIwF4pT92AAAI1ElEQVR42u2dP2gbZxjGn5yDiiHOGbtBaYodBYqHJsFXsqWDRQaDoRB1SuliebmxUSFjQhU6ZpGzVUvkzR5CZDqYdsllqLM09EySIaIQOa6THMEiig0GgXEHfUpk+2Tdne9035/3AREIPumk93fP977f32O7u7tQSUU7aQAY7PZ3puFYKv0ux2QDoWgnBwEY7JVi/w4CGA/4lnUANoAqe9kAbNNwqgQCX4FPAciwgKcBnO3RR7cAsQBYojuIkCAU7WSGBT3Tw8B7AcMCUAZQNg3nPYEQTfDTALIs+LoAt7woEhRcg8Da+yyAHEdPfhCnKAMomIZjEwj+2/28QE+/Vz0CkOcxn+AKhDYApiWv1lYYEGUCQU0AuHWIWEFgOUCOvXSoq0UAuTj7JmIDgVUBJYGTwCiSyoJpOHklQGAuUFCwGfCTP2R7XWFoMbiATRAcqnEA/xTtZF5KR2Bf7BeKs+9kMtOLDqnIQWBNQRnABMU1cO6Qibqy0CKGwGBNAUEQXDqAh0U7mRUSBDYwZFFVEJruFe1kSSgQGL0PFO8biELTUcEQeo7AILhHMYu8xEyHmURqBIGwJabFEnG+QCAIxIZBIwiEh6HMBQgEQeyaCCOBPFKyyPoJrCiqgzMnLgMAvjjxbey/dGOnjqfvirwDcfsoA1aBQWBtUzVMCBJ9Oi5/+StS+hQSfSe5+pUrtQVYr37iHYYZ03ACucNRmoZQnSClT+HHr//G2NA17iAAgLGha0iP3uUdhAJz6d6AULSTBQRfMOIKweS5EpcACAaDDqAcpJLQAkCQAXA9zOZAgCdNJBjOojnhJzoQGGmlMO/64imTeycQEIar7IGNzBHKYVcIF0+ZQtZsAsBQYpOCwwWBERbqcPJw/wUu3WBj+7kMMOhoTgkMD4QomgQA+IzTJqFaX4L16roMMHhuIrw6Qh6KDSlXavOywFDwUkVoHtzACLNKIBhiqSJyYThCAQpLEhhy3RJHrYsbpEHzDWWAQWfNe2BHyIMkCwzTh7mCRm6gFAz5II5AbiAfDNOdKgitgxukyA2khSHnxxHIDeSFwRsIzDoyFGppYdDdVk25OYJs+xYRDO4x7gpCjsIrPQxX95eSmkuSOE6hVQKGzGGOQLmBOjBkCQSCAQDG25sHbV+1QH0HasGQdnOENIUwPhhimrKXcQOBmoUYYUj06dw4gkGhixeGGKS3FsRobfkBlY1qwmAAwHFyg4MaSIx8XIQblrYar1CpLWBs6BpvXzcNoHRcxESxUltAtb6Eje1n2GysYSAxguH+C0jpU6H80GND13gMWFRKtTtCSoQ73th+jj9fTmOzsbbn/zcba9hsrKFaX8KTt3cweW4Ow/3nydq8aaI9WUyJ4AL3X1w5AMF+bTbWcP/FFVRqCxRijyrayZTWTgXPTrC8fsvXNcvrtzyvWCIhpYlwl4/Xb6KxU/d1TWOnjsfrNynEHisHjU1S5doNXm8tB7r29dYyuYI3DXLvCNX6UqzXq9Q0pPh2hGexXk8gcCK/uUHY16si7puG4f4LsV5PIBAIBAJXjZc+FXiINtGnI6VPUZRlACHRdzLwpA0RN+qi8vEQXTp9w/do4JkTl3Hp9A0u7p/jIeiW3muiIDt5bs6zzTc38JzjBoJKbZ6ahjCbiMlzJaRH72IgMeL6NwOJEaRH73Kzi6soEACfhqGFUWuuwMb28wPzEXgaehYJghYINgTUcP95bucciAZBq2l4D5LSEACwNQqd8hA0q4aoj5olCIRQteUIyo7MNE9mua4yBABQbVUNSp7fvP94nvTorIoQ7HGEquoQBFmEIgkEMA3nIwi2yhAEgUEWCAA8apWPSoHQ7bQ2LzBIBMHH2GvMGiyCwBsMkkGwFwSmFYLgcBgkhABoHtu4BwSLIOgMg6QQrJqGUwX2DjpZkPCAjqOe4FqpzePN1l9dl9qJ7AZ7HME0nDJB4C5JIXAHgWmRIFBK5U4glAkCZbRoGs57aUEgCPy7wQEQGCGLBIHiIIjsCgSBL821NwuuIJiGU4Jgw9IEwdHcoJMjABEc/0sQcKNVt66CTiAUCAJp5RpbVxBYt+McQSCd6p3cXsjj/giC4G6wP0nsCgJzhUcEgVRu0LHJ7zadPUsQyO8GXUHgKVcgCKJzAy+O0MoV6gSB0Mof5gaAh0WwpuFUi3ayAOCXOL7BxvZzVGrzoe+WrpBWTMPp2h3gaTW0aTh5dnro2V5/i+H+8/juqwcUzuDydI6nn7WPoSeOEk/44EWzXicmewaBveFs2CBsNf6jcCGSHWJX4aMvyO9q6Dz7gND0Qr4Job71Zms5ih1is90SxMAgsDcO9TS4p++KyrvCk7d3YmsSgjoCTMOxAfwc1h03dur44+U0GjsflITAenU98O7zh1QJvg96D7RRBitHQpvJtLH9DL//+71SW+o3dj5EsVaijoDncx3b3d0N9InsiEALIR8TODb0Ay6eMqU9k6mx8wGV2gKevvstiqrpG+bYvQOBwZBCc+1c6MeYJvp0fC4ZDK1DyCLSDJtdhp6DwGAwmDPoIMWl26bh5I/yBkcGgcGQBvCQ4hGL5kzDyR71TULZVY2VKjMUEzEhCA0EBkOJYBATglBBIBjEhSC0HIESyJ5qNkiHUU8doc0ZbNaxsUpxC71EzEXxxpE4QpszRNLppKDqADJR7nUVKQhtQJQATFM8A2mFQVCN8kN6sik3S2xmoPBWv0GTQgDpqCHomSO0OUMKzZU2ExTjrk1BtpfbGfUUhDYg8mjOpaOq4qAW4XNSibAgkDu4ahVALq5NzWIDoQ2IDJqLL84qDMFtdFmJJD0IijcXc2guPqnGfSPcgNDW75BTAAhuAOAShH1AZNCcNS1Lk1FHc8sargDgGgSXHCIL4KqgAKywpLgUZw4gPAj7XCLLXrx3Wa+yp78UdA4hgeC99MygObB1laMn3xIp+MKD4AJGmkFhsH97kWg+QnPirgXA4tn2lQGhQzNisNcgPs31N3xC0to6yEbzxFwbQFXEJ76b/geXEooCwBQ2IQAAAABJRU5ErkJggg==",warningOutlined:"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TRZEWBzuIdMhQnSyIFXWUKhbBQmkrtOpgcukXNGlIUlwcBdeCgx+LVQcXZ10dXAVB8APE0clJ0UVK/F9SaBHjwXE/3t173L0DhGaVqWbPBKBqlpFOxMVcflXse4UfYQQRw4zETD2ZWczCc3zdw8fXuyjP8j735wgqBZMBPpF4jumGRbxBPL1p6Zz3iUOsLCnE58TjBl2Q+JHrsstvnEsOCzwzZGTT88QhYrHUxXIXs7KhEk8RRxRVo3wh57LCeYuzWq2z9j35CwMFbSXDdZphJLCEJFIQIaOOCqqwEKVVI8VEmvbjHv4Rx58il0yuChg5FlCDCsnxg//B727NYmzSTQrEgd4X2/4YBfp2gVbDtr+Pbbt1AvifgSut4681gdlP0hsdLXIEDG4DF9cdTd4DLneA4SddMiRH8tMUikXg/Yy+KQ8M3QIDa25v7X2cPgBZ6mr5Bjg4BMZKlL3u8e7+7t7+PdPu7wcF5XLiwo0hmwAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAN1wAADdcBQiibeAAAAAd0SU1FB+YDHA8LOJEM5qAAAAOHSURBVHja7ZlLbAxxHMd/07KltNQjJUJESUMiUUIiJBJF4oJLJUjowTM4cFAHktZFBQdOHFSCAw4IlTg4iIhEEa9IvBpB69mgWBTtx2XEGr/ZndnXzM7ON9nDzv/3+n73v7//Y0RChAgRIkSIvIXhVWKgWERqzK8nDcP4llfKA+f5i+Z8I7+I/7EwX8hHgEeKAK1AUT4IsBV71AWdfDnQGUeAT8DwIAtwmMRoCir5yUC3AwG6gWlBI28AlxWy54Bm5flVwAiSAMsUkl1AJTAW+K6MLw0K+b7AM4Xg7hibPcp4G9AvCALsUMi9AQbE2JQArxS7hlwnPxKIKsRWKrarFLuvwOhcFuCkQuoWUKjYFgDXFfsTuUp+BtCjEJqVTh+/ki8AbihEjjvwPeF01vhZgDXJ/p/j9I3VuUK+1Kaj17uI0aD4vwUG5oIAe5XiX1jXdGAdUGd+1lrG+pk+Vuz1O3m7Xd0SxfYfKONLlTg/gMpcueaKu693IIDd+aHZr+Tn2pzsptrYxxXAtKmyOUHO9xv53sADpdBDcXwSCmDaNSlxHwMRPwmw2e3tjgsByoGPSvxNfiE/FPigFLglgZ8jAUzbOiV+JzDMDwIcVIp7kuiG16UAEeChkueA1+QnAb+UwhY48HUsgGm/0KbJTvFSgEtKURcd+roSwPS5oOS74sn1GbBYKeYnMDGDAow3N0NW1GSbfB/gqVLIPhcxXAtg+u1X8j43X7ZmTYBtShEdwCAXMTpifV34DbL4/sG2bJEfAXxRClifxR9gg5I/CozKRvJjSvL7QK8sClAI3FXqOJrpxNNtrqzmedCEZyt19AAzM3nNdU1JesrDZfi0Us9NoCATyWqVZN+BiiRiRYBdwEugHWhM5nADVNjcP9Smm3yJWawVjUnGa8xwrJdASToF0JK8BkqTjKeJ+SrJWP3NWWTFznSRH2MzzVakEFMruC3Nf88uYFymGk1LKo3GZkbtTLFBtygxT6dKvtpmqZmeYtyIKUJ7Kk3Q4RJdnVubDb9s0jzdbnq9TQfKgHeeHThSE2G7Uvd7YLBmbzc1dojIEMuzqIjcAeb4XIPbZq2xb6LKRKReRDZajbUXFhPMIL0lWOgWkSrDMO7FPtSWst0BJC8iUigijU5mQFREiiWY+GwYRmmiGXBGgouzTmZAkYgsF5GKgJFvFZEjhmF0SYgQIUKECBFCROQ3nMO7R8eI5nkAAAAASUVORK5CYII="}),this.side=null,this.design=null,this.editTextCallback=null,this.itemRemovedListeners=[],this.designItemRemovingListeners=[],this.itemChangedListeners=[],this.itemCreatedListeners=[],this.designItemChangedListeners=[],this.selectionChangedListeners=[],this.deselectionChangedListeners=[],this.imageLoadedListeners=[],this.textArtLoadedListeners=[],this.notifyMessageListeners=[],this.removeMessageListeners=[],this.gridImageSelectedListeners=[],this.shapeLoadedListeners=[],this.fillShapeRequestedListeners=[],this.undoChangedListeners=[],this.redoChangedListeners=[],this.bindedUndoStackChanged=this.onUndoStackChanged.bind(this),this.bindedRedoStackChanged=this.onRedoStackChanged.bind(this),this.areaAlertItems=[],this.areasSizeCountCollection=[],this.areasSizeLimit=52428800,this.panOrigin=null,this.preventViewMoving=!0,this.preventAreasAndIndexUpdate=!1,this.usedColorsItemsToCheck=null,this.touchEnabled=!1,this.isSafari=/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent),this.customizedMessages=[],this.fontAscentCache={},this.originalBgImage=null,this.currentDesignOperation=null,this.undoStack=new Zakeke.Customizer.Stack,this.redoStack=new Zakeke.Customizer.Stack,this.setupUndoRedoStacks(),this.executingUndoRedo=!1,this.showDashedEdge=!1,this.DashedEdgeColor="black",this.showSelectedElementDimensions=!1,this.showUnselectedElementsDimensions=!1,this.showTotalSizeOfCurrentSide=!1,this.unitOfMeasurement="cm",this.RGB_HEX=/^#?(?:([\da-f]{3})[\da-f]?|([\da-f]{6})(?:[\da-f]{2})?)$/i,this.supportedBlendModes=["normal","multiply","screen","overlay","soft-light","hard-light","color-dodge","color-burn","darken","lighten","difference","exclusion","hue","saturation","luminosity","color","add","average","negation","lighter","darker","copy","xor"],window.imageEffectCache={},this.maskedImageSelectionMode=MaskedImageSelectionMode.Element,this.shapeImagePlaceholderIconPathd="M 15.2,12 A 3.2,3.2 0 0 1 12,15.2 3.2,3.2 0 0 1 8.8,12 3.2,3.2 0 0 1 12,8.8 3.2,3.2 0 0 1 15.2,12 ZM9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z",this.shapeImagePlaceholderIconFillerSize=8,this.selectedDesignItem=null,this.selectedPaperRootItem=null,this.areaLayersPaperLayer=null,this.areaLayerIcon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M 16 5.9375 L 15.625 6.0625 L 5.625 10.0625 L 3.3125 11 L 5.625 11.9375 L 9.53125 13.5 L 5.625 15.0625 L 3.3125 16 L 5.625 16.9375 L 9.53125 18.5 L 5.625 20.0625 L 3.3125 21 L 5.625 21.9375 L 15.625 25.9375 L 16 26.0625 L 16.375 25.9375 L 26.375 21.9375 L 28.6875 21 L 26.375 20.0625 L 22.46875 18.5 L 26.375 16.9375 L 28.6875 16 L 26.375 15.0625 L 22.46875 13.5 L 26.375 11.9375 L 28.6875 11 L 26.375 10.0625 L 16.375 6.0625 Z M 16 8.09375 L 23.28125 11 L 16 13.90625 L 8.71875 11 Z M 12.25 14.59375 L 15.625 15.9375 L 16 16.0625 L 16.375 15.9375 L 19.75 14.59375 L 23.28125 16 L 16 18.90625 L 8.71875 16 Z M 12.25 19.59375 L 15.625 20.9375 L 16 21.0625 L 16.375 20.9375 L 19.75 19.59375 L 23.28125 21 L 16 23.90625 L 8.71875 21 Z"/></svg>',this.areaLayerArrowIcon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M 4.21875 10.78125 L 2.78125 12.21875 L 15.28125 24.71875 L 16 25.40625 L 16.71875 24.71875 L 29.21875 12.21875 L 27.78125 10.78125 L 16 22.5625 Z"/></svg>',this.initialItemsInfo={},this.eventsToolsCustomizer=new Zakeke.Customizer.EventsToolsCustomizer(this),this.isSetSideEnded=!1,this},MPlaza.Customizer.prototype={debounce:function(e,t,i){var n;return function(){var a=this,r=arguments,o=i&&!n;clearTimeout(n),n=setTimeout(function(){n=null,i||e.apply(a,r)},t),o&&e.apply(a,r)}},throttle:function(e,t){var i;return function(){var n=arguments;i||(e.apply(this,n),i=!0,setTimeout(function(){return i=!1},t))}},createCanvas:function(){return this.canvas=document.createElement("canvas"),this.canvas.setAttribute("id",this.canvasID),this.context=this.canvas.getContext("2d"),this.setupCanvas(),this.isViewer||(this.setupTouchEvents(),this.setupTool(),this.showSelectionBounds()),this.updateCanvasImageQuality(),this.canvas},updateCanvasImageQuality:function(){this.context.imageSmoothingQuality="high",this.context.imageSmoothingEnabled=!0},setupCanvas:function(){this.isViewer||$(this.canvas).mousewheel(function(e){});this.paper.setup(this.canvas),this.paper.Layer.inject({_selectChildren:!1}),this.paper.view.draw();var e=this;this.paper.view.onFrame=function(t){e.loadingCircles.forEach(function(e){e.rotate(3)})}},clearMemoryForIOS:function(){this.canvas.width=1,this.canvas.height=1},appendViewMatrix:function(e){var t=new this.paper.Matrix(e);this.paper.view.matrix.append(t)},translateView:function(e,t){var i=new this.paper.Matrix;i=i.translate(e,t),this.paper.view.matrix.append(i)},rotateView:function(e,t,i){var n=new this.paper.Matrix;n=null!=t&&null!=i?n.rotate(e,t,i):n.rotate(e),this.paper.view.matrix.append(n)},scaleView:function(e,t,i,n){var a=new this.paper.Matrix;a=null!=i&&null!=n?a.scale(e,t,i,n):a.scale(e,t),this.paper.view.matrix.append(a)},getIdentityMatrixValues:function(){return(new this.paper.Matrix).values},getTranslatedMatrixValues:function(e,t,i){var n=new this.paper.Matrix(e);return(n=n.translate(t,i)).values},getRotatedMatrixValues:function(e,t,i,n){var a=new this.paper.Matrix(e);return(a=null!=i&&null!=n?a.rotate(t,i,n):a.rotate(t)).values},getScaledMatrixValues:function(e,t,i,n,a){var r=new this.paper.Matrix(e);return(r=null!=n&&null!=a?r.scale(t,i,n,a):r.scale(t,i)).values},setupTouchEvents:function(){var e=this,t=new Hammer.Manager(this.canvas);t.add(new Hammer.Pan({threshold:5,pointers:0})),t.add(new Hammer.Tap({event:"doubletap",taps:2,threshold:100,posThreshold:1e3})),t.add(new Hammer.Pinch),t.on("panstart panmove panend pan",function(t){e.onPan(t)}),t.on("doubletap",function(t){e.onDoubleTap(t)}),t.on("pinchstart pinch",function(t){e.onPinch(t)})},setupTool:function(){this.tool=new this.paper.Tool;var e=this;this.tool.on({mousedown:function(t){e.onMouseDown(t)},mousemove:function(t){e.onMouseMove(t)},mouseup:function(t){e.onMouseUp(t)},keydown:function(t){e.onKeyDown(t)},keyup:function(t){e.onKeyUp(t)}}),this.tool.minDistance=1,this.tool.activate()},createDOMElement:function(){this.domElement=document.createElement("div"),this.domElement.setAttribute("id","mp-canvas-customizer-div_"+MPlaza.makeID(5)),this.domElement.appendChild(this.canvas),this.domElement.style.position="relative"},appendTo:function(e){e.appendChild(this.domElement),this.resize(e.offsetWidth,e.offsetHeight),this.resize(e.offsetWidth,e.offsetHeight),this.moveOriginToViewCenter(),this.isViewer||this.setupZoomControl();var t=this;$(window).resize(function(){t.resize(e.offsetWidth,e.offsetHeight),setTimeout(t.resize(e.offsetWidth,e.offsetHeight),200)}),$(window).on("orientationchange",function(){setTimeout(function(){e.offsetHeight,t.paper.view.center=new paper.Point(0,0),t.paper.view.update(!1),t.fitToScreen(!1,!0)},200)})},resize:function(e,t){e||(e=this.domElement.offsetWidth),t||(t=this.domElement.offsetHeight),this.isMobile||this.fitToScreen(!1,!0),this.paper.view.viewSize=[e,t],this.paper.view.zoom=this.paper.view.zoom,this.checkAllAlertItems()},moveOriginToViewCenter:function(){this.paper.view.center=new this.paper.Point(0,0)},setupZoomControl:function(){"mp-canvas-zoomControl"!=$("body").find("#mp-canvas-zoomControl").attr("id")&&$('<div id="mp-canvas-zoomControl" class="olControlZoom" unselectable="on"> <a class="olControlZoomOut olButton" id="mp-canvas-zoomout" href="#zoomOut"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAMAAADW3miqAAABklBMVEVkZGT///9kZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGSZMFejAAAAhXRSTlMAAAECBAUGBwgKCwwNDg8QERITFRYXGRocICEiIyQlJykqLC0uMDM1Njc5Oj0+QEFCRUhKTE1OT1BRUlNUVVZYWltdX2BiY2RnaWprbG9wcnN0dXd5ent8f4CCg4WGh4uMjo+RkpOUlZaXmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKzHueo5wAAAfZJREFUeAGF0PtTElEYxvGXTQVrUYmyC5WlGZpd0sKETLBE7VKkoFnSpSgrKlRAAkFY2Kf/u3fB4ZxDzfb9bWc+8+w7hw5z+oKJrdzej2TUr2sk5eCoWffF1SoOa3yecv8L9UVqkKonh/5G3jiszOJOJt/S2audaCABrv7+4bXhS/6ZtRy4wpiKXA+slZ93vdSsy/8SXPq0jI6MGmxSI9ROX7KG12Skr7P5NuKQ6n0KoOSX0DCAyh3+ENGJFE8lJDQPNDZ1FXVPAfg6KNAmD82RisiTAfLXBdoBtq8QkdY2GtHROHAQEagK89NZot7fIiLXAlB7LJAJ8yO/iVtBznnAeCZQBebWOaIedWmJlx4JlAayE52HH3sFlO8LtA5UFzrRqQKwOy7QNGCmBlVknYSULpDvwJpSkHZhFzCekECuZQD5SZLyvgGQ80lIO58FkA20iXYmCR5fJAlR1yS4cvxyi3jC3wE0NkhB5IqAMwtvo4Hb4XimBgu9uzkmI1ZzBqzqRq1ugjM+pE1jL6Qg6hr/YkL0a1EPAyjekxGnh1Kl1n/K27Eh6pkGtz+rIM45Ovt843UieuMkcX0r4CohTUUd6astJZCNCtoicq+0lC2i/hdNNWOLyNPc2g92k13Hm6oUJXsVs1CA7BuIoTjRQ/+pf/mWw/EHz+jJTaZSlbAAAAAASUVORK5CYII="> </a> <a class="olControlZoomIn olButton" id="mp-canvas-zoomin" href="#zoomIn"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAMAAADW3miqAAABklBMVEVkZGT///9kZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGSZMFejAAAAhXRSTlMAAAECBAUGBwgKCwwNDg8QERITFRYXGRocICEiIyQlJykqLC0uMDM1Njc5Oj0+QEFCRUhKTE1OT1BRUlNUVVZYWltdX2BiY2RnaWprbG9wcnN0dXd5ent8f4CCg4WGh4uMjo+RkpOUlZaXmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKzHueo5wAAAftJREFUeAGF0PtXEk0cx/Ev+3DBp0Ulyi5UlmZodkkLEzLBErVLkYJmSZeirKhQAQkEYWE//N/N7nqYGeps799mz+t8ds7QUZ5gJL1d3P+RSYRUhYQcLDJzXVxr4Kj252nf31B/vAmhVmb4TxRIwUiv7OZLli5c7UWDabBa7x9eG7kUml0vglUel5H3gbHy826AzJyhl2DlTovovzGNmewodVOXjeF1EakbzHwbdQj1PQVQDQloBED9jnXodDrmtxNZNpUW0ALQ3lJl5JoG8HWIoy02NE8yIn8eKF3naBfYucIOShcpRP+ngMM4Rw3on84S9XV4RN5FoPmYIx36R/YmPgl5FgDtGUd16NvniNzy0jJbesRRDihM9l782Cugdp+jDaCx2ItOlYG9CY5mAD07JCPjSsiqHAUPjSkJKRf2AO0JceRdAVCaIqHAGwDFoICU8wUAhXCXKGcyYONLJCByToFVS122iD/2HUB7kyRE3jhYevltInw7lso3YaB3N8dFxNS8BqOW1mzpYGkfcrq2H5UQOSe+6OD9WlJjACr3RMRSo9mq9Z/aTnKY3DNgHcxJiOUZm3u++TqduHGSWP2rYNWjiox6UtcsZYO4itgi8q1ayhbRwAtTzdoi8ptbBxEX2XXcVNUE2aukgcJk32ASlUk3/aOBlVsOx29IL9WtgmuD+QAAAABJRU5ErkJggg=="> </a> <a class="olControl3D olButton" id="mp-canvas-show3d" href="#show3d"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAQAAABLCVATAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAJ1SURBVHjapNZBiFZVFADg848zDTnhWItQx9oIYWiU2bgIyUVERdAiazMYldlOg0hIBwLpgzBHsGGIqGB0FxS5ys3gIBIUFAONLWoWQzWLSENplTqO/2nha3xv/t9G3s/ZXO6774N3zj333RDLxkEL5nznhD0eXfo0i4jbgLqMysU45fW6UAgjJSpN2VkXCkcK5E/zUhpzRz0oHJZmbLDNhJTOGqgHhbeKZDcMS+lHa+tB5RiyIJ22olMovKQpjXUOhf1SerZzKExK03o6h7a6Ig3dGlqp313FuGGVfv2lmXJ8JZ3WaId0O+CSlD62Rljtd39L6brPbV+y+mmpaWMr0/CZNOMDZ6VpK/VakCYc942UXq6s7/Wr9FordL/0mwEhTEnPCPOa1gsNL7gmbS43rePSJ63QKk/aVIy/lIaEq5o2FHPvSx9WoHeluf87PHa45II1elzVtLGYf/xGwUvQZofsvRVz0kXpL4PC3RXoYenCzfot12vHnDMrjVihrwI9Ip1vB73pkAfbYg0/SM8XOfoPekKavnEWVaE/pHdKr9/nFduK8T7pvSXJPiaNtTtqx6VPS9Bj0i/uEcIp6dWi/ANCj11Seqgd9IY0e7MKup2UfnbUGWnG6sUNecL3stgQbaBNUnqqsleHXZTmjbq30iL/GF/87BaoyxnpiyWJvlO/vpam7WstSbn8u6TLrb++24sy1OMnabJzKDwnpbc7h8JHUtOLnUPdJqVr1dLWgcI656Q0rCGEQfvrQWF9cQJOGPSAWelwPSj0GpPSFeeLK8ORelAIO01VrjAjdaEQdvu6RI3qqguFsMVu4741Z8GB5aF/BwBgaLXGzqeljgAAAABJRU5ErkJggg=="> </a> </div>').appendTo("#zoomPanel");this.setZoomControlPosition()},setZoomPercentageIncrement:function(e){console.log("Set zoom increment percentage to "+e),this.zoomPercentageIncrement=e},setZoomControlPosition:function(){var e=$("#"+this.canvasID).offset(),t=e.left,i=e.top,n=$("#"+this.canvasID).width(),a=$("#"+this.canvasID).height();$("#mp-canvas-zoomControl").width(),$("#mp-canvas-zoomControl").height()},setupMoveControl:function(){"mp-canvas-moveControl"!=$("body").find("#mp-canvas-moveControl").attr("id")&&$('<div id="mp-canvas-moveControl" class="olControlMove" style="position: absolute; z-index: 1003;" unselectable="on"> <div id="mp-canvas-moveVerticalControl" class="olControlMoveVertical"> <a class="olControlMoveUp olButton" id="mp-canvas-moveup" href="#moveUp">˄</a> <a class="olControlMoveDown olButton" id="mp-canvas-movedown" href="#moveDown">˅</a> </div> <div id="mp-canvas-moveHorizontalControl" class="olControlMoveHorizontal"> <a class="olControlMoveLeft olButton" id="mp-canvas-moveleft" href="#moveLeft">˂</a> <a class="olControlMoveRight olButton" id="mp-canvas-moveright" href="#moveRight">˃</a> </div></div>').appendTo("body");var e=this;$("#mp-canvas-moveup").click(function(t){e.moveSelectionUp()}),$("#mp-canvas-movedown").click(function(t){e.moveSelectionDown()}),$("#mp-canvas-moveleft").click(function(t){e.moveSelectionLeft()}),$("#mp-canvas-moveright").click(function(t){e.moveSelectionRight()}),this.setMoveControlPosition()},setMoveControlPosition:function(){var e=$("#"+this.canvasID).offset(),t=e.left,i=e.top,n=($("#"+this.canvasID).width(),$("#"+this.canvasID).height()),a=($("#mp-canvas-moveControl").width(),t+10),r=i+n-$("#mp-canvas-moveControl").height()-100;$("#mp-canvas-moveControl").css({top:r,left:a,position:"absolute"})},setCustomizedMessages:function(e){var t=this;e.forEach(function(e){t.customizedMessages.push(e)})},setShowDashedEdge:function(e){this.showDashedEdge=e},setShowSelectedElementDimensions:function(e){this.showSelectedElementDimensions=e},setShowUnselectedElementsDimensions:function(e){this.showUnselectedElementsDimensions=e},setShowTotalSizeOfCurrentSide:function(e){this.showTotalSizeOfCurrentSide=e},setUnitOfMeasurement:function(e){this.unitOfMeasurement=e},setDashedEdgeColor:function(e){this.DashedEdgeColor=e},fireSelectionChangedEvent:function(e){for(var t=0;t<this.selectionChangedListeners.length;++t)this.selectionChangedListeners[t](e);var i=this.design.getSideDesignItems(this.side);if(i)for(t=0;t<i.length;t++){var n=this.findItemForDesignItem(i[t]);if(n&&n.data.selected){this.showAreaItems();break}}},fireDeselectionChangedEvent:function(e){for(var t=0;t<this.deselectionChangedListeners.length;++t)this.deselectionChangedListeners[t](e)},fireItemRemovedEvent:function(e){for(var t=0;t<this.itemRemovedListeners.length;++t)this.itemRemovedListeners[t](e)},fireDesignItemRemovingEvent:function(e,t){for(var i=0;i<this.designItemRemovingListeners.length;++i)this.designItemRemovingListeners[i](e,t)},fireItemChangedEvent:function(e){for(var t=0;t<this.itemChangedListeners.length;t++)this.itemChangedListeners[t](e)},fireDesignItemChangedEvent:function(e){for(var t=0;t<this.designItemChangedListeners.length;t++)this.designItemChangedListeners[t](e)},fireItemCreatedEvent:function(e){for(var t=0;t<this.itemCreatedListeners.length;t++)this.itemCreatedListeners[t](e)},fireImageLoadedEvent:function(e){for(var t=0;t<this.imageLoadedListeners.length;t++)this.imageLoadedListeners[t](e)},fireTextArtLoadedEvent:function(e){for(var t=0;t<this.textArtLoadedListeners.length;t++)this.textArtLoadedListeners[t](e)},fireShapeLoadedEvent:function(e){for(var t=0;t<this.shapeLoadedListeners.length;t++)this.shapeLoadedListeners[t](e)},fireGridImageSelectedEvent:function(e){for(var t=0;t<this.gridImageSelectedListeners.length;t++)this.gridImageSelectedListeners[t](e)},fireNotifyMessageEvent:function(e,t,i,n,a,r,o,s,l){for(var h=0;h<this.notifyMessageListeners.length;h++)this.notifyMessageListeners[h](e,t,i,n,a,r,o,s,l)},fireRemoveMessageEvent:function(e){for(var t=0;t<this.removeMessageListeners.length;t++)this.removeMessageListeners[t](e)},fireUndoChangedEvent:function(){for(var e=0;e<this.undoChangedListeners.length;e++)this.undoChangedListeners[e]()},fireRedoChangedEvent:function(){for(var e=0;e<this.redoChangedListeners.length;e++)this.redoChangedListeners[e]()},fireFillShapeRequestedEvent:function(e){for(var t=0;t<this.fillShapeRequestedListeners.length;t++)this.fillShapeRequestedListeners[t](e)},addSelectionChangedListener:function(e){this.selectionChangedListeners.push(e)},addDeselectionListener:function(e){this.deselectionChangedListeners.push(e)},addItemRemovedListener:function(e){this.itemRemovedListeners.push(e)},addDesignItemRemovingListener:function(e){this.designItemRemovingListeners.push(e)},addItemChangedListener:function(e){this.itemChangedListeners.push(e)},addItemCreatedListener:function(e){this.itemCreatedListeners.push(e)},addImageLoadedListener:function(e){this.imageLoadedListeners.push(e)},addTextArtLoadedListener:function(e){this.textArtLoadedListeners.push(e)},addShapeLoadedListener:function(e){this.shapeLoadedListeners.push(e)},addGridImageSelectedListener:function(e){this.gridImageSelectedListeners.push(e)},addNotifyMessageListeners:function(e){this.notifyMessageListeners.push(e)},addRemoveMessageListeners:function(e){this.removeMessageListeners.push(e)},addDesignItemChangedListener:function(e){this.designItemChangedListeners.push(e)},addUndoChangedListener:function(e){this.undoChangedListeners.push(e)},addRedoChangedListener:function(e){this.redoChangedListeners.push(e)},addFillShapeRequestedListener:function(e){this.fillShapeRequestedListeners.push(e)},getScreenPoint:function(e){var t=this.paper.view.projectToView(e),i=$("#"+this.canvasID).offset();return t.x+=i.left,t.y+=i.top,t},onMouseWheel:function(e){var t=this.getAllItemsBounds(),i=this.paper.project.view.bounds;if(!this.zooming&&null!=t){e.preventDefault();var n=new this.paper.Point(e.offsetX,e.offsetY),a=(n=this.paper.project.view.viewToProject(n)).subtract(this.paper.view.center);if(e.deltaY>0)this.paper.view.zoom<4&&(this.paper.view.zoom*=1.3,this.paper.view.center=this.paper.view.center.add(a.multiply((1.3-1)/1.3)));else if(e.deltaY<0){if(t.width<i.width&&t.height<i.height)return;this.paper.view.zoom/=1.3,this.paper.view.center=this.paper.view.center.subtract(a.multiply(1.3-1))}this.hitItem=null,this.updateSelectionState(),this.paper.project.view.update(),this.checkAllAlertItems(),this.checkImagesSizeLimit()}},windowToCanvas:function(e,t){var i=this.canvas.getBoundingClientRect();return{x:e-i.left*($(this.canvas).width()/i.width),y:t-i.top*($(this.canvas).height()/i.height)}},clearCanvas:function(){for(var e=0;e<this.paper.project.layers.length;e++){this.paper.project.layers[e].removeChildren()}this.paper.project.view.update()},getAllAreasBounds:function(){var e=this,t=null;return this.side&&this.side.get("areas").forEach(function(i){var n=e.findItemForArea(i);n&&(t=t?t.unite(n.bounds):n.bounds.clone())}),t},getAllItemsBounds:function(e){void 0===e&&(e=[]);for(var t=null,i=e.length>0?e:this.getAllItems(),n=0;n<i.length;n++)if(!i[n].data.isAreaLayer){var a=this.getItemBounds(i[n]);!a||isNaN(a.width)||isNaN(a.height)||(t=null==t?a.clone():t.unite(a))}return t},getAllItems:function(e,t){void 0===e&&(e=this.paper.project),void 0===t&&(t=this.masterGroup);var i=[],n=this;function a(e){if((!n.isItemGroup(e)||e==t||e.data.isGridGroup||e.data.isGridBox)&&e.children)for(var r=e.children.length-1;r>=0;r--){var o=e.children[r];o.guide||i.push(o),a(o)}}for(var r=0,o=e.layers.length;r<o;r++){var s=e.layers[r];s.guide||a(s)}return i},getAllShapeItems:function(){for(var e=[],t=this.getAllItems(),i=0;i<t.length;i++){var n=t[i];(this.isFilledShape(n)||this.isShape(n))&&e.push(n)}return e},getAllShapeImagePlaceholders:function(){for(var e=[],t=this.getAllShapeItems(),i=0;i<t.length;i++){var n=t[i];!this.isFilledShape(n)&&this.isShape(n)&&n.data&&n.data.isImagePlaceholder&&e.push(n)}return e},getAllMaskedImages:function(){var e=this;return this.getAllItems().filter(function(t){return e.isMaskedImage(t)})},getAllFilledShapes:function(){var e=this;return this.getAllItems().filter(function(t){return e.isFilledShape(t)})},getAllSimpleImages:function(){var e=this;return this.getAllItems().filter(function(t){return t instanceof e.paper.Raster&&!e.isMaskedImage(t)&&!e.isFilledShape(t)})},getAllShapesAndMasks:function(){for(var e=[],t=this.getAllItems(),i=0;i<t.length;i++){var n=t[i];this.isShape(n)?e.push(n):this.isMaskedImage(n)&&e.push(this.getMaskedImageShapeItem(n))}return e},zoomIn:function(){var e=this;if(!(this.paper.view.zoom>=2)){this.preventViewMoving=!1;this.paper.view.zoom*=1.3,this.updateZoomIndicators(),this.updateSelectionState(),this.clampView(),this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.placeHandleOut(),this.getAllShapeImagePlaceholders().forEach(function(t){return e.updateShapeImagePlaceholder(t)}),this.updateAreaLayerNamesSizes(),this.restoreResizable()}},zoomOut:function(){var e=this,t=this.getAllItemsBounds(),i=this.paper.project.view.bounds;if(!(t&&t.width<i.width-100&&t.height<i.height-100)){this.preventViewMoving=!1;this.paper.view.zoom/=1.3,this.updateZoomIndicators(),this.updateSelectionState(),this.clampView(),this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.getAllShapeImagePlaceholders().forEach(function(t){return e.updateShapeImagePlaceholder(t)}),this.updateAreaLayerNamesSizes(),this.restoreResizable()}},setZoom:function(e){this.animatedZoom(this.paper.view.zoom,e/100,this.paper.view.center,this.paper.view.center,30),this.clampView(),this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.updateAreaLayerNamesSizes(),this.restoreResizable()},zoomToBounds:function(e,t,i,n,a){var r,o=this;if(e&&0!=e.width&&0!=e.height){var s=!0;!1===i&&(s=!1);var l=e.clone(),h=1;t>0&&(h=1+t/100),l.width*=h,l.height*=h;var d=this.paper.view.bounds;if(l.width>d.width||l.height>d.height||n){var c=1,u=1;Math.abs(d.width)>1e-7&&(c=d.width/l.width),Math.abs(d.height)>1e-7&&(u=d.height/l.height);var g=Math.min(c,u),f=this.paper.view.zoom,p=this.paper.view.zoom*g*(a?(null!==(r=this.zoomPercentageIncrement)&&void 0!==r?r:100)/100:1),m=this.paper.view.center,v=e.center;s?this.animatedZoom(f,p,m,v,15):(this.paper.view.zoom=p,this.paper.view.center=v),this.preventViewMoving=!0,this.clampView(),this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.updateZoomIndicators(),this.updateSelectionState(),this.getAllShapeImagePlaceholders().forEach(function(e){return o.updateShapeImagePlaceholder(e)}),this.restoreResizable(),this.paper.project.view.update()}}},updateRasterLayer:function(){var e=this.getAllItemsBounds();null==this.rasterLayer&&(this.rasterLayer=this.findItemByName("rasterLayer")),this.rasterLayer?(this.rasterLayer.removeChildren(),this.paper.project.view.update()):(this.rasterLayer=new this.paper.Layer,this.rasterLayer.name="rasterLayer",this.rasterLayer.insertAbove(this.itemsLayer),this.rasterLayer.guide=!0);var t=96;Math.max(e.width,e.height)>2e3&&(t=72),this.rasterLayer.activate();var i=this.paper.project.layers[0].rasterize(t,!1),n=this.paper.project.layers[1].rasterize(t,!1);this.rasterLayer.addChild(i),this.rasterLayer.addChild(n)},toDataURL:function(){return this.canvas.toDataURL()},getDesignDataUrl:function(){return this.itemsLayer.rasterize(96,!1).toDataURL()},showRasterLayer:function(){null==this.rasterLayer&&this.updateRasterLayer();for(var e=0;e<this.paper.project.layers.length;e++){var t=this.paper.project.layers[e];t!=this.rasterLayer&&(t.visible=!1)}this.rasterLayer.visible=!0,this.paper.project.view.update()},hideRasterLayer:function(){for(var e=0;e<this.paper.project.layers.length;e++){var t=this.paper.project.layers[e];t!=this.rasterLayer&&(t.visible=!0,t.activate())}this.rasterLayer.visible=!1,this.paper.project.view.update()},setImageScalingEnabled:function(e){this.isImageScalingEnabled=e},animatedZoom:function(e,t,i,n,a){if(!this.zooming){this.zooming=!0;var r=this;if(!(a<=0)){var o=(t-e)/a,s=n.subtract(i).clone();s=s.divide(a);var l=0,h=setInterval(function(){var e=l==a-1?t-r.paper.view.zoom:o,i=l==a-1?n.subtract(r.paper.view.center):s;r.paper.view.zoom+=e,r.paper.view.center=r.paper.view.center.add(i),r.updateZoomIndicators(),++l==a&&(clearInterval(h),r.zooming=!1,r.clampView(),r.checkAllAlertItems(),r.checkImagesSizeLimit(),r.updateSelectionState(),r.updateAreaLayerNamesSizes(),r.getAllShapeImagePlaceholders().forEach(function(e){return r.updateShapeImagePlaceholder(e)}))},30)}}},fitToScreen:function(e,t){var i=this.getAllItemsBounds();if(i){var n=this.fitToScreenMargin;if(this.imageItem&&this.isMobile){var a=i.width/this.imageItem.bounds.width,r=i.height/this.imageItem.bounds.height,o=Math.max(a,r);if(o>=.8)n=100*(Math.min(o,1)-.8)+20}this.zoomToBounds(i,n,e,t,!0),this.paper.view.update()}},fitToScreenForPreview:function(){var e,t=null===(e=this.imageItem)||void 0===e?void 0:e.bounds,i=this.getAllAreasBounds(),n=this.getAllItemsBounds();if(i&&t&&(n=i.area>t.area?i:t),n){var a=this.fitToScreenMargin;if(this.isMobile){var r=n.width/this.imageItem.bounds.width,o=n.height/this.imageItem.bounds.height,s=Math.max(r,o);if(s>=.8)a=100*(Math.min(s,1)-.8)+20}this.zoomToBounds(n,a,!1,!0),this.paper.view.update()}},updateZoomIndicators:function(){},areAllItemsInView:function(){var e=this.getAllItemsBounds();return this.paper.project.view.bounds.contains(e)},setElementType:function(e){e!=MPlaza.CustomizerElementType.None&&e!=MPlaza.CustomizerElementType.Rectangle&&e!=MPlaza.CustomizerElementType.Oval&&e!=MPlaza.CustomizerElementType.Path&&e!=MPlaza.CustomizerElementType.Free&&e!=MPlaza.CustomizerElementType.Text&&e!=MPlaza.CustomizerElementType.TextArt||(this.elementType=e)},setSide:function(e){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(i){switch(i.label){case 0:return this.removeAllAlertItems(),this.clearCanvas(),this.resetUndoRedo(),this.imageItem=null,this.resetAllDimensionLabels(),this.side=e,[4,new Promise(function(e){return t.updateImageItem(e)})];case 1:return i.sent(),this.masterGroup=new this.paper.Group,this.itemsLayer.addChild(this.masterGroup),this.areaLayersPaperLayer||(this.areaLayersPaperLayer=new this.paper.Layer({name:"areas-layer"}),this.areaLayersPaperLayer.bringToFront(),this.areaLayersPaperLayer.data.isAreaLayersLayer=!0),this.updateAreaItems(),[4,this.restoreResizable()];case 2:return i.sent(),this.updateRotation(),[4,this.updateDesignItemsCanvasItems()];case 3:return i.sent(),[4,this.updateGrids()];case 4:return i.sent(),this.isViewer||this.refreshBackgroundAreas(),this.fitToScreen(!1,!0),this.isSetSideEnded=!0,[2]}})})},setSide_old:function(e,t){this.removeAllAlertItems(),this.clearCanvas(),this.resetUndoRedo(),this.masterGroup=null,this.imageItem=null,this.side=e;var i=this;this.updateImageItem(function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return i.masterGroup=new this.paper.Group,this.itemsLayer.addChild(i.masterGroup),[4,i.rebuildItems()];case 1:return e.sent(),t&&t(),[2]}})})})},updateRotation:function(){this.side.get("canRotate")?this.updateProductAreasRotation():this.eventsToolsCustomizer.setDefaultRotation()},updateProductAreasRotation:function(){var e=this.getCanvasRotation();e&&this.eventsToolsCustomizer.onRotateAreasAndImage(e.degrees,{animation:!1},null)},updateAreasRotation:function(){var e=this.getCanvasRotation();e&&this.eventsToolsCustomizer.onRotateAreas(e.degrees,{animation:!1})},getCanvasRotation:function(){var e=this.side.getSideID(),t=this.design.get("canvasRotation");return null==t?void 0:t.find(function(t){return t.sideID==e})},refreshBackgroundAreas:function(){var e=this,t=this.side.get("areas"),i=this.getAllItems();t&&t.forEach(function(t){var n,a=e.findItemForArea(t);a&&(e.updateBackgroundGroupSize(a),i.find(function(e){var t,i,r;if((null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.isGroupForBackground)&&(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.areaGuid)===(null===(r=null==a?void 0:a.data)||void 0===r?void 0:r.guid))for(var o=0,s=e.children;o<s.length;o++){var l=s[o];if(l.data&&l.data.isAreaForBackground)return n=l.fillColor,!0}})&&(e.removeBackgroundColorArea(a),e.changeBackgroundColorArea(a,n,function(){return null})))})},getCurrentModel:function(){var e=null;if(this.side&&this.side instanceof MPlaza.Side){var t=this.side.getParentModel();if(t&&t instanceof MPlaza.Color){var i=t.getParentModel();i&&i instanceof MPlaza.Model&&(e=i)}}return e||(e=this.model),e},refresh:_.debounce(function(e,t){var i=this;this.updateImageItem(function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,i.rebuildItems()];case 1:return n.sent(),e&&e.boundsToAreas?i.adaptZoomToSideAreas(!1):i.fitToScreen(!1,!0),t&&t(),[2]}})})})},100),rebuildItems:function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return this.masterGroup?Array.from(this.masterGroup.children).forEach(function(e){return e.remove()}):(this.masterGroup=new this.paper.Group,this.itemsLayer.addChild(this.masterGroup)),paper.project.activeLayer.children.filter(function(e){return e.isMaskPath}).forEach(function(e){return e.remove()}),this.updateAreaItems(),[4,this.restoreResizable()];case 1:return e.sent(),this.updateAreasRotation(),[4,this.updateDesignItemsCanvasItems()];case 2:return e.sent(),[4,this.updateGrids()];case 3:return e.sent(),[2]}})})},setDesign:function(e){this.deselectAll(),this.initialItemsInfo={},this.clearDesignItemsCanvasItems(),this.resetUndoRedo(),this.design=e,this.checkAllAlertItems(),this.checkImagesSizeLimit();this.isViewer},refreshDesign:function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,this.updateDesignItemsCanvasItems()];case 1:return e.sent(),[4,this.updateGrids()];case 2:return e.sent(),[2]}})})},setupImageLayer:function(){this.imageLayer||(this.imageLayer=new this.paper.Layer({name:"side-image-layer"}),this.imageLayer.sendToBack(),this.itemsLayer=new this.paper.Layer({name:"items-layer"}),this.itemsLayer.bringToFront(),this.itemsLayer.activate())},updateImageItem:function(e){if(!this.showSideImage||!this.side||!this.side.get("imageUrl"))return this.imageItem&&this.imageItem.remove(),void(e&&e());var t=null;this.design&&(t=this.design.getDesignSide(this.side));var i=this,n=function(e,t){i.imageItem&&i.imageItem.remove(),i.imageItem=e,i.imageLayer.addChild(e),i.paper.project.view.update(),t()};if(this.side.get("colorable")&&t&&t.get("fillColor")){var a="#"+t.get("fillColor"),r=document.createElement("canvas");r.setAttribute("id","customizerOffscreen");var o=r.getContext("2d");r.width=i.imageWidth,r.height=i.imageHeight,this.domElement&&this.domElement.appendChild(r),Caman("#customizerOffscreen",this.side.get("imageUrl"),function(){this.newLayer(function(){this.setBlendingMode("multiply"),this.opacity(100),this.fillColor(a)}),this.render(function(){var t=o.getImageData(0,0,r.width,r.height),a=new i.paper.Raster({position:i.paper.view.center});a.setSize(new i.paper.Size(i.imageWidth,i.imageHeight)),a.setImageData(t,new i.paper.Point(0,0)),n(a,function(){i.domElement&&i.domElement.removeChild(r),e&&e()})})})}else{if(!i.imageLayer){i.imageLayer=new i.paper.Layer,i.imageLayer.name="side-image-layer",i.imageLayer.sendToBack();var s=new i.paper.Layer;i.itemsLayer=s,s.name="items-layer",s.bringToFront(),s.activate()}var l=new this.paper.Raster({crossOrigin:"anonymous",source:this.side.get("imageUrl"),position:new this.paper.Point(0,0)});l.onLoad=function(){n(l,function(){e&&e()})}}},updateAreaItems:function(){if(this.side&&this.side instanceof MPlaza.Side){var e=this.side.get("areas");if(e){for(var t=0;t<e.length;t++){var i=e.at(t);this.createItemForArea(i)}var n=[],a=[];for(t=0;t<e.length;t++){i=e.at(t);var r=this.paper.project.activeLayer.importJSON(i.get("path"));if(r instanceof this.paper.CompoundPath){for(var o=0;o<r.children.length;o++)n.push(r.children[o]);a.push(r)}else n.push(r)}n.forEach(function(e){e.data=void 0});var s=new this.paper.CompoundPath({children:n});s.data={isClippingArea:!0},this.masterGroup.addChild(s),s.sendToBack(),s.fillRule="nonzero",s.clipMask=!0,s.reorient(!1,!0),a.forEach(function(e){e.remove()})}}this.deselectAll(),this.paper.project.view.update()},createItemForArea:function(e){if(e&&e instanceof MPlaza.Area){var t=this.findItemForArea(e);t&&t.remove(),(t=this.paper.project.activeLayer.importJSON(e.get("path"))).data.guid=e.get("guid"),t.data.isArea=!0,t.data.selected=!0,this.masterGroup.addChild(t),this.isViewer&&(t.visible=!1),this.updateAreaItemColor(t),this.createAreaLayersItemsForArea(e,t)}},createAreaLayersItemsForArea:function(e,t){var i=this;this.getAllItems().filter(function(t){return t.data.connectedAreaGuid==e.get("guid")}).forEach(function(e){return e.remove()});var n=0;e.get("layers").each(function(a){var r=!i.isViewer,o=i.isViewer&&!i.isCartPreview,s=i.isViewer&&i.isCartPreview;if(!o){var l=a.get("isVisibleInCanvas"),h=a.get("isVisibleInCart");if(l&&(r||s&&h)){var d=i.areaLayersPaperLayer.importJSON(a.get("json"));d.data.connectedAreaGuid=e.get("guid"),d.data.layerID=a.get("layerID"),d.data.isAreaLayer=!0,a.get("showLabel")&&r&&i.createAreaLayerName(e,t,a,d,n++)}}}),this.updateAreaLayerNamesSizes()},createAreaLayerName:function(e,t,i,n,a){var r,o,s,l,h,d=this,c=this.getAreaLayerPaths(n);if(0!==c.length){var u=null!==(l=null!==(o=null===(r=c[0].strokeColor)||void 0===r?void 0:r.toCSS(!0))&&void 0!==o?o:null===(s=c[0].fillColor)||void 0===s?void 0:s.toCSS(!0))&&void 0!==l?l:"#000000",g=new this.paper.Group({onMouseEnter:function(){return d.paper.project.view.element.style.setProperty("cursor",""!=i.get("description")?"pointer":"default")},onMouseLeave:function(){return d.paper.project.view.element.style.setProperty("cursor",null)}});g.data.connectedAreaGuid=e.get("guid"),g.data.layerID=i.get("layerID"),g.data.isAreaLayerName=!0,g.data.isOpened=!1,g.data.layerIndex=a,this.areaLayersPaperLayer.addChild(g);var f=new this.paper.Point(0,0),p=new this.paper.PointText(new this.paper.Point(0,0));p.content=i.get("displayName"),p.fillColor=u,p.fontSize=16,p.position=f;var m=p.bounds.width;h=Math.max(150,m+70),g.data.tipWidth=h;var v=new this.paper.Path.Rectangle(new this.paper.Rectangle(0,0,h,26));v.position=f,v.isClipMask=!0;var I=new this.paper.Path.Rectangle(new this.paper.Rectangle(0,0,h,26));I.position=f,I.fillColor="#FFFFFF",I.strokeColor="#EEEEEE";var y=new this.paper.PointText(new this.paper.Point(0,20));y.content=this.simpleWordWrap(i.get("description"),h/7),y.fillColor="#555",y.visible=!1,y.justify="left",y.position=I.position.add(new this.paper.Point(0-h/2+y.bounds.width/2+10,15+y.bounds.height/2+10));var C=y.bounds.height,M=this.paper.project.activeLayer.importSVG(this.areaLayerIcon),x=M.children[1];if(x.position=new this.paper.Point(-h/2+20,0),x.scale(.7),x.fillColor=u,g.addChild(v),g.addChild(I),g.addChild(p),g.addChild(y),g.addChild(x),M.remove(),g.clipped=!0,""!=i.get("description")){var S=this.paper.project.activeLayer.importSVG(this.areaLayerArrowIcon),b=S.children[1];b.position=new this.paper.Point(h/2-20,0),b.scale(.4),b.fillColor=u,g.addChild(b),S.remove(),g.onClick=function(){var e=(g.data.isOpened?26:26+C+20)/d.paper.view.zoom/I.bounds.height;I.scale(new d.paper.Point(1,e),g.bounds.topCenter),v.scale(new d.paper.Point(1,e),g.bounds.topCenter),g.data.isOpened=!g.data.isOpened,y.visible=g.data.isOpened}}}},updateAreaLayerNamesSizes:function(e){var t=this;this.areaLayersPaperLayer.children.filter(function(e){return e.data.isAreaLayerName}).forEach(function(e){var i=e.data.layerIndex,n=e.data.tipWidth/t.paper.view.zoom/e.bounds.width,a=t.areaLayersPaperLayer.children.find(function(t){return t.data.layerID==e.data.layerID});if(e.scale(n,n),a){var r=t.getAreaLayerPaths(a);if(r.length>0){for(var o=new t.paper.Rectangle(r[0].bounds),s=0,l=r;s<l.length;s++){var h=l[s];o=o.unite(h.bounds)}var d=[o.bottomCenter,o.rightCenter,o.topCenter,o.leftCenter];e.position=d[i%d.length].add(new t.paper.Point(e.bounds.width/2*[0,1,0,-1][i%d.length],e.bounds.height/2*[1,0,-1,0][i%d.length]))}}})},getAreaLayerPaths:function(e){var t=this,i=[],n=function(e){if(e instanceof t.paper.CompoundPath)i.push(e);else if(e.children)for(var a=0,r=e.children;a<r.length;a++){var o=r[a];n(o)}};return n(e),i},simpleWordWrap:function(e,t){var i=[],n=-1;function a(){e.length<=t?(i.push(" "==e[0]?e.slice(1):e),e=""):e.length&&function(){for(var r=0;r<e.length;r++)if(" "==e[r]&&(n=r),r>=t){(-1==n||" "==e[r])&&(n=r),n>0&&i.push(e.slice(" "==e[0]?1:0,n)),e=e.slice(" "==e[0]?n+1:n),n=-1;break}a()}()}return t=Math.round(t),a(),this.content=i.join("\n")},hideAreaItems:function(){if(this.showSideImage){for(var e=this.getAllAreaItems(),t=0;t<e.length;t++){e[t].visible=!1}this.updateSelectionState(),this.paper.project.view.update()}},showAreaItems:function(){for(var e=this.getAllAreaItems(),t=0;t<e.length;t++){var i=e[t];i.visible=!0,i.strokeWidth=2}this.updateSelectionState(),this.paper.project.view.update()},adaptZoomToSideAreas:function(e){void 0===e&&(e=!0);var t=this.getAllAreasBounds(),i=this.getAllItemsBounds(),n=this.isResizableMode?i:t;this.zoomToBounds(n,this.fitToScreenMargin,e,!0,!0),this.updateSelectionState(),this.paper.project.view.update()},updateAreaItemsColor:function(){for(var e=this.getAllAreaItems(),t=0;t<e.length;t++){var i=e[t];this.updateAreaItemColor(i)}this.paper.project.view.update()},updateAreaItemColor:function(e){e&&e.bounds&&(e.strokeColor=this.getContrastedColor(e.bounds))},getAllAreaItems:function(){var e=[];function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];!a.guide&&a.data&&a.data.guid&&a.data.isArea&&e.push(a),t(a)}}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}return e},getAreasIntersectingItem:function(e){var t=this,i=[];if(e&&e.data&&e.data.guid&&!e.data.isArea&&this.side&&this.side instanceof MPlaza.Side&&this.side.get("areas")){var n=e;e.realBounds&&(n=new this.paper.Path.Rectangle(e.realBounds));for(var a=0;a<this.side.get("areas").length;a++){var r=this.side.get("areas").at(a),o=this.findItemForArea(r);r&&o&&(o instanceof this.paper.CompoundPath&&o.children&&o.children.length>0?__spreadArray([],o.children,!0):[o]).some(function(i){var a,o=n.bounds.intersects(i.bounds),s=!e.data.isImageForBackground&&!e.data.isAreaForBackground||r.get("guid")===e.data.areaGuid,l=!e.data.isGridImage||e.data.isGridImage&&(null===(a=t.design.get("areasGrids"))||void 0===a?void 0:a.find(function(e){return e.get("sideID")==t.side.id&&e.get("areaID")==r.id}));return o&&s&&l})&&i.push(r)}e.realBounds&&n.remove()}return i},getAreasContainingItem:function(e){var t=this,i=[];if(e&&e.data&&e.data.guid&&!e.data.isArea&&this.side&&this.side instanceof MPlaza.Side&&this.side.get("areas")){var n=e;e.realBounds&&(n=new this.paper.Path.Rectangle(e.realBounds));for(var a=0;a<this.side.get("areas").length;a++){var r=this.side.get("areas").at(a),o=this.findItemForArea(r);r&&o&&(o instanceof this.paper.CompoundPath&&o.children&&o.children.length>0?__spreadArray([],o.children,!0):[o]).some(function(i){return!n.bounds.intersects(i.bounds)&&i.bounds.contains(n.bounds)&&i.contains(n.position)&&(!e.data.isImageForBackground&&!e.data.isAreaForBackground||r.get("guid")===e.data.areaGuid)&&(!e.data.isGridImage||e.data.isGridImage&&t.design.get("areasGrids")&&t.design.get("areasGrids").find(function(e){return e.get("sideID")==t.side.id&&e.get("areaID")==r.id}))})&&i.push(r)}e.realBounds&&n.remove()}return i},getAreasIntersectingOrContainingItem:function(e){var t=this,i=[];if(e&&e.data&&e.data.guid&&!e.data.isArea&&this.side&&this.side instanceof MPlaza.Side&&this.side.get("areas")){var n=e;e.realBounds&&(n=new this.paper.Path.Rectangle(e.realBounds));for(var a=0;a<this.side.get("areas").length;a++){var r=this.side.get("areas").at(a),o=this.findItemForArea(r),s=[];if(r&&o){(s=o instanceof this.paper.CompoundPath&&o.children&&o.children.length>0?__spreadArray([],o.children,!0):[o])[0];s.some(function(i){return(n.bounds.intersects(i.bounds)||n.bounds.contains(i.bounds)||i.bounds.contains(n.bounds)||i.contains(n.position))&&(!e.data.isImageForBackground&&!e.data.isAreaForBackground||r.get("guid")===e.data.areaGuid)&&(!e.data.isGridImage||e.data.isGridImage&&t.design.get("areasGrids")&&t.design.get("areasGrids").find(function(e){return e.get("sideID")==t.side.id&&e.get("areaID")==r.id}))})&&i.push(r)}}e.realBounds&&n.remove()}return i},getItemArea:function(e){var t=this.getAreasIntersectingOrContainingItem(e);return t.length>1||0==t.length?null:t[0]},clearDesignItemsCanvasItems:function(){var e=this;function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];t(a),a.data&&a.data.maskPath&&a.data.maskPath.remove(),e.removeProfanityCheckInvalidOverlayAndEdgeForItem(a),(!a.guide&&a.data&&a.data.guid&&!a.data.isArea||a.data.isDashedEdge)&&a.remove()}}e.removeAllAlertItems(),e.resetAllDimensionLabels();for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}},updateDesignItemsCanvasItems:function(){return __awaiter(this,void 0,void 0,function(){var e,t,i,n,a;return __generator(this,function(r){switch(r.label){case 0:if(e=[],this.clearDesignItemsCanvasItems(),!(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design))return[3,4];if(!(t=this.design.getSideDesignItems(this.side).sort(function(e,t){return e.get("index")>t.get("index")})))return[3,4];i=0,r.label=1;case 1:return i<t.length?(n=t[i],[4,this.createItemForDesignItem(n)]):[3,4];case 2:if(((a=r.sent()).data.isImageForBackground||a.data.isAreaForBackground)&&e.indexOf(a.data.areaGuid)>0)return a.remove(),a.data.maskPath&&a.data.maskPath.remove(),a.data.maskAlertPath&&a.data.maskAlertPath.remove(),this.removeDashedEdgeForItem(a),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(a),[3,3];a.data&&(a.data.isImageForBackground||a.data.isAreaForBackground)&&e.indexOf(a.data.areaGuid)<0&&e.push(a.data.areaGuid),a.data.selected=!1,r.label=3;case 3:return i++,[3,1];case 4:return this.deselectAll(),this.isViewer||this.updateItemsIndexes(),this.paper.project.view.update(),[2]}})})},createItemForDesignItem:function(e){var t,i;return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M;return __generator(this,function(x){switch(x.label){case 0:return n=null,e&&e instanceof MPlaza.DesignItem?((n=this.findItemForDesignItem(e))&&(n.remove(),this.deleteDimensionLabel(n.id),n.data.maskPath&&n.data.maskPath.remove(),n.data.maskAlertPath&&n.data.maskAlertPath.remove(),this.removeDashedEdgeForItem(n),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(n)),[4,this.getOrCreateItemFromDesignItem(e)]):[3,2];case 1:if(n=x.sent(),(a=this.getMaskedImageRasterItem(n))&&a instanceof this.paper.Raster&&!(a.data&&a.data.originalBounds&&a.data.originalMatrix)&&(a.data.originalBounds=new this.paper.Rectangle(0,0,a.width,a.height),a.data.originalMatrix=a.matrix.clone()),(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.isTextArea)&&!(null===(i=null==n?void 0:n.data)||void 0===i?void 0:i.originalMatrix)&&(null==n?void 0:n.children)&&(null==n?void 0:n.children.length)>0&&(r=n.children[0],o=r.matrix.a,s=r.matrix.b,l=r.matrix.c,h=r.matrix.d,d=n.bounds.centerX,c=n.bounds.centerY,n.data.originalMatrix=new this.paper.Matrix(o,s,l,h,d,c)),n.data&&(n.data.isImageForBackground||n.data.isAreaForBackground)?(u=this.findItemByGuid(n.data.areaGuid))&&((g=this.getOrCreateBackgroundGroupItem(u)).addChild(n),this.masterGroup.addChild(g),g.sendToBack()):(this.masterGroup.addChild(n),this.updateShapeImagePlaceholder(n)),this.getItemIsTextArea(n)&&n.children){for(f=[],p=[],m=0,v=n.children;m<v.length;m++)(C=v[m])instanceof this.paper.PointText&&(""==C.content||"⠀"==C.content)?p.push(C):f.push(C);for(I=0,y=p;I<y.length;I++)(C=y[I]).remove();p.length>0&&(n.children=f,this.onItemUpdated(n))}n instanceof this.paper.Raster?this.getAllItems().find(function(e){return e==n})&&(this.paper.project.view.update(),this.createMaskForItem(n),this.createDashedEdgeForItem(n),this.createProfanityCheckInvalidOverlayAndEdgeForItem(n),this.checkAlertItems(n),this.fireItemCreatedEvent(n),this.fireImageLoadedEvent(n)):(this.createMaskForItem(n),this.createDashedEdgeForItem(n),this.createProfanityCheckInvalidOverlayAndEdgeForItem(n),this.checkAlertItems(n),this.fireItemCreatedEvent(n)),x.label=2;case 2:return n.visible=!0,M=e.get("constraints"),this.isViewer&&M&&!M.get("isPrintable")&&(n.visible=M.get("keepInPreview")),[2,n]}})})},findAreaByGuid:function(e){return this.side&&this.side instanceof MPlaza.Side&&this.side.get("areas")?this.side.get("areas").getArea(e):null},findItemByGuid:function(e,t){void 0===t&&(t=null),t=t||this.paper;for(var i=e.toUpperCase(),n=function(e,t){if(e.data.guid&&e.data.guid.toUpperCase()==t)return e;if(e.children)for(var i=e.children.length-1;i>=0;i--){var a=e.children[i],r=n(a,t);if(r)return r}},a=0;a<t.project.layers.length;a++){var r=t.project.layers[a];if(!r.guide){var o=n(r,i);if(o)return o}}return null},getChildrens:function(e){var t=[],i=function(e){if(t=__spreadArray(__spreadArray([],t,!0),[e],!1),e.children)for(var n=0,a=e.children;n<a.length;n++){var r=a[n];i(r)}};return i(e),t},removeItemByGuid:function(e){var t=this.findItemByGuid(e);t.remove(),this.onItemRemoved(t)},findItemForArea:function(e){return e&&e instanceof MPlaza.Area?this.findItemByGuid(e.get("guid")):null},findDesignItemByGuid:function(e){var t=null;return this.design&&(t=this.design.get("designItems").getDesignItemByGuid(e)),t},findDesignItemForItem:function(e){return e&&e.data&&e.data.guid?this.findDesignItemByGuid(e.data.guid):null},getPaperItemFromDesignItem:function(e){var t=JSON.parse(e.get("json"));return this.paper.project.importJSON(t)},findItemForDesignItem:function(e){if(e&&e instanceof MPlaza.DesignItem)return this.findItemByGuid(e.get("itemGuid"))},snapDeltaToAngle:function(e,t){var i=180/Math.PI*t,n=e.angle;n=Math.round(n/i)*i;var a=e.clone();return a.angle=n,a},onItemsCreated:function(e){for(var t=0;t<e.length;t++)this.onItemCreated(e[t],null)},onItemCreated:function(e,t){var i=this.createDesignItem(e,t);return this.updateItemsIndexes(),this.checkAllAlertItems(),this.isViewer||this.checkImagesSizeLimit(),this.registerItemOperation("create",i.get("itemGuid"),null,i.clone()),i},onTextArtItemCreated:function(e,t){var i=this.createTextArtDesignItem(e,t);return this.updateItemsIndexes(),this.checkAllAlertItems(),this.isViewer||this.checkImagesSizeLimit(),this.registerItemOperation("create",i.get("itemGuid"),null,i.clone()),i},onShapeItemCreated:function(e,t,i){var n=this.createShapeDesignItem(e,t,i);return this.updateItemsIndexes(),this.checkAllAlertItems(),this.updateShapeImagePlaceholder(e),this.isViewer||this.checkImagesSizeLimit(),this.registerItemOperation("create",n.get("itemGuid"),null,n.clone()),n},onItemsUpdated:function(e){for(var t=0;t<e.length;t++)this.onItemUpdated(e[t])},onItemUpdated:function(e){var t=this.getItemRealBounds(e);e.realBounds=t;var i=null,n=null,a=this.findDesignItemForItem(e);a&&(i=a.clone()),this.checkAlertItems(e),this.checkImagesSizeLimit(),this.updateTransformsData(e),this.updateDesignItem(e),this.updateDesignItemAreasAndIndex(e),this.fireItemChangedEvent(e),this.updateShapeImagePlaceholder(e),(a=this.findDesignItemForItem(e))&&(n=a.clone()),i&&n&&this.registerItemOperation("update",e.data.guid,i,n)},onImageItemUpdated:function(e,t,i){var n=this.findDesignItemByGuid(e.data.guid);if(n){var a=n.clone();this.updateImageDesignItem(e,n,t,i),this.checkAlertItems(e),this.checkImagesSizeLimit(),this.updateTransformsData(e),this.updateDesignItem(e),this.fireItemChangedEvent(e);var r=(n=this.findDesignItemByGuid(e.data.guid)).clone();a&&r&&this.registerItemOperation("update",e.data.guid,a,r)}},onTextArtItemUpdated:function(e,t){var i=this.findDesignItemByGuid(e.data.guid);if(i){var n=i.clone();this.updateTextArtDesignItem(e,i,t),this.fireItemChangedEvent(e),this.updateTransformsData(e);var a=(i=this.findDesignItemByGuid(e.data.guid)).clone();n&&a&&this.registerItemOperation("update",e.data.guid,n,a)}},onShapeItemUpdated:function(e,t,i){var n=this.findDesignItemByGuid(e.data.guid);if(n){var a=n.clone(),r=this.getMaskedImageShapeItem(e);this.updateShapeDesignItem(r,n,t,i),this.fireItemChangedEvent(e),this.updateTransformsData(e),this.updateShapeImagePlaceholder(e);var o=(n=this.findDesignItemByGuid(e.data.guid)).clone();a&&o&&this.registerItemOperation("update",e.data.guid,a,o)}},onDesignItemChanged:function(e){var t=this.findDesignItemForItem(e);t&&this.fireDesignItemChangedEvent(t)},onItemsRemoved:function(e){for(var t=0;t<e.length;t++)this.onItemRemoved(e[t])},onItemRemoved:function(e){var t=this.findDesignItemByGuid(e.data.guid);this._onItemRemovedInternal(e),t&&this.registerItemOperation("delete",e.data.guid,t.clone(),null)},_onItemRemovedInternal:function(e){if(this.removeAlertItems(e),this.checkImagesSizeLimit(),this.removeTextOnPathGuide(e),this.removeTextOnPathHandles(e),this.removeTextAreaGuide(e),this.removeTextAreaHandles(e),this.removeDesignItem(e),this.findDesignItemByGuid(e.data.guid))throw console.trace("Item removed, but the design item is still present.",e,this.findDesignItemByGuid(e.data.guid)),"There was an error during item deletion";this.fireItemRemovedEvent(e),e.data.isProfanityCheckInvalid=!1,e.data.maskPath&&e.data.maskPath.remove(),e.data.maskAlertPath&&e.data.maskAlertPath.remove(),this.removeDashedEdgeForItem(e),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e)},getSerializedPaperItem:function(e){var t=this.getMaskedImageGuideRasterItem(e),i=null,n=this.getMaskedImageGuideShapeItem(e),a=null;t&&(i=t.id,t.remove()),n&&(a=n.id,n.remove());var r={json:e.exportJSON({asString:!0}),svg:e.exportSVG({asString:!0,embedImages:!1})};if(t){var o=this.createMaskedImageGuideRaster(e);o&&i&&(o._id=i)}if(n){var s=this.createMaskedImageGuideShape(e);s&&a&&(s._id=a)}return r},createDesignItem:function(e,t){var i;if(e&&!e.guide){var n=null;if(e.data.guid&&(n=this.findDesignItemByGuid(e.data.guid)),null==n&&(n=new MPlaza.DesignItem,e.data.guid=n.get("itemGuid"),this.design.get("designItems").add(n)),null!=n){n.set("index",e.index);var a=this.getSerializedPaperItem(e);if(n.set("json",a.json),n.set("svg",a.svg),t&&t instanceof MPlaza.Image){if(t.get("itemGuid")&&(n.set("itemGuid",t.get("itemGuid")),e.data.guid=n.get("itemGuid")),n.set("imageID",t.get("imageID")),n.set("imageType",t.get("type")),n.set("imageFormat",t.get("format")),n.set("imageWidth",t.get("width")),n.set("imageHeight",t.get("height")),n.set("imageDpiX",t.get("dpiX")),n.set("imageDpiY",t.get("dpiY")),n.set("imageUserID",t.get("userID")),n.set("imageVisitorID",t.get("visitorID")),n.set("imageVisitorCode",t.get("visitorCode")),n.set("imagePrice",t.get("price")),n.set("applyImagePriceForQuantity",t.get("applyPriceForQuantity")),n.set("providerImageID",t.get("providerImageID")),n.set("imageIsMulticolor",t.get("isMulticolor")),n.set("imagePreferredWidth",t.get("preferredWidth")),n.set("imagePreferredHeight",t.get("preferredHeight")),n.set("imageFileSize",t.get("imageFileSize")),n.set("imageCustomerID",t.get("customerID")),n.set("imageCustomerCode",t.get("customerCode")),n.set("overridePreview",t.get("overridePreview")),"Vector"==t.get("type")&&t.get("colors")&&t.get("colors").length>0)for(var r=0;r<t.get("colors").length;r++)n.get("itemColors").push(t.get("colors").at(r).get("code"));n.set("connectorSettings",new MPlaza.ConnectorSettings),(null===(i=t.get("connectorSettings"))||void 0===i?void 0:i.length)>0&&t.get("connectorSettings").forEach(function(e){var t=new MPlaza.ConnectorSetting;t.set("key",e.key||e.connectorKey),t.set("settings",e.settings),n.get("connectorSettings").push(t)})}else this.updateDesignItemDistinctColors(n,e);if(!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);n.updateAreas(o)}}return n}return null},createTextArtDesignItem:function(e,t){if(e&&!e.guide&&t){var i=null;if(e.data.guid&&(i=this.findDesignItemByGuid(e.data.guid)),null==i&&(i=new MPlaza.DesignItem,e.data.guid=i.get("itemGuid"),this.design.get("designItems").add(i)),null!=i){i.set("index",e.index);var n=this.getSerializedPaperItem(e);i.set("json",n.json),i.set("svg",n.svg);var a=new MPlaza.DesignItemTextArt;a.set("text",t.text),a.set("fontFamilyID",t.fontFamilyID),a.set("fontFaceID",t.fontFaceID),a.set("textArtTypeID",t.textArtTypeID);var r=new MPlaza.TextArtConfig(t.config);if(a.set("config",r),i.set("textArt",a),!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);i.updateAreas(o)}}return i}return null},createShapeDesignItem:function(e,t,i){if(e&&!e.guide&&i&&t&&t instanceof MPlaza.Shape){var n=null;if(e.data.guid&&(n=this.findDesignItemByGuid(e.data.guid)),null==n&&(n=new MPlaza.DesignItem,e.data.guid=n.get("itemGuid"),this.design.get("designItems").add(n)),null!=n){n.set("index",e.index);var a=this.getSerializedPaperItem(e);n.set("json",a.json),n.set("svg",a.svg);var r=new MPlaza.DesignItemShape;if(r.set("shapeID",t.get("shapeID")),r.set("isMask",!1),n.set("shape",r),!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);n.updateAreas(o)}}return n}return null},updateTransformsData:function(e){if(e&&e.data&&(e.data.guid||e.data.isTextOnPath||e.data.isTextArea)&&!e.data.isArea){var t=null;if(e.data.transformsData&&e.data.transformsData.dimensions&&!e.data.needsTransformsDataUpdate)t=e.data.transformsData.dimensions;else{var i=e.clone();i.visible=!1,i.rotate(0-i.rotation);var n=new this.paper.Path.Rectangle(this.getItemBounds(i));n.visible=!1,t={width:n.bounds.width,height:n.bounds.height},n.remove(),i.remove()}e.data.transformsData={position:{x:e.position.x,y:e.position.y},rotation:e.rotation,dimensions:t}}},updateDesignItem:function(e){if(e&&e.data&&e.data.guid&&!e.data.isArea){var t=this.findDesignItemByGuid(e.data.guid);if(t){var i=e.visible;e.visible=!0,this.preventAreasAndIndexUpdate||void 0===e.index||null===e.index||t.set("index",e.index);var n=this.getSerializedPaperItem(e);t.set("json",n.json),t.set("svg",n.svg),e.visible=i,this.updateDesignItemDistinctColors(t,e)}}},updateDesignItemDistinctColors:function(e,t){var i=[],n=this.getMaskedImageRasterItem(t),a=this.getMaskedImageShapeItem(),r=e.get("colorMappings");if(r&&r.length>0){for(var o=0;o<r.length;o++){var s=r.at(o);s.get("dest")&&-1===i.indexOf(s.get("dest"))&&i.push(s.get("dest"))}this.updateDesignItemColors(e,i)}else if(!n&&!a||n&&a){var l=t;if(a?l=a:(t.data.isTextOnPath||t.data.isTextArea)&&(l=null,t.children.length>0&&(l=t.children[0])),l){var h=null;l.strokeWidth>0&&l.strokeColor&&(h=l.strokeColor.toCSS(!0),i.push(h));var d=null;!l.fillColor||h&&l.fillColor==h||(d=l.fillColor,i.push(l.fillColor.toCSS(!0)));var c=null;!l.shadowColor||!l.shadowBlur||!l.shadowOffset.x&&!l.shadowOffset.y||h&&l.shadowColor==h||d&&l.shadowColor==d||(c=l.shadowColor,i.push(c.toCSS(!0)))}this.updateDesignItemColors(e,i)}},updateDesignItemAreasAndIndex:function(e){if(e&&e.data&&e.data.guid&&!e.data.isArea&&!this.preventAreasAndIndexUpdate){var t=this.findDesignItemByGuid(e.data.guid);if(t){var i=this.getAreasIntersectingOrContainingItem(e);t.updateAreas(i);for(var n=this.design.getSideDesignItems(this.side),a=0;a<n.length;a++){var r=n[a],o=this.findItemForDesignItem(r);if(o){var s=r.clone();r.set("index",o.index),this.registerItemOperation("update",o.data.guid,s,r.clone())}}}}},updateDesignItemColors:function(e,t){for(;e.get("itemColors").length>0;)e.get("itemColors").pop();for(var i=0,n=t;i<n.length;i++){var a=n[i];e.get("itemColors").push(a)}},updateDesignItemColorMappings:function(e,t){if(e&&e instanceof MPlaza.DesignItem&&(e.set("colorMappings",new MPlaza.ColorMappings),t))for(var i=0;i<t.length;i++){var n=new MPlaza.ColorMapping(t[i]);e.get("colorMappings").add(n)}},updateImageDesignItem:function(e,t,i,n){var a;if(this.canEditItem(e)){var r=this.getMaskedImageRasterItem(e);if(e&&!e.guide&&r&&r instanceof this.paper.Raster&&t&&t instanceof MPlaza.DesignItem&&i&&i instanceof MPlaza.Image){var o=this.getSerializedPaperItem(e);for(t.set("json",o.json),t.set("svg",o.svg),i.get("itemGuid")&&(t.set("itemGuid",i.get("itemGuid")),e.data.guid=t.get("itemGuid")),t.set("imageID",i.get("imageID")),t.set("imageType",i.get("type")),t.set("imageFormat",i.get("format")),t.set("imageWidth",i.get("width")),t.set("imageHeight",i.get("height")),t.set("imageDpiX",i.get("dpiX")),t.set("imageDpiY",i.get("dpiY")),t.set("imageUserID",i.get("userID")),t.set("imageVisitorID",i.get("visitorID")),t.set("imageVisitorCode",i.get("visitorCode")),t.set("imagePrice",i.get("price")),t.set("imageIsMulticolor",i.get("isMulticolor")),t.set("imagePreferredWidth",i.get("preferredWidth")),t.set("imagePreferredHeight",i.get("preferredHeight")),t.set("imageFileSize",i.get("imageFileSize")),t.set("imageCustomerID",i.get("customerID")),t.set("imageCustomerCode",i.get("customerCode")),t.set("overridePreview",i.get("overridePreview")),this.isSetSideEnded&&t.set("isChanged",!0);t.get("itemColors").length>0;)t.get("itemColors").pop();if("Vector"==i.get("type")&&i.get("colors")&&i.get("colors").length>0)for(var s=0;s<i.get("colors").length;s++)t.get("itemColors").push(i.get("colors").at(s).get("code"));if(t.unset("connectorSettings"),t.set("connectorSettings",new MPlaza.ConnectorSettings),(null===(a=i.get("connectorSettings"))||void 0===a?void 0:a.length)>0&&i.get("connectorSettings").forEach(function(e){var i=new MPlaza.ConnectorSetting;i.set("key",e.key||e.connectorKey),i.set("settings",e.settings),t.get("connectorSettings").push(i)}),t.unset("shape"),n&&n instanceof MPlaza.Shape&&-1!==n.get("shapeID")&&void 0!==n.get("shapeID")){var l=new MPlaza.DesignItemShape;l.set("itemID",t.getDesignItemID()),l.set("shapeID",n.get("shapeID")),l.set("isMask",!0),t.set("shape",l)}if(!this.preventAreasAndIndexUpdate){var h=this.getAreasIntersectingOrContainingItem(e);t.updateAreas(h)}}}},updateTextArtDesignItem:function(e,t,i){if(this.canEditItem(e)&&e&&!e.guide&&(e instanceof this.paper.CompoundPath||e instanceof this.paper.Path)&&e.data&&e.data.isTextArt&&t&&t instanceof MPlaza.DesignItem&&t.isTextArt()&&i){var n=this.getSerializedPaperItem(e);t.set("json",n.json),t.set("svg",n.svg);var a=t.get("textArt");if(a){a.set("text",i.text),a.set("fontFamilyID",i.fontFamilyID),a.set("fontFaceID",i.fontFaceID),a.set("textArtTypeID",i.textArtTypeID);var r=new MPlaza.TextArtConfig(i.config);a.set("config",r)}if(!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);t.updateAreas(o)}}},updateShapeDesignItem:function(e,t,i,n){if(this.canEditItem(e)&&e&&!e.guide&&(e instanceof this.paper.CompoundPath||e instanceof this.paper.Path)&&e.data&&e.data.isShape&&i&&i instanceof MPlaza.Shape&&t&&t instanceof MPlaza.DesignItem){var a=this.getSerializedPaperItem(e);t.set("json",a.json),t.set("svg",a.svg);var r=t.get("shape");if(r&&(r.set("shapeID",i.get("shapeID")),r.set("isMask",!1)),!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);t.updateAreas(o)}for(n&&n instanceof MPlaza.Image?(t.set("imageID",n.get("imageID")),t.set("imageType",n.get("type")),t.set("imageFormat",n.get("format")),t.set("imageWidth",n.get("width")),t.set("imageHeight",n.get("height")),t.set("imageDpiX",n.get("dpiX")),t.set("imageDpiY",n.get("dpiY")),t.set("imageUserID",n.get("userID")),t.set("imageVisitorID",n.get("visitorID")),t.set("imageVisitorCode",n.get("visitorCode")),t.set("imagePrice",n.get("price")),t.set("imageIsMulticolor",n.get("isMulticolor")),t.set("imagePreferredWidth",n.get("preferredWidth")),t.set("imagePreferredHeight",n.get("preferredHeight")),t.set("imageFileSize",n.get("imageFileSize")),t.set("isChanged",!0)):(t.unset("imageID"),t.unset("imageType"),t.unset("imageFormat"),t.unset("imageWidth"),t.unset("imageHeight"),t.unset("imageDpiX"),t.unset("imageDpiY"),t.unset("imageUserID"),t.unset("imageVisitorID"),t.unset("imageVisitorCode"),t.unset("imagePrice"),t.unset("imageIsMulticolor"),t.unset("imagePreferredWidth"),t.unset("imagePreferredHeight"),t.unset("imageFileSize"),t.unset("isChanged"));t.get("itemColors").length>0;)t.get("itemColors").pop();if(n&&n.get("ImageID")>0&&"Vector"==n.get("type")&&n.get("colors")&&n.get("colors").length>0)for(var s=0;s<n.get("colors").length;s++)t.get("itemColors").push(n.get("colors").at(s).get("code"))}},removeDesignItem:function(e){if(e&&e.data&&e.data.guid&&!e.data.isArea){var t=this.findDesignItemByGuid(e.data.guid);t&&this.design.get("designItems").remove(t)}},checkImagesSizeLimit:function(e){var t=this;if(null==e||isNaN(e)||e<=0?e=this.areasSizeLimit:this.areasSizeLimit=e,this.removeSizeLimitAlert(),this.side&&this.side.collection){var i=this.side.collection.models,n=this.getAllImageItems();i&&n&&(this.side.get("areas").forEach(function(e){var i=t.areasSizeCountCollection.findIndex(function(i){return i.sideID==t.side.get("sideID")&&i.areaID==e.get("areaID")});-1==i?t.areasSizeCountCollection.push({sideID:t.side.get("sideID"),areaID:e.get("areaID"),sizeCount:0}):t.areasSizeCountCollection[i].sideID==t.side.get("sideID")&&(t.areasSizeCountCollection[i].sizeCount=0)}),n.forEach(function(e){var i=t.findDesignItemForItem(e);i&&t.getAreasIntersectingOrContainingItem(e).forEach(function(e){var n=t.areasSizeCountCollection.findIndex(function(i){return i.sideID==t.side.get("sideID")&&i.areaID==e.get("areaID")});t.areasSizeCountCollection[n].sizeCount+=i.get("imageFileSize")})}),this.areasSizeCountCollection.filter(function(e){return e.sideID==t.side.get("sideID")}).forEach(function(i){t.side.get("areas").models.forEach(function(n){if(n.get("areaID")==i.areaID&&i.sizeCount>e){var a=StringHelper.format(T._("Total size of uploaded pictures must be less than {0} MB per each print-area","Customizer"),(parseInt(e)/1024/1024).toFixed(2)),r=t.customizedMessages.find(function(e){return e.EventID==MPlaza.EventMessages.UploadLimit});if(r&&(a=StringHelper.format(T._d(r.Description)),!1===r.Visible))return;var o=t.findItemForArea(n);o&&t.fireNotifyMessageEvent(n.get("guid"),2,T._("Warning!","Customizer"),a,!r||r.Closeable,function(){return t.zoomToBounds(o.bounds,t.fitToScreenMargin,!0,!0)},null,null,!!r&&r.AddToCartDisabledIfVisible)}})}))}},removeSizeLimitAlert:function(){this.areaAlertItems.forEach(function(e){e.icon.remove(),e.tooltip.remove()}),this.areaAlertItems=[]},checkAlertItems:function(e){if(e&&(!e.data||!e.data.isImageForBackground&&!e.data.isAreaForBackground)){this.removeAlertItems(e);var t=[],i=this,n=this.getAreasIntersectingOrContainingItem(e),a=i.customizedMessages.filter(function(e){return e.Visible}).find(function(e){return e.EventID==MPlaza.EventMessages.ItemsClippedWarning});a&&n.length>0&&n.forEach(function(n){var r=i.findItemForArea(n),o=new i.paper.Path.Rectangle(e.bounds);r&&r.intersects(o)&&t.push(a),o.remove()});for(var r=1,o=1,s=0;s<n.length;s++){var l=n[s];if(!this.checkItemQualityForArea(e,l)){var h,d=this.getMaskedImageRasterItem(e);if(!d)return;if((h=this.findDesignItemForItem(e))&&h.attributes&&"svg"==h.attributes.imageFormat.toLowerCase())break;var c=h.get("constraints");if(c&&!c.get("isPrintable"))break;var u=this.side.get("ppcm"),g=300,f=this.getSelectedPrintType(l);if(f){var p=f.get("dpi");g=f instanceof MPlaza.PartPrintType&&p&&p>0?p:(f=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(l))).get("dpi")||f.get("printTypeDPI"),"PrintfulPrintType"==f.get("name")&&g>120&&(g*=.75)}else console.warn("Can't determinate the print type DPI");if(r=d.bounds.width/u/2.54*g,o=d.bounds.height/u/2.54*g,I=i.customizedMessages.find(function(e){return e.EventID==MPlaza.EventMessages.DPIWarning})){if(!1===I.Visible&&(h.get("imageCustomerCode")||h.get("imageVisitorCode")||h.get("imageVisitorID")>0||h.get("imageCustomerID")>0)&&!this.model.get("providerID"))break;if(!1===I.EnableCheckForSellerImages&&!h.get("imageCustomerCode")&&!h.get("imageVisitorCode")&&h.get("imageVisitorID")<=0&&h.get("imageCustomerID")<=0)break;t.push(__assign(__assign({},I),{Description:StringHelper.format(T._d(I.Description),r.toFixed(0),o.toFixed(0))}))}else t.push(__assign(__assign({},I),{Description:StringHelper.format(T._("We strongly suggest file with a higher resolution to get better results.<br/>(at least {0} x {1} pixels)","Customizer"),r.toFixed(0),o.toFixed(0))}));break}}if(t.length>0)if(h=this.findDesignItemForItem(e)){for(var m=0,v=t;m<v.length;m++){var I=v[m];this.fireNotifyMessageEvent(h.get("itemGuid"),2,T._("Warning!","Customizer"),T._d(I.Description),!I.Closeable||I.Closeable,this.zoomToItem(e),null,{requiredWidth:r,requiredHeight:o},!!I.AddToCartDisabledIfVisible&&I.AddToCartDisabledIfVisible)}return{itemGuid:h.get("itemGuid"),customizedMessages:t}}}},zoomToItem:function(e){var t=this;return function(){e&&(t.zoomToBounds(e.bounds,t.fitToScreenMargin,!0,!0),t.selectItems([e]))}},checkAllAlertItems:function(){for(var e=[],t=this.getAllItems(),i=0;i<t.length;i++){var n=t[i];if(n&&n.data&&n.data.guid&&!n.data.isArea&&!n.guide){var a=this.checkAlertItems(n);a&&e.push(a)}}return e},drawRealBounds:function(e){if(this.realRect&&this.realRect.remove(),this.getMaskedImageRasterItem(e)){var t=this.getItemRealBounds(e);this.realRect=new this.paper.Path.Rectangle(t),this.realRect.strokeColor="red",this.realRect.strokeWidth=1}},getItemRealBounds:function(e){if(!this.getMaskedImageRasterItem(e))return e.bounds;var t=e.bounds;if(IS_IOS)return t;var i=e.rasterize(72);try{var n,a,r=i.position.x-i.width/2,o=i.position.y-i.height/2,s=i.width,l=i.height,h=i.getImageData().data,d=new Uint32Array(h.buffer),c=s,u=l,g=0,f=0;for(a=0;a<l;a++){for(n=0;n<s;n++)d[n+a*s]>0&&n<c&&(c=n);for(n=s;n>=0;n--)d[n+a*s]>0&&n>g&&(g=n)}for(n=0;n<s;n++){for(a=0;a<l;a++)d[n+a*s]>0&&a<u&&(u=a);for(a=l;a>=0;a--)d[n+a*s]>0&&a>f&&(f=a)}((t=new this.paper.Rectangle(r+c,o+u,g-c,f-u)).width<=0||t.height<=0)&&(t=e.bounds)}catch(e){Logger.info(e.message)}finally{i.remove()}return t},createAlertIcon:function(e,t){if(!e)return null;t=t||!1;var i=25/this.paper.view.zoom,n="data:image/png;base64,"+(t?this.iconsBytes.itemAlertDark:this.iconsBytes.itemAlert),a=new this.paper.Raster({source:n,position:e}),r=function(){var e=a.size,t=new this.paper.Size(i,i),n=1,r=1;Math.abs(e.width)>1e-7&&(n=t.width/e.width),Math.abs(e.height)>1e-7&&(r=t.height/e.height),a.scale(n,r)};return a.size.width>0&&a.size.height>0?r():a.onLoad=function(){r()},a},checkSelectionAlertItems:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[0];this.checkAlertItems(i)}},removeAlertItems:function(e){e&&this.fireRemoveMessageEvent(e.data.guid)},removeAllAlertItems:function(){var e=this;this.isConfigurator||this.isViewer||this.getAllItems().forEach(function(t){return e.removeAlertItems(t)})},removeSelectionAlertItems:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[0];this.removeAlertItems(i)}},checkItemQualityForArea:function(e,t){var i=this.getMaskedImageRasterItem(e);if(e&&i&&e.data&&e.data.guid&&!e.data.isArea&&!e.data.isTextArt&&!e.data.isTextOnPath){var n=this.findDesignItemByGuid(e.data.guid);if(n&&"Vector"!=n.get("imageType")){i.bounds;var a=this.getAreaScaleFactor(t);if(a){var r=this.isMaskedImage(e),o=i.size.width*(r?i.scaling.x:1)*e.scaling.x,s=i.size.height*(r?i.scaling.y:1)*e.scaling.y,l=o*a.width,h=s*a.height;if(l>n.get("imageWidth")+.1*n.get("imageWidth")||h>n.get("imageHeight")+.1*n.get("imageHeight"))return!1}}}return!0},getAreaScaleFactor:function(e){var t=new this.paper.Size(1,1),i=this.getSelectedPrintType(e);(!i||i.get("dpi")<=0)&&(i=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(e)));var n=this.getScaledAreaPixelSize(e,i);return n&&(t.width=n.width/e.get("boundsWidth"),t.height=n.height/e.get("boundsHeight")),t},getSelectedPrintType:function(e){var t=this.design.getSelectedPrintTypeForArea(e),i=null;if(e){var n=e.getSideID(),a=e.getColorID(),r=this.getCurrentModel();r&&n>0&&a>0&&(i=r.get("colors").getColor(a).get("sides").getSide(n).get("printTypes").getPrintType(t)||r.get("printTypes").getPrintType(t))}return i},getModelPrintType:function(e){var t=null,i=this.getCurrentModel();return i&&this.design&&this.design instanceof MPlaza.Design&&i.get("printTypes")instanceof MPlaza.PrintTypes&&(t=i.get("printTypes").getPrintType(e)),t},getScaledAreaPixelSize:function(e,t){var i=new this.paper.Size(0,0),n=null;if(e instanceof MPlaza.Area&&(n=e.getParentModel()),n&&n.get("ppcm")>0){var a=e.get("boundsWidth")/n.get("ppcm"),r=e.get("boundsHeight")/n.get("ppcm");if((!t||t.get("dpi")<=0)&&e.get("screenPPI")>0){var o=a/(e.get("boundsWidth")/e.get("screenPPI")*2.54),s=r/(e.get("boundsHeight")/e.get("screenPPI")*2.54);i.width=Math.round(o*e.get("boundsWidth")),i.height=Math.round(s*e.get("boundsHeight"))}else if(t){var l=t.get("dpi")||t.get("printTypeDPI");"PrintfulPrintType"==t.get("name")&&l>120&&(l*=.75);var h=.3937*a*l,d=.3937*r*l;i.width=Math.round(h),i.height=Math.round(d)}}return i},cloneSelectedItems:function(){var e=this.getLastUndoOperationId();this.beginDesignOperation();for(var t=this.getSelectedItems(),i=[],n=0;n<t.length;n++){var a=t[n];if((!this.getMaskedImageRasterItem(a)||this.canAddImage())&&((!(a instanceof this.paper.PointText)||this.canAddText())&&(!a.data||!a.data.isTextOnPath&&!a.data.isTextArea||this.canAddText())&&(!a.data||!a.data.isTextArt||this.canAddTextArt()))){var r=this.findDesignItemForItem(a);if(r&&(!a.data||!a.data.isTextArt||r.get("textArt"))){var o=a.clone();o.data.guid=void 0,a.data&&a.data.isTextOnPath&&a.data.points&&(o.data.points=[a.data.points[0].clone(),a.data.points[1].clone(),a.data.points[2].clone()]),a.data&&a.data.isTextArea&&a.data.rect&&(o.data.rect=a.data.rect.clone()),a.data&&a.data.originalBounds&&(o.data.originaBounds=a.data.originalBounds.clone()),a.data&&a.data.originalMatrix&&(o.data.originalMatrix=a.data.originalMatrix.clone()),a.data&&a.data.originalPosition&&(o.data.originalPosition=a.data.originalPosition.clone());var s=new this.paper.Point(25,25);if(o.position.x+=s.x,o.position.y+=s.y,o.data.originalPosition){var l=(new this.paper.Matrix).translate(s.x,s.y);o.data.originalPosition=o.data.originalPosition.transform(l)}o.data.needsTransformsDataUpdate=!0,this.onTextOnPathMoved(o,s),this.onTextAreaMoved(o,s),i.push(o);var h=null;if(a.data&&a.data.isTextArt){var d=r.get("textArt"),c={fontFamilyID:d.get("fontFamilyID"),fontFaceID:d.get("fontFaceID"),text:d.get("text"),textArtTypeID:d.get("textArtTypeID"),style:null,config:d.get("config").toJSON()};h=this.onTextArtItemCreated(o,c)}else if(this.isImage(a)){var u=this.createDummyImageFromDesignItem(r);h=this.onItemCreated(o,u)}else if(this.isMaskedImage(a)&&!this.isFilledShape(a)){u=this.createDummyImageFromDesignItem(r);var g=this.createDummyShapeFromDesignItem(r);h=this.onItemCreated(o,u),this.onImageItemUpdated(o,u,g)}else if(this.isShape(a)){var f={isImagePlaceholder:a.data.isImagePlaceholder,style:this.getShapeItemStyle(a)},p=this.createDummyShapeFromDesignItem(r);h=this.onShapeItemCreated(o,p,f)}else if(this.isFilledShape(a)){u=this.createDummyImageFromDesignItem(r),g=this.createDummyShapeFromDesignItem(r),f={isImagePlaceholder:a.data.isImagePlaceholder,style:this.getShapeItemStyle(a)};h=this.onShapeItemCreated(o,g,f),this.onShapeItemUpdated(o,g,u)}else a.data&&(a.data.isTextArea||a.data.isTextOnPath)&&(h=this.onItemCreated(o));if(h&&(h.copyConstraints(r.get("constraints")),r.get("colors").each(function(e){h.changeColor(e.get("imageID"),e.get("colorID"),e.get("colorCode"))}),h.unset("colorMappings"),h.set("colorMappings",new MPlaza.ColorMappings),r.get("colorMappings")))for(n=0;n<r.get("colorMappings").length;n++){var m=new MPlaza.ColorMapping;m.copyAttributes(r.get("colorMappings").at(n)),h.get("colorMappings").add(m)}}}}this.deselectAll(),this.selectItems(i),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(e)},mirrorSelectedItems:function(e){var t=this.getLastUndoOperationId();this.beginDesignOperation();for(var i=this.getSelectedItems(),n=0;n<i.length;n++){var a=i[n];a.data.needsTransformsDataUpdate=!0;var r,o=null,s=null;if(this.isShape||this.isFilledShape(a))(r=this.isShape(a)?a:this.getMaskedImageShapeItem(a))&&r.data.originalMatrix&&r.data.originalPosition&&(o=r.data.originalPosition.clone(),s=r.data.originalMatrix.clone());if("X"==e){a.scale(-1,-1);var l=(new this.paper.Matrix).scale(-1,-1);a.data&&a.data.originalMatrix&&a.data.originalMatrix.prepend(l),a.data&&a.data.originalPosition&&(a.data.originalPosition=a.data.originalPosition.transform(l)),this.onTextOnPathScaled(a,-1,-1,a.bounds.center),this.onTextAreaScaled(a,-1,-1,a.bounds.center)}else{a.scale(1,-1);l=(new this.paper.Matrix).scale(1,-1);a.data&&a.data.originalMatrix&&a.data.originalMatrix.prepend(l),a.data&&a.data.originalPosition&&(a.data.originalPosition=a.data.originalPosition.transform(l)),this.onTextOnPathScaled(a,1,-1,a.bounds.center),this.onTextAreaScaled(a,1,-1,a.bounds.center)}if((this.isShape||this.isFilledShape(a))&&s&&o)(r=this.isShape(a)?a:this.getMaskedImageShapeItem(a))&&r.data.originalMatrix&&r.data.originalPosition&&(this.applyTransformationsToMaskImageSubItems(a),r.data.originalPosition=o,r.data.originalMatrix=s,r.data.flips||(r.data.flips=[]),r.data.flips.push(e))}this.updateTextOnPathGuides(i),this.updateTextAreaGuides(i),this.onItemsUpdated(i),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(t)},createDummyImageFromDesignItem:function(e){var t=new MPlaza.Image;return t.set("imageID",e.get("imageID")),t.set("type",e.get("imageType")),t.set("format",e.get("imageFormat")),t.set("width",e.get("imageWidth")),t.set("height",e.get("imageHeight")),t.set("dpiX",e.get("imageDpiX")),t.set("dpiY",e.get("imageDpiY")),t.set("imageFileSize",e.get("imageFileSize")),t.set("providerImageID",e.get("providerImageID")),t.set("userID",e.get("imageUserID")),t.set("visitorID",e.get("imageVisitorID")),t.set("visitorCode",e.get("imageVisitorCode")),t.set("customerID",e.get("imageCustomerID")),t.set("customerCode",e.get("imageCustomerCode")),t.set("price",e.get("imagePrice")),t.set("preferredWidth",e.get("imagePreferredHeight")),t.set("preferredHeight",e.get("imagePreferredHeight")),t},createDummyShapeFromDesignItem:function(e){var t=new MPlaza.Shape;return e.get("shape")&&t.set("shapeID",e.get("shape").get("shapeID")),t},canAddText:function(){if(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design){var e=this.design.getDesignSide(this.side),t=e?e.get("canAddText"):this.design.get("canAddText");if(null!=t&&null!=t&&"boolean"==typeof t&&!t&&!this.design.get("isTemplate"))return!1;var i=this.side.get("areas").at(0),n=this.getSelectedPrintType(i),a=(e?e.get("maxNrTexts"):this.design.get("maxNrTexts"))||(n&&this.model.get("printTypes").get(n.id).get("printTypeRestrictions")?this.model.get("printTypes").get(n.id).get("printTypeRestrictions").get("maxNrTextElements"):null);if(null!=a&&null!=a&&"number"==typeof a)if((e?this.design.countTextItemsForSide(this.side.getModelID(),this.side.getColorID(),this.side.getSideID()):this.design.countTextItemsForColor(this.side.getModelID(),this.side.getColorID()))>=a)return!1}return!0},canAddImage:function(){if(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design){var e=this.design.getDesignSide(this.side),t=e?e.get("canAddImage"):this.design.get("canAddImage");if(null!=t&&null!=t&&"boolean"==typeof t&&!t&&!this.design.get("isTemplate"))return!1;var i=this.side.get("areas").at(0),n=this.getSelectedPrintType(i),a=(e?e.get("maxNrImages"):this.design.get("maxNrImages"))||(n&&this.model.get("printTypes").get(n.id).get("printTypeRestrictions")?this.model.get("printTypes").get(n.id).get("printTypeRestrictions").get("maxNrImages"):null);if(null!=a&&null!=a&&"number"==typeof a)if((e?this.design.countImageItemsForSide(this.side.getModelID(),this.side.getColorID(),this.side.getSideID()):this.design.countImageItemsForColor(this.side.getModelID(),this.side.getColorID()))>=a)return!1}return!0},canMaskImages:function(){if(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design){if(this.design.get("templateDesignID")<=0)return!0;var e=this.design.getDesignSide(this.side),t=e?e.get("canMaskImages"):this.design.get("canMaskImages");if(null!=t&&null!=t&&"boolean"==typeof t&&!t)return!1}return!0},canAddTextArt:function(){return this.canAddText()},canAddShape:function(){if(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design){if(this.design.get("templateDesignID")<=0)return!0;var e=this.design.getDesignSide(this.side),t=e?e.get("canAddShape"):this.design.get("canAddShape");if(null!=t&&null!=t&&"boolean"==typeof t&&!t)return!1;var i=e?e.get("maxNrShapes"):this.design.get("maxNrShapes");if(null!=i&&null!=i&&"number"==typeof i)if((e?this.design.countShapeItemsForSide(this.side.getModelID(),this.side.getColorID(),this.side.getSideID()):this.design.countShapeItemsForColor(this.side.getModelID(),this.side.getColorID()))>=i)return!1}return!0},canMoveSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(this.isMaskedImage(i)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element)if(this.isFilledShape(i)){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditShapeFilling(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditFilledShape(i))return!1}else{if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditMask(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditMaskedImage(i))return!1}else if(!this.canMoveItem(i))return!1}return!0},canRotateSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(this.isMaskedImage(i)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element)if(this.isFilledShape(i)){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditShapeFilling(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditFilledShape(i))return!1}else{if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditMask(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditMaskedImage(i))return!1}else if(!this.canRotateItem(i))return!1}return!0},canDeleteSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(this.isMaskedImage(i)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element)if(this.isFilledShape(i)){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canDeleteShapeFilling(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask)return!1}else{if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canDeleteMask(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster)return!1}else if(!this.canDeleteItem(i))return!1}return!0},canResizeSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(this.isMaskedImage(i)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element)if(this.isFilledShape(i)){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditShapeFilling(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditFilledShape(i))return!1}else{if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditMask(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditMaskedImage(i))return!1}else{if(i.data.isTextBox&&i.data.adaptText)return!1;if(!this.canResizeItem(i)||i.data&&i.data.isImageForBackground)return!1}var n=this.side.get("areas").at(0),a=this.getSelectedPrintType(n);if(a&&this.model.get("printTypes").get(a.id).get("printTypeRestrictions")&&!1===this.model.get("printTypes").get(a.id).get("printTypeRestrictions").get("allowChangeFontSize")&&!this.design.get("isTemplate")&&(this.getItemIsTextArea(i)||this.getItemIsTextOnPath(i)))return!1}return!0},canEditSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canEditItem(i)||i.data&&i.data.isImageForBackground)return!1}return!0},canChangeSelectionFontFamily:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontFamily(i))return!1}return!0},canChangeSelectionFontSize:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontSize(i))return!1}return!0},canChangeSelectionFontColor:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontColor(i))return!1}return!0},canChangeSelectionFontWeight:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontWeight(i))return!1}return!0},canChangeSelectionFontItalic:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontItalic(i))return!1}return!0},canChangeSelectionTextPathMode:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemTextPathMode(i))return!1}return!0},canChangeSelectionJustification:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemJustification(i))return!1}return!0},canChangeSelectionShadowColor:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemShadowColor(i))return!1}return!0},canChangeSelectionShadowBlur:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemShadowBlur(i))return!1}return!0},canChangeSelectionShadowDistance:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemShadowDistance(i))return!1}return!0},canChangeSelectionShadowAngle:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemShadowAngle(i))return!1}return!0},canResizeTextBoxSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canResizeTextBoxItem(i))return!1}return!0},getItemConstraints:function(e,t){if(this.design&&!(this.design.get("templateDesignID")<=0)||t){var i=e instanceof MPlaza.DesignItem?e:this.findDesignItemForItem(e);return i?i.get("constraints"):null}},getItemConstraintsProperty:function(e,t,i,n){void 0===i&&(i=!0),void 0===n&&(n=!1);var a=this.getItemConstraints(e,n);return a?a.get(t):i},canMoveItem:function(e){return this.getItemConstraintsProperty(e,"canMove")},canRotateItem:function(e){return this.getItemConstraintsProperty(e,"canRotate")},canDeleteItem:function(e){return this.getItemConstraintsProperty(e,"canDelete")},canResizeItem:function(e){return this.getItemConstraintsProperty(e,"canResize")},canStretchItem:function(e){return this.getItemConstraintsProperty(e,"canStretch")},canEditItem:function(e){return this.getItemConstraintsProperty(e,"canEdit")},canChangeItemFontFamily:function(e){return this.getItemConstraintsProperty(e,"canChangeFontFamily")},canChangeItemFontSize:function(e){var t=this.getItemConstraintsProperty(e,"canChangeFontSize");if(t){var i=this.getItemMinFontSize(e),n=this.getItemMaxFontSize(e);null!=i&&null!=i&&null!=n&&null!=n&&(t=i!=n)}return t},getItemMinFontSize:function(e){if(this.side){var t=this.getItemConstraints(e,!1);if(t)return t.get("minFontSize");var i=this.side.get("areas").at(0),n=this.model.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(i));return n&&n.get("printTypeRestrictions")&&n.get("printTypeRestrictions").get("minFontSize")?n.get("printTypeRestrictions").get("minFontSize"):void 0}},getDefaultFontSize:function(){if(!this.side)return null;var e=this.side.get("areas").at(0),t=this.design.getSelectedPrintTypeForArea(e),i=this.model.get("printTypes").getPrintType(t);return i&&i.get("printTypeRestrictions")&&i.get("printTypeRestrictions").get("defaultFontSize")?i.get("printTypeRestrictions").get("defaultFontSize"):null},getFontSizeList:function(){if(!this.side)return null;var e=this.model.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(this.side.get("areas").at(0)));return e&&e.get("printTypeRestrictions")&&e.get("printTypeRestrictions").get("fontSizeList")?e.get("printTypeRestrictions").get("fontSizeList"):[]},getItemMaxFontSize:function(e){if(this.side){var t=this.getItemConstraints(e,!1);if(t)return t.get("maxFontSize");var i=this.side.get("areas").at(0),n=this.model.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(i));return n&&n.get("printTypeRestrictions")&&n.get("printTypeRestrictions").get("maxFontSize")?n.get("printTypeRestrictions").get("maxFontSize"):void 0}},canChangeTextStrokeColor:function(e){return this.getItemConstraintsProperty(e,"canChangeTextStrokeColor")},canChangeTextStrokeWidth:function(e){return this.getItemConstraintsProperty(e,"canChangeTextStrokeWidth")},canChangeItemFontColor:function(e){return this.getItemConstraintsProperty(e,"canChangeFontColor")},canChangeItemFontWeight:function(e){return this.getItemConstraintsProperty(e,"canChangeFontWeight")},canChangeItemFontItalic:function(e){return this.getItemConstraintsProperty(e,"canChangeFontItalic")},canChangeItemTextPathMode:function(e){return this.getItemConstraintsProperty(e,"canChangeTextPathMode")},canChangeItemTextAreaMode:function(e){return this.canEditItem(e)},canChangeItemAdaptText:function(e){return this.getItemConstraintsProperty(e,"canChangeAdaptText")},canWrapTextOnAdaptText:function(e){return this.getItemConstraintsProperty(e,"canWrapTextOnAdaptText",!0,!0)},canChangeItemLetterSpacing:function(e){return this.getItemConstraintsProperty(e,"canChangeLetterSpacing")},canChangeItemLineSpacing:function(e){return this.getItemConstraintsProperty(e,"canChangeLineSpacing")},canChangeItemShadowColor:function(e){return this.getItemConstraintsProperty(e,"canChangeShadowColor")},canChangeItemShadowBlur:function(e){return this.getItemConstraintsProperty(e,"canChangeShadowBlur")},canChangeItemShadowDistance:function(e){return this.getItemConstraintsProperty(e,"canChangeShadowDistance")},canChangeItemShadowAngle:function(e){return this.getItemConstraintsProperty(e,"canChangeShadowAngle")},getItemIsTextOnPath:function(e){return e&&e.data&&e.data.isTextOnPath},getItemIsTextArea:function(e){return e&&e.data&&e.data.isTextArea},getItemIsTextArt:function(e){return e&&e.data&&e.data.isTextArt},getItemIsTextElement:function(e){return e&&e.data&&(e.data.isText||e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)},isRaster:function(e){return"svg"!=e.get("imageFormat").toLowerCase()},canChangeItemJustification:function(e){return this.getItemConstraintsProperty(e,"canChangeJustification")},canChangeItemVerticalAlignment:function(e){return this.getItemConstraintsProperty(e,"canChangeVerticalAlignment")},canTransform:function(e){return this.getItemConstraintsProperty(e,"canTransform")},canChangeSvgColors:function(e){return this.getItemConstraintsProperty(e,"canChangeSvgColors")},canResizeTextBoxItem:function(e){return this.getItemConstraintsProperty(e,"canResizeTextBox")},canChangeItemTextBoxMode:function(e){return this.getItemConstraintsProperty(e,"canChangeTextBoxMode")},toUppercaseOption:function(e){return this.getItemConstraintsProperty(e,"toUppercase",!1,!0)},isAlwaysOnTop:function(e){var t=this.findDesignItemForItem(e);if(!t)return!1;var i=t.get("constraints");return i&&i.get("isAlwaysOnTop")||!1},isItemPrintable:function(e){return this.getItemConstraintsProperty(e,"isPrintable")},isItemStatic:function(e){var t=!(this.canEditItem(e)||this.canMoveItem(e)||this.canRotateItem(e)||this.canResizeItem(e)||this.canDeleteItem(e)||this.canTransform(e));if(this.getMaskedImageRasterItem(e)){var i=this.findDesignItemForItem(e);if(!i)return!1;"Vector"==i.get("imageType")&&(t=t&&!this.canChangeSvgColors(e))}return(e instanceof this.paper.PointText||e&&e.data&&(e.data.isTextOnPath||e.data.isTextArea))&&(t=t&&!(this.canChangeTextStrokeColor(e)||this.canChangeTextStrokeWidth(e)||this.canChangeItemFontFamily(e)||this.canChangeItemFontColor(e)||this.canChangeItemFontWeight(e)||this.canChangeItemTextPathMode(e))),t},itemCanBeTransformed:function(e){return this.canMoveItem(e)||this.canRotateItem(e)||this.canResizeItem(e)||this.canDeleteItem(e)||this.canTransform(e)},isMandatoryToEdit:function(e){return this.getItemConstraintsProperty(e,"mandatoryToEdit")},canAddMask:function(e){return this.getItemConstraintsProperty(e,"canAddMask")},canReplaceMask:function(e){return this.getItemConstraintsProperty(e,"canReplaceMask")},canEditMask:function(e){return this.getItemConstraintsProperty(e,"canEditMask")},canDeleteMask:function(e){return this.getItemConstraintsProperty(e,"canDeleteMask")},canEditMaskedImage:function(e){return this.getItemConstraintsProperty(e,"canEditMaskedImage")},canChangeMaskStrokeColor:function(e){return this.getItemConstraintsProperty(e,"canChangeMaskStrokeColor")},canChangeMaskStrokeWidth:function(e){return this.getItemConstraintsProperty(e,"canChangeMaskStrokeWidth")},canFillShape:function(e){return this.getItemConstraintsProperty(e,"canFillShape")},canReplaceShapeFilling:function(e){return this.getItemConstraintsProperty(e,"canReplaceShapeFilling")},canEditShapeFilling:function(e){return this.getItemConstraintsProperty(e,"canEditShapeFilling")},canDeleteShapeFilling:function(e){return this.getItemConstraintsProperty(e,"canDeleteShapeFilling")},canEditFilledShape:function(e){return this.getItemConstraintsProperty(e,"canEditFilledShape")},canChangeShapeStrokeColor:function(e){return this.getItemConstraintsProperty(e,"canChangeShapeStrokeColor")},canChangeShapeStrokeWidth:function(e){return this.getItemConstraintsProperty(e,"canChangeShapeStrokeWidth")},canChangeShapeFillColor:function(e){return this.getItemConstraintsProperty(e,"canChangeShapeFillColor")},allowTextStroke:function(){return this.getPrintTypeConstraintsProperty("allowTextStroke",!1)},getMinTextStrokeWidth:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("minTextStrokeWidth")&&null!=t.get("minTextStrokeWidth")?t.get("minTextStrokeWidth"):this.getPrintTypeConstraintsProperty("minTextStrokeWidth",null)||0},getMaxTextStrokeWidth:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("maxTextStrokeWidth")&&null!=t.get("maxTextStrokeWidth")?t.get("maxTextStrokeWidth"):this.getPrintTypeConstraintsProperty("maxTextStrokeWidth",null)},adjustInputTextStrokeWidth:function(e,t){var i=this.getMinTextStrokeWidth(e),n=this.getMaxTextStrokeWidth(e);return null!=i&&null!=i&&t<i&&(t=i),null!=n&&null!=n&&t>n&&(t=n),t},allowShadows:function(){return this.getPrintTypeConstraintsProperty("allowShadows",!1)},allowStroke:function(){return this.getPrintTypeConstraintsProperty("allowStroke",!1)},getMinShadowBlur:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("minShadowBlur")&&null!=t.get("minShadowBlur")?t.get("minShadowBlur"):this.getPrintTypeConstraintsProperty("minShadowBlur",null)||0},getMaxShadowBlur:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("maxShadowBlur")&&null!=t.get("maxShadowBlur")?t.get("maxShadowBlur"):this.getPrintTypeConstraintsProperty("maxShadowBlur",null)},adjustInputShadowBlur:function(e,t){var i=this.getMinShadowBlur(e),n=this.getMaxShadowBlur(e);return null!=i&&null!=i&&t<i&&(t=i),null!=n&&null!=n&&t>n&&(t=n),t},getMinShadowDistance:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("minShadowDistance")&&null!=t.get("minShadowDistance")?t.get("minShadowDistance"):this.getPrintTypeConstraintsProperty("minShadowDistance",null)||0},getMaxShadowDistance:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("maxShadowDistance")&&null!=t.get("maxShadowDistance")?t.get("maxShadowDistance"):this.getPrintTypeConstraintsProperty("maxShadowDistance",null)},adjustInputShadowDistance:function(e,t){var i=this.getMinShadowDistance(e),n=this.getMaxShadowDistance(e);return null!=i&&null!=i&&t<i&&(t=i),null!=n&&null!=n&&t>n&&(t=n),t},getMinShadowAngle:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("minShadowAngle")&&null!=t.get("minShadowAngle")?t.get("minShadowAngle"):this.getPrintTypeConstraintsProperty("minShadowAngle",null)||0},getMaxShadowAngle:function(e){var t=this.getItemConstraints(e);if(t&&null!=t.get("maxShadowAngle")&&null!=t.get("maxShadowAngle"))return t.get("maxShadowAngle");var i=this.getPrintTypeConstraintsProperty("maxShadowAngle",null);return null!=i&&null!=i?Math.min(Math.max(0,i),359):359},adjustInputShadowAngle:function(e,t){var i=this.getMinShadowAngle(e)||0,n=this.getMaxShadowAngle(e)||359;return Math.min(Math.max(i,t),n)},canStretchImages:function(){return this.getPrintTypeConstraintsProperty("canStretchImages",!1)},canStretchTexts:function(){return this.getPrintTypeConstraintsProperty("canStretchTexts",!1)},getPrintTypeConstraints:function(){if(this.side&&this.side.get("areas").length>0&&this.model){var e=this.side.get("areas").at(0),t=this.getSelectedPrintType(e);if(t)return this.model.get("printTypes").get(t.id).get("printTypeRestrictions")}return null},getPrintTypeConstraintsProperty:function(e,t){var i=this.getPrintTypeConstraints();return i?i.get(e):t},findItemById:function(e){if(-1==e)return null;function t(i){if(i.id==e)return i;if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=t(i.children[n]);if(null!=a)return a}return null}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=t(this.paper.project.layers[i]);if(null!=a)return a}return null},findItemByName:function(e){if(!e)return null;function t(i){if(i.name===e)return i;if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=t(i.children[n]);if(null!=a)return a}return null}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=t(this.paper.project.layers[i]);if(null!=a)return a}return null},clearSelectionBounds:function(){this.selectionBoundsShape&&this.selectionBoundsShape.remove(),this.selectionMaskMoveImage&&this.selectionMaskMoveImage.remove(),this.selectionMaskMoveShape&&this.selectionMaskMoveShape.remove(),this.selectionMoveHandle&&this.selectionMoveHandle.remove(),this.selectionRotateHandle&&this.selectionRotateHandle.remove(),this.selectionResizeHandle&&this.selectionResizeHandle.remove(),this.selectionDeleteHandle&&this.selectionDeleteHandle.remove(),this.selectionResizeTopHandle&&this.selectionResizeTopHandle.remove(),this.selectionResizeBottomHandle&&this.selectionResizeBottomHandle.remove(),this.selectionResizeLeftHandle&&this.selectionResizeLeftHandle.remove(),this.selectionResizeRightHandle&&this.selectionResizeRightHandle.remove(),this.selectionBoundsShape=null,this.selectionBounds=null,this.selectionMoveHandle=null,this.selectionRotateHandle=null,this.selectionResizeHandle=null,this.selectionDeleteHandle=null,this.selectionMaskMoveImage=null,this.selectionMaskMoveShape=null,this.selectionResizeTopHandle=null,this.selectionResizeBottomHandle=null,this.selectionResizeLeftHandle=null,this.selectionResizeRightHandle=null},showSelectionBounds:function(){this.drawSelectionBounds++,this.drawSelectionBounds>0&&(this.selectionBoundsShape&&(this.selectionBoundsShape.visible=!0),this.selectionMoveHandle&&(this.selectionMoveHandle.visible=!0),this.selectionRotateHandle&&(this.selectionRotateHandle.visible=!0),this.selectionResizeHandle&&(this.selectionResizeHandle.visible=!0),this.selectionDeleteHandle&&(this.selectionDeleteHandle.visible=!0),this.selectionMaskMoveImage&&(this.selectionMaskMoveImage.visible=!0),this.selectionMaskMoveShape&&(this.selectionMaskMoveShape.visible=!0),this.selectionResizeTopHandle&&(this.selectionResizeTopHandle.visible=!0),this.selectionResizeBottomHandle&&(this.selectionResizeBottomHandle.visible=!0),this.selectionResizeLeftHandle&&(this.selectionResizeLeftHandle.visible=!0),this.selectionResizeRightHandle&&(this.selectionResizeRightHandle.visible=!0))},hideSelectionBounds:function(){this.drawSelectionBounds>0&&this.drawSelectionBounds--,0==this.drawSelectionBounds&&(this.selectionBoundsShape&&(this.selectionBoundsShape.visible=!1),this.selectionMoveHandle&&(this.selectionMoveHandle.visible=!1),this.selectionRotateHandle&&(this.selectionRotateHandle.visible=!1),this.selectionResizeHandle&&(this.selectionResizeHandle.visible=!1),this.selectionDeleteHandle&&(this.selectionDeleteHandle.visible=!1),this.selectionMaskMoveImage&&(this.selectionMaskMoveImage.visible=!1),this.selectionMaskMoveShape&&(this.selectionMaskMoveShape.visible=!1),this.selectionResizeTopHandle&&(this.selectionResizeTopHandle.visible=!1),this.selectionResizeBottomHandle&&(this.selectionResizeBottomHandle.visible=!1),this.selectionResizeLeftHandle&&(this.selectionResizeLeftHandle.visible=!1),this.selectionResizeRightHandle&&(this.selectionResizeRightHandle.visible=!1))},updateSelectionState:function(){if(!this.isViewer){if(this.clearSelectionBounds(),this.updateMaskedImageGuides(),this.selectionBounds=this.getSelectionBounds(),null!=this.selectionBounds){var e=new this.paper.Path.Rectangle(this.selectionBounds);e.strokeColor=this.getContrastedColor(this.selectionBounds),e.strokeWidth=1/this.paper.view.zoom,e.dashOffset=.5/this.paper.view.zoom,e.dashArray=[1/this.paper.view.zoom,1/this.paper.view.zoom],e.guide=!0,e.visible=this.drawSelectionBounds>0,this.selectionBoundsShape=e,this.createSelectionHandles()}this.updateTextOnPathGuides(),this.updateTextAreaGuides()}},moveSelectionShapes:function(e){this.selectionBoundsShape&&(this.selectionBoundsShape.position.x+=e.x,this.selectionBoundsShape.position.y+=e.y,this.selectionMoveHandle&&(this.selectionMoveHandle.position.x+=e.x,this.selectionMoveHandle.position.y+=e.y),this.selectionRotateHandle&&(this.selectionRotateHandle.position.x+=e.x,this.selectionRotateHandle.position.y+=e.y),this.selectionResizeHandle&&(this.selectionResizeHandle.position.x+=e.x,this.selectionResizeHandle.position.y+=e.y),this.selectionDeleteHandle&&(this.selectionDeleteHandle.position.x+=e.x,this.selectionDeleteHandle.position.y+=e.y),this.selectionMaskMoveShape&&(this.selectionMaskMoveShape.position.x+=e.x,this.selectionMaskMoveShape.position.y+=e.y),this.selectionMaskMoveImage&&(this.selectionMaskMoveImage.position.x+=e.x,this.selectionMaskMoveImage.position.y+=e.y),this.selectionResizeTopHandle&&(this.selectionResizeTopHandle.position.x+=e.x,this.selectionResizeTopHandle.position.y+=e.y),this.selectionResizeBottomHandle&&(this.selectionResizeBottomHandle.position.x+=e.x,this.selectionResizeBottomHandle.position.y+=e.y),this.selectionResizeLeftHandle&&(this.selectionResizeLeftHandle.position.x+=e.x,this.selectionResizeLeftHandle.position.y+=e.y),this.selectionResizeRightHandle&&(this.selectionResizeRightHandle.position.x+=e.x,this.selectionResizeRightHandle.position.y+=e.y),this.selectionBounds=this.selectionBoundsShape.bounds)},scaleSelectionShapes:function(e,t,i){this.selectionBoundsShape&&(this.selectionBoundsShape.scale(e,t,i),this.selectionBounds=this.selectionBoundsShape.bounds,this.placeHandleOut(this.selectionBoundsShape))},createSelectionHandles:function(){if(this.selectionMoveHandle&&this.selectionMoveHandle.remove(),this.selectionRotateHandle&&this.selectionRotateHandle.remove(),this.selectionResizeHandle&&this.selectionResizeHandle.remove(),this.selectionDeleteHandle&&this.selectionDeleteHandle.remove(),this.selectionMaskMoveShape&&this.selectionMaskMoveShape.remove(),this.selectionMaskMoveImage&&this.selectionMaskMoveImage.remove(),this.selectionResizeTopHandle&&this.selectionResizeTopHandle.remove(),this.selectionResizeBottomHandle&&this.selectionResizeBottomHandle.remove(),this.selectionResizeLeftHandle&&this.selectionResizeLeftHandle.remove(),this.selectionResizeRightHandle&&this.selectionResizeRightHandle.remove(),this.selectionBoundsShape){var e=this.selectionBoundsShape.segments;if(4==e.length){var t=e[0].point,i=e[1].point,n=e[2].point,a=e[3].point,r=i.add(n.subtract(i).divide(2)),o=t.add(a.subtract(t).divide(2)),s=t.add(i.subtract(t).divide(2)),l=a.add(n.subtract(a).divide(2)),h=this.getSelectedItems(),d=h.length>0&&(this.getItemIsTextArea(h[0])||this.getItemIsTextOnPath(h[0]));if(this.showSelectedElementDimensions&&this.createDimensionLabel(r,a),this.showTotalSizeOfCurrentSide&&this.createPrintAreaTotalDimensionLabel(r,a),this.showUnselectedElementsDimensions&&this.createUnselectedDimensionLabel(),this.canMoveSelection()&&(this.selectionMoveHandle=this.createSelectionHandle("move",i)),this.canRotateSelection()&&(this.selectionRotateHandle=this.createSelectionHandle("rotate",n)),this.canDeleteSelection()&&(this.selectionDeleteHandle=this.createSelectionHandle("remove",t)),this.canResizeSelection()&&(!d||!this.isFixedFontListEnabled())){var c=this.getCurrentModel();if(c&&this.design&&this.design instanceof MPlaza.Design&&c.get("printTypes")instanceof MPlaza.PrintTypes&&h.length>0&&this.side&&this.side.get("areas").length>0){var u=h[0],g=this.selectedDesignItem;if(!this.isImagesFixedSizeEnabled()||g&&!g.get("imagePreferredWidth")&&!g.get("imagePreferredHeight")){this.isMobile&&(!u.data||u.data.isTextArea||u.data.isTextOnPath)||(this.selectionResizeHandle=this.createSelectionHandle("resize",a));var f=this.isMaskedImage(u)&&this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster||this.isMaskedImageRasterItem(u)||this.isImage(u),p=this.canStretchItem(u),m=this.canStretchImages(),v=f&&m&&p,I=u.data.isTextArea&&!u.data.isTextOnPath&&!u.data.isTextBox,y=this.canStretchTexts(),C=I&&y&&p;(u.data&&u.data.isTextArt||this.isMaskedImage(u)&&this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask||u.data&&u.data.isShape||v||C)&&(this.selectionResizeTopHandle=this.createLateralSelectionHandle("top",r),this.selectionResizeBottomHandle=this.createLateralSelectionHandle("bottom",o),this.selectionResizeLeftHandle=this.createLateralSelectionHandle("left",s),this.selectionResizeRightHandle=this.createLateralSelectionHandle("right",l))}}}var M=this.getSelectedItem();if(M&&this.isMaskedImage(M)){var x=!(this.canMoveItem(M)||this.canRotateItem(M)||this.canResizeItem(M));!this.isFilledShape(M)&&this.canEditMask(M)&&(this.selectionMaskMoveShape=this.createSelectionHandle("maskMoveShape",l)),this.isFilledShape(M)&&!x&&(this.selectionMaskMoveShape=this.createSelectionHandle("maskMoveShape",l));var S=this.canMoveSelection(),b=this.canRotateSelection(),w=this.canDeleteSelection(),A=this.canResizeSelection(),P=this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster,D=S||b||w||A;this.canEditMaskedImage(M)&&(D&&!P?M.data.isNewImageIntoShape?(M.data.isNewImageIntoShape=!1,this.editImageShapeSelected()):this.selectionMaskMoveImage=this.createSelectionHandle("maskMoveImage",l):this.editImageShapeSelected())}this.placeHandleOut(this.selectionBoundsShape)}}},editImageShapeSelected:function(){this.applyTransformationsToMaskImageSubItems(),this.maskedImageSelectionMode=MaskedImageSelectionMode.Raster,this.updateMaskedImageGuides()},resetAllDimensionLabels:function(){this.isConfigurator||this.isViewer||(this.selectedItemDimensionLabel&&this.selectedItemDimensionLabel.remove(),this.printAreaLabel&&this.printAreaLabel.remove(),this.labelLayer&&(this.labelLayer.remove(),this.selectedItemDimensionLabel=null,this.printAreaLabel=null,this.labelLayer=null),this.dimensionLabelList&&(this.dimensionLabelList.map(function(e){return e.remove(),!1}),this.dimensionLabelList=null,this.unselectedLabelsGroup.remove(),this.unselectedLabelsGroup=null),this.isResizableMode&&this.hideAreaLabelResizableMode())},createUnselectedDimensionLabel:function(){var e=this,t=this.getSelectedItem();if(t)if(this.dimensionLabelList)this.updateUnselectedLabels();else{this.dimensionLabelList=[],this.unselectedLabelsGroup||(this.unselectedLabelsGroup=new this.paper.Group({name:"unselectedLabelsGroup",applyMatrix:!1,visible:!1}));var i=this.getAllItems(),n=this.side.get("ppcm"),a=this.unselectedLabelsGroup;0===this.dimensionLabelList.length&&this.labelLayer&&(this.labelLayer.addChild(a),i.forEach(function(i){if(i.data&&i.data.guid&&!i.data.isArea&&!e.dimensionLabelList["label-".concat(i.id)]&&i.id!==t.id){var r=i.data.transformsData?i.data.transformsData.dimensions.width:i.bounds.width,o=i.data.transformsData?i.data.transformsData.dimensions.height:i.bounds.height,s=new e.paper.Group({name:"label-".concat(i.id),id:"label-".concat(i.id),applyMatrix:!1});a.addChild(s);var l=i.bounds.topLeft,h=i.bounds.topRight,d=l.add(h.subtract(l).divide(2)),c=(r/n/("cm"===e.unitOfMeasurement?1:2.54)).toFixed(2),u=(o/n/("cm"===e.unitOfMeasurement?1:2.54)).toFixed(2);e.createLabel(d,s,"".concat(c).concat(e.unitOfMeasurement," x ").concat(u).concat(e.unitOfMeasurement)),s.position=d.add(new e.paper.Point(0,-22/e.paper.view.zoom));var g=(s.children[1].bounds.width+20)/s.children[0].bounds.width;s.children[0].scale(g,1),e.dimensionLabelList["label-".concat(i.id)]=s}})),a.visible=!0,this.updateUnselectedLabels()}},updateUnselectedLabels:function(){var e=this,t=this.getSelectedItem();if(t){if(!this.dimensionLabelList)return;var i=this.getAllItems(),n=this.side.get("ppcm");if(this.dimensionLabelList["label-".concat(t.id)]&&(this.dimensionLabelList["label-".concat(t.id)].remove(),delete this.dimensionLabelList["label-".concat(t.id)]),this.unselectedLabelsGroup){var a=this.unselectedLabelsGroup;i.forEach(function(i){if(i.data&&i.data.guid&&!i.data.isArea&&i.id!==t.id)if(e.dimensionLabelList["label-".concat(i.id)])e.resizeHandle(e.dimensionLabelList["label-".concat(i.id)],110);else{var r=i.data.transformsData?i.data.transformsData.dimensions.width:i.bounds.width,o=i.data.transformsData?i.data.transformsData.dimensions.height:i.bounds.height,s=new e.paper.Group({name:"label-".concat(i.id),id:"label-".concat(i.id),applyMatrix:!1});a.addChild(s);var l=i.bounds.topLeft,h=i.bounds.topRight,d=l.add(h.subtract(l).divide(2));d.y-=40;var c=(r/n/("cm"===e.unitOfMeasurement?1:2.54)).toFixed(2),u=(o/n/("cm"===e.unitOfMeasurement?1:2.54)).toFixed(2);e.createLabel(d,s,"".concat(c," x ").concat(u," ").concat(e.unitOfMeasurement));var g=(s.children[1].bounds.width+20)/s.children[0].bounds.width;s.children[0].scale(g,1),e.dimensionLabelList["label-".concat(i.id)]=s}})}}},deleteDimensionLabel:function(e){e&&this.dimensionLabelList&&this.dimensionLabelList["label-".concat(""+e)]&&(this.dimensionLabelList["label-".concat(""+e)].remove(),delete this.dimensionLabelList["label-".concat(""+e)])},isGridImage:function(){var e=this.getSelectedItem();return e&&e.data&&e.data.isGridImage},createDimensionLabel:function(e,t){if(this.labelLayer)this.updateLabelsPosition();else{var i=this.paper.project.activeLayer;this.labelLayer=new this.paper.Layer({name:"labels"}),i.activate(),this.labelLayer.visible=!1,this.labelLayer.bringToFront(),this.selectedItemDimensionLabel=new this.paper.Group({name:"widthLabelGroup"}),this.selectedItemDimensionLabel.applyMatrix=!1,this.labelLayer.addChild(this.selectedItemDimensionLabel),this.createLabel(e,this.selectedItemDimensionLabel,"".concat(0," x ").concat(0," ").concat(this.unitOfMeasurement)),this.updateLabelsPosition();var n=(this.selectedItemDimensionLabel.children[1].bounds.width+20)/this.selectedItemDimensionLabel.children[0].bounds.width;this.selectedItemDimensionLabel.children[0].scale(n,1)}},createPrintAreaTotalDimensionLabel:function(){var e;if(this.printAreaLabel)this.updatePrintAreaLabelText();else{if(!this.labelLayer){var t=this.paper.project.activeLayer;this.labelLayer=new this.paper.Layer({name:"labels"}),t.activate(),this.labelLayer.bringToFront()}this.printAreaLabel=new this.paper.Group({name:"heightLabelGroup"}),this.printAreaLabel.applyMatrix=!1,this.labelLayer.addChild(this.printAreaLabel);var i=this.side.get("ppcm");if(this.itemsLayer.children[0].children[1]){var n=null===(e=this.masterGroup)||void 0===e?void 0:e.children[0],a=(n.bounds.width/i/("cm"===this.unitOfMeasurement?1:2.54)).toFixed(2),r=(n.bounds.height/i/("cm"===this.unitOfMeasurement?1:2.54)).toFixed(2);this.createLabelPrintArea(n,this.printAreaLabel,"".concat(a," x ").concat(r," ").concat(this.unitOfMeasurement))}}},createLabelPrintArea:function(e,t,i){var n,a,r,o=new this.paper.Path.Rectangle(new this.paper.Rectangle(0,0,80,15),0);o.fillColor=new this.paper.Color("#ffffff"),o.strokeScaling=!1,o.strokeWidth=0,o.strokeColor=new this.paper.Color("#000000"),o.position=e.pointTop,o.position.y+=28,o.name="labelRectanglePrintArea-".concat(t.name),o.opacity=1;var s=new this.paper.PointText(e.pointTop);if(s.content=i,s.position.y+=32,s.fontSize=12,s.fontWeight=400,s.fontFamily="Inter",s.fillColor=new this.paper.Color("#8FA4AE"),s.justification="center",s.opacity=.7,t.addChildren([o,s]),this.printAreaLabel.position=e.bounds.topCenter.add(new this.paper.Point(0,-22/this.paper.view.zoom)),this.isResizableMode){t.visible=!1;var l=null!==(r=null===(a=null===(n=this.printAreaLabel)||void 0===n?void 0:n.children[1])||void 0===a?void 0:a.content)&&void 0!==r?r:"";this.updateAreaLabelResizableMode(l)}},createLabel:function(e,t,i){var n=new this.paper.Path.Rectangle(new this.paper.Rectangle(0,0,80,15),0);n.fillColor=new this.paper.Color("#ffffff"),n.strokeScaling=!1,n.strokeWidth=0,n.strokeColor=new this.paper.Color("#000000"),n.position=e,n.position.y+=32,n.name="labelRectangle-".concat(t.name);var a=new this.paper.PointText(e);a.content=i,a.position.y+=36,a.fontSize=12,a.fontWeight=400,a.fontFamily="Inter",a.fillColor=new this.paper.Color("#8FA4AE"),a.justification="center",t.addChildren([n,a])},updateLabelsPosition:function(){var e=this.labelLayer,t=this.getSelectedItem();t&&this.selectedItemDimensionLabel&&(this.selectedItemDimensionLabel.position=t.bounds.topCenter.add(new this.paper.Point(0,-22/this.paper.view.zoom)),this.updateLabelsText(),this.resizeHandle(this.selectedItemDimensionLabel,110),e.visible=!0),this.paper.project.view.update()},updatePrintAreaLabelText:function(){var e,t,i,n,a=null===(e=this.masterGroup)||void 0===e?void 0:e.children[0];if(a){var r=this.getAllItems(),o=[];r.forEach(function(e){e.data&&e.data.guid&&!e.data.isArea&&o.push(e)}),this.getAllGridItems().forEach(function(e){e.children&&e.children.length>0&&e.children.forEach(function(e){e.children.forEach(function(e){e.data&&e.data.isGridImage&&o.push(e)})})});var s=this.totalAreaCalculator(o)/("cm"===this.unitOfMeasurement?1:2.54);this.printAreaLabel.children[1].content="".concat(s.toFixed(2)," ").concat(this.unitOfMeasurement,"2");var l=(this.printAreaLabel.children[1].bounds.width+20)/this.printAreaLabel.children[0].bounds.width;this.printAreaLabel.children[0].scale(l,1),this.resizeHandle(this.printAreaLabel,110);var h=new this.paper.Point(0,-22/this.paper.view.zoom);if(this.printAreaLabel.position=a.bounds.topCenter.add(h),this.isResizableMode){this.printAreaLabel.visible=!1;var d=null!==(n=null===(i=null===(t=this.printAreaLabel)||void 0===t?void 0:t.children[1])||void 0===i?void 0:i.content)&&void 0!==n?n:"";this.updateAreaLabelResizableMode(d)}this.labelLayer.visible=!0}},updateAreaLabelResizableMode:function(e){if(this.isResizableMode&&this.resizableMeasuresItem){var t=this.findTotalSizeLabelResizableCanvas(this.resizableMeasuresItem);t&&(t.content=t.data.originalContent+e,t.bounds.y=t.data.originalY,t.visible=!0)}},hideAreaLabelResizableMode:function(){if(this.isResizableMode&&this.resizableMeasuresItem){var e=this.findTotalSizeLabelResizableCanvas(this.resizableMeasuresItem);e&&(e.visible=!1)}},findTotalSizeLabelResizableCanvas:function(e){for(var t,i=null,n=0;n<e.children.length;n++){var a=e.children[n];if((null===(t=null==a?void 0:a.data)||void 0===t?void 0:t.isTotalSizeLabel)?i=a:(null==a?void 0:a.children)&&a.children.length>0&&(i=this.findTotalSizeLabelResizableCanvas(a)),i)break}return i},updateLabelsText:function(e){var t=this.getSelectedItem();if(!t)throw new Error("Item cannot be null");var i=this.side.get("ppcm"),n=(t.bounds.width/i/("cm"===this.unitOfMeasurement?1:2.54)).toFixed(2),a=(t.bounds.height/i/("cm"===this.unitOfMeasurement?1:2.54)).toFixed(2);this.selectedItemDimensionLabel.children[1].content="".concat(n," x ").concat(a," ").concat(this.unitOfMeasurement);var r=(this.selectedItemDimensionLabel.children[1].bounds.width+10)/this.selectedItemDimensionLabel.children[0].bounds.width;this.selectedItemDimensionLabel.children[0].scale(r,1)},totalAreaCalculator:function(e){var t=this,i=0;return[this.side.get("areas").models].forEach(function(n){var a=t.side;if(null!=a&&a.get("ppcm")>0){var r=e.map(function(e){var t=e.data.transformsData?e.data.transformsData.dimensions.width:e.bounds.width,i=e.data.transformsData?e.data.transformsData.dimensions.height:e.bounds.height,n=e.data.transformsData?e.data.transformsData.position.x:e.bounds.x,a=e.data.transformsData?e.data.transformsData.position.y:e.bounds.y;return new Rectangle(t,i,n,a)});i=(i+rectanglesDistinctArea(r,a.get("ppcm")))/("cm"===t.unitOfMeasurement?1:2.54)}},this),i},placeHandleOut:function(e){if(e=e||this.selectionBoundsShape){var t=e.segments[0].point,i=e.segments[1].point,n=e.segments[2].point,a=e.segments[3].point,r=i.add(n.subtract(i).divide(2)),o=t.add(a.subtract(t).divide(2)),s=t.add(i.subtract(t).divide(2)),l=a.add(n.subtract(a).divide(2)),h=a.subtract(i),d=Math.atan2(h.x,h.y),c=i.getDistance(t)/i.getDistance(n),u=d+Math.atan(c);if(this.selectionMoveHandle){var g=.5*this.selectionMoveHandle.bounds.width;this.selectionMoveHandle.position=i,this.selectionMoveHandle.position.y-=Math.sin(u+Math.PI/4)*g,this.selectionMoveHandle.position.x+=Math.cos(u+Math.PI/4)*g}if(this.selectionRotateHandle){g=.5*this.selectionRotateHandle.bounds.width;this.selectionRotateHandle.position=n,this.selectionRotateHandle.position.y-=Math.sin(u-Math.PI/4)*g,this.selectionRotateHandle.position.x+=Math.cos(u-Math.PI/4)*g}if(this.selectionDeleteHandle){g=.5*this.selectionDeleteHandle.bounds.width;this.selectionDeleteHandle.position=t,this.selectionDeleteHandle.position.y-=Math.sin(u+3*Math.PI/4)*g,this.selectionDeleteHandle.position.x+=Math.cos(u+3*Math.PI/4)*g}if(this.selectionResizeHandle){g=.5*this.selectionResizeHandle.bounds.width;this.selectionResizeHandle.position=a,this.selectionResizeHandle.position.y-=Math.sin(u-3*Math.PI/4)*g,this.selectionResizeHandle.position.x+=Math.cos(u-3*Math.PI/4)*g}if(this.selectionMaskMoveImage){g=.5*this.selectionMaskMoveImage.bounds.width;this.selectionMaskMoveImage.position=l,this.selectionMaskMoveImage.position.y-=Math.sin(u+.7-Math.PI/2)*(g+20/this.paper.view.zoom),this.selectionMaskMoveImage.position.x+=Math.cos(u+.7-Math.PI/2)*(g+20/this.paper.view.zoom)}if(this.selectionMaskMoveShape){g=.5*this.selectionMaskMoveShape.bounds.width;this.selectionMaskMoveShape.position=l,this.selectionMaskMoveShape.position.y-=Math.sin(u-.7-Math.PI/2)*(g+20/this.paper.view.zoom),this.selectionMaskMoveShape.position.x+=Math.cos(u-.7-Math.PI/2)*(g+20/this.paper.view.zoom)}if(this.selectionResizeTopHandle||this.selectionResizeBottomHandle||this.selectionResizeLeftHandle||this.selectionResizeRightHandle){var f=this.selectionResizeHandle?.5*this.selectionResizeHandle.bounds.width:.5*this.selectionLateralResizeDimension*2,p=i.clone();p.y-=Math.sin(u+Math.PI/4)*f,p.x+=Math.cos(u+Math.PI/4)*f;var m=n.clone();m.y-=Math.sin(u-Math.PI/4)*f,m.x+=Math.cos(u-Math.PI/4)*f;var v=t.clone();v.y-=Math.sin(u+3*Math.PI/4)*f,v.x+=Math.cos(u+3*Math.PI/4)*f;var I=a.clone();I.y-=Math.sin(u-3*Math.PI/4)*f,I.x+=Math.cos(u-3*Math.PI/4)*f;var y=1.2*(this.selectionLateralResizeDimension/this.paper.view.zoom),C=r.subtract(o).normalize(y);r=r.add(C),o=o.subtract(C),C=l.subtract(s).normalize(y),l=l.add(C),s=s.subtract(C),this.selectionResizeTopHandle&&(this.selectionResizeTopHandle.position=r),this.selectionResizeBottomHandle&&(this.selectionResizeBottomHandle.position=o),this.selectionResizeLeftHandle&&(this.selectionResizeLeftHandle.position=s),this.selectionResizeRightHandle&&(this.selectionResizeRightHandle.position=l)}}},resizeHandle:function(e,t){var i=e.bounds,n=(null!=t?t:200)/_this_1.paper.view.zoom,a=(t=new _this_1.paper.Size(n,n),1);Math.abs(i.width)>1e-7&&(a=t.width/i.width),Math.abs(i.height)>1e-7&&(t.height,i.height),e.scale(a)},createSelectionHandle:function(e,t){if(!this.selectionBounds)return null;var i=this.selectionBoundsShape,n=getViewport(),a=0;a=(n.w,32/this.paper.view.zoom);var r="data:image/png;base64,"+this.iconsBytes[e],o=new this.paper.Raster({source:r,position:t.add()});o.data.isHandle=!0;var s=function(){var e=o.size,t=new this.paper.Size(a,a),i=1,n=1;Math.abs(e.width)>1e-7&&(i=t.width/e.width),Math.abs(e.height)>1e-7&&(n=t.height/e.height),o.scale(i,n)};if(o.size.width>0&&o.size.height>0)s();else{var l=this;o.onLoad=function(){s(),l.placeHandleOut(i)}}return o},createLateralSelectionHandle:function(e,t){var i=this.selectionLateralResizeDimension/this.paper.view.zoom,n=new this.paper.Path.Circle(t,i);return n.data.isLateralResize=!0,n.data.lateralResizeType=e,n.strokeColor=new this.paper.Color(1,1,1,.5),n.strokeWidth=1,n.fillColor=new this.paper.Color(0,0,0,.5),n},isItemFrozen:function(e){return e&&(e.data&&e.data.frozen||this.isItemGroupChild(e)&&e.parent.data&&e.parent.data.frozen)},isItemGroup:function(e){return e instanceof this.paper.Group&&!(e instanceof this.paper.Layer)},isItemGroupChild:function(e){return e.parent&&this.isItemGroup(e.parent)},isItemChild:function(e){return e.parent&&!(e.parent instanceof this.paper.Layer)},getRootDesignItemCanvasItem:function(e){if(e){if(e.isMaskPath)return e.item;if(e.data&&e.data.guid&&!e.data.isArea)return e;if(e.parent&&!(e.parent instanceof this.paper.Layer))return this.getRootDesignItemCanvasItem(e.parent)}return null},isDesignItemCanvasItem:function(e){return null!=this.getRootDesignItemCanvasItem(e)},setItemDataCustomOptions:function(e,t){e.data.customOptions=t,this.onItemUpdated(e),console.log(e.data)},setItemSelection:function(e,t){var i=this.getRootDesignItemCanvasItem(e);if(i&&i.data.selected!=t){i.data.selected=t;var n=this.findDesignItemForItem(i);i.data.maskAlertPath&&i.data.maskAlertPath.remove(),this.createMaskForItem(e),t?(this.cacheSelectedItemConstraints(n),this.checkAlertItems(i),this.removeDashedEdgeForItem(i),this.selectedDesignItem=n,this.selectedPaperRootItem=i):(n&&(this.createDashedEdgeForItem(i),this.createProfanityCheckInvalidOverlayAndEdgeForItem(i)),this.selectedDesignItem=null,this.selectedPaperRootItem=null);var a={designItem:n,selected:t};n&&this.fireSelectionChangedEvent(a)}},createMaskForItem:function(e){if(!e.data||!e.data.isImageForBackground&&!e.data.isAreaForBackground){var t=this.getRootDesignItemCanvasItem(e);if(t&&t.data){var i=this.getAreasIntersectingItem(t),n=this.getAreasContainingItem(t),a=0==i.length&&0==n.length;t.data.maskPath&&t.data.maskPath.remove(),t.data.maskPath=new this.paper.Path.Rectangle(t.bounds),t.data.maskPath.strokeWidth=2,t.data.maskPath.strokeColor="blue",t.data.maskPath.dashArray=[4,10],t.data.maskPath.isMaskPath=!0,t.data.maskPath.item=t,t.data.maskPath.visible=!1,!t.data.selected&&a&&this.itemCanBeTransformed(e)&&(t.data.maskPath.visible=!0)}}},removeMaskForItem:function(e){var t=this.getRootDesignItemCanvasItem(e);t&&t.data&&t.data.maskPath&&t.data.maskPath.remove()},canAddDashedEdge:function(e){var t;return!(!this.design||this.design.get("templateDesignID")<=0||!this.canEditItem(e)||!(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.isTemplateElement)||(null==e?void 0:e.data)&&((null==e?void 0:e.data.isImageForBackground)||(null==e?void 0:e.data.isAreaForBackground)))&&this.showDashedEdge},createDashedEdgeForItem:function(e){if(this.canAddDashedEdge(e)&&!this.isViewer){var t=this.getRootDesignItemCanvasItem(e);if(this.removeDashedEdgeForItem(t),!t.data.maskPath.visible){var i=new this.paper.Path.Rectangle(t.bounds);i.strokeWidth=2,i.strokeColor=this.DashedEdgeColor,i.dashArray=[10,10],i.visible=!0,t.data.dashedEdgeID=i.id,this.masterGroup.addChild(i),i.insertBelow(t),i.data.isDashedEdge=!0}}},removeDashedEdgeForItem:function(e){var t=this.getRootDesignItemCanvasItem(e);if(t&&t.data&&t.data.dashedEdgeID>0){var i=this.paper.project.getItem({id:t.data.dashedEdgeID});i&&(i.remove(),t.data.dashedEdgeID=-1)}},updateDashedEdgeAllItems:function(){for(var e=this.design.get("designItems"),t=[],i=0;i<e.length;i++){var n=e.at(i),a=this.findItemForDesignItem(n);t.push(a)}for(var r=0,o=t;r<o.length;r++){a=o[r];this.removeDashedEdgeForItem(a),this.createDashedEdgeForItem(a)}},createMaskAlertForItem:function(e){var t=this.getRootDesignItemCanvasItem(e);t.data.maskAlertPath&&t.data.maskAlertPath.remove(),t.data.maskAlertPath=new this.paper.Path.Rectangle(t.bounds),t.data.maskAlertPath.strokeWidth=3,t.data.maskAlertPath.strokeColor="red",t.data.maskAlertPath.dashArray=[10,10],t.data.maskAlertPath.isMaskAlertPath=!0,t.data.maskAlertPath.item=t,t.data.maskAlertPath.data.isMaskAlertPath=!0},createProfanityCheckInvalidOverlayAndEdgeForItem:function(e){var t=this;if(!this.isViewer){var i=this.getRootDesignItemCanvasItem(e);if(this.removeProfanityCheckInvalidOverlayAndEdgeForItem(i),!i.data.isProfanityCheckInvalid)return;var n=new this.paper.Path.Rectangle(i.bounds);if(n.strokeWidth=3,n.strokeColor="red",n.dashArray=[10,10],n.visible=!0,n.insertBelow(i),n.data.isProfanityCheckDashedEdge=!0,i.data.profanityCheckDashedEdgeId=n.id,this.masterGroup.addChild(n),this.isImage(i)){this.invalidOverlayLayer||(this.invalidOverlayLayer=new this.paper.Layer({name:"invalid-overlay-layer"}),this.invalidOverlayLayer.bringToFront());var a=new this.paper.Group,r=new this.paper.Group;a.position=new this.paper.Point(0,0),a.data.isInvalidOverlayGroup=!0,r.visible=!1,r.position=new this.paper.Point(0,0),r.data.isInvalidOverlayGroup=!0;var o=i.bounds.width/i.bounds.height,s=new this.paper.Path.Rectangle({width:300,height:300/o});s.position=a.position,s.fillColor=new paper.Color(.1,.1,.1,.65),s.data.isInvalidOverlayGroup=!0,i.data.profanityCheckOverlayId=a.id,a.addChildren([s,r]),this.invalidOverlayLayer.addChild(a),this.itemsLayer.activate();var l=i.bounds.width/a.bounds.width;a.scale(l),a.position=i.position;var h=new this.paper.Raster({source:"data:image/png;base64,"+this.iconsBytes.warningOutlined});h.data.isInvalidOverlayGroup=!0,h.position=new this.paper.Point(s.bounds.x+s.bounds.width/2,s.bounds.y+s.bounds.height/2-20),h.onLoad=function(){var e=new t.paper.PointText({content:"Image not",fillColor:"white",fontStyle:"bold",fontWeight:"bold",fontSize:"18px"});e.data.isInvalidOverlayGroup=!0,e.position=new t.paper.Point(s.bounds.x+s.bounds.width/2,s.bounds.y+s.bounds.height/2+20);var i=new t.paper.PointText({content:"allowed",fillColor:"white",fontStyle:"bold",fontWeight:"bold",fontSize:"18px"});i.data.isInvalidOverlayGroup=!0,i.position=new t.paper.Point(s.bounds.x+s.bounds.width/2,s.bounds.y+s.bounds.height/2+40),r.addChildren([h,e,i]),l=Math.min(s.bounds.width/r.bounds.width,s.bounds.height/r.bounds.height),r.scale(l);var n=100/t.paper.view.zoom;l=n<r.bounds.height?n/r.bounds.height:1,r.scale(l),r.visible=!0}}}},removeProfanityCheckInvalidOverlayAndEdgeForItem:function(e){var t=this.getRootDesignItemCanvasItem(e);if(t&&t.data){if(t.data.profanityCheckDashedEdgeId>0){var i=this.paper.project.getItem({id:t.data.profanityCheckDashedEdgeId});i&&(i.remove(),t.data.profanityCheckDashedEdgeId=-1)}if(t.data.profanityCheckOverlayId>0){var n=this.paper.project.getItem({id:t.data.profanityCheckOverlayId});n&&(n.remove(),t.data.profanityCheckOverlayId=-1)}}},groupSelectedItems:function(){var e=this.getSelectedItems();if(0!=e.length){for(var t=new this.paper.Group,i=0;i<e.length;i++){var n=e[i];n.guide||t.addChild(n)}return this.setItemSelection(t,!0),this.updateSelectionState(),this.paper.project.view.update(),t}},ungroupSelectedItems:function(){var e=this.getSelectedItems();if(0!=e.length){for(var t=0;t<e.length;t++){var i=e[t];i instanceof this.paper.Group&&this.ungroup(i)}this.updateSelectionState(),this.paper.project.view.update()}},ungroup:function(e){if(this.setItemSelection(e,!1),e&&e instanceof this.paper.Group){for(;e.children.length>0;){var t=e.children.pop();t.parent=this.paper.project.activeLayer,this.setItemSelection(t,!0)}e.remove()}},captureSelectionPosition:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];if(!n.guide&&!this.isItemChild(n)){var a=this.getSubItemsToChange(n),r=[];a.forEach(function(e){r.push({id:e.id,position:e.position})}),e.push(r)}}return e},restoreSelectionPosition:function(e){for(var t=0;t<e.length;t++)for(var i=e[t],n=0;n<i.length;n++){var a=i[n],r=this.findItemById(a.id);r||console.log("ITEM NOT FOUND!"),r&&(r.position=a.position)}},captureSelectionState:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i],a=this.getSubItemsToChange(n);if(!n.guide){this.removeMaskForItem(n);this.getMaskedImageRasterItem(n);var r=[];a.forEach(function(e){r.push({id:e.id,applyMatrix:e.applyMatrix,json:e.exportJSON({asString:!1}),matrix:e.matrix.clone(),selectedSegments:[],boundsItemMatrix:e.data&&e.data.originalMatrix?e.data.originalMatrix.clone():null,boundsItemPosition:e.data&&e.data.originalPosition?e.data.originalPosition.clone():null})}),e.push(r)}}return e},restoreSelectionState:function(e){for(var t=0;t<e.length;t++)for(var i=e[t],n=0;n<i.length;n++){var a=i[n],r=this.findItemById(a.id);if(r){if(a.applyMatrix){var o=r.id;r.importJSON(a.json),r._id=o}else r.matrix.set(a.matrix.a,a.matrix.b,a.matrix.c,a.matrix.d,a.matrix.tx,a.matrix.ty);r.data.originalBounds&&r.data.originalMatrix&&a.boundsItemMatrix&&(r.data.originalMatrix=a.boundsItemMatrix.clone()),r.data.originalPosition&&r.data.originalPosition&&a.boundsItemPosition&&(r.data.originalPosition=a.boundsItemPosition.clone())}}},captureSelectionMatrix:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i],a=n;if(this.isMaskedImage(n))a=this.getReferenceItemForSelectedItem(n);else{if(n.guide)continue;if(this.isItemChild(n))continue}var r=this.getMaskedImageRasterItem(n),o={id:n.id,refId:a.id,matrix:a.matrix.clone(),selectedSegments:[],boundsItemMatrix:n.data.originalMatrix?n.data.originalMatrix.clone():null,boundsRasterMatrix:r&&r.data.originalMatrix?r.data.originalMatrix.clone():null};e.push(o)}return e},restoreSelectionMatrix:function(e){for(var t=0;t<e.length;t++){var i=e[t],n=this.findItemById(i.id),a=this.findItemById(i.refId);if(n&&a){a.matrix.set(i.matrix.a,i.matrix.c,i.matrix.b,i.matrix.d,i.matrix.tx,i.matrix.ty),n.data&&n.data.originalMatrix&&(n.data.originalMatrix=i.boundsItemMatrix.clone());var r=this.getMaskedImageRasterItem(n);r&&r.data.originalMatrix&&i.boundsRasterMatrix&&(r.data.originalMatrix=i.boundsRasterMatrix.clone())}}},deselectAll:function(){var e=this.getSelectedItems();this.fireDeselectionChangedEvent(e),this.deselectGridBoxes();for(var t=0;t<e.length;t++){var i=e[t];i.data&&i.data.selected&&this.setItemSelection(i,!1)}this.paper.project.deselectAll(),this.hideAreaItems(),this.labelLayer&&this.labelLayer.visible&&(this.labelLayer.visible=!1),this.isResizableMode&&this.resizableMeasuresItem&&this.hideAreaLabelResizableMode()},selectItems:function(e){if(this.deselectAll(),e&&"[object Array]"===Object.prototype.toString.call(e))for(var t=0;t<e.length;t++){var i=e[t];i&&this.setItemSelection(i,!0)}this.updateSelectionState(),this.paper.project.view.update()},getSelectionBounds:function(){for(var e=null,t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i],a=this.getItemBounds(n);e=null==e?a.clone():e.unite(a)}return e},getSelectedItem:function(){var e=this.getSelectedItems();return e.length>0?e[0]:null},isItemSelected:function(e){for(var t=this.getSelectedItems(),i=0;i<t.length;i++){if(t[i]===e)return!0}return!1},getSelectedItems:function(){for(var e=[],t=function(i){if(!i.guide&&(!i.data||!i.data.isArea)&&(i.data&&i.data.selected&&e.push(i),i.children))for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];t(a)}},i=0;i<this.paper.project.layers.length;i++){var n=this.paper.project.layers[i];n.guide||t(n)}return e},getSelectedSimpleItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||(n instanceof this.paper.Group||n.parent&&this.isItemGroup(n.parent)||e.push(n))}return e},getSelectedGroupItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||this.isItemGroup(n)&&e.push(n)}return e},getSelectedTextItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||(n instanceof this.paper.TextItem?e.push(n):n&&n.data&&n.data.isTextOnPath?e.push(n):n&&n.data&&n.data.isTextArea&&e.push(n))}return e},getDefaultTextItemInfo:function(){var e={text:"",strokeColor:null,strokeWidth:0,fillColor:"black",fontFamily:"Arial",fontSize:18,fontWeight:"normal",fontStyle:"normal",fontStretch:"normal",justification:"center",isTextOnPath:!1,isTextArea:!1,isTextBox:!1,adaptText:!1,letterSpacing:0,lineSpacing:0,scaling:1,verticalAlignment:"top",shadowColor:null,shadowBlur:0,shadowDistance:7,shadowAngle:45};return e},getTextFromItem:function(e){var t="";if(e instanceof this.paper.TextItem)t=e.content;else if(e&&e.data&&e.data.isTextOnPath){if(e.children&&e.children.length>0){var i=e.data.text;if(!i)for(var n=0;n<e.children.length;n++)i+=e.children[n].content;t=i}}else e&&e.data&&e.data.isTextArea&&(t=e.data.text||"");return __assign(__assign({},e),{text:t})},getTextItemInfo:function(e){var t=this.getDefaultTextItemInfo();if(e instanceof this.paper.TextItem)t.text=e.content,t.strokeColor=e.strokeColor,t.strokeWidth=e.strokeWidth,t.fillColor=e.fillColor.toCSS(!0),t.fontFamily=e.fontFamily,t.fontSize=e.fontSize,t.fontWeight=e.fontWeight,t.fontStyle=e.fontStyle,t.fontStretch=e.fontStretch,t.justification=e.justification,t.scaling=e.scaling,t.shadowColor=e.shadowColor,t.shadowBlur=e.shadowBlur,t.shadowDistance=this.getOffsetDistance(e.shadowOffset),t.shadowAngle=this.getOffsetAngle(e.shadowOffset),t.letterSpacing=e.letterSpacing,t.lineSpacing=e.lineSpacing;else if(e&&e.data&&e.data.isTextOnPath){if(e.children.length>0){var i=e.data.text;if(!i)for(var n=0;n<e.children.length;n++)i+=e.children[n].content;t.text=i,t.isTextOnPath=e.data&&e.data.isTextOnPath,t.isTextArea=e.data&&e.data.isTextArea,t.isTextBox=e.data&&e.data.isTextBox,t.adaptText=e.data&&e.data.adaptText,t.strokeColor=e.children[0].strokeColor,t.strokeWidth=e.children[0].strokeWidth,t.fillColor=e.children[0].fillColor,t.fontFamily=e.children[0].fontFamily,t.fontWeight=e.children[0].fontWeight,t.fontStyle=e.children[0].fontStyle,t.fontStretch=e.children[0].fontStretch,t.fontSize=e.children[0].fontSize,t.scaling=e.children[0].scaling,t.justification=e.data.isTextArea?e.data.justification:void 0,t.shadowColor=e.children[0].shadowColor,t.shadowBlur=e.children[0].shadowBlur,t.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),t.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset)}}else e&&e.data&&e.data.isTextArea&&(t=this.getTextAreaItemInfo(e,null));return t.isPlaceHolder=e.data&&e.data.isPlaceHolder||!1,e.data.hasOwnProperty("originalStrokeColor")&&(t.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(t.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(t.shadowColor=e.data.originalShadowColor),e.data.hasOwnProperty("adaptText")&&(t.adaptText=e.data.adaptText),e.data.hasOwnProperty("letterSpacing")&&(t.letterSpacing=e.data.letterSpacing),e.data.hasOwnProperty("lineSpacing")&&(t.lineSpacing=e.data.lineSpacing),t.fontFamily=t.fontFamily.replace(/"/g,""),t},getSelectedTextItemsInfo:function(){var e=this.getDefaultTextItemInfo(),t=this.getSelectedTextItems();if(t&&1==t.length){var i=t[0];e=this.getTextItemInfo(i)}return e.fontFamily=e.fontFamily.replace(/"/g,""),e},getSelectedTextItemsNotOnPath:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n instanceof this.paper.TextItem&&e.push(n)}return e},getSelectedTextOnPathItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextOnPath&&e.push(n)}return e},getSelectedTextAreaItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextArea&&e.push(n)}return e},getSelectedSimpleTextAreaItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextArea&&!n.data.isTextBox&&e.push(n)}return e},getSelectedTextBoxItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextArea&&n.data.isTextBox&&e.push(n)}return e},getSelectedTextArtItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextArt&&e.push(n)}return e},getSelectedShapeItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isShape&&e.push(n)}return e},getSelectedImageItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];this.getMaskedImageRasterItem(n)&&n.data&&n.data.guid&&!n.data.isArea&&e.push(n)}return e},getSelectedMaskedImageItems:function(){var e=this;return this.getSelectedImageItems().filter(function(t){return e.isMaskedImage(t)})},getSelectedFilledShapesItems:function(){var e=this;return this.getSelectedImageItems().filter(function(t){return e.isFilledShape(t)})},getSelectedItemsCommonImageID:function(){for(var e=null,t=this.getSelectedImageItems(),i=0;i<t.length;i++){var n=t[i],a=this.findDesignItemByGuid(n.data.guid);if(a){var r=a.get("imageID");if(null==e)e=r;else if(r!=e)return null}}return e},getSelectedDesignItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i],a=this.findDesignItemForItem(n);n&&e.push(a)}return e},countTextItems:function(){var e=0,t=this;function i(n){if((!t.isItemGroup(n)||n==t.masterGroup)&&n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];!r.guide&&(r instanceof this.paper.TextItem||r.data&&r.data.isTextOnPath||r.data&&r.data.isTextArea)&&e++,i(r)}}for(var n=0,a=t.paper.project.layers.length;n<a;n++){var r=t.paper.project.layers[n];r.guide||i(r)}return e},countImageItems:function(){var e=0,t=this;function i(n){if((!t.isItemGroup(n)||this.isMaskedImage(n)||this.isMaskedImageClipGroup(n)||n==t.masterGroup)&&n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];r&&r instanceof this.paper.Raster&&r.data&&r.data.guid&&!r.data.isArea&&e++,i(r)}}for(var n=0,a=t.paper.project.layers.length;n<a;n++){var r=t.paper.project.layers[n];r.guide||i(r)}return e},countTextArtItems:function(){var e=0,t=this;function i(n){if((!t.isItemGroup(n)||n==t.masterGroup)&&n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];r&&r.data&&r.data.isTextArt&&e++,i(r)}}for(var n=0,a=t.paper.project.layers.length;n<a;n++){var r=t.paper.project.layers[n];r.guide||i(r)}return e},getItemsInfo:function(){var e=[];if(!this.side)return e;var t=this;function i(n){if(n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];if(r&&!r.guide){var o=null,s=t.findDesignItemForItem(r);if(s){var l=s.get("shape"),h=t.getMaskedImageRasterItem(r),d=t.getMaskedImageShapeItem(r);if(r instanceof this.paper.TextItem||r.data&&r.data.isTextOnPath||r.data&&r.data.isTextArea){o=new MPlaza.TextItemInfo(s,r);var c=t.getTextItemInfo(r);o.sideID=t.side.get("sideID"),o.text=c.text,o.strokeColor=c.strokeColor instanceof paper.Color?c.strokeColor.toCSS(!0):c.strokeColor,o.strokeWidth=c.strokeWidth,o.fillColor=c.fillColor instanceof paper.Color?c.fillColor.toCSS(!0):c.fillColor,o.fontFamily=c.fontFamily,o.fontSize=c.fontSize,o.fontWeight=c.fontWeight,o.fontStyle=c.fontStyle,o.fontStretch=c.fontStretch,o.justification=c.justification,o.isTextOnPath=c.isTextOnPath,o.isTextArea=c.isTextArea,o.adaptText=c.adaptText,o.letterSpacing=c.letterSpacing,o.lineSpacing=c.lineSpacing,o.scaling=c.scaling,o.shadowColor=c.shadowColor,o.shadowBlur=c.shadowBlur,o.shadowDistance=t.getOffsetDistance(c.shadowOffset),o.shadowAngle=t.getOffsetAngle(c.shadowOffset)}else h&&r.data&&r.data.guid&&!r.data.isArea?((o=new MPlaza.ImageItemInfo(s,r)).imageID=s.get("imageID"),o.url=h.data.originalUrl||h.source,o.sideID=t.side.get("sideID"),o.visible=r.visible,o.isMasked=t.isMaskedImage(r),o.maskID=l?l.get("shapeID"):void 0,d&&(o.maskStyle.strokeColor=d.strokeColor?d.strokeColor.toCSS(!0):void 0,o.maskStyle.strokeWidth=d.strokeWidth,o.maskStyle.strokeCap=d.strokeCap,o.maskStyle.strokeJoin=d.strokeJoin,o.maskStyle.dashArray=d.dashArray,o.maskStyle.dashOffset=d.dashOffset,d.data.hasOwnProperty("originalStrokeColor")&&(o.maskStyle.strokeColor=d.data.originalStrokeColor))):r.data&&r.data.isTextArt&&(o=t.getTextArtItemInfo(r))}null!=o&&(o.constraints=(s.get("constraints")||new MPlaza.DesignItemConstraints).toJSON(),e.push(o))}i(r)}}for(var n=0;n<t.paper.project.layers.length;n++){var a=t.paper.project.layers[n];a.guide||i(a)}return e},getSelectedAreaItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++)for(var n=t[i],a=this.getAreasIntersectingOrContainingItem(n),r=0;r<a.length;r++){var o=a[r],s=this.findItemForArea(o);s&&e.push(s)}return e},log:function(e){Logger.info(e),$("#logMsg").length&&$("#logMsg").text(e)},appendLog:function(e){var t=$("#logMsg").text();t&&(t+="\n"),t+=e,Logger.info(e),$("#logMsg").text(t)},getTextArtItemInfo:function(e){if(e&&e.data&&e.data.isTextArt){var t=this.findDesignItemForItem(e);if(t){var i=new MPlaza.TextArtItemInfo(t,e),n=t.get("textArt");i.text=n.get("text"),i.fontFamilyID=n.get("fontFamilyID"),i.fontFaceID=n.get("fontFaceID"),i.textArtTypeID=n.get("textArtTypeID"),e instanceof this.paper.Item&&(e.strokeColor&&(i.style.strokeColor=e.strokeColor.toCSS(!0)),i.style.strokeWidth=e.strokeWidth,i.style.strokeCap=e.strokeCap,i.style.strokeJoin=e.strokeJoin,i.style.dashArray=e.dashArray,i.style.dashOffset=e.dashOffset,e.fillColor&&(i.style.fillColor=e.fillColor.toCSS(!0)),e.data.hasOwnProperty("originalStrokeColor")&&(i.style.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(i.style.fillColor=e.data.originalFillColor),e.shadowColor&&(i.style.shadowColor=e.shadowColor.toCSS(!0)),i.style.shadowBlur=e.shadowBlur||0,i.style.shadowDistance=this.getOffsetDistance(e.shadowOffset),i.style.shadowAngle=this.getOffsetAngle(e.shadowOffset));var a=n.get("config");return i.config.angleValue=a.get("angleValue"),i.config.curveValue=a.get("curveValue"),i.config.intensT=a.get("intensT"),i.config.intensB=a.get("intensB"),i.config.isTriangle=a.get("isTriangle"),i.config.isBridge=a.get("isBridge"),i.config.isTop=a.get("isTop"),i.config.isBottom=a.get("isBottom"),i.config.isMiddle=a.get("isMiddle"),i}}return null},getTextArtItemText:function(e){if(e&&e.data&&e.data.isTextArt){var t=this.findDesignItemForItem(e);if(t)return t.get("textArt").get("text")}return null},getImageItemInfo:function(e,t){void 0===t&&(t=null);var i=null;if(e&&e.data&&e.data.guid&&!e.guide&&!e.data.isArea&&(this.side||t)){var n=this.findDesignItemForItem(e);if(n){var a=n.get("shape"),r=this.getMaskedImageRasterItem(e);this.getMaskedImageShapeItem(e);r&&((i=new MPlaza.ImageItemInfo(n,e)).imageID=n.get("imageID"),i.sideID=t?t.get("sideID"):this.side.get("sideID"),i.url=r.data.originalUrl||r.source,i.visible=e.visible,i.isMasked=this.isMaskedImage(e),i.maskID=a?a.get("shapeID"):void 0,i.maskStyle=this.getMaskedImageMaskPathStyle(e)),i.constraints=(n.get("constraints")||new MPlaza.DesignItemConstraints).toJSON()}}return i},getShapeItemInfo:function(e){var t=null;if(e&&(this.isShape(e)||this.isFilledShape(e))){var i=this.findDesignItemForItem(e);if(i){i.get("shape");var n=null;(n=this.isShape(e)?e:this.getMaskedImageShapeItem(e))&&((t=new MPlaza.ShapeItemInfo(i,e)).style=this.getShapeItemStyle(n),t.isImagePlaceholder=n.data.isImagePlaceholder,t.fillerImageID=i.get("imageID"))}}return t},onTouchStart:function(e){if(this.touchEnabled=!0,e.preventDefault(),1==e.touches.length){var t=this.windowToCanvas(e.touches[0].clientX,e.touches[0].clientY),i=new this.paper.Point(t.x,t.y);if(i=this.paper.project.view.viewToProject(i),this.hitTest(i),this.hitTestEnabled=!1,this.interactionMode=MPlaza.CustomizerInteractionMode.Create,this.elementType==MPlaza.CustomizerElementType.None&&(this.interactionMode=MPlaza.CustomizerInteractionMode.Select),this.mouseStartPos=i.clone(),this.adjustmentDelta=null,this.mouseLastPos=i.clone(),this.element=null,this.captureInitialSelectionState(i),this.hitItem)if(this.beginDesignOperation(),this.hitItem.data&&this.hitItem.data.isTextOnPathFirstEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd;else if(this.hitItem.data&&this.hitItem.data.isTextOnPathMiddleEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd;else if(this.hitItem.data&&this.hitItem.data.isTextOnPathLastEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd;else if(this.hitItem.data&&this.hitItem.data.isTextAreaTopEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd;else if(this.hitItem.data&&this.hitItem.data.isTextAreaRightEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd;else if(this.hitItem.data&&this.hitItem.data.isTextAreaBottomEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd;else if(this.hitItem.data&&this.hitItem.data.isTextAreaLeftEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd;else{this.getRootDesignItemCanvasItem(this.hitItem)?this.interactionMode=MPlaza.CustomizerInteractionMode.Select:this.hitItem==this.selectionMoveHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Move:this.hitItem==this.selectionRotateHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Rotate:this.hitItem==this.selectionResizeHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Resize:this.hitItem==this.selectionResizeTopHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeTop:this.hitItem==this.selectionResizeBottomHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeBottom:this.hitItem==this.selectionResizeLeftHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeLeft:this.hitItem==this.selectionResizeRightHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeRight:this.hitItem==this.selectionDeleteHandle&&(this.interactionMode=MPlaza.CustomizerInteractionMode.Delete)}}},onTouchEnd:function(e){this.endDesignOperation(),this.hitTestEnabled=!0,this.hideCenterLines(),this.adjustmentDelta=null;var t=this.getSelectedItems();this.interactionMode==MPlaza.CustomizerInteractionMode.Select?this.selectElement():this.interactionMode==MPlaza.CustomizerInteractionMode.Create?(this.onItemCreated(this.element),this.deselectAll(),this.setItemSelection(this.element,!0)):this.interactionMode==MPlaza.CustomizerInteractionMode.Move?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Rotate?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Resize?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeTop?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeBottom?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeLeft?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeRight?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Delete?this.deleteSelection():this.interactionMode==MPlaza.CustomizerInteractionMode.Edit?this.editElement():this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd&&this.onItemsUpdated(t),this.updateSelectionState(),this.paper.project.view.update()},onTap:function(e){},onDoubleTap:function(e){this.fitToScreen(!0,!0)},onPan:function(e){var t;e.preventDefault();var i=null!==(t=e.position)&&void 0!==t?t:this.windowToCanvas(e.center.x,e.center.y),n=new this.paper.Point(i.x,i.y),a=this.getSelectedItems();e.position||(n=this.paper.project.view.viewToProject(n)),"panstart"==e.type?(this.lastPanPoint.x=n.x,this.lastPanPoint.y=n.y,this.panOrigin=paper.view.center,this.removeAllAlertItems(),this.removeSizeLimitAlert()):"panend"==e.type&&(a.length>0&&this.checkAlertItems(a[0]),this.checkImagesSizeLimit());var r=n.subtract(this.lastPanPoint);this.lastPanPoint.x=n.x,this.lastPanPoint.y=n.y;var o=new MPlaza.PointingInfo;e.srcEvent&&(o.modifiers.option=e.srcEvent.altKey||!1,o.modifiers.control=e.srcEvent.ctrlKey||!1,o.modifiers.shift=e.srcEvent.shiftKey||!1),o.delta=r,o.point=n,this.onPointerDrag(o),this.paper.project.view.update();var s=a.length>0&&!this.canMoveSelection(a[0])&&this.interactionMode==MPlaza.CustomizerInteractionMode.Move;0!=a.length&&!s||!this.panOrigin||this.preventViewMoving||(paper.view.center=this.panOrigin.subtract(new paper.Point(1*e.deltaX/paper.view.zoom,1*e.deltaY/paper.view.zoom))),this.clampView()},onPinch:function(e){try{var t=this.getAllItemsBounds(),i=this.paper.project.view.bounds;if(this.zooming||!t||!i)return;"pinchstart"==e.type&&(this.oldScale=e.scale);var n=e.scale-this.oldScale;if(this.oldScale=e.scale,e.pointers.length<2)return;var a=1+Math.abs(n),r=new paper.Point(e.center.x,e.center.y),o=(r=paper.project.view.viewToProject(r)).subtract(paper.view.center),s=a-1;if(n>0){if(paper.view.zoom>=1.1)return;paper.view.zoom*=a,paper.view.center=paper.view.center.add(o.multiply(s/a))}else if(n<0){if(t.width<i.width-100&&t.height<i.height-100)return;paper.view.zoom/=a,paper.view.center=paper.view.center.subtract(o.multiply(s))}this.preventViewMoving=!1,this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.clampView()}catch(e){alert(e)}},onRotate:function(e){},dumpSelectionPosition:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];Logger.info("item_"+i._id+" - x: "+i.position.x+" - y: "+i.position.y)}},onMouseDown:function(e){var t,i,n,a,r,o,s,l,h,d,c;if(!this.touchEnabled){this.hitTest(e.point),this.hitTestEnabled=!1,this.interactionMode=MPlaza.CustomizerInteractionMode.Create,this.elementType==MPlaza.CustomizerElementType.None&&(this.interactionMode=MPlaza.CustomizerInteractionMode.Select),this.mouseStartPos=e.point.clone(),this.adjustmentDelta=null,this.mouseLastPos=e.point.clone(),this.element=null,this.captureInitialSelectionState(e.point);this.hitItem;if(this.hitItem)if(this.beginDesignOperation(),null===(t=this.hitItem.data)||void 0===t?void 0:t.isTextOnPathFirstEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd;else if(null===(i=this.hitItem.data)||void 0===i?void 0:i.isTextOnPathMiddleEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd;else if(null===(n=this.hitItem.data)||void 0===n?void 0:n.isTextOnPathLastEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd;else if(null===(a=this.hitItem.data)||void 0===a?void 0:a.isTextAreaTopEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd;else if(null===(r=this.hitItem.data)||void 0===r?void 0:r.isTextAreaRightEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd;else if(null===(o=this.hitItem.data)||void 0===o?void 0:o.isTextAreaBottomEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd;else if(null===(s=this.hitItem.data)||void 0===s?void 0:s.isTextAreaLeftEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd;else if(null===(l=this.hitItem.data)||void 0===l?void 0:l.isImageForBackground)this.interactionMode=MPlaza.CustomizerInteractionMode.Select;else if((null===(h=this.hitItem.data)||void 0===h?void 0:h.isGridIcon)||(null===(d=this.hitItem.data)||void 0===d?void 0:d.isGridImage))this.interactionMode=MPlaza.CustomizerInteractionMode.SelectedGridImage;else if(null===(c=this.hitItem.data)||void 0===c?void 0:c.isShapePlaceholderIcon)this.fireFillShapeRequestedEvent({itemGuid:this.hitItem.data.shapeGuid});else{this.getRootDesignItemCanvasItem(this.hitItem)?this.interactionMode=MPlaza.CustomizerInteractionMode.Select:this.hitItem==this.selectionMoveHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Move:this.hitItem==this.selectionRotateHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Rotate:this.hitItem==this.selectionResizeHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Resize:this.hitItem==this.selectionResizeTopHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeTop:this.hitItem==this.selectionResizeBottomHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeBottom:this.hitItem==this.selectionResizeLeftHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeLeft:this.hitItem==this.selectionResizeRightHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeRight:this.hitItem==this.selectionDeleteHandle&&(this.interactionMode=MPlaza.CustomizerInteractionMode.Delete)}}},onMouseMove:function(e){this.hitTestEnabled&&this.hitTest(e.point)},onMouseDrag:function(e){e.preventDefault();var t=new MPlaza.PointingInfo;t.modifiers.option=e.modifiers.option,t.modifiers.control=e.modifiers.control,t.modifiers.shift=e.modifiers.shift,t.delta=e.delta,t.point=e.point,this.onPointerDrag(t)},onPointerDrag:function(e){this.hitTestEnabled=!1,this.labelLayer&&this.labelLayer.visible&&(this.labelLayer.visible=!1),this.frozen||(this.interactionMode!=MPlaza.CustomizerInteractionMode.Select&&this.interactionMode!=MPlaza.CustomizerInteractionMode.SelectedGridImage||(this.selectElement(),this.updateSelectionState(),this.captureInitialSelectionState(e.point),this.interactionMode=MPlaza.CustomizerInteractionMode.Move),this.interactionMode==MPlaza.CustomizerInteractionMode.Create?this.elementType!=MPlaza.CustomizerElementType.Text&&this.createElement(e):this.interactionMode==MPlaza.CustomizerInteractionMode.Move?this.moveSelection(e):this.interactionMode==MPlaza.CustomizerInteractionMode.Rotate?this.rotateSelection(e):this.interactionMode==MPlaza.CustomizerInteractionMode.Resize?this.resizeSelection(e):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeTop?this.resizeSelectionTop(e):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeBottom?this.resizeSelectionBottom(e):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeLeft?this.resizeSelectionLeft(e):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeRight?this.resizeSelectionRight(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd?this.moveTextOnPathFirstEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd?this.moveTextOnPathMiddleEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd?this.moveTextOnPathLastEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd?this.moveTextAreaTopEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd?this.moveTextAreaRightEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd?this.moveTextAreaBottomEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd&&this.moveTextAreaLeftEnd(e),this.selectedPaperRootItem&&this.removeProfanityCheckInvalidOverlayAndEdgeForItem(this.selectedPaperRootItem))},onMouseUp:function(e){this.hitTestEnabled=!0,this.hideCenterLines(),this.adjustmentDelta=null;var t=this.getSelectedItems(),i=new MPlaza.PointingInfo;i.delta=e.delta,i.point=e.point,this.interactionMode==MPlaza.CustomizerInteractionMode.Select?(this.switchMaskedImageSelectionMode(e),this.selectElement()):this.interactionMode==MPlaza.CustomizerInteractionMode.Create?this.elementType==MPlaza.CustomizerElementType.Text?this.createElement(i):(this.onItemCreated(this.element),this.deselectAll(),this.setItemSelection(this.element,!0)):this.interactionMode==MPlaza.CustomizerInteractionMode.Move?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Rotate?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Resize?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeTop?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeBottom?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeLeft?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeRight?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Delete?this.deleteSelection():this.interactionMode==MPlaza.CustomizerInteractionMode.Edit?this.editElement():this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd?(this.onTextAreaGuidesUpdated(this.interactionMode),this.onItemsUpdated(t)):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd?(this.onTextAreaGuidesUpdated(this.interactionMode),this.onItemsUpdated(t)):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd?(this.onTextAreaGuidesUpdated(this.interactionMode),this.onItemsUpdated(t)):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd?(this.onTextAreaGuidesUpdated(this.interactionMode),this.onItemsUpdated(t)):this.interactionMode==MPlaza.CustomizerInteractionMode.SelectedGridImage&&(this.hitItem.data.isGridImage?(this.switchMaskedImageSelectionMode(e),this.selectElement()):this.deselectAll(),this.onGridImageSelected(this.hitItem),this.onItemsUpdated(t)),this.forceSelectedTextAreasToBounds(),t.length>0&&this.createProfanityCheckInvalidOverlayAndEdgeForItem(this.getRootDesignItemCanvasItem(t[0])),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()},hitTest:function(e){var t=this;if(!this.frozen){var i=8,n=this.getSelectedTextItemsInfo();this.isMobile&&(n.isTextOnPath||n.isTextArea)&&(i=25/this.paper.view.zoom);var a=this;if(this.hitItem=null,e&&this.itemsLayer){for(var r=this.itemsLayer.hitTestAll(e,{fill:!0,stroke:!0,tolerance:i,match:function(e){return!(e.item instanceof a.paper.Raster&&0==e.item.getPixel(e.offset.x,e.offset.y).alpha)&&(!(e.item&&e.item.data&&e.item.data.guid&&a.isItemStatic(e.item))&&(!(e.item&&e.item.data&&e.item.data.isAreaForBackground)&&(!(e.item&&e.item.data&&e.item.data.isGridBorderPath)&&(!(e.item&&e.item.data&&e.item.data.isInvalidOverlayGroup)&&(!(e.item&&e.item.data&&e.item.data.isMaskAlertPath)&&!(a.mask&&e.item==a.mask||e.item.isClippingArea))))))}}),o=[],s=0,l=this.getAllItems().filter(function(e){return e&&e instanceof t.paper.Raster&&e.data&&e.data.guid&&!e.data.isArea&&!e.guide});s<l.length;s++){var h=l[s];new this.paper.Rectangle(h.bounds).contains(e)&&o.push(h)}var d=void 0;if(o.length>0)for(var c=60/this.paper.view.zoom,u=c*c,g=0,f=o;g<f.length;g++){if((h=f[g]).bounds.area<u){d=h;break}}if(d)this.hitItem=d;else if(r&&r.length>0)this.hitItem=r[0].item;else for(var p=this.getAllItems(),m=0;m<p.length;m++){var v=p[m];if(v.isMaskPath&&v.contains(e))return void(!v.visibile&&v.item?this.hitItem=v.item:this.hitItem=v)}}}},generateBoundsTest:function(e,t,i){var n=new this.paper.Size(e,t),a=new this.paper.Path.Rectangle(i,n);return a.strokeColor="red",a.strokeWidth=3,a.position=i,a},updatePaper:function(){this.paper.project.view.update()},captureInitialSelectionState:function(e){if(this.selectionBounds){this.originalPositions=this.captureSelectionPosition(),this.originalContent=this.captureSelectionState(),this.pivot=this.selectionBounds.center.clone(),this.corner=this.selectionBounds.bottomRight.clone(),this.cornerLeft=this.selectionBounds.leftCenter,this.cornerRight=this.selectionBounds.rightCenter,this.cornerTop=this.selectionBounds.topCenter,this.cornerBottom=this.selectionBounds.bottomCenter,this.originalSize=this.corner.subtract(this.pivot),this.originalCenter=this.selectionBounds.center,this.originalScaleCenter=this.selectionBounds.center;var t=this.getSelectedItems();if(t&&1==t.length){var i=t[0];i.data&&i.data.rect&&(this.originalCenter=i.data.rect.center)}this.originalShape=this.selectionBoundsShape.exportJSON({asString:!1});var n=e.subtract(this.originalCenter);this.originalAngle=Math.atan2(n.y,n.x);for(var a=this.getAllItems(),r=this.getSelectedItems(),o=[],s=1==r.length?this.getItemArea(r[0]):null,l=0;l<a.length;l++){var h=a[l];if(h&&h.data&&h.data.guid&&!h.data.isArea&&!h.guide&&h!=r[0]&&!h.data.isGroupForBackground&&!h.data.isClippingAreaForBackground&&!h.data.isImageForBackground)this.findDesignItemForItem(h).inOnArea(s)&&o.push(h)}this.snapCache={selectedItems:r,areaItems:o,area:s,areaItem:this.findItemForArea(s)}}},clampView:function(){},onKeyDown:function(e){},onKeyUp:function(e){if(!this.frozen){this.beginDesignOperation(),e.preventDefault(),e.stopPropagation();var t=1;e.modifiers.control&&(t=.5);var i=e.event&&e.event.target&&-1!=["INPUT","TEXTAREA"].indexOf(e.event.target.tagName);"delete"!=e.key||i?"right"!=e.key||i?"left"!=e.key||i?"up"!=e.key||i?"down"!=e.key||i||this.moveSelectionByDelta(0,t):this.moveSelectionByDelta(0,-t):this.moveSelectionByDelta(-t,0):this.moveSelectionByDelta(t,0):this.deleteSelection(),this.endDesignOperation()}},getItemAtPoint:function(e){var t=null,i=4;this.paper.view.zoom>1&&(i=0);var n=this;if(e){var a=this.paper.project.hitTest(e,{fill:!0,stroke:!0,tolerance:i,match:function(e){return!(n.mask&&e.item==n.mask||e.item.isClippingArea)}});if(a.item){var r=this.getRootDesignItemCanvasItem(a.item);t=r||a.item}}return t},selectItemAtPoint:function(e){e||this.deselectAll();var t=this.getItemAtPoint(e);!t||t==this.imageItem||t.data&&t.data.isArea?this.deselectAll():this.setItemSelection(t,!0)},selectElement:function(){if(this.hitItem){var e=this.getRootDesignItemCanvasItem(this.hitItem),t=this.getSelectedItems(),i=t.length>0?t[0]:null;if(!this.findDesignItemForItem(e))return void(this.hitItem.data&&this.hitItem.data.isArea&&this.deselectAll());if(e&&(null==i||i!=e)){if(this.element=e,this.isItemStatic(this.element)||e.data&&(e.data.isAreaForBackground||e.data.isGroupForBackground||e.data.isClippingAreaForBackground))return void this.deselectAll();this.deselectAll(),this.setItemSelection(this.element,!0),i&&this.setItemSelection(i,!1)}}else this.deselectAll()},createElement:function(e){!this.frozen&&this.mouseStartPos&&(this.beginDesignOperation(),this.elementType==MPlaza.CustomizerElementType.Rectangle?this.createRectangle(e):this.elementType==MPlaza.CustomizerElementType.Oval?this.createEllipse(e):this.elementType==MPlaza.CustomizerElementType.Free?this.createFreeHand(e):this.elementType==MPlaza.CustomizerElementType.Text&&this.createText(e),this.endDesignOperation())},createRectangle:function(e){if(e.point){var t=e.point;if(this.element&&this.element.remove(),this.mouseStartPos&&t){var i=this.mouseStartPos,n=t;this.element=new this.paper.Path.Rectangle(i,n),this.element.strokeColor="black",this.element.strokeWidth=1,this.element.fillColor="lavender",Logger.info("Rectangle created")}this.paper.project.view.update()}},createEllipse:function(e){if(e.point){var t=e.point;if(this.element&&this.element.remove(),this.mouseStartPos&&t){var i=this.mouseStartPos,n=t,a=new this.paper.Rectangle(i,n);this.element=new this.paper.Path.Ellipse(a),this.element.strokeColor="black",this.element.strokeWidth=1,this.element.fillColor="lavender",Logger.info("Ellipse created")}this.paper.project.view.update()}},createLine:function(e){if(e.point){var t=e.point;if(this.element&&this.element.remove(),this.mouseStartPos&&t){var i=this.mouseStartPos,n=t;this.element=new this.paper.Path.Line(i,n),this.element.strokeColor="black",this.element.strokeWidth=1,Logger.info("Line created")}this.paper.project.view.update()}},createFreeHand:function(e){if(e.point){var t=e.point;if(t){if(!this.element){this.element=new this.paper.Path;new this.paper.Rectangle(t.x-2,t.y-2,4,4);this.element.strokeColor="black",this.element.strokeWidth=1,this.element.fillColor="lavender"}this.element.add(t),this.paper.project.view.update()}}},sendSelectionToBack:function(){this.beginDesignOperation();for(var e=this.getSelectedItems(),t=0;t<e.length;t++){e[t].sendToBack()}this.imageItem&&this.imageItem.sendToBack(),this.onItemsUpdated(e),this.updateItemsIndexes(),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()},bringSelectionToFront:function(){this.beginDesignOperation();for(var e=this.getSelectedItems(),t=0;t<e.length;t++){e[t].bringToFront()}this.onItemsUpdated(e),this.updateItemsIndexes(),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()},moveSelectionToCenter:function(){if(this.canMoveSelection()){this.beginDesignOperation();for(var e=this.getSelectedItems(),t=null,i=0;i<e.length;i++){var n=e[i],a=this.getAreasIntersectingOrContainingItem(n);if(a.length>1||0==a.length)return;if(null==t)t=a[0];else if(t.get("areaID")!=a[0].get("areaID"))return}if(t){var r=this.findItemForArea(t);if(r){for(i=0;i<e.length;i++){n=e[i];var o=r.position.subtract(n.position);n.position.x=r.position.x,n.position.y=r.position.y,n.data.needsTransformsDataUpdate=!0;var s=(new this.paper.Matrix).translate(o.x,o.y);(n instanceof this.paper.Raster||this.getItemIsTextArt(n)||this.isMaskedImage(n))&&n.data&&n.data.originalMatrix&&n.data.originalMatrix.prepend(s),n.data&&n.data.originalPosition&&(n.data.originalPosition=n.data.originalPosition.transform(s)),this.onTextOnPathMoved(n,o),this.onTextAreaMoved(n,o)}this.onItemsUpdated(e),this.updateSelectionState(),this.paper.project.view.update()}}this.endDesignOperation()}},moveSelectionByDelta:function(e,t){if(!this.frozen&&this.canMoveSelection()){var i=!1;this.currentDesignOperation||(this.beginDesignOperation(),i=!0),this.removeSelectionAlertItems();for(var n=new this.paper.Point(e,t),a=this.getSelectedItems(),r=0;r<a.length;r++){a[r].position=a[r].position.add(n);var o=(new this.paper.Matrix).translate(n.x,n.y);(a[r]instanceof this.paper.Raster||this.getItemIsTextArt(a[r])||this.isMaskedImage(a[r]))&&a[r].data&&a[r].data.originalMatrix&&a[r].data.originalMatrix.prepend(o),a[r].data&&a[r].data.originalPosition&&(a[r].data.originalPosition=a[r].data.originalPosition.transform(o)),this.onTextOnPathMoved(a[r],n),this.onTextAreaMoved(a[r],n)}this.onItemsUpdated(a),this.updateSelectionState(),this.paper.project.view.update(),i&&this.endDesignOperation()}},moveSelectionUp:function(){this.canMoveSelection()&&this.moveSelectionByDelta(0,-2)},moveSelectionDown:function(){this.canMoveSelection()&&this.moveSelectionByDelta(0,2)},moveSelectionLeft:function(){this.canMoveSelection()&&this.moveSelectionByDelta(-2,0)},moveSelectionRight:function(){this.canMoveSelection()&&this.moveSelectionByDelta(2,0)},moveSelection:function(e){var t=this;if(!this.frozen&&this.canMoveSelection()&&e.delta){var i=e.delta;this.hideCenterLines(),null!=this.adjustmentDelta&&(i.x-=this.adjustmentDelta.x,i.y-=this.adjustmentDelta.y),!0===this.canMove&&(!1===this.canMoveX&&(i.x=0),!1===this.canMoveY&&(i.y=0)),this.removeSelectionAlertItems();var n=this.getSelectedItems();if(0!=n.length){for(var a=0;a<n.length;a++){var r=n[a];this.getSubItemsToChange(r).forEach(function(e){if(e){e.position.x+=i.x,e.position.y+=i.y;var n=(new t.paper.Matrix).translate(i.x,i.y);e.data&&e.data.originalMatrix&&e.data.originalMatrix.prepend(n),e.data&&e.data.originalPosition&&(e.data.originalPosition=e.data.originalPosition.transform(n))}}),this.onTextOnPathMoved(n[a],i),this.onTextAreaMoved(n[a],i)}this.moveSelectionShapes(i),this.snapToCenter(),this.snapToItems(),this.updateTextOnPathGuides(n),this.updateTextAreaGuides(n),this.updateShapeImagePlaceholders(n),!this.adjustmentDelta||0==this.adjustmentDelta.x&&0==this.adjustmentDelta.y||this.moveSelectionShapes(this.adjustmentDelta);for(a=0;a<n.length;a++)n[a].data.maskPath&&(n[a].data.maskPath.position=n[a].position),n[a].loadingCircle&&(n[a].loadingCircle.position=n[a].bounds.center)}}},cacheSelectedItemConstraints:function(e){var t,i,n;if(e){var a=e.get("constraints");this.canMove=null===(t=null==a?void 0:a.get("canMove"))||void 0===t||t,this.canMoveX=null===(i=null==a?void 0:a.get("canMoveX"))||void 0===i||i,this.canMoveY=null===(n=null==a?void 0:a.get("canMoveY"))||void 0===n||n}},snapToCenter:function(){var e=this;this.adjustmentDelta||(this.adjustmentDelta=new this.paper.Point(0,0)),this.adjustmentDelta.x=0,this.adjustmentDelta.y=0;var t=3/this.paper.view.zoom;if(this.snapCache&&this.snapCache.area&&this.snapCache.areaItem){for(var i=this.snapCache.areaItem,n=this.snapCache.selectedItems,a=i.bounds,r=this.selectionBounds,o=a.center,s=[new this.paper.Point(r.left,r.center.y),r.center,new this.paper.Point(r.right,r.center.y)],l=[new this.paper.Point(r.center.x,r.top),r.center,new this.paper.Point(r.center.x,r.bottom)],h=null,d=null,c=0;c<s.length;c++){var u=s[c].x-o.x,g=Math.abs(u);(null==h||g<h)&&(h=g,d=u)}var f=null,p=null;for(c=0;c<l.length;c++){u=l[c].y-o.y,g=Math.abs(u);(null==f||g<f)&&(f=g,p=u)}var m=null;h<=t&&(m=d);var v=null;f<=t&&(v=p),this.adjustmentDelta.x=null!=m?-m:0,this.adjustmentDelta.y=null!=v?-v:0;for(c=0;c<n.length;c++){var I=n[c];this.getSubItemsToChange(I).forEach(function(t){null!=m&&(t.position.x-=m),null!=v&&(t.position.y-=v);var i=null!=m?(new e.paper.Matrix).translate(-m,0):null,n=null!=v?(new e.paper.Matrix).translate(0,-v):null;t.data&&t.data.originalMatrix&&(i&&t.data.originalMatrix.prepend(i),n&&t.data.originalMatrix.prepend(n)),t.data&&t.data.originalPosition&&(i&&(t.data.originalPosition=t.data.originalPosition.transform(i)),n&&(t.data.originalPosition=t.data.originalPosition.transform(n)))}),null==m&&null==v||(this.onTextOnPathMoved(I,this.adjustmentDelta),this.onTextAreaMoved(I,this.adjustmentDelta))}null==m&&null==v||(null!=m&&this.showVerticalCenterLine(a),null!=v&&this.showHorizontalCenterLine(a))}},snapToItems:function(){var e=this,t=3/this.paper.view.zoom;if(0!=this.snapCache.selectedItems.length&&this.snapCache&&this.snapCache.area&&this.snapCache.areaItem){var i=this.snapCache.areaItem,n=this.snapCache.selectedItems,a=(this.getAllItems(),null),r=null,o=null,s=null;for(S=0;S<this.snapCache.areaItems.length;S++){for(var l=this.snapCache.areaItems[S],h=(l.bounds,n[0].bounds.leftCenter),d=n[0].bounds.rightCenter,c=n[0].bounds.topCenter,u=n[0].bounds.bottomCenter,g=n[0].bounds.center,f=[g,h,d],p=[g,c,u],m=[l.bounds.center,l.bounds.leftCenter,l.bounds.rightCenter],v=[l.bounds.center,l.bounds.topCenter,l.bounds.bottomCenter],I=0;I<f.length;I++){var y=f[I].x,C=m[I].x;if(Math.abs(y-C)<t){a=y-C,o=C,this.adjustmentDelta.x-=a;break}}for(I=0;I<p.length;I++){var M=p[I].y,x=v[I].y;if(Math.abs(M-x)<t){r=M-x,s=x,this.adjustmentDelta.y-=r;break}}if(null!=a||null!=r)break}for(var S=0;S<n.length;S++){var b=n[S];if(this.getSubItemsToChange(b).forEach(function(t){if(null!=a&&(t.position.x-=a),null!=r&&(t.position.y-=r),null!=a||null!=r){var i=null!=a?-a:0,n=null!=r?-r:0,o=(new e.paper.Matrix).translate(i,n);t.data.originalMatrix&&t.data.originalMatrix.prepend(o),t.data.originalPosition&&(t.data.originalPosition=t.data.originalPosition.transform(o))}}),null!=a||null!=r){var w=null!=a?-a:0,A=null!=r?-r:0;this.onTextOnPathMoved(b,new this.paper.Point(w,A)),this.onTextAreaMoved(b,new this.paper.Point(w,A))}}null==a&&null==r||(this.hideCenterLines(),null!=a&&this.showVerticalCenterLine(new this.paper.Rectangle(o-1,i.bounds.topCenter.y,1,i.bounds.bottomCenter.y)),null!=r&&this.showHorizontalCenterLine(new this.paper.Rectangle(i.bounds.leftCenter.x,s,i.bounds.rightCenter.x,1)))}},showVerticalCenterLine:function(e){var t=this.paper.project.view.bounds,i=new this.paper.Point(e.center.x,t.top),n=new this.paper.Point(e.center.x,t.bottom),a=this.getGuideLineFirstColorOptions();this.verticalCenterLine=this.createGuideLine(i,n,a);var r=this.getGuideLineSecondColorOptions();this.verticalCenterLineSecondColor=this.createGuideLine(i,n,r)},showHorizontalCenterLine:function(e){var t=this.paper.project.view.bounds,i=new this.paper.Point(t.left,e.center.y),n=new this.paper.Point(t.right,e.center.y),a=this.getGuideLineFirstColorOptions();this.horizontalCenterLine=this.createGuideLine(i,n,a);var r=this.getGuideLineSecondColorOptions();this.horizontalCenterLineSecondColor=this.createGuideLine(i,n,r)},getGuideLineFirstColorOptions:function(){return{color:"blue",dashOffset:.5/this.paper.view.zoom}},getGuideLineSecondColorOptions:function(){return{color:"red",dashOffset:2.5/this.paper.view.zoom}},createGuideLine:function(e,t,i){var n,a,r=null!==(n=i.color)&&void 0!==n?n:"blue",o=null!==(a=i.dashOffset)&&void 0!==a?a:.5/this.paper.view.zoom,s=new this.paper.Point(.5/this.paper.view.zoom,.5/this.paper.view.zoom),l=e.add(s),h=t.add(s),d=new this.paper.Path.Line(l,h);return d.strokeColor=r,d.strokeWidth=1/this.paper.view.zoom,d.dashOffset=o,d.dashArray=[1/this.paper.view.zoom,3/this.paper.view.zoom],d.removeOn({drag:!0,up:!0}),d.guide=!0,d},hideCenterLines:function(){this.verticalCenterLine&&this.verticalCenterLine.remove(),this.verticalCenterLineSecondColor&&this.verticalCenterLineSecondColor.remove(),this.horizontalCenterLine&&this.horizontalCenterLine.remove(),this.horizontalCenterLineSecondColor&&this.horizontalCenterLineSecondColor.remove(),this.verticalCenterLine=null,this.verticalCenterLineSecondColor=null,this.horizontalCenterLine=null,this.horizontalCenterLineSecondColor=null},rotateSelection:function(e){var t=this;if(!this.frozen&&this.canRotateSelection()&&e.point){var i=e.point;this.removeSelectionAlertItems(),this.hideCenterLines();var n=this.getSelectedItems();if(1==n.length){var a=n[0],r=i.subtract(this.originalCenter),o=Math.atan2(r.y,r.x)-this.originalAngle;this.restoreSelectionState(this.originalContent);var s=this.selectionBoundsShape.id;this.selectionBoundsShape.importJSON(this.originalShape),this.selectionBoundsShape._id=s;for(var l=o/Math.PI*180,h=[0,90,180,270,360,-90,-180,-270,-360],d=0;d<h.length;d++){var c=h[d],u=a.rotation;a.data.isTextArea&&(u=a.children[0].rotation),Math.abs(l+u-c)<5&&(l=c-u,0!=c&&180!=c&&-180!=c||this.showHorizontalCenterLine(a.bounds),90!=c&&-90!=c||this.showVerticalCenterLine(a.bounds))}if(this.selectionBoundsShape.rotate(l,this.originalCenter),this.createSelectionHandles(),this.placeHandleOut(this.selectionBoundsShape),!a.guide)this.getSubItemsToChange(a).forEach(function(e){if(e.rotate(l,t.originalCenter),e.data.originalMatrix){var i=(new t.paper.Matrix).rotate(l,t.originalCenter);e.data.originalMatrix.prepend(i)}if(e.data.originalPosition){i=(new t.paper.Matrix).rotate(l,t.originalCenter);e.data.originalPosition=e.data.originalPosition.transform(i)}}),this.onTextOnPathRotated(a,l,this.originalCenter),this.onTextAreaRotated(a,l,this.originalCenter),this.updateTextOnPathGuides(n),this.updateTextAreaGuides(n),this.updateShapeImagePlaceholders(n)}}},rotateSelectionAngle:function(e){var t=this;this.removeSelectionAlertItems(),this.restoreSelectionState(this.originalContent);var i=this.selectionBoundsShape.id;this.selectionBoundsShape.importJSON(this.originalShape),this.selectionBoundsShape._id=i,this.selectionBoundsShape.rotate(e,this.originalCenter),this.createSelectionHandles();for(var n=this.getSelectedItems(),a=0;a<n.length;a++){var r=n[a];if(!r.guide)this.getSubItemsToChange(r).forEach(function(i){if(i.rotate(e,t.originalCenter),i.data.originalMatrix){var n=(new t.paper.Matrix).rotate(e,t.originalCenter);i.data.originalMatrix.prepend(n)}if(i.data.originalPosition){n=(new t.paper.Matrix).rotate(e,t.originalCenter);i.data.originalPosition=i.data.originalPosition.transform(n)}}),this.onTextOnPathRotated(r,e,this.originalCenter),this.onTextAreaRotated(r,e,this.originalCenter)}this.updateTextOnPathGuides(n),this.updateTextAreaGuides(n)},resizeSelection:function(e){if(!this.frozen&&this.canResizeSelection()&&(e.point&&(this.removeSelectionAlertItems(),0!=this.getSelectedItems().length))){var t=this.originalScaleCenter.clone(),i=this.corner.subtract(t),n=e.point,a=new this.paper.Point;a.x=n.x-this.selectionResizeHandle.bounds.width/2,a.y=n.y-this.selectionResizeHandle.bounds.width/2;var r=this.projectPointOnLine(t,this.corner,a,!1);if(!(r.subtract(t).length<.1)){var o=r.subtract(this.corner);this.corner.x+=o.x,this.corner.y+=o.y;var s=this.corner.subtract(t),l=1,h=1;Math.abs(i.x)>1e-7&&(l=s.x/i.x),Math.abs(i.y)>1e-7&&(h=s.y/i.y),this.scaleSelectedItems(l,h,t)}}},resizeSelectionTop:function(e){this.resizeSelectionLaterally(e,"top")},resizeSelectionBottom:function(e){this.resizeSelectionLaterally(e,"bottom")},resizeSelectionLeft:function(e){this.resizeSelectionLaterally(e,"left")},resizeSelectionRight:function(e){this.resizeSelectionLaterally(e,"right")},resizeSelectionLaterally:function(e,t){if(!this.frozen&&this.canResizeSelection()&&(e.point&&(this.removeSelectionAlertItems(),0!=this.getSelectedItems().length))){var i=this.originalScaleCenter.clone(),n=this._getResizeCorner(t),a=n.subtract(i),r=e.point,o=this._getResizeCompensatedPoint(t,r),s=0,l=0;"top"===t||"bottom"===t?l=o.y-n.y:s=o.x-n.x,this._moveResizeCorner(t,s,l);var h=n.subtract(i),d=1,c=1;"top"===t||"bottom"===t?c=Math.abs(h.y/a.y):d=Math.abs(h.x/a.x),this.scaleSelectedItems(d,c,i)}},_getResizeCorner:function(e){var t=this.corner;return"top"===e?t=this.cornerTop:"bottom"===e?t=this.cornerBottom:"left"===e?t=this.cornerLeft:"right"===e&&(t=this.cornerRight),t},_moveResizeCorner:function(e,t,i){"top"===e?(this.cornerTop.x+=t,this.cornerTop.y+=i):"bottom"===e?(this.cornerBottom.x+=t,this.cornerBottom.y+=i):"left"===e?(this.cornerLeft.x+=t,this.cornerLeft.y+=i):"right"===e?(this.cornerRight.x+=t,this.cornerRight.y+=i):(this.corner.x+=t,this.corner.y+=i)},_getResizeCompensatedPoint:function(e,t){var i=new this.paper.Point;return"all"===e?(i.x=t.x-this.selectionResizeHandle.bounds.width/2,i.y=t.y-this.selectionResizeHandle.bounds.width/2):(i.x=t.x-this.selectionLateralResizeDimension/2,i.y=t.y-this.selectionLateralResizeDimension/2),i},projectPointOnLine:function(e,t,i,n){var a=new this.paper.Point(0,0);if(e.x==t.x)return a.x=e.x,a.y=i.y,a;if(e.y==t.y)return a.x=i.x,a.y=e.y,a;var r=(t.y-e.y)/(t.x-e.x),o=(t.x*e.y-e.x*t.y)/(t.x-e.x),s=i.y-r*i.x-o;return n?s>0?(a.x=i.x,a.y=r*i.x+o):s<0?(a.y=i.y,a.x=(i.y-o)/r):a=i:s>0?(a.y=i.y,a.x=(i.y-o)/r):s<0?(a.x=i.x,a.y=r*i.x+o):a=i,a},scaleItem:function(e,t,i,n){var a=this;if(e){if(!this.canScaleTextFont(e,t,i))return;var r=this.getSubItemsToChange(e);if(!this.canResizeSelectedTextAreas(t,i,n))return;r.forEach(function(e){if(e.scale(t,i,n),e.data.needsTransformsDataUpdate=!0,e.data.originalMatrix){var r=(new a.paper.Matrix).scale(t,i,n);e.data.originalMatrix.prepend(r)}if(e.data.originalPosition){r=(new a.paper.Matrix).scale(t,i,n);e.data.originalPosition=e.data.originalPosition.transform(r)}}),this.onTextOnPathScaled(e,t,i,n),this.onTextAreaScaled(e,t,i,n),this.updateTextOnPathGuides([e]),this.updateTextAreaGuides([e]),this.updateShapeImagePlaceholders([e]),this.updateSelectionState()}},scaleSelectedItems:function(e,t,i){var n=this;if(e<0||t<0){var a=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(this.side.get("areas").at(0)));if(a&&a.get("printTypeRestrictions")&&!1===a.get("printTypeRestrictions").get("showFlipButtons"))return}if(this.canResizeSelection()&&this.canScaleSelectedTextFont(e,t)&&this.canResizeSelectedTextAreas(e,t,i)){for(var r=this.getSelectedItems(),o=0;o<r.length;o++){var s=r[o];if(!s.guide)this.getSubItemsToChange(s).forEach(function(a){if(a.scale(e,t,i),a.data.needsTransformsDataUpdate=!0,a.data.originalMatrix){var r=(new n.paper.Matrix).scale(e,t,i);a.data.originalMatrix.prepend(r)}if(a.data.originalPosition){r=(new n.paper.Matrix).scale(e,t,i);a.data.originalPosition=a.data.originalPosition.transform(r)}}),this.onTextOnPathScaled(s,e,t,i),this.onTextAreaScaled(s,e,t,i)}this.scaleSelectionShapes(e,t,i),this.updateTextOnPathGuides(r),this.updateTextAreaGuides(r),this.updateShapeImagePlaceholders(r)}},deleteSelection:function(){var e=this;if(this.canDeleteSelection()){this.removeSelectionAlertItems();for(var t,i,n=this.getSelectedItems(),a=function(){if(t=n[o],r.deleteDimensionLabel(t.id),r.isMaskedImage(t)&&!r.isFilledShape(t)&&r.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&r.canDeleteMask(t))r.removeMaskFromImage(t);else if(r.isFilledShape(t)&&r.maskedImageSelectionMode==MaskedImageSelectionMode.Raster)r.removeImageFromShape(t);else{if((i=r.findDesignItemForItem(t))&&r.fireDesignItemRemovingEvent(i,t),t.data&&t.data.isGridImage){var a=t.parent;a&&a.data&&a.data.isGridPathGroup&&r.createGridBoxIcon().then(function(t){var i,n,r=a.children.find(function(e){return e.data&&e.data.isGridBorderPath});r&&(r.fillColor=new paper.Color(1,1,1,.9)),a.addChild(t);var o=e.isMobile?Math.min(Math.min(a.bounds.width,a.bounds.height),180):Math.min(.8*Math.min(a.bounds.width,a.bounds.height),66);(null===(i=null==a?void 0:a.data)||void 0===i?void 0:i.smallestCameraIconDim)&&(o=null===(n=null==a?void 0:a.data)||void 0===n?void 0:n.smallestCameraIconDim),t.data.isGridIcon=!0,t.position.x=a.position.x,t.position.y=a.position.y;var s=e.getIconPosition(a);s&&(t.position.x=s.x,t.position.y=s.y),t.scale(o/t.bounds.width,o/t.bounds.height)})}t.remove(),r.onItemRemoved(t),r.removeShapeImagePlaceholder(t),r.setItemSelection(t,!1)}},r=this,o=0;o<n.length;o++)a();this.updateSelectionState(),this.paper.project.view.update()}},editElement:function(){!this.frozen&&this.mouseStartPos&&this.elementType==MPlaza.CustomizerElementType.Text&&this.editText()},updateItemSyncGuid:function(e,t){var i=this.findDesignItemForItem(e);i&&i.set("syncGuid",t)},getContrastedColor:function(e){var t="black";if(this.imageItem){e.height=Math.max(1,e.height),e.width=Math.max(1,e.width);try{var i=this.imageItem.getAverageColor(e);i&&(t=MPlaza.getContrastYIQ(255*i.red,255*i.green,255*i.blue))}catch(e){console.trace("error getting image avarage color "+e.message)}}return t},insertSVGFromUrl:function(e){var t=this;$.ajax({url:e}).done(function(e){t.insertSVG(e)})},insertSVG:function(e){if(this.side){var t=this.side.get("areas").getMaxArea();if(t){var i=this.paper.project.activeLayer.importSVG(e);this.onItemCreated(i),this.detectItemColors(i);var n=this.findItemForArea(t);if(n){i.position=n.position;var a=i.bounds,r=n.bounds;if(r.intersects(a)||a.contains(r)){var o=r.clone();o.width*=.8,o.height*=.8;var s=1,l=1;Math.abs(o.width)>1e-7&&(s=o.width/a.width),Math.abs(o.height)>1e-7&&(l=o.height/a.height);var h=s>0?1:-1,d=l>0?1:-1;s=l=Math.min(Math.abs(s),Math.abs(l)),s*=h,l*=d,i.scale(s,l),this.masterGroup.addChild(i),this.updateItemsIndexes(),this.onItemUpdated(i),this.onDesignItemChanged(i),this.mask&&this.mask.bringToFront}}}}},detectItemColors:function(e){var t=[],i=function(e){if(e.fillColor){var n=e.fillColor.toCSS(!0);-1===t.indexOf(n)&&t.push(n)}if(e.children)for(var a=0;a<e.children.length;a++){var r=e.children[a];i(r)}};i(e);for(var n=0;n<t.length;n++)Logger.info("Color: "+t[n])},resetShadows:function(e){var t=this,i=this.getLastUndoOperationId();this.beginDesignOperation(),e.filter(this.getItemIsTextElement).forEach(function(e){return t.resetTextElementShadow(e)}),e.filter(this.getItemIsTextArt).forEach(function(e){return t.resetTextArtShadow(e)}),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(i)},insertTextArt:function(e,t){if(e&&this.canAddTextArt()){this.beginDesignOperation();var i=this;Zakeke.Customizer.TextArt.createTextArtPath(e.typrFont,e.opentypeFont,e.text,void 0,void 0,e.config).then(function(n){if(n&&i.side){var a=i.side.get("areas").getMaxArea();if(a){var r=i.getDesignEffectForArea(a);i.allowShadows()||(e.style.shadowColor=null);var o=null!=e.style.strokeWidth?e.style.strokeColor:void 0,s=e.style.fillColor,l=e.style.shadowColor;o=i.forceColorInFixedPalette(null,o),s=i.forceColorInFixedPalette(null,s),l=i.forceColorInFixedPalette(null,l),e.style.strokeColor=i.applyDesignEffectToTextColor(r,o),e.style.fillColor=i.applyDesignEffectToTextColor(r,s),e.style.shadowColor=i.applyDesignEffectToTextColor(r,l),e.style.shadowBlur=i.adjustInputShadowBlur(null,e.style.shadowBlur),e.style.shadowDistance=i.adjustInputShadowDistance(null,e.style.shadowDistance),e.style.shadowAngle=i.adjustInputShadowDistance(null,e.style.shadowAngle);var h=new i.paper.CompoundPath(n);i.applyStyleToItem(h,e.style),h.applyMatrix=!0,h.data={},h.data.isTextArt=!0,h.data.originalBounds=h.bounds,h.data.originalMatrix=new i.paper.Matrix,h.data.originalStrokeColor=o,h.data.originalFillColor=s,h.data.originalShadowColor=l,i.applyDesignEffectToItem(r,h);i.onTextArtItemCreated(h,e);var d=i.findItemForArea(a);if(d){var c=d.position.subtract(h.position);h.position.x+=c.x,h.position.y+=c.y;var u=(new i.paper.Matrix).translate(c.x,c.y);h.data.originalMatrix.prepend(u);var g=h.bounds,f=d.bounds;if(f.intersects(g)||g.contains(f)){var p=f.clone();p.width*=.8,p.height*=.8;var m=1,v=1;Math.abs(p.width)>1e-7&&(m=p.width/g.width),Math.abs(p.height)>1e-7&&(v=p.height/g.height);var I=m>0?1:-1,y=v>0?1:-1;m=v=Math.min(Math.abs(m),Math.abs(v)),m*=I,v*=y,h.scale(m,v),u=(new i.paper.Matrix).scale(m,v),h.data.originalMatrix.prepend(u),i.masterGroup.addChild(h),i.onItemUpdated(h),i.updateItemsIndexes(),i.onDesignItemChanged(h),i.fireTextArtLoadedEvent(),i.mask&&i.mask.bringToFront(),t&&t(h),i.endDesignOperation()}}}}})}},buildTextArtPathElement:function(e,t){return'<path xmlns="http://www.w3.org/2000/svg" d="'+e+'" />'},replaceSelectedTextArt:function(e,t){if(e&&this.design){var i=this.getSelectedTextArtItems();if(i&&i.length>0){var n=i[0];if(!this.canEditItem(n))return;this.replaceTextArt(n,e,t)}}},replaceItemTextArt:function(e,t,i){if(e&&this.design&&t){if(!this.canEditItem(t))return;this.replaceTextArt(t,e,i)}},replaceTextArtByGuid:function(e,t,i){var n=this.findItemByGuid(e);n&&this.replaceTextArt(n,t,i)},replaceTextArt:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n=this;return __generator(this,function(a){switch(a.label){case 0:return[4,new Promise(function(a,r){if(n.canEditItem(e)){var o=n;t.text=n.adjustInputTextByConstraints(e,t.text)||t.text,n.beginDesignOperation(),Zakeke.Customizer.TextArt.createTextArtPath(t.typrFont,t.opentypeFont,t.text,void 0,void 0,t.config).then(function(n){if(n){var r=o.findDesignItemByGuid(e.data.guid);if(r){var s=o.getDesignEffectForDesignItem(r);o.allowShadows()||(t.style.shadowColor=null);var l=null!=t.style.strokeWidth?t.style.strokeColor:void 0,h=t.style.fillColor,d=t.style.shadowColor;l=o.forceColorInFixedPalette(e,l),h=o.forceColorInFixedPalette(e,h),d=o.forceColorInFixedPalette(e,d),t.style.strokeColor=o.applyDesignEffectToTextColor(s,l),t.style.fillColor=o.applyDesignEffectToTextColor(s,h),t.style.shadowColor=o.applyDesignEffectToTextColor(s,d),t.style.shadowBlur=o.adjustInputShadowBlur(e,t.style.shadowBlur),t.style.shadowDistance=o.adjustInputShadowDistance(e,t.style.shadowDistance),t.style.shadowAngle=o.adjustInputShadowDistance(e,t.style.shadowAngle);var c=e.bounds.width,u=e.bounds.height,g=new o.paper.CompoundPath(n);g.visible=!1,o.applyStyleToItem(g,t.style),g.transform(e.data.originalMatrix),g.position=e.position,e.removeChildren(),e.copyContent(g);var f=e.data;e.copyAttributes(g),e.data=f,e.visible=!0,e.data.originalStrokeColor=l,e.data.originalFillColor=h,e.data.originalShadowColor=d,e.data.isProfanityCheckInvalid=!1,o.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),g.remove();var p=e.bounds.width,m=e.bounds.height,v=1,I=1;p>0&&Math.abs(c)>1e-7&&(v=c/p),m>0&&Math.abs(u)>1e-7&&(I=u/m),e.scale(v,I);var y=(new o.paper.Matrix).scale(v,I);e.data.originalMatrix.prepend(y),o.onTextArtItemUpdated(e,t),t.isDirty&&o.onDesignItemChanged(e),o.updateSelectionState(),o.paper.project.view.update(),o.endDesignOperation(),i&&i(e),o.fireTextArtLoadedEvent(),a()}}})}})];case 1:return a.sent(),[2]}})})},changeTextArtStyle:function(e,t,i){if(this.canEditItem(e)&&e&&e instanceof this.paper.Item){this.beginDesignOperation();var n=this.findDesignItemByGuid(e.data.guid),a=this.getDesignEffectForDesignItem(n);this.allowShadows()||(t.shadowColor=null);var r=t.strokeColor,o=t.fillColor,s=t.shadowColor;r=this.forceColorInFixedPalette(e,r,i),o=this.forceColorInFixedPalette(e,o,i),s=this.forceColorInFixedPalette(e,s,i),t.strokeColor=this.applyDesignEffectToTextColor(a,r),t.fillColor=this.applyDesignEffectToTextColor(a,o),t.shadowColor=this.applyDesignEffectToTextColor(a,s),t.shadowBlur=this.adjustInputShadowBlur(e,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(e,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(e,t.shadowAngle),this.applyStyleToItem(e,t),e.data.originalStrokeColor=r,e.data.originalFillColor=o,e.data.originalShadowColor=s,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}},applyStyleToItem:function(e,t){if(e&&e instanceof this.paper.Item&&(null!=t.strokeColor&&(e.strokeColor=t.strokeColor),null!=t.strokeWidth&&(e.strokeWidth=t.strokeWidth),t.strokeCap&&(e.strokeCap=t.strokeCap),t.strokeJoin&&(e.strokeJoin=t.strokeJoin),null!=t.dashOffset&&(e.dashOffset=t.dashOffset),t.dashArray&&(e.dashArray=t.dashArray),t.fillColor&&!this.isFilledShape(e)&&(e.fillColor=t.fillColor),null!=t.shadowColor&&!this.isShape(e)&&!this.isMaskedImageShapeItem(e)&&!this.isMaskedImageMaskItem(e))){e.shadowColor=t.shadowColor,e.shadowBlur=t.shadowBlur;var i=0,n=0;t.hasOwnProperty("shadowDistance")&&(i=t.shadowDistance),t.hasOwnProperty("shadowAngle")&&(n=t.shadowAngle),e.shadowOffset=this.getOffsetByDistanceAngle(i,n)}},getAllTextArtItems:function(){var e=this;return this.getAllItems().filter(function(t){return e.getItemIsTextArt(t)})},resetTextArtShadow:function(e){if(e&&e.data&&e.data.guid&&e.data.isTextArt){var t=this.findDesignItemByGuid(e.data.guid);if(t){this.beginDesignOperation();var i=this.getDesignEffectForDesignItem(t),n=this.getTextArtItemInfo(e);this.allowShadows()||(n.style.shadowColor=null);var a=n.style.shadowColor;a=this.forceColorInFixedPalette(e,a),n.style.shadowColor=this.applyDesignEffectToTextColor(i,a),n.style.shadowBlur=this.adjustInputShadowBlur(e,n.style.shadowBlur),n.style.shadowDistance=this.adjustInputShadowDistance(e,n.style.shadowDistance),n.style.shadowAngle=this.adjustInputShadowDistance(e,n.style.shadowAngle),this.applyStyleToItem(e,n.style),e.data.originalShadowColor=a,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}}},_getRandomColor:function(){return"#"+(16777215*Math.random()<<0).toString(16).padStart(6,"0")},isImageAutofitEnabled:function(e){var t=this.side.get("areas").at(0),i=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(t));return!!i&&(!!i.get("printTypeRestrictions")&&1==i.get("printTypeRestrictions").get("upload"==e?"imageInsertScalingUpload":"imageInsertScalingCliparts"))},isFixedFontListEnabled:function(e){var t,i=this.side.get("areas").at(0),n=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(i));return!!n&&(!!n.get("printTypeRestrictions")&&(null===(t=n.get("printTypeRestrictions").get("fontSizeList"))||void 0===t?void 0:t.length)>0)},insertImageById:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a;return __generator(this,function(r){switch(r.label){case 0:return i=this,(n=new MPlaza.Image).set("imageID",e),[4,new Promise(function(e){n.fetch({success:function(t){e(t)}})})];case 1:return a=r.sent(),[4,i.insertImage(a,t)];case 2:return r.sent(),[2]}})})},insertImage:function(e,t){var i;return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S,b;return __generator(this,function(w){switch(w.label){case 0:return n=null,e&&e instanceof MPlaza.Image?this.canAddImage()?(this.beginDesignOperation(),a="",!this.isImageScalingEnabled&&"svg"!=e.get("format").toLowerCase()&&"vector"!=e.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(t){return t==e.get("format").toLowerCase()})&&(a=e.get("url")),a||(a=e.get("previewUrl")),e.get("overridePreview")&&(null===(i=e.get("connectorSettings"))||void 0===i?void 0:i.length)>0&&(a=e.get("overridePreview")),a?this.side&&(r=this.side.get("areas").getMaxArea())?(o=a,s=this.getDesignEffectForArea(r),[4,this.applyDesignEffectToImageUrl(s,a)]):[3,7]:[2]):[2]:[2];case 1:return a=w.sent(),t?[3,3]:[4,this.getImageDefaultColorMappings(a,null)];case 2:t=w.sent(),w.label=3;case 3:return t&&t.length>0?[4,this.recolorImage(a,t)]:[3,5];case 4:a=w.sent(),w.label=5;case 5:return[4,this.createRasterItem(a)];case 6:(n=w.sent()).data.originalUrl=o,this.applyDesignEffectToItem(s,n),l=this.onItemCreated(n,e),this.updateDesignItemColorMappings(l,t),h=this.getCurrentModel(),(d=this.findItemForArea(r))&&(n.position=d.interiorPoint,c=d.bounds,d instanceof paper.CompoundPath&&d.children.length>0?(u=d.children.sort(function(e,t){return Math.abs(t.area)-Math.abs(e.area)}).at(0),n.position=u.interiorPoint,d.contains(n.position)||(n.position=d.interiorPoint),c=u.bounds):n.position=d.interiorPoint,g=n.bounds,(c.intersects(g)||g.contains(c))&&(f=!1,(e.get("customerID")>0||e.get("visitorID")>0)&&(f=!0),(e.get("visitorCode")||e.get("customerCode"))&&(f=!0),p=this.isImageAutofitEnabled(f?"upload":"cliparts")?1:.8,(m=c.clone()).width*=p,m.height*=p,v=1,I=1,Math.abs(m.width)>1e-7&&(v=m.width/g.width),Math.abs(m.height)>1e-7&&(I=m.height/g.height),y=v>0?1:-1,C=I>0?1:-1,v=I=this.isImageAutofitEnabled(f?"upload":"cliparts")?Math.max(Math.abs(v),Math.abs(I)):Math.min(Math.abs(v),Math.abs(I)),v*=y,I*=C,h&&this.design&&this.design instanceof MPlaza.Design&&h.get("printTypes")instanceof MPlaza.PrintTypes&&this.isImagesFixedSizeEnabled()&&l.get("imagePreferredWidth")&&l.get("imagePreferredHeight")&&(M=this.side.get("ppcm"),x=M/10,S=l.get("imagePreferredWidth")*x,b=l.get("imagePreferredHeight")*x,v=S/g.width,I=b/g.height),n.scale(v,I),n.data.originalBounds=new this.paper.Rectangle(0,0,n.width,n.height),n.data.originalMatrix=n.matrix.clone(),this.onItemUpdated(n),this.onDesignItemChanged(n))),this.masterGroup.addChild(n),this.onItemUpdated(n),this.updateItemsIndexes(),this.onDesignItemChanged(n),this.fireImageLoadedEvent(),this.mask&&this.mask.bringToFront(),this.endDesignOperation(),w.label=7;case 7:return[2,n]}})})},isImagesFixedSizeEnabled:function(){var e,t,i=this.side.get("areas").at(0);if(i){var n=this.getCurrentModel(),a=this.getSelectedPrintType(i),r=n.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(i));a||(a=n.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(i)));var o=null;if(a instanceof MPlaza.PartPrintType){var s=a.get("restrictions");o=s?s.get("useImagesFixedSize"):null}return null==o&&(o=null!==(e=null==r?void 0:r.get("useImagesFixedSize"))&&void 0!==e?e:null===(t=r.get("printTypeRestrictions"))||void 0===t?void 0:t.get("useImagesFixedSize")),o}return!1},replaceSelectedImage:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n;return __generator(this,function(a){switch(a.label){case 0:return e&&e instanceof MPlaza.Image&&this.design&&e.get("previewUrl")?(i=this.getSelectedImageItems())&&i.length>0?(n=i[0],this.canEditItem(n)?[4,this.replaceImage(n,e,t)]:[2,n]):[3,2]:[2,null];case 1:return a.sent(),[2,n];case 2:return[2,null]}})})},replaceImageByGuid:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(a){switch(a.label){case 0:return(n=this.findItemByGuid(e))?[4,this.replaceImage(n,t,i)]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2,n]}})})},replaceImage:function(e,t,i){var n,a;return __awaiter(this,void 0,void 0,function(){var r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x;return __generator(this,function(S){switch(S.label){case 0:return this.canEditItem(e)?(r=t.get("previewUrl"),t.get("overridePreview")&&(null===(n=t.get("connectorSettings"))||void 0===n?void 0:n.length)>0&&(r=t.get("overridePreview")),r?(e.data.isTemplateElement&&(e.data.isTemplateElement=!1),this.beginDesignOperation(),o=this.findDesignItemByGuid(e.data.guid),e.data.isSVGRecolored&&(e.data.isSVGRecolored=!1),e.data.isProfanityCheckInvalid=!1,this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),o&&(o.get("imageID")!==t.get("imageID")||r.startsWith("data:")||(null===(a=t.get("connectorSettings"))||void 0===a?void 0:a.length)>0)?(this.getMaskedImageShapeItem(e),(s=this.getMaskedImageRasterItem(e))?(l=s.width,h=s.height,s.data.originalBounds&&s.data.originalMatrix&&((d=new this.paper.Path.Rectangle(s.data.originalBounds)).visible=!1,d.matrix=s.data.originalMatrix.clone(),c=this.getRectangleItemSize(d),d.remove(),l=c.width,h=c.height),u=s.matrix,g=this.getDesignEffectForDesignItem(o),f=r,[4,this.applyDesignEffectToImageUrl(g,r)]):[3,7]):[3,7]):[2,e]):[2,e];case 1:return r=S.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(r,e)];case 2:i=S.sent(),S.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(r,i)]:[3,5];case 4:r=S.sent(),S.label=5;case 5:return[4,this.changeRasterItem(s,r)];case 6:S.sent(),s.data.originalUrl=f,this.applyDesignEffectToItem(g,e),s.matrix=u,(p=new this.paper.Path.Rectangle(0,0,s.width,s.height)).visible=!1,p.matrix=u.clone(),m=this.getRectangleItemSize(p),p.remove(),v=1,I=1,this.isImagesFixedSizeEnabled()&&t.get("preferredWidth")&&t.get("preferredHeight")?(y=this.side.get("ppcm")/10,m.width=t.get("preferredWidth")*y,m.height=t.get("preferredHeight")*y,v=m.width/e.bounds.width,I=m.height/e.bounds.height):(C=m.width,M=m.height,C==l&&M==h||(Math.abs(C)>1e-7&&(v=l/C),Math.abs(M)>1e-7&&(I=h/M))),x=Math.min(v,I),s.scale(x,x),o.get("colors").reset(),this.updateDesignItemColorMappings(o,i),this.onImageItemUpdated(e,t,this.createDummyShapeFromDesignItem(o)),this.updateSelectionState(),this.paper.project.view.update(),this.fireImageLoadedEvent(),S.label=7;case 7:return this.endDesignOperation(),[2,e]}})})},updateItemsIndexes:function(){var e=this,t=this.design.getSideDesignItems(this.side).sort(function(e,t){return e.get("index")>t.get("index")}).map(function(t){return e.findItemForDesignItem(t)});t.forEach(function(t){null==t||t.bringToFront(),e.updateShapeImagePlaceholder(t)});var i=t.filter(function(t){return e.isAlwaysOnTop(t)});i.forEach(function(e){return e.bringToFront()}),this.isViewer||i.forEach(function(t){return e.onItemUpdated(t)}),this.getAllGridItems().forEach(function(e){return e.sendToBack()});var n=this.getAllItems().filter(function(e){return e.data&&e.data.isGroupForBackground});n.forEach(function(e){return e.sendToBack()}),n.forEach(function(t){return t.children.forEach(function(t){t.data&&(t.data.isImageForBackground||t.data.isAreaForBackground)&&(t.sendToBack(),e.isViewer||e.onItemUpdated(t))})});var a=[];!function e(t){if(null==t?void 0:t.children)for(var i=0;i<t.children.length;i++){var n=t.children[i];n.data&&n.data.isGroupForBackground?a.push(n):e(n)}}(this.masterGroup),a.forEach(function(e){e.sendToBack()})},getRectangleItemSize:function(e){var t=0,i=0,n=e.segments;if(4==n.length){var a=n[0].point,r=n[1].point,o=n[2].point;n[3].point;t=o.subtract(r).length,i=a.subtract(r).length}return new this.paper.Size(t,i)},modifySelectedImageElementColors:function(e){return __awaiter(this,void 0,void 0,function(){var t,i;return __generator(this,function(n){switch(n.label){case 0:return(t=this.getSelectedItems())&&t.length>0?(i=t[0],[4,this.modifyImageElementColors(i,e)]):[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},setImageSizeManually:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h,d,c;return __generator(this,function(u){return(i=this.getSelectedItems())&&i.length>0&&(n=i[0],a=this.side.get("ppcm"),r=n.bounds.height/n.bounds.width,o=e,s=t,e||t?(e?t||(s=e*r):o=t/r,o=o*a*("cm"===this.unitOfMeasurement?1:2.54),s=s*a*("cm"===this.unitOfMeasurement?1:2.54)):(o=n.bounds.width,s=n.bounds.height),l=o/n.bounds.width,h=s/n.bounds.height,n.scale(l,h),n.data.originalMatrix&&(d=n.bounds.center,c=(new this.paper.Matrix).scale(l,h,d),n.data.originalMatrix.prepend(c)),n.data.needsTransformsDataUpdate=!0,this.onItemUpdated(n),this.onDesignItemChanged(n),this.deselectAll(),this.setItemSelection(n,!0)),[2]})})},modifyImageElementColors:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h,d,c,u,g,f,p,m,v;return __generator(this,function(I){switch(I.label){case 0:if(i=this.getMaskedImageRasterItem(e),n=this.side,!(this.design&&e&&i&&"[object Array]"===Object.prototype.toString.call(t)))return[3,7];if(a=this.findDesignItemByGuid(e.data.guid),r=a.clone(),!(a&&a instanceof MPlaza.DesignItem&&a.get("imageID")>0))return[3,7];for(this.beginDesignOperation(),o=a.get("imageID"),(s=new MPlaza.RecoloredImage).set("imageID",o),s.set("versionKey","preview"),l=0;l<t.length;l++)(v=t[l])instanceof MPlaza.ColorChange?s.get("colorChanges").push(v):v.hasOwnProperty("colorID")&&v.hasOwnProperty("code")&&(h=new MPlaza.ColorChange(v),s.get("colorChanges").push(h));return[4,new Promise(function(e,t){s.save(null,{success:function(i,n,a){i&&i.get("imageID")?e(s.get("imageUrl")):t("Errore nella lettura dei dati! "+i.get("message"))},error:function(e,i,n){t("Errore nella lettura dei dati")}})})];case 1:return(d=I.sent())&&this.side==n?(c=i.matrix,u=d,g=this.getDesignEffectForDesignItem(a),f=u,[4,this.applyDesignEffectToImageUrl(g,u)]):[3,7];case 2:return u=I.sent(),[4,this.getImageDefaultColorMappings(u,e)];case 3:return(p=I.sent())&&p.length>0?[4,this.recolorImage(u,p)]:[3,5];case 4:u=I.sent(),I.label=5;case 5:return this.updateDesignItemColorMappings(a,p),[4,this.changeRasterItem(i,u)];case 6:for(I.sent(),i.data.originalUrl=f,this.applyDesignEffectToItem(g,e),i.matrix=c,m=0;m<t.length;m++)(v=t[m])instanceof MPlaza.ColorChange?(a.changeColor(o,v.get("colorID"),v.get("code")),e.data.isSVGRecolored=!0):v.hasOwnProperty("colorID")&&v.hasOwnProperty("code")&&(a.changeColor(o,v.colorID,v.code),e.data.isSVGRecolored=!0);this.updateDesignItemColors(a,a.get("colors").map(function(e){return e.get("colorCode")})),this.registerItemOperation("update",a.get("itemGuid"),r,a),console.log("item: ",e),this.onItemUpdated(e),this.onDesignItemChanged(e),this.updateSelectionState(),this.paper.project.view.update(),this.fireImageLoadedEvent(),this.endDesignOperation(),I.label=7;case 7:return[2]}})})},modifySelectedImageElementsColors:function(e){if(this.design&&"[object Array]"===Object.prototype.toString.call(e)){var t=this,i=this.getSelectedImageItems();if(0==i.length)return;this.beginDesignOperation();for(var n=null,a={},r=0;r<i.length;r++){var o=i[r],s=this.findDesignItemByGuid(o.data.guid),l=s.get("imageID");if(null==n)n=l;else if(n!=l)return;a[o.data.guid]=s}try{var h=new MPlaza.RecoloredImage;h.set("imageID",n),h.set("versionKey","preview");for(r=0;r<e.length;r++){var d=e[r];if(d instanceof MPlaza.ColorChange)h.get("colorChanges").push(d);else if(d.hasOwnProperty("colorID")&&d.hasOwnProperty("code")){var c=new MPlaza.ColorChange(d);h.get("colorChanges").push(c)}}h.save(null,{success:function(r,o,s){r&&r.get("imageID")?(Logger.info("Immagine letta correttamente"),function(r,o){if(r)for(var s,l,h,d="data:image/png;base64,"+r,c=function(){s=i[u],l=a[s.data.guid],t.updateDesignItemColors(l,o);var r=t.getMaskedImageRasterItem(s);h=r.matrix,r.crossOrigin="anonymous",r.source=d,r.onLoad=function(){r.matrix=h;for(var i=0;i<e.length;i++){var a=e[i];a instanceof MPlaza.ColorChange?l.changeColor(n,a.get("colorID"),a.get("code")):a.hasOwnProperty("colorID")&&a.hasOwnProperty("code")&&l.changeColor(n,a.colorID,a.code)}t.onItemUpdated(s),t.updateSelectionState(),t.paper.project.view.update(),t.fireImageLoadedEvent(),this.beginDesignOperation()}},u=0;u<i.length;u++)c()}(h.get("imageData"),h.get("imageColors"))):Logger.info("Errore nella lettura dei dati! "+r.get("message"))},error:function(e,t,i){Logger.info("Errore nella lettura dei dati")}})}catch(e){Logger.info(e)}}},setEditingItem:function(e,t){if(e&&null!=t&&(this.removeLoadingCircle(e),t)){var i=this.getAreasIntersectingOrContainingItem(e);i&&i.length>0&&this.createLoadingCircle(e,e.bounds.center)}},createLoadingCircle:function(e,t){if(!t)return null;var i=25/this.paper.view.zoom,n=Zakeke.config.baseUrl+"/images/customizer/loading-circle.png",a=new this.paper.Raster({source:n,position:t}),r=function(){var e=a.size,t=new this.paper.Size(i,i),n=1,r=1;Math.abs(e.width)>1e-7&&(n=t.width/e.width),Math.abs(e.height)>1e-7&&(r=t.height/e.height),a.scale(n,r)};return a.size.width>0&&a.size.height>0?r():a.onLoad=function(){r()},a.data.isLoadingCircle=!0,e.loadingCircle=a,this.loadingCircles.push(a),a},removeLoadingCircle:function(e){if(e&&e.hasOwnProperty("loadingCircle")&&e.loadingCircle){var t=e.loadingCircle;this.loadingCircles=this.loadingCircles.filter(function(e){return e!=t}),t.remove(),e.loadingCircle=null}},getItemIsImage:function(e){return this.isImage(e)||this.isMaskedImage(e)},scaleBgImage:function(e,t){this.beginDesignOperation();var i=this.getOrCreateBackgroundGroupItem(e).children.find(function(e){return e.data&&e.data.isImageForBackground});i&&(i.scaling=new this.paper.Point(t,t),this.onItemUpdated(i),this.updateSelectionState(),this.paper.view.update(),this.endDesignOperation())},insertImageAsBackground:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C=this;return __generator(this,function(M){switch(M.label){case 0:return n=null,a=null,e&&e instanceof MPlaza.Image?(r=this.findItemForArea(t),o=this.getOrCreateBackgroundGroupItem(r),(s=o.children.find(function(e){return e.data&&e.data.isAreaForBackground}))&&((u=this.findDesignItemForItem(s))&&(a=u.get("syncGuid")),s.remove(),this.onItemRemoved(s)),l="",!this.isImageScalingEnabled&&"svg"!=e.get("format").toLowerCase()&&"vector"!=e.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(t){return t==e.get("format").toLowerCase()})&&(l=e.get("url")),l||(l=e.get("previewUrl")),l?this.side&&t?(this.beginDesignOperation(),h=l,d=this.getDesignEffectForArea(t),[4,this.applyDesignEffectToImageUrl(d,l)]):[3,7]:[2,n]):[2,n];case 1:return l=M.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(l,null)];case 2:i=M.sent(),M.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(l,i)]:[3,5];case 4:l=M.sent(),M.label=5;case 5:return[4,this.createRasterItem(l,!1)];case 6:(n=M.sent()).data.originalUrl=h,this.applyDesignEffectToItem(d,n),n.data.originalImageID=e.id,n.data.isImageForBackground=!0,n.data.areaGuid=o.data.areaGuid,c=null,o.children.forEach(function(e){if(e.data.isImageForBackground){var t=C.findDesignItemForItem(e);t&&(a=t.get("syncGuid"),c=t.get("constraints")),e.remove(),C.onItemRemoved(e)}}),this.onItemCreated(n,e),(u=this.findDesignItemForItem(n)).set("syncGuid",a),this.updateDesignItemColorMappings(u,i),c&&u.setConstraintsFromSource(c),r&&(n.position=r.position,g=n.bounds,((f=r.bounds).intersects(g)||g.contains(f))&&(p=f.clone(),m=1,v=1,Math.abs(p.width)>1e-7&&(m=p.width/g.width),Math.abs(p.height)>1e-7&&(v=p.height/g.height),I=m>0?1:-1,y=v>0?1:-1,m=v=Math.max(Math.abs(m),Math.abs(v)),m*=I,v*=y,n.scale(m,v),n.visible=!0,n.data.initialScaleX=m,n.data.initialScaleY=v,n.data.originalBounds=new this.paper.Rectangle(0,0,n.width,n.height),n.data.originalMatrix=n.matrix.clone())),o.addChild(n),this.updateItemsIndexes(),this.onItemUpdated(n),this.onDesignItemChanged(n),this.fireImageLoadedEvent(),this.endDesignOperation(),M.label=7;case 7:return[2,n]}})})},removeBackgroundColorArea:function(e){var t=this;this.beginDesignOperation();var i=this.getOrCreateBackgroundGroupItem(e);i.children.forEach(function(e){if(e.data.isImageForBackground||e.data.isAreaForBackground){var i=t.findDesignItemForItem(e);t.fireDesignItemRemovingEvent(i,e),e.remove(),t.onItemRemoved(e)}}),i.remove(),this.endDesignOperation()},updateBackgroundGroupSize:function(e){var t=this.getOrCreateBackgroundGroupItem(e),i=t.children.find(function(e){return e instanceof paper.CompoundPath});if(i){i.remove();var n=e.clone();n.data={guid:MPlaza.generateUUID(),areaGuid:e.data.guid,isClippingAreaForBackground:!0},n.strokeWidth=0,n.visible=!0,t.addChild(n),n.sendToBack(),t.clipped=!0,n.bringToFront()}},changeBackgroundColorArea:function(e,t,i){this.beginDesignOperation();var n=this,a=null,r=this.getOrCreateBackgroundGroupItem(e);r.children.forEach(function(e){if(e.data.isImageForBackground||e.data.isAreaForBackground){var t=n.findDesignItemForItem(e);t&&(a=t.get("syncGuid")),e.remove(),i(e),n.onItemRemoved(e)}});var o=r.children.find(function(e){return e.data&&e.data.isAreaForBackground});if(!o){var s=Math.max(r.children[0].bounds.width,r.children[0].bounds.height);o=new this.paper.Path.Rectangle(r.children[0].bounds.point,new this.paper.Size(s,s));var l=new this.paper.Point(o.position.x-(s-r.children[0].bounds.width)/2,o.position.y-(s-r.children[0].bounds.height)/2);o.position=l,o.data={guid:MPlaza.generateUUID(),areaGuid:e.data.guid,isAreaForBackground:!0},o.strokeWidth=0,o.visible=!0,r.addChild(o),this.onItemCreated(o)}var h=n.findDesignItemForItem(o);h.set("syncGuid",a),o.fillColor=t;var d=this.getDesignEffectForDesignItem(h);return this.applyDesignEffectToItem(d,o),this.onItemUpdated(o),this.endDesignOperation(),o},getOrCreateBackgroundGroupItem:function(e){var t;if(function i(n){var a,r,o;if(n.children)for(var s=0;s<n.children.length;s++){var l=n.children[s];if((null==l?void 0:l.data)&&(null===(a=null==l?void 0:l.data)||void 0===a?void 0:a.areaGuid)===(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.guid)&&(null===(o=null==l?void 0:l.data)||void 0===o?void 0:o.isGroupForBackground))return void(t=l);i(l)}}(this.masterGroup),!t){var i=e.clone();i.data={guid:MPlaza.generateUUID(),areaGuid:e.data.guid,isClippingAreaForBackground:!0},i.strokeWidth=0,i.visible=!0,(t=new this.paper.Group(i)).clipped=!0,t.data={guid:MPlaza.generateUUID(),areaGuid:e.data.guid,isGroupForBackground:!0},t.addChild(i),this.masterGroup.addChild(t),t.sendToBack()}return t},getAllTextItems:function(){var e=this;return this.getAllItems().filter(function(t){return e.getItemIsTextElement(t)})},setEditTextCallback:function(e){this.editTextCallback=e},textInfoModified:function(e){e&&this.mouseStartPos&&(this.element?this.modifyTextElement(this.element,e):this.addTextElement(this.mouseStartPos,e),this.element=null)},createText:function(e){if(this.canAddText()&&this.editTextCallback){var t={text:"",strokeColor:null,strokeWidth:0,fillColor:"#000000",fontFamily:"Arial",fontSize:12,fontWeight:"normal",justification:"left",shadowColor:null,shadowBlur:0,shadowDistance:7,shadowAngle:45},i=this;this.editTextCallback(t,function(e){i.textInfoModified(e)})}},editText:function(){if(this.selectElement(),this.canEditSelection()&&this.element&&this.element instanceof this.paper.TextItem&&this.editTextCallback){var e={};e.text=this.element.content,e.strokeColor=this.element.strokeColor.toCSS(!0),e.strokeWidth=this.element.strokeWidth,e.fillColor=this.element.fillColor.toCSS(!0),e.fontFamily=this.element.fontFamily,e.fontSize=this.element.fontSize,e.fontWeight=this.element.fontWeight,e.justification=this.element.justification,e.shadowColor=this.element.shadowColor,e.shadowBlur=this.element.shadowBlur,e.shadowDistance=this.getOffsetDistance(this.element.shadowOffset),e.shadowAngle=this.getOffsetAngle(this.element.shadowOffset);var t=this;this.editTextCallback(e,function(e){t.textInfoModified(e)})}},addTextElement:function(e,t,i,n){if(void 0===i&&(i=!1),void 0===n&&(n=null),!i&&!this.canAddText())return null;var a=null;if(this.side){var r=this.side.get("areas").getMaxArea();if(r){var o=this.getDesignEffectForArea(r);if(t&&t.text){this.beginDesignOperation(),this.deselectAll(),this.updateSelectionState(),this.allowShadows()||(t.shadowColor=null);var s=t.strokeColor||null,l=t.fillColor||"#000000",h=t.shadowColor||null;if(s=this.forceColorInFixedPalette(null,s),l=this.forceColorInFixedPalette(null,l),h=this.forceColorInFixedPalette(null,h),t.shadowBlur=this.adjustInputShadowBlur(null,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(null,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(null,t.shadowAngle),t.strokeWidth=this.adjustInputTextStrokeWidth(null,t.strokeWidth),null!=t.fontSize&&null!=t.fontSize&&"string"==typeof t.fontSize&&(t.fontSize=parseInt(t.fontSize)),a=new this.paper.PointText({rotation:t.rotation||0,content:t.text,strokeColor:this.applyDesignEffectToTextColor(o,s),strokeWidth:null!=t.strokeWidth?t.strokeWidth:0,fillColor:this.applyDesignEffectToTextColor(o,l),fontFamily:this.sanitizeFontFamilyName(t.fontFamily)||"Verdana",fontWeight:t.fontWeight||"normal normal",fontStretch:t.fontStretch||"normal",fontStyle:t.fontStyle||"normal",fontSize:t.fontSize||48,justification:t.justification||"center",shadowColor:t.shadowColor||null,shadowBlur:t.shadowBlur||0,shadowOffset:this.getOffsetByDistanceAngle(t.shadowDistance,t.shadowAngle),lineSpacing:t.lineSpacing,letterSpacing:t.letterSpacing}),n){var d=.75*n;a.fontSize=d}if(a.fontSize=this.adjustTextFontSize(a,a.fontSize),a.data={},a.data.isText=!0,a.data.originalStrokeColor=s,a.data.originalFillColor=l,a.data.originalShadowColor=h,this.applyDesignEffectToItem(o,a),this.masterGroup.addChild(a),this.onItemCreated(a),this.setItemSelection(a,!0),null==e)if(r){var c=this.findItemForArea(r);if(c){a.position=c.interiorPoint;var u=c.bounds;if(c instanceof paper.CompoundPath&&c.children.length>0){var g=c.children.sort(function(e,t){return Math.abs(t.area)-Math.abs(e.area)}).at(0);a.position=g.interiorPoint,c.contains(a.position)||(a.position=c.interiorPoint),u=g.bounds}else a.position=c.interiorPoint;if(a.bounds.height>0&&u.height>0){if(a.bounds.height>u.height){var f=c.bounds.height/a.bounds.height;f=this.adjustTextFontScaling(a,f),a.scale(f)}if(!n&&a.bounds.height/u.height<.2){f=.2*u.height/a.bounds.height;f=this.adjustTextFontScaling(a,f),a.scale(f)}}if(!n){var p=this.getFontSizeList();if(p&&p.length>0)a.fontSize=p[0]/(4*a.scaling.y/3);else{var m=this.getDefaultTextFontSizeFromMinMaxInPx(a);m>0&&(a.fontSize=m)}}this.onItemUpdated(a),this.onDesignItemChanged(a)}}else a.position=this.paper.view.center;else a.position=e;if(this.isSafari){a.visible=!1;var v=this;setTimeout(function(){a.visible=!0,v.paper.project.view.update(!0),v.updateSelectionState()},2e3)}else this.updateSelectionState(),this.paper.project.view.update(!0);t.isTextOnPath&&(a=this.convertSelectedTextItemsToTextOnPath()),this.endDesignOperation()}}}return a},modifyTextElement:function(e,t,i){if(void 0===i&&(i=!0),this.canEditItem(e)&&e){if(this.beginDesignOperation(),e.data&&e.data.isTextOnPath)this.modifyTextOnPathInfo(e,t);else if(e.data&&e.data.isTextArea)this.modifyTextAreaInfo(e,t);else{var n=null,a=this.findDesignItemForItem(e);a&&(n=this.getDesignEffectForDesignItem(a));var r=this.getItemConstraints(e);if(e.content=this.adjustInputTextByConstraints(e,t.text)||e.content,t.strokeWidth=this.adjustInputTextStrokeWidth(e,t.strokeWidth),!r||r.get("canChangeFontColor")){var o=t.strokeColor||this.convertColorToHex(e.strokeColor),s=t.fillColor||this.convertColorToHex(e.fillColor);o=this.forceColorInFixedPalette(e,o),s=this.forceColorInFixedPalette(e,s),e.strokeColor=this.applyDesignEffectToTextColor(n,o),e.fillColor=this.applyDesignEffectToTextColor(n,s),e.data.originalStrokeColor=o,e.data.originalFillColor=s}if(!r||r.get("canChangeShadowColor")){var l=t.shadowColor||this.convertColorToHex(e.shadowColor);l=this.forceColorInFixedPalette(e,l),e.shadowColor=this.applyDesignEffectToTextColor(n,l),e.data.originalShadowColor=l}this.allowShadows()||(e.shadowColor=null),e.shadowBlur=this.adjustInputShadowBlur(e,t.shadowBlur),e.shadowOffset=this.getOffsetByDistanceAngle(this.adjustInputShadowDistance(e,t.shadowDistance),this.adjustInputShadowAngle(e,t.shadowAngle)),e.strokeWidth=null!=t.strokeWidth?t.strokeWidth:e.strokeWidth,r&&!r.get("canChangeFontFamily")||(e.fontFamily=this.sanitizeFontFamilyName(t.fontFamily||e.fontFamily)),e.fontWeight=this.adjustInputFontWeightByConstraints(e,t.fontWeight,r),r&&!r.get("canChangeFontSize")||(e.fontSize=t.fontSize||e.fontSize),r&&!r.get("canChangeJustification")||(e.justification=t.justification||e.justification),t.scaling&&(e.scaling=t.scaling),t.rotation&&(e.rotation=t.rotation)}this.onItemUpdated(e),this.onDesignItemChanged(e),i&&this.setItemSelection(e,!0),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}},modifyTextElements:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElement(e[i],t);else this.modifyTextElement(e,t)},modifyTextElementContentByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementContent(i,t)},modifyTextElementContent:function(e,t){if(this.canEditItem(e)&&!this.sameTextElementContent(e,t)){var i=null;this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.content=this.adjustInputTextByConstraints(e,t),e.data.needsTransformsDataUpdate=!0,e.data.isProfanityCheckInvalid=!1,this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),this.updateSelectionState(),this.paper.project.view.update(),this.onItemUpdated(e),this.onDesignItemChanged(e)):e&&e.data&&e.data.isTextOnPath?(i={text:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.onDesignItemChanged(e)):e&&e.data&&e.data.isTextArea&&(i={text:t},this.modifyTextAreaInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.onDesignItemChanged(e)),this.endDesignOperation()}},modifyTextElementsContent:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementContent(e[i],t);else this.modifyTextElementContent(e,t)},setIsPlaceHolderItem:function(e,t){e.data.isPlaceHolder=t;var i=this.findDesignItemByGuid(e.data.guid),n=e.exportJSON({asString:!0});i.set("json",n)},setIsPlaceHolderItems:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.setIsPlaceHolderItems(e[i],t);else this.setIsPlaceHolderItem(e,t)},sameTextElementContent:function(e,t){var i=this.getTextItemInfo(e);if(i){var n=this.adjustInputTextByConstraints(e,t);if(i.text===n)return!0}return!1},modifyTextElementFillColorByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementFillColor(i,t)},modifyTextElementStrokeColorByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementStrokeColor(i,t)},modifyTextElementStrokeColor:function(e,t){if(this.canChangeTextStrokeColor(e)){var i=void 0,n=this.getTextItemInfo(e);n&&n.strokeColor&&(n.strokeColor instanceof this.paper.Color?i=n.strokeColor.toCSS(!0):"string"==typeof n.strokeColor&&(i=n.strokeColor));var a=null;this.beginDesignOperation();var r=null,o=this.findDesignItemForItem(e);if(o&&(r=this.getDesignEffectForDesignItem(o)),e&&e instanceof this.paper.TextItem){var s=t;s=this.forceColorInFixedPalette(e,s,i);var l=this.applyDesignEffectToTextColor(r,s);e.strokeColor=l,e.data.needsTransformsDataUpdate=!0,e.data.originalStrokeColor=s,this.paper.project.view.update(),this.onItemUpdated(e)}else e&&e.data&&e.data.isTextOnPath?(a={strokeColor:t},this.modifyTextOnPathInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(a={strokeColor:t},this.modifyTextAreaInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation()}},modifyTextElementsStrokeColor:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementStrokeColor(e[i],t);else this.modifyTextElementStrokeColor(e,t)},modifyTextElementStrokeWidth:function(e,t){if(this.canChangeTextStrokeWidth(e)){t=this.adjustInputTextStrokeWidth(e,t);var i=null,n=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.strokeWidth=t,e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()):e&&e.data&&e.data.isTextOnPath?(i={strokeWidth:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={strokeWidth:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsStrokeWidth:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementStrokeWidth(e[i],t);else this.modifyTextElementStrokeWidth(e,t)},modifyTextElementFillColor:function(e,t){if(this.canChangeItemFontColor(e)){var i=void 0,n=this.getTextItemInfo(e);if(n&&n.fillColor&&(n.fillColor instanceof this.paper.Color?i=n.fillColor.toCSS(!0):"string"==typeof n.fillColor&&(i=n.fillColor)),!i||i!==t){var a=null;this.beginDesignOperation();var r=null,o=this.findDesignItemForItem(e);if(o&&(r=this.getDesignEffectForDesignItem(o)),e&&e instanceof this.paper.TextItem){var s=t;s=this.forceColorInFixedPalette(e,s,i);var l=this.applyDesignEffectToTextColor(r,s);e.fillColor=l,e.data.needsTransformsDataUpdate=!0,e.data.originalFillColor=s,this.paper.project.view.update(),this.onItemUpdated(e)}else e&&e.data&&e.data.isTextOnPath?(a={fillColor:t},this.modifyTextOnPathInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(a={fillColor:t},this.modifyTextAreaInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation()}}},modifyTextElementsFillColor:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFillColor(e[i],t);else this.modifyTextElementFillColor(e,t)},modifyTextElementShadowColorByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementShadowColor(i,t)},modifyTextElementShadowColor:function(e,t){if(this.canChangeItemShadowColor(e)){this.allowShadows()||(t=null);var i=void 0,n=this.getTextItemInfo(e);if(n&&n.shadowColor&&(n.shadowColor instanceof this.paper.Color?i=n.shadowColor.toCSS(!0):"string"==typeof n.shadowColor&&(i=n.shadowColor)),!i||i!==t){var a=null;this.beginDesignOperation();var r=null,o=this.findDesignItemForItem(e);if(o&&(r=this.getDesignEffectForDesignItem(o)),e&&e instanceof this.paper.TextItem){var s=t;s=this.forceColorInFixedPalette(e,s,i);var l=this.applyDesignEffectToTextColor(r,s);e.shadowColor=l,e.data.needsTransformsDataUpdate=!0,e.data.originalShadowColor=s,this.paper.project.view.update(),this.onItemUpdated(e)}else e&&e.data&&e.data.isTextOnPath?(a={shadowColor:t},this.modifyTextOnPathInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(a={shadowColor:t},this.modifyTextAreaInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation()}}},modifyTextElementsShadowColor:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementShadowColor(e[i],t);else this.modifyTextElementShadowColor(e,t)},modifyTextElementShadowBlur:function(e,t){if(this.canChangeItemShadowBlur(e)){t=this.adjustInputShadowBlur(e,t);var i=null,n=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.shadowBlur=t,e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()):e&&e.data&&e.data.isTextOnPath?(i={shadowBlur:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={shadowBlur:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsShadowBlur:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementShadowBlur(e[i],t);else this.modifyTextElementShadowBlur(e,t)},modifyTextElementShadowDistance:function(e,t){if(this.canChangeItemShadowDistance(e)){t=this.adjustInputShadowDistance(e,t);var i=null,n=this.getLastUndoOperationId();if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem){var a=this.getOffsetAngle(e.shadowOffset);e.shadowOffset=this.getOffsetByDistanceAngle(t,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()}else e&&e.data&&e.data.isTextOnPath?(i={shadowDistance:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={shadowDistance:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsShadowDistance:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementShadowDistance(e[i],t);else this.modifyTextElementShadowDistance(e,t)},modifyTextElementShadowAngle:function(e,t){if(this.canChangeItemShadowAngle(e)){t=this.adjustInputShadowAngle(e,t);var i=null,n=this.getLastUndoOperationId();if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem){var a=this.getOffsetDistance(e.shadowOffset);e.shadowOffset=this.getOffsetByDistanceAngle(a,t),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()}else e&&e.data&&e.data.isTextOnPath?(i={shadowAngle:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={shadowAngle:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsShadowAngle:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementShadowAngle(e[i],t);else this.modifyTextElementShadowAngle(e,t)},resetTextElementShadow:function(e){if(e&&e.data&&e.data.guid){var t=this.findDesignItemForItem(e),i=this.getTextItemInfo(e);if(t&&i){var n=this.getLastUndoOperationId();if(this.beginDesignOperation(),this.allowShadows()||(i.shadowColor=null),i.shadowBlur=this.adjustInputShadowBlur(e,i.shadowBlur),i.shadowDistance=this.adjustInputShadowDistance(e,i.shadowDistance),i.shadowAngle=this.adjustInputShadowAngle(e,i.shadowAngle),e instanceof this.paper.TextItem){var a=this.getDesignEffectForDesignItem(t),r=i.shadowColor;r=this.forceColorInFixedPalette(e,r),i.shadowColor=this.applyDesignEffectToTextColor(a,r),e.shadowColor=i.shadowColor,e.shadowBlur=i.shadowBlur,e.shadowDistance=i.shadowDistance,e.shadowAngle=i.shadowAngle,e.data.needsTransformsDataUpdate=!0,e.data.originalShadowColor=r,this.paper.project.view.update(),this.onItemUpdated(e)}else e.data.isTextOnPath?(i={shadowColor:i.shadowColor,shadowBlur:i.shadowBlur,shadowDistance:i.shadowDistance,shadowAngle:i.shadowAngle},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e.data.isTextArea&&(i={shadowColor:i.shadowColor,shadowBlur:i.shadowBlur,shadowDistance:i.shadowDistance,shadowAngle:i.shadowAngle},this.modifyTextAreaInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}}},sanitizeFontFamilyName:function(e){return'"'+e.replace(/"/g,"")+'"'},modifyTextElementFontFamilyByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementFontFamily(i,t)},modifyTextElementFontFamily:function(e,t){if(this.canChangeItemFontFamily(e)&&!this.sameTextElementFontFamily(e,t)){var i=null,n=this.getLastUndoOperationId();if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem)if(e.fontFamily=this.sanitizeFontFamilyName(t),e.data.needsTransformsDataUpdate=!0,this.isSafari){e.visible=!1;var a=this;setTimeout(function(){e.visible=!0,a.paper.project.view.update(!0),a.onItemUpdated(e),a.updateSelectionState()},2e3)}else this.paper.project.view.update(!0),this.onItemUpdated(e),this.updateSelectionState();else e&&e.data&&e.data.isTextOnPath?(i={fontFamily:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={fontFamily:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsFontFamily:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFontFamily(e[i],t);else this.modifyTextElementFontFamily(e,t)},sameTextElementFontFamily:function(e,t){var i=this.getTextItemInfo(e);if(i&&this.sanitizeFontFamilyName(i.fontFamily)===this.sanitizeFontFamilyName(t))return!0;return!1},modifyTextElementFontSize:function(e,t){if(this.canChangeItemFontSize(e)){var i=null,n=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.fontSize=t,e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()):e&&e.data&&e.data.isTextOnPath?(i={fontSize:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={fontSize:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsFontSize:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFontSize(e[i],t);else this.modifyTextElementFontSize(e,t)},modifyTextElementFontWeight:function(e,t){if(this.canChangeItemFontWeight(e)){var i=this.getTextItemInfo(e);if(!i||i.fontWeight!==t){var n=null,a=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.fontWeight=t,e.data.needsTransformsDataUpdate=!0,this.paper.project.view.update(),this.onItemUpdated(e),this.updateSelectionState()):e&&e.data&&e.data.isTextOnPath?(n={fontWeight:t},this.modifyTextOnPathInfo(e,n),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(n={fontWeight:t},this.modifyTextAreaInfo(e,n),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}}},modifyTextElementsFontWeight:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFontWeight(e[i],t);else this.modifyTextElementFontWeight(e,t)},modifyTextElementFontStretch:function(e,t){var i=null,n=this.getTextItemInfo(e);if(!n||n.fontStretch!==t){var a=this.getLastUndoOperationId();this.beginDesignOperation(),this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.fontStretch=t,e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()):e&&e.data&&e.data.isTextOnPath?(i={fontStretch:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={fontStretch:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}},modifyTextElementsFontStretch:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFontStretch(e[i],t);else this.modifyTextElementFontStretch(e,t)},modifyTextElementJustification:function(e,t){if(this.canChangeItemJustification(e)){this.beginDesignOperation();var i=null,n=this.getTextItemInfo(e);if(!n.justification||n.justification!=t){if(e&&e instanceof this.paper.TextItem&&(e=this.fromTextToTextArea(e)),e&&e.data&&e.data.isTextOnPath)i={justification:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e);else if(e&&e.data&&e.data.isTextArea){i={justification:t};var a=e.bounds.clone();this.modifyTextAreaInfo(e,i),e.data.isTextBox||(e.position.x=a.x+a.width/2,Math.abs(e.children[0].rotation)<=90?e.position.y=a.y+e.bounds.height/2:e.position.y=a.bottom-e.bounds.height/2),this.updateSelectionState(),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)}this.endDesignOperation()}}},modifyTextElementsJustification:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementJustification(e[i],t);else this.modifyTextElementJustification(e,t)},modifyTextElementVerticalAlign:function(e,t){if(this.canChangeItemVerticalAlignment(e)){this.beginDesignOperation();var i=null,n=this.getTextItemInfo(e);if(!n.verticalAlignment||n.verticalAlignment!=t){if(e&&e instanceof this.paper.TextItem&&(e=this.fromTextToTextArea(e)),e&&e.data&&e.data.isTextOnPath)i={verticalAlignment:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e);else if(e&&e.data&&e.data.isTextArea){i={verticalAlignment:t};var a=e.bounds.clone();this.modifyTextAreaInfo(e,i),e.data.isTextBox||(e.position.x=a.x+a.width/2,Math.abs(e.children[0].rotation)<=90?e.position.y=a.y+e.bounds.height/2:e.position.y=a.bottom-e.bounds.height/2),this.updateSelectionState(),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)}this.endDesignOperation()}}},modifyTextElementsVerticalAlign:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementVerticalAlign(e[i],t);else this.modifyTextElementVerticalAlign(e,t)},modifyTextElementAdaptText:function(e,t){if(this.canChangeItemAdaptText(e)){var i=this.getTextItemInfo(e);if(!i||null==i.adaptText||i.adaptText!==t){var n=null,a=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem||e&&e.data&&e.data.isTextOnPath||e&&e.data&&e.data.isTextArea&&(n={adaptText:t},this.modifyTextAreaInfo(e,n),e.data.isTextBox&&!e.data.adaptText&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}}},modifyTextElementsAdaptText:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementAdaptText(e[i],t);else this.modifyTextElementAdaptText(e,t)},modifyTextElementLetterSpacing:function(e,t){if(this.canChangeItemLetterSpacing(e)){var i=this.getTextItemInfo(e);if(!i||null==i.letterSpacing||i.letterSpacing!==t){var n=null,a=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem||(e&&e.data&&e.data.isTextOnPath?(n={letterSpacing:t},this.modifyTextOnPathInfo(e,n),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(n={letterSpacing:t},this.modifyTextAreaInfo(e,n),e.data.isTextBox&&!e.data.adaptText&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e))),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}}},modifyTextElementsLetterSpacing:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementLetterSpacing(e[i],t);else this.modifyTextElementLetterSpacing(e,t)},modifyTextElementLineSpacing:function(e,t){if(this.canChangeItemLineSpacing(e)){var i=this.getTextItemInfo(e);if(!i||null==i.lineSpacing||i.lineSpacing!==t){var n=null,a=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem||e&&e.data&&e.data.isTextOnPath||e&&e.data&&e.data.isTextArea&&(n={lineSpacing:t},this.modifyTextAreaInfo(e,n),e.data.isTextBox&&!e.data.adaptText&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}}},modifyTextElementsLineSpacing:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementLineSpacing(e[i],t);else this.modifyTextElementLineSpacing(e,t)},adjustTextFontScaling:function(e,t){var i=t;if(e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var n=this.getItemMinFontSize(e),a=this.getItemMaxFontSize(e);if(null!=n||null!=n||null!=a||null!=a){var r=this.getTextItemInfo(e);r&&(null!=n&&null!=n&&(i=Math.min(i,n/(r.fontSize*r.scaling.y*4/3))),null!=a&&null!=a&&(i=Math.max(i,a/(r.fontSize*r.scaling.y*4/3))))}}return i},getDefaultTextFontSizeFromMinMaxInPx:function(e){var t=-1;if(e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var i=this.getItemMinFontSize(e),n=this.getItemMaxFontSize(e);if(null!=i&&null!=i&&null!=n&&null!=n){var a=this.getTextItemInfo(e);a&&(t=(i/(4*a.scaling.y/3)+n/(4*a.scaling.y/3))/2)}}return t},adjustTextFontSize:function(e,t){var i=t;if(e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var n=this.getItemMinFontSize(e),a=this.getItemMaxFontSize(e);if(null!=n||null!=n||null!=a||null!=a){var r=this.getTextItemInfo(e);r&&(null!=n&&null!=n&&(i=Math.max(i,n/(4*r.scaling.y/3))),null!=a&&null!=a&&(i=Math.min(i,a/(4*r.scaling.y/3))))}}return i},canScaleSelectedTextFont:function(e,t){for(var i=this.getSelectedItems(),n=0;n<i.length;n++){var a=i[n];if(!this.canScaleTextFont(a,e,t))return!1}return!0},getScaledTextFontSizePt:function(e,t,i){if(this.getItemIsTextElement(e)){var n=this.getItemMinFontSize(e),a=this.getItemMaxFontSize(e);if(null!=n||null!=n||null!=a||null!=a){var r=this.getTextItemInfo(e);if(r){var o=Math.max(t,i);return 4*(r.fontSize*r.scaling.y*o)/3}}}return 0},canScaleTextFont:function(e,t,i){var n;if(e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var a=this.getItemMinFontSize(e),r=this.getItemMaxFontSize(e);if(null!=a||null!=a||null!=r||null!=r){var o=this.getTextItemInfo(e);if(o){var s=null!==(n=o.rotation)&&void 0!==n?n:0,l=Math.cos(this.toRadians(s))*(i-1),h=Math.sin(this.toRadians(s))*(t-1),d=4*(o.fontSize*o.scaling.y*(1+l+h))/3;if(null!=a&&null!=a&&d<a)return!1;if(null!=r&&null!=r&&d>r)return!1}}}return!0},toRadians:function(e){return e*(Math.PI/180)},canSetSelectedTextFontSizePx:function(e){for(var t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];if(!this.canSetTextFontSizePx(n,e))return!1}return!0},canSetTextFontSizePx:function(e,t){if(e&&e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){if(e.data.adaptText)return!0;var i=this.getItemMinFontSize(e),n=this.getItemMaxFontSize(e);if(null!=i||null!=i||null!=n||null!=n){var a=this.getTextItemInfo(e);if(a){a.fontSize,a.scaling.y;var r=4*t/3;if(null!=i&&null!=i&&r<i)return!1;if(null!=n&&null!=n&&r>n)return!1}}}return!0},canSetSelectedTextFontSizePt:function(e){var t=3*e/4;return this.canSetSelectedTextFontSizePx(t)},canSetTextFontSizePt:function(e,t){return this.canSetTextFontSizePx(e,t)},computeTotalFontSizePt:function(e,t){return e*t*4/3},getTextItemTotalFontSizePx:function(e){if(e&&e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var t=this.getTextItemInfo(e);if(t)return t.fontSize*t.scaling.y}return 0},getTextItemTotalFontSizePt:function(e){return 4*this.getTextItemTotalFontSizePx(e)/3},modifySelectedTextItemsTotalFontSizePt:function(e){var t=3*e/4;this.modifySelectedTextItemsTotalFontSizePx(t)},modifyTextItemTotalFontSizePt:function(e,t){var i=3*t/4;this.modifyTextItemTotalFontSizePx(e,i)},modifySelectedTextItemsTotalFontSizePx:function(e){var t=this.getSelectedTextItems();if(t&&t.length>0){var i=t[0];this.modifyTextItemTotalFontSizePx(i,e)}},modifyTextItemTotalFontSizePx:function(e,t){if(e&&this.canEditItem(e)&&this.canResizeItem(e)&&this.canChangeItemFontSize(e)&&this.canSetTextFontSizePx(e,t)&&e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var i=this.getTextItemInfo(e);if(i){var n=i.fontSize*i.scaling.y;if(n>0){var a=t/n,r=this.getLastUndoOperationId();this.beginDesignOperation(),this.scaleItem(e,a,a,null),this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(r)}}}},addTextOnPathElement:function(e,t,i){if(void 0===i&&(i=!1),i||this.canAddText()){var n=null;if(this.side){var a=this.side.get("areas").getMaxArea();if(a){var r=this.getDesignEffectForArea(a);this.beginDesignOperation();var o=!1;if(e||(e=this.paper.view.center,o=!0),t&&t.text){this.deselectAll(),this.updateSelectionState(),this.allowShadows()||(t.shadowColor=null),this.allowTextStroke()||(t.strokeWidth=0);var s=t.strokeColor||null,l=t.fillColor||"#000000",h=t.shadowColor||null;s=this.forceColorInFixedPalette(null,s),l=this.forceColorInFixedPalette(null,l),h=this.forceColorInFixedPalette(null,h),t.strokeColor=this.applyDesignEffectToTextColor(r,s),t.fillColor=this.applyDesignEffectToTextColor(r,l),t.shadowColor=this.applyDesignEffectToTextColor(r,h),t.shadowBlur=this.adjustInputShadowBlur(null,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(null,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(null,t.shadowAngle);var d=new this.paper.PointText({point:e,content:t.text,strokeColor:t.strokeColor,strokeWidth:null!=t.strokeWidth?t.strokeWidth:0,fillColor:t.fillColor,fontFamily:this.sanitizeFontFamilyName(t.fontFamily||"Verdana"),fontWeight:t.fontWeight||"normal",fontSize:t.fontSize||12,justification:t.justification||"center",shadowColor:t.shadowColor||null,shadowBlur:t.shadowBlur,shadowOffset:this.getOffsetByDistanceAngle(t.shadowDistance,t.shadowAngle)}),c=d.bounds;d.remove();var u=c.clone(),g=this.findItemForArea(a);g&&(u=g.bounds.expand(-50)),o||(u.center=e);var f=Math.min(u.width,u.height),p=new this.paper.Rectangle(u.x+(u.width-f)/2,u.y+(u.height-f)/2,f,f),m=new this.paper.Point(p.left,p.top+f/2),v=new this.paper.Point(p.center.x,p.topLeft.y),I=new this.paper.Point(p.right,p.top+f/2),y=new this.paper.Path.Arc(m,v,I);y.remove(),t.rotation&&(y.rotation=t.rotation,m=y.getPointAt(0*y.length),v=y.getPointAt(.5*y.length),I=y.getPointAt(1*y.length)),(n=new this.paper.Group).addChildren(this.createAlignedText(y,t)),n.data.isTextOnPath=!0,n.data.points=[m,v,I],n.data.text=t.text,n.data.inside=t.inside||!1,n.data.originalStrokeColor=s,n.data.originalFillColor=l,n.data.originalShadowColor=h,n.data.letterSpacing=this.adjustInputLetterSpacingByConstraints(n,t.letterSpacing),this.masterGroup.addChild(n),this.adaptPathToText(n);var C=u.center.subtract(n.position);n.position=u.center,n.data.needsTransformsDataUpdate=!0,this.applyDesignEffectToItem(r,n),this.updateTransformsData(n),this.onTextOnPathMoved(n,C),this.onItemCreated(n),this.setItemSelection(n,!0)}this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}}return n}},getAllImageItems:function(){for(var e=[],t=this.getAllItems(),i=0;i<t.length;i++){var n=t[i],a=this.getMaskedImageRasterItem(n);n&&a&&n.data&&n.data.guid&&!n.data.isArea&&e.push(n)}return e},getAllDesignImageItems:function(){return this.design.get("designItems").models.filter(function(e){return""!==e.get("imageFormat")})},getAllTextOnPathItems:function(){var e=[];function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];!a.guide&&a.data&&a.data.isTextOnPath&&e.push(a),t(a)}}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}return e},setGrids:function(e){this.grids=e},updateGrids:function(e){return void 0===e&&(e=!1),__awaiter(this,void 0,void 0,function(){var t,i,n=this;return __generator(this,function(a){switch(a.label){case 0:return(t=this.design.get("areasGrids")&&this.design.get("areasGrids").models.find(function(e){return e.get("modelID")==n.getCurrentModel().id&&e.get("sideID")==n.side.id}))&&(i=this.grids.find(function(e){return e.id==t.get("gridID")}))?[4,this.createGridItem(i,e)]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}})})},addImageToGridBox:function(e,t,i,n){void 0===n&&(n=!1),this.beginDesignOperation();var a=t.children.find(function(e){return e.data&&e.data.isGridIcon});a&&a.remove();var r=this.getItemBounds(e),o=t.bounds.clone();o.width*=1.1,o.height*=1.1;var s=1,l=1;Math.abs(o.width)>1e-7&&(s=o.width/r.width),Math.abs(o.height)>1e-7&&(l=o.height/r.height);var h=s>0?1:-1,d=l>0?1:-1;s=l=Math.max(Math.abs(s),Math.abs(l)),s*=h,l*=d,e.data.isGridImage&&!n||(e.position=t.position,e.scale(s,l),e.data.initialScaleX=s,e.data.initialScaleY=l,e.data.originalBounds=new this.paper.Rectangle(0,0,this.getImageWidth(e),this.getImageHeight(e)),e.data.originalMatrix=e.matrix.clone()),e.visible=!0,e.data.isGridImage=!0,e.data.gridBoxID=i>=0?i:t.parent.children.indexOf(t),this.isViewer||(this.updateSelectionState(),this.onItemUpdated(e),this.onDesignItemChanged(e));for(var c=0,u=t.children;c<u.length;c++){var g=u[c];g.data&&g.data.isGridBorderPath&&(g.fillColor=new paper.Color(1,1,1,0))}t.addChild(e),e.sendToBack(),this.endDesignOperation()},insertImageInGrid:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h=this;return __generator(this,function(d){switch(d.label){case 0:return i=null,e&&e instanceof MPlaza.Image?this.canAddImage()&&(n=this.getAllGridItems()[0])?!this.side||this.side.get(0=="areas".length)?[2,i]:(a=this.side.get("areas").at(0),this.beginDesignOperation(),r=n.children.find(function(e){return e.data&&e.data.isBoxSelected})||n.children.find(function(e){return e.children&&e.children.find(function(e){return e.data&&e.data.isGridIcon})})||n.children[0],o="",!this.isImageScalingEnabled&&"svg"!=e.get("format").toLowerCase()&&"vector"!=e.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(t){return t==e.get("format").toLowerCase()})&&(o=e.get("url")),o||(o=e.get("previewUrl")),e.get("overridePreview")&&e.get("connectorSettings")&&(o=e.get("overridePreview")),o?(s=o,l=this.getDesignEffectForArea(a),[4,this.applyDesignEffectToImageUrl(l,o)]):[2,i]):[2,i]:[2,i];case 1:return o=d.sent(),t?[3,3]:[4,this.getImageDefaultColorMappings(o,null)];case 2:t=d.sent(),d.label=3;case 3:return t&&t.length>0?[4,this.recolorImage(o,t)]:[3,5];case 4:o=d.sent(),d.label=5;case 5:return[4,this.createRasterItem(o,!1)];case 6:return(i=d.sent()).data.originalUrl=s,this.applyDesignEffectToItem(l,i),i.data.originalImageID=e.id,i.data.areaGuid=r.data.areaGuid,r.children.forEach(function(e){e.data.isGridImage&&(e.remove(),h.onItemRemoved(e))}),this.onItemCreated(i,e),this.addImageToGridBox(i,r,n.children.indexOf(r)),this.onGridImageSelected(i),this.updateItemsIndexes(),this.onItemUpdated(i),this.onDesignItemChanged(i),this.fireImageLoadedEvent(),this.endDesignOperation(),[2,i]}})})},onGridImageSelected:function(e){this.deselectGridBoxes();var t=this.getMaskedImageRasterItem(e);e&&t&&e.data&&(e.data.isGridImage||e.data.isGridIcon)&&(this.selectGridBox(e.parent),this.fireGridImageSelectedEvent(e))},createGridBoxIcon:function(){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(t){return[2,new Promise(function(t){var i=new e.paper.Raster({crossOrigin:"anonymous",source:Zakeke.config.baseUrl+"/images/other/camera_image_grids.png",onMouseEnter:function(){return e.paper.project.view.element.style.setProperty("cursor","pointer")},onMouseLeave:function(){return e.paper.project.view.element.style.setProperty("cursor",null)},visible:!1});i.onLoad=function(){i.onLoad=void 0,i.visible=!0,t(i)}})]})})},deselectGridBoxes:function(){this.getAllGridItems().forEach(function(e){e.children.forEach(function(e){if(e.data&&e.data.isGridPathGroup){var t=e.children.find(function(e){return e.data&&e.data.isGridBorderPath});t&&(t.strokeWidth=0,e.data.isBoxSelected=!1)}})})},selectGridBox:function(e){if(e&&e.data&&e.data.isGridPathGroup){var t=e.children.find(function(e){return e.data&&e.data.isGridBorderPath});t&&(this.createPathDashes(t),e.data.isBoxSelected=!0,e.children.find(function(e){return e.data&&e.data.isGridImage})&&t.bringToFront())}},getAllGridItems:function(){var e=[];function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];!a.guide&&a.data&&a.data.isGridGroup&&e.push(a),t(a)}}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}return e},removeAllGridItems:function(){var e=!1;this.currentDesignOperation||(e=!0,this.beginDesignOperation());for(var t=0,i=this.getAllGridItems();t<i.length;t++){var n=i[t];n.remove();for(var a=0,r=n.children;a<r.length;a++)for(var o=0,s=r[a].children;o<s.length;o++){var l=s[o];l.data&&l.data.isGridImage&&(l.data.isGridImage=!1,this.masterGroup.addChild(l),this.onItemUpdated(l))}}this.paper.project.view.update(),e&&this.endDesignOperation()},createGridItem:function(e,t){var i;return void 0===t&&(t=!1),__awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S,b,w,A=this;return __generator(this,function(P){switch(P.label){case 0:return n=this,this.beginDesignOperation(),(a=!e||!e.get("json"))&&this.removeAllGridBoxIdByItems(),this.removeAllGridItems(),r=this.findItemForArea(this.side.get("areas").at(0)),a||!r?[2]:((o=this.paper.project.activeLayer.importJSON(e.get("json"))).visible=!1,[4,this.createGridBoxIcon()]);case 1:for((s=P.sent()).visible=!1,o.scale(r.bounds.width/o.bounds.width,r.bounds.height/o.bounds.height),o.position.x=r.position.x,o.position.y=r.position.y,this.masterGroup.addChild(o),l=[],h=-1,d=.05*Math.min(o.bounds.width,o.bounds.height),c=0,u=o.children;c<u.length;c++)g=u[c],f=0,this.isMobile?((f=.2*Math.min(g.bounds.width,g.bounds.height))<d&&(f=d),(-1==h||f<h)&&(h=Math.max(f,60))):((f=.2*Math.min(g.bounds.width,g.bounds.height))<d&&(f=d),(-1==h||f<h)&&(h=Math.max(f,30)));for(p=0,m=o.children;p<m.length;p++)(v=m[p]).data.isGridBox=!0,v.data.smallestCameraIconDim=h,v.children.length>1&&(I=v.children.find(function(e){return e.data&&e.data.isGridBorderPath}))&&(I.strokeWidth=0,I.strokeColor="#000000",n.isViewer||(I.fillColor=new paper.Color(1,1,1,.9),(y=s.clone()).visible=!0,y.data.isGridIcon=!0,y.onMouseEnter=function(){return A.paper.project.view.element.style.setProperty("cursor","pointer")},y.onMouseLeave=function(){return A.paper.project.view.element.style.setProperty("cursor",null)},y.position.x=I.interiorPoint.x,y.position.y=I.interiorPoint.y,y.scale(h/y.bounds.width,h/y.bounds.height),this.isShapeContainsBounds(v,y)||(C=this.getIconPosition(v))&&(y.position.x=C.x,y.position.y=C.y),l.push(y),v.addChild(y)));for(s.remove(),M=this.getAllImageItems().filter(function(e){return!e.data.isImageForBackground}),(x=M.filter(function(e){return e.data&&e.data.isGridImage})).forEach(function(e){e.visible=!1}),S=function(){var e=M[w],n=null,a=-1;if(e.data&&null!=e.data.gridBoxID&&(n=o.children[e.data.gridBoxID])&&(a=e.data.gridBoxID),!n){if(null!=(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.gridBoxID)&&(w>=o.children.length||e.data.gridBoxID>=o.children.length))return e.remove(),b.onItemRemoved(e),"continue";n=o.children[w],a=w}var r=null,s=b.findDesignItemForItem(e);if(s&&(r=s.get("constraints")),!r||(r.get("canEdit")||r.get("canMove")||r.get("canRotate")||r.get("canResize")||r.get("canDelete"))&&e.data&&!e.data.isGridIcon)if(e.loaded)b.addImageToGridBox(e,n,a,t);else{var l=e.onLoad||function(){};e.onLoad=function(){l(),A.addImageToGridBox(e,n,a,t)}}else e.data&&null!=e.data.gridBoxID&&(e.data.isGridImage=!1,e.data.gridBoxID=null,b.isViewer||(b.onItemUpdated(e),b.onDesignItemChanged(e)))},b=this,w=0;w<M.length;w++)S();return o.visible=!0,this.updateItemsIndexes(),this.paper.project.view.update(),this.endDesignOperation(),this.resetUndoRedo(),x.forEach(function(e){e.visible=!0;var t=A.findDesignItemForItem(e);if(t){var i=t.get("constraints");A.isViewer&&i&&!i.get("isPrintable")&&(e.visible=i.get("keepInPreview"))}}),[2]}})})},getIconPosition:function(e){var t=e.children.find(function(e){return e.data&&e.data.isGridBorderPath});if(!t)return null;for(var i,n=t.bounds.width/20,a=t.bounds.height/20,r=new paper.Shape.Circle(new paper.Point(0,0),0),o=1,s=0;s<20;s++)for(var l=t.bounds.y+a*s,h=0;h<20;h++){var d=t.bounds.x+n*h,c=new paper.Point(d,l);if(t.contains(c))for(r.position=c,r.radius=o;;){if(!this.isShapeContainsCircle(t,r)){if(r.radius--,r.radius>o)o=r.radius,i=c;else if(r.radius==o&&i){var u=t.position.getDistance(i);t.position.getDistance(c)<u&&(i=c)}break}r.radius+=1}}return r.remove(),i},isShapeContainsCircle:function(e,t){var i=t.bounds.leftCenter,n=t.bounds.topCenter,a=t.bounds.rightCenter,r=t.bounds.bottomCenter;return e.contains(i)&&e.contains(n)&&e.contains(a)&&e.contains(r)},isShapeContainsBounds:function(e,t){var i=t.bounds.leftCenter,n=t.bounds.topCenter,a=t.bounds.rightCenter,r=t.bounds.bottomCenter,o=t.bounds.topLeft,s=t.bounds.topRight,l=t.bounds.bottomRight,h=t.bounds.bottomLeft;return e.contains(i)&&e.contains(n)&&e.contains(a)&&e.contains(r)&&e.contains(o)&&e.contains(s)&&e.contains(l)&&e.contains(h)},removeAllGridBoxIdByItems:function(){for(var e,t=0,i=this.getAllGridItems();t<i.length;t++)for(var n=0,a=i[t].children;n<a.length;n++)for(var r=0,o=a[n].children;r<o.length;r++){var s=o[r];s.data&&s.data.isGridImage&&(null===(e=null==s?void 0:s.data)||void 0===e?void 0:e.hasOwnProperty("gridBoxID"))&&delete s.data.gridBoxID}},updateTextOnPathGuides:function(e){e||(e=this.getAllTextOnPathItems());for(var t=0;t<e.length;t++){var i=e[t];this.updateTextOnPathGuide(i)}},updateTextOnPathGuide:function(e){e.data.selected?(this.drawTextOnPathGuide(e),this.drawTextOnPathHandles(e)):(this.removeTextOnPathGuide(e),this.removeTextOnPathHandles(e))},createPathDashes:function(e,t){if(void 0===t&&(t=[]),e){t&&0!=t.length||(t=["black","white"]);for(var i=[],n=t.length-1,a=0;a<1;a=Math.round(100*(a+.03))/100){var r=Math.min(Math.round(100*(a+.03))/100,1),o=t[n=(n+1)%t.length];i=__spreadArray(__spreadArray([],i,!0),[[o,a],[o,r]],!1)}var s=Math.max(e.bounds.width,e.bounds.height);e.strokeColor={gradient:{stops:i},origin:e.bounds.topLeft,destination:new paper.Point(e.bounds.topLeft.x+s,e.bounds.topLeft.y+s)},e.strokeWidth=1.5/this.paper.view.zoom,e.dashArray=[]}},drawTextOnPathGuide:function(e){if(this.removeTextOnPathGuide(e),e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var t=new this.paper.Path.Arc(e.data.points[0],e.data.points[1],e.data.points[2]);t.data.isTextOnPathGuide=!0,t.strokeWidth=2/this.paper.view.zoom,t.dashOffset=.5/this.paper.view.zoom,t.dashArray=[1/this.paper.view.zoom,1/this.paper.view.zoom],t.guide=!0,t.data.itemGuid=e.data.guid,this.isViewer||this.createPathDashes(t)}},findTextOnPathGuide:function(e){if(e&&e.data&&e.data.isTextOnPath&&e.data.guid)for(var t=e.data.guid.toUpperCase(),i=function(e,n){if(e.data&&e.data.isTextOnPathGuide&&e.data.itemGuid&&e.data.itemGuid.toUpperCase()==n)return e;if(e.children)for(var a=e.children.length-1;a>=0;a--){var r=e.children[a],o=i(r,t);if(o)return o}},n=0;n<this.paper.project.layers.length;n++){var a=this.paper.project.layers[n];if(!a.guide){var r=i(a,t);if(r)return r}}return null},removeTextOnPathGuide:function(e){var t=this.findTextOnPathGuide(e);t&&t.remove()},drawTextOnPathHandles:function(e){if(this.removeTextOnPathHandles(e),this.canMoveItem(e)&&e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var t=e.data.points[0],i=e.data.points[1],n=e.data.points[2],a=new this.paper.Rectangle(t,new this.paper.Point(n.x,i.y)),r=(this.getContrastedColor(a),this.selectionLateralResizeDimension/this.paper.view.zoom),o=new this.paper.Path.Circle(t,r);o.data.isTextOnPathHandle=!0,o.data.isTextOnPathFirstEndHandle=!0,o.strokeColor=new this.paper.Color(1,1,1,.5),o.strokeWidth=1,o.fillColor=new this.paper.Color(0,0,0,.5),o.data.itemGuid=e.data.guid;var s=new this.paper.Path.Circle(i,r);s.data.isTextOnPathHandle=!0,s.data.isTextOnPathMiddleEndHandle=!0,s.strokeColor=new this.paper.Color(1,1,1,.5),s.strokeWidth=1,s.fillColor=new this.paper.Color(0,0,0,.5),s.data.itemGuid=e.data.guid;var l=new this.paper.Path.Circle(n,r);l.data.isTextOnPathHandle=!0,l.data.isTextOnPathLastEndHandle=!0,l.strokeColor=new this.paper.Color(1,1,1,.5),l.strokeWidth=1,l.fillColor=new this.paper.Color(0,0,0,.5),l.data.itemGuid=e.data.guid,this.isViewer&&(o.visible=!1,s.visible=!1,l.visible=!1)}},findTextOnPathHandles:function(e){var t=[];if(e&&e.data&&e.data.isTextOnPath&&e.data.guid)for(var i=e.data.guid.toUpperCase(),n=function(e,a){if(e.data&&e.data.isTextOnPathHandle&&e.data.itemGuid&&e.data.itemGuid.toUpperCase()==a&&t.push(e),e.children)for(var r=e.children.length-1;r>=0;r--){var o=e.children[r];n(o,i)}},a=0;a<this.paper.project.layers.length;a++){var r=this.paper.project.layers[a];r.guide||n(r,i)}return t},removeTextOnPathHandles:function(e){for(var t=this.findTextOnPathHandles(e),i=0;i<t.length;i++){t[i].remove()}},onTextOnPathMoved:function(e,t){if(e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var i=e.data.points[0],n=e.data.points[1],a=e.data.points[2],r=new this.paper.Path.Arc(i,n,a);r.remove(),r.position.x+=t.x,r.position.y+=t.y,e.data.points[0]=r.getPointAt(0*r.length),e.data.points[1]=r.getPointAt(.5*r.length),e.data.points[2]=r.getPointAt(1*r.length)}},onTextOnPathRotated:function(e,t,i){if(e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var n=e.data.points[0],a=e.data.points[1],r=e.data.points[2],o=new this.paper.Path.Arc(n,a,r);o.remove(),o.rotate(t,i),e.data.points[0]=o.getPointAt(0*o.length),e.data.points[1]=o.getPointAt(.5*o.length),e.data.points[2]=o.getPointAt(1*o.length)}},onTextOnPathScaled:function(e,t,i,n){if(e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var a=e.data.points[0],r=e.data.points[1],o=e.data.points[2],s=new this.paper.Path.Arc(a,r,o);s.remove(),s.scale(t,i,n),e.data.points[0]=s.getPointAt(0*s.length),e.data.points[1]=s.getPointAt(.5*s.length),e.data.points[2]=s.getPointAt(1*s.length)}},moveTextOnPathFirstEnd:function(e){if(!this.frozen&&e.delta){var t=e.delta;this.hideCenterLines(),this.removeSelectionAlertItems();var i=this.getSelectedTextOnPathItems();if(i&&i.length>0){var n=i[0];n&&n.data&&n.data.isTextOnPath&&n.data.points&&"[object Array]"===Object.prototype.toString.call(n.data.points)&&3==n.data.points.length&&(n.data.points[0].x+=t.x,n.data.points[0].y+=t.y,this.canMovePathTextHandles(n)?(n.data.needsTransformsDataUpdate=!0,this.drawTextOnPathGuide(n),this.drawTextOnPathHandles(n),this.updateTextOnPath(n)):(n.data.points[0].x-=t.x,n.data.points[0].y-=t.y))}}},moveTextOnPathMiddleEnd:function(e){if(!this.frozen&&e.delta){var t=e.delta;this.hideCenterLines(),this.removeSelectionAlertItems();var i=this.getSelectedTextOnPathItems();if(i&&i.length>0){var n=i[0];n&&n.data&&n.data.isTextOnPath&&n.data.points&&"[object Array]"===Object.prototype.toString.call(n.data.points)&&3==n.data.points.length&&(n.data.points[1].x+=t.x,n.data.points[1].y+=t.y,this.canMovePathTextHandles(n)?(n.data.needsTransformsDataUpdate=!0,this.drawTextOnPathGuide(n),this.drawTextOnPathHandles(n),this.updateTextOnPath(n)):(n.data.points[1].x-=t.x,n.data.points[1].y-=t.y))}}},moveTextOnPathLastEnd:function(e){if(!this.frozen&&e.delta){var t=e.delta;this.hideCenterLines(),this.removeSelectionAlertItems();var i=this.getSelectedTextOnPathItems();if(i&&i.length>0){var n=i[0];n&&n.data&&n.data.isTextOnPath&&n.data.points&&"[object Array]"===Object.prototype.toString.call(n.data.points)&&3==n.data.points.length&&(n.data.points[2].x+=t.x,n.data.points[2].y+=t.y,this.canMovePathTextHandles(n)?(n.data.needsTransformsDataUpdate=!0,this.drawTextOnPathGuide(n),this.drawTextOnPathHandles(n),this.updateTextOnPath(n)):(n.data.points[2].x-=t.x,n.data.points[2].y-=t.y))}}},modifyTextOnPathInfo:function(e,t,i){t&&(t.text=this.adjustInputTextByConstraints(e,null!=t.text?t.text:e.data.text),t.letterSpacing=this.adjustInputLetterSpacingByConstraints(e,t.letterSpacing?parseInt(t.letterSpacing):void 0),t.strokeWidth=this.adjustInputTextStrokeWidth(e,t.strokeWidth),t.text&&(e.data.isProfanityCheckInvalid=!1,this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e))),this.removeAllAlertItems(),this.updateTextOnPath(e,t,i),this.adaptPathToText(e),this.updateTextOnPath(e,null,i),this.checkAllAlertItems(),this.checkImagesSizeLimit()},updateTextOnPath:function(e,t,i){if(this.beginDesignOperation(),e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0){var n=e.data.text;if(!n)for(var a=0;a<e.children.length;a++)n+=e.children[a].content;var r=this.getItemConstraints(e),o=null,s=this.findDesignItemForItem(e);s&&(o=this.getDesignEffectForDesignItem(s)),s&&(o=this.getDesignEffectForDesignItem(s));var l=null,h=null,d=null,c=!0;t||(t={},c=!1);var u=!1;t.hasOwnProperty("shadowColor")&&(u=!0),t.text=t.text||n,this.allowShadows()||(t.shadowColor=null),!r||r.get("canChangeFontColor")?(t.hasOwnProperty("strokeColor")&&(l=t.strokeColor),null!=t.fillColor&&(h=t.fillColor),l=this.forceColorInFixedPalette(e,l,i),h=this.forceColorInFixedPalette(e,h,i),t.strokeColor=void 0!==t.strokeColor?this.applyDesignEffectToTextColor(o,l):e.children[0].strokeColor,t.strokeColor&&(l=this.forceColorInFixedPalette(null,t.strokeColor)),t.fillColor=null!=t.fillColor?this.applyDesignEffectToTextColor(o,h):e.children[0].fillColor):(t.strokeColor=e.children[0].strokeColor,t.fillColor=e.children[0].fillColor),!r||r.get("canChangeShadowColor")?(void 0!==t.shadowColor&&(d=t.shadowColor),d=this.forceColorInFixedPalette(e,d,i),t.shadowColor=this.allowShadows()?void 0!==t.shadowColor?this.applyDesignEffectToTextColor(o,d):e.children[0].shadowColor:null):t.shadowColor=this.allowShadows()?e.children[0].shadowColor:null,u&&void 0!==d&&(e.data.originalShadowColor=d),t.strokeWidth=null!=t.strokeWidth?t.strokeWidth:e.children[0].strokeWidth,t.shadowBlur=null!=t.shadowBlur?t.shadowBlur:e.children[0].shadowBlur,t.shadowDistance=null!=t.shadowDistance?t.shadowDistance:this.getOffsetDistance(e.children[0].shadowOffset),t.shadowAngle=null!=t.shadowAngle?t.shadowAngle:this.getOffsetAngle(e.children[0].shadowOffset),t.shadowBlur=this.adjustInputShadowBlur(e,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(e,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(e,t.shadowAngle),!r||r.get("canChangeFontFamily")?t.fontFamily=null!=t.fontFamily?t.fontFamily:e.children[0].fontFamily:t.fontFamily=e.children[0].fontFamily,t.fontFamily=this.sanitizeFontFamilyName(t.fontFamily);var g=null!=t.fontWeight?t.fontWeight:e.children[0].fontWeight;t.fontWeight=this.adjustInputFontWeightByConstraints(e.children[0].fontWeight,g,r),t.fontStretch=null!=t.fontStretch?t.fontStretch:e.children[0].fontStretch,!r||r.get("canChangeFontSize")?t.fontSize=null!=t.fontSize?t.fontSize:e.children[0].fontSize:t.fontSize=e.children[0].fontSize,t.scaling=null!=t.scaling?t.scaling:e.children[0].scaling,e.data.text=t.text,c&&void 0!==l&&(e.data.originalStrokeColor=l),h&&(e.data.originalFillColor=h),t.letterSpacing=null!=t.letterSpacing?t.letterSpacing:null!=e.data.letterSpacing?e.data.letterSpacing:0,e.data.letterSpacing=t.letterSpacing,e.removeChildren();var f=e.data.points[0],p=e.data.points[1],m=e.data.points[2],v=new this.paper.Path.Arc(f,p,m);v.remove();var I=v.getPointAt(.5*v.length);e.data.points[1]=I;var y=this.createAlignedText(v,t,null);e.addChildren(y),this.applyDesignEffectToItem(o,e),this.updateSelectionState(),this.paper.project.view.update()}this.endDesignOperation()},adaptPathToText:function(e){performance.now();if(e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var t=e.data.text;if(!t)for(var i=0;i<e.children.length;i++)t+=e.children[i].content;var n=e.data.points[0],a=e.data.points[1],r=e.data.points[2],o=new this.paper.Path.Arc(n,a,r);o.remove();var s={};s.text=t,s.strokeColor=e.children[0].strokeColor,s.strokeWidth=e.children[0].strokeWidth,s.fillColor=e.children[0].fillColor,s.fontFamily=e.children[0].fontFamily,s.fontWeight=e.children[0].fontWeight,s.fontSize=e.children[0].fontSize,s.scaling=e.children[0].scaling,s.letterSpacing=null!=e.data.letterSpacing?e.data.letterSpacing:0,s.shadowColor=e.children[0].shadowColor,s.shadowBlur=e.children[0].shadowBlur,s.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),s.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset);var l=0;if(this.isLetterSpacingSpecified(s)){var h=this.getTextExtraSpace(s),d=null;for(i=0;i<t.length;i++)i>0&&(l+=h),l+=(d=this.createPointText(t.substring(i,i+1),s)).bounds.width,d.remove()}else{var c=this.createPointText(t,s);c.remove(),l=c.bounds.width}if(Math.abs(l-o.length)<.001){performance.now();return}var u=this.getCircleCenter(n,r,a),g=n.getDistance(u),f=2*Math.PI*g,p=(o.length,(l-o.length)/f*360),m=this.getCircleAngleAtPoint(u.x,u.y,g,n.x,n.y),v=this.getCircleAngleAtPoint(u.x,u.y,g,r.x,r.y),I=this.getCircleAngleAtPoint(u.x,u.y,g,a.x,a.y),y=0,C=0;(m=this.getNormalizedAngle(m))>(v=this.getNormalizedAngle(v))?y=360-(C=m-v):C=360-(y=v-m),(I=this.getNormalizedAngle(I))<m?(p+C>359&&(p=359-C),m+=p/2,v-=p/2):(p+y>359&&(p=359-y),m-=p/2,v+=p/2),m=this.getNormalizedAngle(m),v=this.getNormalizedAngle(v);var M=this.getCirclePointAtAngle(u.x,u.y,g,m),x=this.getCirclePointAtAngle(u.x,u.y,g,v);e.data.points[0]=M,e.data.points[2]=x,this.updateSelectionState(),this.paper.project.view.update()}performance.now()},createAlignedText:function(e,t,i){performance.now();var n=[],a=t.inside||!1;if(t&&t.text&&t.text.length>0&&e){var r=t.text,o=(this.getSpaceWidth(t),this.getTextExtraSpace(t)),s=this.getTotalTextLength(t,e),l=this.getGlyphTexts(t),h=this.getGlyphsLength(l,o),d=this.isLetterSpacingSpecified(t)?h:s;if(!i){var c={path:e,totalLength:d,glyphTexts:l};i=this.getStartOffset(c)}for(var u={startOffset:i,info:t,glyphTexts:l,extraSpace:o},g=this.getGlyphOffsets(u),f=0;f<r.length;f++){var p=g[f];if(p<0&&e.closed&&(p=e.length+p),e.length<p&&(e.closed?p%=e.length:p=void 0),void 0===p)l[f].remove();else{n.push(l[f]);var m=e.getPointAt(p);l[f].point=m;var v=e.getTangentAt(p);if(v){var I=v.angle;a&&(I-=180),l[f].rotate(I,m)}}}}performance.now();return n},getTotalTextLength:function(e,t){var i=e.text,n=this.createPointText(i,e);return n.bounds.centerX=t.bounds.centerX,this.paper.project.view.update(),n.remove(),n.bounds.width},getGlyphTexts:function(e){for(var t=e.text,i=[],n=0;n<t.length;n++)i[n]=this.createPointText(t.substring(n,n+1),e),i[n].justification="center";return i},getGlyphsLength:function(e,t){for(var i=0,n=0;n<e.length;n++)n>0&&(i+=t),i+=e[n].bounds.width;return i},getStartOffset:function(e){var t=e.path,i=e.totalLength,n=e.glyphTexts,a=n[0],r=(n[n.length-1],0);i<t.length+.05&&(r=(t.length-i)/2+a.bounds.width/2);return r},getGlyphOffsets:function(e){for(var t=e.startOffset,i=e.info,n=e.glyphTexts,a=e.extraSpace,r=i.text,o=i.inside||!1,s=[t],l=1;l<r.length;l++){var h=this.createPointText(r.substring(l-1,l+1),i);h.remove();var d=s[l-1],c=n[l-1],u=n[l];if(o)s[l]=d-(h.bounds.width-c.bounds.width/2-u.bounds.width/2+a);else{var g=c.bounds.width/2+u.bounds.width/2,f=d+(h.bounds.width-g+a);s[l]=f}}return s},canMovePathTextHandles:function(e){var t=!0,i=e.data.points[0],n=e.data.points[1],a=e.data.points[2],r=new this.paper.Path.Arc(i,n,a);r.remove();var o=this.getInfoFromTextToPath(e),s=this.getTextExtraSpace(o),l=this.getTotalTextLength(o,r),h=this.getGlyphTexts(o);h.forEach(function(e){e.remove()});var d=this.getGlyphsLength(h,s),c=this.isLetterSpacingSpecified(o)?d:l,u=this.getStartOffset({path:r,totalLength:c,glyphTexts:h}),g=this.getGlyphOffsets({startOffset:u,info:o,glyphTexts:h,extraSpace:s}),f=g[g.length-1];return r.length<f&&(t=!1),t},getInfoFromTextToPath:function(e){var t={},i=e.data.text;if(!i)for(var n=0;n<e.children.length;n++)i+=e.children[n].content;var a=e.children[0];return t.text=i,t.strokeColor=a.strokeColor,t.strokeWidth=a.strokeWidth,t.fillColor=a.fillColor,t.fontFamily=a.fontFamily,t.fontWeight=a.fontWeight,t.fontSize=a.fontSize,t.scaling=a.scaling,t.letterSpacing=null!=e.data.letterSpacing?e.data.letterSpacing:0,t.shadowColor=a.shadowColor,t.shadowBlur=a.shadowBlur,t.shadowDistance=this.getOffsetDistance(a.shadowOffset),t.shadowAngle=this.getOffsetAngle(a.shadowOffset),t},createPointText:function(e,t){var i=new this.paper.PointText;return i.content=e,t&&(i.strokeColor=t.strokeColor,i.strokeWidth=null!=t.strokeWidth?t.strokeWidth:0,i.fillColor=t.fillColor||"black",i.fontFamily=t.fontFamily||"Verdana",i.fontWeight=t.fontWeight||"normal",i.fontSize=t.fontSize||12,t.scaling&&(i.scaling=t.scaling),i.shadowColor=t.shadowColor,i.shadowBlur=t.shadowBlur,i.shadowOffset=this.getOffsetByDistanceAngle(t.shadowDistance,t.shadowAngle)),i},getCircleCenter:function(e,t,i){var n=Math.pow(t.x,2)+Math.pow(t.y,2),a=(Math.pow(e.x,2)+Math.pow(e.y,2)-n)/2,r=(n-Math.pow(i.x,2)-Math.pow(i.y,2))/2,o=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);return!(Math.abs(o)<1e-14)&&new this.paper.Point((a*(t.y-i.y)-r*(e.y-t.y))/o,((e.x-t.x)*r-(t.x-i.x)*a)/o)},getCirclePointAtAngle:function(e,t,i,n){var a=n*Math.PI/180,r=i*Math.cos(a)+e,o=i*Math.sin(a)+t;return new paper.Point(r,o)},getCircleAngleAtPoint:function(e,t,i,n,a){return 0==i?0:(180*Math.atan2(a-t,n-e)/Math.PI+360)%360},getNormalizedAngle:function(e){return e<0&&(e=360+e),e>360&&(e-=360),e},addTextAreaElement:function(e,t,i){if(void 0===i&&(i=!0),i||this.canAddText()){var n=null;if(this.side)if(a=this.side.get("areas").getMaxArea()){if(this.beginDesignOperation(),!e&&this.side){var a=this.side.get("areas").getMaxArea(),r=this.findItemForArea(a);r&&(e=r.bounds.expand(-50))}if(!e)return;if(t&&t.text){var o=this.getDesignEffectForArea(a);this.allowShadows()||(t.shadowColor=null);var s=t.strokeColor||null,l=t.fillColor||"#000000",h=t.shadowColor||null;s=this.forceColorInFixedPalette(null,s),l=this.forceColorInFixedPalette(null,l),h=this.forceColorInFixedPalette(null,h),t.strokeColor=this.applyDesignEffectToTextColor(o,s),t.fillColor=this.applyDesignEffectToTextColor(o,l),t.shadowColor=this.applyDesignEffectToTextColor(o,h),t.shadowBlur=this.adjustInputShadowBlur(null,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(null,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(null,t.shadowAngle),t.letterSpacing=null!=t.letterSpacing?t.letterSpacing:0,t.lineSpacing=null!=t.lineSpacing?t.lineSpacing:0,t.strokeWidth=this.adjustInputTextStrokeWidth(null,t.strokeWidth),this.deselectAll(),this.updateSelectionState(),n=new this.paper.Group;var d=this.createWrappedText(e,t,!1).textItems;n.addChildren(d),this.applyDesignEffectToItem(o,n),e=n.bounds,n.data.rect=e,n.data.isTextArea=!0,n.data.text=t.text,n.data.justification=null!=t.justification?t.justification:"justify",n.data.originalStrokeColor=s,n.data.originalFillColor=l,n.data.originalShadowColor=h,n.data.letterSpacing=t.letterSpacing,n.data.lineSpacing=t.lineSpacing,n.rotation=t.rotation,this.masterGroup.addChild(n);var c=e.center.subtract(n.position);n.position=e.center,n.data.needsTransformsDataUpdate=!0,this.updateTransformsData(n),this.onTextAreaMoved(n,c),this.forceTextAreaToBounds(n),this.onItemCreated(n),this.setItemSelection(n,!0)}this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}return n}},isItemTextArea:function(e){return e&&e.data&&e.data.isTextArea},isItemTextBox:function(e){return this.isItemTextArea(e)&&e.data.isTextBox},isSimpleTextArea:function(e){return e&&e.data&&e.data.isTextArea&&!e.data.isTextBox},convertSelectedTextAreaToTextBox:function(){var e=this;this.getSelectedTextAreaItems().forEach(function(t){return e.convertTextAreaToTextBox(t)})},convertSelectedTextBoxToTextArea:function(){var e=this;this.getSelectedTextAreaItems().forEach(function(t){return e.convertTextBoxToTextArea(t)})},toggleSelectedTextArea:function(){var e=this;this.getSelectedTextAreaItems().forEach(function(t){t.data.isTextBox?e.convertTextBoxToTextArea(t):e.convertTextAreaToTextBox(t)})},convertTextAreaToTextBox:function(e){if(this.canChangeItemTextBoxMode(e)&&this.isSimpleTextArea(e)){var t=this.getLastUndoOperationId();this.beginDesignOperation(),e.data.isTextBox=!0,this.updateTextArea(e,null),this.onItemUpdated(e),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(t)}},convertTextBoxToTextArea:function(e){if(this.canChangeItemTextBoxMode(e)&&this.isItemTextBox(e)){var t=this.getLastUndoOperationId();this.beginDesignOperation(),e.data.isTextBox=!1,this.updateTextArea(e,null),this.onItemUpdated(e),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(t)}},getAllTextAreaItems:function(){var e=[];function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];!a.guide&&a.data&&a.data.isTextArea&&e.push(a),t(a)}}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}return e},updateTextAreaGuides:function(e){e||(e=this.getAllTextAreaItems());for(var t=0;t<e.length;t++){var i=e[t];this.updateTextAreaGuide(i)}},updateTextAreaGuide:function(e){e.data.selected&&this.canEditItem(e)?(this.drawTextAreaGuide(e),this.drawTextAreaHandles(e)):(this.removeTextAreaGuide(e),this.removeTextAreaHandles(e))},drawTextAreaGuide:function(e){if(this.removeTextAreaGuide(e),e&&e.data&&e.data.isTextArea&&e.data.isTextBox&&e.data.rect){var t=new this.paper.Path.Rectangle(e.data.rect);t.data.isTextAreaGuide=!0,t.strokeWidth=1/this.paper.view.zoom,t.dashOffset=1/this.paper.view.zoom,t.dashArray=[2/this.paper.view.zoom,2/this.paper.view.zoom],t.guide=!0,t.data.itemGuid=e.data.guid,t.strokeColor=this.getContrastedColor(e.data.rect),e.children&&e.children.length>0?t.rotation=e.children[0].rotation:e.data.textInfo&&null!=e.data.textInfo.rotation&&(t.rotation=e.data.textInfo.rotation)}},findTextAreaGuide:function(e){if(e&&e.data&&e.data.isTextArea&&e.data.guid)for(var t=e.data.guid.toUpperCase(),i=function(e,n){if(e.data&&e.data.isTextAreaGuide&&e.data.itemGuid&&e.data.itemGuid.toUpperCase()==n)return e;if(e.children)for(var a=e.children.length-1;a>=0;a--){var r=e.children[a],o=i(r,t);if(o)return o}},n=0;n<this.paper.project.layers.length;n++){var a=this.paper.project.layers[n];if(!a.guide){var r=i(a,t);if(r)return r}}return null},removeTextAreaGuide:function(e){var t=this.findTextAreaGuide(e);t&&t.remove()},drawTextAreaHandles:function(e){if(this.removeTextAreaHandles(e),this.canResizeTextBoxItem(e)&&e&&e.data&&e.data.isTextArea&&e.data.isTextBox&&e.data.rect){var t=this.selectionLateralResizeDimension/this.paper.view.zoom,i=new this.paper.Path.Rectangle(e.data.rect);e.children&&e.children.length>0?i.rotation=e.children[0].rotation:e.data.textInfo&&null!=e.data.textInfo.rotation&&(i.rotation=e.data.textInfo.rotation),i.remove();var n=i.segments;if(4==n.length){var a=n[0].point,r=n[1].point,o=n[2].point,s=n[3].point,l=r.add(o.subtract(r).divide(2)),h=a.add(s.subtract(a).divide(2)),d=a.add(r.subtract(a).divide(2)),c=s.add(o.subtract(s).divide(2)),u=1.2*t,g=l.subtract(h).normalize(u);l=l.add(g),h=h.subtract(g),g=c.subtract(d).normalize(u),c=c.add(g),d=d.subtract(g);var f=new this.paper.Path.Circle(l,t);f.data.isTextAreaHandle=!0,f.data.isTextAreaTopEndHandle=!0,f.strokeColor=new this.paper.Color(1,1,1,.5),f.strokeWidth=1,f.fillColor=new this.paper.Color(0,0,0,.5),f.data.itemGuid=e.data.guid;var p=new this.paper.Path.Circle(c,t);p.data.isTextAreaHandle=!0,p.data.isTextAreaRightEndHandle=!0,p.strokeColor=new this.paper.Color(1,1,1,.5),p.strokeWidth=1,p.fillColor=new this.paper.Color(0,0,0,.5),p.data.itemGuid=e.data.guid;var m=new this.paper.Path.Circle(h,t);m.data.isTextAreaHandle=!0,m.data.isTextAreaBottomEndHandle=!0,m.strokeColor=new this.paper.Color(1,1,1,.5),m.strokeWidth=1,m.fillColor=new this.paper.Color(0,0,0,.5),m.data.itemGuid=e.data.guid;var v=new this.paper.Path.Circle(d,t);v.data.isTextAreaHandle=!0,v.data.isTextAreaLeftEndHandle=!0,v.strokeColor=new this.paper.Color(1,1,1,.5),v.strokeWidth=1,v.fillColor=new this.paper.Color(0,0,0,.5),v.data.itemGuid=e.data.guid}}},findTextAreaHandles:function(e){var t=[];if(e&&e.data&&e.data.isTextArea&&e.data.guid)for(var i=e.data.guid.toUpperCase(),n=function(e,a){if(e.data&&e.data.isTextAreaHandle&&e.data.itemGuid&&e.data.itemGuid.toUpperCase()==a&&t.push(e),e.children)for(var r=e.children.length-1;r>=0;r--){var o=e.children[r];n(o,i)}},a=0;a<this.paper.project.layers.length;a++){var r=this.paper.project.layers[a];r.guide||n(r,i)}return t},removeTextAreaHandles:function(e){for(var t=this.findTextAreaHandles(e),i=0;i<t.length;i++){t[i].remove()}},onTextAreaMoved:function(e,t){if(e&&e.data&&e.data.isTextArea&&e.data.rect){var i=e.data.rect.clone();i.x+=t.x,i.y+=t.y,e.data.rect=i}},onTextAreaRotated:function(e,t,i){e&&e.data&&e.data.isTextBox&&this.updateTextArea(e,null)},onTextAreaScaled:function(e,t,i,n){if(e&&e.data&&e.data.isTextArea&&e.data.rect)if(e.data.isTextBox)this.updateTextArea(e,null);else{var a=new this.paper.Path.Rectangle(e.data.rect);a.remove(),a.scale(t,i,n),e.data.rect=a.bounds.clone()}},canResizeSelectedTextAreas:function(e,t,i){for(var n=this.getSelectedItems(),a=0;a<n.length;a++){var r=n[a];if(!this.canResizeTextArea(r,e,t,i))return!1}return!0},canResizeTextArea:function(e,t,i,n){if(e&&e.data&&e.data.isTextArea&&e.data.isTextBox&&e.data.rect&&e.children&&e.children.length>0){var a=e.children[0].clone();a.scale(t,i,n);var r=a.scaling;a.remove();var o=this.getTextAreaItemInfo(e,null);o.scaling=r;var s=this.createWrappedText(e.data.rect.clone(),o,!0).textItems;if(console.log("children count: "+s.length),0==s.length)return!1;s.forEach(function(e){e.remove()})}return!0},moveTextAreaTopEnd:function(e){this.moveTextAreaEnd(e,"top")},moveTextAreaRightEnd:function(e){this.moveTextAreaEnd(e,"right")},moveTextAreaBottomEnd:function(e){this.moveTextAreaEnd(e,"bottom")},moveTextAreaLeftEnd:function(e){this.moveTextAreaEnd(e,"left")},moveTextAreaEnd:function(e,t){if(!this.frozen&&e.delta){var i=e.delta;this.hideCenterLines(),this.removeSelectionAlertItems();var n=this.getSelectedTextAreaItems();if(n&&n.length>0){var a=n[0];if(a&&a.data&&a.data.isTextArea&&a.data.rect){var r=a.data.rect.clone(),o="bottom";"top"==t?(a.data.rect.top+=i.y,o="bottom"):"right"==t?(a.data.rect.right+=i.x,o="left"):"bottom"==t?(a.data.rect.bottom+=i.y,o="top"):"left"==t&&(a.data.rect.left+=i.x,o="right"),this.correctTextBoxRectRotationError(a,r,o),a.data.needsTransformsDataUpdate=!0,this.drawTextAreaGuide(a),this.drawTextAreaHandles(a),this.updateTextArea(a,null),0==a.children.length&&a.data.text&&(a.data.rect=r.clone(),a.data.needsTransformsDataUpdate=!0,this.drawTextAreaGuide(a),this.drawTextAreaHandles(a),this.updateTextArea(a,null))}}}},correctTextBoxRectRotationError:function(e,t,i){if(e&&e.data&&e.data.isTextBox&&e.data.rect){var n=0;if(e.children&&e.children.length>0?n=e.children[0].rotation:e.data.textInfo&&null!=e.data.textInfo.rotation&&(n=e.data.textInfo.rotation),0!=n){var a=new this.paper.Path.Rectangle(t);a.rotate(n),a.remove();var r=a.segments,o=null,s=null,l=null,h=null;if(4==r.length){var d=r[0].point,c=r[1].point,u=r[2].point,g=r[3].point;o=c.add(u.subtract(c).divide(2)),s=d.add(g.subtract(d).divide(2)),l=d.add(c.subtract(d).divide(2)),h=g.add(u.subtract(g).divide(2))}var f=new this.paper.Path.Rectangle(e.data.rect);f.rotate(n),f.remove();var p=f.segments,m=null,v=null,I=null,y=null;if(4==p.length){var C=p[0].point,M=p[1].point,x=p[2].point,S=p[3].point;m=M.add(x.subtract(M).divide(2)),v=C.add(S.subtract(C).divide(2)),I=C.add(M.subtract(C).divide(2)),y=S.add(x.subtract(S).divide(2))}var b=null,w=null;if("bottom"==i?(b=s,w=v):"top"==i?(b=o,w=m):"right"==i?(b=h,w=y):"left"==i&&(b=l,w=I),b&&w){var A=w.subtract(b);e.data.rect.x-=A.x,e.data.rect.y-=A.y}}}},adaptTextBoxFontSize:function(e){if(this.isItemTextBox(e)){var t=this.getItemConstraints(e);if(t&&!t.get("canChangeFontSize"))return;var i=this.getTextAreaItemInfo(e,null);if(i.adaptText)return;for(var n=i.fontSize;i.text&&0==e.children.length&&n>=1;)n-=1,this.updateTextArea(e,{fontSize:n})}},modifyTextAreaInfo:function(e,t,i){t&&(t.text=this.adjustInputTextByConstraints(e,null!=t.text?t.text:e.data.text),t.letterSpacing=this.adjustInputLetterSpacingByConstraints(e,t.letterSpacing?parseInt(t.letterSpacing):void 0),t.lineSpacing=this.adjustInputLineSpacingByConstraints(e,t.lineSpacing?parseInt(t.lineSpacing):void 0),t.strokeWidth=this.adjustInputTextStrokeWidth(e,t.strokeWidth),t.text&&(e.data.isProfanityCheckInvalid=!1,this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e))),this.removeAllAlertItems(),this.updateTextArea(e,t,i),this.checkImagesSizeLimit()},getTextAreaItemInfo:function(e,t){if(e&&e.data&&e.data.isTextArea){var i=null;if(e.children.length>0){var n=e.children[0];i={};var a="string"==typeof n.strokeColor||n.strokeColor instanceof String;i.strokeColor=a||null===n.strokeColor?n.strokeColor:n.strokeColor.toCSS(!0),i.fillColor="string"==typeof n.fillColor||n.fillColor instanceof String?n.fillColor:n.fillColor.toCSS(!0),i.strokeWidth=n.strokeWidth,i.fontFamily=n.fontFamily,i.fontWeight=n.fontWeight,i.fontStretch=n.fontStretch,i.fontSize=n.fontSize,i.scaling=n.scaling,i.rotation=n.rotation,i.shadowColor=null,n.shadowColor&&(i.shadowColor="string"==typeof n.shadowColor||n.shadowColor instanceof String?n.shadowColor:n.shadowColor.toCSS(!0)),i.shadowBlur=n.shadowBlur,i.shadowDistance=this.getOffsetDistance(n.shadowOffset),i.shadowAngle=this.getOffsetAngle(n.shadowOffset)}i=i||{};var r=this.getItemConstraints(e);(t=t||{}).text=t.text||e.data.text;var o=e.data.textInfo||{};!r||r.get("canChangeFontColor")?(t.strokeColor=void 0!==t.strokeColor?t.strokeColor:void 0!==i.strokeColor?i.strokeColor:o.strokeColor,t.fillColor=null!=t.fillColor?t.fillColor:null!=i.fillColor?i.fillColor:o.fillColor):(t.strokeColor=void 0!==i.strokeColor?i.strokeColor:o.strokeColor,t.fillColor=null!=i.fillColor?i.fillColor:o.fillColor),t.strokeWidth=null!=t.strokeWidth?t.strokeWidth:null!=i.strokeWidth?i.strokeWidth:o.strokeWidth,!r||r.get("canChangeFontFamily")?t.fontFamily=null!=t.fontFamily?t.fontFamily:null!=i.fontFamily?i.fontFamily:o.fontFamily:t.fontFamily=null!=i.fontFamily?i.fontFamily:o.fontFamily,t.fontFamily=this.sanitizeFontFamilyName(t.fontFamily);var s=null!=t.fontWeight?t.fontWeight:null!=i.fontWeight?i.fontWeight:o.fontWeight;t.fontWeight=this.adjustInputFontWeightByConstraints(null!=i.fontWeight?i.fontWeight:o.fontWeight,s,r),t.fontStretch=null!=t.fontStretch?t.fontStretch:null!=i.fontStretch?i.fontStretch:o.fontStretch,!r||r.get("canChangeFontSize")?t.fontSize=null!=t.fontSize?t.fontSize:null!=i.fontSize?i.fontSize:o.fontSize:t.fontSize=null!=i.fontSize?i.fontSize:o.fontSize,t.scaling=null!=t.scaling?t.scaling:null!=i.scaling?i.scaling:o.scaling,t.scaling=t.scaling||1,t.justification=null!=t.justification?t.justification:null!=e.data.justification?e.data.justification:"justify",t.rotation=null!=i.rotation?i.rotation:o.rotation,t.rotation=t.rotation||0,t.isTextBox=e.data&&e.data.isTextBox,t.adaptText=null!=t.adaptText?t.adaptText:null!=e.data.adaptText&&e.data.adaptText,t.wrapTextOnAdaptText=this.canWrapTextOnAdaptText(e),!r||r.get("canChangeVerticalAlignment")?t.verticalAlignment=null!=t.verticalAlignment?t.verticalAlignment:null!=e.data.verticalAlignment?e.data.verticalAlignment:"top":t.verticalAlignment=null!=e.data.verticalAlignment?e.data.verticalAlignment:"top";null!=t.letterSpacing?t.letterSpacing:null!=e.data.letterSpacing&&e.data.letterSpacing;t.letterSpacing=this.adjustInputLetterSpacingByConstraints(e,t.letterSpacing);null!=t.lineSpacing?t.lineSpacing:null!=e.data.lineSpacing&&e.data.lineSpacing;return t.lineSpacing=this.adjustInputLineSpacingByConstraints(e,t.lineSpacing),!r||r.get("canChangeShadowColor")?t.shadowColor=void 0!==t.shadowColor?t.shadowColor:void 0!==i.shadowColor?i.shadowColor:o.shadowColor:t.shadowColor=void 0!==i.shadowColor?i.shadowColor:o.shadowColor,!r||r.get("canChangeShadowBlur")?t.shadowBlur=void 0!==t.shadowBlur?t.shadowBlur:null!=i.shadowBlur?i.shadowBlur:o.shadowBlur:t.shadowBlur=void 0!==i.shadowBlur?i.shadowBlur:o.shadowBlur,!r||r.get("canChangeShadowDistance")?t.shadowDistance=void 0!==t.shadowDistance?t.shadowDistance:null!=i.shadowDistance?i.shadowDistance:o.shadowDistance:t.shadowDistance=void 0!==i.shadowDistance?i.shadowDistance:o.shadowDistance,!r||r.get("canChangeShadowAngle")?t.shadowAngle=void 0!==t.shadowAngle?t.shadowAngle:null!=i.shadowAngle?i.shadowAngle:o.shadowAngle:t.shadowAngle=void 0!==i.shadowAngle?i.shadowAngle:o.shadowAngle,this.allowShadows()||(t.shadowColor=null,e.data.originalShadowColor=null),t.shadowBlur=this.adjustInputShadowBlur(e,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(e,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(e,t.shadowAngle),t}return null},setTextAreaItemInfo:function(e,t){e&&(e.data.textInfo=t)},updateTextArea:function(e,t,i){var n,a;if(e&&e.data&&e.data.isTextArea&&e.data.rect){var r=e.data.text||t.text,o=this.getTextAreaItemInfo(e),s=null,l=this.findDesignItemForItem(e);l&&(s=this.getDesignEffectForDesignItem(l));var h=null,d=null,c=null;t&&void 0!==t.strokeColor&&(h=t.strokeColor,h=this.forceColorInFixedPalette(e,h,o.strokeColor,i),t.strokeColor=this.applyDesignEffectToTextColor(s,h),e.data.originalStrokeColor=h),t&&null!=t.fillColor&&(d=t.fillColor,d=this.forceColorInFixedPalette(e,d,o.fillColor,i),t.fillColor=this.applyDesignEffectToTextColor(s,d),e.data.originalFillColor=d),t&&void 0!==t.shadowColor&&(c=t.shadowColor,c=this.forceColorInFixedPalette(e,c,o.shadowColor,i),t.shadowColor=this.applyDesignEffectToTextColor(s,c),e.data.originalShadowColor=c),this.beginDesignOperation();var u=e.bounds.clone();if(t=this.getTextAreaItemInfo(e,t)){!e.data.isTextBox&&(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.originalMatrix)&&(t.disableScaling=!0);var g=t.text;e.data.justification=t.justification,e.data.text=t.text,e.data.adaptText=t.adaptText,e.data.letterSpacing=t.letterSpacing,e.data.lineSpacing=t.lineSpacing,e.data.verticalAlignment=t.verticalAlignment;var f=t.rotation;t.scaling.x,t.scaling.y,e.matrix.clone();if(e.data.isTextBox){var p=e.data.rect.center.clone();e.rotate(-f,p)}else e.rotate(0-f);var m=e.bounds.clone();if(e.removeChildren(),e.data.isTextBox)if(e.data.adaptText){var v=null;if(r&&r.length>0&&t.text&&Math.abs(r.length-t.text.length)>5){var I=Math.abs(r.length-t.text.length),y=t.fontSize,C=t.fontSize;for(r.length<t.text.length?(C=t.fontSize,(y=this.adjustTextFontSize(e,C-4*I))<1&&(y=1)):(y=t.fontSize,C=this.adjustTextFontSize(e,y+4*I)),t.fontSize=Math.round(y+(C-y)/2);t.fontSize-y>0&&C-t.fontSize>0;)v&&v.textItems.forEach(function(e){return e.remove()}),(v=this.createWrappedText(e.data.rect,t,!0)).limitsExceeded?C=t.fontSize:y=t.fontSize,t.fontSize=Math.round(y+(C-y)/2)}for(v||(v=this.createWrappedText(e.data.rect,t,!0));!v.limitsExceeded&&this.canSetTextFontSizePx(e,t.fontSize+1);)v.textItems.forEach(function(e){return e.remove()}),t.fontSize+=1,v=this.createWrappedText(e.data.rect,t,!0);for(;v.limitsExceeded&&t.fontSize>1&&this.canSetTextFontSizePx(e,t.fontSize-1);)v.textItems.forEach(function(e){return e.remove()}),t.fontSize-=1,v=this.createWrappedText(e.data.rect,t,!0);e.addChildren(v.textItems)}else{var M=this.createWrappedText(e.data.rect.clone(),t,!0).textItems;e.addChildren(M)}else{var x=this.createWrappedText(m,t,!1).textItems;e.addChildren(x)}if(this.applyDesignEffectToItem(s,e),e.data.isTextBox){p=e.data.rect.center.clone();e.rotate(f,p)}else(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.originalMatrix)&&(this.paper.project.view.update(),this.setScaleRotationMatrix(e.matrix,e.data.originalMatrix));e.data.isTextBox||this.alignTextAreaItem(e,f,t.justification,u,g),e.data.isTextBox||(e.data.rect=e.bounds.clone()),this.setTextAreaItemInfo(e,t),this.updateSelectionState(),this.paper.project.view.update()}this.endDesignOperation()}},setScaleRotationMatrix:function(e,t){var i=[t.a,t.b,t.c,t.d,e.tx,e.ty];e.set(i),this.paper.project.view.update()},alignTextAreaItem:function(e,t,i,n,a){if(null!=a){var r=new this.paper.Point(n.x+n.width/2,n.y+n.height/2);if("center"!=i&&"justify"!=i){var o=new this.paper.Point(n.left+e.bounds.width/2,n.top+e.bounds.height/2),s=new this.paper.Point(n.right-e.bounds.width/2,n.top+e.bounds.height/2),l=new this.paper.Point(n.left+e.bounds.width/2,n.bottom-e.bounds.height/2),h=new this.paper.Point(n.right-e.bounds.width/2,n.bottom-e.bounds.height/2);t>=0&&t<=90?r="left"==i?o:h:t>90&&t<=180?r="left"==i?s:l:t>=-90&&t<0?r="left"==i?l:s:t>-180&&t<-90&&(r="left"==i?h:o),e.position=r;var d=e.data.text.split("\n"),c=a.split("\n"),u=d.length-c.length;if(d.length!=c.length){var g=e.children[0].clone();g.visible=!1,g.rotate(0-t);var f=new this.paper.Path.Circle("left"==i?g.bounds.topLeft.clone():g.bounds.topRight.clone(),1);f.visible=!1,f.pivot=new this.paper.Point(g.position.x,g.position.y),f.rotate(t),f.pivot=null,t>=0&&t<=90?"left"==i?r.x-=(f.position.x-e.children[0].bounds.left)*u:r.y+=(e.children[0].bounds.bottom-f.position.y)*u:t>90&&t<=180?"left"==i?r.y-=(f.position.y-e.children[0].bounds.top)*u:r.x-=(f.position.x-e.children[0].bounds.left)*u:t>=-90&&t<0?"left"==i?r.y+=(e.children[0].bounds.bottom-f.position.y)*u:r.x+=(e.children[0].bounds.right-f.position.x)*u:t>-180&&t<-90&&("left"==i?r.x+=(e.children[0].bounds.right-f.position.x)*u:r.y-=(f.position.y-e.children[0].bounds.top)*u),f.remove(),g.remove()}}e.position=r}},onTextAreaGuidesUpdated:function(e){var t=this.getSelectedItems()[0];t&&t.data&&t.data.isTextArea&&(this.updateSelectionState(),this.updateTextArea(t,null),t.data.isTextBox||(t.data.rect=this.findTextAreaGuide(t).bounds.clone()))},forceSelectedTextAreasToBounds:function(){for(var e=this.getSelectedTextAreaItems(),t=0;t<e.length;t++)this.forceTextAreaToBounds(e[t])},forceTextAreaToBounds:function(e){if(e&&e.data&&e.data.isTextArea&&e.data.rect&&!e.data.isTextBox){var t=e.bounds.clone();t.isEmpty()||(e.data.rect=t)}},createWrappedText:function(e,t,i,n){var a=this,r=this,o=!1,s=[],l=t.text,h=/[\u0590-\u05ff\u0600-\u06ff]/.test(l),d=null!=t.justification?t.justification:"justify";if(i){var c=this.createPointText(".",t);if(c.remove(),c.bounds.width>e.width+.001)return Logger.info("text area too small for even a single text char"),{limitsExceeded:o=!0,textItems:s}}var u=this.getLineHeight(t);if(u>e.height+.001)return Logger.info("text area too small for even a single text char"),{limitsExceeded:o=!0,textItems:s};var g=this.getSpaceWidth(t),f=this.getTextExtraSpace(t),p=null,m=[],v=[],I=[],y=e.width,C=e.x+e.width,M=e.y+e.height;i||(C=Number.MAX_VALUE),i||(M=Number.MAX_VALUE);var x=e.x,S=e.y+u,b=!1;(null==t?void 0:t.disableScaling)&&(t.scaling,t.scaling=new this.paper.Point(1,1),u=this.getLineHeight(t),g=this.getSpaceWidth(t),f=this.getTextExtraSpace(t));for(var w=function(e){if(null===e||0===e.length)return 0;if(e instanceof r.paper.PointText)return e.bounds.width;var t=e[0].bounds.x,i=e[e.length-1].bounds.right;return Math.abs(i-t)},A=function(e,i){if(e)if(r.isLetterSpacingSpecified(t)){if(e&&e.length>=0){var n=r.createPointText(i,t);n.justification="center";var a=function(e,i){if(!r.isLetterSpacingSpecified(t))return 0;var n=0,a=r.createPointText(i,t);a.justification="center",a.remove(),null!==e&&0!==e.length||(n=x+a.bounds.width/2);var o=e[e.length-1],s=r.createPointText(o.content+i,t);return s.remove(),n=o.point.x+(s.bounds.width-o.bounds.width/2-a.bounds.width/2),n+=f,n=Math.max(n,o.point.x)}(e,i);n.point=new r.paper.Point(a,S),e.push(n),s.push(n)}}else e.content+=i},P=function(e){if(e)if(r.isLetterSpacingSpecified(t)){if(e.length>0)for(var i=0;i<e.length;i++)e[i].remove(),s.pop()}else e.remove(),s.pop()},D=function(e){if(e&&e.length>0){var i=e[0],n=e[e.length-1],a=0,o=0;if(r.isLetterSpacingSpecified(t)){if(0==i.length)return 0;if(0==n.length)return 0;a=i[0].bounds.x,o=n[n.length-1].bounds.right}else a=i.bounds.x,o=n.bounds.right;return Math.abs(o-a)}return 0},k=function(){p=null,m=[],!0!==t.adaptText||!1!==t.wrapTextOnAdaptText?(x=e.x,(S+=u+r.getLineExtraSpace(t))>M&&(b=!0,o=!0)):o=!0},_=function(){m.push(p),1===m.length&&(v.push(m),1===v.length&&I.push(v))},T=function(e){var i=r.createPointText(e,t);r.isLetterSpacingSpecified(t)&&(i.justification="center");var n=i.bounds.width;if(x+n>C&&(m&&m.length>0?k():o=!0),b||o)i.remove();else{if(r.isLetterSpacingSpecified(t)?i.point=new r.paper.Point(x+i.bounds.width/2,S):i.point=new r.paper.Point(x,S),0==I.length&&i.bounds.bottom>S){var a=i.bounds.bottom-S;S-=a,M-=a,r.isLetterSpacingSpecified(t)?i.point=new r.paper.Point(x+i.bounds.width/2,S):i.point=new r.paper.Point(x,S)}p=r.isLetterSpacingSpecified(t)?[i]:i,s.push(i),_()}},z=function(e){if(A(p,e),x+w(p)>C+1e-4)if(1==m.length||t.adaptText)if(t.adaptText)m.pop(),P(p),o=!0;else{if(r.isLetterSpacingSpecified(t))p.pop().remove(),s.pop();else p.content=p.content.substring(0,p.content.length-1);k(),T(e)}else{var i=p;m.pop(),k(),p=i,b?P(p):(!function(e,i,n){if(e)if(r.isLetterSpacingSpecified(t)){if(e.length>0)for(var a=e[0].bounds.x-i,o=0;o<e.length;o++)e[o].point=new r.paper.Point(e[o].point.x-a,n)}else e.point=new r.paper.Point(i,n)}(p,x,S),_())}},O=function(e){p&&0!==p.length?z(e):T(e)},B=0;B<l.length&&!b&&!o;B++){var E=l[B];"\n"==E?(k(),v=[]):" "===E?(p&&(x+=w(p)),p=null,x+g<=C?x+=g+f:k()):O(E)}var R=void 0,F=void 0;for(B=0;B<I.length;B++)for(var L=I[B],G=0;G<L.length;G++){if(0!==(Z=L[G]).length){for(var U=0;U<Z.length;U++){var j=Z[U];j instanceof r.paper.PointText?(R=null==R?j.bounds.top:Math.min(R,j.bounds.top),F=null==F?j.bounds.bottom:Math.max(F,j.bounds.bottom)):j.length>0&&j.forEach(function(e){R=null==R?e.bounds.top:Math.min(R,e.bounds.top),F=null==F?e.bounds.bottom:Math.max(F,e.bounds.bottom)})}if("justify"!=d||G!=L.length-1){var N=D(Z);N>y&&(y=N),h&&this.invertLineRtlWords(Z,e.x,e.x+e.width,g,t),this.justifyLine(Z,e,e.x+N,d,t)}}}var W=null==R||null==F?0:e.height-Math.abs(F-R);if(i&&W>0&&("middle"==t.verticalAlignment||"bottom"==t.verticalAlignment)){"middle"==t.verticalAlignment&&(W/=2);for(B=0;B<I.length;B++)for(L=I[B],G=0;G<L.length;G++){var Z;if(0!==(Z=L[G]).length)for(U=0;U<Z.length;U++){var H=Z[U];H instanceof r.paper.PointText?H.point=new this.paper.Point(H.point.x,H.point.y+W):H.length>0&&H.forEach(function(e){e.point=new a.paper.Point(e.point.x,e.point.y+W)})}}}return i||(e.width=y),{limitsExceeded:o||b,textItems:s}},justifyLine:function(e,t,i,n,a){var r=this,o=function(e,t,i){if(e)if(e instanceof r.paper.PointText)e.point=new r.paper.Point(t,i);else if(e.length>0)for(var n=e[0].bounds.x-t,a=0;a<e.length;a++)e[a].point=new r.paper.Point(e[a].point.x-n,i)};if(e.length>0){var s=i-t.x,l=t.width-s;if("justify"==n){if(e.length>1)for(var h=l/(e.length-1),d=1;d<e.length;d++){if((c=e[d])instanceof r.paper.PointText)c.point=new this.paper.Point(c.point.x+h*d,c.point.y);else o(c,c[0].bounds.x+h*d,c[0].point.y)}}else if("right"==n)for(d=0;d<e.length;d++){if((c=e[d])instanceof r.paper.PointText)c.point=new this.paper.Point(c.point.x+l,c.point.y);else o(c,c[0].bounds.x+l,c[0].point.y)}else if("center"==n)for(d=0;d<e.length;d++){var c;if((c=e[d])instanceof r.paper.PointText)c.point=new this.paper.Point(c.point.x+l/2,c.point.y);else o(c,c[0].bounds.x+l/2,c[0].point.y)}}},invertLineRtlWords:function(e,t,i,n,a){var r=this,o=(n=this.getSpaceWidth(a),this.getTextExtraSpace(a)),s=function(e){if(null===e||0===e.length)return 0;if(e instanceof r.paper.PointText)return e.bounds.width;for(var t=[],i=0;i<e.length;i++)t[i]=e[i];t.sort(function(e,t){return e.point.x>t.point.x?1:t.point.x>e.point.x?-1:0});var n=t[0].bounds.x,a=t[t.length-1].bounds.right;return Math.abs(a-n)},l=function(e,t,i){if(e&&t)if(e instanceof r.paper.PointText)e.point=new r.paper.Point(i,e.point.y);else if(t&&t.length>0)for(var n=t[0].bounds.x-i,a=0;a<t.length;a++)t[a].point=new r.paper.Point(t[a].point.x-n,t[a].point.y)},h=function(e){var t="";if(!e||0==e.length)return t;if(e instanceof r.paper.PointText)return e.content;for(var i=0;i<e.length;i++)t+=e[i].content;return t},d=function(e){return/[\u0590-\u05ff\u0600-\u06ff]/.test(e)},c=function(e){return/[!,.:;?]/g.test(e)},u=function(e){var t=h(e),i=t,n="",a="";if(d(t)){for(var r=t.length-1;r>=0&&(a=t.substring(r),!d(a));r--)n=a,i=t.substring(0,r);i&&n&&(e.content=n+i)}else{for(r=t.length-1;r>=0&&(a=t[r],c(a));r--)n=t.substring(r),i=t.substring(0,r);i&&n&&(e.content=n+i)}return e},g=function(e){var t=h(e),i=-1;if(d(t)){for(var s=e.length-1;s>=0;s--)if(d(h(e.slice(s)))){i=s+1;break}}else for(s=e.length-1;s>=0;s--)if(!c(e[s].content)){i=s+1;break}var l=e.slice(0);if(i>=0){l=[];for(s=i;s<e.length;s++)l[s-i]=e[s];for(s=0;s<i&&s<e.length;s++)l[e.length-1-s]=e[s];var u=e[0].bounds.x,g=u,f=null,p=null;for(s=0;s<l.length;s++){if(f=l[s],0==s)g=u+f.bounds.width/2;else{p=l[s-1];var m=r.createPointText(p.content+f.content,a);m.remove(),g=p.point.x+(m.bounds.width-p.bounds.width/2-f.bounds.width/2),g+=n*o,g=Math.max(g,p.point.x)}f.point.x=g}}return l};if(e.length>1)for(var f=t,p=e.length-1;p>=0;p--){var m=e[p],v=m;v=!r.isLetterSpacingSpecified(a)&&m instanceof r.paper.PointText?u(m):g(m),p<e.length-1&&(f+=n+o),l(m,v,f),f+=s(v)}else 1==e.length&&(r.isLetterSpacingSpecified(a)?g(e[0]):u(e[0]))},getLineHeight:function(e){var t=this.createPointText("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",e);return t.remove(),t.bounds.height},getLineWidth:function(e,t){var i=this.createPointText(e,t);return i.remove(),i.bounds.width},getSpaceWidth:function(e){var t=this.createPointText(" ",e);return t.remove(),t.bounds.width},getFontAscent:function(e){var t=this.getShortcutFontProperty(e),i=this.fontAscentCache.hasOwnProperty(t)?this.fontAscentCache[t]:null,n=this.createPointText("M",e),a=n.bounds;n.remove();var r=Math.floor(a.width)+1,o=Math.floor(a.height)+1;if(!i){var s=$("<canvas>",{id:Math.floor(99999*Math.random()+1)}).attr({width:r,height:o})[0],l=s.getContext("2d");l.fillRect(0,0,s.width,s.height),l.textBaseline="top",l.fillStyle="white",l.font=t,l.fillText("M",0,0);for(var h=l.getImageData(0,0,s.width,s.height).data,d=-1,c=-1,u=0;u<s.height;u++)for(var g=0;g<s.width;g++){if(0!==h[4*(u*s.width+g)]){-1===d&&(d=u);break}if(g===s.width-1&&-1!==d){c=u,u=s.height;break}}i=c-d,this.fontAscentCache[t]=i}return i},getShortcutFontProperty:function(e){var t=e.fontSize+"px "+e.fontFamily;return e.fontStretch&&"normal"!=e.fontStretch&&(t=e.fontStretch+" "+t),e.fontWeight&&"normal"!=e.fontWeight&&(t=e.fontWeight+" "+t),e.fontStyle&&"normal"!=e.fontStyle&&(t=e.fontStyle+" "+t),t},getTextExtraSpace:function(e){return null!=e.letterSpacing?.75*e.letterSpacing:0},isLetterSpacingSpecified:function(e){return null!=e.letterSpacing&&0!=e.letterSpacing},getLineExtraSpace:function(e){return null!=e.lineSpacing?.75*e.lineSpacing:0},isLineSpacingSpecified:function(e){return null!=e.lineSpacing&&0!=e.lineSpacing},toggleSelectionTextOnPath:function(){for(var e=[],t=this.getSelectedTextItems(),i=0;i<t.length;i++){var n=this.toggleItemTextOnPath(t[i]);n&&e.push(n)}return e},convertSelectedTextItemsToTextOnPath:function(){return this.convertSelectionToTextOnPath()},convertSelectedTextOnPathItemsToText:function(){return this.convertSelectionToText()},convertSelectionToText:function(){for(var e=[],t=this.getSelectedTextItems(),i=0;i<t.length;i++){var n=this.convertToText(t[i]);n&&e.push(n)}return e},convertSelectionToTextOnPath:function(){for(var e=[],t=this.getSelectedTextItems(),i=0;i<t.length;i++){var n=this.convertToTextOnPath(t[i]);n&&(n.data.isTemplateElement=t[i].data&&t[i].data.isTemplateElement,e.push(n))}return e},convertSelectionToTextArea:function(){for(var e=[],t=this.getSelectedTextItems(),i=0;i<t.length;i++){var n=this.convertToTextArea(t[i]);n&&e.push(n)}return e},toggleItemTextOnPath:function(e){return e?e instanceof this.paper.TextItem||e&&e.data&&e.data.isTextArea?this.convertToTextOnPath(e):e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0?this.convertToTextArea(e):this.convertToText(e):null},convertToTextOnPath:function(e){return!this.canChangeItemTextPathMode(e)||e.data&&e.data.isTextOnPath?null:e&&e instanceof this.paper.TextItem?this.fromTextToTextOnPath(e):e&&e.data&&e.data.isTextArea&&e.data.rect?this.fromTextAreaToTextOnPath(e):void 0},convertToText:function(e){return!this.getItemIsTextArea(e)&&!this.canChangeItemTextPathMode(e)||this.getItemIsTextArea(e)&&!this.canChangeItemTextAreaMode(e)||e instanceof this.paper.TextItem?null:e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0?this.fromTextOnPathToText(e):e&&e.data&&e.data.isTextArea&&e.data.rect?this.fromTextAreaToText(e):void 0},convertToTextArea:function(e){return!this.canChangeItemTextAreaMode(e)||e.data&&e.data.isTextArea?null:e&&e instanceof this.paper.TextItem?this.fromTextToTextArea(e):e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0?this.fromTextOnPathToTextArea(e):void 0},fromTextToTextOnPath:function(e){if(!this.canChangeItemTextPathMode(e))return null;var t=null;if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid")),e.remove(),this.onItemRemoved(e);var r=null;e.shadowColor&&(r="string"==typeof e.shadowColor||e.shadowColor instanceof String?e.shadowColor:e.shadowColor.toCSS(!0));var o={};o.text=e.content,o.strokeColor=e.strokeColor,o.strokeWidth=e.strokeWidth,o.fillColor=e.fillColor,o.fontFamily=e.fontFamily,o.fontWeight=e.fontWeight,o.fontSize=e.fontSize,o.scaling=e.scaling,o.rotation=e.rotation,o.shadowColor=r,o.shadowBlur=e.shadowBlur,o.shadowDistance=this.getOffsetDistance(e.shadowOffset),o.shadowAngle=this.getOffsetAngle(e.shadowOffset),e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(o.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(o.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(o.shadowColor=e.data.originalShadowColor));var s=(t=this.addTextOnPathElement(e.position,o,!0)).position.clone();if(t.position.y=e.bounds.top+t.bounds.height/2,s.x=0-s.x+t.position.x,s.y=0-s.y+t.position.y,this.onTextOnPathMoved(t,s),this.updateTextOnPathGuide(t),n){var l=this.findDesignItemForItem(t);l&&l.setConstraintsFromSource(n)}this.onItemUpdated(t),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.updateItemSyncGuid(t,a)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(t),this.joinUndoChains(e,t),t},fromTextToTextArea:function(e){if(!this.canChangeItemTextAreaMode(e))return null;var t=null;if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid"));var r=e.bounds.clone();r.bottom=r.bottom,r.bottom+=5*r.height,e.remove(),this.onItemRemoved(e);var o=null;e.shadowColor&&(o="string"==typeof e.shadowColor||e.shadowColor instanceof String?e.shadowColor:e.shadowColor.toCSS(!0));var s=null;e.strokeColor&&(s="string"==typeof e.strokeColor||e.strokeColor instanceof String?e.strokeColor:e.strokeColor.toCSS(!0));var l={};if(l.text=e.content,l.strokeWidth=e.strokeWidth,l.strokeColor=s,l.fillColor="string"==typeof e.fillColor||e.fillColor instanceof String?e.fillColor:e.fillColor.toCSS(!0),l.fontFamily=e.fontFamily,l.fontWeight=e.fontWeight,l.fontSize=e.fontSize,l.scaling=e.scaling,l.rotation=e.rotation,l.justification=e.data&&e.data.justification?e.data.justification:void 0!==e.justification?e.justification:"justify",l.shadowColor=o,l.shadowBlur=e.shadowBlur,l.shadowDistance=this.getOffsetDistance(e.shadowOffset),l.shadowAngle=this.getOffsetAngle(e.shadowOffset),l.lineSpacing=e.lineSpacing,l.letterSpacing=e.letterSpacing,e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(l.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(l.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(l.shadowColor=e.data.originalShadowColor)),r.left=e.bounds.left,r.right=e.bounds.right,r.top=e.bounds.top,(t=this.addTextAreaElement(r,l,!0)).position.y=r.top+t.bounds.height/2,t.position.x=r.left+e.bounds.width/2,t.data.rect=t.bounds.clone(),t.data.originalMatrix=t.matrix.clone(),(null==t?void 0:t.children.length)>0){var h=t.children[0],d=h.matrix.a,c=h.matrix.b,u=h.matrix.c,g=h.matrix.d,f=t.bounds.centerX,p=t.bounds.centerY;t.data.originalMatrix=new this.paper.Matrix(d,c,u,g,f,p)}if(this.updateTextAreaGuide(t),n){var m=this.findDesignItemForItem(t);m&&m.setConstraintsFromSource(n)}this.onItemUpdated(t),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.updateItemSyncGuid(t,a)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(t),this.joinUndoChains(e,t),t},fromTextOnPathToText:function(e){if(!this.canChangeItemTextPathMode(e))return null;var t=null;if(this.beginDesignOperation(),e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid")),e.remove(),this.onItemRemoved(e);var r=e.data.text;if(!r)for(var o=0;o<e.children.length;o++)r+=e.children[o].content;var s=null,l=e.children[0].shadowColor;l&&(s="string"==typeof l||l instanceof String?l:l.toCSS(!0));var h={};h.text=r,h.strokeColor=e.children[0].strokeColor,h.strokeWidth=e.children[0].strokeWidth,h.fillColor=e.children[0].fillColor,h.fontFamily=e.children[0].fontFamily,h.fontWeight=e.children[0].fontWeight,h.fontStretch=e.children[0].fontStretch,h.fontSize=e.children[0].fontSize,h.scaling=e.children[0].scaling,h.shadowColor=s,h.shadowBlur=e.children[0].shadowBlur,h.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),h.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset),e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(h.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(h.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(h.shadowColor=e.data.originalShadowColor));var d=e.data.points[0],c=(e.data.points[1],e.data.points[2].subtract(d)),u=d.add(c.divide(2));if(h.rotation=c.angle,t=this.addTextElement(u,h,!0),n){var g=this.findDesignItemForItem(t);g&&(g.setConstraintsFromSource(n),this.updateSelectionState(),this.paper.project.view.update())}this.updateItemSyncGuid(t,a)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(t),this.joinUndoChains(e,t),t},fromTextOnPathToTextArea:function(e){var t;if(!this.canChangeItemTextAreaMode(e)||!this.canChangeItemTextPathMode(e))return null;var i=null;if(this.beginDesignOperation(),e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0){var n=this.findDesignItemForItem(e),a=null,r=null;n&&(a=n.get("constraints"),r=n.get("syncGuid"));var o=e.bounds.clone();o.bottom=o.bottom,o.bottom+=5*o.height,e.remove(),this.onItemRemoved(e);var s=e.data.text;if(!s)for(var l=0;l<e.children.length;l++)s+=e.children[l].content;var h=null,d=e.children[0].shadowColor;d&&(h="string"==typeof d||d instanceof String?d:d.toCSS(!0));var c={};c.text=s,c.strokeColor=e.children[0].strokeColor,c.strokeWidth=e.children[0].strokeWidth,c.fillColor=e.children[0].fillColor,c.fontFamily=e.children[0].fontFamily,c.fontWeight=e.children[0].fontWeight,c.fontStretch=e.children[0].fontStretch,c.fontSize=e.children[0].fontSize,c.scaling=e.children[0].scaling,c.justification=e.data&&e.data.justification?e.data.justification:"justify",c.shadowColor=h,c.shadowBlur=e.children[0].shadowBlur,c.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),c.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset);var u=null,g=null,f=!1,p=null;if(e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(c.strokeColor=e.data.originalStrokeColor,u=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(c.fillColor=e.data.originalFillColor,g=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(f=!0,c.shadowColor=e.data.originalShadowColor,p=e.data.originalShadowColor)),o.left=e.bounds.left,o.right=e.bounds.right,o.top=e.bounds.top,i=this.addTextAreaElement(o,c,!0),u&&(i.data.originalStrokeColor=u),g&&(i.data.originalFillColor=g),f&&(i.data.originalShadowColor=p),!(null===(t=null==i?void 0:i.data)||void 0===t?void 0:t.originalMatrix)&&(null==i?void 0:i.children)&&(null==i?void 0:i.children.length)>0){var m=i.children[0],v=m.matrix.a,I=m.matrix.b,y=m.matrix.c,C=m.matrix.d,M=i.bounds.centerX,x=i.bounds.centerY;i.data.originalMatrix=new this.paper.Matrix(v,I,y,C,M,x)}if(i.position.y=o.top+i.bounds.height/2,i.position.x=o.left+e.bounds.width/2,i.data.rect=i.bounds.clone(),i.data.isTemplateElement=e.data&&e.data.isTemplateElement,this.updateTextAreaGuide(i),a){var S=this.findDesignItemForItem(i);S&&S.setConstraintsFromSource(a)}this.onItemUpdated(i),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.updateItemSyncGuid(i,r)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(i),this.joinUndoChains(e,i),i},fromTextAreaToText:function(e){if(!this.canChangeItemTextAreaMode(e))return null;var t=null;if(this.beginDesignOperation(),e&&e.data&&e.data.isTextArea&&e.data.rect){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid")),e.remove(),this.onItemRemoved(e);var r=e.data.text;if(!r)for(var o=0;o<e.children.length;o++)o>0&&(r+=" "),r+=e.children[o].content;var s=null,l=e.children[0].shadowColor;l&&(s="string"==typeof l||l instanceof String?l:l.toCSS(!0));var h={};h.text=r,h.strokeColor=e.children[0].strokeColor,h.strokeWidth=e.children[0].strokeWidth,h.fillColor=e.children[0].fillColor,h.fontFamily=e.children[0].fontFamily,h.fontWeight=e.children[0].fontWeight,h.fontStretch=e.children[0].fontStretch,h.fontSize=e.children[0].fontSize,h.scaling=e.children[0].scaling,h.shadowColor=s,h.shadowBlur=e.children[0].shadowBlur,h.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),h.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset);var d=null,c=null,u=!1,g=null;e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(h.strokeColor=e.data.originalStrokeColor,d=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(h.fillColor=e.data.originalFillColor,c=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(u=!0,h.shadowColor=e.data.originalShadowColor,g=e.data.originalShadowColor));var f=e.children[0].point;if(t=this.addTextElement(f,h,!0),d&&(t.data.strokeColor=d),c&&(t.data.fillColor=c),u&&(t.data.originalShadowColor=g),n){var p=this.findDesignItemForItem(t);p&&(p.setConstraintsFromSource(n),this.updateSelectionState(),this.paper.project.view.update())}this.updateItemSyncGuid(t,a)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(t),this.joinUndoChains(e,t),t},fromTextAreaToTextOnPath:function(e){var t,i;if(!this.canChangeItemTextPathMode(e)||!this.canChangeItemTextAreaMode(e))return null;var n=null;if(this.beginDesignOperation(),e&&e.data&&e.data.isTextArea&&e.data.rect){var a=this.findDesignItemForItem(e),r=null,o=null;a&&(r=a.get("constraints"),o=a.get("syncGuid")),e.remove(),this.onItemRemoved(e);var s=e.data.text;if(!s)for(var l=0;l<e.children.length;l++)l>0&&(s+=" "),s+=e.children[l].content;var h=null,d=e.children[0].shadowColor;d&&(h="string"==typeof d||d instanceof String?d:d.toCSS(!0));var c={};c.text=s,c.strokeColor=null!==(i=null===(t=e.children[0].strokeColor)||void 0===t?void 0:t.toCSS(!0))&&void 0!==i?i:null,c.strokeWidth=e.children[0].strokeWidth,c.fillColor=e.children[0].fillColor.toCSS(!0),c.fontFamily=e.children[0].fontFamily,c.fontWeight=e.children[0].fontWeight,c.fontStretch=e.children[0].fontStretch,c.fontSize=e.children[0].fontSize,c.scaling=e.children[0].scaling,c.shadowColor=h,c.shadowBlur=e.children[0].shadowBlur,c.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),c.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset);var u=null,g=null,f=!1,p=null;e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(c.strokeColor=e.data.originalStrokeColor,u=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(c.fillColor=e.data.originalFillColor,g=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(f=!0,c.shadowColor=e.data.originalShadowColor,p=e.data.originalShadowColor));var m=this.getItemRealBounds(e),v=new this.paper.Point(m.x+m.width/2,e.children[0].point.y);n=this.addTextOnPathElement(v,c,!0),u&&(n.data.originalStrokeColor=u),g&&(n.data.originalFillColor=g),f&&(n.data.originalShadowColor=p),e.data&&e.data.justification&&(n.data.justification=e.data.justification);var I=n.position.clone();if(n.position.y=e.bounds.top+n.bounds.height/2,I.x=0-I.x+n.position.x,I.y=0-I.y+n.position.y,this.onTextOnPathMoved(n,I),this.updateTextOnPathGuide(n),r){var y=this.findDesignItemForItem(n);y&&y.setConstraintsFromSource(r)}this.onItemUpdated(n),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.updateItemSyncGuid(n,o)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(n),this.joinUndoChains(e,n),n},removeSideBackColor:function(){if(this.side&&this.design){var e=this.design.getDesignSide(this.side);e&&this.design.get("sides").remove(e);var t=this;this.updateImageItem(function(){t.isViewer||t.updateAreaItemsColor(),t.updateSelectionState()})}},setSideBackColor:function(e){if(this.side&&this.design){var t=this.design.getDesignSide(this.side);t||((t=new MPlaza.DesignSide).set("modelID",this.design.get("modelID")),t.set("colorID",this.side.getColorID()),t.set("sideID",this.side.getSideID()),this.design.get("sides").add(t)),t.set("fillColor",e);var i=this;this.updateImageItem(function(){i.isViewer||i.updateAreaItemsColor(),i.updateSelectionState()})}},adjustInputFontWeightByConstraints:function(e,t,i){var n=t||e;if(i&&(!i.get("canChangeFontWeight")||!i.get("canChangeFontItalic"))){if("number"==typeof e)return e;n=n+="";var a=e&&-1!=e.indexOf("bold"),r=e&&-1!=e.indexOf("italic"),o=i.get("canChangeFontWeight")?-1!=n.indexOf("bold"):a,s=i.get("canChangeFontItalic")?-1!=n.indexOf("italic"):r,l=[];l.push(s?"italic":"normal"),l.push(o?"bold":"normal"),n=l.join(" ")}return n},adjustInputTextByConstraints:function(e,t){var i=t;if(e&&null!=t&&null!=t){var n=this.getItemConstraints(e);if(n&&n.get("canEdit")&&(n.get("keepNrChars")||n.get("minNrChars")>0||n.get("maxNrChars")>0)){var a="";if(e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0){if(!(a=e.data.text))for(var r=0;r<e.children.length;r++)a+=e.children[r].content}else e instanceof this.paper.TextItem?a=e.content:e.data&&e.data.isTextArt&&(a=this.getTextArtItemText(e));var o=a.length,s=n.get("minNrChars"),l=n.get("maxNrChars");if(n.get("keepNrChars")&&(s=o,l=o),s>0&&t.length<s){var h=n.get("paddingString");n.get("paddingTypeID")==MPlaza.PaddingType.Start?i=t.padStart(s,h):n.get("paddingTypeID")==MPlaza.PaddingType.End?i=t.padEnd(s,h):n.get("paddingTypeID")==MPlaza.PaddingType.StartEnd&&(i=t.padStartEnd(s,h))}l>0&&i.length>l&&(i=i.substring(0,l)),0==i.trim().length&&0==n.get("canDelete")&&(i=this.isConfigurator?"⠀":a.substring(0,1))}}return this.isConfigurator&&""==i.trim()&&(i="⠀"),i},adjustInputLetterSpacingByConstraints:function(e,t){var i=t;if(e){var n=null!=e.data.letterSpacing?e.data.letterSpacing:0;null==i&&(i=n);var a=this.getItemConstraints(e);a&&(a.get("canEdit")&&a.get("canChangeLetterSpacing")&&"number"==typeof t?(null!=a.get("minLetterSpacing")&&null!=a.get("minLetterSpacing")&&(i=Math.max(i,a.get("minLetterSpacing"))),null!=a.get("maxLetterSpacing")&&null!=a.get("maxLetterSpacing")&&(i=Math.min(i,a.get("maxLetterSpacing")))):i=n)}return i},adjustInputLineSpacingByConstraints:function(e,t){var i=t;if(e){var n=null!=e.data.lineSpacing?e.data.lineSpacing:0;null==i&&(i=n);var a=this.getItemConstraints(e);a&&(a.get("canEdit")&&a.get("canChangeLineSpacing")&&"number"==typeof t?(null!=a.get("minLineSpacing")&&null!=a.get("minLineSpacing")&&(i=Math.max(i,a.get("minLineSpacing"))),null!=a.get("maxLineSpacing")&&null!=a.get("maxLineSpacing")&&(i=Math.min(i,a.get("maxLineSpacing")))):i=n)}return i},highlightsCanvasItemFromDesignItems:function(e){var t=this;e.forEach(function(e){var i=t.findItemByGuid(e.get("itemGuid"));i&&t.createMaskAlertForItem(i)})},setInvalidItemsForProfanityCheck:function(e){this.preventAreasAndIndexUpdate=!0;var t=this;e.forEach(function(e){var i=t.getPaperItemFromDesignItem(e);i&&(i.data.isProfanityCheckInvalid=!0,t.onItemUpdated(i),i.remove())}),this.preventAreasAndIndexUpdate=!1},replaceProfanityTextFromItem:function(e,t){this.preventAreasAndIndexUpdate=!0;var i=this.paper.importJSON(e.get("json"));if(i){var n="",a=null;if(this.getItemIsTextArea(i)||this.getItemIsTextOnPath(i)?(a=this.getTextItemInfo(i),n=a.text):this.getItemIsTextArt(i)&&(a=this.getTextArtItemInfo(i),n=a.text),t.profanityList){var r=0;t.profanityList.forEach(function(e){(n=n.replace(e,e.replace(/./g,"x")))!==i.data.text&&r++}),0===r&&(n=n.replace(/./g,"x"))}this.getItemIsTextArea(i)||this.getItemIsTextOnPath(i)?this.modifyTextElementsContent(i,n):this.getItemIsTextArt(i),this.onItemUpdated(i)}this.preventAreasAndIndexUpdate=!1},undoRedoSupported:function(){return 0==this.getAllGridItems().length},beginDesignOperation:function(){this.undoRedoSupported()&&(this.currentDesignOperation&&this.currentDesignOperation.itemOperations.length>0&&this.undoStack.push(this.currentDesignOperation),this.currentDesignOperation={operationId:MPlaza.generateUUID(),itemOperations:[]})},endDesignOperation:function(){this.undoRedoSupported()&&this.currentDesignOperation&&this.currentDesignOperation.itemOperations.length>0&&(this.undoStack.push(this.currentDesignOperation),this.resetRedo(),this.currentDesignOperation=null)},registerItemOperation:function(e,t,i,n){if(this.undoRedoSupported()&&!this.executingUndoRedo){if(i&&n){var a=!1;i.get("colors").length!=n.get("colors").length&&(a=!0),n.get("colors").each(function(e,t){var n=i.get("colors").find(function(t){return t.get("colorID")==e.get("colorID")});n?n.get("colorCode")!=e.get("colorCode")&&(a=!0):a=!0});var r=i.get("index")!=n.get("index");if(i.get("json")==n.get("json")&&!a&&!r)return}var o={itemGuid:t,type:e,oldDesignItem:i,newDesignItem:n},s=!1;this.currentDesignOperation||(this.beginDesignOperation(),s=!0),this.updateDesignOperation(this.currentDesignOperation,o),s&&this.endDesignOperation()}},registerRotationOperation:function(e,t){var i=!1;this.currentDesignOperation||(this.beginDesignOperation(),i=!0);var n={type:e,degrees:t};this.updateDesignOperation(this.currentDesignOperation,n),i&&this.endDesignOperation()},updateDesignOperation:function(e,t){for(var i=null,n=-1,a=0;a<e.itemOperations.length;a++){var r=e.itemOperations[a];if(r.itemGuid==t.itemGuid){n=a,i=r;break}}if(i&&n>=0){var o=this.mergeItemOperations(i,t);e.itemOperations[n]=o||t}else e.itemOperations.push(t)},mergeItemOperations:function(e,t){var i=null;return"create"===e.type?"update"===t.type&&(i={type:"create",itemGuid:e.itemGuid,oldDesignItem:null,newDesignItem:t.newDesignItem}):"update"===e.type&&"update"===t.type&&(i={type:"update",itemGuid:e.itemGuid,oldDesignItem:e.oldDesignItem,newDesignItem:t.newDesignItem}),i},undo:function(){return __awaiter(this,void 0,void 0,function(){var e,t,i;return __generator(this,function(n){switch(n.label){case 0:if(this.executiongUndoRedo)return[2];if(!(this.undoStack.count()>0))return[3,7];this.executingUndoRedo=!0,n.label=1;case 1:n.trys.push([1,,6,7]),e=this.undoStack.pop(),t=0,n.label=2;case 2:return t<e.itemOperations.length?(i=e.itemOperations[t],[4,this.undoItemOperation(i)]):[3,5];case 3:n.sent(),n.label=4;case 4:return t++,[3,2];case 5:return this.redoStack.push(e),[3,7];case 6:return this.executingUndoRedo=!1,[7];case 7:return[2]}})})},redo:function(){return __awaiter(this,void 0,void 0,function(){var e,t,i;return __generator(this,function(n){switch(n.label){case 0:if(this.executiongUndoRedo)return[2];if(!(this.redoStack.count()>0))return[3,7];this.executingUndoRedo=!0,n.label=1;case 1:n.trys.push([1,,6,7]),e=this.redoStack.pop(),t=0,n.label=2;case 2:return t<e.itemOperations.length?(i=e.itemOperations[t],[4,this.redoItemOperation(i)]):[3,5];case 3:n.sent(),n.label=4;case 4:return t++,[3,2];case 5:return this.undoStack.push(e),[3,7];case 6:return this.executingUndoRedo=!1,[7];case 7:return[2]}})})},undoItemOperation:function(e){return __awaiter(this,void 0,void 0,function(){var t,i,n,a;return __generator(this,function(r){switch(r.label){case 0:return this.getSelectedItems().map(function(e){return e.data.guid}),t=null,"create"!=e.type?[3,1]:((i=this.findItemByGuid(e.itemGuid))&&(i.remove(),this._onItemRemovedInternal(i)),[3,7]);case 1:return"update"!==e.type?[3,4]:(n=this.findDesignItemByGuid(e.itemGuid))?(n.resetColors(),n.copyAttributes(e.oldDesignItem),[4,this.createItemForDesignItem(n)]):[3,3];case 2:t=r.sent(),r.label=3;case 3:return[3,7];case 4:return"delete"!==e.type?[3,6]:(a=e.oldDesignItem.clone(),this.design.get("designItems").add(a),[4,this.createItemForDesignItem(a)]);case 5:return t=r.sent(),[3,7];case 6:"rotation"===e.type&&this.eventsToolsCustomizer.undoRotation(e.degrees),r.label=7;case 7:return this.updateItemsIndexes(),t&&this.isItemSelected(t)&&this.selectItems([t]),this.paper.project.view.update(),[2]}})})},redoItemOperation:function(e){return __awaiter(this,void 0,void 0,function(){var t,i,n,a;return __generator(this,function(r){switch(r.label){case 0:return t=null,"create"!=e.type?[3,2]:(i=e.newDesignItem.clone(),this.design.get("designItems").add(i),[4,this.createItemForDesignItem(i)]);case 1:return t=r.sent(),[3,6];case 2:return"update"!==e.type?[3,5]:(n=this.findDesignItemByGuid(e.itemGuid))?(n.resetColors(),n.copyAttributes(e.newDesignItem),[4,this.createItemForDesignItem(n)]):[3,4];case 3:t=r.sent(),r.label=4;case 4:return[3,6];case 5:"delete"===e.type?(a=this.findItemByGuid(e.itemGuid))&&(a.remove(),this._onItemRemovedInternal(a)):"rotation"===e.type&&this.eventsToolsCustomizer.redoRotation(e.degrees),r.label=6;case 6:return this.updateItemsIndexes(),t&&this.isItemSelected(t)&&this.selectItems([t]),this.paper.project.view.update(),[2]}})})},hasUndo:function(){return this.undoRedoSupported()&&this.undoStack.count()>0},hasRedo:function(){return this.undoRedoSupported()&&this.redoStack.count()>0},resetUndoRedo:function(){this.isConfigurator||this.isViewer||(this.detachUndoRedoEvents(),this.undoStack.clear(),this.redoStack.clear(),this.attachUndoRedoEvents(),this.fireUndoChangedEvent(),this.fireRedoChangedEvent())},resetUndo:function(){this.detachUndoRedoEvents(),this.undoStack.clear(),this.attachUndoRedoEvents(),this.fireUndoChangedEvent()},resetRedo:function(){this.detachUndoRedoEvents(),this.redoStack.clear(),this.attachUndoRedoEvents(),this.fireRedoChangedEvent()},removeLastUndoItemOperation:function(){if(this.undoStack.count()>0)return this.undoStack.pop()},removeFirstRedoItemOperation:function(){if(this.redoStack.count()>0)return this.redoStack.pop()},setupUndoRedoStacks:function(){this.attachUndoRedoEvents()},attachUndoRedoEvents:function(){this.undoStack.addChangedEventListener(this.bindedUndoStackChanged),this.redoStack.addChangedEventListener(this.bindedRedoStackChanged)},detachUndoRedoEvents:function(){this.undoStack.removeChangedEventListener(this.bindedUndoStackChanged),this.redoStack.removeChangedEventListener(this.bindedRedoStackChanged)},onUndoStackChanged:function(){this.fireUndoChangedEvent()},onRedoStackChanged:function(){this.fireRedoChangedEvent()},getUndoCount:function(){return this.undoStack.count()},getRedoCount:function(){return this.redoStack.count()},clearUndoForItem:function(e){this.clearOperationsStackForItem(this.undoStack,e)},clearRedoForItem:function(e){this.clearOperationsStackForItem(this.redoStack,e)},clearOperationsStackForItem:function(e,t){if(e&&t){for(var i=e.getAllData(),n=[],a=0;a<i.length;a++){for(var r=i[a],o=0;o<r.itemOperations.length;o++){r.itemOperations[o].itemGuid===t.data.guid&&r.itemOperations.splice(o--,1)}0==r.itemOperations.length&&n.push(r)}n.length>0&&e.removeDataArray(n)}},mergeAllUndoItemsOperations:function(e){if(e){for(var t=function(e,t){for(var i=0;i<e.itemOperations.length;i++)if(e.itemOperations[i].itemGuid==t.data.guid)return e.itemOperations[i];return null},i=function(e,t){for(var i=0;i<e.itemOperations.length;i++)e.itemOperations[i].itemGuid===t.data.guid&&e.itemOperations.splice(i--,1)},n=this.undoStack.getAllData(),a=[],r=null,o=null,s=n.length-1;s>=0;s--){var l=n[s],h=t(l,e);h&&(r&&o&&(this.updateDesignOperation(l,o),i(r,e),0==r.itemOperations.length&&a.push(r)),r=l,o=h)}a.length>0&&this.undoStack.removeDataArray(a)}},joinUndoChains:function(e,t){for(var i=function(e,t){for(var i=0;i<e.itemOperations.length;i++)if(e.itemOperations[i].itemGuid===t.data.guid)return!0;return!1},n=this.undoStack.getAllData(),a=null,r=null,o=0;o<n.length;o++){var s=n[o];i(s,e)&&(a=s),i(s,t)&&!r&&(r=s)}if(a&&r&&a!==r){var l=function(e,t){for(var i=0;i<e.itemOperations.length;i++)if(e.itemOperations[i].itemGuid==t.data.guid)return e.itemOperations[i];return null}(r,t);this.updateDesignOperation(a,l),function(e,t){for(var i=0;i<e.itemOperations.length;i++)e.itemOperations[i].itemGuid===t.data.guid&&e.itemOperations.splice(i--,1)}(r,t),0==r.itemOperations.length&&this.undoStack.removeData(r)}},getLastUndoOperationId:function(){var e=this.undoStack.getLastData();return e?e.operationId:null},mergeAllUndoOperationsAfterId:function(e){var t=null;if(e){var i=this.undoStack.getLastData(function(t){return t.operationId===e});t=this.undoStack.getAllDataAfter(i)}else t=this.undoStack.getAllData();t&&this.mergeUndoDesignOperations(t)},mergeUndoDesignOperations:function(e){var t=[];if(e.length>1)for(var i=e[0],n=1;n<e.length;n++){for(var a=e[n],r=0;r<a.itemOperations.length;r++){var o=a.itemOperations[r];this.updateDesignOperation(i,o),a.itemOperations.splice(r--,1)}t.push(a)}t.length>0&&this.undoStack.removeDataArray(t)},getUsedColorsWithCount:function(){var e=new Map;if(this.ignoreUsedColorsOnColorCheck)return e;for(var t=this.usedColorsItemsToCheck||this.getAllItems(),i=0;i<t.length;i++){var n=t[i],a=this.findDesignItemForItem(n);if(!a||!a.get("constraints")||0!=a.get("constraints").get("isPrintable")){var r;if(a&&a.get("colorMappings")&&a.get("colorMappings").length>0)a.get("colorMappings").toJSON().filter(function(e){return Boolean(e.dest)}).reduce(function(e,t){return e.add(t.dest)},new Set).forEach(function(t){return e.set(t,e.has(t)?e.get(t)+1:1)});if(this.getItemIsTextElement(n))(r=this.getTextItemInfo(n)).strokeColor&&r.strokeWidth>0&&e.set(r.strokeColor,e.has(r.strokeColor)?e.get(r.strokeColor)+1:1),r.fillColor&&e.set(r.fillColor,e.has(r.fillColor)?e.get(r.fillColor)+1:1),r.shadowColor&&e.set(r.shadowColor,e.has(r.shadowColor)?e.get(r.shadowColor)+1:1);if(this.getItemIsTextArt(n))(r=this.getTextArtItemInfo(n)).style.strokeColor&&r.style.strokeWidth>0&&e.set(r.style.strokeColor,e.has(r.style.strokeColor)?e.get(r.style.strokeColor)+1:1),r.style.fillColor&&e.set(r.style.fillColor,e.has(r.style.fillColor)?e.get(r.style.fillColor)+1:1),r.style.shadowColor&&e.set(r.style.shadowColor,e.has(r.style.shadowColor)?e.get(r.style.shadowColor)+1:1);if(this.isShape(n)||this.isMaskedImage(n)){var o=this.getShapeItemStyle(n);o&&(o.strokeColor&&o.strokeWidth>0&&e.set(o.strokeColor,e.has(o.strokeColor)?e.get(o.strokeColor)+1:1),o.fillColor&&e.set(o.fillColor,e.has(o.fillColor)?e.get(o.fillColor)+1:1))}if(n.data.isGroupForBackground){var s=n.children.find(function(e){return e.data.isAreaForBackground});if(s){if(s.strokeColor&&s.strokeWidth>0){var l=s.strokeColor instanceof paper.Color?s.strokeColor.toCSS(!0):s.strokeColor;e.set(l,e.has(l)?e.get(l)+1:1)}if(s.fillColor){l=s.fillColor instanceof paper.Color?s.fillColor.toCSS(!0):s.fillColor;e.set(l,e.has(l)?e.get(l)+1:1)}}}a&&a.get("colors").length>0&&(!a.get("colorMappings")||0==a.get("colorMappings").length)&&a.get("colors").forEach(function(t){var i=t.get("colorCode");e.set(i,e.has(i)?e.get(i)+1:1)})}}return e},getUsedColors:function(){return Array.from(this.getUsedColorsWithCount().keys())},_getPrintTypeColorLimits:function(e,t){void 0===t&&(t=null);var i={maxColors:void 0,palette:[]};if(!this.design||!this.side&&!t)return i;var n=null;if(t)n=this.design.getSelectedPrintTypeForArea(t.get("areas").at(0));else{var a=this.findDesignItemForItem(e),r=null;if(a&&a instanceof MPlaza.DesignItem&&a.get("areas").length>0){var o=a.get("areas").at(0);r=this.side.findAreaByID(o.get("areaID"))}else r=this.side.get("areas").getMaxArea();n=this.design.getSelectedPrintTypeForArea(r)}var s=this.getModelPrintType(n);if(!s)return i;var l=s.get("paletteColors"),h=void 0;return null!=s.get("maxColors")&&null!=s.get("maxColors")&&s.get("maxColors")>0&&(h=s.get("maxColors")),l&&l.length>0&&(h=h?Math.min(h,l.length):l.length),h?(i.maxColors=h,i.palette=l||[],i):i},getSelectableColors:function(e,t){if(void 0===t&&(t=null),this.design&&(this.side||t)){var i=this._getPrintTypeColorLimits(e,t);if(void 0!==i.maxColors&&null!==i.maxColor){var n=i.maxColors,a=i.palette,r=this.getUsedColors();return r.length<n?a.length>0?a:void 0:r}}},getImageDefaultColorMappings:function(e,t,i,n){return void 0===n&&(n=null),__awaiter(this,void 0,void 0,function(){var a,r,o,s,l,h,d;return __generator(this,function(c){switch(c.label){case 0:return this.design&&(this.side||n)?(a=this._getPrintTypeColorLimits(t,n),r=a.maxColors,o=a.palette,null==r||null==r?[2,[]]:(s=this.getUsedColors(),i?[3,2]:[4,Zakeke.Customizer.ImageProcessor.getImagePalette(e,10)])):[2,[]];case 1:i=c.sent(),c.label=2;case 2:for(l=[],h=function(){var e=i[d],t=e;s.find(function(t){return t===e})||(s.length<r?(o.length>0&&(t=Zakeke.Customizer.ImageProcessor.remapColor(e,o)),s.find(function(e){return e===t})||s.push(t)):t=Zakeke.Customizer.ImageProcessor.remapColor(e,s)),l.push({src:e,dest:t})},d=0;d<i.length;d++)h();return[2,l]}})})},_getColorMappingSourcePalette:function(e){return e.map(function(e){return e.src}).join(",")},_getColorMappingDestPalette:function(e){return e.map(function(e){return e.dest}).join(",")},createDesignEffectForRecoloring:function(e){var t=new MPlaza.DesignEffect;t.set("blendMode","normal"),t.set("opacity",1),t.set("imageEffectTypeName","reduce colors");var i=new MPlaza.ImageEffectParameterValue;return i.set("name","palette"),i.set("value",this._getColorMappingSourcePalette(e)),t.get("imageEffectParameterValues").add(i),(i=new MPlaza.ImageEffectParameterValue).set("name","replacementPalette"),i.set("value",this._getColorMappingDestPalette(e)),t.get("imageEffectParameterValues").add(i),t},recolorImage:function(e,t){return __awaiter(this,void 0,void 0,function(){var i;return __generator(this,function(n){switch(n.label){case 0:return i=this.createDesignEffectForRecoloring(t),[4,this.applyDesignEffectToImageUrl(i,e)];case 1:return[2,n.sent()]}})})},changeColorMapping:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h;return __generator(this,function(d){switch(d.label){case 0:i=this.getLastUndoOperationId(),this.beginDesignOperation(),n=this.getAllItems(),this.usedColorsItemsToCheck=[],a=0,d.label=1;case 1:return a<n.length?(r=n[a],this.getItemIsTextArt(r)&&((o=this.getTextArtItemInfo(r)).style.strokeColor==e&&(o.style.strokeColor=t),o.style.fillColor==e&&(o.style.fillColor=t),o.style.shadowColor==e&&(o.style.shadowColor=t),this.changeTextArtStyle(r,o.style),this.onItemUpdated(r)),this.getItemIsTextOnPath(r)&&((o=this.getTextItemInfo(r)).strokeColor==e&&(o.strokeColor=t),o.fillColor==e&&(o.fillColor=t),o.shadowColor==e&&(o.shadowColor=t),this.modifyTextOnPathInfo(r,{strokeColor:o.strokeColor,fillColor:o.fillColor,shadowColor:o.shadowColor}),this.onItemUpdated(r)),this.getItemIsTextArea(r)&&((o=this.getTextItemInfo(r)).strokeColor==e&&(o.strokeColor=t),o.fillColor==e&&(o.fillColor=t),o.shadowColor==e&&(o.shadowColor=t),this.modifyTextAreaInfo(r,{strokeColor:o.strokeColor,fillColor:o.fillColor,shadowColor:o.shadowColor}),this.onItemUpdated(r)),r instanceof this.paper.Raster||this.isMaskedImage(r)?[4,this.changeImageItemColorMapping(r,null,e,t)]:[3,3]):[3,5];case 2:d.sent(),d.label=3;case 3:(this.isShape(r)||this.isMaskedImage(r))&&(s=this.isShape(r)?r:this.getMaskedImageShapeItem(r),(l=this.getShapeItemStyle(s)).strokeColor==e&&(l.strokeColor=t),l.fillColor==e&&(l.fillColor=t),this.changeShapeStyle(r,l),this.onItemUpdated(r)),r.data.isGroupForBackground&&(h=r.children.find(function(e){return e.data.isAreaForBackground}))&&((h.strokeColor instanceof paper.Color?h.strokeColor.toCSS(!0):h.strokeColor)==e&&(h.strokeColor=t),(h.fillColor instanceof paper.Color?h.fillColor.toCSS(!0):h.fillColor)==e&&(h.fillColor=t),this.onItemUpdated(h)),this.usedColorsItemsToCheck.push(r),d.label=4;case 4:return a++,[3,1];case 5:return this.usedColorsItemsToCheck=null,this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(i),[2]}})})},changeImageItemColorMapping:function(e,t,i,n){var a,r;return __awaiter(this,void 0,void 0,function(){var o,s,l,h,d,c,u,g,f,p,m,v,I,y,C;return __generator(this,function(M){switch(M.label){case 0:return e?(o=this.getImageItemInfo(e),s=this.findDesignItemByGuid(e.data.guid),l=this.getMaskedImageRasterItem(e),h=!1,o&&s&&l?(this.beginDesignOperation(),d=o.url,c=this.getDesignEffectForDesignItem(s),d,[4,this.applyDesignEffectToImageUrl(c,d)]):[3,4]):[3,4];case 1:for(d=M.sent(),u=null!==(r=null===(a=s.get("colorMappings"))||void 0===a?void 0:a.toJSON())&&void 0!==r?r:[],g=0,f=u;g<f.length;g++)p=f[g],m=t&&p.src==t&&p.dest!=n,v=i&&p.dest==i,(m||v)&&(p.dest=n,h=!0);return h?(I=this.createDesignEffectForRecoloring(u),[4,this.applyDesignEffectToImageUrl(I,d)]):[2,e];case 2:return d=M.sent(),[4,this.changeRasterItem(l,d)];case 3:M.sent(),this.applyDesignEffectToItem(c,e),this.updateDesignItemColorMappings(s,u),this.endDesignOperation(),y=this.createDummyImageFromDesignItem(s),C=this.createDummyShapeFromDesignItem(s),this.onImageItemUpdated(e,y,C),this.updateSelectionState(),this.paper.project.view.update(),M.label=4;case 4:return[2,e]}})})},forceColorInFixedPalette:function(e,t,i,n){if(void 0===n&&(n=null),!t)return t;i||(i=t),t instanceof this.paper.Color&&(t=t.toCSS(!0)),i instanceof this.paper.Color&&(i=t instanceof this.paper.Color?t.toCSS(!0):t);var a=t,r=this.getSelectableColors(e,n),o=this.getUsedColorsWithCount(),s=!r||o.has(i)&&o.get(i)<=1&&-1!==r.indexOf(i);return r&&r.length>0&&!s&&(r.find(function(e){return e===t})||(a=Zakeke.Customizer.ImageProcessor.remapColor(t,r))),a},resetRecoloring:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l;return __generator(this,function(h){switch(h.label){case 0:i=this.getLastUndoOperationId(),this.beginDesignOperation(),this.usedColorsItemsToCheck=[],n=0,h.label=1;case 1:return n<e.length?(a=e[n],this.getItemIsTextArt(a)&&((r=this.getTextArtItemInfo(a)).style.strokeColor&&(r.style.strokeColor=this.forceColorInFixedPalette(a,r.style.strokeColor,null,t)),r.style.fillColor&&(r.style.fillColor=this.forceColorInFixedPalette(a,r.style.fillColor,null,t)),r.style.shadowColor&&(r.style.shadowColor=this.forceColorInFixedPalette(a,r.style.shadowColor,null,t)),this.changeTextArtStyle(a,r.style,t)),this.getItemIsTextOnPath(a)&&((r=this.getTextItemInfo(a)).strokeColor&&(r.strokeColor=this.forceColorInFixedPalette(a,r.strokeColor,null,t)),r.fillColor&&(r.fillColor=this.forceColorInFixedPalette(a,r.fillColor,null,t)),r.shadowColor&&(r.shadowColor=this.forceColorInFixedPalette(a,r.shadowColor,null,t)),this.modifyTextOnPathInfo(a,{strokeColor:r.strokeColor,fillColor:r.fillColor,shadowColor:r.shadowColor},t)),this.getItemIsTextArea(a)&&((r=this.getTextItemInfo(a)).strokeColor&&(r.strokeColor=this.forceColorInFixedPalette(a,r.strokeColor,null,t)),r.fillColor&&(r.fillColor=this.forceColorInFixedPalette(a,r.fillColor,null,t)),r.shadowColor&&(r.shadowColor=this.forceColorInFixedPalette(a,r.shadowColor,null,t)),this.modifyTextAreaInfo(a,{strokeColor:r.strokeColor,fillColor:r.fillColor,shadowColor:r.shadowColor},t)),a instanceof this.paper.Raster||this.isMaskedImage(a)?[4,this.resetImageColorMapping(a,t,null)]:[3,3]):[3,5];case 2:h.sent(),h.label=3;case 3:(this.isShape(a)||this.isMaskedImage(a))&&(o=this.isShape(a)?a:this.getMaskedImageShapeItem(a),(s=this.getShapeItemStyle(o)).strokeColor&&(s.strokeColor=this.forceColorInFixedPalette(a,s.strokeColor,null,t)),s.fillColor&&(s.fillColor=this.forceColorInFixedPalette(a,s.fillColor,null,t)),this.changeShapeStyle(a,s)),this.isAreaForBackground(a)&&(l=a.fillColor.toCSS(!0))&&(a.fillColor=this.forceColorInFixedPalette(a,l,null,t)),this.onItemUpdated(a),this.usedColorsItemsToCheck.push(a),h.label=4;case 4:return n++,[3,1];case 5:return this.usedColorsItemsToCheck=null,this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(i),[2]}})})},resetImageColorMapping:function(e,t,i){return void 0===t&&(t=null),__awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h;return __generator(this,function(d){switch(d.label){case 0:return e?(n=this.getImageItemInfo(e,t),a=this.findDesignItemByGuid(e.data.guid),r=this.getMaskedImageRasterItem(e),n&&a&&r?(this.beginDesignOperation(),o=n.url,s=this.getDesignEffectForDesignItem(a),o,[4,this.applyDesignEffectToImageUrl(s,o)]):[3,7]):[3,7];case 1:return o=d.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(o,e,null,t)];case 2:i=d.sent(),d.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(o,i)]:[3,5];case 4:o=d.sent(),d.label=5;case 5:return[4,this.changeRasterItem(r,o)];case 6:d.sent(),this.applyDesignEffectToItem(s,e),this.updateDesignItemColorMappings(a,i),this.endDesignOperation(),l=this.createDummyImageFromDesignItem(a),h=this.createDummyShapeFromDesignItem(a),this.onImageItemUpdated(e,l,h),this.updateSelectionState(),this.paper.project.view.update(),d.label=7;case 7:return[2,e]}})})},getDesignEffectForArea:function(e){var t=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(e));if(t)return t.get("previewDesignEffect")},applyDesignEffectToImageUrl:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C;return __generator(this,function(M){switch(M.label){case 0:return i=t,e&&e instanceof MPlaza.DesignEffect&&e.get("imageEffectTypeName")?(n=this._getCachedImageEffectResult(t,e))?(i=n,[3,21]):[3,1]:[3,21];case 1:if(a=null,r=e.get("imageEffectParameterValues").getValue("overlay color"),o=void 0,r&&(o=this.hex2rgb(r)),s=e.get("imageEffectParameterValues").getValue("halftone"),l=Zakeke.Customizer.HalfoneType.None,s)switch(s.toLowerCase()){case"errordiffusion":l=Zakeke.Customizer.HalfoneType.ErrorDiffusion;break;case"dithering":l=Zakeke.Customizer.HalfoneType.Dithering;break;default:l=Zakeke.Customizer.HalfoneType.None}switch(h=e.get("imageEffectParameterValues").getValueNumber("threshold level"),d=null,null!=h&&!isNaN(h)&&h>=0&&h<=255&&(d=h),c=e.get("imageEffectParameterValues").getValueBoolean("invert"),u=e.get("imageEffectParameterValues").getValue("dark color"),g={red:0,green:0,blue:0},u&&(g=this.hex2rgb(u)),f=e.get("imageEffectParameterValues").getValue("light color"),p={red:255,green:255,blue:255},f&&(p=this.hex2rgb(f)),m=e.get("imageEffectParameterValues").getValueBoolean("remove white"),v=e.get("imageEffectTypeName").toLowerCase(),v){case"greyscale":return[3,2];case"contrasted greyscale":return[3,4];case"soft greyscale":return[3,6];case"hard greyscale":return[3,8];case"black and white":return[3,10];case"black and transparent":return[3,12];case"dark and light":return[3,14];case"silhouette":return[3,16];case"reduce colors":return[3,18]}return[3,20];case 2:return[4,Zakeke.Customizer.ImageProcessor.greyScale(t,l,c,o)];case 3:return a=M.sent(),[3,20];case 4:return[4,Zakeke.Customizer.ImageProcessor.greyScalePlus(t,l,c,o)];case 5:return a=M.sent(),[3,20];case 6:return[4,Zakeke.Customizer.ImageProcessor.desaturate(t,l,c,o)];case 7:return a=M.sent(),[3,20];case 8:return[4,Zakeke.Customizer.ImageProcessor.blackAndWhite(t,l,c,o)];case 9:return a=M.sent(),[3,20];case 10:return[4,Zakeke.Customizer.ImageProcessor.thresholding(t,d,c,o)];case 11:return a=M.sent(),[3,20];case 12:return[4,Zakeke.Customizer.ImageProcessor.thresholdingTransparentWhite(t,d,c,o)];case 13:return a=M.sent(),[3,20];case 14:return[4,Zakeke.Customizer.ImageProcessor.thresholdingDarkAndLight(t,d,c,g,p)];case 15:return a=M.sent(),[3,20];case 16:return[4,Zakeke.Customizer.ImageProcessor.overlapColor(t,o,m)];case 17:return a=M.sent(),[3,20];case 18:return I=e.get("imageEffectParameterValues").getValueNumber("colors"),y=e.get("imageEffectParameterValues").getValue("palette"),C=e.get("imageEffectParameterValues").getValue("replacementPalette"),[4,Zakeke.Customizer.ImageProcessor.reduce(t,I,y,C)];case 19:return a=M.sent(),[3,20];case 20:a&&(i=URL.createObjectURL(a)),this._cacheImageEffectResult(t,e,i),M.label=21;case 21:return[2,i]}})})},applyDesignEffectToTextColor:function(e,t){return t&&e&&e.get("textColor")?e.get("textColor"):t},applyDesignEffectToShapeColor:function(e,t){return t&&e&&e.get("textColor")?e.get("textColor"):t},applyDesignEffectToItem:function(e,t,i){void 0===i&&(i=!1);var n=-1!=navigator.userAgent.indexOf("Firefox");if(t){var a="normal",r=!1,o=1;if(e&&e instanceof MPlaza.DesignEffect){var s=e.get("blendMode")||"normal";a=this.supportedBlendModes.find(function(e){return e==s.toLowerCase()})||"normal",i&&n&&(a="normal"),r=e.get("enhanceBlendMode"),null!=(o=e.get("opacity"))&&null!=o||(o=1),o=Math.max(Math.min(1,o),0)}if(t.blendMode=a,t.enhanceBlendMode=r,t.opacity=o,this.isMaskedImage(t)){var l=this.getMaskedImageShapeItem(t),h=this.getMaskedImageRasterItem(t);this.applyDesignEffectToItem(e,l,i),this.applyDesignEffectToItem(e,h,i)}}},hex2rgb:function(e){var t=String(e).match(this.RGB_HEX)||[],i=t[1],n=t[2],a=[0,0,0];if(n){var r=Number.parseInt(n,16);a=[r>>16,r>>8&255,255&r]}else i&&(a=Array.from(i,function(e){return Number.parseInt(e,16)}).map(function(e){return e<<4|e}));return{red:a[0],green:a[1],blue:a[2]}},getOrCreateItemFromDesignItem:function(e){var t,i,n,a;return __awaiter(this,void 0,void 0,function(){var r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S,b,w,A,P,D,k,_,T,z,O=this;return __generator(this,function(B){switch(B.label){case 0:return r=null,o=e.get("itemGuid"),s=null,l="",h=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.length>0&&4==e.length&&"Color"==e[0]?e.slice(1,4):e},e&&e instanceof MPlaza.DesignItem?(l=e.get("json"),s=this.getDesignEffectForDesignItem(e),d=JSON.parse(l),e.get("imageID")>0?"[object Array]"===Object.prototype.toString.call(d)&&2==d.length&&"Raster"==d[0]&&d[1].source?(v=d[1].source,d[1].data&&d[1].data.originalUrl&&(v=d[1].data.originalUrl),[4,this.applyDesignEffectToImageUrl(s,v)]):[3,4]:[3,10]):[3,11];case 1:return I=B.sent(),(y=null!==(i=null===(t=e.get("colorMappings"))||void 0===t?void 0:t.toJSON())&&void 0!==i?i:[])&&y.length>0?[4,this.recolorImage(I,y)]:[3,3];case 2:I=B.sent(),B.label=3;case 3:return d[1].source=I,l=JSON.stringify(d),[3,9];case 4:return"[object Array]"===Object.prototype.toString.call(d)&&2==d.length&&"Group"==d[0]&&d[1].data&&d[1].data.isMaskedImageMainGroup?((c=d[1].children.filter(function(e){return"[object Array]"===Object.prototype.toString.call(e)&&2==e.length&&"CompoundPath"==e[0]}))&&(u=c[0],(S=u[1].strokeColor)&&(S=new this.paper.Color(S).toCSS(!0)),u[1].data&&u[1].data.originalStrokeColor&&(S=u[1].data.originalStrokeColor),P=this.applyDesignEffectToTextColor(s,S),u[1].data&&(u[1].data.originalStrokeColor=new this.paper.Color(S).toCSS(!0)),C=void 0,P&&(C=new this.paper.Color(P).components),u[1].strokeColor=C),(g=d[1].children.filter(function(e){return"[object Array]"===Object.prototype.toString.call(e)&&2==e.length&&"Group"==e[0]}))?(f=g[0],p=f[1].children.filter(function(e){return"[object Array]"===Object.prototype.toString.call(e)&&2==e.length&&"Raster"==e[0]}),m=p[0],v=m[1].source,m[1].data&&m[1].data.originalUrl&&(v=m[1].data.originalUrl),[4,this.applyDesignEffectToImageUrl(s,v)]):[3,8]):[3,9];case 5:return I=B.sent(),(y=null!==(a=null===(n=e.get("colorMappings"))||void 0===n?void 0:n.toJSON())&&void 0!==a?a:[])&&y.length>0?[4,this.recolorImage(I,y)]:[3,7];case 6:I=B.sent(),B.label=7;case 7:m[1].source=I,B.label=8;case 8:l=JSON.stringify(d),B.label=9;case 9:return[3,11];case 10:"[object Array]"===Object.prototype.toString.call(d)&&2==d.length&&"CompoundPath"==d[0]?(S=d[1].strokeColor,b=d[1].fillColor,w=d[1].shadowColor,S&&(S=new this.paper.Color(S).toCSS(!0)),b&&(b=new this.paper.Color(b).toCSS(!0)),w&&(w=new this.paper.Color(w).toCSS(!0)),d[1].data&&(d[1].data.originalStrokeColor&&(S=d[1].data.originalStrokeColor),d[1].data.originalFillColor&&(b=d[1].data.originalFillColor),d[1].data.originalShadowColor&&(w=d[1].data.originalShadowColor)),P=this.applyDesignEffectToTextColor(s,S),D=this.applyDesignEffectToTextColor(s,b),k=this.applyDesignEffectToTextColor(s,w),d[1].data&&(d[1].data.originalStrokeColor=new this.paper.Color(S).toCSS(!0),d[1].data.originalFillColor=new this.paper.Color(b).toCSS(!0),d[1].data.originalShadowColor=new this.paper.Color(w).toCSS(!0)),C=void 0,M=void 0,x=void 0,P&&(C=new this.paper.Color(P).components),D&&(M=new this.paper.Color(D).components),k&&(x=new this.paper.Color(k).components),d[1].strokeColor=C,d[1].fillColor=M,d[1].shadowColor=x,l=JSON.stringify(d)):"[object Array]"===Object.prototype.toString.call(d)&&2==d.length&&"Group"==d[0]&&d[1].data&&(d[1].data.isTextArea||d[1].data.isTextOnPath)&&(S=null,d[1].data&&d[1].data.hasOwnProperty("originalStrokeColor")?S=d[1].data.originalStrokeColor:d[1].data&&d[1].data.textInfo&&d[1].data.textInfo.hasOwnProperty("strokeColor")&&(S=new this.paper.Color(h(d[1].data.textInfo.strokeColor)).toCSS(!0)),!S&&d[1].children&&"[object Array]"===Object.prototype.toString.call(d[1].children)&&d[1].children.length>0&&(A=d[1].children[0])&&"[object Array]"===Object.prototype.toString.call(A)&&2==A.length&&"PointText"==A[0]&&A[1].strokeColor&&(S=new this.paper.Color(A[1].strokeColor).toCSS(!0)),b=null,d[1].data&&d[1].data.hasOwnProperty("originalFillColor")?b=d[1].data.originalFillColor:d[1].data&&d[1].data.textInfo&&d[1].data.textInfo.hasOwnProperty("fillColor")?b=new this.paper.Color(h(d[1].data.textInfo.fillColor)).toCSS(!0):d[1].children&&"[object Array]"===Object.prototype.toString.call(d[1].children)&&d[1].children.length>0&&(A=d[1].children[0])&&"[object Array]"===Object.prototype.toString.call(A)&&2==A.length&&"PointText"==A[0]&&A[1].fillColor&&(b=new this.paper.Color(A[1].fillColor).toCSS(!0)),w=null,d[1].data&&d[1].data.hasOwnProperty("originalShadowColor")?w=d[1].data.originalShadowColor:d[1].data&&d[1].data.textInfo&&d[1].data.textInfo.hasOwnProperty("shadowColor")?w=new this.paper.Color(h(d[1].data.textInfo.shadowColor)).toCSS(!0):d[1].children&&"[object Array]"===Object.prototype.toString.call(d[1].children)&&d[1].children.length>0&&(A=d[1].children[0])&&"[object Array]"===Object.prototype.toString.call(A)&&2==A.length&&"PointText"==A[0]&&A[1].shadowColor&&(w=new this.paper.Color(A[1].shadowColor).toCSS(!0)),P=this.applyDesignEffectToTextColor(s,S),D=this.applyDesignEffectToTextColor(s,b),k=this.applyDesignEffectToTextColor(s,w),d[1].data&&(S&&(d[1].data.originalStrokeColor=new this.paper.Color(S).toCSS(!0)),d[1].data.originalFillColor=new this.paper.Color(b).toCSS(!0),w&&(d[1].data.originalShadowColor=new this.paper.Color(w).toCSS(!0))),_=void 0,T=void 0,z=void 0,P&&(_=new this.paper.Color(P).components),D&&(T=new this.paper.Color(D).components),k&&(z=new this.paper.Color(k).components),this.isViewer,d[1].data.textInfo&&(d[1].data.textInfo.strokeColor=_,d[1].data.textInfo.fillColor=T,d[1].data.textInfo.shadowColor=z),d[1].children&&"[object Array]"===Object.prototype.toString.call(d[1].children)&&d[1].children.length>0&&d[1].children.forEach(function(e){"[object Array]"===Object.prototype.toString.call(e)&&2==e.length&&"PointText"==e[0]&&(e[1].strokeColor=_,e[1].fillColor=T,e[1].shadowColor=z)}),l=JSON.stringify(d)),B.label=11;case 11:return[4,new Promise(function(e){var t=O.findItemByGuid(o);!t&&l&&((t=O.paper.project.activeLayer.importJSON(l)).data.guid=o,t.visible=!1);var i=null,n=null;if(t){if(t&&t instanceof O.paper.TextItem?n=O.convertTextToTextArea(t):t instanceof O.paper.Raster&&(i=t),O.isMaskedImage(t)||O.isFilledShape(t)){i=O.getMaskedImageRasterItem(t);var a=O.getMaskedImageShapeItem(t);a.strokeColor||(a.strokeWidth=0)}O.isShape(t)&&O.isImagePlaceholder(t)&&O.updateShapeImagePlaceholder(t),n?e(n):i?i.onLoad=function(){e(t)}:e(t)}else e(t)})];case 12:return r=B.sent(),this.applyDesignEffectToItem(s,r),[2,r]}})})},convertTextToTextArea:function(e){var t=null;if(e&&e instanceof this.paper.TextItem){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid"));var r=e.bounds.clone();r.bottom=r.bottom,r.bottom+=5*r.height,e.remove();var o=null;e.shadowColor&&(o="string"==typeof e.shadowColor||e.shadowColor instanceof String?e.shadowColor:e.shadowColor.toCSS(!0));var s=null;e.strokeColor&&(s="string"==typeof e.strokeColor||e.strokeColor instanceof String?e.strokeColor:e.strokeColor.toCSS(!0));var l={};if(l.text=e.content,l.strokeWidth=e.strokeWidth,l.strokeColor=s,l.fillColor="string"==typeof e.fillColor||e.fillColor instanceof String?e.fillColor:e.fillColor.toCSS(!0),l.fontFamily=e.fontFamily,l.fontWeight=e.fontWeight,l.fontSize=e.fontSize,l.scaling=e.scaling,l.rotation=e.rotation,l.justification=e.data&&e.data.justification?e.data.justification:void 0!==e.justification?e.justification:"justify",l.shadowColor=o,l.shadowBlur=e.shadowBlur,l.shadowDistance=this.getOffsetDistance(e.shadowOffset),l.shadowAngle=this.getOffsetAngle(e.shadowOffset),l.lineSpacing=e.lineSpacing,l.letterSpacing=e.letterSpacing,e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(l.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(l.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(l.shadowColor=e.data.originalShadowColor)),r.left=e.bounds.left,r.right=e.bounds.right,r.top=e.bounds.top,t=this.generateTextAreaFromText(r,l,e),this.masterGroup.addChild(t),t.position.y=r.top+t.bounds.height/2,t.position.x=r.left+e.bounds.width/2,t.data.rect=t.bounds.clone(),t.data.originalMatrix=t.matrix.clone(),(null==t?void 0:t.children.length)>0){var h=t.children[0],d=h.matrix.a,c=h.matrix.b,u=h.matrix.c,g=h.matrix.d,f=t.bounds.centerX,p=t.bounds.centerY;t.data.originalMatrix=new this.paper.Matrix(d,c,u,g,f,p)}if(n){var m=this.findDesignItemForItem(t);m&&m.setConstraintsFromSource(n)}t.data.guid=e.data.guid,this.updateDesignItem(t),this.paper.project.view.update(),this.updateItemSyncGuid(t,a)}return t},generateTextAreaFromText:function(e,t,i){var n=null;if(this.side&&(a=this.side.get("areas").getMaxArea())){if(!e&&this.side){var a=this.side.get("areas").getMaxArea(),r=this.findItemForArea(a);r&&(e=r.bounds.expand(-50))}if(!e)return;if(t&&t.text){var o=this.getDesignEffectForArea(a);this.allowShadows()||(t.shadowColor=null);var s=t.strokeColor||null,l=t.fillColor||"#000000",h=t.shadowColor||null;s=this.forceColorInFixedPalette(null,s),l=this.forceColorInFixedPalette(null,l),h=this.forceColorInFixedPalette(null,h),t.strokeColor=this.applyDesignEffectToTextColor(o,s),t.fillColor=this.applyDesignEffectToTextColor(o,l),t.shadowColor=this.applyDesignEffectToTextColor(o,h),t.shadowBlur=this.adjustInputShadowBlur(null,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(null,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(null,t.shadowAngle),t.letterSpacing=null!=t.letterSpacing?t.letterSpacing:0,t.lineSpacing=null!=t.lineSpacing?t.lineSpacing:0,t.strokeWidth=this.adjustInputTextStrokeWidth(null,t.strokeWidth),n=new this.paper.Group;var d=this.createWrappedText(e,t,!1).textItems;n.addChildren(d),this.applyDesignEffectToItem(o,n),e=n.bounds,n.data.rect=e,n.data.isTextArea=!0,n.data.text=t.text,n.data.justification=null!=t.justification?t.justification:"justify",n.data.originalStrokeColor=s,n.data.originalFillColor=l,n.data.originalShadowColor=h,n.data.letterSpacing=t.letterSpacing,n.data.lineSpacing=t.lineSpacing,n.rotation=t.rotation,n.position=e.center,n.data.needsTransformsDataUpdate=!0,this.updateTransformsData(n),this.forceTextAreaToBounds(n)}this.paper.project.view.update()}return n},getDesignEffectForDesignItem:function(e){var t=null;if(this.side&&e&&e instanceof MPlaza.DesignItem&&e.get("areas").length>0){var i=e.get("areas").at(0),n=this.side.findAreaByID(i.get("areaID"));t=this.getDesignEffectForArea(n)}return t},createRasterItem:function(e,t){var i=this;return void 0===t&&(t=!0),new Promise(function(n){var a=new i.paper.Raster({crossOrigin:"anonymous",source:e,visibile:t});a.onLoad=function(){a.onLoad=void 0,n(a)}})},changeRasterItem:function(e,t){return new Promise(function(i){e.crossOrigin="anonymous",e.source=t,e.onLoad=function(){e.onLoad=void 0,i()}})},convertColorToHex:function(e){var t=void 0;return e&&e instanceof this.paper.Color&&(t=e.toCSS(!0)),t},_getImageEffectCacheKey:function(e,t){var i="image_effect_"+e,n=JSON.stringify(t.toJSON());return i+="_"+CryptoJS.SHA1(n).toString()},_emptyImageEffectCache:function(){window.imageEffectCache={}},_getCachedImageEffectResult:function(e,t){var i=this._getImageEffectCacheKey(e,t);return window.imageEffectCache.hasOwnProperty(i)?window.imageEffectCache[i]:null},_cacheImageEffectResult:function(e,t,i){if(e&&t&&i){var n=this._getImageEffectCacheKey(e,t);window.imageEffectCache[n]=i}},isMaskedImage:function(e){return e&&e instanceof this.paper.Group&&e.data&&e.data.isMaskedImageMainGroup},isMaskedImageRasterItem:function(e){return this.isImage(e)&&this.isMaskedImageClipGroup(e.parent)},isImage:function(e){return e&&e instanceof this.paper.Raster},isMaskedImageClipGroup:function(e){return e&&e instanceof this.paper.Group&&e.data&&e.data.isMaskedImageClipGroup},isMaskedImageGuideRaster:function(e){return e&&e instanceof this.paper.Raster&&e.data&&e.data.isMaskedImageGuideRaster},isMaskedImageSelected:function(){var e=this;return this.getSelectedItems().some(function(t){return e.isMaskedImage(t)})},isMaskedImageShapeItem:function(e){return e&&e.data&&e.data.isMaskedImageShape},isMaskedImageMaskItem:function(e){return e&&e.data&&e.data.isMaskedImageMask},applyMaskToImageItemAsync:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r;return __generator(this,function(o){switch(o.label){case 0:return this.canEditItem(e)?this.isImage(e)&&!this.canMaskImages()?[2,e]:this.isImage(e)&&!this.canAddMask(e)?[2,e]:this.isMaskedImage(e)&&!this.canReplaceMask(e)?[2,e]:!this.isMaskedImage(e)||t||this.canDeleteMask(e)?(n=this.getLastUndoOperationId(),this.beginDesignOperation(),a=e,t?[3,1]:(a=this.removeMaskFromImage(e),[3,3])):[2,e]:[2,e];case 1:return[4,this._loadShapePathDataAsync(t)];case 2:r=o.sent(),e&&(this.isMaskedImage(e)?a=this.updateMaskedImage(e,t,r,i):e instanceof this.paper.Raster&&(a=this.createMaskedImage(e,t,r,i))),o.label=3;case 3:return this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n),[2,a]}})})},getMaskedImageRasterItem:function(e){var t=this;if(e&&e instanceof this.paper.Raster)return e;if(e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup){var i=e.children.find(function(e){return e instanceof t.paper.Group});if(i)return i.children.find(function(e){return e instanceof t.paper.Raster})}return e&&e instanceof this.paper.Group&&e.data.isMaskedImageClipGroup?e.children.find(function(e){return e instanceof t.paper.Raster}):null},getMaskedImageShapeItem:function(e){return e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup?e.children.find(function(e){return e.data&&e.data.isMaskedImageShape}):null},getMaskedImageMaskItem:function(e){var t=this;if(e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup){var i=e.children.find(function(e){return e instanceof t.paper.Group});if(i)return i.children.find(function(e){return e&&e.data&&e.data.isMaskedImageMask})}return e&&e instanceof this.paper.Group&&e.data.isMaskedImageClipGroup?e.children.find(function(e){return e&&e.data&&e.data.isMaskedImageMask}):null},getMaskedImageClipGroupItem:function(e){var t=this;return e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup?e.children.find(function(e){return e instanceof t.paper.Group}):e&&e instanceof this.paper.Group&&e.data.isMaskedImageClipGroup?e:null},getMaskedImageGuideRasterItem:function(e){return e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup?e.children.find(function(e){return e.data&&e.data.isMaskedImageGuideRaster}):null},getMaskedImageFromGuideRasterItem:function(e){if(e&&e instanceof this.paper.Raster&&e.data.isMaskedImageGuideRaster){var t=e.parent;if(t&&t instanceof this.paper.Group&&t.data&&t.data.isMaskedImageMainGroup)return t}return null},getMaskedImageGuideShapeItem:function(e){return e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup?e.children.find(function(e){return e.data&&e.data.isMaskedImageGuideShape}):null},getMaskedImageFromGuideShapeItem:function(e){if(e&&e instanceof this.paper.CompoundPath&&e.data.isMaskedImageGuideShapeItem){var t=e.parent;if(t&&t instanceof this.paper.Group&&t.data&&t.data.isMaskedImageMainGroup)return t}return null},getMaskedImageMaskPathStyle:function(e){var t=void 0;if(e){var i=this.getMaskedImageShapeItem(e);i&&(t={strokeColor:i.strokeColor?i.strokeColor.toCSS(!0):void 0,strokeWidth:i.strokeWidth,strokeCap:i.strokeCap,strokeJoin:i.strokeJoin,dashArray:i.dashArray,dashOffset:i.dashOffset},i.data.hasOwnProperty("originalStrokeColor")&&(t.strokeColor=i.data.originalStrokeColor))}return t},createMaskedImage:function(e,t,i,n){if(!this.canMaskImages()||!this.canAddMask(e))return e;if(e&&e instanceof this.paper.Raster&&i){var a=this.findDesignItemForItem(e);if(a){var r=this.getDesignEffectForDesignItem(a),o=this.isItemSelected(e),s=e.parent,l=e.bounds.width,h=e.bounds.height;delete e.data.selected;var d=this.boundPath(i,l,h),c=new this.paper.CompoundPath(d);c.position=e.position,c.data.isMaskedImageMask=!0;var u=c.clone();u.data.originalBounds=u.bounds,u.data.originalMatrix=new this.paper.Matrix,u.data.originalParentMatrix=new this.paper.Matrix,u.data.isMaskedImageShape=!0;var g=n.strokeColor;g=this.forceColorInFixedPalette(e,g),n.strokeColor=this.applyDesignEffectToTextColor(r,g),this.applyStyleToMaskShape(u,n),u.data.originalStrokeColor=g;var f=new this.paper.Group(c);f.clipped=!0,f.data.isMaskedImageClipGroup=!0;var p=new this.paper.Group(f,u);p.applyMatrix=!1,p.data.guid=e.data.guid,delete e.data.guid,p.data.isMaskedImageMainGroup=!0,p.data.originalBounds=u.bounds,p.data.originalMatrix=new this.paper.Matrix,e.data.maskPath&&e.data.maskPath.remove(),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),e.data.hasOwnProperty("isGridImage")&&(p.data.isGridImage=e.data.isGridImage,delete e.data.isGridImage),e.data.hasOwnProperty("gridBoxID")&&(p.data.gridBoxID=e.data.gridBoxID,delete e.data.gridBoxID),this.applyDesignEffectToItem(r,p,!0),s.addChild(p),p.insertAbove(e),f.addChild(e);var m=this.createDummyImageFromDesignItem(a);return this.onImageItemUpdated(p,m,t),e.data.selected=!1,p.data.selected=o,this.updateSelectionState(),p}}return e},updateMaskedImage:function(e,t,i,n){if(!this.canReplaceMask(e))return e;if(e&&this.isMaskedImage(e)){var a=this.findDesignItemForItem(e);if(a){var r=this.getDesignEffectForDesignItem(a),o=this.getMaskedImageShapeItem(e),s=this.getMaskedImageMaskItem(e),l=this.getMaskedImageRasterItem(e);if(o&&s&&l){delete l.data.selected;var h=n,d=this.getMaskedImageMaskPathStyle(e);this.canChangeMaskStrokeColor(e)&&h.strokeColor||(h.strokeColor=d.strokeColor),this.canChangeMaskStrokeWidth(e)&&h.strokeWidth||(h.strokeWidth=d.strokeWidth);var c=h.strokeColor;c=this.forceColorInFixedPalette(e,c),h.strokeColor=this.applyDesignEffectToTextColor(r,c);var u=o.bounds;if(o.data.originalBounds&&o.data.originalMatrix){u=o.data.originalBounds;var g=new this.paper.Path.Rectangle(0,0,u.width,u.height);g.visible=!1,g.matrix=o.data.originalMatrix.clone();var f=this.getRectangleItemSize(g);g.remove(),u=new this.paper.Rectangle(0,0,f.width,f.height)}else{var p=new this.paper.Path.Rectangle(0,0,l.width,l.height);p.remove(),p.scale(l.scaling),u=p.bounds}var m=l.position,v=o.data.originalParentMatrix?o.data.originalParentMatrix:o.matrix,I=u.width,y=u.height,C=this.boundPath(i,I,y),M=new this.paper.CompoundPath(C),x=M.clone();this.applyStyleToItem(x,h),s.removeChildren(),s.copyContent(M),o.removeChildren(),o.copyContent(x),o.data.originalStrokeColor=c,M.remove(),x.remove(),o.matrix=v.clone(),o.position=m.clone(),s.matrix=v.clone(),s.position=m.clone();var S=this.createDummyImageFromDesignItem(a);this.onImageItemUpdated(e,S,t),this.updateSelectionState()}}}},updateMakedImageMaskStyle:function(e,t){if(e&&this.isMaskedImage(e)){var i=this.findDesignItemForItem(e);if(i){var n=this.getDesignEffectForDesignItem(i),a=this.getMaskedImageShapeItem(e);if(a){this.beginDesignOperation();var r=this.getMaskedImageMaskPathStyle(e),o=r.strokeColor;this.canChangeMaskStrokeColor(e)&&null!=t.strokeColor&&(o=t.strokeColor),t.strokeColor=o;var s=r.strokeWidth;this.canChangeMaskStrokeWidth(e)&&null!=t.strokeWidth&&null!=t.strokeWidth&&(s=t.strokeWidth),t.strokeWidth=s,a.data.originalStrokeColor=null!=t.strokeWidth?t.strokeColor:void 0,a.data.originalStrokeColor=this.forceColorInFixedPalette(e,a.data.originalStrokeColor),t.strokeColor=this.applyDesignEffectToTextColor(n,a.data.originalStrokeColor),this.applyStyleToItem(a,t);var l=this.createDummyImageFromDesignItem(i),h=this.createDummyShapeFromDesignItem(i);this.onImageItemUpdated(e,l,h),this.endDesignOperation()}}}},removeMaskFromImage:function(e){var t=e;if(e&&this.isMaskedImage(e)&&!this.isFilledShape(e)){var i=this.isItemSelected(e),n=e.parent,a=this.findDesignItemForItem(e),r=this.getMaskedImageRasterItem(e);if(a&&r){var o=e.matrix;(t=r).data.guid=e.data.guid,n.insertChild(e.index,t),e.remove(),t.matrix.prepend(o),t.data.originalMatrix&&t.data.originalMatrix.prepend(o);var s=this.createDummyImageFromDesignItem(a);this.onImageItemUpdated(t,s,null),e.data.selected=!1,t.data.selected=i,this.updateSelectionState()}}return t},boundPath:function(e,t,i){var n=Raphael.pathBBox(e),a=t/n.width,r=i/n.height,o=Math.min(a,r);0===o&&(o=1);var s="s"+o+","+o+",0,0",l=Raphael.transformPath(e,"t"+-n.x+","+(i/o-n.y));return(l=Raphael.transformPath(l,s)).toString()},applyStyleToMaskShape:function(e,t){e&&e instanceof this.paper.Item&&(null!=t.strokeColor&&(e.strokeColor=t.strokeColor),null!=t.strokeWidth&&(e.strokeWidth=t.strokeWidth),t.strokeCap&&(e.strokeCap=t.strokeCap),t.strokeJoin&&(e.strokeJoin=t.strokeJoin),null!=t.dashOffset&&(e.dashOffset=t.dashOffset),t.dashArray&&(e.dashArray=t.dashArray))},getReferenceItemForSelectedItem:function(e){if(this.isMaskedImage(e)){var t=e;return this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster?t=this.getMaskedImageGuideRasterItem(e):this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&(t=this.getMaskedImageGuideShapeItem(e)),t}return e},getItemBounds:function(e){var t=e.bounds;if(this.isMaskedImage(e)){var i=this.getMaskedImageShapeItem(e);if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster){var n=this.getMaskedImageGuideRasterItem(e);n&&(i=n)}else if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask){var a=this.getMaskedImageGuideShapeItem(e);a&&(i=a)}if(i)if(e.applyMatrix)t=i.bounds;else{var r=i.clone();r.remove(),r.matrix=r.matrix.prepend(e.matrix),t=r.strokeBounds}}return t},getImageWidth:function(e){if(this.isMaskedImage(e)){var t=this.getMaskedImageShapeItem(e);if(t){if(!e.applyMatrix){var i=t.clone();return i.remove(),i.matrix=i.matrix.prepend(e.matrix),i.bounds.width}return t.bounds.width}}else if(this.isImage(e))return e.width;return 0},getImageHeight:function(e){if(this.isMaskedImage(e)){var t=this.getMaskedImageShape(e);if(t){if(!e.applyMatrix){var i=t.clone();return i.remove(),i.matrix=i.matrix.prepend(e.matrix),i.bounds.height}return t.bounds.height}}else if(this.isImage(e))return e.height;return 0},_loadShapePathDataAsync:function(e){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(i){switch(i.label){case 0:return e&&e instanceof MPlaza.Shape&&(t=e.get("pathDataUrl"))?[4,this._loadFileAsync(t,!1)]:[3,2];case 1:return[2,i.sent()];case 2:return[2]}})})},_loadFileAsync:function(e,t){return void 0===t&&(t=!0),new Promise(function(i,n){FileTools.LoadFile(e,function(e){i(e)},void 0,void 0,t,function(e,t){n(t)})})},_loadRandomShapeAsync:function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=Math.floor(3e3*Math.random())+1,[4,this._loadShapeByIdAsync(e)];case 1:return[2,t.sent()]}})})},_loadShapeByIdAsync:function(e){return new Promise(function(t,i){new MPlaza.Shape({shapeID:e}).fetch({success:function(e,i,n){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(i){return t(e),[2]})})},error:function(e,t,n){Logger.info("Error while loading shape"),i()},data:{}})})},createMaskedImageGuideRaster:function(e){if(this.isMaskedImage(e)){var t=this.getMaskedImageGuideRasterItem(e);if(t)return t;var i=this.getMaskedImageRasterItem(e);return i&&(t=i.clone(),i.data.originalBounds&&(t.data.originalBounds=i.data.originalBounds.clone()),i.data.originalMatrix&&(t.data.originalMatrix=i.data.originalMatrix.clone()),t.parent=e,t.sendToBack(),t.opacity=.3,t.data.isMaskedImageGuideRaster=!0),t}},createMaskedImageGuideShape:function(e){if(this.isMaskedImage(e)){var t=this.getMaskedImageGuideShapeItem(e);if(t)return t;var i=this.getMaskedImageShapeItem(e);if(i){(t=i.clone()).blendMode="normal",t.opacity=1,i.data.originalBounds&&(t.data.originalBounds=i.data.originalBounds.clone()),i.data.originalMatrix&&(t.data.originalMatrix=i.data.originalMatrix.clone()),t.parent=e,t.bringToFront();var n="red";n=i.strokeWidth>0&&i.strokeColor?MPlaza.getContrastYIQ(255*i.strokeColor.red,255*i.strokeColor.green,255*i.strokeColor.blue):this.getContrastedColor(i.bounds),t.strokeColor=n,t.strokeWidth=2,t.dashArray=[4,10],t.data.isMaskedImageGuideShape=!0}return t}},removeMaskedImageGuideRaster:function(e){var t=this.getMaskedImageGuideRasterItem(e);t&&t.remove()},removeMaskedImageGuideShape:function(e){var t=this.getMaskedImageGuideShapeItem(e);t&&t.remove()},updateMaskedImageGuides:function(e){for(var t=this.getAllImageItems(),i=0;i<t.length;i++){e=t[i];this.isItemSelected(e)?this.isMaskedImage(e)&&(this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element?(this.createMaskedImageGuideRaster(e),this.createMaskedImageGuideShape(e)):(this.removeMaskedImageGuideRaster(e),this.removeMaskedImageGuideShape(e))):(this.removeMaskedImageGuideRaster(e),this.removeMaskedImageGuideShape(e))}},getSubItemsToChange:function(e){var t=[];if(e)if(this.isMaskedImage(e)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster){var i=this.getMaskedImageGuideRasterItem(e);i&&t.push(i);var n=this.getMaskedImageRasterItem(e);n&&t.push(n)}else if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask){var a=this.getMaskedImageGuideShapeItem(e);a&&t.push(a);var r=this.getMaskedImageShapeItem(e);r&&t.push(r);var o=this.getMaskedImageMaskItem(e);o&&t.push(o)}}else t.push(e);return t},switchMaskedImageSelectionMode:function(e){this.hitTest(e.point),this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element?this.setMaskedImageSelectionMode(MaskedImageSelectionMode.Element):this.hitItem==this.selectionMaskMoveShape?this.setMaskedImageSelectionMode(MaskedImageSelectionMode.Mask):this.hitItem==this.selectionMaskMoveImage&&this.setMaskedImageSelectionMode(MaskedImageSelectionMode.Raster)},setMaskedImageSelectionMode:function(e){var t=this.getSelectedMaskedImageItems();if(t.length>0){var i=t[0],n=!0;this.canEditItem(i)?(e!==MaskedImageSelectionMode.Mask||this.canEditMask(i)||(n=!1),e!==MaskedImageSelectionMode.Raster||this.canEditMaskedImage(i)||(n=!1)):n=!1,n?(this.applyTransformationsToMaskImageSubItems(),this.maskedImageSelectionMode=e,this.updateSelectionState()):this.maskedImageSelectionMode=MaskedImageSelectionMode.Element}else this.maskedImageSelectionMode=MaskedImageSelectionMode.Element},applyTransformationsToMaskImageSubItems:function(){for(var e=this,t=this.getSelectedImageItems().filter(function(t){return e.isMaskedImage(t)}),i=0;i<t.length;i++){var n=t[i];if(!n.applyMatrix){var a=n.matrix.clone();n.matrix=new this.paper.Matrix;var r=[];r.push(this.getMaskedImageShapeItem(n)),r.push(this.getMaskedImageMaskItem(n)),r.push(this.getMaskedImageRasterItem(n)),r.forEach(function(e){e.matrix.prepend(a),e.data.originalMatrix&&e.data.originalMatrix.prepend(a),e.data.originalPosition&&(e.data.originalPosition=e.data.originalPosition.transform(a)),e.data.originalParentMatrix&&e.data.originalParentMatrix.prepend(a)})}}},insertRandomShape:function(e){return __awaiter(this,void 0,void 0,function(){var t,i;return __generator(this,function(n){switch(n.label){case 0:return t=e||{isImagePlaceholder:!0,style:{strokeColor:"black",strokeWidth:2,fillColor:"darkred"}},[4,this._loadRandomShapeAsync()];case 1:return i=n.sent(),[4,this.insertShape(i,t)];case 2:return[2,n.sent()]}})})},insertShape:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h,d,c,u,g,f,p,m,v;return __generator(this,function(I){switch(I.label){case 0:return i=null,t?this.canAddShape()?(this.beginDesignOperation(),[4,this._loadShapePathDataAsync(e)]):[2,i]:[2];case 1:return(n=I.sent())&&this.side&&(a=this.side.get("areas").getMaxArea())&&(r=this.getDesignEffectForArea(a),o=t.style.strokeColor,s=t.style.fillColor,o=this.forceColorInFixedPalette(null,o),s=this.forceColorInFixedPalette(null,s),t.style.strokeColor=this.applyDesignEffectToTextColor(r,o),t.style.fillColor=this.applyDesignEffectToTextColor(r,s),i=new this.paper.CompoundPath(n),this.applyStyleToItem(i,t.style),i.data={},i.data.isShape=!0,i.data.originalBounds=i.bounds,i.data.originalMatrix=new this.paper.Matrix,i.data.originalPosition=i.position,i.data.originalStrokeColor=o,i.data.originalFillColor=s,i.data.isImagePlaceholder=t.isImagePlaceholder,this.applyDesignEffectToItem(r,i),this.onShapeItemCreated(i,e,t),(l=this.findItemForArea(a))&&(h=l.position.subtract(i.position),i.position.x+=h.x,i.position.y+=h.y,d=(new this.paper.Matrix).translate(h.x,h.y),i.data.originalMatrix.prepend(d),i.data.originalPosition=i.data.originalPosition.transform(d),c=i.bounds,((u=l.bounds).intersects(c)||c.contains(u))&&((g=u.clone()).width*=.8,g.height*=.8,f=1,p=1,Math.abs(g.width)>1e-7&&(f=g.width/c.width),Math.abs(g.height)>1e-7&&(p=g.height/c.height),m=f>0?1:-1,v=p>0?1:-1,f=p=Math.min(Math.abs(f),Math.abs(p)),f*=m,p*=v,i.scale(f,p),d=(new this.paper.Matrix).scale(f,p),i.data.originalMatrix.prepend(d),i.data.originalPosition=i.data.originalPosition.transform(d),this.masterGroup.addChild(i),this.onItemUpdated(i),this.updateItemsIndexes(),this.onDesignItemChanged(i),this.fireShapeLoadedEvent(),this.mask&&this.mask.bringToFront()))),this.endDesignOperation(),[2,i]}})})},replaceSelectedShape:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n;return __generator(this,function(a){switch(a.label){case 0:return t&&this.design?(i=this.getSelectedShapeItems())&&i.length>0?(n=i[0],this.canEditItem(n)?[4,this.replaceShape(n,e,t)]:[2]):[3,2]:[2];case 1:a.sent(),a.label=2;case 2:return[2]}})})},replaceShapeByGuid:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(a){switch(a.label){case 0:return(n=this.findItemByGuid(e))?[4,this.replaceShape(n,t,i)]:[3,2];case 1:return[2,a.sent()];case 2:return[2,null]}})})},replaceShape:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x;return __generator(this,function(S){switch(S.label){case 0:return this.canEditItem(e)?(this.beginDesignOperation(),(n=this.isShape(e)?e:this.getMaskedImageShapeItem(e))?[4,this._loadShapePathDataAsync(t)]:[2,e]):[2,e];case 1:return(a=S.sent())&&(r=this.findDesignItemByGuid(e.data.guid))&&(o=this.getDesignEffectForDesignItem(r),s=this.getShapeItemStyle(n),l=s.strokeColor,this.canChangeShapeStrokeColor(e)&&null!=i.style.strokeColor&&(l=i.style.strokeColor),i.style.strokeColor=l,h=s.strokeWidth,this.canChangeShapeStrokeWidth(e)&&null!=i.style.strokeWidth&&null!=i.style.strokeWidth&&(h=i.style.strokeWidth),i.style.strokeWidth=h,d=s.fillColor,this.canChangeShapeFillColor(e)&&null!=i.style.fillColor&&(d=i.style.fillColor),i.style.fillColor=d,c=null!=i.style.strokeWidth?i.style.strokeColor:void 0,u=i.style.fillColor,c=this.forceColorInFixedPalette(e,c),u=this.forceColorInFixedPalette(e,u),i.style.strokeColor=this.applyDesignEffectToTextColor(o,c),i.style.fillColor=this.applyDesignEffectToTextColor(o,u),g=e.bounds.width,f=e.bounds.height,(p=new this.paper.CompoundPath(a)).visible=!1,this.applyStyleToItem(p,i.style),p.transform(e.data.originalMatrix),p.position=e.position,e.removeChildren(),e.copyContent(p),m=e.data,e.copyAttributes(p),e.data=m,e.visible=!0,e.data.originalStrokeColor=c,e.data.originalFillColor=u,e.data.isImagePlaceholder=i.isImagePlaceholder,p.remove(),v=e.bounds.width,I=e.bounds.height,y=1,C=1,v>0&&Math.abs(g)>1e-7&&(y=g/v),I>0&&Math.abs(f)>1e-7&&(C=f/I),e.scale(y,C),M=(new this.paper.Matrix).scale(y,C),e.data.originalMatrix.prepend(M),x=this.createDummyImageFromDesignItem(r),this.onShapeItemUpdated(e,t,x),this.updateSelectionState(),this.paper.project.view.update(),this.fireShapeLoadedEvent()),this.endDesignOperation(),[2]}})})},changeShapeStyle:function(e,t){if(this.canEditItem(e)&&(this.isShape(e)||this.isFilledShape(e))){var i=this.isShape(e)?e:this.getMaskedImageShapeItem(e);if(i){var n=this.getShapeItemStyle(i),a=n.strokeColor;this.canChangeShapeStrokeColor(e)&&null!=t.strokeColor&&(a=t.strokeColor),t.strokeColor=a;var r=n.strokeWidth;this.canChangeShapeStrokeWidth(e)&&null!=t.strokeWidth&&null!=t.strokeWidth&&(r=t.strokeWidth),t.strokeWidth=r;var o=n.fillColor;if(this.canChangeShapeFillColor(e)&&null!=t.fillColor&&(o=t.fillColor),t.fillColor=o,e&&e instanceof this.paper.Item){this.beginDesignOperation();var s=this.findDesignItemByGuid(e.data.guid),l=this.getDesignEffectForDesignItem(s),h=t.strokeColor,d=t.fillColor;h=this.forceColorInFixedPalette(e,h),d=this.forceColorInFixedPalette(e,d),t.strokeColor=this.applyDesignEffectToTextColor(l,h),t.fillColor=this.applyDesignEffectToTextColor(l,d),this.applyStyleToItem(e,t),i.data.originalStrokeColor=h,i.data.originalFillColor=d,this.onItemUpdated(e),this.endDesignOperation()}}}},updateShapeImagePlaceholders:function(e){var t=this;e.forEach(function(e){t.updateShapeImagePlaceholder(e)})},_removeShapesReferenceBounds:function(){this.shapesReferenceBounds&&this.shapesReferenceBounds.forEach(function(e){return e.remove()}),this.shapesReferenceBounds=[]},_updateShapesReferenceBounds:function(){this.removeShapesReferenceBounds();for(var e=this.getAllShapeItems(),t=0;t<e.length;t++){var i=e[t],n=null;if(this.isFilledShape(i)?n=this.getMaskedImageShapeItem(i):this.isShape(i)&&(n=i),n&&n.data&&n.data.originalBounds&&n.data.originalMatrix&&n.data.originalPosition){var a=new this.paper.Path.Rectangle(n.data.originalBounds);a.strokeColor="red",a.strokeWidth=3,a.matrix=n.data.originalMatrix,a.position=n.data.originalPosition.clone(),this.shapesReferenceBounds.push(a);var r=new this.paper.Path.Circle(n.data.originalPosition,5);r.fillColor="red",this.shapesReferenceBounds.push(r);var o=n.clone(),s=o.position.clone();o.rotate(-n.data.originalMatrix.rotation,s);var l=o.bounds;o.remove();var h=new this.paper.Path.Rectangle(l);h.strokeColor="blue",h.strokeWidth=3,h.rotate(n.data.originalMatrix.rotation,s),this.shapesReferenceBounds.push(h)}}},updateShapeImagePlaceholder:function(e){var t=this;if(this.removeShapeImagePlaceholder(e),e instanceof this.paper.CompoundPath&&e.data&&e.data.isShape&&e.data.isImagePlaceholder&&!e.data.isMaskedImageShape){var i=e.clone();delete i.data.guid,i.data.isShapePlaceholderPath=!0,i.guide=!0,i.data.shapeGuid=e.data.guid,i.opacity=1,i.blendMode="normal",i.strokeColor="none",i.strokeWidth=0,i.fillColor="#ededed",i.onMouseEnter=function(){return t.paper.project.view.element.style.setProperty("cursor","pointer")},i.onMouseLeave=function(){return t.paper.project.view.element.style.setProperty("cursor",null)};var n=i.interiorPoint,a=0,r=0,o=0;i.children.forEach(function(e){e.segments.forEach(function(e){a+=e.point.x,r+=e.point.y,o++})}),o>0&&(n=new paper.Point(a/o,r/o));var s=new this.paper.Path.Circle(n,this.shapeImagePlaceholderIconFillerSize);s.fillColor="#ededed",s.data.isShapePlaceholderIcon=!0,s.data.shapeGuid=e.data.guid,s.onMouseEnter=function(){return t.paper.project.view.element.style.setProperty("cursor","pointer")},s.onMouseLeave=function(){return t.paper.project.view.element.style.setProperty("cursor",null)},s.onMouseUp=function(){return t.fireFillShapeRequestedEvent({itemGuid:e.data.guid})};var l=new this.paper.CompoundPath(this.shapeImagePlaceholderIconPathd),h=i.bounds.width/l.bounds.width>6?2:1;l.data.isShapePlaceholderIcon=!0,l.data.shapeGuid=e.data.guid,l.fillColor="#222222";var d=this.paper.view.zoom>.25?this.paper.view.zoom:1.5*this.paper.view.zoom;l.scaling=new this.paper.Size(h/d,h/d),l.onMouseEnter=function(){return t.paper.project.view.element.style.setProperty("cursor","pointer")},l.onMouseLeave=function(){return t.paper.project.view.element.style.setProperty("cursor",null)},l.onMouseUp=function(){return t.fireFillShapeRequestedEvent({itemGuid:e.data.guid})},l.position=n,i.insertAbove(e),l.insertAbove(i),s.insertAbove(i)}},removeShapeImagePlaceholder:function(e){this.getShapeImagePlaceholderElements(e).forEach(function(e){return e.remove()})},getShapeImagePlaceholderElements:function(e){var t=[];if(e&&e.data&&e.data.guid)for(var i=function(n){if(n.data&&(n.data.isShapePlaceholderPath||n.data.isShapePlaceholderIcon)&&n.data.shapeGuid==e.data.guid&&t.push(n),n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];i(r)}},n=0;n<this.paper.project.layers.length;n++){var a=this.paper.project.layers[n];a.guide||i(a)}return t},isShape:function(e){return e&&e.data&&e.data.isShape},getShapeItemStyle:function(e){var t=void 0;if(!e)return t;var i=this.isShape(e)?e:this.getMaskedImageShapeItem(e);return i&&(t={},e.strokeColor&&(t.strokeColor=i.strokeColor.toCSS(!0)),t.strokeWidth=i.strokeWidth,t.strokeCap=i.strokeCap,t.strokeJoin=i.strokeJoin,t.dashArray=i.dashArray,t.dashOffset=i.dashOffset,i.fillColor&&(t.fillColor=i.fillColor.toCSS(!0)),i.data.hasOwnProperty("originalStrokeColor")&&(t.strokeColor=i.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(t.fillColor=i.data.originalFillColor)),t},isFilledShape:function(e){return this.isMaskedImage(e)&&e.data&&e.data.isFilledShape},isImagePlaceholder:function(e){return this.isShape(e)&&!this.isFilledShape(e)&&e.data&&e.data.isImagePlaceholder},fillShapeItemWithImageAsync:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a;return __generator(this,function(r){switch(r.label){case 0:return this.canEditItem(e)&&(this.isShape(e)||this.isFilledShape(e))?(this.isImagePlaceholder(e)&&this.changeShapeImagePlaceholder(e,!1),n=this.getLastUndoOperationId(),this.beginDesignOperation(),a=e,t?[3,1]:(a=this.removeImageFromShape(e),[3,5])):[2,e];case 1:return this.isFilledShape(e)?[4,this.updateFilledShapeAsync(e,t,i)]:[3,3];case 2:return a=r.sent(),[3,5];case 3:return this.isShape(e)?[4,this.createFilledShapeAsync(e,t,i)]:[3,5];case 4:a=r.sent(),r.label=5;case 5:return this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n),[2,a]}})})},createFilledShapeAsync:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S;return __generator(this,function(b){switch(b.label){case 0:return this.isShape(e)&&(t&&t instanceof MPlaza.Image&&(e.data&&e.data.isImagePlaceholder||this.canFillShape(e)))?(n="",!this.isImageScalingEnabled&&"svg"!=t.get("format").toLowerCase()&&"vector"!=t.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(e){return e==t.get("format").toLowerCase()})&&(n=t.get("url")),n||(n=t.get("previewUrl")),n?e&&e instanceof this.paper.CompoundPath&&e.data&&e.data.isShape&&(a=this.findDesignItemForItem(e))?(r=this.getDesignEffectForDesignItem(a),o=this.isItemSelected(e),e.parent,s=n,[4,this.applyDesignEffectToImageUrl(r,n)]):[3,7]:[2,e]):[2,e];case 1:return n=b.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(n,e)];case 2:i=b.sent(),b.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(n,i)]:[3,5];case 4:n=b.sent(),b.label=5;case 5:return[4,this.createRasterItem(n,!1)];case 6:return(l=b.sent()).data.originalUrl=s,this.applyDesignEffectToItem(r,l),h=e.bounds.clone(),d=new this.paper.Matrix,c=e.position,e.data.originalBounds&&e.data.originalMatrix&&e.data.originalPosition&&(u=e.clone(),g=u.position.clone(),u.rotate(-e.data.originalMatrix.rotation,g),f=u.bounds,h=f.clone(),u.remove(),(p=new this.paper.Path.Rectangle(f)).rotate(e.data.originalMatrix.rotation,g),c=p.position,p.remove(),d.rotate(e.data.originalMatrix.rotation),e.data.flips&&e.data.flips.forEach(function(e){return"X"==e?d.scale(-1,-1):d.scale(1,-1)})),m=1,v=1,h.width>1e-7&&l.bounds.width>0&&(m=h.width/l.bounds.width),h.height>1e-7&&l.bounds.height>0&&(v=h.height/l.bounds.height),m=v=Math.max(Math.abs(m),Math.abs(v)),l.scale(m,v),l.matrix.prepend(d),l.position=c,l.data.originalBounds=new this.paper.Rectangle(0,0,l.width,l.height),l.data.originalMatrix=l.matrix.clone(),e.fillColor=null,e.originalParentMatrix=new this.paper.Matrix,e.data.isMaskedImageShape=!0,(I=e.clone()).data={},I.position=e.position,I.data.isMaskedImageMask=!0,y=null!=e.data.originalStrokeColor?e.data.originalStrokeColor:void 0,y=this.forceColorInFixedPalette(e,y),C=this.applyDesignEffectToTextColor(r,y),e.strokeColor=C,e.data.originalStrokeColor=y,(M=new this.paper.Group(I,l)).clipped=!0,M.data.isMaskedImageClipGroup=!0,l.visibile=!0,(x=new this.paper.Group(M)).insertAbove(e),x.addChild(e),x.applyMatrix=!1,x.data.guid=e.data.guid,delete e.data.guid,x.data.isMaskedImageMainGroup=!0,x.data.isFilledShape=!0,x.data.originalBounds=e.bounds,x.data.originalMatrix=new this.paper.Matrix,x.data.isNewImageIntoShape=!0,e.data.maskPath&&e.data.maskPath.remove(),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),this.applyDesignEffectToItem(r,x,!0),S=this.createDummyShapeFromDesignItem(a),this.onImageItemUpdated(x,t,S),e.data.selected=!1,x.data.selected=o,this.updateSelectionState(),this.updateShapeImagePlaceholder(x),this.updateItemsIndexes(),this.updateDesignItemColorMappings(a,i),[2,x];case 7:return[2,e]}})})},updateFilledShapeAsync:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v;return __generator(this,function(I){switch(I.label){case 0:return t&&t instanceof MPlaza.Image&&this.isFilledShape(e)?(n=this.getMaskedImageShapeItem(e),a=this.getMaskedImageRasterItem(e),n.data&&n.data.isImagePlaceholder||this.canReplaceShapeFilling(e)?(r="",!this.isImageScalingEnabled&&"svg"!=t.get("format").toLowerCase()&&"vector"!=t.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(e){return e==t.get("format").toLowerCase()})&&(r=t.get("url")),r||(r=t.get("previewUrl")),r?(this.applyTransformationsToMaskImageSubItems(e),(o=this.findDesignItemByGuid(e.data.guid))?o.get("imageID")===t.get("imageID")?[3,7]:a?(s=this.getDesignEffectForDesignItem(o),l=r,[4,this.applyDesignEffectToImageUrl(s,r)]):[3,7]:[3,7]):[2,e]):[2,e]):[2,e];case 1:return r=I.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(r,e)];case 2:i=I.sent(),I.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(r,i)]:[3,5];case 4:r=I.sent(),I.label=5;case 5:return[4,this.changeRasterItem(a,r)];case 6:I.sent(),a.matrix=new this.paper.Matrix,a.data.originalUrl=l,this.applyDesignEffectToItem(s,e),h=e.bounds.clone(),d=new this.paper.Matrix,c=e.position,n.data.originalBounds&&n.data.originalMatrix&&n.data.originalPosition&&(u=n.clone(),g=u.position.clone(),u.rotate(-n.data.originalMatrix.rotation,g),f=u.bounds,h=f.clone(),u.remove(),(p=new this.paper.Path.Rectangle(f)).rotate(n.data.originalMatrix.rotation,g),c=p.position,p.remove(),d.rotate(n.data.originalMatrix.rotation),n.data.flips&&n.data.flips.forEach(function(e){return"X"==e?d.scale(-1,-1):d.scale(1,-1)})),m=1,v=1,h.width>1e-7&&a.bounds.width>0&&(m=h.width/a.bounds.width),h.height>1e-7&&a.bounds.height>0&&(v=h.height/a.bounds.height),m=v=Math.max(Math.abs(m),Math.abs(v)),a.scale(m,v),a.matrix.prepend(d),a.position=c,a.data.originalBounds=new this.paper.Rectangle(0,0,a.width,a.height),a.data.originalMatrix=a.matrix.clone(),this.onImageItemUpdated(e,t,this.createDummyShapeFromDesignItem(o)),this.updateDesignItemColorMappings(o,i),e.data.isNewImageIntoShape=!0,this.updateSelectionState(),this.paper.project.view.update(),this.fireImageLoadedEvent(),I.label=7;case 7:return[2,e]}})})},removeImageFromShape:function(e,t){var i=e;if(e&&this.isFilledShape(e)){var n=this.isItemSelected(e),a=e.parent,r=this.findDesignItemForItem(e),o=this.getMaskedImageShapeItem(e);if(!(o.data&&o.data.isImagePlaceholder||this.canDeleteShapeFilling(e)))return e;if(r&&o){var s=this.getDesignEffectForDesignItem(r),l=e.matrix;(i=o).data.guid=e.data.guid,a.addChild(i),e.remove();var h=o.data.originalStrokeColor||o.strokeColor,d=o.data.originalFillColor||o.fillColor;h=this.forceColorInFixedPalette(e,h),d=this.forceColorInFixedPalette(e,d),o.data.originalStrokeColor=h,o.data.originalFillColor=d,h=this.applyDesignEffectToTextColor(s,h),d=this.applyDesignEffectToTextColor(s,d),i.strokeColor=h,i.fillColor=d,i.data.isMaskedImageShape=!1,this.applyDesignEffectToItem(s,o),i.matrix.prepend(l),i.data.originalMatrix&&i.data.originalMatrix.prepend(l);var c=this.createDummyShapeFromDesignItem(r);this.onShapeItemUpdated(i,c,null),this.updateItemsIndexes(),this.updateDesignItemColorMappings(r,[]),n&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element&&(this.maskedImageSelectionMode=MaskedImageSelectionMode.Element),e.data.selected=!1,i.data.selected=n,this.updateSelectionState(),this.changeShapeImagePlaceholder(i,!0),this.updateShapeDesignItem(i,r,c,null)}}return i},changeShapeImagePlaceholder:function(e,t){t?this.setImagePlaceholder(e):this.unsetImagePlaceholder(e)},setImagePlaceholder:function(e){if(this.isShape(e)||this.isFilledShape(e)){var t=this.findDesignItemForItem(e);if(t){var i=this.getLastUndoOperationId();this.beginDesignOperation();var n=this.isShape(e)?e:this.removeImageFromShape(e);if(n){n.data.isImagePlaceholder=!0;var a=this.createDummyImageFromDesignItem(t),r=this.createDummyShapeFromDesignItem(t);this.onShapeItemUpdated(e,r,a),this.updateSelectionState(),this.paper.project.view.update()}this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(i)}}},unsetImagePlaceholder:function(e){if(this.isShape(e)&&e.data.isImagePlaceholder){var t=this.findDesignItemForItem(e);if(t){this.beginDesignOperation(),e.data.isImagePlaceholder=!1;var i=this.createDummyImageFromDesignItem(t),n=this.createDummyShapeFromDesignItem(t);this.onShapeItemUpdated(e,n,i),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}}},getItemIsShape:function(e){return this.isFilledShape(e)||this.isShape(e)},getOffsetDistance:function(e){return e&&e instanceof paper.Point?Math.round(e.length):0},getOffsetAngle:function(e){if(e&&e instanceof paper.Point){var t=e.angle;return t<0&&(t+=360),t=Math.round(t)}return 0},getOffsetByDistanceAngle:function(e,t){return null==e||null==t?new this.paper.Point(0,0):new this.paper.Point({length:e,angle:t})},updateTemplateItem:function(e){var t=JSON.parse(e.get("json"));if(t[1].data.isTemplateElement=!0,t[1].data.isTextArea&&t[1].data.text&&(t[1].data.defaultPlaceHolderText=t[1].data.text),t[1].data.isTextArt){var i=e.get("textArt");t[1].data.defaultPlaceHolderText=i.attributes.text}e.set("json",JSON.stringify(t))},applyDescToDesignAsync:function(e){return __awaiter(this,void 0,void 0,function(){var t,i,n,a,r=this;return __generator(this,function(o){switch(o.label){case 0:if(!this.design||!this.design.get("elementsDescs"))return[3,5];if(!(t=this.design.get("elementsDescs").getDescById(e)))return[3,5];i=this.getSelectedItems(),n=0,o.label=1;case 1:return n<t.get("elements").length?(a=t.get("elements").at(n),[4,this.applyDesignElementToDesignAsync(a)]):[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:this.deselectAll(),i.forEach(function(e){return r.setItemSelection(e,!0)}),o.label=5;case 5:return[2]}})})},applyDesignElementToDesignAsync:function(e){return __awaiter(this,void 0,void 0,function(){var t,i,n,a,r;return __generator(this,function(o){switch(o.label){case 0:if(!(e&&e instanceof MPlaza.DesignElement))return[3,4];t=e.get("tag"),i=this.findItemsByTag(t),n=0,a=i,o.label=1;case 1:return n<a.length?(r=a[n],[4,this.applyDesignElementToItemAsync(e,r)]):[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:return[2]}})})},applyDesignElementToItemAsync:function(e,t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(i){switch(i.label){case 0:return this.saveItemInitialInfo(t),this.getItemIsTextElement(t)?[4,this.applyDesignElementToTextItemAsync(e,t)]:[3,2];case 1:return i.sent(),[3,8];case 2:return this.getItemIsTextArt(t)?[4,this.applyDesignElementToTextArtItemAsync(e,t)]:[3,4];case 3:return i.sent(),[3,8];case 4:return this.getItemIsImage(t)?[4,this.applyDesignElementToImageItemAsync(e,t)]:[3,6];case 5:return i.sent(),[3,8];case 6:return this.getItemIsShape(t)?[4,this.applyDesignElementToShapeItemAsync(e,t)]:[3,8];case 7:i.sent(),i.label=8;case 8:return[2]}})})},applyDesignElementToTextItemAsync:function(e,t){var i=this.fromDesignElementToTextItemInfo(e);return i&&this.modifyTextElement(t,i,!1),Promise.resolve()},fromDesignElementToTextItemInfo:function(e){var t=null;if(e&&e.get("text")){for(var i in t=e.get("text").toJSON())null!==t[i]&&void 0!==t[i]||delete t[i];t.text=t.content,delete t.content}return t},applyDesignElementToTextArtItemAsync:function(e,t){return Promise.resolve()},applyDesignElementToImageItemAsync:function(e,t){return Promise.resolve()},applyDesignElementToShapeItemAsync:function(e,t){return Promise.resolve()},saveItemInitialInfo:function(e){if(e&&e.data&&e.data.guid&&!this.initialItemsInfo.hasOwnProperty(e.data.guid)){var t=null;this.getItemIsTextElement(e)?t=this.getTextItemInfo(e):this.getItemIsTextArt(e)?t=this.getTextArtItemInfo(e):this.getItemIsImage(e)?t=this.getImageItemInfo(e):this.getShapeItemInfo(e)&&(t=this.getShapeItemInfo(e)),this.initialItemsInfo[e.data.guid]=t}},resetItemsInitialStateAsync:function(){return __awaiter(this,void 0,void 0,function(){var e,t,i,n,a,r;return __generator(this,function(o){switch(o.label){case 0:if(!this.initialItemsInfo)return[3,4];for(i in e=this.initialItemsInfo,t=[],e)t.push(i);n=0,o.label=1;case 1:return n<t.length?(i=t[n])in e?(a=i,r=this.findItemByGuid(a),[4,this.resetSingleItemInitialStateAsync(r)]):[3,3]:[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:return[2]}})})},resetSingleItemInitialStateAsync:function(e){if(e&&e.data&&e.data.guid){var t=null;this.initialItemsInfo.hasOwnProperty(e.data.guid)&&(t=this.initialItemsInfo[e.data.guid],this.getItemIsTextElement(e)?this.modifyTextElement(e,t,!1):this.getItemIsTextArt(e)||this.getItemIsImage(e)||this.getItemIsShape(e))}return Promise.resolve()},findItemsByTag:function(e){var t=[];if(this.design)for(var i=0,n=this.design.getDesignItemsByTag(e);i<n.length;i++){var a=n[i],r=this.findItemForDesignItem(a);r&&t.push(r)}return t},getBackgroundColorForArea:function(e){var t=this,i=null;return this.design.get("designItems").forEach(function(n){var a,r=JSON.parse(n.get("json"));r.length>1&&r[1].data&&r[1].data.isAreaForBackground&&r[1].fillColor&&e.get("guid")===r[1].data.areaGuid&&(i=(new((a=t.paper.Color).bind.apply(a,__spreadArray(__spreadArray([void 0],r[1].fillColor,!1),[0],!1)))).toCSS(!0))}),i},updateResizableProductSideImage:function(e,t,i,n){if(this.showSideImage){this.imageItem&&(this.imageItem.remove(),this.imageItem=null),this.resizableSideImageItem&&(this.resizableSideImageItem.remove(),this.resizableSideImageItem=null),this.resizableMeasuresItem&&(this.resizableMeasuresItem.remove(),this.resizableMeasuresItem=null),this.resizableSplitColumnsItem&&(this.resizableSplitColumnsItem.remove(),this.resizableSplitColumnsItem=null);var a=this.productImageGenerator.generateImage({width:e,height:t,scale:1/this.paper.view.zoom,shape:{borderColor:"#DDDDDD",borderRadius:0,fillColor:"#FFFFFF",shadowColor:"#00000055",shadowBlur:5,shadowOffset:{x:0,y:10}},splitColumns:{columns:i,rows:n,lineColor:"#CCC",lineWidth:1,lineDashArray:[10,10],marginHorizontal:0,marginVertical:0},measures:{lineColor:"#D2D5D8",lineWidth:1,lineDashArray:[4,4],widthDistance:10,heightDistance:10,widthLabel:Math.round(e/this.side.get("ppcm")/("cm"===this.unitOfMeasurement?1:2.54)*100)/100+this.unitOfMeasurement,heightLabel:Math.round(t/this.side.get("ppcm")/("cm"===this.unitOfMeasurement?1:2.54)*100)/100+this.unitOfMeasurement,labelFontSize:12,labelColor:"#8FA4AE",fontFamily:"Inter",fontWeight:"400",totalSizeLabel:"Total design size "}}),r=a.shape,o=a.splitColumns,s=a.measures;this.resizableSideImageItem=this.imageLayer.importJSON(r.json),this.resizableMeasuresItem=this.imageLayer.importJSON(s.json),this.resizableSplitColumnsItem=this.imageLayer.importJSON(o.json),this.hideAreaLabelResizableMode(),this.paper.project.view.update()}},setResizableProductSize:function(e,t,i,n,a){if(this.side&&this.masterGroup){this.paper.activate();this.side.get("ppcm");var r=this.side.get("areas").at(0),o=this.findItemForArea(r),s=this.masterGroup.children.find(function(e){return e.data&&e.data.isClippingArea});if(o&&s){var l=this.productAreaGenerator.generateArea({width:e,height:t,borderRadius:i}),h=this.paper.project.importJSON(l.json);h.remove();var d=__assign({},o.style),c=__assign({},o.data),u=__assign({},s.data);o instanceof this.paper.Path?o.copyContent(h):o instanceof this.paper.CompoundPath&&o.children[0].copyContent(h),s.children[0].copyContent(h),s.removeChildren(1),o.style=d,o.data=c,s.data=u,this.updateResizableProductSideImage(e,t,n,a)}}},restoreResizable:function(){var e,t,i,n;return __awaiter(this,void 0,void 0,function(){var a,r,o=this;return __generator(this,function(s){return(a=null===(e=this.side)||void 0===e?void 0:e.getColorID())&&(r=null===(t=this.design.get("options"))||void 0===t?void 0:t.find(function(e){return e.get("colorID")==a&&(e.get("sideID")==o.side.get("sideID")||null==e.get("sideID"))}))&&r.get("width")&&r.get("height")&&this.setResizableProductSize(r.get("width"),r.get("height"),0,null!==(i=r.get("columns"))&&void 0!==i?i:1,null!==(n=r.get("rows"))&&void 0!==n?n:1),[2]})})},isAreaForBackground:function(e){return e&&e.data&&e.data.isAreaForBackground}};var Zakeke;__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var a in t=arguments[i])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(a,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}l((n=n.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var i,n,a,r,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(o=0)),o;)try{if(i=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},__spreadArray=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,a=0,r=t.length;a<r;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){!function(e){var t=function(){function e(e){this.isRotating=!1,this.defaultRotationOptions={animation:!0,rotationButtonPressed:!1},this.isExecutionDesignOperation=!1,this.onRotationComplete=null,this.customizer=e}return Object.defineProperty(e.prototype,"paper",{get:function(){return this.customizer.paper},enumerable:!1,configurable:!0}),e.prototype.onRotateAreasAndImage=function(e,t,i){if(!this.isRotating){this.onRotationComplete=i,this.isRotating=!0;var n=this.getAreasAndImageRotationOptions(t);this.onRotate(e,n,t.rotationButtonPressed)}},e.prototype.getAreasAndImageRotationOptions=function(e){var t,i=[],n=this.customizer.imageLayer.children[0],a=new paper.Point(0,0);n&&(i.push(n),a=null!==(t=null==n?void 0:n.position)&&void 0!==t?t:new paper.Point(0,0));var r=this.getAreasItem();return i.push.apply(i,r),i.forEach(function(e){e.applyMatrix=!1}),__assign(__assign({},e),{rotationCenter:a,itemsToRotate:i})},e.prototype.onRotateAreas=function(e,t){if(void 0===t&&(t=this.defaultRotationOptions),!this.isRotating){this.isRotating=!0;var i=this.getAreasRotationOptions(t);this.onRotate(e,i,t.rotationButtonPressed)}},e.prototype.getAreasRotationOptions=function(e){var t,i=this.customizer.imageLayer.children[0],n=null!==(t=null==i?void 0:i.position)&&void 0!==t?t:new paper.Point(0,0),a=this.getAreasItem();return a.forEach(function(e){e.applyMatrix=!1}),__assign(__assign({},e),{rotationCenter:n,itemsToRotate:a})},e.prototype.getAreasItem=function(){var e=this.getClipAreas(),t=this.getLayersArea(),i=this.customizer.getAllAreaItems();return __spreadArray(__spreadArray(__spreadArray([],e,!0),t,!0),i,!0)},e.prototype.getClipAreas=function(){return this.customizer.getAreaLayerPaths(this.customizer.itemsLayer).filter(function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.isClippingArea})},e.prototype.getLayersArea=function(){var e,t=[];return(null===(e=this.customizer.areaLayersPaperLayer)||void 0===e?void 0:e.children)&&(t=this.customizer.areaLayersPaperLayer.children.filter(function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.isAreaLayer})),t},e.prototype.onRotate=function(e,t,i){var n=t.animation,a=t.rotationCenter,r=t.itemsToRotate,o=this.customizer.getCanvasRotation(),s=0;o&&(s=o.degrees);var l=s;if(i&&(l=(s+e)%360),n){var h={itemsToRotate:r,degrees:e,rotationCenter:a,finalDegrees:l};this.onRotationFrame(h)}else{for(var d=0,c=r;d<c.length;d++){var u=c[d],g=null!=a?a:new paper.Point(0,0);u.rotate(e,g)}this.endRotation(l,r)}},e.prototype.onRotationFrame=function(e){var t,i=this,n=e.degrees,a=e.itemsToRotate,r=null!==(t=null==e?void 0:e.rotationCenter)&&void 0!==t?t:new paper.Point(0,0),o=0,s=!1,l=n/20;this.customizer.paper.view.onFrame=function(t){for(var h=0,d=a;h<d.length;h++){var c=d[h];if(Math.abs(o+l)<=Math.abs(n))c.rotate(l,r);else{var u=n-o;Math.abs(u)>0&&c.rotate(u,r),s=!0}}s&&(i.endRotation(e.finalDegrees,a),i.customizer.paper.view.onFrame=null),i.customizer.updateSelectionState(),o+=l}},e.prototype.endRotation=function(e,t){var i;return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){return t.forEach(function(e){e.applyMatrix=!0}),this.saveRotation(e),this.isExecutionDesignOperation||null===(i=this.onRotationComplete)||void 0===i||i.call(this),this.customizer.paper.project.view.update(),this.isRotating=!1,this.isExecutionDesignOperation=!1,[2]})})},e.prototype.saveRotation=function(e){var t=this.createRotationObj(Math.round(e)),i=this.customizer.side.getSideID();this.customizer.design.get("canvasRotation")||this.customizer.design.set("canvasRotation",[]);var n=this.customizer.design.get("canvasRotation");if(n){var a=n.findIndex(function(e){return e.sideID==i});a>-1?n[a]=t:n.push(t)}},e.prototype.createRotationObj=function(e){var t=e;e<0&&(t=360+e);var i={};return i.sideID=this.customizer.side.getSideID(),i.degrees=t,i},e.prototype.setDefaultRotation=function(){var e=this.customizer.imageLayer.children[0];if(e){var t=-1*e.rotation;-0===t&&0===t||this.onRotate(t,{animation:!1,rotationCenter:e.position,itemsToRotate:[]},!1)}this.saveRotation(0)},e.prototype.getRadians=function(e){return e*(Math.PI/180)},e.prototype.undoRotation=function(e){this.isExecutionDesignOperation=!0,this.onRotateAreasAndImage(-1*e,this.defaultRotationOptions,null)},e.prototype.redoRotation=function(e){this.isExecutionDesignOperation=!0,this.onRotateAreasAndImage(e,this.defaultRotationOptions,null)},e}();e.EventsToolsCustomizer=t}(e.Customizer||(e.Customizer={}))}(Zakeke||(Zakeke={}));
|
|
1
|
+
function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach(function(t){_defineProperty(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function _defineProperty(e,t,i){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==typeof t?t:String(t)}function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}!function(){"use strict";var e=function(t){if(!(this instanceof e))return new e(t);if(this.version=1,this.support=!("undefined"==typeof File||"undefined"==typeof Blob||"undefined"==typeof FileList||!Blob.prototype.webkitSlice&&!Blob.prototype.mozSlice&&!Blob.prototype.slice),!this.support)return!1;var i=this;i.files=[],i.defaults={chunkSize:1048576,forceChunkSize:!1,simultaneousUploads:3,fileParameterName:"file",chunkNumberParameterName:"resumableChunkNumber",chunkSizeParameterName:"resumableChunkSize",currentChunkSizeParameterName:"resumableCurrentChunkSize",totalSizeParameterName:"resumableTotalSize",typeParameterName:"resumableType",identifierParameterName:"resumableIdentifier",fileNameParameterName:"resumableFilename",relativePathParameterName:"resumableRelativePath",totalChunksParameterName:"resumableTotalChunks",dragOverClass:"dragover",throttleProgressCallbacks:.5,query:{},headers:{},preprocess:null,preprocessFile:null,method:"multipart",uploadMethod:"POST",testMethod:"GET",prioritizeFirstAndLastChunk:!1,target:"/",testTarget:null,parameterNamespace:"",testChunks:!0,generateUniqueIdentifier:null,getTarget:null,maxChunkRetries:100,chunkRetryInterval:void 0,permanentErrors:[400,401,403,404,409,415,500,501],maxFiles:void 0,withCredentials:!1,xhrTimeout:0,clearInput:!0,chunkFormat:"blob",setChunkTypeFromFile:!1,maxFilesErrorCallback:function(e,t){var n=i.getOpt("maxFiles");alert("Please upload no more than "+n+" file"+(1===n?"":"s")+" at a time.")},minFileSize:1,minFileSizeErrorCallback:function(e,t){alert(e.fileName||e.name+"is too small, please upload files larger than "+n.formatSize(i.getOpt("minFileSize"))+".File size:"+e.size+" - File type:"+e.type+" - File object type:"+typeof e)},maxFileSize:void 0,maxFileSizeErrorCallback:function(e,t){alert(e.fileName||e.name+" is too large, please upload files less than "+n.formatSize(i.getOpt("maxFileSize"))+".")},fileType:[],fileTypeErrorCallback:function(e,t){alert(e.fileName||e.name+" has type not allowed, please upload files of type "+i.getOpt("fileType")+".")}},i.opts=t||{},i.getOpt=function(t){var i=this;if(t instanceof Array){var a={};return n.each(t,function(e){a[e]=i.getOpt(e)}),a}if(i instanceof u){if(void 0!==i.opts[t])return i.opts[t];i=i.fileObj}if(i instanceof c){if(void 0!==i.opts[t])return i.opts[t];i=i.resumableObj}if(i instanceof e)return void 0!==i.opts[t]?i.opts[t]:i.defaults[t]},i.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var i=0;i<e.length;i++)if(e[i]===t)return i;return-1},i.events=[],i.on=function(e,t){i.events.push(e.toLowerCase(),t)},i.fire=function(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);var n=e[0].toLowerCase();for(t=0;t<=i.events.length;t+=2)i.events[t]==n&&i.events[t+1].apply(i,e.slice(1)),"catchall"==i.events[t]&&i.events[t+1].apply(null,e);"fileerror"==n&&i.fire("error",e[2],e[1]),"fileprogress"==n&&i.fire("progress")};var n={stopEvent:function(e){e.stopPropagation(),e.preventDefault()},each:function(e,t){if(void 0!==e.length){for(var i=0;i<e.length;i++)if(!1===t(e[i]))return}else for(i in e)if(!1===t(i,e[i]))return},generateUniqueIdentifier:function(e,t){var n=i.getOpt("generateUniqueIdentifier");if("function"==typeof n)return n(e,t);var a=e.webkitRelativePath||e.relativePath||e.fileName||e.name;return e.size+"-"+a.replace(/[^0-9a-zA-Z_-]/gim,"")},contains:function(e,t){var i=!1;return n.each(e,function(e){return e!=t||(i=!0,!1)}),i},formatSize:function(e){return e<1024?e+" bytes":e<1048576?(e/1024).toFixed(0)+" KB":e<1073741824?(e/1024/1024).toFixed(1)+" MB":(e/1024/1024/1024).toFixed(1)+" GB"},getTarget:function(e,t){var n=i.getOpt("target");if("test"===e&&i.getOpt("testTarget")&&(n="/"===i.getOpt("testTarget")?i.getOpt("target"):i.getOpt("testTarget")),"function"==typeof n)return n(t);var a=n.indexOf("?")<0?"?":"&",r=t.join("&");return r&&(n=n+a+r),n}},a=function(e){e.currentTarget.classList.remove(i.getOpt("dragOverClass")),n.stopEvent(e),e.dataTransfer&&e.dataTransfer.items?h(e.dataTransfer.items,e):e.dataTransfer&&e.dataTransfer.files&&h(e.dataTransfer.files,e)},r=function(e){e.currentTarget.classList.remove(i.getOpt("dragOverClass"))},o=function(e){e.preventDefault();var t=e.dataTransfer;i.indexOf(t.types,"Files")>=0?(e.stopPropagation(),t.dropEffect="copy",t.effectAllowed="copy",e.currentTarget.classList.add(i.getOpt("dragOverClass"))):(t.dropEffect="none",t.effectAllowed="none")};function s(e,t,i,n){var a;return e.isFile?e.file(function(e){e.relativePath=t+e.name,i.push(e),n()}):(e.isDirectory?a=e:e instanceof File&&i.push(e),"function"==typeof e.webkitGetAsEntry&&(a=e.webkitGetAsEntry()),a&&a.isDirectory?function(e,t,i,n){var a=e.createReader(),r=[];!function e(){a.readEntries(function(a){if(a.length)return r=r.concat(a),e();l(r.map(function(e){return s.bind(null,e,t,i)}),n)})}()}(a,t+a.name+"/",i,n):("function"==typeof e.getAsFile&&(e=e.getAsFile())instanceof File&&(e.relativePath=t+e.name,i.push(e)),void n()))}function l(e,t){if(!e||0===e.length)return t();e[0](function(){l(e.slice(1),t)})}function h(e,t){if(e.length){i.fire("beforeAdd");var n=[];l(Array.prototype.map.call(e,function(e){var t=e;return"function"==typeof e.webkitGetAsEntry&&(t=e.webkitGetAsEntry()),s.bind(null,t,"",n)}),function(){n.length&&d(n,t)})}}var d=function(e,t){var a=0,r=i.getOpt(["maxFiles","minFileSize","maxFileSize","maxFilesErrorCallback","minFileSizeErrorCallback","maxFileSizeErrorCallback","fileType","fileTypeErrorCallback"]);if(void 0!==r.maxFiles&&r.maxFiles<e.length+i.files.length){if(1!==r.maxFiles||1!==i.files.length||1!==e.length)return r.maxFilesErrorCallback(e,a++),!1;i.removeFile(i.files[0])}var o=[],s=[],l=e.length,h=function(){if(!--l){if(!o.length&&!s.length)return;window.setTimeout(function(){i.fire("filesAdded",o,s)},0)}};n.each(e,function(e){var l=e.name,d=e.type;if(r.fileType.length>0){var u=!1;for(var g in r.fileType){r.fileType[g]=r.fileType[g].replace(/\s/g,"").toLowerCase();var f=(r.fileType[g].match(/^[^.][^/]+$/)?".":"")+r.fileType[g];if(l.substr(-1*f.length).toLowerCase()===f||-1!==f.indexOf("/")&&(-1!==f.indexOf("*")&&d.substr(0,f.indexOf("*"))===f.substr(0,f.indexOf("*"))||d===f)){u=!0;break}}if(!u)return r.fileTypeErrorCallback(e,a++),!0}if(void 0!==r.minFileSize&&e.size<r.minFileSize)return r.minFileSizeErrorCallback(e,a++),!0;if(void 0!==r.maxFileSize&&e.size>r.maxFileSize)return r.maxFileSizeErrorCallback(e,a++),!0;function p(n){i.getFromUniqueIdentifier(n)?s.push(e):function(){e.uniqueIdentifier=n;var a=new c(i,e,n);i.files.push(a),o.push(a),a.container=void 0!==t?t.srcElement:null,window.setTimeout(function(){i.fire("fileAdded",a,t)},0)}(),h()}var m=n.generateUniqueIdentifier(e,t);m&&"function"==typeof m.then?m.then(function(e){p(e)},function(){h()}):p(m)})};function c(e,t,i){var a=this;a.opts={},a.getOpt=e.getOpt,a._prevProgress=0,a.resumableObj=e,a.file=t,a.fileName=t.fileName||t.name,a.size=t.size,a.relativePath=t.relativePath||t.webkitRelativePath||a.fileName,a.uniqueIdentifier=i,a._pause=!1,a.container="",a.preprocessState=0;var r=void 0!==i,o=function(e,t){switch(e){case"progress":a.resumableObj.fire("fileProgress",a,t);break;case"error":a.abort(),r=!0,a.chunks=[],a.resumableObj.fire("fileError",a,t);break;case"success":if(r)return;a.resumableObj.fire("fileProgress",a,t),a.isComplete()&&a.resumableObj.fire("fileSuccess",a,t);break;case"retry":a.resumableObj.fire("fileRetry",a)}};return a.chunks=[],a.abort=function(){var e=0;n.each(a.chunks,function(t){"uploading"==t.status()&&(t.abort(),e++)}),e>0&&a.resumableObj.fire("fileProgress",a)},a.cancel=function(){var e=a.chunks;a.chunks=[],n.each(e,function(e){"uploading"==e.status()&&(e.abort(),a.resumableObj.uploadNextChunk())}),a.resumableObj.removeFile(a),a.resumableObj.fire("fileProgress",a)},a.retry=function(){a.bootstrap();var e=!1;a.resumableObj.on("chunkingComplete",function(){e||a.resumableObj.upload(),e=!0})},a.bootstrap=function(){a.abort(),r=!1,a.chunks=[],a._prevProgress=0;for(var e=a.getOpt("forceChunkSize")?Math.ceil:Math.floor,t=Math.max(e(a.file.size/a.getOpt("chunkSize")),1),i=0;i<t;i++)!function(e){window.setTimeout(function(){a.chunks.push(new u(a.resumableObj,a,e,o)),a.resumableObj.fire("chunkingProgress",a,e/t)},0)}(i);window.setTimeout(function(){a.resumableObj.fire("chunkingComplete",a)},0)},a.progress=function(){if(r)return 1;var e=0,t=!1;return n.each(a.chunks,function(i){"error"==i.status()&&(t=!0),e+=i.progress(!0)}),e=t?1:e>.99999?1:e,e=Math.max(a._prevProgress,e),a._prevProgress=e,e},a.isUploading=function(){var e=!1;return n.each(a.chunks,function(t){if("uploading"==t.status())return e=!0,!1}),e},a.isComplete=function(){var e=!1;return 1!==a.preprocessState&&(n.each(a.chunks,function(t){var i=t.status();if("pending"==i||"uploading"==i||1===t.preprocessState)return e=!0,!1}),!e)},a.pause=function(e){a._pause=void 0===e?!a._pause:e},a.isPaused=function(){return a._pause},a.preprocessFinished=function(){a.preprocessState=2,a.upload()},a.upload=function(){var e=!1;if(!1===a.isPaused()){var t=a.getOpt("preprocessFile");if("function"==typeof t)switch(a.preprocessState){case 0:return a.preprocessState=1,t(a),!0;case 1:return!0}n.each(a.chunks,function(t){if("pending"==t.status()&&1!==t.preprocessState)return t.send(),e=!0,!1})}return e},a.markChunksCompleted=function(e){if(a.chunks&&!(a.chunks.length<=e))for(var t=0;t<e;t++)a.chunks[t].markComplete=!0},a.resumableObj.fire("chunkingStart",a),a.bootstrap(),this}function u(e,t,i,a){var r=this;r.opts={},r.getOpt=e.getOpt,r.resumableObj=e,r.fileObj=t,r.fileObjSize=t.size,r.fileObjType=t.file.type,r.offset=i,r.callback=a,r.lastProgressCallback=new Date,r.tested=!1,r.retries=0,r.pendingRetry=!1,r.preprocessState=0,r.markComplete=!1;var o=r.getOpt("chunkSize");return r.loaded=0,r.startByte=r.offset*o,r.endByte=Math.min(r.fileObjSize,(r.offset+1)*o),r.fileObjSize-r.endByte<o&&!r.getOpt("forceChunkSize")&&(r.endByte=r.fileObjSize),r.xhr=null,r.test=function(){r.xhr=new XMLHttpRequest;var e=function(e){r.tested=!0;var t=r.status();"success"==t?(r.callback(t,r.message()),r.resumableObj.uploadNextChunk()):r.send()};r.xhr.addEventListener("load",e,!1),r.xhr.addEventListener("error",e,!1),r.xhr.addEventListener("timeout",e,!1);var t=[],i=r.getOpt("parameterNamespace"),a=r.getOpt("query");"function"==typeof a&&(a=a(r.fileObj,r)),n.each(a,function(e,n){t.push([encodeURIComponent(i+e),encodeURIComponent(n)].join("="))}),t=t.concat([["chunkNumberParameterName",r.offset+1],["chunkSizeParameterName",r.getOpt("chunkSize")],["currentChunkSizeParameterName",r.endByte-r.startByte],["totalSizeParameterName",r.fileObjSize],["typeParameterName",r.fileObjType],["identifierParameterName",r.fileObj.uniqueIdentifier],["fileNameParameterName",r.fileObj.fileName],["relativePathParameterName",r.fileObj.relativePath],["totalChunksParameterName",r.fileObj.chunks.length]].filter(function(e){return r.getOpt(e[0])}).map(function(e){return[i+r.getOpt(e[0]),encodeURIComponent(e[1])].join("=")})),r.xhr.open(r.getOpt("testMethod"),n.getTarget("test",t)),r.xhr.timeout=r.getOpt("xhrTimeout"),r.xhr.withCredentials=r.getOpt("withCredentials");var o=r.getOpt("headers");"function"==typeof o&&(o=o(r.fileObj,r)),n.each(o,function(e,t){r.xhr.setRequestHeader(e,t)}),r.xhr.send(null)},r.preprocessFinished=function(){r.preprocessState=2,r.send()},r.send=function(){var e=r.getOpt("preprocess");if("function"==typeof e)switch(r.preprocessState){case 0:return r.preprocessState=1,void e(r);case 1:return}if(!r.getOpt("testChunks")||r.tested){r.xhr=new XMLHttpRequest,r.xhr.upload.addEventListener("progress",function(e){new Date-r.lastProgressCallback>1e3*r.getOpt("throttleProgressCallbacks")&&(r.callback("progress"),r.lastProgressCallback=new Date),r.loaded=e.loaded||0},!1),r.loaded=0,r.pendingRetry=!1,r.callback("progress");var t=function(e){var t=r.status();if("success"==t||"error"==t)r.callback(t,r.message()),r.resumableObj.uploadNextChunk();else{r.callback("retry",r.message()),r.abort(),r.retries++;var i=r.getOpt("chunkRetryInterval");void 0!==i?(r.pendingRetry=!0,setTimeout(r.send,i)):r.send()}};r.xhr.addEventListener("load",t,!1),r.xhr.addEventListener("error",t,!1),r.xhr.addEventListener("timeout",t,!1);var i=[["chunkNumberParameterName",r.offset+1],["chunkSizeParameterName",r.getOpt("chunkSize")],["currentChunkSizeParameterName",r.endByte-r.startByte],["totalSizeParameterName",r.fileObjSize],["typeParameterName",r.fileObjType],["identifierParameterName",r.fileObj.uniqueIdentifier],["fileNameParameterName",r.fileObj.fileName],["relativePathParameterName",r.fileObj.relativePath],["totalChunksParameterName",r.fileObj.chunks.length]].filter(function(e){return r.getOpt(e[0])}).reduce(function(e,t){return e[r.getOpt(t[0])]=t[1],e},{}),a=r.getOpt("query");"function"==typeof a&&(a=a(r.fileObj,r)),n.each(a,function(e,t){i[e]=t});var o=r.fileObj.file.slice?"slice":r.fileObj.file.mozSlice?"mozSlice":r.fileObj.file.webkitSlice?"webkitSlice":"slice",s=r.fileObj.file[o](r.startByte,r.endByte,r.getOpt("setChunkTypeFromFile")?r.fileObj.file.type:""),l=null,h=[],d=r.getOpt("parameterNamespace");if("octet"===r.getOpt("method"))l=s,n.each(i,function(e,t){h.push([encodeURIComponent(d+e),encodeURIComponent(t)].join("="))});else if(l=new FormData,n.each(i,function(e,t){l.append(d+e,t),h.push([encodeURIComponent(d+e),encodeURIComponent(t)].join("="))}),"blob"==r.getOpt("chunkFormat"))l.append(d+r.getOpt("fileParameterName"),s,r.fileObj.fileName);else if("base64"==r.getOpt("chunkFormat")){var c=new FileReader;c.onload=function(e){l.append(d+r.getOpt("fileParameterName"),c.result),r.xhr.send(l)},c.readAsDataURL(s)}var u=n.getTarget("upload",h),g=r.getOpt("uploadMethod");r.xhr.open(g,u),"octet"===r.getOpt("method")&&r.xhr.setRequestHeader("Content-Type","application/octet-stream"),r.xhr.timeout=r.getOpt("xhrTimeout"),r.xhr.withCredentials=r.getOpt("withCredentials");var f=r.getOpt("headers");"function"==typeof f&&(f=f(r.fileObj,r)),n.each(f,function(e,t){r.xhr.setRequestHeader(e,t)}),"blob"==r.getOpt("chunkFormat")&&r.xhr.send(l)}else r.test()},r.abort=function(){r.xhr&&r.xhr.abort(),r.xhr=null},r.status=function(){return r.pendingRetry?"uploading":r.markComplete?"success":r.xhr?r.xhr.readyState<4?"uploading":200==r.xhr.status||201==r.xhr.status?"success":n.contains(r.getOpt("permanentErrors"),r.xhr.status)||r.retries>=r.getOpt("maxChunkRetries")?"error":(r.abort(),"pending"):"pending"},r.message=function(){return r.xhr?r.xhr.responseText:""},r.progress=function(e){void 0===e&&(e=!1);var t=e?(r.endByte-r.startByte)/r.fileObjSize:1;if(r.pendingRetry)return 0;switch(r.xhr&&r.xhr.status||r.markComplete||(t*=.95),r.status()){case"success":case"error":return 1*t;case"pending":return 0*t;default:return r.loaded/(r.endByte-r.startByte)*t}},this}return i.uploadNextChunk=function(){var e=!1;if(i.getOpt("prioritizeFirstAndLastChunk")&&(n.each(i.files,function(t){return t.chunks.length&&"pending"==t.chunks[0].status()&&0===t.chunks[0].preprocessState?(t.chunks[0].send(),e=!0,!1):t.chunks.length>1&&"pending"==t.chunks[t.chunks.length-1].status()&&0===t.chunks[t.chunks.length-1].preprocessState?(t.chunks[t.chunks.length-1].send(),e=!0,!1):void 0}),e))return!0;if(n.each(i.files,function(t){if(e=t.upload())return!1}),e)return!0;var t=!1;return n.each(i.files,function(e){if(!e.isComplete())return t=!0,!1}),t||i.fire("complete"),!1},i.assignBrowse=function(e,t){void 0===e.length&&(e=[e]),n.each(e,function(e){var n;"INPUT"===e.tagName&&"file"===e.type?n=e:((n=document.createElement("input")).setAttribute("type","file"),n.style.display="none",e.addEventListener("click",function(){n.style.opacity=0,n.style.display="block",n.focus(),n.click(),n.style.display="none"},!1),e.appendChild(n));var a=i.getOpt("maxFiles");void 0===a||1!=a?n.setAttribute("multiple","multiple"):n.removeAttribute("multiple"),t?n.setAttribute("webkitdirectory","webkitdirectory"):n.removeAttribute("webkitdirectory");var r=i.getOpt("fileType");void 0!==r&&r.length>=1?n.setAttribute("accept",r.map(function(e){return(e=e.replace(/\s/g,"").toLowerCase()).match(/^[^.][^/]+$/)&&(e="."+e),e}).join(",")):n.removeAttribute("accept"),n.addEventListener("change",function(e){d(e.target.files,e),i.getOpt("clearInput")&&(e.target.value="")},!1)})},i.assignDrop=function(e){void 0===e.length&&(e=[e]),n.each(e,function(e){e.addEventListener("dragover",o,!1),e.addEventListener("dragenter",o,!1),e.addEventListener("dragleave",r,!1),e.addEventListener("drop",a,!1)})},i.unAssignDrop=function(e){void 0===e.length&&(e=[e]),n.each(e,function(e){e.removeEventListener("dragover",o),e.removeEventListener("dragenter",o),e.removeEventListener("dragleave",r),e.removeEventListener("drop",a)})},i.isUploading=function(){var e=!1;return n.each(i.files,function(t){if(t.isUploading())return e=!0,!1}),e},i.upload=function(){if(!i.isUploading()){i.fire("uploadStart");for(var e=1;e<=i.getOpt("simultaneousUploads");e++)i.uploadNextChunk()}},i.pause=function(){n.each(i.files,function(e){e.abort()}),i.fire("pause")},i.cancel=function(){i.fire("beforeCancel");for(var e=i.files.length-1;e>=0;e--)i.files[e].cancel();i.fire("cancel")},i.progress=function(){var e=0,t=0;return n.each(i.files,function(i){e+=i.progress()*i.size,t+=i.size}),t>0?e/t:0},i.addFile=function(e,t){d([e],t)},i.addFiles=function(e,t){d(e,t)},i.removeFile=function(e){for(var t=i.files.length-1;t>=0;t--)i.files[t]===e&&i.files.splice(t,1)},i.getFromUniqueIdentifier=function(e){var t=!1;return n.each(i.files,function(i){i.uniqueIdentifier==e&&(t=i)}),t},i.getSize=function(){var e=0;return n.each(i.files,function(t){e+=t.size}),e},i.handleDropEvent=function(e){a(e)},i.handleChangeEvent=function(e){d(e.target.files,e),e.target.value=""},i.updateQuery=function(e){i.opts.query=e},this};"undefined"!=typeof module?(module.exports=e,module.exports.Resumable=e):"function"==typeof define&&define.amd?define(function(){return e}):window.Resumable=e}(),function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e:e(jQuery)}(function(e){var t,i,n=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],a="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],r=Array.prototype.slice;if(e.event.fixHooks)for(var o=n.length;o;)e.event.fixHooks[n[--o]]=e.event.mouseHooks;var s=e.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var t=a.length;t;)this.addEventListener(a[--t],l,!1);else this.onmousewheel=l;e.data(this,"mousewheel-line-height",s.getLineHeight(this)),e.data(this,"mousewheel-page-height",s.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var t=a.length;t;)this.removeEventListener(a[--t],l,!1);else this.onmousewheel=null;e.removeData(this,"mousewheel-line-height"),e.removeData(this,"mousewheel-page-height")},getLineHeight:function(t){var i=e(t),n=i["offsetParent"in e.fn?"offsetParent":"parent"]();return n.length||(n=e("body")),parseInt(n.css("fontSize"),10)||parseInt(i.css("fontSize"),10)||16},getPageHeight:function(t){return e(t).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};function l(n){var a,o=n||window.event,l=r.call(arguments,1),c=0,u=0,g=0,f=0,p=0;if((n=e.event.fix(o)).type="mousewheel","detail"in o&&(g=-1*o.detail),"wheelDelta"in o&&(g=o.wheelDelta),"wheelDeltaY"in o&&(g=o.wheelDeltaY),"wheelDeltaX"in o&&(u=-1*o.wheelDeltaX),"axis"in o&&o.axis===o.HORIZONTAL_AXIS&&(u=-1*g,g=0),c=0===g?u:g,"deltaY"in o&&(c=g=-1*o.deltaY),"deltaX"in o&&(u=o.deltaX,0===g&&(c=-1*u)),0!==g||0!==u){if(1===o.deltaMode){var m=e.data(this,"mousewheel-line-height");c*=m,g*=m,u*=m}else if(2===o.deltaMode){var v=e.data(this,"mousewheel-page-height");c*=v,g*=v,u*=v}if(a=Math.max(Math.abs(g),Math.abs(u)),(!i||a<i)&&(i=a,d(o,a)&&(i/=40)),d(o,a)&&(c/=40,u/=40,g/=40),c=Math[c>=1?"floor":"ceil"](c/i),u=Math[u>=1?"floor":"ceil"](u/i),g=Math[g>=1?"floor":"ceil"](g/i),s.settings.normalizeOffset&&this.getBoundingClientRect){var I=this.getBoundingClientRect();f=n.clientX-I.left,p=n.clientY-I.top}return n.deltaX=u,n.deltaY=g,n.deltaFactor=i,n.offsetX=f,n.offsetY=p,n.deltaMode=0,l.unshift(n,c,u,g),t&&clearTimeout(t),t=setTimeout(h,200),(e.event.dispatch||e.event.handle).apply(this,l)}}function h(){i=null}function d(e,t){return s.settings.adjustOldDeltas&&"mousewheel"===e.type&&t%120==0}e.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})}),function(){function e(e,t,i){return e.call.apply(e.bind,arguments)}function t(e,t,i){if(!e)throw Error();if(2<arguments.length){var n=Array.prototype.slice.call(arguments,2);return function(){var i=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(i,n),e.apply(t,i)}}return function(){return e.apply(t,arguments)}}function i(n,a,r){return(i=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?e:t).apply(null,arguments)}var n=Date.now||function(){return+new Date};function a(e,t){this.a=e,this.o=t||e,this.c=this.o.document}var r=!!window.FontFace;function o(e,t,i,n){if(t=e.c.createElement(t),i)for(var a in i)i.hasOwnProperty(a)&&("style"==a?t.style.cssText=i[a]:t.setAttribute(a,i[a]));return n&&t.appendChild(e.c.createTextNode(n)),t}function s(e,t,i){(e=e.c.getElementsByTagName(t)[0])||(e=document.documentElement),e.insertBefore(i,e.lastChild)}function l(e){e.parentNode&&e.parentNode.removeChild(e)}function h(e,t,i){t=t||[],i=i||[];for(var n=e.className.split(/\s+/),a=0;a<t.length;a+=1){for(var r=!1,o=0;o<n.length;o+=1)if(t[a]===n[o]){r=!0;break}r||n.push(t[a])}for(t=[],a=0;a<n.length;a+=1){for(r=!1,o=0;o<i.length;o+=1)if(n[a]===i[o]){r=!0;break}r||t.push(n[a])}e.className=t.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function d(e,t){for(var i=e.className.split(/\s+/),n=0,a=i.length;n<a;n++)if(i[n]==t)return!0;return!1}function c(e,t,i){function n(){d&&a&&l&&(d(h),d=null)}t=o(e,"link",{rel:"stylesheet",href:t,media:"all"});var a=!1,l=!0,h=null,d=i||null;r?(t.onload=function(){a=!0,n()},t.onerror=function(){a=!0,h=Error("Stylesheet failed to load"),n()}):setTimeout(function(){a=!0,n()},0),s(e,"head",t)}function u(e,t,i,n){var a=e.c.getElementsByTagName("head")[0];if(a){var r=o(e,"script",{src:t}),s=!1;return r.onload=r.onreadystatechange=function(){s||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(s=!0,i&&i(null),r.onload=r.onreadystatechange=null,"HEAD"==r.parentNode.tagName&&a.removeChild(r))},a.appendChild(r),setTimeout(function(){s||(s=!0,i&&i(Error("Script load timeout")))},n||5e3),r}return null}function g(){this.a=0,this.c=null}function f(e){return e.a++,function(){e.a--,m(e)}}function p(e,t){e.c=t,m(e)}function m(e){0==e.a&&e.c&&(e.c(),e.c=null)}function v(e){this.a=e||"-"}function I(e,t){this.c=e,this.f=4,this.a="n";var i=(t||"n4").match(/^([nio])([1-9])$/i);i&&(this.a=i[1],this.f=parseInt(i[2],10))}function y(e){var t=[];e=e.split(/,\s*/);for(var i=0;i<e.length;i++){var n=e[i].replace(/["]/g,"");-1!=n.indexOf(" ")||/^\d/.test(n)?t.push('"'+n+'"'):t.push(n)}return t.join(",")}function C(e){return e.a+e.f}function M(e){var t="normal";return"o"===e.a?t="oblique":"i"===e.a&&(t="italic"),t}function x(e){var t=4,i="n",n=null;return e&&((n=e.match(/(normal|oblique|italic)/i))&&n[1]&&(i=n[1].substr(0,1).toLowerCase()),(n=e.match(/([1-9]00|normal|bold)/i))&&n[1]&&(/bold/i.test(n[1])?t=7:/[1-9]00/.test(n[1])&&(t=parseInt(n[1].substr(0,1),10)))),i+t}function S(e,t){this.c=e,this.f=e.o.document.documentElement,this.h=t,this.a=new v("-"),this.j=!1!==t.events,this.g=!1!==t.classes}function b(e){if(e.g){var t=d(e.f,e.a.c("wf","active")),i=[],n=[e.a.c("wf","loading")];t||i.push(e.a.c("wf","inactive")),h(e.f,i,n)}w(e,"inactive")}function w(e,t,i){e.j&&e.h[t]&&(i?e.h[t](i.c,C(i)):e.h[t]())}function A(){this.c={}}function P(e,t){this.c=e,this.f=t,this.a=o(this.c,"span",{"aria-hidden":"true"},this.f)}function D(e){s(e.c,"body",e.a)}function k(e){return"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+y(e.c)+";font-style:"+M(e)+";font-weight:"+e.f+"00;"}function _(e,t,i,n,a,r){this.g=e,this.j=t,this.a=n,this.c=i,this.f=a||3e3,this.h=r||void 0}function T(e,t,i,n,a,r,o){this.v=e,this.B=t,this.c=i,this.a=n,this.s=o||"BESbswy",this.f={},this.w=a||3e3,this.u=r||null,this.m=this.j=this.h=this.g=null,this.g=new P(this.c,this.s),this.h=new P(this.c,this.s),this.j=new P(this.c,this.s),this.m=new P(this.c,this.s),e=k(e=new I(this.a.c+",serif",C(this.a))),this.g.a.style.cssText=e,e=k(e=new I(this.a.c+",sans-serif",C(this.a))),this.h.a.style.cssText=e,e=k(e=new I("serif",C(this.a))),this.j.a.style.cssText=e,e=k(e=new I("sans-serif",C(this.a))),this.m.a.style.cssText=e,D(this.g),D(this.h),D(this.j),D(this.m)}v.prototype.c=function(e){for(var t=[],i=0;i<arguments.length;i++)t.push(arguments[i].replace(/[\W_]+/g,"").toLowerCase());return t.join(this.a)},_.prototype.start=function(){var e=this.c.o.document,t=this,i=n(),a=new Promise(function(a,r){!function o(){n()-i>=t.f?r():e.fonts.load(function(e){return M(e)+" "+e.f+"00 300px "+y(e.c)}(t.a),t.h).then(function(e){1<=e.length?a():setTimeout(o,25)},function(){r()})}()}),r=null,o=new Promise(function(e,i){r=setTimeout(i,t.f)});Promise.race([o,a]).then(function(){r&&(clearTimeout(r),r=null),t.g(t.a)},function(){t.j(t.a)})};var z={D:"serif",C:"sans-serif"},O=null;function B(){if(null===O){var e=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);O=!!e&&(536>parseInt(e[1],10)||536===parseInt(e[1],10)&&11>=parseInt(e[2],10))}return O}function E(e,t,i){for(var n in z)if(z.hasOwnProperty(n)&&t===e.f[z[n]]&&i===e.f[z[n]])return!0;return!1}function R(e){var t,a=e.g.a.offsetWidth,r=e.h.a.offsetWidth;(t=a===e.f.serif&&r===e.f["sans-serif"])||(t=B()&&E(e,a,r)),t?n()-e.A>=e.w?B()&&E(e,a,r)&&(null===e.u||e.u.hasOwnProperty(e.a.c))?F(e,e.v):F(e,e.B):function(e){setTimeout(i(function(){R(this)},e),50)}(e):F(e,e.v)}function F(e,t){setTimeout(i(function(){l(this.g.a),l(this.h.a),l(this.j.a),l(this.m.a),t(this.a)},e),0)}function L(e,t,i){this.c=e,this.a=t,this.f=0,this.m=this.j=!1,this.s=i}T.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=n(),R(this)};var G=null;function U(e){0==--e.f&&e.j&&(e.m?((e=e.a).g&&h(e.f,[e.a.c("wf","active")],[e.a.c("wf","loading"),e.a.c("wf","inactive")]),w(e,"active")):b(e.a))}function j(e){this.j=e,this.a=new A,this.h=0,this.f=this.g=!0}function N(e,t,n,a,r){var o=0==--e.h;(e.f||e.g)&&setTimeout(function(){var e=r||null,s=a||{};if(0===n.length&&o)b(t.a);else{t.f+=n.length,o&&(t.j=o);var l,d=[];for(l=0;l<n.length;l++){var c=n[l],u=s[c.c],g=t.a,f=c;if(g.g&&h(g.f,[g.a.c("wf",f.c,C(f).toString(),"loading")]),w(g,"fontloading",f),g=null,null===G)if(window.FontFace){f=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent);var p=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);G=f?42<parseInt(f[1],10):!p}else G=!1;g=G?new _(i(t.g,t),i(t.h,t),t.c,c,t.s,u):new T(i(t.g,t),i(t.h,t),t.c,c,t.s,e,u),d.push(g)}for(l=0;l<d.length;l++)d[l].start()}},0)}function W(e,t){this.c=e,this.a=t}function Z(e,t){this.c=e,this.a=t}function H(e,t){this.c=e||V,this.a=[],this.f=[],this.g=t||""}L.prototype.g=function(e){var t=this.a;t.g&&h(t.f,[t.a.c("wf",e.c,C(e).toString(),"active")],[t.a.c("wf",e.c,C(e).toString(),"loading"),t.a.c("wf",e.c,C(e).toString(),"inactive")]),w(t,"fontactive",e),this.m=!0,U(this)},L.prototype.h=function(e){var t=this.a;if(t.g){var i=d(t.f,t.a.c("wf",e.c,C(e).toString(),"active")),n=[],a=[t.a.c("wf",e.c,C(e).toString(),"loading")];i||n.push(t.a.c("wf",e.c,C(e).toString(),"inactive")),h(t.f,n,a)}w(t,"fontinactive",e),U(this)},j.prototype.load=function(e){this.c=new a(this.j,e.context||this.j),this.g=!1!==e.events,this.f=!1!==e.classes,function(e,t,i){var n=[],a=i.timeout;!function(e){e.g&&h(e.f,[e.a.c("wf","loading")]),w(e,"loading")}(t);var n=function(e,t,i){var n,a=[];for(n in t)if(t.hasOwnProperty(n)){var r=e.c[n];r&&a.push(r(t[n],i))}return a}(e.a,i,e.c),r=new L(e.c,t,a);for(e.h=n.length,t=0,i=n.length;t<i;t++)n[t].load(function(t,i,n){N(e,r,t,i,n)})}(this,new S(this.c,e),e)},W.prototype.load=function(e){var t=this,i=t.a.projectId,n=t.a.version;if(i){var a=t.c.o;u(this.c,(t.a.api||"https://fast.fonts.net/jsapi")+"/"+i+".js"+(n?"?v="+n:""),function(n){n?e([]):(a["__MonotypeConfiguration__"+i]=function(){return t.a},function t(){if(a["__mti_fntLst"+i]){var n,r=a["__mti_fntLst"+i](),o=[];if(r)for(var s=0;s<r.length;s++){var l=r[s].fontfamily;null!=r[s].fontStyle&&null!=r[s].fontWeight?(n=r[s].fontStyle+r[s].fontWeight,o.push(new I(l,n))):o.push(new I(l))}e(o)}else setTimeout(function(){t()},50)}())}).id="__MonotypeAPIScript__"+i}else e([])},Z.prototype.load=function(e){var t,i,n=this.a.urls||[],a=this.a.families||[],r=this.a.testStrings||{},o=new g;for(t=0,i=n.length;t<i;t++)c(this.c,n[t],f(o));var s=[];for(t=0,i=a.length;t<i;t++)if((n=a[t].split(":"))[1])for(var l=n[1].split(","),h=0;h<l.length;h+=1)s.push(new I(n[0],l[h]));else s.push(new I(n[0]));p(o,function(){e(s,r)})};var V="https://fonts.googleapis.com/css";function q(e){this.f=e,this.a=[],this.c={}}var J={latin:"BESbswy","latin-ext":"çöüğş",cyrillic:"йяЖ",greek:"αβΣ",khmer:"កខគ",Hanuman:"កខគ"},Q={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},K={i:"i",italic:"i",n:"n",normal:"n"},Y=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;function X(e,t){this.c=e,this.a=t}var $={Arimo:!0,Cousine:!0,Tinos:!0};function ee(e,t){this.c=e,this.a=t}function te(e,t){this.c=e,this.f=t,this.a=[]}X.prototype.load=function(e){var t=new g,i=this.c,n=new H(this.a.api,this.a.text),a=this.a.families;!function(e,t){for(var i=t.length,n=0;n<i;n++){var a=t[n].split(":");3==a.length&&e.f.push(a.pop());var r="";2==a.length&&""!=a[1]&&(r=":"),e.a.push(a.join(r))}}(n,a);var r=new q(a);!function(e){for(var t=e.f.length,i=0;i<t;i++){var n=e.f[i].split(":"),a=n[0].replace(/\+/g," "),r=["n4"];if(2<=n.length){var o;if(o=[],s=n[1])for(var s,l=(s=s.split(",")).length,h=0;h<l;h++){var d;if((d=s[h]).match(/^[\w-]+$/))if(null==(u=Y.exec(d.toLowerCase())))d="";else{if(d=null==(d=u[2])||""==d?"n":K[d],null==(u=u[1])||""==u)u="4";else var c=Q[u],u=c||(isNaN(u)?"4":u.substr(0,1));d=[d,u].join("")}else d="";d&&o.push(d)}0<o.length&&(r=o),3==n.length&&(o=[],0<(n=(n=n[2])?n.split(","):o).length&&(n=J[n[0]])&&(e.c[a]=n))}for(e.c[a]||(n=J[a])&&(e.c[a]=n),n=0;n<r.length;n+=1)e.a.push(new I(a,r[n]))}}(r),c(i,function(e){if(0==e.a.length)throw Error("No fonts to load!");if(-1!=e.c.indexOf("kit="))return e.c;for(var t=e.a.length,i=[],n=0;n<t;n++)i.push(e.a[n].replace(/ /g,"+"));return t=e.c+"?family="+i.join("%7C"),0<e.f.length&&(t+="&subset="+e.f.join(",")),0<e.g.length&&(t+="&text="+encodeURIComponent(e.g)),t}(n),f(t)),p(t,function(){e(r.a,r.c,$)})},ee.prototype.load=function(e){var t=this.a.id,i=this.c.o;t?u(this.c,(this.a.api||"https://use.typekit.net")+"/"+t+".js",function(t){if(t)e([]);else if(i.Typekit&&i.Typekit.config&&i.Typekit.config.fn){t=i.Typekit.config.fn;for(var n=[],a=0;a<t.length;a+=2)for(var r=t[a],o=t[a+1],s=0;s<o.length;s++)n.push(new I(r,o[s]));try{i.Typekit.load({events:!1,classes:!1,async:!0})}catch(e){}e(n)}},2e3):e([])},te.prototype.load=function(e){var t=this.f.id,i=this.c.o,n=this;t?(i.__webfontfontdeckmodule__||(i.__webfontfontdeckmodule__={}),i.__webfontfontdeckmodule__[t]=function(t,i){for(var a=0,r=i.fonts.length;a<r;++a){var o=i.fonts[a];n.a.push(new I(o.name,x("font-weight:"+o.weight+";font-style:"+o.style)))}e(n.a)},u(this.c,(this.f.api||"https://f.fontdeck.com/s/css/js/")+function(e){return e.o.location.hostname||e.a.location.hostname}(this.c)+"/"+t+".js",function(t){t&&e([])})):e([])};var ie=new j(window);ie.a.c.custom=function(e,t){return new Z(t,e)},ie.a.c.fontdeck=function(e,t){return new te(t,e)},ie.a.c.monotype=function(e,t){return new W(t,e)},ie.a.c.typekit=function(e,t){return new ee(t,e)},ie.a.c.google=function(e,t){return new X(t,e)};var ne={load:i(ie.load,ie)};"function"==typeof define&&define.amd?define(function(){return ne}):"undefined"!=typeof module&&module.exports?module.exports=ne:(window.WebFont=ne,window.WebFontConfig&&ie.load(window.WebFontConfig))}(),function(e,t){"object"==typeof exports&&typeof module<"u"?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=typeof globalThis<"u"?globalThis:e||self).ZakekeResizableCanvas={})}(this,function(e){"use strict";var t=Object.defineProperty,i=(e,i,n)=>(((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n),n),n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var a={exports:{}};const r=function(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var i=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),i}(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var o;o=a,function(e,t){var i=(e=e||r).window,n=e.document,a=new function(){var e=/^(statics|enumerable|beans|preserve)$/,i=[],n=i.slice,a=Object.create,r=Object.getOwnPropertyDescriptor,o=Object.defineProperty,s=i.forEach||function(e,t){for(var i=0,n=this.length;i<n;i++)e.call(t,this[i],i,this)},l=Object.assign||function(e){for(var t=1,i=arguments.length;t<i;t++){var n=arguments[t];for(var a in n)n.hasOwnProperty(a)&&(e[a]=n[a])}return e},h=function(e,t,i){if(e){var n=r(e,"length");(n&&"number"==typeof n.value?s:function(e,t){for(var i in this)this.hasOwnProperty(i)&&e.call(t,this[i],i,this)}).call(e,t,i=i||e)}return i};function d(t,i,n,a,s){var l={};function h(e,h){"string"==typeof(h=h||(h=r(i,e))&&(h.get?h:h.value))&&"#"===h[0]&&(h=t[h.substring(1)]||h);var d,u="function"==typeof h,g=h,f=s||u&&!h.base?h&&h.get?e in t:t[e]:null;(!s||!f)&&(u&&f&&(h.base=f),u&&!1!==a&&(d=e.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(l[d[3].toLowerCase()+d[4]]=d[2]),(!g||u||!g.get||"function"!=typeof g.get||!c.isPlainObject(g))&&(g={value:g,writable:!0}),(r(t,e)||{configurable:!0}).configurable&&(g.configurable=!0,g.enumerable=null!=n?n:!d),o(t,e,g))}if(i){for(var d in i)i.hasOwnProperty(d)&&!e.test(d)&&h(d);for(var d in l){var u=l[d],g=t["set"+u],f=t["get"+u]||g&&t["is"+u];f&&(!0===a||0===f.length)&&h(d,{get:f,set:g})}}return t}function c(){for(var e=0,t=arguments.length;e<t;e++){var i=arguments[e];i&&l(this,i)}return this}return d(c,{inject:function(e){if(e){var t=!0===e.statics?e:e.statics,i=e.beans,n=e.preserve;t!==e&&d(this.prototype,e,e.enumerable,i,n),d(this,t,null,i,n)}for(var a=1,r=arguments.length;a<r;a++)this.inject(arguments[a]);return this},extend:function(){for(var e,t,i,n=this,r=0,s=arguments.length;r<s&&(!e||!t);r++)i=arguments[r],e=e||i.initialize,t=t||i.prototype;return t=(e=e||function(){n.apply(this,arguments)}).prototype=t||a(this.prototype),o(t,"constructor",{value:e,writable:!0,configurable:!0}),d(e,this),arguments.length&&this.inject.apply(e,arguments),e.base=n,e}}).inject({enumerable:!1,initialize:c,set:c,inject:function(){for(var e=0,t=arguments.length;e<t;e++){var i=arguments[e];i&&d(this,i,i.enumerable,i.beans,i.preserve)}return this},extend:function(){var e=a(this);return e.inject.apply(e,arguments)},each:function(e,t){return h(this,e,t)},clone:function(){return new this.constructor(this)},statics:{set:l,each:h,create:a,define:o,describe:r,clone:function(e){return l(new e.constructor,e)},isPlainObject:function(e){var t=null!=e&&e.constructor;return t&&(t===Object||t===c||"Object"===t.name)},pick:function(e,i){return e!==t?e:i},slice:function(e,t,i){return n.call(e,t,i)}}})};o.exports=a,a.inject({enumerable:!1,toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+a.each(this,function(e,t){if(!/^_/.test(t)){var i=typeof e;this.push(t+": "+("number"===i?c.instance.number(e):"string"===i?"'"+e+"'":e))}},[]).join(", ")+" }"},getClassName:function(){return this._class||""},importJSON:function(e){return a.importJSON(e,this)},exportJSON:function(e){return a.exportJSON(this,e)},toJSON:function(){return a.serialize(this)},set:function(e,t){return e&&a.filter(this,e,t,this._prioritize),this}},{beans:!1,statics:{exports:{},extend:function e(){var t=e.base.apply(this,arguments),i=t.prototype._class;return i&&!a.exports[i]&&(a.exports[i]=t),t},equals:function(e,t){if(e===t)return!0;if(e&&e.equals)return e.equals(t);if(t&&t.equals)return t.equals(e);if(e&&t&&"object"==typeof e&&"object"==typeof t){if(Array.isArray(e)&&Array.isArray(t)){if((i=e.length)!==t.length)return!1;for(;i--;)if(!a.equals(e[i],t[i]))return!1}else{var i,n=Object.keys(e);if((i=n.length)!==Object.keys(t).length)return!1;for(;i--;){var r=n[i];if(!t.hasOwnProperty(r)||!a.equals(e[r],t[r]))return!1}}return!0}return!1},read:function(e,i,n,r){if(this===a){var o=this.peek(e,i);return e.__index++,o}var s=this.prototype,l=s._readIndex,h=i||l&&e.__index||0,d=e.length,c=e[h];if(r=r||d-h,c instanceof this||n&&n.readNull&&null==c&&r<=1)return l&&(e.__index=h+1),c&&n&&n.clone?c.clone():c;if(c=a.create(s),l&&(c.__read=!0),c=c.initialize.apply(c,h>0||h+r<d?a.slice(e,h,h+r):e)||c,l){e.__index=h+c.__read;var u=c.__filtered;u&&(e.__filtered=u,c.__filtered=t),c.__read=t}return c},peek:function(e,t){return e[e.__index=t||e.__index||0]},remain:function(e){return e.length-(e.__index||0)},readList:function(e,t,i,n){for(var a,r=[],o=t||0,s=n?o+n:e.length,l=o;l<s;l++)r.push(Array.isArray(a=e[l])?this.read(a,0,i):this.read(e,l,i,1));return r},readNamed:function(e,i,n,r,o){var s=this.getNamed(e,i),l=s!==t;if(l){var h=e.__filtered;if(!h){var d=this.getSource(e);(h=e.__filtered=a.create(d)).__unfiltered=d}h[i]=t}return this.read(l?[s]:e,n,r,o)},readSupported:function(e,i){var n=this.getSource(e),a=this,r=!1;return n&&Object.keys(n).forEach(function(n){if(n in i){var o=a.readNamed(e,n);o!==t&&(i[n]=o),r=!0}}),r},getSource:function(e){var i=e.__source;if(i===t){var n=1===e.length&&e[0];i=e.__source=n&&a.isPlainObject(n)?n:null}return i},getNamed:function(e,t){var i=this.getSource(e);if(i)return t?i[t]:e.__filtered||i},hasNamed:function(e,t){return!!this.getNamed(e,t)},filter:function(e,i,n,a){var r;function o(a){if(!(n&&a in n||r&&a in r)){var o=i[a];o!==t&&(e[a]=o)}}if(a){for(var s,l={},h=0,d=a.length;h<d;h++)(s=a[h])in i&&(o(s),l[s]=!0);r=l}return Object.keys(i.__unfiltered||i).forEach(o),e},isPlainValue:function(e,t){return a.isPlainObject(e)||Array.isArray(e)||t&&"string"==typeof e},serialize:function(e,t,i,n){t=t||{};var r,o=!n;if(o&&(t.formatter=new c(t.precision),n={length:0,definitions:{},references:{},add:function(e,t){var i="#"+e._id,n=this.references[i];if(!n){this.length++;var a=t.call(e),r=e._class;r&&a[0]!==r&&a.unshift(r),this.definitions[i]=a,n=this.references[i]=[i]}return n}}),e&&e._serialize){r=e._serialize(t,n);var s=e._class;s&&!e._compactSerialize&&(o||!i)&&r[0]!==s&&r.unshift(s)}else if(Array.isArray(e)){r=[];for(var l=0,h=e.length;l<h;l++)r[l]=a.serialize(e[l],t,i,n)}else if(a.isPlainObject(e)){r={};var d=Object.keys(e);for(l=0,h=d.length;l<h;l++){var u=d[l];r[u]=a.serialize(e[u],t,i,n)}}else r="number"==typeof e?t.formatter.number(e,t.precision):e;return o&&n.length>0?[["dictionary",n.definitions],r]:r},deserialize:function(e,t,i,n,r){var o=e,s=!i,l=s&&e&&e.length&&"dictionary"===e[0][0];if(i=i||{},Array.isArray(e)){var h=e[0],d="dictionary"===h;if(1==e.length&&/^#/.test(h))return i.dictionary[h];o=[];for(var c=(h=a.exports[h])?1:0,u=e.length;c<u;c++)o.push(a.deserialize(e[c],t,i,d,l));if(h){var g=o;o=t?t(h,g,s||r):new h(g)}}else if(a.isPlainObject(e))for(var f in o={},n&&(i.dictionary=o),e)o[f]=a.deserialize(e[f],t,i);return l?o[1]:o},exportJSON:function(e,t){var i=a.serialize(e,t);return t&&0==t.asString?i:JSON.stringify(i)},importJSON:function(e,t){return a.deserialize("string"==typeof e?JSON.parse(e):e,function(e,i,n){var r=n&&t&&t.constructor===e,o=r?t:a.create(e.prototype);if(1===i.length&&o instanceof S&&(r||!(o instanceof w))){var s=i[0];a.isPlainObject(s)&&(s.insert=!1,r&&(i=i.concat([S.INSERT])))}return(r?o.set:e).apply(o,i),r&&(t=null),o})},push:function(e,t){var i=t.length;if(i<4096)e.push.apply(e,t);else{var n=e.length;e.length+=i;for(var a=0;a<i;a++)e[n+a]=t[a]}return e},splice:function(e,i,n,r){var o=i&&i.length,s=n===t;(n=s?e.length:n)>e.length&&(n=e.length);for(var l=0;l<o;l++)i[l]._index=n+l;if(s)return a.push(e,i),[];var h=[n,r];i&&a.push(h,i);for(var d=e.splice.apply(e,h),c=(l=0,d.length);l<c;l++)d[l]._index=t;for(l=n+o,c=e.length;l<c;l++)e[l]._index=l;return d},capitalize:function(e){return e.replace(/\b[a-z]/g,function(e){return e.toUpperCase()})},camelize:function(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})},hyphenate:function(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}}});var s={on:function(e,t){if("string"!=typeof e)a.each(e,function(e,t){this.on(t,e)},this);else{var i=this._eventTypes,n=i&&i[e],r=this._callbacks=this._callbacks||{};-1===(r=r[e]=r[e]||[]).indexOf(t)&&(r.push(t),n&&n.install&&1===r.length&&n.install.call(this,e))}return this},off:function(e,t){if("string"==typeof e){var i,n=this._eventTypes,r=n&&n[e],o=this._callbacks&&this._callbacks[e];return o&&(!t||-1!==(i=o.indexOf(t))&&1===o.length?(r&&r.uninstall&&r.uninstall.call(this,e),delete this._callbacks[e]):-1!==i&&o.splice(i,1)),this}a.each(e,function(e,t){this.off(t,e)},this)},once:function(e,t){return this.on(e,function i(){t.apply(this,arguments),this.off(e,i)})},emit:function(e,t){var i=this._callbacks&&this._callbacks[e];if(!i)return!1;var n=a.slice(arguments,1),r=t&&t.target&&!t.currentTarget;i=i.slice(),r&&(t.currentTarget=this);for(var o=0,s=i.length;o<s;o++)if(0==i[o].apply(this,n)){t&&t.stop&&t.stop();break}return r&&delete t.currentTarget,!0},responds:function(e){return!(!this._callbacks||!this._callbacks[e])},attach:"#on",detach:"#off",fire:"#emit",_installEvents:function(e){var t=this._eventTypes,i=this._callbacks,n=e?"install":"uninstall";if(t)for(var a in i)if(i[a].length>0){var r=t[a],o=r&&r[n];o&&o.call(this,a)}},statics:{inject:function e(t){var i=t._events;if(i){var n={};a.each(i,function(e,i){var r="string"==typeof e,o=r?e:i,s=a.capitalize(o),l=o.substring(2).toLowerCase();n[l]=r?{}:e,o="_"+o,t["get"+s]=function(){return this[o]},t["set"+s]=function(e){var t=this[o];t&&this.off(l,t),e&&this.on(l,e),this[o]=e}}),t._eventTypes=n}return e.base.apply(this,arguments)}}},l=a.extend({_class:"PaperScope",initialize:function t(){le=this,this.settings=new a({applyMatrix:!0,insertItems:!0,handleSize:4,hitTolerance:0}),this.project=null,this.projects=[],this.tools=[],this._id=t._id++,t._scopes[this._id]=this;var i=t.prototype;if(!this.support){var n=ae.getContext(1,1)||{};i.support={nativeDash:"setLineDash"in n||"mozDash"in n,nativeBlendModes:re.nativeModes},ae.release(n)}if(!this.agent){var r=e.navigator.userAgent.toLowerCase(),o=(/(darwin|win|mac|linux|freebsd|sunos)/.exec(r)||[])[0],s="darwin"===o?"mac":o,l=i.agent=i.browser={platform:s};s&&(l[s]=!0),r.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom|node|jsdom)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:v?([.\d]+))?/g,function(e,t,i,n,a){if(!l.chrome){var r="opera"===t?n:/^(node|trident)$/.test(t)?a:i;l.version=r,l.versionNumber=parseFloat(r),t={trident:"msie",jsdom:"node"}[t]||t,l.name=t,l[t]=!0}}),l.chrome&&delete l.webkit,l.atom&&delete l.chrome}},version:"0.12.17",getView:function(){var e=this.project;return e&&e._view},getPaper:function(){return this},execute:function(e,t){var i=le.PaperScript.execute(e,this,t);return J.updateFocus(),i},install:function(e){var t=this;for(var i in a.each(["project","view","tool"],function(i){a.define(e,i,{configurable:!0,get:function(){return t[i]}})}),this)!/^_/.test(i)&&this[i]&&(e[i]=this[i])},setup:function(e){return le=this,this.project=new x(e),this},createCanvas:function(e,t){return ae.getCanvas(e,t)},activate:function(){le=this},clear:function(){for(var e=this.projects,t=this.tools,i=e.length-1;i>=0;i--)e[i].remove();for(i=t.length-1;i>=0;i--)t[i].remove()},remove:function(){this.clear(),delete l._scopes[this._id]},statics:new function(){function e(e){return e+="Attribute",function(t,i){return t[e](i)||t[e]("data-paper-"+i)}}return{_scopes:{},_id:0,get:function(e){return this._scopes[e]||null},getAttribute:e("get"),hasAttribute:e("has")}}}),h=a.extend(s,{initialize:function(e){this._scope=le,this._index=this._scope[this._list].push(this)-1,(e||!this._scope[this._reference])&&this.activate()},activate:function(){if(!this._scope)return!1;var e=this._scope[this._reference];return e&&e!==this&&e.emit("deactivate"),this._scope[this._reference]=this,this.emit("activate",e),!0},isActive:function(){return this._scope[this._reference]===this},remove:function(){return null!=this._index&&(a.splice(this._scope[this._list],null,this._index,1),this._scope[this._reference]==this&&(this._scope[this._reference]=null),this._scope=null,!0)},getView:function(){return this._scope.getView()}}),d={findItemBoundsCollisions:function(e,t,i){function n(e){for(var t=new Array(e.length),i=0;i<e.length;i++){var n=e[i].getBounds();t[i]=[n.left,n.top,n.right,n.bottom]}return t}var a=n(e),r=t&&t!==e?n(t):a;return this.findBoundsCollisions(a,r,i||0)},findCurveBoundsCollisions:function(e,t,i,n){function a(e){for(var t=Math.min,i=Math.max,n=new Array(e.length),a=0;a<e.length;a++){var r=e[a];n[a]=[t(r[0],r[2],r[4],r[6]),t(r[1],r[3],r[5],r[7]),i(r[0],r[2],r[4],r[6]),i(r[1],r[3],r[5],r[7])]}return n}var r=a(e),o=t&&t!==e?a(t):r;if(n){for(var s=this.findBoundsCollisions(r,o,i||0,!1,!0),l=this.findBoundsCollisions(r,o,i||0,!0,!0),h=[],d=0,c=s.length;d<c;d++)h[d]={hor:s[d],ver:l[d]};return h}return this.findBoundsCollisions(r,o,i||0)},findBoundsCollisions:function(e,t,i,n,a){var r=!t||e===t,o=r?e:e.concat(t),s=e.length,l=o.length;function h(e,t,i){for(var n=0,a=e.length;n<a;){var r=a+n>>>1;o[e[r]][t]<i?n=r+1:a=r}return n-1}for(var d=n?1:0,c=d+2,u=n?0:1,g=u+2,f=new Array(l),p=0;p<l;p++)f[p]=p;f.sort(function(e,t){return o[e][d]-o[t][d]});var m=[],v=new Array(s);for(p=0;p<l;p++){var I=f[p],y=o[I],C=r?I:I-s,M=I<s,x=r||!M,S=M?[]:null;if(m.length){var b=h(m,c,y[d]-i)+1;if(m.splice(0,b),r&&a){S=S.concat(m);for(var w=0;w<m.length;w++)v[D=m[w]].push(C)}else{var A=y[g],P=y[u];for(w=0;w<m.length;w++){var D=m[w],k=o[D],_=D<s,T=r||D>=s;(a||(M&&T||x&&_)&&A>=k[u]-i&&P<=k[g]+i)&&(M&&T&&S.push(r?D:D-s),x&&_&&v[D].push(C))}}}if(M&&(e===t&&S.push(I),v[I]=S),m.length){var z=h(m,c,y[c]);m.splice(z+1,0,I)}else m.push(I)}for(p=0;p<v.length;p++){var O=v[p];O&&O.sort(function(e,t){return e-t})}return v}},c=a.extend({initialize:function(e){this.precision=a.pick(e,5),this.multiplier=Math.pow(10,this.precision)},number:function(e){return this.precision<16?Math.round(e*this.multiplier)/this.multiplier:e},pair:function(e,t,i){return this.number(e)+(i||",")+this.number(t)},point:function(e,t){return this.number(e.x)+(t||",")+this.number(e.y)},size:function(e,t){return this.number(e.width)+(t||",")+this.number(e.height)},rectangle:function(e,t){return this.point(e,t)+(t||",")+this.size(e,t)}});c.instance=new c;var u=new function(){var e=[[.5773502691896257],[0,.7745966692414834],[.33998104358485626,.8611363115940526],[0,.5384693101056831,.906179845938664],[.2386191860831969,.6612093864662645,.932469514203152],[0,.4058451513773972,.7415311855993945,.9491079123427585],[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],[0,.3242534234038089,.6133714327005904,.8360311073266358,.9681602395076261],[.14887433898163122,.4333953941292472,.6794095682990244,.8650633666889845,.9739065285171717],[0,.26954315595234496,.5190961292068118,.7301520055740494,.8870625997680953,.978228658146057],[.1252334085114689,.3678314989981802,.5873179542866175,.7699026741943047,.9041172563704749,.9815606342467192],[0,.2304583159551348,.44849275103644687,.6423493394403402,.8015780907333099,.9175983992229779,.9841830547185881],[.10805494870734367,.31911236892788974,.5152486363581541,.6872929048116855,.827201315069765,.9284348836635735,.9862838086968123],[0,.20119409399743451,.3941513470775634,.5709721726085388,.7244177313601701,.8482065834104272,.937273392400706,.9879925180204854],[.09501250983763744,.2816035507792589,.45801677765722737,.6178762444026438,.755404408355003,.8656312023878318,.9445750230732326,.9894009349916499]],t=[[1],[.8888888888888888,.5555555555555556],[.6521451548625461,.34785484513745385],[.5688888888888889,.47862867049936647,.23692688505618908],[.46791393457269104,.3607615730481386,.17132449237917036],[.4179591836734694,.3818300505051189,.27970539148927664,.1294849661688697],[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626],[.3302393550012598,.31234707704000286,.26061069640293544,.1806481606948574,.08127438836157441],[.29552422471475287,.26926671930999635,.21908636251598204,.1494513491505806,.06667134430868814],[.2729250867779006,.26280454451024665,.23319376459199048,.18629021092773426,.1255803694649046,.05566856711617366],[.24914704581340277,.2334925365383548,.20316742672306592,.16007832854334622,.10693932599531843,.04717533638651183],[.2325515532308739,.22628318026289723,.2078160475368885,.17814598076194574,.13887351021978725,.09212149983772845,.04048400476531588],[.2152638534631578,.2051984637212956,.18553839747793782,.15720316715819355,.12151857068790319,.08015808715976021,.03511946033175186],[.2025782419255613,.19843148532711158,.1861610000155622,.16626920581699392,.13957067792615432,.10715922046717194,.07036604748810812,.03075324199611727],[.1894506104550685,.18260341504492358,.16915651939500254,.14959598881657674,.12462897125553388,.09515851168249279,.062253523938647894,.027152459411754096]],i=Math.abs,n=Math.sqrt,a=Math.pow,r=Math.log2||function(e){return Math.log(e)*Math.LOG2E},o=1e-12,s=1.12e-16;function l(e,t,i){return e<t?t:e>i?i:e}function h(e,t,n){function a(e){var t=134217729*e,i=e-t+t;return[i,e-i]}var r=t*t-e*n,o=t*t+e*n;if(3*i(r)<o){var s=a(e),l=a(t),h=a(n),d=t*t,c=e*n;r=d-c+(l[0]*l[0]-d+2*l[0]*l[1]+l[1]*l[1]-(s[0]*h[0]-c+s[0]*h[1]+s[1]*h[0]+s[1]*h[1]))}return r}function d(){var e=Math.max.apply(Math,arguments);return e&&(e<1e-8||e>1e8)?a(2,-Math.round(r(e))):0}return{EPSILON:o,MACHINE_EPSILON:s,CURVETIME_EPSILON:1e-8,GEOMETRIC_EPSILON:1e-7,TRIGONOMETRIC_EPSILON:1e-8,ANGULAR_EPSILON:1e-5,KAPPA:4*(n(2)-1)/3,isZero:function(e){return e>=-o&&e<=o},isMachineZero:function(e){return e>=-s&&e<=s},clamp:l,integrate:function(i,n,a,r){for(var o=e[r-2],s=t[r-2],l=.5*(a-n),h=l+n,d=0,c=r+1>>1,u=1&r?s[d++]*i(h):0;d<c;){var g=l*o[d];u+=s[d++]*(i(h+g)+i(h-g))}return l*u},findRoot:function(e,t,n,a,r,o,s){for(var h=0;h<o;h++){var d=e(n),c=d/t(n),u=n-c;if(i(c)<s){n=u;break}d>0?(r=n,n=u<=a?.5*(a+r):u):(a=n,n=u>=r?.5*(a+r):u)}return l(n,a,r)},solveQuadratic:function(e,t,a,r,c,u){var g,f=1/0;if(i(e)<o){if(i(t)<o)return i(a)<o?-1:0;g=-a/t}else{var p=h(e,t*=-.5,a);if(p&&i(p)<s){var m=d(i(e),i(t),i(a));m&&(p=h(e*=m,t*=m,a*=m))}if(p>=-s){var v=p<0?0:n(p),I=t+(t<0?-v:v);0===I?f=-(g=a/e):(g=I/e,f=a/I)}}var y=0,C=null==c,M=c-o,x=u+o;return isFinite(g)&&(C||g>M&&g<x)&&(r[y++]=C?g:l(g,c,u)),f!==g&&isFinite(f)&&(C||f>M&&f<x)&&(r[y++]=C?f:l(f,c,u)),y},solveCubic:function(e,t,r,h,c,g,f){var p,m,v,I,y,C=d(i(e),i(t),i(r),i(h));function M(i){var n=e*(p=i);I=(n+(m=n+t))*p+(v=m*p+r),y=v*p+h}if(C&&(e*=C,t*=C,r*=C,h*=C),i(e)<o)e=t,m=r,v=h,p=1/0;else if(i(h)<o)m=t,v=r,p=0;else{M(-t/e/3);var x=y/e,S=a(i(x),1/3),b=x<0?-1:1,w=-I/e,A=w>0?1.324717957244746*Math.max(S,n(w)):S,P=p-b*A;if(P!==p){do{M(P),P=0===I?p:p-y/I/(1+s)}while(b*P>b*p);i(e)*p*p>i(h/p)&&(m=((v=-h/p)-r)/p)}}var D=u.solveQuadratic(e,m,v,c,g,f),k=null==g;return isFinite(p)&&(0===D||D>0&&p!==c[0]&&p!==c[1])&&(k||p>g-o&&p<f+o)&&(c[D++]=k?p:l(p,g,f)),D}}},g={_id:1,_pools:{},get:function(e){if(e){var t=this._pools[e];return t||(t=this._pools[e]={_id:1}),t._id++}return this._id++}},f=a.extend({_class:"Point",_readIndex:!0,initialize:function(e,t){var i=typeof e,n=this.__read,a=0;if("number"===i){var r="number"==typeof t;this._set(e,r?t:e),n&&(a=r?2:1)}else if("undefined"===i||null===e)this._set(0,0),n&&(a=null===e?1:0);else{var o="string"===i?e.split(/[\s,]+/)||[]:e;a=1,Array.isArray(o)?this._set(+o[0],+(o.length>1?o[1]:o[0])):"x"in o?this._set(o.x||0,o.y||0):"width"in o?this._set(o.width||0,o.height||0):"angle"in o?(this._set(o.length||0,0),this.setAngle(o.angle||0)):(this._set(0,0),a=0)}return n&&(this.__read=a),this},set:"#initialize",_set:function(e,t){return this.x=e,this.y=t,this},equals:function(e){return this===e||e&&(this.x===e.x&&this.y===e.y||Array.isArray(e)&&this.x===e[0]&&this.y===e[1])||!1},clone:function(){return new f(this.x,this.y)},toString:function(){var e=c.instance;return"{ x: "+e.number(this.x)+", y: "+e.number(this.y)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.x),t.number(this.y)]},getLength:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},setLength:function(e){if(this.isZero()){var t=this._angle||0;this._set(Math.cos(t)*e,Math.sin(t)*e)}else{var i=e/this.getLength();u.isZero(i)&&this.getAngle(),this._set(this.x*i,this.y*i)}},getAngle:function(){return 180*this.getAngleInRadians.apply(this,arguments)/Math.PI},setAngle:function(e){this.setAngleInRadians.call(this,e*Math.PI/180)},getAngleInDegrees:"#getAngle",setAngleInDegrees:"#setAngle",getAngleInRadians:function(){if(arguments.length){var e=f.read(arguments),t=this.getLength()*e.getLength();if(u.isZero(t))return NaN;var i=this.dot(e)/t;return Math.acos(i<-1?-1:i>1?1:i)}return this.isZero()?this._angle||0:this._angle=Math.atan2(this.y,this.x)},setAngleInRadians:function(e){if(this._angle=e,!this.isZero()){var t=this.getLength();this._set(Math.cos(e)*t,Math.sin(e)*t)}},getQuadrant:function(){return this.x>=0?this.y>=0?1:4:this.y>=0?2:3}},{beans:!1,getDirectedAngle:function(){var e=f.read(arguments);return 180*Math.atan2(this.cross(e),this.dot(e))/Math.PI},getDistance:function(){var e=arguments,t=f.read(e),i=t.x-this.x,n=t.y-this.y,r=i*i+n*n;return a.read(e)?r:Math.sqrt(r)},normalize:function(e){e===t&&(e=1);var i=this.getLength(),n=0!==i?e/i:0,a=new f(this.x*n,this.y*n);return n>=0&&(a._angle=this._angle),a},rotate:function(e,t){if(0===e)return this.clone();e=e*Math.PI/180;var i=t?this.subtract(t):this,n=Math.sin(e),a=Math.cos(e);return i=new f(i.x*a-i.y*n,i.x*n+i.y*a),t?i.add(t):i},transform:function(e){return e?e._transformPoint(this):this},add:function(){var e=f.read(arguments);return new f(this.x+e.x,this.y+e.y)},subtract:function(){var e=f.read(arguments);return new f(this.x-e.x,this.y-e.y)},multiply:function(){var e=f.read(arguments);return new f(this.x*e.x,this.y*e.y)},divide:function(){var e=f.read(arguments);return new f(this.x/e.x,this.y/e.y)},modulo:function(){var e=f.read(arguments);return new f(this.x%e.x,this.y%e.y)},negate:function(){return new f(-this.x,-this.y)},isInside:function(){return I.read(arguments).contains(this)},isClose:function(){var e=arguments,t=f.read(e),i=a.read(e);return this.getDistance(t)<=i},isCollinear:function(){var e=f.read(arguments);return f.isCollinear(this.x,this.y,e.x,e.y)},isColinear:"#isCollinear",isOrthogonal:function(){var e=f.read(arguments);return f.isOrthogonal(this.x,this.y,e.x,e.y)},isZero:function(){var e=u.isZero;return e(this.x)&&e(this.y)},isNaN:function(){return isNaN(this.x)||isNaN(this.y)},isInQuadrant:function(e){return this.x*(e>1&&e<4?-1:1)>=0&&this.y*(e>2?-1:1)>=0},dot:function(){var e=f.read(arguments);return this.x*e.x+this.y*e.y},cross:function(){var e=f.read(arguments);return this.x*e.y-this.y*e.x},project:function(){var e=f.read(arguments),t=e.isZero()?0:this.dot(e)/e.dot(e);return new f(e.x*t,e.y*t)},statics:{min:function(){var e=arguments,t=f.read(e),i=f.read(e);return new f(Math.min(t.x,i.x),Math.min(t.y,i.y))},max:function(){var e=arguments,t=f.read(e),i=f.read(e);return new f(Math.max(t.x,i.x),Math.max(t.y,i.y))},random:function(){return new f(Math.random(),Math.random())},isCollinear:function(e,t,i,n){return Math.abs(e*n-t*i)<=1e-8*Math.sqrt((e*e+t*t)*(i*i+n*n))},isOrthogonal:function(e,t,i,n){return Math.abs(e*i+t*n)<=1e-8*Math.sqrt((e*e+t*t)*(i*i+n*n))}}},a.each(["round","ceil","floor","abs"],function(e){var t=Math[e];this[e]=function(){return new f(t(this.x),t(this.y))}},{})),p=f.extend({initialize:function(e,t,i,n){this._x=e,this._y=t,this._owner=i,this._setter=n},_set:function(e,t,i){return this._x=e,this._y=t,i||this._owner[this._setter](this),this},getX:function(){return this._x},setX:function(e){this._x=e,this._owner[this._setter](this)},getY:function(){return this._y},setY:function(e){this._y=e,this._owner[this._setter](this)},isSelected:function(){return!!(this._owner._selection&this._getSelection())},setSelected:function(e){this._owner._changeSelection(this._getSelection(),e)},_getSelection:function(){return"setPosition"===this._setter?4:0}}),m=a.extend({_class:"Size",_readIndex:!0,initialize:function(e,t){var i=typeof e,n=this.__read,a=0;if("number"===i){var r="number"==typeof t;this._set(e,r?t:e),n&&(a=r?2:1)}else if("undefined"===i||null===e)this._set(0,0),n&&(a=null===e?1:0);else{var o="string"===i?e.split(/[\s,]+/)||[]:e;a=1,Array.isArray(o)?this._set(+o[0],+(o.length>1?o[1]:o[0])):"width"in o?this._set(o.width||0,o.height||0):"x"in o?this._set(o.x||0,o.y||0):(this._set(0,0),a=0)}return n&&(this.__read=a),this},set:"#initialize",_set:function(e,t){return this.width=e,this.height=t,this},equals:function(e){return e===this||e&&(this.width===e.width&&this.height===e.height||Array.isArray(e)&&this.width===e[0]&&this.height===e[1])||!1},clone:function(){return new m(this.width,this.height)},toString:function(){var e=c.instance;return"{ width: "+e.number(this.width)+", height: "+e.number(this.height)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.width),t.number(this.height)]},add:function(){var e=m.read(arguments);return new m(this.width+e.width,this.height+e.height)},subtract:function(){var e=m.read(arguments);return new m(this.width-e.width,this.height-e.height)},multiply:function(){var e=m.read(arguments);return new m(this.width*e.width,this.height*e.height)},divide:function(){var e=m.read(arguments);return new m(this.width/e.width,this.height/e.height)},modulo:function(){var e=m.read(arguments);return new m(this.width%e.width,this.height%e.height)},negate:function(){return new m(-this.width,-this.height)},isZero:function(){var e=u.isZero;return e(this.width)&&e(this.height)},isNaN:function(){return isNaN(this.width)||isNaN(this.height)},statics:{min:function(e,t){return new m(Math.min(e.width,t.width),Math.min(e.height,t.height))},max:function(e,t){return new m(Math.max(e.width,t.width),Math.max(e.height,t.height))},random:function(){return new m(Math.random(),Math.random())}}},a.each(["round","ceil","floor","abs"],function(e){var t=Math[e];this[e]=function(){return new m(t(this.width),t(this.height))}},{})),v=m.extend({initialize:function(e,t,i,n){this._width=e,this._height=t,this._owner=i,this._setter=n},_set:function(e,t,i){return this._width=e,this._height=t,i||this._owner[this._setter](this),this},getWidth:function(){return this._width},setWidth:function(e){this._width=e,this._owner[this._setter](this)},getHeight:function(){return this._height},setHeight:function(e){this._height=e,this._owner[this._setter](this)}}),I=a.extend({_class:"Rectangle",_readIndex:!0,beans:!0,initialize:function(e,i,n,r){var o,s=arguments,l=typeof e;if("number"===l?(this._set(e,i,n,r),o=4):"undefined"===l||null===e?(this._set(0,0,0,0),o=null===e?1:0):1===s.length&&(Array.isArray(e)?(this._set.apply(this,e),o=1):e.x!==t||e.width!==t?(this._set(e.x||0,e.y||0,e.width||0,e.height||0),o=1):e.from===t&&e.to===t&&(this._set(0,0,0,0),a.readSupported(s,this)&&(o=1))),o===t){var h,d,c=f.readNamed(s,"from"),u=a.peek(s),g=c.x,p=c.y;if(u&&u.x!==t||a.hasNamed(s,"to")){var v=f.readNamed(s,"to");h=v.x-g,d=v.y-p,h<0&&(g=v.x,h=-h),d<0&&(p=v.y,d=-d)}else{var I=m.read(s);h=I.width,d=I.height}this._set(g,p,h,d),o=s.__index}var y=s.__filtered;return y&&(this.__filtered=y),this.__read&&(this.__read=o),this},set:"#initialize",_set:function(e,t,i,n){return this.x=e,this.y=t,this.width=i,this.height=n,this},clone:function(){return new I(this.x,this.y,this.width,this.height)},equals:function(e){var t=a.isPlainValue(e)?I.read(arguments):e;return t===this||t&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height||!1},toString:function(){var e=c.instance;return"{ x: "+e.number(this.x)+", y: "+e.number(this.y)+", width: "+e.number(this.width)+", height: "+e.number(this.height)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.x),t.number(this.y),t.number(this.width),t.number(this.height)]},getPoint:function(e){return new(e?f:p)(this.x,this.y,this,"setPoint")},setPoint:function(){var e=f.read(arguments);this.x=e.x,this.y=e.y},getSize:function(e){return new(e?m:v)(this.width,this.height,this,"setSize")},_fw:1,_fh:1,setSize:function(){var e=m.read(arguments),t=this._sx,i=this._sy,n=e.width,a=e.height;t&&(this.x+=(this.width-n)*t),i&&(this.y+=(this.height-a)*i),this.width=n,this.height=a,this._fw=this._fh=1},getLeft:function(){return this.x},setLeft:function(e){if(!this._fw){var t=e-this.x;this.width-=.5===this._sx?2*t:t}this.x=e,this._sx=this._fw=0},getTop:function(){return this.y},setTop:function(e){if(!this._fh){var t=e-this.y;this.height-=.5===this._sy?2*t:t}this.y=e,this._sy=this._fh=0},getRight:function(){return this.x+this.width},setRight:function(e){if(!this._fw){var t=e-this.x;this.width=.5===this._sx?2*t:t}this.x=e-this.width,this._sx=1,this._fw=0},getBottom:function(){return this.y+this.height},setBottom:function(e){if(!this._fh){var t=e-this.y;this.height=.5===this._sy?2*t:t}this.y=e-this.height,this._sy=1,this._fh=0},getCenterX:function(){return this.x+this.width/2},setCenterX:function(e){this._fw||.5===this._sx?this.x=e-this.width/2:(this._sx&&(this.x+=2*(e-this.x)*this._sx),this.width=2*(e-this.x)),this._sx=.5,this._fw=0},getCenterY:function(){return this.y+this.height/2},setCenterY:function(e){this._fh||.5===this._sy?this.y=e-this.height/2:(this._sy&&(this.y+=2*(e-this.y)*this._sy),this.height=2*(e-this.y)),this._sy=.5,this._fh=0},getCenter:function(e){return new(e?f:p)(this.getCenterX(),this.getCenterY(),this,"setCenter")},setCenter:function(){var e=f.read(arguments);return this.setCenterX(e.x),this.setCenterY(e.y),this},getArea:function(){return this.width*this.height},isEmpty:function(){return 0===this.width||0===this.height},contains:function(e){return e&&e.width!==t||4===(Array.isArray(e)?e:arguments).length?this._containsRectangle(I.read(arguments)):this._containsPoint(f.read(arguments))},_containsPoint:function(e){var t=e.x,i=e.y;return t>=this.x&&i>=this.y&&t<=this.x+this.width&&i<=this.y+this.height},_containsRectangle:function(e){var t=e.x,i=e.y;return t>=this.x&&i>=this.y&&t+e.width<=this.x+this.width&&i+e.height<=this.y+this.height},intersects:function(){var e=I.read(arguments),t=a.read(arguments)||0;return e.x+e.width>this.x-t&&e.y+e.height>this.y-t&&e.x<this.x+this.width+t&&e.y<this.y+this.height+t},intersect:function(){var e=I.read(arguments),t=Math.max(this.x,e.x),i=Math.max(this.y,e.y),n=Math.min(this.x+this.width,e.x+e.width),a=Math.min(this.y+this.height,e.y+e.height);return new I(t,i,n-t,a-i)},unite:function(){var e=I.read(arguments),t=Math.min(this.x,e.x),i=Math.min(this.y,e.y),n=Math.max(this.x+this.width,e.x+e.width),a=Math.max(this.y+this.height,e.y+e.height);return new I(t,i,n-t,a-i)},include:function(){var e=f.read(arguments),t=Math.min(this.x,e.x),i=Math.min(this.y,e.y),n=Math.max(this.x+this.width,e.x),a=Math.max(this.y+this.height,e.y);return new I(t,i,n-t,a-i)},expand:function(){var e=m.read(arguments),t=e.width,i=e.height;return new I(this.x-t/2,this.y-i/2,this.width+t,this.height+i)},scale:function(e,i){return this.expand(this.width*e-this.width,this.height*(i===t?e:i)-this.height)}},a.each([["Top","Left"],["Top","Right"],["Bottom","Left"],["Bottom","Right"],["Left","Center"],["Top","Center"],["Right","Center"],["Bottom","Center"]],function(e,t){var i=e.join(""),n=/^[RL]/.test(i);t>=4&&(e[1]+=n?"Y":"X");var a=e[n?0:1],r=e[n?1:0],o="get"+a,s="get"+r,l="set"+a,h="set"+r,d="set"+i;this["get"+i]=function(e){return new(e?f:p)(this[o](),this[s](),this,d)},this[d]=function(){var e=f.read(arguments);this[l](e.x),this[h](e.y)}},{beans:!0})),y=I.extend({initialize:function(e,t,i,n,a,r){this._set(e,t,i,n,!0),this._owner=a,this._setter=r},_set:function(e,t,i,n,a){return this._x=e,this._y=t,this._width=i,this._height=n,a||this._owner[this._setter](this),this}},new function(){var e=I.prototype;return a.each(["x","y","width","height"],function(e){var t=a.capitalize(e),i="_"+e;this["get"+t]=function(){return this[i]},this["set"+t]=function(e){this[i]=e,this._dontNotify||this._owner[this._setter](this)}},a.each(["Point","Size","Center","Left","Top","Right","Bottom","CenterX","CenterY","TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],function(t){var i="set"+t;this[i]=function(){this._dontNotify=!0,e[i].apply(this,arguments),this._dontNotify=!1,this._owner[this._setter](this)}},{isSelected:function(){return!!(2&this._owner._selection)},setSelected:function(e){var t=this._owner;t._changeSelection&&t._changeSelection(2,e)}}))}),C=a.extend({_class:"Matrix",initialize:function e(t,i){var n=arguments,a=n.length,r=!0;if(a>=6?this._set.apply(this,n):1===a||2===a?t instanceof e?this._set(t._a,t._b,t._c,t._d,t._tx,t._ty,i):Array.isArray(t)?this._set.apply(this,i?t.concat([i]):t):r=!1:a?r=!1:this.reset(),!r)throw new Error("Unsupported matrix parameters");return this},set:"#initialize",_set:function(e,t,i,n,a,r,o){return this._a=e,this._b=t,this._c=i,this._d=n,this._tx=a,this._ty=r,o||this._changed(),this},_serialize:function(e,t){return a.serialize(this.getValues(),e,!0,t)},_changed:function(){var e=this._owner;e&&(e._applyMatrix?e.transform(null,!0):e._changed(25))},clone:function(){return new C(this._a,this._b,this._c,this._d,this._tx,this._ty)},equals:function(e){return e===this||e&&this._a===e._a&&this._b===e._b&&this._c===e._c&&this._d===e._d&&this._tx===e._tx&&this._ty===e._ty},toString:function(){var e=c.instance;return"[["+[e.number(this._a),e.number(this._c),e.number(this._tx)].join(", ")+"], ["+[e.number(this._b),e.number(this._d),e.number(this._ty)].join(", ")+"]]"},reset:function(e){return this._a=this._d=1,this._b=this._c=this._tx=this._ty=0,e||this._changed(),this},apply:function(e,t){var i=this._owner;return!!i&&(i.transform(null,a.pick(e,!0),t),this.isIdentity())},translate:function(){var e=f.read(arguments),t=e.x,i=e.y;return this._tx+=t*this._a+i*this._c,this._ty+=t*this._b+i*this._d,this._changed(),this},scale:function(){var e=arguments,t=f.read(e),i=f.read(e,0,{readNull:!0});return i&&this.translate(i),this._a*=t.x,this._b*=t.x,this._c*=t.y,this._d*=t.y,i&&this.translate(i.negate()),this._changed(),this},rotate:function(e){e*=Math.PI/180;var t=f.read(arguments,1),i=t.x,n=t.y,a=Math.cos(e),r=Math.sin(e),o=i-i*a+n*r,s=n-i*r-n*a,l=this._a,h=this._b,d=this._c,c=this._d;return this._a=a*l+r*d,this._b=a*h+r*c,this._c=-r*l+a*d,this._d=-r*h+a*c,this._tx+=o*l+s*d,this._ty+=o*h+s*c,this._changed(),this},shear:function(){var e=arguments,t=f.read(e),i=f.read(e,0,{readNull:!0});i&&this.translate(i);var n=this._a,a=this._b;return this._a+=t.y*this._c,this._b+=t.y*this._d,this._c+=t.x*n,this._d+=t.x*a,i&&this.translate(i.negate()),this._changed(),this},skew:function(){var e=arguments,t=f.read(e),i=f.read(e,0,{readNull:!0}),n=Math.PI/180,a=new f(Math.tan(t.x*n),Math.tan(t.y*n));return this.shear(a,i)},append:function(e,t){if(e){var i=this._a,n=this._b,a=this._c,r=this._d,o=e._a,s=e._c,l=e._b,h=e._d,d=e._tx,c=e._ty;this._a=o*i+l*a,this._c=s*i+h*a,this._b=o*n+l*r,this._d=s*n+h*r,this._tx+=d*i+c*a,this._ty+=d*n+c*r,t||this._changed()}return this},prepend:function(e,t){if(e){var i=this._a,n=this._b,a=this._c,r=this._d,o=this._tx,s=this._ty,l=e._a,h=e._c,d=e._b,c=e._d,u=e._tx,g=e._ty;this._a=l*i+h*n,this._c=l*a+h*r,this._b=d*i+c*n,this._d=d*a+c*r,this._tx=l*o+h*s+u,this._ty=d*o+c*s+g,t||this._changed()}return this},appended:function(e){return this.clone().append(e)},prepended:function(e){return this.clone().prepend(e)},invert:function(){var e=this._a,t=this._b,i=this._c,n=this._d,a=this._tx,r=this._ty,o=e*n-t*i,s=null;return o&&!isNaN(o)&&isFinite(a)&&isFinite(r)&&(this._a=n/o,this._b=-t/o,this._c=-i/o,this._d=e/o,this._tx=(i*r-n*a)/o,this._ty=(t*a-e*r)/o,s=this),s},inverted:function(){return this.clone().invert()},concatenate:"#append",preConcatenate:"#prepend",chain:"#appended",_shiftless:function(){return new C(this._a,this._b,this._c,this._d,0,0)},_orNullIfIdentity:function(){return this.isIdentity()?null:this},isIdentity:function(){return 1===this._a&&0===this._b&&0===this._c&&1===this._d&&0===this._tx&&0===this._ty},isInvertible:function(){var e=this._a*this._d-this._c*this._b;return e&&!isNaN(e)&&isFinite(this._tx)&&isFinite(this._ty)},isSingular:function(){return!this.isInvertible()},transform:function(e,t,i){return arguments.length<3?this._transformPoint(f.read(arguments)):this._transformCoordinates(e,t,i)},_transformPoint:function(e,t,i){var n=e.x,a=e.y;return t||(t=new f),t._set(n*this._a+a*this._c+this._tx,n*this._b+a*this._d+this._ty,i)},_transformCoordinates:function(e,t,i){for(var n=0,a=2*i;n<a;n+=2){var r=e[n],o=e[n+1];t[n]=r*this._a+o*this._c+this._tx,t[n+1]=r*this._b+o*this._d+this._ty}return t},_transformCorners:function(e){var t=e.x,i=e.y,n=t+e.width,a=i+e.height,r=[t,i,n,i,n,a,t,a];return this._transformCoordinates(r,r,4)},_transformBounds:function(e,t,i){for(var n=this._transformCorners(e),a=n.slice(0,2),r=a.slice(),o=2;o<8;o++){var s=n[o],l=1&o;s<a[l]?a[l]=s:s>r[l]&&(r[l]=s)}return t||(t=new I),t._set(a[0],a[1],r[0]-a[0],r[1]-a[1],i)},inverseTransform:function(){return this._inverseTransform(f.read(arguments))},_inverseTransform:function(e,t,i){var n=this._a,a=this._b,r=this._c,o=this._d,s=this._tx,l=this._ty,h=n*o-a*r,d=null;if(h&&!isNaN(h)&&isFinite(s)&&isFinite(l)){var c=e.x-this._tx,u=e.y-this._ty;t||(t=new f),d=t._set((c*o-u*r)/h,(u*n-c*a)/h,i)}return d},decompose:function(){var e,t,i,n=this._a,a=this._b,r=this._c,o=this._d,s=n*o-a*r,l=Math.sqrt,h=Math.atan2,d=180/Math.PI;if(0!==n||0!==a){var c=l(n*n+a*a);e=Math.acos(n/c)*(a>0?1:-1),t=[c,s/c],i=[h(n*r+a*o,c*c),0]}else if(0!==r||0!==o){var u=l(r*r+o*o);e=Math.asin(r/u)*(o>0?1:-1),t=[s/u,u],i=[0,h(n*r+a*o,u*u)]}else e=0,i=t=[0,0];return{translation:this.getTranslation(),rotation:e*d,scaling:new f(t),skewing:new f(i[0]*d,i[1]*d)}},getValues:function(){return[this._a,this._b,this._c,this._d,this._tx,this._ty]},getTranslation:function(){return new f(this._tx,this._ty)},getScaling:function(){return this.decompose().scaling},getRotation:function(){return this.decompose().rotation},applyToContext:function(e){this.isIdentity()||e.transform(this._a,this._b,this._c,this._d,this._tx,this._ty)}},a.each(["a","b","c","d","tx","ty"],function(e){var t=a.capitalize(e),i="_"+e;this["get"+t]=function(){return this[i]},this["set"+t]=function(e){this[i]=e,this._changed()}},{})),M=a.extend({_class:"Line",initialize:function(e,t,i,n,a){var r=!1;arguments.length>=4?(this._px=e,this._py=t,this._vx=i,this._vy=n,r=a):(this._px=e.x,this._py=e.y,this._vx=t.x,this._vy=t.y,r=i),r||(this._vx-=this._px,this._vy-=this._py)},getPoint:function(){return new f(this._px,this._py)},getVector:function(){return new f(this._vx,this._vy)},getLength:function(){return this.getVector().getLength()},intersect:function(e,t){return M.intersect(this._px,this._py,this._vx,this._vy,e._px,e._py,e._vx,e._vy,!0,t)},getSide:function(e,t){return M.getSide(this._px,this._py,this._vx,this._vy,e.x,e.y,!0,t)},getDistance:function(e){return Math.abs(this.getSignedDistance(e))},getSignedDistance:function(e){return M.getSignedDistance(this._px,this._py,this._vx,this._vy,e.x,e.y,!0)},isCollinear:function(e){return f.isCollinear(this._vx,this._vy,e._vx,e._vy)},isOrthogonal:function(e){return f.isOrthogonal(this._vx,this._vy,e._vx,e._vy)},statics:{intersect:function(e,t,i,n,a,r,o,s,l,h){l||(i-=e,n-=t,o-=a,s-=r);var d=i*s-n*o;if(!u.isMachineZero(d)){var c=e-a,g=t-r,p=(o*g-s*c)/d,m=(i*g-n*c)/d,v=-1e-12,I=1+1e-12;if(h||v<p&&p<I&&v<m&&m<I)return h||(p=p<=0?0:p>=1?1:p),new f(e+p*i,t+p*n)}},getSide:function(e,t,i,n,a,r,o,s){o||(i-=e,n-=t);var l=a-e,h=l*n-(r-t)*i;return!s&&u.isMachineZero(h)&&(h=(l*i+l*i)/(i*i+n*n))>=0&&h<=1&&(h=0),h<0?-1:h>0?1:0},getSignedDistance:function(e,t,i,n,a,r,o){return o||(i-=e,n-=t),0===i?n>0?a-e:e-a:0===n?i<0?r-t:t-r:((a-e)*n-(r-t)*i)/(n>i?n*Math.sqrt(1+i*i/(n*n)):i*Math.sqrt(1+n*n/(i*i)))},getDistance:function(e,t,i,n,a,r,o){return Math.abs(M.getSignedDistance(e,t,i,n,a,r,o))}}}),x=h.extend({_class:"Project",_list:"projects",_reference:"project",_compactSerialize:!0,initialize:function(e){h.call(this,!0),this._children=[],this._namedChildren={},this._activeLayer=null,this._currentStyle=new H(null,null,this),this._view=J.create(this,e||ae.getCanvas(1,1)),this._selectionItems={},this._selectionCount=0,this._updateVersion=0},_serialize:function(e,t){return a.serialize(this._children,e,!0,t)},_changed:function(e,t){if(1&e){var i=this._view;i&&(i._needsUpdate=!0,!i._requested&&i._autoUpdate&&i.requestUpdate())}var n=this._changes;if(n&&t){var a=this._changesById,r=t._id,o=a[r];o?o.flags|=e:n.push(a[r]={item:t,flags:e})}},clear:function(){for(var e=this._children,t=e.length-1;t>=0;t--)e[t].remove()},isEmpty:function(){return!this._children.length},remove:function e(){return!!e.base.call(this)&&(this._view&&this._view.remove(),!0)},getView:function(){return this._view},getCurrentStyle:function(){return this._currentStyle},setCurrentStyle:function(e){this._currentStyle.set(e)},getIndex:function(){return this._index},getOptions:function(){return this._scope.settings},getLayers:function(){return this._children},getActiveLayer:function(){return this._activeLayer||new w({project:this,insert:!0})},getSymbolDefinitions:function(){var e=[],t={};return this.getItems({class:D,match:function(i){var n=i._definition,a=n._id;return t[a]||(t[a]=!0,e.push(n)),!1}}),e},getSymbols:"getSymbolDefinitions",getSelectedItems:function(){var e=this._selectionItems,t=[];for(var i in e){var n=e[i],a=n._selection;1&a&&n.isInserted()?t.push(n):a||this._updateSelection(n)}return t},_updateSelection:function(e){var t=e._id,i=this._selectionItems;e._selection?i[t]!==e&&(this._selectionCount++,i[t]=e):i[t]===e&&(this._selectionCount--,delete i[t])},selectAll:function(){for(var e=this._children,t=0,i=e.length;t<i;t++)e[t].setFullySelected(!0)},deselectAll:function(){var e=this._selectionItems;for(var t in e)e[t].setFullySelected(!1)},addLayer:function(e){return this.insertLayer(t,e)},insertLayer:function(e,t){if(t instanceof w){t._remove(!1,!0),a.splice(this._children,[t],e,0),t._setProject(this,!0);var i=t._name;i&&t.setName(i),this._changes&&t._changed(5),this._activeLayer||(this._activeLayer=t)}else t=null;return t},_insertItem:function(e,i,n){return i=this.insertLayer(e,i)||(this._activeLayer||this._insertItem(t,new w(S.NO_INSERT),!0)).insertChild(e,i),n&&i.activate&&i.activate(),i},getItems:function(e){return S._getItems(this,e)},getItem:function(e){return S._getItems(this,e,null,null,!0)[0]||null},importJSON:function(e){this.activate();var t=this._activeLayer;return a.importJSON(e,t&&t.isEmpty()&&t)},removeOn:function(e){var t=this._removeSets;if(t){"mouseup"===e&&(t.mousedrag=null);var i=t[e];if(i){for(var n in i){var a=i[n];for(var r in t){var o=t[r];o&&o!=i&&delete o[a._id]}a.remove()}t[e]=null}}},draw:function(e,t,i){this._updateVersion++,e.save(),t.applyToContext(e);for(var n=this._children,r=new a({offset:new f(0,0),pixelRatio:i,viewMatrix:t.isIdentity()?null:t,matrices:[new C],updateMatrix:!0}),o=0,s=n.length;o<s;o++)n[o].draw(e,r);if(e.restore(),this._selectionCount>0){e.save(),e.strokeWidth=1;var l=this._selectionItems,h=this._scope.settings.handleSize,d=this._updateVersion;for(var c in l)l[c]._drawSelection(e,t,h,l,d);e.restore()}}}),S=a.extend(s,{statics:{extend:function e(t){return t._serializeFields&&(t._serializeFields=a.set({},this.prototype._serializeFields,t._serializeFields)),e.base.apply(this,arguments)},INSERT:{insert:!0},NO_INSERT:{insert:!1}},_class:"Item",_name:null,_applyMatrix:!0,_canApplyMatrix:!0,_canScaleStroke:!1,_pivot:null,_visible:!0,_blendMode:"normal",_opacity:1,_locked:!1,_guide:!1,_clipMask:!1,_selection:0,_selectBounds:!0,_selectChildren:!1,_serializeFields:{name:null,applyMatrix:null,matrix:new C,pivot:null,visible:!0,blendMode:"normal",opacity:1,locked:!1,guide:!1,clipMask:!1,selected:!1,data:{}},_prioritize:["applyMatrix"]},new function(){var e=["onMouseDown","onMouseUp","onMouseDrag","onClick","onDoubleClick","onMouseMove","onMouseEnter","onMouseLeave"];return a.each(e,function(e){this._events[e]={install:function(e){this.getView()._countItemEvent(e,1)},uninstall:function(e){this.getView()._countItemEvent(e,-1)}}},{_events:{onFrame:{install:function(){this.getView()._animateItem(this,!0)},uninstall:function(){this.getView()._animateItem(this,!1)}},onLoad:{},onError:{}},statics:{_itemHandlers:e}})},{initialize:function(){},_initialize:function(e,i){var n=e&&a.isPlainObject(e),r=n&&!0===e.internal,o=this._matrix=new C,s=n&&e.project||le.project,l=le.settings;return this._id=r?null:g.get(),this._parent=this._index=null,this._applyMatrix=this._canApplyMatrix&&l.applyMatrix,i&&o.translate(i),o._owner=this,this._style=new H(s._currentStyle,this,s),r||n&&0==e.insert||!l.insertItems&&(!n||1!=e.insert)?this._setProject(s):(n&&e.parent||s)._insertItem(t,this,!0),n&&e!==S.NO_INSERT&&e!==S.INSERT&&this.set(e,{internal:!0,insert:!0,project:!0,parent:!0}),n},_serialize:function(e,t){var i={},n=this;function r(r){for(var o in r){var s=n[o];a.equals(s,"leading"===o?1.2*r.fontSize:r[o])||(i[o]=a.serialize(s,e,"data"!==o,t))}}return r(this._serializeFields),this instanceof b||r(this._style._defaults),[this._class,i]},_changed:function(e){var i=this._symbol,n=this._parent||i,a=this._project;8&e&&(this._bounds=this._position=this._decomposed=t),16&e&&(this._globalMatrix=t),n&&72&e&&S._clearBoundsCache(n),2&e&&S._clearBoundsCache(this),a&&a._changed(e,this),i&&i._changed(e)},getId:function(){return this._id},getName:function(){return this._name},setName:function(e){if(this._name&&this._removeNamed(),e===+e+"")throw new Error("Names consisting only of numbers are not supported.");var i=this._getOwner();if(e&&i){var n=i._children,a=i._namedChildren;(a[e]=a[e]||[]).push(this),e in n||(n[e]=this)}this._name=e||t,this._changed(256)},getStyle:function(){return this._style},setStyle:function(e){this.getStyle().set(e)}},a.each(["locked","visible","blendMode","opacity","guide"],function(e){var t=a.capitalize(e),i="_"+e,n={locked:256,visible:265};this["get"+t]=function(){return this[i]},this["set"+t]=function(t){t!=this[i]&&(this[i]=t,this._changed(n[e]||257))}},{}),{beans:!0,getSelection:function(){return this._selection},setSelection:function(e){if(e!==this._selection){this._selection=e;var t=this._project;t&&(t._updateSelection(this),this._changed(257))}},_changeSelection:function(e,t){var i=this._selection;this.setSelection(t?i|e:i&~e)},isSelected:function(){if(this._selectChildren)for(var e=this._children,t=0,i=e.length;t<i;t++)if(e[t].isSelected())return!0;return!!(1&this._selection)},setSelected:function(e){if(this._selectChildren)for(var t=this._children,i=0,n=t.length;i<n;i++)t[i].setSelected(e);this._changeSelection(1,e)},isFullySelected:function(){var e=this._children,t=!!(1&this._selection);if(e&&t){for(var i=0,n=e.length;i<n;i++)if(!e[i].isFullySelected())return!1;return!0}return t},setFullySelected:function(e){var t=this._children;if(t)for(var i=0,n=t.length;i<n;i++)t[i].setFullySelected(e);this._changeSelection(1,e)},isClipMask:function(){return this._clipMask},setClipMask:function(e){this._clipMask!=(e=!!e)&&(this._clipMask=e,e&&(this.setFillColor(null),this.setStrokeColor(null)),this._changed(257),this._parent&&this._parent._changed(2048))},getData:function(){return this._data||(this._data={}),this._data},setData:function(e){this._data=e},getPosition:function(e){var t=e?f:p,i=this._position||(this._position=this._getPositionFromBounds());return new t(i.x,i.y,this,"setPosition")},setPosition:function(){this.translate(f.read(arguments).subtract(this.getPosition(!0)))},_getPositionFromBounds:function(e){return this._pivot?this._matrix._transformPoint(this._pivot):(e||this.getBounds()).getCenter(!0)},getPivot:function(){var e=this._pivot;return e?new p(e.x,e.y,this,"setPivot"):null},setPivot:function(){this._pivot=f.read(arguments,0,{clone:!0,readNull:!0}),this._position=t}},a.each({getStrokeBounds:{stroke:!0},getHandleBounds:{handle:!0},getInternalBounds:{internal:!0}},function(e,t){this[t]=function(t){return this.getBounds(t,e)}},{beans:!0,getBounds:function(e,t){var i=t||e instanceof C,n=a.set({},i?t:e,this._boundsOptions);(!n.stroke||this.getStrokeScaling())&&(n.cacheItem=this);var r=this._getCachedBounds(i&&e,n).rect;return arguments.length?r:new y(r.x,r.y,r.width,r.height,this,"setBounds")},setBounds:function(){var e=I.read(arguments),t=this.getBounds(),i=this._matrix,n=new C,a=e.getCenter();n.translate(a),(e.width!=t.width||e.height!=t.height)&&(i.isInvertible()||(i.set(i._backup||(new C).translate(i.getTranslation())),t=this.getBounds()),n.scale(0!==t.width?e.width/t.width:0,0!==t.height?e.height/t.height:0)),a=t.getCenter(),n.translate(-a.x,-a.y),this.transform(n)},_getBounds:function(e,t){var i=this._children;return i&&i.length?(S._updateBoundsCache(this,t.cacheItem),S._getBounds(i,e,t)):new I},_getBoundsCacheKey:function(e,t){return[e.stroke?1:0,e.handle?1:0,t?1:0].join("")},_getCachedBounds:function(e,t,i){e=e&&e._orNullIfIdentity();var n=t.internal&&!i,a=t.cacheItem,r=n?null:this._matrix._orNullIfIdentity(),o=a&&(!e||e.equals(r))&&this._getBoundsCacheKey(t,n),s=this._bounds;if(S._updateBoundsCache(this._parent||this._symbol,a),o&&s&&o in s)return{rect:(u=s[o]).rect.clone(),nonscaling:u.nonscaling};var l=this._getBounds(e||r,t),h=l.rect||l,d=this._style,c=l.nonscaling||d.hasStroke()&&!d.getStrokeScaling();if(o){s||(this._bounds=s={});var u=s[o]={rect:h.clone(),nonscaling:c,internal:n}}return{rect:h,nonscaling:c}},_getStrokeMatrix:function(e,t){var i=this.getStrokeScaling()?null:t&&t.internal?this:this._parent||this._symbol&&this._symbol._item,n=i?i.getViewMatrix().invert():e;return n&&n._shiftless()},statics:{_updateBoundsCache:function(e,t){if(e&&t){var i=t._id,n=e._boundsCache=e._boundsCache||{ids:{},list:[]};n.ids[i]||(n.list.push(t),n.ids[i]=t)}},_clearBoundsCache:function(e){var i=e._boundsCache;if(i){e._bounds=e._position=e._boundsCache=t;for(var n=0,a=i.list,r=a.length;n<r;n++){var o=a[n];o!==e&&(o._bounds=o._position=t,o._boundsCache&&S._clearBoundsCache(o))}}},_getBounds:function(e,t,i){var n=1/0,a=-n,r=n,o=a,s=!1;i=i||{};for(var l=0,h=e.length;l<h;l++){var d=e[l];if(d._visible&&!d.isEmpty(!0)){var c=d._getCachedBounds(t&&t.appended(d._matrix),i,!0),u=c.rect;n=Math.min(u.x,n),r=Math.min(u.y,r),a=Math.max(u.x+u.width,a),o=Math.max(u.y+u.height,o),c.nonscaling&&(s=!0)}}return{rect:isFinite(n)?new I(n,r,a-n,o-r):new I,nonscaling:s}}}}),{beans:!0,_decompose:function(){return this._applyMatrix?null:this._decomposed||(this._decomposed=this._matrix.decompose())},getRotation:function(){var e=this._decompose();return e?e.rotation:0},setRotation:function(e){var t=this.getRotation();if(null!=t&&null!=e){var i=this._decomposed;this.rotate(e-t),i&&(i.rotation=e,this._decomposed=i)}},getScaling:function(){var e=this._decompose(),t=e&&e.scaling;return new p(t?t.x:1,t?t.y:1,this,"setScaling")},setScaling:function(){var e=this.getScaling(),t=f.read(arguments,0,{clone:!0,readNull:!0});if(e&&t&&!e.equals(t)){var i=this.getRotation(),n=this._decomposed,a=new C,r=u.isZero;if(r(e.x)||r(e.y))a.translate(n.translation),i&&a.rotate(i),a.scale(t.x,t.y),this._matrix.set(a);else{var o=this.getPosition(!0);a.translate(o),i&&a.rotate(i),a.scale(t.x/e.x,t.y/e.y),i&&a.rotate(-i),a.translate(o.negate()),this.transform(a)}n&&(n.scaling=t,this._decomposed=n)}},getMatrix:function(){return this._matrix},setMatrix:function(){var e=this._matrix;e.set.apply(e,arguments)},getGlobalMatrix:function(e){var t=this._globalMatrix;if(t)for(var i=this._parent,n=[];i;){if(!i._globalMatrix){t=null;for(var a=0,r=n.length;a<r;a++)n[a]._globalMatrix=null;break}n.push(i),i=i._parent}return t||(t=this._globalMatrix=this._matrix.clone(),(i=this._parent)&&t.prepend(i.getGlobalMatrix(!0))),e?t:t.clone()},getViewMatrix:function(){return this.getGlobalMatrix().prepend(this.getView()._matrix)},getApplyMatrix:function(){return this._applyMatrix},setApplyMatrix:function(e){(this._applyMatrix=this._canApplyMatrix&&!!e)&&this.transform(null,!0)},getTransformContent:"#getApplyMatrix",setTransformContent:"#setApplyMatrix"},{getProject:function(){return this._project},_setProject:function(e,t){if(this._project!==e){this._project&&this._installEvents(!1),this._project=e;for(var i=this._children,n=0,a=i&&i.length;n<a;n++)i[n]._setProject(e);t=!0}t&&this._installEvents(!0)},getView:function(){return this._project._view},_installEvents:function e(t){e.base.call(this,t);for(var i=this._children,n=0,a=i&&i.length;n<a;n++)i[n]._installEvents(t)},getLayer:function(){for(var e=this;e=e._parent;)if(e instanceof w)return e;return null},getParent:function(){return this._parent},setParent:function(e){return e.addChild(this)},_getOwner:"#getParent",getChildren:function(){return this._children},setChildren:function(e){this.removeChildren(),this.addChildren(e)},getFirstChild:function(){return this._children&&this._children[0]||null},getLastChild:function(){return this._children&&this._children[this._children.length-1]||null},getNextSibling:function(){var e=this._getOwner();return e&&e._children[this._index+1]||null},getPreviousSibling:function(){var e=this._getOwner();return e&&e._children[this._index-1]||null},getIndex:function(){return this._index},equals:function(e){return e===this||e&&this._class===e._class&&this._style.equals(e._style)&&this._matrix.equals(e._matrix)&&this._locked===e._locked&&this._visible===e._visible&&this._blendMode===e._blendMode&&this._opacity===e._opacity&&this._clipMask===e._clipMask&&this._guide===e._guide&&this._equals(e)||!1},_equals:function(e){return a.equals(this._children,e._children)},clone:function(e){var i=new this.constructor(S.NO_INSERT),n=this._children,r=a.pick(e?e.insert:t,e===t||!0===e),o=a.pick(e?e.deep:t,!0);n&&i.copyAttributes(this),(!n||o)&&i.copyContent(this),n||i.copyAttributes(this),r&&i.insertAbove(this);var s=this._name,l=this._parent;if(s&&l){n=l._children;for(var h=s,d=1;n[s];)s=h+" "+d++;s!==h&&i.setName(s)}return i},copyContent:function(e){for(var t=e._children,i=0,n=t&&t.length;i<n;i++)this.addChild(t[i].clone(!1),!0)},copyAttributes:function(e,t){this.setStyle(e._style);for(var i=["_locked","_visible","_blendMode","_opacity","_clipMask","_guide"],n=0,r=i.length;n<r;n++){var o=i[n];e.hasOwnProperty(o)&&(this[o]=e[o])}t||this._matrix.set(e._matrix,!0),this.setApplyMatrix(e._applyMatrix),this.setPivot(e._pivot),this.setSelection(e._selection);var s=e._data,l=e._name;this._data=s?a.clone(s):null,l&&this.setName(l)},rasterize:function(e,i){var n,r,o;a.isPlainObject(e)?(n=e.resolution,r=e.insert,o=e.raster):(n=e,r=i),o||(o=new P(S.NO_INSERT));var s=this.getStrokeBounds(),l=(n||this.getView().getResolution())/72,h=s.getTopLeft().floor(),d=s.getBottomRight().ceil(),c=new m(d.subtract(h)),u=c.multiply(l);if(o.setSize(u,!0),!u.isZero()){var g=o.getContext(!0),f=(new C).scale(l).translate(h.negate());g.save(),f.applyToContext(g),this.draw(g,new a({matrices:[f]})),g.restore()}return o._matrix.set((new C).translate(h.add(c.divide(2))).scale(1/l)),(r===t||r)&&o.insertAbove(this),o},contains:function(){var e=this._matrix;return e.isInvertible()&&!!this._contains(e._inverseTransform(f.read(arguments)))},_contains:function(e){var t=this._children;if(t){for(var i=t.length-1;i>=0;i--)if(t[i].contains(e))return!0;return!1}return e.isInside(this.getInternalBounds())},isInside:function(){return I.read(arguments).contains(this.getBounds())},_asPathItem:function(){return new R.Rectangle({rectangle:this.getInternalBounds(),matrix:this._matrix,insert:!1})},intersects:function(e,t){return e instanceof S&&this._asPathItem().getIntersections(e._asPathItem(),null,t,!0).length>0}},new function(){function e(){var e=arguments;return this._hitTest(f.read(e),_.getOptions(e))}function t(){var e=arguments,t=f.read(e),i=_.getOptions(e),n=[];return this._hitTest(t,new a({all:n},i)),n}function i(e,t,i,n){var a=this._children;if(a)for(var r=a.length-1;r>=0;r--){var o=a[r],s=o!==n&&o._hitTest(e,t,i);if(s&&!t.all)return s}return null}return x.inject({hitTest:e,hitTestAll:t,_hitTest:i}),{hitTest:e,hitTestAll:t,_hitTestChildren:i}},{_hitTest:function(e,t,i){if(this._locked||!this._visible||this._guide&&!t.guides||this.isEmpty())return null;var n=this._matrix,r=i?i.appended(n):this.getGlobalMatrix().prepend(this.getView()._matrix),o=Math.max(t.tolerance,1e-12),s=t._tolerancePadding=new m(R._getStrokePadding(o,n._shiftless().invert()));if(!(e=n._inverseTransform(e))||!this._children&&!this.getBounds({internal:!0,stroke:!0,handle:!0}).expand(s.multiply(2))._containsPoint(e))return null;var l,h,d=!(t.guides&&!this._guide||t.selected&&!this.isSelected()||t.type&&t.type!==a.hyphenate(this._class)||t.class&&!(this instanceof t.class)),c=t.match,u=this;function g(e){return e&&c&&!c(e)&&(e=null),e&&t.all&&t.all.push(e),e}function f(t,i){var n=i?l["get"+i]():u.getPosition();if(e.subtract(n).divide(s).length<=1)return new _(t,u,{name:i?a.hyphenate(i):t,point:n})}var p=t.position,v=t.center,I=t.bounds;if(d&&this._parent&&(p||v||I)){if((v||I)&&(l=this.getInternalBounds()),!(h=p&&f("position")||v&&f("center","Center"))&&I)for(var y=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],C=0;C<8&&!h;C++)h=f("bounds",y[C]);h=g(h)}return h||(h=this._hitTestChildren(e,t,r)||d&&g(this._hitTestSelf(e,t,r,this.getStrokeScaling()?null:r._shiftless().invert()))||null),h&&h.point&&(h.point=n.transform(h.point)),h},_hitTestSelf:function(e,t){if(t.fill&&this.hasFill()&&this._contains(e))return new _("fill",this)},matches:function(e,t){var i=typeof e;if("object"===i){for(var n in e)if(e.hasOwnProperty(n)&&!this.matches(n,e[n]))return!1;return!0}if("function"===i)return e(this);if("match"===e)return t(this);var r=/^(empty|editable)$/.test(e)?this["is"+a.capitalize(e)]():"type"===e?a.hyphenate(this._class):this[e];if("class"===e){if("function"==typeof t)return this instanceof t;r=this._class}if("function"==typeof t)return!!t(r);if(t){if(t.test)return t.test(r);if(a.isPlainObject(t))return function e(t,i){for(var n in t)if(t.hasOwnProperty(n)){var r=t[n],o=i[n];if(a.isPlainObject(r)&&a.isPlainObject(o)){if(!e(r,o))return!1}else if(!a.equals(r,o))return!1}return!0}(t,r)}return a.equals(r,t)},getItems:function(e){return S._getItems(this,e,this._matrix)},getItem:function(e){return S._getItems(this,e,this._matrix,null,!0)[0]||null},statics:{_getItems:function e(t,i,n,r,o){if(!r){var s="object"==typeof i&&i,l=s&&s.overlapping,h=s&&s.inside,d=(y=l||h)&&I.read([y]);r={items:[],recursive:s&&!1!==s.recursive,inside:!!h,overlapping:!!l,rect:d,path:l&&new R.Rectangle({rectangle:d,insert:!1})},s&&(i=a.filter({},i,{recursive:!0,inside:!0,overlapping:!0}))}var c=t._children,u=r.items;n=(d=r.rect)&&(n||new C);for(var g=0,f=c&&c.length;g<f;g++){var p=c[g],m=n&&n.appended(p._matrix),v=!0;if(d){var y=p.getBounds(m);if(!d.intersects(y))continue;d.contains(y)||r.overlapping&&(y.contains(d)||r.path.intersects(p,m))||(v=!1)}if(v&&p.matches(i)&&(u.push(p),o)||(!1!==r.recursive&&e(p,i,m,r,o),o&&u.length>0))break}return u}}},{importJSON:function(e){var t=a.importJSON(e,this);return t!==this?this.addChild(t):t},addChild:function(e){return this.insertChild(t,e)},insertChild:function(e,t){var i=t?this.insertChildren(e,[t]):null;return i&&i[0]},addChildren:function(e){return this.insertChildren(this._children.length,e)},insertChildren:function(e,t){var i=this._children;if(i&&t&&t.length>0){for(var n={},r=(t=a.slice(t)).length-1;r>=0;r--){var o=(d=t[r])&&d._id;!d||n[o]?t.splice(r,1):(d._remove(!1,!0),n[o]=!0)}a.splice(i,t,e,0);for(var s=this._project,l=s._changes,h=(r=0,t.length);r<h;r++){var d,c=(d=t[r])._name;d._parent=this,d._setProject(s,!0),c&&d.setName(c),l&&d._changed(5)}this._changed(11)}else t=null;return t},_insertItem:"#insertChild",_insertAt:function(e,t){var i=e&&e._getOwner(),n=e!==this&&i?this:null;return n&&(n._remove(!1,!0),i._insertItem(e._index+t,n)),n},insertAbove:function(e){return this._insertAt(e,1)},insertBelow:function(e){return this._insertAt(e,0)},sendToBack:function(){var e=this._getOwner();return e?e._insertItem(0,this):null},bringToFront:function(){var e=this._getOwner();return e?e._insertItem(t,this):null},appendTop:"#addChild",appendBottom:function(e){return this.insertChild(0,e)},moveAbove:"#insertAbove",moveBelow:"#insertBelow",addTo:function(e){return e._insertItem(t,this)},copyTo:function(e){return this.clone(!1).addTo(e)},reduce:function(e){var t=this._children;if(t&&1===t.length){var i=t[0].reduce(e);return this._parent?(i.insertAbove(this),this.remove()):i.remove(),i}return this},_removeNamed:function(){var e=this._getOwner();if(e){var t=e._children,i=e._namedChildren,n=this._name,a=i[n],r=a?a.indexOf(this):-1;-1!==r&&(t[n]==this&&delete t[n],a.splice(r,1),a.length?t[n]=a[0]:delete i[n])}},_remove:function(e,t){var i=this._getOwner(),n=this._project,r=this._index;return this._style&&this._style._dispose(),!!i&&(this._name&&this._removeNamed(),null!=r&&(n._activeLayer===this&&(n._activeLayer=this.getNextSibling()||this.getPreviousSibling()),a.splice(i._children,null,r,1)),this._installEvents(!1),e&&n._changes&&this._changed(5),t&&i._changed(11,this),this._parent=null,!0)},remove:function(){return this._remove(!0,!0)},replaceWith:function(e){var t=e&&e.insertBelow(this);return t&&this.remove(),t},removeChildren:function(e,t){if(!this._children)return null;e=e||0,t=a.pick(t,this._children.length);for(var i=a.splice(this._children,null,e,t-e),n=i.length-1;n>=0;n--)i[n]._remove(!0,!1);return i.length>0&&this._changed(11),i},clear:"#removeChildren",reverseChildren:function(){if(this._children){this._children.reverse();for(var e=0,t=this._children.length;e<t;e++)this._children[e]._index=e;this._changed(11)}},isEmpty:function(e){var t=this._children,i=t?t.length:0;if(e){for(var n=0;n<i;n++)if(!t[n].isEmpty(e))return!1;return!0}return!i},isEditable:function(){for(var e=this;e;){if(!e._visible||e._locked)return!1;e=e._parent}return!0},hasFill:function(){return this.getStyle().hasFill()},hasStroke:function(){return this.getStyle().hasStroke()},hasShadow:function(){return this.getStyle().hasShadow()},_getOrder:function(e){function t(e){var t=[];do{t.unshift(e)}while(e=e._parent);return t}for(var i=t(this),n=t(e),a=0,r=Math.min(i.length,n.length);a<r;a++)if(i[a]!=n[a])return i[a]._index<n[a]._index?1:-1;return 0},hasChildren:function(){return this._children&&this._children.length>0},isInserted:function(){return!!this._parent&&this._parent.isInserted()},isAbove:function(e){return-1===this._getOrder(e)},isBelow:function(e){return 1===this._getOrder(e)},isParent:function(e){return this._parent===e},isChild:function(e){return e&&e._parent===this},isDescendant:function(e){for(var t=this;t=t._parent;)if(t===e)return!0;return!1},isAncestor:function(e){return!!e&&e.isDescendant(this)},isSibling:function(e){return this._parent===e._parent},isGroupedWith:function(e){for(var t=this._parent;t;){if(t._parent&&/^(Group|Layer|CompoundPath)$/.test(t._class)&&e.isDescendant(t))return!0;t=t._parent}return!1}},a.each(["rotate","scale","shear","skew"],function(e){var t="rotate"===e;this[e]=function(){var i=arguments,n=(t?a:f).read(i),r=f.read(i,0,{readNull:!0});return this.transform((new C)[e](n,r||this.getPosition(!0)))}},{translate:function(){var e=new C;return this.transform(e.translate.apply(e,arguments))},transform:function(e,t,i){var n=this._matrix,a=e&&!e.isIdentity(),r=i&&this._canApplyMatrix||this._applyMatrix&&(a||!n.isIdentity()||t&&this._children);if(!a&&!r)return this;if(a){!e.isInvertible()&&n.isInvertible()&&(n._backup=n.getValues()),n.prepend(e,!0);var o=this._style,s=o.getFillColor(!0),l=o.getStrokeColor(!0);s&&s.transform(e),l&&l.transform(e)}if(r&&(r=this._transformContent(n,t,i))){var h=this._pivot;h&&n._transformPoint(h,h,!0),n.reset(!0),i&&this._canApplyMatrix&&(this._applyMatrix=!0)}var d=this._bounds,c=this._position;(a||r)&&this._changed(25);var u=a&&d&&e.decompose();if(u&&u.skewing.isZero()&&u.rotation%90==0){for(var g in d){var f=d[g];if(f.nonscaling)delete d[g];else if(r||!f.internal){var p=f.rect;e._transformBounds(p,p)}}this._bounds=d;var m=d[this._getBoundsCacheKey(this._boundsOptions||{})];m&&(this._position=this._getPositionFromBounds(m.rect))}else a&&c&&this._pivot&&(this._position=e._transformPoint(c,c));return this},_transformContent:function(e,t,i){var n=this._children;if(n){for(var a=0,r=n.length;a<r;a++)n[a].transform(e,t,i);return!0}},globalToLocal:function(){return this.getGlobalMatrix(!0)._inverseTransform(f.read(arguments))},localToGlobal:function(){return this.getGlobalMatrix(!0)._transformPoint(f.read(arguments))},parentToLocal:function(){return this._matrix._inverseTransform(f.read(arguments))},localToParent:function(){return this._matrix._transformPoint(f.read(arguments))},fitBounds:function(e,t){e=I.read(arguments);var i=this.getBounds(),n=i.height/i.width,a=e.height/e.width,r=(t?n>a:n<a)?e.width/i.width:e.height/i.height,o=new I(new f,new m(i.width*r,i.height*r));o.setCenter(e.getCenter()),this.setBounds(o)}}),{_setStyles:function(e,t,i){var n=this._style,a=this._matrix;if(n.hasFill()&&(e.fillStyle=n.getFillColor().toCanvasStyle(e,a)),n.hasStroke()){e.strokeStyle=n.getStrokeColor().toCanvasStyle(e,a),e.lineWidth=n.getStrokeWidth();var r=n.getStrokeJoin(),o=n.getStrokeCap(),s=n.getMiterLimit();if(r&&(e.lineJoin=r),o&&(e.lineCap=o),s&&(e.miterLimit=s),le.support.nativeDash){var l=n.getDashArray(),h=n.getDashOffset();l&&l.length&&("setLineDash"in e?(e.setLineDash(l),e.lineDashOffset=h):(e.mozDash=l,e.mozDashOffset=h))}}if(n.hasShadow()){var d=t.pixelRatio||1,c=i._shiftless().prepend((new C).scale(d,d)),u=c.transform(new f(n.getShadowBlur(),0)),g=c.transform(this.getShadowOffset());e.shadowColor=n.getShadowColor().toCanvasStyle(e),e.shadowBlur=u.getLength(),e.shadowOffsetX=g.x,e.shadowOffsetY=g.y}},draw:function(e,t,i){if(this._updateVersion=this._project._updateVersion,this._visible&&0!==this._opacity){var n=t.matrices,a=t.viewMatrix,r=this._matrix,o=n[n.length-1].appended(r);if(o.isInvertible()){a=a?a.appended(o):o,n.push(o),t.updateMatrix&&(this._globalMatrix=o);var s,l,h,d=this._blendMode,c=u.clamp(this._opacity,0,1),g="normal"===d,f=re.nativeModes[d],p=g&&1===c||t.dontStart||t.clip||(f||g&&c<1)&&this._canComposite(),m=t.pixelRatio||1;if(!p){var v=this.getStrokeBounds(a);if(!v.width||!v.height)return void n.pop();h=t.offset,l=t.offset=v.getTopLeft().floor(),s=e,e=ae.getContext(v.getSize().ceil().add(1).multiply(m)),1!==m&&e.scale(m,m)}e.save();var I=i?i.appended(r):this._canScaleStroke&&!this.getStrokeScaling(!0)&&a,y=!p&&t.clipItem,C=!I||y;if(p?(e.globalAlpha=c,f&&(e.globalCompositeOperation=d)):C&&e.translate(-l.x,-l.y),C&&(p?r:a).applyToContext(e),y&&t.clipItem.draw(e,t.extend({clip:!0})),I){e.setTransform(m,0,0,m,0,0);var M=t.offset;M&&e.translate(-M.x,-M.y)}this._draw(e,t,a,I),e.restore(),n.pop(),t.clip&&!t.dontFinish&&e.clip(this.getFillRule()),p||(re.process(d,e,s,c,l.subtract(h).multiply(m)),ae.release(e),t.offset=h)}}},_isUpdated:function(e){var t=this._parent;if(t instanceof F)return t._isUpdated(e);var i=this._updateVersion===e;return!i&&t&&t._visible&&t._isUpdated(e)&&(this._updateVersion=e,i=!0),i},_drawSelection:function(e,t,i,n,a){var r=this._selection,o=1&r,s=2&r||o&&this._selectBounds,l=4&r;if(this._drawSelected||(o=!1),(o||s||l)&&this._isUpdated(a)){var h,d=this.getSelectedColor(!0)||(h=this.getLayer())&&h.getSelectedColor(!0),c=t.appended(this.getGlobalMatrix(!0)),u=i/2;if(e.strokeStyle=e.fillStyle=d?d.toCanvasStyle(e):"#009dec",o&&this._drawSelected(e,c,n),l){var g=this.getPosition(!0),f=this._parent,p=f?f.localToGlobal(g):g,m=p.x,v=p.y;e.beginPath(),e.arc(m,v,u,0,2*Math.PI,!0),e.stroke();for(var I=[[0,-1],[1,0],[0,1],[-1,0]],y=u,C=i+1,M=0;M<4;M++){var x=I[M],S=x[0],b=x[1];e.moveTo(m+S*y,v+b*y),e.lineTo(m+S*C,v+b*C),e.stroke()}}if(s){var w=c._transformCorners(this.getInternalBounds());for(e.beginPath(),M=0;M<8;M++)e[M?"lineTo":"moveTo"](w[M],w[++M]);for(e.closePath(),e.stroke(),M=0;M<8;M++)e.fillRect(w[M]-u,w[++M]-u,i,i)}}},_canComposite:function(){return!1}},a.each(["down","drag","up","move"],function(e){this["removeOn"+a.capitalize(e)]=function(){var t={};return t[e]=!0,this.removeOn(t)}},{removeOn:function(e){for(var t in e)if(e[t]){var i="mouse"+t,n=this._project,a=n._removeSets=n._removeSets||{};a[i]=a[i]||{},a[i][this._id]=this}return this}}),{tween:function(e,t,i){i||(i=t,t=e,e=null,i||(i=t,t=null));var n=i&&i.easing,a=i&&i.start,r=null!=i&&("number"==typeof i?i:i.duration),o=new ie(this,e,t,r,n,a);return r&&this.on("frame",function e(t){o._handleFrame(1e3*t.time),o.running||this.off("frame",e)}),o},tweenTo:function(e,t){return this.tween(null,e,t)},tweenFrom:function(e,t){return this.tween(e,null,t)}}),b=S.extend({_class:"Group",_selectBounds:!1,_selectChildren:!0,_serializeFields:{children:[]},initialize:function(e){this._children=[],this._namedChildren={},this._initialize(e)||this.addChildren(Array.isArray(e)?e:arguments)},_changed:function e(i){e.base.call(this,i),2050&i&&(this._clipItem=t)},_getClipItem:function(){var e=this._clipItem;if(e===t){e=null;for(var i=this._children,n=0,a=i.length;n<a;n++)if(i[n]._clipMask){e=i[n];break}this._clipItem=e}return e},isClipped:function(){return!!this._getClipItem()},setClipped:function(e){var t=this.getFirstChild();t&&t.setClipMask(e)},_getBounds:function e(t,i){var n=this._getClipItem();return n?n._getCachedBounds(n._matrix.prepended(t),a.set({},i,{stroke:!1})):e.base.call(this,t,i)},_hitTestChildren:function e(t,i,n){var a=this._getClipItem();return(!a||a.contains(t))&&e.base.call(this,t,i,n,a)},_draw:function(e,t){var i=t.clip,n=!i&&this._getClipItem();t=t.extend({clipItem:n,clip:!1}),i?(e.beginPath(),t.dontStart=t.dontFinish=!0):n&&n.draw(e,t.extend({clip:!0}));for(var a=this._children,r=0,o=a.length;r<o;r++){var s=a[r];s!==n&&s.draw(e,t)}}}),w=b.extend({_class:"Layer",initialize:function(){b.apply(this,arguments)},_getOwner:function(){return this._parent||null!=this._index&&this._project},isInserted:function e(){return this._parent?e.base.call(this):null!=this._index},activate:function(){this._project._activeLayer=this},_hitTestSelf:function(){}}),A=S.extend({_class:"Shape",_applyMatrix:!1,_canApplyMatrix:!1,_canScaleStroke:!0,_serializeFields:{type:null,size:null,radius:null},initialize:function(e,t){this._initialize(e,t)},_equals:function(e){return this._type===e._type&&this._size.equals(e._size)&&a.equals(this._radius,e._radius)},copyContent:function(e){this.setType(e._type),this.setSize(e._size),this.setRadius(e._radius)},getType:function(){return this._type},setType:function(e){this._type=e},getShape:"#getType",setShape:"#setType",getSize:function(){var e=this._size;return new v(e.width,e.height,this,"setSize")},setSize:function(){var e=m.read(arguments);if(this._size){if(!this._size.equals(e)){var t=this._type,i=e.width,n=e.height;"rectangle"===t?this._radius.set(m.min(this._radius,e.divide(2).abs())):"circle"===t?(i=n=(i+n)/2,this._radius=i/2):"ellipse"===t&&this._radius._set(i/2,n/2),this._size._set(i,n),this._changed(9)}}else this._size=e.clone()},getRadius:function(){var e=this._radius;return"circle"===this._type?e:new v(e.width,e.height,this,"setRadius")},setRadius:function(e){var t=this._type;if("circle"===t){if(e===this._radius)return;var i=2*e;this._radius=e,this._size._set(i,i)}else if(e=m.read(arguments),this._radius){if(this._radius.equals(e))return;this._radius.set(e),"rectangle"===t?(i=m.max(this._size,e.multiply(2)),this._size.set(i)):"ellipse"===t&&this._size._set(2*e.width,2*e.height)}else this._radius=e.clone();this._changed(9)},isEmpty:function(){return!1},toPath:function(e){var i=new(R[a.capitalize(this._type)])({center:new f,size:this._size,radius:this._radius,insert:!1});return i.copyAttributes(this),le.settings.applyMatrix&&i.setApplyMatrix(!0),(e===t||e)&&i.insertAbove(this),i},toShape:"#clone",_asPathItem:function(){return this.toPath(!1)},_draw:function(e,t,i,n){var a=this._style,r=a.hasFill(),o=a.hasStroke(),s=t.dontFinish||t.clip,l=!n;if(r||o||s){var h=this._type,d=this._radius,c="circle"===h;if(t.dontStart||e.beginPath(),l&&c)e.arc(0,0,d,0,2*Math.PI,!0);else{var u=c?d:d.width,g=c?d:d.height,f=this._size,p=f.width,m=f.height;if(l&&"rectangle"===h&&0===u&&0===g)e.rect(-p/2,-m/2,p,m);else{var v=p/2,I=m/2,y=.44771525016920644,C=u*y,M=g*y,x=[-v,-I+g,-v,-I+M,-v+C,-I,-v+u,-I,v-u,-I,v-C,-I,v,-I+M,v,-I+g,v,I-g,v,I-M,v-C,I,v-u,I,-v+u,I,-v+C,I,-v,I-M,-v,I-g];n&&n.transform(x,x,32),e.moveTo(x[0],x[1]),e.bezierCurveTo(x[2],x[3],x[4],x[5],x[6],x[7]),v!==u&&e.lineTo(x[8],x[9]),e.bezierCurveTo(x[10],x[11],x[12],x[13],x[14],x[15]),I!==g&&e.lineTo(x[16],x[17]),e.bezierCurveTo(x[18],x[19],x[20],x[21],x[22],x[23]),v!==u&&e.lineTo(x[24],x[25]),e.bezierCurveTo(x[26],x[27],x[28],x[29],x[30],x[31])}}e.closePath()}!s&&(r||o)&&(this._setStyles(e,t,i),r&&(e.fill(a.getFillRule()),e.shadowColor="rgba(0,0,0,0)"),o&&e.stroke())},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_getBounds:function(e,t){var i=new I(this._size).setCenter(0,0),n=this._style,a=t.stroke&&n.hasStroke()&&n.getStrokeWidth();return e&&(i=e._transformBounds(i)),a?i.expand(R._getStrokePadding(a,this._getStrokeMatrix(e,t))):i}},new function(){function e(e,t,i){var n=e._radius;if(!n.isZero())for(var a=e._size.divide(2),r=1;r<=4;r++){var o=new f(r>1&&r<4?-1:1,r>2?-1:1),s=o.multiply(a),l=s.subtract(o.multiply(n));if(new I(i?s.add(o.multiply(i)):s,l).contains(t))return{point:l,quadrant:r}}}function t(e,t,i,n){var a=e.divide(t);return(!n||a.isInQuadrant(n))&&a.subtract(a.normalize()).multiply(t).divide(i).length<=1}return{_contains:function t(i){if("rectangle"===this._type){var n=e(this,i);return n?i.subtract(n.point).divide(this._radius).getLength()<=1:t.base.call(this,i)}return i.divide(this.size).getLength()<=.5},_hitTestSelf:function i(n,a,r,o){var s=!1,l=this._style,h=a.stroke&&l.hasStroke(),d=a.fill&&l.hasFill();if(h||d){var c=this._type,u=this._radius,g=h?l.getStrokeWidth()/2:0,f=a._tolerancePadding.add(R._getStrokePadding(g,!l.getStrokeScaling()&&o));if("rectangle"===c){var p=f.multiply(2),m=e(this,n,p);if(m)s=t(n.subtract(m.point),u,f,m.quadrant);else{var v=new I(this._size).setCenter(0,0),y=v.expand(p),C=v.expand(p.negate());s=y._containsPoint(n)&&!C._containsPoint(n)}}else s=t(n,u,f)}return s?new _(h?"stroke":"fill",this):i.base.apply(this,arguments)}}},{statics:new function(){function e(e,t,i,n,r){var o=a.create(A.prototype);return o._type=e,o._size=i,o._radius=n,o._initialize(a.getNamed(r),t),o}return{Circle:function(){var t=arguments,i=f.readNamed(t,"center"),n=a.readNamed(t,"radius");return e("circle",i,new m(2*n),n,t)},Rectangle:function(){var t=arguments,i=I.readNamed(t,"rectangle"),n=m.min(m.readNamed(t,"radius"),i.getSize(!0).divide(2));return e("rectangle",i.getCenter(!0),i.getSize(!0),n,t)},Ellipse:function(){var t=arguments,i=A._readEllipse(t),n=i.radius;return e("ellipse",i.center,n.multiply(2),n,t)},_readEllipse:function(e){var t,i;if(a.hasNamed(e,"radius"))t=f.readNamed(e,"center"),i=m.readNamed(e,"radius");else{var n=I.readNamed(e,"rectangle");t=n.getCenter(!0),i=n.getSize(!0).divide(2)}return{center:t,radius:i}}}}}),P=S.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!1,handle:!1},_serializeFields:{crossOrigin:null,source:null},_prioritize:["crossOrigin"],_smoothing:"low",beans:!0,initialize:function(e,i){if(!this._initialize(e,i!==t&&f.read(arguments))){var a,r=typeof e,o="string"===r?n.getElementById(e):"object"===r?e:null;if(o&&o!==S.NO_INSERT)if(o.getContext||null!=o.naturalHeight)a=o;else if(o){var s=m.read(arguments);s.isZero()||(a=ae.getCanvas(s))}a?this.setImage(a):this.setSource(e)}this._size||(this._size=new m,this._loaded=!1)},_equals:function(e){return this.getSource()===e.getSource()},copyContent:function(e){var t=e._image,i=e._canvas;if(t)this._setImage(t);else if(i){var n=ae.getCanvas(e._size);n.getContext("2d").drawImage(i,0,0),this._setImage(n)}this._crossOrigin=e._crossOrigin},getSize:function(){var e=this._size;return new v(e?e.width:0,e?e.height:0,this,"setSize")},setSize:function(e,t){var i=m.read(arguments);if(i.equals(this._size))t&&this.clear();else if(i.width>0&&i.height>0){var n=!t&&this.getElement();this._setImage(ae.getCanvas(i)),n&&this.getContext(!0).drawImage(n,0,0,i.width,i.height)}else this._canvas&&ae.release(this._canvas),this._size=i.clone()},getWidth:function(){return this._size?this._size.width:0},setWidth:function(e){this.setSize(e,this.getHeight())},getHeight:function(){return this._size?this._size.height:0},setHeight:function(e){this.setSize(this.getWidth(),e)},getLoaded:function(){return this._loaded},isEmpty:function(){var e=this._size;return!e||0===e.width&&0===e.height},getResolution:function(){var e=this._matrix,t=new f(0,0).transform(e),i=new f(1,0).transform(e).subtract(t),n=new f(0,1).transform(e).subtract(t);return new m(72/i.getLength(),72/n.getLength())},getPpi:"#getResolution",getImage:function(){return this._image},setImage:function(e){var t=this;function i(e){var i=t.getView(),n=e&&e.type||"load";i&&t.responds(n)&&(le=i._scope,t.emit(n,new K(e)))}this._setImage(e),this._loaded?setTimeout(i,0):e&&q.add(e,{load:function(n){t._setImage(e),i(n)},error:i})},_setImage:function(e){this._canvas&&ae.release(this._canvas),e&&e.getContext?(this._image=null,this._canvas=e,this._loaded=!0):(this._image=e,this._canvas=null,this._loaded=!!(e&&e.src&&e.complete)),this._size=new m(e?e.naturalWidth||e.width:0,e?e.naturalHeight||e.height:0),this._context=null,this._changed(1033)},getCanvas:function(){if(!this._canvas){var e=ae.getContext(this._size);try{this._image&&e.drawImage(this._image,0,0),this._canvas=e.canvas}catch(t){ae.release(e)}}return this._canvas},setCanvas:"#setImage",getContext:function(e){return this._context||(this._context=this.getCanvas().getContext("2d")),e&&(this._image=null,this._changed(1025)),this._context},setContext:function(e){this._context=e},getSource:function(){var e=this._image;return e&&e.src||this.toDataURL()},setSource:function(t){var i=new e.Image,n=this._crossOrigin;n&&(i.crossOrigin=n),t&&(i.src=t),this.setImage(i)},getCrossOrigin:function(){var e=this._image;return e&&e.crossOrigin||this._crossOrigin||""},setCrossOrigin:function(e){this._crossOrigin=e;var t=this._image;t&&(t.crossOrigin=e)},getSmoothing:function(){return this._smoothing},setSmoothing:function(e){this._smoothing="string"==typeof e?e:e?"low":"off",this._changed(257)},getElement:function(){return this._canvas||this._loaded&&this._image}},{beans:!1,getSubCanvas:function(){var e=I.read(arguments),t=ae.getContext(e.getSize());return t.drawImage(this.getCanvas(),e.x,e.y,e.width,e.height,0,0,e.width,e.height),t.canvas},getSubRaster:function(){var e=I.read(arguments),t=new P(S.NO_INSERT);return t._setImage(this.getSubCanvas(e)),t.translate(e.getCenter().subtract(this.getSize().divide(2))),t._matrix.prepend(this._matrix),t.insertAbove(this),t},toDataURL:function(){var e=this._image,t=e&&e.src;if(/^data:/.test(t))return t;var i=this.getCanvas();return i?i.toDataURL.apply(i,arguments):null},drawImage:function(e){var t=f.read(arguments,1);this.getContext(!0).drawImage(e,t.x,t.y)},getAverageColor:function(e){var t,i;if(e?e instanceof E?(i=e,t=e.getBounds()):"object"==typeof e&&("width"in e?t=new I(e):"x"in e&&(t=new I(e.x-.5,e.y-.5,1,1))):t=this.getBounds(),!t)return null;var n=Math.min(t.width,32),r=Math.min(t.height,32),o=P._sampleContext;o?o.clearRect(0,0,33,33):o=P._sampleContext=ae.getContext(new m(32)),o.save();var s=(new C).scale(n/t.width,r/t.height).translate(-t.x,-t.y);s.applyToContext(o),i&&i.draw(o,new a({clip:!0,matrices:[s]})),this._matrix.applyToContext(o);var l=this.getElement(),h=this._size;l&&o.drawImage(l,-h.width/2,-h.height/2),o.restore();for(var d=o.getImageData(.5,.5,Math.ceil(n),Math.ceil(r)).data,c=[0,0,0],u=0,g=0,f=d.length;g<f;g+=4){var p=d[g+3];u+=p,p/=255,c[0]+=d[g]*p,c[1]+=d[g+1]*p,c[2]+=d[g+2]*p}for(g=0;g<3;g++)c[g]/=u;return u?N.read(c):null},getPixel:function(){var e=f.read(arguments),t=this.getContext().getImageData(e.x,e.y,1,1).data;return new N("rgb",[t[0]/255,t[1]/255,t[2]/255],t[3]/255)},setPixel:function(){var e=arguments,t=f.read(e),i=N.read(e),n=i._convert("rgb"),a=i._alpha,r=this.getContext(!0),o=r.createImageData(1,1),s=o.data;s[0]=255*n[0],s[1]=255*n[1],s[2]=255*n[2],s[3]=null!=a?255*a:255,r.putImageData(o,t.x,t.y)},clear:function(){var e=this._size;this.getContext(!0).clearRect(0,0,e.width+1,e.height+1)},createImageData:function(){var e=m.read(arguments);return this.getContext().createImageData(e.width,e.height)},getImageData:function(){var e=I.read(arguments);return e.isEmpty()&&(e=new I(this._size)),this.getContext().getImageData(e.x,e.y,e.width,e.height)},putImageData:function(e){var t=f.read(arguments,1);this.getContext(!0).putImageData(e,t.x,t.y)},setImageData:function(e){this.setSize(e),this.getContext(!0).putImageData(e,0,0)},_getBounds:function(e,t){var i=new I(this._size).setCenter(0,0);return e?e._transformBounds(i):i},_hitTestSelf:function(e){if(this._contains(e)){var t=this;return new _("pixel",t,{offset:e.add(t._size.divide(2)).round(),color:{get:function(){return t.getPixel(this.offset)}}})}},_draw:function(e,t,i){var n=this.getElement();if(n&&n.width>0&&n.height>0){e.globalAlpha=u.clamp(this._opacity,0,1),this._setStyles(e,t,i);var a=this._smoothing,r="off"===a;V.setPrefixed(e,r?"imageSmoothingEnabled":"imageSmoothingQuality",!r&&a),e.drawImage(n,-this._size.width/2,-this._size.height/2)}},_canComposite:function(){return!0}}),D=S.extend({_class:"SymbolItem",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!0},_serializeFields:{symbol:null},initialize:function(e,i){this._initialize(e,i!==t&&f.read(arguments,1))||this.setDefinition(e instanceof k?e:new k(e))},_equals:function(e){return this._definition===e._definition},copyContent:function(e){this.setDefinition(e._definition)},getDefinition:function(){return this._definition},setDefinition:function(e){this._definition=e,this._changed(9)},getSymbol:"#getDefinition",setSymbol:"#setDefinition",isEmpty:function(){return this._definition._item.isEmpty()},_getBounds:function(e,t){var i=this._definition._item;return i._getCachedBounds(i._matrix.prepended(e),t)},_hitTestSelf:function(e,t,i){var n=t.extend({all:!1}),a=this._definition._item._hitTest(e,n,i);return a&&(a.item=this),a},_draw:function(e,t){this._definition._item.draw(e,t)}}),k=a.extend({_class:"SymbolDefinition",initialize:function(e,t){this._id=g.get(),this.project=le.project,e&&this.setItem(e,t)},_serialize:function(e,t){return t.add(this,function(){return a.serialize([this._class,this._item],e,!1,t)})},_changed:function(e){8&e&&S._clearBoundsCache(this),1&e&&this.project._changed(e)},getItem:function(){return this._item},setItem:function(e,t){e._symbol&&(e=e.clone()),this._item&&(this._item._symbol=null),this._item=e,e.remove(),e.setSelected(!1),t||e.setPosition(new f),e._symbol=this,this._changed(9)},getDefinition:"#getItem",setDefinition:"#setItem",place:function(e){return new D(this,e)},clone:function(){return new k(this._item.clone(!1))},equals:function(e){return e===this||e&&this._item.equals(e._item)||!1}}),_=a.extend({_class:"HitResult",initialize:function(e,t,i){this.type=e,this.item=t,i&&this.inject(i)},statics:{getOptions:function(e){var t=e&&a.read(e);return new a({type:null,tolerance:le.settings.hitTolerance,fill:!t,stroke:!t,segments:!t,handles:!1,ends:!1,position:!1,center:!1,bounds:!1,guides:!1,selected:!1},t)}}}),T=a.extend({_class:"Segment",beans:!0,_selection:0,initialize:function(e,i,n,a,r,o){var s,l,h,d,c=arguments.length;c>0&&(null==e||"object"==typeof e?1===c&&e&&"point"in e?(s=e.point,l=e.handleIn,h=e.handleOut,d=e.selection):(s=e,l=i,h=n,d=a):(s=[e,i],l=n!==t?[n,a]:null,h=r!==t?[r,o]:null)),new z(s,this,"_point"),new z(l,this,"_handleIn"),new z(h,this,"_handleOut"),d&&this.setSelection(d)},_serialize:function(e,t){var i=this._point,n=this._selection,r=n||this.hasHandles()?[i,this._handleIn,this._handleOut]:i;return n&&r.push(n),a.serialize(r,e,!0,t)},_changed:function(e){var t=this._path;if(t){var i,n=t._curves,a=this._index;n&&((!e||e===this._point||e===this._handleIn)&&(i=a>0?n[a-1]:t._closed?n[n.length-1]:null)&&i._changed(),(!e||e===this._point||e===this._handleOut)&&(i=n[a])&&i._changed()),t._changed(41)}},getPoint:function(){return this._point},setPoint:function(){this._point.set(f.read(arguments))},getHandleIn:function(){return this._handleIn},setHandleIn:function(){this._handleIn.set(f.read(arguments))},getHandleOut:function(){return this._handleOut},setHandleOut:function(){this._handleOut.set(f.read(arguments))},hasHandles:function(){return!this._handleIn.isZero()||!this._handleOut.isZero()},isSmooth:function(){var e=this._handleIn,t=this._handleOut;return!e.isZero()&&!t.isZero()&&e.isCollinear(t)},clearHandles:function(){this._handleIn._set(0,0),this._handleOut._set(0,0)},getSelection:function(){return this._selection},setSelection:function(e){var t=this._selection,i=this._path;this._selection=e=e||0,i&&e!==t&&(i._updateSelection(this,t,e),i._changed(257))},_changeSelection:function(e,t){var i=this._selection;this.setSelection(t?i|e:i&~e)},isSelected:function(){return!!(7&this._selection)},setSelected:function(e){this._changeSelection(7,e)},getIndex:function(){return this._index!==t?this._index:null},getPath:function(){return this._path||null},getCurve:function(){var e=this._path,t=this._index;return e?(t>0&&!e._closed&&t===e._segments.length-1&&t--,e.getCurves()[t]||null):null},getLocation:function(){var e=this.getCurve();return e?new B(e,this===e._segment1?0:1):null},getNext:function(){var e=this._path&&this._path._segments;return e&&(e[this._index+1]||this._path._closed&&e[0])||null},smooth:function(e,i,n){var a=e||{},r=a.type,o=a.factor,s=this.getPrevious(),l=this.getNext(),h=(s||this)._point,d=this._point,c=(l||this)._point,u=h.getDistance(d),g=d.getDistance(c);if(r&&"catmull-rom"!==r){if("geometric"!==r)throw new Error("Smoothing method '"+r+"' not supported.");if(s&&l){var p=h.subtract(c),m=o===t?.4:o,v=m*u/(u+g);i||this.setHandleIn(p.multiply(v)),n||this.setHandleOut(p.multiply(v-m))}}else{var I=o===t?.5:o,y=Math.pow(u,I),C=y*y,M=Math.pow(g,I),x=M*M;if(!i&&s){var S=2*x+3*M*y+C,b=3*M*(M+y);this.setHandleIn(0!==b?new f((x*h._x+S*d._x-C*c._x)/b-d._x,(x*h._y+S*d._y-C*c._y)/b-d._y):new f)}!n&&l&&(S=2*C+3*y*M+x,b=3*y*(y+M),this.setHandleOut(0!==b?new f((C*c._x+S*d._x-x*h._x)/b-d._x,(C*c._y+S*d._y-x*h._y)/b-d._y):new f))}},getPrevious:function(){var e=this._path&&this._path._segments;return e&&(e[this._index-1]||this._path._closed&&e[e.length-1])||null},isFirst:function(){return!this._index},isLast:function(){var e=this._path;return e&&this._index===e._segments.length-1||!1},reverse:function(){var e=this._handleIn,t=this._handleOut,i=e.clone();e.set(t),t.set(i)},reversed:function(){return new T(this._point,this._handleOut,this._handleIn)},remove:function(){return!!this._path&&!!this._path.removeSegment(this._index)},clone:function(){return new T(this._point,this._handleIn,this._handleOut)},equals:function(e){return e===this||e&&this._class===e._class&&this._point.equals(e._point)&&this._handleIn.equals(e._handleIn)&&this._handleOut.equals(e._handleOut)||!1},toString:function(){var e=["point: "+this._point];return this._handleIn.isZero()||e.push("handleIn: "+this._handleIn),this._handleOut.isZero()||e.push("handleOut: "+this._handleOut),"{ "+e.join(", ")+" }"},transform:function(e){this._transformCoordinates(e,new Array(6),!0),this._changed()},interpolate:function(e,t,i){var n=1-i,a=i,r=e._point,o=t._point,s=e._handleIn,l=t._handleIn,h=t._handleOut,d=e._handleOut;this._point._set(n*r._x+a*o._x,n*r._y+a*o._y,!0),this._handleIn._set(n*s._x+a*l._x,n*s._y+a*l._y,!0),this._handleOut._set(n*d._x+a*h._x,n*d._y+a*h._y,!0),this._changed()},_transformCoordinates:function(e,t,i){var n=this._point,a=i&&this._handleIn.isZero()?null:this._handleIn,r=i&&this._handleOut.isZero()?null:this._handleOut,o=n._x,s=n._y,l=2;return t[0]=o,t[1]=s,a&&(t[l++]=a._x+o,t[l++]=a._y+s),r&&(t[l++]=r._x+o,t[l++]=r._y+s),e&&(e._transformCoordinates(t,t,l/2),o=t[0],s=t[1],i?(n._x=o,n._y=s,l=2,a&&(a._x=t[l++]-o,a._y=t[l++]-s),r&&(r._x=t[l++]-o,r._y=t[l++]-s)):(a||(t[l++]=o,t[l++]=s),r||(t[l++]=o,t[l++]=s))),t}}),z=f.extend({initialize:function(e,i,n){var a,r,o;if(e)if((a=e[0])!==t)r=e[1];else{var s=e;(a=s.x)===t&&(a=(s=f.read(arguments)).x),r=s.y,o=s.selected}else a=r=0;this._x=a,this._y=r,this._owner=i,i[n]=this,o&&this.setSelected(!0)},_set:function(e,t){return this._x=e,this._y=t,this._owner._changed(this),this},getX:function(){return this._x},setX:function(e){this._x=e,this._owner._changed(this)},getY:function(){return this._y},setY:function(e){this._y=e,this._owner._changed(this)},isZero:function(){var e=u.isZero;return e(this._x)&&e(this._y)},isSelected:function(){return!!(this._owner._selection&this._getSelection())},setSelected:function(e){this._owner._changeSelection(this._getSelection(),e)},_getSelection:function(){var e=this._owner;return this===e._point?1:this===e._handleIn?2:this===e._handleOut?4:0}}),O=a.extend({_class:"Curve",beans:!0,initialize:function(e,t,i,n,a,r,o,s){var l,h,d,c,u,g,f=arguments.length;3===f?(this._path=e,l=t,h=i):f?1===f?"segment1"in e?(l=new T(e.segment1),h=new T(e.segment2)):"point1"in e?(d=e.point1,u=e.handle1,g=e.handle2,c=e.point2):Array.isArray(e)&&(d=[e[0],e[1]],c=[e[6],e[7]],u=[e[2]-e[0],e[3]-e[1]],g=[e[4]-e[6],e[5]-e[7]]):2===f?(l=new T(e),h=new T(t)):4===f?(d=e,u=t,g=i,c=n):8===f&&(d=[e,t],c=[o,s],u=[i-e,n-t],g=[a-o,r-s]):(l=new T,h=new T),this._segment1=l||new T(d,null,u),this._segment2=h||new T(c,g,null)},_serialize:function(e,t){return a.serialize(this.hasHandles()?[this.getPoint1(),this.getHandle1(),this.getHandle2(),this.getPoint2()]:[this.getPoint1(),this.getPoint2()],e,!0,t)},_changed:function(){this._length=this._bounds=t},clone:function(){return new O(this._segment1,this._segment2)},toString:function(){var e=["point1: "+this._segment1._point];return this._segment1._handleOut.isZero()||e.push("handle1: "+this._segment1._handleOut),this._segment2._handleIn.isZero()||e.push("handle2: "+this._segment2._handleIn),e.push("point2: "+this._segment2._point),"{ "+e.join(", ")+" }"},classify:function(){return O.classify(this.getValues())},remove:function(){var e=!1;if(this._path){var t=this._segment2,i=t._handleOut;(e=t.remove())&&this._segment1._handleOut.set(i)}return e},getPoint1:function(){return this._segment1._point},setPoint1:function(){this._segment1._point.set(f.read(arguments))},getPoint2:function(){return this._segment2._point},setPoint2:function(){this._segment2._point.set(f.read(arguments))},getHandle1:function(){return this._segment1._handleOut},setHandle1:function(){this._segment1._handleOut.set(f.read(arguments))},getHandle2:function(){return this._segment2._handleIn},setHandle2:function(){this._segment2._handleIn.set(f.read(arguments))},getSegment1:function(){return this._segment1},getSegment2:function(){return this._segment2},getPath:function(){return this._path},getIndex:function(){return this._segment1._index},getNext:function(){var e=this._path&&this._path._curves;return e&&(e[this._segment1._index+1]||this._path._closed&&e[0])||null},getPrevious:function(){var e=this._path&&this._path._curves;return e&&(e[this._segment1._index-1]||this._path._closed&&e[e.length-1])||null},isFirst:function(){return!this._segment1._index},isLast:function(){var e=this._path;return e&&this._segment1._index===e._curves.length-1||!1},isSelected:function(){return this.getPoint1().isSelected()&&this.getHandle1().isSelected()&&this.getHandle2().isSelected()&&this.getPoint2().isSelected()},setSelected:function(e){this.getPoint1().setSelected(e),this.getHandle1().setSelected(e),this.getHandle2().setSelected(e),this.getPoint2().setSelected(e)},getValues:function(e){return O.getValues(this._segment1,this._segment2,e)},getPoints:function(){for(var e=this.getValues(),t=[],i=0;i<8;i+=2)t.push(new f(e[i],e[i+1]));return t}},{getLength:function(){return null==this._length&&(this._length=O.getLength(this.getValues(),0,1)),this._length},getArea:function(){return O.getArea(this.getValues())},getLine:function(){return new M(this._segment1._point,this._segment2._point)},getPart:function(e,t){return new O(O.getPart(this.getValues(),e,t))},getPartLength:function(e,t){return O.getLength(this.getValues(),e,t)},divideAt:function(e){return this.divideAtTime(e&&e.curve===this?e.time:this.getTimeAt(e))},divideAtTime:function(e,t){var i=null;if(e>=1e-8&&e<=1-1e-8){var n=O.subdivide(this.getValues(),e),a=n[0],r=n[1],o=t||this.hasHandles(),s=this._segment1,l=this._segment2,h=this._path;o&&(s._handleOut._set(a[2]-a[0],a[3]-a[1]),l._handleIn._set(r[4]-r[6],r[5]-r[7]));var d=a[6],c=a[7],u=new T(new f(d,c),o&&new f(a[4]-d,a[5]-c),o&&new f(r[2]-d,r[3]-c));h?(h.insert(s._index+1,u),i=this.getNext()):(this._segment2=u,this._changed(),i=new O(u,l))}return i},splitAt:function(e){var t=this._path;return t?t.splitAt(e):null},splitAtTime:function(e){return this.splitAt(this.getLocationAtTime(e))},divide:function(e,i){return this.divideAtTime(e===t?.5:i?e:this.getTimeAt(e))},split:function(e,i){return this.splitAtTime(e===t?.5:i?e:this.getTimeAt(e))},reversed:function(){return new O(this._segment2.reversed(),this._segment1.reversed())},clearHandles:function(){this._segment1._handleOut._set(0,0),this._segment2._handleIn._set(0,0)},statics:{getValues:function(e,t,i,n){var a=e._point,r=e._handleOut,o=t._handleIn,s=t._point,l=a.x,h=a.y,d=s.x,c=s.y,u=n?[l,h,l,h,d,c,d,c]:[l,h,l+r._x,h+r._y,d+o._x,c+o._y,d,c];return i&&i._transformCoordinates(u,u,4),u},subdivide:function(e,i){var n=e[0],a=e[1],r=e[2],o=e[3],s=e[4],l=e[5],h=e[6],d=e[7];i===t&&(i=.5);var c=1-i,u=c*n+i*r,g=c*a+i*o,f=c*r+i*s,p=c*o+i*l,m=c*s+i*h,v=c*l+i*d,I=c*u+i*f,y=c*g+i*p,C=c*f+i*m,M=c*p+i*v,x=c*I+i*C,S=c*y+i*M;return[[n,a,u,g,I,y,x,S],[x,S,C,M,m,v,h,d]]},getMonoCurves:function(e,t){var i=[],n=t?0:1,a=e[n+0],r=e[n+2],o=e[n+4],s=e[n+6];if(a>=r==r>=o&&r>=o==o>=s||O.isStraight(e))i.push(e);else{var l=3*(r-o)-a+s,h=2*(a+o)-4*r,d=r-a,c=[],g=u.solveQuadratic(l,h,d,c,1e-8,1-1e-8);if(g){c.sort();var f=c[0],p=O.subdivide(e,f);i.push(p[0]),g>1&&(f=(c[1]-f)/(1-f),p=O.subdivide(p[1],f),i.push(p[0])),i.push(p[1])}else i.push(e)}return i},solveCubic:function(e,t,i,n,a,r){var o=e[t],s=e[t+2],l=e[t+4],h=e[t+6],d=0;if(!(o<i&&h<i&&s<i&&l<i||o>i&&h>i&&s>i&&l>i)){var c=3*(s-o),g=3*(l-s)-c,f=h-o-c-g;d=u.solveCubic(f,g,c,o-i,n,a,r)}return d},getTimeOf:function(e,t){var i=new f(e[0],e[1]),n=new f(e[6],e[7]),a=1e-7;if(null===(t.isClose(i,1e-12)?0:t.isClose(n,1e-12)?1:null))for(var r=[t.x,t.y],o=[],s=0;s<2;s++)for(var l=O.solveCubic(e,s,r[s],o,0,1),h=0;h<l;h++){var d=o[h];if(t.isClose(O.getPoint(e,d),a))return d}return t.isClose(i,a)?0:t.isClose(n,a)?1:null},getNearestTime:function(e,t){if(O.isStraight(e)){var i=e[0],n=e[1],a=e[6]-i,r=e[7]-n,o=a*a+r*r;if(0===o)return 0;var s=((t.x-i)*a+(t.y-n)*r)/o;return s<1e-12?0:s>.999999999999?1:O.getTimeOf(e,new f(i+s*a,n+s*r))}var l=1/0,h=0;function d(i){if(i>=0&&i<=1){var n=t.getDistance(O.getPoint(e,i),!0);if(n<l)return l=n,h=i,!0}}for(var c=0;c<=100;c++)d(c/100);for(var u=.005;u>1e-8;)!d(h-u)&&!d(h+u)&&(u/=2);return h},getPart:function(e,t,i){var n=t>i;if(n){var a=t;t=i,i=a}return t>0&&(e=O.subdivide(e,t)[1]),i<1&&(e=O.subdivide(e,(i-t)/(1-t))[0]),n?[e[6],e[7],e[4],e[5],e[2],e[3],e[0],e[1]]:e},isFlatEnough:function(e,t){var i=e[0],n=e[1],a=e[2],r=e[3],o=e[4],s=e[5],l=e[6],h=e[7],d=3*a-2*i-l,c=3*r-2*n-h,u=3*o-2*l-i,g=3*s-2*h-n;return Math.max(d*d,u*u)+Math.max(c*c,g*g)<=16*t*t},getArea:function(e){var t=e[0],i=e[1],n=e[2],a=e[3],r=e[4],o=e[5],s=e[6],l=e[7];return 3*((l-i)*(n+r)-(s-t)*(a+o)+a*(t-r)-n*(i-o)+l*(r+t/3)-s*(o+i/3))/20},getBounds:function(e){for(var t=e.slice(0,2),i=t.slice(),n=[0,0],a=0;a<2;a++)O._addBounds(e[a],e[a+2],e[a+4],e[a+6],a,0,t,i,n);return new I(t[0],t[1],i[0]-t[0],i[1]-t[1])},_addBounds:function(e,t,i,n,a,r,o,s,l){function h(e,t){var i=e-t,n=e+t;i<o[a]&&(o[a]=i),n>s[a]&&(s[a]=n)}r/=2;var d=o[a]+r,c=s[a]-r;if(e<d||t<d||i<d||n<d||e>c||t>c||i>c||n>c)if(t<e!=t<n&&i<e!=i<n)h(e,0),h(n,0);else{var g=3*(t-i)-e+n,f=2*(e+i)-4*t,p=t-e,m=u.solveQuadratic(g,f,p,l);h(n,0);for(var v=0;v<m;v++){var I=l[v],y=1-I;1e-8<=I&&I<=1-1e-8&&h(y*y*y*e+3*y*y*I*t+3*y*I*I*i+I*I*I*n,r)}}}}},a.each(["getBounds","getStrokeBounds","getHandleBounds"],function(e){this[e]=function(){this._bounds||(this._bounds={});var t=this._bounds[e];return t||(t=this._bounds[e]=R[e]([this._segment1,this._segment2],!1,this._path)),t.clone()}},{}),a.each({isStraight:function(e,t,i,n){if(t.isZero()&&i.isZero())return!0;var a=n.subtract(e);if(a.isZero())return!1;if(a.isCollinear(t)&&a.isCollinear(i)){var r=new M(e,n);if(r.getDistance(e.add(t))<1e-7&&r.getDistance(n.add(i))<1e-7){var o=a.dot(a),s=a.dot(t)/o,l=a.dot(i)/o;return s>=0&&s<=1&&l<=0&&l>=-1}}return!1},isLinear:function(e,t,i,n){var a=n.subtract(e).divide(3);return t.equals(a)&&i.negate().equals(a)}},function(e,t){this[t]=function(t){var i=this._segment1,n=this._segment2;return e(i._point,i._handleOut,n._handleIn,n._point,t)},this.statics[t]=function(t,i){var n=t[0],a=t[1],r=t[6],o=t[7];return e(new f(n,a),new f(t[2]-n,t[3]-a),new f(t[4]-r,t[5]-o),new f(r,o),i)}},{statics:{},hasHandles:function(){return!this._segment1._handleOut.isZero()||!this._segment2._handleIn.isZero()},hasLength:function(e){return(!this.getPoint1().equals(this.getPoint2())||this.hasHandles())&&this.getLength()>(e||0)},isCollinear:function(e){return e&&this.isStraight()&&e.isStraight()&&this.getLine().isCollinear(e.getLine())},isHorizontal:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).y)<1e-8},isVertical:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).x)<1e-8}}),{beans:!1,getLocationAt:function(e,t){return this.getLocationAtTime(t?e:this.getTimeAt(e))},getLocationAtTime:function(e){return null!=e&&e>=0&&e<=1?new B(this,e):null},getTimeAt:function(e,t){return O.getTimeAt(this.getValues(),e,t)},getParameterAt:"#getTimeAt",getTimesWithTangent:function(){var e=f.read(arguments);return e.isZero()?[]:O.getTimesWithTangent(this.getValues(),e)},getOffsetAtTime:function(e){return this.getPartLength(0,e)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(f.read(arguments)))},getOffsetOf:function(){var e=this.getLocationOf.apply(this,arguments);return e?e.getOffset():null},getTimeOf:function(){return O.getTimeOf(this.getValues(),f.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var e=f.read(arguments),t=this.getValues(),i=O.getNearestTime(t,e),n=O.getPoint(t,i);return new B(this,i,n,null,e.getDistance(n))},getNearestPoint:function(){var e=this.getNearestLocation.apply(this,arguments);return e&&e.getPoint()}},new function(){var e=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return a.each(e,function(e){this[e+"At"]=function(t,i){var n=this.getValues();return O[e](n,i?t:O.getTimeAt(n,t))},this[e+"AtTime"]=function(t){return O[e](this.getValues(),t)}},{statics:{_evaluateMethods:e}})},new function(){function e(e){var t=e[0],i=e[1],n=e[2],a=e[3],r=e[4],o=e[5],s=e[6],l=e[7],h=9*(n-r)+3*(s-t),d=6*(t+r)-12*n,c=3*(n-t),u=9*(a-o)+3*(l-i),g=6*(i+o)-12*a,f=3*(a-i);return function(e){var t=(h*e+d)*e+c,i=(u*e+g)*e+f;return Math.sqrt(t*t+i*i)}}function i(e,t){return Math.max(2,Math.min(16,Math.ceil(32*Math.abs(t-e))))}function n(e,t,i,n){if(null==t||t<0||t>1)return null;var a=e[0],r=e[1],o=e[2],s=e[3],l=e[4],h=e[5],d=e[6],c=e[7],g=u.isZero;g(o-a)&&g(s-r)&&(o=a,s=r),g(l-d)&&g(h-c)&&(l=d,h=c);var p,m,v=3*(o-a),I=3*(l-o)-v,y=d-a-v-I,C=3*(s-r),M=3*(h-s)-C,x=c-r-C-M;if(0===i)p=0===t?a:1===t?d:((y*t+I)*t+v)*t+a,m=0===t?r:1===t?c:((x*t+M)*t+C)*t+r;else{var S=1e-8,b=1-S;if(t<S?(p=v,m=C):t>b?(p=3*(d-l),m=3*(c-h)):(p=(3*y*t+2*I)*t+v,m=(3*x*t+2*M)*t+C),n){0===p&&0===m&&(t<S||t>b)&&(p=l-o,m=h-s);var w=Math.sqrt(p*p+m*m);w&&(p/=w,m/=w)}if(3===i){l=6*y*t+2*I,h=6*x*t+2*M;var A=Math.pow(p*p+m*m,1.5);p=0!==A?(p*h-m*l)/A:0,m=0}}return 2===i?new f(m,-p):new f(p,m)}return{statics:{classify:function(e){var i=e[0],n=e[1],a=e[2],r=e[3],o=e[4],s=e[5],l=e[6],h=e[7],d=a*(n-h)+r*(l-i)+i*h-n*l,c=3*(o*(r-n)+s*(i-a)+a*n-r*i),g=c-d,f=g-d+(i*(h-s)+n*(o-l)+l*s-h*o),p=Math.sqrt(f*f+g*g+c*c),m=0!==p?1/p:0,v=u.isZero,I="serpentine";function y(e,i,n){var a=i!==t,r=a&&i>0&&i<1,o=a&&n>0&&n<1;return a&&(!(r||o)||"loop"===e&&!(r&&o))&&(e="arch",r=o=!1),{type:e,roots:r||o?r&&o?i<n?[i,n]:[n,i]:[r?i:n]:null}}if(g*=m,c*=m,v(f*=m))return v(g)?y(v(c)?"line":"quadratic"):y(I,c/(3*g));var C=3*g*g-4*f*c;if(v(C))return y("cusp",g/(2*f));var M=C>0?Math.sqrt(C/3):Math.sqrt(-C),x=2*f;return y(C>0?I:"loop",(g+M)/x,(g-M)/x)},getLength:function(n,a,r,o){if(a===t&&(a=0),r===t&&(r=1),O.isStraight(n)){var s=n;r<1&&(s=O.subdivide(s,r)[0],a/=r),a>0&&(s=O.subdivide(s,a)[1]);var l=s[6]-s[0],h=s[7]-s[1];return Math.sqrt(l*l+h*h)}return u.integrate(o||e(n),a,r,i(a,r))},getTimeAt:function(n,a,r){if(r===t&&(r=a<0?1:0),0===a)return r;var o=Math.abs,s=a>0,l=s?r:0,h=s?1:r,d=e(n),c=O.getLength(n,l,h,d),g=o(a)-c;if(o(g)<1e-12)return s?h:l;if(g>1e-12)return null;var f=a/c,p=0;return u.findRoot(function(e){return p+=u.integrate(d,r,e,i(r,e)),r=e,p-a},d,r+f,l,h,32,1e-12)},getPoint:function(e,t){return n(e,t,0,!1)},getTangent:function(e,t){return n(e,t,1,!0)},getWeightedTangent:function(e,t){return n(e,t,1,!1)},getNormal:function(e,t){return n(e,t,2,!0)},getWeightedNormal:function(e,t){return n(e,t,2,!1)},getCurvature:function(e,t){return n(e,t,3,!1).x},getPeaks:function(e){var t=e[0],i=e[1],n=e[2],a=e[3],r=e[4],o=e[5],s=3*n-t-3*r+e[6],l=3*t-6*n+3*r,h=-3*t+3*n,d=3*a-i-3*o+e[7],c=3*i-6*a+3*o,g=-3*i+3*a,f=[];return u.solveCubic(9*(s*s+d*d),9*(s*l+c*d),2*(l*l+c*c)+3*(h*s+g*d),h*l+c*g,f,1e-8,1-1e-8),f.sort()}}}},new function(){function e(e,t,i,n,a,r,o){var s=!o&&i.getPrevious()===a,l=!o&&i!==a&&i.getNext()===a,h=1e-8,d=1-h;if(null!==n&&n>=(s?h:0)&&n<=(l?d:1)&&null!==r&&r>=(l?h:0)&&r<=(s?d:1)){var c=new B(i,n,null,o),u=new B(a,r,null,o);c._intersection=u,u._intersection=c,(!t||t(c))&&B.insert(e,c,!0)}}function t(e,t,n,a){return e[0][1]<n?i(e,!0,n):t[0][1]>a?i(t,!1,a):e[0][0]}function i(e,t,i){for(var n=e[0][0],a=e[0][1],r=1,o=e.length;r<o;r++){var s=e[r][0],l=e[r][1];if(t?l>=i:l<=i)return l===i?s:n+(i-a)*(s-n)/(l-a);n=s,a=l}return null}function n(e,t,i,n,a){var r=u.isZero;if(r(n)&&r(a)){var o=O.getTimeOf(e,new f(t,i));return null===o?[]:[o]}for(var s=Math.atan2(-a,n),l=Math.sin(s),h=Math.cos(s),d=[],c=[],g=0;g<8;g+=2){var p=e[g]-t,m=e[g+1]-i;d.push(p*h-m*l,p*l+m*h)}return O.solveCubic(d,1,0,c,0,1),c}function a(i,a,r,s,l,h){var d=1e-12,c=Math.min,u=Math.max;if(u(i[0],i[2],i[4],i[6])+d>c(a[0],a[2],a[4],a[6])&&c(i[0],i[2],i[4],i[6])-d<u(a[0],a[2],a[4],a[6])&&u(i[1],i[3],i[5],i[7])+d>c(a[1],a[3],a[5],a[7])&&c(i[1],i[3],i[5],i[7])-d<u(a[1],a[3],a[5],a[7])){var g=o(i,a);if(g)for(var p=0;p<2;p++){var m=g[p];e(l,h,r,m[0],s,m[1],!0)}else{var v=O.isStraight(i),I=O.isStraight(a),y=v&&I,C=v&&!I,x=l.length;if((y?function(t,i,n,a,r,o){var s=M.intersect(t[0],t[1],t[6],t[7],i[0],i[1],i[6],i[7]);s&&e(r,o,n,O.getTimeOf(t,s),a,O.getTimeOf(i,s))}:v||I?function(t,i,a,r,o,s,l){for(var h=i[0],d=i[1],c=n(t,h,d,i[6]-h,i[7]-d),u=0,g=c.length;u<g;u++){var f=c[u],p=O.getPoint(t,f),m=O.getTimeOf(i,p);null!==m&&e(o,s,l?r:a,l?m:f,l?a:r,l?f:m)}}:function i(n,a,r,o,s,l,h,d,c,u,g,f,p){if(++c>=4096||++d>=40)return c;var m,v,I=a[0],y=a[1],C=a[6],x=a[7],S=M.getSignedDistance,b=S(I,y,C,x,a[2],a[3]),w=S(I,y,C,x,a[4],a[5]),A=b*w>0?.75:4/9,P=A*Math.min(0,b,w),D=A*Math.max(0,b,w),k=S(I,y,C,x,n[0],n[1]),_=S(I,y,C,x,n[2],n[3]),T=S(I,y,C,x,n[4],n[5]),z=S(I,y,C,x,n[6],n[7]),B=function(e,t,i,n){var a,r=[0,e],o=[1/3,t],s=[2/3,i],l=[1,n],h=t-(2*e+n)/3,d=i-(e+2*n)/3;if(h*d<0)a=[[r,o,l],[r,s,l]];else{var c=h/d;a=[c>=2?[r,o,l]:c<=.5?[r,s,l]:[r,o,s,l],[r,l]]}return(h||d)<0?a.reverse():a}(k,_,T,z),E=B[0],R=B[1];if(0===b&&0===w&&0===k&&0===_&&0===T&&0===z||null==(m=t(E,R,P,D))||null==(v=t(E.reverse(),R.reverse(),P,D)))return c;var F=u+(g-u)*m,L=u+(g-u)*v;if(Math.max(p-f,L-F)<1e-9){var G=(F+L)/2,U=(f+p)/2;e(s,l,h?o:r,h?U:G,h?r:o,h?G:U)}else{n=O.getPart(n,m,v);var j=p-f;if(v-m>.8)if(L-F>j)G=(F+L)/2,c=i(a,(N=O.subdivide(n,.5))[0],o,r,s,l,!h,d,c,f,p,F,G),c=i(a,N[1],o,r,s,l,!h,d,c,f,p,G,L);else{var N;U=(f+p)/2,c=i((N=O.subdivide(a,.5))[0],n,o,r,s,l,!h,d,c,f,U,F,L),c=i(N[1],n,o,r,s,l,!h,d,c,U,p,F,L)}else c=0===j||j>=1e-9?i(a,n,o,r,s,l,!h,d,c,f,p,F,L):i(n,a,r,o,s,l,h,d,c,F,L,f,p)}return c})(C?a:i,C?i:a,C?s:r,C?r:s,l,h,C,0,0,0,1,0,1),!y||l.length===x)for(p=0;p<4;p++){var S=p>>1,b=1&p,w=6*S,A=6*b,P=new f(i[w],i[w+1]),D=new f(a[A],a[A+1]);P.isClose(D,d)&&e(l,h,r,S,s,b)}}}return l}function r(t,i,n,a){var r=O.classify(t);if("loop"===r.type){var o=r.roots;e(n,a,i,o[0],i,o[1])}return n}function o(e,t){function i(e){var t=e[6]-e[0],i=e[7]-e[1];return t*t+i*i}var n=Math.abs,a=M.getDistance,r=1e-7,o=O.isStraight(e),s=O.isStraight(t),l=o&&s,h=i(e)<i(t),d=h?t:e,c=h?e:t,u=d[0],g=d[1],p=d[6]-u,m=d[7]-g;if(a(u,g,p,m,c[0],c[1],!0)<r&&a(u,g,p,m,c[6],c[7],!0)<r)!l&&a(u,g,p,m,d[2],d[3],!0)<r&&a(u,g,p,m,d[4],d[5],!0)<r&&a(u,g,p,m,c[2],c[3],!0)<r&&a(u,g,p,m,c[4],c[5],!0)<r&&(o=s=l=!0);else if(l)return null;if(o^s)return null;for(var v=[e,t],I=[],y=0;y<4&&I.length<2;y++){var C=1&y,x=1^C,S=y>>1,b=O.getTimeOf(v[C],new f(v[x][S?6:0],v[x][S?7:1]));if(null!=b){var w=C?[S,b]:[b,S];(!I.length||n(w[0]-I[0][0])>1e-8&&n(w[1]-I[0][1])>1e-8)&&I.push(w)}if(y>2&&!I.length)break}if(2!==I.length)I=null;else if(!l){var A=O.getPart(e,I[0][0],I[1][0]),P=O.getPart(t,I[0][1],I[1][1]);(n(P[2]-A[2])>r||n(P[3]-A[3])>r||n(P[4]-A[4])>r||n(P[5]-A[5])>r)&&(I=null)}return I}return{getIntersections:function(e){var t=this.getValues(),i=e&&e!==this&&e.getValues();return i?a(t,i,this,e,[]):r(t,this,[])},statics:{getOverlaps:o,getIntersections:function(e,t,i,n,o,s){var l=!t;l&&(t=e);for(var h=e.length,c=t.length,u=new Array(h),g=l?u:new Array(c),f=[],p=0;p<h;p++)u[p]=e[p].getValues(n);if(!l)for(p=0;p<c;p++)g[p]=t[p].getValues(o);for(var m=d.findCurveBoundsCollisions(u,g,1e-7),v=0;v<h;v++){var I=e[v],y=u[v];l&&r(y,I,f,i);var C=m[v];if(C)for(var M=0;M<C.length;M++){if(s&&f.length)return f;var x=C[M];if(!l||x>v){var S=t[x];a(y,g[x],I,S,f,i)}}}return f},getCurveLineIntersections:n,getTimesWithTangent:function(e,t){var i=e[0],n=e[1],a=e[2],r=e[3],o=e[4],s=e[5],l=e[6],h=e[7],d=t.normalize(),c=d.x,g=d.y,f=3*l-9*o+9*a-3*i,p=3*h-9*s+9*r-3*n,m=6*o-12*a+6*i,v=6*s-12*r+6*n,I=3*a-3*i,y=3*r-3*n,C=2*f*g-2*p*c,M=[];if(Math.abs(C)<u.CURVETIME_EPSILON){if(0!=(C=f*v-p*m)){var x=-(f*y-p*I)/C;x>=0&&x<=1&&M.push(x)}}else{var S=(m*m-4*f*I)*g*g+(-2*m*v+4*p*I+4*f*y)*c*g+(v*v-4*p*y)*c*c,b=m*g-v*c;if(S>=0&&0!=C){var w=Math.sqrt(S),A=-(b+w)/C,P=(-b+w)/C;A>=0&&A<=1&&M.push(A),P>=0&&P<=1&&M.push(P)}}return M}}}}),B=a.extend({_class:"CurveLocation",initialize:function(e,t,i,n,a){if(t>=.99999999){var r=e.getNext();r&&(t=0,e=r)}this._setCurve(e),this._time=t,this._point=i||e.getPointAtTime(t),this._overlap=n,this._distance=a,this._intersection=this._next=this._previous=null},_setPath:function(e){this._path=e,this._version=e?e._version:0},_setCurve:function(e){this._setPath(e._path),this._curve=e,this._segment=null,this._segment1=e._segment1,this._segment2=e._segment2},_setSegment:function(e){var t=e.getCurve();t?this._setCurve(t):(this._setPath(e._path),this._segment1=e,this._segment2=null),this._segment=e,this._time=e===this._segment1?0:1,this._point=e._point.clone()},getSegment:function(){var e=this._segment;if(!e){var t=this.getCurve(),i=this.getTime();0===i?e=t._segment1:1===i?e=t._segment2:null!=i&&(e=t.getPartLength(0,i)<t.getPartLength(i,1)?t._segment1:t._segment2),this._segment=e}return e},getCurve:function(){var e=this._path,t=this;function i(e){var i=e&&e.getCurve();if(i&&null!=(t._time=i.getTimeOf(t._point)))return t._setCurve(i),i}return e&&e._version!==this._version&&(this._time=this._offset=this._curveOffset=this._curve=null),this._curve||i(this._segment)||i(this._segment1)||i(this._segment2.getPrevious())},getPath:function(){var e=this.getCurve();return e&&e._path},getIndex:function(){var e=this.getCurve();return e&&e.getIndex()},getTime:function(){var e=this.getCurve(),t=this._time;return e&&null==t?this._time=e.getTimeOf(this._point):t},getParameter:"#getTime",getPoint:function(){return this._point},getOffset:function(){var e=this._offset;if(null==e){e=0;var t=this.getPath(),i=this.getIndex();if(t&&null!=i)for(var n=t.getCurves(),a=0;a<i;a++)e+=n[a].getLength();this._offset=e+=this.getCurveOffset()}return e},getCurveOffset:function(){var e=this._curveOffset;if(null==e){var t=this.getCurve(),i=this.getTime();this._curveOffset=e=null!=i&&t&&t.getPartLength(0,i)}return e},getIntersection:function(){return this._intersection},getDistance:function(){return this._distance},divide:function(){var e=this.getCurve(),t=e&&e.divideAtTime(this.getTime());return t&&this._setSegment(t._segment1),t},split:function(){var e=this.getCurve(),t=e._path,i=e&&e.splitAtTime(this.getTime());return i&&this._setSegment(t.getLastSegment()),i},equals:function(e,t){var i=this===e;if(!i&&e instanceof B){var n=this.getCurve(),a=e.getCurve(),r=n._path;if(r===a._path){var o=Math.abs,s=o(this.getOffset()-e.getOffset()),l=!t&&this._intersection,h=!t&&e._intersection;i=(s<1e-7||r&&o(r.getLength()-s)<1e-7)&&(!l&&!h||l&&h&&l.equals(h,!0))}}return i},toString:function(){var e=[],t=this.getPoint(),i=c.instance;t&&e.push("point: "+t);var n=this.getIndex();null!=n&&e.push("index: "+n);var a=this.getTime();return null!=a&&e.push("time: "+i.number(a)),null!=this._distance&&e.push("distance: "+i.number(this._distance)),"{ "+e.join(", ")+" }"},isTouching:function(){var e=this._intersection;if(e&&this.getTangent().isCollinear(e.getTangent())){var t=this.getCurve(),i=e.getCurve();return!(t.isStraight()&&i.isStraight()&&t.getLine().intersect(i.getLine()))}return!1},isCrossing:function(){var e=this._intersection;if(!e)return!1;var t=this.getTime(),i=e.getTime(),n=1e-8,a=1-n,r=t>=n&&t<=a,o=i>=n&&i<=a;if(r&&o)return!this.isTouching();var s=this.getCurve(),l=s&&t<n?s.getPrevious():s,h=e.getCurve(),d=h&&i<n?h.getPrevious():h;if(t>a&&(s=s.getNext()),i>a&&(h=h.getNext()),!(l&&s&&d&&h))return!1;var c=[];function u(e,t){var i=e.getValues(),n=O.classify(i).roots||O.getPeaks(i),a=n.length,r=O.getLength(i,t&&a?n[a-1]:0,!t&&a?n[0]:1);c.push(a?r:r/32)}function g(e,t,i){return t<i?e>t&&e<i:e>t||e<i}r||(u(l,!0),u(s,!1)),o||(u(d,!0),u(h,!1));var f=this.getPoint(),p=Math.min.apply(Math,c),m=r?s.getTangentAtTime(t):s.getPointAt(p).subtract(f),v=r?m.negate():l.getPointAt(-p).subtract(f),I=o?h.getTangentAtTime(i):h.getPointAt(p).subtract(f),y=o?I.negate():d.getPointAt(-p).subtract(f),C=v.getAngle(),M=m.getAngle(),x=y.getAngle(),S=I.getAngle();return!!(r?g(C,x,S)^g(M,x,S)&&g(C,S,x)^g(M,S,x):g(x,C,M)^g(S,C,M)&&g(x,M,C)^g(S,M,C))},hasOverlap:function(){return!!this._overlap}},a.each(O._evaluateMethods,function(e){var t=e+"At";this[e]=function(){var e=this.getCurve(),i=this.getTime();return null!=i&&e&&e[t](i,!0)}},{preserve:!0}),new function(){function e(e,t,i){var n=e.length,a=0,r=n-1;function o(i,a){for(var r=i+a;r>=-1&&r<=n;r+=a){var o=e[(r%n+n)%n];if(!t.getPoint().isClose(o.getPoint(),1e-7))break;if(t.equals(o))return o}return null}for(;a<=r;){var s,l=a+r>>>1,h=e[l];if(i&&(s=t.equals(h)?h:o(l,-1)||o(l,1)))return t._overlap&&(s._overlap=s._intersection._overlap=!0),s;var d=t.getPath(),c=h.getPath();(d!==c?d._id-c._id:t.getIndex()+t.getTime()-(h.getIndex()+h.getTime()))<0?r=l-1:a=l+1}return e.splice(a,0,t),t}return{statics:{insert:e,expand:function(t){for(var i=t.slice(),n=t.length-1;n>=0;n--)e(i,t[n]._intersection,!1);return i}}}}),E=S.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,beans:!0,initialize:function(){},statics:{create:function(e){var t,i,n;if(a.isPlainObject(e)?(i=e.segments,t=e.pathData):Array.isArray(e)?i=e:"string"==typeof e&&(t=e),i){var r=i[0];n=r&&Array.isArray(r[0])}else t&&(n=(t.match(/m/gi)||[]).length>1||/z\s*\S+/i.test(t));return new(n?F:R)(e)}},_asPathItem:function(){return this},isClockwise:function(){return this.getArea()>=0},setClockwise:function(e){this.isClockwise()!=(e=!!e)&&this.reverse()},setPathData:function(e){var t,i,n,a=e&&e.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/gi),r=!1,o=new f,s=new f;function l(e,i){var n=+t[e];return r&&(n+=o[i]),n}function h(e){return new f(l(e,"x"),l(e+1,"y"))}this.clear();for(var d=0,c=a&&a.length;d<c;d++){var u=a[d],g=u[0],p=g.toLowerCase(),v=(t=u.match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g))&&t.length;switch(r=g===p,"z"===i&&!/[mz]/.test(p)&&this.moveTo(o),p){case"m":case"l":for(var I="m"===p,y=0;y<v;y+=2)this[I?"moveTo":"lineTo"](o=h(y)),I&&(s=o,I=!1);n=o;break;case"h":case"v":var C="h"===p?"x":"y";for(o=o.clone(),y=0;y<v;y++)o[C]=l(y,C),this.lineTo(o);n=o;break;case"c":for(y=0;y<v;y+=6)this.cubicCurveTo(h(y),n=h(y+2),o=h(y+4));break;case"s":for(y=0;y<v;y+=4)this.cubicCurveTo(/[cs]/.test(i)?o.multiply(2).subtract(n):o,n=h(y),o=h(y+2)),i=p;break;case"q":for(y=0;y<v;y+=4)this.quadraticCurveTo(n=h(y),o=h(y+2));break;case"t":for(y=0;y<v;y+=2)this.quadraticCurveTo(n=/[qt]/.test(i)?o.multiply(2).subtract(n):o,o=h(y)),i=p;break;case"a":for(y=0;y<v;y+=7)this.arcTo(o=h(y+5),new m(+t[y],+t[y+1]),+t[y+2],+t[y+4],+t[y+3]);break;case"z":this.closePath(1e-12),o=s}i=p}},_canComposite:function(){return!(this.hasFill()&&this.hasStroke())},_contains:function(e){var t=e.isInside(this.getBounds({internal:!0,handle:!0}))?this._getWinding(e):{};return t.onPath||!!("evenodd"===this.getFillRule()?1&t.windingL||1&t.windingR:t.winding)},getIntersections:function(e,t,i,n){var a=this===e||!e,r=this._matrix._orNullIfIdentity(),o=a?r:(i||e._matrix)._orNullIfIdentity();return a||this.getBounds(r).intersects(e.getBounds(o),1e-12)?O.getIntersections(this.getCurves(),!a&&e.getCurves(),t,r,o,n):[]},getCrossings:function(e){return this.getIntersections(e,function(e){return e.isCrossing()})},getNearestLocation:function(){for(var e=f.read(arguments),t=this.getCurves(),i=1/0,n=null,a=0,r=t.length;a<r;a++){var o=t[a].getNearestLocation(e);o._distance<i&&(i=o._distance,n=o)}return n},getNearestPoint:function(){var e=this.getNearestLocation.apply(this,arguments);return e&&e.getPoint()},interpolate:function(e,t,i){var n=!this._children,a=n?"_segments":"_children",r=e[a],o=t[a],s=this[a];if(!r||!o||r.length!==o.length)throw new Error("Invalid operands in interpolate() call: "+e+", "+t);var l=s.length,h=o.length;if(l<h)for(var d=n?T:R,c=l;c<h;c++)this.add(new d);else l>h&&this[n?"removeSegments":"removeChildren"](h,l);for(c=0;c<h;c++)s[c].interpolate(r[c],o[c],i);n&&(this.setClosed(e._closed),this._changed(9))},compare:function(e){var t=!1;if(e){var i=this._children||[this],n=e._children?e._children.slice():[e],a=i.length,r=n.length,o=[],s=0;t=!0;for(var l=d.findItemBoundsCollisions(i,n,u.GEOMETRIC_EPSILON),h=a-1;h>=0&&t;h--){var c=i[h];t=!1;var g=l[h];if(g)for(var f=g.length-1;f>=0&&!t;f--)c.compare(n[g[f]])&&(o[g[f]]||(o[g[f]]=!0,s++),t=!0)}t=t&&s===r}return t}}),R=E.extend({_class:"Path",_serializeFields:{segments:[],closed:!1},initialize:function(e){this._closed=!1,this._segments=[],this._version=0;var i=arguments,n=Array.isArray(e)?"object"==typeof e[0]?e:i:!e||e.size!==t||e.x===t&&e.point===t?null:i;n&&n.length>0?this.setSegments(n):(this._curves=t,this._segmentSelection=0,!n&&"string"==typeof e&&(this.setPathData(e),e=null)),this._initialize(!n&&e)},_equals:function(e){return this._closed===e._closed&&a.equals(this._segments,e._segments)},copyContent:function(e){this.setSegments(e._segments),this._closed=e._closed},_changed:function e(i){if(e.base.call(this,i),8&i){if(this._length=this._area=t,32&i)this._version++;else if(this._curves)for(var n=0,a=this._curves.length;n<a;n++)this._curves[n]._changed()}else 64&i&&(this._bounds=t)},getStyle:function(){var e=this._parent;return(e instanceof F?e:this)._style},getSegments:function(){return this._segments},setSegments:function(e){var i=this.isFullySelected(),n=e&&e.length;if(this._segments.length=0,this._segmentSelection=0,this._curves=t,n){var a=e[n-1];"boolean"==typeof a&&(this.setClosed(a),n--),this._add(T.readList(e,0,{},n))}i&&this.setFullySelected(!0)},getFirstSegment:function(){return this._segments[0]},getLastSegment:function(){return this._segments[this._segments.length-1]},getCurves:function(){var e=this._curves,t=this._segments;if(!e){var i=this._countCurves();e=this._curves=new Array(i);for(var n=0;n<i;n++)e[n]=new O(this,t[n],t[n+1]||t[0])}return e},getFirstCurve:function(){return this.getCurves()[0]},getLastCurve:function(){var e=this.getCurves();return e[e.length-1]},isClosed:function(){return this._closed},setClosed:function(e){if(this._closed!=(e=!!e)){if(this._closed=e,this._curves){var t=this._curves.length=this._countCurves();e&&(this._curves[t-1]=new O(this,this._segments[t-1],this._segments[0]))}this._changed(41)}}},{beans:!0,getPathData:function(e,t){var i,n,a,r,o,s,l,h,d=this._segments,u=d.length,g=new c(t),f=new Array(6),p=!0,m=[];function v(t,d){if(t._transformCoordinates(e,f),i=f[0],n=f[1],p)m.push("M"+g.pair(i,n)),p=!1;else if(o=f[2],s=f[3],o===i&&s===n&&l===a&&h===r){if(!d){var c=i-a,u=n-r;m.push(0===c?"v"+g.number(u):0===u?"h"+g.number(c):"l"+g.pair(c,u))}}else m.push("c"+g.pair(l-a,h-r)+" "+g.pair(o-a,s-r)+" "+g.pair(i-a,n-r));a=i,r=n,l=f[4],h=f[5]}if(!u)return"";for(var I=0;I<u;I++)v(d[I]);return this._closed&&u>0&&(v(d[0],!0),m.push("z")),m.join("")},isEmpty:function(){return!this._segments.length},_transformContent:function(e){for(var t=this._segments,i=new Array(6),n=0,a=t.length;n<a;n++)t[n]._transformCoordinates(e,i,!0);return!0},_add:function(e,t){for(var i=this._segments,n=this._curves,r=e.length,o=null==t,s=(t=o?i.length:t,0);s<r;s++){var l=e[s];l._path&&(l=e[s]=l.clone()),l._path=this,l._index=t+s,l._selection&&this._updateSelection(l,0,l._selection)}if(o)a.push(i,e);else{i.splice.apply(i,[t,0].concat(e)),s=t+r;for(var h=i.length;s<h;s++)i[s]._index=s}if(n){var d=this._countCurves(),c=t>0&&t+r-1===d?t-1:t,u=c,g=Math.min(c+r,d);for(e._curves&&(n.splice.apply(n,[c,0].concat(e._curves)),u+=e._curves.length),s=u;s<g;s++)n.splice(s,0,new O(this,null,null));this._adjustCurves(c,g)}return this._changed(41),e},_adjustCurves:function(e,t){for(var i,n=this._segments,a=this._curves,r=e;r<t;r++)(i=a[r])._path=this,i._segment1=n[r],i._segment2=n[r+1]||n[0],i._changed();(i=a[this._closed&&!e?n.length-1:e-1])&&(i._segment2=n[e]||n[0],i._changed()),(i=a[t])&&(i._segment1=n[t],i._changed())},_countCurves:function(){var e=this._segments.length;return!this._closed&&e>0?e-1:e},add:function(e){var t=arguments;return t.length>1&&"number"!=typeof e?this._add(T.readList(t)):this._add([T.read(t)])[0]},insert:function(e,t){var i=arguments;return i.length>2&&"number"!=typeof t?this._add(T.readList(i,1),e):this._add([T.read(i,1)],e)[0]},addSegment:function(){return this._add([T.read(arguments)])[0]},insertSegment:function(e){return this._add([T.read(arguments,1)],e)[0]},addSegments:function(e){return this._add(T.readList(e))},insertSegments:function(e,t){return this._add(T.readList(t),e)},removeSegment:function(e){return this.removeSegments(e,e+1)[0]||null},removeSegments:function(e,t,i){e=e||0,t=a.pick(t,this._segments.length);var n=this._segments,r=this._curves,o=n.length,s=n.splice(e,t-e),l=s.length;if(!l)return s;for(var h=0;h<l;h++){var d=s[h];d._selection&&this._updateSelection(d,d._selection,0),d._index=d._path=null}h=e;for(var c=n.length;h<c;h++)n[h]._index=h;if(r){var u=e>0&&t===o+(this._closed?1:0)?e-1:e;for(h=(r=r.splice(u,l)).length-1;h>=0;h--)r[h]._path=null;i&&(s._curves=r.slice(1)),this._adjustCurves(u,u)}return this._changed(41),s},clear:"#removeSegments",hasHandles:function(){for(var e=this._segments,t=0,i=e.length;t<i;t++)if(e[t].hasHandles())return!0;return!1},clearHandles:function(){for(var e=this._segments,t=0,i=e.length;t<i;t++)e[t].clearHandles()},getLength:function(){if(null==this._length){for(var e=this.getCurves(),t=0,i=0,n=e.length;i<n;i++)t+=e[i].getLength();this._length=t}return this._length},getArea:function(){var e=this._area;if(null==e){var t=this._segments,i=this._closed;e=0;for(var n=0,a=t.length;n<a;n++){var r=n+1===a;e+=O.getArea(O.getValues(t[n],t[r?0:n+1],null,r&&!i))}this._area=e}return e},isFullySelected:function(){var e=this._segments.length;return this.isSelected()&&e>0&&this._segmentSelection===7*e},setFullySelected:function(e){e&&this._selectSegments(!0),this.setSelected(e)},setSelection:function e(t){1&t||this._selectSegments(!1),e.base.call(this,t)},_selectSegments:function(e){var t=this._segments,i=t.length,n=e?7:0;this._segmentSelection=n*i;for(var a=0;a<i;a++)t[a]._selection=n},_updateSelection:function(e,t,i){e._selection=i,(this._segmentSelection+=i-t)>0&&this.setSelected(!0)},divideAt:function(e){var t,i=this.getLocationAt(e);return i&&(t=i.getCurve().divideAt(i.getCurveOffset()))?t._segment1:null},splitAt:function(e){var t=this.getLocationAt(e),i=t&&t.index,n=t&&t.time;n>1-1e-8&&(i++,n=0);var a=this.getCurves();if(i>=0&&i<a.length){n>=1e-8&&a[i++].divideAtTime(n);var r,o=this.removeSegments(i,this._segments.length,!0);return this._closed?(this.setClosed(!1),r=this):((r=new R(S.NO_INSERT)).insertAbove(this),r.copyAttributes(this)),r._add(o,0),this.addSegment(o[0]),r}return null},split:function(e,i){var n,a=i===t?e:(n=this.getCurves()[e])&&n.getLocationAtTime(i);return null!=a?this.splitAt(a):null},join:function(e,t){var i=t||0;if(e&&e!==this){var n=e._segments,a=this.getLastSegment(),r=e.getLastSegment();if(!r)return this;a&&a._point.isClose(r._point,i)&&e.reverse();var o=e.getFirstSegment();if(a&&a._point.isClose(o._point,i))a.setHandleOut(o._handleOut),this._add(n.slice(1));else{var s=this.getFirstSegment();s&&s._point.isClose(o._point,i)&&e.reverse(),r=e.getLastSegment(),s&&s._point.isClose(r._point,i)?(s.setHandleIn(r._handleIn),this._add(n.slice(0,n.length-1),0)):this._add(n.slice())}e._closed&&this._add([n[0]]),e.remove()}var l=this.getFirstSegment(),h=this.getLastSegment();return l!==h&&l._point.isClose(h._point,i)&&(l.setHandleIn(h._handleIn),h.remove(),this.setClosed(!0)),this},reduce:function(e){for(var t=this.getCurves(),i=e&&e.simplify,n=i?1e-7:0,a=t.length-1;a>=0;a--){var r=t[a];!r.hasHandles()&&(!r.hasLength(n)||i&&r.isCollinear(r.getNext()))&&r.remove()}return this},reverse:function(){this._segments.reverse();for(var e=0,t=this._segments.length;e<t;e++){var i=this._segments[e],n=i._handleIn;i._handleIn=i._handleOut,i._handleOut=n,i._index=e}this._curves=null,this._changed(9)},flatten:function(e){for(var t=new L(this,e||.25,256,!0).parts,i=t.length,n=[],a=0;a<i;a++)n.push(new T(t[a].curve.slice(0,2)));!this._closed&&i>0&&n.push(new T(t[i-1].curve.slice(6))),this.setSegments(n)},simplify:function(e){var t=new G(this).fit(e||2.5);return t&&this.setSegments(t),!!t},smooth:function(e){var i=this,n=e||{},a=n.type||"asymmetric",r=this._segments,o=r.length,s=this._closed;function l(e,t){var n=e&&e.index;if(null!=n){var a=e.path;if(a&&a!==i)throw new Error(e._class+" "+n+" of "+a+" is not part of "+i);t&&e instanceof O&&n++}else n="number"==typeof e?e:t;return Math.min(n<0&&s?n%o:n<0?n+o:n,o-1)}var h=s&&n.from===t&&n.to===t,d=l(n.from,0),c=l(n.to,o-1);if(d>c)if(s)d-=o;else{var u=d;d=c,c=u}if(/^(?:asymmetric|continuous)$/.test(a)){var g="asymmetric"===a,f=Math.min,p=c-d+1,m=p-1,v=h?f(p,4):1,I=v,y=v,C=[];if(s||(I=f(1,d),y=f(1,o-c-1)),(m+=I+y)<=1)return;for(var M=0,x=d-I;M<=m;M++,x++)C[M]=r[(x<0?x+o:x)%o]._point;var S=C[0]._x+2*C[1]._x,b=C[0]._y+2*C[1]._y,w=2,A=m-1,P=[S],D=[b],k=[w],_=[],T=[];for(M=1;M<m;M++){var z=M<A,B=z?4:g?2:7,E=z?4:g?3:8,R=z?2:g?0:1,F=(z||g?1:2)/w;w=k[M]=B-F,S=P[M]=E*C[M]._x+R*C[M+1]._x-F*S,b=D[M]=E*C[M]._y+R*C[M+1]._y-F*b}for(_[A]=P[A]/k[A],T[A]=D[A]/k[A],M=m-2;M>=0;M--)_[M]=(P[M]-_[M+1])/k[M],T[M]=(D[M]-T[M+1])/k[M];_[m]=(3*C[m]._x-_[A])/2,T[m]=(3*C[m]._y-T[A])/2,M=I;var L=m-y;for(x=d;M<=L;M++,x++){var G=r[x<0?x+o:x],U=G._point,j=_[M]-U._x,N=T[M]-U._y;(h||M<L)&&G.setHandleOut(j,N),(h||M>I)&&G.setHandleIn(-j,-N)}}else for(M=d;M<=c;M++)r[M<0?M+o:M].smooth(n,!h&&M===d,!h&&M===c)},toShape:function(e){if(!this._closed)return null;var i,n,a,r,o,s,l,h=this._segments;function d(e,t){var i=h[e],n=i.getNext(),a=h[t],r=a.getNext();return i._handleOut.isZero()&&n._handleIn.isZero()&&a._handleOut.isZero()&&r._handleIn.isZero()&&n._point.subtract(i._point).isCollinear(r._point.subtract(a._point))}function c(e){var t=h[e],i=t.getNext(),n=t._handleOut,a=i._handleIn,r=.5522847498307936;if(n.isOrthogonal(a)){var o=t._point,s=i._point,l=new M(o,n,!0).intersect(new M(s,a,!0),!0);return l&&u.isZero(n.getLength()/l.subtract(o).getLength()-r)&&u.isZero(a.getLength()/l.subtract(s).getLength()-r)}return!1}function g(e,t){return h[e]._point.getDistance(h[t]._point)}if(!this.hasHandles()&&4===h.length&&d(0,2)&&d(1,3)&&(o=h[1],s=o.getPrevious(),l=o.getNext(),s._handleOut.isZero()&&o._handleIn.isZero()&&o._handleOut.isZero()&&l._handleIn.isZero()&&o._point.subtract(s._point).isOrthogonal(l._point.subtract(o._point)))?(i=A.Rectangle,n=new m(g(0,3),g(0,1)),r=h[1]._point.add(h[2]._point).divide(2)):8===h.length&&c(0)&&c(2)&&c(4)&&c(6)&&d(1,5)&&d(3,7)?(i=A.Rectangle,a=(n=new m(g(1,6),g(0,3))).subtract(new m(g(0,7),g(1,2))).divide(2),r=h[3]._point.add(h[4]._point).divide(2)):4===h.length&&c(0)&&c(1)&&c(2)&&c(3)&&(u.isZero(g(0,2)-g(1,3))?(i=A.Circle,a=g(0,2)/2):(i=A.Ellipse,a=new m(g(2,0)/2,g(3,1)/2)),r=h[1]._point),i){var f=this.getPosition(!0),p=new i({center:f,size:n,radius:a,insert:!1});return p.copyAttributes(this,!0),p._matrix.prepend(this._matrix),p.rotate(r.subtract(f).getAngle()+90),(e===t||e)&&p.insertAbove(this),p}return null},toPath:"#clone",compare:function e(t){if(!t||t instanceof F)return e.base.call(this,t);var i=this.getCurves(),n=t.getCurves(),a=i.length,r=n.length;if(!a||!r)return a==r;for(var o,s,l=i[0].getValues(),h=[],d=0,c=0,u=0;u<r;u++){var g=n[u].getValues();if(h.push(g),m=O.getOverlaps(l,g)){o=!u&&m[0][0]>0?r-1:u,s=m[0][1];break}}var f,p=Math.abs;for(g=h[o];l&&g;){var m;if((m=O.getOverlaps(l,g))&&p(m[0][0]-c)<1e-8){1===(c=m[1][0])&&(l=++d<a?i[d].getValues():null,c=0);var v=m[0][1];if(p(v-s)<1e-8){if(f||(f=[o,v]),1===(s=m[1][1])&&(++o>=r&&(o=0),g=h[o]||n[o].getValues(),s=0),!l)return f[0]===o&&f[1]===s;continue}}break}return!1},_hitTestSelf:function(e,t,i,n){var a,r,o,s,l,h,d=this,c=this.getStyle(),u=this._segments,g=u.length,f=this._closed,p=t._tolerancePadding,m=p,v=t.stroke&&c.hasStroke(),I=t.fill&&c.hasFill(),y=t.curves,C=v?c.getStrokeWidth()/2:I&&t.tolerance>0||y?0:null;function M(t,i){return e.subtract(t).divide(i).length<=1}function x(e,i,n){if(!t.selected||i.isSelected()){var a=e._point;if(i!==a&&(i=i.add(a)),M(i,m))return new _(n,d,{segment:e,point:i})}}function S(e,i){return(i||t.segments)&&x(e,e._point,"segment")||!i&&t.handles&&(x(e,e._handleIn,"handle-in")||x(e,e._handleOut,"handle-out"))}function b(e){s.add(e)}function w(t){var i,l=f||t._index>0&&t._index<g-1;return"round"===(l?a:r)?M(t._point,m):(s=new R({internal:!0,closed:!0}),l?t.isSmooth()||R._addBevelJoin(t,a,C,o,null,n,b,!0):"square"===r&&R._addSquareCap(t,r,C,null,n,b,!0),s.isEmpty()?void 0:s.contains(e)||(i=s.getNearestLocation(e))&&M(i.getPoint(),p))}if(null!==C&&(C>0?(a=c.getStrokeJoin(),r=c.getStrokeCap(),o=c.getMiterLimit(),m=m.add(R._getStrokePadding(C,n))):a=r="round"),!t.ends||t.segments||f){if(t.segments||t.handles)for(var A=0;A<g;A++)if(h=S(u[A]))return h}else if(h=S(u[0],!0)||S(u[g-1],!0))return h;if(null!==C){if(l=this.getNearestLocation(e)){var P=l.getTime();0===P||1===P&&g>1?w(l.getSegment())||(l=null):M(l.getPoint(),m)||(l=null)}if(!l&&"miter"===a&&g>1)for(A=0;A<g;A++){var D=u[A];if(e.getDistance(D._point)<=o*C&&w(D)){l=D.getLocation();break}}}return!l&&I&&this._contains(e)||l&&!v&&!y?new _("fill",this):l?new _(v?"stroke":"curve",this,{location:l,point:l.getPoint()}):null}},a.each(O._evaluateMethods,function(e){this[e+"At"]=function(t){var i=this.getLocationAt(t);return i&&i[e]()}},{beans:!1,getLocationOf:function(){for(var e=f.read(arguments),t=this.getCurves(),i=0,n=t.length;i<n;i++){var a=t[i].getLocationOf(e);if(a)return a}return null},getOffsetOf:function(){var e=this.getLocationOf.apply(this,arguments);return e?e.getOffset():null},getLocationAt:function(e){if("number"==typeof e){for(var t=this.getCurves(),i=0,n=0,a=t.length;n<a;n++){var r=i,o=t[n];if((i+=o.getLength())>e)return o.getLocationAt(e-r)}if(t.length>0&&e<=this.getLength())return new B(t[t.length-1],1)}else if(e&&e.getPath&&e.getPath()===this)return e;return null},getOffsetsWithTangent:function(){var e=f.read(arguments);if(e.isZero())return[];for(var t=[],i=0,n=this.getCurves(),a=0,r=n.length;a<r;a++){for(var o=n[a],s=o.getTimesWithTangent(e),l=0,h=s.length;l<h;l++){var d=i+o.getOffsetAtTime(s[l]);t.indexOf(d)<0&&t.push(d)}i+=o.length}return t}}),new function(){function e(e,t,i){var n,a,r,o,s,l,h,d,c=t._segments,u=c.length,g=new Array(6),f=!0;function p(t){if(i)t._transformCoordinates(i,g),n=g[0],a=g[1];else{var c=t._point;n=c._x,a=c._y}if(f)e.moveTo(n,a),f=!1;else{if(i)s=g[2],l=g[3];else{var u=t._handleIn;s=n+u._x,l=a+u._y}s===n&&l===a&&h===r&&d===o?e.lineTo(n,a):e.bezierCurveTo(h,d,s,l,n,a)}r=n,o=a,i?(h=g[4],d=g[5]):(u=t._handleOut,h=r+u._x,d=o+u._y)}for(var m=0;m<u;m++)p(c[m]);t._closed&&u>0&&p(c[0])}return{_draw:function(t,i,n,a){var r=i.dontStart,o=i.dontFinish||i.clip,s=this.getStyle(),l=s.hasFill(),h=s.hasStroke(),d=s.getDashArray(),c=!le.support.nativeDash&&h&&d&&d.length;function u(e){return d[(e%c+c)%c]}if(r||t.beginPath(),(l||h&&!c||o)&&(e(t,this,a),this._closed&&t.closePath()),!o&&(l||h)&&(this._setStyles(t,i,n),l&&(t.fill(s.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),h)){if(c){r||t.beginPath();for(var g,f=new L(this,.25,32,!1,a),p=f.length,m=-s.getDashOffset(),v=0;m>0;)m-=u(v--)+u(v--);for(;m<p;)g=m+u(v++),(m>0||g>0)&&f.drawPart(t,Math.max(m,0),Math.max(g,0)),m=g+u(v++)}t.stroke()}},_drawSelected:function(t,i){t.beginPath(),e(t,this,i),t.stroke(),function(e,t,i,n){if(!(n<=0))for(var a,r,o=n/2,s=n-2,l=o-1,h=new Array(6),d=0,c=t.length;d<c;d++){var u=t[d],g=u._selection;if(u._transformCoordinates(i,h),a=h[0],r=h[1],2&g&&p(2),4&g&&p(4),e.fillRect(a-o,r-o,n,n),s>0&&!(1&g)){var f=e.fillStyle;e.fillStyle="#ffffff",e.fillRect(a-l,r-l,s,s),e.fillStyle=f}}function p(t){var i=h[t],n=h[t+1];(a!=i||r!=n)&&(e.beginPath(),e.moveTo(a,r),e.lineTo(i,n),e.stroke(),e.beginPath(),e.arc(i,n,o,0,2*Math.PI,!0),e.fill())}}(t,this._segments,i,le.settings.handleSize)}}},new function(){function e(e){var t=e._segments;if(!t.length)throw new Error("Use a moveTo() command first");return t[t.length-1]}return{moveTo:function(){var e=this._segments;1===e.length&&this.removeSegment(0),e.length||this._add([new T(f.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new T(f.read(arguments))])},cubicCurveTo:function(){var t=arguments,i=f.read(t),n=f.read(t),a=f.read(t),r=e(this);r.setHandleOut(i.subtract(r._point)),this._add([new T(a,n.subtract(a))])},quadraticCurveTo:function(){var t=arguments,i=f.read(t),n=f.read(t),a=e(this)._point;this.cubicCurveTo(i.add(a.subtract(i).multiply(1/3)),i.add(n.subtract(i).multiply(1/3)),n)},curveTo:function(){var t=arguments,i=f.read(t),n=f.read(t),r=a.pick(a.read(t),.5),o=1-r,s=e(this)._point,l=i.subtract(s.multiply(o*o)).subtract(n.multiply(r*r)).divide(2*r*o);if(l.isNaN())throw new Error("Cannot put a curve through points with parameter = "+r);this.quadraticCurveTo(l,n)},arcTo:function(){var t,i,n,r,o=arguments,s=Math.abs,l=Math.sqrt,h=e(this),d=h._point,c=f.read(o),g=a.peek(o);if("boolean"==typeof(x=a.pick(g,!0)))var p=(b=d.add(c).divide(2)).add(b.subtract(d).rotate(x?-90:90));else if(a.remain(o)<=2)p=c,c=f.read(o);else if(!d.equals(c)){var v=m.read(o),I=u.isZero;if(I(v.width)||I(v.height))return this.lineTo(c);var y=a.read(o),x=!!a.read(o),S=!!a.read(o),b=d.add(c).divide(2),w=(q=d.subtract(b).rotate(-y)).x,A=q.y,P=s(v.width),D=s(v.height),k=P*P,_=D*D,z=w*w,O=A*A,B=l(z/k+O/_);if(B>1&&(k=(P*=B)*P,_=(D*=B)*D),s(B=(k*_-k*O-_*z)/(k*O+_*z))<1e-12&&(B=0),B<0)throw new Error("Cannot create an arc with the given arguments");t=new f(P*A/D,-D*w/P).multiply((S===x?-1:1)*l(B)).rotate(y).add(b),i=(n=(r=(new C).translate(t).rotate(y).scale(P,D))._inverseTransform(d)).getDirectedAngle(r._inverseTransform(c)),!x&&i>0?i-=360:x&&i<0&&(i+=360)}if(p){var E=new M(d.add(p).divide(2),p.subtract(d).rotate(90),!0),R=new M(p.add(c).divide(2),c.subtract(p).rotate(90),!0),F=new M(d,c),L=F.getSide(p);if(!(t=E.intersect(R,!0))){if(!L)return this.lineTo(c);throw new Error("Cannot create an arc with the given arguments")}i=(n=d.subtract(t)).getDirectedAngle(c.subtract(t));var G=F.getSide(t,!0);0===G?i=L*s(i):L===G&&(i+=i<0?360:-360)}if(i){for(var U=s(i),j=U>=360?4:Math.ceil((U-1e-5)/90),N=i/j,W=N*Math.PI/360,Z=4/3*Math.sin(W)/(1+Math.cos(W)),H=[],V=0;V<=j;V++){var q=c,J=null;if(V<j&&(J=n.rotate(90).multiply(Z),r?(q=r._transformPoint(n),J=r._transformPoint(n.add(J)).subtract(q)):q=t.add(n)),V){var Q=n.rotate(-90).multiply(Z);r&&(Q=r._transformPoint(n.add(Q)).subtract(q)),H.push(new T(q,Q,J))}else h.setHandleOut(J);n=n.rotate(N)}this._add(H)}},lineBy:function(){var t=f.read(arguments),i=e(this)._point;this.lineTo(i.add(t))},curveBy:function(){var t=arguments,i=f.read(t),n=f.read(t),r=a.read(t),o=e(this)._point;this.curveTo(o.add(i),o.add(n),r)},cubicCurveBy:function(){var t=arguments,i=f.read(t),n=f.read(t),a=f.read(t),r=e(this)._point;this.cubicCurveTo(r.add(i),r.add(n),r.add(a))},quadraticCurveBy:function(){var t=arguments,i=f.read(t),n=f.read(t),a=e(this)._point;this.quadraticCurveTo(a.add(i),a.add(n))},arcBy:function(){var t=arguments,i=e(this)._point,n=i.add(f.read(t)),r=a.pick(a.peek(t),!0);"boolean"==typeof r?this.arcTo(n,r):this.arcTo(n,i.add(f.read(t)))},closePath:function(e){this.setClosed(!0),this.join(this,e)}}},{_getBounds:function(e,t){var i=t.handle?"getHandleBounds":t.stroke?"getStrokeBounds":"getBounds";return R[i](this._segments,this._closed,this,e,t)},statics:{getBounds:function(e,t,i,n,a,r){var o=e[0];if(!o)return new I;var s=new Array(6),l=o._transformCoordinates(n,new Array(6)),h=l.slice(0,2),d=h.slice(),c=new Array(2);function u(e){e._transformCoordinates(n,s);for(var t=0;t<2;t++)O._addBounds(l[t],l[t+4],s[t+2],s[t],t,r?r[t]:0,h,d,c);var i=l;l=s,s=i}for(var g=1,f=e.length;g<f;g++)u(e[g]);return t&&u(o),new I(h[0],h[1],d[0]-h[0],d[1]-h[1])},getStrokeBounds:function(e,t,i,n,a){var r=i.getStyle(),o=r.hasStroke(),s=r.getStrokeWidth(),l=o&&i._getStrokeMatrix(n,a),h=o&&R._getStrokePadding(s,l),d=R.getBounds(e,t,i,n,a,h);if(!o)return d;var c=s/2,u=r.getStrokeJoin(),g=r.getStrokeCap(),f=r.getMiterLimit(),p=new I(new m(h));function v(e){d=d.include(e)}function y(e){d=d.unite(p.setCenter(e._point.transform(n)))}function C(e,t){"round"===t||e.isSmooth()?y(e):R._addBevelJoin(e,t,c,f,n,l,v)}function M(e,t){"round"===t?y(e):R._addSquareCap(e,t,c,n,l,v)}var x=e.length-(t?0:1);if(x>0){for(var S=1;S<x;S++)C(e[S],u);t?C(e[0],u):(M(e[0],g),M(e[e.length-1],g))}return d},_getStrokePadding:function(e,t){if(!t)return[e,e];var i=new f(e,0).transform(t),n=new f(0,e).transform(t),a=i.getAngleInRadians(),r=i.getLength(),o=n.getLength(),s=Math.sin(a),l=Math.cos(a),h=Math.tan(a),d=Math.atan2(o*h,r),c=Math.atan2(o,h*r);return[Math.abs(r*Math.cos(d)*l+o*Math.sin(d)*s),Math.abs(o*Math.sin(c)*l+r*Math.cos(c)*s)]},_addBevelJoin:function(e,t,i,n,a,r,o,s){var l=e.getCurve(),h=l.getPrevious(),d=l.getPoint1().transform(a),c=h.getNormalAtTime(1).multiply(i).transform(r),u=l.getNormalAtTime(0).multiply(i).transform(r),g=c.getDirectedAngle(u);if((g<0||g>=180)&&(c=c.negate(),u=u.negate()),s&&o(d),o(d.add(c)),"miter"===t){var p=new M(d.add(c),new f(-c.y,c.x),!0).intersect(new M(d.add(u),new f(-u.y,u.x),!0),!0);p&&d.getDistance(p)<=n*i&&o(p)}o(d.add(u))},_addSquareCap:function(e,t,i,n,a,r,o){var s=e._point.transform(n),l=e.getLocation(),h=l.getNormal().multiply(0===l.getTime()?i:-i).transform(a);"square"===t&&(o&&(r(s.subtract(h)),r(s.add(h))),s=s.add(h.rotate(-90))),r(s.add(h)),r(s.subtract(h))},getHandleBounds:function(e,t,i,n,a){var r,o,s=i.getStyle();if(a.stroke&&s.hasStroke()){var l=i._getStrokeMatrix(n,a),h=s.getStrokeWidth()/2,d=h;"miter"===s.getStrokeJoin()&&(d=h*s.getMiterLimit()),"square"===s.getStrokeCap()&&(d=Math.max(d,h*Math.SQRT2)),r=R._getStrokePadding(h,l),o=R._getStrokePadding(d,l)}for(var c=new Array(6),u=1/0,g=-u,f=u,p=g,m=0,v=e.length;m<v;m++){e[m]._transformCoordinates(n,c);for(var y=0;y<6;y+=2){var C=y?r:o,M=C?C[0]:0,x=C?C[1]:0,S=c[y],b=c[y+1],w=S-M,A=S+M,P=b-x,D=b+x;w<u&&(u=w),A>g&&(g=A),P<f&&(f=P),D>p&&(p=D)}}return new I(u,f,g-u,p-f)}}});R.inject({statics:new function(){var e=.5522847498307936,t=[new T([-1,0],[0,e],[0,-e]),new T([0,-1],[-e,0],[e,0]),new T([1,0],[0,-e],[0,e]),new T([0,1],[e,0],[-e,0])];function i(e,t,i){var n=a.getNamed(i),r=new R(n&&(1==n.insert?S.INSERT:0==n.insert?S.NO_INSERT:null));return r._add(e),r._closed=t,r.set(n,S.INSERT)}function n(e,n,a){for(var r=new Array(4),o=0;o<4;o++){var s=t[o];r[o]=new T(s._point.multiply(n).add(e),s._handleIn.multiply(n),s._handleOut.multiply(n))}return i(r,!0,a)}return{Line:function(){var e=arguments;return i([new T(f.readNamed(e,"from")),new T(f.readNamed(e,"to"))],!1,e)},Circle:function(){var e=arguments,t=f.readNamed(e,"center"),i=a.readNamed(e,"radius");return n(t,new m(i),e)},Rectangle:function(){var t,n=arguments,a=I.readNamed(n,"rectangle"),r=m.readNamed(n,"radius",0,{readNull:!0}),o=a.getBottomLeft(!0),s=a.getTopLeft(!0),l=a.getTopRight(!0),h=a.getBottomRight(!0);if(!r||r.isZero())t=[new T(o),new T(s),new T(l),new T(h)];else{var d=(r=m.min(r,a.getSize(!0).divide(2))).width,c=r.height,u=d*e,g=c*e;t=[new T(o.add(d,0),null,[-u,0]),new T(o.subtract(0,c),[0,g]),new T(s.add(0,c),null,[0,-g]),new T(s.add(d,0),[-u,0],null),new T(l.subtract(d,0),null,[u,0]),new T(l.add(0,c),[0,-g],null),new T(h.subtract(0,c),null,[0,g]),new T(h.subtract(d,0),[u,0])]}return i(t,!0,n)},RoundRectangle:"#Rectangle",Ellipse:function(){var e=arguments,t=A._readEllipse(e);return n(t.center,t.radius,e)},Oval:"#Ellipse",Arc:function(){var e=arguments,t=f.readNamed(e,"from"),i=f.readNamed(e,"through"),n=f.readNamed(e,"to"),r=a.getNamed(e),o=new R(r&&0==r.insert&&S.NO_INSERT);return o.moveTo(t),o.arcTo(i,n),o.set(r)},RegularPolygon:function(){for(var e=arguments,t=f.readNamed(e,"center"),n=a.readNamed(e,"sides"),r=a.readNamed(e,"radius"),o=360/n,s=n%3==0,l=new f(0,s?-r:r),h=s?-1:.5,d=new Array(n),c=0;c<n;c++)d[c]=new T(t.add(l.rotate((c+h)*o)));return i(d,!0,e)},Star:function(){for(var e=arguments,t=f.readNamed(e,"center"),n=2*a.readNamed(e,"points"),r=a.readNamed(e,"radius1"),o=a.readNamed(e,"radius2"),s=360/n,l=new f(0,-1),h=new Array(n),d=0;d<n;d++)h[d]=new T(t.add(l.rotate(s*d).multiply(d%2?o:r)));return i(h,!0,e)}}}});var F=E.extend({_class:"CompoundPath",_serializeFields:{children:[]},beans:!0,initialize:function(e){this._children=[],this._namedChildren={},this._initialize(e)||("string"==typeof e?this.setPathData(e):this.addChildren(Array.isArray(e)?e:arguments))},insertChildren:function e(t,i){var n=i,r=n[0];r&&"number"==typeof r[0]&&(n=[n]);for(var o=i.length-1;o>=0;o--){var s=n[o];n===i&&!(s instanceof R)&&(n=a.slice(n)),Array.isArray(s)?n[o]=new R({segments:s,insert:!1}):s instanceof F&&(n.splice.apply(n,[o,1].concat(s.removeChildren())),s.remove())}return e.base.call(this,t,n)},reduce:function e(t){for(var i=this._children,n=i.length-1;n>=0;n--)(a=i[n].reduce(t)).isEmpty()&&a.remove();var a;return i.length?e.base.call(this):((a=new R(S.NO_INSERT)).copyAttributes(this),a.insertAbove(this),this.remove(),a)},isClosed:function(){for(var e=this._children,t=0,i=e.length;t<i;t++)if(!e[t]._closed)return!1;return!0},setClosed:function(e){for(var t=this._children,i=0,n=t.length;i<n;i++)t[i].setClosed(e)},getFirstSegment:function(){var e=this.getFirstChild();return e&&e.getFirstSegment()},getLastSegment:function(){var e=this.getLastChild();return e&&e.getLastSegment()},getCurves:function(){for(var e=this._children,t=[],i=0,n=e.length;i<n;i++)a.push(t,e[i].getCurves());return t},getFirstCurve:function(){var e=this.getFirstChild();return e&&e.getFirstCurve()},getLastCurve:function(){var e=this.getLastChild();return e&&e.getLastCurve()},getArea:function(){for(var e=this._children,t=0,i=0,n=e.length;i<n;i++)t+=e[i].getArea();return t},getLength:function(){for(var e=this._children,t=0,i=0,n=e.length;i<n;i++)t+=e[i].getLength();return t},getPathData:function(e,t){for(var i=this._children,n=[],a=0,r=i.length;a<r;a++){var o=i[a],s=o._matrix;n.push(o.getPathData(e&&!s.isIdentity()?e.appended(s):e,t))}return n.join("")},_hitTestChildren:function e(t,i,n){return e.base.call(this,t,i.class===R||"path"===i.type?i:a.set({},i,{fill:!1}),n)},_draw:function(e,t,i,n){var a=this._children;if(a.length){t=t.extend({dontStart:!0,dontFinish:!0}),e.beginPath();for(var r=0,o=a.length;r<o;r++)a[r].draw(e,t,n);if(!t.clip){this._setStyles(e,t,i);var s=this._style;s.hasFill()&&(e.fill(s.getFillRule()),e.shadowColor="rgba(0,0,0,0)"),s.hasStroke()&&e.stroke()}}},_drawSelected:function(e,t,i){for(var n=this._children,a=0,r=n.length;a<r;a++){var o=n[a],s=o._matrix;i[o._id]||o._drawSelected(e,s.isIdentity()?t:t.appended(s))}}},new function(){function e(e,t){var i=e._children;if(t&&!i.length)throw new Error("Use a moveTo() command first");return i[i.length-1]}return a.each(["lineTo","cubicCurveTo","quadraticCurveTo","curveTo","arcTo","lineBy","cubicCurveBy","quadraticCurveBy","curveBy","arcBy"],function(t){this[t]=function(){var i=e(this,!0);i[t].apply(i,arguments)}},{moveTo:function(){var t=e(this),i=t&&t.isEmpty()?t:new R(S.NO_INSERT);i!==t&&this.addChild(i),i.moveTo.apply(i,arguments)},moveBy:function(){var t=e(this,!0),i=t&&t.getLastSegment(),n=f.read(arguments);this.moveTo(i?n.add(i._point):n)},closePath:function(t){e(this,!0).closePath(t)}})},a.each(["reverse","flatten","simplify","smooth"],function(e){this[e]=function(t){for(var i,n=this._children,a=0,r=n.length;a<r;a++)i=n[a][e](t)||i;return i}},{}));E.inject(new function(){var e=Math.min,i=Math.max,n=Math.abs,r={unite:{1:!0,2:!0},intersect:{2:!0},subtract:{1:!0},exclude:{1:!0,"-1":!0}};function o(e){return e._children||[e]}function s(e,t){var i=e.clone(!1).reduce({simplify:!0}).transform(null,!0,!0);if(t){for(var n=o(i),a=0,r=n.length;a<r;a++)!(e=n[a])._closed&&!e.isEmpty()&&(e.closePath(1e-12),e.getFirstSegment().setHandleIn(0,0),e.getLastSegment().setHandleOut(0,0));i=i.resolveCrossings().reorient("nonzero"===i.getFillRule(),!0)}return i}function l(e,t,i,n,a){var r=new F(S.NO_INSERT);return r.addChildren(e,!0),r=r.reduce({simplify:t}),a&&0==a.insert||r.insertAbove(n&&i.isSibling(n)&&i.getIndex()<n.getIndex()?n:i),r.copyAttributes(i,!0),r}function h(e){return e.hasOverlap()||e.isCrossing()}function c(e,t,i,n){if(n&&(0==n.trace||n.stroke)&&/^(subtract|intersect)$/.test(i))return g(e,t,i);var c=s(e,!0),u=t&&e!==t&&s(t,!0),f=r[i];f[i]=!0,u&&(f.subtract||f.exclude)^u.isClockwise()^c.isClockwise()&&u.reverse();var p,I=v(B.expand(c.getIntersections(u,h))),M=o(c),x=u&&o(u),S=[],b=[];function w(e){for(var t=0,i=e.length;t<i;t++){var n=e[t];a.push(S,n._segments),a.push(b,n.getCurves()),n._overlapsOnly=!0}}function A(e){for(var t=[],i=0,n=e&&e.length;i<n;i++)t.push(b[e[i]]);return t}if(I.length){w(M),x&&w(x);for(var P=new Array(b.length),D=0,k=b.length;D<k;D++)P[D]=b[D].getValues();var _=d.findCurveBoundsCollisions(P,P,0,!0),T={};for(D=0;D<b.length;D++){var z=b[D],O=z._path._id;(T[O]=T[O]||{})[z.getIndex()]={hor:A(_[D].hor),ver:A(_[D].ver)}}for(D=0,k=I.length;D<k;D++)y(I[D]._segment,c,u,T,f);for(D=0,k=S.length;D<k;D++){var E=S[D],R=E._intersection;E._winding||y(E,c,u,T,f),R&&R._overlap||(E._path._overlapsOnly=!1)}p=C(S,f)}else p=m(x?M.concat(x):M.slice(),function(e){return!!f[e]});return l(p,!0,e,t,n)}function g(e,t,i){var n=s(e),a=s(t),r=n.getIntersections(a,h),o="subtract"===i,d="divide"===i,c={},u=[];function g(e){if(!c[e._id]&&(d||a.contains(e.getPointAt(e.getLength()/2))^o))return u.unshift(e),c[e._id]=!0}for(var f=r.length-1;f>=0;f--){var p=r[f].split();p&&(g(p)&&p.getFirstSegment().setHandleIn(0,0),n.getLastSegment().setHandleOut(0,0))}return g(n),l(u,!1,e,t)}function f(e,t){for(var i=e;i;){if(i===t)return;i=i._previous}for(;e._next&&e._next!==t;)e=e._next;if(!e._next){for(;t._previous;)t=t._previous;e._next=t,t._previous=e}}function p(e){for(var t=e.length-1;t>=0;t--)e[t].clearHandles()}function m(e,t,i){var r=e&&e.length;if(r){var o=a.each(e,function(e,t){this[e._id]={container:null,winding:e.isClockwise()?1:-1,index:t}},{}),s=e.slice().sort(function(e,t){return n(t.getArea())-n(e.getArea())}),l=s[0],h=d.findItemBoundsCollisions(s,null,u.GEOMETRIC_EPSILON);null==i&&(i=l.isClockwise());for(var c=0;c<r;c++){var g=s[c],f=o[g._id],p=0,m=h[c];if(m)for(var v=null,I=m.length-1;I>=0;I--)if(m[I]<c){v=v||g.getInteriorPoint();var y=s[m[I]];if(y.contains(v)){var C=o[y._id];p=C.winding,f.winding+=p,f.container=C.exclude?C.container:y;break}}if(t(f.winding)===t(p))f.exclude=!0,e[f.index]=null;else{var M=f.container;g.setClockwise(M?!M.isClockwise():i)}}}return e}function v(e,t,i){var n,a,r,o=t&&[],s=1e-8,l=!1,h=i||[],d=i&&{};function c(e){return e._path._id+"."+e._segment1._index}for(var u=(i&&i.length)-1;u>=0;u--)(g=i[u])._path&&(d[c(g)]=!0);for(u=e.length-1;u>=0;u--){var g,m,v=e[u],I=v._time,y=I,C=t&&!t(v);if((g=v._curve)&&(g!==a?(l=!g.hasHandles()||d&&d[c(g)],n=[],r=null,a=g):r>=s&&(I/=r)),C)n&&n.push(v);else{if(t&&o.unshift(v),r=y,I<s)m=g._segment1;else if(I>.99999999)m=g._segment2;else{var M=g.divideAtTime(I,!0);l&&h.push(g,M),m=M._segment1;for(var x=n.length-1;x>=0;x--){var S=n[x];S._time=(S._time-I)/(1-I)}}v._setSegment(m);var b=m._intersection,w=v._intersection;if(b){f(b,w);for(var A=b;A;)f(A._intersection,b),A=A._next}else m._intersection=w}}return i||p(h),o||e}function I(t,a,r,o,s){var l,h,d=Array.isArray(a)?a:a[r?"hor":"ver"],c=r?1:0,u=1^c,g=[t.x,t.y],f=g[c],p=g[u],m=1e-6,v=f-1e-9,y=f+1e-9,C=0,M=0,x=0,S=0,b=!1,w=!1,A=1,P=[];function D(n){var h=n[u+0],d=n[u+6];if(!(p<e(h,d)||p>i(h,d))){var g=n[c+0],C=n[c+2],M=n[c+4],w=n[c+6];if(h===d)return void((g<y&&w>v||w<y&&g>v)&&(b=!0));var D=p===h?0:p===d||v>i(g,C,M,w)||y<e(g,C,M,w)?1:O.solveCubic(n,u,p,P,0,1)>0?P[0]:1,k=0===D?g:1===D?w:O.getPoint(n,D)[r?"y":"x"],_=h>d?1:-1,T=l[u]>l[u+6]?1:-1,z=l[c+6];return p!==h?(k<v?x+=_:k>y?S+=_:b=!0,k>f-m&&k<f+m&&(A/=2)):(_!==T?g<v?x+=_:g>y&&(S+=_):g!=z&&(z<y&&k>y?(S+=_,b=!0):z>v&&k<v&&(x+=_,b=!0)),A/=4),l=n,!s&&k>v&&k<y&&0===O.getTangent(n,D)[r?"x":"y"]&&I(t,a,!r,o,!0)}}function k(t){var n=t[u+0],a=t[u+2],o=t[u+4],s=t[u+6];if(p<=i(n,a,o,s)&&p>=e(n,a,o,s))for(var l,h=t[c+0],d=t[c+2],g=t[c+4],f=t[c+6],m=v>i(h,d,g,f)||y<e(h,d,g,f)?[t]:O.getMonoCurves(t,r),I=0,C=m.length;I<C;I++)if(l=D(m[I]))return l}for(var _=0,T=d.length;_<T;_++){var z,B=d[_],E=B._path,R=B.getValues();if(!(_&&d[_-1]._path===E||(l=null,E._closed||(h=O.getValues(E.getLastCurve().getSegment2(),B.getSegment1(),null,!o),h[u]!==h[u+6]&&(l=h)),l))){l=R;for(var F=E.getLastCurve();F&&F!==B;){var L=F.getValues();if(L[u]!==L[u+6]){l=L;break}F=F.getPrevious()}}if(z=k(R))return z;if(_+1===T||d[_+1]._path!==E){if(h&&(z=k(h)))return z;b&&!x&&!S&&(x=S=E.isClockwise(o)^r?1:-1),C+=x,M+=S,x=S=0,b&&(w=!0,b=!1),h=null}}return C=n(C),M=n(M),{winding:i(C,M),windingL:C,windingR:M,quality:A,onPath:w}}function y(e,t,i,a,r){var o=[],s=e,l=0;do{if(y=e.getCurve()){var h=y.getLength();o.push({segment:e,curve:y,length:h}),l+=h}e=e.getNext()}while(e&&!e._intersection&&e!==s);for(var d=[.5,.25,.75],c={winding:0,quality:-1},g=0;g<d.length&&c.quality<.5;g++){h=l*d[g];for(var f=0,p=o.length;f<p;f++){var m=o[f],v=m.length;if(h<=v){var y,C=(y=m.curve)._path,M=C._parent,x=M instanceof F?M:C,S=u.clamp(y.getTimeAt(h),.001,.999),b=y.getPointAtTime(S),w=n(y.getTangentAtTime(S).y)<Math.SQRT1_2,A=null;if(r.subtract&&i){var P=(x===t?i:t)._getWinding(b,w,!0);if(x===t&&P.winding||x===i&&!P.winding){if(P.quality<1)continue;A={winding:0,quality:1}}}(A=A||I(b,a[C._id][y.getIndex()],w,!0)).quality>c.quality&&(c=A);break}h-=v}}for(f=o.length-1;f>=0;f--)o[f].segment._winding=c}function C(e,t){var i,n=[];function a(e){var i;return!(!e||e._visited||t&&(!t[(i=e._winding||{}).winding]||t.unite&&2===i.winding&&i.windingL&&i.windingR))}function r(e){if(e)for(var t=0,n=i.length;t<n;t++)if(e===i[t])return!0;return!1}function o(e){for(var t=e._segments,i=0,n=t.length;i<n;i++)t[i]._visited=!0}function s(e,t){var n=e._intersection,o=n,s=[];function l(n,o){for(;n&&n!==o;){var l=n._segment,h=l&&l._path;if(h){var d=l.getNext()||h.getFirstSegment(),c=d._intersection;l!==e&&(r(l)||r(d)||d&&a(l)&&(a(d)||c&&a(c._segment)))&&s.push(l),t&&i.push(l)}n=n._next}}if(t&&(i=[e]),n){for(l(n);n&&n._previous;)n=n._previous;l(n,o)}return s}e.sort(function(e,t){var i=e._intersection,n=t._intersection,a=!(!i||!i._overlap),r=!(!n||!n._overlap),o=e._path,s=t._path;return a^r?a?1:-1:!i^!n?i?1:-1:o!==s?o._id-s._id:e._index-t._index});for(var l=0,h=e.length;l<h;l++){var d,c,u,g=e[l],f=a(g),p=null,m=!1,v=!0,I=[];if(f&&g._path._overlapsOnly){var y=g._path,C=g._intersection._segment._path;y.compare(C)&&(y.getArea()&&n.push(y.clone(!1)),o(y),o(C),f=!1)}for(;f;){var M=!p,x=s(g,M),b=x.shift(),w=!(m=!M&&(r(g)||r(b)))&&b;if(M&&(p=new R(S.NO_INSERT),d=null),m){(g.isFirst()||g.isLast())&&(v=g._path._closed),g._visited=!0;break}if(w&&d&&(I.push(d),d=null),d||(w&&x.push(g),d={start:p._segments.length,crossings:x,visited:c=[],handleIn:u}),w&&(g=b),!a(g)){p.removeSegments(d.start);for(var A=0,P=c.length;A<P;A++)c[A]._visited=!1;c.length=0;do{(!(g=d&&d.crossings.shift())||!g._path)&&(g=null,(d=I.pop())&&(c=d.visited,u=d.handleIn))}while(d&&!a(g));if(!g)break}var D=g.getNext();p.add(new T(g._point,u,D&&g._handleOut)),g._visited=!0,c.push(g),g=D||g._path.getFirstSegment(),u=D&&D._handleIn}m&&(v&&(p.getFirstSegment().setHandleIn(u),p.setClosed(v)),0!==p.getArea()&&n.push(p))}return n}return{_getWinding:function(e,t,i){return I(e,this.getCurves(),t,i)},unite:function(e,t){return c(this,e,"unite",t)},intersect:function(e,t){return c(this,e,"intersect",t)},subtract:function(e,t){return c(this,e,"subtract",t)},exclude:function(e,t){return c(this,e,"exclude",t)},divide:function(e,t){return t&&(0==t.trace||t.stroke)?g(this,e,"divide"):l([this.subtract(e,t),this.intersect(e,t)],!0,this,e,t)},resolveCrossings:function(){var e=this._children,t=e||[this];function i(e,t){var i=e&&e._intersection;return i&&i._overlap&&i._path===t}var n=!1,r=!1,o=this.getIntersections(null,function(e){return e.hasOverlap()&&(n=!0)||e.isCrossing()&&(r=!0)}),s=n&&r&&[];if(o=B.expand(o),n)for(var l=v(o,function(e){return e.hasOverlap()},s),h=l.length-1;h>=0;h--){var d=l[h],c=d._path,u=d._segment,g=u.getPrevious(),f=u.getNext();i(g,c)&&i(f,c)&&(u.remove(),g._handleOut._set(0,0),f._handleIn._set(0,0),g!==u&&!g.getCurve().hasLength()&&(f._handleIn.set(g._handleIn),g.remove()))}r&&(v(o,n&&function(e){var t=e.getCurve(),i=e.getSegment(),n=e._intersection,a=n._curve,r=n._segment;if(t&&a&&t._path&&a._path)return!0;i&&(i._intersection=null),r&&(r._intersection=null)},s),s&&p(s),t=C(a.each(t,function(e){a.push(this,e._segments)},[])));var m,I=t.length;return I>1&&e?(t!==e&&this.setChildren(t),m=this):1===I&&!e&&(t[0]!==this&&this.setSegments(t[0].removeSegments()),m=this),m||((m=new F(S.NO_INSERT)).addChildren(t),(m=m.reduce()).copyAttributes(this),this.replaceWith(m)),m},reorient:function(e,i){var n=this._children;return n&&n.length?this.setChildren(m(this.removeChildren(),function(t){return!!(e?t:1&t)},i)):i!==t&&this.setClockwise(i),this},getInteriorPoint:function(){var t=this.getBounds().getCenter(!0);if(!this.contains(t)){for(var n=this.getCurves(),a=t.y,r=[],o=[],s=0,l=n.length;s<l;s++){var h=n[s].getValues(),d=h[1],c=h[3],u=h[5],g=h[7];if(a>=e(d,c,u,g)&&a<=i(d,c,u,g))for(var f=O.getMonoCurves(h),p=0,m=f.length;p<m;p++){var v=f[p],I=v[1],y=v[7];if(I!==y&&(a>=I&&a<=y||a>=y&&a<=I)){var C=a===I?v[0]:a===y?v[6]:1===O.solveCubic(v,1,a,o,0,1)?O.getPoint(v,o[0]).x:(v[0]+v[6])/2;r.push(C)}}}r.length>1&&(r.sort(function(e,t){return e-t}),t.x=(r[0]+r[1])/2)}return t}}});var L=a.extend({_class:"PathFlattener",initialize:function(e,t,i,n,a){var r,o=[],s=[],l=0,h=1/(i||32),d=e._segments,c=d[0];function u(e,i){var r=O.getValues(e,i,a);o.push(r),function e(i,a,r,o){if(!(o-r>h)||n&&O.isStraight(i)||O.isFlatEnough(i,t||.25)){var d=i[6]-i[0],c=i[7]-i[1],u=Math.sqrt(d*d+c*c);u>0&&(l+=u,s.push({offset:l,curve:i,index:a,time:o}))}else{var g=O.subdivide(i,.5),f=(r+o)/2;e(g[0],a,r,f),e(g[1],a,f,o)}}(r,e._index,0,1)}for(var g=1,f=d.length;g<f;g++)u(c,r=d[g]),c=r;e._closed&&u(r||c,d[0]),this.curves=o,this.parts=s,this.length=l,this.index=0},_get:function(e){for(var t,i=this.parts,n=i.length,a=this.index;t=a,a&&!(i[--a].offset<e););for(;t<n;t++){var r=i[t];if(r.offset>=e){this.index=t;var o=i[t-1],s=o&&o.index===r.index?o.time:0,l=o?o.offset:0;return{index:r.index,time:s+(r.time-s)*(e-l)/(r.offset-l)}}}return{index:i[n-1].index,time:1}},drawPart:function(e,t,i){for(var n=this._get(t),a=this._get(i),r=n.index,o=a.index;r<=o;r++){var s=O.getPart(this.curves[r],r===n.index?n.time:0,r===a.index?a.time:1);r===n.index&&e.moveTo(s[0],s[1]),e.bezierCurveTo.apply(e,s.slice(2))}}},a.each(O._evaluateMethods,function(e){this[e+"At"]=function(t){var i=this._get(t);return O[e](this.curves[i.index],i.time)}},{})),G=a.extend({initialize:function(e){for(var t,i=this.points=[],n=e._segments,a=e._closed,r=0,o=n.length;r<o;r++){var s=n[r].point;(!t||!t.equals(s))&&i.push(t=s.clone())}a&&(i.unshift(i[i.length-1]),i.push(i[1])),this.closed=a},fit:function(e){var t=this.points,i=t.length,n=null;return i>0&&(n=[new T(t[0])],i>1&&(this.fitCubic(n,e,0,i-1,t[1].subtract(t[0]),t[i-2].subtract(t[i-1])),this.closed&&(n.shift(),n.pop()))),n},fitCubic:function(e,t,i,n,a,r){var o=this.points;if(n-i!=1){for(var s,l=this.chordLengthParameterize(i,n),h=Math.max(t,t*t),d=!0,c=0;c<=4;c++){var u=this.generateBezier(i,n,l,a,r),g=this.findMaxError(i,n,u,l);if(g.error<t&&d)return void this.addCurve(e,u);if(s=g.index,g.error>=h)break;d=this.reparameterize(i,n,l,u),h=g.error}var f=o[s-1].subtract(o[s+1]);this.fitCubic(e,t,i,s,a,f),this.fitCubic(e,t,s,n,f.negate(),r)}else{var p=o[i],m=o[n],v=p.getDistance(m)/3;this.addCurve(e,[p,p.add(a.normalize(v)),m.add(r.normalize(v)),m])}},addCurve:function(e,t){e[e.length-1].setHandleOut(t[1].subtract(t[0])),e.push(new T(t[3],t[2].subtract(t[3])))},generateBezier:function(e,t,i,n,a){for(var r=1e-12,o=Math.abs,s=this.points,l=s[e],h=s[t],d=[[0,0],[0,0]],c=[0,0],u=0,g=t-e+1;u<g;u++){var f=i[u],p=1-f,m=3*f*p,v=p*p*p,I=m*p,y=m*f,C=f*f*f,M=n.normalize(I),x=a.normalize(y),S=s[e+u].subtract(l.multiply(v+I)).subtract(h.multiply(y+C));d[0][0]+=M.dot(M),d[0][1]+=M.dot(x),d[1][0]=d[0][1],d[1][1]+=x.dot(x),c[0]+=M.dot(S),c[1]+=x.dot(S)}var b,w,A=d[0][0]*d[1][1]-d[1][0]*d[0][1];if(o(A)>r){var P=d[0][0]*c[1]-d[1][0]*c[0];b=(c[0]*d[1][1]-c[1]*d[0][1])/A,w=P/A}else{var D=d[0][0]+d[0][1],k=d[1][0]+d[1][1];b=w=o(D)>r?c[0]/D:o(k)>r?c[1]/k:0}var _,T,z=h.getDistance(l),O=r*z;if(b<O||w<O)b=w=z/3;else{var B=h.subtract(l);_=n.normalize(b),T=a.normalize(w),_.dot(B)-T.dot(B)>z*z&&(b=w=z/3,_=T=null)}return[l,l.add(_||n.normalize(b)),h.add(T||a.normalize(w)),h]},reparameterize:function(e,t,i,n){for(var a=e;a<=t;a++)i[a-e]=this.findRoot(n,this.points[a],i[a-e]);a=1;for(var r=i.length;a<r;a++)if(i[a]<=i[a-1])return!1;return!0},findRoot:function(e,t,i){for(var n=[],a=[],r=0;r<=2;r++)n[r]=e[r+1].subtract(e[r]).multiply(3);for(r=0;r<=1;r++)a[r]=n[r+1].subtract(n[r]).multiply(2);var o=this.evaluate(3,e,i),s=this.evaluate(2,n,i),l=this.evaluate(1,a,i),h=o.subtract(t),d=s.dot(s)+h.dot(l);return u.isMachineZero(d)?i:i-h.dot(s)/d},evaluate:function(e,t,i){for(var n=t.slice(),a=1;a<=e;a++)for(var r=0;r<=e-a;r++)n[r]=n[r].multiply(1-i).add(n[r+1].multiply(i));return n[0]},chordLengthParameterize:function(e,t){for(var i=[0],n=e+1;n<=t;n++)i[n-e]=i[n-e-1]+this.points[n].getDistance(this.points[n-1]);n=1;for(var a=t-e;n<=a;n++)i[n]/=i[a];return i},findMaxError:function(e,t,i,n){for(var a=Math.floor((t-e+1)/2),r=0,o=e+1;o<t;o++){var s=this.evaluate(3,i,n[o-e]).subtract(this.points[o]),l=s.x*s.x+s.y*s.y;l>=r&&(r=l,a=o)}return{error:r,index:a}}}),U=S.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(e){this._content="",this._lines=[];var i=e&&a.isPlainObject(e)&&e.x===t&&e.y===t;this._initialize(i&&e,!i&&f.read(arguments))},_equals:function(e){return this._content===e._content},copyContent:function(e){this.setContent(e._content)},getContent:function(){return this._content},setContent:function(e){this._content=""+e,this._lines=this._content.split(/\r\n|\n|\r/gm),this._changed(521)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),j=U.extend({_class:"PointText",initialize:function(){U.apply(this,arguments)},getPoint:function(){var e=this._matrix.getTranslation();return new p(e.x,e.y,this,"setPoint")},setPoint:function(){var e=f.read(arguments);this.translate(e.subtract(this._matrix.getTranslation()))},_draw:function(e,t,i){if(this._content){this._setStyles(e,t,i);var n=this._lines,a=this._style,r=a.hasFill(),o=a.hasStroke(),s=a.getLeading(),l=e.shadowColor;e.font=a.getFontStyle(),e.textAlign=a.getJustification();for(var h=0,d=n.length;h<d;h++){e.shadowColor=l;var c=n[h];r&&(e.fillText(c,0,0),e.shadowColor="rgba(0,0,0,0)"),o&&e.strokeText(c,0,0),e.translate(0,s)}}},_getBounds:function(e,t){var i=this._style,n=this._lines,a=n.length,r=i.getJustification(),o=i.getLeading(),s=this.getView().getTextWidth(i.getFontStyle(),n),l=0;"left"!==r&&(l-=s/("center"===r?2:1));var h=new I(l,a?-.75*o:0,s,a*o);return e?e._transformBounds(h,h):h}}),N=a.extend(new function(){var e,t={gray:["gray"],rgb:["red","green","blue"],hsb:["hue","saturation","brightness"],hsl:["hue","saturation","lightness"],gradient:["gradient","origin","destination","highlight"]},n={},r={transparent:[0,0,0,0]},o=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]],s={"rgb-hsb":function(e,t,i){var n=Math.max(e,t,i),a=n-Math.min(e,t,i);return[0===a?0:60*(n==e?(t-i)/a+(t<i?6:0):n==t?(i-e)/a+2:(e-t)/a+4),0===n?0:a/n,n]},"hsb-rgb":function(e,t,i){var n,a=(e=(e/60%6+6)%6)-(n=Math.floor(e)),r=[i,i*(1-t),i*(1-t*a),i*(1-t*(1-a))];return[r[(n=o[n])[0]],r[n[1]],r[n[2]]]},"rgb-hsl":function(e,t,i){var n=Math.max(e,t,i),a=Math.min(e,t,i),r=n-a,o=0===r,s=(n+a)/2;return[o?0:60*(n==e?(t-i)/r+(t<i?6:0):n==t?(i-e)/r+2:(e-t)/r+4),o?0:s<.5?r/(n+a):r/(2-n-a),s]},"hsl-rgb":function(e,t,i){if(0===t)return[i,i,i];for(var n=[(e=(e/360%1+1)%1)+1/3,e,e-1/3],a=i<.5?i*(1+t):i+t-i*t,r=2*i-a,o=[],s=0;s<3;s++){var l=n[s];l<0&&(l+=1),l>1&&(l-=1),o[s]=6*l<1?r+6*(a-r)*l:2*l<1?a:3*l<2?r+(a-r)*(2/3-l)*6:r}return o},"rgb-gray":function(e,t,i){return[.2989*e+.587*t+.114*i]},"gray-rgb":function(e){return[e,e,e]},"gray-hsb":function(e){return[0,0,e]},"gray-hsl":function(e){return[0,0,e]},"gradient-rgb":function(){return[]},"rgb-gradient":function(){return[]}};return a.each(t,function(e,i){n[i]=[],a.each(e,function(e,r){var o=a.capitalize(e),s=/^(hue|saturation)$/.test(e),l=n[i][r]="gradient"===i?"gradient"===e?function(e){var t=this._components[0];return t!==(e=W.read(Array.isArray(e)?e:arguments,0,{readNull:!0}))&&(t&&t._removeOwner(this),e&&e._addOwner(this)),e}:function(){return f.read(arguments,0,{readNull:"highlight"===e,clone:!0})}:function(e){return null==e||isNaN(e)?0:+e};this["get"+o]=function(){return this._type===i||s&&/^hs[bl]$/.test(this._type)?this._components[r]:this._convert(i)[r]},this["set"+o]=function(e){this._type!==i&&!(s&&/^hs[bl]$/.test(this._type))&&(this._components=this._convert(i),this._properties=t[i],this._type=i),this._components[r]=l.call(this,e),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function o(s){var l,h,d,c,u=arguments,g=this.__read,f=0;Array.isArray(s)&&(s=(u=s)[0]);var p=null!=s&&typeof s;if("string"===p&&s in t&&(l=s,s=u[1],Array.isArray(s)?(h=s,d=u[2]):(g&&(f=1),u=a.slice(u,1),p=typeof s)),!h){if(c="number"===p?u:"object"===p&&null!=s.length?s:null){l||(l=c.length>=3?"rgb":"gray");var m=t[l].length;d=c[m],g&&(f+=c===arguments?m+(null!=d?1:0):1),c.length>m&&(c=a.slice(c,0,m))}else if("string"===p){var v=function(t){var n,a=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?$/i)||t.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])?$/i),o="rgb";if(a){var s=a[4]?4:3;n=new Array(s);for(var l=0;l<s;l++){var h=a[l+1];n[l]=parseInt(1==h.length?h+h:h,16)/255}}else if(a=t.match(/^(rgb|hsl)a?\((.*)\)$/)){o=a[1],n=a[2].trim().split(/[,\s]+/g);for(var d="hsl"===o,c=(l=0,Math.min(n.length,4));l<c;l++){var u=n[l];if(h=parseFloat(u),d)if(0===l){var g=u.match(/([a-z]*)$/)[1];h*={turn:360,rad:180/Math.PI,grad:.9}[g]||1}else l<3&&(h/=100);else l<3&&(h/=/%$/.test(u)?100:255);n[l]=h}}else{var f=r[t];if(!f)if(i){e||((e=ae.getContext(1,1,{willReadFrequently:!0})).globalCompositeOperation="copy"),e.fillStyle="rgba(0,0,0,0)",e.fillStyle=t,e.fillRect(0,0,1,1);var p=e.getImageData(0,0,1,1).data;f=r[t]=[p[0]/255,p[1]/255,p[2]/255]}else f=[0,0,0];n=f.slice()}return[o,n]}(s);l=v[0],4===(h=v[1]).length&&(d=h[3],h.length--)}else if("object"===p)if(s.constructor===o){if(l=s._type,h=s._components.slice(),d=s._alpha,"gradient"===l)for(var I=1,y=h.length;I<y;I++){var C=h[I];C&&(h[I]=C.clone())}}else if(s.constructor===W)l="gradient",c=u;else{var M=t[l="hue"in s?"lightness"in s?"hsl":"hsb":"gradient"in s||"stops"in s||"radial"in s?"gradient":"gray"in s?"gray":"rgb"],x=n[l];for(this._components=h=[],I=0,y=M.length;I<y;I++)null==(S=s[M[I]])&&!I&&"gradient"===l&&"stops"in s&&(S={stops:s.stops,radial:s.radial}),null!=(S=x[I].call(this,S))&&(h[I]=S);d=s.alpha}g&&l&&(f=1)}if(this._type=l||"rgb",!h)for(this._components=h=[],I=0,y=(x=n[this._type]).length;I<y;I++){var S;null!=(S=x[I].call(this,c&&c[I]))&&(h[I]=S)}return this._components=h,this._properties=t[this._type],this._alpha=d,g&&(this.__read=f),this},set:"#initialize",_serialize:function(e,t){var i=this.getComponents();return a.serialize(/^(gray|rgb)$/.test(this._type)?i:[this._type].concat(i),e,!0,t)},_changed:function(){this._canvasStyle=null,this._owner&&(this._setter?this._owner[this._setter](this):this._owner._changed(129))},_convert:function(e){var t;return this._type===e?this._components.slice():(t=s[this._type+"-"+e])?t.apply(this,this._components):s["rgb-"+e].apply(this,s[this._type+"-rgb"].apply(this,this._components))},convert:function(e){return new N(e,this._convert(e),this._alpha)},getType:function(){return this._type},setType:function(e){this._components=this._convert(e),this._properties=t[e],this._type=e},getComponents:function(){var e=this._components.slice();return null!=this._alpha&&e.push(this._alpha),e},getAlpha:function(){return null!=this._alpha?this._alpha:1},setAlpha:function(e){this._alpha=null==e?null:Math.min(Math.max(e,0),1),this._changed()},hasAlpha:function(){return null!=this._alpha},equals:function(e){var t=a.isPlainValue(e,!0)?N.read(arguments):e;return t===this||t&&this._class===t._class&&this._type===t._type&&this.getAlpha()===t.getAlpha()&&a.equals(this._components,t._components)||!1},toString:function(){for(var e=this._properties,t=[],i="gradient"===this._type,n=c.instance,a=0,r=e.length;a<r;a++){var o=this._components[a];null!=o&&t.push(e[a]+": "+(i?o:n.number(o)))}return null!=this._alpha&&t.push("alpha: "+n.number(this._alpha)),"{ "+t.join(", ")+" }"},toCSS:function(e){var t=this._convert("rgb"),i=e||null==this._alpha?1:this._alpha;function n(e){return Math.round(255*(e<0?0:e>1?1:e))}return t=[n(t[0]),n(t[1]),n(t[2])],i<1&&t.push(i<0?0:i),e?"#"+((1<<24)+(t[0]<<16)+(t[1]<<8)+t[2]).toString(16).slice(1):(4==t.length?"rgba(":"rgb(")+t.join(",")+")"},toCanvasStyle:function(e,t){if(this._canvasStyle)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var i,n=this._components,a=n[0],r=a._stops,o=n[1],s=n[2],l=n[3],h=t&&t.inverted();if(h&&(o=h._transformPoint(o),s=h._transformPoint(s),l&&(l=h._transformPoint(l))),a._radial){var d=s.getDistance(o);if(l){var c=l.subtract(o);c.getLength()>d&&(l=o.add(c.normalize(d-.1)))}var u=l||o;i=e.createRadialGradient(u.x,u.y,0,o.x,o.y,d)}else i=e.createLinearGradient(o.x,o.y,s.x,s.y);for(var g=0,f=r.length;g<f;g++){var p,m=r[g],v=m._offset;i.addColorStop(null!==(p=v)&&void 0!==p?p:g/(f-1),m._color.toCanvasStyle())}return this._canvasStyle=i},transform:function(e){if("gradient"===this._type){for(var t=this._components,i=1,n=t.length;i<n;i++){var a=t[i];e._transformPoint(a,a,!0)}this._changed()}},statics:{_types:t,random:function(){var e=Math.random;return new N(e(),e(),e())},_setOwner:function(e,t,i){return e&&(e._owner&&t&&e._owner!==t&&(e=e.clone()),!e._owner^!t&&(e._owner=t||null,e._setter=i||null)),e}}})},new function(){return a.each({add:function(e,t){return e+t},subtract:function(e,t){return e-t},multiply:function(e,t){return e*t},divide:function(e,t){return e/t}},function(e,t){this[t]=function(t){t=N.read(arguments);for(var i=this._type,n=this._components,a=t._convert(i),r=0,o=n.length;r<o;r++)a[r]=e(n[r],a[r]);return new N(i,a,null!=this._alpha?e(this._alpha,t.getAlpha()):null)}},{})}),W=a.extend({_class:"Gradient",initialize:function(e,t){this._id=g.get(),e&&a.isPlainObject(e)&&(this.set(e),e=t=null),null==this._stops&&this.setStops(e||["white","black"]),null==this._radial&&this.setRadial("string"==typeof t&&"radial"===t||t||!1)},_serialize:function(e,t){return t.add(this,function(){return a.serialize([this._stops,this._radial],e,!0,t)})},_changed:function(){for(var e=0,t=this._owners&&this._owners.length;e<t;e++)this._owners[e]._changed()},_addOwner:function(e){this._owners||(this._owners=[]),this._owners.push(e)},_removeOwner:function(e){var i=this._owners?this._owners.indexOf(e):-1;-1!=i&&(this._owners.splice(i,1),this._owners.length||(this._owners=t))},clone:function(){for(var e=[],t=0,i=this._stops.length;t<i;t++)e[t]=this._stops[t].clone();return new W(e,this._radial)},getStops:function(){return this._stops},setStops:function(e){if(e.length<2)throw new Error("Gradient stop list needs to contain at least two stops.");var i=this._stops;if(i)for(var n=0,a=i.length;n<a;n++)i[n]._owner=t;for(n=0,a=(i=this._stops=Z.readList(e,0,{clone:!0})).length;n<a;n++)i[n]._owner=this;this._changed()},getRadial:function(){return this._radial},setRadial:function(e){this._radial=e,this._changed()},equals:function(e){if(e===this)return!0;if(e&&this._class===e._class){var t=this._stops,i=e._stops,n=t.length;if(n===i.length){for(var a=0;a<n;a++)if(!t[a].equals(i[a]))return!1;return!0}}return!1}}),Z=a.extend({_class:"GradientStop",initialize:function(e,i){var n=e,a=i;"object"==typeof e&&i===t&&(Array.isArray(e)&&"number"!=typeof e[0]?(n=e[0],a=e[1]):("color"in e||"offset"in e||"rampPoint"in e)&&(n=e.color,a=e.offset||e.rampPoint||0)),this.setColor(n),this.setOffset(a)},clone:function(){return new Z(this._color.clone(),this._offset)},_serialize:function(e,t){var i=this._color,n=this._offset;return a.serialize(null==n?[i]:[i,n],e,!0,t)},_changed:function(){this._owner&&this._owner._changed(129)},getOffset:function(){return this._offset},setOffset:function(e){this._offset=e,this._changed()},getRampPoint:"#getOffset",setRampPoint:"#setOffset",getColor:function(){return this._color},setColor:function(){N._setOwner(this._color,null),this._color=N._setOwner(N.read(arguments,0),this,"setColor"),this._changed()},equals:function(e){return e===this||e&&this._class===e._class&&this._color.equals(e._color)&&this._offset==e._offset||!1}}),H=a.extend(new function(){var e={fillColor:null,fillRule:"nonzero",strokeColor:null,strokeWidth:1,strokeCap:"butt",strokeJoin:"miter",strokeScaling:!0,miterLimit:10,dashOffset:0,dashArray:[],shadowColor:null,shadowBlur:0,shadowOffset:new f,selectedColor:null},i=a.set({},e,{fontFamily:"sans-serif",fontWeight:"normal",fontSize:12,leading:null,justification:"left"}),n=a.set({},i,{fillColor:new N}),r={strokeWidth:193,strokeCap:193,strokeJoin:193,strokeScaling:201,miterLimit:193,fontFamily:9,fontWeight:9,fontSize:9,font:9,leading:9,justification:9},o={beans:!0},s={_class:"Style",beans:!0,initialize:function(t,a,r){this._values={},this._owner=a,this._project=a&&a._project||r||le.project,this._defaults=!a||a instanceof b?i:a instanceof U?n:e,t&&this.set(t)}};return a.each(i,function(e,i){var n=/Color$/.test(i),l="shadowOffset"===i,h=a.capitalize(i),d=r[i],c="set"+h,u="get"+h;s[c]=function(e){var t=this._owner,a=t&&t._children,r=a&&a.length>0&&!(t instanceof F);if(r)for(var o=0,s=a.length;o<s;o++)a[o]._style[c](e);if(("selectedColor"===i||!r)&&i in this._defaults){var l=this._values[i];l!==e&&(n&&(l&&(N._setOwner(l,null),l._canvasStyle=null),e&&e.constructor===N&&(e=N._setOwner(e,t,r&&c))),this._values[i]=e,t&&t._changed(d||129))}},s[u]=function(e){var r=this._owner,o=r&&r._children,s=o&&o.length>0&&!(r instanceof F);if(s&&!e)for(var h=0,d=o.length;h<d;h++){var g=o[h]._style[u]();if(h){if(!a.equals(p,g))return t}else p=g}else if(i in this._defaults){var p;if((p=this._values[i])===t)(p=this._defaults[i])&&p.clone&&(p=p.clone());else{var m=n?N:l?f:null;m&&(!p||p.constructor!==m)&&(this._values[i]=p=m.read([p],0,{readNull:!0,clone:!0}))}}return p&&n&&(p=N._setOwner(p,r,s&&c)),p},o[u]=function(e){return this._style[u](e)},o[c]=function(e){this._style[c](e)}}),a.each({Font:"FontFamily",WindingRule:"FillRule"},function(e,t){var i="get"+t,n="set"+t;s[i]=o[i]="#get"+e,s[n]=o[n]="#set"+e}),S.inject(o),s},{set:function(e){var t=e instanceof H,i=t?e._values:e;if(i)for(var n in i)if(n in this._defaults){var a=i[n];this[n]=a&&t&&a.clone?a.clone():a}},equals:function(e){function i(e,i,n){var r=e._values,o=i._values,s=i._defaults;for(var l in r){var h=r[l],d=o[l];if(!(n&&l in o||a.equals(h,d===t?s[l]:d)))return!1}return!0}return e===this||e&&this._class===e._class&&i(this,e)&&i(e,this,!0)||!1},_dispose:function(){var e;(e=this.getFillColor())&&(e._canvasStyle=null),(e=this.getStrokeColor())&&(e._canvasStyle=null),(e=this.getShadowColor())&&(e._canvasStyle=null)},hasFill:function(){var e=this.getFillColor();return!!e&&e.alpha>0},hasStroke:function(){var e=this.getStrokeColor();return!!e&&e.alpha>0&&this.getStrokeWidth()>0},hasShadow:function(){var e=this.getShadowColor();return!!e&&e.alpha>0&&(this.getShadowBlur()>0||!this.getShadowOffset().isZero())},getView:function(){return this._project._view},getFontStyle:function(){var e=this.getFontSize();return this.getFontWeight()+" "+e+(/[a-z]/i.test(e+"")?" ":"px ")+this.getFontFamily()},getFont:"#getFontFamily",setFont:"#setFontFamily",getLeading:function e(){var t=e.base.call(this),i=this.getFontSize();return/pt|em|%|px/.test(i)&&(i=this.getView().getPixelSize(i)),null!=t?t:1.2*i}}),V=new function(){function e(e,t,i,n){for(var a=["","webkit","moz","Moz","ms","o"],r=t[0].toUpperCase()+t.substring(1),o=0;o<6;o++){var s=a[o],l=s?s+r:t;if(l in e){if(!i)return e[l];e[l]=n;break}}}return{getStyles:function(e){var t=e&&9!==e.nodeType?e.ownerDocument:e,i=t&&t.defaultView;return i&&i.getComputedStyle(e,"")},getBounds:function(e,t){var i,n=e.ownerDocument,a=n.body,r=n.documentElement;try{i=e.getBoundingClientRect()}catch(e){i={left:0,top:0,width:0,height:0}}var o=i.left-(r.clientLeft||a.clientLeft||0),s=i.top-(r.clientTop||a.clientTop||0);if(!t){var l=n.defaultView;o+=l.pageXOffset||r.scrollLeft||a.scrollLeft,s+=l.pageYOffset||r.scrollTop||a.scrollTop}return new I(o,s,i.width,i.height)},getViewportBounds:function(e){var t=e.ownerDocument,i=t.defaultView,n=t.documentElement;return new I(0,0,i.innerWidth||n.clientWidth,i.innerHeight||n.clientHeight)},getOffset:function(e,t){return V.getBounds(e,t).getPoint()},getSize:function(e){return V.getBounds(e,!0).getSize()},isInvisible:function(e){return V.getSize(e).equals(new m(0,0))},isInView:function(e){return!V.isInvisible(e)&&V.getViewportBounds(e).intersects(V.getBounds(e,!0))},isInserted:function(e){return n.body.contains(e)},getPrefixed:function(t,i){return t&&e(t,i)},setPrefixed:function(t,i,n){if("object"==typeof i)for(var a in i)e(t,a,!0,i[a]);else e(t,i,!0,n)}}},q={add:function(e,t){if(e)for(var i in t)for(var a=t[i],r=i.split(/[\s,]+/g),o=0,s=r.length;o<s;o++){var l=r[o],h=e===n&&("touchstart"===l||"touchmove"===l)&&{passive:!1};e.addEventListener(l,a,h)}},remove:function(e,t){if(e)for(var i in t)for(var n=t[i],a=i.split(/[\s,]+/g),r=0,o=a.length;r<o;r++)e.removeEventListener(a[r],n,!1)},getPoint:function(e){var t=e.targetTouches?e.targetTouches.length?e.targetTouches[0]:e.changedTouches[0]:e;return new f(t.pageX||t.clientX+n.documentElement.scrollLeft,t.pageY||t.clientY+n.documentElement.scrollTop)},getTarget:function(e){return e.target||e.srcElement},getRelatedTarget:function(e){return e.relatedTarget||e.toElement},getOffset:function(e,t){return q.getPoint(e).subtract(V.getOffset(t||q.getTarget(e)))}};q.requestAnimationFrame=new function(){var e,t=V.getPrefixed(i,"requestAnimationFrame"),n=!1,a=[];function r(){var e=a;a=[];for(var i=0,o=e.length;i<o;i++)e[i]();(n=t&&a.length)&&t(r)}return function(i){a.push(i),t?n||(t(r),n=!0):e||(e=setInterval(r,1e3/60))}};var J=a.extend(s,{_class:"View",initialize:function e(t,a){function r(e){return a[e]||parseInt(a.getAttribute(e),10)}function o(){var e=V.getSize(a);return e.isNaN()||e.isZero()?new m(r("width"),r("height")):e}var s;if(i&&a){this._id=a.getAttribute("id"),null==this._id&&a.setAttribute("id",this._id="paper-view-"+e._id++),q.add(a,this._viewEvents);var h="none";if(V.setPrefixed(a.style,{userDrag:h,userSelect:h,touchCallout:h,contentZooming:h,tapHighlightColor:"rgba(0,0,0,0)"}),l.hasAttribute(a,"resize")){var d=this;q.add(i,this._windowEvents={resize:function(){d.setViewSize(o())}})}if(s=o(),l.hasAttribute(a,"stats")&&typeof Stats<"u"){this._stats=new Stats;var c=this._stats.domElement,u=c.style,g=V.getOffset(a);u.position="absolute",u.left=g.x+"px",u.top=g.y+"px",n.body.appendChild(c)}}else s=new m(a),a=null;this._project=t,this._scope=t._scope,this._element=a,this._pixelRatio||(this._pixelRatio=i&&i.devicePixelRatio||1),this._setElementSize(s.width,s.height),this._viewSize=s,e._views.push(this),e._viewsById[this._id]=this,(this._matrix=new C)._owner=this,e._focused||(e._focused=this),this._frameItems={},this._frameItemCount=0,this._itemEvents={native:{},virtual:{}},this._autoUpdate=!le.agent.node,this._needsUpdate=!1},remove:function(){if(!this._project)return!1;J._focused===this&&(J._focused=null),J._views.splice(J._views.indexOf(this),1),delete J._viewsById[this._id];var e=this._project;return e._view===this&&(e._view=null),q.remove(this._element,this._viewEvents),q.remove(i,this._windowEvents),this._element=this._project=null,this.off("frame"),this._animate=!1,this._frameItems={},!0},_events:a.each(S._itemHandlers.concat(["onResize","onKeyDown","onKeyUp"]),function(e){this[e]={}},{onFrame:{install:function(){this.play()},uninstall:function(){this.pause()}}}),_animate:!1,_time:0,_count:0,getAutoUpdate:function(){return this._autoUpdate},setAutoUpdate:function(e){this._autoUpdate=e,e&&this.requestUpdate()},update:function(){},draw:function(){this.update()},requestUpdate:function(){if(!this._requested){var e=this;q.requestAnimationFrame(function(){if(e._requested=!1,e._animate){e.requestUpdate();var t=e._element;(!V.getPrefixed(n,"hidden")||"true"===l.getAttribute(t,"keepalive"))&&V.isInView(t)&&e._handleFrame()}e._autoUpdate&&e.update()}),this._requested=!0}},play:function(){this._animate=!0,this.requestUpdate()},pause:function(){this._animate=!1},_handleFrame:function(){le=this._scope;var e=Date.now()/1e3,t=this._last?e-this._last:0;this._last=e,this.emit("frame",new a({delta:t,time:this._time+=t,count:this._count++})),this._stats&&this._stats.update()},_animateItem:function(e,t){var i=this._frameItems;t?(i[e._id]={item:e,time:0,count:0},1==++this._frameItemCount&&this.on("frame",this._handleFrameItems)):(delete i[e._id],0==--this._frameItemCount&&this.off("frame",this._handleFrameItems))},_handleFrameItems:function(e){for(var t in this._frameItems){var i=this._frameItems[t];i.item.emit("frame",new a(e,{time:i.time+=e.delta,count:i.count++}))}},_changed:function(){this._project._changed(4097),this._bounds=this._decomposed=t},getElement:function(){return this._element},getPixelRatio:function(){return this._pixelRatio},getResolution:function(){return 72*this._pixelRatio},getViewSize:function(){var e=this._viewSize;return new v(e.width,e.height,this,"setViewSize")},setViewSize:function(){var e=m.read(arguments),t=e.subtract(this._viewSize);t.isZero()||(this._setElementSize(e.width,e.height),this._viewSize.set(e),this._changed(),this.emit("resize",{size:e,delta:t}),this._autoUpdate&&this.update())},_setElementSize:function(e,t){var i=this._element;i&&(i.width!==e&&(i.width=e),i.height!==t&&(i.height=t))},getBounds:function(){return this._bounds||(this._bounds=this._matrix.inverted()._transformBounds(new I(new f,this._viewSize))),this._bounds},getSize:function(){return this.getBounds().getSize()},isVisible:function(){return V.isInView(this._element)},isInserted:function(){return V.isInserted(this._element)},getPixelSize:function(e){var t,i=this._element;if(i){var a=i.parentNode,r=n.createElement("div");r.style.fontSize=e,a.appendChild(r),t=parseFloat(V.getStyles(r).fontSize),a.removeChild(r)}else t=parseFloat(t);return t},getTextWidth:function(e,t){return 0}},a.each(["rotate","scale","shear","skew"],function(e){var t="rotate"===e;this[e]=function(){var i=arguments,n=(t?a:f).read(i),r=f.read(i,0,{readNull:!0});return this.transform((new C)[e](n,r||this.getCenter(!0)))}},{_decompose:function(){return this._decomposed||(this._decomposed=this._matrix.decompose())},translate:function(){var e=new C;return this.transform(e.translate.apply(e,arguments))},getCenter:function(){return this.getBounds().getCenter()},setCenter:function(){var e=f.read(arguments);this.translate(this.getCenter().subtract(e))},getZoom:function(){var e=this._decompose().scaling;return(e.x+e.y)/2},setZoom:function(e){this.transform((new C).scale(e/this.getZoom(),this.getCenter()))},getRotation:function(){return this._decompose().rotation},setRotation:function(e){var t=this.getRotation();null!=t&&null!=e&&this.rotate(e-t)},getScaling:function(){var e=this._decompose().scaling;return new p(e.x,e.y,this,"setScaling")},setScaling:function(){var e=this.getScaling(),t=f.read(arguments,0,{clone:!0,readNull:!0});e&&t&&this.scale(t.x/e.x,t.y/e.y)},getMatrix:function(){return this._matrix},setMatrix:function(){var e=this._matrix;e.set.apply(e,arguments)},transform:function(e){this._matrix.append(e)},scrollBy:function(){this.translate(f.read(arguments).negate())}}),{projectToView:function(){return this._matrix._transformPoint(f.read(arguments))},viewToProject:function(){return this._matrix._inverseTransform(f.read(arguments))},getEventPoint:function(e){return this.viewToProject(q.getOffset(e,this._element))}},{statics:{_views:[],_viewsById:{},_id:0,create:function(e,t){return n&&"string"==typeof t&&(t=n.getElementById(t)),new(i?Q:J)(e,t)}}},new function(){if(i){var e,t,a,r,o,s=!1,l=!1,h=i.navigator;h.pointerEnabled||h.msPointerEnabled?(a="pointerdown MSPointerDown",r="pointermove MSPointerMove",o="pointerup pointercancel MSPointerUp MSPointerCancel"):(a="touchstart",r="touchmove",o="touchend touchcancel","ontouchstart"in i&&h.userAgent.match(/mobile|tablet|ip(ad|hone|od)|android|silk/i)||(a+=" mousedown",r+=" mousemove",o+=" mouseup"));var d={},c={mouseout:function(e){var t=J._focused,i=q.getRelatedTarget(e);if(t&&(!i||"HTML"===i.nodeName)){var n=q.getOffset(e,t._element),a=n.x,r=Math.abs,o=r(a),s=o-(1<<25);n.x=r(s)<o?s*(a<0?-1:1):a,P(t,e,t.viewToProject(n))}},scroll:A};d[a]=function(e){var t=J._focused=w(e);s||(s=!0,t._handleMouseEvent("mousedown",e))},c[r]=function(i){var n=J._focused;if(!l){var a=w(i);a?n!==a&&(n&&P(n,i),e||(e=n),n=J._focused=t=a):t&&t===n&&(e&&!e.isInserted()&&(e=null),n=J._focused=e,e=null,A())}n&&P(n,i)},c[a]=function(){l=!0},c[o]=function(e){var t=J._focused;t&&s&&t._handleMouseEvent("mouseup",e),l=s=!1},q.add(n,c),q.add(i,{load:A});var u,g,f,p,m,v,I,y,C=!1,M=!1,x={doubleclick:"click",mousedrag:"mousemove"},S=!1,b={mousedown:{mousedown:1,mousedrag:1,click:1,doubleclick:1},mouseup:{mouseup:1,mousedrag:1,click:1,doubleclick:1},mousemove:{mousedrag:1,mousemove:1,mouseenter:1,mouseleave:1}};return{_viewEvents:d,_handleMouseEvent:function(e,t,i){var n=this._itemEvents,a=n.native[e],r="mousemove"===e,o=this._scope.tool,l=this;function h(e){return n.virtual[e]||l.responds(e)||o&&o.responds(e)}r&&s&&h("mousedrag")&&(e="mousedrag"),i||(i=this.getEventPoint(t));var d=this.getBounds().contains(i),c=a&&d&&l._project.hitTest(i,{tolerance:0,fill:!0,stroke:!0}),x=c&&c.item||null,b=!1,w={};if(w[e.substr(5)]=!0,a&&x!==p&&(p&&D(p,null,"mouseleave",t,i),x&&D(x,null,"mouseenter",t,i),p=x),S^d&&(D(this,null,d?"mouseenter":"mouseleave",t,i),b=!0),(d||w.drag)&&!i.equals(g)&&(k(this,x,r?e:"mousemove",t,i,g),b=!0),S=d,w.down&&d||w.up&&u){if(k(this,x,e,t,i,u),w.down){if(y=x===v&&Date.now()-I<300,f=v=x,!M&&x){for(var A=x;A&&!A.responds("mousedrag");)A=A._parent;A&&(m=x)}u=i}else w.up&&(!M&&x===f&&(I=Date.now(),k(this,x,y?"doubleclick":"click",t,i,u),y=!1),f=m=null);S=!1,b=!0}g=i,b&&o&&(C=o._handleMouseEvent(e,t,i,w)||C),!1!==t.cancelable&&(C&&!w.move||w.down&&h("mouseup"))&&t.preventDefault()},_handleKeyEvent:function(e,t,i,n){var a,r=this._scope,o=r.tool;function s(o){o.responds(e)&&(le=r,o.emit(e,a=a||new Y(e,t,i,n)))}this.isVisible()&&(s(this),o&&o.responds(e)&&s(o))},_countItemEvent:function(e,t){var i=this._itemEvents,n=i.native,a=i.virtual;for(var r in b)n[r]=(n[r]||0)+(b[r][e]||0)*t;a[e]=(a[e]||0)+t},statics:{updateFocus:A,_resetState:function(){s=l=C=S=!1,e=t=u=g=f=p=m=v=I=y=null}}}}function w(e){var t=q.getTarget(e);return t.getAttribute&&J._viewsById[t.getAttribute("id")]}function A(){var e=J._focused;if(!e||!e.isVisible())for(var i=0,n=J._views.length;i<n;i++)if((e=J._views[i]).isVisible()){J._focused=t=e;break}}function P(e,t,i){e._handleMouseEvent("mousemove",t,i)}function D(e,t,i,n,a,r,o){var s,l=!1;function h(e,i){if(e.responds(i)){if(s||(s=new $(i,n,a,t||e,r?a.subtract(r):null)),e.emit(i,s)&&(C=!0,s.prevented&&(M=!0),s.stopped))return l=!0}else{var o=x[i];if(o)return h(e,o)}}for(;e&&e!==o&&!h(e,i);)e=e._parent;return l}function k(e,t,i,n,a,r){return e._project.removeOn(i),M=C=!1,m&&D(m,null,i,n,a,r)||t&&t!==m&&!t.isDescendant(m)&&D(t,null,"mousedrag"===i?"mousemove":i,n,a,r,m)||D(e,m||t||e,i,n,a,r)}}),Q=J.extend({_class:"CanvasView",initialize:function(e,t){if(!(t instanceof i.HTMLCanvasElement)){var n=m.read(arguments,1);if(n.isZero())throw new Error("Cannot create CanvasView with the provided argument: "+a.slice(arguments,1));t=ae.getCanvas(n)}var r=this._context=t.getContext("2d");if(r.save(),this._pixelRatio=1,!/^off|false$/.test(l.getAttribute(t,"hidpi"))){var o=i.devicePixelRatio||1,s=V.getPrefixed(r,"backingStorePixelRatio")||1;this._pixelRatio=o/s}J.call(this,e,t),this._needsUpdate=!0},remove:function e(){return this._context.restore(),e.base.call(this)},_setElementSize:function e(t,i){var n=this._pixelRatio;if(e.base.call(this,t*n,i*n),1!==n){var a=this._element,r=this._context;if(!l.hasAttribute(a,"resize")){var o=a.style;o.width=t+"px",o.height=i+"px"}r.restore(),r.save(),r.scale(n,n)}},getContext:function(){return this._context},getPixelSize:function e(t){var i,n=le.agent;if(n&&n.firefox)i=e.base.call(this,t);else{var a=this._context,r=a.font;a.font=t+" serif",i=parseFloat(a.font),a.font=r}return i},getTextWidth:function(e,t){var i=this._context,n=i.font,a=0;i.font=e;for(var r=0,o=t.length;r<o;r++)a=Math.max(a,i.measureText(t[r]).width);return i.font=n,a},update:function(){if(!this._needsUpdate)return!1;var e=this._project,t=this._context,i=this._viewSize;return t.clearRect(0,0,i.width+1,i.height+1),e&&e.draw(t,this._matrix,this._pixelRatio),this._needsUpdate=!1,!0}}),K=a.extend({_class:"Event",initialize:function(e){this.event=e,this.type=e&&e.type},prevented:!1,stopped:!1,preventDefault:function(){this.prevented=!0,this.event.preventDefault()},stopPropagation:function(){this.stopped=!0,this.event.stopPropagation()},stop:function(){this.stopPropagation(),this.preventDefault()},getTimeStamp:function(){return this.event.timeStamp},getModifiers:function(){return X.modifiers}}),Y=K.extend({_class:"KeyEvent",initialize:function(e,t,i,n){this.type=e,this.event=t,this.key=i,this.character=n},toString:function(){return"{ type: '"+this.type+"', key: '"+this.key+"', character: '"+this.character+"', modifiers: "+this.getModifiers()+" }"}}),X=new function(){var e,r,o={"\t":"tab"," ":"space","\b":"backspace","":"delete",Spacebar:"space",Del:"delete",Win:"meta",Esc:"escape"},s={tab:"\t",space:" ",enter:"\r"},l={},h={},d=new a({shift:!1,control:!1,alt:!1,meta:!1,capsLock:!1,space:!1}).inject({option:{get:function(){return this.alt}},command:{get:function(){var e=le&&le.agent;return e&&e.mac?this.meta:this.control}}});function c(e){var i=e.key||e.keyIdentifier;return i=/^U\+/.test(i)?String.fromCharCode(parseInt(i.substr(2),16)):/^Arrow[A-Z]/.test(i)?i.substr(5):"Unidentified"===i||i===t?String.fromCharCode(e.keyCode):i,o[i]||(i.length>1?a.hyphenate(i):i.toLowerCase())}function u(t,i,n,r){var o,s=J._focused;if(l[i]=t,t?h[i]=n:delete h[i],i.length>1&&(o=a.camelize(i))in d){d[o]=t;var c=le&&le.agent;if("meta"===o&&c&&c.mac)if(t)e={};else{for(var g in e)g in h&&u(!1,g,e[g],r);e=null}}else t&&e&&(e[i]=n);s&&s._handleKeyEvent(t?"keydown":"keyup",r,i,n)}return q.add(n,{keydown:function(e){var t=c(e),i=le&&le.agent;t.length>1||i&&i.chrome&&(e.altKey||i.mac&&e.metaKey||!i.mac&&e.ctrlKey)?u(!0,t,s[t]||(t.length>1?"":t),e):r=t},keypress:function(e){if(r){var t=c(e),i=e.charCode,n=i>=32?String.fromCharCode(i):t.length>1?"":t;t!==r&&(t=n.toLowerCase()),u(!0,t,n,e),r=null}},keyup:function(e){var t=c(e);t in h&&u(!1,t,h[t],e)}}),q.add(i,{blur:function(e){for(var t in h)u(!1,t,h[t],e)}}),{modifiers:d,isDown:function(e){return!!l[e]}}},$=K.extend({_class:"MouseEvent",initialize:function(e,t,i,n,a){this.type=e,this.event=t,this.point=i,this.target=n,this.delta=a},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),ee=K.extend({_class:"ToolEvent",_item:null,initialize:function(e,t,i){this.tool=e,this.type=t,this.event=i},_choosePoint:function(e,t){return e||(t?t.clone():null)},getPoint:function(){return this._choosePoint(this._point,this.tool._point)},setPoint:function(e){this._point=e},getLastPoint:function(){return this._choosePoint(this._lastPoint,this.tool._lastPoint)},setLastPoint:function(e){this._lastPoint=e},getDownPoint:function(){return this._choosePoint(this._downPoint,this.tool._downPoint)},setDownPoint:function(e){this._downPoint=e},getMiddlePoint:function(){return!this._middlePoint&&this.tool._lastPoint?this.tool._point.add(this.tool._lastPoint).divide(2):this._middlePoint},setMiddlePoint:function(e){this._middlePoint=e},getDelta:function(){return!this._delta&&this.tool._lastPoint?this.tool._point.subtract(this.tool._lastPoint):this._delta},setDelta:function(e){this._delta=e},getCount:function(){return this.tool[/^mouse(down|up)$/.test(this.type)?"_downCount":"_moveCount"]},setCount:function(e){this.tool[/^mouse(down|up)$/.test(this.type)?"downCount":"count"]=e},getItem:function(){if(!this._item){var e=this.tool._scope.project.hitTest(this.getPoint());if(e){for(var t=e.item,i=t._parent;/^(Group|CompoundPath)$/.test(i._class);)t=i,i=i._parent;this._item=t}}return this._item},setItem:function(e){this._item=e},toString:function(){return"{ type: "+this.type+", point: "+this.getPoint()+", count: "+this.getCount()+", modifiers: "+this.getModifiers()+" }"}}),te=h.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onActivate","onDeactivate","onEditOptions","onKeyDown","onKeyUp"],initialize:function(e){h.call(this),this._moveCount=-1,this._downCount=-1,this.set(e)},getMinDistance:function(){return this._minDistance},setMinDistance:function(e){this._minDistance=e,null!=e&&null!=this._maxDistance&&e>this._maxDistance&&(this._maxDistance=e)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(e){this._maxDistance=e,null!=this._minDistance&&null!=e&&e<this._minDistance&&(this._minDistance=e)},getFixedDistance:function(){return this._minDistance==this._maxDistance?this._minDistance:null},setFixedDistance:function(e){this._minDistance=this._maxDistance=e},_handleMouseEvent:function(e,t,i,n){le=this._scope,n.drag&&!this.responds(e)&&(e="mousemove");var a=n.move||n.drag,r=this.responds(e),o=this.minDistance,s=this.maxDistance,l=!1,h=this;function d(e,t){var r=i,o=a?h._point:h._downPoint||r;if(a){if(h._moveCount>=0&&r.equals(o))return!1;if(o&&(null!=e||null!=t)){var s=r.subtract(o),l=s.getLength();if(l<(e||0))return!1;t&&(r=o.add(s.normalize(Math.min(l,t))))}h._moveCount++}return h._point=r,h._lastPoint=o||r,n.down&&(h._moveCount=-1,h._downPoint=r,h._downCount++),!0}function c(){r&&(l=h.emit(e,new ee(h,e,t))||l)}if(n.down)d(),c();else if(n.up)d(null,s),c();else if(r)for(;d(o,s);)c();return l}}),ie=a.extend(s,{_class:"Tween",statics:{easings:new a({linear:function(e){return e},easeInQuad:function(e){return e*e},easeOutQuad:function(e){return e*(2-e)},easeInOutQuad:function(e){return e<.5?2*e*e:2*(2-e)*e-1},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return--e*e*e+1},easeInOutCubic:function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1- --e*e*e*e},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1+--e*e*e*e*e},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e}})},initialize:function e(t,i,n,a,r,o){this.object=t;var s=typeof r,l="function"===s;this.type=l?s:"string"===s?r:"linear",this.easing=l?r:e.easings[this.type],this.duration=a,this.running=!1,this._then=null,this._startTime=null;var h=i||n;this._keys=h?Object.keys(h):[],this._parsedKeys=this._parseKeys(this._keys),this._from=h&&this._getState(i),this._to=h&&this._getState(n),!1!==o&&this.start()},then:function(e){return this._then=e,this},start:function(){return this._startTime=null,this.running=!0,this},stop:function(){return this.running=!1,this},update:function(e){if(this.running){e>=1&&(e=1,this.running=!1);for(var t=this.easing(e),i=this._keys,n=function(i){return"function"==typeof i?i(t,e):i},r=0,o=i&&i.length;r<o;r++){var s=i[r],l=n(this._from[s]),h=n(this._to[s]),d=l&&h&&l.__add&&h.__add?h.__subtract(l).__multiply(t).__add(l):(h-l)*t+l;this._setProperty(this._parsedKeys[s],d)}this.responds("update")&&this.emit("update",new a({progress:e,factor:t})),!this.running&&this._then&&this._then(this.object)}return this},_events:{onUpdate:{}},_handleFrame:function(e){var t=this._startTime,i=t?(e-t)/this.duration:0;t||(this._startTime=e),this.update(i)},_getState:function(e){for(var t=this._keys,i={},n=0,a=t.length;n<a;n++){var r,o=t[n],s=this._parsedKeys[o],l=this._getProperty(s);if(e){var h=this._resolveValue(l,e[o]);this._setProperty(s,h),r=(r=this._getProperty(s))&&r.clone?r.clone():r,this._setProperty(s,l)}else r=l&&l.clone?l.clone():l;i[o]=r}return i},_resolveValue:function(e,t){if(t){if(Array.isArray(t)&&2===t.length){var i=t[0];return i&&i.match&&i.match(/^[+\-\*\/]=/)?this._calculate(e,i[0],t[1]):t}if("string"==typeof t){var n=t.match(/^[+\-*/]=(.*)/);if(n){var a=JSON.parse(n[1].replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g,'"$2": '));return this._calculate(e,t[0],a)}}}return t},_calculate:function(e,t,i){return le.PaperScript.calculateBinary(e,t,i)},_parseKeys:function(e){for(var t={},i=0,n=e.length;i<n;i++){var a=e[i],r=a.replace(/\.([^.]*)/g,"/$1").replace(/\[['"]?([^'"\]]*)['"]?\]/g,"/$1");t[a]=r.split("/")}return t},_getProperty:function(e,t){for(var i=this.object,n=0,a=e.length-(t||0);n<a&&i;n++)i=i[e[n]];return i},_setProperty:function(e,t){var i=this._getProperty(e,1);i&&(i[e[e.length-1]]=t)}}),ne={request:function(t){var i=new e.XMLHttpRequest;return i.open((t.method||"get").toUpperCase(),t.url,a.pick(t.async,!0)),t.mimeType&&i.overrideMimeType(t.mimeType),i.onload=function(){var e=i.status;0===e||200===e?t.onLoad&&t.onLoad.call(i,i.responseText):i.onerror()},i.onerror=function(){var e=i.status,n='Could not load "'+t.url+'" (Status: '+e+")";if(!t.onError)throw new Error(n);t.onError(n,e)},i.send(null)}},ae=a.exports.CanvasProvider={canvases:[],getCanvas:function(e,t,a){if(!i)return null;var r,o=!0;"object"==typeof e&&(t=e.height,e=e.width),this.canvases.length?r=this.canvases.pop():(r=n.createElement("canvas"),o=!1);var s=r.getContext("2d",a||{});if(!s)throw new Error("Canvas "+r+" is unable to provide a 2D context.");return r.width===e&&r.height===t?o&&s.clearRect(0,0,e+1,t+1):(r.width=e,r.height=t),s.save(),r},getContext:function(e,t,i){var n=this.getCanvas(e,t,i);return n?n.getContext("2d",i||{}):null},release:function(e){var t=e&&e.canvas?e.canvas:e;t&&t.getContext&&(t.getContext("2d").restore(),this.canvases.push(t))}},re=new function(){var e,t,i,n,r,o,s,l,h,d,c,u=Math.min,g=Math.max,f=Math.abs;function p(e,t,i){return.2989*e+.587*t+.114*i}function m(e,t,i,n){var a=n-p(e,t,i),r=(n=p(h=e+a,d=t+a,c=i+a),u(h,d,c)),o=g(h,d,c);if(r<0){var s=n-r;h=n+(h-n)*n/s,d=n+(d-n)*n/s,c=n+(c-n)*n/s}if(o>255){var l=255-n,f=o-n;h=n+(h-n)*l/f,d=n+(d-n)*l/f,c=n+(c-n)*l/f}}function v(e,t,i){return g(e,t,i)-u(e,t,i)}function I(e,t,i,n){var a,r=[e,t,i],o=g(e,t,i),s=u(e,t,i);a=0===u(s=s===e?0:s===t?1:2,o=o===e?0:o===t?1:2)?1===g(s,o)?2:1:0,r[o]>r[s]?(r[a]=(r[a]-r[s])*n/(r[o]-r[s]),r[o]=n):r[a]=r[o]=0,r[s]=0,h=r[0],d=r[1],c=r[2]}var y={multiply:function(){h=r*e/255,d=o*t/255,c=s*i/255},screen:function(){h=r+e-r*e/255,d=o+t-o*t/255,c=s+i-s*i/255},overlay:function(){h=r<128?2*r*e/255:255-2*(255-r)*(255-e)/255,d=o<128?2*o*t/255:255-2*(255-o)*(255-t)/255,c=s<128?2*s*i/255:255-2*(255-s)*(255-i)/255},"soft-light":function(){var n=e*r/255;h=n+r*(255-(255-r)*(255-e)/255-n)/255,d=(n=t*o/255)+o*(255-(255-o)*(255-t)/255-n)/255,c=(n=i*s/255)+s*(255-(255-s)*(255-i)/255-n)/255},"hard-light":function(){h=e<128?2*e*r/255:255-2*(255-e)*(255-r)/255,d=t<128?2*t*o/255:255-2*(255-t)*(255-o)/255,c=i<128?2*i*s/255:255-2*(255-i)*(255-s)/255},"color-dodge":function(){h=0===r?0:255===e?255:u(255,255*r/(255-e)),d=0===o?0:255===t?255:u(255,255*o/(255-t)),c=0===s?0:255===i?255:u(255,255*s/(255-i))},"color-burn":function(){h=255===r?255:0===e?0:g(0,255-255*(255-r)/e),d=255===o?255:0===t?0:g(0,255-255*(255-o)/t),c=255===s?255:0===i?0:g(0,255-255*(255-s)/i)},darken:function(){h=r<e?r:e,d=o<t?o:t,c=s<i?s:i},lighten:function(){h=r>e?r:e,d=o>t?o:t,c=s>i?s:i},difference:function(){(h=r-e)<0&&(h=-h),(d=o-t)<0&&(d=-d),(c=s-i)<0&&(c=-c)},exclusion:function(){h=r+e*(255-r-r)/255,d=o+t*(255-o-o)/255,c=s+i*(255-s-s)/255},hue:function(){I(e,t,i,v(r,o,s)),m(h,d,c,p(r,o,s))},saturation:function(){I(r,o,s,v(e,t,i)),m(h,d,c,p(r,o,s))},luminosity:function(){m(r,o,s,p(e,t,i))},color:function(){m(e,t,i,p(r,o,s))},add:function(){h=u(r+e,255),d=u(o+t,255),c=u(s+i,255)},subtract:function(){h=g(r-e,0),d=g(o-t,0),c=g(s-i,0)},average:function(){h=(r+e)/2,d=(o+t)/2,c=(s+i)/2},negation:function(){h=255-f(255-e-r),d=255-f(255-t-o),c=255-f(255-i-s)}},C=this.nativeModes=a.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],function(e){this[e]=!0},{}),M=ae.getContext(1,1,{willReadFrequently:!0});M&&(a.each(y,function(e,t){var i="darken"===t,n=!1;M.save();try{M.fillStyle=i?"#300":"#a00",M.fillRect(0,0,1,1),M.globalCompositeOperation=t,M.globalCompositeOperation===t&&(M.fillStyle=i?"#a00":"#300",M.fillRect(0,0,1,1),n=M.getImageData(0,0,1,1).data[0]!==i?170:51)}catch(e){}M.restore(),C[t]=n}),ae.release(M)),this.process=function(a,u,g,f,p){var m=u.canvas,v="normal"===a;if(v||C[a])g.save(),g.setTransform(1,0,0,1,0,0),g.globalAlpha=f,v||(g.globalCompositeOperation=a),g.drawImage(m,p.x,p.y),g.restore();else{var I=y[a];if(!I)return;for(var M=g.getImageData(p.x,p.y,m.width,m.height),x=M.data,S=u.getImageData(0,0,m.width,m.height).data,b=0,w=x.length;b<w;b+=4){e=S[b],r=x[b],t=S[b+1],o=x[b+1],i=S[b+2],s=x[b+2],n=S[b+3],l=x[b+3],I();var A=n*f/255,P=1-A;x[b]=A*h+P*r,x[b+1]=A*d+P*o,x[b+2]=A*c+P*s,x[b+3]=n*f+P*l}g.putImageData(M,p.x,p.y)}}},oe=new function(){var e="http://www.w3.org/2000/svg",t="http://www.w3.org/2000/xmlns",i="http://www.w3.org/1999/xlink",a={href:i,xlink:t,xmlns:t+"/","xmlns:xlink":t+"/"};function r(e,t,i){for(var n in t){var r=t[n],o=a[n];"number"==typeof r&&i&&(r=i.number(r)),o?e.setAttributeNS(o,n,r):e.setAttribute(n,r)}return e}return{svg:e,xmlns:t,xlink:i,create:function(t,i,a){return r(n.createElementNS(e,t),i,a)},get:function(e,t){var i=a[t],n=i?e.getAttributeNS(i,t):e.getAttribute(t);return"null"===n?null:n},set:r}},se=a.each({fillColor:["fill","color"],fillRule:["fill-rule","string"],strokeColor:["stroke","color"],strokeWidth:["stroke-width","number"],strokeCap:["stroke-linecap","string"],strokeJoin:["stroke-linejoin","string"],strokeScaling:["vector-effect","lookup",{true:"none",false:"non-scaling-stroke"},function(e,t){return!t&&(e instanceof E||e instanceof A||e instanceof U)}],miterLimit:["stroke-miterlimit","number"],dashArray:["stroke-dasharray","array"],dashOffset:["stroke-dashoffset","number"],fontFamily:["font-family","string"],fontWeight:["font-weight","string"],fontSize:["font-size","number"],justification:["text-anchor","lookup",{left:"start",center:"middle",right:"end"}],opacity:["opacity","number"],blendMode:["mix-blend-mode","style"]},function(e,t){var i=a.capitalize(t),n=e[2];this[t]={type:e[1],property:t,attribute:e[0],toSVG:n,fromSVG:n&&a.each(n,function(e,t){this[e]=t},{}),exportFilter:e[3],get:"get"+i,set:"set"+i}},{});new function(){var t;function i(e,i,n){var r,o=new a,s=e.getTranslation();if(i&&(e.isInvertible()?(r=(e=e._shiftless())._inverseTransform(s),s=null):r=new f,o[n?"cx":"x"]=r.x,o[n?"cy":"y"]=r.y),!e.isIdentity()){var l=e.decompose();if(l){var h=[],d=l.rotation,c=l.scaling,g=l.skewing;s&&!s.isZero()&&h.push("translate("+t.point(s)+")"),d&&h.push("rotate("+t.number(d)+")"),(!u.isZero(c.x-1)||!u.isZero(c.y-1))&&h.push("scale("+t.point(c)+")"),g.x&&h.push("skewX("+t.number(g.x)+")"),g.y&&h.push("skewY("+t.number(g.y)+")"),o.transform=h.join(" ")}else o.transform="matrix("+e.getValues().join(",")+")"}return o}function n(e,n){for(var a=i(e._matrix),r=e._children,o=oe.create("g",a,t),s=0,l=r.length;s<l;s++){var h=r[s],c=m(h,n);if(c)if(h.isClipMask()){var u=oe.create("clipPath");u.appendChild(c),d(h,u,"clip"),oe.set(o,{"clip-path":"url(#"+u.id+")"})}else o.appendChild(c)}return o}function r(e){var n=e._type,a=e._radius,r=i(e._matrix,!0,"rectangle"!==n);if("rectangle"===n){n="rect";var o=e._size,s=o.width,l=o.height;r.x-=s/2,r.y-=l/2,r.width=s,r.height=l,a.isZero()&&(a=null)}return a&&("circle"===n?r.r=a:(r.rx=a.width,r.ry=a.height)),oe.create(n,r,t)}var o,s={Group:n,Layer:n,Raster:function(e,n){var a=i(e._matrix,!0),r=e.getSize(),o=e.getImage();return a.x-=r.width/2,a.y-=r.height/2,a.width=r.width,a.height=r.height,a.href=0==n.embedImages&&o&&o.src||e.toDataURL(),oe.create("image",a,t)},Path:function(e,n){var a=n.matchShapes;if(a){var o=e.toShape(!1);if(o)return r(o)}var s,l=e._segments,h=l.length,d=i(e._matrix);if(a&&h>=2&&!e.hasHandles())if(h>2){s=e._closed?"polygon":"polyline";for(var c=[],u=0;u<h;u++)c.push(t.point(l[u]._point));d.points=c.join(" ")}else{s="line";var g=l[0]._point,f=l[1]._point;d.set({x1:g.x,y1:g.y,x2:f.x,y2:f.y})}else s="path",d.d=e.getPathData(null,n.precision);return oe.create(s,d,t)},Shape:r,CompoundPath:function(e,n){var a=i(e._matrix),r=e.getPathData(null,n.precision);return r&&(a.d=r),oe.create("path",a,t)},SymbolItem:function(e,n){var a=i(e._matrix,!0),r=e._definition,o=h(r,"symbol"),s=r._item,l=s.getStrokeBounds();return o||((o=oe.create("symbol",{viewBox:t.rectangle(l)})).appendChild(m(s,n)),d(r,o,"symbol")),a.href="#"+o.id,a.x+=l.x,a.y+=l.y,a.width=l.width,a.height=l.height,a.overflow="visible",oe.create("use",a,t)},PointText:function(e){var n=oe.create("text",i(e._matrix,!0),t);return n.textContent=e._content,n}};function l(e,i,n){var r={},o=!n&&e.getParent(),s=[];return null!=e._name&&(r.id=e._name),a.each(se,function(i){var n=i.get,l=i.type,c=e[n]();if(i.exportFilter?i.exportFilter(e,c):!o||!a.equals(o[n](),c)){if("color"===l&&null!=c){var u=c.getAlpha();u<1&&(r[i.attribute+"-opacity"]=u)}"style"===l?s.push(i.attribute+": "+c):r[i.attribute]=null==c?"none":"color"===l?c.gradient?function(e){var i=h(e,"color");if(!i){var n,a=e.getGradient(),r=a._radial,o=e.getOrigin(),s=e.getDestination();if(r){n={cx:o.x,cy:o.y,r:o.getDistance(s)};var l=e.getHighlight();l&&(n.fx=l.x,n.fy=l.y)}else n={x1:o.x,y1:o.y,x2:s.x,y2:s.y};n.gradientUnits="userSpaceOnUse",i=oe.create((r?"radial":"linear")+"Gradient",n,t);for(var c=a._stops,u=0,g=c.length;u<g;u++){var f,p=c[u],m=p._color,v=m.getAlpha();n={offset:null!==(f=p._offset)&&void 0!==f?f:u/(g-1)},m&&(n["stop-color"]=m.toCSS(!0)),v<1&&(n["stop-opacity"]=v),i.appendChild(oe.create("stop",n,t))}d(e,i,"color")}return"url(#"+i.id+")"}(c):c.toCSS(!0):"array"===l?c.join(","):"lookup"===l?i.toSVG[c]:c}}),s.length&&(r.style=s.join(";")),1===r.opacity&&delete r.opacity,e._visible||(r.visibility="hidden"),oe.set(i,r,t)}function h(e,t){return o||(o={ids:{},svgs:{}}),e&&o.svgs[t+"-"+(e._id||e.__id||(e.__id=g.get("svg")))]}function d(e,t,i){o||h();var n=o.ids[i]=(o.ids[i]||0)+1;t.id=i+"-"+n,o.svgs[i+"-"+(e._id||e.__id)]=t}function p(t,i){var n=t,a=null;if(o){for(var r in n="svg"===t.nodeName.toLowerCase()&&t,o.svgs)a||(n||(n=oe.create("svg")).appendChild(t),a=n.insertBefore(oe.create("defs"),n.firstChild)),a.appendChild(o.svgs[r]);o=null}return i.asString?(new e.XMLSerializer).serializeToString(n):n}function m(e,t,i){var n=s[e._class],a=n&&n(e,t);if(a){var r=t.onExport;r&&(a=r(e,a,t)||a);var o=JSON.stringify(e._data);o&&"{}"!==o&&"null"!==o&&a.setAttribute("data-paper-data",o)}return a&&l(e,a,i)}function v(e){return e||(e={}),t=new c(e.precision),e}S.inject({exportSVG:function(e){return p(m(this,e=v(e),!0),e)}}),x.inject({exportSVG:function(e){e=v(e);var n=this._children,r=this.getView(),o=a.pick(e.bounds,"view"),s=e.matrix||"view"===o&&r._matrix,l=s&&C.read([s]),h="view"===o?new I([0,0],r.getViewSize()):"content"===o?S._getBounds(n,l,{stroke:!0}).rect:I.read([o],0,{readNull:!0}),d={version:"1.1",xmlns:oe.svg,"xmlns:xlink":oe.xlink};h&&(d.width=h.width,d.height=h.height,(h.x||0===h.x||h.y||0===h.y)&&(d.viewBox=t.rectangle(h)));var c=oe.create("svg",d,t),u=c;l&&!l.isIdentity()&&(u=c.appendChild(oe.create("g",i(l),t)));for(var g=0,f=n.length;g<f;g++)u.appendChild(m(n[g],e,!0));return p(c,e)}})},new function(){var r,o={};function s(e,t,i,n,a,o){var s=oe.get(e,t)||o,l=null==s?n?null:i?"":0:i?s:parseFloat(s);return/%\s*$/.test(s)?l/100*(a?1:r[/x|^width/.test(t)?"width":"height"]):l}function l(e,t,i,n,a,r,o){return t=s(e,t||"x",!1,n,a,r),i=s(e,i||"y",!1,n,a,o),!n||null!=t&&null!=i?new f(t,i):null}function h(e,t,i,n,a){return t=s(e,t||"width",!1,n,a),i=s(e,i||"height",!1,n,a),!n||null!=t&&null!=i?new m(t,i):null}function d(e,t,i){return"none"===e?null:"number"===t?parseFloat(e):"array"===t?e?e.split(/[\s,]+/g).map(parseFloat):[]:"color"===t?_(e)||e:"lookup"===t?i[e]:e}function c(e,t,i,n){var a=e.childNodes,r="clippath"===t,o="defs"===t,s=new b,l=s._project,h=l._currentStyle,d=[];if(!r&&!o&&(s=D(s,e,n),l._currentStyle=s._style.clone()),n)for(var c=e.querySelectorAll("defs"),u=0,g=c.length;u<g;u++)T(c[u],i,!1);for(u=0,g=a.length;u<g;u++){var f,p=a[u];1===p.nodeType&&!/^defs$/i.test(p.nodeName)&&(f=T(p,i,!1))&&!(f instanceof k)&&d.push(f)}return s.addChildren(d),r&&(s=D(s.reduce(),e,n)),l._currentStyle=h,(r||o)&&(s.remove(),s=null),s}function u(e,t){for(var i=e.getAttribute("points").match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g),n=[],a=0,r=i.length;a<r;a+=2)n.push(new f(parseFloat(i[a]),parseFloat(i[a+1])));var o=new R(n);return"polygon"===t&&o.closePath(),o}function g(e,t){var i,n=(s(e,"href",!0)||"").substring(1),a="radialgradient"===t;if(n)(i=o[n].getGradient())._radial^a&&((i=i.clone())._radial=a);else{for(var r=e.childNodes,h=[],d=0,c=r.length;d<c;d++){var u=r[d];1===u.nodeType&&h.push(D(new Z,u))}i=new W(h,a)}var g,f,p,m="userSpaceOnUse"!==s(e,"gradientUnits",!0);return a?(f=(g=l(e,"cx","cy",!1,m,"50%","50%")).add(s(e,"r",!1,!1,m,"50%"),0),p=l(e,"fx","fy",!0,m)):(g=l(e,"x1","y1",!1,m,"0%","0%"),f=l(e,"x2","y2",!1,m,"100%","0%")),D(new N(i,g,f,p),e)._scaleToBounds=m,null}var p={"#document":function(e,t,i,n){for(var a=e.childNodes,r=0,o=a.length;r<o;r++){var s=a[r];if(1===s.nodeType)return T(s,i,n)}},g:c,svg:c,clippath:c,polygon:u,polyline:u,path:function(e){return E.create(e.getAttribute("d"))},lineargradient:g,radialgradient:g,image:function(e){var t=new P(s(e,"href",!0));return t.on("load",function(){var t=h(e);this.setSize(t);var i=l(e).add(t.divide(2));this._matrix.append((new C).translate(i))}),t},symbol:function(e,t,i,n){return new k(c(e,t,i,n),!0)},defs:c,use:function(e){var t=(s(e,"href",!0)||"").substring(1),i=o[t],n=l(e);return i?i instanceof k?i.place(n):i.clone().translate(n):null},circle:function(e){return new A.Circle(l(e,"cx","cy"),s(e,"r"))},ellipse:function(e){return new A.Ellipse({center:l(e,"cx","cy"),radius:h(e,"rx","ry")})},rect:function(e){return new A.Rectangle(new I(l(e),h(e)),h(e,"rx","ry"))},line:function(e){return new R.Line(l(e,"x1","y1"),l(e,"x2","y2"))},text:function(e){var t=new j(l(e).add(l(e,"dx","dy")));return t.setContent(e.textContent.trim()||""),t},switch:c};function v(e,t,i,n){if(e.transform){for(var a=(n.getAttribute(i)||"").split(/\)\s*/g),r=new C,o=0,s=a.length;o<s;o++){var l=a[o];if(!l)break;for(var h=l.split(/\(\s*/),d=h[0],c=h[1].split(/[\s,]+/g),u=0,g=c.length;u<g;u++)c[u]=parseFloat(c[u]);switch(d){case"matrix":r.append(new C(c[0],c[1],c[2],c[3],c[4],c[5]));break;case"rotate":r.rotate(c[0],c[1]||0,c[2]||0);break;case"translate":r.translate(c[0],c[1]||0);break;case"scale":r.scale(c);break;case"skewX":r.skew(c[0],0);break;case"skewY":r.skew(0,c[0])}}e.transform(r)}}function y(e,t,i){var n="fill-opacity"===i?"getFillColor":"getStrokeColor",a=e[n]&&e[n]();a&&a.setAlpha(parseFloat(t))}var M=a.set(a.each(se,function(e){this[e.attribute]=function(t,i){if(t[e.set]&&(t[e.set](d(i,e.type,e.fromSVG)),"color"===e.type)){var n=t[e.get]();if(n&&n._scaleToBounds){var a=t.getBounds();n.transform((new C).translate(a.getPoint()).scale(a.getSize()))}}}},{}),{id:function(e,t){o[t]=e,e.setName&&e.setName(t)},"clip-path":function(e,t){var i=_(t);if(i){if((i=i.clone()).setClipMask(!0),!(e instanceof b))return new b(i,e);e.insertChild(0,i)}},gradientTransform:v,transform:v,"fill-opacity":y,"stroke-opacity":y,visibility:function(e,t){e.setVisible&&e.setVisible("visible"===t)},display:function(e,t){e.setVisible&&e.setVisible(null!==t)},"stop-color":function(e,t){e.setColor&&e.setColor(t)},"stop-opacity":function(e,t){e._color&&e._color.setAlpha(parseFloat(t))},offset:function(e,t){if(e.setOffset){var i=t.match(/(.*)%$/);e.setOffset(i?i[1]/100:parseFloat(t))}},viewBox:function(e,t,i,n,a){var r,o=new I(d(t,"array")),s=h(n,null,null,!0);if(e instanceof b){var l=s?s.divide(o.getSize()):1,c=(new C).scale(l).translate(o.getPoint().negate());r=e}else e instanceof k&&(s&&o.setSize(s),r=e._item);if(r){if("visible"!==w(n,"overflow",a)){var u=new A.Rectangle(o);u.setClipMask(!0),r.addChild(u)}c&&r.transform(c)}}});function w(e,i,n){var r=e.attributes[i],o=r&&r.value;if(!o&&e.style){var s=a.camelize(i);!(o=e.style[s])&&n.node[s]!==n.parent[s]&&(o=n.node[s])}return o?"none"===o?null:o:t}function D(e,i,n){var r=i.parentNode,o={node:V.getStyles(i)||{},parent:!n&&!/^defs$/i.test(r.tagName)&&V.getStyles(r)||{}};return a.each(M,function(n,a){var r=w(i,a,o);e=r!==t&&n(e,r,a,i,o)||e}),e}function _(e){var t=e&&e.match(/\((?:["'#]*)([^"')]+)/),n=t&&t[1],a=n&&o[i?n.replace(i.location.href.split("#")[0]+"#",""):n];return a&&a._scaleToBounds&&((a=a.clone())._scaleToBounds=!0),a}function T(e,t,i){var s,l,d,c=e.nodeName.toLowerCase(),u="#document"!==c,g=n.body;i&&u&&(r=le.getView().getSize(),r=h(e,null,null,!0)||r,s=oe.create("svg",{style:"stroke-width: 1px; stroke-miterlimit: 10"}),l=e.parentNode,d=e.nextSibling,s.appendChild(e),g.appendChild(s));var f=le.settings,m=f.applyMatrix,v=f.insertItems;f.applyMatrix=!1,f.insertItems=!1;var I=p[c],y=I&&I(e,c,t,i)||null;if(f.insertItems=v,f.applyMatrix=m,y){u&&!(y instanceof b)&&(y=D(y,e,i));var C=t.onImport,M=u&&e.getAttribute("data-paper-data");C&&(y=C(e,y,t)||y),t.expandShapes&&y instanceof A&&(y.remove(),y=y.toPath()),M&&(y._data=JSON.parse(M))}return s&&(g.removeChild(s),l&&(d?l.insertBefore(e,d):l.appendChild(e))),i&&(o={},y&&a.pick(t.applyMatrix,m)&&y.matrix.apply(!0,!0)),y}function z(i,a,r){if(!i)return null;a="function"==typeof a?{onLoad:a}:a||{};var o=le,s=null;function l(n){try{var l="object"==typeof n?n:(new e.DOMParser).parseFromString(n.trim(),"image/svg+xml");if(!l.nodeName)throw l=null,new Error("Unsupported SVG source: "+i);le=o,s=T(l,a,!0),(!a||!1!==a.insert)&&r._insertItem(t,s);var d=a.onLoad;d&&d(s,n)}catch(e){h(e)}}function h(e,t){var i=a.onError;if(!i)throw new Error(e);i(e,t)}if("string"!=typeof i||/^[\s\S]*</.test(i)){if(typeof File<"u"&&i instanceof File){var d=new FileReader;return d.onload=function(){l(d.result)},d.onerror=function(){h(d.error)},d.readAsText(i)}l(i)}else{var c=n.getElementById(i);c?l(c):ne.request({url:i,async:!0,onLoad:l,onError:h})}return s}S.inject({importSVG:function(e,t){return z(e,t,this)}}),x.inject({importSVG:function(e,t){return this.activate(),z(e,t,this)}})},a.exports.PaperScript=function(){var r,o,s,h,d=this,c=d.acorn;if(!c)try{c=require("acorn")}catch(e){}function u(e,t){return(d.acorn||c).parse(e,t)}c||(c=r=o={},s=this,h=function(e){var t,i,n,a;e.version="0.5.0",e.parse=function(e,a){return i=String(e),n=i.length,o(a),Ve(),function(e){v=I=s,t.locations&&(y=new He),C=x=null,M=[],Xe();var i=e||dt(),n=!0;for(e||(i.body=[]);u!==_;){var a=xt();i.body.push(a),n&>(a)&&st(!0),n=!1}return ut(i,"Program")}(t.program)};var r=e.defaultOptions={ecmaVersion:5,strictSemicolons:!1,allowTrailingCommas:!0,forbidReserved:!1,allowReturnOutsideFunction:!1,locations:!1,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null};function o(e){for(var i in t=e||{},r)Object.prototype.hasOwnProperty.call(t,i)||(t[i]=r[i]);a=t.sourceFile||null}var s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S=e.getLineInfo=function(e,t){for(var i=1,n=0;;){Ne.lastIndex=n;var a=Ne.exec(e);if(!(a&&a.index<t))break;++i,n=a.index+a[0].length}return{line:i,column:t-n}};function b(e,t){var n=S(i,e);t+=" ("+n.line+":"+n.column+")";var a=new SyntaxError(t);throw a.pos=e,a.loc=n,a.raisedAt=s,a}e.tokenize=function(e,a){i=String(e),n=i.length,o(a),Ve();var r={};function v(e){return I=h,Xe(e),r.start=l,r.end=h,r.startLoc=d,r.endLoc=c,r.type=u,r.value=g,r}return v.jumpTo=function(e,n){if(s=e,t.locations){p=1,m=Ne.lastIndex=0;for(var a;(a=Ne.exec(i))&&a.index<e;)++p,m=a.index+a[0].length}f=n,Ke()},v};var w=[],A={type:"num"},P={type:"regexp"},D={type:"string"},k={type:"name"},_={type:"eof"},T={keyword:"break"},z={keyword:"case",beforeExpr:!0},O={keyword:"catch"},B={keyword:"continue"},E={keyword:"debugger"},R={keyword:"default"},F={keyword:"do",isLoop:!0},L={keyword:"else",beforeExpr:!0},G={keyword:"finally"},U={keyword:"for",isLoop:!0},j={keyword:"function"},N={keyword:"if"},W={keyword:"return",beforeExpr:!0},Z={keyword:"switch"},H={keyword:"throw",beforeExpr:!0},V={keyword:"try"},q={keyword:"var"},J={keyword:"while",isLoop:!0},Q={keyword:"with"},K={keyword:"new",beforeExpr:!0},Y={keyword:"this"},X={keyword:"null",atomValue:null},$={keyword:"true",atomValue:!0},ee={keyword:"false",atomValue:!1},te={keyword:"in",binop:7,beforeExpr:!0},ie={break:T,case:z,catch:O,continue:B,debugger:E,default:R,do:F,else:L,finally:G,for:U,function:j,if:N,return:W,switch:Z,throw:H,try:V,var:q,while:J,with:Q,null:X,true:$,false:ee,new:K,in:te,instanceof:{keyword:"instanceof",binop:7,beforeExpr:!0},this:Y,typeof:{keyword:"typeof",prefix:!0,beforeExpr:!0},void:{keyword:"void",prefix:!0,beforeExpr:!0},delete:{keyword:"delete",prefix:!0,beforeExpr:!0}},ne={type:"[",beforeExpr:!0},ae={type:"]"},re={type:"{",beforeExpr:!0},oe={type:"}"},se={type:"(",beforeExpr:!0},le={type:")"},he={type:",",beforeExpr:!0},de={type:";",beforeExpr:!0},ce={type:":",beforeExpr:!0},ue={type:"."},ge={type:"?",beforeExpr:!0},fe={binop:10,beforeExpr:!0},pe={isAssign:!0,beforeExpr:!0},me={isAssign:!0,beforeExpr:!0},ve={postfix:!0,prefix:!0,isUpdate:!0},Ie={prefix:!0,beforeExpr:!0},ye={binop:1,beforeExpr:!0},Ce={binop:2,beforeExpr:!0},Me={binop:3,beforeExpr:!0},xe={binop:4,beforeExpr:!0},Se={binop:5,beforeExpr:!0},be={binop:6,beforeExpr:!0},we={binop:7,beforeExpr:!0},Ae={binop:8,beforeExpr:!0},Pe={binop:9,prefix:!0,beforeExpr:!0},De={binop:10,beforeExpr:!0};for(var ke in e.tokTypes={bracketL:ne,bracketR:ae,braceL:re,braceR:oe,parenL:se,parenR:le,comma:he,semi:de,colon:ce,dot:ue,question:ge,slash:fe,eq:pe,name:k,eof:_,num:A,regexp:P,string:D},ie)e.tokTypes["_"+ke]=ie[ke];function _e(e){e=e.split(" ");var t="",i=[];e:for(var n=0;n<e.length;++n){for(var a=0;a<i.length;++a)if(i[a][0].length==e[n].length){i[a].push(e[n]);continue e}i.push([e[n]])}function r(e){if(1==e.length)return t+="return str === "+JSON.stringify(e[0])+";";t+="switch(str){";for(var i=0;i<e.length;++i)t+="case "+JSON.stringify(e[i])+":";t+="return true}return false;"}if(i.length>3){for(i.sort(function(e,t){return t.length-e.length}),t+="switch(str.length){",n=0;n<i.length;++n){var o=i[n];t+="case "+o[0].length+":",r(o)}t+="}"}else r(e);return new Function("str",t)}var Te,ze=_e("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"),Oe=_e("class enum extends super const export import"),Be=_e("implements interface let package private protected public static yield"),Ee=_e("eval arguments"),Re=_e("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"),Fe=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Le="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Ge=new RegExp("["+Le+"]"),Ue=new RegExp("["+Le+"̀-ͯ҃-֑҇-ׇֽֿׁׂׅׄؐ-ؚؠ-ىٲ-ۓۧ-ۨۻ-ۼܰ-݊ࠀ-ࠔࠛ-ࠣࠥ-ࠧࠩ-࠭ࡀ-ࡗࣤ-ࣾऀ-ःऺ-़ा-ॏ॑-ॗॢ-ॣ०-९ঁ-ঃ়া-ৄেৈৗয়-ৠਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢ-ૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୟ-ୠ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఁ-ఃె-ైొ-్ౕౖౢ-ౣ౦-౯ಂಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢ-ೣ೦-೯ംഃെ-ൈൗൢ-ൣ൦-൯ංඃ්ා-ුූෘ-ෟෲෳิ-ฺเ-ๅ๐-๙ິ-ູ່-ໍ໐-໙༘༙༠-༩༹༵༷ཁ-ཇཱ-྄྆-྇ྍ-ྗྙ-ྼ࿆က-ဩ၀-၉ၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟ᜎ-ᜐᜠ-ᜰᝀ-ᝐᝲᝳក-ឲ៝០-៩᠋-᠍᠐-᠙ᤠ-ᤫᤰ-᤻ᥑ-ᥭᦰ-ᧀᧈ-ᧉ᧐-᧙ᨀ-ᨕᨠ-ᩓ᩠-᩿᩼-᪉᪐-᪙ᭆ-ᭋ᭐-᭙᭫-᭳᮰-᮹᯦-᯳ᰀ-ᰢ᱀-᱉ᱛ-ᱽ᳐-᳒ᴀ-ᶾḁ-ἕ‿⁀⁔⃐-⃥⃜⃡-⃰ⶁ-ⶖⷠ-ⷿ〡-〨゙゚Ꙁ-ꙭꙴ-꙽ꚟ꛰-꛱ꟸ-ꠀ꠆ꠋꠣ-ꠧꢀ-ꢁꢴ-꣄꣐-꣙ꣳ-ꣷ꤀-꤉ꤦ-꤭ꤰ-ꥅꦀ-ꦃ꦳-꧀ꨀ-ꨧꩀ-ꩁꩌ-ꩍ꩐-꩙ꩻꫠ-ꫩꫲ-ꫳꯀ-ꯡ꯬꯭꯰-꯹ﬠ-ﬨ︀-️︠-︦︳︴﹍-﹏0-9_]"),je=/[\n\r\u2028\u2029]/,Ne=/\r\n|[\n\r\u2028\u2029]/g,We=e.isIdentifierStart=function(e){return e<65?36===e:e<91||(e<97?95===e:e<123||e>=170&&Ge.test(String.fromCharCode(e)))},Ze=e.isIdentifierChar=function(e){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||e>=170&&Ue.test(String.fromCharCode(e))))};function He(){this.line=p,this.column=s-m}function Ve(){p=1,s=m=0,f=!0,Ke()}function qe(e,i){h=s,t.locations&&(c=new He),u=e,Ke(),g=i,f=e.beforeExpr}function Je(){var e=t.onComment&&t.locations&&new He,n=s,a=i.indexOf("*/",s+=2);if(-1===a&&b(s-2,"Unterminated comment"),s=a+2,t.locations){Ne.lastIndex=n;for(var r;(r=Ne.exec(i))&&r.index<s;)++p,m=r.index+r[0].length}t.onComment&&t.onComment(!0,i.slice(n+2,a),n,s,e,t.locations&&new He)}function Qe(){for(var e=s,a=t.onComment&&t.locations&&new He,r=i.charCodeAt(s+=2);s<n&&10!==r&&13!==r&&8232!==r&&8233!==r;)++s,r=i.charCodeAt(s);t.onComment&&t.onComment(!1,i.slice(e+2,s),e,s,a,t.locations&&new He)}function Ke(){for(;s<n;){var e=i.charCodeAt(s);if(32===e)++s;else if(13===e)++s,10===(a=i.charCodeAt(s))&&++s,t.locations&&(++p,m=s);else if(10===e||8232===e||8233===e)++s,t.locations&&(++p,m=s);else if(e>8&&e<14)++s;else if(47===e){var a;if(42===(a=i.charCodeAt(s+1)))Je();else{if(47!==a)break;Qe()}}else if(160===e)++s;else{if(!(e>=5760&&Fe.test(String.fromCharCode(e))))break;++s}}}function Ye(e){switch(e){case 46:return function(){var e=i.charCodeAt(s+1);return e>=48&&e<=57?it(!0):(++s,qe(ue))}();case 40:return++s,qe(se);case 41:return++s,qe(le);case 59:return++s,qe(de);case 44:return++s,qe(he);case 91:return++s,qe(ne);case 93:return++s,qe(ae);case 123:return++s,qe(re);case 125:return++s,qe(oe);case 58:return++s,qe(ce);case 63:return++s,qe(ge);case 48:var a=i.charCodeAt(s+1);if(120===a||88===a)return function(){s+=2;var e=tt(16);return null==e&&b(l+2,"Expected hexadecimal number"),We(i.charCodeAt(s))&&b(s,"Identifier directly after number"),qe(A,e)}();case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return it(!1);case 34:case 39:return function(e){s++;for(var a="";;){s>=n&&b(l,"Unterminated string constant");var r=i.charCodeAt(s);if(r===e)return++s,qe(D,a);if(92===r){r=i.charCodeAt(++s);var o=/^[0-7]+/.exec(i.slice(s,s+3));for(o&&(o=o[0]);o&&parseInt(o,8)>255;)o=o.slice(0,-1);if("0"===o&&(o=null),++s,o)x&&b(s-2,"Octal literal in strict mode"),a+=String.fromCharCode(parseInt(o,8)),s+=o.length-1;else switch(r){case 110:a+="\n";break;case 114:a+="\r";break;case 120:a+=String.fromCharCode(nt(2));break;case 117:a+=String.fromCharCode(nt(4));break;case 85:a+=String.fromCharCode(nt(8));break;case 116:a+="\t";break;case 98:a+="\b";break;case 118:a+="\v";break;case 102:a+="\f";break;case 48:a+="\0";break;case 13:10===i.charCodeAt(s)&&++s;case 10:t.locations&&(m=s,++p);break;default:a+=String.fromCharCode(r)}}else(13===r||10===r||8232===r||8233===r)&&b(l,"Unterminated string constant"),a+=String.fromCharCode(r),++s}}(e);case 47:return function(){var e=i.charCodeAt(s+1);return f?(++s,et()):61===e?$e(me,2):$e(fe,1)}();case 37:case 42:return 61===i.charCodeAt(s+1)?$e(me,2):$e(De,1);case 124:case 38:return function(e){var t=i.charCodeAt(s+1);return t===e?$e(124===e?ye:Ce,2):61===t?$e(me,2):$e(124===e?Me:Se,1)}(e);case 94:return 61===i.charCodeAt(s+1)?$e(me,2):$e(xe,1);case 43:case 45:return function(e){var t=i.charCodeAt(s+1);return t===e?45==t&&62==i.charCodeAt(s+2)&&je.test(i.slice(I,s))?(s+=3,Qe(),Ke(),Xe()):$e(ve,2):61===t?$e(me,2):$e(Pe,1)}(e);case 60:case 62:return function(e){var t=i.charCodeAt(s+1),n=1;return t===e?(n=62===e&&62===i.charCodeAt(s+2)?3:2,61===i.charCodeAt(s+n)?$e(me,n+1):$e(Ae,n)):33==t&&60==e&&45==i.charCodeAt(s+2)&&45==i.charCodeAt(s+3)?(s+=4,Qe(),Ke(),Xe()):(61===t&&(n=61===i.charCodeAt(s+2)?3:2),$e(we,n))}(e);case 61:case 33:return function(e){return 61===i.charCodeAt(s+1)?$e(be,61===i.charCodeAt(s+2)?3:2):$e(61===e?pe:Ie,1)}(e);case 126:return $e(Ie,1)}return!1}function Xe(e){if(e?s=l+1:l=s,t.locations&&(d=new He),e)return et();if(s>=n)return qe(_);var a=i.charCodeAt(s);if(We(a)||92===a)return rt();var r=Ye(a);if(!1===r){var o=String.fromCharCode(a);if("\\"===o||Ge.test(o))return rt();b(s,"Unexpected character '"+o+"'")}return r}function $e(e,t){var n=i.slice(s,s+t);s+=t,qe(e,n)}function et(){for(var e,t,a=s;;){s>=n&&b(a,"Unterminated regular expression");var r=i.charAt(s);if(je.test(r)&&b(a,"Unterminated regular expression"),e)e=!1;else{if("["===r)t=!0;else if("]"===r&&t)t=!1;else if("/"===r&&!t)break;e="\\"===r}++s}var o=i.slice(a,s);++s;var l=at();l&&!/^[gmsiy]*$/.test(l)&&b(a,"Invalid regexp flag");try{var h=new RegExp(o,l)}catch(e){e instanceof SyntaxError&&b(a,e.message),b(e)}return qe(P,h)}function tt(e,t){for(var n=s,a=0,r=0,o=null!=t?t:1/0;r<o;++r){var l,h=i.charCodeAt(s);if((l=h>=97?h-97+10:h>=65?h-65+10:h>=48&&h<=57?h-48:1/0)>=e)break;++s,a=a*e+l}return s===n||null!=t&&s-n!==t?null:a}function it(e){var t=s,n=!1,a=48===i.charCodeAt(s);!e&&null===tt(10)&&b(t,"Invalid number"),46===i.charCodeAt(s)&&(++s,tt(10),n=!0);var r=i.charCodeAt(s);(69===r||101===r)&&((43===(r=i.charCodeAt(++s))||45===r)&&++s,null===tt(10)&&b(t,"Invalid number"),n=!0),We(i.charCodeAt(s))&&b(s,"Identifier directly after number");var o,l=i.slice(t,s);return n?o=parseFloat(l):a&&1!==l.length?/[89]/.test(l)||x?b(t,"Invalid number"):o=parseInt(l,8):o=parseInt(l,10),qe(A,o)}function nt(e){var t=tt(16,e);return null===t&&b(l,"Bad character escape sequence"),t}function at(){Te=!1;for(var e,t=!0,n=s;;){var a=i.charCodeAt(s);if(Ze(a))Te&&(e+=i.charAt(s)),++s;else{if(92!==a)break;Te||(e=i.slice(n,s)),Te=!0,117!=i.charCodeAt(++s)&&b(s,"Expecting Unicode escape sequence \\uXXXX"),++s;var r=nt(4),o=String.fromCharCode(r);o||b(s-1,"Invalid Unicode escape"),(t?We(r):Ze(r))||b(s-4,"Invalid Unicode escape"),e+=o}t=!1}return Te?e:i.slice(n,s)}function rt(){var e=at(),t=k;return!Te&&Re(e)&&(t=ie[e]),qe(t,e)}function ot(){v=l,I=h,y=c,Xe()}function st(e){if(x=e,s=l,t.locations)for(;s<m;)m=i.lastIndexOf("\n",m-2)+1,--p;Ke(),Xe()}function lt(){this.type=null,this.start=l,this.end=null}function ht(){this.start=d,this.end=null,null!==a&&(this.source=a)}function dt(){var e=new lt;return t.locations&&(e.loc=new ht),t.directSourceFile&&(e.sourceFile=t.directSourceFile),t.ranges&&(e.range=[l,0]),e}function ct(e){var i=new lt;return i.start=e.start,t.locations&&(i.loc=new ht,i.loc.start=e.loc.start),t.ranges&&(i.range=[e.range[0],0]),i}function ut(e,i){return e.type=i,e.end=I,t.locations&&(e.loc.end=y),t.ranges&&(e.range[1]=I),e}function gt(e){return t.ecmaVersion>=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"use strict"===e.expression.value}function ft(e){if(u===e)return ot(),!0}function pt(){return!t.strictSemicolons&&(u===_||u===oe||je.test(i.slice(I,l)))}function mt(){!ft(de)&&!pt()&&It()}function vt(e){u===e?ot():It()}function It(){b(l,"Unexpected token")}function yt(e){"Identifier"!==e.type&&"MemberExpression"!==e.type&&b(e.start,"Assigning to rvalue"),x&&"Identifier"===e.type&&Ee(e.name)&&b(e.start,"Assigning to "+e.name+" in strict mode")}var Ct={kind:"loop"},Mt={kind:"switch"};function xt(){(u===fe||u===me&&"/="==g)&&Xe(!0);var e=u,n=dt();switch(e){case T:case B:ot();var a=e===T;ft(de)||pt()?n.label=null:u!==k?It():(n.label=Rt(),mt());for(var r=0;r<M.length;++r){var o=M[r];if((null==n.label||o.name===n.label.name)&&(null!=o.kind&&(a||"loop"===o.kind)||n.label&&a))break}return r===M.length&&b(n.start,"Unsyntactic "+e.keyword),ut(n,a?"BreakStatement":"ContinueStatement");case E:return ot(),mt(),ut(n,"DebuggerStatement");case F:return ot(),M.push(Ct),n.body=xt(),M.pop(),vt(J),n.test=St(),mt(),ut(n,"DoWhileStatement");case U:if(ot(),M.push(Ct),vt(se),u===de)return wt(n,null);if(u===q){var s=dt();return ot(),Pt(s,!0),ut(s,"VariableDeclaration"),1===s.declarations.length&&ft(te)?At(n,s):wt(n,s)}return s=Dt(!1,!0),ft(te)?(yt(s),At(n,s)):wt(n,s);case j:return ot(),Bt(n,!0);case N:return ot(),n.test=St(),n.consequent=xt(),n.alternate=ft(L)?xt():null,ut(n,"IfStatement");case W:return!C&&!t.allowReturnOutsideFunction&&b(l,"'return' outside of function"),ot(),ft(de)||pt()?n.argument=null:(n.argument=Dt(),mt()),ut(n,"ReturnStatement");case Z:ot(),n.discriminant=St(),n.cases=[],vt(re),M.push(Mt);for(var h,d;u!=oe;)if(u===z||u===R){var c=u===z;h&&ut(h,"SwitchCase"),n.cases.push(h=dt()),h.consequent=[],ot(),c?h.test=Dt():(d&&b(v,"Multiple default clauses"),d=!0,h.test=null),vt(ce)}else h||It(),h.consequent.push(xt());return h&&ut(h,"SwitchCase"),ot(),M.pop(),ut(n,"SwitchStatement");case H:return ot(),je.test(i.slice(I,l))&&b(I,"Illegal newline after throw"),n.argument=Dt(),mt(),ut(n,"ThrowStatement");case V:if(ot(),n.block=bt(),n.handler=null,u===O){var f=dt();ot(),vt(se),f.param=Rt(),x&&Ee(f.param.name)&&b(f.param.start,"Binding "+f.param.name+" in strict mode"),vt(le),f.guard=null,f.body=bt(),n.handler=ut(f,"CatchClause")}return n.guardedHandlers=w,n.finalizer=ft(G)?bt():null,!n.handler&&!n.finalizer&&b(n.start,"Missing catch or finally clause"),ut(n,"TryStatement");case q:return ot(),Pt(n),mt(),ut(n,"VariableDeclaration");case J:return ot(),n.test=St(),M.push(Ct),n.body=xt(),M.pop(),ut(n,"WhileStatement");case Q:return x&&b(l,"'with' in strict mode"),ot(),n.object=St(),n.body=xt(),ut(n,"WithStatement");case re:return bt();case de:return ot(),ut(n,"EmptyStatement");default:var p=g,m=Dt();if(e===k&&"Identifier"===m.type&&ft(ce)){for(r=0;r<M.length;++r)M[r].name===p&&b(m.start,"Label '"+p+"' is already declared");var y=u.isLoop?"loop":u===Z?"switch":null;return M.push({name:p,kind:y}),n.body=xt(),M.pop(),n.label=m,ut(n,"LabeledStatement")}return n.expression=m,mt(),ut(n,"ExpressionStatement")}}function St(){vt(se);var e=Dt();return vt(le),e}function bt(e){var t,i=dt(),n=!0,a=!1;for(i.body=[],vt(re);!ft(oe);){var r=xt();i.body.push(r),n&&e&>(r)&&(t=a,st(a=!0)),n=!1}return a&&!t&&st(!1),ut(i,"BlockStatement")}function wt(e,t){return e.init=t,vt(de),e.test=u===de?null:Dt(),vt(de),e.update=u===le?null:Dt(),vt(le),e.body=xt(),M.pop(),ut(e,"ForStatement")}function At(e,t){return e.left=t,e.right=Dt(),vt(le),e.body=xt(),M.pop(),ut(e,"ForInStatement")}function Pt(e,t){for(e.declarations=[],e.kind="var";;){var i=dt();if(i.id=Rt(),x&&Ee(i.id.name)&&b(i.id.start,"Binding "+i.id.name+" in strict mode"),i.init=ft(pe)?Dt(!0,t):null,e.declarations.push(ut(i,"VariableDeclarator")),!ft(he))break}return e}function Dt(e,t){var i=kt(t);if(!e&&u===he){var n=ct(i);for(n.expressions=[i];ft(he);)n.expressions.push(kt(t));return ut(n,"SequenceExpression")}return i}function kt(e){var t=function(e){var t=function(e){return function e(t,i,n){var a=u.binop;if(null!=a&&(!n||u!==te)&&a>i){var r=ct(t);r.left=t,r.operator=g;var o=u;ot(),r.right=e(_t(),a,n);var s=ut(r,o===ye||o===Ce?"LogicalExpression":"BinaryExpression");return e(s,i,n)}return t}(_t(),-1,e)}(e);if(ft(ge)){var i=ct(t);return i.test=t,i.consequent=Dt(!0),vt(ce),i.alternate=Dt(!0,e),ut(i,"ConditionalExpression")}return t}(e);if(u.isAssign){var i=ct(t);return i.operator=g,i.left=t,ot(),i.right=kt(e),yt(t),ut(i,"AssignmentExpression")}return t}function _t(){if(u.prefix){var e=dt(),t=u.isUpdate;return e.operator=g,e.prefix=!0,f=!0,ot(),e.argument=_t(),t?yt(e.argument):x&&"delete"===e.operator&&"Identifier"===e.argument.type&&b(e.start,"Deleting local variable in strict mode"),ut(e,t?"UpdateExpression":"UnaryExpression")}for(var i=Tt(zt());u.postfix&&!pt();)(e=ct(i)).operator=g,e.prefix=!1,e.argument=i,yt(i),ot(),i=ut(e,"UpdateExpression");return i}function Tt(e,t){var i;return ft(ue)?((i=ct(e)).object=e,i.property=Rt(!0),i.computed=!1,Tt(ut(i,"MemberExpression"),t)):ft(ne)?((i=ct(e)).object=e,i.property=Dt(),i.computed=!0,vt(ae),Tt(ut(i,"MemberExpression"),t)):!t&&ft(se)?((i=ct(e)).callee=e,i.arguments=Et(le,!1),Tt(ut(i,"CallExpression"),t)):e}function zt(){switch(u){case Y:var e=dt();return ot(),ut(e,"ThisExpression");case k:return Rt();case A:case D:case P:return(e=dt()).value=g,e.raw=i.slice(l,h),ot(),ut(e,"Literal");case X:case $:case ee:return(e=dt()).value=u.atomValue,e.raw=u.keyword,ot(),ut(e,"Literal");case se:var n=d,a=l;ot();var r=Dt();return r.start=a,r.end=h,t.locations&&(r.loc.start=n,r.loc.end=c),t.ranges&&(r.range=[a,h]),vt(le),r;case ne:return e=dt(),ot(),e.elements=Et(ae,!0,!0),ut(e,"ArrayExpression");case re:return function(){var e=dt(),i=!0,n=!1;for(e.properties=[],ot();!ft(oe);){if(i)i=!1;else if(vt(he),t.allowTrailingCommas&&ft(oe))break;var a,r={key:Ot()},o=!1;if(ft(ce)?(r.value=Dt(!0),a=r.kind="init"):t.ecmaVersion>=5&&"Identifier"===r.key.type&&("get"===r.key.name||"set"===r.key.name)?(o=n=!0,a=r.kind=r.key.name,r.key=Ot(),u!==se&&It(),r.value=Bt(dt(),!1)):It(),"Identifier"===r.key.type&&(x||n))for(var s=0;s<e.properties.length;++s){var l=e.properties[s];if(l.key.name===r.key.name){var h=a==l.kind||o&&"init"===l.kind||"init"===a&&("get"===l.kind||"set"===l.kind);h&&!x&&"init"===a&&"init"===l.kind&&(h=!1),h&&b(r.key.start,"Redefinition of property")}}e.properties.push(r)}return ut(e,"ObjectExpression")}();case j:return e=dt(),ot(),Bt(e,!1);case K:return function(){var e=dt();return ot(),e.callee=Tt(zt(),!0),ft(se)?e.arguments=Et(le,!1):e.arguments=w,ut(e,"NewExpression")}();default:It()}}function Ot(){return u===A||u===D?zt():Rt(!0)}function Bt(e,t){u===k?e.id=Rt():t?It():e.id=null,e.params=[];var i=!0;for(vt(se);!ft(le);)i?i=!1:vt(he),e.params.push(Rt());var n=C,a=M;if(C=!0,M=[],e.body=bt(!0),C=n,M=a,x||e.body.body.length&>(e.body.body[0]))for(var r=e.id?-1:0;r<e.params.length;++r){var o=r<0?e.id:e.params[r];if((Be(o.name)||Ee(o.name))&&b(o.start,"Defining '"+o.name+"' in strict mode"),r>=0)for(var s=0;s<r;++s)o.name===e.params[s].name&&b(o.start,"Argument name clash in strict mode")}return ut(e,t?"FunctionDeclaration":"FunctionExpression")}function Et(e,i,n){for(var a=[],r=!0;!ft(e);){if(r)r=!1;else if(vt(he),i&&t.allowTrailingCommas&&ft(e))break;n&&u===he?a.push(null):a.push(Dt(!0))}return a}function Rt(e){var n=dt();return e&&"everywhere"==t.forbidReserved&&(e=!1),u===k?(!e&&(t.forbidReserved&&(3===t.ecmaVersion?ze:Oe)(g)||x&&Be(g))&&-1==i.slice(l,h).indexOf("\\")&&b(l,"The keyword '"+g+"' is reserved"),n.name=g):e&&u.keyword?n.name=u.keyword:It(),f=!1,ot(),ut(n,"Identifier")}},"object"==typeof r&&"object"==typeof o?h(r):"function"==typeof t&&t.amd?t(["exports"],h):h(s.acorn||(s.acorn={})),c.version||(c=null));var g={"+":"__add","-":"__subtract","*":"__multiply","/":"__divide","%":"__modulo","==":"__equals","!=":"__equals"},p={"-":"__negate","+":"__self"},v=a.each(["add","subtract","multiply","divide","modulo","equals","negate"],function(e){this["__"+e]="#"+e},{__self:function(){return this}});function I(e,t,i){var n=g[t];if(e&&e[n]){var a=e[n](i);return"!="===t?!a:a}switch(t){case"+":return e+i;case"-":return e-i;case"*":return e*i;case"/":return e/i;case"%":return e%i;case"==":return e==i;case"!=":return e!=i}}function y(e,t){var i=p[e];if(t&&t[i])return t[i]();switch(e){case"+":return+t;case"-":return-t}}function C(t,a){if(!t)return"";var r=[];function o(e){for(var t=0,i=r.length;t<i;t++){var n=r[t];if(n[0]>=e)break;e+=n[1]}return e}function s(e){return t.substring(o(e.range[0]),o(e.range[1]))}function l(e,i){for(var n=o(e.range[0]),a=o(e.range[1]),s=0,l=r.length-1;l>=0;l--)if(n>r[l][0]){s=l+1;break}r.splice(s,0,[n,i.length-a+n]),t=t.substring(0,n)+i+t.substring(a)}function h(e,i){switch(e.type){case"UnaryExpression":if(e.operator in p&&"Literal"!==e.argument.type){var n=s(e.argument);l(e,'$__("'+e.operator+'", '+n+")")}break;case"BinaryExpression":if(e.operator in g&&"Literal"!==e.left.type){var a=s(e.left),r=s(e.right),h=function(e,i){return t.substring(o(e.range[1]),o(i.range[0]))}(e.left,e.right),d=e.operator;l(e,"__$__("+a+","+h.replace(new RegExp("\\"+d),'"'+d+'"')+", "+r+")")}break;case"UpdateExpression":case"AssignmentExpression":var c=i&&i.type;if(!("ForStatement"===c||"BinaryExpression"===c&&/^[=!<>]/.test(i.operator)||"MemberExpression"===c&&i.computed))if("UpdateExpression"===e.type){var u=(n=s(e.argument))+" = "+(f="__$__("+n+', "'+e.operator[0]+'", 1)');e.prefix?u="("+u+")":("AssignmentExpression"===c||"VariableDeclarator"===c||"BinaryExpression"===c)&&(s(i.left||i.id)===n&&(u=f),u=n+"; "+u),l(e,u)}else if(/^.=$/.test(e.operator)&&"Literal"!==e.left.type){a=s(e.left),r=s(e.right);var f=a+" = __$__("+a+', "'+e.operator[0]+'", '+r+")";l(e,/^\(.*\)$/.test(s(e))?"("+f+")":f)}}}var d,c=(a=a||{}).url||"",f=a.sourceMaps,m=a.paperFeatures||{},v=a.source||t,I=a.offset||0,y=le.agent,C=y.versionNumber,M=!1,x=/\r\n|\n|\r/gm;if(f&&(y.chrome&&C>=30||y.webkit&&C>=537.76||y.firefox&&C>=23||y.node)){if(y.node)I-=2;else if(i&&c&&!i.location.href.indexOf(c)){var S=n.getElementsByTagName("html")[0].innerHTML;I=S.substr(0,S.indexOf(t)+1).match(x).length+1}var b=["AA"+function(e){var t="";for(e=(Math.abs(e)<<1)+(e<0?1:0);e||!t;){var i=31&e;(e>>=5)&&(i|=32),t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[i]}return t}((M=I>0&&!(y.chrome&&C>=36||y.safari&&C>=600||y.firefox&&C>=40||y.node))?0:I)+"A"];b.length=(t.match(x)||[]).length+1+(M?I:0),d={version:3,file:c,names:[],mappings:b.join(";AACA"),sourceRoot:"",sources:[c],sourcesContent:[v]}}return(!1!==m.operatorOverloading||!1!==m.moduleExports)&&function e(t,i,n){if(t){for(var a in t)if("range"!==a&&"loc"!==a){var r=t[a];if(Array.isArray(r))for(var o=0,d=r.length;o<d;o++)e(r[o],t,n);else r&&"object"==typeof r&&e(r,t,n)}!1!==n.operatorOverloading&&h(t,i),!1!==n.moduleExports&&function(e){switch(e.type){case"ExportDefaultDeclaration":l({range:[e.start,e.declaration.start]},"module.exports = ");break;case"ExportNamedDeclaration":var t=e.declaration,i=e.specifiers;if(t){var n=t.declarations;n&&(n.forEach(function(e){l(e,"module.exports."+s(e))}),l({range:[e.start,t.start+t.kind.length]},""))}else if(i){var a=i.map(function(e){var t=s(e);return"module.exports."+t+" = "+t+"; "}).join("");a&&l(e,a)}}}(t)}}(u(t,{ranges:!0,preserveParens:!0,sourceType:"module"}),null,m),d&&(M&&(t=new Array(I+1).join("\n")+t),/^(inline|both)$/.test(f)&&(t+="\n//# sourceMappingURL=data:application/json;base64,"+e.btoa(unescape(encodeURIComponent(JSON.stringify(d))))),t+="\n//# sourceURL="+(c||"paperscript")),{url:c,source:v,code:t,map:d}}function M(e,t,i){le=t;var r,o=t.getView(),s=/\btool\.\w+|\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/.test(e)&&!/\bnew\s+Tool\b/.test(e)?new te:null,l=s?s._events:[],h=["onFrame","onResize"].concat(l),d=[],c=[],u="object"==typeof e?e:C(e,i);function g(t,i){for(var n in t)(i||!/^_/.test(n))&&new RegExp("([\\b\\s\\W]|^)"+n.replace(/\$/g,"\\$")+"\\b").test(e)&&(d.push(n),c.push(t[n]))}e=u.code,g({__$__:I,$__:y,paper:t,tool:s},!0),g(t),e="var module = { exports: {} }; "+e,(M=a.each(h,function(t){new RegExp("\\s+"+t+"\\b").test(e)&&(d.push(t),this.push("module.exports."+t+" = "+t+";"))},[]).join("\n"))&&(e+="\n"+M),e+="\nreturn module.exports;";var p=le.agent;if(n&&(p.chrome||p.firefox&&p.versionNumber<40)){var m=n.createElement("script"),v=n.head||n.getElementsByTagName("head")[0];p.firefox&&(e="\n"+e),m.appendChild(n.createTextNode("document.__paperscript__ = function("+d+") {"+e+"\n}")),v.appendChild(m),r=n.__paperscript__,delete n.__paperscript__,v.removeChild(m)}else r=Function(d,e);var M,x=(M=r&&r.apply(t,c))||{};return a.each(l,function(e){var t=x[e];t&&(s[e]=t)}),o&&(x.onResize&&o.setOnResize(x.onResize),o.emit("resize",{size:o.size,delta:new f}),x.onFrame&&o.setOnFrame(x.onFrame),o.requestUpdate()),M}function x(e){if(/^text\/(?:x-|)paperscript$/.test(e.type)&&"true"!==l.getAttribute(e,"ignore")){var t=l.getAttribute(e,"canvas"),i=n.getElementById(t),a=e.src||e.getAttribute("data-src"),r=l.hasAttribute(e,"async"),o="data-paper-scope";if(!i)throw new Error('Unable to find canvas with id "'+t+'"');var s=l.get(i.getAttribute(o))||(new l).setup(i);return i.setAttribute(o,s._id),a?ne.request({url:a,async:r,mimeType:"text/plain",onLoad:function(e){M(e,s,a)}}):M(e.innerHTML,s,e.baseURI),e.setAttribute("data-paper-ignore","true"),s}}function S(){a.each(n&&n.getElementsByTagName("script"),x)}return f.inject(v),m.inject(v),N.inject(v),i&&("complete"===n.readyState?setTimeout(S):q.add(i,{load:S})),{compile:C,execute:M,load:function(e){return e?x(e):S()},parse:u,calculateBinary:I,calculateUnary:y}}.call(this);var le=new(l.inject(a.exports,{Base:a,Numerical:u,Key:X,DomEvent:q,DomElement:V,document:n,window:i,Symbol:k,PlacedSymbol:D}));return le.agent.node&&r(le),"function"==typeof t&&t.amd?t("paper",le):o&&(o.exports=le),le}.call(n,"object"==typeof self?self:null);const s=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(a.exports);e.Preview3DGenerator=class{constructor(){i(this,"_paperScope",new s.PaperScope),i(this,"_baseMaterial",null),i(this,"_borderMaterial",null);const e=document.createElement("canvas");e.width=1,e.height=1,this._paperScope.setup(new s.Size(1,1))}generatePreview3D(e,t){if(!e.columns||isNaN(e.columns)||e.columns<1||e.rows<1||!e.rows||isNaN(e.rows))throw new Error("Invalid columns or rows value. Columns and rows must be greater than 0 and must be a number.");console.log("Generating 3D preview for resizable canvas...",e),this._baseMaterial||(this._baseMaterial=new BABYLON.PBRMaterial("baseMaterial",t)),this._borderMaterial||(this._borderMaterial=new BABYLON.PBRMaterial("borderMaterial",t)),this._baseMaterial.albedoColor=new BABYLON.Color3(1,1,1),this._baseMaterial.metallic=0,this._baseMaterial.roughness=.5,this._borderMaterial.albedoColor=BABYLON.Color3.FromHexString(e.borderColor),this._borderMaterial.metallic=0,this._borderMaterial.roughness=.5,e.useCheckerTexture&&(this._baseMaterial.albedoTexture=new BABYLON.Texture("https://zakekecdn.blob.core.windows.net/cdn/Test/checker_texture.png",t),this._baseMaterial.albedoTexture.wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,this._baseMaterial.albedoTexture.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE,this._borderMaterial.albedoTexture=new BABYLON.Texture("https://zakekecdn.blob.core.windows.net/cdn/Test/checker_texture.png",t),this._borderMaterial.albedoTexture.wrapU=BABYLON.Texture.CLAMP_ADDRESSMODE,this._borderMaterial.albedoTexture.wrapV=BABYLON.Texture.CLAMP_ADDRESSMODE);const i=new BABYLON.Mesh("groupMesh",t),n=[],a=[],r=[];for(let i=0;i<e.columns;i++)for(let o=0;o<e.rows;o++){const[s,l,h]=this.generateCanvasMesh(e,t,i,o);n.push(s),a.push(l),r.push(h)}const o=BABYLON.Mesh.MergeMeshes(n,!0,!0,void 0,!1,!1),s=BABYLON.Mesh.MergeMeshes(a,!0,!0,void 0,!1,!1),l=BABYLON.Mesh.MergeMeshes(r,!0,!0,void 0,!1,!1);if(!o||!s||!l)return null;o.material=this._borderMaterial,s.material=this._baseMaterial,l.material=this._baseMaterial,o.parent=i,s.parent=i,l.parent=i,o.name="borders",s.name="back",l.name="front";const h=BABYLON.SceneSerializer.SerializeMesh(i,!1,!0);return null==i||i.dispose(),h}generateCanvasMesh(e,t,i,n){var a,r,o,s;const l=e.width/e.columns,h=e.height/e.rows,d=.1*l,c=BABYLON.MeshBuilder.CreateBox("borders",{width:l,height:h,depth:e.depth},t),u=BABYLON.MeshBuilder.CreatePlane("front",{width:l,height:h},t),g=BABYLON.MeshBuilder.CreatePlane("back",{width:l,height:h},t);c.position=new BABYLON.Vector3(l/2+i*(l+d),h/2+n*(h+d)),u.position=new BABYLON.Vector3(l/2+i*(l+d),h/2+n*(h+d),-e.depth/2),g.position=new BABYLON.Vector3(l/2+i*(l+d),h/2+n*(h+d),e.depth/2),g.rotate(BABYLON.Axis.X,Math.PI,BABYLON.Space.WORLD),g.rotate(BABYLON.Axis.Z,Math.PI,BABYLON.Space.WORLD),c.material=this._borderMaterial,g.material=this._borderMaterial,u.material=this._baseMaterial;const f=c.getVerticesData(BABYLON.VertexBuffer.NormalKind),p=c.getVerticesData(BABYLON.VertexBuffer.UVKind),m=u.getVerticesData(BABYLON.VertexBuffer.UVKind),v=g.getVerticesData(BABYLON.VertexBuffer.UVKind);if(e.borderRadius>0&&console.warn("Mirror canvas effect will not work for border radius > 0"),0===e.borderRadius){const t=e.depth/e.width,a=e.depth/e.height,r=Math.min(t,a),o=l/e.width,s=h/e.height;for(var I=0;I<p.length;I+=2){const t=Math.round(f[I/2*3]),a=Math.round(f[I/2*3+1]),l=Math.round(f[I/2*3+2]),h=1==t&&0==a&&0==l,d=0==t&&1==a&&0==l,c=0==t&&-1==a&&0==l;if(-1==t&&0==a&&0==l){var y=p[I],C=p[I+1];p[I]=C*r+o*i,p[I+1]=y*s+s*n}h&&(y=p[I],C=p[I+1],p[I]=C*r+(1-r)-o*(e.columns-1-i),p[I+1]=y*s+s*n),c&&(y=p[I],C=p[I+1],p[I]=C*o+o*i,p[I+1]=y*r+s*n),d&&(y=p[I],C=p[I+1],p[I]=(1-C)*o+o*i,p[I+1]=(1-y)*r+(1-r))}for(c.setVerticesData(BABYLON.VertexBuffer.UVKind,p),I=0;I<m.length;I+=2)y=m[I],C=m[I+1],m[I]=y*o+o*i,m[I+1]=C*s+s*n;for(u.setVerticesData(BABYLON.VertexBuffer.UVKind,m),I=0;I<v.length;I+=2)y=v[I],C=v[I+1],v[I]=y*o+o*(e.columns-1-i),v[I+1]=C*s+s*n;g.setVerticesData(BABYLON.VertexBuffer.UVKind,v)}u.isVisible=!1,g.isVisible=!1;const M=null!==(a=c.getVerticesData(BABYLON.VertexBuffer.PositionKind))&&void 0!==a?a:[],x=null!==(r=c.getVerticesData(BABYLON.VertexBuffer.NormalKind))&&void 0!==r?r:[],S=null!==(o=c.getVerticesData(BABYLON.VertexBuffer.UVKind))&&void 0!==o?o:[],b=null!==(s=c.getIndices())&&void 0!==s?s:[];return M.splice(0,24),x.splice(0,24),S.splice(0,16),b.splice(b.length-12,12),c.updateVerticesData(BABYLON.VertexBuffer.PositionKind,M),c.updateVerticesData(BABYLON.VertexBuffer.NormalKind,x),c.updateVerticesData(BABYLON.VertexBuffer.UVKind,S),c.updateIndices(b),[c,g,u]}},e.ProductAreaGenerator=class{constructor(){i(this,"_paperScope",new s.PaperScope),this._paperScope.setup(new s.Size(1,1))}generateArea(e){if(e.width<=0||e.height<=0)throw new Error("Width and height must be greater than 0");const t=new this._paperScope.Path.Rectangle({point:[0,0],size:[e.width,e.height],radius:e.borderRadius});return t.position=new this._paperScope.Point(0,0),t.remove(),{json:t.exportJSON(),svg:t.exportSVG({asString:!0})}}},e.ProductImageGenerator=class{constructor(){i(this,"_paperScope",new s.PaperScope),this._paperScope.setup(new s.Size(1,1))}generateImage(e){if(e.width<=0||e.height<=0)throw new Error("Width and height must be greater than 0");return{shape:this.createShape(e),splitColumns:this.createSplitColumns(e),measures:this.createMeasures(e)}}createShape(e){const t=new this._paperScope.Path.Rectangle({point:[0,0],size:[e.width,e.height],radius:e.shape.borderRadius,fillColor:e.shape.fillColor,strokeColor:e.shape.borderColor,strokeWidth:e.shape.borderWidth,shadowColor:e.shape.shadowColor,shadowBlur:e.shape.shadowBlur*e.scale,shadowOffset:new this._paperScope.Point(e.shape.shadowOffset.x*e.scale,e.shape.shadowOffset.y*e.scale)});return t.position=new this._paperScope.Point(0,0),t.remove(),{json:t.exportJSON(),svg:t.exportSVG({asString:!0})}}createSplitColumns(e){const t=new this._paperScope.Group,i=e.width/e.splitColumns.columns,n=e.height/e.splitColumns.rows;for(let n=1;n<e.splitColumns.columns;n++){const a=n*i,r=new this._paperScope.Path.Line({from:[a,0+e.splitColumns.marginVertical],to:[a,e.height-e.splitColumns.marginVertical],strokeColor:e.splitColumns.lineColor,strokeWidth:e.splitColumns.lineWidth,dashArray:e.splitColumns.lineDashArray,strokeScaling:!1});t.addChild(r)}for(let i=1;i<e.splitColumns.rows;i++){const a=i*n,r=new this._paperScope.Path.Line({from:[0+e.splitColumns.marginVertical,a],to:[e.width-e.splitColumns.marginVertical,a],strokeColor:e.splitColumns.lineColor,strokeWidth:e.splitColumns.lineWidth,dashArray:e.splitColumns.lineDashArray,strokeScaling:!1});t.addChild(r)}return t.position=new this._paperScope.Point(0,0),{json:t.exportJSON(),svg:t.exportSVG({asString:!0})}}createMeasures(e){var t,i,n,a,r,o;const s=new this._paperScope.Group,l=this.createArrow(e,new this._paperScope.Point(-e.width/2,-e.height/2-e.measures.widthDistance*e.scale),new this._paperScope.Point(+e.width/2,-e.height/2-e.measures.widthDistance*e.scale)),h=this.createArrow(e,new this._paperScope.Point(e.width/2+e.measures.heightDistance*e.scale,-e.height/2),new this._paperScope.Point(e.width/2+e.measures.heightDistance*e.scale,+e.height/2)),d=(e.measures.heightDistance+10)*e.scale,c=(e.measures.widthDistance+5)*e.scale,u=new this._paperScope.PointText({fillColor:e.measures.labelColor,fontFamily:null!==(t=e.measures.fontFamily)&&void 0!==t?t:"Courier New",fontWeight:null!==(i=e.measures.fontWeight)&&void 0!==i?i:"bold",fontSize:e.measures.labelFontSize*e.scale,justification:"center",position:[0,-e.height/2-c],content:e.measures.widthLabel}),g=new this._paperScope.PointText({fillColor:e.measures.labelColor,fontFamily:null!==(n=e.measures.fontFamily)&&void 0!==n?n:"Courier New",fontWeight:null!==(a=e.measures.fontWeight)&&void 0!==a?a:"bold",fontSize:e.measures.labelFontSize*e.scale,justification:"center",verticalLine:"base",position:[e.width/2+d,0],content:e.measures.heightLabel,rotation:-270}),f=new this._paperScope.PointText({fillColor:e.measures.labelColor,fontFamily:null!==(r=e.measures.fontFamily)&&void 0!==r?r:"Courier New",fontWeight:null!==(o=e.measures.fontWeight)&&void 0!==o?o:"bold",fontSize:e.measures.labelFontSize*e.scale,justification:"center",verticalLine:"base",position:[0-e.width/2-(e.measures.heightDistance+5)*e.scale,-e.height/2-c],content:e.measures.totalSizeLabel,rotation:-90});return f.bounds.y+=f.bounds.height/2+d,f.data.isTotalSizeLabel=!0,f.data.originalContent=f.content,f.data.originalY=f.bounds.y,s.addChild(u),s.addChild(g),s.addChild(l),s.addChild(h),s.addChild(f),{json:s.exportJSON(),svg:s.exportSVG({asString:!0})}}createArrow(e,t,i){const n=new this._paperScope.Group,a=i.subtract(t).angle,r={strokeColor:e.measures.lineColor,strokeWidth:e.measures.lineWidth,dashArray:e.measures.lineDashArray,strokeScaling:!1},o=new this._paperScope.Path.Line(_objectSpread({from:t,to:i},r)),s=new this._paperScope.Path.Line(_objectSpread({from:t,to:t.add(new this._paperScope.Point(-5*e.scale,-5*e.scale))},r)),l=new this._paperScope.Path.Line(_objectSpread({from:t,to:t.add(new this._paperScope.Point(-5*e.scale,5*e.scale))},r)),h=new this._paperScope.Path.Line(_objectSpread({from:i,to:i.add(new this._paperScope.Point(-5*e.scale,-5*e.scale))},r)),d=new this._paperScope.Path.Line(_objectSpread({from:i,to:i.add(new this._paperScope.Point(-5*e.scale,5*e.scale))},r));return s.rotate(a+180,t),l.rotate(a+180,t),h.rotate(a,i),d.rotate(a,i),n.addChild(o),n.addChild(s),n.addChild(l),n.addChild(h),n.addChild(d),n}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}),(MPlaza=MPlaza||{}).EmptyUUID="00000000-0000-0000-0000-000000000000",MPlaza.generateUUID=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:7&i|8).toString(16)})},MPlaza.getContrastYIQ=function(e,t,i){return(299*e+587*t+114*i)/1e3>=128?"black":"white"},MPlaza.getContrastYIQHex=function(e){return(299*parseInt(e.substr(0,2),16)+587*parseInt(e.substr(2,2),16)+114*parseInt(e.substr(4,2),16))/1e3>=128?"black":"white"},MPlaza.makeID=function(e){for(var t="",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=0;n<e;n++)t+=i.charAt(Math.floor(Math.random()*i.length));return t},MPlaza.cloudFlareApiUrl=function(){return"string"==typeof Zakeke.config.cloudFlareApiUrl&&null!==Zakeke.config.cloudFlareApiUrl&&""!==Zakeke.config.cloudFlareApiUrl.trim()?Zakeke.config.cloudFlareApiUrl:null},MPlaza.syncCloudflare=function(e,t,i){var n=function(e){void 0!==e._defaultUrl&&(e.url=e._defaultUrl),delete e.cloudflareUrl,delete e._defaultUrl},a=Backbone.sync;t.hasOwnProperty("retrySyncEngine")&&(a=t.retrySyncEngine);var r=0,o=t.stepsLimit||2;t.cloudflareUrl=MPlaza.cloudFlareApiUrl(),t._defaultUrl=t.url,t.url=function(){var e=t._defaultUrl();return"string"==typeof t.cloudflareUrl&&null!==t.cloudflareUrl&&""!==t.cloudflareUrl.trim()&&(e=e.replace(Zakeke.config.baseApiUrl,Zakeke.config.cloudFlareApiUrl)),e},"read"===e&&null!==t.cloudflareUrl||(n(t),o=1);var s=$.Deferred(),l=function(h,d,c){var u=_.extend({},i);++r>o?(n(t),i.error(h,d,c),s.reject(h,d,c)):(delete u.error,delete u.success,a(e,t,u).then(function(e,a,r){n(t),i.success(e,a,r),s.resolve(e,a,r)}).fail(function(e,i,a){n(t),l(e,i,a)}))};return l(),s.promise()},MPlaza.PricingModel={Simple:1,Advanced:2,RuleBased:3},MPlaza.PricingType={Undefined:1,Global:2,PerColor:3},MPlaza.PricingApplicationType={Undefined:1,Global:2,PerSide:3,PerArea:4},MPlaza.AttributeType={Options:1,Color:2,Number:3,String:4},MPlaza.LogicalOperator={AND:"AND",OR:"OR"},MPlaza.ComparisonOperator={Equal:"Equal",NotEqual:"NotEqual",In:"In",NotIn:"NotIn"},MPlaza.SceneElementType={None:0,Mesh:1,Material:2,Light:4,Camera:8,CameraLocation:16,SubMesh:32},MPlaza.SceneElementType.All=MPlaza.SceneElementType.Mesh|MPlaza.SceneElementType.Material|MPlaza.SceneElementType.Light|MPlaza.SceneElementType.Camera|MPlaza.SceneElementType.CameraLocation|MPlaza.SceneElementType.SubMesh,MPlaza.SceneActionType={Filter:1,ShowHideMesh:2,SetMeshMaterial:3,SetMaterialColor:4,SetCameraLocation:5,AdjustCamera:6,SetSubMeshMaterial:7,SetCameraPivot:8,ResetCameraPivot:9,EnableDiableZoom:10,SetMeshDesignMaterial:11,SetMeshDesignEffect:12},MPlaza.PaddingType={Start:1,End:2,StartEnd:3},MPlaza.AttributeOptionPreviewShape={Rectangle:1,Circle:2},MPlaza.AttributeGroupDirection={Horizontal:0,Vertical:1},MPlaza.DeviceType={Any:0,PC:1,Phone:2,Tablet:4},MPlaza.DeviceType.All=MPlaza.DeviceType.PC|MPlaza.DeviceType.Phone|MPlaza.DeviceType.Tablet,MPlaza.ExtensionFieldDataType={Money:1,Integer:2,Decimal:3},MPlaza.ExtensionFieldOperationType={None:1,Addition:2};var TempStateObjectInterface={tempState:null,initTempState:function(){this.tempState=this.clone(),this.callToTempStateChildren("initTempState")},applyTempState:function(){this.tempState&&this.set(this.tempState.attributes),this.callToTempStateChildren("applyTempState")},resetTempState:function(){this.tempState=null},childHasTempState:function(e){return!(!e||!e.hasOwnProperty("tempState"))},hasTempStateChildren:function(){return!!(this.tempStateChildren&&Array.isArray(this.tempStateChildren)&&this.tempStateChildren.length>0)},callToTempStateChildren:function(e){if(this.hasTempStateChildren()&&this.tempState)for(var t=0;t<this.tempStateChildren.length;t++){var i=this.tempState.get(this.tempStateChildren[t]);this.childHasTempState(i)&&e&&i[e]()}}};function MarvinColorModelConverter(){}function MarvinImage(e,t,i){this.image=null,this.canvas=null,this.ctx=null,this.data=null,this.colorModel=null==i?MarvinImage.COLOR_MODEL_RGB:i,null!=e&&this.create(e,t),i==MarvinImage.COLOR_MODEL_BINARY&&(this.arrBinaryColor=new Array(e*t))}function MarvinImageMask(e,t){this.width=e,this.height=t,this.arrMask=0!=e&&0!=t?MarvinJSUtils.createMatrix2D(width,height):null}function MarvinSegment(e,t,i,n){this.x1=e,this.x2=i,this.y1=t,this.y2=n,-1!=e&&-1!=t&&-1!=i&&-1!=n&&(this.width=i-e+1,this.height=n-t+1,this.area=this.width*this.height)}function MarvinColor(e,t,i){return this.red=e,this.green=t,this.blue=i,this}MPlaza.UserIdentity=Backbone.AssociatedModel.extend({defaults:{nominative:"",token:""},idAttribute:"userID",initialize:function(){},url:function(){return Zakeke.config.baseApiUrl+"login"},sync:MPlaza.syncCloudflare}),MPlaza.AttributeProposition=Backbone.AssociatedModel.extend({defaults:{attributeGuid:"",op:"Equal",value:""},initialize:function(){},relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.AttributePropositions=Backbone.Collection.extend({model:MPlaza.AttributeProposition,sync:MPlaza.syncCloudflare}),MPlaza.AttributeExpression=Backbone.AssociatedModel.extend({defaults:{op:"AND",propositions:null,expressions:null},initialize:function(){this.get("propositions")||this.set("propositions",[]),this.get("expressions")||this.set("expressions",[]),this.get("propositions").parentModel=this,this.get("expressions").parentModel=this},getAllAttributeGuids:function(){for(var e=[],t=function(t){var i=t.attributeGuid;Zakeke.arrayContains(e,i)||e.push(i)},i=function(e){for(var i=0;i<e.propositions.length;i++){var n=e.proposition[i];t(n)}},n=0;n<this.get("propositions").length;n++){var a=this.get("propositions")[n];t(a)}for(n=0;n<this.get("expressions").length;n++){i(this.get("expressions")[n])}return e},isEmpty:function(){return 0==this.get("propositions").length&&0==this.get("expressions").length},sync:MPlaza.syncCloudflare}),MPlaza.AttributeExpressions=Backbone.Collection.extend({model:MPlaza.AttributeExpression,sync:MPlaza.syncCloudflare}),MPlaza.AttributeSelectionColor=Backbone.AssociatedModel.extend({defaults:{selectionExpression:null,colorID:-1},idAttribute:"selectionID",sync:MPlaza.syncCloudflare}),MPlaza.AttributeSelectionColors=Backbone.Collection.extend({model:MPlaza.AttributeSelectionColor,getAttributeSelectionColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("selectionID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ComposerPricingPrice=Backbone.AssociatedModel.extend({defaults:{qtyFrom:0,qtyTo:null,price:0},idAttribute:"priceID",initialize:function(){},relations:[],getPricingID:function(){return this.collection&&this.collection.getPricingID?this.collection.getPricingID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ComposerPricingPrices=Backbone.Collection.extend({model:MPlaza.ComposerPricingPrice,getPricingID:function(){return this.parentModel&&this.parentModel.getPricingID?this.parentModel.getPricingID():null},sync:MPlaza.syncCloudflare}),MPlaza.ComposerPricing=Backbone.AssociatedModel.extend({defaults:{prices:[]},idAttribute:"pricingID",initialize:function(){var e=this;this.get("prices").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("prices").on("add",function(){e._fireEvent("change")}),this.get("prices").on("remove",function(){e._fireEvent("change")}),this.get("prices").on("change",function(){e._fireEvent("change")})},_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},relations:[{type:Backbone.Many,key:"prices",collectionType:MPlaza.ComposerPricingPrices}],url:function(){var e=Zakeke.config.baseApiUrl+"composerpricings";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},getPricingID:function(){return this.get("pricingID")},toString:function(){},getComposerPricingPriceForQuantity:function(e){for(var t=0;t<this.get("prices").length;t++){var i=this.get("prices").at(t);if(i.get("qtyFrom")<=e&&(!i.get("qtyTo")||e<i.get("qtyTo")))return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ComposerPricings=Backbone.Collection.extend({model:MPlaza.ComposerPricing,url:function(){return Zakeke.config.baseApiUrl+"composerpricings"},getComposerPricing:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("pricingID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.AttributePricing=Backbone.AssociatedModel.extend({defaults:{selectedOptionID:null,selectedOptionGuid:null,selectedValue:"",constraintExpression:null,price:0,pricingID:-1},idAttribute:"attributePricingID",initialize:function(){},resetIDs:function(){this.unset("attributePricingID")},relations:[{type:Backbone.One,key:"constraintExpression",relatedModel:MPlaza.AttributeExpression}],sync:MPlaza.syncCloudflare}),MPlaza.AttributePricings=Backbone.Collection.extend({model:MPlaza.AttributePricing,resetIDs:function(){for(var e=0;e<this.length;e++){this.at(e).resetIDs()}},sync:MPlaza.syncCloudflare}),MPlaza.AttributeSceneAction=Backbone.AssociatedModel.extend({defaults:{name:"",actionTypeID:MPlaza.SceneActionType.ShowHideMesh,sceneElementTypeID:MPlaza.SceneElementType.Mesh,selector:"",propertyName:"",value:"",execOrder:0,deviceTypes:MPlaza.DeviceType.Any},idAttribute:"actionID",initialize:function(){this.get("actionGuid")||this.set("actionGuid",MPlaza.generateUUID())},relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("actionID")},sync:MPlaza.syncCloudflare}),MPlaza.AttributeSceneActions=Backbone.Collection.extend({model:MPlaza.AttributeSceneAction,resetIDs:function(){for(var e=0;e<this.length;e++){this.at(e).resetIDs()}},comparator:function(e){return e.get("execOrder")},getActionByID:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("actionID")===e)return i}return null},getActionByGuid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("actionGuid")===e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.AttributeOptionExtensionField=Backbone.AssociatedModel.extend({defaults:{name:"",dataTypeID:MPlaza.ExtensionFieldDataType.Integer,operationTypeID:MPlaza.ExtensionFieldOperationType.Addition,label:"",formatString:"",value:""},idAttribute:"extensionFieldID",relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},resetIDs:function(){this.unset("extensionFieldID")},sync:MPlaza.syncCloudflare}),MPlaza.AttributeOptionExtensionFields=Backbone.Collection.extend({model:MPlaza.AttributeOptionExtensionField,resetIDs:function(){for(var e=0;e<this.length;e++){this.at(e).resetIDs()}},sync:MPlaza.syncCloudflare}),MPlaza.AttributeOption=Backbone.AssociatedModel.extend({defaults:{optionCode:"",tempImageFileKey:"",imageUrl:"",imageFileObjectID:-1,tempImageFileObjectID:-1,displayOrder:0,name:"",description:"",isDefault:!1,constraintExpression:null,actions:[],optionExtensionFields:[]},idAttribute:"optionID",initialize:function(){this.get("actions").parentModel=this,this.get("optionExtensionFields").parentModel=this,this.get("optionGuid")||this.set("optionGuid",MPlaza.generateUUID())},relations:[{type:Backbone.Many,key:"actions",collectionType:MPlaza.AttributeSceneActions},{type:Backbone.One,key:"constraintExpression",relatedModel:MPlaza.AttributeExpression},{type:Backbone.Many,key:"optionExtensionFields",collectionType:MPlaza.AttributeOptionExtensionFields}],resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("optionID"),this.set("optionGuid",MPlaza.generateUUID()),this.get("actions").resetIDs(),this.get("optionExtensionFields").resetIDs()},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getPricings:function(){var e=[],t=this.getParentModel();return t&&(e=t.getOptionPricings(this.get("optionGuid"))),e},addSimplePricing:function(e,t){var i=this.getParentModel();if(i){var n=new MPlaza.AttributePricing;return this.get("optionID")&&n.set("selectedOptionID",this.get("optionID")),n.set("selectedOptionGuid",this.get("optionGuid")),t&&t instanceof MPlaza.AttributeExpression&&n.set("constraintExpression",t),n.set("price",e),i.get("pricings").add(n),n}return null},addAdvancedPricing:function(e,t){var i=this.getParentModel();if(i&&e&&e instanceof MPlaza.ComposerPricing){var n=new MPlaza.AttributePricing;this.get("optionID")&&n.set("selectedOptionID",this.get("optionID")),n.set("selectedOptionGuid",this.get("optionGuid")),t&&t instanceof MPlaza.AttributeExpression&&n.set("constraintExpression",t),n.set("pricingID",e.get("pricingID")),i.get("pricings").add(n)}},removePricing:function(e){var t=this.getParentModel();t&&t.get("pricings").remove(e)},getActionByID:function(e){return this.get("actions").getActionByID(e)},getExtensionField:function(e){return this.get("extensionFields")&&this.get("extensionFields").filter(t=>t.extensionFieldID===e)[0]},getExtensionFields:function(){return this.get("extensionFields")},getActionByGuid:function(e){return this.get("actions").getActionByGuid(e)},sync:MPlaza.syncCloudflare}),MPlaza.AttributeOptions=Backbone.Collection.extend({model:MPlaza.AttributeOption,comparator:function(e){return e.get("displayOrder")},resetIDs:function(){for(var e=0;e<this.length;e++){this.at(e).resetIDs()}},sync:MPlaza.syncCloudflare}),MPlaza.Attribute=Backbone.AssociatedModel.extend({defaults:{attributeCode:"",attributeTypeID:MPlaza.AttributeType.Options,name:"",description:"",groupID:-1,groupGuid:MPlaza.EmptyUUID,stepID:-1,stepGuid:MPlaza.EmptyUUID,defaultValue:"",displayOrder:0,optionPreviewShapeID:MPlaza.AttributeOptionPreviewShape.Rectangle,options:[],preActions:[],valueActions:[],postActions:[],pricings:[],constraintExpression:null,meshSelector:"",cameraLocationID:null,hideOptionsLabel:!1},idAttribute:"attributeID",initialize:function(){this.get("attributeGuid")||this.set("attributeGuid",MPlaza.generateUUID()),this.get("options").parentModel=this,this.get("preActions").parentModel=this,this.get("valueActions").parentModel=this,this.get("postActions").parentModel=this,this.get("pricings").parentModel=this},relations:[{type:Backbone.Many,key:"options",collectionType:MPlaza.AttributeOptions},{type:Backbone.Many,key:"preActions",collectionType:MPlaza.AttributeSceneActions},{type:Backbone.Many,key:"valueActions",collectionType:MPlaza.AttributeSceneActions},{type:Backbone.Many,key:"postActions",collectionType:MPlaza.AttributeSceneActions},{type:Backbone.Many,key:"pricings",collectionType:MPlaza.AttributePricings},{type:Backbone.One,key:"constraintExpression",relatedModel:MPlaza.AttributeExpression}],getOption:function(e){return this.get("options").findWhere({optionID:e})},getOptionByGuid:function(e){return this.get("options").findWhere({optionGuid:e})},getOptionByCode:function(e){if(!e)return null;for(var t=0;t<this.get("options").length;t++){var i=this.get("options").at(t);if(i.get("optionCode")&&i.get("optionCode")===e)return i}return null},cloneAttribute:function(e){const t=[];for(let e=0;e<this.get("options").length;e++){const i=this.get("options").at(e),n=this.get("pricings").find(e=>e.get("selectedOptionGuid")===i.get("optionGuid"));n&&t.push({optionIndex:this.get("options").indexOf(i),pricingIndex:this.get("pricings").indexOf(n)})}var i=this.clone();void 0!==e&&i.set("name",e);for(var n=0;n<this.get("options").length;n++){var a=this.get("options").at(n),r=i.get("options").at(n);r.resetIDs(),r.set("tempImageFileObjectID",a.get("imageFileObjectID"))}i.resetIDs();for(const{optionIndex:e,pricingIndex:n}of t){const t=i.get("options").at(e),a=i.get("pricings").at(n);a.set("selectedOptionID",t.get("optionID")),a.set("selectedOptionGuid",t.get("optionGuid"))}return i},addClonedOption:function(e,t){var i=e.clone();void 0!==t&&i.set("name",t),i.resetIDs(),i.set("isDefault",!1),i.set("tempImageFileObjectID",e.get("imageFileObjectID")),this.get("options").add(i);const n=this.get("pricings").find(t=>t.get("selectedOptionGuid")===e.get("optionGuid"));if(n){const e=n.clone();e.resetIDs(),e.set("selectedOptionID",i.get("optionID")),e.set("selectedOptionGuid",i.get("optionGuid")),this.get("pricings").add(e)}return i},getOptionPricings:function(e){return this.get("pricings").where({selectedOptionGuid:e})},resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("attributeID"),this.set("attributeGuid",MPlaza.generateUUID()),this.get("options").resetIDs(),this.get("pricings").resetIDs()},sync:MPlaza.syncCloudflare}),MPlaza.Attributes=Backbone.Collection.extend({model:MPlaza.Attribute,getAttribute:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeID")===e)return i}return null},getAttributeByGuid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeGuid")===e)return i}return null},getAttributeByCode:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeCode")===e)return i}return null},comparator:function(e){return e.get("displayOrder")},sync:MPlaza.syncCloudflare}),MPlaza.AttributeGroup=Backbone.AssociatedModel.extend({defaults:{tempImageFileKey:"",imageUrl:"",name:"",displayOrder:0,sceneCameraLocationID:MPlaza.EmptyUUID,meshSelector:"",direction:0,attributesAlwaysOpened:!1},idAttribute:"groupID",initialize:function(){this.get("groupGuid")||this.set("groupGuid",MPlaza.generateUUID())},relations:[],resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("groupID"),this.set("groupGuid",MPlaza.generateUUID())},cloneGroup:function(e){var t=this.clone();return void 0!==e&&t.set("name",e),t.resetIDs(),t},sync:MPlaza.syncCloudflare}),MPlaza.AttributeGroups=Backbone.Collection.extend({model:MPlaza.AttributeGroup,sync:MPlaza.syncCloudflare}),MPlaza.AttributeStep=Backbone.AssociatedModel.extend({defaults:{groupID:-1,groupGuid:null,name:"",displayOrder:0},idAttribute:"stepID",initialize:function(){this.get("stepGuid")||this.set("stepGuid",MPlaza.generateUUID())},relations:[],resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("stepID"),this.set("stepGuid",MPlaza.generateUUID())},cloneStep:function(e){var t=this.clone();return void 0!==e&&t.set("name",e),t.resetIDs(),t},sync:MPlaza.syncCloudflare}),MPlaza.AttributeSteps=Backbone.Collection.extend({model:MPlaza.AttributeStep,comparator:function(e){return e.get("displayOrder")},sync:MPlaza.syncCloudflare}),MPlaza.CompositionCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:null,macroCategoryID:null},relations:[],resetIDs:function(){}}),MPlaza.CompositionCategories=Backbone.Collection.extend({model:MPlaza.CompositionCategory,sync:MPlaza.syncCloudflare}),MPlaza.FrontEndComposition=Backbone.AssociatedModel.extend({defaults:{compositionID:null,name:"",previewImageUrl:""},idAttribute:"compositionID",relations:[],resetIDs:function(){}}),MPlaza.FrontEndCompositions=Backbone.Collection.extend({model:MPlaza.FrontEndComposition,sync:MPlaza.syncCloudflare}),MPlaza.FrontEndCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:null,name:"",composition:MPlaza.FrontEndCompositions},idAttribute:"categoryID",relations:[{type:Backbone.Many,key:"composition",collectionType:MPlaza.FrontEndCompositions}],resetIDs:function(){}}),MPlaza.FrontEndCategories=Backbone.Collection.extend({model:MPlaza.FrontEndCategory,sync:MPlaza.syncCloudflare}),MPlaza.FrontEndMacroCategory=Backbone.AssociatedModel.extend({defaults:{macroCategoryID:null,name:"",category:MPlaza.FrontEndCategories},idAttribute:"macroCategoryID",relations:[{type:Backbone.Many,key:"category",collectionType:MPlaza.FrontEndCategories}],resetIDs:function(){}}),MPlaza.FrontEndMacroCategories=Backbone.Collection.extend({model:MPlaza.FrontEndMacroCategory,sync:MPlaza.syncCloudflare}),MPlaza.TemplateGroup=Backbone.AssociatedModel.extend({defaults:{templateGroupGuid:null,templateGroupID:-1,groupGuid:MPlaza.EmptyUUID,groupID:-1,stepGuid:MPlaza.EmptyUUID,name:"",displayOrder:0,stepID:-1,categories:[],compositions:[],macrocategories:[],macrocategory:[]},idAttribute:"templateGroupGuid",initialize:function(){this.get("templateGroupGuid")||this.set("templateGroupGuid",MPlaza.generateUUID())},relations:[{type:Backbone.Many,key:"categories",collectionType:MPlaza.CompositionCategories},{type:Backbone.Many,key:"macrocategory",collectionType:MPlaza.FrontEndMacroCategories}],resetIDs:function(){this.tempID=Zakeke.generateUUID(),this.unset("templateGroupID"),this.set("templateGroupGuid",MPlaza.generateUUID())},cloneTemplateGroup:function(e){var t=this.clone();return void 0!==e&&t.set("name",e),t.resetIDs(),t},sync:MPlaza.syncCloudflare}),MPlaza.TemplateGroups=Backbone.Collection.extend({model:MPlaza.TemplateGroup,sync:MPlaza.syncCloudflare}),MPlaza.AttributeSteps=Backbone.Collection.extend({model:MPlaza.AttributeStep,comparator:function(e){return e.get("displayOrder")},sync:MPlaza.syncCloudflare}),MPlaza.ExtensionField=Backbone.AssociatedModel.extend({defaults:{fieldID:null,name:"",dataTypeID:MPlaza.ExtensionFieldDataType.Integer,operationTypeID:MPlaza.ExtensionFieldOperationType.None,dataTypeName:"",operationTypeName:"",label:"",formatString:""},idAttribute:"fieldID",relations:[],resetIDs:function(){this.unset("fieldID")},url:function(){return null!==this.id?Zakeke.config.baseApiUrl+"extensionFields/"+this.id:Zakeke.config.baseApiUrl+"extensionFields/"},sync:MPlaza.syncCloudflare}),MPlaza.SellerSetting=Backbone.AssociatedModel.extend({defaults:{sellerID:null,minimumFractionDigits:2,isCompositionRecapEnabled:!1,isCompositionRecapVisibleFromStart:!1,canUserCloseCompositionRecap:!1,hotJarSiteID:null,googleTagManagerID:null},idAttribute:"sellerID",relations:[],resetIDs:function(){this.unset("sellerID")},url:function(){return Zakeke.config.baseApiUrl+"sellerSetting/"},sync:MPlaza.syncCloudflare}),MPlaza.ExtensionFields=Backbone.AssociatedModel.extend({model:MPlaza.ExtensionField,url:function(){return Zakeke.config.baseApiUrl+"extensionFields"},sync:MPlaza.syncCloudflare}),MPlaza.DiffuseConfig=Backbone.AssociatedModel.extend({defaults:{enabled:!0,blendMode:"normal",level:1},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.OpacityConfig=Backbone.AssociatedModel.extend({defaults:{enabled:!0},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.MeshDesignGeneralConfig=Backbone.AssociatedModel.extend({defaults:{showDesign:!0,desktopTextureResolutionWidth:null,desktopTextureResolutionHeight:null,mobileTextureResolutionWidth:null,mobileTextureResolutionHeight:null},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.InnerShadowConfig=Backbone.AssociatedModel.extend({defaults:{enabled:!1,color:"#000000",angle:135,distance:2,size:5},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.OuterShadowConfig=Backbone.AssociatedModel.extend({defaults:{enabled:!1,color:"#000000",angle:135,distance:2,size:5},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.NormalmapConfig=Backbone.AssociatedModel.extend({defaults:{showDesign:!0,showOnDesign:!0,showOnMesh:!0,bias:50,invertR:!1,invertG:!1,preBlurEnabled:!1,preBlur:1,postBlurEnabled:!1,postBlur:1,intensity:.5,bevel:!0},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.MeshDesignConfig=Backbone.AssociatedModel.extend({defaults:{general:null,diffuse:null,opacity:null,normalmap:null,innerShadow:null,outerShadow:null},initialize:function(){this.get("general")&&(this.get("general").parentModel=this),this.get("diffuse")&&(this.get("diffuse").parentModel=this),this.get("opacity")&&(this.get("opacity").parentModel=this),this.get("normalmap")&&(this.get("normalmap").parentModel=this),this.get("innerShadow")&&(this.get("innerShadow").parentModel=this),this.get("outerShadow")&&(this.get("outerShadow").parentModel=this)},relations:[{type:Backbone.One,key:"general",relatedModel:MPlaza.MeshDesignGeneralConfig},{type:Backbone.One,key:"diffuse",relatedModel:MPlaza.DiffuseConfig},{type:Backbone.One,key:"opacity",relatedModel:MPlaza.OpacityConfig},{type:Backbone.One,key:"normalmap",relatedModel:MPlaza.NormalmapConfig},{type:Backbone.One,key:"innerShadow",relatedModel:MPlaza.InnerShadowConfig},{type:Backbone.One,key:"outerShadow",relatedModel:MPlaza.OuterShadowConfig}],getParentModel:function(){return this.parentModel},toString:function(){},getGeneralConfig:function(){return this.get("general")&&this.get("general")instanceof MPlaza.MeshDesignGeneralConfig?this.get("general"):null},getOrCreateGeneralConfig:function(){var e=this.get("general");return e||(e=new MPlaza.MeshDesignGeneralConfig,this.set("general",e)),e},getShowDesign:function(){var e=this.getGeneralConfig();return!e||e.get("showDesign")},setShowDesign:function(e){this.getOrCreateGeneralConfig().set("showDesign",e)},getDesktopTextureResolutionWidth:function(){var e,t=this.getGeneralConfig();return t&&null!==(e=t.get("desktopTextureResolutionWidth"))&&void 0!==e?e:1024},setDesktopTextureResolutionWidth:function(e){this.getOrCreateGeneralConfig().set("desktopTextureResolutionWidth",e)},getDesktopTextureResolutionHeight:function(){var e,t=this.getGeneralConfig();return t&&null!==(e=t.get("desktopTextureResolutionHeight"))&&void 0!==e?e:1024},setDesktopTextureResolutionHeight:function(e){this.getOrCreateGeneralConfig().set("desktopTextureResolutionHeight",e)},getMobileTextureResolutionWidth:function(){var e,t=this.getGeneralConfig();return t&&null!==(e=t.get("mobileTextureResolutionWidth"))&&void 0!==e?e:1024},setMobileTextureResolutionWidth:function(e){this.getOrCreateGeneralConfig().set("mobileTextureResolutionWidth",e)},getMobileTextureResolutionHeight:function(){var e,t=this.getGeneralConfig();return t&&null!==(e=t.get("mobileTextureResolutionHeight"))&&void 0!==e?e:1024},setMobileTextureResolutionHeight:function(e){this.getOrCreateGeneralConfig().set("mobileTextureResolutionHeight",e)},getDiffuseConfig:function(){return this.get("diffuse")&&this.get("diffuse")instanceof MPlaza.DiffuseConfig?this.get("diffuse"):null},getOrCreateDiffuseConfing:function(){var e=this.get("diffuse");return e||(e=new MPlaza.DiffuseConfig,this.set("diffuse",e)),e},getDiffuseEnabled:function(){var e=this.getDiffuseConfig();return!e||e.get("enabled")},setDiffuseEnabled:function(e){this.getOrCreateDiffuseConfing().set("enabled",e)},getDiffuseBlendMode:function(){var e=this.getDiffuseConfig();return e&&e.get("blendMode")?e.get("blendMode"):"normal"},setDiffuseBlendMode:function(e){this.getOrCreateDiffuseConfing().set("blendMode",e)},getDiffuseLevel:function(){var e=this.getDiffuseConfig();return e&&null!=e.get("level")&&null!=e.get("level")?e.get("level"):1},setDiffuseLevel:function(e){this.getOrCreateDiffuseConfing().set("level",e)},getOpacityConfig:function(){return this.get("opacity")&&this.get("opacity")instanceof MPlaza.OpacityConfig?this.get("opacity"):null},getOrCreateOpacityConfig:function(){var e=this.get("opacity");return e||(e=new MPlaza.OpacityConfig,this.set("opacity",e)),e},getOpacityEnabled:function(){var e=this.getOpacityConfig();return!!e&&e.get("enabled")},setOpacityEnabled:function(e){this.getOrCreateOpacityConfig().set("enabled",e)},getNormalmapConfig:function(){return this.get("normalmap")&&this.get("normalmap")instanceof MPlaza.NormalmapConfig?this.get("normalmap"):null},getOrCreateNormalmapConfig:function(){var e=this.get("normalmap");return e||(e=new MPlaza.NormalmapConfig,this.set("normalmap",e)),e},getNormalmapEnabled:function(){var e=this.getNormalmapConfig();return!!e&&e.get("enabled")},setNormalmapEnabled:function(e){this.getOrCreateNormalmapConfig().set("enabled",e)},getInnerShadowConfig:function(){return this.get("innerShadow")&&this.get("innerShadow")instanceof MPlaza.InnerShadowConfig?this.get("innerShadow"):null},getOrCreateInnerShadowConfig:function(){var e=this.get("innerShadow");return e||(e=new MPlaza.InnerShadowConfig,this.set("innerShadow",e)),e},getInnerShadowEnabled:function(){var e=this.getInnerShadowConfig();return!!e&&e.get("enabled")},setInnerShadowEnabled:function(e){this.getOrCreateInnerShadowConfig().set("enabled",e)},getOuterShadowConfig:function(){return this.get("outerShadow")&&this.get("outerShadow")instanceof MPlaza.OuterShadowConfig?this.get("outerShadow"):null},getOrCreateOuterShadowConfig:function(){var e=this.get("outerShadow");return e||(e=new MPlaza.OuterShadowConfig,this.set("outerShadow",e)),e},getOuterShadowEnabled:function(){var e=this.getOuterShadowConfig();return!!e&&e.get("enabled")},setOuterShadowEnabled:function(e){this.getOrCreateOuterShadowConfig().set("enabled",e)},sync:MPlaza.syncCloudflare}),MPlaza.ModelSceneMeshSide=Backbone.AssociatedModel.extend({defaults:{meshID:"",subMeshID:0,sideID:-1,matrix:"",percWidth:1,percHeight:1,uvChannel:0,materialID:null,materialTexture:"",config:null,isResizable:!1},idAttribute:"key",initialize:function(){},relations:[{type:Backbone.One,key:"config",relatedModel:MPlaza.MeshDesignConfig}],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getConfig:function(){return this.get("config")},getOrCreateConfig:function(){var e=this.getConfig();return e||(e=new MPlaza.MeshDesignConfig,this.set("config",e)),e},sync:MPlaza.syncCloudflare}),MPlaza.ModelSceneMeshSides=Backbone.Collection.extend({model:MPlaza.ModelSceneMeshSide,sync:MPlaza.syncCloudflare}),MPlaza.ModelSceneMeshDesignEffect=Backbone.AssociatedModel.extend({defaults:{meshID:"",subMeshID:0,name:"",materialID:null,config:null,isDefault:!1},idAttribute:"effectID",initialize:function(){this.get("effectID")||this.set("effectID",MPlaza.generateUUID())},relations:[{type:Backbone.One,key:"config",relatedModel:MPlaza.MeshDesignConfig}],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getConfig:function(){return this.get("config")},getOrCreateConfig:function(){var e=this.getConfig();return e||(e=new MPlaza.MeshDesignConfig,this.set("config",e)),e},sync:MPlaza.syncCloudflare}),MPlaza.ModelSceneMeshDesignEffects=Backbone.Collection.extend({model:MPlaza.ModelSceneMeshDesignEffect,sync:MPlaza.syncCloudflare}),MPlaza.ModelScene=Backbone.AssociatedModel.extend({defaults:{sceneID:"",isDefault:!1,meshSides:[],meshDesignEffects:[],isResizable:!1},initialize:function(){var e=this;this.get("meshSides").parentModel=this,this.get("meshDesignEffects").parentModel=this,this.get("meshDesignEffects").on("change",function(){e.trigger("change")}),this.get("meshSides").on("change",function(){e.trigger("change")})},relations:[{type:Backbone.Many,key:"meshSides",collectionType:MPlaza.ModelSceneMeshSides},{type:Backbone.Many,key:"meshDesignEffects",collectionType:MPlaza.ModelSceneMeshDesignEffects}],isEffectForMesh:function(e,t,i){var n=this.get("meshDesignEffects");if(n)for(var a=0;a<n.length;a++){var r=n.at(a);if(r.get("meshID")===e&&r.get("subMeshID")===t&&r.get("effectID")===i)return!0}return!1},getMeshDesignEffect:function(e){var t=this.get("meshDesignEffects");if(t)for(var i=0;i<t.length;i++){var n=t.at(i);if(n.get("effectID")===e)return n}return null},getMeshDesignEffects:function(e,t){var i=this.get("meshDesignEffects");if(i)for(var n=0;n<i.length;n++){var a=i.at(n);if(a.get("meshID")==e&&a.get("subMeshID")==t)return a}return null},getDefaultDesignEffect:function(e,t){var i=this.get("meshDesignEffects");if(i)for(var n=0;n<i.length;n++){var a=i.at(n);if(a.get("meshID")==e&&a.get("subMeshID")==t&&a.get("isDefault"))return a}return null},sync:MPlaza.syncCloudflare}),MPlaza.ModelScenes=Backbone.Collection.extend({model:MPlaza.ModelScene,sync:MPlaza.syncCloudflare}),MPlaza.AttributeSelectionScript=function(){this.attributeID=-1,this.selectedValue="",this.actions=[]},MPlaza.DesignPrice=Backbone.AssociatedModel.extend({defaults:{qtyFrom:0,qtyTo:null,price:0,firstColorPrice:null},idAttribute:"priceID",initialize:function(){},relations:[],getPricingID:function(){return this.collection&&this.collection.getPricingID?this.collection.getPricingID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignPrices=Backbone.Collection.extend({model:MPlaza.DesignPrice,getPricingID:function(){return this.parentModel&&this.parentModel.getPricingID?this.parentModel.getPricingID():null},sync:MPlaza.syncCloudflare}),MPlaza.SetupPrice=Backbone.AssociatedModel.extend({defaults:{qtyFrom:0,qtyTo:null,price:0,firstColorPrice:null},idAttribute:"priceID",initialize:function(){},relations:[],getPricingID:function(){return this.collection&&this.collection.getPricingID?this.collection.getPricingID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.SetupPrices=Backbone.Collection.extend({model:MPlaza.SetupPrice,getPricingID:function(){return this.parentModel&&this.parentModel.getPricingID?this.parentModel.getPricingID():null},sync:MPlaza.syncCloudflare}),MPlaza.Pricing=Backbone.AssociatedModel.extend({defaults:{setupPriceTypeID:MPlaza.PricingType.Global,designPriceTypeID:MPlaza.PricingType.Global,setupPrices:[],designPrices:[]},idAttribute:"pricingID",initialize:function(){var e=this;this.get("setupPrices").parentModel=this,this.get("designPrices").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("setupPrices").on("add",function(){e._fireEvent("change")}),this.get("setupPrices").on("remove",function(){e._fireEvent("change")}),this.get("setupPrices").on("change",function(){e._fireEvent("change")}),this.get("designPrices").on("add",function(){e._fireEvent("change")}),this.get("designPrices").on("remove",function(){e._fireEvent("change")}),this.get("designPrices").on("change",function(){e._fireEvent("change")})},_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},relations:[{type:Backbone.Many,key:"setupPrices",collectionType:MPlaza.SetupPrices},{type:Backbone.Many,key:"designPrices",collectionType:MPlaza.DesignPrices}],url:function(){var e=Zakeke.config.baseApiUrl+"pricings";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},getPricingID:function(){return this.get("pricingID")},toString:function(){},getSetupPriceForQuantity:function(e){for(var t=0;t<this.get("setupPrices").length;t++){var i=this.get("setupPrices").at(t);if(i.get("qtyFrom")<=e&&(!i.get("qtyTo")||e<i.get("qtyTo")))return i}return null},getDesignPriceForQuantity:function(e){for(var t=0;t<this.get("designPrices").length;t++){var i=this.get("designPrices").at(t);if(i.get("qtyFrom")<=e&&(!i.get("qtyTo")||e<i.get("qtyTo")))return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.Pricings=Backbone.Collection.extend({model:MPlaza.Pricing,url:function(){return Zakeke.config.baseApiUrl+"pricings"},getPricing:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("pricingID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameterValue=Backbone.AssociatedModel.extend({defaults:{},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{name:this.get("name"),value:this.get("value")}},copyAttributes:function(e){this.set("name",e.get("name")),this.set("value",e.get("value"))},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameterValues=Backbone.Collection.extend({model:MPlaza.ImageEffectParameterValue,getValue:function(e){for(var t=0;t<this.length;t++)if(this.at(t).get("name").toLowerCase()===e.toLowerCase())return this.at(t).get("value")},getValueNumber:function(e){var t=this.getValue(e);if(t)return Number(t)},getValueInt:function(e){var t=this.getValue(e);if(t)return parseInt(t)},getValueFloat:function(e){var t=this.getValue(e);if(t)return parseFloat(t)},getValueBoolean:function(e){var t=this.getValue(e);if(t)return"true"===t.toLowerCase()},sync:MPlaza.syncCloudflare}),MPlaza.DesignEffect=Backbone.AssociatedModel.extend({defaults:{blendMode:"normal",enhancedBlendMode:!1,opacity:1,textColor:null,imageEffectTypeName:null,imageEffectParameterValues:[]},initialize:function(){this.get("imageEffectParameterValues").parentModel=this},relations:[{type:Backbone.Many,key:"imageEffectParameterValues",collectionType:MPlaza.ImageEffectParameterValues}],sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameterOption=Backbone.AssociatedModel.extend({defaults:{},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{nameKey:this.get("nameKey"),value:this.get("value")}},copyAttributes:function(e){this.set("nameKey",e.get("nameKey")),this.set("value",e.get("value"))},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameterOptions=Backbone.Collection.extend({model:MPlaza.ImageEffectParameterOption,sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameter=Backbone.AssociatedModel.extend({defaults:{name:"",options:[]},initialize:function(){},relations:[{type:Backbone.Many,key:"options",collectionType:MPlaza.ImageEffectParameterOptions}],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{name:this.get("name"),labelKey:this.get("labelKey"),type:this.get("type"),min:this.get("min"),max:this.get("max"),step:this.get("step"),required:this.get("required"),defaultValue:this.get("defaultValue"),displayOrder:this.get("displayOrder"),options:this.get("options").toJSON()}},copyAttributes:function(e){this.set("name",e.get("name")),this.set("labelKey",e.get("labelKey")),this.set("type",e.get("type")),this.set("min",e.get("min")),this.set("max",e.get("max")),this.set("step",e.get("step")),this.set("required",e.get("required")),this.set("defaultValue",e.get("defaultValue")),this.set("displayOrder",e.get("displayOrder"));for(var t=[],i=0;i<e.get("options").length;i++){var n=e.get("options").at(i),a=new MPlaza.ImageEffectParameterOption;a.copyAttributes(n),t.push(a)}this.set("options",t)},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectParameters=Backbone.Collection.extend({model:MPlaza.ImageEffectParameter,sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectType=Backbone.AssociatedModel.extend({defaults:{name:"",parameters:[]},idAttribute:"imageEffectTypeID",initialize:function(){this.get("parameters").parentModel=this},relations:[{type:Backbone.Many,key:"parameters",collectionType:MPlaza.ImageEffectParameters}],url:function(){var e=Zakeke.config.baseApiUrl+"imageeffects/types";return void 0!==this.id&&null!==this.id&&this.id>0&&(e=e+"/"+this.id),e},getImageEffectTypeID:function(){return this.get("imageEffectTypeID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ImageEffectTypes=Backbone.Collection.extend({model:MPlaza.ImageEffectType,url:function(){return Zakeke.config.baseApiUrl+"imageeffects/types"},sync:MPlaza.syncCloudflare}),MPlaza.PrintTypeFont=Backbone.AssociatedModel.extend({defaults:{printTypeID:-1,fontFamilyID:-1,fontFamilyName:null},idAttribute:"fontFamilyID",initialize:function(){},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.PrintTypeFonts=Backbone.Collection.extend({model:MPlaza.PrintTypeFont,getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getFont:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("fontFamilyID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.PartPrintTypeRestriction=Backbone.AssociatedModel.extend({defaults:{disableTextColors:null,textColors:null,disableSellerImages:null,disableUserImages:null,useImagesFixedSize:null,canAddText:null,canChangeSvgColors:null,canUseImageFilters:null,uploadRestrictions:null,canIgnoreDPIWarning:null,canPreviewDesignsPDF:null,useCustomFonts:null,defaultFontFamilyID:null,fonts:[],showLayerButtons:null,showDuplicateButton:null,showFlipButtons:null,showImageProvider:null,canUseTextArt:null,imageEditingToolSettingsToExclude:null,imageInsertScalingUpload:null,imageInsertScalingCliparts:null,allowTextStroke:null,minTextStrokeWidth:null,maxTextStrokeWidth:null,canStretchImages:null},idAttribute:"partPrintTypeRestrictionID",initialize:function(){var e=this;this.get("fonts").url=function(){return e.url()+"/fonts"},this.get("fonts").parentModel=this},relations:[{type:Backbone.Many,key:"fonts",collectionType:MPlaza.PrintTypeFonts}],url:function(){var e=Zakeke.config.baseApiUrl+"partPrintTypeRestrictions";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getPartPrintTypeRestrictionID:function(){return this.get("partPrintTypeRestrictionID")},getParentModel:function(){return this.parentModel?this.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.PartPrintTypeOutputSettings=Backbone.AssociatedModel.extend({defaults:{width:0,height:0,partPrintTypeOutputSettingsID:-1,rows:0,columns:0,marginH:0,marginV:0,rotation:0,flowDirectionH:1,flowDirectionV:1,flowDirectionPriority:1},idAttribute:"partPrintTypeOutputSettingsID",sync:MPlaza.syncCloudflare}),MPlaza.PartPrintType=Backbone.AssociatedModel.extend({defaults:{isEnabled:!0,pricingID:-1,patID:MPlaza.PricingApplicationType.Global,partPrintTypeRestrictionID:null,dpi:null,restrictions:null,outputSettings:null},idAttribute:"printTypeID",initialize:function(){this.get("restrictions")&&(this.get("restrictions").parentModel=this),this.get("outputSettings")&&(this.get("outputSettings").parentModel=this)},relations:[{type:Backbone.One,key:"restrictions",relatedModel:MPlaza.PartPrintTypeRestriction},{type:Backbone.One,key:"outputSettings",relatedModel:MPlaza.PartPrintTypeOutputSettings}],url:function(){var e=Zakeke.config.baseApiUrl+"partprintTypes";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getPrintTypeID:function(){return this.get("printTypeID")},toString:function(){},setRestrictions:function(e){this.set("restrictions",e),e&&(this.get("restrictions").parentModel=this)},setOutputSettings:function(e){this.set("outputSettings",e),e&&(this.get("outputSettings").parentModel=this)},sync:MPlaza.syncCloudflare}),MPlaza.PartPrintTypes=Backbone.Collection.extend({model:MPlaza.PartPrintType,url:function(){return Zakeke.config.baseApiUrl+"partprinttypes"},getPrintType:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.AreaLayer=Backbone.AssociatedModel.extend({defaults:{name:"",json:"",svg:"",displayOrder:0,isVisibleInCanvas:!0,isVisibleInCart:!0,isVisibleInOutput:!0,showLabel:!0,isClipMask:!1},idAttribute:"layerID",initialize:function(){this.get("layerID")||this.set("layerID",MPlaza.generateUUID())},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.collection&&this.collection.getColorID?this.collection.getColorID():null},getSideID:function(){return this.collection&&this.collection.getSideID?this.collection.getSideID():null},getAreaID:function(){return this.collection&&this.collection.getAreaID?this.collection.getAreaID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getArea:function(){return this.getParentModel()},getSide:function(){var e=this.getArea();return e&&e instanceof MPlaza.Area?e.getSide():null},getColor:function(){var e=this.getSide();return e&&e instanceof MPlaza.Side?e.getParentModel():null},getModel:function(){var e=this.getColor();return e&&e instanceof MPlaza.Color?e.getParentModel():null},sync:MPlaza.syncCloudflare}),MPlaza.AreaLayers=Backbone.Collection.extend({model:MPlaza.AreaLayer,getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID?this.parentModel.getColorID():null},getSideID:function(){return this.parentModel&&this.parentModel.getSideID?this.parentModel.getSideID():null},getAreaID:function(){return this.parentModel&&this.parentModel.getAreaID?this.parentModel.getAreaID():null},sync:MPlaza.syncCloudflare}),MPlaza.AreaTextConstraints=Backbone.AssociatedModel.extend({defaults:{maxNumItems:-1,maxNumChars:-1,fitArea:!1,canMove:!0,canResize:!0,canRotate:!0,fixedDirection:0},initialize:function(){},url:function(){return""},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.AreaTemplateFile=Backbone.AssociatedModel.extend({defaults:{fileID:"",fileUrl:""},initialize:function(){},url:function(){return""},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.Area=Backbone.AssociatedModel.extend({defaults:{guid:"",name:"",path:"",pathSVG:"",boundsX:0,boundsY:0,boundsWidth:0,boundsHeight:0,clipOut:!0,screenPPI:0,textConstraints:null,templateFile:null,printTypes:[],layers:[]},idAttribute:"areaID",relations:[{type:Backbone.One,key:"textConstraints",relatedModel:MPlaza.AreaTextConstraints},{type:Backbone.One,key:"templateFile",relatedModel:MPlaza.AreaTemplateFile},{type:Backbone.Many,key:"printTypes",collectionType:MPlaza.PartPrintTypes},{type:Backbone.Many,key:"layers",collectionType:MPlaza.AreaLayers}],initialize:function(){this.get("guid")||this.set("guid",MPlaza.generateUUID()),this.get("textConstraints")&&(this.get("textConstraints").parentModel=this),this.get("templateFile")&&(this.get("templateFile").parentModel=this),this.get("layers")&&(this.get("layers").parentModel=this)},url:function(){var e=Zakeke.config.baseApiUrl+"areas";return this.collection&&this.collection.url&&(e=this.collection.url()),this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.collection&&this.collection.getColorID?this.collection.getColorID():null},getSideID:function(){return this.collection&&this.collection.getSideID?this.collection.getSideID():null},getAreaID:function(){return this.get("areaID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getPrintType:function(e){for(var t=0;t<this.get("printTypes").length;t++){var i=this.get("printTypes").at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},getSide:function(){return this.getParentModel()},getColor:function(){var e=this.getParentModel();return e&&e instanceof MPlaza.Side?e.getParentModel():null},getModel:function(){var e=this.getParentModel();if(e&&e instanceof MPlaza.Side){var t=e.getParentModel();if(t&&t instanceof MPlaza.Color)return t.getParentModel()}return null},sync:MPlaza.syncCloudflare}),MPlaza.Areas=Backbone.Collection.extend({model:MPlaza.Area,getArea:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("guid")==e)return i}return null},getAreaByID:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("areaID")==e)return i}return null},getMaxArea:function(){for(var e=0,t=null,i=0;i<this.length;i++){var n=this.at(i),a=new paper.Rectangle(n.get("boundsX"),n.get("boundsY"),n.get("boundsWidth"),n.get("boundsHeight")).area;e<a&&(e=a,t=n)}return t},url:function(){return Zakeke.config.baseApiUrl+"areas"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID?this.parentModel.getColorID():null},getSideID:function(){return this.parentModel&&this.parentModel.getSideID?this.parentModel.getSideID():null},sync:MPlaza.syncCloudflare}),MPlaza.Side=Backbone.AssociatedModel.extend({defaults:{name:"",code:"",ppcm:0,tempImageFileKey:"",imageUrl:"",colorable:!1,sortOrder:null,isDefault:!1,printTypes:[],areas:[],cameraLocationID:null},idAttribute:"sideID",initialize:function(){var e=this;this.get("areas").url=function(){return e.url()+"/areas"},this.get("areas").parentModel=this},relations:[{type:Backbone.Many,key:"areas",collectionType:MPlaza.Areas},{type:Backbone.Many,key:"printTypes",collectionType:MPlaza.PartPrintTypes}],url:function(){var e=Zakeke.config.baseApiUrl+"sides";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.collection&&this.collection.getColorID?this.collection.getColorID():null},getSideID:function(){return this.get("sideID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},findAreaByID:function(e){var t=this.get("areas");return t?t.findWhere({areaID:e}):null},findAreaByGuid:function(e){var t=this.get("areas");return t?t.findWhere({guid:e}):null},getPrintType:function(e){for(var t=0;t<this.get("printTypes").length;t++){var i=this.get("printTypes").at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},toString:function(){},getColor:function(){return this.getParentModel()},getModel:function(){var e=this.getParentModel();return e&&e instanceof MPlaza.Color?e.getParentModel():null},sync:MPlaza.syncCloudflare}),MPlaza.Sides=Backbone.Collection.extend({model:MPlaza.Side,url:function(){return Zakeke.config.baseApiUrl+"sides"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID?this.parentModel.getColorID():null},getSide:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("sideID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.CompliantColor=Backbone.AssociatedModel.extend({defaults:{},idAttribute:"colorCode",url:function(){var e=Zakeke.config.baseApiUrl+"compliantColors";return this.collection&&this.collection.url&&(e=this.collection.url()),this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){if(this.collection&&this.collection.getModelID)return this.collection.getModelID()},getColorID:function(){if(this.collection&&this.collection.getColorID)return this.collection.getColorID()},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.CompliantColors=Backbone.Collection.extend({model:MPlaza.CompliantColor,getCompliantColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorCode")==e)return i}return null},url:function(){return Zakeke.config.baseApiUrl+"compliantColors"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID()?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID()?this.parentModel.getColorID():null},sync:MPlaza.syncCloudflare}),MPlaza.Size=Backbone.AssociatedModel.extend({defaults:{name:"",genre:""},idAttribute:"sizeID",url:function(){var e=Zakeke.config.baseApiUrl+"sizes";return this.collection&&this.collection.url&&(e=this.collection.url()),this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){if(this.collection&&this.collection.getModelID)return this.collection.getModelID()},getColorID:function(){if(this.collection&&this.collection.getColorID)return this.collection.getColorID()},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.Sizes=Backbone.Collection.extend({model:MPlaza.Size,getSize:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("sizeID")==e)return i}return null},url:function(){return Zakeke.config.baseApiUrl+"sizes"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getColorID:function(){return this.parentModel&&this.parentModel.getColorID?this.parentModel.getColorID():null},sync:MPlaza.syncCloudflare}),MPlaza.Color=Backbone.AssociatedModel.extend({defaults:{name:"",colorCode:"",colorHexCode:"",code:"",colorProviderCode:"",imageUrl:"",showSideImage:!1,position:0,sizes:[],compliantColors:[],printTypes:[],sides:[]},idAttribute:"colorID",initialize:function(){var e=this;this.get("sizes").url=function(){return e.url()+"/sizes"},this.get("compliantColors").url=function(){return e.url()+"/compliantColors"},this.get("sides").url=function(){return e.url()+"/sides"},this.get("sizes").parentModel=this,this.get("compliantColors").parentModel=this,this.get("sides").parentModel=this},relations:[{type:Backbone.Many,key:"sizes",collectionType:MPlaza.Sizes},{type:Backbone.Many,key:"compliantColors",collectionType:MPlaza.CompliantColors},{type:Backbone.Many,key:"sides",collectionType:MPlaza.Sides},{type:Backbone.Many,key:"printTypes",collectionType:MPlaza.PartPrintTypes}],url:function(){var e=Zakeke.config.baseApiUrl+"colors";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.get("colorID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},findSize:function(e){var t=this.get("sizes");return t?t.findWhere({sizeID:e}):null},findCompliantColor:function(e){return this.get("compliantColors")?sizes.findWhere({colorCode:e}):null},findSide:function(e){var t=this.get("sides");return t?t.findWhere({sideID:e}):null},getAreaWithGuid:function(e){for(var t=this.get("sides"),i=0;i<t.length;i++){var n=t.at(i).getArea(e);if(n)return n}return null},getPrintType:function(e){for(var t=0;t<this.get("printTypes").length;t++){var i=this.get("printTypes").at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},toString:function(){},getModel:function(){return this.getParentModel()},sync:MPlaza.syncCloudflare}),MPlaza.Colors=Backbone.Collection.extend({model:MPlaza.Color,url:function(){return Zakeke.config.baseApiUrl+"colors"},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},comparator:function(e){return e.get("position")},sync:MPlaza.syncCloudflare}),MPlaza.PrintType=Backbone.AssociatedModel.extend({defaults:{name:"",dpi:300,printTypeDPI:0,priceDeltaPerc:0,priceDeltaValue:0,price:0,textBasePrice:0,imageBasePrice:0,pricingID:-1,patID:MPlaza.PricingApplicationType.Global,disableTextColors:null,disableImageColors:null,disableSellerImages:null,disableUserImages:null,useImagesFixedSize:null,textColors:null,imageColors:null,canAddText:null,canChangeSvgColors:null,canUseImageFilters:null,uploadRestrictions:null,canIgnoreDPIWarning:null,useCustomFonts:null,printTypeFonts:[],printTypeDefaultFontFamilyID:null,fonts:[],defaultFontFamilyID:null,pantoneEnabled:!1,canPreviewDesignsPDF:null,outputTypeID:1,outputSettings:null,showLayerButtons:null,showDuplicateButton:null,showFlipButtons:null,showImageProvider:null,canUseTextArt:null,imageEditingToolSettingsToExclude:null,printTypeRestrictionsID:null,printTypeRestrictions:null,previewDesignEffect:null,outputDesignEffect:null,maxColors:null,paletteID:null,paletteColors:[],splitColorFiles:!1,layeredPdf:!1},idAttribute:"printTypeID",initialize:function(){var e=this;this.get("printTypeFonts").url=function(){return e.url()+"/printtypefonts"},this.get("fonts").url=function(){return e.url()+"/fonts"},this.get("printTypeFonts").parentModel=this,this.get("fonts").parentModel=this,this.get("printTypeRestrictions")&&(this.get("printTypeRestrictions").parentModel=this)},relations:[{type:Backbone.One,key:"printTypeRestrictions",relatedModel:MPlaza.PartPrintTypeRestriction},{type:Backbone.Many,key:"printTypeFonts",collectionType:MPlaza.PrintTypeFonts},{type:Backbone.Many,key:"fonts",collectionType:MPlaza.PrintTypeFonts},{type:Backbone.One,key:"outputSettings",relatedModel:MPlaza.PartPrintTypeOutputSettings},{type:Backbone.One,key:"previewDesignEffect",relatedModel:MPlaza.DesignEffect},{type:Backbone.One,key:"outputDesignEffect",relatedModel:MPlaza.DesignEffect}],url:function(){var e=Zakeke.config.baseApiUrl+"printTypes";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getPrintTypeID:function(){return this.get("printTypeID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},setOutputSettings:function(e){this.set("outputSettings",e),e&&(this.get("outputSettings").parentModel=this)},sync:MPlaza.syncCloudflare}),MPlaza.PrintTypes=Backbone.Collection.extend({model:MPlaza.PrintType,url:function(){return Zakeke.config.baseApiUrl+"printtypes"},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},getPrintType:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("printTypeID")>0?i.get("printTypeID")===e:i.tempID&&i.tempID===e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.OptionsItem=Backbone.AssociatedModel.extend({defaults:{optionId:-1,modelID:-1,colorID:-1,sideID:null,optionsData:{}},idAttribute:"optionId",initialize:function(){},relations:[],getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getColorID:function(){return this.get("colorID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},getModel:function(){return this.getParentModel()},sync:MPlaza.syncCloudflare}),MPlaza.ModelOptions=Backbone.Collection.extend({model:MPlaza.OptionsItem,url:function(){return Zakeke.config.baseApiUrl+"options"},getModelID:function(){return this.parentModel?this.parentModel.getModelID():null},sync:MPlaza.syncCloudflare}),MPlaza.PreviewColor=Backbone.AssociatedModel.extend({defaults:{color:"",hasTexture:!1,textureUrl:"",tempTextureFileKey:"",isCustomTexture:!1,refractionMode:null,reflectivity:null,opacity:null,opacityAffectCustomization:null,textureWidth:null,textureHeight:null,itemsPositionX:null,itemsPositionY:null,itemsScaleX:null,itemsScaleY:null},idAttribute:"colorID",initialize:function(){},url:function(){var e=Zakeke.config.baseApiUrl+"previewcolors";return this.collection&&this.collection.url&&(e=this.collection.url()),this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getPreviewModelID:function(){return this.collection&&this.collection.getPreviewModelID?this.collection.getPreviewModelID():null},getPartID:function(){return this.collection&&this.collection.getPartID?this.collection.getPartID():null},getColorID:function(){return this.get("colorID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.PreviewColors=Backbone.Collection.extend({model:MPlaza.PreviewColor,getPreviewColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},url:function(){return Zakeke.config.baseApiUrl+"previewcolors"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getPreviewModelID:function(){return this.parentModel&&this.parentModel.getPreviewModelID?this.parentModel.getPreviewModelID():null},getPartID:function(){return this.parentModel&&this.parentModel.getPartID?this.parentModel.getPartID():null},sync:MPlaza.syncCloudflare}),MPlaza.PreviewPart=Backbone.AssociatedModel.extend({defaults:{materialIndex:-1,sideID:-1,color:"",hasTexture:!1,textureWidth:0,textureHeight:0,textureUrl:"",tempTextureFileKey:"",reflectivity:0,opacity:1,opacityAffectCustomization:!0,itemsPositionX:0,itemsPositionY:0,itemsScaleX:0,itemsScaleY:0,refractionMode:!1,colors:[]},idAttribute:"partID",initialize:function(){var e=this;this.get("colors").url=function(){return e.url()+"/previewcolors"},this.get("colors").parentModel=this},relations:[{type:Backbone.Many,key:"colors",collectionType:MPlaza.PreviewColors}],url:function(){var e=Zakeke.config.baseApiUrl+"previewparts";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getPreviewModelID:function(){return this.collection&&this.collection.getPreviewModelID?this.collection.getPreviewModelID():null},getPartID:function(){return this.get("partID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},findColor:function(e){var t=this.get("colors");return t?t.findWhere({colorID:e}):null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.PreviewParts=Backbone.Collection.extend({model:MPlaza.PreviewPart,url:function(){return Zakeke.config.baseApiUrl+"previewparts"},getModelID:function(){return this.parentModel&&this.parentModel.getModelID?this.parentModel.getModelID():null},getPreviewModelID:function(){return this.parentModel&&this.parentModel.getPreviewModelID?this.parentModel.getPreviewModelID():null},getPreviewPart:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("partID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.PreviewModel=Backbone.AssociatedModel.extend({defaults:{backface:!1,scale:1,tempModel3DFileKey:"",model3DUrl:"",parts:[]},idAttribute:"modelID",initialize:function(){var e=this;this.get("parts").url=function(){return e.url()+"/previewparts"},this.get("parts").parentModel=this},relations:[{type:Backbone.Many,key:"parts",collectionType:MPlaza.PreviewParts}],url:function(){var e=Zakeke.config.baseApiUrl+"previewmodels";return this.collection&&this.collection.url&&(e=this.collection.url()),null!=this.id&&null!=this.id&&this.id>=0&&(e=e+"/"+this.id),e},getModelID:function(){return this.collection&&this.collection.getModelID?this.collection.getModelID():null},getPreviewModelID:function(){return this.get("modelID")},getParentModel:function(){return this.parentModel?this.parentModel:null},findPart:function(e){var t=this.get("parts");return t?t.findWhere({partID:e}):null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.QuantityRule=Backbone.AssociatedModel.extend({defaults:{minQuantity:null,maxQuantity:null,step:null},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptionMaterialAction=Backbone.AssociatedModel.extend({defaults:{actionGuid:"",meshID:""},initialize:function(){},relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptionMaterialActions=Backbone.Collection.extend({model:MPlaza.VariantOptionMaterialAction,getActionForMesh(e){for(var t=0;t<this.length;t++)if(this.at(t).get("meshID")===e)return this.at(t);return null},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptionMaterial=Backbone.AssociatedModel.extend({defaults:{optionMaterialID:"",variableMaterialID:"",actions:[]},initialize:function(){this.get("actions").parentModel=this},relations:[{type:Backbone.Many,key:"actions",collectionType:MPlaza.VariantOptionMaterialActions}],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptionMaterials=Backbone.Collection.extend({model:MPlaza.VariantOptionMaterial,sync:MPlaza.syncCloudflare}),MPlaza.VariantOption=Backbone.AssociatedModel.extend({defaults:{variantID:"",optionGuid:"",materials:[],meshes:[]},initialize:function(){this.get("materials").parentModel=this},relations:[{type:Backbone.Many,key:"materials",collectionType:MPlaza.VariantOptionMaterials}],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.VariantOptions=Backbone.Collection.extend({model:MPlaza.VariantOption,getVariantOption(e){for(var t=0;t<this.length;t++)if(this.at(t).get("variantID")===e)return this.at(t);return null},sync:MPlaza.syncCloudflare}),MPlaza.VariableMaterial=Backbone.AssociatedModel.extend({defaults:{materialID:"",meshes:[]},initialize:function(){},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.VariableMaterials=Backbone.Collection.extend({model:MPlaza.VariableMaterial,getVariableMaterial(e){for(var t=0;t<this.length;t++)if(this.at(t).get("materialID")===e)return this.at(t);return null},sync:MPlaza.syncCloudflare}),MPlaza.VariantsAttributeOptions=Backbone.AssociatedModel.extend({defaults:{attributeGuid:"",variableMaterials:[],variantOptions:[]},initialize:function(){this.get("variableMaterials").parentModel=this,this.get("variantOptions").parentModel=this},relations:[{type:Backbone.Many,key:"variableMaterials",collectionType:MPlaza.VariableMaterials},{type:Backbone.Many,key:"variantOptions",collectionType:MPlaza.VariantOptions}],getParentModel:function(){return this.parentModel?this.parentModel:null},getOptionsMaterialIDs:function(){for(var e=[],t=0;t<this.get("variantOptions").length;t++)for(var i=this.get("variantOptions").at(t),n=0;n<i.get("materials").length;n++){var a=i.get("materials").at(n).get("optionMaterialID");-1===e.indexOf(a)&&e.push(a)}return e},setVariableMaterial:function(e,t){var i=this.get("variableMaterials").getVariableMaterial(e);i||((i=new MPlaza.VariableMaterial).set("materialID",e),this.get("variableMaterials").push(i)),i.set("meshes",t)},removeVariableMaterial:function(e){var t=this.get("variableMaterials").getVariableMaterial(e);t&&this.get("variableMaterials").remove(t)},getVariantOption:function(e){return this.get("variantOptions").getVariantOption(e)},sync:MPlaza.syncCloudflare}),MPlaza.Preview3D=Backbone.AssociatedModel.extend({defaults:{variantsAttributeOptions:null},initialize:function(){this.get("variantsAttributeOptions")&&(this.get("variantsAttributeOptions").parentModel=this)},relations:[{type:Backbone.One,key:"variantsAttributeOptions",relatedModel:MPlaza.VariantsAttributeOptions}],getParentModel:function(){return this.parentModel?this.parentModel:null},getVariantsAttributeOptions:function(){return this.get("variantsAttributeOptions")},getOrCreateVariantsAttributeOptions:function(){var e=this.getVariantsAttributeOptions();return e||(e=new MPlaza.VariantsAttributeOptions,this.set("variantsAttributeOptions",e)),e},sync:MPlaza.syncCloudflare}),MPlaza.Model=Backbone.AssociatedModel.extend({defaults:{name:"",description:"",code:"",statusID:1,tempSmallImageFileKey:"",smallImageUrl:"",tempLargeImageFileKey:"",largeImageUrl:"",price:0,variantIconCode:"",variantTypeName:"",pricingModelID:MPlaza.PricingModel.Simple,defaultDesignTemplateID:-1,loadFirstDesignTemplate:!1,showTemplateSelection:!1,printTypes:[],colors:[],options:[],preview3D:null,previewModel:null,pricings:[],composerPricings:[],scenes:[],attributeGroups:[],templateGroups:[],attributeSteps:[],attributes:[],attributeSelectionColors:[],backgroundColorRules:null,areaBackgroundRules:null,quoteRule:null,quantityRule:null,hasAdditionalFeeOnImagesProvider:!1,isShowSecondScreenEnabled:!1,environment:1},idAttribute:"modelID",_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},removeEventListener:function(e){this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&delete this._eventListeners[e]},initialize:function(){var e=this;this.get("printTypes").url=function(){return e.url()+"/printTypes"},this.get("colors").url=function(){return e.url()+"/colors"},this.get("options").url=function(){return e.url()+"/options"},this.get("printTypes").parentModel=this,this.get("colors").parentModel=this,this.get("options").parentModel=this,this.get("preview3D")&&(this.get("preview3D").parentModel=this),this.get("previewModel")&&(this.get("previewModel").parentModel=this),this.get("scenes").parentModel=this,this.get("attributeGroups").parentModel=this,this.get("templateGroups").parentModel=this,this.get("attributeSteps").parentModel=this,this.get("attributes").parentModel=this,this.get("attributeSelectionColors").parentModel=this,this.on("change",function(e){e.trigger("change")}),this.get("printTypes").on("change",function(){e._fireEvent("change")}),this.get("colors").on("change",function(){e._fireEvent("change")}),this.get("options").on("change",function(){e._fireEvent("change")}),this.get("scenes").on("change",function(){e._fireEvent("change")}),this.get("attributeGroups").on("change",function(){e._fireEvent("change")}),this.get("templateGroups").on("change",function(){e._fireEvent("change")}),this.get("attributeSteps").on("change",function(){e._fireEvent("change")}),this.get("attributes").on("change",function(){e._fireEvent("change")}),this.get("attributeSelectionColors").on("change",function(){e._fireEvent("change")}),this.get("pricings").on("change",function(){e._fireEvent("change")})},relations:[{type:Backbone.One,key:"preview3D",relatedModel:MPlaza.Preview3D},{type:Backbone.One,key:"previewModel",relatedModel:MPlaza.PreviewModel},{type:Backbone.One,key:"quantityRule",relatedModel:MPlaza.QuantityRule},{type:Backbone.Many,key:"printTypes",collectionType:MPlaza.PrintTypes},{type:Backbone.Many,key:"options",collectionType:MPlaza.ModelOptions},{type:Backbone.Many,key:"colors",collectionType:MPlaza.Colors},{type:Backbone.Many,key:"pricings",collectionType:MPlaza.Pricings},{type:Backbone.Many,key:"composerPricings",collectionType:MPlaza.ComposerPricings},{type:Backbone.Many,key:"scenes",collectionType:MPlaza.ModelScenes},{type:Backbone.Many,key:"attributeGroups",collectionType:MPlaza.AttributeGroups},{type:Backbone.Many,key:"templateGroups",collectionType:MPlaza.TemplateGroups},{type:Backbone.Many,key:"attributeSteps",collectionType:MPlaza.AttributeSteps},{type:Backbone.Many,key:"attributes",collectionType:MPlaza.Attributes},{type:Backbone.Many,key:"attributeSelectionColors",collectionType:MPlaza.AttributeSelectionColors}],url:function(){var e=Zakeke.config.baseApiUrl+"models";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},getModelID:function(){return this.get("modelID")},toString:function(){},getPreview3D:function(){return this.get("preview3D")},getOrCreatePreview3D:function(){var e=this.getPreview3D();return e||(e=new MPlaza.Preview3D,this.set("preview3D",e)),e},getModelPriceDeltaPerc:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("priceDeltaPerc")}return 0},getModelPriceDeltaValue:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("priceDeltaValue")}return 0},getModelPrice:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("price")}return 0},getModelTextBasePrice:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("textBasePrice")}return 0},getModelImageBasePrice:function(e){var t=this.get("printTypes");if(t){var i=t.getPrintType(e);if(i)return i.get("imageBasePrice")}return 0},getPrintType:function(e){var t=this.get("printTypes");return t?t.getPrintType(e):null},getDefaultSceneID:function(){for(var e=0;e<this.get("scenes").length;e++){var t=this.get("scenes").at(e);if(t.get("isDefault"))return t.get("sceneID")}return null},getAttributesByGroupID:function(e){for(var t=[],i=0;i<this.get("attributes").length;i++){var n=this.get("attributes").at(i);n.get("groupID")==e&&t.push(n)}return t},getAttributesWithoutGroup:function(){for(var e=[],t=0;t<this.get("attributes").length;t++){var i=this.get("attributes").at(t);i.get("groupID")<=0&&e.push(i)}return e},getTemplateGroupsWithoutGroup:function(){for(var e=[],t=0;t<this.get("templateGroups").length;t++){var i=this.get("templateGroups").at(t);i.get("groupID")<=0&&e.push(i)}return e},getAttribute:function(e){return this.get("attributes").getAttribute(e)},getAttributeByGuid:function(e){return this.get("attributes").getAttributeByGuid(e)},getOption:function(e){for(var t=0;t<this.get("attributes").length;t++){var i=this.get("attributes").at(t).get("options").findWhere({optionID:e});if(i)return i}return null},getOptionByGuid:function(e){for(var t=0;t<this.get("attributes").length;t++){var i=this.get("attributes").at(t).get("options").findWhere({optionGuid:e});if(i)return i}return null},getComposerPricing:function(e){for(var t=0;t<this.get("composerPricings").length;t++){var i=this.get("composerPricings").at(t);if(i.get("pricingID")==e)return i}return null},getModelSide:function(e,t){for(var i=0;i<this.get("colors").length;i++){var n=this.get("colors").at(i);if(n.get("colorID")==e)for(var a=0;a<n.get("sides").length;a++){var r=n.get("sides").at(a);if(r.get("sideID")==t)return r}}return null},getAttributeSelectionColor:function(e){return this.get("attributeSelectionColors").getAttributeSelectionColor(e)},setShowTemplateSelection(e){this.set("showTemplateSelection",e)},sync:MPlaza.syncCloudflare}),MPlaza.Models=Backbone.Collection.extend({model:MPlaza.Model,url:function(){return Zakeke.config.baseApiUrl+"models"},getModel:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("modelID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ColorMapping=Backbone.AssociatedModel.extend({defaults:{src:"",dest:""},initialize:function(){},copyAttributes:function(e){this.set("src",e.get("src")),this.set("dest",e.get("dest"))},toJSON:function(){return{src:this.get("src"),dest:this.get("dest")}},sync:MPlaza.syncCloudflare}),MPlaza.ColorMappings=Backbone.Collection.extend({model:MPlaza.ColorMapping,toJSON:function(){var e=[];return this.forEach(t=>e.push(t.toJSON())),e},sync:MPlaza.syncCloudflare}),MPlaza.ConnectorSetting=Backbone.AssociatedModel.extend({defaults:{key:"",settings:""},initialize:function(){},copyAttributes:function(e){this.set("key",e.get("key")),this.set("settings",e.get("settings"))},toJSON:function(){return{key:this.get("key"),settings:this.get("settings")}},sync:MPlaza.syncCloudflare}),MPlaza.ConnectorSettings=Backbone.Collection.extend({model:MPlaza.ConnectorSetting,toJSON:function(){var e=[];return this.forEach(t=>e.push(t.toJSON())),e},sync:MPlaza.syncCloudflare}),MPlaza.TextArtConfig=Backbone.AssociatedModel.extend({defaults:{},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{angleValue:this.get("angleValue"),curveValue:this.get("curveValue"),intensT:this.get("intensT"),intensB:this.get("intensB"),isTriangle:this.get("isTriangle"),isBridge:this.get("isBridge"),isTop:this.get("isTop"),isBottom:this.get("isBottom"),isMiddle:this.get("isMiddle")}},copyAttributes:function(e){this.set("angleValue",e.get("angleValue")),this.set("curveValue",e.get("curveValue")),this.set("intensT",e.get("intensT")),this.set("intensB",e.get("intensB")),this.set("isTriangle",e.get("isTriangle")),this.set("isBridge",e.get("isBridge")),this.set("isTop",e.get("isTop")),this.set("isBottom",e.get("isBottom")),this.set("isMiddle",e.get("isMiddle"))},sync:MPlaza.syncCloudflare}),MPlaza.TextArtControl=Backbone.AssociatedModel.extend({defaults:{},initialize:function(){},relations:[],getParentModel:function(){return this.parentModel},toString:function(){},toJSON:function(){return{property:this.get("property"),labelKey:this.get("labelKey"),type:this.get("type"),min:this.get("min"),max:this.get("max"),step:this.get("step")}},copyAttributes:function(e){this.set("property",e.get("property")),this.set("labelKey",e.get("labelKey")),this.set("type",e.get("type")),this.set("min",e.get("min")),this.set("max",e.get("max")),this.set("step",e.get("step"))},sync:MPlaza.syncCloudflare}),MPlaza.TextArtControls=Backbone.Collection.extend({model:MPlaza.TextArtControl,sync:MPlaza.syncCloudflare}),MPlaza.TextArtType=Backbone.AssociatedModel.extend({defaults:{name:"",imageUrl:"",config:null,controls:[]},idAttribute:"textArtTypeID",initialize:function(){this.get("controls").parentModel=this,this.get("config")&&(this.get("config").parentModel=this)},relations:[{type:Backbone.One,key:"config",relatedModel:MPlaza.TextArtConfig},{type:Backbone.Many,key:"controls",collectionType:MPlaza.TextArtControls}],url:function(){var e=Zakeke.config.baseApiUrl+"textart/types";return void 0!==this.id&&null!==this.id&&this.id>0&&(e=e+"/"+this.id),e},getTextArtTypeID:function(){return this.get("textArtTypeID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.TextArtTypes=Backbone.Collection.extend({model:MPlaza.TextArtType,url:function(){return Zakeke.config.baseApiUrl+"textart/types"},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemColor=Backbone.AssociatedModel.extend({defaults:{imageID:-1,colorID:-1,colorCode:""},idAttribute:"key",initialize:function(){},getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getDesignItemID:function(){return this.collection&&this.collection.getDesignItemID?this.collection.getDesignItemID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemColors=Backbone.Collection.extend({model:MPlaza.DesignItemColor,getDesignItemColor:function(e,t){for(var i=0;i<this.length;i++){var n=this.at(i);if(n.get("imageID")==e&&n.get("colorID")==t)return n}return null},getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},getDesignItemID:function(){return this.parentModel&&this.parentModel.getDesignItemID?this.parentModel.getDesignItemID():null},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemArea=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,areaID:-1},idAttribute:"id",initialize:function(){},getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getDesignItemID:function(){return this.collection&&this.collection.getDesignItemID?this.collection.getDesignItemID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemAreas=Backbone.Collection.extend({model:MPlaza.DesignItemArea,getDesignItemArea:function(e,t,i,n){for(var a=0;a<this.length;a++){var r=this.at(a);if(r.get("modelID")==e&&r.get("colorID")==t&&r.get("sideID")==i&&r.get("areaID")==n)return r}return null},getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},getDesignItemID:function(){return this.parentModel&&this.parentModel.getDesignItemID?this.parentModel.getDesignItemID():null},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemConstraints=Backbone.AssociatedModel.extend({defaults:{itemID:-1,canMove:!0,canMoveX:!0,canMoveY:!0,canRotate:!0,canResize:!0,canDelete:!0,canEdit:!0,keepNrChars:!1,minNrChars:0,maxNrChars:0,paddingTypeID:MPlaza.PaddingType.Start,paddingString:"",canChangeFontFamily:!0,canChangeFontSize:!0,canChangeFontColor:!0,canChangeFontWeight:!0,canChangeFontItalic:!0,canChangeTextPathMode:!0,canChangeJustification:!0,canTransform:!0,canChangeSvgColors:!0,isAlwaysOnTop:!1,isPrintable:!0,keepInPreview:!0,mandatoryToEdit:!1,canSyncContent:!0,canSyncAlignment:!0,canSyncFontFamily:!0,canSyncFontStyle:!0,canSyncFontColor:!0,canSyncCurved:!0,canSyncTransforms:!1,canResizeTextBox:!0,canChangeTextBoxMode:!0,toUppercase:!1,canChangeTextBoxMode:!0,toUppercase:!1,canAddMask:!0,canReplaceMask:!0,canEditMask:!0,canDeleteMask:!0,canEditMaskedImage:!0,canChangeMaskStrokeColor:!0,canChangeMaskStrokeWidth:!0,canFillShape:!0,canReplaceShapeFilling:!0,canEditShapeFilling:!0,canDeleteShapeFilling:!0,canEditFilledShape:!0,canChangeShapeStrokeColor:!0,canChangeShapeStrokeWidth:!0,canChangeShapeFillColor:!0,canChangeLetterSpacing:!1,minLetterSpacing:null,maxLetterSpacing:null,canChangeLineSpacing:!1,minLineSpacing:null,maxLineSpacing:null,canChangeAdaptText:!0,canWrapTextOnAdaptText:!0,minFontSize:null,maxFontSize:null,canChangeVerticalAlignment:!0,canChangeShadowColor:!0,canChangeShadowBlur:!0,canChangeShadowDistance:!0,canChangeShadowAngle:!0,minShadowBlur:null,maxShadowBlur:null,minShadowDistance:null,maxShadowDistance:null,minShadowAngle:null,maxShadowAngle:null,canChangeTextStrokeColor:!0,canChangeTextStrokeWidth:!0,minTextStrokeWidth:null,maxTextStrokeWidth:null,canStretch:!0},idAttribute:"itemID",initialize:function(){},url:function(){return""},getDesignID:function(){return this.parentModel?this.parentModel.getDesignID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},copyAttributes:function(e){this.set("canMove",e.get("canMove")),this.set("canRotate",e.get("canRotate")),this.set("canResize",e.get("canResize")),this.set("canDelete",e.get("canDelete")),this.set("canEdit",e.get("canEdit")),this.set("keepNrChars",e.get("keepNrChars")),this.set("minNrChars",e.get("minNrChars")),this.set("maxNrChars",e.get("maxNrChars")),this.set("paddingTypeID",e.get("paddingTypeID")),this.set("paddingString",e.get("paddingString")),this.set("canChangeFontFamily",e.get("canChangeFontFamily")),this.set("canChangeFontSize",e.get("canChangeFontSize")),this.set("canChangeFontColor",e.get("canChangeFontColor")),this.set("canChangeFontWeight",e.get("canChangeFontWeight")),this.set("canChangeTextPathMode",e.get("canChangeTextPathMode")),this.set("canChangeJustification",e.get("canChangeJustification")),this.set("canTransform",e.get("canTransform")),this.set("canChangeSvgColors",e.get("canChangeSvgColors")),this.set("isAlwaysOnTop",e.get("isAlwaysOnTop")),this.set("isPrintable",e.get("isPrintable")),this.set("keepInPreview",e.get("keepInPreview")),this.set("mandatoryToEdit",e.get("mandatoryToEdit")),this.set("canSyncContent",e.get("canSyncContent")),this.set("canSyncAlignment",e.get("canSyncAlignment")),this.set("canSyncFontFamily",e.get("canSyncFontFamily")),this.set("canSyncFontStyle",e.get("canSyncFontStyle")),this.set("canSyncFontColor",e.get("canSyncFontColor")),this.set("canSyncCurved",e.get("canSyncCurved")),this.set("canSyncTransforms",e.get("canSyncTransforms")),this.set("canResizeTextBox",e.get("canResizeTextBox")),this.set("canChangeTextBoxMode",e.get("canChangeTextBoxMode")),this.set("toUppercase",e.get("toUppercase")),this.set("canAddMask",e.get("canAddMask")),this.set("canReplaceMask",e.get("canReplaceMask")),this.set("canEditMask",e.get("canEditMask")),this.set("canDeleteMask",e.get("canDeleteMask")),this.set("canEditMaskedImage",e.get("canEditMaskedImage")),this.set("canChangeMaskStrokeColor",e.get("canChangeMaskStrokeColor")),this.set("canChangeMaskStrokeWidth",e.get("canChangeMaskStrokeWidth")),this.set("canFillShape",e.get("canFillShape")),this.set("canReplaceShapeFilling",e.get("canReplaceShapeFilling")),this.set("canEditShapeFilling",e.get("canEditShapeFilling")),this.set("canDeleteShapeFilling",e.get("canDeleteShapeFilling")),this.set("canEditFilledShape",e.get("canEditFilledShape")),this.set("canChangeShapeStrokeColor",e.get("canChangeShapeStrokeColor")),this.set("canChangeShapeStrokeWidth",e.get("canChangeShapeStrokeWidth")),this.set("canChangeShapeFillColor",e.get("canChangeShapeFillColor")),this.set("canChangeLetterSpacing",e.get("canChangeLetterSpacing")),this.set("minLetterSpacing",e.get("minLetterSpacing")),this.set("maxLetterSpacing",e.get("maxLetterSpacing")),this.set("canChangeLineSpacing",e.get("canChangeLineSpacing")),this.set("minLineSpacing",e.get("minLineSpacing")),this.set("canChangeAdaptText",e.get("canChangeAdaptText")),this.set("canWrapTextOnAdaptText",e.get("canWrapTextOnAdaptText")),this.set("minFontSize",e.get("minFontSize")),this.set("maxFontSize",e.get("maxFontSize")),this.set("canChangeVerticalAlignment",e.get("canChangeVerticalAlignment")),this.set("canChangeShadowColor",e.get("canChangeShadowColor")),this.set("canChangeShadowBlur",e.get("canChangeShadowBlur")),this.set("canChangeShadowDistance",e.get("canChangeShadowDistance")),this.set("canChangeShadowAngle",e.get("canChangeShadowAngle")),this.set("minShadowBlur",e.get("minShadowBlur")),this.set("maxShadowBlur",e.get("maxShadowBlur")),this.set("minShadowDistance",e.get("minShadowDistance")),this.set("maxShadowDistance",e.get("maxShadowDistance")),this.set("minShadowAngle",e.get("minShadowAngle")),this.set("maxShadowAngle",e.get("maxShadowAngle")),this.set("canStretch",e.get("canStretch"))},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemTextArt=Backbone.AssociatedModel.extend({defaults:{itemID:-1,text:"",fontFamilyID:-1,fontFaceID:-1,textArtTypeID:-1,config:null},idAttribute:"itemID",initialize:function(){this.get("config")&&(this.get("config").parentModel=this)},relations:[{type:Backbone.One,key:"config",relatedModel:MPlaza.TextArtConfig}],url:function(){return""},getDesignID:function(){return this.parentModel?this.parentModel.getDesignID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},copyAttributes:function(e){if(this.set("text",e.get("text")),this.set("fontFamilyID",e.get("fontFamilyID")),this.set("fontFaceID",e.get("fontFaceID")),this.set("textArtTypeID",e.get("textArtTypeID")),this.unset("config"),e.get("config")){var t=e.get("config"),i=new MPlaza.TextArtConfig;i.set("itemID",this.get("itemID")),i.copyAttributes(t),this.set("config",i)}},sync:MPlaza.syncCloudflare}),MPlaza.DesignItemShape=Backbone.AssociatedModel.extend({defaults:{itemID:-1,shapeID:-1,isMask:!0},idAttribute:"itemID",initialize:function(){},relations:[],url:function(){return""},getDesignID:function(){return this.parentModel?this.parentModel.getDesignID():null},getParentModel:function(){return this.parentModel?this.parentModel:null},toString:function(){},copyAttributes:function(e){this.set("shapeID",e.get("shapeID")),this.set("isMask",e.get("isMask"))},sync:MPlaza.syncCloudflare}),MPlaza.DesignItem=Backbone.AssociatedModel.extend({defaults:{name:"",index:0,json:"",svg:"",imageID:-1,imageType:"",imageFormat:"",imageWidth:0,imageHeight:0,imageDpiX:0,imageDpiY:0,imageFileSize:0,imageCustomerID:-1,imageVisitorID:-1,imagePrice:0,providerImageID:null,applyImagePriceForQuantity:null,imageIsMulticolor:!1,imageContainsRaster:!1,imagePreferredWidth:null,imagePreferredHeight:null,syncGuid:null,isChanged:!0,areas:[],colors:[],constraints:null,textArt:null,shape:null,colorMappings:[],overridePreview:"",connectorSettings:[]},resetColors:function(){this.set("colors",[])},copyAttributes:function(e){if(this.set("index",e.get("index")),this.set("name",e.get("name")),this.set("json",e.get("json")),this.set("svg",e.get("svg")),this.set("imageID",e.get("imageID")),this.set("imageType",e.get("imageType")),this.set("imageFormat",e.get("imageFormat")),this.set("imageWidth",e.get("imageWidth")),this.set("imageHeight",e.get("imageHeight")),this.set("imageDpiX",e.get("imageDpiX")),this.set("imageDpiY",e.get("imageDpiY")),this.set("imageFileSize",e.get("imageFileSize")),this.set("imageCustomerID",e.get("imageCustomerID")),this.set("imageVisitorID",e.get("imageVisitorID")),this.set("imagePrice",e.get("imagePrice")),this.set("applyImagePriceForQuantity",e.get("applyImagePriceForQuantity")),this.set("providerImageID",e.get("providerImageID")),this.set("imageIsMulticolor",e.get("imageIsMulticolor")),this.set("imageContainsRaster",e.get("imageContainsRaster")),this.set("imagePreferredWidth",e.get("imagePreferredWidth")),this.set("imagePreferredHeight",e.get("imagePreferredHeight")),this.set("isChanged",e.get("isChanged")),this.set("itemColors",[]),e.get("itemColors"))for(var t=0;t<e.get("itemColors").length;t++)this.get("itemColors").push(e.get("itemColors")[t]);if(this.unset("colorMappings"),this.set("colorMappings",new MPlaza.ColorMappings),e.get("colorMappings"))for(t=0;t<e.get("colorMappings").length;t++){var i=new MPlaza.ColorMapping;i.copyAttributes(e.get("colorMappings").at(t)),this.get("colorMappings").add(i)}if(this.unset("connectorSettings"),this.set("connectorSettings",new MPlaza.ConnectorSettings),e.get("connectorSettings"))for(t=0;t<e.get("connectorSettings").length;t++){var n=new MPlaza.ConnectorSetting;n.copyAttributes(e.get("connectorSettings").at(t)),this.get("connectorSettings").add(n)}this.set("syncGuid",e.get("syncGuid"));for(t=0;t<e.get("colors").length;t++){var a=e.get("colors").at(t),r=this.get("colors").find(e=>e.get("colorID")==a.get("colorID"));r||(r=new MPlaza.DesignItemColor,this.get("colors").add(r)),r.set("imageID",a.get("imageID")),r.set("colorID",a.get("colorID")),r.set("colorCode",a.get("colorCode"))}if(this.unset("constraints"),e.get("constraints")){var o=e.get("constraints"),s=new MPlaza.DesignItemConstraints;s.set("itemID",this.get("itemID")),s.copyAttributes(o),this.set("constraints",s)}if(this.unset("textArt"),e.get("textArt")){var l=e.get("textArt"),h=new MPlaza.DesignItemTextArt;h.set("itemID",this.get("itemID")),h.copyAttributes(l),this.set("textArt",h)}if(this.unset("shape"),e.get("shape")){var d=e.get("shape"),c=new MPlaza.DesignItemShape;c.set("itemID",this.get("itemID")),c.copyAttributes(d),this.set("shape",c)}},copyConstraints:function(e){if(this.unset("constraints"),e){var t=new MPlaza.DesignItemConstraints;t.set("itemID",this.get("itemID")),t.copyAttributes(e),this.set("constraints",t)}},copyTextArt:function(e){if(this.unset("textArt"),source.get("textArt")){var t=new MPlaza.DesignItemTextArt;t.set("itemID",this.get("itemID")),t.copyAttributes(e),this.set("textArt",t)}},copyShape:function(e){if(this.unset("shape"),source.get("shape")){var t=new MPlaza.DesignItemShape;t.set("itemID",this.get("itemID")),t.copyAttributes(e),this.set("shape",t)}},idAttribute:"itemGuid",initialize:function(){this.get("areas").parentModel=this,this.get("colors").parentModel=this,this.get("constraints")&&(this.get("constraints").parentModel=this),this.get("textArt")&&(this.get("textArt").parentModel=this),this.get("itemGuid")||this.set("itemGuid",MPlaza.generateUUID()),this.get("itemColors")||this.set("itemColors",[])},relations:[{type:Backbone.Many,key:"areas",collectionType:MPlaza.DesignItemAreas},{type:Backbone.Many,key:"colors",collectionType:MPlaza.DesignItemColors},{type:Backbone.One,key:"constraints",relatedModel:MPlaza.DesignItemConstraints},{type:Backbone.One,key:"textArt",relatedModel:MPlaza.DesignItemTextArt},{type:Backbone.One,key:"shape",relatedModel:MPlaza.DesignItemShape},{type:Backbone.Many,key:"colorMappings",collectionType:MPlaza.ColorMappings},{type:Backbone.Many,key:"connectorSettings",collectionType:MPlaza.ConnectorSettings}],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getDesignItemID:function(){return this.get("itemID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},findArea:function(e,t,i,n){var a=this.get("areas");return a?a.getDesignItemArea(e,t,i,n):null},findColor:function(e,t){var i=this.get("colors");return i?i.getDesignItemColor(e,t):null},toString:function(){},isOnSide:function(e){if(!(e&&e instanceof MPlaza.Side))return!1;for(var t=this.get("areas"),i=0;i<t.length;i++){var n=t.at(i);if(n.get("areaGuid")&&(!n.get("areaID")||n.get("areaID")<=0)){for(var a=0;a<e.get("areas").length;a++)if(e.get("areas").at(a).get("guid")==n.get("areaGuid"))return!0}else if(n.get("sideID")==e.getSideID())return!0}return!1},inOnArea:function(e){return!!(e||e instanceof MPlaza.Area)&&null!=this.findArea(e.getModelID(),e.getColorID(),e.getSideID(),e.getAreaID())},updateAreas:function(e){for(;this.get("areas").length>0;)this.get("areas").pop();for(var t=0;t<e.length;t++)this.addArea(e[t])},addArea:function(e){if(e&&e instanceof MPlaza.Area&&!this.findArea(e.getModelID(),e.getColorID(),e.getSideID(),e.getAreaID())){var t=new MPlaza.DesignItemArea;t.set("modelID",e.getModelID()),t.set("colorID",e.getColorID()),t.set("sideID",e.getSideID()),t.set("areaID",e.getAreaID()),t.set("areaGuid",e.get("guid")),this.get("areas").add(t)}},changeColor:function(e,t,i){if(e===this.get("imageID")){var n=this.findColor(e,t);n||((n=new MPlaza.DesignItemColor).set("imageID",e),n.set("colorID",t),this.get("colors").add(n)),n.set("colorCode",i)}},setConstraintsFromSource:function(e){this.unset("constraints");var t=new MPlaza.DesignItemConstraints;t.itemID=this.get("itemID"),t.copyAttributes(e),this.set("constraints",t)},setTextArtFromSource:function(e){this.unset("textArt");var t=new MPlaza.DesignItemTextArt;t.itemID=this.get("itemID"),t.copyAttributes(e),this.set("textArt",t)},isTextArt:function(){return null!==this.get("textArt")&&void 0!==this.get("textArt")},sync:MPlaza.syncCloudflare}),MPlaza.DesignItems=Backbone.Collection.extend({model:MPlaza.DesignItem,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},getDesignItemByGuid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("itemGuid")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignTemplateCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:-1,name:""},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignTemplateCategories=Backbone.Collection.extend({model:MPlaza.DesignTemplateCategory,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findCategory:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("categoryID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignTemplateColor=Backbone.AssociatedModel.extend({defaults:{colorID:-1,name:"",isDefault:!1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignTemplateColors=Backbone.Collection.extend({model:MPlaza.DesignTemplateColor,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignArea=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,areaID:-1,printTypeID:-1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignAreas=Backbone.Collection.extend({model:MPlaza.DesignArea,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findArea:function(e,t,i,n){for(var a=0;a<this.length;a++){var r=this.at(a);if(r.get("modelID")==e&&r.get("colorID")==t&&r.get("sideID")==i&&r.get("areaID")==n)return r}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignAreaGrid=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,areaID:-1,gridID:-1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignAreasGrids=Backbone.Collection.extend({model:MPlaza.DesignAreaGrid,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findAreaGrid:function(e,t,i,n,a){for(var r=0;r<this.length;r++){var o=this.at(r);if(o.get("modelID")==e&&o.get("colorID")==t&&o.get("sideID")==i&&o.get("areaID")==n&&o.get("gridID")==a)return o}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignSidePrintType=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,printTypeID:-1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignSidesPrintTypes=Backbone.Collection.extend({model:MPlaza.DesignSidePrintType,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findSidePrintType:function(e,t,i,n){for(var a=0;a<this.length;a++){var r=this.at(a);if(r.get("modelID")==e&&r.get("colorID")==t&&r.get("sideID")==i&&r.get("printTypeID")==n)return r}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignSide=Backbone.AssociatedModel.extend({defaults:{modelID:-1,colorID:-1,sideID:-1,fillColor:"",canAddText:!0,canAddImage:!0,canAddShape:!0,canMaskImages:!0,maxNrTexts:null,maxNrImages:null,maxNrShapes:null,canChangeSvgColors:!0,uploadRestrictions:null,disableSellerImages:!1},initialize:function(){},relations:[],getDesignID:function(){return this.collection&&this.collection.getDesignID?this.collection.getDesignID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignSides=Backbone.Collection.extend({model:MPlaza.DesignSide,getDesignID:function(){return this.parentModel&&this.parentModel.getDesignID?this.parentModel.getDesignID():null},findSide:function(e,t,i){for(var n=0;n<this.length;n++){var a=this.at(n);if(a.get("modelID")==e&&a.get("colorID")==t&&a.get("sideID")==i)return a}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignClientPreview=Backbone.AssociatedModel.extend({defaults:{sideID:-1,fileObjectID:-1,url:""},initialize:function(){},relations:[],sync:MPlaza.syncCloudflare}),MPlaza.DesignClientPreviews=Backbone.Collection.extend({model:MPlaza.DesignClientPreview,sync:MPlaza.syncCloudflare}),MPlaza.TextDesignElement=Backbone.AssociatedModel.extend({defaults:{},copyAttributes:function(e){var t=function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))};t("content"),t("strokeColor"),t("strokeWidth"),t("fillColor"),t("fontFamily"),t("fontSize"),t("fontWeight"),t("fontStyle"),t("fontStretch"),t("justification"),t("adaptText"),t("letterSpacing"),t("lineSpacing"),t("verticalAlignment"),t("shadowColor"),t("shadowBlur"),t("shadowBlur"),t("shadowBlur")}}),MPlaza.TextArtDesignElement=Backbone.AssociatedModel.extend({defaults:{},copyAttributes:function(e){!function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))}("content")}}),MPlaza.ImageDesignElement=Backbone.AssociatedModel.extend({defaults:{},copyAttributes:function(e){!function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))}("imageID")}}),MPlaza.ShapeDesignElement=Backbone.AssociatedModel.extend({defaults:{},copyAttributes:function(e){!function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))}("shapeID")}}),MPlaza.DesignElement=Backbone.AssociatedModel.extend({defaults:{tag:"",text:null,textArt:null,image:null,shape:null},initialize:function(){},relations:[{type:Backbone.One,key:"text",relatedModel:MPlaza.TextDesignElement},{type:Backbone.One,key:"textArt",relatedModel:MPlaza.TextArtDesignElement},{type:Backbone.One,key:"image",relatedModel:MPlaza.ImageDesignElement},{type:Backbone.One,key:"shape",relatedModel:MPlaza.ShapeDesignElement}],copyAttributes:function(e){if(function(e,t){this.unset(t),void 0!==e.get(t)&&null!=e.get(t)&&this.set(t,e.get(t))}("tag"),this.unset("text"),e.get("text")){var t=new MPlaza.TextDesignElement;t.copyAttributes(e.get("text")),this.set("text",t)}if(this.unset("textArt"),e.get("textArt")){var i=new MPlaza.TextArtDesignElement;i.copyAttributes(e.get("textArt")),this.set("textArt",i)}if(this.unset("image"),e.get("image")){var n=new MPlaza.ImageDesignElement;n.copyAttributes(e.get("image")),this.set("image",n)}if(this.unset("shape"),e.get("shape")){var a=new MPlaza.ShapeDesignElement;a.copyAttributes(e.get("shape")),this.set("shape",a)}}}),MPlaza.DesignElements=Backbone.Collection.extend({model:MPlaza.DesignElement}),MPlaza.DesignElementsDesc=Backbone.AssociatedModel.extend({defaults:{elements:[]},idAttribute:"id",initialize:function(){this.get("id")||this.set("id",MPlaza.generateUUID())},relations:[{type:Backbone.Many,key:"elements",collectionType:MPlaza.DesignElements}],copyAttributes:function(e){if(this.unset("elements"),null!==e.get("elements")&&void 0!==e.get("elements")){for(var t=[],i=0;i<e.get("elements").length;i++){var n=e.get("elements").at(i),a=new MPlaza.DesignElement;a.copyAttributes(n),t.push(a)}this.set("elements",t)}}}),MPlaza.DesignElementsDescs=Backbone.Collection.extend({model:MPlaza.DesignElementsDesc,getDescById:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.id===e)return i}return null}}),MPlaza.DesignOptionsItem=Backbone.AssociatedModel.extend({defaults:{colorID:-1,sideID:null,width:null,height:null,columns:1,rows:1},idAttribute:"optionId",initialize:function(){},relations:[]}),MPlaza.DesignOptions=Backbone.Collection.extend({model:MPlaza.DesignOptionsItem}),MPlaza.Design=Backbone.AssociatedModel.extend({defaults:{modelID:-1,modelName:"",pricingModelID:-1,modelPriceDeltaPerc:0,modelPriceDeltaValue:0,modelPrice:0,modelTextBasePrice:0,modelImageBasePrice:0,printTypeID:-1,description:"",info:"",isTemplate:!1,isDraft:!1,name:"",templateCode:"",parentTemplateId:null,templateDesignID:-1,customerID:-1,visitorID:-1,sells:0,finalPrice:0,tempPreviewImageData:null,tempPreviewImageUrl:"",canAddText:!0,canAddImage:!0,canAddShape:!0,canMaskImages:!0,maxNrTexts:null,maxNrImages:null,maxNrShapes:null,filterCode:"",canChangeSvgColors:!0,uploadRestrictions:null,disableSellerImages:!1,hasSyncEnabled:!1,pdSettings:-1,sides:[],sidesPrintTypes:[],areasGrids:[],areas:[],designItems:[],categories:[],colors:[],tags:[],clientPreviews:[],elementsDescs:[],options:[],canvasRotation:[]},idAttribute:"docID",initialize:function(){var e=this;this.get("sides").parentModel=this,this.get("sidesPrintTypes").parentModel=this,this.get("areasGrids")||this.set("areasGrids",new MPlaza.DesignAreasGrids),this.get("areasGrids").parentModel=this,this.get("areas").parentModel=this,this.get("designItems").parentModel=this,this.get("colors")||this.set("colors",new MPlaza.DesignTemplateColors),this.get("categories").parentModel=this,this.get("colors").parentModel=this,this.get("options")||this.set("options",new MPlaza.DesignOptions),this.get("options").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("designItems").on("add",function(){e._fireEvent("change")}),this.get("designItems").on("remove",function(){e._fireEvent("change")}),this.get("designItems").on("change",function(){e._fireEvent("change")}),this.get("categories").on("change",function(){e._fireEvent("change")}),this.get("colors").on("change",function(){e._fireEvent("change")}),this.get("clientPreviews").on("change",function(){e._fireEvent("change")}),this.get("sidesPrintTypes").on("change",function(){e._fireEvent("change")}),this.get("options").on("change",function(){e._fireEvent("change")})},_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},isEmpty:function(){return 0==this.get("designItems").length},relations:[{type:Backbone.Many,key:"sides",collectionType:MPlaza.DesignSides},{type:Backbone.Many,key:"sidesPrintTypes",collectionType:MPlaza.DesignSidesPrintTypes},{type:Backbone.Many,key:"areasGrids",collectionType:MPlaza.DesignAreasGrids},{type:Backbone.Many,key:"areas",collectionType:MPlaza.DesignAreas},{type:Backbone.Many,key:"designItems",collectionType:MPlaza.DesignItems},{type:Backbone.Many,key:"categories",collectionType:MPlaza.DesignTemplateCategories},{type:Backbone.Many,key:"colors",collectionType:MPlaza.DesignTemplateColors},{type:Backbone.Many,key:"clientPreviews",collectionType:MPlaza.DesignClientPreviews},{type:Backbone.Many,key:"elementsDescs",collectionType:MPlaza.DesignElementsDescs},{type:Backbone.Many,key:"options",collectionType:MPlaza.DesignOptions}],url:function(){var e=Zakeke.config.baseApiUrl+"proxydesigns";return null!=this.id&&null!=this.id&&(e=e+"/"+this.id),!0===this.attributes.isDraft&&(e+="/?draft=true"),e},getDesignID:function(){return this.get("designID")},toString:function(){},getDesignItems:function(){return this.get("designItems")},getSideDesignItems:function(e){for(var t=[],i=0;i<this.get("designItems").length;i++){var n=this.get("designItems").at(i);n.isOnSide(e)&&t.push(n)}return t.sort(function(e,t){return e.get("index")-t.get("index")}),t},getAreaDesignItems:function(e){var t=[];if(e&&e instanceof MPlaza.Area)for(var i=0;i<this.get("designItems").length;i++){var n=this.get("designItems").at(i);n.inOnArea(e)&&t.push(n)}return t.sort(function(e,t){return e.get("index")-t.get("index")}),t},getDesignItemsByTag:function(e){var t=[];for(let i=0;i<this.get("designItems").length;i++){const n=this.get("designItems").at(i);null!==n.get("tag")&&void 0!==n.get("tag")&&n.get("tag")===e&&t.push(n)}return t.sort(function(e,t){return e.get("index")-t.get("index")}),t},setModel:function(e){if(e&&e instanceof MPlaza.Model){this.set("modelID",e.get("modelID")),this.set("modelName",e.get("name")),this.set("pricingModelID",e.get("pricingModelID"));var t=this.get("printTypeID");this.set("modelPriceDeltaPerc",e.getModelPriceDeltaPerc(t)),this.set("modelPriceDeltaValue",e.getModelPriceDeltaValue(t)),this.set("modelPrice",e.getModelPrice(t)),this.set("modelTextBasePrice",e.getModelTextBasePrice(t)),this.set("modelImageBasePrice",e.getModelImageBasePrice(t))}},setPrintType:function(e){e&&e instanceof MPlaza.PrintType&&(this.set("printTypeID",e.get("printTypeID")||e.tempID),this.set("modelPriceDeltaPerc",e.get("priceDeltaPerc")),this.set("modelPriceDeltaValue",e.get("priceDeltaValue")),this.set("modelPrice",e.get("price")),this.set("modelTextBasePrice",e.get("textBasePrice")),this.set("modelImageBasePrice",e.get("imageBasePrice")))},cloneWithDifferentModel:function(e){var t=new MPlaza.Design;if(!(e&&e instanceof MPlaza.Model))return t;if(e.get("modelID")==this.get("modelID"))return this.clone();if(0==e.get("colors").length)return t;t.setModel(e);var i=e.get("printTypes").getPrintType(this.get("printTypeID"));!i&&e.get("printTypes").length>0&&(i=e.get("printTypes").at(0)),i?t.set("printTypeID",i.get("printTypeID")):t.set("printTypeID",-1);var n=e.get("colors").at(0);if(n)for(var a=0;a<this.get("designItems").length;a++){var r=this.get("designItems").at(a),o=new MPlaza.DesignItem;o.copyAttributes(r);for(var s=0;s<r.get("areas").length;s++){var l=r.get("areas").at(s),h=n.get("sides").getSide(l.get("sideID"));if(h){var d=h.get("areas").getAreaByID(l.get("areaID"));d&&o.addArea(d)}}o.get("areas").length>0&&t.get("designItems").add(o)}for(var c=0;c<this.get("categories").length;c++){var u=this.get("categories").at(c),g=new MPlaza.DesignTemplateCategory;g.set("categoryID",u.get("categoryID")),g.set("name",u.get("name")),t.get("categories").add(g)}for(c=0;c<this.get("colors").length;c++){var f=this.get("colors").at(c),p=new MPlaza.DesignTemplateColor;p.set("colorID",f.get("colorID")),p.set("name",f.get("name")),t.get("colors").add(p)}if(null!==this.get("elementsDescs")&&void 0!==this.get("elementsDescs")){var m=new MPlaza.DesignElementsDescs;for(c=0;c<this.get("elementsDescs").length;c++){var v=this.get("elementsDescs").at(c),I=new MPlaza.DesignElementsDesc;I.copyAttributes(v),m.push(I)}t.set("elementsDescs",m)}return t},changeColor:function(e){if(e){var t=[],i=[],n=[];for(let t of this.get("areasGrids").models)t.set("modelID",e.getModelID()),e.get("sides").find(e=>e.id==t.get("sideID"))&&t.set("colorID",e.getColorID());for(var a=0;a<this.get("sides").length;a++){var r=this.get("sides").at(a),o=null;if(r.get("modelID")==e.getModelID()){var s=e.get("sides").getSide(r.get("sideID"));s&&(o=s)}var l=null;let I=null;for(var h=0;h<this.get("sidesPrintTypes").length;h++){var d=this.get("sidesPrintTypes").at(h);d.get("modelID")==r.get("modelID")&&d.get("colorID")==r.get("colorID")&&d.get("sideID")==r.get("sideID")&&(l=d)}for(var c=0;c<this.get("areasGrids").length;c++){let e=this.get("areasGrids").at(c);e.get("modelID")==r.get("modelID")&&e.get("colorID")==r.get("colorID")&&e.get("sideID")==r.get("sideID")&&(I=e)}if(o){var u=null;for(var g of this.get("sides").models)g!==r&&g.get("modelID")===e.getModelID()&&g.get("colorID")===e.getColorID()&&g.get("sideID")===r.get("sideID")&&(u=g);u?t.push(r):r.set("colorID",e.get("colorID"));var f=null;for(var p of this.get("sidesPrintTypes").models)p!==l&&p.get("modelID")===e.getModelID()&&p.get("colorID")===e.getColorID()&&p.get("sideID")===r.get("sideID")&&(f=p);if(f&&l)i.push(l);else if(l)l.set("colorID",e.get("colorID"));else if(!f){var m=-1;m=o.get("printTypes").length>0?o.get("printTypes").at(0):e.getParentModel().get("printTypes").at(0);var v=new MPlaza.DesignSidePrintType;v.set("modelID",r.get("modelID")),v.set("colorID",r.get("colorID")),v.set("sideID",r.get("sideID")),v.set("printTypeID",m),this.get("sidesPrintTypes").add(v)}}else t.push(r),l&&i.push(l),I&&n.push(I)}for(var I of t)this.get("sides").remove(I);for(var y of i)this.get("sidesPrintTypes").remove(y);for(let e of n)this.get("areasGrids").remove(e);for(var C=[],M=0;M<this.get("designItems").length;M++){var x=this.get("designItems").at(M),S=[];for(h=0;h<x.get("areas").length;h++){var b=x.get("areas").at(h),w=!1;if(b.get("modelID")==e.getModelID())if(g=e.get("sides").getSide(b.get("sideID")))g.get("areas").getAreaByID(b.get("areaID"))&&(w=!0);w?b.set("colorID",e.get("colorID")):S.push(b)}S.length>0&&x.get("areas").remove(S),0==x.get("areas").length&&C.push(x)}C.length>0&&this.get("designItems").remove(C),this._fireEvent("change")}},addSide:function(e){if(e&&e instanceof MPlaza.Side&&!this.get("sides").findSide(e.getModelID(),e.getColorID(),e.getSideID())){var t=new MPlaza.DesignSide;t.set("modelID",area.getModelID()),t.set("colorID",area.getColorID()),t.set("sideID",area.getSideID()),this.get("sides").add(t)}},addSidePrintType:function(e,t){if(e&&t&&e instanceof MPlaza.Side&&t instanceof MPlaza.PartPrintType&&!this.get("sidesPrintTypes").findSidePrintType(e.getModelID(),e.getColorID(),e.getSideID(),t.getPrintTypeID())){var i=new MPlaza.DesignSidePrintType;i.set("modelID",e.getModelID()),i.set("colorID",e.getColorID()),i.set("sideID",e.getSideID()),i.set("printTypeID",t.getPrintTypeID()),this.get("sidesPrintTypes").add(i)}},addArea:function(e){if(e&&side instanceof MPlaza.Area&&!this.get("areas").findArea(e.getModelID(),e.getColorID(),e.getSideID(),e.getAreaID())){var t=new MPlaza.DesignArea;t.set("modelID",e.getModelID()),t.set("colorID",e.getColorID()),t.set("sideID",e.getSideID()),t.set("areaID",e.getAreaID()),t.set("areaGuid",e.get("guid")),this.get("areas").add(t)}},getDesignSide:function(e){if(e&&e instanceof MPlaza.Side)return this.get("sides").findSide(e.getModelID(),e.getColorID(),e.getSideID())},getDesignSidePrintType:function(e,t){if(e&&t&&e instanceof MPlaza.Side&&t instanceof MPlaza.PartPrintType)return this.get("sidesPrintTypes").findSide(e.getModelID(),e.getColorID(),e.getSideID(),t.getPrintTypeID())},getDesignArea:function(e){if(e&&e instanceof MPlaza.Area)return this.get("areas").findArea(e.getModelID(),e.getColorID(),e.getSideID(),e.getAreaID())},getSelectedPrintTypeForArea:function(e){if(!e)return this.get("printTypeID");var t=this.getDesignArea(e);return this.getSelectedPrintTypeForDesignArea(t,e.getSideID(),e.getColorID())},getSelectedPrintTypeForDesignArea:function(e,t,i){if(e&&e.get("printTypeID")&&e.get("printTypeID")>0)return parseInt(e.get("printTypeID"));for(var n=null,a=0;a<this.get("sidesPrintTypes").length;a++){var r=this.get("sidesPrintTypes").at(a);r.get("colorID")==i&&r.get("sideID")==t&&(n=r)}return n?parseInt(n.get("printTypeID")):parseInt(this.get("printTypeID"))},getImageDesignItems:function(e){for(var t=[],i=0;i<this.get("designItems").length;i++){var n=this.get("designItems").at(i);n.get("imageID")==e&&t.push(n)}return t},getDesignPrice:function(e,t=1){for(var i=0,n=this.get("customerID"),a=this.get("visitorID"),r=[],o=0;o<this.get("designItems").length;o++){var s=this.get("designItems").at(o);if(s.get("imageID")>0){i+=this.get("modelImageBasePrice");var l=s.get("imagePrice");l>0&&!r.find(e=>e.get("providerImageID")===s.get("providerImageID"))&&(s.get("providerImageID")&&r.push(s),e.get("hasAdditionalFeeOnImagesProvider")||(l=null==s.get("applyImagePriceForQuantity")||s.get("applyImagePriceForQuantity")?l:l/t),n>0?n!=s.get("imageCustomerID")&&(i+=l):a>0?a!=s.get("imageVisitorID")&&(i+=l):i+=l)}else i+=this.get("modelTextBasePrice")}return i*t},getPrice:function(){var e=this.get("modelFinalPrice");return Math.round(100*e)/100},getDesignPriceEx:function(e,t){if(counter={},e&&e instanceof MPlaza.Model&&t>0)for(var i=0;i<e.get("colors").length;i++)for(var n=e.get("colors").at(i),a=0;a<n.get("sides").length;a++)for(var r=n.get("sides").at(a),o=0;o<r.get("areas").length;o++){var s=r.get("areas").at(o),l=this.getAreaDesignItems(s).filter(function(e){var t=e.get("constraints");return!t||1==t.get("isPrintable")});l.length>0&&this.addAreaPrice(s,l,t,counter)}var h=0;for(var d in counter)if(counter.hasOwnProperty(d)){var c=counter[d];isNaN(c)||(h+=c)}return Math.round(100*h)/100},addAreaPrice:function(e,t,i,n){var a=this.getSelectedPrintTypeForArea(e),r=this.getAreaPricingRef(e,a),o=r.pricingApplicationType,s=e.getModel();if(s&&s instanceof MPlaza.Model&&s.get("pricings")){var l=0,h=0,d=r.pricingID>0?s.get("pricings").getPricing(r.pricingID):null;if(d&&d instanceof MPlaza.Pricing){var c=0;d.get("setupPriceTypeID")!=MPlaza.PricingType.PerColor&&d.get("designPriceTypeID")!=MPlaza.PricingType.PerColor||(c=this.getAreaColorsCount(e,t));var u=d.getSetupPriceForQuantity(i);if(u)if(d.get("setupPriceTypeID")==MPlaza.PricingType.PerColor){if(c>0){var g=c;null!=u.get("firstColorPrice")&&null!=u.get("firstColorPrice")&&(l+=u.get("firstColorPrice"),g--),l+=g*u.get("price")}}else d.get("setupPriceTypeID")==MPlaza.PricingType.Global&&(l+=u.get("price"));var f=d.getDesignPriceForQuantity(i);if(f)if(d.get("designPriceTypeID")==MPlaza.PricingType.PerColor){if(c>0){g=c;null!=f.get("firstColorPrice")&&null!=f.get("firstColorPrice")&&(h+=f.get("firstColorPrice")*i,g--),h+=g*f.get("price")*i}}else d.get("designPriceTypeID")==MPlaza.PricingType.Global&&(h+=f.get("price")*i)}var p=null;switch(o){case MPlaza.PricingApplicationType.Global:p=this.getModelCounterKey(e.getModel(),a);break;case MPlaza.PricingApplicationType.PerSide:p=this.getSideCounterKey(e.getSide(),a);break;case MPlaza.PricingApplicationType.PerArea:p=this.getAreaCounterKey(e,a)}null!=p&&(n[p]=l+h);for(var m=[],v=0;v<t.length;v++){var I=t[v];if(I.get("imageID")>0&&I.get("imagePrice")>0&&!m.find(e=>e.get("providerImageID")===I.get("providerImageID"))){m.push(I);var y=I.get("imagePrice");y=s.get("hasAdditionalFeeOnImagesProvider")?I.get("imagePrice")*i:null===I.get("applyImagePriceForQuantity")||I.get("applyImagePriceForQuantity")?I.get("imagePrice")*i:I.get("imagePrice");var C=this.getImageCounterKey(I.get("providerImageID"));if(!(C in n)){var M=y;n[C]=M+(n[C]||0)}}}}},getAreaPricingRef:function(e,t){var i=-1,n=MPlaza.PricingApplicationType.Undefined,a=e.getPrintType(t);if(a&&a.get("pricingID")>0)i=a.get("pricingID"),n=a.get("patID");else{var r=e.getParentModel(),o=r.getPrintType(t);if(o&&o.get("pricingID")>0)i=o.get("pricingID"),n=o.get("patID");else{var s=r.getParentModel(),l=s.getPrintType(t);if(l&&l.get("pricingID")>0)i=l.get("pricingID"),n=l.get("patID");else{var h=s.getParentModel().getPrintType(t);h&&h.get("pricingID")>0&&(i=h.get("pricingID"),n=h.get("patID"))}}}return{pricingID:i,pricingApplicationType:n}},getAreaColorsCount:function(e,t){for(var i={},n=0;n<t.length;n++)for(var a=t[n].get("itemColors"),r=0;r<a.length;r++)i[a[r]]=1+(i[a[r]]||0);return Object.keys(i).length},getModelCounterKey:function(e,t){return t+"_"+e.get("modelID")},getColorCounterKey:function(e,t){return t+"_"+e.getModelID()+"_"+e.get("colorID")},getSideCounterKey:function(e,t){return t+"_"+e.getModelID()+"_"+e.getColorID()+"_"+e.get("sideID")},getAreaCounterKey:function(e,t){return t+"_"+e.getModelID()+"_"+e.getColorID()+"_"+e.getSideID()+"_"+e.get("areaID")},getImageCounterKey:function(e){return"img_"+e},countTextItemsForColor:function(e,t){for(var i={},n=0,a=0;a<this.get("designItems").length;a++){var r=this.get("designItems").at(a),o=JSON.parse(r.get("json")),s=o.length>1&&o[1].data&&o[1].data.isAreaForBackground;if(r.get("imageID")<=0&&!s)for(var l=0;l<r.get("areas").length;l++){var h=r.get("areas").at(l);h.get("modelID")==e&&h.get("colorID")==t&&(i.hasOwnProperty(r.get("itemGuid"))||(n++,i[r.get("itemGuid")]=!0))}}return n},countTextItemsForSide:function(e,t,i){for(var n={},a=0,r=0;r<this.get("designItems").length;r++){var o=this.get("designItems").at(r),s=JSON.parse(o.get("json")),l=s.length>1&&s[1].data&&s[1].data.isAreaForBackground;if(o.get("imageID")<=0&&!l)for(var h=0;h<o.get("areas").length;h++){var d=o.get("areas").at(h);d.get("modelID")==e&&d.get("colorID")==t&&d.get("sideID")==i&&(n.hasOwnProperty(o.get("itemGuid"))||(a++,n[o.get("itemGuid")]=!0))}}return a},countImageItemsForColor:function(e,t){for(var i={},n=0,a=0;a<this.get("designItems").length;a++){var r=this.get("designItems").at(a);if(r.get("imageID")>0)for(var o=0;o<r.get("areas").length;o++){var s=r.get("areas").at(o);s.get("modelID")==e&&s.get("colorID")==t&&(i.hasOwnProperty(r.get("itemGuid"))||(n++,i[r.get("itemGuid")]=!0))}}return n},countImageItemsForSide:function(e,t,i){for(var n={},a=0,r=0;r<this.get("designItems").length;r++){var o=this.get("designItems").at(r);if(o.get("imageID")>0)for(var s=0;s<o.get("areas").length;s++){var l=o.get("areas").at(s);l.get("modelID")==e&&l.get("colorID")==t&&l.get("sideID")==i&&(n.hasOwnProperty(o.get("itemGuid"))||(a++,n[o.get("itemGuid")]=!0))}}return a},countShapeItemsForColor:function(e,t){for(var i={},n=0,a=0;a<this.get("designItems").length;a++){var r=this.get("designItems").at(a),o=r.get("shape");if(o&&!o.get("isMask"))for(var s=0;s<r.get("areas").length;s++){var l=r.get("areas").at(s);l.get("modelID")==e&&l.get("colorID")==t&&(i.hasOwnProperty(r.get("itemGuid"))||(n++,i[r.get("itemGuid")]=!0))}}return n},countShapeItemsForSide:function(e,t,i){for(var n={},a=0,r=0;r<this.get("designItems").length;r++){var o=this.get("designItems").at(r);if(o.get("imageID")>0){var s=o.get("shape");if(s&&!s.get("isMask"))for(var l=0;l<o.get("areas").length;l++){var h=o.get("areas").at(l);h.get("modelID")==e&&h.get("colorID")==t&&h.get("sideID")==i&&(n.hasOwnProperty(o.get("itemGuid"))||(a++,n[o.get("itemGuid")]=!0))}}}return a},getTextItemsFonts:function(){for(var e=[],t=0;t<this.get("designItems").length;t++){var i=this.get("designItems").at(t);if(i.get("imageID")<=0){var n=i.get("json"),a=JSON.parse(n)[1],r=a.fontFamily||(a.children&&a.children.length>0&&a.children[0].length>1?a.children[0][1].fontFamily:null);r=r.replace(/"/g,""),_.contains(e,r)||e.push(r)}}return e}}),MPlaza.Designs=Backbone.Collection.extend({model:MPlaza.Design,url:function(){return Zakeke.config.baseApiUrl+"designs"},getDesign:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("designID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ImageColor=Backbone.AssociatedModel.extend({defaults:{colorID:-1,code:""},initialize:function(){},relations:[],getImageID:function(){return this.collection&&this.collection.getImageID?this.collection.getImageID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ImageColors=Backbone.Collection.extend({model:MPlaza.ImageColor,getImageID:function(){return this.parentModel&&this.parentModel.getImageID?this.parentModel.getImageID():null},findColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},setupUrlForImageID:function(e){this.url=function(){return Zakeke.config.baseApiUrl+"images/"+e+"/colors"}},sync:MPlaza.syncCloudflare}),MPlaza.ImageAssignedCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:-1,name:""},initialize:function(){},relations:[],getImageID:function(){return this.collection&&this.collection.getImageID?this.collection.getImageID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ImageAssignedCategories=Backbone.Collection.extend({model:MPlaza.ImageAssignedCategory,getImageID:function(){return this.parentModel&&this.parentModel.getImageID?this.parentModel.getImageID():null},findCategory:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("categoryID")==e)return i}return null},setupUrlForImageID:function(e){this.url=function(){return Zakeke.config.baseApiUrl+"images/"+e+"/categories"}},sync:MPlaza.syncCloudflare}),MPlaza.Image=Backbone.AssociatedModel.extend({defaults:{imageID:-1,name:"",type:"",format:"",width:0,height:0,dpiX:0,dpiY:0,isMulticolor:!1,containsRaster:!1,isFilterApplied:!1,imageFileSize:0,sellerID:-1,visitorID:-1,customerID:-1,price:0,url:"",previewUrl:"",choiceUrl:"",preferredWidth:null,preferredHeight:null,colors:[],categories:[],selectionColors:"",sourceUrlImage:"",applyPriceForQuantity:null},idAttribute:"imageID",initialize:function(){var e=this;this.get("colors").parentModel=this,this.get("colors").url=function(){return e.url()+"/"+e.id+"/imagecolors"},this.get("categories").parentModel=this,this.get("categories").url=function(){return e.url()+"/"+e.id+"/categories"}},relations:[{type:Backbone.Many,key:"colors",collectionType:MPlaza.ImageColors},{type:Backbone.Many,key:"categories",collectionType:MPlaza.ImageAssignedCategories}],url:function(){var e=Zakeke.config.baseApiUrl+"images",t=this.getUrlId();return null!==t&&(e=e+"/"+t),e},getImageID:function(){return this.get("imageID")},toString:function(){},getUrlId:function(){return void 0!==this.id&&null!=this.id&&null!=this.id&&this.id>0?this.id:null},sync:function(e,t,i){return null===this.getUrlId()?MPlaza.syncCloudflare.call(this,e,t,i):Backbone.sync.call(this,e,t,i)}}),MPlaza.Images=Backbone.Collection.extend({model:MPlaza.Image,url:function(){return Zakeke.config.baseApiUrl+"images"},getImage:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("imageID")==e)return i}return null},sync:function(e,t,i){return void 0!==i&&void 0!==i.data&&void 0!==i.data.type&&"lib"===i.data.type?MPlaza.syncCloudflare.call(this,e,t,i):Backbone.sync.call(this,e,t,i)}}),MPlaza.BgImages=Backbone.Collection.extend({model:MPlaza.Image,url:function(){return Zakeke.config.baseApiUrl+"images?onlybackground=true"},getImage:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("imageID")==e)return i}return null}}),MPlaza.ImageFormatCount=Backbone.AssociatedModel.extend({defaults:{fileFormat:"",rastersCount:0,vectorsCount:0},idAttribute:"fileFormat",url:function(){return null},sync:MPlaza.syncCloudflare}),MPlaza.ImageFormatsCounts=Backbone.Collection.extend({model:MPlaza.ImageFormatCount,url:function(){return null},comparator:function(e){return e.get("fileFormat")},sync:MPlaza.syncCloudflare}),MPlaza.ImageCategory=Backbone.AssociatedModel.extend({defaults:{categoryID:-1,name:"",imagesCount:0,imageFormatsCounts:[]},idAttribute:"categoryID",initialize:function(){this.get("imageFormatsCounts").parentModel=this},relations:[{type:Backbone.Many,key:"imageFormatsCounts",collectionType:MPlaza.ImageFormatsCounts}],url:function(){return null},sync:MPlaza.syncCloudflare}),MPlaza.ImageCategories=Backbone.Collection.extend({model:MPlaza.ImageCategory,url:function(){return null},comparator:function(e){return e.get("name")},sync:MPlaza.syncCloudflare}),MPlaza.ImageMacroCategory=Backbone.AssociatedModel.extend({defaults:{macroCategoryID:-1,name:"",onlyForBackgrounds:!1,imagesCount:0,categories:[]},idAttribute:"macroCategoryID",initialize:function(){this.get("categories").parentModel=this},relations:[{type:Backbone.Many,key:"categories",collectionType:MPlaza.ImageCategories}],url:function(){var e=Zakeke.config.baseApiUrl+"imagesMacroCategories";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},sync:MPlaza.syncCloudflare}),MPlaza.ImageMacroCategories=Backbone.Collection.extend({model:MPlaza.ImageMacroCategory,url:function(){return Zakeke.config.baseApiUrl+"imageMacroCategories"},comparator:function(e){return e.get("name")},sync:MPlaza.syncCloudflare}),MPlaza.ImageMacroCategoriesBackground=Backbone.Collection.extend({model:MPlaza.ImageMacroCategory,url:function(){return Zakeke.config.baseApiUrl+"imageMacroCategories?onlybackground=true"},comparator:function(e){return e.get("name")},sync:MPlaza.syncCloudflare}),MPlaza.ColorChange=Backbone.AssociatedModel.extend({defaults:{colorID:-1,code:""},initialize:function(){},relations:[],getImageID:function(){return this.collection&&this.collection.getImageID?this.collection.getImageID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ColorChanges=Backbone.Collection.extend({model:MPlaza.ColorChange,getImageID:function(){return this.parentModel&&this.parentModel.getImageID?this.parentModel.getImageID():null},findColor:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("colorID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.RecoloredImage=Backbone.AssociatedModel.extend({defaults:{imageID:-1,colorChanges:[],versionKey:"",imageUrl:""},idAttribute:"imageID",initialize:function(){this.get("colorChanges").parentModel=this},relations:[{type:Backbone.Many,key:"colorChanges",collectionType:MPlaza.ColorChanges}],url:function(){var e=Zakeke.config.baseApiUrl+"recoloredimages";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},getImageID:function(){return this.get("imageID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DrawingItem=Backbone.Model.extend({defaults:{guid:null,info:""},initialize:function(){this.set("guid",MPlaza.generateUUID())}}),MPlaza.DrawingItems=Backbone.Collection.extend({model:MPlaza.DrawingItem,getDrawingItem:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("guid")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.CompositionItem=Backbone.AssociatedModel.extend({defaults:{attributeID:-1,attributeGuid:"",attributeTypeID:MPlaza.AttributeType.Options,attributeCode:"",attributeName:"",selectedOptionID:null,selectedOptionGuid:null,selectedOptionCode:"",selectedOptionName:null,selectedValue:null},copyAttributes:function(e){this.set("attributeID",e.get("attributeID")),this.set("attributeGuid",e.get("attributeGuid")),this.set("attributeTypeID",e.get("attributeTypeID")),this.set("attributeCode",e.get("attributeCode")),this.set("attributeName",e.get("attributeName")),this.set("selectedOptionID",e.get("selectedOptionID")),this.set("selectedOptionGuid",e.get("selectedOptionGuid")),this.set("selectedOptionCode",e.get("selectedOptionCode")),this.set("selectedOptionName",e.get("selectedOptionName")),this.set("selectedValue",e.get("selectedValue"))},idAttribute:"itemGuid",initialize:function(){this.get("itemGuid")||this.set("itemGuid",MPlaza.generateUUID())},getCompositionID:function(){return this.collection&&this.collection.getCompositionID?this.collection.getCompositionID():null},getCompositionItemID:function(){return this.get("itemID")},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.CompositionItems=Backbone.Collection.extend({model:MPlaza.CompositionItem,getCompositionID:function(){return this.parentModel&&this.parentModel.getCompositionID?this.parentModel.getCompositionID():null},getCompositionItem:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("itemID")==e)return i}return null},getCompositionItemByAttributeID:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeID")==e)return i}return null},getCompositionItemByAttributeGuid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("attributeGuid")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.CompositionCategoryMapping=Backbone.AssociatedModel.extend({defaults:{categoryID:null,name:""},relations:[],resetIDs:function(){}}),MPlaza.CompositionCategoriesMapping=Backbone.Collection.extend({model:MPlaza.CompositionCategoryMapping,sync:MPlaza.syncCloudflare}),MPlaza.Composition=Backbone.AssociatedModel.extend({defaults:{name:"",designID:-1,designDocID:"",modelID:-1,modelName:"",modelPrice:0,customerID:-1,visitorID:-1,finalPrice:0,previewImageData:null,previewImageUrl:"",compositionItems:[],categories:[]},idAttribute:"docID",initialize:function(){var e=this;this.get("compositionItems").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("compositionItems").on("add",function(){e._fireEvent("change")}),this.get("compositionItems").on("remove",function(){e._fireEvent("change")}),this.get("compositionItems").on("change",function(){e._fireEvent("change")})},_eventListeners:{change:[]},_fireEvent:function(e,t){if(this._eventListeners&&_.isObject(this._eventListeners)&&_.has(this._eventListeners,e)&&_.isArray(this._eventListeners[e]))for(var i=this._eventListeners[e],n=0;n<i.length;++n)i[n](t)},trigger:function(e){this._fireEvent(e)},addEventListener:function(e,t){this._eventListeners&&_.isObject(this._eventListeners)&&(_.has(this._eventListeners,e)||(this._eventListeners[e]=[]),this._eventListeners[e].push(t))},isEmpty:function(){return 0==this.get("compositionItems").length},relations:[{type:Backbone.Many,key:"compositionItems",collectionType:MPlaza.CompositionItems},{type:Backbone.Many,key:"categories",collectionType:MPlaza.CompositionCategoriesMapping}],url:function(){var e=Zakeke.config.baseApiUrl+"proxycompositions";return null!=this.id&&null!=this.id&&(e=e+"/"+this.id),e},getCompositionID:function(){return this.get("compositionID")},toString:function(){},setModel:function(e){e&&e instanceof MPlaza.Model&&(this.set("modelID",e.get("modelID")),this.set("modelName",e.get("name")),this.set("modelPrice",e.getModelPrice(printTypeID)))},getCompositionItemByAttributeID:function(e){return this.get("compositionItems").getCompositionItemByAttributeID(e)},getCompositionItemByAttributeGuid:function(e){return this.get("compositionItems").getCompositionItemByAttributeGuid(e)},getPrice:function(e,t){for(var i=e.get("price"),n=0;n<this.get("compositionItems").length;n++){var a=this.get("compositionItems").at(n),r=(e.getAttribute(a.get("attributeID")),this.getAttributePricing(a,e));if(r)if(null!=r.get("pricingID")&&r.get("pricingID")>0){var o=e.getComposerPricing(r.get("pricingID"));if(o){var s=o.getComposerPricingPriceForQuantity(t);s&&(i+=s.get("price"))}}else i+=r.get("price")}return i*t},getAttributePricing:function(e,t){var i=null,n=t.getAttribute(e.get("attributeID"));if(e.get("attributeTypeID")==MPlaza.AttributeType.Options&&e.get("selectedOptionID"))for(var a=0;a<n.get("pricings").length;a++){if((o=n.get("pricings").at(a)).get("selectedOptionID")==e.get("selectedOptionID"))if(!(r=o.get("constraintExpression"))||this.evaluateAttributeExpression(r)){i=o;break}}else if(e.get("selectedValue"))for(a=0;a<n.get("pricings").length;a++){var r;if((o=n.get("pricings").at(a)).get("selectedValue")==e.get("selectedValue"))if(!(r=o.get("constraintExpression"))||this.evaluateAttributeExpression(r)){i=o;break}}if(!i)for(a=0;a<n.get("pricings").length;a++){var o;if(!(o=n.get("pricings").at(a)).get("selectedOptionID")&&!o.get("selectedValue")){i=o;break}}return i},evaluateAttributeExpression:function(e){if(!(e&&e instanceof MPlaza.AttributeExpression))return!1;for(var t=e.get("op"),i=t==MPlaza.LogicalOperator.AND,n=0;n<e.get("propositions").length;n++){var a=e.get("propositions")[n],r=this.evaluateAttributeProposition(a);if(t==MPlaza.LogicalOperator.AND){if(!(i=i&&r))return!1}else if(i=i||r)return!0}for(n=0;n<e.get("expressions").length;n++){var o=e.get("expressions")[n];r=this.evaluateChildAttributeExpression(o);if(t==MPlaza.LogicalOperator.AND){if(!(i=i&&r))return!1}else if(i=i||r)return!0}return i},evaluateChildAttributeExpression:function(e){for(var t=e.op,i=t==MPlaza.LogicalOperator.AND,n=0;n<e.propositions.length;n++){var a=e.propositions[n],r=this.evaluateAttributeProposition(a);if(t==MPlaza.LogicalOperator.AND){if(!(i=i&&r))return!1}else if(i=i||r)return!0}for(n=0;n<e.expressions.length;n++){var o=e.expressions[n];r=this.evaluateChildAttributeExpression(o);if(t==MPlaza.LogicalOperator.AND){if(!(i=i&&r))return!1}else if(i=i||r)return!0}return i},evaluateAttributeProposition:function(e){if(e&&e.hasOwnProperty("attributeGuid")&&e.hasOwnProperty("op")&&e.hasOwnProperty("value")){var t=e.attributeGuid,i=this.getCompositionItemByAttributeGuid(t);if(i){var n=i.get("selectedValue");i.get("attributeTypeID")==MPlaza.AttributeType.Options&&(n=i.get("selectedOptionGuid"));var a=!1;if(e.op==MPlaza.ComparisonOperator.Equal)a=n==e.value;else if(e.op==MPlaza.ComparisonOperator.NotEqual)a=n!=e.value;else if(e.op==MPlaza.ComparisonOperator.In||e.op==MPlaza.ComparisonOperator.NotIn){var r=e.value.split(";");a=e.op==MPlaza.ComparisonOperator.In?Zakeke.arrayContains(r,n):!Zakeke.arrayContains(r,n)}return a}}return!1}}),MPlaza.Compositions=Backbone.Collection.extend({model:MPlaza.Composition,url:function(){return Zakeke.config.baseApiUrl+"proxycompositions"},getComposition:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("compositionID")==e)return i}return null},getCompositionByDocID:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("docID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.TemplateCategory=Backbone.AssociatedModel.extend({defaults:{id:-1,name:"",isDummy:!1,displayOrder:0},url:function(){return null},sync:MPlaza.syncCloudflare}),MPlaza.TemplateCategories=Backbone.Collection.extend({model:MPlaza.TemplateCategory,url:function(){return null},sync:MPlaza.syncCloudflare}),MPlaza.TemplateMacroCategory=Backbone.AssociatedModel.extend({defaults:{id:-1,name:"",isDummy:!1,displayOrder:0,categories:[]},initialize:function(){this.get("categories").parentModel=this},relations:[{type:Backbone.Many,key:"categories",collectionType:MPlaza.TemplateCategories}],url:function(){var e=Zakeke.config.baseApiUrl+"designs/templatemacrocategories";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},sync:MPlaza.syncCloudflare}),MPlaza.TemplateMacroCategories=Backbone.Collection.extend({model:MPlaza.TemplateMacroCategory,url:function(){return Zakeke.config.baseApiUrl+"designs/templatemacrocategories"},sync:MPlaza.syncCloudflare}),MPlaza.Grid=Backbone.AssociatedModel.extend({defaults:{json:"",svg:"",name:"",sellerID:-1,isDeleted:!1},idAttribute:"gridID",initialize:function(){},relations:[],getGridRuleID:function(){return this.collection&&this.collection.getGridRuleID?this.collection.getGridRuleID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.Grids=Backbone.Collection.extend({model:MPlaza.Grid,getGridRuleID:function(){return this.parentModel&&this.parentModel.getGridRuleID?this.parentModel.getGridRuleID():null},findGrid:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("gridID")==e)return i}return null},sync:MPlaza.syncCloudflare,comparator:function(e){return e.get("name")}}),MPlaza.GridRuleGridSideMapping=Backbone.AssociatedModel.extend({defaults:{gridRuleID:-1,gridID:-1,productID:null,sideID:null},initialize:function(){},relations:[],getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.GridRuleGridSideMappings=Backbone.Collection.extend({model:MPlaza.GridRuleGridSideMapping,modelId:function(e){return e.gridID+"-"+e.productID+"-"+e.sideID},getGridRuleID:function(){return this.parentModel&&this.parentModel.getGridRuleID?this.parentModel.getGridRuleID():null},findAssociation:function(e,t,i,n){for(var a=0;a<this.length;a++){var r=this.at(a);if(r.get("gridRuleID")==e&&r.get("gridID")==t&&r.get("productID")==i&&r.get("sideID")==n)return r}return null},sync:MPlaza.syncCloudflare}),MPlaza.GridRule=Backbone.AssociatedModel.extend({defaults:{name:"",sellerID:-1,associations:[],grids:[]},idAttribute:"gridRuleID",initialize:function(){var e=this;this.get("associations").parentModel=this,this.get("grids").parentModel=this,this.on("change",function(){e._fireEvent("change")}),this.get("associations").on("add",function(){e._fireEvent("change")}),this.get("associations").on("remove",function(){e._fireEvent("change")}),this.get("associations").on("change",function(){e._fireEvent("change")})},relations:[{type:Backbone.Many,key:"associations",collectionType:MPlaza.GridRuleGridSideMappings},{type:Backbone.Many,key:"grids",collectionType:MPlaza.Grids}],url:function(){var e=Zakeke.config.baseApiUrl+"gridrules";return null!=this.id&&null!=this.id&&(e=e+"/"+this.id),e},getGridRuleID:function(){return this.get("gridRuleID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.GridRules=Backbone.Collection.extend({model:MPlaza.GridRule,url:function(){return Zakeke.config.baseApiUrl+"gridrules/"},findGridRule:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("gridRuleID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.Quote=Backbone.AssociatedModel.extend({defaults:{sellerID:-1,designDocID:"",compositionDocID:"",orderDocID:"",visitorID:-1,visitorCode:"",customerID:-1,customerCode:"",formData:"",subject:"",statusID:1,createdOn:null,amount:0,shippingAmount:0,additionalAmountLabel:"",additionalAmount:0,modelPrice:0,variantName:"",quantity:1,notifyEmailList:"",quoteRuleID:-1},idAttribute:"quoteID",initialize:function(){},relations:[],getQuoteID:function(){return this.collection&&this.collection.getQuoteID?this.collection.getQuoteID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},url:function(){var e=Zakeke.config.baseApiUrl+"quotes";return null!=this.id&&null!=this.id&&(e=e+"/"+this.id),e},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.Quotes=Backbone.Collection.extend({model:MPlaza.Quote,getQuoteID:function(){return this.parentModel&&this.parentModel.getQuoteID?this.parentModel.getQuoteID():null},findQuote:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("quoteID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.DesignEffectTemplate=Backbone.AssociatedModel.extend({defaults:{name:"",sellerID:-1,previewDesignEffect:null,outputDesignEffect:null},idAttribute:"templateID",initialize:function(){},relations:[{type:Backbone.One,key:"previewDesignEffect",relatedModel:MPlaza.DesignEffect},{type:Backbone.One,key:"outputDesignEffect",relatedModel:MPlaza.DesignEffect}],url:function(){var e=Zakeke.config.baseApiUrl+"gridrules";return void 0!==this.id&&null!==this.id&&(e=e+"/"+this.id),e},getTemplateID:function(){return this.get("templateID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.DesignEffectTemplates=Backbone.Collection.extend({model:MPlaza.DesignEffectTemplate,url:function(){return Zakeke.config.baseApiUrl+"designeffecttemplates/"},findTemplate:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("templateID")==e)return i}return null},sync:MPlaza.syncCloudflare}),MPlaza.ShapeCategory=Backbone.AssociatedModel.extend({defaults:{name:"",imagesCount:0},idAttribute:"shapeCategoryID",initialize:function(){},relations:[],url:function(){var e=Zakeke.config.baseApiUrl+"shapeCategories";return null!=this.id&&null!=this.id&&this.id>0&&(e=e+"/"+this.id),e},sync:MPlaza.syncCloudflare}),MPlaza.ShapeCategories=Backbone.Collection.extend({model:MPlaza.ShapeCategory,url:function(){return Zakeke.config.baseApiUrl+"shapeCategories"},comparator:function(e){return e.get("name")},sync:MPlaza.syncCloudflare}),MPlaza.ShapeAssignedCategory=Backbone.AssociatedModel.extend({defaults:{shapeCategoryID:-1,name:""},initialize:function(){},relations:[],getShapeID:function(){return this.collection&&this.collection.getShapeID?this.collection.getShapeID():null},getParentModel:function(){return this.collection&&this.collection.parentModel?this.collection.parentModel:null},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.ShapeAssignedCategories=Backbone.Collection.extend({model:MPlaza.ShapeAssignedCategory,getShapeID:function(){return this.parentModel&&this.parentModel.getShapeID?this.parentModel.getShapeID():null},findShapeCategory:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("shapeCategoryID")===e)return i}return null},setupUrlForShapeID:function(e){this.url=function(){return Zakeke.config.baseApiUrl+"shapes/"+e+"/categories"}},sync:MPlaza.syncCloudflare}),MPlaza.Shape=Backbone.AssociatedModel.extend({defaults:{name:"",tags:"",pathDataUrl:"",imageUrl:"",maskImageUrl:"",categories:[]},idAttribute:"shapeID",initialize:function(){var e=this;this.get("categories").parentModel=this,this.get("categories").url=function(){return e.url()+"/"+e.id+"/categories"},this.get("shapeGuid")||this.set("shapeGuid",MPlaza.generateUUID())},relations:[{type:Backbone.Many,key:"categories",collectionType:MPlaza.ShapeAssignedCategories}],url:function(){var e=Zakeke.config.baseApiUrl+"shapes";return void 0!==this.id&&null!==this.id&&this.id>0&&(e=e+"/"+this.id),e},getShapeID:function(){return this.get("shapeID")},toString:function(){},sync:MPlaza.syncCloudflare}),MPlaza.Shapes=Backbone.Collection.extend({model:MPlaza.Shape,url:function(){return Zakeke.config.baseApiUrl+"shapes"},getShape:function(e){for(var t=0;t<this.length;t++){var i=this.at(t);if(i.get("shapeID")===e)return i}return null},sync:MPlaza.syncCloudflare}),function(e){!function(e){var t=function(){function e(){this._topNode=void 0,this._count=0,this._changedEventListeners=[],this._enableChangedEvent=!0}return e.prototype.count=function(){return this._count},e.prototype.isEmpty=function(){return void 0===this._topNode},e.prototype.push=function(e){var t=new i(e,this._topNode);this._topNode=t,this._count++,this.fireChangedEventListener()},e.prototype.pop=function(){if(0!=this._count){var e=this._topNode;return this._topNode=e.previous,this._count--,this.fireChangedEventListener(),e.data}},e.prototype.peek=function(){return this._topNode.data},e.prototype.clear=function(){this._topNode&&this._count>0&&(this._topNode=void 0,this._count=0,this.fireChangedEventListener())},e.prototype.addChangedEventListener=function(e){this._changedEventListeners.push(e)},e.prototype.removeChangedEventListener=function(e){for(var t=0;t<this._changedEventListeners.length;t++)this._changedEventListeners[t]==e&&this._changedEventListeners.splice(t--,1)},e.prototype.fireChangedEventListener=function(){if(this._enableChangedEvent)for(var e=0;e<this._changedEventListeners.length;e++){(0,this._changedEventListeners[e])()}},e.prototype.getAllData=function(){for(var e=new Array(this._count),t=this._count-1,i=this._topNode;i;)e[t]=i.data,i=i.previous,t--;return e},e.prototype.getLastData=function(e){for(var t=this._topNode;t;){if(!e||e(t.data))return t.data;t=t.previous}return null},e.prototype.getAllDataAfter=function(e){for(var t=[],i=this._topNode;i&&i.data!=e;)t.push(i.data),i=i.previous;return t.reverse()},e.prototype.removeDataArray=function(e){var t=this;this._enableChangedEvent=!1,e.forEach(function(e){t.removeData(e)}),this._enableChangedEvent=!0,this.fireChangedEventListener()},e.prototype.removeData=function(e){var t=this.getNodeHavingData(e);t&&(this.removeNode(t),this.fireChangedEventListener())},e.prototype.getNodeHavingData=function(e){for(var t=this._topNode;t;){if(t.data==e)return t;t=t.previous}return null},e.prototype.removeNode=function(e){if(e)if(this._topNode==e)this._topNode=e.previous,this._count--;else{var t=this.getFollowingNode(e);t&&(t.previous=e.previous,this._count--)}},e.prototype.getFollowingNode=function(e){for(var t=this._topNode;t;){if(t.previous==e)return t;t=t.previous}},e}();e.Stack=t;var i=function(){return function(e,t){this.previous=t,this.data=e}}()}(e.Customizer||(e.Customizer={}))}(Zakeke||(Zakeke={})),MarvinColorModelConverter.rgbToBinary=function(e,t){for(var i=new MarvinImage(e.getWidth(),e.getHeight(),MarvinImage.COLOR_MODEL_BINARY),n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++){Math.ceil(.3*e.getIntComponent0(a,n)+.59*e.getIntComponent1(a,n)+.11*e.getIntComponent2(a,n))<=t?i.setBinaryColor(a,n,!0):i.setBinaryColor(a,n,!1)}return i},MarvinColorModelConverter.binaryToRgb=function(e){for(var t=new MarvinImage(e.getWidth(),e.getHeight(),MarvinImage.COLOR_MODEL_RGB),i=0;i<e.getHeight();i++)for(var n=0;n<e.getWidth();n++)e.getBinaryColor(n,i)?t.setIntColor(n,i,255,0,0,0):t.setIntColor(n,i,255,255,255,255);return t},MarvinColorModelConverter.rgbToHsv=function(e){for(var t,i,n,a=new Array(3*e.length),r=0;r<e.length;r++){t=(16711680&e[r])>>>16,i=(65280&e[r])>>>8,n=255&e[r],t/=255,i/=255,n/=255;var o,s,l,h=Math.max(Math.max(t,i),n),d=h-Math.min(Math.min(t,i),n);o=0!=d?h==t?i>=n?(i-n)/d*60:(i-n)/d*60+360:h==i?(n-t)/d*60+120:(t-i)/d*60+240:0,l=h,s=0!=d?d/l:0,a[3*r]=o,a[3*r+1]=s,a[3*r+2]=l}return a},MarvinColorModelConverter.hsvToRgb=function(e){for(var t=new Array(e.length/3),i=0,n=0;i<e.length;i+=3,n++){var a=e[i],r=e[i+1],o=e[i+2],s=Math.ceil(a/60%6),l=a/60-s,h=o*(1-r),d=o*(1-l*r),c=o*(1-(1-l)*r),u=0,g=0,f=0;switch(Math.ceil(s)){case 0:u=Math.ceil(255*o),g=Math.ceil(255*c),f=Math.ceil(255*h);break;case 1:u=Math.ceil(255*d),g=Math.ceil(255*o),f=Math.ceil(255*h);break;case 2:u=Math.ceil(255*h),g=Math.ceil(255*o),f=Math.ceil(255*c);break;case 3:u=Math.ceil(255*h),g=Math.ceil(255*d),f=Math.ceil(255*o);break;case 4:u=Math.ceil(255*c),g=Math.ceil(255*h),f=Math.ceil(255*o);break;case 5:u=Math.ceil(255*o),g=Math.ceil(255*h),f=Math.ceil(255*d)}t[n]=4278190080+(u<<16)+(g<<8)+f}return t},MarvinImage.COLOR_MODEL_RGB=0,MarvinImage.COLOR_MODEL_BINARY=1,MarvinImage.prototype.create=function(e,t){this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t,this.ctx=this.canvas.getContext("2d"),this.imageData=this.ctx.getImageData(0,0,e,t),this.width=e,this.height=t},MarvinImage.prototype.setDimension=function(e,t){this.create(e,t)},MarvinImage.prototype.load=function(e,t){this.onload=t,this.image=new Image;var i=this;this.image.onload=function(){i.callbackImageLoaded(i)},this.image.crossOrigin="anonymous",this.image.src=e},MarvinImage.prototype.callbackImageLoaded=function(e){e.width=e.image.width,e.height=e.image.height,e.canvas=document.createElement("canvas"),e.canvas.width=e.image.width,e.canvas.height=e.image.height,e.ctx=e.canvas.getContext("2d"),e.ctx.drawImage(e.image,0,0),this.imageData=e.ctx.getImageData(0,0,e.getWidth(),e.getHeight()),null!=e.onload&&e.onload()},MarvinImage.prototype.clone=function(){var e=new MarvinImage(this.getWidth(),this.getHeight(),this.colorModel);return MarvinImage.copyColorArray(this,e),e},MarvinImage.prototype.update=function(e){this.canvas.getContext("2d").putImageData(this.imageData,0,0)},MarvinImage.prototype.clear=function(e){for(var t=0;t<this.getHeight();t++)for(var i=0;i<this.getWidth();i++)this.setIntColor(i,t,e)},MarvinImage.prototype.getColorModel=function(){return this.colorModel},MarvinImage.prototype.getAlphaComponent=function(e,t){var i=4*(t*this.getWidth()+e);return this.imageData.data[i+3]},MarvinImage.prototype.setAlphaComponent=function(e,t,i){var n=4*(t*this.getWidth()+e);this.imageData.data[n+3]=i},MarvinImage.prototype.getIntComponent0=function(e,t){var i=4*(t*this.getWidth()+e);return this.imageData.data[i]},MarvinImage.prototype.getIntComponent1=function(e,t){var i=4*(t*this.getWidth()+e);return this.imageData.data[i+1]},MarvinImage.prototype.getIntComponent2=function(e,t){var i=4*(t*this.getWidth()+e);return this.imageData.data[i+2]},MarvinImage.prototype.setIntColor=function(e,t,i,n,a,r){null==n?this.setIntColor1(e,t,i):null==a&&null==r?this.setIntColor2(e,t,i,n):null==r?this.setIntColor3(e,t,i,n,a):this.setIntColor4(e,t,i,n,a,r)},MarvinImage.prototype.getIntColor=function(e,t){var i=4*(t*this.getWidth()+e);return 4294967296+(this.imageData.data[i+3]<<24)+(this.imageData.data[i]<<16)+(this.imageData.data[i+1]<<8)+this.imageData.data[i+2]},MarvinImage.prototype.setIntColor1=function(e,t,i){var n=(4278190080&i)>>>24,a=(16711680&i)>>16,r=(65280&i)>>8,o=255&i;this.setIntColor4(e,t,n,a,r,o)},MarvinImage.prototype.setBinaryColor=function(e,t,i){var n=t*this.getWidth()+e;this.arrBinaryColor[n]=i},MarvinImage.prototype.getBinaryColor=function(e,t){var i=t*this.getWidth()+e;return this.arrBinaryColor[i]},MarvinImage.copyColorArray=function(e,t){if(e.getColorModel()==t.getColorModel())switch(e.getColorModel()){case MarvinImage.COLOR_MODEL_RGB:for(var i=0;i<e.imageData.data.length;i++)t.imageData.data[i]=e.imageData.data[i];break;case MarvinImage.COLOR_MODEL_BINARY:for(i=0;i<e.arrBinaryColor.length;i++)t.arrBinaryColor[i]=e.arrBinaryColor[i]}},MarvinImage.prototype.drawRect=function(e,t,i,n,a){for(var r=e;r<e+i;r++)this.setIntColor(r,t,a),this.setIntColor(r,t+(n-1),a);for(r=t;r<t+n;r++)this.setIntColor(e,r,a),this.setIntColor(e+(i-1),r,a)},MarvinImage.prototype.fillRect=function(e,t,i,n,a){for(var r=e;r<e+i;r++)for(var o=t;o<t+n;o++)r<this.getWidth()&&o<this.getHeight()&&this.setIntColor(r,o,a)},MarvinImage.prototype.setColorToAlpha=function(e,t){for(var i=0;i<this.height;i++)for(var n=0;n<this.width;n++)(16777215&this.getIntColor(n,i))==(16777215&e)&&this.setAlphaComponent(n,i,t)},MarvinImage.prototype.setAlphaToColor=function(e){for(var t=0;t<this.height;t++)for(var i=0;i<this.width;i++)0==this.getAlphaComponent(i,t)&&this.setIntColor(i,t,4294967295)},MarvinImage.prototype.setIntColor2=function(e,t,i,n){var a=(16711680&n)>>16,r=(65280&n)>>8,o=255&n;this.setIntColor4(e,t,i,a,r,o)},MarvinImage.prototype.setIntColor3=function(e,t,i,n,a){this.setIntColor4(e,t,255,i,n,a)},MarvinImage.prototype.setIntColor4=function(e,t,i,n,a,r){var o=4*(t*this.getWidth()+e);this.imageData.data[o]=n,this.imageData.data[o+1]=a,this.imageData.data[o+2]=r,this.imageData.data[o+3]=i},MarvinImage.prototype.getWidth=function(){return this.width},MarvinImage.prototype.getHeight=function(){return this.height},MarvinImage.prototype.isValidPosition=function(e,t){return e>=0&&e<this.width&&t>=0&&t<this.height},MarvinImage.prototype.draw=function(e,t,i,n){null==t&&(t=0),null==i&&(i=0),e.getContext("2d").putImageData(this.imageData,t,i)},MarvinImage.prototype.toBlob=function(){return this.update(),MarvinImage.dataURItoBlob(this.canvas.toDataURL("image/png"))},MarvinImage.dataURItoBlob=function(e){var t;t=e.split(",")[0].indexOf("base64")>=0?atob(e.split(",")[1]):unescape(e.split(",")[1]);for(var i=e.split(",")[0].split(":")[1].split(";")[0],n=new Uint8Array(t.length),a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return new Blob([n],{type:i})},MarvinImageMask.prototype.getWidth=function(){return this.width},MarvinImageMask.prototype.getHeight=function(){return this.height},MarvinImageMask.prototype.addPixel=function(e,t){this.arrMask[e][t]=!0},MarvinImageMask.prototype.removePixel=function(e,t){this.arrMask[e][t]=!1},MarvinImageMask.prototype.clear=function(){if(null!=this.arrMask)for(var e=0;e<height;e++)for(var t=0;t<width;t++)this.arrMask[t][e]=!1},MarvinImageMask.prototype.getMask=function(){return this.arrMask},MarvinImageMask.prototype.addRectRegion=function(e,t,i,n){for(var a=e;a<e+i;a++)for(var r=t;r<t+n;r++)this.arrMask[a][r]=!0},MarvinImageMask.createNullMask=function(){return new MarvinImageMask(0,0)},MarvinImageMask.NULL_MASK=MarvinImageMask.createNullMask(),MarvinSegment.segmentMinDistance=function(e,t){for(var i,n,a=0;a<e.size()-1;a++)for(var r=a+1;r<e.size();r++)i=e[a],n=e[r],MarvinMath.euclidianDistance((i.x1+i.x2)/2,(i.y1+i.y2)/2,(n.x1+n.x2)/2,(n.y1+n.y2)/2)<t&&(e.splice(r,1),r--)},MarvinColor.prototype.setId=function(e){this.id=e},MarvinColor.prototype.getId=function(){return this.id},MarvinColor.prototype.setName=function(e){this.name=e},MarvinColor.prototype.getName=function(){return this.name};var MarvinJSUtils=new Object;MarvinJSUtils.createMatrix2D=function(e,t,i){for(var n=new Array(e),a=0;a<n.length;a++)n[a]=new Array(t),n[a].fill(i);return n},MarvinJSUtils.createMatrix3D=function(e,t,i,n){for(var a=new Array(e),r=0;r<a.length;r++){a[r]=new Array(t);for(var o=0;o<a[r].length;o++)a[r][o]=new Array(i),a[r][o].fill(n)}return a},MarvinJSUtils.createMatrix4D=function(e,t,i,n,a){for(var r=new Array(e),o=0;o<r.length;o++){r[o]=new Array(t);for(var s=0;s<r[o].length;s++){r[o][s]=new Array(i);for(var l=0;l<r[o][s].length;l++)r[o][s][l]=new Array(n),r[o][s][l].fill(a)}}return r};var MarvinMath=new Object;function DetermineFixedCameraBackground(){MarvinAbstractImagePlugin.super(this),this.load()}function DetermineSceneBackground(){MarvinAbstractImagePlugin.super(this),this.load()}function GaussianBlur(){MarvinAbstractImagePlugin.super(this),this.load()}function AlphaBoundary(){MarvinAbstractImagePlugin.super(this),this.load()}function AverageColor(){MarvinAbstractImagePlugin.super(this),this.load()}function BlackAndWhite(){MarvinAbstractImagePlugin.super(this),this.MAX_RLEVEL=.03,this.load()}function BrightnessAndContrast(){MarvinAbstractImagePlugin.super(this),this.load()}function ColorChannel(){MarvinAbstractImagePlugin.super(this),this.load()}function Emboss(){MarvinAbstractImagePlugin.super(this),this.load()}function GrayScale(){MarvinAbstractImagePlugin.super(this),this.load()}function Invert(){MarvinAbstractImagePlugin.super(this),this.load()}function Sepia(){MarvinAbstractImagePlugin.super(this),this.load()}function Thresholding(){MarvinAbstractImagePlugin.super(this),this.load(),this.threshold=null,this.thresholdRange=null,this.neighborhood=null,this.range=null}function ThresholdingNeighborhood(){MarvinAbstractImagePlugin.super(this),this.load()}function CombineByAlpha(){MarvinAbstractImagePlugin.super(this),this.load()}function MergePhotos(){MarvinAbstractImagePlugin.super(this),this.load()}function Convolution(){MarvinAbstractImagePlugin.super(this),this.load()}function Moravec(){MarvinAbstractImagePlugin.super(this),this.load()}function Prewitt(){MarvinAbstractImagePlugin.super(this),this.matrixPrewittX=[[1,0,-1],[1,0,-1],[1,0,-1]],this.matrixPrewittY=[[1,1,1],[0,0,0],[-1,-1,-1]],this.load()}function BoundaryFill(){MarvinAbstractImagePlugin.super(this),this.load()}function ErrorDiffusion(){MarvinAbstractImagePlugin.super(this),this.load()}MarvinMath.getTrueMatrix=function(e,t){for(var i=MarvinJSUtils.createMatrix2D(e,t),n=0;n<e;n++)for(var a=0;a<t;a++)i[n][a]=!0;return i},MarvinMath.scaleMatrix=function(e,t){for(var i=MarvinJSUtils.createMatrix2D(e.length,e.length),n=0;n<e.length;n++)for(var a=0;a<e.length;a++)i[n][a]=e[n][a]*t;return i},MarvinMath.euclideanDistance=function(e,t,i,n,a,r){return null!=r?MarvinMath.euclideanDistance3D(e,t,i,n,a,r):MarvinMath.euclideanDistance3D(e,t,i,n)},MarvinMath.euclideanDistance2D=function(e,t,i,n){var a=e-i,r=t-n;return Math.sqrt(a*a+r*r)},MarvinMath.euclideanDistance3D=function(e,t,i,n,a,r){var o=e-n,s=t-a,l=i-r;return Math.sqrt(o*o+s*s+l*l)},DetermineFixedCameraBackground.prototype.load=function(){this.initialized=!1},DetermineFixedCameraBackground.prototype.initialize=function(e){this.weights=this.weights=MarvinJSUtils.createMatrix4D(e.getWidth(),e.getHeight(),3,26,0),initialized=!0},DetermineFixedCameraBackground.prototype.process=function(e,t,i,n,a){this.initialized||this.initialize(e);for(var r=0;r<e.getHeight();r++)for(var o=0;o<e.getWidth();o++){var s=e.getIntComponent0(o,r),l=e.getIntComponent1(o,r),h=e.getIntComponent2(o,r);weights[o][r][0][s/10]++,weights[o][r][1][l/10]++,weights[o][r][2][h/10]++,t.setIntColor(o,r,255,this.getProbableColor(weights[o][r][0]),this.getProbableColor(weights[o][r][1]),this.getProbableColor(weights[o][r][2]))}},DetermineFixedCameraBackground.prototype.getProbableColor=function(e){for(var t=-1,i=0,n=0;n<e.length;n++)(-1==t||e[n]>t)&&(t=e[n],i=n);return 10*i},DetermineSceneBackground.prototype.load=function(){this.setAttribute("threshold",30)},DetermineSceneBackground.prototype.process=function(e,t){for(var i=this.getAttribute("threshold"),n=e[0],a=0;a<n.getHeight();a++)for(var r=0;r<n.getWidth();r++)t.setIntColor(r,a,this.getBackgroundPixel(r,a,e,i))},DetermineSceneBackground.prototype.getBackgroundPixel=function(e,t,i,n){var a=new Array;for(var r in i){var o=i[r],s=new Array(4);if(s[0]=o.getIntComponent0(e,t),s[1]=o.getIntComponent1(e,t),s[2]=o.getIntComponent2(e,t),s[3]=0,0==a.length)a.push(s);else{var l=!1;for(var h in a){var d=a[h];if(Math.abs(d[0]-s[0])<.3*n&&Math.abs(d[1]-s[1])<.3*n&&Math.abs(d[2]-s[2])<.3*n){d[0]=Math.floor((d[0]+s[0])/2),d[1]=Math.floor((d[1]+s[1])/2),d[2]=Math.floor((d[2]+s[2])/2),d[3]++,l=!0;break}}l||a.push(s)}}var c=-1,u=0;for(d=null,r=0;r<a.length;r++)d=a[r],(-1==c||d[3]>c)&&(c=d[3],u=r);return 4278190080+((d=a[u])[0]<<16)+(d[1]<<8)+d[2]},GaussianBlur.prototype.load=function(){this.RED=0,this.GREEN=1,this.BLUE=2,this.kernelMatrix=null,this.resultMatrix=null,this.appiledkernelMatrix=null,this.radius=null,this.setAttribute("radius",3)},GaussianBlur.prototype.process=function(e,t,i,n,a){this.radius=this.getAttribute("radius");var r,o=e.getWidth(),s=e.getHeight();this.kernelMatrix=this.getGaussianKernel(),this.resultMatrix=MarvinJSUtils.createMatrix3D(o,s,3,0),this.appiledkernelMatrix=MarvinJSUtils.createMatrix2D(o,s,0);for(var l=n.getMask(),h=0;h<o;h++)for(var d=0;d<s;d++)(null==l||l[h][d])&&(r=e.getIntColor(h,d),this.applyKernel(h,d,r,t));for(h=0;h<o;h++)for(d=0;d<s;d++)(null==l||l[h][d])&&(this.resultMatrix[h][d][this.RED]=this.resultMatrix[h][d][0]/this.appiledkernelMatrix[h][d]%256,this.resultMatrix[h][d][this.GREEN]=this.resultMatrix[h][d][1]/this.appiledkernelMatrix[h][d]%256,this.resultMatrix[h][d][this.BLUE]=this.resultMatrix[h][d][2]/this.appiledkernelMatrix[h][d]%256,t.setIntColor(h,d,e.getAlphaComponent(h,d),Math.floor(this.resultMatrix[h][d][0]),Math.floor(this.resultMatrix[h][d][1]),Math.floor(this.resultMatrix[h][d][2])))},GaussianBlur.prototype.getGaussianKernel=function(){for(var e,t,i,n=MarvinJSUtils.createMatrix2D(2*this.radius+1,2*this.radius+1),a=this.radius/3,r=1;r<=2*this.radius+1;r++)for(var o=1;o<=2*this.radius+1;o++)t=Math.abs(r-(this.radius+1)),i=Math.abs(o-(this.radius+1)),e=Math.sqrt(t*t+i*i),n[o-1][r-1]=1/(2*Math.PI*a*a)*Math.exp(-e*e/(2*a*a));return n},GaussianBlur.prototype.applyKernel=function(e,t,i,n){for(var a=t;a<t+2*this.radius;a++)for(var r=e;r<e+2*this.radius;r++)r-this.radius>=0&&r-this.radius<n.getWidth()&&a-this.radius>=0&&a-this.radius<n.getHeight()&&(this.resultMatrix[r-this.radius][a-this.radius][this.RED]+=((16711680&i)>>>16)*this.kernelMatrix[r-e][a-t],this.resultMatrix[r-this.radius][a-this.radius][this.GREEN]+=((65280&i)>>>8)*this.kernelMatrix[r-e][a-t],this.resultMatrix[r-this.radius][a-this.radius][this.BLUE]+=(255&i)*this.kernelMatrix[r-e][a-t],this.appiledkernelMatrix[r-this.radius][a-this.radius]+=this.kernelMatrix[r-e][a-t])},AlphaBoundary.prototype.load=function(){this.setAttribute("radius",5)},AlphaBoundary.prototype.process=function(e,t,i,n,a){for(var r=this.getAttribute("radius"),o=0;o<t.getHeight();o++)for(var s=0;s<t.getWidth();s++)this.alphaRadius(t,s,o,r)},AlphaBoundary.prototype.alphaRadius=function(e,t,i,n){for(var a,r=e.getAlphaComponent(t,i),o=0,s=0,l=Math.floor(n/2),h=i-l;h<i+l;h++)for(var d=t-l;d<t+l;d++)d>=0&&d<e.getWidth()&&h>=0&&h<e.getHeight()&&(o+=e.getAlphaComponent(d,h),s++);(a=Math.floor(o/s))<r&&e.setAlphaComponent(t,i,a)},AverageColor.prototype.load=function(){},AverageColor.prototype.process=function(e,t,i,n,a){for(var r=0,o=0,s=0,l=0;l<e.getWidth();l++)for(var h=0;h<e.getHeight();h++)r+=e.getIntComponent0(l,h),o+=e.getIntComponent1(l,h),s+=e.getIntComponent2(l,h);var d=e.getWidth()*e.getHeight();r=Math.round(r/d),o=Math.round(o/d),s=Math.round(s/d),null!=i&&i.set("averageColor",[r,o,s])},BlackAndWhite.prototype.load=function(){this.grayScale=new GrayScale,this.setAttribute("level",10)},BlackAndWhite.prototype.process=function(e,t,i,n,a){this.grayScale.process(e,t);for(var r,o=this.getAttribute("level"),s=o/100*this.MAX_RLEVEL,l=0,h=0;h<t.getHeight();h++)for(var d=0;d<t.getWidth();d++)r=(r=e.getIntComponent0(d,h))<=127?Math.max(r*(1-(127-r)*s),0):Math.min(r*(1+(r-127)*s),255),l++<1&&(console.log("gray:"+r),console.log("level:"+o),console.log("rlevel:"+s)),t.setIntColor(d,h,255,Math.floor(r),Math.floor(r),Math.floor(r))},BrightnessAndContrast.prototype.load=function(){this.setAttribute("brightness",0),this.setAttribute("contrast",0)},BrightnessAndContrast.prototype.process=function(e,t,i,n,a){var r,o,s,l=this.getAttribute("brightness"),h=this.getAttribute("contrast");h=Math.pow((127+h)/127,2);for(var d=0;d<e.getWidth();d++)for(var c=0;c<e.getHeight();c++)r=e.getIntComponent0(d,c),o=e.getIntComponent1(d,c),s=e.getIntComponent2(d,c),(r+=(1-r/255)*l)<0&&(r=0),r>255&&(r=255),(o+=(1-o/255)*l)<0&&(o=0),o>255&&(o=255),(s+=(1-s/255)*l)<0&&(s=0),s>255&&(s=255),t.setIntColor(d,c,e.getAlphaComponent(d,c),Math.floor(r),Math.floor(o),Math.floor(s));for(d=0;d<e.getWidth();d++)for(c=0;c<e.getHeight();c++)r=t.getIntComponent0(d,c),o=t.getIntComponent1(d,c),s=t.getIntComponent2(d,c),r/=255,r-=.5,r*=h,r+=.5,o/=255,o-=.5,o*=h,o+=.5,s/=255,s-=.5,s*=h,s+=.5,(r*=255)<0&&(r=0),r>255&&(r=255),(o*=255)<0&&(o=0),o>255&&(o=255),(s*=255)<0&&(s=0),s>255&&(s=255),t.setIntColor(d,c,e.getAlphaComponent(d,c),Math.floor(r),Math.floor(o),Math.floor(s))},ColorChannel.prototype.load=function(){this.setAttribute("red",0),this.setAttribute("green",0),this.setAttribute("blue",0)},ColorChannel.prototype.process=function(e,t,i,n,a){var r,o,s,l=this.getAttribute("red"),h=this.getAttribute("green"),d=this.getAttribute("blue"),c=1+Math.abs(l/100*2.5),u=1+Math.abs(h/100*2.5),g=1+Math.abs(d/100*2.5);c=l>0?c:1/c,u=h>0?u:1/u,g=d>0?g:1/g;for(var f=0;f<e.getHeight();f++)for(var p=0;p<e.getWidth();p++)r=e.getIntComponent0(p,f),o=e.getIntComponent1(p,f),s=e.getIntComponent2(p,f),r=Math.min(r*c,255),o=Math.min(o*u,255),s=Math.min(s*g,255),t.setIntColor(p,f,255,r,o,s)},Emboss.prototype.load=function(){},Emboss.prototype.process=function(e,t,i,n,a){for(var r=n.getMask(),o=0;o<e.getWidth();o++)for(var s=0;s<e.getHeight();s++)if(null==r||r[o][s]){var l=0,h=0,d=0;s>0&&o>0?(l=e.getIntComponent0(o,s)-e.getIntComponent0(o-1,s-1),h=e.getIntComponent1(o,s)-e.getIntComponent1(o-1,s-1),d=e.getIntComponent2(o,s)-e.getIntComponent2(o-1,s-1)):(l=0,h=0,d=0);var c=l;Math.abs(h)>Math.abs(c)&&(c=h),Math.abs(d)>Math.abs(c)&&(c=d);var u=Math.max(Math.min(128+c,255),0);t.setIntColor(o,s,255,u,u,u)}else t.setIntColor(o,s,255,e.getIntColor(o,s))},GrayScale.prototype.load=function(){},GrayScale.prototype.process=function(e,t,i,n,a){var r,o,s,l,h;null!=n&&(r=n.getMask());for(var d=0;d<e.getWidth();d++)for(var c=0;c<e.getHeight();c++)(null==r||r[d][c])&&(o=e.getIntComponent0(d,c),s=e.getIntComponent1(d,c),l=e.getIntComponent2(d,c),h=Math.ceil(.3*o+.59*s+.11*l),t.setIntColor(d,c,e.getAlphaComponent(d,c),h,h,h))},Invert.prototype.load=function(){},Invert.prototype.process=function(e,t,i,n,a){for(var r,o,s,l=n.getMask(),h=0;h<e.getWidth();h++)for(var d=0;d<e.getHeight();d++)(null==l||l[h][d])&&(r=255-e.getIntComponent0(h,d),o=255-e.getIntComponent1(h,d),s=255-e.getIntComponent2(h,d),t.setIntColor(h,d,e.getAlphaComponent(h,d),r,o,s))},Sepia.prototype.load=function(){this.setAttribute("txtValue","20"),this.setAttribute("intensity",20)},Sepia.prototype.process=function(e,t,i,n,a){var r,o,s,l;l=this.getAttribute("intensity");e.getWidth(),e.getHeight();for(var h=n.getMask(),d=0;d<e.getWidth();d++)for(var c=0;c<e.getHeight();c++)(null==h||h[d][c])&&(r=o=s=((r=e.getIntComponent0(d,c))+(o=e.getIntComponent1(d,c))+(s=e.getIntComponent2(d,c)))/3,r=this.truncate(r+2*l),o=this.truncate(o+l),t.setIntColor(d,c,e.getAlphaComponent(d,c),r,o,s))},Sepia.prototype.truncate=function(e){return e<0?0:e>255?255:e},Thresholding.prototype.load=function(){this.setAttribute("threshold",125),this.setAttribute("thresholdRange",-1),this.setAttribute("neighborhood",-1),this.setAttribute("range",-1),this.pluginGray=new GrayScale},Thresholding.prototype.process=function(e,t,i,n,a){this.threshold=this.getAttribute("threshold"),this.thresholdRange=this.getAttribute("thresholdRange"),this.neighborhood=this.getAttribute("neighborhood"),this.range=this.getAttribute("range"),-1==this.thresholdRange&&(this.thresholdRange=255-threshold),this.pluginGray.process(e,t,i,n,a);var r=n.getMask();-1==this.neighborhood&&-1==this.range?this.hardThreshold(e,t,r):this.contrastThreshold(e,t)},Thresholding.prototype.hardThreshold=function(e,t,i){for(var n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++)if(null==i||i[a][n]){var r=e.getIntComponent0(a,n);r<this.threshold||r>this.threshold+this.thresholdRange?t.setIntColor(a,n,e.getAlphaComponent(a,n),0,0,0):t.setIntColor(a,n,e.getAlphaComponent(a,n),255,255,255)}},Thresholding.prototype.contrastThreshold=function(e,t){this.range=1;for(var i=0;i<e.getWidth();i++)for(var n=0;n<e.getHeight();n++)checkNeighbors(i,n,neighborhood,neighborhood,e)?t.setIntColor(i,n,0,0,0):t.setIntColor(i,n,255,255,255)},Thresholding.prototype.checkNeighbors=function(e,t,i,n,a){var r,o=0;r=a.getIntComponent0(e,t);for(var s=0-i;s<=i;s++)for(var l=0-n;l<=n;l++)0==s&&0==l||r<getSafeColor(e+s,t+l,a)-range&&-1!=getSafeColor(e+s,t+l,a)&&o++;return o>i*n*.5},Thresholding.prototype.getSafeColor=function(e,t,i){return e>=0&&e<i.getWidth()&&t>=0&&t<i.getHeight()?i.getIntComponent0(e,t):-1},ThresholdingNeighborhood.prototype.load=function(){this.setAttribute("neighborhoodSide",10),this.setAttribute("samplingPixelDistance",1),this.setAttribute("thresholdPercentageOfAverage",1)},ThresholdingNeighborhood.prototype.process=function(e,t,i,n,a){for(var r=this.getAttribute("neighborhoodSide"),o=this.getAttribute("samplingPixelDistance"),s=this.getAttribute("thresholdPercentageOfAverage"),l=0;l<e.getHeight();l++)for(var h=0;h<e.getWidth();h++)this.theshold(e,t,h,l,s,r,o)},ThresholdingNeighborhood.prototype.theshold=function(e,t,i,n,a,r,o){for(var s=-1,l=-1,h=0,d=0,c=o,u=n-r/2;u<n+(c+r/2);u+=c)for(var g=i-r/2;g<i+r/2;g+=c)if(g>=0&&u>=0&&g<e.getWidth()&&u<e.getHeight()){var f=e.getIntComponent0(g,u);(-1==s||f<s)&&(s=f),(-1==l||f>l)&&(l=f),d+=f,h++}d/=h,(f=e.getIntComponent0(i,n))<d*a||l-s<=30?t.setIntColor(i,n,255,0,0,0):t.setIntColor(i,n,255,255,255,255)},CombineByAlpha.prototype.load=function(){this.setAttribute("x",0),this.setAttribute("y",0),this.setAttribute("imageOther",null)},CombineByAlpha.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("imageOther"),o=this.getAttribute("x"),s=this.getAttribute("y");if(null!=r)for(var l=0;l<e.getHeight();l++)for(var h=0;h<e.getWidth();h++){var d=h-o,c=l-s;if(d>=0&&d<r.getWidth()&&c>=0&&c<r.getHeight()){var u=r.getAlphaComponent(d,c);if(0!=u){var g=u/255,f=e.getIntComponent0(h,l),p=e.getIntComponent1(h,l),m=e.getIntComponent2(h,l),v=r.getIntComponent0(d,c),I=r.getIntComponent1(d,c),y=r.getIntComponent2(d,c),C=Math.floor(f*(1-g)+v*g),M=Math.floor(p*(1-g)+I*g),x=Math.floor(m*(1-g)+y*g);t.setIntColor(h,l,Math.max(e.getAlphaComponent(o,s),u),C,M,x)}else t.setIntColor(h,l,e.getIntColor(h,l))}else t.setIntColor(h,l,e.getIntColor(h,l))}},MergePhotos.prototype.load=function(){this.background=new DetermineSceneBackground,this.background.load(),this.setAttribute("threshold",30)},MergePhotos.prototype.process=function(e,t){if(e.length>0){var i=this.getAttribute("threshold");this.background.setAttribute("threshold",i);var n=e[0].clone();this.background.process(e,n),MarvinImage.copyColorArray(n,t),this.mergePhotos(e,t,n,i)}},MergePhotos.prototype.mergePhotos=function(e,t,i,n){for(var a in e){var r=e[a];this.mergePhotosSingle(r,t,i,n)}},MergePhotos.prototype.mergePhotosSingle=function(e,t,i,n){for(var a,r,o,s,l,h,d=0;d<e.getHeight();d++)for(var c=0;c<e.getWidth();c++)a=e.getIntComponent0(c,d),r=e.getIntComponent1(c,d),o=e.getIntComponent2(c,d),s=i.getIntComponent0(c,d),l=i.getIntComponent1(c,d),h=i.getIntComponent2(c,d),(Math.abs(a-s)>n||Math.abs(r-l)>n||Math.abs(o-h)>n)&&t.setIntColor(c,d,255,a,r,o)},Convolution.prototype.load=function(){this.setAttribute("matrix",null)},Convolution.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrix");if(null!=r&&r.length>0)for(var o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++)o>=r.length/2&&o<e.getHeight()-r.length/2&&s>=r[0].length/2&&s<e.getWidth()-r[0].length/2?this.applyMatrix(s,o,r,e,t):t.setIntColor(s,o,4278190080)},Convolution.prototype.applyMatrix=function(e,t,i,n,a){for(var r,o,s=0,l=0,h=0,d=Math.ceil(i[0].length/2),c=Math.ceil(i.length/2),u=0;u<i.length;u++)for(var g=0;g<i[0].length;g++)0!=i[u][g]&&(o=t+(u-c),(r=e+(g-d))>=0&&r<a.getWidth()&&o>=0&&o<a.getHeight()&&(s+=i[u][g]*n.getIntComponent0(r,o),l+=i[u][g]*n.getIntComponent1(r,o),h+=i[u][g]*n.getIntComponent2(r,o)));s=Math.abs(s),l=Math.abs(l),h=Math.abs(h),s+=a.getIntComponent0(e,t),l+=a.getIntComponent1(e,t),h+=a.getIntComponent2(e,t),s=Math.min(s,255),l=Math.min(l,255),h=Math.min(h,255),s=Math.max(s,0),l=Math.max(l,0),h=Math.max(h,0),a.setIntColor(e,t,n.getAlphaComponent(e,t),Math.floor(s),Math.floor(l),Math.floor(h))},Moravec.prototype.load=function(){this.setAttribute("matrixSize",3),this.setAttribute("threshold",0)},Moravec.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrixSize"),o=this.getAttribute("threshold"),s=new MarvinImage(e.getWidth(),e.getHeight());Marvin.grayScale(e,s);for(var l=MarvinJSUtils.createMatrix2D(s.getWidth(),s.getHeight(),0),h=MarvinJSUtils.createMatrix2D(s.getWidth(),s.getHeight(),0),d=0;d<s.getHeight();d++)for(var c=0;c<s.getWidth();c++)l[c][d]=this.c(c,d,r,s),l[c][d]<o&&(l[c][d]=0);for(c=0;c<l.length;c++)for(d=0;d<l[c].length;d++)h[c][d]=this.nonmax(c,d,r,l),h[c][d]>0&&(h[c][d]=1);null!=i&&i.set("cornernessMap",h)},Moravec.prototype.nonmax=function(e,t,i,n){var a=Math.floor(i/2);if(e-(a+1)>=0&&e+(a+1)<n.length&&t-(a+1)>=0&&t+(a+1)<n[0].length)for(var r=-a;r<=a;r++)for(var o=-a;o<=a;o++)if((0!=r||0!=o)&&n[e][t]<n[e+r][t+o])return 0;return n[e][t]},Moravec.directions=[[1,0],[-1,0],[0,1],[0,-1],[-1,-1],[1,-1],[-1,1],[1,1]],Moravec.prototype.c=function(e,t,i,n){var a,r=-1,o=Math.floor(i/2);if(e-(o+1)>=0&&e+(o+1)<n.getWidth()&&t-(o+1)>=0&&t+(o+1)<n.getHeight())for(var s=0;s<Moravec.directions.length;s++){a=0;for(var l=-o;l<=o;l++)for(var h=-o;h<=o;h++)a+=Math.pow(n.getIntComponent0(e+l,t+h)-n.getIntComponent0(e+l+Moravec.directions[s][0],t+h+Moravec.directions[s][1]),2);(-1==r||a<r)&&(r=a)}return r},Prewitt.prototype.load=function(){this.convolution=new Convolution,this.setAttribute("intensity",1)},Prewitt.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("intensity");1==r?(this.convolution.setAttribute("matrix",this.matrixPrewittX),this.convolution.process(e,t,null,n,this.previewMode),this.convolution.setAttribute("matrix",this.matrixPrewittY),this.convolution.process(e,t,null,n,this.previewMode)):(this.convolution.setAttribute("matrix",MarvinMath.scaleMatrix(this.matrixPrewittX,r)),this.convolution.process(e,t,null,n,a),this.convolution.setAttribute("matrix",MarvinMath.scaleMatrix(this.matrixPrewittY,r)),this.convolution.process(e,t,null,n,a))},BoundaryFill.prototype.load=function(){this.setAttribute("x",0),this.setAttribute("y",0),this.setAttribute("color",4294901760),this.setAttribute("tile",null),this.setAttribute("threshold",0)},BoundaryFill.prototype.process=function(e,t,i,n,a){var r,o,s,l=new Array,h=this.getAttribute("x"),d=this.getAttribute("y"),c=this.getAttribute("tile");if(this.threshold=this.getAttribute("threshold"),t.isValidPosition(h,d)){e.getIntColor(h,d);var u=e.getIntComponent0(h,d),g=e.getIntComponent1(h,d),f=e.getIntComponent2(h,d),p=this.getAttribute("color"),m=MarvinJSUtils.createMatrix2D(t.getWidth(),t.getHeight,!1);for(m[h][d]=!0,l.push(new MarvinPoint(h,d));l.length>0;){for(o=new MarvinPoint((r=l.splice(0,1)[0]).x,r.y),s=new MarvinPoint(r.x,r.y);o.x-1>=0&&this.match(e,o.x-1,o.y,u,g,f,this.threshold)&&!m[o.x-1][o.y];)o.x--;for(;s.x+1<e.getWidth()&&this.match(e,s.x+1,s.y,u,g,f,this.threshold)&&!m[s.x+1][s.y];)s.x++;for(var v=o.x;v<=s.x;v++)m[v][r.y]=!0,r.y-1>=0&&this.match(e,v,r.y-1,u,g,f,this.threshold)&&!m[v][r.y-1]&&l.push(new MarvinPoint(v,r.y-1)),r.y+1<t.getHeight()&&this.match(e,v,r.y+1,u,g,f,this.threshold)&&!m[v][r.y+1]&&l.push(new MarvinPoint(v,r.y+1))}if(null!=c);else for(var I=0;I<t.getHeight();I++)for(var y=0;y<t.getWidth();y++)m[y][I]&&t.setIntColor(y,I,p)}},BoundaryFill.prototype.match=function(e,t,i,n,a,r,o){return Math.abs(e.getIntComponent0(t,i)-n)+Math.abs(e.getIntComponent1(t,i)-a)+Math.abs(e.getIntComponent2(t,i)-r)<=o},ErrorDiffusion.prototype.load=function(){this.threshold=128},ErrorDiffusion.prototype.process=function(e,t,i,n,a){var r,o;Marvin.grayScale(e,t,i,n,a),null!=n&&(o=n.getMask());for(var s=0;s<t.getHeight();s++)for(var l=0;l<t.getWidth();l++){var h;if(null==o||o[l][s])(h=t.getIntComponent0(l,s))>this.threshold?(t.setIntColor(l,s,e.getAlphaComponent(l,s),255,255,255),r=-(255-h)):(t.setIntColor(l,s,e.getAlphaComponent(l,s),0,0,0),r=h),l+1<t.getWidth()&&(h=t.getIntComponent0(l+1,s),h+=Math.floor(.4375*r),h=this.getValidGray(h),t.setIntColor(l+1,s,e.getAlphaComponent(l+1,s),h,h,h),s+1<t.getHeight()&&(h=t.getIntComponent0(l+1,s+1),h+=Math.floor(.0625*r),h=this.getValidGray(h),t.setIntColor(l+1,s+1,e.getAlphaComponent(l+1,s+1),h,h,h))),s+1<t.getHeight()&&(h=t.getIntComponent0(l,s+1),h+=Math.floor(.3125*r),h=this.getValidGray(h),t.setIntColor(l,s+1,e.getAlphaComponent(l,s+1),h,h,h),l-1>=0&&(h=t.getIntComponent0(l-1,s+1),h+=Math.floor(.1875*r),h=this.getValidGray(h),t.setIntColor(l-1,s+1,e.getAlphaComponent(l-1,s+1),h,h,h)))}},ErrorDiffusion.prototype.getValidGray=function(e){return e<0?0:e>255?255:e};var MarvinAbstractImagePlugin=new Object;function Closing(){MarvinAbstractImagePlugin.super(this),this.load()}function Dilation(){MarvinAbstractImagePlugin.super(this),this.load()}function Erosion(){MarvinAbstractImagePlugin.super(this),this.load()}function FindTextRegions(){MarvinAbstractImagePlugin.super(this),this.load()}function IteratedFunctionSystem(){MarvinAbstractImagePlugin.super(this),this.load()}function Crop(){MarvinAbstractImagePlugin.super(this),this.load()}function FloodfillSegmentation(){MarvinAbstractImagePlugin.super(this),this.load()}function Scale(){MarvinAbstractImagePlugin.super(this),this.load()}function MarvinAttributes(){this.hashAttributes=new Object}function MarvinPoint(e,t){this.x=e,this.y=t}MarvinAbstractImagePlugin.super=function(e){e.attributes={},e.setAttribute=MarvinAbstractImagePlugin.setAttribute,e.getAttribute=MarvinAbstractImagePlugin.getAttribute},MarvinAbstractImagePlugin.setAttribute=function(e,t){this.attributes[e]=t},MarvinAbstractImagePlugin.getAttribute=function(e,t){return this.attributes[e]},Closing.prototype.load=function(){this.matrix=MarvinJSUtils.createMatrix2D(3,3,!0),this.setAttribute("matrix",3)},Closing.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrix");e.getColorModel()==MarvinImage.COLOR_MODEL_BINARY&&null!=r&&(Marvin.morphologicalDilation(e,t,r),MarvinImage.copyColorArray(t,e),Marvin.morphologicalErosion(e,t,r))},Dilation.prototype.load=function(){this.matrix=MarvinJSUtils.createMatrix2D(3,3,!0),this.setAttribute("matrix",3)},Dilation.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrix");if(e.getColorModel()==MarvinImage.COLOR_MODEL_BINARY&&null!=r){MarvinImage.copyColorArray(e,t);for(var o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++)this.applyMatrix(s,o,r,e,t)}},Dilation.prototype.applyMatrix=function(e,t,i,n,a){var r,o,s=i[0].length/2,l=i.length/2;if(n.getBinaryColor(e,t))for(var h=0;h<i.length;h++)for(var d=0;d<i.length;d++)h==l&&d==s||!i[h][d]||(o=t+(h-l),(r=e+(d-s))>0&&r<a.getWidth()&&o>0&&o<a.getHeight()&&a.setBinaryColor(r,o,!0))},Erosion.prototype.load=function(){this.matrix=MarvinJSUtils.createMatrix2D(3,3,!0),this.setAttribute("matrix",3)},Erosion.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("matrix");if(e.getColorModel()==MarvinImage.COLOR_MODEL_BINARY&&null!=r){MarvinImage.copyColorArray(e,t);for(var o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++)this.applyMatrix(s,o,r,e,t)}},Erosion.prototype.applyMatrix=function(e,t,i,n,a){var r,o,s=Math.floor(i[0].length/2),l=Math.floor(i.length/2);if(!n.getBinaryColor(e,t))for(var h=0;h<i.length;h++)for(var d=0;d<i[0].length;d++)h==l&&d==s||!i[h][d]||(o=t+(h-l),(r=e+(d-s))>=0&&r<a.getWidth()&&o>=0&&o<a.getHeight()&&a.setBinaryColor(r,o,!1))},FindTextRegions.prototype.load=function(){this.setAttribute("maxWhiteSpace",10),this.setAttribute("maxFontLineWidth",10),this.setAttribute("minTextWidth",30),this.setAttribute("grayScaleThreshold",127)},FindTextRegions.prototype.process=function(e,t,i,n,a){e=e.clone();var r=this.getAttribute("maxWhiteSpace"),o=this.getAttribute("maxFontLineWidth"),s=this.getAttribute("minTextWidth"),l=this.getAttribute("grayScaleThreshold");Marvin.thresholding(e,e,l);for(var h=[],d=0;d<e.getHeight();d++)h.push([]);for(var c,u=MarvinJSUtils.createMatrix2D(e.getWidth(),e.getHeight,!1),g=-1,f=0,p=0,m=0,v=0;v<e.getHeight();v++)for(var I=0;I<e.getWidth();I++)if(!u[I][v]){if(4294967295==(c=e.getIntColor(I,v))&&-1!=g&&(p++,m=0),4278190080==c&&(m++,-1==g&&(g=I),p=0),p>r||m>o||I==e.getWidth()-1){if(f>=s)(A=h[v]).push([g,v,g+f,v]);p=0,m=0,f=0,g=-1}-1!=g&&f++,u[I][v]=!0}for(v=0;v<e.getHeight()-2;v++)for(var y=h[v],C=v+1;C<=v+2;C++){var M=h[C];for(d=0;d<y.length;d++)for(var x=y[d],S=0;S<M.length;S++){var b=M[S];if(x[0]<=b[0]&&x[2]>=b[2]||x[0]>=b[0]&&x[0]<=b[2]||x[2]>=b[0]&&x[2]<=b[2]){x[0]=Math.min(x[0],b[0]),x[2]=Math.max(x[2],b[2]),x[3]=b[3],y.splice(d,1),d--,M.splice(S,1),M.push(x);break}}}var w=[];for(v=0;v<e.getHeight();v++){var A=h[v];for(var d in A){var P=A[d];w.push(new MarvinSegment(P[0],P[1],P[2],P[3]))}}i.set("matches",w)},IteratedFunctionSystem.prototype.load=function(){this.rules=[],this.EXAMPLE_RULES="0,0,0,0.16,0,0,0.01\n0.85,0.04,-0.04,0.85,0,1.6,0.85\n0.2,-0.26,0.23,0.22,0,1.6,0.07\n-0.15,0.28,0.26,0.24,0,0.44,0.07\n",this.setAttribute("rules",this.EXAMPLE_RULES),this.setAttribute("iterations",1e6)},IteratedFunctionSystem.prototype.process=function(e,t,i,n,a){this.loadRules();var r,o,s,l,h,d,c=this.getAttribute("iterations"),u=999999999,g=999999999,f=-999999999,p=-99999999,m=[0,0];t.clear(4294967295);for(var v=0;v<c;v++)d=this.getRule(),this.applyRule(m,d),(r=m[0])<u&&(u=r),r>f&&(f=r),(o=m[1])<g&&(g=o),o>p&&(p=o);var I=t.getWidth(),y=t.getHeight(),C=Math.abs(f-u),M=Math.abs(p-g);C>M?M*(h=I/C)>y&&(h*=y/(M*h)):C*(h=y/M)>I&&(h*=I/(C*h)),h*=.9,s=Math.floor(I/2-(u+C/2)*h),l=Math.floor(y-(y/2-(g+M/2)*h)),m[0]=0,m[1]=0;for(v=0;v<c;v++)d=this.getRule(),this.applyRule(m,d),r=Math.floor(m[0]*h+s),o=l-Math.floor(m[1]*h),r>=0&&r<I&&o>=0&&o<y&&t.setIntColor(Math.floor(r),Math.floor(o),255,0)},IteratedFunctionSystem.prototype.loadRules=function(){this.rules=[];for(var e=this.getAttribute("rules").split("\n"),t=0;t<e.length;t++)this.addRule(e[t])},IteratedFunctionSystem.prototype.addRule=function(e){var t=(e=e.replace(/ /g,"")).split(",");if(7==t.length){var i=new Object;i.a=parseFloat(t[0]),i.b=parseFloat(t[1]),i.c=parseFloat(t[2]),i.d=parseFloat(t[3]),i.e=parseFloat(t[4]),i.f=parseFloat(t[5]),i.probability=parseFloat(t[6]),this.rules.push(i)}},IteratedFunctionSystem.prototype.getRule=function(){var e,t=Math.random(),i=0;for(e=0;e<this.rules.length;e++)if(t<(i+=this.rules[e].probability))return this.rules[e];return 0!=e?this.rules[e-1]:this.rules[0]},IteratedFunctionSystem.prototype.applyRule=function(e,t){var i=t.a*e[0]+t.b*e[1]+t.e,n=t.c*e[0]+t.d*e[1]+t.f;e[0]=i,e[1]=n},Crop.prototype.load=function(){this.setAttribute("x",0),this.setAttribute("y",0),this.setAttribute("width",0),this.setAttribute("height",0)},Crop.prototype.process=function(e,t,i,n,a){var r=this.getAttribute("x"),o=this.getAttribute("y"),s=this.getAttribute("width"),l=this.getAttribute("height");t.setDimension(s,l);for(var h=r;h<r+s;h++)for(var d=o;d<o+l;d++)t.setIntColor(h-r,d-o,e.getIntColor(h,d))},FloodfillSegmentation.prototype.load=function(){this.setAttribute("returnType","MarvinSegment")},FloodfillSegmentation.prototype.process=function(e,t,i,n,a){if(null!=i){var r=this.getAttribute("returnType"),o=e.clone(),s=this.floodfillSegmentation(e,o);switch(r){case"MarvinSegment":i.set("segments",s);break;case"MarvinBlobSegment":i.set("blobSegments",blobSegments(o,s))}}},FloodfillSegmentation.prototype.floodfillSegmentation=function(e,t){t.clear(4278190080);for(var i=1,n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++){if(0==(16777215&(l=t.getIntColor(a,n)))&&e.getAlphaComponent(a,n)>0){var r=4278190080|i++;Marvin.boundaryFill(e,t,a,n,r)}}var o,s=new Array(i-1);for(n=0;n<t.getHeight();n++)for(a=0;a<t.getWidth();a++){var l;16777215!=(l=16777215&t.getIntColor(a,n))&&l>0&&(null==(o=s[l-1])&&(o=new MarvinSegment,s[l-1]=o),(-1==o.x1||a<o.x1)&&(o.x1=a),(-1==o.x2||a>o.x2)&&(o.x2=a),o.width=o.x2-o.x1+1,(-1==o.y1||n<o.y1)&&(o.y1=n),(-1==o.y2||n>o.y2)&&(o.y2=n),o.height=o.y2-o.y1+1,o.area++)}return s},FloodfillSegmentation.prototype.blobSegments=function(e,t){for(var i,n,a=new Array(t.length),r=0;r<t.length;r++){n=t[r],i=4278190080+(r+1),a[r]=new MarvinBlobSegment(n.x1,n.y1);var o=new MarvinBlob(n.width,n.height);a[r].setBlob(o);for(var s=n.y1;s<=n.y2;s++)for(var l=n.x1;l<=n.x2;l++)e.getIntColor(l,s)==i&&o.setValue(l-n.x1,s-n.y1,!0)}return a},Scale.prototype.load=function(){this.setAttribute("newWidth",0),this.setAttribute("newHeight",0)},Scale.prototype.process=function(e,t,i,n,a){if(!a){var r=e.getWidth(),o=e.getHeight(),s=this.getAttribute("newWidth"),l=this.getAttribute("newHeight");t.getWidth()==s&&t.getHeight()==l||t.setDimension(s,l);for(var h,d,c=Math.floor((r<<16)/s),u=Math.floor((o<<16)/l),g=0;g<l;g++)for(var f=0;f<s;f++)h=Math.floor(f*c>>16),d=Math.floor(g*u>>16),t.setIntColor(f,g,e.getAlphaComponent(h,d),e.getIntColor(h,d))}},MarvinAttributes.prototype.set=function(e,t){this.hashAttributes[e]=t},MarvinAttributes.prototype.get=function(e,t){var i=this.hashAttributes[e];return null!=i?i:t},MarvinAttributes.prototype.clone=function(){var e=new MarvinAttributes;for(var t in this.hashAttributes)e.set(t,this.hashAttributes[t]);return e},MarvinPoint.prototype.setX=function(e){this.x=e},MarvinPoint.prototype.getX=function(){return this.x},MarvinPoint.prototype.setY=function(e){this.y=y},MarvinPoint.prototype.getY=function(){return this.y};var marvinLoadPluginMethods=function(e){Marvin.plugins=new Object,Marvin.plugins.alphaBoundary=new AlphaBoundary,Marvin.alphaBoundary=function(e,t,i){Marvin.plugins.alphaBoundary.setAttribute("radius",i),Marvin.plugins.alphaBoundary.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.averageColor=new AverageColor,Marvin.averageColor=function(e){var t=new MarvinAttributes;return Marvin.plugins.averageColor.process(e,null,t,MarvinImageMask.NULL_MASK,!1),t.get("averageColor")},Marvin.plugins.blackAndWhite=new BlackAndWhite,Marvin.blackAndWhite=function(e,t,i){Marvin.plugins.blackAndWhite.setAttribute("level",i),Marvin.plugins.blackAndWhite.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.boundaryFill=new BoundaryFill,Marvin.boundaryFill=function(e,t,i,n,a,r){Marvin.plugins.boundaryFill.setAttribute("x",i),Marvin.plugins.boundaryFill.setAttribute("y",n),Marvin.plugins.boundaryFill.setAttribute("color",a),null!=r&&Marvin.plugins.boundaryFill.setAttribute("threshold",r),Marvin.plugins.boundaryFill.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.brightnessAndContrast=new BrightnessAndContrast,Marvin.brightnessAndContrast=function(e,t,i,n){Marvin.plugins.brightnessAndContrast.setAttribute("brightness",i),Marvin.plugins.brightnessAndContrast.setAttribute("contrast",n),Marvin.plugins.brightnessAndContrast.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.colorChannel=new ColorChannel,Marvin.colorChannel=function(e,t,i,n,a){Marvin.plugins.colorChannel.setAttribute("red",i),Marvin.plugins.colorChannel.setAttribute("green",n),Marvin.plugins.colorChannel.setAttribute("blue",a),Marvin.plugins.colorChannel.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.crop=new Crop,Marvin.crop=function(e,t,i,n,a,r){Marvin.plugins.crop.setAttribute("x",i),Marvin.plugins.crop.setAttribute("y",n),Marvin.plugins.crop.setAttribute("width",a),Marvin.plugins.crop.setAttribute("height",r),Marvin.plugins.crop.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.combineByAlpha=new CombineByAlpha,Marvin.combineByAlpha=function(e,t,i,n,a){Marvin.plugins.combineByAlpha.setAttribute("imageOther",t),Marvin.plugins.combineByAlpha.setAttribute("x",n),Marvin.plugins.combineByAlpha.setAttribute("y",a),Marvin.plugins.combineByAlpha.process(e,i,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.emboss=new Emboss,Marvin.emboss=function(e,t){Marvin.plugins.emboss.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.halftoneErrorDiffusion=new ErrorDiffusion,Marvin.halftoneErrorDiffusion=function(e,t){Marvin.plugins.halftoneErrorDiffusion.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.findTextRegions=new FindTextRegions,Marvin.findTextRegions=function(e,t,i,n,a){var r=new MarvinAttributes;return Marvin.plugins.findTextRegions.setAttribute("maxWhiteSpace",Marvin.getValue(t,10)),Marvin.plugins.findTextRegions.setAttribute("maxFontLineWidth",Marvin.getValue(i,10)),Marvin.plugins.findTextRegions.setAttribute("minTextWidth",Marvin.getValue(n,30)),Marvin.plugins.findTextRegions.setAttribute("grayScaleThreshold",Marvin.getValue(a,127)),Marvin.plugins.findTextRegions.process(e,null,r,MarvinImageMask.NULL_MASK,!1),r.get("matches")},Marvin.plugins.floodfillSegmentation=new FloodfillSegmentation,Marvin.floodfillSegmentation=function(e){var t=new MarvinAttributes;return Marvin.plugins.floodfillSegmentation.setAttribute("returnType","MarvinSegment"),Marvin.plugins.floodfillSegmentation.process(e,null,t,MarvinImageMask.NULL_MASK,!1),t.get("segments")},Marvin.plugins.gaussianBlur=new GaussianBlur,Marvin.gaussianBlur=function(e,t,i){Marvin.plugins.gaussianBlur.setAttribute("radius",Marvin.getValue(i,3)),Marvin.plugins.gaussianBlur.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.invertColors=new Invert,Marvin.invertColors=function(e,t){Marvin.plugins.invertColors.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.iteratedFunctionSystem=new IteratedFunctionSystem,Marvin.iteratedFunctionSystem=function(e,t,i,n){Marvin.plugins.iteratedFunctionSystem.setAttribute("rules",i),Marvin.plugins.iteratedFunctionSystem.setAttribute("iterations",n),Marvin.plugins.iteratedFunctionSystem.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.grayScale=new GrayScale,Marvin.grayScale=function(e,t){Marvin.plugins.grayScale.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.mergePhotos=new MergePhotos,Marvin.mergePhotos=function(e,t,i){Marvin.plugins.mergePhotos.setAttribute("threshold",i),Marvin.plugins.mergePhotos.process(e,t)},Marvin.plugins.moravec=new Moravec,Marvin.moravec=function(e,t,i,n){var a=new MarvinAttributes;return Marvin.plugins.moravec.setAttribute("matrixSize",i),Marvin.plugins.moravec.setAttribute("threshold",n),Marvin.plugins.moravec.process(e,t,a,MarvinImageMask.NULL_MASK,!1),a.get("cornernessMap")},Marvin.plugins.morphologicalDilation=new Dilation,Marvin.morphologicalDilation=function(e,t,i){Marvin.plugins.morphologicalDilation.setAttribute("matrix",i),Marvin.plugins.morphologicalDilation.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.morphologicalErosion=new Erosion,Marvin.morphologicalErosion=function(e,t,i){Marvin.plugins.morphologicalErosion.setAttribute("matrix",i),Marvin.plugins.morphologicalErosion.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.morphologicalClosing=new Closing,Marvin.morphologicalClosing=function(e,t,i){Marvin.plugins.morphologicalClosing.setAttribute("matrix",i),Marvin.plugins.morphologicalClosing.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.prewitt=new Prewitt,Marvin.prewitt=function(e,t,i){Marvin.plugins.prewitt.setAttribute("intensity",Marvin.getValue(i,1)),Marvin.plugins.prewitt.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.scale=new Scale,Marvin.scale=function(e,t,i,n){if(null==n){var a=e.getHeight()/e.getWidth();n=Math.floor(a*i)}Marvin.plugins.scale.setAttribute("newWidth",i),Marvin.plugins.scale.setAttribute("newHeight",n),Marvin.plugins.scale.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.sepia=new Sepia,Marvin.sepia=function(e,t,i){Marvin.plugins.sepia.setAttribute("intensity",i),Marvin.plugins.sepia.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.thresholding=new Thresholding,Marvin.thresholding=function(e,t,i,n){Marvin.plugins.thresholding.setAttribute("threshold",i),Marvin.plugins.thresholding.setAttribute("thresholdRange",n),Marvin.plugins.thresholding.process(e,t,null,MarvinImageMask.NULL_MASK,!1)},Marvin.plugins.thresholdingNeighborhood=new ThresholdingNeighborhood,Marvin.thresholdingNeighborhood=function(e,t,i,n,a){Marvin.plugins.thresholdingNeighborhood.setAttribute("thresholdPercentageOfAverage",i),Marvin.plugins.thresholdingNeighborhood.setAttribute("neighborhoodSide",n),Marvin.plugins.thresholdingNeighborhood.setAttribute("samplingPixelDistance",a),Marvin.plugins.thresholdingNeighborhood.process(e,t,null,MarvinImageMask.NULL_MASK,!1)}},Marvin=new Object;Marvin.getValue=function(e,t){return null!=e?e:t},marvinLoadPluginMethods(),function(e){!function(e){var t;!function(e){e[e.None=0]="None",e[e.ErrorDiffusion=1]="ErrorDiffusion",e[e.Dithering=2]="Dithering"}(t=e.HalfoneType||(e.HalfoneType={}));var i=function(){function e(){}return e.greyScale=function(e,i,n,a){var r=this;return void 0===i&&(i=t.None),void 0===n&&(n=!1),void 0===a&&(a=null),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){var e=l.clone();Marvin.grayScale(l,e),i!=t.None?(i==t.ErrorDiffusion?r.errorDiffusion(e,e):i==t.Dithering&&r.dithering(e,e),n&&r.invertImageColors(e,e),a&&r.replaceBlack(e,a.red,a.green,a.blue)):(n&&r.invertImageColors(e,e),a&&r.overlayColorToImage(e,e,a.red,a.green,a.blue)),o(e.toBlob())})})},e.greyScalePlus=function(e,i,n,a){var r=this;return void 0===i&&(i=t.None),void 0===n&&(n=!1),void 0===a&&(a=null),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){var e=l.clone();Marvin.grayScale(l,e);for(var s=[0,0,0],h=0;h<e.getHeight();h++)for(var d=0;d<e.getWidth();d++){var c=l.getAlphaComponent(d,h),u=e.getIntComponent0(d,h),g=e.getIntComponent1(d,h),f=e.getIntComponent2(d,h);r.RGBtoHSB(u,g,f,s),s[1]=0;var p=r.HSBtoRGB(s[0],s[1],s[2]),m=r.numberToColor(p),v=r.overlayColorComponentValue(m.red,u),I=r.overlayColorComponentValue(m.green,g),y=r.overlayColorComponentValue(m.blue,f);e.setIntColor(d,h,c,v,I,y)}e.update(),i!=t.None?(i==t.ErrorDiffusion?r.errorDiffusion(e,e):i==t.Dithering&&r.dithering(e,e),n&&r.invertImageColors(e,e),a&&r.replaceBlack(e,a.red,a.green,a.blue)):(n&&r.invertImageColors(e,e),a&&r.overlayColorToImage(e,e,a.red,a.green,a.blue)),o(e.toBlob())})})},e.desaturate=function(e,i,n,a){var r=this;return void 0===i&&(i=t.None),void 0===n&&(n=!1),void 0===a&&(a=null),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){for(var e=l.clone(),s=[0,0,0],h=0;h<e.getHeight();h++)for(var d=0;d<e.getWidth();d++){var c=l.getAlphaComponent(d,h);r.RGBtoHSB(e.getIntComponent0(d,h),e.getIntComponent1(d,h),e.getIntComponent2(d,h),s),s[1]=0;var u=r.HSBtoRGB(s[0],s[1],s[2]),g=r.numberToColor(u);e.setIntColor(d,h,c,g.red,g.green,g.blue)}i!=t.None?(i==t.ErrorDiffusion?r.errorDiffusion(e,e):i==t.Dithering&&r.dithering(e,e),n&&r.invertImageColors(e,e),a&&r.replaceBlack(e,a.red,a.green,a.blue)):(n&&r.invertImageColors(e,e),a&&r.overlayColorToImage(e,e,a.red,a.green,a.blue)),o(e.toBlob())})})},e.blackAndWhite=function(e,i,n,a){var r=this;return void 0===i&&(i=t.None),void 0===n&&(n=!1),void 0===a&&(a=null),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){for(var e=l.clone(),s=0,h=0;h<e.getHeight();h++)for(var d=0;d<e.getWidth();d++){var c=l.getAlphaComponent(d,h);s=(s=l.getIntComponent0(d,h))<=127?Math.max(s*(1-.006*(127-s)),0):Math.min(s*(1+.006*(s-127)),255),e.setIntColor(d,h,c,s,s,s)}i!=t.None?(i==t.ErrorDiffusion?r.errorDiffusion(e,e):i==t.Dithering&&r.dithering(e,e),n&&r.invertImageColors(e,e),a&&r.replaceBlack(e,a.red,a.green,a.blue)):(n&&r.invertImageColors(e,e),a&&r.overlayColorToImage(e,e,a.red,a.green,a.blue)),o(e.toBlob())})})},e.thresholding=function(e,t,i,n){var a=this;return void 0===i&&(i=!1),void 0===n&&(n=null),null!=t&&null!=t||(t=160),new Promise(function(r,o){var s=new MarvinImage;s.load(e,function(){var e=s.clone();Marvin.thresholding(s,e,t),i&&a.invertImageColors(e,e),n&&a.replaceBlack(e,n.red,n.green,n.blue),r(e.toBlob())})})},e.thresholdingTransparentWhite=function(e,t,i,n){var a=this;return void 0===i&&(i=!1),void 0===n&&(n=null),null!=t&&null!=t||(t=160),new Promise(function(r,o){var s=new MarvinImage;s.load(e,function(){var e=s.clone();Marvin.thresholding(s,e,t),i&&a.invertImageColors(e,e),a.setWhiteTransparent(e),n&&a.replaceBlack(e,n.red,n.green,n.blue),r(e.toBlob())})})},e.thresholdingDarkAndLight=function(e,t,i,n,a){var r=this;return void 0===i&&(i=!1),null!=t&&null!=t||(t=160),new Promise(function(o,s){var l=new MarvinImage;l.load(e,function(){var e=l.clone();Marvin.thresholding(l,e,t),i&&r.invertImageColors(e,e),r.replaceBlackAndWhite(e,n,a),r.setWhiteTransparent(e),o(e.toBlob())})})},e.halftoneErrorDiffusion=function(e){return new Promise(function(t,i){var n=new MarvinImage;n.load(e,function(){var e=n.clone();Marvin.halftoneErrorDiffusion(n,e),t(e.toBlob())})})},e.overlapColor=function(e,t,i){var n=t||{red:0,green:0,blue:0};return new Promise(function(t,a){var r=new MarvinImage;r.load(e,function(){for(var e=r.clone(),a=0;a<e.getHeight();a++)for(var o=0;o<e.getWidth();o++){var s=r.getAlphaComponent(o,a),l=r.getIntComponent0(o,a),h=r.getIntComponent1(o,a),d=r.getIntComponent2(o,a);i&&255==l&&255==h&&255==d&&(s=0),e.setIntColor(o,a,s,n.red,n.green,n.blue)}t(e.toBlob())})})},e.downloadImage=function(e,t){t=t||"test.png";var i=e.toBlob(),n=document.createElement("a");n.setAttribute("download",t);var a=URL.createObjectURL(i);n.href=a,n.setAttribute("target","_blank"),n.click(),URL.revokeObjectURL(a)},e.overlayColor=function(e,t){var i=this,n=t||{red:0,green:0,blue:0};return new Promise(function(t,a){var r=new MarvinImage;r.load(e,function(){for(var e=r.clone(),a=[0,0,0],o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++){var l=r.getAlphaComponent(s,o);i.RGBtoHSB(r.getIntComponent0(s,o),r.getIntComponent1(s,o),r.getIntComponent2(s,o),a),a[1]=0;var h=i.HSBtoRGB(a[0],a[1],a[2]),d=i.numberToColor(h),c=i.multiplyColorComponentValue(d.red,n.red),u=i.multiplyColorComponentValue(d.green,n.green),g=i.multiplyColorComponentValue(d.blue,n.blue);e.setIntColor(s,o,l,c,u,g)}t(e.toBlob())})})},e.overlayColorHard=function(e,t){var i=this,n=t||{red:0,green:0,blue:0};return new Promise(function(t,a){var r=new MarvinImage;r.load(e,function(){for(var e=r.clone(),a=0,o=0;o<e.getHeight();o++)for(var s=0;s<e.getWidth();s++){var l=r.getAlphaComponent(s,o);a=(a=r.getIntComponent0(s,o))<=127?Math.max(a*(1-.006*(127-a)),0):Math.min(a*(1+.006*(a-127)),255);var h=i.multiplyColorComponentValue(a,n.red),d=i.multiplyColorComponentValue(a,n.green),c=i.multiplyColorComponentValue(a,n.blue);e.setIntColor(s,o,l,h,d,c)}t(e.toBlob())})})},e.edgeDetection2=function(e){return new Promise(function(t,i){var n=new MarvinImage;n.load(e,function(){var e=n.clone();e.clear(4278190080),Marvin.prewitt(n,e),Marvin.invertColors(e,e),Marvin.thresholding(e,e,200),t(e.toBlob())})})},e.multiplyColorComponentValue=function(e,t){var i=e*t/255;return i=i>255?255:i<0?0:Math.floor(i)},e.overlayColorComponentValue=function(e,t){var i=e/255,n=t/255,a=i<.5?2*i*n:1-2*(1-i)*(1-n);return Math.floor(255*a)},e.RGBtoHSB=function(e,t,i,n){null==n&&(n=[]);var a=0,r=0;if(e<t?(a=e,r=t):(a=t,r=e),i>r?r=i:i<a&&(a=i),n[2]=r/255,n[1]=0==r?0:(r-a)/r,0==n[1])n[0]=0;else{var o=6*(r-a);n[0]=e==r?(t-i)/o:t==r?1/3+(i-e)/o:2/3+(e-t)/o,n[0]<0&&n[0]++}return n},e.HSBtoRGB=function(e,t,i){if(0==t)return this.convert(i,i,i,0);var n=6*(e-=Math.floor(e)),a=6*e-n,r=i*(1-t),o=i*(1-t*a),s=i*(1-t*(1-a));switch(n){case 0:return this.convert(i,s,r,0);case 1:return this.convert(o,i,r,0);case 2:return this.convert(r,i,s,0);case 3:return this.convert(r,o,i,0);case 4:return this.convert(s,r,i,0);case 5:return this.convert(i,r,o,0)}},e.convert=function(e,t,i,n){var a=Math.round(255*e),r=Math.round(255*t),o=Math.round(255*i);return Math.round(255*n)<<24|a<<16|r<<8|o},e.numberToColor=function(e){return{red:(e&this.RED_MASK)>>16,green:(e&this.GREEN_MASK)>>8,blue:e&this.BLUE_MASK}},e.errorDiffusion=function(e,t){for(var i=0,n=0,a=0;a<t.getHeight();a++)for(var r=0;r<t.getWidth();r++)(i=t.getIntComponent0(r,a))>128?(t.setIntColor(r,a,e.getAlphaComponent(r,a),255,255,255),n=-(255-i)):(t.setIntColor(r,a,e.getAlphaComponent(r,a),0,0,0),n=i),r+1<t.getWidth()&&(i=t.getIntComponent0(r+1,a),i+=Math.floor(.4375*n),i=this.getValidGray(i),t.setIntColor(r+1,a,e.getAlphaComponent(r+1,a),i,i,i),a+1<t.getHeight()&&(i=t.getIntComponent0(r+1,a+1),i+=Math.floor(.0625*n),i=this.getValidGray(i),t.setIntColor(r+1,a+1,e.getAlphaComponent(r+1,a+1),i,i,i))),a+1<t.getHeight()&&(i=t.getIntComponent0(r,a+1),i+=Math.floor(.3125*n),i=this.getValidGray(i),t.setIntColor(r,a+1,e.getAlphaComponent(r,a+1),i,i,i),r-1>=0&&(i=t.getIntComponent0(r-1,a+1),i+=Math.floor(.1875*n),i=this.getValidGray(i),t.setIntColor(r-1,a+1,e.getAlphaComponent(r-1,a+1),i,i,i)))},e.dithering=function(e,t){for(var i=[167,200,230,216,181,94,72,193,242,232,36,52,222,167,200,181,126,210,94,72,232,153,111,36,52],n=0;n<e.getWidth();n+=5)for(var a=0;a<e.getHeight();a+=5)for(var r=void 0,o=void 0,s=0;s<25;s++)o=s/5,n+(r=s%5)<e.getWidth()&&a+o<e.getHeight()&&(255-e.getIntComponent0(n+r,a+o)>i[s]?t.setIntColor(n+r,a+o,e.getAlphaComponent(n+r,a+o),0,0,0):t.setIntColor(n+r,a+o,e.getAlphaComponent(n+r,a+o),255,255,255))},e.getValidGray=function(e){return e<0?0:e>255?255:e},e.replaceBlack=function(e,t,i,n){for(var a=0;a<e.getHeight();a++)for(var r=0;r<e.getWidth();r++){var o=e.getAlphaComponent(r,a),s=e.getIntComponent0(r,a),l=e.getIntComponent1(r,a),h=e.getIntComponent2(r,a);0==s&&0==l&&0==h&&(s=t,l=i,h=n),e.setIntColor(r,a,o,s,l,h)}},e.replaceBlackAndWhite=function(e,t,i){for(var n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++){var r=e.getAlphaComponent(a,n),o=e.getIntComponent0(a,n),s=e.getIntComponent1(a,n),l=e.getIntComponent2(a,n);0==o&&0==s&&0==l?(o=t.red,s=t.green,l=t.blue):255==o&&255==s&&255==l&&(o=i.red,s=i.green,l=i.blue),e.setIntColor(a,n,r,o,s,l)}},e.setWhiteTransparent=function(e){for(var t=0;t<e.getHeight();t++)for(var i=0;i<e.getWidth();i++){var n=e.getAlphaComponent(i,t),a=e.getIntComponent0(i,t),r=e.getIntComponent1(i,t),o=e.getIntComponent2(i,t);255==a&&255==r&&255==o&&(n=0),e.setIntColor(i,t,n,a,r,o)}},e.replaceColor=function(e,t,i){for(var n=0;n<e.getHeight();n++)for(var a=0;a<e.getWidth();a++){var r=e.getAlphaComponent(a,n),o=e.getIntComponent0(a,n),s=e.getIntComponent1(a,n),l=e.getIntComponent2(a,n);o==t.red&&s==t.green&&l==t.blue&&(o=i.red,s=i.green,l=i.blue),e.setIntColor(a,n,r,o,s,l)}},e.overlayColorToImage=function(e,t,i,n,a){for(var r=0;r<t.getHeight();r++)for(var o=0;o<t.getWidth();o++){var s=e.getAlphaComponent(o,r),l=this.multiplyColorComponentValue(t.getIntComponent0(o,r),i),h=this.multiplyColorComponentValue(t.getIntComponent1(o,r),n),d=this.multiplyColorComponentValue(t.getIntComponent2(o,r),a);t.setIntColor(o,r,s,l,h,d)}t.update()},e.invertImageColors=function(e,t){Marvin.invertColors(e,t)},e.hexToRgb=function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null},e.componentToHex=function(e){var t=e.toString(16);return 1==t.length?"0"+t:t},e.rgbToHex=function(e,t,i){return"#"+this.componentToHex(e)+this.componentToHex(t)+this.componentToHex(i)},e.textToPalette=function(t,i){void 0===i&&(i=!1);var n=[];t&&t.split(",").forEach(function(t){if(t&&"null"!=t){var a=e.hexToRgb(t);a&&n.push([a.r,a.g,a.b])}else i&&n.push(null)});return n},e.paletteToText=function(e){var t="";if(e&&e.length>0)for(var i=0;i<e.length;i++){var n=e[i];t.length>0&&(t+=","),t+=this.rgbToHex(n[0],n[1],n[2])}return t},e.rgbToInt=function(e,t,i){return 255<<24|i<<16|t<<8|e},e.intToRgb=function(e){return[255&e,(65280&e)>>8,(16711680&e)>>16]},e.reduce=function(e,t,i,n){var a=this;return new Promise(function(r,o){var s=a.textToPalette(i),l=null;n&&(l=a.textToPalette(n,!0)),s&&l&&s.length!=l.length&&o("The replacement palette must contains the same colors of main palette");var h=new Image;h.addEventListener("load",function(){var e={colors:256,palette:[],paletteRep:void 0};null!=t&&null!=t&&(e.colors=t),s.length>0&&(e.colors=s.length,e.palette=s,l&&l.length==s.length&&(e.paletteRep=l));var i=new RgbQuant(e);if(0==s.length){i.sample(h);i.palette(!0)}var n=i.reduce(h,3),a=new Blob([n]);r(a)}),h.crossOrigin="Anonymous",h.src=e})},e.getImagePalette=function(e,t){var i=this,n=Math.min(256,t),a=n;return a<256&&(a=Math.min(256,a+10)),new Promise(function(t,r){var o=new Image;o.addEventListener("load",function(){var e=new RgbQuant({colors:a});e.sample(o);var r=e.palette(!0,!0),s=i.paletteToText(r).split(",").slice(0,n);s=s.filter(function(e,t,i){return i.indexOf(e)===t}),t(s)}),o.crossOrigin="Anonymous",o.src=e})},e.remapPalette=function(t,i){for(var n=[],a=0;a<i.length;a++){var r=e.hexToRgb(i[a]);r&&n.push([r.r,r.g,r.b])}var o={colors:256,palette:[]};n.length>0&&(o.colors=n.length,o.palette=n);var s=new RgbQuant(o),l={};for(a=0;a<t.length;a++){var h=t[a],d=e.hexToRgb(h),c=e.rgbToInt(d.r,d.g,d.b),u=s.nearestColor(c),g=e.intToRgb(u),f=e.rgbToHex(g[0],g[1],g[2]);l[h]=f}return l},e.remapColor=function(t,i){return e.remapPalette([t],i)[t]},e.RED_MASK=255<<16,e.GREEN_MASK=65280,e.BLUE_MASK=255,e}();e.ImageProcessor=i}(e.Customizer||(e.Customizer={}))}(Zakeke||(Zakeke={}));var MaskedImageSelectionMode,__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var a in t=arguments[i])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(a,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}l((n=n.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var i,n,a,r,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(o=0)),o;)try{if(i=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},__spreadArray=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,a=0,r=t.length;a<r;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))},_this_1=this,MPlaza=MPlaza||{},IS_IOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;String.prototype.padStart||(String.prototype.padStart=function(e,t){return e>>=0,t=String(t||" "),this.length>e?String(this):((e-=this.length)>t.length&&(t+=t.repeat(e/t.length)),t.slice(0,e)+String(this))}),String.prototype.padEnd||(String.prototype.padEnd=function(e,t){return e>>=0,t=String(t||" "),this.length>e?String(this):((e-=this.length)>t.length&&(t+=t.repeat(e/t.length)),String(this)+t.slice(0,e))}),String.prototype.padStartEnd||(String.prototype.padStartEnd=function(e,t){if(e>>=0,t=String(t||" "),this.length>e)return String(this);e-=this.length;var i=Math.floor(e/2),n=e%2>0?i+1:i,a=i,r=t;n>r.length&&(r+=r.repeat(n/r.length));var o=t;return a>o.length&&(o+=o.repeat(a/o.length)),r.slice(0,n)+String(this)+o.slice(0,a)}),MPlaza.EventMessages={DPIWarning:1,UploadLimit:2,AddToCartConfirmation:4,ItemsClippedWarning:7},MPlaza.CustomizerElementType={None:"none",Rectangle:"rectangle",Oval:"oval",Line:"line",Path:"pen",Free:"freeHand",Text:"text",Image:"image",TextArt:"textart",Shape:"shape"},MPlaza.CustomizerInteractionMode={None:"none",Select:"select",Create:"create",Move:"move",Rotate:"rotate",Resize:"resize",ResizeTop:"resizeTop",ResizeBottom:"resizeBottom",ResizeLeft:"resizeLeft",ResizeRight:"resizeRight",Delete:"delete",Edit:"edit",MoveTextOnPathFirstEnd:"moveTextOnPathFirstEnd",MoveTextOnPathMiddleEnd:"moveTextOnPathMiddleEnd",MoveTextOnPathLastEnd:"moveTextOnPathLastEnd",MoveTextAreaTopEnd:"moveTextAreaTopEnd",MoveTextAreaRightEnd:"moveTextAreaRightEnd",MoveTextAreaBottomEnd:"moveTextAreaBottomEnd",MoveTextAreaLeftEnd:"moveTextAreaLeftEnd"},function(e){e[e.Element=1]="Element",e[e.Raster=2]="Raster",e[e.Mask=3]="Mask"}(MaskedImageSelectionMode||(MaskedImageSelectionMode={})),MPlaza.PointingInfo=function(){return this.modifiers={option:!1,control:!1,shift:!1},this.point=void 0,this.delta=void 0,this};var getViewport=function(){var e="CSS1Compat"==document.compatMode;return{l:window.pageXOffset||(e?document.documentElement.scrollLeft:document.body.scrollLeft),t:window.pageYOffset||(e?document.documentElement.scrollTop:document.body.scrollTop),w:window.innerWidth||(e?document.documentElement.clientWidth:document.body.clientWidth),h:window.innerHeight||(e?document.documentElement.clientHeight:document.body.clientHeight)}};MPlaza.ItemInfo=function(e,t){this.designItem=e,this.item=t,this.elementType=MPlaza.CustomizerElementType.None,this.sideID=-1,this.itemGuid=MPlaza.EmptyUUID,this.constraints=[],e&&e instanceof MPlaza.DesignItem&&(this.itemGuid=e.get("itemGuid"))},MPlaza.TextItemInfo=function(e,t){MPlaza.ItemInfo.call(this,e,t),this.elementType=MPlaza.CustomizerElementType.Text,this.text="",this.strokeColor="black",this.strokeWidth=0,this.fillColor="black",this.fontFamily="Arial",this.fontSize=18,this.fontWeight="normal",this.fontStyle="normal",this.fontStretch="normal",this.justification="center",this.isTextOnPath=!1,this.isTextArea=!1,this.adaptText=!1,this.letterSpacing=0,this.lineSpacing=0,this.scaling=1,this.verticalAlignment="top",this.shadowColor=null,this.shadowBlur=0,this.shadowDistance=7,this.shadowAngle=45,this.__defineGetter__("totalFontSizePt",function(){return this.fontSize*this.scaling*4/3})},MPlaza.TextItemInfo.prototype=Object.create(MPlaza.ItemInfo.prototype),MPlaza.TextItemInfo.prototype.constructor=MPlaza.TextItemInfo,MPlaza.ImageItemInfo=function(e,t){MPlaza.ItemInfo.call(this,e,t),this.elementType=MPlaza.CustomizerElementType.Image,this.url="",this.deleted=!1,this.isMasked=!1,this.maskID=-1,this.maskStyle={strokeColor:void 0,strokeWidth:void 0,strokeCap:void 0,strokeJoin:void 0,dashArray:void 0,dashOffset:void 0}},MPlaza.ImageItemInfo.prototype=Object.create(MPlaza.ItemInfo.prototype),MPlaza.ImageItemInfo.prototype.constructor=MPlaza.ImageItemInfo,MPlaza.ShapeItemInfo=function(e,t){MPlaza.ItemInfo.call(this,e,t),this.elementType=MPlaza.CustomizerElementType.Shape,this.style={strokeColor:void 0,strokeWidth:void 0,strokeCap:void 0,strokeJoin:void 0,dashArray:void 0,dashOffset:void 0,fillColor:void 0},this.isImagePlaceholder=!1,this.fillerImageID=-1},MPlaza.ShapeItemInfo.prototype=Object.create(MPlaza.ItemInfo.prototype),MPlaza.ShapeItemInfo.prototype.constructor=MPlaza.ShapeItemInfo,MPlaza.TextArtItemInfo=function(e,t){MPlaza.ItemInfo.call(this,e,t),this.elementType=MPlaza.CustomizerElementType.TextArt,this.text="",this.fontFamilyID=-1,this.fontFaceID=-1,this.text="",this.textArtTypeID=-1,this.style={strokeColor:void 0,strokeWidth:void 0,strokeCap:void 0,strokeJoin:void 0,dashArray:void 0,dashOffset:void 0,fillColor:void 0,shadowColor:void 0,shadowBlur:void 0,shadowDistance:void 0,shadowAngle:void 0},this.config={angleValue:0,curveValue:0,intensT:0,intensB:0,isTriangle:!1,isBridge:!1,isTop:!1,isBottom:!1,isMiddle:!1}},MPlaza.TextArtItemInfo.prototype=Object.create(MPlaza.ItemInfo.prototype),MPlaza.TextArtItemInfo.prototype.constructor=MPlaza.TextArtItemInfo,MPlaza.Customizer=function(e,t,i,n){this.isViewer=e||!1,this.isMobile=t||!1,this.isConfigurator=n||!1,this.isCartPreview=!1,this.isResizableMode=!1,this.isImageScalingEnabled=!0,this.showSideImage=!0,this.fitToScreenMargin=this.isMobile?18:13,this.zoomPercentageIncrement=100,this.canvasID="mp-canvas-customizer_"+MPlaza.makeID(5),this.canvas=null,this.context=null,null!=i&&(this.canvas=i,this.context=this.canvas.getContext("2d")),this._paper=new paper.PaperScope,this.__defineGetter__("paper",function(){return paper=this._paper,this._paper}),this.__defineSetter__("viewMatrix",function(e){var t=new this.paper.Matrix(e);this.paper.view.matrix=t}),this.rasterLayer=null,this.zooming=!1,this.frozen=!1,this.tool=null,this.clipboard=null,this.selectionBounds=null,this.selectionBoundsShape=null,this.selectionMoveHandle=null,this.selectionRotateHandle=null,this.selectionResizeHandle=null,this.selectionDeleteHandle=null,this.selectionMaskMoveImage=null,this.selectionMaskMoveShape=null,this.selectionResizeTopHandle=null,this.selectionResizeBottomHandle=null,this.selectionResizeLeftHandle=null,this.selectionResizeRightHandle=null,this.selectionLateralResizeDimension=this.isMobile?12:8,this.drawSelectionBounds=0,this.model=null,this.grids=[],this.loadingCircles=[],this.interactionMode=MPlaza.CustomizerInteractionMode.None,this.elementType=MPlaza.CustomizerElementType.None,this.hammertime=null,this.hitItem=null,this.hitTestEnabled=!0,this.mouseStartPos=null,this.adjustmentDelta=null,this.originalPositions=null,this.element=null,this.pivot=null,this.corner=null,this.topCorner=null,this.bottomCorner=null,this.leftCorner=null,this.rightCorner=null,this.originalSize=null,this.originalCenter=null,this.originalScaleCenter=null,this.originalContent=null,this.originalMatrix=null,this.originalShape=null,this.originalAngle=null,this.itemsLayer=null,this.imageLayer=null,this.imageItem=null,this.imageWidth=500,this.imageHeight=516,this.mask=null,this.verticalCenterLine=null,this.verticalCenterLineSecondColor=null,this.horizontalCenterLine=null,this.horizontalCenterLineSecondColor=null,this.resizableSideImageItem=null,this.resizableMeasuresItem=null,this.resizableSplitColumnsItem=null,this.productImageGenerator=new ZakekeResizableCanvas.ProductImageGenerator,this.productAreaGenerator=new ZakekeResizableCanvas.ProductAreaGenerator,void 0!==i&&null!=i?this.setupCanvas():(this.createCanvas(),this.createDOMElement()),this.setupImageLayer(),this.lastPanPoint=new this.paper.Point(0,0),this.iconsBytes=null,this.masterGroup=null,this.snapCache=null,this.oldScale=1;getViewport();return this.isViewer||(this.iconsBytes={move:"iVBORw0KGgoAAAANSUhEUgAAAJIAAACSCAYAAACue5OOAAAACXBIWXMAAC4jAAAuIwF4pT92AAAOQElEQVR42u2dTUxT6RrH/2NMWlhIJwIpi9aaMBGjCQVXIMnQScYMK4+zmRk2Uq9rL4suXDFMV96EZNA1Y+sGrxssm+nEmwAmiCtpSTDUaEJtF5DK5LYuarvyLvp2LkOg53nP5/uenidpjHDO6aHn1//z9X588fnzZ7jmml475X4ErrkgueaC5Jqz7HS7fwDRmbkQgBD77/gJh4UA5I/5+Rr7N5+Ix/Lt/Dl+0S7BNgMmfOgVAjBo8NtsASgzwLIAsu0CmGNBYuCMH3qds+lW3jOo1gCknAqWo0CKzsyFAUwxcAYFvc33AFIAkol4LOuCJJbyTANQbFSdtodKWpCiM3NTTH2+dsiXegvAfCIeS7ogmQ+Pj6nPlITqQ7UKgHkGVdkFyRyApgF0tUlGLRVQQoNkNUAdXg+C/l7SsYX9Ej7V6i5QooPEYqBZM1zYhVAAwb4edPu6EPT3ovvLM+j2aeO0WqujsFdCYb+Eg3IFhb0PeJMvmgXUbCIem3dBoqfw80YF0R1eDwZCAQycb7yoiqPXCvsl5HaLjVe+aKR6bQGYTsRjay5IJ0M0C+BnI+AZHujH8MWvMHyxX4i/LbdbxGbuLTZ33uHP8kcjLnmfKVTZBenvKpSEziLi1fAloeBpBdV6ZhubuXd6leo9gCkR1Ml2kKIzc9MAftV6/lnfGVwbuYKxocvo9HqkSsuqtTo2d94itbqhV6V+ScRjs20JEsvIkgCuawVIiYxibOiyI3L99cw21jOv9QTqzwEodrk6W0BiriylJSNzGkDHub3F9AqK+x+0ZnbjdrRbLAcpOjOnMCXiyrc7vB4okVFcG7mCdrD1zDYW06taY6io1a0WS0FitaEE73nfjgxDiVyVLgYyIoZKrb7Af15uCh83WQZSdGZuHsA/ed3Y7RsTGDgfQDtbYb+EhaW0Fnf3KBGPTTkGpOjMXBLATVeF9FlqdQPLqxtCwmQ6SLwQdXg9uH1jQvhakJ3B+IPHKd7YyXSYTAWJF6KAvwd3JhXNfa92ip0eLKZ4SwWmwmQaSLwx0dXwJdz+fsKlhMMW0yu8gbhpMJkCEm929tNEpG3SejPKBL89/cP2bM5wkFid6Cn1+H/c+M6xxUUrYeKsORleZzIUJFaxXgOx2OhCZGyJ4N7DJzwwDRlZATcMJNY7y4LY9nAhsh2mCoCQUb05I+f+J50I0cJSGgtLaSnuNejvxd1bP6CDVnvrwv+nnIsBEhsKct2JEL3IvsaL7GupYLp9g5z9DrLBhPa7NhYXZZyWnTUhkrVEwZnNRfQOjjNCkUjR/9XwJakhAiCVMo0NXca3I8PkZ8hiXHtAYrKoOjw24O+R5pt8EkQywjQ58Q0uhEgN73NozNixHiTm0lQH6nd4Pbh760dHQCQjTHcmFZz1naEc+s/ozNy4HYpEml915ydFig4+FSLZYOr0enBnUjE0TDEMJNYCUZ139u3IsBRjiXghkg2moL8X1yOjJBenNYs7pQEiH0WNAv4eTE5841iIZINJiYwi4O+hHDqtJfDWokikefjtAJFsMBETni5q2KIZpEOLOkjv0oyCSCaYOFzcTbaAmWmKpKpGjdkeV9sKIplgUiKj1Cxu1hSQqGo0OREROkszCyKZYCKGHVyqxKNIqmp01ndG6D6a2RDJAtPwxX5qoXLWLJCkDbCtgkgWmBRarKRQMzgSSKxu1KWW7os688NqiGSAaeB8gKJKXWis12mYIqmqkagNWbsgkgEmoipNGwIS66kNyhgb2Q2R6DANnA9QipTnKD04iiKpSpuIaiQKRKLDRHx2qgxQdkdq2fHr8HqEU6NqrY6xocvk+9KxjAx3K6haqwtVHhkbukyZgaLoAom5tZbjsIcH+oWrG3V6PVyV9U6vV8d7eaVf5GJs6JLaRMuu6MyckojHUlpd2xSFaNfkNqJ7U/TESIpakC3Kt7FqzeLpjrznbl8XJejWBhIrj7d2a4LUjRaW0ijslaQDqbBXEiYAJ3iWLhbqcCuSYsCbt112Jms2RxQFRQtI42rZmlWr6DsVIpFg6vZ1UUYFjBsO0kAo4ELkMJgIqvQ1F0gsPuoSNT5yGkSiwDQQCqoec1KV+yRFCqtdMNjX60LkMJiIGXjYMJDsio+cDpHdMHV6PZQ46Vg2TmuJj5wGUbCvx5Zz1WACYPkM5aC/V21flBAPSCEDJFAaJRJ1QJ4dMAX7epHJveMOuE9ybedap4pnHAOR6+b4s/HjRk2eOuYg1UDbquWL2x0iO2Dq/pIkEmGKa1Mdo2tFxsYL0WJ6hdzFD/aZNwt4Mb2Cwh5tSEq1VhPOzRFFwkcBKUSJ7kVTIq3jiYw2EzdHtgyms74zagF3c5u0ljFSS5CI88dddyaxm9MSunDP/dczCMyFSM4AnOLaTony4bgQiQNTt4aiJLdrcyFyPkzdXxrj2lqCZHQx0oVIejdnv2tzIXIOTLaCVNgvuRQY+FnaOQbcVpDu3vrR9HJCO1jA34O7t360dVrYcSC13OTEyEH2nWzpZBcmuSE6CaSWWy8ZLZ8uTOJBxNO6EcK1uTCJqUSEXmFWN0haaHVhcpw7K1NAyre6gpnNURcmMSA6KFe4zznNC5JVbu7ew39zQRvw93ANIzHLeK5drdW4/0YrlEil838sI6e1vFFut2jqcFstME1OfCPEOgQ845xyu0X8K/FEKIiIapRXdW2UDeCsKHy5bs6emOjgvx+NAYlZSyytqki7MFkfWFOebSIeI7u2LFpMz83tFoGI2DETj61ntnFQ/qjp3G4T18+0IzsjFJy3qMG2KkhaonqRYVrPvNY8PPZCKGAKSHal+ARFOrZgfYrn4MNRvV0wtYObswuiaq1O+aLmDQPpL/dmU2nAyTDZWWwkPtM1MkiJeCyrFnDbAZLTYbK7Yp3LFyiBNh0kiirl8kXbPnAnwiRCF58gDlsn/aIVSCm1OMnOgWlOgkkEiA7KFUp8tKYFpDW1q27uvLP1ATgBJlHGExGfJT9IlDhpPbNt+4NowmTXwl96LNjXKwRE1GepZ8F2od3bYZhE3rVS9PsmurXlVr/UBZIoquSaJW4tpRkkJmUq7s2dTiS7PXv5SjdIp4kXuHnSLz/V6ljPbAu1J0m1Vje1N3fY3uSLiM7MSRVYH1Ujwvij5UQ8Vtbj2gAgaRDRbZ3NiQgRx7NTZUAVJFbJfN/qmOL+B9sq3TLAJCpEB+UKpVldaZWt8SgSAMyr+r/VDSGzIrthEhUiAEitbBjy7HlASqoF3W/yReFUyW6YRIbooFyhrruQNAwkFmipypuIqmQXTCJDBACLv69SDnt03GhIPYoEALOUDEZEVbIaJtEhyu0W1dbS5nJrXCAxMh+pHbfwVMw97q2CSXSIODzHc9YmMxYkqir9Wf4orIszGyYZIHr28hV1WPEsz3W5QKKq0rOXrywfims3TDJAVK3VqV/yR5RpaXoUCQCm1TK4T7U6Fpb+gMhmJEwyQAQ0Vsj7RJuTOMt7bW6QWAanGoS9yReFq3ibAZMsEG3uvKMG2PepmZpeRUIiHpuFSrUbAB6nV4Vf3k8PTLJAdFCuUJOgihY10gwSsymqnIqyv72RMMkCEQA8WExRXdqUWnPWcJBYMLasdlxx/wMWf18R/sPmgUkmiBaW0tRREM8pPTUzFKmpSqrp2Yvsa6FLAjwwyQTRemab2gapUD2MKSAxGSTdwPLqhhSjKVvBJBNEud0ifntKzpyntQTYRipScxTlfcqxixIE3yfBJBNEhf0SHjwme6nlRDyW1PuehixGmojHptFi8lzTPtXquPfwiXQwyQbRvYdPqMH1e70urWlffP782ZA/IDozF0Jjdq7qjigdXg/u3vrBlt26ea2ZcToQogqAcZ5+mumKxFQpD0ChHCubMjkQomZclDXq/Q1dZ5uVBKJOg8mBEP1iRFxkims74uaSaDHz5Kibm5yICDULRSbL7Rbx4HGKB6JHiXhsyuj7MAUkXpgA4KeJCK6NXHHJ4LD1zDZPig80io7jZtyLaVtIMOqXqcc/Tq9K0U4RxRaW0rwQbVFjWC122uS/dwqNFSwGKQe/yL5GYb+E299PSJHR2WEH5QoeLKZ4J39usQytbNZ9mebaDrk4HxoTB76mntPh9UCJjLqu7oht7rzDwtM0TzxkCUSWgKQ1ZgIaK8be/v47TfvQO8mqtToWltLU8UR/i4kAKGZDZClIWmFqd3Vaz2xjMb3Kq0KmZWdCgMRgmgbwK+95AX+PMPuNWJXWp1Y3tK7/fZ+1reBYkBhMChozOLl9ltPd3UG5gtTKhtbdxytoVKyTVt+3LSAxmMIMpkEt518NX8K10SuOye50AgQ0GrCKkW0PKUA6lNHN88ZNRxXq2sgVDF/sl9aFPXv5SksgfdiWoWOYrPQgGeHqmnaWbS4zNnRJeLdXZYuTPXv5irLIlZCuTEiQDqlTEsB1vde6EApg+GI/hi/2CwNVtVbH5s5bnmlBlNR+Su/IRseBdESd5gGcM+J6AX8PBs4HMDzwleUZX263iFy+iM2dt0YuQyiMCgkN0iF1mgbws9HXboLV7etC0N+LYF+v7vFG1Vodhb0SDsoVFPZLKOx90Lxtl1paD2DWzlhIKpAOARVCY8LeTbPf60KooVadXo/q4u+FvdJfzeU31uzJIpQbkw4kO4ASzJ4zBVoT/UalAKkNgXoEICkDQFKCdASoKfY65xB4KixrnRfZhTkKpGOyvCkjygY22TKAlGhZWNuBdCTTU9jrugzwMIDKTvj8HQPSCUo1zl6DNt/OFhojRdcArDkFnrYA6Ri1CjOowgBCJsL1Ho2JolkGTtaJ4LQlSC0ACwNoQuZjPx4nnt7MqMoMmrJdnXcXJNccY6fcj8A1FyTXXJBcc5b9D4O1t0lsiFUUAAAAAElFTkSuQmCC",rotate:"iVBORw0KGgoAAAANSUhEUgAAAJIAAACSCAYAAACue5OOAAAACXBIWXMAAC4jAAAuIwF4pT92AAAQUElEQVR42u2dTUwb1xbH/0WR+FiAqxBEFgZHIgookQJmBYkUiFQUusHJJg2LPkhRF5Ee5VV+alaUePGUSqiieVIWfUkMXdBmU8ymREQqVCKwCgaJKEZBwtiLWIQqdhZgVn0LX6cuBd8z4ztz74znSIi0DB4z/t3zdc8594M//vgDjjhSqJQ4j8ARByRHHJAcsZccK/YH0D886gHgYf/ZccglLvY9ecjP5tn3lWDAnyzm5/hBsTjbDJhm9tXB4KkXfJtVAFEAK+xrvlgAsy1IDBwfg6YDQJWkt7LFNNc8AyvqgKQ+PB0MHp8B2kak1poHMB4M+FcckNSBpxlAn+Lw5NNW4wyqqAOS+fC4GDhDAM7bZFH/xoAad0AyB6Ah9lUFe8oWgDEGVdIBSbzjPALgH0UUUacYUGNWAEppkHI00Ndm3O+4qxLVLpqiiyW2sZfeNw2oYMA/4oCkD6IhpoWEmrDyslLU1dag8ZQb1QycupM1qCgr1fV6O8kUdt6+QyyxjZ1kCrHXb7AejRtl8oaCAX/IAYkewo+JcqLLy0rR6HHD29SAupM1qKutMeXviCW2EdmMI7IZRziyIdop71MtylMGJGbGRgB8IcJEeZsacLHlnGng8GT55QaWX77CcmRDlEm8o5K5UwIkpoXGUUAeqLysFN7GBnS1tyoDDw+qZysvCn2pVaadVooepP7h0ZFCnOnjrkr4OtvhbTqt28+RJbvpfcwuPcdCeA2/J98V4oyPBAP+saIEiZmyeb2+0BmPG77OdjSectsi1l8IryE0t1gIUNNMOyWLBiS2rTGvJyKzG0CCgZJm6kwHqX94tA9AUK8Ju9hyDsUgs0vPEZpb1OOYpwD4ggH/vG1B6h8eHdMTlfV0tqOrrdVyPpAIH2ryl1/1OuX9Zu7bmQZS//DoODRucbhrT2DgWrfyUZjREtmM48HUjB5z9y+znHBTQNIDUU9nO3yd7XDkT+0UmnuGp0vLWn91Ihjw91keJK0QHXdVYrDXV/Ra6ChZfrmBB1MzWn0nw2EyFCStELU0NmDgWnfR+UJaZSeZwr3JEOKJN8rAZBhIWiH6qM2L3u7LDiXGOuKG+UyGgKQVos+uXimasF60hOYWMT23KD2aEw6SljxReVkpBm/4bJtcNEsWwmt4OPVEy690is4zCQWJbb7OUSG6ffO641TLgSkFoENkBlwYSKwcdgWEbQ8HIiVgWmUwCdmbE9n7H7IbRLvpfQzfn7AMSBdbzuGzq1eol59HpnQHyoDEtj5Iu/hWgujuo5+0hthWg6mHlTTLB6l/eNQH4v7ZZ1evOBCZBFMPfVdghFVjyAOJ1RSR1GOPRXburQ5RVnyd7bjQfJZyaZUIE1eoRhqn+EUtjQ2W2DezC0RZ6f34Mty1J0j+EqtUNR8kZtJ6eNdld/AdiMyXirJSDPb6UE7bcvqaRd7mgcRMGinVboW9MztClJVqVxUGrpIX8ripICHT/crt+LjR3am8c21niLLibWrAR21eyqWXmKUxHiSm/rgh4xmPG11trQ5EyjjfF3DcVUm5dMwUkEBooy4vK8XAtSsORIr5S0QTV6/H8dYEEtNG3F39rrZW8jAGByLzpPGUm5oSGGJ+MFm0TrXlkprt9rATRKGcMo0KNoSi+sNKpRdLvpQAoW28irkvZM1E3rRl2miTd91X/deVLQsRrYmyAyoaT2WGVFgFrNml5/hxhlukkQLgoW7qlojURmfYQy0Wc7aX3kc4soEfZ+bw72//h7uPHmMhvKY8SF1trRTHuwqZ2ZzifCRmL7m+kaomzSyfaD0ax8OpJ7j1n/8iNLeIXXMGcemM4kif1ZBQkKjhvqraKLIZN9Wx3kvvY3puEf5vv1dWQ11sOUfRSvWs4lUYSH2CCJci3qYGLaUVQoF6OPUEdx89RiyxbVWtJAYklumst6o2yl2BMmDKmjwV/SeiVrpE2YOjaCRuylz1DLYKMGW104OfZ5R7JiK00rFCnezsmD2rSPbBaem6+Kr/OnbT+4gltrGbThc0cPTZygvsJN9hsNenxGZ2V1srpZ2pjxe18xKSPkFEWxqmrNk+uGD0zoXMmLqfcPvmJ9JhqigrxYXms7xGy/r+4dHmfF0nJYWDdBZWFBFmztuUaTEf/fJz9HS2U+t+AADxxBvcm1Rj0rG36XTB5o0HUke+H7prT1hym0C0z1RRVgpfZ/t7oLRoJhV8Jm9TA2URdOgCiUVrVXYza0Y64Fmg7tz6lFriimcrL5SI5ryNXD/3fL7orUQvgYf5DA5MGamrrcHtm59Qd9oxOTMnPc9ENG8dwkGSbdZ20/vYSaaUhamirBQD17pJMO2l9zH5y5xkkBoMA+k8JZKRJbNLzzF8/wehK9mIPBMVpvVoXLqJa+GbN20gsWEQ+UNiT520P3gnmcI0m/gqevtBJkyTM3NSN3oJyqH+qIK3Er3+kUyNFPp18S9mwQowUXrM9thJAAqDdCQbR4HUzPOPZCXSdpKpvyXPrABT1meimGxZQuz4adYCkkfADQ2RhfCLI1ez6jDV1dZw80x76X2pvtIZj1soSHkd7bqTMkFay/sh5Jo9UTCJlK62Vm7y76jFYopWOsnNf3lIIFEmU8jSSJHNOHdoueqVCBVlpdz3uB6NC01taBFCSuc8VSO5+NTKAWk58irvz4+7Ki0xj5KilZZfbkh5bxQlcVjkVqLV0c6uKlkaycraKPf58bYkeH+rYRrpQ1I3bnPBGom6hyRadtP73LprK23Z8LYkIlFJIOncrSjRvprKpPyBsdfbXLNmpUoEHvR7greAtIieSgDNpk2aWeOs0EaP9WZ180LtnbfvpLwvPcGUZtMmM/S34vsqJNRWsfNEmGmTJTzn04ozu3lugsoNlpYFyY5ip4H1DkiS0wAOSI4Us3gckBwRIVEHJJUCCElJx6I2bXYKle3oQ2kGaedtStJDzR8qy8oCF6SRbJTSOAyk+fwfmJxsKy9zLWuTsxDhzQ8gbqAKFz2L0jKmjfdQ44k3lkrg8cAvLyuVtnf4O19ZzFNAShayigwDyVXFneWz/PKVZUDi1VbJ2jvUuxgPA2nFqJsZbd5kFs5rFV45rawCPV6VhZbwPynoZsKFV8MTT7yxhK+0EF7jjsGRVVtF8Y+CAT8fJMrJy7IiJMrUjNDcovIg8d6jzHZ4QhplVYuzvVXgzYyDiVOiuh6NC9VKO8mU8L+XNwRUZslw7DV3+m9SC0grBd7MMOlq5z/kyZlfxYH09p2p/XLlZaXUySCyNNK8MJDWJab262pruJWF8cQboTCZ2XzZ1dYqLaMdS2xTRhiuCAOJkgcxUijzoZ8uLQvtWDUDpnJCz5uRQvxMNYE0z72pRK3UeMpNGcEifICV0TDJ1EZEkFKHRWxHgsROxFnN94qyk3+9H3dyIzgjPnijYPrnDZ/00xMIyuFIBVOi55eyfojMLYlqVxXpwWc/eNXNnOyePKJ/JB4kFbRSV1srycRlp+6r7oDLFOJCCxkE0ob0BzBwrZvc/ft0aRnD9yeEBQp2gonwWW4d5R/lBYn5SdP5Xjkc2ZC+454dYEUdlh5PvME3wce4++ixEKDsAFMssU3Z8c87XZ5XRsLVSirMiM6MI76uafL+ejSOb4KPMXx/AgvhtYIWhNVhml0kbXbnBSnvmbZsfMnbfC9w3FWJ0S8/V2Zl3X30WNO5ILnirj2BxlNuVLuq3lcnxhLblPNf3+eBbt+8bqnKxt30Pvzffs97ZlvBgN+jGyQGUwhAT75rVDoQOZbYxoOfZ6QdxW41mBbCa5TDfb4LBvxDhZg2rkpTxbz91cx9QormjBCrmTlitcQ47wIuSMGAfxyZo7uPlMwZZOoU31eUlWKw14cb3Z2a/KZig4kyShHAKqW0iFqzzSVS9BBQEdLV1orArU+laKcsTCp3txC10RjlIipI3BdTTStlpdpVhcFeH77qv04Z/Sv43pXSBpNRtBGhiiNFcW3IILFE1LQVtVJWGk+5cfvmddy59SkuNJ813OS5a08ocUJkodqI5RO5ckzDvcd40duzlRfoam9VOmKpq615P4E/e5RoJEryFWwD0UJ4jVpTNkZ9TW74fyAVMA/gUr5rzngyK99qspNMYeftO0Si8fcHIGfyLGlNqQTVIdpN72P4/gRl4UwEA/4+6use0/g+RgDkzc5lj4uy2umS1a4qVLuq/pYPi2xmMuB2gAjItGwRte+IltfV1GkbDPjnAfzGu072cVEyxAoQxRLblKPZAeBOvg3agkFiMkQJfVU49NeB6K9C/ExSWnwj3SCx5NQE77pwZEOJMhMHoj+jNKKvN0KN1ArVSFmtxE0aPZiasbWJswpEGkzaajDgH9NzD10gMWK5ztheeh/3JkMORJKjNA2fwZDe++gea8PI5Tre69G40BJXByLtfhExSvuOBVPmgsSkj2LiRPeYORDRZHLmV4QjJD91S2u4LxQkFiKS3sDDqSeWr222EkQL4TU8XVomKwQ9DrZIjZQ1cdOUa61cjmoliCKbcUqxWlbuFGLShIGUY+K2KM636qUVVocoltjGvR/JzvVqMOAfEXFfISAxteijXJuN5KySFqg7WWMpiDTUrKdwyLlrekXTpi1P+odH+wAEqat8sNdnqcP6bAQRALRQKh+lgMRgGgPwBeVaK3Zd2ASiflZCDWVBYjCNA/iHA5M50ZkGxxogdITIdLYPyhA400xyfaav7/9gmzyTmRKaW9QK0YQREBmmkZhWciHTqXue+jsftXnR233ZIYQju6y6gphszIWoz6j3ZBhIemE643FjsNdnq0PxRPtDOhpADYXIcJD0wlReVoqBq93SZwapJrNLz8nt42ZCZApIemECgJbGBgxc6y567bSTTOHBz0/0DIE1BSLTQMqBaYwazeVqp97uTsvVgIt0qGeXnusZjGEaRKaClAMUOc900Hfq/bizaNIEkc04HkzN6G2TEp4nUg4kBlMfiBnwg3Kh+Sx8l9ttmxGPbMYRmlvUO8s8BcAnYhPWEiAxmJqRaQeud4AqGCAgk7fzae3+sDxIOX7TODgdvDygLracU2Y+k1ZZfrmB2aXnhZ6m8J1RiUZLgJQD1BAyBXK61ctxVyW62lpxseWc8lHeTjKFhfALLITXCm0VTyFTlCa9MF4JkBhMHqadLhX6Wi2NDfA2NcDbdFoZqHaSKSy/3MBCeE3UNLlpCKhstB1IIrVTrrhrT8DbdBqNHrep5m83vY/Y620sR14hshkXOYpwC8CQClpIaZByfCfNOSdqGqHu5AnU1dYc2utfCDSxxPb77wbMsMx2wI6pooWUB+lAZDcmwtxRAAMyw7GqP8yvDGOvt7Gb3tc8qaQAmUCmAzaq6melNEg5QHUwc3cJxSXKA2QpkA4ANVRIusAByAHpYIQ3hEz3il1S3FssalXSB7IlSAeg6kOmg8WqWmoCQEi1KKzoQDoQ6fUh02KjOlTTyGwPhayofWwN0iFQdeR8nZf8llaRqceat7rmKSqQ8oDVnPNVbyA0UWQOEZ6XsRPvgGQ+YM0AXAwsF/vfHYRfTeLP06az/06KbDh0QHKkKKXEeQSOOCA54oDkiL3k/xH7i8FYmXomAAAAAElFTkSuQmCC",resize:"iVBORw0KGgoAAAANSUhEUgAAAJMAAACSCAYAAABBufiwAAAACXBIWXMAAC4jAAAuIwF4pT92AAAO80lEQVR42u2dT0wbVx7Hv0WVMBzAVSAiBxNHIgKUSDHkFBIpGGmjOJc4XNJy2OAU9ZBDN7vySjl5XR9WWQltaVbqZZ3Y7IE2F3Av6yiVApEInIJBIsJRkfjjQxChqp0DMafswW9aLzUzb968efNsv6+EkJLxzHjeh9/v937v937z0YcPH6CkxEMN6hEoKZiUFExKtauP1SMAQpFxLwAvADcAX4VD3OR3vsL/zZHfy4lYOF/Pz/GjegrACTQ+8jNIADrJ+TIrADYBLBPQ6gaymoYpFBnXoNF+Wh26lS0C1hyAuUQsvKlgqg6AggScoA1Wh6f1SgFIJWLhZQWTfBZolPy0VtntbwGYIGBtKpicAchNrM9dAOdq5I/7BwDJRCycUjCJC6JHCUStqE1p1ipZTcF71cBEIIoCuFVHs+0CgWqiGqCSHibizqIA/iTiesfcLWhz/7/Ba3Y1Yr948Ltjt3d28b7Cv9sEVTQRC08omNhBitrhzppcjejsOI6eUx60EXg6TxxHs6uR6Xx7+QL2fnmH7Z1d7OUL2H7zFq83c3a5v7uyxlRSwhSKjA8CSPKa2je5GtHf04WeUx50njiOzo7jQr5HdiOH7Z1dZDdyyGTXeZ76OYBR2WZ/UsFEXNoEj7jomLsF/b1duNR3Vhg8RlpaW8fS2k9Yyq7zcI8FEktFFUyVrVHKikvTLNCVgfPSAKQH1nxmlYfFWgEQlMFKSQFTKDI+YSXAPuZuQdA/gP7e08xxj1Payxcwn3mFp4svrVirAomlknULE5nup8CYdOz2ehD0D6DnlKcm8gDzmVWkZhfwc/4d6ykmCVT5uoLJilurNYg4Q+WY23MEplBkfBRAgsWdjQSG0N/bhXpQanaB1f0VAAyKXkQWDlMoMp5kma1d9w8g6B9AvWm/eID4dJo1UA+JjKOEwsQCUrfXg7Hhq7/LStebshs5xGfSLK5PGFBCYGLNH30W8OPKhfNQ+s1KTf33GV4svzL70a9E5KNsh4mANGdmxnbM3YIvR4LS54qc0tLaOuIzabOx1GQiFh61875E7E5JmgGpr6cLsTu3FEg66u/twr3bN+HpaDfzsVtkrbM6LZPZGKleg2zBwbltMZRtMJkF6fMbV3Gp76wihEHx6bTZOMoWoGyBKRQZvwvga5pjm1yNuHf7pnJrFjWfWcXDmSdmPtLHOw/FHSayO2RGgSQ9UAUAPp6Z8gbOIPlIwK1AckCX+s7i8xtXaQ9vBZAis225YCI3lQTFWpsCSRqgzqGU/5POMk3QpAAUSNIBdYuslcoBE4mTqGZuIwG/AkkQUBd9Z6gNASkHchamMvdmqM8CfjX9F6ix4QD6eqgqLFppx9Buy0QVJ130nVHrbA4BRZkpv0xSOs7ARNzbdaPjPB3tGLk2pEbWATW7GjE2HEATXTlz1Iq7a7AAEpV7ayJfptpqs2tJnR3HMRLw2+7urHSOo9ocGfQPMAfc9x89tu2v9cuRoG2DN59ZxXzmlS3nvnf7JnNAvrS2TrOOdzkUGR9MxMJzQmAipvBvRsf19XRZipPs2BWrpSbsnkllN3IsdUe2x0+RbydpCuySKHXVE+LmojSDNnLNL9XDFJnjGhsOmJmaC4ufRgJUsetJltyTaZjIrhLDnFLQPyBVqa0TyVIZgerv7aJNF0yYXWphsUyGVsnT0S5VGsDJrLuMQI1c89PM7lpJXGwPTGQh97LhzQaGFEgSA9XmbqX9Y7cPJpqT95FuIwokuYG6cuE8jrlbDK2TmdiJGiYygzOMlWQJumVcUJYJqGZXI22JdJQ7TCj1kdTVRd8ZKYJumSsTZALqUt9ZGut0kqx0cIXJ0MUFh+TYDNBWoZWg0tGzbh6GhBom4jd1R6fb65FmAHM7b3H/0fcV+1A6LYbif9utE8XM7jrNmh2tZQpyIryugZINpPJgnAcDhjCRxJVuZcAxd4uU7W1kAWq/eID7jx5LCVLJOlHFcKOWYaIhUuY6JaeBKoH0vV3ddznFmK00WfFzRq6OC0xO9UuirNFBbuctHkylHAMpt/PW8FhPR7ujszzKMQwyw0Tj4vp6uhwJvLXpP23h/OvNHOLTaWlBunf7U0fTBpSB+KgVyzQoo1UqzyOZ2YnxYvmVEKBYQNKKB50Eqp/O1blthOm0YyCV/1XJApQZkErf5dPfVaE6BRTlWA7aApOno11oOa5eZtvM1h67gNrLF0yCdPPI5+cEUJQzcvMwEXN2TharRLNEYmYAeAO1ly8g8u1/TIFktNwjGqhmVyO6vR5bLJOhi+vxeqQBiWUAlrLr2MsXOA2EC23G61ym1w1FA0VhnY6Mm/Rg8nEyi8JAMjMA2nl5zUSbSfyjt0eNdQFaJFCUBsLH1TJ1e+UEiWYA7Koq0APK6jVFAWUlbtKDyat3ts4T7bZ/sdidP1oa8EoDYHd5SiWgeF1zbDggxDpR7AD2moVJ911vImqFeLig8v32ouqcDgM1diNQVc06KO61IkwfHzGTGxQx0KI0NhxAfDqN4NCAsEHVgMpu5Kru9RxtnxiO7WWWPJOjwTfPgXWir3izq7Eq3/PCOktvYAm+m1TfgJpWc5Px+FbyXkyWSTXrqm2xjm8Dy0xOSakSI0wwiUgLKDkrlvQAk5trdrnU0671uIlhjBvUY1PiJQWTkoJJScGkpGBSUlIwKSmYlBRMSgqmCtrU+1B2I6eeXI2LYjv7JheYlJTMwKSr7Z1d9ShrWKzjexRMui8Cfi9hEy0lftp/TzW+y7Qw5WvNOm3v7GI+syr8mnf+/i/h1xVhmRKxcJ4KJpqXsOz98q6qHs79R4/xcOaJsIHVrvm+eCD0ujxEsTH1udnUQMFpy8SjQVf5oAIQMrCHr8nruvvFAyFQbr8x3OKeNwvTstPpgaeLLy09vEqDajdQR11Tuy7rH6HWXcWuV4+ZTAssm4VpzuIFuYh14PUG1S6gjK4JlN6hZxYoM216BM3k5rhaJpFBuNmBpxlUO4BKPVswvOZ70iyV9tmJBMmEx1nmDpPITDjtwO8XDxCfTlOlL5pcjeg8wW+nDe3LlWmBEg0S5ZhuVZrJ6cKUiIU3AWzpnXVpbR0iZQSU+a5tfLeK03RCoQXKCZAAIGscvhwZ/jSwflCLm0S3RD4KKKdB4gmUUyAtra3TWHR7YCrdwE/C8yCHgTLbkNRqdxU7gXIKJBNjyQxTioZmJ6QBxdLZVkTTDbNAxafTpnpiOuTiVkj4Yx4mEmit6B2Tya471v3/4cwTRL6dZGqRLELNrkbE7tyiatKV23mLv/7z346BtLS2TvNWcV1PRVM1kJTR1WmieACOgHR4lifbe3oZxzBpFSZDV/d08aW0D8lpkKoBqP3iAc1LgrYSsfCyJZiIj1wxMtEyVhHIApLsQFEmbg2NCm1x3IShdVqQyzp1ez1SgSQzUJSeZYIXTCkYVBG8WH7Frac2H5BuSgeSppFrQ9I0TJvPrNLEnc/1ZnGmYCKzOkMzl3q2IMUDer2Zk7Z+SEtlyFKtmpqlGrMkzUFmasCjRgfIZJ1kLEhzMiFpIR1QSMTCfGEiZu55tVgn2YCSDSQAmEo/4xIrsVimqrNOsgAlI0iUsVLBNphIbbihdYpPP5HKvTgJlIwg7RcPMJWepbJKR5Wb8LBMVNbp9WbOsTU7mYCSEaRS0P2CZgJgyioxwURrnabSzxx/BbyTQMkK0vbOLn5cXOJulVgtE5V1+jn/DqnZF9JNzUUAJStIpRCE6oWNpq0ScMS7U2isUygyPgnglt5xPy4uob/ntHSvxng48wSX+s7aeo2RwJAt56V5e8DR7m2BFvC7Zq0SAHz04cMHphsLRca9KNWJ6xYHNbkaMf6XL6TNRteLshs5/CPxmObQlUQs7GO5BnN/JpJ3MnR374sHeDCVUqPp8OztwXfUYzDKeh1Lzb4SsfAEDCoKtNkdZdpeyQY9mErRLt98Y1RmYhtMZkj+YXah6ho41ILi02naDbNbNJ7GVpgIyX+mOXYqPat6OwnUfGaVpuhNU5Al6OZtmTR3Z5h7MrubVckaSA9nqFcivrLi3rjCpJENg5onDaj4dFq6hGYtaXtnl3a5BCjVKkV5XJcbTMREBmmOze28xf1H3yugbAKJps8CUYF2zERbJm2pJaSAqhqQBq3GSeViTlrqKRQZT8IgO67J09GOseGAelWrRS2trSM+kzZTwRmiLXpzFCYCVArAdZpj7dz7r4LtIwPuKO/7sPMNBaOgSGiWz/JUHsq8ptLPzII0aQdItlomYp3cKG0pPkf7mev+AQT9A4oSA2l9qDLZdbMgjdp1T7bCxApUt9eDL0eCanFYJ9B+MJWi2hovCiQhMLEC1eRqxNiNAPp7uxQ9ZXq6+BLf0eeQhIEkDCZWoADgDxf6EfRfrHsrtZcvID79hKUxrRCQhMJUBlSSdpanrFRJqdkFPF18ybJx8yu7gm3HYSqDKgnKPNThWGps+KqQZl0yKLuRQ3wmbTY2+vUx884jSQkTAWoUQILlsxd9ZxAcGqhZqLIbpfovxl7rWmZ7WfR9OwYTAcpH4qhWBZVliIBSXo/rEknVwFQWR6UAXGY9x0XfGVzqOyvdxgVazWdWMZ95ZfWtD98kYuG7Tn4Px2Eqg+ougK+tnMPT0Y4rF86jv/e09LO/vXwB85lXtNu0jdxakOZNXHUDU5nbm7BipTT19XShv7dLKrD28gUsra1jPrPKa0/dJBi3JdU8TIesVJQ1lqo0C+w55UEP+S1K+8UDZDdyyG5uI7uR47kpcwvAqAzWSHqYymKpCZYUAg1cnSfa0dlxHG3uVi6A7RcPsP1mF9s7u7/+tmFHbwGlbdtRGcdMWpjKoBokVuqy3dfq9paganO3oO0TfaO4/WYX+8UD7BeLoraBTwKI0rQDVDBJBJVkkh6iqoOpDqGqGoiqFqYyqLwEqiCvQF0CbaG0djkhywytLmA6FKgHUarsrFZrNQkglYiFq7opQ9XDVMFaBcmPzGAVUFpGShGI8rXw/GsKpgoWa5CANQjgpMO3tKIBJFt+SMHEDpeP/PbaCNgKgE2U+lfN1So8dQuTDmQ+AG4CmZv88yDFR/P47aXYm9pPNc2+FExK0qpBPQIlBZOSgkmpdvU/qa4Z7QH/pAsAAAAASUVORK5CYII=",remove:"iVBORw0KGgoAAAANSUhEUgAAAJIAAACSCAYAAACue5OOAAAACXBIWXMAAC4jAAAuIwF4pT92AAAKi0lEQVR42u2d73XiOhPGH+fc7+atALYCvBXgrQBuBXArgK0AtoLlVgCpIKQCnApwKsBUgKlg3g+Czd1NgsaWbEv2POfoZHePNzHSL/NHGkkBEUEkMtWDdIFIQBIJSKJ26a/O90AQ9ABE17/Fnzw1AJB98O/J9WsGoqzT3diZYFsBE1+hia5wDC3/lFcA+RWwFEDaFcDaC1IQDK7g3Fq/oTe5XMFKAOzaCla7QAqCCMDsCs7Q0bc8AdgB2IIoFZDcsjyza+t79vatgcpfkILgBs+oJb/UrwDWV/eXC0jVB8wLT61PkZhqDWDtE1B+gPQG0AJA2KGs+hHAyocA3W2Q6gYoDIEo4j2bZcDpVFdP/HDdQrkLkoqBVpW4sNFIATMYvH0dDMp9rzwH0lSBlaZv7XKpwuWtQLQWkPhZ2NZqED0eA3GsGtfimCpNgSR5a/bAegWwAFHi1LgRkTsNWBFAxi0MiaZToqcnckaHA9F8TtTvk5XPCKwJ6Lkydq4AFBGQGneua/Dcg2o6VcCbfeaMgFhAUhAtCMhLd2a/T7RcEp3P5J3OZ6LNxoaVWnUXJKBHwM4IoM2GWqOnJ6LRyASmtElX558raxtAf2q/NwEqJyDqBkhAXMqVhSHRz5/UGZm5vFm7QQJmpYNoH2MgGzHUclk+q2slSCqoLu7G9nvqvA4HouGwDEzbdoEEbAt3wnzeTSt0T+Ws07YdIBWFKAz9mAtq0joVj522foNUFKLhkOh4FFg4sdN47BRM7sREXQ2oTTSfOwOTG9nZcilQmEwTOJDNVTVPxP9gbZ5crHNWvNi6nfV5JrtlJGoXR8IuQttsgNkMIktlK3FcpFzlm81SFHsgqWrGBNxtQAJR0zBdAES2ynht7v3fCkQNK4pUEV3Icggh1FYouANSECwAjAUiR2DasfkYIgjslO5aWsmX7MzvbC5uPmvjloNMpzK47i6p5Ka1TGbBdhCsACz1BnSofHevJ66nbk0mwPMz58lnEE3qz9pUqn/Qh3ShyibKbvcRmSnPVdzE24NXekrAJNjmBWnbrUDUpHq9IsH39jqNU5NFUpsXN9rn5nNgvXa3k9dr9Rtra8AWC7c/6/fvnCd/gGhVfdamivYzVlGay4uw06mt/WX+JBS8WvCcgEH1WRt3E6PLlY1VQOQDTMcjd01uWy1IyhrlXndmlRD58Pn5UwKD6tJ/TrofhupAhapT/e1W/Zyia1G8VNhc43G5cwZWq+rfbTDgZHGPIJrZj5G41qiuLUNmmwndbXVov7dulYqk//ozivp9tzMXkVIcq6N9GPaxinmkmRNmWWRHvLGacueVeCCpeaO+1hrJqn4brdLCHkhijbpslWZ2QFInqI3EGnXWKvURBBNzkDimTSDyV7yx04Kkn0cKgkwbH53P9ZeIpKm9dTLXrETd4s0r/e/eqbp/aSCKtBBNp83UGdV1qGhXrNKPHxyrtC3r2vR2bzKRgRD3pnFtQZDi3s6QMHTHvSSJuDJTC//6eu+JC4h6xV2bytaG3lijb9/8BMmVc85nM129UoggiD+roLzn2vS/KuLW2iPeWE7KxEj3QQpDAalNGgzUJg2NI7YPkiu+XVRnvDYsBpKKj/oCkoD0ARtxEYsUWfmhojZmkJZBkgnB9qnX48RJA3sgjUbS6W2V3kBERUAaiDUSkIoE3A9Fo/NfqaKoqyDdkjENSB88JBapQ+IZCQZIOrcmFklAYoIEAanjKpG5PXDnCX4pDKWjuzANUFDFLZLER6IPpgAepE9E731SrLVZApKoEpXL2kQiY5BksVZkJdgWiZggZXf/h69F9iLHQBKJxLWJBCRRfUpT3RO5OUhFz20U+Sf9pteUA9J9HHlXEYjEtSG3QKzIZ728WHFtet+l96Gi9ro1pmvj3HEqcVKXA+1CwfZJQBKQPhVRygXpPikyu91e6Y3EKzfYBtS16xIjiUViG5kHbjD1my4XcW/dzdhSeyCJe2uneGOa8EFSmdtFQBKQTC2SPk7i35Mq8kX6MX397Ijk8iBdLhJ0t0l5rjuM9C4T5UEC1OV7oq5Yo5IgqUmnk7g3AcnUIgHA/e9+Ool7a4tb01/R+nzvComHsgT+0notA+G7eCHKXaPCudQmx70rSOu6DFmnIPBzEF04sN3CpTacCsmtNnuTWMlfJQkHortuzQ5IgNwe6bN4oYnWUuhdm3Ib9y+3AYD9vtlduOLaiivLgC9fdE/dvcymiEUCAD22YpX8E2/MWJE41yL1oMoHQmetklikKqwRAHzhVM0+MD9s7rxV0h9X556aPP2ON1aPrNJrFNvXpjdxLy/NLZv4eEpKU7dLJQnw+GjNrV2NDfEbsCVljD9v/T7R+Uy163gkCkPSvp9Lbb+nRjQacd4vKcJGUZAGrA5aLpvpoJ8//YFoPm+mjzYb7jvG1YGkYFqzXuRwaKajplP3IZpOm+mb85lrtZOiXJQBqUdArn2Z0Yga09OTcrGuARSGymo2pfGY+66Dolzw0v/3qfYKwFL73HLZbCaXJO6UBEdRs1e37nbA339znvwXRIvCSFDZeYwgyKC7ZRIADgc5m7tpZZkag8tFP4sNDHTraqbp/5+asVNcOXSi+WkGPUQAsCgDkRlI6v73f7XPnU7qTnlRM1osOLXYAPACoq0BD1S+qcA7c3pKoMvip/p5mQDbPNj+PVaKAexZz242Yp3qUpoCX79yn/4OIqNSV3OQFExrAHPWs02Xm3QFojjmxkXPIDJOJ+2ApGDS1ywBaqEySSSTcwOiE4CobIBtK2t7lxtAt80bUB8wjmX3SRXKcxU68CBSY2YBIrsgqXIDnokUmKqzRLwMDQD++ejArOZd25uLmwHYsJ4VN9eEOwNKzl7X5dpulmnLml+6WaavX2Xrd70QPdqGyHweybR2SeaZ6ponurW0qvGuDqQyME2nzRTF+aj5vDhEQM9PkMrANBw2V8vkg45H1UcOQVQPSGVgarpux1U9PZUpJ64covpAKgPTrTjueBSAzuciRWm1Q1QvSGVh6rp12mzKbmrY1gVR/SApmGalylT7/eZ2XTShw4G72+Ojtq57XOsHScEUs+q+P3N3bQ7Gj0fTDQyzJsa0GZDetjalRjsx2mShzAHKCIiaGs/mQHorjFsb7cwYjVQ246v2extbqHZ1xkPugfQG1KS0q/tvDLVc+pHlnc8qgTDfMpUTsHBhDN0A6c067azsHxsO1UC5BNX5rDKwcmn8x5sYDctjbTb7q//m1QMTqJNP+la+33CoFjUnk/orM2/76na7IuUd2qVuACvT0ljrw+YcSAqmHoAFOJswy4AVRb8304NU81ytwmeZ+pqmnFuGyugRBluGugfSG1ADACsA08p/1nCogOr19PVRWfZ2zVg1wPypFwAz7llFApILQLmll6sbS5wfIi9A6h5QzwDWPgDkJ0i/AzW7tn5L4LlAnZC2dtmFtQuk91neDMDYY+uzM9ouLSBZz/Qm1zb2Ah4FUCtO2GgPSB9bqvjamj7y9hXqgiDVWgJPN0B6b62iK1QRgEGFcJ2g7n1Nr+CkbQSnmyB9DlgE4AbZbVbyv3++p1tGlV+hyW1uOBSQRJ3Ug3SBSEASCUiidun/DlECl01FAtQAAAAASUVORK5CYII=",itemAlert:"iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3FpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQyIDc5LjE2MDkyNCwgMjAxNy8wNy8xMy0wMTowNjozOSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpkZmM5M2YyZi1hYzg1LTVlNGUtODE2Zi0yN2UzOTNjNTM0ZjgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RTk1OEVGRDQyRUI0MTFFOEJGQzRCQjY0RDUzNERGMzYiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RTk1OEVGRDMyRUI0MTFFOEJGQzRCQjY0RDUzNERGMzYiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOmFjYjg5M2U2LTllNTktYmY0ZS04MWVjLTM4NmQyOGQ1NjEwZiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpkZmM5M2YyZi1hYzg1LTVlNGUtODE2Zi0yN2UzOTNjNTM0ZjgiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz53t8IQAAACGUlEQVR42qyVz0sbQRTH36YhblAJCtYKHqonBW3soWB78VCKCkppBCFeevBWKCiekj/AnIT0klsPXhQKLbQWtIgXDyp4UgNtQcSDP1APkhYxDZrt9zvOxkXdTUJ88GFmZ998Z/btvDeGZVniYnUgCvrBE/AI5MAe2AbzYBac3jmbwjcwQQycWsWNPnEQvKlj2Ds2DIMDj9GdAx2Sz0tucUly3+flYmVN8scnys/3sEH8L7olMNAvgVcvMeDjcBoMQmO3oOcIRTNYZXuxlZaziZhc/vwlXvagvU2qpxLi7+wQHaLnui0Im2AZPOMuz96NiZXNSilmmKZUp5JXuxdZBz3g3Kffj1FU7bQMUfWP4Ms5nEsNraV2XI92BzENZfpeu35+1fCQav99+uwaltDCV8Y8g8dWnz5SIYbAK6bB8fcKN+NcalCLmhTu5RP/fqXm0OijcBd7PFKVmkMjTOFG9uxzWok5NBr9/B8gUHTS4WFZi1CYM2qZUV67/hOJFhWjhrYjhuK3WgFp6rmDp2GFp8+1xgaFf7DH3PeymtQHhZc5NBZKThBz9K1qsx+nS0oQu1bEwCTT8i9iWU5K2/Wi9susXYziIGHXiiTY4gsWFDqWI8o5WjSttcQWPgcRcMAqxdX5acWMPvTVlW0fvNFatwp9C7rf7qPQ33U1BfV1cz9Xk8tlOsKCoi/TJj3OhNrkkQIzbpfpfwEGAB0OebpeExhfAAAAAElFTkSuQmCC",itemAlertDark:"iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3FpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQyIDc5LjE2MDkyNCwgMjAxNy8wNy8xMy0wMTowNjozOSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpkZmM5M2YyZi1hYzg1LTVlNGUtODE2Zi0yN2UzOTNjNTM0ZjgiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RjQzNTRGRTYyRUI0MTFFODlFNDdCODEyNTEzMUI5NkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RjQzNTRGRTUyRUI0MTFFODlFNDdCODEyNTEzMUI5NkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOmFjYjg5M2U2LTllNTktYmY0ZS04MWVjLTM4NmQyOGQ1NjEwZiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpkZmM5M2YyZi1hYzg1LTVlNGUtODE2Zi0yN2UzOTNjNTM0ZjgiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7DiQshAAACAklEQVR42qyVvS9DURjG3yuiDNLQwUcMNNKkidDFoB1qU4M/gIQJo1oQgsFnsGDEzMLCoDYkarDUx6KRxkBEaMQktdTz3JwrV7m3qp7kl3Puvec899xzz/u+WjqdFguVgU7QDhpBJXgHd+AG7IMt8PLjbBpnUAxGwUs6uzhmDJRk+mgZK64Fe6CB909OonJ0eCSxWEySyaQ+wOVyic/nk2BrUAIBv2iaxttXoAPcGkZm4xpwyjYej8viwpIkEgmxk9vtluGRIfF4PKK2qEW1n8bF4Bg0R6NRmZ6akVQqJb+Rw+GQiclx8fv9vDwDQfBWoJ4P0pQrzcWU4ljO4Vx6KC99xeVoE2idfb39lp8fag/pbWQ/Yrkt6xtr3PNXXhaoI+Xkj7Lb056ebh0rcS496EVPGrfxin8/X5k8QjT2sccjla9MHk00rmDPOKf5yORRUcgfC4qyTXp6es7pJTR+AKWMKLtVhwfCWc3oofTIrbhmj2FqJ6/Xq2Mnk8c5jQ/YY+zbidFF7GTyiBSq1DeLhOLkIbc6yzvbO1nzBpMSxADZMnLFKJhjWIYHBnMKaSNfrKwuG8loDMwbuWIZXPIBP5cDczHlHGV6pby+pM16Bg+o/mPavAetqrp8S/R1YPc/Ev1PpalElZt/LU2ZxbSLCUUV0yp1nwF1wSMFNq2K6YcAAwCfZ3CwpLDluwAAAABJRU5ErkJggg==",maskMoveShape:"iVBORw0KGgoAAAANSUhEUgAAAIIAAACCCAYAAACKAxD9AAAACXBIWXMAAC4jAAAuIwF4pT92AAAI3klEQVR42u2dvXMTRxjGH90w6jw2Yxq78dGYivgYqOxCR0WVQZmhSgqLSiXKX4D4C3J0uEIUScUMctIkFaeeDBJUoeHU2A1MpFGnRineUywJfZx0u3f77u4zo5E/5fPtT+8+7+67u4XRaARjdFbYAeAl+MkI1VEEg1TQDoSzghc3ths/7wAopXjFVvwcAohiSEILgnrvcD9+eCkbfF11YjjaAJqojnoWhGwb3wVQjh8lha6sA6AZQ9G2IMht/AqAIwb3tRtDEXDxGmqDcFYYN/5DxlG3BaCB6qhhQVgfgAqAOoADjfxYF0AjjhI9C8JyAOpxBNAJgFn1AQSqAaEGCHpGAFZA5AvCWcGPb8YRzFUXQA3VUdM8ECj/DwCcwmrSVFbyyjKcnDKByELwjUoA2rFP0jgiUBRoME8FtY0O2YBA4/9Nw8ygCDNZyco7OBlAUAPw3kKwtrYBvMFZIeAfEc4KDesFhHUVZZlpphwQyA+EhqeFotWJu4o2DxAsBLJ9gy8DBkcwBF6cGloI5PmGML7PioJAFxfGF2vFDAbHQmBhEOMRyBNEFgLensERAIGNBBpEhrRdQ5OtMdz3dYKhEb8pcwCBBotKLG/drgd8/5ae9dBR/KbMGAQqJOE7YngSTD/roVKa4WhnAwg8AC/Z3q5bFWAvDmR7JfpcHz2Jp/klZw3UD7XBdQKpuAP8FAHFCW877AO/usCwpwsMfQDeulPY60aEOjjPIp4E0xAA9LleXQSZR2ldA4WcJ2xvz74PHC6wNYenOmURY79QF981cO8SAOBRG9hdkul+7QCvPZ1gWKuLSBoReHcJt2vLIQDo+7drxnYRqyMCZQnv2d6OLZeiQTHB4OewT1FhEOkExA9Jyt2SRATeTuo4SAbB2Dgea2Ucqf0SjDo6CQxiie0t2PcBd82iafehbsbxAEAtbUTg/fbwG9n+nrqqrYoKzpJoUGFtEO/Vga0NL3/rgH5fL+NY28wsnhUitiBsucCPn9O/zm83dTKOfQDuokpoZ4k34BsN7jfUeh0GUcFZ2KdwlVu+mlRKq70SvZ4+qiQHgcYNeGYKxR3x6d9xQK+rSwZB3i9RROAbDdIYRHOMYyWZWTwr9MCxBnHXAx5JHAB9fQf42tYFhpuzcxDOnJSRZyGq7Klkvaaqa6u6Bp7OaLLqSJb0qmYqL+4aaOTpX5YGcbbqSJb0qma6M7kewmEfDU6CbCAAdKtmKi/qGnx2/8qyqiNZ0qeaaSEI/CJCXlPGekxVH01ORDmxP/DYZQtJqo6kparaVDP5sxGBV6zbcvMf5LlXp+vQDAReVZvHGRrEZcaRfxfBOCJsUnUkS/yrmY5mQeAz5axa9RD3aibaDxvO+AMWkjGplNqvsJ+UcscRgYfj2XKBu0/VvLa7TzkbR2YgqF4txLeayR+DoH7GILLqSJaYVzM5oAMy1ZWMqiOpaS27aqYSj65BRYOooXEsjF5A3fP+ZFcdyRK/aqbr15S+vGEP+OM+PxD41St4aoMwiHRbmay0WbSysiBYWRCsLAhWFgQrC4LVYl2zt0CAdj2afbwxZ9rmImSRBqs9sqiy3DJws0zPScrmBl3gMgQ+BCqOOl4vjF6gDdlnLqgw/n4R0iOtblWAu/V08x+XLeBdXcz1iFB1VLgGQP54qCoFJWlu/K5HNQciSuj3SnRexGULeFtRottwQOcxWa2KAo/ei19HsVeizUDzrWNoWRCS6H4D8CUeT1HcBh68yXOldc+CsErHQXZrK/2XecHQtiCs6g5uZ3wqgf8yj3USEYFQHYW21ecYw7zK4x40sy53+z8iAHQSudVYJzkuqct6D4Z4swxnkgorZLMNzyodnma1TqI1mT4CdJqrFUCDRSoom0G4tgVhnvZ9dSqmD0+z8ArhNAi0517XdgsV064nnI0INioAwJ6v1vXITSVbkzu1T4LQNBqC4o56C2nkgjDV3s5EGtEE7elvpm4ouAS0uC3TJywAwfSooOqydjmAdpbvxWxBMEWN2S9Mg0Ddg80e9FdzOQjWNJqg83nHBM8DITDy9nwxZpS9Me+L34JAtJwbB4KqK5gvQpGv1l10PPCidQ3mRQWxN1yMBsLtWn3RN+aDQDUKLeNg+KrYbPyl8GjQWA+EFfRoq38aal3PZ6G+fek/txgEE6NCpFDCNOyLvJ4uqqP6ZiCYGBUGEfDplRrX8lGoTVvZjstBoKhgVgbxrq5GNPggDITOMm+QNCIAdDRc36io8PF5/jCKS2cTnTCyGgQaVwiMiwp5ZRCXLZHdwqukVerJ9kcgo2FOpfOwR2sShxkHwkEX+FPY8rc+1jjeeZ2NMipmjSm0gd/97GAY9oG/yiK7hMpkBZI4EKj+/ZmFQcbf6dDfEbdvwvmioWQREcG8LmIMw2tPnmeIzkVD0N0kem+yh1IZppW0DSKC4e9n4qLDsA+Ej0V3B9Q+a3QJY12dDb2O6Pift4l/XoUDsETtY1TcAb6r0bmPmyyLG3SBTw0aJxA/4/kzqqONUo7NQCAYagB+gcka76O06y3fROOyRfUOF6HMYexXqI42NvSbg0AwNACcwoq05U7XPn5pZ1Xn0EF1lKrKNR0IBEOI+BQQq1zUAeBv4gvSmsV55tEuq89HfREQiAGBLsK3MPCFQFREsDDkB4GwwQdxezFbGNhCIBaEaRhatr2kGUNXNARisgabWmalFjYcNcwXBILBDjqJUarBovxBIBh80DK6bdueG+lxklIz9UEgGNwYhiPbronVjbuCTNbiZQPCFRB1AE9tG6/UcwB1WX4gfxAIBg+02MJGh/lRoLZuUQlPEKajQ816h/yigBogXHmHAMBDw9PCWlZeQE0QpjOLOsyaxcytG1AXBLOA6MZdQEOli1ILhGkgapp1GS0AgSoRgAcI0x6iBqp5OGDY+H3Q+EmQtwfgDcI0FOUYiDKDTOMcQFO18K8HCPOh8BWJFON3fhgD0ON2S3mC8G334ccPD9kMVHXjRm8DCFUP+2aAsNhsujOPnTUh6YIOvurFDR4BiHQ9A+s/810wc9nms20AAAAASUVORK5CYII=",maskMoveImage:"iVBORw0KGgoAAAANSUhEUgAAAIIAAACCCAYAAACKAxD9AAAACXBIWXMAAC4jAAAuIwF4pT92AAAI1ElEQVR42u2dP2gbZxjGn5yDiiHOGbtBaYodBYqHJsFXsqWDRQaDoRB1SuliebmxUSFjQhU6ZpGzVUvkzR5CZDqYdsllqLM09EySIaIQOa6THMEiig0GgXEHfUpk+2Tdne9035/3AREIPumk93fP977f32O7u7tQSUU7aQAY7PZ3puFYKv0ux2QDoWgnBwEY7JVi/w4CGA/4lnUANoAqe9kAbNNwqgQCX4FPAciwgKcBnO3RR7cAsQBYojuIkCAU7WSGBT3Tw8B7AcMCUAZQNg3nPYEQTfDTALIs+LoAt7woEhRcg8Da+yyAHEdPfhCnKAMomIZjEwj+2/28QE+/Vz0CkOcxn+AKhDYApiWv1lYYEGUCQU0AuHWIWEFgOUCOvXSoq0UAuTj7JmIDgVUBJYGTwCiSyoJpOHklQGAuUFCwGfCTP2R7XWFoMbiATRAcqnEA/xTtZF5KR2Bf7BeKs+9kMtOLDqnIQWBNQRnABMU1cO6Qibqy0CKGwGBNAUEQXDqAh0U7mRUSBDYwZFFVEJruFe1kSSgQGL0PFO8biELTUcEQeo7AILhHMYu8xEyHmURqBIGwJabFEnG+QCAIxIZBIwiEh6HMBQgEQeyaCCOBPFKyyPoJrCiqgzMnLgMAvjjxbey/dGOnjqfvirwDcfsoA1aBQWBtUzVMCBJ9Oi5/+StS+hQSfSe5+pUrtQVYr37iHYYZ03ACucNRmoZQnSClT+HHr//G2NA17iAAgLGha0iP3uUdhAJz6d6AULSTBQRfMOIKweS5EpcACAaDDqAcpJLQAkCQAXA9zOZAgCdNJBjOojnhJzoQGGmlMO/64imTeycQEIar7IGNzBHKYVcIF0+ZQtZsAsBQYpOCwwWBERbqcPJw/wUu3WBj+7kMMOhoTgkMD4QomgQA+IzTJqFaX4L16roMMHhuIrw6Qh6KDSlXavOywFDwUkVoHtzACLNKIBhiqSJyYThCAQpLEhhy3RJHrYsbpEHzDWWAQWfNe2BHyIMkCwzTh7mCRm6gFAz5II5AbiAfDNOdKgitgxukyA2khSHnxxHIDeSFwRsIzDoyFGppYdDdVk25OYJs+xYRDO4x7gpCjsIrPQxX95eSmkuSOE6hVQKGzGGOQLmBOjBkCQSCAQDG25sHbV+1QH0HasGQdnOENIUwPhhimrKXcQOBmoUYYUj06dw4gkGhixeGGKS3FsRobfkBlY1qwmAAwHFyg4MaSIx8XIQblrYar1CpLWBs6BpvXzcNoHRcxESxUltAtb6Eje1n2GysYSAxguH+C0jpU6H80GND13gMWFRKtTtCSoQ73th+jj9fTmOzsbbn/zcba9hsrKFaX8KTt3cweW4Ow/3nydq8aaI9WUyJ4AL3X1w5AMF+bTbWcP/FFVRqCxRijyrayZTWTgXPTrC8fsvXNcvrtzyvWCIhpYlwl4/Xb6KxU/d1TWOnjsfrNynEHisHjU1S5doNXm8tB7r29dYyuYI3DXLvCNX6UqzXq9Q0pPh2hGexXk8gcCK/uUHY16si7puG4f4LsV5PIBAIBAJXjZc+FXiINtGnI6VPUZRlACHRdzLwpA0RN+qi8vEQXTp9w/do4JkTl3Hp9A0u7p/jIeiW3muiIDt5bs6zzTc38JzjBoJKbZ6ahjCbiMlzJaRH72IgMeL6NwOJEaRH73Kzi6soEACfhqGFUWuuwMb28wPzEXgaehYJghYINgTUcP95bucciAZBq2l4D5LSEACwNQqd8hA0q4aoj5olCIRQteUIyo7MNE9mua4yBABQbVUNSp7fvP94nvTorIoQ7HGEquoQBFmEIgkEMA3nIwi2yhAEgUEWCAA8apWPSoHQ7bQ2LzBIBMHH2GvMGiyCwBsMkkGwFwSmFYLgcBgkhABoHtu4BwSLIOgMg6QQrJqGUwX2DjpZkPCAjqOe4FqpzePN1l9dl9qJ7AZ7HME0nDJB4C5JIXAHgWmRIFBK5U4glAkCZbRoGs57aUEgCPy7wQEQGCGLBIHiIIjsCgSBL821NwuuIJiGU4Jgw9IEwdHcoJMjABEc/0sQcKNVt66CTiAUCAJp5RpbVxBYt+McQSCd6p3cXsjj/giC4G6wP0nsCgJzhUcEgVRu0LHJ7zadPUsQyO8GXUHgKVcgCKJzAy+O0MoV6gSB0Mof5gaAh0WwpuFUi3ayAOCXOL7BxvZzVGrzoe+WrpBWTMPp2h3gaTW0aTh5dnro2V5/i+H+8/juqwcUzuDydI6nn7WPoSeOEk/44EWzXicmewaBveFs2CBsNf6jcCGSHWJX4aMvyO9q6Dz7gND0Qr4Job71Zms5ih1is90SxMAgsDcO9TS4p++KyrvCk7d3YmsSgjoCTMOxAfwc1h03dur44+U0GjsflITAenU98O7zh1QJvg96D7RRBitHQpvJtLH9DL//+71SW+o3dj5EsVaijoDncx3b3d0N9InsiEALIR8TODb0Ay6eMqU9k6mx8wGV2gKevvstiqrpG+bYvQOBwZBCc+1c6MeYJvp0fC4ZDK1DyCLSDJtdhp6DwGAwmDPoIMWl26bh5I/yBkcGgcGQBvCQ4hGL5kzDyR71TULZVY2VKjMUEzEhCA0EBkOJYBATglBBIBjEhSC0HIESyJ5qNkiHUU8doc0ZbNaxsUpxC71EzEXxxpE4QpszRNLppKDqADJR7nUVKQhtQJQATFM8A2mFQVCN8kN6sik3S2xmoPBWv0GTQgDpqCHomSO0OUMKzZU2ExTjrk1BtpfbGfUUhDYg8mjOpaOq4qAW4XNSibAgkDu4ahVALq5NzWIDoQ2IDJqLL84qDMFtdFmJJD0IijcXc2guPqnGfSPcgNDW75BTAAhuAOAShH1AZNCcNS1Lk1FHc8sargDgGgSXHCIL4KqgAKywpLgUZw4gPAj7XCLLXrx3Wa+yp78UdA4hgeC99MygObB1laMn3xIp+MKD4AJGmkFhsH97kWg+QnPirgXA4tn2lQGhQzNisNcgPs31N3xC0to6yEbzxFwbQFXEJ76b/geXEooCwBQ2IQAAAABJRU5ErkJggg==",warningOutlined:"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TRZEWBzuIdMhQnSyIFXWUKhbBQmkrtOpgcukXNGlIUlwcBdeCgx+LVQcXZ10dXAVB8APE0clJ0UVK/F9SaBHjwXE/3t173L0DhGaVqWbPBKBqlpFOxMVcflXse4UfYQQRw4zETD2ZWczCc3zdw8fXuyjP8j735wgqBZMBPpF4jumGRbxBPL1p6Zz3iUOsLCnE58TjBl2Q+JHrsstvnEsOCzwzZGTT88QhYrHUxXIXs7KhEk8RRxRVo3wh57LCeYuzWq2z9j35CwMFbSXDdZphJLCEJFIQIaOOCqqwEKVVI8VEmvbjHv4Rx58il0yuChg5FlCDCsnxg//B727NYmzSTQrEgd4X2/4YBfp2gVbDtr+Pbbt1AvifgSut4681gdlP0hsdLXIEDG4DF9cdTd4DLneA4SddMiRH8tMUikXg/Yy+KQ8M3QIDa25v7X2cPgBZ6mr5Bjg4BMZKlL3u8e7+7t7+PdPu7wcF5XLiwo0hmwAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAN1wAADdcBQiibeAAAAAd0SU1FB+YDHA8LOJEM5qAAAAOHSURBVHja7ZlLbAxxHMd/07KltNQjJUJESUMiUUIiJBJF4oJLJUjowTM4cFAHktZFBQdOHFSCAw4IlTg4iIhEEa9IvBpB69mgWBTtx2XEGr/ZndnXzM7ON9nDzv/3+n73v7//Y0RChAgRIkSIvIXhVWKgWERqzK8nDcP4llfKA+f5i+Z8I7+I/7EwX8hHgEeKAK1AUT4IsBV71AWdfDnQGUeAT8DwIAtwmMRoCir5yUC3AwG6gWlBI28AlxWy54Bm5flVwAiSAMsUkl1AJTAW+K6MLw0K+b7AM4Xg7hibPcp4G9AvCALsUMi9AQbE2JQArxS7hlwnPxKIKsRWKrarFLuvwOhcFuCkQuoWUKjYFgDXFfsTuUp+BtCjEJqVTh+/ki8AbihEjjvwPeF01vhZgDXJ/p/j9I3VuUK+1Kaj17uI0aD4vwUG5oIAe5XiX1jXdGAdUGd+1lrG+pk+Vuz1O3m7Xd0SxfYfKONLlTg/gMpcueaKu693IIDd+aHZr+Tn2pzsptrYxxXAtKmyOUHO9xv53sADpdBDcXwSCmDaNSlxHwMRPwmw2e3tjgsByoGPSvxNfiE/FPigFLglgZ8jAUzbOiV+JzDMDwIcVIp7kuiG16UAEeChkueA1+QnAb+UwhY48HUsgGm/0KbJTvFSgEtKURcd+roSwPS5oOS74sn1GbBYKeYnMDGDAow3N0NW1GSbfB/gqVLIPhcxXAtg+u1X8j43X7ZmTYBtShEdwCAXMTpifV34DbL4/sG2bJEfAXxRClifxR9gg5I/CozKRvJjSvL7QK8sClAI3FXqOJrpxNNtrqzmedCEZyt19AAzM3nNdU1JesrDZfi0Us9NoCATyWqVZN+BiiRiRYBdwEugHWhM5nADVNjcP9Smm3yJWawVjUnGa8xwrJdASToF0JK8BkqTjKeJ+SrJWP3NWWTFznSRH2MzzVakEFMruC3Nf88uYFymGk1LKo3GZkbtTLFBtygxT6dKvtpmqZmeYtyIKUJ7Kk3Q4RJdnVubDb9s0jzdbnq9TQfKgHeeHThSE2G7Uvd7YLBmbzc1dojIEMuzqIjcAeb4XIPbZq2xb6LKRKReRDZajbUXFhPMIL0lWOgWkSrDMO7FPtSWst0BJC8iUigijU5mQFREiiWY+GwYRmmiGXBGgouzTmZAkYgsF5GKgJFvFZEjhmF0SYgQIUKECBFCROQ3nMO7R8eI5nkAAAAASUVORK5CYII="}),this.side=null,this.design=null,this.editTextCallback=null,this.itemRemovedListeners=[],this.designItemRemovingListeners=[],this.itemChangedListeners=[],this.itemCreatedListeners=[],this.designItemChangedListeners=[],this.selectionChangedListeners=[],this.deselectionChangedListeners=[],this.imageLoadedListeners=[],this.textArtLoadedListeners=[],this.notifyMessageListeners=[],this.removeMessageListeners=[],this.gridImageSelectedListeners=[],this.shapeLoadedListeners=[],this.fillShapeRequestedListeners=[],this.undoChangedListeners=[],this.redoChangedListeners=[],this.bindedUndoStackChanged=this.onUndoStackChanged.bind(this),this.bindedRedoStackChanged=this.onRedoStackChanged.bind(this),this.areaAlertItems=[],this.areasSizeCountCollection=[],this.areasSizeLimit=52428800,this.panOrigin=null,this.preventViewMoving=!0,this.preventAreasAndIndexUpdate=!1,this.usedColorsItemsToCheck=null,this.touchEnabled=!1,this.isSafari=/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent),this.customizedMessages=[],this.fontAscentCache={},this.originalBgImage=null,this.currentDesignOperation=null,this.undoStack=new Zakeke.Customizer.Stack,this.redoStack=new Zakeke.Customizer.Stack,this.setupUndoRedoStacks(),this.executingUndoRedo=!1,this.showDashedEdge=!1,this.DashedEdgeColor="black",this.showSelectedElementDimensions=!1,this.showUnselectedElementsDimensions=!1,this.showTotalSizeOfCurrentSide=!1,this.unitOfMeasurement="cm",this.RGB_HEX=/^#?(?:([\da-f]{3})[\da-f]?|([\da-f]{6})(?:[\da-f]{2})?)$/i,this.supportedBlendModes=["normal","multiply","screen","overlay","soft-light","hard-light","color-dodge","color-burn","darken","lighten","difference","exclusion","hue","saturation","luminosity","color","add","average","negation","lighter","darker","copy","xor"],window.imageEffectCache={},this.maskedImageSelectionMode=MaskedImageSelectionMode.Element,this.shapeImagePlaceholderIconPathd="M 15.2,12 A 3.2,3.2 0 0 1 12,15.2 3.2,3.2 0 0 1 8.8,12 3.2,3.2 0 0 1 12,8.8 3.2,3.2 0 0 1 15.2,12 ZM9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z",this.shapeImagePlaceholderIconFillerSize=8,this.selectedDesignItem=null,this.selectedPaperRootItem=null,this.areaLayersPaperLayer=null,this.areaLayerIcon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M 16 5.9375 L 15.625 6.0625 L 5.625 10.0625 L 3.3125 11 L 5.625 11.9375 L 9.53125 13.5 L 5.625 15.0625 L 3.3125 16 L 5.625 16.9375 L 9.53125 18.5 L 5.625 20.0625 L 3.3125 21 L 5.625 21.9375 L 15.625 25.9375 L 16 26.0625 L 16.375 25.9375 L 26.375 21.9375 L 28.6875 21 L 26.375 20.0625 L 22.46875 18.5 L 26.375 16.9375 L 28.6875 16 L 26.375 15.0625 L 22.46875 13.5 L 26.375 11.9375 L 28.6875 11 L 26.375 10.0625 L 16.375 6.0625 Z M 16 8.09375 L 23.28125 11 L 16 13.90625 L 8.71875 11 Z M 12.25 14.59375 L 15.625 15.9375 L 16 16.0625 L 16.375 15.9375 L 19.75 14.59375 L 23.28125 16 L 16 18.90625 L 8.71875 16 Z M 12.25 19.59375 L 15.625 20.9375 L 16 21.0625 L 16.375 20.9375 L 19.75 19.59375 L 23.28125 21 L 16 23.90625 L 8.71875 21 Z"/></svg>',this.areaLayerArrowIcon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M 4.21875 10.78125 L 2.78125 12.21875 L 15.28125 24.71875 L 16 25.40625 L 16.71875 24.71875 L 29.21875 12.21875 L 27.78125 10.78125 L 16 22.5625 Z"/></svg>',this.initialItemsInfo={},this.eventsToolsCustomizer=new Zakeke.Customizer.EventsToolsCustomizer(this),this.isSetSideEnded=!1,this.strokeJoinText="round",this},MPlaza.Customizer.prototype={debounce:function(e,t,i){var n;return function(){var a=this,r=arguments,o=i&&!n;clearTimeout(n),n=setTimeout(function(){n=null,i||e.apply(a,r)},t),o&&e.apply(a,r)}},throttle:function(e,t){var i;return function(){var n=arguments;i||(e.apply(this,n),i=!0,setTimeout(function(){return i=!1},t))}},createCanvas:function(){return this.canvas=document.createElement("canvas"),this.canvas.setAttribute("id",this.canvasID),this.context=this.canvas.getContext("2d"),this.setupCanvas(),this.isViewer||(this.setupTouchEvents(),this.setupTool(),this.showSelectionBounds()),this.updateCanvasImageQuality(),this.canvas},updateCanvasImageQuality:function(){this.context.imageSmoothingQuality="high",this.context.imageSmoothingEnabled=!0},setupCanvas:function(){this.isViewer||$(this.canvas).mousewheel(function(e){});this.paper.setup(this.canvas),this.paper.Layer.inject({_selectChildren:!1}),this.paper.view.draw();var e=this;this.paper.view.onFrame=function(t){e.loadingCircles.forEach(function(e){e.rotate(3)})}},clearMemoryForIOS:function(){this.canvas.width=1,this.canvas.height=1},appendViewMatrix:function(e){var t=new this.paper.Matrix(e);this.paper.view.matrix.append(t)},translateView:function(e,t){var i=new this.paper.Matrix;i=i.translate(e,t),this.paper.view.matrix.append(i)},rotateView:function(e,t,i){var n=new this.paper.Matrix;n=null!=t&&null!=i?n.rotate(e,t,i):n.rotate(e),this.paper.view.matrix.append(n)},scaleView:function(e,t,i,n){var a=new this.paper.Matrix;a=null!=i&&null!=n?a.scale(e,t,i,n):a.scale(e,t),this.paper.view.matrix.append(a)},getIdentityMatrixValues:function(){return(new this.paper.Matrix).values},getTranslatedMatrixValues:function(e,t,i){var n=new this.paper.Matrix(e);return(n=n.translate(t,i)).values},getRotatedMatrixValues:function(e,t,i,n){var a=new this.paper.Matrix(e);return(a=null!=i&&null!=n?a.rotate(t,i,n):a.rotate(t)).values},getScaledMatrixValues:function(e,t,i,n,a){var r=new this.paper.Matrix(e);return(r=null!=n&&null!=a?r.scale(t,i,n,a):r.scale(t,i)).values},setupTouchEvents:function(){var e=this,t=new Hammer.Manager(this.canvas);t.add(new Hammer.Pan({threshold:5,pointers:0})),t.add(new Hammer.Tap({event:"doubletap",taps:2,threshold:100,posThreshold:1e3})),t.add(new Hammer.Pinch),t.on("panstart panmove panend pan",function(t){e.onPan(t)}),t.on("doubletap",function(t){e.onDoubleTap(t)}),t.on("pinchstart pinch",function(t){e.onPinch(t)})},setupTool:function(){this.tool=new this.paper.Tool;var e=this;this.tool.on({mousedown:function(t){e.onMouseDown(t)},mousemove:function(t){e.onMouseMove(t)},mouseup:function(t){e.onMouseUp(t)},keydown:function(t){e.onKeyDown(t)},keyup:function(t){e.onKeyUp(t)}}),this.tool.minDistance=1,this.tool.activate()},createDOMElement:function(){this.domElement=document.createElement("div"),this.domElement.setAttribute("id","mp-canvas-customizer-div_"+MPlaza.makeID(5)),this.domElement.appendChild(this.canvas),this.domElement.style.position="relative"},appendTo:function(e){e.appendChild(this.domElement),this.resize(e.offsetWidth,e.offsetHeight),this.resize(e.offsetWidth,e.offsetHeight),this.moveOriginToViewCenter(),this.isViewer||this.setupZoomControl();var t=this;$(window).resize(function(){t.resize(e.offsetWidth,e.offsetHeight),setTimeout(t.resize(e.offsetWidth,e.offsetHeight),200)}),$(window).on("orientationchange",function(){setTimeout(function(){e.offsetHeight,t.paper.view.center=new paper.Point(0,0),t.paper.view.update(!1),t.fitToScreen(!1,!0)},200)})},resize:function(e,t,i){if(void 0===i&&(i=!1),e||(e=this.domElement.offsetWidth),t||(t=this.domElement.offsetHeight),this.isMobile||this.fitToScreen(!1,!0),i){var n=this.paper.view.pixelRatio;e/=n,t/=n}this.paper.view.viewSize=[e,t],this.paper.view.zoom=this.paper.view.zoom,this.checkAllAlertItems()},moveOriginToViewCenter:function(){this.paper.view.center=new this.paper.Point(0,0)},setupZoomControl:function(){"mp-canvas-zoomControl"!=$("body").find("#mp-canvas-zoomControl").attr("id")&&$('<div id="mp-canvas-zoomControl" class="olControlZoom" unselectable="on"> <a class="olControlZoomOut olButton" id="mp-canvas-zoomout" href="#zoomOut"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAMAAADW3miqAAABklBMVEVkZGT///9kZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGSZMFejAAAAhXRSTlMAAAECBAUGBwgKCwwNDg8QERITFRYXGRocICEiIyQlJykqLC0uMDM1Njc5Oj0+QEFCRUhKTE1OT1BRUlNUVVZYWltdX2BiY2RnaWprbG9wcnN0dXd5ent8f4CCg4WGh4uMjo+RkpOUlZaXmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKzHueo5wAAAfZJREFUeAGF0PtTElEYxvGXTQVrUYmyC5WlGZpd0sKETLBE7VKkoFnSpSgrKlRAAkFY2Kf/u3fB4ZxDzfb9bWc+8+w7hw5z+oKJrdzej2TUr2sk5eCoWffF1SoOa3yecv8L9UVqkKonh/5G3jiszOJOJt/S2audaCABrv7+4bXhS/6ZtRy4wpiKXA+slZ93vdSsy/8SXPq0jI6MGmxSI9ROX7KG12Skr7P5NuKQ6n0KoOSX0DCAyh3+ENGJFE8lJDQPNDZ1FXVPAfg6KNAmD82RisiTAfLXBdoBtq8QkdY2GtHROHAQEagK89NZot7fIiLXAlB7LJAJ8yO/iVtBznnAeCZQBebWOaIedWmJlx4JlAayE52HH3sFlO8LtA5UFzrRqQKwOy7QNGCmBlVknYSULpDvwJpSkHZhFzCekECuZQD5SZLyvgGQ80lIO58FkA20iXYmCR5fJAlR1yS4cvxyi3jC3wE0NkhB5IqAMwtvo4Hb4XimBgu9uzkmI1ZzBqzqRq1ugjM+pE1jL6Qg6hr/YkL0a1EPAyjekxGnh1Kl1n/K27Eh6pkGtz+rIM45Ovt843UieuMkcX0r4CohTUUd6astJZCNCtoicq+0lC2i/hdNNWOLyNPc2g92k13Hm6oUJXsVs1CA7BuIoTjRQ/+pf/mWw/EHz+jJTaZSlbAAAAAASUVORK5CYII="> </a> <a class="olControlZoomIn olButton" id="mp-canvas-zoomin" href="#zoomIn"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAMAAADW3miqAAABklBMVEVkZGT///9kZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGRkZGSZMFejAAAAhXRSTlMAAAECBAUGBwgKCwwNDg8QERITFRYXGRocICEiIyQlJykqLC0uMDM1Njc5Oj0+QEFCRUhKTE1OT1BRUlNUVVZYWltdX2BiY2RnaWprbG9wcnN0dXd5ent8f4CCg4WGh4uMjo+RkpOUlZaXmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKzHueo5wAAAftJREFUeAGF0PtXEk0cx/Ev+3DBp0Ulyi5UlmZodkkLEzLBErVLkYJmSZeirKhQAQkEYWE//N/N7nqYGeps799mz+t8ds7QUZ5gJL1d3P+RSYRUhYQcLDJzXVxr4Kj252nf31B/vAmhVmb4TxRIwUiv7OZLli5c7UWDabBa7x9eG7kUml0vglUel5H3gbHy826AzJyhl2DlTovovzGNmewodVOXjeF1EakbzHwbdQj1PQVQDQloBED9jnXodDrmtxNZNpUW0ALQ3lJl5JoG8HWIoy02NE8yIn8eKF3naBfYucIOShcpRP+ngMM4Rw3on84S9XV4RN5FoPmYIx36R/YmPgl5FgDtGUd16NvniNzy0jJbesRRDihM9l782Cugdp+jDaCx2ItOlYG9CY5mAD07JCPjSsiqHAUPjSkJKRf2AO0JceRdAVCaIqHAGwDFoICU8wUAhXCXKGcyYONLJCByToFVS122iD/2HUB7kyRE3jhYevltInw7lso3YaB3N8dFxNS8BqOW1mzpYGkfcrq2H5UQOSe+6OD9WlJjACr3RMRSo9mq9Z/aTnKY3DNgHcxJiOUZm3u++TqduHGSWP2rYNWjiox6UtcsZYO4itgi8q1ayhbRwAtTzdoi8ptbBxEX2XXcVNUE2aukgcJk32ASlUk3/aOBlVsOx29IL9WtgmuD+QAAAABJRU5ErkJggg=="> </a> <a class="olControl3D olButton" id="mp-canvas-show3d" href="#show3d"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAQAAABLCVATAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAJ1SURBVHjapNZBiFZVFADg848zDTnhWItQx9oIYWiU2bgIyUVERdAiazMYldlOg0hIBwLpgzBHsGGIqGB0FxS5ys3gIBIUFAONLWoWQzWLSENplTqO/2nha3xv/t9G3s/ZXO6774N3zj333RDLxkEL5nznhD0eXfo0i4jbgLqMysU45fW6UAgjJSpN2VkXCkcK5E/zUhpzRz0oHJZmbLDNhJTOGqgHhbeKZDcMS+lHa+tB5RiyIJ22olMovKQpjXUOhf1SerZzKExK03o6h7a6Ig3dGlqp313FuGGVfv2lmXJ8JZ3WaId0O+CSlD62Rljtd39L6brPbV+y+mmpaWMr0/CZNOMDZ6VpK/VakCYc942UXq6s7/Wr9FordL/0mwEhTEnPCPOa1gsNL7gmbS43rePSJ63QKk/aVIy/lIaEq5o2FHPvSx9WoHeluf87PHa45II1elzVtLGYf/xGwUvQZofsvRVz0kXpL4PC3RXoYenCzfot12vHnDMrjVihrwI9Ip1vB73pkAfbYg0/SM8XOfoPekKavnEWVaE/pHdKr9/nFduK8T7pvSXJPiaNtTtqx6VPS9Bj0i/uEcIp6dWi/ANCj11Seqgd9IY0e7MKup2UfnbUGWnG6sUNecL3stgQbaBNUnqqsleHXZTmjbq30iL/GF/87BaoyxnpiyWJvlO/vpam7WstSbn8u6TLrb++24sy1OMnabJzKDwnpbc7h8JHUtOLnUPdJqVr1dLWgcI656Q0rCGEQfvrQWF9cQJOGPSAWelwPSj0GpPSFeeLK8ORelAIO01VrjAjdaEQdvu6RI3qqguFsMVu4741Z8GB5aF/BwBgaLXGzqeljgAAAABJRU5ErkJggg=="> </a> </div>').appendTo("#zoomPanel");this.setZoomControlPosition()},setZoomPercentageIncrement:function(e){console.log("Set zoom increment percentage to "+e),this.zoomPercentageIncrement=e},setZoomControlPosition:function(){var e=$("#"+this.canvasID).offset(),t=e.left,i=e.top,n=$("#"+this.canvasID).width(),a=$("#"+this.canvasID).height();$("#mp-canvas-zoomControl").width(),$("#mp-canvas-zoomControl").height()},setupMoveControl:function(){"mp-canvas-moveControl"!=$("body").find("#mp-canvas-moveControl").attr("id")&&$('<div id="mp-canvas-moveControl" class="olControlMove" style="position: absolute; z-index: 1003;" unselectable="on"> <div id="mp-canvas-moveVerticalControl" class="olControlMoveVertical"> <a class="olControlMoveUp olButton" id="mp-canvas-moveup" href="#moveUp">˄</a> <a class="olControlMoveDown olButton" id="mp-canvas-movedown" href="#moveDown">˅</a> </div> <div id="mp-canvas-moveHorizontalControl" class="olControlMoveHorizontal"> <a class="olControlMoveLeft olButton" id="mp-canvas-moveleft" href="#moveLeft">˂</a> <a class="olControlMoveRight olButton" id="mp-canvas-moveright" href="#moveRight">˃</a> </div></div>').appendTo("body");var e=this;$("#mp-canvas-moveup").click(function(t){e.moveSelectionUp()}),$("#mp-canvas-movedown").click(function(t){e.moveSelectionDown()}),$("#mp-canvas-moveleft").click(function(t){e.moveSelectionLeft()}),$("#mp-canvas-moveright").click(function(t){e.moveSelectionRight()}),this.setMoveControlPosition()},setMoveControlPosition:function(){var e=$("#"+this.canvasID).offset(),t=e.left,i=e.top,n=($("#"+this.canvasID).width(),$("#"+this.canvasID).height()),a=($("#mp-canvas-moveControl").width(),t+10),r=i+n-$("#mp-canvas-moveControl").height()-100;$("#mp-canvas-moveControl").css({top:r,left:a,position:"absolute"})},setCustomizedMessages:function(e){var t=this;e.forEach(function(e){t.customizedMessages.push(e)})},setShowDashedEdge:function(e){this.showDashedEdge=e},setShowSelectedElementDimensions:function(e){this.showSelectedElementDimensions=e},setShowUnselectedElementsDimensions:function(e){this.showUnselectedElementsDimensions=e},setShowTotalSizeOfCurrentSide:function(e){this.showTotalSizeOfCurrentSide=e},setUnitOfMeasurement:function(e){this.unitOfMeasurement=e},setDashedEdgeColor:function(e){this.DashedEdgeColor=e},fireSelectionChangedEvent:function(e){for(var t=0;t<this.selectionChangedListeners.length;++t)this.selectionChangedListeners[t](e);var i=this.design.getSideDesignItems(this.side);if(i)for(t=0;t<i.length;t++){var n=this.findItemForDesignItem(i[t]);if(n&&n.data.selected){this.showAreaItems();break}}},fireDeselectionChangedEvent:function(e){for(var t=0;t<this.deselectionChangedListeners.length;++t)this.deselectionChangedListeners[t](e)},fireItemRemovedEvent:function(e){for(var t=0;t<this.itemRemovedListeners.length;++t)this.itemRemovedListeners[t](e)},fireDesignItemRemovingEvent:function(e,t){for(var i=0;i<this.designItemRemovingListeners.length;++i)this.designItemRemovingListeners[i](e,t)},fireItemChangedEvent:function(e){for(var t=0;t<this.itemChangedListeners.length;t++)this.itemChangedListeners[t](e)},fireDesignItemChangedEvent:function(e){for(var t=0;t<this.designItemChangedListeners.length;t++)this.designItemChangedListeners[t](e)},fireItemCreatedEvent:function(e){for(var t=0;t<this.itemCreatedListeners.length;t++)this.itemCreatedListeners[t](e)},fireImageLoadedEvent:function(e){for(var t=0;t<this.imageLoadedListeners.length;t++)this.imageLoadedListeners[t](e)},fireTextArtLoadedEvent:function(e){for(var t=0;t<this.textArtLoadedListeners.length;t++)this.textArtLoadedListeners[t](e)},fireShapeLoadedEvent:function(e){for(var t=0;t<this.shapeLoadedListeners.length;t++)this.shapeLoadedListeners[t](e)},fireGridImageSelectedEvent:function(e){for(var t=0;t<this.gridImageSelectedListeners.length;t++)this.gridImageSelectedListeners[t](e)},fireNotifyMessageEvent:function(e,t,i,n,a,r,o,s,l){for(var h=0;h<this.notifyMessageListeners.length;h++)this.notifyMessageListeners[h](e,t,i,n,a,r,o,s,l)},fireRemoveMessageEvent:function(e){for(var t=0;t<this.removeMessageListeners.length;t++)this.removeMessageListeners[t](e)},fireUndoChangedEvent:function(){for(var e=0;e<this.undoChangedListeners.length;e++)this.undoChangedListeners[e]()},fireRedoChangedEvent:function(){for(var e=0;e<this.redoChangedListeners.length;e++)this.redoChangedListeners[e]()},fireFillShapeRequestedEvent:function(e){for(var t=0;t<this.fillShapeRequestedListeners.length;t++)this.fillShapeRequestedListeners[t](e)},addSelectionChangedListener:function(e){this.selectionChangedListeners.push(e)},addDeselectionListener:function(e){this.deselectionChangedListeners.push(e)},addItemRemovedListener:function(e){this.itemRemovedListeners.push(e)},addDesignItemRemovingListener:function(e){this.designItemRemovingListeners.push(e)},addItemChangedListener:function(e){this.itemChangedListeners.push(e)},addItemCreatedListener:function(e){this.itemCreatedListeners.push(e)},addImageLoadedListener:function(e){this.imageLoadedListeners.push(e)},addTextArtLoadedListener:function(e){this.textArtLoadedListeners.push(e)},addShapeLoadedListener:function(e){this.shapeLoadedListeners.push(e)},addGridImageSelectedListener:function(e){this.gridImageSelectedListeners.push(e)},addNotifyMessageListeners:function(e){this.notifyMessageListeners.push(e)},addRemoveMessageListeners:function(e){this.removeMessageListeners.push(e)},addDesignItemChangedListener:function(e){this.designItemChangedListeners.push(e)},addUndoChangedListener:function(e){this.undoChangedListeners.push(e)},addRedoChangedListener:function(e){this.redoChangedListeners.push(e)},addFillShapeRequestedListener:function(e){this.fillShapeRequestedListeners.push(e)},getScreenPoint:function(e){var t=this.paper.view.projectToView(e),i=$("#"+this.canvasID).offset();return t.x+=i.left,t.y+=i.top,t},onMouseWheel:function(e){var t=this.getAllItemsBounds(),i=this.paper.project.view.bounds;if(!this.zooming&&null!=t){e.preventDefault();var n=new this.paper.Point(e.offsetX,e.offsetY),a=(n=this.paper.project.view.viewToProject(n)).subtract(this.paper.view.center);if(e.deltaY>0)this.paper.view.zoom<4&&(this.paper.view.zoom*=1.3,this.paper.view.center=this.paper.view.center.add(a.multiply((1.3-1)/1.3)));else if(e.deltaY<0){if(t.width<i.width&&t.height<i.height)return;this.paper.view.zoom/=1.3,this.paper.view.center=this.paper.view.center.subtract(a.multiply(1.3-1))}this.hitItem=null,this.updateSelectionState(),this.paper.project.view.update(),this.checkAllAlertItems(),this.checkImagesSizeLimit()}},windowToCanvas:function(e,t){var i=this.canvas.getBoundingClientRect();return{x:e-i.left*($(this.canvas).width()/i.width),y:t-i.top*($(this.canvas).height()/i.height)}},clearCanvas:function(){for(var e=0;e<this.paper.project.layers.length;e++){this.paper.project.layers[e].removeChildren()}this.paper.project.view.update()},getAllAreasBounds:function(){var e=this,t=null;return this.side&&this.side.get("areas").forEach(function(i){var n=e.findItemForArea(i);n&&(t=t?t.unite(n.bounds):n.bounds.clone())}),t},getAllItemsBounds:function(e){void 0===e&&(e=[]);for(var t=null,i=e.length>0?e:this.getAllItems(),n=0;n<i.length;n++)if(!i[n].data.isAreaLayer){var a=this.getItemBounds(i[n]);!a||isNaN(a.width)||isNaN(a.height)||(t=null==t?a.clone():t.unite(a))}return t},getAllItems:function(e,t){void 0===e&&(e=this.paper.project),void 0===t&&(t=this.masterGroup);var i=[],n=this;function a(e){if((!n.isItemGroup(e)||e==t||e.data.isGridGroup||e.data.isGridBox)&&e.children)for(var r=e.children.length-1;r>=0;r--){var o=e.children[r];o.guide||i.push(o),a(o)}}for(var r=0,o=e.layers.length;r<o;r++){var s=e.layers[r];s.guide||a(s)}return i},getAllShapeItems:function(){for(var e=[],t=this.getAllItems(),i=0;i<t.length;i++){var n=t[i];(this.isFilledShape(n)||this.isShape(n))&&e.push(n)}return e},getAllShapeImagePlaceholders:function(){for(var e=[],t=this.getAllShapeItems(),i=0;i<t.length;i++){var n=t[i];!this.isFilledShape(n)&&this.isShape(n)&&n.data&&n.data.isImagePlaceholder&&e.push(n)}return e},getAllMaskedImages:function(){var e=this;return this.getAllItems().filter(function(t){return e.isMaskedImage(t)})},getAllFilledShapes:function(){var e=this;return this.getAllItems().filter(function(t){return e.isFilledShape(t)})},getAllSimpleImages:function(){var e=this;return this.getAllItems().filter(function(t){return t instanceof e.paper.Raster&&!e.isMaskedImage(t)&&!e.isFilledShape(t)})},getAllShapesAndMasks:function(){for(var e=[],t=this.getAllItems(),i=0;i<t.length;i++){var n=t[i];this.isShape(n)?e.push(n):this.isMaskedImage(n)&&e.push(this.getMaskedImageShapeItem(n))}return e},zoomIn:function(){var e=this;if(!(this.paper.view.zoom>=2)){this.preventViewMoving=!1;this.paper.view.zoom*=1.3,this.updateZoomIndicators(),this.updateSelectionState(),this.clampView(),this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.placeHandleOut(),this.getAllShapeImagePlaceholders().forEach(function(t){return e.updateShapeImagePlaceholder(t)}),this.updateAreaLayerNamesSizes(),this.restoreResizable()}},zoomOut:function(){var e=this,t=this.getAllItemsBounds(),i=this.paper.project.view.bounds;if(!(t&&t.width<i.width-100&&t.height<i.height-100)){this.preventViewMoving=!1;this.paper.view.zoom/=1.3,this.updateZoomIndicators(),this.updateSelectionState(),this.clampView(),this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.getAllShapeImagePlaceholders().forEach(function(t){return e.updateShapeImagePlaceholder(t)}),this.updateAreaLayerNamesSizes(),this.restoreResizable()}},setZoom:function(e){this.animatedZoom(this.paper.view.zoom,e/100,this.paper.view.center,this.paper.view.center,30),this.clampView(),this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.updateAreaLayerNamesSizes(),this.restoreResizable()},zoomToBounds:function(e,t,i,n,a){var r,o=this;if(e&&0!=e.width&&0!=e.height){var s=!0;!1===i&&(s=!1);var l=e.clone(),h=1;t>0&&(h=1+t/100),l.width*=h,l.height*=h;var d=this.paper.view.bounds;if(l.width>d.width||l.height>d.height||n){var c=1,u=1;Math.abs(d.width)>1e-7&&(c=d.width/l.width),Math.abs(d.height)>1e-7&&(u=d.height/l.height);var g=Math.min(c,u),f=this.paper.view.zoom,p=this.paper.view.zoom*g*(a?(null!==(r=this.zoomPercentageIncrement)&&void 0!==r?r:100)/100:1),m=this.paper.view.center,v=e.center;s?this.animatedZoom(f,p,m,v,15):(this.paper.view.zoom=p,this.paper.view.center=v),this.preventViewMoving=!0,this.clampView(),this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.updateZoomIndicators(),this.updateSelectionState(),this.getAllShapeImagePlaceholders().forEach(function(e){return o.updateShapeImagePlaceholder(e)}),this.restoreResizable(),this.paper.project.view.update()}}},updateRasterLayer:function(){var e=this.getAllItemsBounds();null==this.rasterLayer&&(this.rasterLayer=this.findItemByName("rasterLayer")),this.rasterLayer?(this.rasterLayer.removeChildren(),this.paper.project.view.update()):(this.rasterLayer=new this.paper.Layer,this.rasterLayer.name="rasterLayer",this.rasterLayer.insertAbove(this.itemsLayer),this.rasterLayer.guide=!0);var t=96;Math.max(e.width,e.height)>2e3&&(t=72),this.rasterLayer.activate();var i=this.paper.project.layers[0].rasterize(t,!1),n=this.paper.project.layers[1].rasterize(t,!1);this.rasterLayer.addChild(i),this.rasterLayer.addChild(n)},toDataURL:function(){return this.canvas.toDataURL()},getDesignDataUrl:function(){return this.itemsLayer.rasterize(96,!1).toDataURL()},showRasterLayer:function(){null==this.rasterLayer&&this.updateRasterLayer();for(var e=0;e<this.paper.project.layers.length;e++){var t=this.paper.project.layers[e];t!=this.rasterLayer&&(t.visible=!1)}this.rasterLayer.visible=!0,this.paper.project.view.update()},hideRasterLayer:function(){for(var e=0;e<this.paper.project.layers.length;e++){var t=this.paper.project.layers[e];t!=this.rasterLayer&&(t.visible=!0,t.activate())}this.rasterLayer.visible=!1,this.paper.project.view.update()},setImageScalingEnabled:function(e){this.isImageScalingEnabled=e},animatedZoom:function(e,t,i,n,a){if(!this.zooming){this.zooming=!0;var r=this;if(!(a<=0)){var o=(t-e)/a,s=n.subtract(i).clone();s=s.divide(a);var l=0,h=setInterval(function(){var e=l==a-1?t-r.paper.view.zoom:o,i=l==a-1?n.subtract(r.paper.view.center):s;r.paper.view.zoom+=e,r.paper.view.center=r.paper.view.center.add(i),r.updateZoomIndicators(),++l==a&&(clearInterval(h),r.zooming=!1,r.clampView(),r.checkAllAlertItems(),r.checkImagesSizeLimit(),r.updateSelectionState(),r.updateAreaLayerNamesSizes(),r.getAllShapeImagePlaceholders().forEach(function(e){return r.updateShapeImagePlaceholder(e)}))},30)}}},fitToScreen:function(e,t){var i=this.getAllItemsBounds();if(i){var n=this.fitToScreenMargin;if(this.imageItem&&this.isMobile){var a=i.width/this.imageItem.bounds.width,r=i.height/this.imageItem.bounds.height,o=Math.max(a,r);if(o>=.8)n=100*(Math.min(o,1)-.8)+20}this.zoomToBounds(i,n,e,t,!0),this.paper.view.update()}},fitToScreenForPreview:function(){var e,t=null===(e=this.imageItem)||void 0===e?void 0:e.bounds,i=this.getAllAreasBounds(),n=this.getAllItemsBounds();if(i&&t&&(n=i.area>t.area?i:t),n){var a=this.fitToScreenMargin;if(this.isMobile){var r=n.width/this.imageItem.bounds.width,o=n.height/this.imageItem.bounds.height,s=Math.max(r,o);if(s>=.8)a=100*(Math.min(s,1)-.8)+20}this.zoomToBounds(n,a,!1,!0),this.paper.view.update()}},updateZoomIndicators:function(){},areAllItemsInView:function(){var e=this.getAllItemsBounds();return this.paper.project.view.bounds.contains(e)},setElementType:function(e){e!=MPlaza.CustomizerElementType.None&&e!=MPlaza.CustomizerElementType.Rectangle&&e!=MPlaza.CustomizerElementType.Oval&&e!=MPlaza.CustomizerElementType.Path&&e!=MPlaza.CustomizerElementType.Free&&e!=MPlaza.CustomizerElementType.Text&&e!=MPlaza.CustomizerElementType.TextArt||(this.elementType=e)},setSide:function(e){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(i){switch(i.label){case 0:return this.removeAllAlertItems(),this.clearCanvas(),this.resetUndoRedo(),this.imageItem=null,this.resetAllDimensionLabels(),this.side=e,[4,new Promise(function(e){return t.updateImageItem(e)})];case 1:return i.sent(),this.masterGroup=new this.paper.Group,this.itemsLayer.addChild(this.masterGroup),this.areaLayersPaperLayer||(this.areaLayersPaperLayer=new this.paper.Layer({name:"areas-layer"}),this.areaLayersPaperLayer.bringToFront(),this.areaLayersPaperLayer.data.isAreaLayersLayer=!0),this.updateAreaItems(),[4,this.restoreResizable()];case 2:return i.sent(),this.updateRotation(),[4,this.updateDesignItemsCanvasItems()];case 3:return i.sent(),[4,this.updateGrids()];case 4:return i.sent(),this.isViewer||this.refreshBackgroundAreas(),this.fitToScreen(!1,!0),this.isSetSideEnded=!0,[2]}})})},setSide_old:function(e,t){this.removeAllAlertItems(),this.clearCanvas(),this.resetUndoRedo(),this.masterGroup=null,this.imageItem=null,this.side=e;var i=this;this.updateImageItem(function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return i.masterGroup=new this.paper.Group,this.itemsLayer.addChild(i.masterGroup),[4,i.rebuildItems()];case 1:return e.sent(),t&&t(),[2]}})})})},updateRotation:function(){this.side.get("canRotate")?this.updateProductAreasRotation():this.eventsToolsCustomizer.setDefaultRotation()},updateProductAreasRotation:function(){var e=this.getCanvasRotation();e&&this.eventsToolsCustomizer.onRotateAreasAndImage(e.degrees,{animation:!1},null)},updateAreasRotation:function(){var e=this.getCanvasRotation();e&&this.eventsToolsCustomizer.onRotateAreas(e.degrees,{animation:!1})},getCanvasRotation:function(){var e=this.side.getSideID(),t=this.design.get("canvasRotation");return null==t?void 0:t.find(function(t){return t.sideID==e})},refreshBackgroundAreas:function(){var e=this,t=this.side.get("areas"),i=this.getAllItems();t&&t.forEach(function(t){var n,a=e.findItemForArea(t);a&&(e.updateBackgroundGroupSize(a),i.find(function(e){var t,i,r;if((null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.isGroupForBackground)&&(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.areaGuid)===(null===(r=null==a?void 0:a.data)||void 0===r?void 0:r.guid))for(var o=0,s=e.children;o<s.length;o++){var l=s[o];if(l.data&&l.data.isAreaForBackground)return n=l.fillColor,!0}})&&(e.removeBackgroundColorArea(a),e.changeBackgroundColorArea(a,n,function(){return null})))})},getCurrentModel:function(){var e=null;if(this.side&&this.side instanceof MPlaza.Side){var t=this.side.getParentModel();if(t&&t instanceof MPlaza.Color){var i=t.getParentModel();i&&i instanceof MPlaza.Model&&(e=i)}}return e||(e=this.model),e},refresh:_.debounce(function(e,t){var i=this;this.updateImageItem(function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){switch(n.label){case 0:return[4,i.rebuildItems()];case 1:return n.sent(),e&&e.boundsToAreas?i.adaptZoomToSideAreas(!1):i.fitToScreen(!1,!0),t&&t(),[2]}})})})},100),rebuildItems:function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return this.masterGroup?Array.from(this.masterGroup.children).forEach(function(e){return e.remove()}):(this.masterGroup=new this.paper.Group,this.itemsLayer.addChild(this.masterGroup)),paper.project.activeLayer.children.filter(function(e){return e.isMaskPath}).forEach(function(e){return e.remove()}),this.updateAreaItems(),[4,this.restoreResizable()];case 1:return e.sent(),this.updateAreasRotation(),[4,this.updateDesignItemsCanvasItems()];case 2:return e.sent(),[4,this.updateGrids()];case 3:return e.sent(),[2]}})})},setDesign:function(e){this.deselectAll(),this.initialItemsInfo={},this.clearDesignItemsCanvasItems(),this.resetUndoRedo(),this.design=e,this.checkAllAlertItems(),this.checkImagesSizeLimit();this.isViewer},refreshDesign:function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,this.updateDesignItemsCanvasItems()];case 1:return e.sent(),[4,this.updateGrids()];case 2:return e.sent(),[2]}})})},setupImageLayer:function(){this.imageLayer||(this.imageLayer=new this.paper.Layer({name:"side-image-layer"}),this.imageLayer.sendToBack(),this.itemsLayer=new this.paper.Layer({name:"items-layer"}),this.itemsLayer.bringToFront(),this.itemsLayer.activate())},updateImageItem:function(e){if(!this.showSideImage||!this.side||!this.side.get("imageUrl"))return this.imageItem&&this.imageItem.remove(),void(e&&e());var t=null;this.design&&(t=this.design.getDesignSide(this.side));var i=this,n=function(e,t){i.imageItem&&i.imageItem.remove(),i.imageItem=e,i.imageLayer.addChild(e),i.paper.project.view.update(),t()};if(this.side.get("colorable")&&t&&t.get("fillColor")){var a="#"+t.get("fillColor"),r=document.createElement("canvas");r.setAttribute("id","customizerOffscreen");var o=r.getContext("2d");r.width=i.imageWidth,r.height=i.imageHeight,this.domElement&&this.domElement.appendChild(r),Caman("#customizerOffscreen",this.side.get("imageUrl"),function(){this.newLayer(function(){this.setBlendingMode("multiply"),this.opacity(100),this.fillColor(a)}),this.render(function(){var t=o.getImageData(0,0,r.width,r.height),a=new i.paper.Raster({position:i.paper.view.center});a.setSize(new i.paper.Size(i.imageWidth,i.imageHeight)),a.setImageData(t,new i.paper.Point(0,0)),n(a,function(){i.domElement&&i.domElement.removeChild(r),e&&e()})})})}else{if(!i.imageLayer){i.imageLayer=new i.paper.Layer,i.imageLayer.name="side-image-layer",i.imageLayer.sendToBack();var s=new i.paper.Layer;i.itemsLayer=s,s.name="items-layer",s.bringToFront(),s.activate()}var l=new this.paper.Raster({crossOrigin:"anonymous",source:this.side.get("imageUrl"),position:new this.paper.Point(0,0)});l.onLoad=function(){n(l,function(){e&&e()})}}},updateAreaItems:function(){if(this.side&&this.side instanceof MPlaza.Side){var e=this.side.get("areas");if(e){for(var t=0;t<e.length;t++){var i=e.at(t);this.createItemForArea(i)}var n=[],a=[];for(t=0;t<e.length;t++){i=e.at(t);var r=this.paper.project.activeLayer.importJSON(i.get("path"));if(r instanceof this.paper.CompoundPath){for(var o=0;o<r.children.length;o++)n.push(r.children[o]);a.push(r)}else n.push(r)}n.forEach(function(e){e.data=void 0});var s=new this.paper.CompoundPath({children:n});s.data={isClippingArea:!0},this.masterGroup.addChild(s),s.sendToBack(),s.fillRule="nonzero",s.clipMask=!0,s.reorient(!1,!0),a.forEach(function(e){e.remove()})}}this.deselectAll(),this.paper.project.view.update()},createItemForArea:function(e){if(e&&e instanceof MPlaza.Area){var t=this.findItemForArea(e);t&&t.remove(),(t=this.paper.project.activeLayer.importJSON(e.get("path"))).data.guid=e.get("guid"),t.data.isArea=!0,t.data.selected=!0,this.masterGroup.addChild(t),this.isViewer&&(t.visible=!1),this.updateAreaItemColor(t),this.createAreaLayersItemsForArea(e,t)}},createAreaLayersItemsForArea:function(e,t){var i=this;this.getAllItems().filter(function(t){return t.data.connectedAreaGuid==e.get("guid")}).forEach(function(e){return e.remove()});var n=0;e.get("layers").each(function(a){var r=!i.isViewer,o=i.isViewer&&!i.isCartPreview,s=i.isViewer&&i.isCartPreview;if(!o){var l=a.get("isVisibleInCanvas"),h=a.get("isVisibleInCart");if(l&&(r||s&&h)){var d=i.areaLayersPaperLayer.importJSON(a.get("json"));d.data.connectedAreaGuid=e.get("guid"),d.data.layerID=a.get("layerID"),d.data.isAreaLayer=!0,a.get("showLabel")&&r&&i.createAreaLayerName(e,t,a,d,n++)}}}),this.updateAreaLayerNamesSizes()},createAreaLayerName:function(e,t,i,n,a){var r,o,s,l,h,d=this,c=this.getAreaLayerPaths(n);if(0!==c.length){var u=null!==(l=null!==(o=null===(r=c[0].strokeColor)||void 0===r?void 0:r.toCSS(!0))&&void 0!==o?o:null===(s=c[0].fillColor)||void 0===s?void 0:s.toCSS(!0))&&void 0!==l?l:"#000000",g=new this.paper.Group({onMouseEnter:function(){return d.paper.project.view.element.style.setProperty("cursor",""!=i.get("description")?"pointer":"default")},onMouseLeave:function(){return d.paper.project.view.element.style.setProperty("cursor",null)}});g.data.connectedAreaGuid=e.get("guid"),g.data.layerID=i.get("layerID"),g.data.isAreaLayerName=!0,g.data.isOpened=!1,g.data.layerIndex=a,this.areaLayersPaperLayer.addChild(g);var f=new this.paper.Point(0,0),p=new this.paper.PointText(new this.paper.Point(0,0));p.content=i.get("displayName"),p.fillColor=u,p.fontSize=16,p.position=f;var m=p.bounds.width;h=Math.max(150,m+70),g.data.tipWidth=h;var v=new this.paper.Path.Rectangle(new this.paper.Rectangle(0,0,h,26));v.position=f,v.isClipMask=!0;var I=new this.paper.Path.Rectangle(new this.paper.Rectangle(0,0,h,26));I.position=f,I.fillColor="#FFFFFF",I.strokeColor="#EEEEEE";var y=new this.paper.PointText(new this.paper.Point(0,20));y.content=this.simpleWordWrap(i.get("description"),h/7),y.fillColor="#555",y.visible=!1,y.justify="left",y.position=I.position.add(new this.paper.Point(0-h/2+y.bounds.width/2+10,15+y.bounds.height/2+10));var C=y.bounds.height,M=this.paper.project.activeLayer.importSVG(this.areaLayerIcon),x=M.children[1];if(x.position=new this.paper.Point(-h/2+20,0),x.scale(.7),x.fillColor=u,g.addChild(v),g.addChild(I),g.addChild(p),g.addChild(y),g.addChild(x),M.remove(),g.clipped=!0,""!=i.get("description")){var S=this.paper.project.activeLayer.importSVG(this.areaLayerArrowIcon),b=S.children[1];b.position=new this.paper.Point(h/2-20,0),b.scale(.4),b.fillColor=u,g.addChild(b),S.remove(),g.onClick=function(){var e=(g.data.isOpened?26:26+C+20)/d.paper.view.zoom/I.bounds.height;I.scale(new d.paper.Point(1,e),g.bounds.topCenter),v.scale(new d.paper.Point(1,e),g.bounds.topCenter),g.data.isOpened=!g.data.isOpened,y.visible=g.data.isOpened}}}},updateAreaLayerNamesSizes:function(e){var t=this;this.areaLayersPaperLayer.children.filter(function(e){return e.data.isAreaLayerName}).forEach(function(e){var i=e.data.layerIndex,n=e.data.tipWidth/t.paper.view.zoom/e.bounds.width,a=t.areaLayersPaperLayer.children.find(function(t){return t.data.layerID==e.data.layerID});if(e.scale(n,n),a){var r=t.getAreaLayerPaths(a);if(r.length>0){for(var o=new t.paper.Rectangle(r[0].bounds),s=0,l=r;s<l.length;s++){var h=l[s];o=o.unite(h.bounds)}var d=[o.bottomCenter,o.rightCenter,o.topCenter,o.leftCenter];e.position=d[i%d.length].add(new t.paper.Point(e.bounds.width/2*[0,1,0,-1][i%d.length],e.bounds.height/2*[1,0,-1,0][i%d.length]))}}})},getAreaLayerPaths:function(e){var t=this,i=[],n=function(e){if(e instanceof t.paper.CompoundPath)i.push(e);else if(e.children)for(var a=0,r=e.children;a<r.length;a++){var o=r[a];n(o)}};return n(e),i},simpleWordWrap:function(e,t){var i=[],n=-1;function a(){e.length<=t?(i.push(" "==e[0]?e.slice(1):e),e=""):e.length&&function(){for(var r=0;r<e.length;r++)if(" "==e[r]&&(n=r),r>=t){(-1==n||" "==e[r])&&(n=r),n>0&&i.push(e.slice(" "==e[0]?1:0,n)),e=e.slice(" "==e[0]?n+1:n),n=-1;break}a()}()}return t=Math.round(t),a(),this.content=i.join("\n")},hideAreaItems:function(){if(this.showSideImage){for(var e=this.getAllAreaItems(),t=0;t<e.length;t++){e[t].visible=!1}this.updateSelectionState(),this.paper.project.view.update()}},showAreaItems:function(){for(var e=this.getAllAreaItems(),t=0;t<e.length;t++){var i=e[t];i.visible=!0,i.strokeWidth=2}this.updateSelectionState(),this.paper.project.view.update()},adaptZoomToSideAreas:function(e){void 0===e&&(e=!0);var t=this.getAllAreasBounds(),i=this.getAllItemsBounds(),n=this.isResizableMode?i:t;this.zoomToBounds(n,this.fitToScreenMargin,e,!0,!0),this.updateSelectionState(),this.paper.project.view.update()},updateAreaItemsColor:function(){for(var e=this.getAllAreaItems(),t=0;t<e.length;t++){var i=e[t];this.updateAreaItemColor(i)}this.paper.project.view.update()},updateAreaItemColor:function(e){e&&e.bounds&&(e.strokeColor=this.getContrastedColor(e.bounds))},getAllAreaItems:function(){var e=[];function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];!a.guide&&a.data&&a.data.guid&&a.data.isArea&&e.push(a),t(a)}}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}return e},getAreasIntersectingItem:function(e){var t=this,i=[];if(e&&e.data&&e.data.guid&&!e.data.isArea&&this.side&&this.side instanceof MPlaza.Side&&this.side.get("areas")){var n=e;e.realBounds&&(n=new this.paper.Path.Rectangle(e.realBounds));for(var a=0;a<this.side.get("areas").length;a++){var r=this.side.get("areas").at(a),o=this.findItemForArea(r);r&&o&&(o instanceof this.paper.CompoundPath&&o.children&&o.children.length>0?__spreadArray([],o.children,!0):[o]).some(function(i){var a,o=n.bounds.intersects(i.bounds),s=!e.data.isImageForBackground&&!e.data.isAreaForBackground||r.get("guid")===e.data.areaGuid,l=!e.data.isGridImage||e.data.isGridImage&&(null===(a=t.design.get("areasGrids"))||void 0===a?void 0:a.find(function(e){return e.get("sideID")==t.side.id&&e.get("areaID")==r.id}));return o&&s&&l})&&i.push(r)}e.realBounds&&n.remove()}return i},getAreasContainingItem:function(e){var t=this,i=[];if(e&&e.data&&e.data.guid&&!e.data.isArea&&this.side&&this.side instanceof MPlaza.Side&&this.side.get("areas")){var n=e;e.realBounds&&(n=new this.paper.Path.Rectangle(e.realBounds));for(var a=0;a<this.side.get("areas").length;a++){var r=this.side.get("areas").at(a),o=this.findItemForArea(r);r&&o&&(o instanceof this.paper.CompoundPath&&o.children&&o.children.length>0?__spreadArray([],o.children,!0):[o]).some(function(i){return!n.bounds.intersects(i.bounds)&&i.bounds.contains(n.bounds)&&i.contains(n.position)&&(!e.data.isImageForBackground&&!e.data.isAreaForBackground||r.get("guid")===e.data.areaGuid)&&(!e.data.isGridImage||e.data.isGridImage&&t.design.get("areasGrids")&&t.design.get("areasGrids").find(function(e){return e.get("sideID")==t.side.id&&e.get("areaID")==r.id}))})&&i.push(r)}e.realBounds&&n.remove()}return i},getAreasIntersectingOrContainingItem:function(e){var t=this,i=[];if(e&&e.data&&e.data.guid&&!e.data.isArea&&this.side&&this.side instanceof MPlaza.Side&&this.side.get("areas")){var n=e;e.realBounds&&(n=new this.paper.Path.Rectangle(e.realBounds));for(var a=0;a<this.side.get("areas").length;a++){var r=this.side.get("areas").at(a),o=this.findItemForArea(r),s=[];if(r&&o){(s=o instanceof this.paper.CompoundPath&&o.children&&o.children.length>0?__spreadArray([],o.children,!0):[o])[0];s.some(function(i){return(n.bounds.intersects(i.bounds)||n.bounds.contains(i.bounds)||i.bounds.contains(n.bounds)||i.contains(n.position))&&(!e.data.isImageForBackground&&!e.data.isAreaForBackground||r.get("guid")===e.data.areaGuid)&&(!e.data.isGridImage||e.data.isGridImage&&t.design.get("areasGrids")&&t.design.get("areasGrids").find(function(e){return e.get("sideID")==t.side.id&&e.get("areaID")==r.id}))})&&i.push(r)}}e.realBounds&&n.remove()}return i},getItemArea:function(e){var t=this.getAreasIntersectingOrContainingItem(e);return t.length>1||0==t.length?null:t[0]},clearDesignItemsCanvasItems:function(){var e=this;function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];t(a),a.data&&a.data.maskPath&&a.data.maskPath.remove(),e.removeProfanityCheckInvalidOverlayAndEdgeForItem(a),(!a.guide&&a.data&&a.data.guid&&!a.data.isArea||a.data.isDashedEdge)&&a.remove()}}e.removeAllAlertItems(),e.resetAllDimensionLabels();for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}},updateDesignItemsCanvasItems:function(){return __awaiter(this,void 0,void 0,function(){var e,t,i,n,a,r=this;return __generator(this,function(o){switch(o.label){case 0:if(e=[],this.clearDesignItemsCanvasItems(),!(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design))return[3,4];if(!(t=this.design.getSideDesignItems(this.side).sort(function(e,t){return e.get("index")>t.get("index")})))return[3,4];i=0,o.label=1;case 1:return i<t.length?(n=t[i],[4,this.createItemForDesignItem(n)]):[3,4];case 2:if(a=o.sent(),this.convertOldStrokeIntoNew(a),a.data.isTextArea&&a.children.forEach(function(e){e.strokeJoin=r.strokeJoinText}),(a.data.isImageForBackground||a.data.isAreaForBackground)&&e.indexOf(a.data.areaGuid)>0)return a.remove(),a.data.maskPath&&a.data.maskPath.remove(),a.data.maskAlertPath&&a.data.maskAlertPath.remove(),this.removeDashedEdgeForItem(a),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(a),[3,3];a.data&&(a.data.isImageForBackground||a.data.isAreaForBackground)&&e.indexOf(a.data.areaGuid)<0&&e.push(a.data.areaGuid),a.data.selected=!1,o.label=3;case 3:return i++,[3,1];case 4:return this.deselectAll(),this.isViewer||this.updateItemsIndexes(),this.paper.project.view.update(),[2]}})})},convertOldStrokeIntoNew:function(e){var t=this.hasGroupTextStroke(e),i=this.hasGroupTextExternalStroke(e);if(t&&!i){var n=e.children.filter(function(e){return e.clone(!1)});e.removeChildren();var a=this.getExternalStrokeText(n);e.addChildren(a),e.addChildren(n),this.updateDesignItem(e)}},hasGroupTextStroke:function(e){var t,i=!1;if((this.getItemIsTextArea(e)||this.getItemIsTextOnPath(e))&&(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)>0){var n=e.children[0];n.strokeWidth>0&&n.strokeColor&&(i=!0)}return i},hasGroupTextExternalStroke:function(e){var t,i=!1;if((this.getItemIsTextArea(e)||this.getItemIsTextOnPath(e))&&(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)>1){var n=e.children[0],a=e.children[e.children.length-1],r=n.strokeWidth>0&&n.strokeColor,o=a.strokeWidth>0&&a.strokeColor;i=r&&!o}return i},createItemForDesignItem:function(e){var t,i;return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M;return __generator(this,function(x){switch(x.label){case 0:return n=null,e&&e instanceof MPlaza.DesignItem?((n=this.findItemForDesignItem(e))&&(n.remove(),this.deleteDimensionLabel(n.id),n.data.maskPath&&n.data.maskPath.remove(),n.data.maskAlertPath&&n.data.maskAlertPath.remove(),this.removeDashedEdgeForItem(n),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(n)),[4,this.getOrCreateItemFromDesignItem(e)]):[3,2];case 1:if(n=x.sent(),(a=this.getMaskedImageRasterItem(n))&&a instanceof this.paper.Raster&&!(a.data&&a.data.originalBounds&&a.data.originalMatrix)&&(a.data.originalBounds=new this.paper.Rectangle(0,0,a.width,a.height),a.data.originalMatrix=a.matrix.clone()),(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.isTextArea)&&!(null===(i=null==n?void 0:n.data)||void 0===i?void 0:i.originalMatrix)&&(null==n?void 0:n.children)&&(null==n?void 0:n.children.length)>0&&(r=n.children[0],o=r.matrix.a,s=r.matrix.b,l=r.matrix.c,h=r.matrix.d,d=n.bounds.centerX,c=n.bounds.centerY,n.data.originalMatrix=new this.paper.Matrix(o,s,l,h,d,c)),n.data&&(n.data.isImageForBackground||n.data.isAreaForBackground)?(u=this.findItemByGuid(n.data.areaGuid))&&((g=this.getOrCreateBackgroundGroupItem(u)).addChild(n),this.masterGroup.addChild(g),g.sendToBack()):(this.masterGroup.addChild(n),this.updateShapeImagePlaceholder(n)),this.getItemIsTextArea(n)&&n.children){for(f=[],p=[],m=0,v=n.children;m<v.length;m++)(C=v[m])instanceof this.paper.PointText&&(""==C.content||"⠀"==C.content)?p.push(C):f.push(C);for(I=0,y=p;I<y.length;I++)(C=y[I]).remove();p.length>0&&(n.children=f,this.onItemUpdated(n))}n instanceof this.paper.Raster?this.getAllItems().find(function(e){return e==n})&&(this.paper.project.view.update(),this.createMaskForItem(n),this.createDashedEdgeForItem(n),this.createProfanityCheckInvalidOverlayAndEdgeForItem(n),this.checkAlertItems(n),this.fireItemCreatedEvent(n),this.fireImageLoadedEvent(n)):(this.createMaskForItem(n),this.createDashedEdgeForItem(n),this.createProfanityCheckInvalidOverlayAndEdgeForItem(n),this.checkAlertItems(n),this.fireItemCreatedEvent(n)),x.label=2;case 2:return n.visible=!0,M=e.get("constraints"),this.isViewer&&M&&!M.get("isPrintable")&&(n.visible=M.get("keepInPreview")),[2,n]}})})},findAreaByGuid:function(e){return this.side&&this.side instanceof MPlaza.Side&&this.side.get("areas")?this.side.get("areas").getArea(e):null},findItemByGuid:function(e,t){void 0===t&&(t=null),t=t||this.paper;for(var i=e.toUpperCase(),n=function(e,t){if(e.data.guid&&e.data.guid.toUpperCase()==t)return e;if(e.children)for(var i=e.children.length-1;i>=0;i--){var a=e.children[i],r=n(a,t);if(r)return r}},a=0;a<t.project.layers.length;a++){var r=t.project.layers[a];if(!r.guide){var o=n(r,i);if(o)return o}}return null},getChildrens:function(e){var t=[],i=function(e){if(t=__spreadArray(__spreadArray([],t,!0),[e],!1),e.children)for(var n=0,a=e.children;n<a.length;n++){var r=a[n];i(r)}};return i(e),t},removeItemByGuid:function(e){var t=this.findItemByGuid(e);t.remove(),this.onItemRemoved(t)},findItemForArea:function(e){return e&&e instanceof MPlaza.Area?this.findItemByGuid(e.get("guid")):null},findDesignItemByGuid:function(e){var t=null;return this.design&&(t=this.design.get("designItems").getDesignItemByGuid(e)),t},findDesignItemForItem:function(e){return e&&e.data&&e.data.guid?this.findDesignItemByGuid(e.data.guid):null},getPaperItemFromDesignItem:function(e){var t=JSON.parse(e.get("json"));return this.paper.project.importJSON(t)},findItemForDesignItem:function(e){if(e&&e instanceof MPlaza.DesignItem)return this.findItemByGuid(e.get("itemGuid"))},snapDeltaToAngle:function(e,t){var i=180/Math.PI*t,n=e.angle;n=Math.round(n/i)*i;var a=e.clone();return a.angle=n,a},onItemsCreated:function(e){for(var t=0;t<e.length;t++)this.onItemCreated(e[t],null)},onItemCreated:function(e,t){var i=this.createDesignItem(e,t);return this.updateItemsIndexes(),this.checkAllAlertItems(),this.isViewer||this.checkImagesSizeLimit(),this.registerItemOperation("create",i.get("itemGuid"),null,i.clone()),i},onTextArtItemCreated:function(e,t){var i=this.createTextArtDesignItem(e,t);return this.updateItemsIndexes(),this.checkAllAlertItems(),this.isViewer||this.checkImagesSizeLimit(),this.registerItemOperation("create",i.get("itemGuid"),null,i.clone()),i},onShapeItemCreated:function(e,t,i){var n=this.createShapeDesignItem(e,t,i);return this.updateItemsIndexes(),this.checkAllAlertItems(),this.updateShapeImagePlaceholder(e),this.isViewer||this.checkImagesSizeLimit(),this.registerItemOperation("create",n.get("itemGuid"),null,n.clone()),n},onItemsUpdated:function(e){for(var t=0;t<e.length;t++)this.onItemUpdated(e[t])},onItemUpdated:function(e){var t=this.getItemRealBounds(e);e.realBounds=t;var i=null,n=null,a=this.findDesignItemForItem(e);a&&(i=a.clone()),this.checkAlertItems(e),this.checkImagesSizeLimit(),this.updateTransformsData(e),this.updateDesignItem(e),this.updateDesignItemAreasAndIndex(e),this.fireItemChangedEvent(e),this.updateShapeImagePlaceholder(e),(a=this.findDesignItemForItem(e))&&(n=a.clone()),i&&n&&this.registerItemOperation("update",e.data.guid,i,n)},onImageItemUpdated:function(e,t,i){var n=this.findDesignItemByGuid(e.data.guid);if(n){var a=n.clone();this.updateImageDesignItem(e,n,t,i),this.checkAlertItems(e),this.checkImagesSizeLimit(),this.updateTransformsData(e),this.updateDesignItem(e),this.fireItemChangedEvent(e);var r=(n=this.findDesignItemByGuid(e.data.guid)).clone();a&&r&&this.registerItemOperation("update",e.data.guid,a,r)}},onTextArtItemUpdated:function(e,t){var i=this.findDesignItemByGuid(e.data.guid);if(i){var n=i.clone();this.updateTextArtDesignItem(e,i,t),this.fireItemChangedEvent(e),this.updateTransformsData(e);var a=(i=this.findDesignItemByGuid(e.data.guid)).clone();n&&a&&this.registerItemOperation("update",e.data.guid,n,a)}},onShapeItemUpdated:function(e,t,i){var n=this.findDesignItemByGuid(e.data.guid);if(n){var a=n.clone(),r=this.getMaskedImageShapeItem(e);this.updateShapeDesignItem(r,n,t,i),this.fireItemChangedEvent(e),this.updateTransformsData(e),this.updateShapeImagePlaceholder(e);var o=(n=this.findDesignItemByGuid(e.data.guid)).clone();a&&o&&this.registerItemOperation("update",e.data.guid,a,o)}},onDesignItemChanged:function(e){var t=this.findDesignItemForItem(e);t&&this.fireDesignItemChangedEvent(t)},onItemsRemoved:function(e){for(var t=0;t<e.length;t++)this.onItemRemoved(e[t])},onItemRemoved:function(e){var t=this.findDesignItemByGuid(e.data.guid);this._onItemRemovedInternal(e),t&&this.registerItemOperation("delete",e.data.guid,t.clone(),null)},_onItemRemovedInternal:function(e){if(this.removeAlertItems(e),this.checkImagesSizeLimit(),this.removeTextOnPathGuide(e),this.removeTextOnPathHandles(e),this.removeTextAreaGuide(e),this.removeTextAreaHandles(e),this.removeDesignItem(e),this.findDesignItemByGuid(e.data.guid))throw console.trace("Item removed, but the design item is still present.",e,this.findDesignItemByGuid(e.data.guid)),"There was an error during item deletion";this.fireItemRemovedEvent(e),e.data.isProfanityCheckInvalid=!1,e.data.maskPath&&e.data.maskPath.remove(),e.data.maskAlertPath&&e.data.maskAlertPath.remove(),this.removeDashedEdgeForItem(e),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e)},getSerializedPaperItem:function(e){var t=this.getMaskedImageGuideRasterItem(e),i=null,n=this.getMaskedImageGuideShapeItem(e),a=null;t&&(i=t.id,t.remove()),n&&(a=n.id,n.remove());var r={json:e.exportJSON({asString:!0}),svg:e.exportSVG({asString:!0,embedImages:!1})};if(t){var o=this.createMaskedImageGuideRaster(e);o&&i&&(o._id=i)}if(n){var s=this.createMaskedImageGuideShape(e);s&&a&&(s._id=a)}return r},getRasterList:function(e){var t=this,i=[],n=function(e){t.isImage(e)&&i.push(e),(null==e?void 0:e.children)&&e.children.length>0&&e.children.forEach(function(e){n(e)})};return n(e),i},createDesignItem:function(e,t){var i;if(e&&!e.guide){var n=null;if(e.data.guid&&(n=this.findDesignItemByGuid(e.data.guid)),null==n&&(n=new MPlaza.DesignItem,e.data.guid=n.get("itemGuid"),this.design.get("designItems").add(n)),null!=n){n.set("index",e.index);var a=this.getSerializedPaperItem(e);if(n.set("json",a.json),n.set("svg",a.svg),t&&t instanceof MPlaza.Image){if(t.get("itemGuid")&&(n.set("itemGuid",t.get("itemGuid")),e.data.guid=n.get("itemGuid")),n.set("imageID",t.get("imageID")),n.set("imageType",t.get("type")),n.set("imageFormat",t.get("format")),n.set("imageWidth",t.get("width")),n.set("imageHeight",t.get("height")),n.set("imageDpiX",t.get("dpiX")),n.set("imageDpiY",t.get("dpiY")),n.set("imageUserID",t.get("userID")),n.set("imageVisitorID",t.get("visitorID")),n.set("imageVisitorCode",t.get("visitorCode")),n.set("imagePrice",t.get("price")),n.set("applyImagePriceForQuantity",t.get("applyPriceForQuantity")),n.set("providerImageID",t.get("providerImageID")),n.set("imageIsMulticolor",t.get("isMulticolor")),n.set("imagePreferredWidth",t.get("preferredWidth")),n.set("imagePreferredHeight",t.get("preferredHeight")),n.set("imageFileSize",t.get("imageFileSize")),n.set("imageCustomerID",t.get("customerID")),n.set("imageCustomerCode",t.get("customerCode")),n.set("overridePreview",t.get("overridePreview")),"Vector"==t.get("type")&&t.get("colors")&&t.get("colors").length>0)for(var r=0;r<t.get("colors").length;r++)n.get("itemColors").push(t.get("colors").at(r).get("code"));n.set("connectorSettings",new MPlaza.ConnectorSettings),(null===(i=t.get("connectorSettings"))||void 0===i?void 0:i.length)>0&&t.get("connectorSettings").forEach(function(e){var t=new MPlaza.ConnectorSetting;t.set("key",e.key||e.connectorKey),t.set("settings",e.settings),n.get("connectorSettings").push(t)})}else this.updateDesignItemDistinctColors(n,e);if(!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);n.updateAreas(o)}}return n}return null},createTextArtDesignItem:function(e,t){if(e&&!e.guide&&t){var i=null;if(e.data.guid&&(i=this.findDesignItemByGuid(e.data.guid)),null==i&&(i=new MPlaza.DesignItem,e.data.guid=i.get("itemGuid"),this.design.get("designItems").add(i)),null!=i){i.set("index",e.index);var n=this.getSerializedPaperItem(e);i.set("json",n.json),i.set("svg",n.svg);var a=new MPlaza.DesignItemTextArt;a.set("text",t.text),a.set("fontFamilyID",t.fontFamilyID),a.set("fontFaceID",t.fontFaceID),a.set("textArtTypeID",t.textArtTypeID);var r=new MPlaza.TextArtConfig(t.config);if(a.set("config",r),i.set("textArt",a),!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);i.updateAreas(o)}}return i}return null},createShapeDesignItem:function(e,t,i){if(e&&!e.guide&&i&&t&&t instanceof MPlaza.Shape){var n=null;if(e.data.guid&&(n=this.findDesignItemByGuid(e.data.guid)),null==n&&(n=new MPlaza.DesignItem,e.data.guid=n.get("itemGuid"),this.design.get("designItems").add(n)),null!=n){n.set("index",e.index);var a=this.getSerializedPaperItem(e);n.set("json",a.json),n.set("svg",a.svg);var r=new MPlaza.DesignItemShape;if(r.set("shapeID",t.get("shapeID")),r.set("isMask",!1),n.set("shape",r),!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);n.updateAreas(o)}}return n}return null},updateTransformsData:function(e){if(e&&e.data&&(e.data.guid||e.data.isTextOnPath||e.data.isTextArea)&&!e.data.isArea){var t=null;if(e.data.transformsData&&e.data.transformsData.dimensions&&!e.data.needsTransformsDataUpdate)t=e.data.transformsData.dimensions;else{var i=e.clone();i.visible=!1,i.rotate(0-i.rotation);var n=new this.paper.Path.Rectangle(this.getItemBounds(i));n.visible=!1,t={width:n.bounds.width,height:n.bounds.height},n.remove(),i.remove()}e.data.transformsData={position:{x:e.position.x,y:e.position.y},rotation:e.rotation,dimensions:t}}},updateDesignItem:function(e){if(e&&e.data&&e.data.guid&&!e.data.isArea){var t=this.findDesignItemByGuid(e.data.guid);if(t){var i=e.visible;e.visible=!0,this.preventAreasAndIndexUpdate||void 0===e.index||null===e.index||t.set("index",e.index);var n=this.getSerializedPaperItem(e);t.set("json",n.json),t.set("svg",n.svg),e.visible=i,this.updateDesignItemDistinctColors(t,e)}}},updateDesignItemDistinctColors:function(e,t){var i=[],n=this.getMaskedImageRasterItem(t),a=this.getMaskedImageShapeItem(),r=e.get("colorMappings");if(r&&r.length>0){for(var o=0;o<r.length;o++){var s=r.at(o);s.get("dest")&&-1===i.indexOf(s.get("dest"))&&i.push(s.get("dest"))}this.updateDesignItemColors(e,i)}else if(!n&&!a||n&&a){var l=t;if(a?l=a:(t.data.isTextOnPath||t.data.isTextArea)&&(l=null,t.children.length>0&&(l=t.children[0])),l){var h=null;l.strokeWidth>0&&l.strokeColor&&(h=l.strokeColor.toCSS(!0),i.push(h));var d=null;!l.fillColor||h&&l.fillColor==h||(d=l.fillColor,i.push(l.fillColor.toCSS(!0)));var c=null;!l.shadowColor||!l.shadowBlur||!l.shadowOffset.x&&!l.shadowOffset.y||h&&l.shadowColor==h||d&&l.shadowColor==d||(c=l.shadowColor,i.push(c.toCSS(!0)))}this.updateDesignItemColors(e,i)}},updateDesignItemAreasAndIndex:function(e){if(e&&e.data&&e.data.guid&&!e.data.isArea&&!this.preventAreasAndIndexUpdate){var t=this.findDesignItemByGuid(e.data.guid);if(t){var i=this.getAreasIntersectingOrContainingItem(e);t.updateAreas(i);for(var n=this.design.getSideDesignItems(this.side),a=0;a<n.length;a++){var r=n[a],o=this.findItemForDesignItem(r);if(o){var s=r.clone();r.set("index",o.index),this.registerItemOperation("update",o.data.guid,s,r.clone())}}}}},updateDesignItemColors:function(e,t){for(;e.get("itemColors").length>0;)e.get("itemColors").pop();for(var i=0,n=t;i<n.length;i++){var a=n[i];e.get("itemColors").push(a)}},updateDesignItemColorMappings:function(e,t){if(e&&e instanceof MPlaza.DesignItem&&(e.set("colorMappings",new MPlaza.ColorMappings),t))for(var i=0;i<t.length;i++){var n=new MPlaza.ColorMapping(t[i]);e.get("colorMappings").add(n)}},updateImageDesignItem:function(e,t,i,n){var a;if(this.canEditItem(e)){var r=this.getMaskedImageRasterItem(e);if(e&&!e.guide&&r&&r instanceof this.paper.Raster&&t&&t instanceof MPlaza.DesignItem&&i&&i instanceof MPlaza.Image){var o=this.getSerializedPaperItem(e);for(t.set("json",o.json),t.set("svg",o.svg),i.get("itemGuid")&&(t.set("itemGuid",i.get("itemGuid")),e.data.guid=t.get("itemGuid")),t.set("imageID",i.get("imageID")),t.set("imageType",i.get("type")),t.set("imageFormat",i.get("format")),t.set("imageWidth",i.get("width")),t.set("imageHeight",i.get("height")),t.set("imageDpiX",i.get("dpiX")),t.set("imageDpiY",i.get("dpiY")),t.set("imageUserID",i.get("userID")),t.set("imageVisitorID",i.get("visitorID")),t.set("imageVisitorCode",i.get("visitorCode")),t.set("imagePrice",i.get("price")),t.set("imageIsMulticolor",i.get("isMulticolor")),t.set("imagePreferredWidth",i.get("preferredWidth")),t.set("imagePreferredHeight",i.get("preferredHeight")),t.set("imageFileSize",i.get("imageFileSize")),t.set("imageCustomerID",i.get("customerID")),t.set("imageCustomerCode",i.get("customerCode")),t.set("overridePreview",i.get("overridePreview")),this.isSetSideEnded&&t.set("isChanged",!0);t.get("itemColors").length>0;)t.get("itemColors").pop();if("Vector"==i.get("type")&&i.get("colors")&&i.get("colors").length>0)for(var s=0;s<i.get("colors").length;s++)t.get("itemColors").push(i.get("colors").at(s).get("code"));if(t.unset("connectorSettings"),t.set("connectorSettings",new MPlaza.ConnectorSettings),(null===(a=i.get("connectorSettings"))||void 0===a?void 0:a.length)>0&&i.get("connectorSettings").forEach(function(e){var i=new MPlaza.ConnectorSetting;i.set("key",e.key||e.connectorKey),i.set("settings",e.settings),t.get("connectorSettings").push(i)}),t.unset("shape"),n&&n instanceof MPlaza.Shape&&-1!==n.get("shapeID")&&void 0!==n.get("shapeID")){var l=new MPlaza.DesignItemShape;l.set("itemID",t.getDesignItemID()),l.set("shapeID",n.get("shapeID")),l.set("isMask",!0),t.set("shape",l)}if(!this.preventAreasAndIndexUpdate){var h=this.getAreasIntersectingOrContainingItem(e);t.updateAreas(h)}}}},updateTextArtDesignItem:function(e,t,i){if(this.canEditItem(e)&&e&&!e.guide&&(e instanceof this.paper.CompoundPath||e instanceof this.paper.Path)&&e.data&&e.data.isTextArt&&t&&t instanceof MPlaza.DesignItem&&t.isTextArt()&&i){var n=this.getSerializedPaperItem(e);t.set("json",n.json),t.set("svg",n.svg);var a=t.get("textArt");if(a){a.set("text",i.text),a.set("fontFamilyID",i.fontFamilyID),a.set("fontFaceID",i.fontFaceID),a.set("textArtTypeID",i.textArtTypeID);var r=new MPlaza.TextArtConfig(i.config);a.set("config",r)}if(!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);t.updateAreas(o)}}},updateShapeDesignItem:function(e,t,i,n){if(this.canEditItem(e)&&e&&!e.guide&&(e instanceof this.paper.CompoundPath||e instanceof this.paper.Path)&&e.data&&e.data.isShape&&i&&i instanceof MPlaza.Shape&&t&&t instanceof MPlaza.DesignItem){var a=this.getSerializedPaperItem(e);t.set("json",a.json),t.set("svg",a.svg);var r=t.get("shape");if(r&&(r.set("shapeID",i.get("shapeID")),r.set("isMask",!1)),!this.preventAreasAndIndexUpdate){var o=this.getAreasIntersectingOrContainingItem(e);t.updateAreas(o)}for(n&&n instanceof MPlaza.Image?(t.set("imageID",n.get("imageID")),t.set("imageType",n.get("type")),t.set("imageFormat",n.get("format")),t.set("imageWidth",n.get("width")),t.set("imageHeight",n.get("height")),t.set("imageDpiX",n.get("dpiX")),t.set("imageDpiY",n.get("dpiY")),t.set("imageUserID",n.get("userID")),t.set("imageVisitorID",n.get("visitorID")),t.set("imageVisitorCode",n.get("visitorCode")),t.set("imagePrice",n.get("price")),t.set("imageIsMulticolor",n.get("isMulticolor")),t.set("imagePreferredWidth",n.get("preferredWidth")),t.set("imagePreferredHeight",n.get("preferredHeight")),t.set("imageFileSize",n.get("imageFileSize")),t.set("isChanged",!0)):(t.unset("imageID"),t.unset("imageType"),t.unset("imageFormat"),t.unset("imageWidth"),t.unset("imageHeight"),t.unset("imageDpiX"),t.unset("imageDpiY"),t.unset("imageUserID"),t.unset("imageVisitorID"),t.unset("imageVisitorCode"),t.unset("imagePrice"),t.unset("imageIsMulticolor"),t.unset("imagePreferredWidth"),t.unset("imagePreferredHeight"),t.unset("imageFileSize"));t.get("itemColors").length>0;)t.get("itemColors").pop();if(n&&n.get("ImageID")>0&&"Vector"==n.get("type")&&n.get("colors")&&n.get("colors").length>0)for(var s=0;s<n.get("colors").length;s++)t.get("itemColors").push(n.get("colors").at(s).get("code"))}},removeDesignItem:function(e){if(e&&e.data&&e.data.guid&&!e.data.isArea){var t=this.findDesignItemByGuid(e.data.guid);t&&this.design.get("designItems").remove(t)}},checkImagesSizeLimit:function(e){var t=this;if(null==e||isNaN(e)||e<=0?e=this.areasSizeLimit:this.areasSizeLimit=e,this.removeSizeLimitAlert(),this.side&&this.side.collection){var i=this.side.collection.models,n=this.getAllImageItems();i&&n&&(this.side.get("areas").forEach(function(e){var i=t.areasSizeCountCollection.findIndex(function(i){return i.sideID==t.side.get("sideID")&&i.areaID==e.get("areaID")});-1==i?t.areasSizeCountCollection.push({sideID:t.side.get("sideID"),areaID:e.get("areaID"),sizeCount:0}):t.areasSizeCountCollection[i].sideID==t.side.get("sideID")&&(t.areasSizeCountCollection[i].sizeCount=0)}),n.forEach(function(e){var i=t.findDesignItemForItem(e);i&&t.getAreasIntersectingOrContainingItem(e).forEach(function(e){var n=t.areasSizeCountCollection.findIndex(function(i){return i.sideID==t.side.get("sideID")&&i.areaID==e.get("areaID")});t.areasSizeCountCollection[n].sizeCount+=i.get("imageFileSize")})}),this.areasSizeCountCollection.filter(function(e){return e.sideID==t.side.get("sideID")}).forEach(function(i){t.side.get("areas").models.forEach(function(n){if(n.get("areaID")==i.areaID&&i.sizeCount>e){var a=StringHelper.format(T._("Total size of uploaded pictures must be less than {0} MB per each print-area","Customizer"),(parseInt(e)/1024/1024).toFixed(2)),r=t.customizedMessages.find(function(e){return e.EventID==MPlaza.EventMessages.UploadLimit});if(r&&(a=StringHelper.format(T._d(r.Description)),!1===r.Visible))return;var o=t.findItemForArea(n);o&&t.fireNotifyMessageEvent(n.get("guid"),2,T._("Warning!","Customizer"),a,!r||r.Closeable,function(){return t.zoomToBounds(o.bounds,t.fitToScreenMargin,!0,!0)},null,null,!!r&&r.AddToCartDisabledIfVisible)}})}))}},removeSizeLimitAlert:function(){this.areaAlertItems.forEach(function(e){e.icon.remove(),e.tooltip.remove()}),this.areaAlertItems=[]},checkAlertItems:function(e){if(e&&(!e.data||!e.data.isImageForBackground&&!e.data.isAreaForBackground)){this.removeAlertItems(e);var t=[],i=this,n=this.getAreasIntersectingOrContainingItem(e),a=i.customizedMessages.filter(function(e){return e.Visible}).find(function(e){return e.EventID==MPlaza.EventMessages.ItemsClippedWarning});a&&n.length>0&&n.forEach(function(n){var r=i.findItemForArea(n),o=new i.paper.Path.Rectangle(e.bounds);r&&r.intersects(o)&&t.push(a),o.remove()});for(var r=1,o=1,s=0;s<n.length;s++){var l=n[s];if(!this.checkItemQualityForArea(e,l)){var h,d=this.getMaskedImageRasterItem(e);if(!d)return;if((h=this.findDesignItemForItem(e))&&h.attributes&&"svg"==h.attributes.imageFormat.toLowerCase())break;var c=h.get("constraints");if(c&&!c.get("isPrintable"))break;var u=this.side.get("ppcm"),g=300,f=this.getSelectedPrintType(l);if(f){var p=f.get("dpi");g=f instanceof MPlaza.PartPrintType&&p&&p>0?p:(f=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(l))).get("dpi")||f.get("printTypeDPI"),"PrintfulPrintType"==f.get("name")&&g>120&&(g*=.75)}else console.warn("Can't determinate the print type DPI");if(r=d.bounds.width/u/2.54*g,o=d.bounds.height/u/2.54*g,I=i.customizedMessages.find(function(e){return e.EventID==MPlaza.EventMessages.DPIWarning})){if(!1===I.Visible&&(h.get("imageCustomerCode")||h.get("imageVisitorCode")||h.get("imageVisitorID")>0||h.get("imageCustomerID")>0)&&!this.model.get("providerID"))break;if(!1===I.EnableCheckForSellerImages&&!h.get("imageCustomerCode")&&!h.get("imageVisitorCode")&&h.get("imageVisitorID")<=0&&h.get("imageCustomerID")<=0)break;t.push(__assign(__assign({},I),{Description:StringHelper.format(T._d(I.Description),r.toFixed(0),o.toFixed(0))}))}else t.push(__assign(__assign({},I),{Description:StringHelper.format(T._("We strongly suggest file with a higher resolution to get better results.<br/>(at least {0} x {1} pixels)","Customizer"),r.toFixed(0),o.toFixed(0))}));break}}if(t.length>0)if(h=this.findDesignItemForItem(e)){for(var m=0,v=t;m<v.length;m++){var I=v[m];this.fireNotifyMessageEvent(h.get("itemGuid"),2,T._("Warning!","Customizer"),T._d(I.Description),!I.Closeable||I.Closeable,this.zoomToItem(e),null,{requiredWidth:r,requiredHeight:o},!!I.AddToCartDisabledIfVisible&&I.AddToCartDisabledIfVisible)}return{itemGuid:h.get("itemGuid"),customizedMessages:t}}}},zoomToItem:function(e){var t=this;return function(){e&&(t.zoomToBounds(e.bounds,t.fitToScreenMargin,!0,!0),t.selectItems([e]))}},checkAllAlertItems:function(){for(var e=[],t=this.getAllItems(),i=0;i<t.length;i++){var n=t[i];if(n&&n.data&&n.data.guid&&!n.data.isArea&&!n.guide){var a=this.checkAlertItems(n);a&&e.push(a)}}return e},drawRealBounds:function(e){if(this.realRect&&this.realRect.remove(),this.getMaskedImageRasterItem(e)){var t=this.getItemRealBounds(e);this.realRect=new this.paper.Path.Rectangle(t),this.realRect.strokeColor="red",this.realRect.strokeWidth=1}},getItemRealBounds:function(e){if(!this.getMaskedImageRasterItem(e))return e.bounds;var t=e.bounds;if(IS_IOS)return t;var i=e.rasterize(72);try{var n,a,r=i.position.x-i.width/2,o=i.position.y-i.height/2,s=i.width,l=i.height,h=i.getImageData().data,d=new Uint32Array(h.buffer),c=s,u=l,g=0,f=0;for(a=0;a<l;a++){for(n=0;n<s;n++)d[n+a*s]>0&&n<c&&(c=n);for(n=s;n>=0;n--)d[n+a*s]>0&&n>g&&(g=n)}for(n=0;n<s;n++){for(a=0;a<l;a++)d[n+a*s]>0&&a<u&&(u=a);for(a=l;a>=0;a--)d[n+a*s]>0&&a>f&&(f=a)}((t=new this.paper.Rectangle(r+c,o+u,g-c,f-u)).width<=0||t.height<=0)&&(t=e.bounds)}catch(e){Logger.info(e.message)}finally{i.remove()}return t},createAlertIcon:function(e,t){if(!e)return null;t=t||!1;var i=25/this.paper.view.zoom,n="data:image/png;base64,"+(t?this.iconsBytes.itemAlertDark:this.iconsBytes.itemAlert),a=new this.paper.Raster({source:n,position:e}),r=function(){var e=a.size,t=new this.paper.Size(i,i),n=1,r=1;Math.abs(e.width)>1e-7&&(n=t.width/e.width),Math.abs(e.height)>1e-7&&(r=t.height/e.height),a.scale(n,r)};return a.size.width>0&&a.size.height>0?r():a.onLoad=function(){r()},a},checkSelectionAlertItems:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[0];this.checkAlertItems(i)}},removeAlertItems:function(e){e&&this.fireRemoveMessageEvent(e.data.guid)},removeAllAlertItems:function(){var e=this;this.isConfigurator||this.isViewer||this.getAllItems().forEach(function(t){return e.removeAlertItems(t)})},removeSelectionAlertItems:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[0];this.removeAlertItems(i)}},checkItemQualityForArea:function(e,t){var i=this.getMaskedImageRasterItem(e);if(e&&i&&e.data&&e.data.guid&&!e.data.isArea&&!e.data.isTextArt&&!e.data.isTextOnPath){var n=this.findDesignItemByGuid(e.data.guid);if(n&&"Vector"!=n.get("imageType")){i.bounds;var a=this.getAreaScaleFactor(t);if(a){var r=this.isMaskedImage(e),o=i.size.width*(r?i.scaling.x:1)*e.scaling.x,s=i.size.height*(r?i.scaling.y:1)*e.scaling.y,l=o*a.width,h=s*a.height;if(l>n.get("imageWidth")+.1*n.get("imageWidth")||h>n.get("imageHeight")+.1*n.get("imageHeight"))return!1}}}return!0},getAreaScaleFactor:function(e){var t=new this.paper.Size(1,1),i=this.getSelectedPrintType(e);(!i||i.get("dpi")<=0)&&(i=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(e)));var n=this.getScaledAreaPixelSize(e,i);return n&&(t.width=n.width/e.get("boundsWidth"),t.height=n.height/e.get("boundsHeight")),t},getSelectedPrintType:function(e){var t=this.design.getSelectedPrintTypeForArea(e),i=null;if(e){var n=e.getSideID(),a=e.getColorID(),r=this.getCurrentModel();r&&n>0&&a>0&&(i=r.get("colors").getColor(a).get("sides").getSide(n).get("printTypes").getPrintType(t)||r.get("printTypes").getPrintType(t))}return i},getModelPrintType:function(e){var t=null,i=this.getCurrentModel();return i&&this.design&&this.design instanceof MPlaza.Design&&i.get("printTypes")instanceof MPlaza.PrintTypes&&(t=i.get("printTypes").getPrintType(e)),t},getScaledAreaPixelSize:function(e,t){var i=new this.paper.Size(0,0),n=null;if(e instanceof MPlaza.Area&&(n=e.getParentModel()),n&&n.get("ppcm")>0){var a=e.get("boundsWidth")/n.get("ppcm"),r=e.get("boundsHeight")/n.get("ppcm");if((!t||t.get("dpi")<=0)&&e.get("screenPPI")>0){var o=a/(e.get("boundsWidth")/e.get("screenPPI")*2.54),s=r/(e.get("boundsHeight")/e.get("screenPPI")*2.54);i.width=Math.round(o*e.get("boundsWidth")),i.height=Math.round(s*e.get("boundsHeight"))}else if(t){var l=t.get("dpi")||t.get("printTypeDPI");"PrintfulPrintType"==t.get("name")&&l>120&&(l*=.75);var h=.3937*a*l,d=.3937*r*l;i.width=Math.round(h),i.height=Math.round(d)}}return i},cloneSelectedItems:function(){var e=this.getLastUndoOperationId();this.beginDesignOperation();for(var t=this.getSelectedItems(),i=[],n=0;n<t.length;n++){var a=t[n];if((!this.getMaskedImageRasterItem(a)||this.canAddImage())&&((!(a instanceof this.paper.PointText)||this.canAddText())&&(!a.data||!a.data.isTextOnPath&&!a.data.isTextArea||this.canAddText())&&(!a.data||!a.data.isTextArt||this.canAddTextArt()))){var r=this.findDesignItemForItem(a);if(r&&(!a.data||!a.data.isTextArt||r.get("textArt"))){var o=a.clone();o.data.guid=void 0,a.data&&a.data.isTextOnPath&&a.data.points&&(o.data.points=[a.data.points[0].clone(),a.data.points[1].clone(),a.data.points[2].clone()]),a.data&&a.data.isTextArea&&a.data.rect&&(o.data.rect=a.data.rect.clone()),a.data&&a.data.originalBounds&&(o.data.originaBounds=a.data.originalBounds.clone()),a.data&&a.data.originalMatrix&&(o.data.originalMatrix=a.data.originalMatrix.clone()),a.data&&a.data.originalPosition&&(o.data.originalPosition=a.data.originalPosition.clone());var s=new this.paper.Point(25,25);if(o.position.x+=s.x,o.position.y+=s.y,o.data.originalPosition){var l=(new this.paper.Matrix).translate(s.x,s.y);o.data.originalPosition=o.data.originalPosition.transform(l)}o.data.needsTransformsDataUpdate=!0,this.onTextOnPathMoved(o,s),this.onTextAreaMoved(o,s),i.push(o);var h=null;if(a.data&&a.data.isTextArt){var d=r.get("textArt"),c={fontFamilyID:d.get("fontFamilyID"),fontFaceID:d.get("fontFaceID"),text:d.get("text"),textArtTypeID:d.get("textArtTypeID"),style:null,config:d.get("config").toJSON()};h=this.onTextArtItemCreated(o,c)}else if(this.isImage(a)){var u=this.createDummyImageFromDesignItem(r);h=this.onItemCreated(o,u)}else if(this.isMaskedImage(a)&&!this.isFilledShape(a)){u=this.createDummyImageFromDesignItem(r);var g=this.createDummyShapeFromDesignItem(r);h=this.onItemCreated(o,u),this.onImageItemUpdated(o,u,g)}else if(this.isShape(a)){var f={isImagePlaceholder:a.data.isImagePlaceholder,style:this.getShapeItemStyle(a)},p=this.createDummyShapeFromDesignItem(r);h=this.onShapeItemCreated(o,p,f)}else if(this.isFilledShape(a)){u=this.createDummyImageFromDesignItem(r),g=this.createDummyShapeFromDesignItem(r),f={isImagePlaceholder:a.data.isImagePlaceholder,style:this.getShapeItemStyle(a)};h=this.onShapeItemCreated(o,g,f),this.onShapeItemUpdated(o,g,u)}else a.data&&(a.data.isTextArea||a.data.isTextOnPath)&&(h=this.onItemCreated(o));if(h&&(h.copyConstraints(r.get("constraints")),r.get("colors").each(function(e){h.changeColor(e.get("imageID"),e.get("colorID"),e.get("colorCode"))}),h.unset("colorMappings"),h.set("colorMappings",new MPlaza.ColorMappings),r.get("colorMappings")))for(n=0;n<r.get("colorMappings").length;n++){var m=new MPlaza.ColorMapping;m.copyAttributes(r.get("colorMappings").at(n)),h.get("colorMappings").add(m)}}}}this.deselectAll(),this.selectItems(i),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(e)},mirrorSelectedItems:function(e){var t=this.getLastUndoOperationId();this.beginDesignOperation();for(var i=this.getSelectedItems(),n=0;n<i.length;n++){var a=i[n];a.data.needsTransformsDataUpdate=!0;var r,o=null,s=null;if(this.isShape||this.isFilledShape(a))(r=this.isShape(a)?a:this.getMaskedImageShapeItem(a))&&r.data.originalMatrix&&r.data.originalPosition&&(o=r.data.originalPosition.clone(),s=r.data.originalMatrix.clone());if("X"==e){a.scale(-1,-1);var l=(new this.paper.Matrix).scale(-1,-1);a.data&&a.data.originalMatrix&&a.data.originalMatrix.prepend(l),a.data&&a.data.originalPosition&&(a.data.originalPosition=a.data.originalPosition.transform(l)),this.onTextOnPathScaled(a,-1,-1,a.bounds.center),this.onTextAreaScaled(a,-1,-1,a.bounds.center)}else{a.scale(1,-1);l=(new this.paper.Matrix).scale(1,-1);a.data&&a.data.originalMatrix&&a.data.originalMatrix.prepend(l),a.data&&a.data.originalPosition&&(a.data.originalPosition=a.data.originalPosition.transform(l)),this.onTextOnPathScaled(a,1,-1,a.bounds.center),this.onTextAreaScaled(a,1,-1,a.bounds.center)}if((this.isShape||this.isFilledShape(a))&&s&&o)(r=this.isShape(a)?a:this.getMaskedImageShapeItem(a))&&r.data.originalMatrix&&r.data.originalPosition&&(this.applyTransformationsToMaskImageSubItems(a),r.data.originalPosition=o,r.data.originalMatrix=s,r.data.flips||(r.data.flips=[]),r.data.flips.push(e))}this.updateTextOnPathGuides(i),this.updateTextAreaGuides(i),this.onItemsUpdated(i),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(t)},createDummyImageFromDesignItem:function(e){var t=new MPlaza.Image;return t.set("imageID",e.get("imageID")),t.set("type",e.get("imageType")),t.set("format",e.get("imageFormat")),t.set("width",e.get("imageWidth")),t.set("height",e.get("imageHeight")),t.set("dpiX",e.get("imageDpiX")),t.set("dpiY",e.get("imageDpiY")),t.set("imageFileSize",e.get("imageFileSize")),t.set("providerImageID",e.get("providerImageID")),t.set("userID",e.get("imageUserID")),t.set("visitorID",e.get("imageVisitorID")),t.set("visitorCode",e.get("imageVisitorCode")),t.set("customerID",e.get("imageCustomerID")),t.set("customerCode",e.get("imageCustomerCode")),t.set("price",e.get("imagePrice")),t.set("preferredWidth",e.get("imagePreferredHeight")),t.set("preferredHeight",e.get("imagePreferredHeight")),t},createDummyShapeFromDesignItem:function(e){var t=new MPlaza.Shape;return e.get("shape")&&t.set("shapeID",e.get("shape").get("shapeID")),t},canAddText:function(){if(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design){var e=this.design.getDesignSide(this.side),t=e?e.get("canAddText"):this.design.get("canAddText");if(null!=t&&null!=t&&"boolean"==typeof t&&!t&&!this.design.get("isTemplate"))return!1;var i=this.side.get("areas").at(0),n=this.getSelectedPrintType(i),a=(e?e.get("maxNrTexts"):this.design.get("maxNrTexts"))||(n&&this.model.get("printTypes").get(n.id).get("printTypeRestrictions")?this.model.get("printTypes").get(n.id).get("printTypeRestrictions").get("maxNrTextElements"):null);if(null!=a&&null!=a&&"number"==typeof a)if((e?this.design.countTextItemsForSide(this.side.getModelID(),this.side.getColorID(),this.side.getSideID()):this.design.countTextItemsForColor(this.side.getModelID(),this.side.getColorID()))>=a)return!1}return!0},canAddImage:function(){if(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design){var e=this.design.getDesignSide(this.side),t=e?e.get("canAddImage"):this.design.get("canAddImage");if(null!=t&&null!=t&&"boolean"==typeof t&&!t&&!this.design.get("isTemplate"))return!1;var i=this.side.get("areas").at(0),n=this.getSelectedPrintType(i),a=(e?e.get("maxNrImages"):this.design.get("maxNrImages"))||(n&&this.model.get("printTypes").get(n.id).get("printTypeRestrictions")?this.model.get("printTypes").get(n.id).get("printTypeRestrictions").get("maxNrImages"):null);if(null!=a&&null!=a&&"number"==typeof a)if((e?this.design.countImageItemsForSide(this.side.getModelID(),this.side.getColorID(),this.side.getSideID()):this.design.countImageItemsForColor(this.side.getModelID(),this.side.getColorID()))>=a)return!1}return!0},canMaskImages:function(){if(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design){if(this.design.get("templateDesignID")<=0)return!0;var e=this.design.getDesignSide(this.side),t=e?e.get("canMaskImages"):this.design.get("canMaskImages");if(null!=t&&null!=t&&"boolean"==typeof t&&!t)return!1}return!0},canAddTextArt:function(){return this.canAddText()},canAddShape:function(){if(this.side&&this.side instanceof MPlaza.Side&&this.design&&this.design instanceof MPlaza.Design){if(this.design.get("templateDesignID")<=0)return!0;var e=this.design.getDesignSide(this.side),t=e?e.get("canAddShape"):this.design.get("canAddShape");if(null!=t&&null!=t&&"boolean"==typeof t&&!t)return!1;var i=e?e.get("maxNrShapes"):this.design.get("maxNrShapes");if(null!=i&&null!=i&&"number"==typeof i)if((e?this.design.countShapeItemsForSide(this.side.getModelID(),this.side.getColorID(),this.side.getSideID()):this.design.countShapeItemsForColor(this.side.getModelID(),this.side.getColorID()))>=i)return!1}return!0},canMoveSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(this.isMaskedImage(i)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element)if(this.isFilledShape(i)){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditShapeFilling(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditFilledShape(i))return!1}else{if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditMask(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditMaskedImage(i))return!1}else if(!this.canMoveItem(i))return!1}return!0},canRotateSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(this.isMaskedImage(i)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element)if(this.isFilledShape(i)){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditShapeFilling(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditFilledShape(i))return!1}else{if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditMask(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditMaskedImage(i))return!1}else if(!this.canRotateItem(i))return!1}return!0},canDeleteSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(this.isMaskedImage(i)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element)if(this.isFilledShape(i)){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canDeleteShapeFilling(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask)return!1}else{if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canDeleteMask(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster)return!1}else if(!this.canDeleteItem(i))return!1}return!0},canResizeSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(this.isMaskedImage(i)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element)if(this.isFilledShape(i)){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditShapeFilling(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditFilledShape(i))return!1}else{if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&!this.canEditMask(i))return!1;if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster&&!this.canEditMaskedImage(i))return!1}else{if(i.data.isTextBox&&i.data.adaptText)return!1;if(!this.canResizeItem(i)||i.data&&i.data.isImageForBackground)return!1}var n=this.side.get("areas").at(0),a=this.getSelectedPrintType(n);if(a&&this.model.get("printTypes").get(a.id).get("printTypeRestrictions")&&!1===this.model.get("printTypes").get(a.id).get("printTypeRestrictions").get("allowChangeFontSize")&&!this.design.get("isTemplate")&&(this.getItemIsTextArea(i)||this.getItemIsTextOnPath(i)))return!1}return!0},canEditSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canEditItem(i)||i.data&&i.data.isImageForBackground)return!1}return!0},canChangeSelectionFontFamily:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontFamily(i))return!1}return!0},canChangeSelectionFontSize:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontSize(i))return!1}return!0},canChangeSelectionFontColor:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontColor(i))return!1}return!0},canChangeSelectionFontWeight:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontWeight(i))return!1}return!0},canChangeSelectionFontItalic:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemFontItalic(i))return!1}return!0},canChangeSelectionTextPathMode:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemTextPathMode(i))return!1}return!0},canChangeSelectionJustification:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemJustification(i))return!1}return!0},canChangeSelectionShadowColor:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemShadowColor(i))return!1}return!0},canChangeSelectionShadowBlur:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemShadowBlur(i))return!1}return!0},canChangeSelectionShadowDistance:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemShadowDistance(i))return!1}return!0},canChangeSelectionShadowAngle:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canChangeItemShadowAngle(i))return!1}return!0},canResizeTextBoxSelection:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];if(!this.canResizeTextBoxItem(i))return!1}return!0},getItemConstraints:function(e,t){if(this.design&&!(this.design.get("templateDesignID")<=0)||t){var i=e instanceof MPlaza.DesignItem?e:this.findDesignItemForItem(e);return i?i.get("constraints"):null}},getItemConstraintsProperty:function(e,t,i,n){void 0===i&&(i=!0),void 0===n&&(n=!1);var a=this.getItemConstraints(e,n);return a?a.get(t):i},canMoveItem:function(e){return this.getItemConstraintsProperty(e,"canMove")},canRotateItem:function(e){return this.getItemConstraintsProperty(e,"canRotate")},canDeleteItem:function(e){return this.getItemConstraintsProperty(e,"canDelete")},canResizeItem:function(e){return this.getItemConstraintsProperty(e,"canResize")},canStretchItem:function(e){return this.getItemConstraintsProperty(e,"canStretch")},canEditItem:function(e){return this.getItemConstraintsProperty(e,"canEdit")},canChangeItemFontFamily:function(e){return this.getItemConstraintsProperty(e,"canChangeFontFamily")},canChangeItemFontSize:function(e){var t=this.getItemConstraintsProperty(e,"canChangeFontSize");if(t){var i=this.getItemMinFontSize(e),n=this.getItemMaxFontSize(e);null!=i&&null!=i&&null!=n&&null!=n&&(t=i!=n)}return t},getItemMinFontSize:function(e){if(this.side){var t=this.getItemConstraints(e,!1);if(t)return t.get("minFontSize");var i=this.side.get("areas").at(0),n=this.model.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(i));return n&&n.get("printTypeRestrictions")&&n.get("printTypeRestrictions").get("minFontSize")?n.get("printTypeRestrictions").get("minFontSize"):void 0}},getDefaultFontSize:function(){if(!this.side)return null;var e=this.side.get("areas").at(0),t=this.design.getSelectedPrintTypeForArea(e),i=this.model.get("printTypes").getPrintType(t);return i&&i.get("printTypeRestrictions")&&i.get("printTypeRestrictions").get("defaultFontSize")?i.get("printTypeRestrictions").get("defaultFontSize"):null},getFontSizeList:function(){if(!this.side)return null;var e=this.model.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(this.side.get("areas").at(0)));return e&&e.get("printTypeRestrictions")&&e.get("printTypeRestrictions").get("fontSizeList")?e.get("printTypeRestrictions").get("fontSizeList"):[]},getItemMaxFontSize:function(e){if(this.side){var t=this.getItemConstraints(e,!1);if(t)return t.get("maxFontSize");var i=this.side.get("areas").at(0),n=this.model.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(i));return n&&n.get("printTypeRestrictions")&&n.get("printTypeRestrictions").get("maxFontSize")?n.get("printTypeRestrictions").get("maxFontSize"):void 0}},canChangeTextStrokeColor:function(e){return this.getItemConstraintsProperty(e,"canChangeTextStrokeColor")},canChangeTextStrokeWidth:function(e){return this.getItemConstraintsProperty(e,"canChangeTextStrokeWidth")},canChangeItemFontColor:function(e){return this.getItemConstraintsProperty(e,"canChangeFontColor")},canChangeItemFontWeight:function(e){return this.getItemConstraintsProperty(e,"canChangeFontWeight")},canChangeItemFontItalic:function(e){return this.getItemConstraintsProperty(e,"canChangeFontItalic")},canChangeItemTextPathMode:function(e){return this.getItemConstraintsProperty(e,"canChangeTextPathMode")},canChangeItemTextAreaMode:function(e){return this.canEditItem(e)},canChangeItemAdaptText:function(e){return this.getItemConstraintsProperty(e,"canChangeAdaptText")},canWrapTextOnAdaptText:function(e){return this.getItemConstraintsProperty(e,"canWrapTextOnAdaptText",!0,!0)},canChangeItemLetterSpacing:function(e){return this.getItemConstraintsProperty(e,"canChangeLetterSpacing")},canChangeItemLineSpacing:function(e){return this.getItemConstraintsProperty(e,"canChangeLineSpacing")},canChangeItemShadowColor:function(e){return this.getItemConstraintsProperty(e,"canChangeShadowColor")},canChangeItemShadowBlur:function(e){return this.getItemConstraintsProperty(e,"canChangeShadowBlur")},canChangeItemShadowDistance:function(e){return this.getItemConstraintsProperty(e,"canChangeShadowDistance")},canChangeItemShadowAngle:function(e){return this.getItemConstraintsProperty(e,"canChangeShadowAngle")},getItemIsTextOnPath:function(e){return e&&e.data&&e.data.isTextOnPath},getItemIsTextArea:function(e){return e&&e.data&&e.data.isTextArea},getItemIsTextArt:function(e){return e&&e.data&&e.data.isTextArt},getItemIsTextElement:function(e){return e&&e.data&&(e.data.isText||e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)},isRaster:function(e){return"svg"!=e.get("imageFormat").toLowerCase()},canChangeItemJustification:function(e){return this.getItemConstraintsProperty(e,"canChangeJustification")},canChangeItemVerticalAlignment:function(e){return this.getItemConstraintsProperty(e,"canChangeVerticalAlignment")},canTransform:function(e){return this.getItemConstraintsProperty(e,"canTransform")},canChangeSvgColors:function(e){return this.getItemConstraintsProperty(e,"canChangeSvgColors")},canResizeTextBoxItem:function(e){return this.getItemConstraintsProperty(e,"canResizeTextBox")},canChangeItemTextBoxMode:function(e){return this.getItemConstraintsProperty(e,"canChangeTextBoxMode")},toUppercaseOption:function(e){return this.getItemConstraintsProperty(e,"toUppercase",!1,!0)},isAlwaysOnTop:function(e){var t=this.findDesignItemForItem(e);if(!t)return!1;var i=t.get("constraints");return i&&i.get("isAlwaysOnTop")||!1},isAlwaysOnBottom:function(e){var t=this.findDesignItemForItem(e);if(!t)return!1;var i=t.get("constraints");return i&&i.get("isAlwaysOnBottom")||!1},isItemPrintable:function(e){return this.getItemConstraintsProperty(e,"isPrintable")},isItemStatic:function(e){var t=!(this.canEditItem(e)||this.canMoveItem(e)||this.canRotateItem(e)||this.canResizeItem(e)||this.canDeleteItem(e)||this.canTransform(e));if(this.getMaskedImageRasterItem(e)){var i=this.findDesignItemForItem(e);if(!i)return!1;"Vector"==i.get("imageType")&&(t=t&&!this.canChangeSvgColors(e))}return(e instanceof this.paper.PointText||e&&e.data&&(e.data.isTextOnPath||e.data.isTextArea))&&(t=t&&!(this.canChangeTextStrokeColor(e)||this.canChangeTextStrokeWidth(e)||this.canChangeItemFontFamily(e)||this.canChangeItemFontColor(e)||this.canChangeItemFontWeight(e)||this.canChangeItemTextPathMode(e))),t},itemCanBeTransformed:function(e){return this.canMoveItem(e)||this.canRotateItem(e)||this.canResizeItem(e)||this.canDeleteItem(e)||this.canTransform(e)},isMandatoryToEdit:function(e){return this.getItemConstraintsProperty(e,"mandatoryToEdit")},canAddMask:function(e){return this.getItemConstraintsProperty(e,"canAddMask")},canReplaceMask:function(e){return this.getItemConstraintsProperty(e,"canReplaceMask")},canEditMask:function(e){return this.getItemConstraintsProperty(e,"canEditMask")},canDeleteMask:function(e){return this.getItemConstraintsProperty(e,"canDeleteMask")},canEditMaskedImage:function(e){return this.getItemConstraintsProperty(e,"canEditMaskedImage")},canChangeMaskStrokeColor:function(e){return this.getItemConstraintsProperty(e,"canChangeMaskStrokeColor")},canChangeMaskStrokeWidth:function(e){return this.getItemConstraintsProperty(e,"canChangeMaskStrokeWidth")},canFillShape:function(e){return this.getItemConstraintsProperty(e,"canFillShape")},canReplaceShapeFilling:function(e){return this.getItemConstraintsProperty(e,"canReplaceShapeFilling")},canEditShapeFilling:function(e){return this.getItemConstraintsProperty(e,"canEditShapeFilling")},canDeleteShapeFilling:function(e){return this.getItemConstraintsProperty(e,"canDeleteShapeFilling")},canEditFilledShape:function(e){return this.getItemConstraintsProperty(e,"canEditFilledShape")},canChangeShapeStrokeColor:function(e){return this.getItemConstraintsProperty(e,"canChangeShapeStrokeColor")},canChangeShapeStrokeWidth:function(e){return this.getItemConstraintsProperty(e,"canChangeShapeStrokeWidth")},canChangeShapeFillColor:function(e){return this.getItemConstraintsProperty(e,"canChangeShapeFillColor")},allowTextStroke:function(){return this.getPrintTypeConstraintsProperty("allowTextStroke",!1)},getMinTextStrokeWidth:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("minTextStrokeWidth")&&null!=t.get("minTextStrokeWidth")?t.get("minTextStrokeWidth"):this.getPrintTypeConstraintsProperty("minTextStrokeWidth",null)||0},getMaxTextStrokeWidth:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("maxTextStrokeWidth")&&null!=t.get("maxTextStrokeWidth")?t.get("maxTextStrokeWidth"):this.getPrintTypeConstraintsProperty("maxTextStrokeWidth",null)},adjustInputTextStrokeWidth:function(e,t){var i=this.getMinTextStrokeWidth(e),n=this.getMaxTextStrokeWidth(e);return null!=i&&null!=i&&t<i&&(t=i),null!=n&&null!=n&&t>n&&(t=n),t},allowShadows:function(){return this.getPrintTypeConstraintsProperty("allowShadows",!1)},allowStroke:function(){return this.getPrintTypeConstraintsProperty("allowStroke",!1)},getMinShadowBlur:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("minShadowBlur")&&null!=t.get("minShadowBlur")?t.get("minShadowBlur"):this.getPrintTypeConstraintsProperty("minShadowBlur",null)||0},getMaxShadowBlur:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("maxShadowBlur")&&null!=t.get("maxShadowBlur")?t.get("maxShadowBlur"):this.getPrintTypeConstraintsProperty("maxShadowBlur",null)},adjustInputShadowBlur:function(e,t){var i=this.getMinShadowBlur(e),n=this.getMaxShadowBlur(e);return null!=i&&null!=i&&t<i&&(t=i),null!=n&&null!=n&&t>n&&(t=n),t},getMinShadowDistance:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("minShadowDistance")&&null!=t.get("minShadowDistance")?t.get("minShadowDistance"):this.getPrintTypeConstraintsProperty("minShadowDistance",null)||0},getMaxShadowDistance:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("maxShadowDistance")&&null!=t.get("maxShadowDistance")?t.get("maxShadowDistance"):this.getPrintTypeConstraintsProperty("maxShadowDistance",null)},adjustInputShadowDistance:function(e,t){var i=this.getMinShadowDistance(e),n=this.getMaxShadowDistance(e);return null!=i&&null!=i&&t<i&&(t=i),null!=n&&null!=n&&t>n&&(t=n),t},getMinShadowAngle:function(e){var t=this.getItemConstraints(e);return t&&null!=t.get("minShadowAngle")&&null!=t.get("minShadowAngle")?t.get("minShadowAngle"):this.getPrintTypeConstraintsProperty("minShadowAngle",null)||0},getMaxShadowAngle:function(e){var t=this.getItemConstraints(e);if(t&&null!=t.get("maxShadowAngle")&&null!=t.get("maxShadowAngle"))return t.get("maxShadowAngle");var i=this.getPrintTypeConstraintsProperty("maxShadowAngle",null);return null!=i&&null!=i?Math.min(Math.max(0,i),359):359},adjustInputShadowAngle:function(e,t){var i=this.getMinShadowAngle(e)||0,n=this.getMaxShadowAngle(e)||359;return Math.min(Math.max(i,t),n)},canStretchImages:function(){return this.getPrintTypeConstraintsProperty("canStretchImages",!1)},canStretchTexts:function(){return this.getPrintTypeConstraintsProperty("canStretchTexts",!1)},getPrintTypeConstraints:function(){if(this.side&&this.side.get("areas").length>0&&this.model){var e=this.side.get("areas").at(0),t=this.getSelectedPrintType(e);if(t)return this.model.get("printTypes").get(t.id).get("printTypeRestrictions")}return null},getPrintTypeConstraintsProperty:function(e,t){var i=this.getPrintTypeConstraints();return i?i.get(e):t},findItemById:function(e){if(-1==e)return null;function t(i){if(i.id==e)return i;if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=t(i.children[n]);if(null!=a)return a}return null}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=t(this.paper.project.layers[i]);if(null!=a)return a}return null},findItemByName:function(e){if(!e)return null;function t(i){if(i.name===e)return i;if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=t(i.children[n]);if(null!=a)return a}return null}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=t(this.paper.project.layers[i]);if(null!=a)return a}return null},clearSelectionBounds:function(){this.selectionBoundsShape&&this.selectionBoundsShape.remove(),this.selectionMaskMoveImage&&this.selectionMaskMoveImage.remove(),this.selectionMaskMoveShape&&this.selectionMaskMoveShape.remove(),this.selectionMoveHandle&&this.selectionMoveHandle.remove(),this.selectionRotateHandle&&this.selectionRotateHandle.remove(),this.selectionResizeHandle&&this.selectionResizeHandle.remove(),this.selectionDeleteHandle&&this.selectionDeleteHandle.remove(),this.selectionResizeTopHandle&&this.selectionResizeTopHandle.remove(),this.selectionResizeBottomHandle&&this.selectionResizeBottomHandle.remove(),this.selectionResizeLeftHandle&&this.selectionResizeLeftHandle.remove(),this.selectionResizeRightHandle&&this.selectionResizeRightHandle.remove(),this.selectionBoundsShape=null,this.selectionBounds=null,this.selectionMoveHandle=null,this.selectionRotateHandle=null,this.selectionResizeHandle=null,this.selectionDeleteHandle=null,this.selectionMaskMoveImage=null,this.selectionMaskMoveShape=null,this.selectionResizeTopHandle=null,this.selectionResizeBottomHandle=null,this.selectionResizeLeftHandle=null,this.selectionResizeRightHandle=null},showSelectionBounds:function(){this.drawSelectionBounds++,this.drawSelectionBounds>0&&(this.selectionBoundsShape&&(this.selectionBoundsShape.visible=!0),this.selectionMoveHandle&&(this.selectionMoveHandle.visible=!0),this.selectionRotateHandle&&(this.selectionRotateHandle.visible=!0),this.selectionResizeHandle&&(this.selectionResizeHandle.visible=!0),this.selectionDeleteHandle&&(this.selectionDeleteHandle.visible=!0),this.selectionMaskMoveImage&&(this.selectionMaskMoveImage.visible=!0),this.selectionMaskMoveShape&&(this.selectionMaskMoveShape.visible=!0),this.selectionResizeTopHandle&&(this.selectionResizeTopHandle.visible=!0),this.selectionResizeBottomHandle&&(this.selectionResizeBottomHandle.visible=!0),this.selectionResizeLeftHandle&&(this.selectionResizeLeftHandle.visible=!0),this.selectionResizeRightHandle&&(this.selectionResizeRightHandle.visible=!0))},hideSelectionBounds:function(){this.drawSelectionBounds>0&&this.drawSelectionBounds--,0==this.drawSelectionBounds&&(this.selectionBoundsShape&&(this.selectionBoundsShape.visible=!1),this.selectionMoveHandle&&(this.selectionMoveHandle.visible=!1),this.selectionRotateHandle&&(this.selectionRotateHandle.visible=!1),this.selectionResizeHandle&&(this.selectionResizeHandle.visible=!1),this.selectionDeleteHandle&&(this.selectionDeleteHandle.visible=!1),this.selectionMaskMoveImage&&(this.selectionMaskMoveImage.visible=!1),this.selectionMaskMoveShape&&(this.selectionMaskMoveShape.visible=!1),this.selectionResizeTopHandle&&(this.selectionResizeTopHandle.visible=!1),this.selectionResizeBottomHandle&&(this.selectionResizeBottomHandle.visible=!1),this.selectionResizeLeftHandle&&(this.selectionResizeLeftHandle.visible=!1),this.selectionResizeRightHandle&&(this.selectionResizeRightHandle.visible=!1))},updateSelectionState:function(){if(!this.isViewer){if(this.clearSelectionBounds(),this.updateMaskedImageGuides(),this.selectionBounds=this.getSelectionBounds(),null!=this.selectionBounds){var e=new this.paper.Path.Rectangle(this.selectionBounds);e.strokeColor=this.getContrastedColor(this.selectionBounds),e.strokeWidth=1/this.paper.view.zoom,e.dashOffset=.5/this.paper.view.zoom,e.dashArray=[1/this.paper.view.zoom,1/this.paper.view.zoom],e.guide=!0,e.visible=this.drawSelectionBounds>0,this.selectionBoundsShape=e,this.createSelectionHandles()}this.updateTextOnPathGuides(),this.updateTextAreaGuides()}},moveSelectionShapes:function(e){this.selectionBoundsShape&&(this.selectionBoundsShape.position.x+=e.x,this.selectionBoundsShape.position.y+=e.y,this.selectionMoveHandle&&(this.selectionMoveHandle.position.x+=e.x,this.selectionMoveHandle.position.y+=e.y),this.selectionRotateHandle&&(this.selectionRotateHandle.position.x+=e.x,this.selectionRotateHandle.position.y+=e.y),this.selectionResizeHandle&&(this.selectionResizeHandle.position.x+=e.x,this.selectionResizeHandle.position.y+=e.y),this.selectionDeleteHandle&&(this.selectionDeleteHandle.position.x+=e.x,this.selectionDeleteHandle.position.y+=e.y),this.selectionMaskMoveShape&&(this.selectionMaskMoveShape.position.x+=e.x,this.selectionMaskMoveShape.position.y+=e.y),this.selectionMaskMoveImage&&(this.selectionMaskMoveImage.position.x+=e.x,this.selectionMaskMoveImage.position.y+=e.y),this.selectionResizeTopHandle&&(this.selectionResizeTopHandle.position.x+=e.x,this.selectionResizeTopHandle.position.y+=e.y),this.selectionResizeBottomHandle&&(this.selectionResizeBottomHandle.position.x+=e.x,this.selectionResizeBottomHandle.position.y+=e.y),this.selectionResizeLeftHandle&&(this.selectionResizeLeftHandle.position.x+=e.x,this.selectionResizeLeftHandle.position.y+=e.y),this.selectionResizeRightHandle&&(this.selectionResizeRightHandle.position.x+=e.x,this.selectionResizeRightHandle.position.y+=e.y),this.selectionBounds=this.selectionBoundsShape.bounds)},scaleSelectionShapes:function(e,t,i){this.selectionBoundsShape&&(this.selectionBoundsShape.scale(e,t,i),this.selectionBounds=this.selectionBoundsShape.bounds,this.placeHandleOut(this.selectionBoundsShape))},createSelectionHandles:function(){if(this.selectionMoveHandle&&this.selectionMoveHandle.remove(),this.selectionRotateHandle&&this.selectionRotateHandle.remove(),this.selectionResizeHandle&&this.selectionResizeHandle.remove(),this.selectionDeleteHandle&&this.selectionDeleteHandle.remove(),this.selectionMaskMoveShape&&this.selectionMaskMoveShape.remove(),this.selectionMaskMoveImage&&this.selectionMaskMoveImage.remove(),this.selectionResizeTopHandle&&this.selectionResizeTopHandle.remove(),this.selectionResizeBottomHandle&&this.selectionResizeBottomHandle.remove(),this.selectionResizeLeftHandle&&this.selectionResizeLeftHandle.remove(),this.selectionResizeRightHandle&&this.selectionResizeRightHandle.remove(),this.selectionBoundsShape){var e=this.selectionBoundsShape.segments;if(4==e.length){var t=e[0].point,i=e[1].point,n=e[2].point,a=e[3].point,r=i.add(n.subtract(i).divide(2)),o=t.add(a.subtract(t).divide(2)),s=t.add(i.subtract(t).divide(2)),l=a.add(n.subtract(a).divide(2)),h=this.getSelectedItems(),d=h.length>0&&(this.getItemIsTextArea(h[0])||this.getItemIsTextOnPath(h[0]));if(this.showSelectedElementDimensions&&this.createDimensionLabel(r,a),this.showTotalSizeOfCurrentSide&&this.createPrintAreaTotalDimensionLabel(r,a),this.showUnselectedElementsDimensions&&this.createUnselectedDimensionLabel(),this.canMoveSelection()&&(this.selectionMoveHandle=this.createSelectionHandle("move",i)),this.canRotateSelection()&&(this.selectionRotateHandle=this.createSelectionHandle("rotate",n)),this.canDeleteSelection()&&(this.selectionDeleteHandle=this.createSelectionHandle("remove",t)),this.canResizeSelection()&&(!d||!this.isFixedFontListEnabled())){var c=this.getCurrentModel();if(c&&this.design&&this.design instanceof MPlaza.Design&&c.get("printTypes")instanceof MPlaza.PrintTypes&&h.length>0&&this.side&&this.side.get("areas").length>0){var u=h[0],g=this.selectedDesignItem;if(!this.isImagesFixedSizeEnabled()||g&&!g.get("imagePreferredWidth")&&!g.get("imagePreferredHeight")){this.isMobile&&(!u.data||u.data.isTextArea||u.data.isTextOnPath)||(this.selectionResizeHandle=this.createSelectionHandle("resize",a));var f=this.isMaskedImage(u)&&this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster||this.isMaskedImageRasterItem(u)||this.isImage(u),p=this.canStretchItem(u),m=this.canStretchImages(),v=f&&m&&p,I=u.data.isTextArea&&!u.data.isTextOnPath&&!u.data.isTextBox,y=this.canStretchTexts(),C=I&&y&&p;(u.data&&u.data.isTextArt||this.isMaskedImage(u)&&this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask||u.data&&u.data.isShape||v||C)&&(this.selectionResizeTopHandle=this.createLateralSelectionHandle("top",r),this.selectionResizeBottomHandle=this.createLateralSelectionHandle("bottom",o),this.selectionResizeLeftHandle=this.createLateralSelectionHandle("left",s),this.selectionResizeRightHandle=this.createLateralSelectionHandle("right",l))}}}var M=this.getSelectedItem();if(M&&this.isMaskedImage(M)){var x=!(this.canMoveItem(M)||this.canRotateItem(M)||this.canResizeItem(M));!this.isFilledShape(M)&&this.canEditMask(M)&&(this.selectionMaskMoveShape=this.createSelectionHandle("maskMoveShape",l)),this.isFilledShape(M)&&!x&&(this.selectionMaskMoveShape=this.createSelectionHandle("maskMoveShape",l));var S=this.canMoveSelection(),b=this.canRotateSelection(),w=this.canDeleteSelection(),A=this.canResizeSelection(),P=this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster,D=S||b||w||A;this.canEditMaskedImage(M)&&(D&&!P?M.data.isNewImageIntoShape?(M.data.isNewImageIntoShape=!1,this.editImageShapeSelected()):this.selectionMaskMoveImage=this.createSelectionHandle("maskMoveImage",l):this.editImageShapeSelected())}this.placeHandleOut(this.selectionBoundsShape)}}},editImageShapeSelected:function(){this.applyTransformationsToMaskImageSubItems(),this.maskedImageSelectionMode=MaskedImageSelectionMode.Raster,this.updateMaskedImageGuides()},resetAllDimensionLabels:function(){this.isConfigurator||this.isViewer||(this.selectedItemDimensionLabel&&this.selectedItemDimensionLabel.remove(),this.printAreaLabel&&this.printAreaLabel.remove(),this.labelLayer&&(this.labelLayer.remove(),this.selectedItemDimensionLabel=null,this.printAreaLabel=null,this.labelLayer=null),this.dimensionLabelList&&(this.dimensionLabelList.map(function(e){return e.remove(),!1}),this.dimensionLabelList=null,this.unselectedLabelsGroup.remove(),this.unselectedLabelsGroup=null),this.isResizableMode&&this.hideAreaLabelResizableMode())},createUnselectedDimensionLabel:function(){var e=this,t=this.getSelectedItem();if(t)if(this.dimensionLabelList)this.updateUnselectedLabels();else{this.dimensionLabelList=[],this.unselectedLabelsGroup||(this.unselectedLabelsGroup=new this.paper.Group({name:"unselectedLabelsGroup",applyMatrix:!1,visible:!1}));var i=this.getAllItems(),n=this.side.get("ppcm"),a=this.unselectedLabelsGroup;0===this.dimensionLabelList.length&&this.labelLayer&&(this.labelLayer.addChild(a),i.forEach(function(i){if(i.data&&i.data.guid&&!i.data.isArea&&!i.data.isGroupForBackground&&!e.dimensionLabelList["label-".concat(i.id)]&&i.id!==t.id){var r=i.data.transformsData?i.data.transformsData.dimensions.width:i.bounds.width,o=i.data.transformsData?i.data.transformsData.dimensions.height:i.bounds.height,s=new e.paper.Group({name:"label-".concat(i.id),id:"label-".concat(i.id),applyMatrix:!1});a.addChild(s);var l=i.bounds.topLeft,h=i.bounds.topRight,d=l.add(h.subtract(l).divide(2)),c=(r/n/("cm"===e.unitOfMeasurement?1:2.54)).toFixed(2),u=(o/n/("cm"===e.unitOfMeasurement?1:2.54)).toFixed(2);e.createLabel(d,s,"".concat(c).concat(e.unitOfMeasurement," x ").concat(u).concat(e.unitOfMeasurement)),s.position=d.add(new e.paper.Point(0,-22/e.paper.view.zoom));var g=(s.children[1].bounds.width+20)/s.children[0].bounds.width;s.children[0].scale(g,1),e.dimensionLabelList["label-".concat(i.id)]=s}})),a.visible=!0,this.updateUnselectedLabels()}},updateUnselectedLabels:function(){var e=this,t=this.getSelectedItem();if(t){if(!this.dimensionLabelList)return;var i=this.getAllItems(),n=this.side.get("ppcm");if(this.dimensionLabelList["label-".concat(t.id)]&&(this.dimensionLabelList["label-".concat(t.id)].remove(),delete this.dimensionLabelList["label-".concat(t.id)]),this.unselectedLabelsGroup){var a=this.unselectedLabelsGroup;i.forEach(function(i){if(i.data&&i.data.guid&&!i.data.isArea&&!i.data.isGroupForBackground&&i.id!==t.id)if(e.dimensionLabelList["label-".concat(i.id)])e.resizeHandle(e.dimensionLabelList["label-".concat(i.id)],110);else{var r=i.data.transformsData?i.data.transformsData.dimensions.width:i.bounds.width,o=i.data.transformsData?i.data.transformsData.dimensions.height:i.bounds.height,s=new e.paper.Group({name:"label-".concat(i.id),id:"label-".concat(i.id),applyMatrix:!1});a.addChild(s);var l=i.bounds.topLeft,h=i.bounds.topRight,d=l.add(h.subtract(l).divide(2));d.y-=40;var c=(r/n/("cm"===e.unitOfMeasurement?1:2.54)).toFixed(2),u=(o/n/("cm"===e.unitOfMeasurement?1:2.54)).toFixed(2);e.createLabel(d,s,"".concat(c," x ").concat(u," ").concat(e.unitOfMeasurement));var g=(s.children[1].bounds.width+20)/s.children[0].bounds.width;s.children[0].scale(g,1),e.dimensionLabelList["label-".concat(i.id)]=s}})}}},deleteDimensionLabel:function(e){e&&this.dimensionLabelList&&this.dimensionLabelList["label-".concat(""+e)]&&(this.dimensionLabelList["label-".concat(""+e)].remove(),delete this.dimensionLabelList["label-".concat(""+e)])},isGridImage:function(){var e=this.getSelectedItem();return e&&e.data&&e.data.isGridImage},createDimensionLabel:function(e,t){if(this.labelLayer)this.updateLabelsPosition();else{var i=this.paper.project.activeLayer;this.labelLayer=new this.paper.Layer({name:"labels"}),i.activate(),this.labelLayer.visible=!1,this.labelLayer.bringToFront(),this.selectedItemDimensionLabel=new this.paper.Group({name:"widthLabelGroup"}),this.selectedItemDimensionLabel.applyMatrix=!1,this.labelLayer.addChild(this.selectedItemDimensionLabel),this.createLabel(e,this.selectedItemDimensionLabel,"".concat(0," x ").concat(0," ").concat(this.unitOfMeasurement)),this.updateLabelsPosition();var n=(this.selectedItemDimensionLabel.children[1].bounds.width+20)/this.selectedItemDimensionLabel.children[0].bounds.width;this.selectedItemDimensionLabel.children[0].scale(n,1)}},createPrintAreaTotalDimensionLabel:function(){var e;if(this.printAreaLabel)this.updatePrintAreaLabelText();else{if(!this.labelLayer){var t=this.paper.project.activeLayer;this.labelLayer=new this.paper.Layer({name:"labels"}),t.activate(),this.labelLayer.bringToFront()}this.printAreaLabel=new this.paper.Group({name:"heightLabelGroup"}),this.printAreaLabel.applyMatrix=!1,this.labelLayer.addChild(this.printAreaLabel);var i=this.side.get("ppcm");if(this.itemsLayer.children[0].children[1]){var n=null===(e=this.masterGroup)||void 0===e?void 0:e.children[0],a=(n.bounds.width/i/("cm"===this.unitOfMeasurement?1:2.54)).toFixed(2),r=(n.bounds.height/i/("cm"===this.unitOfMeasurement?1:2.54)).toFixed(2);this.createLabelPrintArea(n,this.printAreaLabel,"".concat(a," x ").concat(r," ").concat(this.unitOfMeasurement))}}},createLabelPrintArea:function(e,t,i){var n,a,r,o=new this.paper.Path.Rectangle(new this.paper.Rectangle(0,0,80,15),0);o.fillColor=new this.paper.Color("#ffffff"),o.strokeScaling=!1,o.strokeWidth=0,o.strokeColor=new this.paper.Color("#000000"),o.position=e.pointTop,o.position.y+=28,o.name="labelRectanglePrintArea-".concat(t.name),o.opacity=1;var s=new this.paper.PointText(e.pointTop);if(s.content=i,s.position.y+=32,s.fontSize=12,s.fontWeight=400,s.fontFamily="Inter",s.fillColor=new this.paper.Color("#8FA4AE"),s.justification="center",s.opacity=.7,t.addChildren([o,s]),this.printAreaLabel.position=e.bounds.topCenter.add(new this.paper.Point(0,-22/this.paper.view.zoom)),this.isResizableMode){t.visible=!1;var l=null!==(r=null===(a=null===(n=this.printAreaLabel)||void 0===n?void 0:n.children[1])||void 0===a?void 0:a.content)&&void 0!==r?r:"";this.updateAreaLabelResizableMode(l)}},createLabel:function(e,t,i){var n=new this.paper.Path.Rectangle(new this.paper.Rectangle(0,0,80,15),0);n.fillColor=new this.paper.Color("#ffffff"),n.strokeScaling=!1,n.strokeWidth=0,n.strokeColor=new this.paper.Color("#000000"),n.position=e,n.position.y+=32,n.name="labelRectangle-".concat(t.name);var a=new this.paper.PointText(e);a.content=i,a.position.y+=36,a.fontSize=12,a.fontWeight=400,a.fontFamily="Inter",a.fillColor=new this.paper.Color("#8FA4AE"),a.justification="center",t.addChildren([n,a])},updateLabelsPosition:function(){var e=this.labelLayer,t=this.getSelectedItem();t&&this.selectedItemDimensionLabel&&(this.selectedItemDimensionLabel.position=t.bounds.topCenter.add(new this.paper.Point(0,-22/this.paper.view.zoom)),this.updateLabelsText(),this.resizeHandle(this.selectedItemDimensionLabel,110),e.visible=!0),this.paper.project.view.update()},updatePrintAreaLabelText:function(){var e,t,i,n,a=null===(e=this.masterGroup)||void 0===e?void 0:e.children[0];if(a){var r=this.getAllItems(),o=[];r.forEach(function(e){e.data&&e.data.guid&&!e.data.isArea&&!e.data.isGroupForBackground&&o.push(e)}),this.getAllGridItems().forEach(function(e){e.children&&e.children.length>0&&e.children.forEach(function(e){e.children.forEach(function(e){e.data&&e.data.isGridImage&&o.push(e)})})});var s=this.totalAreaCalculator(o)/("cm"===this.unitOfMeasurement?1:2.54);this.printAreaLabel.children[1].content="".concat(s.toFixed(2)," ").concat(this.unitOfMeasurement,"2");var l=(this.printAreaLabel.children[1].bounds.width+20)/this.printAreaLabel.children[0].bounds.width;this.printAreaLabel.children[0].scale(l,1),this.resizeHandle(this.printAreaLabel,110);var h=new this.paper.Point(0,-22/this.paper.view.zoom);if(this.printAreaLabel.position=a.bounds.topCenter.add(h),this.isResizableMode){this.printAreaLabel.visible=!1;var d=null!==(n=null===(i=null===(t=this.printAreaLabel)||void 0===t?void 0:t.children[1])||void 0===i?void 0:i.content)&&void 0!==n?n:"";this.updateAreaLabelResizableMode(d)}this.labelLayer.visible=!0}},updateAreaLabelResizableMode:function(e){if(this.isResizableMode&&this.resizableMeasuresItem){var t=this.findTotalSizeLabelResizableCanvas(this.resizableMeasuresItem);t&&(t.content=t.data.originalContent+e,t.bounds.y=t.data.originalY,t.visible=!0)}},hideAreaLabelResizableMode:function(){if(this.isResizableMode&&this.resizableMeasuresItem){var e=this.findTotalSizeLabelResizableCanvas(this.resizableMeasuresItem);e&&(e.visible=!1)}},findTotalSizeLabelResizableCanvas:function(e){for(var t,i=null,n=0;n<e.children.length;n++){var a=e.children[n];if((null===(t=null==a?void 0:a.data)||void 0===t?void 0:t.isTotalSizeLabel)?i=a:(null==a?void 0:a.children)&&a.children.length>0&&(i=this.findTotalSizeLabelResizableCanvas(a)),i)break}return i},updateLabelsText:function(e){var t=this.getSelectedItem();if(!t)throw new Error("Item cannot be null");var i=this.side.get("ppcm"),n=(t.bounds.width/i/("cm"===this.unitOfMeasurement?1:2.54)).toFixed(2),a=(t.bounds.height/i/("cm"===this.unitOfMeasurement?1:2.54)).toFixed(2);this.selectedItemDimensionLabel.children[1].content="".concat(n," x ").concat(a," ").concat(this.unitOfMeasurement);var r=(this.selectedItemDimensionLabel.children[1].bounds.width+10)/this.selectedItemDimensionLabel.children[0].bounds.width;this.selectedItemDimensionLabel.children[0].scale(r,1)},totalAreaCalculator:function(e){var t=this,i=0;return[this.side.get("areas").models].forEach(function(n){var a=t.side;if(null!=a&&a.get("ppcm")>0){var r=e.map(function(e){var t=e.data.transformsData?e.data.transformsData.dimensions.width:e.bounds.width,i=e.data.transformsData?e.data.transformsData.dimensions.height:e.bounds.height,n=e.data.transformsData?e.data.transformsData.position.x:e.bounds.x,a=e.data.transformsData?e.data.transformsData.position.y:e.bounds.y;return new Rectangle(t,i,n,a)});i=(i+rectanglesDistinctArea(r,a.get("ppcm")))/("cm"===t.unitOfMeasurement?1:2.54)}},this),i},placeHandleOut:function(e){if(e=e||this.selectionBoundsShape){var t=e.segments[0].point,i=e.segments[1].point,n=e.segments[2].point,a=e.segments[3].point,r=i.add(n.subtract(i).divide(2)),o=t.add(a.subtract(t).divide(2)),s=t.add(i.subtract(t).divide(2)),l=a.add(n.subtract(a).divide(2)),h=a.subtract(i),d=Math.atan2(h.x,h.y),c=i.getDistance(t)/i.getDistance(n),u=d+Math.atan(c);if(this.selectionMoveHandle){var g=.5*this.selectionMoveHandle.bounds.width;this.selectionMoveHandle.position=i,this.selectionMoveHandle.position.y-=Math.sin(u+Math.PI/4)*g,this.selectionMoveHandle.position.x+=Math.cos(u+Math.PI/4)*g}if(this.selectionRotateHandle){g=.5*this.selectionRotateHandle.bounds.width;this.selectionRotateHandle.position=n,this.selectionRotateHandle.position.y-=Math.sin(u-Math.PI/4)*g,this.selectionRotateHandle.position.x+=Math.cos(u-Math.PI/4)*g}if(this.selectionDeleteHandle){g=.5*this.selectionDeleteHandle.bounds.width;this.selectionDeleteHandle.position=t,this.selectionDeleteHandle.position.y-=Math.sin(u+3*Math.PI/4)*g,this.selectionDeleteHandle.position.x+=Math.cos(u+3*Math.PI/4)*g}if(this.selectionResizeHandle){g=.5*this.selectionResizeHandle.bounds.width;this.selectionResizeHandle.position=a,this.selectionResizeHandle.position.y-=Math.sin(u-3*Math.PI/4)*g,this.selectionResizeHandle.position.x+=Math.cos(u-3*Math.PI/4)*g}if(this.selectionMaskMoveImage){g=.5*this.selectionMaskMoveImage.bounds.width;this.selectionMaskMoveImage.position=l,this.selectionMaskMoveImage.position.y-=Math.sin(u+.7-Math.PI/2)*(g+20/this.paper.view.zoom),this.selectionMaskMoveImage.position.x+=Math.cos(u+.7-Math.PI/2)*(g+20/this.paper.view.zoom)}if(this.selectionMaskMoveShape){g=.5*this.selectionMaskMoveShape.bounds.width;this.selectionMaskMoveShape.position=l,this.selectionMaskMoveShape.position.y-=Math.sin(u-.7-Math.PI/2)*(g+20/this.paper.view.zoom),this.selectionMaskMoveShape.position.x+=Math.cos(u-.7-Math.PI/2)*(g+20/this.paper.view.zoom)}if(this.selectionResizeTopHandle||this.selectionResizeBottomHandle||this.selectionResizeLeftHandle||this.selectionResizeRightHandle){var f=this.selectionResizeHandle?.5*this.selectionResizeHandle.bounds.width:.5*this.selectionLateralResizeDimension*2,p=i.clone();p.y-=Math.sin(u+Math.PI/4)*f,p.x+=Math.cos(u+Math.PI/4)*f;var m=n.clone();m.y-=Math.sin(u-Math.PI/4)*f,m.x+=Math.cos(u-Math.PI/4)*f;var v=t.clone();v.y-=Math.sin(u+3*Math.PI/4)*f,v.x+=Math.cos(u+3*Math.PI/4)*f;var I=a.clone();I.y-=Math.sin(u-3*Math.PI/4)*f,I.x+=Math.cos(u-3*Math.PI/4)*f;var y=1.2*(this.selectionLateralResizeDimension/this.paper.view.zoom),C=r.subtract(o).normalize(y);r=r.add(C),o=o.subtract(C),C=l.subtract(s).normalize(y),l=l.add(C),s=s.subtract(C),this.selectionResizeTopHandle&&(this.selectionResizeTopHandle.position=r),this.selectionResizeBottomHandle&&(this.selectionResizeBottomHandle.position=o),this.selectionResizeLeftHandle&&(this.selectionResizeLeftHandle.position=s),this.selectionResizeRightHandle&&(this.selectionResizeRightHandle.position=l)}}},resizeHandle:function(e,t){var i=e.bounds,n=(null!=t?t:200)/_this_1.paper.view.zoom,a=(t=new _this_1.paper.Size(n,n),1);Math.abs(i.width)>1e-7&&(a=t.width/i.width),Math.abs(i.height)>1e-7&&(t.height,i.height),e.scale(a)},createSelectionHandle:function(e,t){if(!this.selectionBounds)return null;var i=this.selectionBoundsShape,n=getViewport(),a=0;a=(n.w,32/this.paper.view.zoom);var r="data:image/png;base64,"+this.iconsBytes[e],o=new this.paper.Raster({source:r,position:t.add()});o.data.isHandle=!0;var s=function(){var e=o.size,t=new this.paper.Size(a,a),i=1,n=1;Math.abs(e.width)>1e-7&&(i=t.width/e.width),Math.abs(e.height)>1e-7&&(n=t.height/e.height),o.scale(i,n)};if(o.size.width>0&&o.size.height>0)s();else{var l=this;o.onLoad=function(){s(),l.placeHandleOut(i)}}return o},createLateralSelectionHandle:function(e,t){var i=this.selectionLateralResizeDimension/this.paper.view.zoom,n=new this.paper.Path.Circle(t,i);return n.data.isLateralResize=!0,n.data.lateralResizeType=e,n.strokeColor=new this.paper.Color(1,1,1,.5),n.strokeWidth=1,n.fillColor=new this.paper.Color(0,0,0,.5),n},isItemFrozen:function(e){return e&&(e.data&&e.data.frozen||this.isItemGroupChild(e)&&e.parent.data&&e.parent.data.frozen)},isItemGroup:function(e){return e instanceof this.paper.Group&&!(e instanceof this.paper.Layer)},isItemGroupChild:function(e){return e.parent&&this.isItemGroup(e.parent)},isItemChild:function(e){return e.parent&&!(e.parent instanceof this.paper.Layer)},getRootDesignItemCanvasItem:function(e){if(e){if(e.isMaskPath)return e.item;if(e.data&&e.data.guid&&!e.data.isArea)return e;if(e.parent&&!(e.parent instanceof this.paper.Layer))return this.getRootDesignItemCanvasItem(e.parent)}return null},isDesignItemCanvasItem:function(e){return null!=this.getRootDesignItemCanvasItem(e)},setItemDataCustomOptions:function(e,t){e.data.customOptions=t,this.onItemUpdated(e),console.log(e.data)},setItemSelection:function(e,t){var i=this.getRootDesignItemCanvasItem(e);if(i&&i.data.selected!=t){i.data.selected=t;var n=this.findDesignItemForItem(i);i.data.maskAlertPath&&i.data.maskAlertPath.remove(),this.createMaskForItem(e),t?(this.cacheSelectedItemConstraints(n),this.checkAlertItems(i),this.removeDashedEdgeForItem(i),this.selectedDesignItem=n,this.selectedPaperRootItem=i):(n&&(this.createDashedEdgeForItem(i),this.createProfanityCheckInvalidOverlayAndEdgeForItem(i)),this.selectedDesignItem=null,this.selectedPaperRootItem=null);var a={designItem:n,selected:t};n&&this.fireSelectionChangedEvent(a)}},createMaskForItem:function(e){if(!e.data||!e.data.isImageForBackground&&!e.data.isAreaForBackground){var t=this.getRootDesignItemCanvasItem(e);if(t&&t.data){var i=this.getAreasIntersectingItem(t),n=this.getAreasContainingItem(t),a=0==i.length&&0==n.length;t.data.maskPath&&t.data.maskPath.remove(),t.data.maskPath=new this.paper.Path.Rectangle(t.bounds),t.data.maskPath.strokeWidth=2,t.data.maskPath.strokeColor="blue",t.data.maskPath.dashArray=[4,10],t.data.maskPath.isMaskPath=!0,t.data.maskPath.item=t,t.data.maskPath.visible=!1,!t.data.selected&&a&&this.itemCanBeTransformed(e)&&(t.data.maskPath.visible=!0)}}},removeMaskForItem:function(e){var t=this.getRootDesignItemCanvasItem(e);t&&t.data&&t.data.maskPath&&t.data.maskPath.remove()},canAddDashedEdge:function(e){var t;return!(!this.design||this.design.get("templateDesignID")<=0||!this.canEditItem(e)||!(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.isTemplateElement)||(null==e?void 0:e.data)&&((null==e?void 0:e.data.isImageForBackground)||(null==e?void 0:e.data.isAreaForBackground)))&&this.showDashedEdge},createDashedEdgeForItem:function(e){if(this.canAddDashedEdge(e)&&!this.isViewer){var t=this.getRootDesignItemCanvasItem(e);if(this.removeDashedEdgeForItem(t),!t.data.maskPath.visible){var i=new this.paper.Path.Rectangle(t.bounds);i.strokeWidth=2,i.strokeColor=this.DashedEdgeColor,i.dashArray=[10,10],i.visible=!0,t.data.dashedEdgeID=i.id,this.masterGroup.addChild(i),i.insertBelow(t),i.data.isDashedEdge=!0}}},removeDashedEdgeForItem:function(e){var t=this.getRootDesignItemCanvasItem(e);if(t&&t.data&&t.data.dashedEdgeID>0){var i=this.paper.project.getItem({id:t.data.dashedEdgeID});i&&(i.remove(),t.data.dashedEdgeID=-1)}},updateDashedEdgeAllItems:function(){for(var e=this.design.get("designItems"),t=[],i=0;i<e.length;i++){var n=e.at(i),a=this.findItemForDesignItem(n);t.push(a)}for(var r=0,o=t;r<o.length;r++){a=o[r];this.removeDashedEdgeForItem(a),this.createDashedEdgeForItem(a)}},createMaskAlertForItem:function(e){var t=this.getRootDesignItemCanvasItem(e);t.data.maskAlertPath&&t.data.maskAlertPath.remove(),t.data.maskAlertPath=new this.paper.Path.Rectangle(t.bounds),t.data.maskAlertPath.strokeWidth=3,t.data.maskAlertPath.strokeColor="red",t.data.maskAlertPath.dashArray=[10,10],t.data.maskAlertPath.isMaskAlertPath=!0,t.data.maskAlertPath.item=t,t.data.maskAlertPath.data.isMaskAlertPath=!0},createProfanityCheckInvalidOverlayAndEdgeForItem:function(e){var t=this;if(!this.isViewer){var i=this.getRootDesignItemCanvasItem(e);if(this.removeProfanityCheckInvalidOverlayAndEdgeForItem(i),!i.data.isProfanityCheckInvalid)return;var n=new this.paper.Path.Rectangle(i.bounds);if(n.strokeWidth=3,n.strokeColor="red",n.dashArray=[10,10],n.visible=!0,n.insertBelow(i),n.data.isProfanityCheckDashedEdge=!0,i.data.profanityCheckDashedEdgeId=n.id,this.masterGroup.addChild(n),this.isImage(i)){this.invalidOverlayLayer||(this.invalidOverlayLayer=new this.paper.Layer({name:"invalid-overlay-layer"}),this.invalidOverlayLayer.bringToFront());var a=new this.paper.Group,r=new this.paper.Group;a.position=new this.paper.Point(0,0),a.data.isInvalidOverlayGroup=!0,r.visible=!1,r.position=new this.paper.Point(0,0),r.data.isInvalidOverlayGroup=!0;var o=i.bounds.width/i.bounds.height,s=new this.paper.Path.Rectangle({width:300,height:300/o});s.position=a.position,s.fillColor=new paper.Color(.1,.1,.1,.65),s.data.isInvalidOverlayGroup=!0,i.data.profanityCheckOverlayId=a.id,a.addChildren([s,r]),this.invalidOverlayLayer.addChild(a),this.itemsLayer.activate();var l=i.bounds.width/a.bounds.width;a.scale(l),a.position=i.position;var h=new this.paper.Raster({source:"data:image/png;base64,"+this.iconsBytes.warningOutlined});h.data.isInvalidOverlayGroup=!0,h.position=new this.paper.Point(s.bounds.x+s.bounds.width/2,s.bounds.y+s.bounds.height/2-20),h.onLoad=function(){var e=new t.paper.PointText({content:"Image not",fillColor:"white",fontStyle:"bold",fontWeight:"bold",fontSize:"18px"});e.data.isInvalidOverlayGroup=!0,e.position=new t.paper.Point(s.bounds.x+s.bounds.width/2,s.bounds.y+s.bounds.height/2+20);var i=new t.paper.PointText({content:"allowed",fillColor:"white",fontStyle:"bold",fontWeight:"bold",fontSize:"18px"});i.data.isInvalidOverlayGroup=!0,i.position=new t.paper.Point(s.bounds.x+s.bounds.width/2,s.bounds.y+s.bounds.height/2+40),r.addChildren([h,e,i]),l=Math.min(s.bounds.width/r.bounds.width,s.bounds.height/r.bounds.height),r.scale(l);var n=100/t.paper.view.zoom;l=n<r.bounds.height?n/r.bounds.height:1,r.scale(l),r.visible=!0}}}},removeProfanityCheckInvalidOverlayAndEdgeForItem:function(e){var t=this.getRootDesignItemCanvasItem(e);if(t&&t.data){if(t.data.profanityCheckDashedEdgeId>0){var i=this.paper.project.getItem({id:t.data.profanityCheckDashedEdgeId});i&&(i.remove(),t.data.profanityCheckDashedEdgeId=-1)}if(t.data.profanityCheckOverlayId>0){var n=this.paper.project.getItem({id:t.data.profanityCheckOverlayId});n&&(n.remove(),t.data.profanityCheckOverlayId=-1)}}},groupSelectedItems:function(){var e=this.getSelectedItems();if(0!=e.length){for(var t=new this.paper.Group,i=0;i<e.length;i++){var n=e[i];n.guide||t.addChild(n)}return this.setItemSelection(t,!0),this.updateSelectionState(),this.paper.project.view.update(),t}},ungroupSelectedItems:function(){var e=this.getSelectedItems();if(0!=e.length){for(var t=0;t<e.length;t++){var i=e[t];i instanceof this.paper.Group&&this.ungroup(i)}this.updateSelectionState(),this.paper.project.view.update()}},ungroup:function(e){if(this.setItemSelection(e,!1),e&&e instanceof this.paper.Group){for(;e.children.length>0;){var t=e.children.pop();t.parent=this.paper.project.activeLayer,this.setItemSelection(t,!0)}e.remove()}},captureSelectionPosition:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];if(!n.guide&&!this.isItemChild(n)){var a=this.getSubItemsToChange(n),r=[];a.forEach(function(e){r.push({id:e.id,position:e.position})}),e.push(r)}}return e},restoreSelectionPosition:function(e){for(var t=0;t<e.length;t++)for(var i=e[t],n=0;n<i.length;n++){var a=i[n],r=this.findItemById(a.id);r||console.log("ITEM NOT FOUND!"),r&&(r.position=a.position)}},captureSelectionState:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i],a=this.getSubItemsToChange(n);if(!n.guide){this.removeMaskForItem(n);this.getMaskedImageRasterItem(n);var r=[];a.forEach(function(e){r.push({id:e.id,applyMatrix:e.applyMatrix,json:e.exportJSON({asString:!1}),matrix:e.matrix.clone(),selectedSegments:[],boundsItemMatrix:e.data&&e.data.originalMatrix?e.data.originalMatrix.clone():null,boundsItemPosition:e.data&&e.data.originalPosition?e.data.originalPosition.clone():null})}),e.push(r)}}return e},restoreSelectionState:function(e){for(var t=0;t<e.length;t++)for(var i=e[t],n=0;n<i.length;n++){var a=i[n],r=this.findItemById(a.id);if(r){if(a.applyMatrix){var o=r.id;r.importJSON(a.json),r._id=o}else r.matrix.set(a.matrix.a,a.matrix.b,a.matrix.c,a.matrix.d,a.matrix.tx,a.matrix.ty);r.data.originalBounds&&r.data.originalMatrix&&a.boundsItemMatrix&&(r.data.originalMatrix=a.boundsItemMatrix.clone()),r.data.originalPosition&&r.data.originalPosition&&a.boundsItemPosition&&(r.data.originalPosition=a.boundsItemPosition.clone())}}},captureSelectionMatrix:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i],a=n;if(this.isMaskedImage(n))a=this.getReferenceItemForSelectedItem(n);else{if(n.guide)continue;if(this.isItemChild(n))continue}var r=this.getMaskedImageRasterItem(n),o={id:n.id,refId:a.id,matrix:a.matrix.clone(),selectedSegments:[],boundsItemMatrix:n.data.originalMatrix?n.data.originalMatrix.clone():null,boundsRasterMatrix:r&&r.data.originalMatrix?r.data.originalMatrix.clone():null};e.push(o)}return e},restoreSelectionMatrix:function(e){for(var t=0;t<e.length;t++){var i=e[t],n=this.findItemById(i.id),a=this.findItemById(i.refId);if(n&&a){a.matrix.set(i.matrix.a,i.matrix.c,i.matrix.b,i.matrix.d,i.matrix.tx,i.matrix.ty),n.data&&n.data.originalMatrix&&(n.data.originalMatrix=i.boundsItemMatrix.clone());var r=this.getMaskedImageRasterItem(n);r&&r.data.originalMatrix&&i.boundsRasterMatrix&&(r.data.originalMatrix=i.boundsRasterMatrix.clone())}}},deselectAll:function(){var e=this.getSelectedItems();this.fireDeselectionChangedEvent(e),this.deselectGridBoxes();for(var t=0;t<e.length;t++){var i=e[t];i.data&&i.data.selected&&this.setItemSelection(i,!1)}this.paper.project.deselectAll(),this.hideAreaItems(),this.labelLayer&&this.labelLayer.visible&&(this.labelLayer.visible=!1),this.isResizableMode&&this.resizableMeasuresItem&&this.hideAreaLabelResizableMode()},selectItems:function(e){if(this.deselectAll(),e&&"[object Array]"===Object.prototype.toString.call(e))for(var t=0;t<e.length;t++){var i=e[t];i&&this.setItemSelection(i,!0)}this.updateSelectionState(),this.paper.project.view.update()},getSelectionBounds:function(){for(var e=null,t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i],a=this.getItemBounds(n);e=null==e?a.clone():e.unite(a)}return e},getSelectedItem:function(){var e=this.getSelectedItems();return e.length>0?e[0]:null},isItemSelected:function(e){for(var t=this.getSelectedItems(),i=0;i<t.length;i++){if(t[i]===e)return!0}return!1},getSelectedItems:function(){for(var e=[],t=function(i){if(!i.guide&&(!i.data||!i.data.isArea)&&(i.data&&i.data.selected&&e.push(i),i.children))for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];t(a)}},i=0;i<this.paper.project.layers.length;i++){var n=this.paper.project.layers[i];n.guide||t(n)}return e},getSelectedSimpleItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||(n instanceof this.paper.Group||n.parent&&this.isItemGroup(n.parent)||e.push(n))}return e},getSelectedGroupItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||this.isItemGroup(n)&&e.push(n)}return e},getSelectedTextItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||(n instanceof this.paper.TextItem?e.push(n):n&&n.data&&n.data.isTextOnPath?e.push(n):n&&n.data&&n.data.isTextArea&&e.push(n))}return e},getDefaultTextItemInfo:function(){var e={text:"",strokeColor:null,strokeWidth:0,fillColor:"black",fontFamily:"Arial",fontSize:18,fontWeight:"normal",fontStyle:"normal",fontStretch:"normal",justification:"center",isTextOnPath:!1,isTextArea:!1,isTextBox:!1,adaptText:!1,letterSpacing:0,lineSpacing:0,scaling:1,verticalAlignment:"top",shadowColor:null,shadowBlur:0,shadowDistance:7,shadowAngle:45};return e},getTextFromItem:function(e){var t="";if(e instanceof this.paper.TextItem)t=e.content;else if(e&&e.data&&e.data.isTextOnPath){if(e.children&&e.children.length>0){var i=e.data.text;if(!i)for(var n=0;n<e.children.length;n++)i+=e.children[n].content;t=i}}else e&&e.data&&e.data.isTextArea&&(t=e.data.text||"");return __assign(__assign({},e),{text:t})},getTextItemInfo:function(e){var t=this.getDefaultTextItemInfo();if(e instanceof this.paper.TextItem)t.text=e.content,t.strokeColor=e.strokeColor,t.strokeWidth=e.strokeWidth,t.fillColor=e.fillColor.toCSS(!0),t.fontFamily=e.fontFamily,t.fontSize=e.fontSize,t.fontWeight=e.fontWeight,t.fontStyle=e.fontStyle,t.fontStretch=e.fontStretch,t.justification=e.justification,t.scaling=e.scaling,t.shadowColor=e.shadowColor,t.shadowBlur=e.shadowBlur,t.shadowDistance=this.getOffsetDistance(e.shadowOffset),t.shadowAngle=this.getOffsetAngle(e.shadowOffset),t.letterSpacing=e.letterSpacing,t.lineSpacing=e.lineSpacing;else if(e&&e.data&&e.data.isTextOnPath){if(e.children.length>0){var i=e.data.text;if(!i)for(var n=0;n<e.children.length;n++)i+=e.children[n].content;t.text=i,t.isTextOnPath=e.data&&e.data.isTextOnPath,t.isTextArea=e.data&&e.data.isTextArea,t.isTextBox=e.data&&e.data.isTextBox,t.adaptText=e.data&&e.data.adaptText,t.strokeColor=e.children[0].strokeColor,t.strokeWidth=e.children[0].strokeWidth,t.fillColor=e.children[0].fillColor,t.fontFamily=e.children[0].fontFamily,t.fontWeight=e.children[0].fontWeight,t.fontStyle=e.children[0].fontStyle,t.fontStretch=e.children[0].fontStretch,t.fontSize=e.children[0].fontSize,t.scaling=e.children[0].scaling,t.justification=e.data.isTextArea?e.data.justification:void 0,t.shadowColor=e.children[0].shadowColor,t.shadowBlur=e.children[0].shadowBlur,t.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),t.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset)}}else e&&e.data&&e.data.isTextArea&&(t=this.getTextAreaItemInfo(e,null));return t.isPlaceHolder=e.data&&e.data.isPlaceHolder||!1,e.data.hasOwnProperty("originalStrokeColor")&&(t.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(t.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(t.shadowColor=e.data.originalShadowColor),e.data.hasOwnProperty("adaptText")&&(t.adaptText=e.data.adaptText),e.data.hasOwnProperty("letterSpacing")&&(t.letterSpacing=e.data.letterSpacing),e.data.hasOwnProperty("lineSpacing")&&(t.lineSpacing=e.data.lineSpacing),t.fontFamily=t.fontFamily.replace(/"/g,""),t},getSelectedTextItemsInfo:function(){var e=this.getDefaultTextItemInfo(),t=this.getSelectedTextItems();if(t&&1==t.length){var i=t[0];e=this.getTextItemInfo(i)}return e.fontFamily=e.fontFamily.replace(/"/g,""),e},getSelectedTextItemsNotOnPath:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n instanceof this.paper.TextItem&&e.push(n)}return e},getSelectedTextOnPathItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextOnPath&&e.push(n)}return e},getSelectedTextAreaItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextArea&&e.push(n)}return e},getSelectedSimpleTextAreaItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextArea&&!n.data.isTextBox&&e.push(n)}return e},getSelectedTextBoxItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextArea&&n.data.isTextBox&&e.push(n)}return e},getSelectedTextArtItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isTextArt&&e.push(n)}return e},getSelectedShapeItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];n.guide||n&&n.data&&n.data.isShape&&e.push(n)}return e},getSelectedImageItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];this.getMaskedImageRasterItem(n)&&n.data&&n.data.guid&&!n.data.isArea&&e.push(n)}return e},getSelectedMaskedImageItems:function(){var e=this;return this.getSelectedImageItems().filter(function(t){return e.isMaskedImage(t)})},getSelectedFilledShapesItems:function(){var e=this;return this.getSelectedImageItems().filter(function(t){return e.isFilledShape(t)})},getSelectedItemsCommonImageID:function(){for(var e=null,t=this.getSelectedImageItems(),i=0;i<t.length;i++){var n=t[i],a=this.findDesignItemByGuid(n.data.guid);if(a){var r=a.get("imageID");if(null==e)e=r;else if(r!=e)return null}}return e},getSelectedDesignItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i],a=this.findDesignItemForItem(n);n&&e.push(a)}return e},countTextItems:function(){var e=0,t=this;function i(n){if((!t.isItemGroup(n)||n==t.masterGroup)&&n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];!r.guide&&(r instanceof this.paper.TextItem||r.data&&r.data.isTextOnPath||r.data&&r.data.isTextArea)&&e++,i(r)}}for(var n=0,a=t.paper.project.layers.length;n<a;n++){var r=t.paper.project.layers[n];r.guide||i(r)}return e},countImageItems:function(){var e=0,t=this;function i(n){if((!t.isItemGroup(n)||this.isMaskedImage(n)||this.isMaskedImageClipGroup(n)||n==t.masterGroup)&&n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];r&&r instanceof this.paper.Raster&&r.data&&r.data.guid&&!r.data.isArea&&e++,i(r)}}for(var n=0,a=t.paper.project.layers.length;n<a;n++){var r=t.paper.project.layers[n];r.guide||i(r)}return e},countTextArtItems:function(){var e=0,t=this;function i(n){if((!t.isItemGroup(n)||n==t.masterGroup)&&n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];r&&r.data&&r.data.isTextArt&&e++,i(r)}}for(var n=0,a=t.paper.project.layers.length;n<a;n++){var r=t.paper.project.layers[n];r.guide||i(r)}return e},getItemsInfo:function(){var e=[];if(!this.side)return e;var t=this;function i(n){if(n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];if(r&&!r.guide){var o=null,s=t.findDesignItemForItem(r);if(s){var l=s.get("shape"),h=t.getMaskedImageRasterItem(r),d=t.getMaskedImageShapeItem(r);if(r instanceof this.paper.TextItem||r.data&&r.data.isTextOnPath||r.data&&r.data.isTextArea){o=new MPlaza.TextItemInfo(s,r);var c=t.getTextItemInfo(r);o.sideID=t.side.get("sideID"),o.text=c.text,o.strokeColor=c.strokeColor instanceof paper.Color?c.strokeColor.toCSS(!0):c.strokeColor,o.strokeWidth=c.strokeWidth,o.fillColor=c.fillColor instanceof paper.Color?c.fillColor.toCSS(!0):c.fillColor,o.fontFamily=c.fontFamily,o.fontSize=c.fontSize,o.fontWeight=c.fontWeight,o.fontStyle=c.fontStyle,o.fontStretch=c.fontStretch,o.justification=c.justification,o.isTextOnPath=c.isTextOnPath,o.isTextArea=c.isTextArea,o.adaptText=c.adaptText,o.letterSpacing=c.letterSpacing,o.lineSpacing=c.lineSpacing,o.scaling=c.scaling,o.shadowColor=c.shadowColor,o.shadowBlur=c.shadowBlur,o.shadowDistance=t.getOffsetDistance(c.shadowOffset),o.shadowAngle=t.getOffsetAngle(c.shadowOffset)}else h&&r.data&&r.data.guid&&!r.data.isArea?((o=new MPlaza.ImageItemInfo(s,r)).imageID=s.get("imageID"),o.url=h.data.originalUrl||h.source,o.sideID=t.side.get("sideID"),o.visible=r.visible,o.isMasked=t.isMaskedImage(r),o.maskID=l?l.get("shapeID"):void 0,d&&(o.maskStyle.strokeColor=d.strokeColor?d.strokeColor.toCSS(!0):void 0,o.maskStyle.strokeWidth=d.strokeWidth,o.maskStyle.strokeCap=d.strokeCap,o.maskStyle.strokeJoin=d.strokeJoin,o.maskStyle.dashArray=d.dashArray,o.maskStyle.dashOffset=d.dashOffset,d.data.hasOwnProperty("originalStrokeColor")&&(o.maskStyle.strokeColor=d.data.originalStrokeColor))):r.data&&r.data.isTextArt&&(o=t.getTextArtItemInfo(r))}null!=o&&(o.constraints=(s.get("constraints")||new MPlaza.DesignItemConstraints).toJSON(),e.push(o))}i(r)}}for(var n=0;n<t.paper.project.layers.length;n++){var a=t.paper.project.layers[n];a.guide||i(a)}return e},getSelectedAreaItems:function(){for(var e=[],t=this.getSelectedItems(),i=0;i<t.length;i++)for(var n=t[i],a=this.getAreasIntersectingOrContainingItem(n),r=0;r<a.length;r++){var o=a[r],s=this.findItemForArea(o);s&&e.push(s)}return e},log:function(e){Logger.info(e),$("#logMsg").length&&$("#logMsg").text(e)},appendLog:function(e){var t=$("#logMsg").text();t&&(t+="\n"),t+=e,Logger.info(e),$("#logMsg").text(t)},getTextArtItemInfo:function(e){if(e&&e.data&&e.data.isTextArt){var t=this.findDesignItemForItem(e);if(t){var i=new MPlaza.TextArtItemInfo(t,e),n=t.get("textArt");i.text=n.get("text"),i.fontFamilyID=n.get("fontFamilyID"),i.fontFaceID=n.get("fontFaceID"),i.textArtTypeID=n.get("textArtTypeID"),e instanceof this.paper.Item&&(e.strokeColor&&(i.style.strokeColor=e.strokeColor.toCSS(!0)),i.style.strokeWidth=e.strokeWidth,i.style.strokeCap=e.strokeCap,i.style.strokeJoin=e.strokeJoin,i.style.dashArray=e.dashArray,i.style.dashOffset=e.dashOffset,e.fillColor&&(i.style.fillColor=e.fillColor.toCSS(!0)),e.data.hasOwnProperty("originalStrokeColor")&&(i.style.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(i.style.fillColor=e.data.originalFillColor),e.shadowColor&&(i.style.shadowColor=e.shadowColor.toCSS(!0)),i.style.shadowBlur=e.shadowBlur||0,i.style.shadowDistance=this.getOffsetDistance(e.shadowOffset),i.style.shadowAngle=this.getOffsetAngle(e.shadowOffset));var a=n.get("config");return i.config.angleValue=a.get("angleValue"),i.config.curveValue=a.get("curveValue"),i.config.intensT=a.get("intensT"),i.config.intensB=a.get("intensB"),i.config.isTriangle=a.get("isTriangle"),i.config.isBridge=a.get("isBridge"),i.config.isTop=a.get("isTop"),i.config.isBottom=a.get("isBottom"),i.config.isMiddle=a.get("isMiddle"),i}}return null},getTextArtItemText:function(e){if(e&&e.data&&e.data.isTextArt){var t=this.findDesignItemForItem(e);if(t)return t.get("textArt").get("text")}return null},getImageItemInfo:function(e,t){void 0===t&&(t=null);var i=null;if(e&&e.data&&e.data.guid&&!e.guide&&!e.data.isArea&&(this.side||t)){var n=this.findDesignItemForItem(e);if(n){var a=n.get("shape"),r=this.getMaskedImageRasterItem(e);this.getMaskedImageShapeItem(e);r&&((i=new MPlaza.ImageItemInfo(n,e)).imageID=n.get("imageID"),i.sideID=t?t.get("sideID"):this.side.get("sideID"),i.url=r.data.originalUrl||r.source,i.visible=e.visible,i.isMasked=this.isMaskedImage(e),i.maskID=a?a.get("shapeID"):void 0,i.maskStyle=this.getMaskedImageMaskPathStyle(e)),i.constraints=(n.get("constraints")||new MPlaza.DesignItemConstraints).toJSON()}}return i},getShapeItemInfo:function(e){var t=null;if(e&&(this.isShape(e)||this.isFilledShape(e))){var i=this.findDesignItemForItem(e);if(i){i.get("shape");var n=null;(n=this.isShape(e)?e:this.getMaskedImageShapeItem(e))&&((t=new MPlaza.ShapeItemInfo(i,e)).style=this.getShapeItemStyle(n),t.isImagePlaceholder=n.data.isImagePlaceholder,t.fillerImageID=i.get("imageID"))}}return t},onTouchStart:function(e){if(this.touchEnabled=!0,e.preventDefault(),1==e.touches.length){var t=this.windowToCanvas(e.touches[0].clientX,e.touches[0].clientY),i=new this.paper.Point(t.x,t.y);if(i=this.paper.project.view.viewToProject(i),this.hitTest(i),this.hitTestEnabled=!1,this.interactionMode=MPlaza.CustomizerInteractionMode.Create,this.elementType==MPlaza.CustomizerElementType.None&&(this.interactionMode=MPlaza.CustomizerInteractionMode.Select),this.mouseStartPos=i.clone(),this.adjustmentDelta=null,this.mouseLastPos=i.clone(),this.element=null,this.captureInitialSelectionState(i),this.hitItem)if(this.beginDesignOperation(),this.hitItem.data&&this.hitItem.data.isTextOnPathFirstEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd;else if(this.hitItem.data&&this.hitItem.data.isTextOnPathMiddleEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd;else if(this.hitItem.data&&this.hitItem.data.isTextOnPathLastEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd;else if(this.hitItem.data&&this.hitItem.data.isTextAreaTopEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd;else if(this.hitItem.data&&this.hitItem.data.isTextAreaRightEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd;else if(this.hitItem.data&&this.hitItem.data.isTextAreaBottomEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd;else if(this.hitItem.data&&this.hitItem.data.isTextAreaLeftEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd;else{this.getRootDesignItemCanvasItem(this.hitItem)?this.interactionMode=MPlaza.CustomizerInteractionMode.Select:this.hitItem==this.selectionMoveHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Move:this.hitItem==this.selectionRotateHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Rotate:this.hitItem==this.selectionResizeHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Resize:this.hitItem==this.selectionResizeTopHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeTop:this.hitItem==this.selectionResizeBottomHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeBottom:this.hitItem==this.selectionResizeLeftHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeLeft:this.hitItem==this.selectionResizeRightHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeRight:this.hitItem==this.selectionDeleteHandle&&(this.interactionMode=MPlaza.CustomizerInteractionMode.Delete)}}},onTouchEnd:function(e){this.endDesignOperation(),this.hitTestEnabled=!0,this.hideCenterLines(),this.adjustmentDelta=null;var t=this.getSelectedItems();this.interactionMode==MPlaza.CustomizerInteractionMode.Select?this.selectElement():this.interactionMode==MPlaza.CustomizerInteractionMode.Create?(this.onItemCreated(this.element),this.deselectAll(),this.setItemSelection(this.element,!0)):this.interactionMode==MPlaza.CustomizerInteractionMode.Move?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Rotate?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Resize?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeTop?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeBottom?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeLeft?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeRight?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Delete?this.deleteSelection():this.interactionMode==MPlaza.CustomizerInteractionMode.Edit?this.editElement():this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd&&this.onItemsUpdated(t),this.updateSelectionState(),this.paper.project.view.update()},onTap:function(e){},onDoubleTap:function(e){this.fitToScreen(!0,!0)},onPan:function(e){var t;if(null==e||!e.isFinal){e.preventDefault();var i=null!==(t=e.position)&&void 0!==t?t:this.windowToCanvas(e.center.x,e.center.y),n=new this.paper.Point(i.x,i.y),a=this.getSelectedItems();e.position||(n=this.paper.project.view.viewToProject(n)),"panstart"==e.type?(this.lastPanPoint.x=n.x,this.lastPanPoint.y=n.y,this.panOrigin=paper.view.center,this.removeAllAlertItems(),this.removeSizeLimitAlert()):"panend"==e.type&&(a.length>0&&this.checkAlertItems(a[0]),this.checkImagesSizeLimit());var r=n.subtract(this.lastPanPoint);this.lastPanPoint.x=n.x,this.lastPanPoint.y=n.y;var o=new MPlaza.PointingInfo;e.srcEvent&&(o.modifiers.option=e.srcEvent.altKey||!1,o.modifiers.control=e.srcEvent.ctrlKey||!1,o.modifiers.shift=e.srcEvent.shiftKey||!1),o.delta=r,o.point=n,this.onPointerDrag(o),this.paper.project.view.update();var s=a.length>0&&!this.canMoveSelection(a[0])&&this.interactionMode==MPlaza.CustomizerInteractionMode.Move;0!=a.length&&!s||!this.panOrigin||this.preventViewMoving||(paper.view.center=this.panOrigin.subtract(new paper.Point(1*e.deltaX/paper.view.zoom,1*e.deltaY/paper.view.zoom))),this.clampView()}},onPinch:function(e){try{var t=this.getAllItemsBounds(),i=this.paper.project.view.bounds;if(this.zooming||!t||!i)return;"pinchstart"==e.type&&(this.oldScale=e.scale);var n=e.scale-this.oldScale;if(this.oldScale=e.scale,e.pointers.length<2)return;var a=1+Math.abs(n),r=new paper.Point(e.center.x,e.center.y),o=(r=paper.project.view.viewToProject(r)).subtract(paper.view.center),s=a-1;if(n>0){if(paper.view.zoom>=1.1)return;paper.view.zoom*=a,paper.view.center=paper.view.center.add(o.multiply(s/a))}else if(n<0){if(t.width<i.width-100&&t.height<i.height-100)return;paper.view.zoom/=a,paper.view.center=paper.view.center.subtract(o.multiply(s))}this.preventViewMoving=!1,this.checkAllAlertItems(),this.checkImagesSizeLimit(),this.clampView()}catch(e){alert(e)}},onRotate:function(e){},dumpSelectionPosition:function(){for(var e=this.getSelectedItems(),t=0;t<e.length;t++){var i=e[t];Logger.info("item_"+i._id+" - x: "+i.position.x+" - y: "+i.position.y)}},onMouseDown:function(e){var t,i,n,a,r,o,s,l,h,d,c;if(!this.touchEnabled){this.hitTest(e.point),this.hitTestEnabled=!1,this.interactionMode=MPlaza.CustomizerInteractionMode.Create,this.elementType==MPlaza.CustomizerElementType.None&&(this.interactionMode=MPlaza.CustomizerInteractionMode.Select),this.mouseStartPos=e.point.clone(),this.adjustmentDelta=null,this.mouseLastPos=e.point.clone(),this.element=null,this.captureInitialSelectionState(e.point);this.hitItem;if(this.hitItem)if(this.beginDesignOperation(),null===(t=this.hitItem.data)||void 0===t?void 0:t.isTextOnPathFirstEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd;else if(null===(i=this.hitItem.data)||void 0===i?void 0:i.isTextOnPathMiddleEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd;else if(null===(n=this.hitItem.data)||void 0===n?void 0:n.isTextOnPathLastEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd;else if(null===(a=this.hitItem.data)||void 0===a?void 0:a.isTextAreaTopEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd;else if(null===(r=this.hitItem.data)||void 0===r?void 0:r.isTextAreaRightEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd;else if(null===(o=this.hitItem.data)||void 0===o?void 0:o.isTextAreaBottomEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd;else if(null===(s=this.hitItem.data)||void 0===s?void 0:s.isTextAreaLeftEndHandle)this.interactionMode=MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd;else if(null===(l=this.hitItem.data)||void 0===l?void 0:l.isImageForBackground)this.interactionMode=MPlaza.CustomizerInteractionMode.Select;else if((null===(h=this.hitItem.data)||void 0===h?void 0:h.isGridIcon)||(null===(d=this.hitItem.data)||void 0===d?void 0:d.isGridImage))this.interactionMode=MPlaza.CustomizerInteractionMode.SelectedGridImage;else if(null===(c=this.hitItem.data)||void 0===c?void 0:c.isShapePlaceholderIcon)this.fireFillShapeRequestedEvent({itemGuid:this.hitItem.data.shapeGuid});else{this.getRootDesignItemCanvasItem(this.hitItem)?this.interactionMode=MPlaza.CustomizerInteractionMode.Select:this.hitItem==this.selectionMoveHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Move:this.hitItem==this.selectionRotateHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Rotate:this.hitItem==this.selectionResizeHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.Resize:this.hitItem==this.selectionResizeTopHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeTop:this.hitItem==this.selectionResizeBottomHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeBottom:this.hitItem==this.selectionResizeLeftHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeLeft:this.hitItem==this.selectionResizeRightHandle?this.interactionMode=MPlaza.CustomizerInteractionMode.ResizeRight:this.hitItem==this.selectionDeleteHandle&&(this.interactionMode=MPlaza.CustomizerInteractionMode.Delete)}}},onMouseMove:function(e){this.hitTestEnabled&&this.hitTest(e.point)},onMouseDrag:function(e){e.preventDefault();var t=new MPlaza.PointingInfo;t.modifiers.option=e.modifiers.option,t.modifiers.control=e.modifiers.control,t.modifiers.shift=e.modifiers.shift,t.delta=e.delta,t.point=e.point,this.onPointerDrag(t)},onPointerDrag:function(e){this.hitTestEnabled=!1,this.labelLayer&&this.labelLayer.visible&&(this.labelLayer.visible=!1),this.frozen||(this.interactionMode!=MPlaza.CustomizerInteractionMode.Select&&this.interactionMode!=MPlaza.CustomizerInteractionMode.SelectedGridImage||(this.selectElement(),this.updateSelectionState(),this.captureInitialSelectionState(e.point),this.interactionMode=MPlaza.CustomizerInteractionMode.Move),this.interactionMode==MPlaza.CustomizerInteractionMode.Create?this.elementType!=MPlaza.CustomizerElementType.Text&&this.createElement(e):this.interactionMode==MPlaza.CustomizerInteractionMode.Move?this.moveSelection(e):this.interactionMode==MPlaza.CustomizerInteractionMode.Rotate?this.rotateSelection(e):this.interactionMode==MPlaza.CustomizerInteractionMode.Resize?this.resizeSelection(e):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeTop?this.resizeSelectionTop(e):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeBottom?this.resizeSelectionBottom(e):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeLeft?this.resizeSelectionLeft(e):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeRight?this.resizeSelectionRight(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd?this.moveTextOnPathFirstEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd?this.moveTextOnPathMiddleEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd?this.moveTextOnPathLastEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd?this.moveTextAreaTopEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd?this.moveTextAreaRightEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd?this.moveTextAreaBottomEnd(e):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd&&this.moveTextAreaLeftEnd(e),this.selectedPaperRootItem&&this.removeProfanityCheckInvalidOverlayAndEdgeForItem(this.selectedPaperRootItem))},onMouseUp:function(e){this.hitTestEnabled=!0,this.hideCenterLines(),this.adjustmentDelta=null;var t=this.getSelectedItems(),i=new MPlaza.PointingInfo;i.delta=e.delta,i.point=e.point,this.interactionMode==MPlaza.CustomizerInteractionMode.Select?(this.switchMaskedImageSelectionMode(e),this.selectElement()):this.interactionMode==MPlaza.CustomizerInteractionMode.Create?this.elementType==MPlaza.CustomizerElementType.Text?this.createElement(i):(this.onItemCreated(this.element),this.deselectAll(),this.setItemSelection(this.element,!0)):this.interactionMode==MPlaza.CustomizerInteractionMode.Move?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Rotate?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Resize?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeTop?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeBottom?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeLeft?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.ResizeRight?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.Delete?this.deleteSelection():this.interactionMode==MPlaza.CustomizerInteractionMode.Edit?this.editElement():this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathFirstEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathMiddleEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextOnPathLastEnd?this.onItemsUpdated(t):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaTopEnd?(this.onTextAreaGuidesUpdated(this.interactionMode),this.onItemsUpdated(t)):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaRightEnd?(this.onTextAreaGuidesUpdated(this.interactionMode),this.onItemsUpdated(t)):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaBottomEnd?(this.onTextAreaGuidesUpdated(this.interactionMode),this.onItemsUpdated(t)):this.interactionMode==MPlaza.CustomizerInteractionMode.MoveTextAreaLeftEnd?(this.onTextAreaGuidesUpdated(this.interactionMode),this.onItemsUpdated(t)):this.interactionMode==MPlaza.CustomizerInteractionMode.SelectedGridImage&&(this.hitItem.data.isGridImage?(this.switchMaskedImageSelectionMode(e),this.selectElement()):this.deselectAll(),this.onGridImageSelected(this.hitItem),this.onItemsUpdated(t)),this.forceSelectedTextAreasToBounds(),t.length>0&&this.createProfanityCheckInvalidOverlayAndEdgeForItem(this.getRootDesignItemCanvasItem(t[0])),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()},hitTest:function(e){var t=this;if(!this.frozen){var i=8,n=this.getSelectedTextItemsInfo();this.isMobile&&(n.isTextOnPath||n.isTextArea)&&(i=25/this.paper.view.zoom);var a=this;if(this.hitItem=null,e&&this.itemsLayer){for(var r=this.itemsLayer.hitTestAll(e,{fill:!0,stroke:!0,tolerance:i,match:function(e){return!(e.item instanceof a.paper.Raster&&0==e.item.getPixel(e.offset.x,e.offset.y).alpha)&&(!(e.item&&e.item.data&&e.item.data.guid&&a.isItemStatic(e.item))&&(!(e.item&&e.item.data&&e.item.data.isAreaForBackground)&&(!(e.item&&e.item.data&&e.item.data.isGridBorderPath)&&(!(e.item&&e.item.data&&e.item.data.isInvalidOverlayGroup)&&(!(e.item&&e.item.data&&e.item.data.isMaskAlertPath)&&!(a.mask&&e.item==a.mask||e.item.isClippingArea))))))}}),o=[],s=0,l=this.getAllItems().filter(function(e){return e&&e instanceof t.paper.Raster&&e.data&&e.data.guid&&!e.data.isArea&&!e.guide});s<l.length;s++){var h=l[s];new this.paper.Rectangle(h.bounds).contains(e)&&o.push(h)}var d=void 0;if(o.length>0)for(var c=60/this.paper.view.zoom,u=c*c,g=0,f=o;g<f.length;g++){if((h=f[g]).bounds.area<u){d=h;break}}if(d)this.hitItem=d;else if(r&&r.length>0)this.hitItem=r[0].item;else for(var p=this.getAllItems(),m=0;m<p.length;m++){var v=p[m];if(v.isMaskPath&&v.contains(e))return void(!v.visibile&&v.item?this.hitItem=v.item:this.hitItem=v)}}}},generateBoundsTest:function(e,t,i){var n=new this.paper.Size(e,t),a=new this.paper.Path.Rectangle(i,n);return a.strokeColor="red",a.strokeWidth=3,a.position=i,a},updatePaper:function(){this.paper.project.view.update()},captureInitialSelectionState:function(e){if(this.selectionBounds){this.originalPositions=this.captureSelectionPosition(),this.originalContent=this.captureSelectionState(),this.pivot=this.selectionBounds.center.clone(),this.corner=this.selectionBounds.bottomRight.clone(),this.cornerLeft=this.selectionBounds.leftCenter,this.cornerRight=this.selectionBounds.rightCenter,this.cornerTop=this.selectionBounds.topCenter,this.cornerBottom=this.selectionBounds.bottomCenter,this.originalSize=this.corner.subtract(this.pivot),this.originalCenter=this.selectionBounds.center,this.originalScaleCenter=this.selectionBounds.center;var t=this.getSelectedItems();if(t&&1==t.length){var i=t[0];i.data&&i.data.rect&&(this.originalCenter=i.data.rect.center)}this.originalShape=this.selectionBoundsShape.exportJSON({asString:!1});var n=e.subtract(this.originalCenter);this.originalAngle=Math.atan2(n.y,n.x);for(var a=this.getAllItems(),r=this.getSelectedItems(),o=[],s=1==r.length?this.getItemArea(r[0]):null,l=0;l<a.length;l++){var h=a[l];if(h&&h.data&&h.data.guid&&!h.data.isArea&&!h.guide&&h!=r[0]&&!h.data.isGroupForBackground&&!h.data.isClippingAreaForBackground&&!h.data.isImageForBackground)this.findDesignItemForItem(h).inOnArea(s)&&o.push(h)}this.snapCache={selectedItems:r,areaItems:o,area:s,areaItem:this.findItemForArea(s)}}},clampView:function(){},onKeyDown:function(e){},onKeyUp:function(e){if(!this.frozen){this.beginDesignOperation(),e.preventDefault(),e.stopPropagation();var t=1;e.modifiers.control&&(t=.5);var i=e.event&&e.event.target&&-1!=["INPUT","TEXTAREA"].indexOf(e.event.target.tagName);"delete"!=e.key||i?"right"!=e.key||i?"left"!=e.key||i?"up"!=e.key||i?"down"!=e.key||i||this.moveSelectionByDelta(0,t):this.moveSelectionByDelta(0,-t):this.moveSelectionByDelta(-t,0):this.moveSelectionByDelta(t,0):this.deleteSelection(),this.endDesignOperation()}},getItemAtPoint:function(e){var t=null,i=4;this.paper.view.zoom>1&&(i=0);var n=this;if(e){var a=this.paper.project.hitTest(e,{fill:!0,stroke:!0,tolerance:i,match:function(e){return!(n.mask&&e.item==n.mask||e.item.isClippingArea)}});if(a.item){var r=this.getRootDesignItemCanvasItem(a.item);t=r||a.item}}return t},selectItemAtPoint:function(e){e||this.deselectAll();var t=this.getItemAtPoint(e);!t||t==this.imageItem||t.data&&t.data.isArea?this.deselectAll():this.setItemSelection(t,!0)},selectElement:function(){if(this.hitItem){var e=this.getRootDesignItemCanvasItem(this.hitItem),t=this.getSelectedItems(),i=t.length>0?t[0]:null;if(!this.findDesignItemForItem(e))return void(this.hitItem.data&&this.hitItem.data.isArea&&this.deselectAll());if(e&&(null==i||i!=e)){if(this.element=e,this.isItemStatic(this.element)||e.data&&(e.data.isAreaForBackground||e.data.isGroupForBackground||e.data.isClippingAreaForBackground))return void this.deselectAll();this.deselectAll(),this.setItemSelection(this.element,!0),i&&this.setItemSelection(i,!1)}}else this.deselectAll()},createElement:function(e){!this.frozen&&this.mouseStartPos&&(this.beginDesignOperation(),this.elementType==MPlaza.CustomizerElementType.Rectangle?this.createRectangle(e):this.elementType==MPlaza.CustomizerElementType.Oval?this.createEllipse(e):this.elementType==MPlaza.CustomizerElementType.Free?this.createFreeHand(e):this.elementType==MPlaza.CustomizerElementType.Text&&this.createText(e),this.endDesignOperation())},createRectangle:function(e){if(e.point){var t=e.point;if(this.element&&this.element.remove(),this.mouseStartPos&&t){var i=this.mouseStartPos,n=t;this.element=new this.paper.Path.Rectangle(i,n),this.element.strokeColor="black",this.element.strokeWidth=1,this.element.fillColor="lavender",Logger.info("Rectangle created")}this.paper.project.view.update()}},createEllipse:function(e){if(e.point){var t=e.point;if(this.element&&this.element.remove(),this.mouseStartPos&&t){var i=this.mouseStartPos,n=t,a=new this.paper.Rectangle(i,n);this.element=new this.paper.Path.Ellipse(a),this.element.strokeColor="black",this.element.strokeWidth=1,this.element.fillColor="lavender",Logger.info("Ellipse created")}this.paper.project.view.update()}},createLine:function(e){if(e.point){var t=e.point;if(this.element&&this.element.remove(),this.mouseStartPos&&t){var i=this.mouseStartPos,n=t;this.element=new this.paper.Path.Line(i,n),this.element.strokeColor="black",this.element.strokeWidth=1,Logger.info("Line created")}this.paper.project.view.update()}},createFreeHand:function(e){if(e.point){var t=e.point;if(t){if(!this.element){this.element=new this.paper.Path;new this.paper.Rectangle(t.x-2,t.y-2,4,4);this.element.strokeColor="black",this.element.strokeWidth=1,this.element.fillColor="lavender"}this.element.add(t),this.paper.project.view.update()}}},sendSelectionToBack:function(){this.beginDesignOperation();for(var e=this.getSelectedItems(),t=0;t<e.length;t++){e[t].sendToBack()}this.imageItem&&this.imageItem.sendToBack(),this.onItemsUpdated(e),this.updateItemsIndexes(),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()},bringSelectionToFront:function(){this.beginDesignOperation();for(var e=this.getSelectedItems(),t=0;t<e.length;t++){e[t].bringToFront()}this.onItemsUpdated(e),this.updateItemsIndexes(),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()},moveSelectionToCenter:function(){if(this.canMoveSelection()){this.beginDesignOperation();for(var e=this.getSelectedItems(),t=null,i=0;i<e.length;i++){var n=e[i],a=this.getAreasIntersectingOrContainingItem(n);if(a.length>1||0==a.length)return;if(null==t)t=a[0];else if(t.get("areaID")!=a[0].get("areaID"))return}if(t){var r=this.findItemForArea(t);if(r){for(i=0;i<e.length;i++){n=e[i];var o=r.position.subtract(n.position);n.position.x=r.position.x,n.position.y=r.position.y,n.data.needsTransformsDataUpdate=!0;var s=(new this.paper.Matrix).translate(o.x,o.y);(n instanceof this.paper.Raster||this.getItemIsTextArt(n)||this.isMaskedImage(n))&&n.data&&n.data.originalMatrix&&n.data.originalMatrix.prepend(s),n.data&&n.data.originalPosition&&(n.data.originalPosition=n.data.originalPosition.transform(s)),this.onTextOnPathMoved(n,o),this.onTextAreaMoved(n,o)}this.onItemsUpdated(e),this.updateSelectionState(),this.paper.project.view.update()}}this.endDesignOperation()}},moveSelectionByDelta:function(e,t){if(!this.frozen&&this.canMoveSelection()){var i=!1;this.currentDesignOperation||(this.beginDesignOperation(),i=!0),this.removeSelectionAlertItems();for(var n=new this.paper.Point(e,t),a=this.getSelectedItems(),r=0;r<a.length;r++){a[r].position=a[r].position.add(n);var o=(new this.paper.Matrix).translate(n.x,n.y);(a[r]instanceof this.paper.Raster||this.getItemIsTextArt(a[r])||this.isMaskedImage(a[r]))&&a[r].data&&a[r].data.originalMatrix&&a[r].data.originalMatrix.prepend(o),a[r].data&&a[r].data.originalPosition&&(a[r].data.originalPosition=a[r].data.originalPosition.transform(o)),this.onTextOnPathMoved(a[r],n),this.onTextAreaMoved(a[r],n)}this.onItemsUpdated(a),this.updateSelectionState(),this.paper.project.view.update(),i&&this.endDesignOperation()}},moveSelectionUp:function(){this.canMoveSelection()&&this.moveSelectionByDelta(0,-2)},moveSelectionDown:function(){this.canMoveSelection()&&this.moveSelectionByDelta(0,2)},moveSelectionLeft:function(){this.canMoveSelection()&&this.moveSelectionByDelta(-2,0)},moveSelectionRight:function(){this.canMoveSelection()&&this.moveSelectionByDelta(2,0)},moveSelection:function(e){var t=this;if(!this.frozen&&this.canMoveSelection()&&e.delta){var i=e.delta;this.hideCenterLines(),null!=this.adjustmentDelta&&(i.x-=this.adjustmentDelta.x,i.y-=this.adjustmentDelta.y),!0===this.canMove&&(!1===this.canMoveX&&(i.x=0),!1===this.canMoveY&&(i.y=0)),this.removeSelectionAlertItems();var n=this.getSelectedItems();if(0!=n.length){for(var a=0;a<n.length;a++){var r=n[a];this.getSubItemsToChange(r).forEach(function(e){if(e){e.position.x+=i.x,e.position.y+=i.y;var n=(new t.paper.Matrix).translate(i.x,i.y);e.data&&e.data.originalMatrix&&e.data.originalMatrix.prepend(n),e.data&&e.data.originalPosition&&(e.data.originalPosition=e.data.originalPosition.transform(n))}}),this.onTextOnPathMoved(n[a],i),this.onTextAreaMoved(n[a],i)}this.moveSelectionShapes(i),this.snapToCenter(),this.snapToItems(),this.updateTextOnPathGuides(n),this.updateTextAreaGuides(n),this.updateShapeImagePlaceholders(n),!this.adjustmentDelta||0==this.adjustmentDelta.x&&0==this.adjustmentDelta.y||this.moveSelectionShapes(this.adjustmentDelta);for(a=0;a<n.length;a++)n[a].data.maskPath&&(n[a].data.maskPath.position=n[a].position),n[a].loadingCircle&&(n[a].loadingCircle.position=n[a].bounds.center)}}},cacheSelectedItemConstraints:function(e){var t,i,n;if(e){var a=e.get("constraints");this.canMove=null===(t=null==a?void 0:a.get("canMove"))||void 0===t||t,this.canMoveX=null===(i=null==a?void 0:a.get("canMoveX"))||void 0===i||i,this.canMoveY=null===(n=null==a?void 0:a.get("canMoveY"))||void 0===n||n}},snapToCenter:function(){var e=this;this.adjustmentDelta||(this.adjustmentDelta=new this.paper.Point(0,0)),this.adjustmentDelta.x=0,this.adjustmentDelta.y=0;var t=3/this.paper.view.zoom;if(this.snapCache&&this.snapCache.area&&this.snapCache.areaItem){for(var i=this.snapCache.areaItem,n=this.snapCache.selectedItems,a=i.bounds,r=this.selectionBounds,o=a.center,s=[new this.paper.Point(r.left,r.center.y),r.center,new this.paper.Point(r.right,r.center.y)],l=[new this.paper.Point(r.center.x,r.top),r.center,new this.paper.Point(r.center.x,r.bottom)],h=null,d=null,c=0;c<s.length;c++){var u=s[c].x-o.x,g=Math.abs(u);(null==h||g<h)&&(h=g,d=u)}var f=null,p=null;for(c=0;c<l.length;c++){u=l[c].y-o.y,g=Math.abs(u);(null==f||g<f)&&(f=g,p=u)}var m=null;h<=t&&(m=d);var v=null;f<=t&&(v=p),this.adjustmentDelta.x=null!=m?-m:0,this.adjustmentDelta.y=null!=v?-v:0;for(c=0;c<n.length;c++){var I=n[c];this.getSubItemsToChange(I).forEach(function(t){null!=m&&(t.position.x-=m),null!=v&&(t.position.y-=v);var i=null!=m?(new e.paper.Matrix).translate(-m,0):null,n=null!=v?(new e.paper.Matrix).translate(0,-v):null;t.data&&t.data.originalMatrix&&(i&&t.data.originalMatrix.prepend(i),n&&t.data.originalMatrix.prepend(n)),t.data&&t.data.originalPosition&&(i&&(t.data.originalPosition=t.data.originalPosition.transform(i)),n&&(t.data.originalPosition=t.data.originalPosition.transform(n)))}),null==m&&null==v||(this.onTextOnPathMoved(I,this.adjustmentDelta),this.onTextAreaMoved(I,this.adjustmentDelta))}null==m&&null==v||(null!=m&&this.showVerticalCenterLine(a),null!=v&&this.showHorizontalCenterLine(a))}},snapToItems:function(){var e=this,t=3/this.paper.view.zoom;if(0!=this.snapCache.selectedItems.length&&this.snapCache&&this.snapCache.area&&this.snapCache.areaItem){var i=this.snapCache.areaItem,n=this.snapCache.selectedItems,a=(this.getAllItems(),null),r=null,o=null,s=null;for(S=0;S<this.snapCache.areaItems.length;S++){for(var l=this.snapCache.areaItems[S],h=(l.bounds,n[0].bounds.leftCenter),d=n[0].bounds.rightCenter,c=n[0].bounds.topCenter,u=n[0].bounds.bottomCenter,g=n[0].bounds.center,f=[g,h,d],p=[g,c,u],m=[l.bounds.center,l.bounds.leftCenter,l.bounds.rightCenter],v=[l.bounds.center,l.bounds.topCenter,l.bounds.bottomCenter],I=0;I<f.length;I++){var y=f[I].x,C=m[I].x;if(Math.abs(y-C)<t){a=y-C,o=C,this.adjustmentDelta.x-=a;break}}for(I=0;I<p.length;I++){var M=p[I].y,x=v[I].y;if(Math.abs(M-x)<t){r=M-x,s=x,this.adjustmentDelta.y-=r;break}}if(null!=a||null!=r)break}for(var S=0;S<n.length;S++){var b=n[S];if(this.getSubItemsToChange(b).forEach(function(t){if(null!=a&&(t.position.x-=a),null!=r&&(t.position.y-=r),null!=a||null!=r){var i=null!=a?-a:0,n=null!=r?-r:0,o=(new e.paper.Matrix).translate(i,n);t.data.originalMatrix&&t.data.originalMatrix.prepend(o),t.data.originalPosition&&(t.data.originalPosition=t.data.originalPosition.transform(o))}}),null!=a||null!=r){var w=null!=a?-a:0,A=null!=r?-r:0;this.onTextOnPathMoved(b,new this.paper.Point(w,A)),this.onTextAreaMoved(b,new this.paper.Point(w,A))}}null==a&&null==r||(this.hideCenterLines(),null!=a&&this.showVerticalCenterLine(new this.paper.Rectangle(o-1,i.bounds.topCenter.y,1,i.bounds.bottomCenter.y)),null!=r&&this.showHorizontalCenterLine(new this.paper.Rectangle(i.bounds.leftCenter.x,s,i.bounds.rightCenter.x,1)))}},showVerticalCenterLine:function(e){var t=this.paper.project.view.bounds,i=new this.paper.Point(e.center.x,t.top),n=new this.paper.Point(e.center.x,t.bottom),a=this.getGuideLineFirstColorOptions();this.verticalCenterLine=this.createGuideLine(i,n,a);var r=this.getGuideLineSecondColorOptions();this.verticalCenterLineSecondColor=this.createGuideLine(i,n,r)},showHorizontalCenterLine:function(e){var t=this.paper.project.view.bounds,i=new this.paper.Point(t.left,e.center.y),n=new this.paper.Point(t.right,e.center.y),a=this.getGuideLineFirstColorOptions();this.horizontalCenterLine=this.createGuideLine(i,n,a);var r=this.getGuideLineSecondColorOptions();this.horizontalCenterLineSecondColor=this.createGuideLine(i,n,r)},getGuideLineFirstColorOptions:function(){return{color:"blue",dashOffset:.5/this.paper.view.zoom}},getGuideLineSecondColorOptions:function(){return{color:"red",dashOffset:2.5/this.paper.view.zoom}},createGuideLine:function(e,t,i){var n,a,r=null!==(n=i.color)&&void 0!==n?n:"blue",o=null!==(a=i.dashOffset)&&void 0!==a?a:.5/this.paper.view.zoom,s=new this.paper.Point(.5/this.paper.view.zoom,.5/this.paper.view.zoom),l=e.add(s),h=t.add(s),d=new this.paper.Path.Line(l,h);return d.strokeColor=r,d.strokeWidth=1/this.paper.view.zoom,d.dashOffset=o,d.dashArray=[1/this.paper.view.zoom,3/this.paper.view.zoom],d.removeOn({drag:!0,up:!0}),d.guide=!0,d},hideCenterLines:function(){this.verticalCenterLine&&this.verticalCenterLine.remove(),this.verticalCenterLineSecondColor&&this.verticalCenterLineSecondColor.remove(),this.horizontalCenterLine&&this.horizontalCenterLine.remove(),this.horizontalCenterLineSecondColor&&this.horizontalCenterLineSecondColor.remove(),this.verticalCenterLine=null,this.verticalCenterLineSecondColor=null,this.horizontalCenterLine=null,this.horizontalCenterLineSecondColor=null},rotateSelection:function(e){var t=this;if(!this.frozen&&this.canRotateSelection()&&e.point){var i=e.point;this.removeSelectionAlertItems(),this.hideCenterLines();var n=this.getSelectedItems();if(1==n.length){var a=n[0],r=i.subtract(this.originalCenter),o=Math.atan2(r.y,r.x)-this.originalAngle;this.restoreSelectionState(this.originalContent);var s=this.selectionBoundsShape.id;this.selectionBoundsShape.importJSON(this.originalShape),this.selectionBoundsShape._id=s;for(var l=o/Math.PI*180,h=[0,90,180,270,360,-90,-180,-270,-360],d=0;d<h.length;d++){var c=h[d],u=a.rotation;a.data.isTextArea&&(u=a.children[0].rotation),Math.abs(l+u-c)<5&&(l=c-u,0!=c&&180!=c&&-180!=c||this.showHorizontalCenterLine(a.bounds),90!=c&&-90!=c||this.showVerticalCenterLine(a.bounds))}if(this.selectionBoundsShape.rotate(l,this.originalCenter),this.createSelectionHandles(),this.placeHandleOut(this.selectionBoundsShape),!a.guide)this.getSubItemsToChange(a).forEach(function(e){if(e.rotate(l,t.originalCenter),e.data.originalMatrix){var i=(new t.paper.Matrix).rotate(l,t.originalCenter);e.data.originalMatrix.prepend(i)}if(e.data.originalPosition){i=(new t.paper.Matrix).rotate(l,t.originalCenter);e.data.originalPosition=e.data.originalPosition.transform(i)}}),this.onTextOnPathRotated(a,l,this.originalCenter),this.onTextAreaRotated(a,l,this.originalCenter),this.updateTextOnPathGuides(n),this.updateTextAreaGuides(n),this.updateShapeImagePlaceholders(n)}}},rotateSelectionAngle:function(e){var t=this;this.removeSelectionAlertItems(),this.restoreSelectionState(this.originalContent);var i=this.selectionBoundsShape.id;this.selectionBoundsShape.importJSON(this.originalShape),this.selectionBoundsShape._id=i,this.selectionBoundsShape.rotate(e,this.originalCenter),this.createSelectionHandles();for(var n=this.getSelectedItems(),a=0;a<n.length;a++){var r=n[a];if(!r.guide)this.getSubItemsToChange(r).forEach(function(i){if(i.rotate(e,t.originalCenter),i.data.originalMatrix){var n=(new t.paper.Matrix).rotate(e,t.originalCenter);i.data.originalMatrix.prepend(n)}if(i.data.originalPosition){n=(new t.paper.Matrix).rotate(e,t.originalCenter);i.data.originalPosition=i.data.originalPosition.transform(n)}}),this.onTextOnPathRotated(r,e,this.originalCenter),this.onTextAreaRotated(r,e,this.originalCenter)}this.updateTextOnPathGuides(n),this.updateTextAreaGuides(n)},resizeSelection:function(e){if(!this.frozen&&this.canResizeSelection()&&(e.point&&(this.removeSelectionAlertItems(),0!=this.getSelectedItems().length))){var t=this.originalScaleCenter.clone(),i=this.corner.subtract(t),n=e.point,a=new this.paper.Point;a.x=n.x-this.selectionResizeHandle.bounds.width/2,a.y=n.y-this.selectionResizeHandle.bounds.width/2;var r=this.projectPointOnLine(t,this.corner,a,!1);if(!(r.subtract(t).length<.1)){var o=r.subtract(this.corner);this.corner.x+=o.x,this.corner.y+=o.y;var s=this.corner.subtract(t),l=1,h=1;Math.abs(i.x)>1e-7&&(l=s.x/i.x),Math.abs(i.y)>1e-7&&(h=s.y/i.y),this.scaleSelectedItems(l,h,t)}}},resizeSelectionTop:function(e){this.resizeSelectionLaterally(e,"top")},resizeSelectionBottom:function(e){this.resizeSelectionLaterally(e,"bottom")},resizeSelectionLeft:function(e){this.resizeSelectionLaterally(e,"left")},resizeSelectionRight:function(e){this.resizeSelectionLaterally(e,"right")},resizeSelectionLaterally:function(e,t){if(!this.frozen&&this.canResizeSelection()&&(e.point&&(this.removeSelectionAlertItems(),0!=this.getSelectedItems().length))){var i=this.originalScaleCenter.clone(),n=this._getResizeCorner(t),a=n.subtract(i),r=e.point,o=this._getResizeCompensatedPoint(t,r),s=0,l=0;"top"===t||"bottom"===t?l=o.y-n.y:s=o.x-n.x,this._moveResizeCorner(t,s,l);var h=n.subtract(i),d=1,c=1;"top"===t||"bottom"===t?c=Math.abs(h.y/a.y):d=Math.abs(h.x/a.x),this.scaleSelectedItems(d,c,i)}},_getResizeCorner:function(e){var t=this.corner;return"top"===e?t=this.cornerTop:"bottom"===e?t=this.cornerBottom:"left"===e?t=this.cornerLeft:"right"===e&&(t=this.cornerRight),t},_moveResizeCorner:function(e,t,i){"top"===e?(this.cornerTop.x+=t,this.cornerTop.y+=i):"bottom"===e?(this.cornerBottom.x+=t,this.cornerBottom.y+=i):"left"===e?(this.cornerLeft.x+=t,this.cornerLeft.y+=i):"right"===e?(this.cornerRight.x+=t,this.cornerRight.y+=i):(this.corner.x+=t,this.corner.y+=i)},_getResizeCompensatedPoint:function(e,t){var i=new this.paper.Point;return"all"===e?(i.x=t.x-this.selectionResizeHandle.bounds.width/2,i.y=t.y-this.selectionResizeHandle.bounds.width/2):(i.x=t.x-this.selectionLateralResizeDimension/2,i.y=t.y-this.selectionLateralResizeDimension/2),i},projectPointOnLine:function(e,t,i,n){var a=new this.paper.Point(0,0);if(e.x==t.x)return a.x=e.x,a.y=i.y,a;if(e.y==t.y)return a.x=i.x,a.y=e.y,a;var r=(t.y-e.y)/(t.x-e.x),o=(t.x*e.y-e.x*t.y)/(t.x-e.x),s=i.y-r*i.x-o;return n?s>0?(a.x=i.x,a.y=r*i.x+o):s<0?(a.y=i.y,a.x=(i.y-o)/r):a=i:s>0?(a.y=i.y,a.x=(i.y-o)/r):s<0?(a.x=i.x,a.y=r*i.x+o):a=i,a},scaleItem:function(e,t,i,n){var a=this;if(e){if(!this.canScaleTextFont(e,t,i))return;var r=this.getSubItemsToChange(e);if(!this.canResizeSelectedTextAreas(t,i,n))return;r.forEach(function(e){if(e.scale(t,i,n),e.data.needsTransformsDataUpdate=!0,e.data.originalMatrix){var r=(new a.paper.Matrix).scale(t,i,n);e.data.originalMatrix.prepend(r)}if(e.data.originalPosition){r=(new a.paper.Matrix).scale(t,i,n);e.data.originalPosition=e.data.originalPosition.transform(r)}}),this.onTextOnPathScaled(e,t,i,n),this.onTextAreaScaled(e,t,i,n),this.updateTextOnPathGuides([e]),this.updateTextAreaGuides([e]),this.updateShapeImagePlaceholders([e]),this.updateSelectionState()}},scaleSelectedItems:function(e,t,i){var n=this;if(e<0||t<0){var a=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(this.side.get("areas").at(0)));if(a&&a.get("printTypeRestrictions")&&!1===a.get("printTypeRestrictions").get("showFlipButtons"))return}if(this.canResizeSelection()&&this.canScaleSelectedTextFont(e,t)&&this.canResizeSelectedTextAreas(e,t,i)){for(var r=this.getSelectedItems(),o=0;o<r.length;o++){var s=r[o];if(!s.guide)this.getSubItemsToChange(s).forEach(function(a){if(a.scale(e,t,i),a.data.needsTransformsDataUpdate=!0,a.data.originalMatrix){var r=(new n.paper.Matrix).scale(e,t,i);a.data.originalMatrix.prepend(r)}if(a.data.originalPosition){r=(new n.paper.Matrix).scale(e,t,i);a.data.originalPosition=a.data.originalPosition.transform(r)}}),this.onTextOnPathScaled(s,e,t,i),this.onTextAreaScaled(s,e,t,i)}this.scaleSelectionShapes(e,t,i),this.updateTextOnPathGuides(r),this.updateTextAreaGuides(r),this.updateShapeImagePlaceholders(r)}},deleteSelection:function(){var e=this;if(this.canDeleteSelection()){this.removeSelectionAlertItems();for(var t,i,n=this.getSelectedItems(),a=function(){if(t=n[o],r.deleteDimensionLabel(t.id),r.isMaskedImage(t)&&!r.isFilledShape(t)&&r.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&r.canDeleteMask(t))r.removeMaskFromImage(t);else if(r.isFilledShape(t)&&r.maskedImageSelectionMode==MaskedImageSelectionMode.Raster)r.removeImageFromShape(t);else{if((i=r.findDesignItemForItem(t))&&r.fireDesignItemRemovingEvent(i,t),t.data&&t.data.isGridImage){var a=t.parent;a&&a.data&&a.data.isGridPathGroup&&r.createGridBoxIcon().then(function(t){var i,n,r=a.children.find(function(e){return e.data&&e.data.isGridBorderPath});r&&(r.fillColor=new paper.Color(1,1,1,.9)),a.addChild(t);var o=e.isMobile?Math.min(Math.min(a.bounds.width,a.bounds.height),180):Math.min(.8*Math.min(a.bounds.width,a.bounds.height),66);(null===(i=null==a?void 0:a.data)||void 0===i?void 0:i.smallestCameraIconDim)&&(o=null===(n=null==a?void 0:a.data)||void 0===n?void 0:n.smallestCameraIconDim),t.data.isGridIcon=!0,t.position.x=a.position.x,t.position.y=a.position.y;var s=e.getIconPosition(a);s&&(t.position.x=s.x,t.position.y=s.y),t.scale(o/t.bounds.width,o/t.bounds.height)})}t.remove(),r.onItemRemoved(t),r.removeShapeImagePlaceholder(t),r.setItemSelection(t,!1)}},r=this,o=0;o<n.length;o++)a();this.updateSelectionState(),this.paper.project.view.update()}},editElement:function(){!this.frozen&&this.mouseStartPos&&this.elementType==MPlaza.CustomizerElementType.Text&&this.editText()},updateItemSyncGuid:function(e,t){var i=this.findDesignItemForItem(e);i&&i.set("syncGuid",t)},getContrastedColor:function(e){var t="black";if(this.imageItem){e.height=Math.max(1,e.height),e.width=Math.max(1,e.width);try{var i=this.imageItem.getAverageColor(e);i&&(t=MPlaza.getContrastYIQ(255*i.red,255*i.green,255*i.blue))}catch(e){console.trace("error getting image avarage color "+e.message)}}return t},insertSVGFromUrl:function(e){var t=this;$.ajax({url:e}).done(function(e){t.insertSVG(e)})},insertSVG:function(e){if(this.side){var t=this.side.get("areas").getMaxArea();if(t){var i=this.paper.project.activeLayer.importSVG(e);this.onItemCreated(i),this.detectItemColors(i);var n=this.findItemForArea(t);if(n){i.position=n.position;var a=i.bounds,r=n.bounds;if(r.intersects(a)||a.contains(r)){var o=r.clone();o.width*=.8,o.height*=.8;var s=1,l=1;Math.abs(o.width)>1e-7&&(s=o.width/a.width),Math.abs(o.height)>1e-7&&(l=o.height/a.height);var h=s>0?1:-1,d=l>0?1:-1;s=l=Math.min(Math.abs(s),Math.abs(l)),s*=h,l*=d,i.scale(s,l),this.masterGroup.addChild(i),this.updateItemsIndexes(),this.onItemUpdated(i),this.onDesignItemChanged(i),this.mask&&this.mask.bringToFront}}}}},detectItemColors:function(e){var t=[],i=function(e){if(e.fillColor){var n=e.fillColor.toCSS(!0);-1===t.indexOf(n)&&t.push(n)}if(e.children)for(var a=0;a<e.children.length;a++){var r=e.children[a];i(r)}};i(e);for(var n=0;n<t.length;n++)Logger.info("Color: "+t[n])},resetShadows:function(e){var t=this,i=this.getLastUndoOperationId();this.beginDesignOperation(),e.filter(this.getItemIsTextElement).forEach(function(e){return t.resetTextElementShadow(e)}),e.filter(this.getItemIsTextArt).forEach(function(e){return t.resetTextArtShadow(e)}),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(i)},insertTextArt:function(e,t){if(e&&this.canAddTextArt()){this.beginDesignOperation();var i=this;Zakeke.Customizer.TextArt.createTextArtPath(e.typrFont,e.opentypeFont,e.text,void 0,void 0,e.config).then(function(n){if(n&&i.side){var a=i.side.get("areas").getMaxArea();if(a){var r=i.getDesignEffectForArea(a);i.allowShadows()||(e.style.shadowColor=null);var o=null!=e.style.strokeWidth?e.style.strokeColor:void 0,s=e.style.fillColor,l=e.style.shadowColor;o=i.forceColorInFixedPalette(null,o),s=i.forceColorInFixedPalette(null,s),l=i.forceColorInFixedPalette(null,l),e.style.strokeColor=i.applyDesignEffectToTextColor(r,o),e.style.fillColor=i.applyDesignEffectToTextColor(r,s),e.style.shadowColor=i.applyDesignEffectToTextColor(r,l),e.style.shadowBlur=i.adjustInputShadowBlur(null,e.style.shadowBlur),e.style.shadowDistance=i.adjustInputShadowDistance(null,e.style.shadowDistance),e.style.shadowAngle=i.adjustInputShadowDistance(null,e.style.shadowAngle);var h=new i.paper.CompoundPath(n);i.applyStyleToItem(h,e.style),h.applyMatrix=!0,h.data={},h.data.isTextArt=!0,h.data.originalBounds=h.bounds,h.data.originalMatrix=new i.paper.Matrix,h.data.originalStrokeColor=o,h.data.originalFillColor=s,h.data.originalShadowColor=l,i.applyDesignEffectToItem(r,h);i.onTextArtItemCreated(h,e);var d=i.findItemForArea(a);if(d){var c=d.position.subtract(h.position);h.position.x+=c.x,h.position.y+=c.y;var u=(new i.paper.Matrix).translate(c.x,c.y);h.data.originalMatrix.prepend(u);var g=h.bounds,f=d.bounds;if(f.intersects(g)||g.contains(f)){var p=f.clone();p.width*=.8,p.height*=.8;var m=1,v=1;Math.abs(p.width)>1e-7&&(m=p.width/g.width),Math.abs(p.height)>1e-7&&(v=p.height/g.height);var I=m>0?1:-1,y=v>0?1:-1;m=v=Math.min(Math.abs(m),Math.abs(v)),m*=I,v*=y,h.scale(m,v),u=(new i.paper.Matrix).scale(m,v),h.data.originalMatrix.prepend(u),i.masterGroup.addChild(h),i.onItemUpdated(h),i.updateItemsIndexes(),i.onDesignItemChanged(h),i.fireTextArtLoadedEvent(),i.mask&&i.mask.bringToFront(),t&&t(h),i.endDesignOperation()}}}}})}},buildTextArtPathElement:function(e,t){return'<path xmlns="http://www.w3.org/2000/svg" d="'+e+'" />'},replaceSelectedTextArt:function(e,t){if(e&&this.design){var i=this.getSelectedTextArtItems();if(i&&i.length>0){var n=i[0];if(!this.canEditItem(n))return;this.replaceTextArt(n,e,t)}}},replaceItemTextArt:function(e,t,i){if(e&&this.design&&t){if(!this.canEditItem(t))return;this.replaceTextArt(t,e,i)}},replaceTextArtByGuid:function(e,t,i){var n=this.findItemByGuid(e);n&&this.replaceTextArt(n,t,i)},replaceTextArt:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n=this;return __generator(this,function(a){switch(a.label){case 0:return[4,new Promise(function(a,r){if(n.canEditItem(e)){var o=n;t.text=n.adjustInputTextByConstraints(e,t.text)||t.text,n.beginDesignOperation(),Zakeke.Customizer.TextArt.createTextArtPath(t.typrFont,t.opentypeFont,t.text,void 0,void 0,t.config).then(function(n){if(n){var r=o.findDesignItemByGuid(e.data.guid);if(r){var s=o.getDesignEffectForDesignItem(r);o.allowShadows()||(t.style.shadowColor=null);var l=null!=t.style.strokeWidth?t.style.strokeColor:void 0,h=t.style.fillColor,d=t.style.shadowColor;l=o.forceColorInFixedPalette(e,l),h=o.forceColorInFixedPalette(e,h),d=o.forceColorInFixedPalette(e,d),t.style.strokeColor=o.applyDesignEffectToTextColor(s,l),t.style.fillColor=o.applyDesignEffectToTextColor(s,h),t.style.shadowColor=o.applyDesignEffectToTextColor(s,d),t.style.shadowBlur=o.adjustInputShadowBlur(e,t.style.shadowBlur),t.style.shadowDistance=o.adjustInputShadowDistance(e,t.style.shadowDistance),t.style.shadowAngle=o.adjustInputShadowDistance(e,t.style.shadowAngle);var c=e.bounds.width,u=e.bounds.height,g=new o.paper.CompoundPath(n);g.visible=!1,o.applyStyleToItem(g,t.style),g.transform(e.data.originalMatrix),g.position=e.position,e.removeChildren(),e.copyContent(g);var f=e.data;e.copyAttributes(g),e.data=f,e.visible=!0,e.data.originalStrokeColor=l,e.data.originalFillColor=h,e.data.originalShadowColor=d,e.data.isProfanityCheckInvalid=!1,o.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),g.remove();var p=e.bounds.width,m=e.bounds.height,v=1,I=1;p>0&&Math.abs(c)>1e-7&&(v=c/p),m>0&&Math.abs(u)>1e-7&&(I=u/m),e.scale(v,I);var y=(new o.paper.Matrix).scale(v,I);e.data.originalMatrix.prepend(y),o.onTextArtItemUpdated(e,t),t.isDirty&&o.onDesignItemChanged(e),o.updateSelectionState(),o.paper.project.view.update(),o.endDesignOperation(),i&&i(e),o.fireTextArtLoadedEvent(),a()}}})}})];case 1:return a.sent(),[2]}})})},changeTextArtStyle:function(e,t,i){if(this.canEditItem(e)&&e&&e instanceof this.paper.Item){this.beginDesignOperation();var n=this.findDesignItemByGuid(e.data.guid),a=this.getDesignEffectForDesignItem(n);this.allowShadows()||(t.shadowColor=null);var r=t.strokeColor,o=t.fillColor,s=t.shadowColor;r=this.forceColorInFixedPalette(e,r,i),o=this.forceColorInFixedPalette(e,o,i),s=this.forceColorInFixedPalette(e,s,i),t.strokeColor=this.applyDesignEffectToTextColor(a,r),t.fillColor=this.applyDesignEffectToTextColor(a,o),t.shadowColor=this.applyDesignEffectToTextColor(a,s),t.shadowBlur=this.adjustInputShadowBlur(e,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(e,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(e,t.shadowAngle),this.applyStyleToItem(e,t),e.data.originalStrokeColor=r,e.data.originalFillColor=o,e.data.originalShadowColor=s,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}},applyStyleToItem:function(e,t){if(e&&e instanceof this.paper.Item&&(null!=t.strokeColor&&(e.strokeColor=t.strokeColor),null!=t.strokeWidth&&(e.strokeWidth=t.strokeWidth),t.strokeCap&&(e.strokeCap=t.strokeCap),t.strokeJoin&&(e.strokeJoin=t.strokeJoin),null!=t.dashOffset&&(e.dashOffset=t.dashOffset),t.dashArray&&(e.dashArray=t.dashArray),t.fillColor&&!this.isFilledShape(e)&&(e.fillColor=t.fillColor),null!=t.shadowColor&&!this.isShape(e)&&!this.isMaskedImageShapeItem(e)&&!this.isMaskedImageMaskItem(e))){e.shadowColor=t.shadowColor,e.shadowBlur=t.shadowBlur;var i=0,n=0;t.hasOwnProperty("shadowDistance")&&(i=t.shadowDistance),t.hasOwnProperty("shadowAngle")&&(n=t.shadowAngle),e.shadowOffset=this.getOffsetByDistanceAngle(i,n)}},getAllTextArtItems:function(){var e=this;return this.getAllItems().filter(function(t){return e.getItemIsTextArt(t)})},resetTextArtShadow:function(e){if(e&&e.data&&e.data.guid&&e.data.isTextArt){var t=this.findDesignItemByGuid(e.data.guid);if(t){this.beginDesignOperation();var i=this.getDesignEffectForDesignItem(t),n=this.getTextArtItemInfo(e);this.allowShadows()||(n.style.shadowColor=null);var a=n.style.shadowColor;a=this.forceColorInFixedPalette(e,a),n.style.shadowColor=this.applyDesignEffectToTextColor(i,a),n.style.shadowBlur=this.adjustInputShadowBlur(e,n.style.shadowBlur),n.style.shadowDistance=this.adjustInputShadowDistance(e,n.style.shadowDistance),n.style.shadowAngle=this.adjustInputShadowDistance(e,n.style.shadowAngle),this.applyStyleToItem(e,n.style),e.data.originalShadowColor=a,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}}},_getRandomColor:function(){return"#"+(16777215*Math.random()<<0).toString(16).padStart(6,"0")},isImageAutofitEnabled:function(e){var t=this.side.get("areas").at(0),i=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(t));return!!i&&(!!i.get("printTypeRestrictions")&&1==i.get("printTypeRestrictions").get("upload"==e?"imageInsertScalingUpload":"imageInsertScalingCliparts"))},isFixedFontListEnabled:function(e){var t,i=this.side.get("areas").at(0),n=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(i));return!!n&&(!!n.get("printTypeRestrictions")&&(null===(t=n.get("printTypeRestrictions").get("fontSizeList"))||void 0===t?void 0:t.length)>0)},insertImageById:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a;return __generator(this,function(r){switch(r.label){case 0:return i=this,(n=new MPlaza.Image).set("imageID",e),[4,new Promise(function(e){n.fetch({success:function(t){e(t)}})})];case 1:return a=r.sent(),[4,i.insertImage(a,t)];case 2:return r.sent(),[2]}})})},insertImage:function(e,t){var i;return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S,b;return __generator(this,function(w){switch(w.label){case 0:return n=null,e&&e instanceof MPlaza.Image?this.canAddImage()?(this.beginDesignOperation(),a="",!this.isImageScalingEnabled&&"svg"!=e.get("format").toLowerCase()&&"vector"!=e.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(t){return t==e.get("format").toLowerCase()})&&(a=e.get("url")),a||(a=e.get("previewUrl")),e.get("overridePreview")&&(null===(i=e.get("connectorSettings"))||void 0===i?void 0:i.length)>0&&(a=e.get("overridePreview")),a?this.side&&(r=this.side.get("areas").getMaxArea())?(o=a,s=this.getDesignEffectForArea(r),[4,this.applyDesignEffectToImageUrl(s,a)]):[3,7]:[2]):[2]:[2];case 1:return a=w.sent(),t?[3,3]:[4,this.getImageDefaultColorMappings(a,null)];case 2:t=w.sent(),w.label=3;case 3:return t&&t.length>0?[4,this.recolorImage(a,t)]:[3,5];case 4:a=w.sent(),w.label=5;case 5:return[4,this.createRasterItem(a)];case 6:(n=w.sent()).data.originalUrl=o,this.applyDesignEffectToItem(s,n),l=this.onItemCreated(n,e),this.updateDesignItemColorMappings(l,t),h=this.getCurrentModel(),(d=this.findItemForArea(r))&&(n.position=d.interiorPoint,c=d.bounds,d instanceof paper.CompoundPath&&d.children.length>0?(u=d.children.sort(function(e,t){return Math.abs(t.area)-Math.abs(e.area)}).at(0),n.position=u.interiorPoint,d.contains(n.position)||(n.position=d.interiorPoint),c=u.bounds):n.position=d.interiorPoint,g=n.bounds,(c.intersects(g)||g.contains(c))&&(f=!1,(e.get("customerID")>0||e.get("visitorID")>0)&&(f=!0),(e.get("visitorCode")||e.get("customerCode"))&&(f=!0),p=this.isImageAutofitEnabled(f?"upload":"cliparts")?1:.8,(m=c.clone()).width*=p,m.height*=p,v=1,I=1,Math.abs(m.width)>1e-7&&(v=m.width/g.width),Math.abs(m.height)>1e-7&&(I=m.height/g.height),y=v>0?1:-1,C=I>0?1:-1,v=I=this.isImageAutofitEnabled(f?"upload":"cliparts")?Math.max(Math.abs(v),Math.abs(I)):Math.min(Math.abs(v),Math.abs(I)),v*=y,I*=C,h&&this.design&&this.design instanceof MPlaza.Design&&h.get("printTypes")instanceof MPlaza.PrintTypes&&this.isImagesFixedSizeEnabled()&&l.get("imagePreferredWidth")&&l.get("imagePreferredHeight")&&(M=this.side.get("ppcm"),x=M/10,S=l.get("imagePreferredWidth")*x,b=l.get("imagePreferredHeight")*x,v=S/g.width,I=b/g.height),n.scale(v,I),n.data.originalBounds=new this.paper.Rectangle(0,0,n.width,n.height),n.data.originalMatrix=n.matrix.clone(),this.onItemUpdated(n),this.onDesignItemChanged(n))),this.masterGroup.addChild(n),this.onItemUpdated(n),this.updateItemsIndexes(),this.onDesignItemChanged(n),this.fireImageLoadedEvent(),this.mask&&this.mask.bringToFront(),this.endDesignOperation(),w.label=7;case 7:return[2,n]}})})},isImagesFixedSizeEnabled:function(){var e,t,i=this.side.get("areas").at(0);if(i){var n=this.getCurrentModel(),a=this.getSelectedPrintType(i),r=n.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(i));a||(a=n.get("printTypes").getPrintType(this.design.getSelectedPrintTypeForArea(i)));var o=null;if(a instanceof MPlaza.PartPrintType){var s=a.get("restrictions");o=s?s.get("useImagesFixedSize"):null}return null==o&&(o=null!==(e=null==r?void 0:r.get("useImagesFixedSize"))&&void 0!==e?e:null===(t=r.get("printTypeRestrictions"))||void 0===t?void 0:t.get("useImagesFixedSize")),o}return!1},replaceSelectedImage:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n;return __generator(this,function(a){switch(a.label){case 0:return e&&e instanceof MPlaza.Image&&this.design&&e.get("previewUrl")?(i=this.getSelectedImageItems())&&i.length>0?(n=i[0],this.canEditItem(n)?[4,this.replaceImage(n,e,t)]:[2,n]):[3,2]:[2,null];case 1:return a.sent(),[2,n];case 2:return[2,null]}})})},replaceImageByGuid:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(a){switch(a.label){case 0:return(n=this.findItemByGuid(e))?[4,this.replaceImage(n,t,i)]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2,n]}})})},replaceImage:function(e,t,i){var n,a;return __awaiter(this,void 0,void 0,function(){var r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x;return __generator(this,function(S){switch(S.label){case 0:return this.canEditItem(e)?(r=t.get("previewUrl"),t.get("overridePreview")&&(null===(n=t.get("connectorSettings"))||void 0===n?void 0:n.length)>0&&(r=t.get("overridePreview")),r?(e.data.isTemplateElement&&(e.data.isTemplateElement=!1),this.beginDesignOperation(),o=this.findDesignItemByGuid(e.data.guid),e.data.isSVGRecolored&&(e.data.isSVGRecolored=!1),e.data.isProfanityCheckInvalid=!1,this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),o&&(o.get("imageID")!==t.get("imageID")||r.startsWith("data:")||(null===(a=t.get("connectorSettings"))||void 0===a?void 0:a.length)>0)?(this.getMaskedImageShapeItem(e),(s=this.getMaskedImageRasterItem(e))?(l=s.width,h=s.height,s.data.originalBounds&&s.data.originalMatrix&&((d=new this.paper.Path.Rectangle(s.data.originalBounds)).visible=!1,d.matrix=s.data.originalMatrix.clone(),c=this.getRectangleItemSize(d),d.remove(),l=c.width,h=c.height),u=s.matrix,g=this.getDesignEffectForDesignItem(o),f=r,[4,this.applyDesignEffectToImageUrl(g,r)]):[3,7]):[3,7]):[2,e]):[2,e];case 1:return r=S.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(r,e)];case 2:i=S.sent(),S.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(r,i)]:[3,5];case 4:r=S.sent(),S.label=5;case 5:return[4,this.changeRasterItem(s,r)];case 6:S.sent(),s.data.originalUrl=f,this.applyDesignEffectToItem(g,e),s.matrix=u,(p=new this.paper.Path.Rectangle(0,0,s.width,s.height)).visible=!1,p.matrix=u.clone(),m=this.getRectangleItemSize(p),p.remove(),v=1,I=1,this.isImagesFixedSizeEnabled()&&t.get("preferredWidth")&&t.get("preferredHeight")?(y=this.side.get("ppcm")/10,m.width=t.get("preferredWidth")*y,m.height=t.get("preferredHeight")*y,v=m.width/e.bounds.width,I=m.height/e.bounds.height):(C=m.width,M=m.height,C==l&&M==h||(Math.abs(C)>1e-7&&(v=l/C),Math.abs(M)>1e-7&&(I=h/M))),x=Math.min(v,I),s.scale(x,x),o.get("colors").reset(),this.updateDesignItemColorMappings(o,i),this.onImageItemUpdated(e,t,this.createDummyShapeFromDesignItem(o)),this.updateSelectionState(),this.paper.project.view.update(),this.fireImageLoadedEvent(),S.label=7;case 7:return this.endDesignOperation(),[2,e]}})})},updateItemsIndexes:function(){var e=this;console.log("ZAKEKE SAFARI BUG update item indexes");var t=this.getDesignItemsOnSide().sort(function(e,t){return e.get("index")>t.get("index")}).map(function(t){return e.findItemForDesignItem(t)});t.forEach(function(t){null==t||t.bringToFront(),e.updateShapeImagePlaceholder(t)});var i=t.filter(function(t){return e.isAlwaysOnTop(t)});i.forEach(function(e){return e.bringToFront()});var n=t.filter(function(t){return e.isAlwaysOnBottom(t)});n.reverse().forEach(function(e){e.sendToBack()}),this.isViewer||(i.forEach(function(t){return e.onItemUpdated(t)}),n.forEach(function(t){return e.onItemUpdated(t)})),this.getAllGridItems().forEach(function(e){return e.sendToBack()});var a=this.getAllItems().filter(function(e){return e.data&&e.data.isGroupForBackground});a.forEach(function(e){return e.sendToBack()}),a.forEach(function(t){return t.children.forEach(function(t){t.data&&(t.data.isImageForBackground||t.data.isAreaForBackground)&&(t.sendToBack(),e.isViewer||e.onItemUpdated(t))})});var r=[];!function e(t){if(null==t?void 0:t.children)for(var i=0;i<t.children.length;i++){var n=t.children[i];n.data&&n.data.isGroupForBackground?r.push(n):e(n)}}(this.masterGroup),r.forEach(function(e){e.sendToBack()})},getDesignItemsOnSide:function(){var e=this,t=this.design.getSideDesignItems(this.side);return this.getAllDesignItemsArray().forEach(function(i){var n=!1;t.some(function(e){return i.id===e.id})||(n=e.isDesignItemIntoMasterGroup(i)),n&&t.push(i)}),t},getAllDesignItemsArray:function(){for(var e=[],t=this.design.get("designItems"),i=0;i<t.length;i++){var n=t.at(i);e.push(n)}return e},isDesignItemIntoMasterGroup:function(e){var t=!1;return this.masterGroup&&this.masterGroup.children.forEach(function(i){var n;if(null===(n=null==i?void 0:i.data)||void 0===n?void 0:n.guid){var a=i.data.guid;e.id===a&&(t=!0)}}),t},getRectangleItemSize:function(e){var t=0,i=0,n=e.segments;if(4==n.length){var a=n[0].point,r=n[1].point,o=n[2].point;n[3].point;t=o.subtract(r).length,i=a.subtract(r).length}return new this.paper.Size(t,i)},modifySelectedImageElementColors:function(e){return __awaiter(this,void 0,void 0,function(){var t,i;return __generator(this,function(n){switch(n.label){case 0:return(t=this.getSelectedItems())&&t.length>0?(i=t[0],[4,this.modifyImageElementColors(i,e)]):[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},setImageSizeManually:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h,d,c;return __generator(this,function(u){return(i=this.getSelectedItems())&&i.length>0&&(n=i[0],a=this.side.get("ppcm"),r=n.bounds.height/n.bounds.width,o=e,s=t,e||t?(e?t||(s=e*r):o=t/r,o=o*a*("cm"===this.unitOfMeasurement?1:2.54),s=s*a*("cm"===this.unitOfMeasurement?1:2.54)):(o=n.bounds.width,s=n.bounds.height),l=o/n.bounds.width,h=s/n.bounds.height,n.scale(l,h),n.data.originalMatrix&&(d=n.bounds.center,c=(new this.paper.Matrix).scale(l,h,d),n.data.originalMatrix.prepend(c)),n.data.needsTransformsDataUpdate=!0,this.onItemUpdated(n),this.onDesignItemChanged(n),this.deselectAll(),this.setItemSelection(n,!0)),[2]})})},modifyImageElementColors:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h,d,c,u,g,f,p,m,v;return __generator(this,function(I){switch(I.label){case 0:if(i=this.getMaskedImageRasterItem(e),n=this.side,!(this.design&&e&&i&&"[object Array]"===Object.prototype.toString.call(t)))return[3,7];if(a=this.findDesignItemByGuid(e.data.guid),r=a.clone(),!(a&&a instanceof MPlaza.DesignItem&&a.get("imageID")>0))return[3,7];for(this.beginDesignOperation(),o=a.get("imageID"),(s=new MPlaza.RecoloredImage).set("imageID",o),s.set("versionKey","preview"),l=0;l<t.length;l++)(v=t[l])instanceof MPlaza.ColorChange?s.get("colorChanges").push(v):v.hasOwnProperty("colorID")&&v.hasOwnProperty("code")&&(h=new MPlaza.ColorChange(v),s.get("colorChanges").push(h));return[4,new Promise(function(e,t){s.save(null,{success:function(i,n,a){i&&i.get("imageID")?e(s.get("imageUrl")):t("Errore nella lettura dei dati! "+i.get("message"))},error:function(e,i,n){t("Errore nella lettura dei dati")}})})];case 1:return(d=I.sent())&&this.side==n?(c=i.matrix,u=d,g=this.getDesignEffectForDesignItem(a),f=u,[4,this.applyDesignEffectToImageUrl(g,u)]):[3,7];case 2:return u=I.sent(),[4,this.getImageDefaultColorMappings(u,e)];case 3:return(p=I.sent())&&p.length>0?[4,this.recolorImage(u,p)]:[3,5];case 4:u=I.sent(),I.label=5;case 5:return this.updateDesignItemColorMappings(a,p),[4,this.changeRasterItem(i,u)];case 6:for(I.sent(),i.data.originalUrl=f,this.applyDesignEffectToItem(g,e),i.matrix=c,m=0;m<t.length;m++)(v=t[m])instanceof MPlaza.ColorChange?(a.changeColor(o,v.get("colorID"),v.get("code")),e.data.isSVGRecolored=!0):v.hasOwnProperty("colorID")&&v.hasOwnProperty("code")&&(a.changeColor(o,v.colorID,v.code),e.data.isSVGRecolored=!0);this.updateDesignItemColors(a,a.get("colors").map(function(e){return e.get("colorCode")})),this.registerItemOperation("update",a.get("itemGuid"),r,a),console.log("item: ",e),this.onItemUpdated(e),this.onDesignItemChanged(e),this.updateSelectionState(),this.paper.project.view.update(),this.fireImageLoadedEvent(),this.endDesignOperation(),I.label=7;case 7:return[2]}})})},modifySelectedImageElementsColors:function(e){if(this.design&&"[object Array]"===Object.prototype.toString.call(e)){var t=this,i=this.getSelectedImageItems();if(0==i.length)return;this.beginDesignOperation();for(var n=null,a={},r=0;r<i.length;r++){var o=i[r],s=this.findDesignItemByGuid(o.data.guid),l=s.get("imageID");if(null==n)n=l;else if(n!=l)return;a[o.data.guid]=s}try{var h=new MPlaza.RecoloredImage;h.set("imageID",n),h.set("versionKey","preview");for(r=0;r<e.length;r++){var d=e[r];if(d instanceof MPlaza.ColorChange)h.get("colorChanges").push(d);else if(d.hasOwnProperty("colorID")&&d.hasOwnProperty("code")){var c=new MPlaza.ColorChange(d);h.get("colorChanges").push(c)}}h.save(null,{success:function(r,o,s){r&&r.get("imageID")?(Logger.info("Immagine letta correttamente"),function(r,o){if(r)for(var s,l,h,d="data:image/png;base64,"+r,c=function(){s=i[u],l=a[s.data.guid],t.updateDesignItemColors(l,o);var r=t.getMaskedImageRasterItem(s);h=r.matrix,r.crossOrigin="anonymous",r.source=d,r.onLoad=function(){r.matrix=h;for(var i=0;i<e.length;i++){var a=e[i];a instanceof MPlaza.ColorChange?l.changeColor(n,a.get("colorID"),a.get("code")):a.hasOwnProperty("colorID")&&a.hasOwnProperty("code")&&l.changeColor(n,a.colorID,a.code)}t.onItemUpdated(s),t.updateSelectionState(),t.paper.project.view.update(),t.fireImageLoadedEvent(),this.beginDesignOperation()}},u=0;u<i.length;u++)c()}(h.get("imageData"),h.get("imageColors"))):Logger.info("Errore nella lettura dei dati! "+r.get("message"))},error:function(e,t,i){Logger.info("Errore nella lettura dei dati")}})}catch(e){Logger.info(e)}}},setEditingItem:function(e,t){if(e&&null!=t&&(this.removeLoadingCircle(e),t)){var i=this.getAreasIntersectingOrContainingItem(e);i&&i.length>0&&this.createLoadingCircle(e,e.bounds.center)}},createLoadingCircle:function(e,t){if(!t)return null;var i=25/this.paper.view.zoom,n=Zakeke.config.baseUrl+"/assets/customizer/images/customizer/loading-circle.png",a=new this.paper.Raster({source:n,position:t}),r=function(){var e=a.size,t=new this.paper.Size(i,i),n=1,r=1;Math.abs(e.width)>1e-7&&(n=t.width/e.width),Math.abs(e.height)>1e-7&&(r=t.height/e.height),a.scale(n,r)};return a.size.width>0&&a.size.height>0?r():a.onLoad=function(){r()},a.data.isLoadingCircle=!0,e.loadingCircle=a,this.loadingCircles.push(a),a},removeLoadingCircle:function(e){if(e&&e.hasOwnProperty("loadingCircle")&&e.loadingCircle){var t=e.loadingCircle;this.loadingCircles=this.loadingCircles.filter(function(e){return e!=t}),t.remove(),e.loadingCircle=null}},getItemIsImage:function(e){return this.isImage(e)||this.isMaskedImage(e)},scaleBgImage:function(e,t){this.beginDesignOperation();var i=this.getOrCreateBackgroundGroupItem(e).children.find(function(e){return e.data&&e.data.isImageForBackground});i&&(i.scaling=new this.paper.Point(t,t),this.onItemUpdated(i),this.updateSelectionState(),this.paper.view.update(),this.endDesignOperation())},insertImageAsBackground:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C=this;return __generator(this,function(M){switch(M.label){case 0:return n=null,a=null,e&&e instanceof MPlaza.Image?(r=this.findItemForArea(t),o=this.getOrCreateBackgroundGroupItem(r),(s=o.children.find(function(e){return e.data&&e.data.isAreaForBackground}))&&((u=this.findDesignItemForItem(s))&&(a=u.get("syncGuid")),s.remove(),this.onItemRemoved(s)),l="",!this.isImageScalingEnabled&&"svg"!=e.get("format").toLowerCase()&&"vector"!=e.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(t){return t==e.get("format").toLowerCase()})&&(l=e.get("url")),l||(l=e.get("previewUrl")),l?this.side&&t?(this.beginDesignOperation(),h=l,d=this.getDesignEffectForArea(t),[4,this.applyDesignEffectToImageUrl(d,l)]):[3,7]:[2,n]):[2,n];case 1:return l=M.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(l,null)];case 2:i=M.sent(),M.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(l,i)]:[3,5];case 4:l=M.sent(),M.label=5;case 5:return[4,this.createRasterItem(l,!1)];case 6:(n=M.sent()).data.originalUrl=h,this.applyDesignEffectToItem(d,n),n.data.originalImageID=e.id,n.data.isImageForBackground=!0,n.data.areaGuid=o.data.areaGuid,c=null,o.children.filter(function(e){return e.data.isImageForBackground}).forEach(function(e){var t=C.findDesignItemForItem(e);t&&(a=t.get("syncGuid"),c=t.get("constraints")),e.remove(),C.onItemRemoved(e)}),this.onItemCreated(n,e),(u=this.findDesignItemForItem(n)).set("syncGuid",a),this.updateDesignItemColorMappings(u,i),c&&u.setConstraintsFromSource(c),r&&(n.position=r.position,g=n.bounds,((f=r.bounds).intersects(g)||g.contains(f))&&(p=f.clone(),m=1,v=1,Math.abs(p.width)>1e-7&&(m=p.width/g.width),Math.abs(p.height)>1e-7&&(v=p.height/g.height),I=m>0?1:-1,y=v>0?1:-1,m=v=Math.max(Math.abs(m),Math.abs(v)),m*=I,v*=y,n.scale(m,v),n.visible=!0,n.data.initialScaleX=m,n.data.initialScaleY=v,n.data.originalBounds=new this.paper.Rectangle(0,0,n.width,n.height),n.data.originalMatrix=n.matrix.clone())),o.addChild(n),this.updateItemsIndexes(),this.onItemUpdated(n),this.onDesignItemChanged(n),this.fireImageLoadedEvent(),this.endDesignOperation(),M.label=7;case 7:return[2,n]}})})},removeBackgroundColorArea:function(e){var t=this;this.beginDesignOperation();var i=this.getOrCreateBackgroundGroupItem(e);i.children.forEach(function(e){if(e.data.isImageForBackground||e.data.isAreaForBackground){var i=t.findDesignItemForItem(e);t.fireDesignItemRemovingEvent(i,e),e.remove(),t.onItemRemoved(e)}}),i.remove(),this.endDesignOperation()},updateBackgroundGroupSize:function(e){var t=this.getOrCreateBackgroundGroupItem(e),i=t.children.find(function(e){return e instanceof paper.CompoundPath});if(i){i.remove();var n=e.clone();n.data={guid:MPlaza.generateUUID(),areaGuid:e.data.guid,isClippingAreaForBackground:!0},n.strokeWidth=0,n.visible=!0,t.addChild(n),n.sendToBack(),t.clipped=!0,n.bringToFront()}},changeBackgroundColorArea:function(e,t,i){this.beginDesignOperation();var n=this,a=null,r=this.getOrCreateBackgroundGroupItem(e);r.children.forEach(function(e){if(e.data.isImageForBackground||e.data.isAreaForBackground){var t=n.findDesignItemForItem(e);t&&(a=t.get("syncGuid")),e.remove(),i(e),n.onItemRemoved(e)}});var o=r.children.find(function(e){return e.data&&e.data.isAreaForBackground});if(!o){var s=Math.max(r.children[0].bounds.width,r.children[0].bounds.height);o=new this.paper.Path.Rectangle(r.children[0].bounds.point,new this.paper.Size(s,s));var l=new this.paper.Point(o.position.x-(s-r.children[0].bounds.width)/2,o.position.y-(s-r.children[0].bounds.height)/2);o.position=l,o.data={guid:MPlaza.generateUUID(),areaGuid:e.data.guid,isAreaForBackground:!0},o.strokeWidth=0,o.visible=!0,r.addChild(o),this.onItemCreated(o)}var h=n.findDesignItemForItem(o);h.set("syncGuid",a),o.fillColor=t;var d=this.getDesignEffectForDesignItem(h);return this.applyDesignEffectToItem(d,o),this.onItemUpdated(o),this.endDesignOperation(),o},getOrCreateBackgroundGroupItem:function(e){var t=this.getBackgroundItem(e);if(!t){var i=e.clone();i.data={guid:MPlaza.generateUUID(),areaGuid:e.data.guid,isClippingAreaForBackground:!0},i.strokeWidth=0,i.visible=!0,(t=new this.paper.Group(i)).clipped=!0,t.data={guid:MPlaza.generateUUID(),areaGuid:e.data.guid,isGroupForBackground:!0},t.addChild(i),this.masterGroup.addChild(t),t.sendToBack()}return t},getBackgroundItem:function(e){var t;return function i(n){var a,r,o;if(n&&n.children)for(var s=0;s<n.children.length;s++){var l=n.children[s];if((null==l?void 0:l.data)&&(null===(a=null==l?void 0:l.data)||void 0===a?void 0:a.areaGuid)===(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.guid)&&(null===(o=null==l?void 0:l.data)||void 0===o?void 0:o.isGroupForBackground))return void(t=l);i(l)}}(this.masterGroup),t},getAreasWithBackground:function(){var e=this,t=[];return this.side&&this.side.get("areas").each(function(i,n){var a=e.findItemByGuid(i.get("guid")),r=e.getBackgroundItem(a),o=null==r?void 0:r.children.find(function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.isImageForBackground});o?e.canEditItem(o)&&t.push(i):t.push(i)}),t},getAreasNoColorBackgroundChange:function(){var e=this,t=[];return this.side&&this.side.get("areas").each(function(i,n){var a=e.findItemByGuid(i.get("guid")),r=e.getBackgroundItem(a),o=null==r?void 0:r.children.find(function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.isImageForBackground});if(o){var s=e.canEditItem(o),l=e.canDeleteItem(o);s&&!l&&t.push(i)}}),t},getAllTextItems:function(){var e=this;return this.getAllItems().filter(function(t){return e.getItemIsTextElement(t)})},setEditTextCallback:function(e){this.editTextCallback=e},textInfoModified:function(e){e&&this.mouseStartPos&&(this.element?this.modifyTextElement(this.element,e):this.addTextElement(this.mouseStartPos,e),this.element=null)},createText:function(e){if(this.canAddText()&&this.editTextCallback){var t={text:"",strokeColor:null,strokeWidth:0,fillColor:"#000000",fontFamily:"Arial",fontSize:12,fontWeight:"normal",justification:"left",shadowColor:null,shadowBlur:0,shadowDistance:7,shadowAngle:45},i=this;this.editTextCallback(t,function(e){i.textInfoModified(e)})}},editText:function(){if(this.selectElement(),this.canEditSelection()&&this.element&&this.element instanceof this.paper.TextItem&&this.editTextCallback){var e={};e.text=this.element.content,e.strokeColor=this.element.strokeColor.toCSS(!0),e.strokeWidth=this.element.strokeWidth,e.fillColor=this.element.fillColor.toCSS(!0),e.fontFamily=this.element.fontFamily,e.fontSize=this.element.fontSize,e.fontWeight=this.element.fontWeight,e.justification=this.element.justification,e.shadowColor=this.element.shadowColor,e.shadowBlur=this.element.shadowBlur,e.shadowDistance=this.getOffsetDistance(this.element.shadowOffset),e.shadowAngle=this.getOffsetAngle(this.element.shadowOffset);var t=this;this.editTextCallback(e,function(e){t.textInfoModified(e)})}},addTextElement:function(e,t,i,n){if(void 0===i&&(i=!1),void 0===n&&(n=null),!i&&!this.canAddText())return null;var a=null;if(this.side){var r=this.side.get("areas").getMaxArea();if(r){var o=this.getDesignEffectForArea(r);if(t&&t.text){this.beginDesignOperation(),this.deselectAll(),this.updateSelectionState(),this.allowShadows()||(t.shadowColor=null);var s=t.strokeColor||null,l=t.fillColor||"#000000",h=t.shadowColor||null;if(s=this.forceColorInFixedPalette(null,s),l=this.forceColorInFixedPalette(null,l),h=this.forceColorInFixedPalette(null,h),t.shadowBlur=this.adjustInputShadowBlur(null,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(null,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(null,t.shadowAngle),t.strokeWidth=this.adjustInputTextStrokeWidth(null,t.strokeWidth),null!=t.fontSize&&null!=t.fontSize&&"string"==typeof t.fontSize&&(t.fontSize=parseInt(t.fontSize)),a=new this.paper.PointText({rotation:t.rotation||0,content:t.text,strokeColor:this.applyDesignEffectToTextColor(o,s),strokeWidth:null!=t.strokeWidth?t.strokeWidth:0,strokeJoin:this.strokeJoinText,fillColor:this.applyDesignEffectToTextColor(o,l),fontFamily:this.sanitizeFontFamilyName(t.fontFamily)||"Verdana",fontWeight:t.fontWeight||"normal normal",fontStretch:t.fontStretch||"normal",fontStyle:t.fontStyle||"normal",fontSize:t.fontSize||48,justification:t.justification||"center",shadowColor:t.shadowColor||null,shadowBlur:t.shadowBlur||0,shadowOffset:this.getOffsetByDistanceAngle(t.shadowDistance,t.shadowAngle),lineSpacing:t.lineSpacing,letterSpacing:t.letterSpacing}),n){var d=.75*n;a.fontSize=d}if(a.fontSize=this.adjustTextFontSize(a,a.fontSize),a.data={},a.data.isText=!0,a.data.originalStrokeColor=s,a.data.originalFillColor=l,a.data.originalShadowColor=h,this.applyDesignEffectToItem(o,a),this.masterGroup.addChild(a),null==e)if(r){var c=this.findItemForArea(r);if(c){a.position=c.interiorPoint;var u=c.bounds;if(c instanceof paper.CompoundPath&&c.children.length>0){var g=c.children.sort(function(e,t){return Math.abs(t.area)-Math.abs(e.area)}).at(0);a.position=g.interiorPoint,c.contains(a.position)||(a.position=c.interiorPoint),u=g.bounds}else a.position=c.interiorPoint;if(a.bounds.height>0&&u.height>0){if(a.bounds.height>u.height){var f=c.bounds.height/a.bounds.height;f=this.adjustTextFontScaling(a,f),a.scale(f)}if(!n&&a.bounds.height/u.height<.2){f=.2*u.height/a.bounds.height;f=this.adjustTextFontScaling(a,f),a.scale(f)}}if(!n){var p=this.getFontSizeList();if(p&&p.length>0)a.fontSize=p[0]/(4*a.scaling.y/3);else{var m=this.getDefaultTextFontSizeFromMinMaxInPx(a);m>0&&(a.fontSize=m)}}}}else a.position=this.paper.view.center;else a.position=e;if(this.onItemCreated(a),this.setItemSelection(a,!0),this.isSafari){a.visible=!1;var v=this;setTimeout(function(){a.visible=!0,v.paper.project.view.update(!0),v.updateSelectionState()},2e3)}else this.updateSelectionState(),this.paper.project.view.update(!0);t.isTextOnPath&&(a=this.convertSelectedTextItemsToTextOnPath()),this.endDesignOperation()}}}return a},modifyTextElement:function(e,t,i){if(void 0===i&&(i=!0),this.canEditItem(e)&&e){if(this.beginDesignOperation(),e.data&&e.data.isTextOnPath)this.modifyTextOnPathInfo(e,t);else if(e.data&&e.data.isTextArea)this.modifyTextAreaInfo(e,t);else{var n=null,a=this.findDesignItemForItem(e);a&&(n=this.getDesignEffectForDesignItem(a));var r=this.getItemConstraints(e);if(e.content=this.adjustInputTextByConstraints(e,t.text)||e.content,t.strokeWidth=this.adjustInputTextStrokeWidth(e,t.strokeWidth),!r||r.get("canChangeFontColor")){var o=t.strokeColor||this.convertColorToHex(e.strokeColor),s=t.fillColor||this.convertColorToHex(e.fillColor);o=this.forceColorInFixedPalette(e,o),s=this.forceColorInFixedPalette(e,s),e.strokeColor=this.applyDesignEffectToTextColor(n,o),e.fillColor=this.applyDesignEffectToTextColor(n,s),e.data.originalStrokeColor=o,e.data.originalFillColor=s}if(!r||r.get("canChangeShadowColor")){var l=t.shadowColor||this.convertColorToHex(e.shadowColor);l=this.forceColorInFixedPalette(e,l),e.shadowColor=this.applyDesignEffectToTextColor(n,l),e.data.originalShadowColor=l}this.allowShadows()||(e.shadowColor=null),e.shadowBlur=this.adjustInputShadowBlur(e,t.shadowBlur),e.shadowOffset=this.getOffsetByDistanceAngle(this.adjustInputShadowDistance(e,t.shadowDistance),this.adjustInputShadowAngle(e,t.shadowAngle)),e.strokeWidth=null!=t.strokeWidth?t.strokeWidth:e.strokeWidth,r&&!r.get("canChangeFontFamily")||(e.fontFamily=this.sanitizeFontFamilyName(t.fontFamily||e.fontFamily)),e.fontWeight=this.adjustInputFontWeightByConstraints(e,t.fontWeight,r),r&&!r.get("canChangeFontSize")||(e.fontSize=t.fontSize||e.fontSize),r&&!r.get("canChangeJustification")||(e.justification=t.justification||e.justification),t.scaling&&(e.scaling=t.scaling),t.rotation&&(e.rotation=t.rotation)}this.onItemUpdated(e),this.onDesignItemChanged(e),i&&this.setItemSelection(e,!0),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}},modifyTextElements:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElement(e[i],t);else this.modifyTextElement(e,t)},modifyTextElementContentByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementContent(i,t)},modifyTextElementContent:function(e,t){if(this.canEditItem(e)&&!this.sameTextElementContent(e,t)){var i=null;this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.content=this.adjustInputTextByConstraints(e,t),e.data.needsTransformsDataUpdate=!0,e.data.isProfanityCheckInvalid=!1,this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),this.updateSelectionState(),this.paper.project.view.update(),this.onItemUpdated(e),this.onDesignItemChanged(e)):e&&e.data&&e.data.isTextOnPath?(i={text:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.onDesignItemChanged(e)):e&&e.data&&e.data.isTextArea&&(i={text:t},this.modifyTextAreaInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.onDesignItemChanged(e)),this.endDesignOperation()}},modifyTextElementsContent:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementContent(e[i],t);else this.modifyTextElementContent(e,t)},setIsPlaceHolderItem:function(e,t){e.data.isPlaceHolder=t;var i=this.findDesignItemByGuid(e.data.guid),n=e.exportJSON({asString:!0});i.set("json",n)},setIsPlaceHolderItems:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.setIsPlaceHolderItems(e[i],t);else this.setIsPlaceHolderItem(e,t)},sameTextElementContent:function(e,t){var i=this.getTextItemInfo(e);if(i){var n=this.adjustInputTextByConstraints(e,t);if(i.text===n)return!0}return!1},modifyTextElementFillColorByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementFillColor(i,t)},modifyTextElementStrokeColorByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementStrokeColor(i,t)},modifyTextElementStrokeColor:function(e,t){if(this.canChangeTextStrokeColor(e)){var i=void 0,n=this.getTextItemInfo(e);n&&n.strokeColor&&(n.strokeColor instanceof this.paper.Color?i=n.strokeColor.toCSS(!0):"string"==typeof n.strokeColor&&(i=n.strokeColor));var a=null;this.beginDesignOperation();var r=null,o=this.findDesignItemForItem(e);if(o&&(r=this.getDesignEffectForDesignItem(o)),e&&e instanceof this.paper.TextItem){var s=t;s=this.forceColorInFixedPalette(e,s,i);var l=this.applyDesignEffectToTextColor(r,s);e.strokeColor=l,e.data.needsTransformsDataUpdate=!0,e.data.originalStrokeColor=s,this.paper.project.view.update(),this.onItemUpdated(e)}else e&&e.data&&e.data.isTextOnPath?(a={strokeColor:t},this.modifyTextOnPathInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(a={strokeColor:t},this.modifyTextAreaInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation()}},modifyTextElementsStrokeColor:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementStrokeColor(e[i],t);else this.modifyTextElementStrokeColor(e,t)},modifyTextElementStrokeWidth:function(e,t){if(this.canChangeTextStrokeWidth(e)){t=this.adjustInputTextStrokeWidth(e,t);var i=null,n=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.strokeWidth=t,e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()):e&&e.data&&e.data.isTextOnPath?(i={strokeWidth:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={strokeWidth:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsStrokeWidth:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementStrokeWidth(e[i],t);else this.modifyTextElementStrokeWidth(e,t)},modifyTextElementFillColor:function(e,t){if(this.canChangeItemFontColor(e)){var i=void 0,n=this.getTextItemInfo(e);if(n&&n.fillColor&&(n.fillColor instanceof this.paper.Color?i=n.fillColor.toCSS(!0):"string"==typeof n.fillColor&&(i=n.fillColor)),!i||i!==t){var a=null;this.beginDesignOperation();var r=null,o=this.findDesignItemForItem(e);if(o&&(r=this.getDesignEffectForDesignItem(o)),e&&e instanceof this.paper.TextItem){var s=t;s=this.forceColorInFixedPalette(e,s,i);var l=this.applyDesignEffectToTextColor(r,s);e.fillColor=l,e.data.needsTransformsDataUpdate=!0,e.data.originalFillColor=s,this.paper.project.view.update(),this.onItemUpdated(e)}else e&&e.data&&e.data.isTextOnPath?(a={fillColor:t},this.modifyTextOnPathInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(a={fillColor:t},this.modifyTextAreaInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation()}}},modifyTextElementsFillColor:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFillColor(e[i],t);else this.modifyTextElementFillColor(e,t)},modifyTextElementShadowColorByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementShadowColor(i,t)},modifyTextElementShadowColor:function(e,t){if(this.canChangeItemShadowColor(e)){this.allowShadows()||(t=null);var i=void 0,n=this.getTextItemInfo(e);if(n&&n.shadowColor&&(n.shadowColor instanceof this.paper.Color?i=n.shadowColor.toCSS(!0):"string"==typeof n.shadowColor&&(i=n.shadowColor)),!i||i!==t){var a=null;this.beginDesignOperation();var r=null,o=this.findDesignItemForItem(e);if(o&&(r=this.getDesignEffectForDesignItem(o)),e&&e instanceof this.paper.TextItem){var s=t;s=this.forceColorInFixedPalette(e,s,i);var l=this.applyDesignEffectToTextColor(r,s);e.shadowColor=l,e.data.needsTransformsDataUpdate=!0,e.data.originalShadowColor=s,this.paper.project.view.update(),this.onItemUpdated(e)}else e&&e.data&&e.data.isTextOnPath?(a={shadowColor:t},this.modifyTextOnPathInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(a={shadowColor:t},this.modifyTextAreaInfo(e,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation()}}},modifyTextElementsShadowColor:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementShadowColor(e[i],t);else this.modifyTextElementShadowColor(e,t)},modifyTextElementShadowBlur:function(e,t){if(this.canChangeItemShadowBlur(e)){t=this.adjustInputShadowBlur(e,t);var i=null,n=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.shadowBlur=t,e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()):e&&e.data&&e.data.isTextOnPath?(i={shadowBlur:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={shadowBlur:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsShadowBlur:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementShadowBlur(e[i],t);else this.modifyTextElementShadowBlur(e,t)},modifyTextElementShadowDistance:function(e,t){if(this.canChangeItemShadowDistance(e)){t=this.adjustInputShadowDistance(e,t);var i=null,n=this.getLastUndoOperationId();if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem){var a=this.getOffsetAngle(e.shadowOffset);e.shadowOffset=this.getOffsetByDistanceAngle(t,a),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()}else e&&e.data&&e.data.isTextOnPath?(i={shadowDistance:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={shadowDistance:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsShadowDistance:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementShadowDistance(e[i],t);else this.modifyTextElementShadowDistance(e,t)},modifyTextElementShadowAngle:function(e,t){if(this.canChangeItemShadowAngle(e)){t=this.adjustInputShadowAngle(e,t);var i=null,n=this.getLastUndoOperationId();if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem){var a=this.getOffsetDistance(e.shadowOffset);e.shadowOffset=this.getOffsetByDistanceAngle(a,t),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()}else e&&e.data&&e.data.isTextOnPath?(i={shadowAngle:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={shadowAngle:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsShadowAngle:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementShadowAngle(e[i],t);else this.modifyTextElementShadowAngle(e,t)},resetTextElementShadow:function(e){if(e&&e.data&&e.data.guid){var t=this.findDesignItemForItem(e),i=this.getTextItemInfo(e);if(t&&i){var n=this.getLastUndoOperationId();if(this.beginDesignOperation(),this.allowShadows()||(i.shadowColor=null),i.shadowBlur=this.adjustInputShadowBlur(e,i.shadowBlur),i.shadowDistance=this.adjustInputShadowDistance(e,i.shadowDistance),i.shadowAngle=this.adjustInputShadowAngle(e,i.shadowAngle),e instanceof this.paper.TextItem){var a=this.getDesignEffectForDesignItem(t),r=i.shadowColor;r=this.forceColorInFixedPalette(e,r),i.shadowColor=this.applyDesignEffectToTextColor(a,r),e.shadowColor=i.shadowColor,e.shadowBlur=i.shadowBlur,e.shadowDistance=i.shadowDistance,e.shadowAngle=i.shadowAngle,e.data.needsTransformsDataUpdate=!0,e.data.originalShadowColor=r,this.paper.project.view.update(),this.onItemUpdated(e)}else e.data.isTextOnPath?(i={shadowColor:i.shadowColor,shadowBlur:i.shadowBlur,shadowDistance:i.shadowDistance,shadowAngle:i.shadowAngle},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e.data.isTextArea&&(i={shadowColor:i.shadowColor,shadowBlur:i.shadowBlur,shadowDistance:i.shadowDistance,shadowAngle:i.shadowAngle},this.modifyTextAreaInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}}},sanitizeFontFamilyName:function(e){return'"'+e.replace(/"/g,"")+'"'},modifyTextElementFontFamilyByGuid:function(e,t){var i=this.findItemByGuid(e);i&&this.modifyTextElementFontFamily(i,t)},modifyTextElementFontFamily:function(e,t){if(this.canChangeItemFontFamily(e)&&!this.sameTextElementFontFamily(e,t)){var i=null,n=this.getLastUndoOperationId();if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem)if(e.fontFamily=this.sanitizeFontFamilyName(t),e.data.needsTransformsDataUpdate=!0,this.isSafari){e.visible=!1;var a=this;setTimeout(function(){e.visible=!0,a.paper.project.view.update(!0),a.onItemUpdated(e),a.updateSelectionState()},2e3)}else this.paper.project.view.update(!0),this.onItemUpdated(e),this.updateSelectionState();else e&&e.data&&e.data.isTextOnPath?(i={fontFamily:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={fontFamily:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e));this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsFontFamily:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFontFamily(e[i],t);else this.modifyTextElementFontFamily(e,t)},sameTextElementFontFamily:function(e,t){var i=this.getTextItemInfo(e);if(i&&this.sanitizeFontFamilyName(i.fontFamily)===this.sanitizeFontFamilyName(t))return!0;return!1},modifyTextElementFontSize:function(e,t){if(this.canChangeItemFontSize(e)){var i=null,n=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.fontSize=t,e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()):e&&e.data&&e.data.isTextOnPath?(i={fontSize:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={fontSize:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n)}},modifyTextElementsFontSize:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFontSize(e[i],t);else this.modifyTextElementFontSize(e,t)},modifyTextElementFontWeight:function(e,t){if(this.canChangeItemFontWeight(e)){var i=this.getTextItemInfo(e);if(!i||i.fontWeight!==t){var n=null,a=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.fontWeight=t,e.data.needsTransformsDataUpdate=!0,this.paper.project.view.update(),this.onItemUpdated(e),this.updateSelectionState()):e&&e.data&&e.data.isTextOnPath?(n={fontWeight:t},this.modifyTextOnPathInfo(e,n),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(n={fontWeight:t},this.modifyTextAreaInfo(e,n),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}}},modifyTextElementsFontWeight:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFontWeight(e[i],t);else this.modifyTextElementFontWeight(e,t)},modifyTextElementFontStretch:function(e,t){var i=null,n=this.getTextItemInfo(e);if(!n||n.fontStretch!==t){var a=this.getLastUndoOperationId();this.beginDesignOperation(),this.beginDesignOperation(),e&&e instanceof this.paper.TextItem?(e.fontStretch=t,e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update()):e&&e.data&&e.data.isTextOnPath?(i={fontStretch:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(i={fontStretch:t},this.modifyTextAreaInfo(e,i),e.data.isTextBox&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}},modifyTextElementsFontStretch:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementFontStretch(e[i],t);else this.modifyTextElementFontStretch(e,t)},modifyTextElementJustification:function(e,t){if(this.canChangeItemJustification(e)){this.beginDesignOperation();var i=null,n=this.getTextItemInfo(e);if(!n.justification||n.justification!=t){if(e&&e instanceof this.paper.TextItem&&(e=this.fromTextToTextArea(e)),e&&e.data&&e.data.isTextOnPath)i={justification:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e);else if(e&&e.data&&e.data.isTextArea){i={justification:t};var a=e.bounds.clone();this.modifyTextAreaInfo(e,i),e.data.isTextBox||(e.position.x=a.x+a.width/2,Math.abs(e.children[0].rotation)<=90?e.position.y=a.y+e.bounds.height/2:e.position.y=a.bottom-e.bounds.height/2),this.updateSelectionState(),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)}this.endDesignOperation()}}},modifyTextElementsJustification:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementJustification(e[i],t);else this.modifyTextElementJustification(e,t)},modifyTextElementVerticalAlign:function(e,t){if(this.canChangeItemVerticalAlignment(e)){this.beginDesignOperation();var i=null,n=this.getTextItemInfo(e);if(!n.verticalAlignment||n.verticalAlignment!=t){if(e&&e instanceof this.paper.TextItem&&(e=this.fromTextToTextArea(e)),e&&e.data&&e.data.isTextOnPath)i={verticalAlignment:t},this.modifyTextOnPathInfo(e,i),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e);else if(e&&e.data&&e.data.isTextArea){i={verticalAlignment:t};var a=e.bounds.clone();this.modifyTextAreaInfo(e,i),e.data.isTextBox||(e.position.x=a.x+a.width/2,Math.abs(e.children[0].rotation)<=90?e.position.y=a.y+e.bounds.height/2:e.position.y=a.bottom-e.bounds.height/2),this.updateSelectionState(),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)}this.endDesignOperation()}}},modifyTextElementsVerticalAlign:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementVerticalAlign(e[i],t);else this.modifyTextElementVerticalAlign(e,t)},modifyTextElementAdaptText:function(e,t){if(this.canChangeItemAdaptText(e)){var i=this.getTextItemInfo(e);if(!i||null==i.adaptText||i.adaptText!==t){var n=null,a=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem||e&&e.data&&e.data.isTextOnPath||e&&e.data&&e.data.isTextArea&&(n={adaptText:t},this.modifyTextAreaInfo(e,n),e.data.isTextBox&&!e.data.adaptText&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}}},modifyTextElementsAdaptText:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementAdaptText(e[i],t);else this.modifyTextElementAdaptText(e,t)},modifyTextElementLetterSpacing:function(e,t){if(this.canChangeItemLetterSpacing(e)){var i=this.getTextItemInfo(e);if(!i||null==i.letterSpacing||i.letterSpacing!==t){var n=null,a=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem||(e&&e.data&&e.data.isTextOnPath?(n={letterSpacing:t},this.modifyTextOnPathInfo(e,n),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)):e&&e.data&&e.data.isTextArea&&(n={letterSpacing:t},this.modifyTextAreaInfo(e,n),e.data.isTextBox&&!e.data.adaptText&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e))),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}}},modifyTextElementsLetterSpacing:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementLetterSpacing(e[i],t);else this.modifyTextElementLetterSpacing(e,t)},modifyTextElementLineSpacing:function(e,t){if(this.canChangeItemLineSpacing(e)){var i=this.getTextItemInfo(e);if(!i||null==i.lineSpacing||i.lineSpacing!==t){var n=null,a=this.getLastUndoOperationId();this.beginDesignOperation(),e&&e instanceof this.paper.TextItem||e&&e.data&&e.data.isTextOnPath||e&&e.data&&e.data.isTextArea&&(n={lineSpacing:t},this.modifyTextAreaInfo(e,n),e.data.isTextBox&&!e.data.adaptText&&e.children&&0==e.children.length&&this.adaptTextBoxFontSize(e),e.data.needsTransformsDataUpdate=!0,this.onItemUpdated(e)),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(a)}}},modifyTextElementsLineSpacing:function(e,t){if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;i<e.length;i++)this.modifyTextElementLineSpacing(e[i],t);else this.modifyTextElementLineSpacing(e,t)},adjustTextFontScaling:function(e,t){var i=t;if(e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var n=this.getItemMinFontSize(e),a=this.getItemMaxFontSize(e);if(null!=n||null!=n||null!=a||null!=a){var r=this.getTextItemInfo(e);r&&(null!=n&&null!=n&&(i=Math.min(i,n/(r.fontSize*r.scaling.y*4/3))),null!=a&&null!=a&&(i=Math.max(i,a/(r.fontSize*r.scaling.y*4/3))))}}return i},getDefaultTextFontSizeFromMinMaxInPx:function(e){var t=-1;if(e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var i=this.getItemMinFontSize(e),n=this.getItemMaxFontSize(e);if(null!=i&&null!=i&&null!=n&&null!=n){var a=this.getTextItemInfo(e);a&&(t=(i/(4*a.scaling.y/3)+n/(4*a.scaling.y/3))/2)}}return t},adjustTextFontSize:function(e,t){var i=t;if(e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var n=this.getItemMinFontSize(e),a=this.getItemMaxFontSize(e);if(null!=n||null!=n||null!=a||null!=a){var r=this.getTextItemInfo(e);r&&(null!=n&&null!=n&&(i=Math.max(i,n/(4*r.scaling.y/3))),null!=a&&null!=a&&(i=Math.min(i,a/(4*r.scaling.y/3))))}}return i},canScaleSelectedTextFont:function(e,t){for(var i=this.getSelectedItems(),n=0;n<i.length;n++){var a=i[n];if(!this.canScaleTextFont(a,e,t))return!1}return!0},getScaledTextFontSizePt:function(e,t,i){if(this.getItemIsTextElement(e)){var n=this.getItemMinFontSize(e),a=this.getItemMaxFontSize(e);if(null!=n||null!=n||null!=a||null!=a){var r=this.getTextItemInfo(e);if(r){var o=Math.max(t,i);return 4*(r.fontSize*r.scaling.y*o)/3}}}return 0},canScaleTextFont:function(e,t,i){var n;if(e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var a=this.getItemMinFontSize(e),r=this.getItemMaxFontSize(e);if(null!=a||null!=a||null!=r||null!=r){var o=this.getTextItemInfo(e);if(o){var s=null!==(n=o.rotation)&&void 0!==n?n:0,l=Math.cos(this.toRadians(s)),h=Math.sin(this.toRadians(s)),d=Math.abs(l)*(i-1),c=Math.abs(h)*(t-1),u=4*(o.fontSize*o.scaling.y*(1+d+c))/3;if(null!=a&&null!=a&&u<a)return!1;if(null!=r&&null!=r&&u>r)return!1}}}return!0},toRadians:function(e){return e*(Math.PI/180)},canSetSelectedTextFontSizePx:function(e){for(var t=this.getSelectedItems(),i=0;i<t.length;i++){var n=t[i];if(!this.canSetTextFontSizePx(n,e))return!1}return!0},canSetTextFontSizePx:function(e,t){if(e&&e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){if(e.data.adaptText)return!0;var i=this.getItemMinFontSize(e),n=this.getItemMaxFontSize(e);if(null!=i||null!=i||null!=n||null!=n){var a=this.getTextItemInfo(e);if(a){a.fontSize,a.scaling.y;var r=4*t/3;if(null!=i&&null!=i&&r<i)return!1;if(null!=n&&null!=n&&r>n)return!1}}}return!0},canSetSelectedTextFontSizePt:function(e){var t=3*e/4;return this.canSetSelectedTextFontSizePx(t)},canSetTextFontSizePt:function(e,t){return this.canSetTextFontSizePx(e,t)},computeTotalFontSizePt:function(e,t){return e*t*4/3},getTextItemTotalFontSizePx:function(e){if(e&&e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var t=this.getTextItemInfo(e);if(t)return t.fontSize*t.scaling.y}return 0},getTextItemTotalFontSizePt:function(e){return 4*this.getTextItemTotalFontSizePx(e)/3},modifySelectedTextItemsTotalFontSizePt:function(e){var t=3*e/4;this.modifySelectedTextItemsTotalFontSizePx(t)},modifyTextItemTotalFontSizePt:function(e,t){var i=3*t/4;this.modifyTextItemTotalFontSizePx(e,i)},modifySelectedTextItemsTotalFontSizePx:function(e){var t=this.getSelectedTextItems();if(t&&t.length>0){var i=t[0];this.modifyTextItemTotalFontSizePx(i,e)}},modifyTextItemTotalFontSizePx:function(e,t){var i=this.canResizeItem(e),n=this.canChangeItemFontSize(e);if(e&&i&&n&&this.canSetTextFontSizePx(e,t)&&e.data&&(e instanceof this.paper.TextItem||e.data.isTextOnPath||e.data.isTextArea)){var a=this.getTextItemInfo(e);if(a){var r=a.fontSize*a.scaling.y;if(r>0){var o=t/r,s=this.getLastUndoOperationId();this.beginDesignOperation(),this.scaleItem(e,o,o,null),this.onItemUpdated(e),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(s)}}}},addTextOnPathElement:function(e,t,i){if(void 0===i&&(i=!1),i||this.canAddText()){var n=null;if(this.side){var a=this.side.get("areas").getMaxArea();if(a){var r=this.getDesignEffectForArea(a);this.beginDesignOperation();var o=!1;if(e||(e=this.paper.view.center,o=!0),t&&t.text){this.deselectAll(),this.updateSelectionState(),this.allowShadows()||(t.shadowColor=null),this.allowTextStroke()||(t.strokeWidth=0);var s=t.strokeColor||null,l=t.fillColor||"#000000",h=t.shadowColor||null;s=this.forceColorInFixedPalette(null,s),l=this.forceColorInFixedPalette(null,l),h=this.forceColorInFixedPalette(null,h),t.strokeColor=this.applyDesignEffectToTextColor(r,s),t.fillColor=this.applyDesignEffectToTextColor(r,l),t.shadowColor=this.applyDesignEffectToTextColor(r,h),t.shadowBlur=this.adjustInputShadowBlur(null,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(null,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(null,t.shadowAngle);var d=new this.paper.PointText({point:e,content:t.text,strokeColor:t.strokeColor,strokeWidth:null!=t.strokeWidth?t.strokeWidth:0,strokeJoin:this.strokeJoinText,fillColor:t.fillColor,fontFamily:this.sanitizeFontFamilyName(t.fontFamily||"Verdana"),fontWeight:t.fontWeight||"normal",fontSize:t.fontSize||12,justification:t.justification||"center",shadowColor:t.shadowColor||null,shadowBlur:t.shadowBlur,shadowOffset:this.getOffsetByDistanceAngle(t.shadowDistance,t.shadowAngle)}),c=d.bounds;d.remove();var u=c.clone(),g=this.findItemForArea(a);g&&(u=g.bounds.expand(-50)),o||(u.center=e);var f=Math.min(u.width,u.height),p=new this.paper.Rectangle(u.x+(u.width-f)/2,u.y+(u.height-f)/2,f,f),m=new this.paper.Point(p.left,p.top+f/2),v=new this.paper.Point(p.center.x,p.topLeft.y),I=new this.paper.Point(p.right,p.top+f/2),y=new this.paper.Path.Arc(m,v,I);y.remove(),t.rotation&&(y.rotation=t.rotation,m=y.getPointAt(0*y.length),v=y.getPointAt(.5*y.length),I=y.getPointAt(1*y.length)),n=new this.paper.Group;var C=this.createAlignedText(y,t);if(this.hasTextItemsStroke(C)){var M=this.getExternalStrokeText(C);n.addChildren(M)}n.addChildren(C),n.data.isTextOnPath=!0,n.data.points=[m,v,I],n.data.text=t.text,n.data.inside=t.inside||!1,n.data.originalStrokeColor=s,n.data.originalFillColor=l,n.data.originalShadowColor=h,n.data.letterSpacing=this.adjustInputLetterSpacingByConstraints(n,t.letterSpacing),this.masterGroup.addChild(n),this.adaptPathToText(n);var x=u.center.subtract(n.position);n.position=u.center,n.data.needsTransformsDataUpdate=!0,this.applyDesignEffectToItem(r,n),this.updateTransformsData(n),this.onTextOnPathMoved(n,x),this.onItemCreated(n),this.setItemSelection(n,!0)}this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}}return n}},getAllImageItems:function(){for(var e=[],t=this.getAllItems(),i=0;i<t.length;i++){var n=t[i],a=this.getMaskedImageRasterItem(n);n&&a&&n.data&&n.data.guid&&!n.data.isArea&&e.push(n)}return e},getAllDesignImageItems:function(){return this.design.get("designItems").models.filter(function(e){return""!==e.get("imageFormat")})},getAllTextOnPathItems:function(){var e=[];function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];!a.guide&&a.data&&a.data.isTextOnPath&&e.push(a),t(a)}}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}return e},setGrids:function(e){this.grids=e},updateGrids:function(e){return void 0===e&&(e=!1),__awaiter(this,void 0,void 0,function(){var t,i,n=this;return __generator(this,function(a){switch(a.label){case 0:return(t=this.design.get("areasGrids")&&this.design.get("areasGrids").models.find(function(e){return e.get("modelID")==n.getCurrentModel().id&&e.get("sideID")==n.side.id}))&&(i=this.grids.find(function(e){return e.id==t.get("gridID")}))?[4,this.createGridItem(i,e)]:[3,2];case 1:a.sent(),a.label=2;case 2:return[2]}})})},addImageToGridBox:function(e,t,i,n){void 0===n&&(n=!1),this.beginDesignOperation();var a=t.children.find(function(e){return e.data&&e.data.isGridIcon});a&&a.remove();var r=this.getItemBounds(e),o=t.bounds.clone();o.width*=1.1,o.height*=1.1;var s=1,l=1;Math.abs(o.width)>1e-7&&(s=o.width/r.width),Math.abs(o.height)>1e-7&&(l=o.height/r.height);var h=s>0?1:-1,d=l>0?1:-1;s=l=Math.max(Math.abs(s),Math.abs(l)),s*=h,l*=d,this.isViewer||e.data.isGridImage&&!n||(e.position=t.position,e.scale(s,l),e.data.initialScaleX=s,e.data.initialScaleY=l,e.data.originalBounds=new this.paper.Rectangle(0,0,this.getImageWidth(e),this.getImageHeight(e)),e.data.originalMatrix=e.matrix.clone()),e.visible=!0,e.data.isGridImage=!0,e.data.gridBoxID=i>=0?i:t.parent.children.indexOf(t),this.isViewer||(this.updateSelectionState(),this.onItemUpdated(e),this.onDesignItemChanged(e));for(var c=0,u=t.children;c<u.length;c++){var g=u[c];g.data&&g.data.isGridBorderPath&&(g.fillColor=new paper.Color(1,1,1,0))}t.addChild(e),e.sendToBack(),this.endDesignOperation()},insertImageInGrid:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h=this;return __generator(this,function(d){switch(d.label){case 0:return i=null,e&&e instanceof MPlaza.Image?this.canAddImage()&&(n=this.getAllGridItems()[0])?!this.side||this.side.get(0=="areas".length)?[2,i]:(a=this.side.get("areas").at(0),this.beginDesignOperation(),r=n.children.find(function(e){return e.data&&e.data.isBoxSelected})||n.children.find(function(e){return e.children&&e.children.find(function(e){return e.data&&e.data.isGridIcon})})||n.children[0],o="",!this.isImageScalingEnabled&&"svg"!=e.get("format").toLowerCase()&&"vector"!=e.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(t){return t==e.get("format").toLowerCase()})&&(o=e.get("url")),o||(o=e.get("previewUrl")),e.get("overridePreview")&&e.get("connectorSettings")&&(o=e.get("overridePreview")),o?(s=o,l=this.getDesignEffectForArea(a),[4,this.applyDesignEffectToImageUrl(l,o)]):[2,i]):[2,i]:[2,i];case 1:return o=d.sent(),t?[3,3]:[4,this.getImageDefaultColorMappings(o,null)];case 2:t=d.sent(),d.label=3;case 3:return t&&t.length>0?[4,this.recolorImage(o,t)]:[3,5];case 4:o=d.sent(),d.label=5;case 5:return[4,this.createRasterItem(o,!1)];case 6:return(i=d.sent()).data.originalUrl=s,this.applyDesignEffectToItem(l,i),i.data.originalImageID=e.id,i.data.areaGuid=r.data.areaGuid,r.children.forEach(function(e){e.data.isGridImage&&(e.remove(),h.onItemRemoved(e))}),this.onItemCreated(i,e),this.addImageToGridBox(i,r,n.children.indexOf(r)),this.onGridImageSelected(i),this.updateItemsIndexes(),this.onItemUpdated(i),this.onDesignItemChanged(i),this.fireImageLoadedEvent(),this.endDesignOperation(),[2,i]}})})},onGridImageSelected:function(e){this.deselectGridBoxes();var t=this.getMaskedImageRasterItem(e);e&&t&&e.data&&(e.data.isGridImage||e.data.isGridIcon)&&(this.selectGridBox(e.parent),this.fireGridImageSelectedEvent(e))},createGridBoxIcon:function(){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(t){return[2,new Promise(function(t){var i=new e.paper.Raster({crossOrigin:"anonymous",source:Zakeke.config.baseUrl+"/assets/customizer/images/other/camera_image_grids.png",onMouseEnter:function(){return e.paper.project.view.element.style.setProperty("cursor","pointer")},onMouseLeave:function(){return e.paper.project.view.element.style.setProperty("cursor",null)},visible:!1});i.onLoad=function(){i.onLoad=void 0,i.visible=!0,t(i)}})]})})},deselectGridBoxes:function(){this.getAllGridItems().forEach(function(e){e.children.forEach(function(e){if(e.data&&e.data.isGridPathGroup){var t=e.children.find(function(e){return e.data&&e.data.isGridBorderPath});t&&(t.strokeWidth=0,e.data.isBoxSelected=!1)}})})},selectGridBox:function(e){if(e&&e.data&&e.data.isGridPathGroup){var t=e.children.find(function(e){return e.data&&e.data.isGridBorderPath});t&&(this.createPathDashes(t),e.data.isBoxSelected=!0,e.children.find(function(e){return e.data&&e.data.isGridImage})&&t.bringToFront())}},getAllGridItems:function(){var e=[];function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];!a.guide&&a.data&&a.data.isGridGroup&&e.push(a),t(a)}}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}return e},removeAllGridItems:function(){var e=!1;this.currentDesignOperation||(e=!0,this.beginDesignOperation());for(var t=0,i=this.getAllGridItems();t<i.length;t++){var n=i[t];n.remove();for(var a=0,r=n.children;a<r.length;a++)for(var o=0,s=r[a].children;o<s.length;o++){var l=s[o];l.data&&l.data.isGridImage&&(l.data.isGridImage=!1,this.masterGroup.addChild(l),this.onItemUpdated(l))}}this.paper.project.view.update(),e&&this.endDesignOperation()},createGridItem:function(e,t){var i;return void 0===t&&(t=!1),__awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S=this;return __generator(this,function(b){switch(b.label){case 0:return this,this.beginDesignOperation(),(n=!e||!e.get("json"))&&this.removeAllGridBoxIdByItems(),this.removeAllGridItems(),a=this.findItemForArea(this.side.get("areas").at(0)),n||!a?[2]:((r=this.paper.project.activeLayer.importJSON(e.get("json"))).visible=!1,[4,this.createGridBoxIcon()]);case 1:for((o=b.sent()).visible=!1,r.scale(a.bounds.width/r.bounds.width,a.bounds.height/r.bounds.height),r.position.x=a.position.x,r.position.y=a.position.y,this.masterGroup.addChild(r),s=[],l=-1,h=.05*Math.min(r.bounds.width,r.bounds.height),d=0,c=r.children;d<c.length;d++)u=c[d],g=0,this.isMobile?((g=.2*Math.min(u.bounds.width,u.bounds.height))<h&&(g=h),(-1==l||g<l)&&(l=Math.max(g,60))):((g=.2*Math.min(u.bounds.width,u.bounds.height))<h&&(g=h),(-1==l||g<l)&&(l=Math.max(g,30)));for(f=0,p=r.children;f<p.length;f++)m=p[f],(v=this.getPlaceholderIcon(m,o,l))&&(s.push(v),m.addChild(v));for(o.remove(),I=this.getAllImageItems().filter(function(e){return!e.data.isImageForBackground}),(y=I.filter(function(e){return e.data&&e.data.isGridImage})).forEach(function(e){e.visible=!1}),C=function(){var e=I[x],n=null,a=-1;if(e.data&&null!=e.data.gridBoxID&&(n=r.children[e.data.gridBoxID])&&(a=e.data.gridBoxID),!n){if(null!=(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.gridBoxID)&&(x>=r.children.length||e.data.gridBoxID>=r.children.length))return e.remove(),M.onItemRemoved(e),"continue";n=r.children[x],a=x}var o=null,s=M.findDesignItemForItem(e);if(s&&(o=s.get("constraints")),!o||(o.get("canEdit")||o.get("canMove")||o.get("canRotate")||o.get("canResize")||o.get("canDelete"))&&e.data&&!e.data.isGridIcon)if(e.loaded)M.addImageToGridBox(e,n,a,t);else{var l=e.onLoad||function(){};e.onLoad=function(){l(),S.addImageToGridBox(e,n,a,t)}}else e.data&&null!=e.data.gridBoxID&&(e.data.isGridImage=!1,e.data.gridBoxID=null,M.isViewer||(M.onItemUpdated(e),M.onDesignItemChanged(e)))},M=this,x=0;x<I.length;x++)C();return r.visible=!0,this.updateItemsIndexes(),this.paper.project.view.update(),this.endDesignOperation(),this.resetUndoRedo(),y.forEach(function(e){e.visible=!0;var t=S.findDesignItemForItem(e);if(t){var i=t.get("constraints");S.isViewer&&i&&!i.get("isPrintable")&&(e.visible=i.get("keepInPreview"))}}),[2]}})})},getPlaceholderIcon:function(e,t,i){var n=this,a=null;if(e.data.isGridBox=!0,e.data.smallestCameraIconDim=i,e.children.length>1){var r=e.children.find(function(e){return e.data&&e.data.isGridBorderPath});if(r&&(r.strokeWidth=0,r.strokeColor="#000000",!this.isViewer)){r.fillColor=new paper.Color(1,1,1,.9);var o=t.clone();o.visible=!0,o.data.isGridIcon=!0,o.onMouseEnter=function(){return n.paper.project.view.element.style.setProperty("cursor","pointer")},o.onMouseLeave=function(){return n.paper.project.view.element.style.setProperty("cursor",null)},o.position.x=r.interiorPoint.x,o.position.y=r.interiorPoint.y,o.scale(i/o.bounds.width,i/o.bounds.height);var s=this.isIconIntoAreas(o),l=this.isItemIntoPath(e,o);if(!s||!l){var h=this.getIconPosition(e);h&&(o.position.x=h.x,o.position.y=h.y)}a=o}}return a},isIconIntoAreas:function(e){var t=this;return this.getAllAreas().some(function(i){return t.isItemIntoPath(i,e)})},getAllAreas:function(){var e=this,t=[],i=this.side.get("areas");return i&&i.forEach(function(i){var n=e.findItemForArea(i);t.push(n)}),t},getIconPosition:function(e){var t=e.children.find(function(e){return e.data&&e.data.isGridBorderPath});if(!t)return null;for(var i,n=t.bounds.width/20,a=t.bounds.height/20,r=new paper.Shape.Circle(new paper.Point(0,0),0),o=1,s=0;s<20;s++)for(var l=t.bounds.y+a*s,h=0;h<20;h++){var d=t.bounds.x+n*h,c=new paper.Point(d,l),u=this.isPointIntoAreas(c);if(t.contains(c)&&u)for(r.position=c,r.radius=o;;){var g=this.isCircleIntoAreas(r);if(!this.isCircleIntoPath(t,r)||!g){if(r.radius--,r.radius>o)o=r.radius,i=c;else if(r.radius==o&&i){var f=t.position.getDistance(i);t.position.getDistance(c)<f&&(i=c)}break}r.radius+=1}}return r.remove(),i},isCircleIntoAreas:function(e){var t=this;return this.getAllAreas().some(function(i){return t.isCircleIntoPath(i,e)})},isPointIntoAreas:function(e){return this.getAllAreas().some(function(t){return t.contains(e)})},isCircleIntoPath:function(e,t){var i=t.bounds.leftCenter,n=t.bounds.topCenter,a=t.bounds.rightCenter,r=t.bounds.bottomCenter;return e.contains(i)&&e.contains(n)&&e.contains(a)&&e.contains(r)},isItemIntoPath:function(e,t){var i=t.bounds.leftCenter,n=t.bounds.topCenter,a=t.bounds.rightCenter,r=t.bounds.bottomCenter,o=t.bounds.topLeft,s=t.bounds.topRight,l=t.bounds.bottomRight,h=t.bounds.bottomLeft;return e.contains(i)&&e.contains(n)&&e.contains(a)&&e.contains(r)&&e.contains(o)&&e.contains(s)&&e.contains(l)&&e.contains(h)},removeAllGridBoxIdByItems:function(){for(var e,t=0,i=this.getAllGridItems();t<i.length;t++)for(var n=0,a=i[t].children;n<a.length;n++)for(var r=0,o=a[n].children;r<o.length;r++){var s=o[r];s.data&&s.data.isGridImage&&(null===(e=null==s?void 0:s.data)||void 0===e?void 0:e.hasOwnProperty("gridBoxID"))&&delete s.data.gridBoxID}},updateTextOnPathGuides:function(e){e||(e=this.getAllTextOnPathItems());for(var t=0;t<e.length;t++){var i=e[t];this.updateTextOnPathGuide(i)}},updateTextOnPathGuide:function(e){e.data.selected?(this.drawTextOnPathGuide(e),this.drawTextOnPathHandles(e)):(this.removeTextOnPathGuide(e),this.removeTextOnPathHandles(e))},createPathDashes:function(e,t){if(void 0===t&&(t=[]),e){t&&0!=t.length||(t=["black","white"]);for(var i=[],n=t.length-1,a=0;a<1;a=Math.round(100*(a+.03))/100){var r=Math.min(Math.round(100*(a+.03))/100,1),o=t[n=(n+1)%t.length];i=__spreadArray(__spreadArray([],i,!0),[[o,a],[o,r]],!1)}var s=Math.max(e.bounds.width,e.bounds.height);e.strokeColor={gradient:{stops:i},origin:e.bounds.topLeft,destination:new paper.Point(e.bounds.topLeft.x+s,e.bounds.topLeft.y+s)},e.strokeWidth=1.5/this.paper.view.zoom,e.dashArray=[]}},drawTextOnPathGuide:function(e){if(this.removeTextOnPathGuide(e),e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var t=new this.paper.Path.Arc(e.data.points[0],e.data.points[1],e.data.points[2]);t.data.isTextOnPathGuide=!0,t.strokeWidth=2/this.paper.view.zoom,t.dashOffset=.5/this.paper.view.zoom,t.dashArray=[1/this.paper.view.zoom,1/this.paper.view.zoom],t.guide=!0,t.data.itemGuid=e.data.guid,this.isViewer||this.createPathDashes(t)}},findTextOnPathGuide:function(e){if(e&&e.data&&e.data.isTextOnPath&&e.data.guid)for(var t=e.data.guid.toUpperCase(),i=function(e,n){if(e.data&&e.data.isTextOnPathGuide&&e.data.itemGuid&&e.data.itemGuid.toUpperCase()==n)return e;if(e.children)for(var a=e.children.length-1;a>=0;a--){var r=e.children[a],o=i(r,t);if(o)return o}},n=0;n<this.paper.project.layers.length;n++){var a=this.paper.project.layers[n];if(!a.guide){var r=i(a,t);if(r)return r}}return null},removeTextOnPathGuide:function(e){var t=this.findTextOnPathGuide(e);t&&t.remove()},drawTextOnPathHandles:function(e){if(this.removeTextOnPathHandles(e),this.canMoveItem(e)&&e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var t=e.data.points[0],i=e.data.points[1],n=e.data.points[2],a=new this.paper.Rectangle(t,new this.paper.Point(n.x,i.y)),r=(this.getContrastedColor(a),this.selectionLateralResizeDimension/this.paper.view.zoom),o=new this.paper.Path.Circle(t,r);o.data.isTextOnPathHandle=!0,o.data.isTextOnPathFirstEndHandle=!0,o.strokeColor=new this.paper.Color(1,1,1,.5),o.strokeWidth=1,o.fillColor=new this.paper.Color(0,0,0,.5),o.data.itemGuid=e.data.guid;var s=new this.paper.Path.Circle(i,r);s.data.isTextOnPathHandle=!0,s.data.isTextOnPathMiddleEndHandle=!0,s.strokeColor=new this.paper.Color(1,1,1,.5),s.strokeWidth=1,s.fillColor=new this.paper.Color(0,0,0,.5),s.data.itemGuid=e.data.guid;var l=new this.paper.Path.Circle(n,r);l.data.isTextOnPathHandle=!0,l.data.isTextOnPathLastEndHandle=!0,l.strokeColor=new this.paper.Color(1,1,1,.5),l.strokeWidth=1,l.fillColor=new this.paper.Color(0,0,0,.5),l.data.itemGuid=e.data.guid,this.isViewer&&(o.visible=!1,s.visible=!1,l.visible=!1)}},findTextOnPathHandles:function(e){var t=[];if(e&&e.data&&e.data.isTextOnPath&&e.data.guid)for(var i=e.data.guid.toUpperCase(),n=function(e,a){if(e.data&&e.data.isTextOnPathHandle&&e.data.itemGuid&&e.data.itemGuid.toUpperCase()==a&&t.push(e),e.children)for(var r=e.children.length-1;r>=0;r--){var o=e.children[r];n(o,i)}},a=0;a<this.paper.project.layers.length;a++){var r=this.paper.project.layers[a];r.guide||n(r,i)}return t},removeTextOnPathHandles:function(e){for(var t=this.findTextOnPathHandles(e),i=0;i<t.length;i++){t[i].remove()}},onTextOnPathMoved:function(e,t){if(e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var i=e.data.points[0],n=e.data.points[1],a=e.data.points[2],r=new this.paper.Path.Arc(i,n,a);r.remove(),r.position.x+=t.x,r.position.y+=t.y,e.data.points[0]=r.getPointAt(0*r.length),e.data.points[1]=r.getPointAt(.5*r.length),e.data.points[2]=r.getPointAt(1*r.length)}},onTextOnPathRotated:function(e,t,i){if(e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var n=e.data.points[0],a=e.data.points[1],r=e.data.points[2],o=new this.paper.Path.Arc(n,a,r);o.remove(),o.rotate(t,i),e.data.points[0]=o.getPointAt(0*o.length),e.data.points[1]=o.getPointAt(.5*o.length),e.data.points[2]=o.getPointAt(1*o.length)}},onTextOnPathScaled:function(e,t,i,n){if(e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var a=e.data.points[0],r=e.data.points[1],o=e.data.points[2],s=new this.paper.Path.Arc(a,r,o);s.remove(),s.scale(t,i,n),e.data.points[0]=s.getPointAt(0*s.length),e.data.points[1]=s.getPointAt(.5*s.length),e.data.points[2]=s.getPointAt(1*s.length)}},moveTextOnPathFirstEnd:function(e){if(!this.frozen&&e.delta){var t=e.delta;this.hideCenterLines(),this.removeSelectionAlertItems();var i=this.getSelectedTextOnPathItems();if(i&&i.length>0){var n=i[0];n&&n.data&&n.data.isTextOnPath&&n.data.points&&"[object Array]"===Object.prototype.toString.call(n.data.points)&&3==n.data.points.length&&(n.data.points[0].x+=t.x,n.data.points[0].y+=t.y,this.canMovePathTextHandles(n)?(n.data.needsTransformsDataUpdate=!0,this.drawTextOnPathGuide(n),this.drawTextOnPathHandles(n),this.updateTextOnPath(n)):(n.data.points[0].x-=t.x,n.data.points[0].y-=t.y))}}},moveTextOnPathMiddleEnd:function(e){if(!this.frozen&&e.delta){var t=e.delta;this.hideCenterLines(),this.removeSelectionAlertItems();var i=this.getSelectedTextOnPathItems();if(i&&i.length>0){var n=i[0];n&&n.data&&n.data.isTextOnPath&&n.data.points&&"[object Array]"===Object.prototype.toString.call(n.data.points)&&3==n.data.points.length&&(n.data.points[1].x+=t.x,n.data.points[1].y+=t.y,this.canMovePathTextHandles(n)?(n.data.needsTransformsDataUpdate=!0,this.drawTextOnPathGuide(n),this.drawTextOnPathHandles(n),this.updateTextOnPath(n)):(n.data.points[1].x-=t.x,n.data.points[1].y-=t.y))}}},moveTextOnPathLastEnd:function(e){if(!this.frozen&&e.delta){var t=e.delta;this.hideCenterLines(),this.removeSelectionAlertItems();var i=this.getSelectedTextOnPathItems();if(i&&i.length>0){var n=i[0];n&&n.data&&n.data.isTextOnPath&&n.data.points&&"[object Array]"===Object.prototype.toString.call(n.data.points)&&3==n.data.points.length&&(n.data.points[2].x+=t.x,n.data.points[2].y+=t.y,this.canMovePathTextHandles(n)?(n.data.needsTransformsDataUpdate=!0,this.drawTextOnPathGuide(n),this.drawTextOnPathHandles(n),this.updateTextOnPath(n)):(n.data.points[2].x-=t.x,n.data.points[2].y-=t.y))}}},modifyTextOnPathInfo:function(e,t,i){t&&(t.text=this.adjustInputTextByConstraints(e,null!=t.text?t.text:e.data.text),t.letterSpacing=this.adjustInputLetterSpacingByConstraints(e,t.letterSpacing?parseInt(t.letterSpacing):void 0),t.strokeWidth=this.adjustInputTextStrokeWidth(e,t.strokeWidth),t.text&&(e.data.isProfanityCheckInvalid=!1,this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e))),this.removeAllAlertItems(),this.updateTextOnPath(e,t,i),this.adaptPathToText(e),this.updateTextOnPath(e,null,i),this.checkAllAlertItems(),this.checkImagesSizeLimit()},updateTextOnPath:function(e,t,i){if(this.beginDesignOperation(),e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0){var n=e.data.text;if(!n)for(var a=0;a<e.children.length;a++)n+=e.children[a].content;var r=this.getItemConstraints(e),o=null,s=this.findDesignItemForItem(e);s&&(o=this.getDesignEffectForDesignItem(s)),s&&(o=this.getDesignEffectForDesignItem(s));var l=null,h=null,d=null,c=!0;t||(t={},c=!1);var u=!1;t.hasOwnProperty("shadowColor")&&(u=!0),t.text=t.text||n,this.allowShadows()||(t.shadowColor=null),!r||r.get("canChangeFontColor")?(t.hasOwnProperty("strokeColor")&&(l=t.strokeColor),null!=t.fillColor&&(h=t.fillColor),l=this.forceColorInFixedPalette(e,l,i),h=this.forceColorInFixedPalette(e,h,i),t.strokeColor=void 0!==t.strokeColor?this.applyDesignEffectToTextColor(o,l):e.children[0].strokeColor,t.strokeColor&&(l=this.forceColorInFixedPalette(null,t.strokeColor)),t.fillColor=null!=t.fillColor?this.applyDesignEffectToTextColor(o,h):e.children[0].fillColor):(t.strokeColor=e.children[0].strokeColor,t.fillColor=e.children[0].fillColor),!r||r.get("canChangeShadowColor")?(void 0!==t.shadowColor&&(d=t.shadowColor),d=this.forceColorInFixedPalette(e,d,i),t.shadowColor=this.allowShadows()?void 0!==t.shadowColor?this.applyDesignEffectToTextColor(o,d):e.children[0].shadowColor:null):t.shadowColor=this.allowShadows()?e.children[0].shadowColor:null,u&&void 0!==d&&(e.data.originalShadowColor=d),t.strokeWidth=null!=t.strokeWidth?t.strokeWidth:e.children[0].strokeWidth,t.shadowBlur=null!=t.shadowBlur?t.shadowBlur:e.children[0].shadowBlur,t.shadowDistance=null!=t.shadowDistance?t.shadowDistance:this.getOffsetDistance(e.children[0].shadowOffset),t.shadowAngle=null!=t.shadowAngle?t.shadowAngle:this.getOffsetAngle(e.children[0].shadowOffset),t.shadowBlur=this.adjustInputShadowBlur(e,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(e,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(e,t.shadowAngle),!r||r.get("canChangeFontFamily")?t.fontFamily=null!=t.fontFamily?t.fontFamily:e.children[0].fontFamily:t.fontFamily=e.children[0].fontFamily,t.fontFamily=this.sanitizeFontFamilyName(t.fontFamily);var g=null!=t.fontWeight?t.fontWeight:e.children[0].fontWeight;t.fontWeight=this.adjustInputFontWeightByConstraints(e.children[0].fontWeight,g,r),t.fontStretch=null!=t.fontStretch?t.fontStretch:e.children[0].fontStretch,!r||r.get("canChangeFontSize")?t.fontSize=null!=t.fontSize?t.fontSize:e.children[0].fontSize:t.fontSize=e.children[0].fontSize,t.scaling=null!=t.scaling?t.scaling:e.children[0].scaling,e.data.text=t.text,c&&void 0!==l&&(e.data.originalStrokeColor=l),h&&(e.data.originalFillColor=h),t.letterSpacing=null!=t.letterSpacing?t.letterSpacing:null!=e.data.letterSpacing?e.data.letterSpacing:0,e.data.letterSpacing=t.letterSpacing,e.removeChildren();var f=e.data.points[0],p=e.data.points[1],m=e.data.points[2],v=new this.paper.Path.Arc(f,p,m);v.remove();var I=v.getPointAt(.5*v.length);e.data.points[1]=I;var y=this.createAlignedText(v,t,null);if(this.hasTextItemsStroke(y)){var C=this.getExternalStrokeText(y);e.addChildren(C)}e.addChildren(y),this.applyDesignEffectToItem(o,e),this.updateSelectionState(),this.paper.project.view.update()}this.endDesignOperation()},adaptPathToText:function(e){performance.now();if(e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length){var t=e.data.text;if(!t)for(var i=0;i<e.children.length;i++)t+=e.children[i].content;var n=e.data.points[0],a=e.data.points[1],r=e.data.points[2],o=new this.paper.Path.Arc(n,a,r);o.remove();var s={};s.text=t,s.strokeColor=e.children[0].strokeColor,s.strokeWidth=e.children[0].strokeWidth,s.fillColor=e.children[0].fillColor,s.fontFamily=e.children[0].fontFamily,s.fontWeight=e.children[0].fontWeight,s.fontSize=e.children[0].fontSize,s.scaling=e.children[0].scaling,s.letterSpacing=null!=e.data.letterSpacing?e.data.letterSpacing:0,s.shadowColor=e.children[0].shadowColor,s.shadowBlur=e.children[0].shadowBlur,s.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),s.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset);var l=0;if(this.isLetterSpacingSpecified(s)){var h=this.getTextExtraSpace(s),d=null;for(i=0;i<t.length;i++)i>0&&(l+=h),l+=(d=this.createPointText(t.substring(i,i+1),s)).bounds.width,d.remove()}else{var c=this.createPointText(t,s);c.remove(),l=c.bounds.width}if(Math.abs(l-o.length)<.001){performance.now();return}var u=this.getCircleCenter(n,r,a),g=n.getDistance(u),f=2*Math.PI*g,p=(o.length,(l-o.length)/f*360),m=this.getCircleAngleAtPoint(u.x,u.y,g,n.x,n.y),v=this.getCircleAngleAtPoint(u.x,u.y,g,r.x,r.y),I=this.getCircleAngleAtPoint(u.x,u.y,g,a.x,a.y),y=0,C=0;(m=this.getNormalizedAngle(m))>(v=this.getNormalizedAngle(v))?y=360-(C=m-v):C=360-(y=v-m),(I=this.getNormalizedAngle(I))<m?(p+C>359&&(p=359-C),m+=p/2,v-=p/2):(p+y>359&&(p=359-y),m-=p/2,v+=p/2),m=this.getNormalizedAngle(m),v=this.getNormalizedAngle(v);var M=this.getCirclePointAtAngle(u.x,u.y,g,m),x=this.getCirclePointAtAngle(u.x,u.y,g,v);e.data.points[0]=M,e.data.points[2]=x,this.updateSelectionState(),this.paper.project.view.update()}performance.now()},createAlignedText:function(e,t,i){performance.now();var n=[],a=t.inside||!1;if(t&&t.text&&t.text.length>0&&e){var r=t.text,o=(this.getSpaceWidth(t),this.getTextExtraSpace(t)),s=this.getTotalTextLength(t,e),l=this.getGlyphTexts(t),h=this.getGlyphsLength(l,o),d=this.isLetterSpacingSpecified(t)?h:s;if(!i){var c={path:e,totalLength:d,glyphTexts:l};i=this.getStartOffset(c)}for(var u={startOffset:i,info:t,glyphTexts:l,extraSpace:o},g=this.getGlyphOffsets(u),f=0;f<r.length;f++){var p=g[f];if(p<0&&e.closed&&(p=e.length+p),e.length<p&&(e.closed?p%=e.length:p=void 0),void 0===p)l[f].remove();else{n.push(l[f]);var m=e.getPointAt(p);l[f].point=m;var v=e.getTangentAt(p);if(v){var I=v.angle;a&&(I-=180),l[f].rotate(I,m)}}}}performance.now();return n},getTotalTextLength:function(e,t){var i=e.text,n=this.createPointText(i,e);return n.bounds.centerX=t.bounds.centerX,this.paper.project.view.update(),n.remove(),n.bounds.width},getGlyphTexts:function(e){for(var t=e.text,i=[],n=0;n<t.length;n++)i[n]=this.createPointText(t.substring(n,n+1),e),i[n].justification="center";return i},getGlyphsLength:function(e,t){for(var i=0,n=0;n<e.length;n++)n>0&&(i+=t),i+=e[n].bounds.width;return i},getStartOffset:function(e){var t=e.path,i=e.totalLength,n=e.glyphTexts,a=n[0],r=(n[n.length-1],0);i<t.length+.05&&(r=(t.length-i)/2+a.bounds.width/2);return r},getGlyphOffsets:function(e){for(var t=e.startOffset,i=e.info,n=e.glyphTexts,a=e.extraSpace,r=i.text,o=i.inside||!1,s=[t],l=1;l<r.length;l++){var h=this.createPointText(r.substring(l-1,l+1),i);h.remove();var d=s[l-1],c=n[l-1],u=n[l];if(o)s[l]=d-(h.bounds.width-c.bounds.width/2-u.bounds.width/2+a);else{var g=c.bounds.width/2+u.bounds.width/2,f=d+(h.bounds.width-g+a);s[l]=f}}return s},canMovePathTextHandles:function(e){var t=!0,i=e.data.points[0],n=e.data.points[1],a=e.data.points[2],r=new this.paper.Path.Arc(i,n,a);r.remove();var o=this.getInfoFromTextToPath(e),s=this.getTextExtraSpace(o),l=this.getTotalTextLength(o,r),h=this.getGlyphTexts(o);h.forEach(function(e){e.remove()});var d=this.getGlyphsLength(h,s),c=this.isLetterSpacingSpecified(o)?d:l,u=this.getStartOffset({path:r,totalLength:c,glyphTexts:h}),g=this.getGlyphOffsets({startOffset:u,info:o,glyphTexts:h,extraSpace:s}),f=g[g.length-1];return r.length<f&&(t=!1),t},getInfoFromTextToPath:function(e){var t={},i=e.data.text;if(!i)for(var n=0;n<e.children.length;n++)i+=e.children[n].content;var a=e.children[0];return t.text=i,t.strokeColor=a.strokeColor,t.strokeWidth=a.strokeWidth,t.fillColor=a.fillColor,t.fontFamily=a.fontFamily,t.fontWeight=a.fontWeight,t.fontSize=a.fontSize,t.scaling=a.scaling,t.letterSpacing=null!=e.data.letterSpacing?e.data.letterSpacing:0,t.shadowColor=a.shadowColor,t.shadowBlur=a.shadowBlur,t.shadowDistance=this.getOffsetDistance(a.shadowOffset),t.shadowAngle=this.getOffsetAngle(a.shadowOffset),t},createPointText:function(e,t){var i=new this.paper.PointText;return i.content=e,t&&(i.strokeColor=t.strokeColor,i.strokeWidth=null!=t.strokeWidth?t.strokeWidth:0,i.strokeJoin=this.strokeJoinText,i.fillColor=t.fillColor||"black",i.fontFamily=t.fontFamily||"Verdana",i.fontWeight=t.fontWeight||"normal",i.fontSize=t.fontSize||12,t.scaling&&(i.scaling=t.scaling),i.shadowColor=t.shadowColor,i.shadowBlur=t.shadowBlur,i.shadowOffset=this.getOffsetByDistanceAngle(t.shadowDistance,t.shadowAngle)),i},getCircleCenter:function(e,t,i){var n=Math.pow(t.x,2)+Math.pow(t.y,2),a=(Math.pow(e.x,2)+Math.pow(e.y,2)-n)/2,r=(n-Math.pow(i.x,2)-Math.pow(i.y,2))/2,o=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);return!(Math.abs(o)<1e-14)&&new this.paper.Point((a*(t.y-i.y)-r*(e.y-t.y))/o,((e.x-t.x)*r-(t.x-i.x)*a)/o)},getCirclePointAtAngle:function(e,t,i,n){var a=n*Math.PI/180,r=i*Math.cos(a)+e,o=i*Math.sin(a)+t;return new paper.Point(r,o)},getCircleAngleAtPoint:function(e,t,i,n,a){return 0==i?0:(180*Math.atan2(a-t,n-e)/Math.PI+360)%360},getNormalizedAngle:function(e){return e<0&&(e=360+e),e>360&&(e-=360),e},addTextAreaElement:function(e,t,i){if(void 0===i&&(i=!0),i||this.canAddText()){var n=null;if(this.side)if(a=this.side.get("areas").getMaxArea()){if(this.beginDesignOperation(),!e&&this.side){var a=this.side.get("areas").getMaxArea(),r=this.findItemForArea(a);r&&(e=r.bounds.expand(-50))}if(!e)return;if(t&&t.text){var o=this.getDesignEffectForArea(a);this.allowShadows()||(t.shadowColor=null);var s=t.strokeColor||null,l=t.fillColor||"#000000",h=t.shadowColor||null;s=this.forceColorInFixedPalette(null,s),l=this.forceColorInFixedPalette(null,l),h=this.forceColorInFixedPalette(null,h),t.strokeColor=this.applyDesignEffectToTextColor(o,s),t.fillColor=this.applyDesignEffectToTextColor(o,l),t.shadowColor=this.applyDesignEffectToTextColor(o,h),t.shadowBlur=this.adjustInputShadowBlur(null,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(null,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(null,t.shadowAngle),t.letterSpacing=null!=t.letterSpacing?t.letterSpacing:0,t.lineSpacing=null!=t.lineSpacing?t.lineSpacing:0,t.strokeWidth=this.adjustInputTextStrokeWidth(null,t.strokeWidth),this.deselectAll(),this.updateSelectionState(),n=new this.paper.Group;var d=this.createWrappedText(e,t,!1).textItems;if(this.hasTextItemsStroke(d)){var c=this.getExternalStrokeText(d);n.addChildren(c)}n.addChildren(d),this.applyDesignEffectToItem(o,n),e=n.bounds,n.data.rect=e,n.data.isTextArea=!0,n.data.text=t.text,n.data.justification=null!=t.justification?t.justification:"justify",n.data.originalStrokeColor=s,n.data.originalFillColor=l,n.data.originalShadowColor=h,n.data.letterSpacing=t.letterSpacing,n.data.lineSpacing=t.lineSpacing,n.rotation=t.rotation,this.masterGroup.addChild(n);var u=e.center.subtract(n.position);n.position=e.center,n.data.needsTransformsDataUpdate=!0,this.updateTransformsData(n),this.onTextAreaMoved(n,u),this.forceTextAreaToBounds(n),this.onItemCreated(n),this.setItemSelection(n,!0)}this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}return n}},isItemTextArea:function(e){return e&&e.data&&e.data.isTextArea},isItemTextBox:function(e){return this.isItemTextArea(e)&&e.data.isTextBox},isSimpleTextArea:function(e){return e&&e.data&&e.data.isTextArea&&!e.data.isTextBox},convertSelectedTextAreaToTextBox:function(){var e=this;this.getSelectedTextAreaItems().forEach(function(t){return e.convertTextAreaToTextBox(t)})},convertSelectedTextBoxToTextArea:function(){var e=this;this.getSelectedTextAreaItems().forEach(function(t){return e.convertTextBoxToTextArea(t)})},toggleSelectedTextArea:function(){var e=this;this.getSelectedTextAreaItems().forEach(function(t){t.data.isTextBox?e.convertTextBoxToTextArea(t):e.convertTextAreaToTextBox(t)})},convertTextAreaToTextBox:function(e){if(this.canChangeItemTextBoxMode(e)&&this.isSimpleTextArea(e)){var t=this.getLastUndoOperationId();this.beginDesignOperation(),e.data.isTextBox=!0,this.updateTextArea({item:e,isTextBoxClicked:!0}),this.onItemUpdated(e),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(t)}},convertTextBoxToTextArea:function(e){if(this.canChangeItemTextBoxMode(e)&&this.isItemTextBox(e)){var t=this.getLastUndoOperationId();this.beginDesignOperation(),e.data.isTextBox=!1,this.updateTextArea({item:e}),this.onItemUpdated(e),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(t)}},getAllTextAreaItems:function(){var e=[];function t(i){if(i.children)for(var n=i.children.length-1;n>=0;n--){var a=i.children[n];!a.guide&&a.data&&a.data.isTextArea&&e.push(a),t(a)}}for(var i=0,n=this.paper.project.layers.length;i<n;i++){var a=this.paper.project.layers[i];a.guide||t(a)}return e},updateTextAreaGuides:function(e){e||(e=this.getAllTextAreaItems());for(var t=0;t<e.length;t++){var i=e[t];this.updateTextAreaGuide(i)}},updateTextAreaGuide:function(e){e.data.selected&&this.canEditItem(e)?(this.drawTextAreaGuide(e),this.drawTextAreaHandles(e)):(this.removeTextAreaGuide(e),this.removeTextAreaHandles(e))},drawTextAreaGuide:function(e){if(this.removeTextAreaGuide(e),e&&e.data&&e.data.isTextArea&&e.data.isTextBox&&e.data.rect){var t=new this.paper.Path.Rectangle(e.data.rect);t.data.isTextAreaGuide=!0,t.strokeWidth=1/this.paper.view.zoom,t.dashOffset=1/this.paper.view.zoom,t.dashArray=[2/this.paper.view.zoom,2/this.paper.view.zoom],t.guide=!0,t.data.itemGuid=e.data.guid,t.strokeColor=this.getContrastedColor(e.data.rect),e.children&&e.children.length>0?t.rotation=e.children[0].rotation:e.data.textInfo&&null!=e.data.textInfo.rotation&&(t.rotation=e.data.textInfo.rotation)}},findTextAreaGuide:function(e){if(e&&e.data&&e.data.isTextArea&&e.data.guid)for(var t=e.data.guid.toUpperCase(),i=function(e,n){if(e.data&&e.data.isTextAreaGuide&&e.data.itemGuid&&e.data.itemGuid.toUpperCase()==n)return e;if(e.children)for(var a=e.children.length-1;a>=0;a--){var r=e.children[a],o=i(r,t);if(o)return o}},n=0;n<this.paper.project.layers.length;n++){var a=this.paper.project.layers[n];if(!a.guide){var r=i(a,t);if(r)return r}}return null},removeTextAreaGuide:function(e){var t=this.findTextAreaGuide(e);t&&t.remove()},drawTextAreaHandles:function(e){if(this.removeTextAreaHandles(e),this.canResizeTextBoxItem(e)&&e&&e.data&&e.data.isTextArea&&e.data.isTextBox&&e.data.rect){var t=this.selectionLateralResizeDimension/this.paper.view.zoom,i=new this.paper.Path.Rectangle(e.data.rect);e.children&&e.children.length>0?i.rotation=e.children[0].rotation:e.data.textInfo&&null!=e.data.textInfo.rotation&&(i.rotation=e.data.textInfo.rotation),i.remove();var n=i.segments;if(4==n.length){var a=n[0].point,r=n[1].point,o=n[2].point,s=n[3].point,l=r.add(o.subtract(r).divide(2)),h=a.add(s.subtract(a).divide(2)),d=a.add(r.subtract(a).divide(2)),c=s.add(o.subtract(s).divide(2)),u=1.2*t,g=l.subtract(h).normalize(u);l=l.add(g),h=h.subtract(g),g=c.subtract(d).normalize(u),c=c.add(g),d=d.subtract(g);var f=new this.paper.Path.Circle(l,t);f.data.isTextAreaHandle=!0,f.data.isTextAreaTopEndHandle=!0,f.strokeColor=new this.paper.Color(1,1,1,.5),f.strokeWidth=1,f.fillColor=new this.paper.Color(0,0,0,.5),f.data.itemGuid=e.data.guid;var p=new this.paper.Path.Circle(c,t);p.data.isTextAreaHandle=!0,p.data.isTextAreaRightEndHandle=!0,p.strokeColor=new this.paper.Color(1,1,1,.5),p.strokeWidth=1,p.fillColor=new this.paper.Color(0,0,0,.5),p.data.itemGuid=e.data.guid;var m=new this.paper.Path.Circle(h,t);m.data.isTextAreaHandle=!0,m.data.isTextAreaBottomEndHandle=!0,m.strokeColor=new this.paper.Color(1,1,1,.5),m.strokeWidth=1,m.fillColor=new this.paper.Color(0,0,0,.5),m.data.itemGuid=e.data.guid;var v=new this.paper.Path.Circle(d,t);v.data.isTextAreaHandle=!0,v.data.isTextAreaLeftEndHandle=!0,v.strokeColor=new this.paper.Color(1,1,1,.5),v.strokeWidth=1,v.fillColor=new this.paper.Color(0,0,0,.5),v.data.itemGuid=e.data.guid}}},findTextAreaHandles:function(e){var t=[];if(e&&e.data&&e.data.isTextArea&&e.data.guid)for(var i=e.data.guid.toUpperCase(),n=function(e,a){if(e.data&&e.data.isTextAreaHandle&&e.data.itemGuid&&e.data.itemGuid.toUpperCase()==a&&t.push(e),e.children)for(var r=e.children.length-1;r>=0;r--){var o=e.children[r];n(o,i)}},a=0;a<this.paper.project.layers.length;a++){var r=this.paper.project.layers[a];r.guide||n(r,i)}return t},removeTextAreaHandles:function(e){for(var t=this.findTextAreaHandles(e),i=0;i<t.length;i++){t[i].remove()}},onTextAreaMoved:function(e,t){if(e&&e.data&&e.data.isTextArea&&e.data.rect){var i=e.data.rect.clone();i.x+=t.x,i.y+=t.y,e.data.rect=i}},onTextAreaRotated:function(e,t,i){e&&e.data&&e.data.isTextBox&&this.updateTextArea({item:e})},onTextAreaScaled:function(e,t,i,n){if(e&&e.data&&e.data.isTextArea&&e.data.rect)if(e.data.isTextBox)this.updateTextArea({item:e});else{var a=new this.paper.Path.Rectangle(e.data.rect);a.remove(),a.scale(t,i,n),e.data.rect=a.bounds.clone()}},canResizeSelectedTextAreas:function(e,t,i){for(var n=this.getSelectedItems(),a=0;a<n.length;a++){var r=n[a];if(!this.canResizeTextArea(r,e,t,i))return!1}return!0},canResizeTextArea:function(e,t,i,n){if(e&&e.data&&e.data.isTextArea&&e.data.isTextBox&&e.data.rect&&e.children&&e.children.length>0){var a=e.children[0].clone();a.scale(t,i,n);var r=a.scaling;a.remove();var o=this.getTextAreaItemInfo(e,null);o.scaling=r;var s=this.createWrappedText(e.data.rect.clone(),o,!0).textItems;if(console.log("children count: "+s.length),0==s.length)return!1;s.forEach(function(e){e.remove()})}return!0},moveTextAreaTopEnd:function(e){this.moveTextAreaEnd(e,"top")},moveTextAreaRightEnd:function(e){this.moveTextAreaEnd(e,"right")},moveTextAreaBottomEnd:function(e){this.moveTextAreaEnd(e,"bottom")},moveTextAreaLeftEnd:function(e){this.moveTextAreaEnd(e,"left")},moveTextAreaEnd:function(e,t){var i;if(!this.frozen&&e.delta){var n=e.delta;this.hideCenterLines(),this.removeSelectionAlertItems();var a=this.getSelectedTextAreaItems();if(a&&a.length>0){var r=a[0];if(r&&r.data&&r.data.isTextArea&&r.data.rect){var o=r.data.rect.clone(),s=0;(null==r?void 0:r.children.length)>0&&(s=null!==(i=null==r?void 0:r.children[0].rotation)&&void 0!==i?i:0);var l=this.getDeltaByRotationForTextArea({deltaUser:n,rotation:s,direction:t}),h="bottom";"top"==t?(r.data.rect.top+=l,h="bottom"):"right"==t?(r.data.rect.right+=l,h="left"):"bottom"==t?(r.data.rect.bottom+=l,h="top"):"left"==t&&(r.data.rect.left+=l,h="right"),this.correctTextBoxRectRotationError(r,o,h),r.data.needsTransformsDataUpdate=!0,this.drawTextAreaGuide(r),this.drawTextAreaHandles(r),this.updateTextArea({item:r}),0==r.children.length&&r.data.text&&(r.data.rect=o.clone(),r.data.needsTransformsDataUpdate=!0,this.drawTextAreaGuide(r),this.drawTextAreaHandles(r),this.updateTextArea({item:r}))}}}},getDeltaByRotationForTextArea:function(e){var t=e.deltaUser,i=e.rotation,n=e.direction,a=this.toRadians(i),r=Math.cos(a),o=Math.sin(a),s=0;if("top"==n||"bottom"==n)s=-1*o*t.x+r*t.y;else if("right"==n||"left"==n){s=r*t.x+o*t.y}return s},correctTextBoxRectRotationError:function(e,t,i){if(e&&e.data&&e.data.isTextBox&&e.data.rect){var n=0;if(e.children&&e.children.length>0?n=e.children[0].rotation:e.data.textInfo&&null!=e.data.textInfo.rotation&&(n=e.data.textInfo.rotation),0!=n){var a=new this.paper.Path.Rectangle(t);a.rotate(n),a.remove();var r=a.segments,o=null,s=null,l=null,h=null;if(4==r.length){var d=r[0].point,c=r[1].point,u=r[2].point,g=r[3].point;o=c.add(u.subtract(c).divide(2)),s=d.add(g.subtract(d).divide(2)),l=d.add(c.subtract(d).divide(2)),h=g.add(u.subtract(g).divide(2))}var f=new this.paper.Path.Rectangle(e.data.rect);f.rotate(n),f.remove();var p=f.segments,m=null,v=null,I=null,y=null;if(4==p.length){var C=p[0].point,M=p[1].point,x=p[2].point,S=p[3].point;m=M.add(x.subtract(M).divide(2)),v=C.add(S.subtract(C).divide(2)),I=C.add(M.subtract(C).divide(2)),y=S.add(x.subtract(S).divide(2))}var b=null,w=null;if("bottom"==i?(b=s,w=v):"top"==i?(b=o,w=m):"right"==i?(b=h,w=y):"left"==i&&(b=l,w=I),b&&w){var A=w.subtract(b);e.data.rect.x-=A.x,e.data.rect.y-=A.y}}}},adaptTextBoxFontSize:function(e){if(this.isItemTextBox(e)){var t=this.getItemConstraints(e);if(t&&!t.get("canChangeFontSize"))return;var i=this.getTextAreaItemInfo(e,null);if(i.adaptText)return;for(var n=i.fontSize;i.text&&0==e.children.length&&n>=1;)n-=1,this.updateTextArea({item:e,info:{fontSize:n}})}},modifyTextAreaInfo:function(e,t,i){t&&(t.text=this.adjustInputTextByConstraints(e,null!=t.text?t.text:e.data.text),t.letterSpacing=this.adjustInputLetterSpacingByConstraints(e,t.letterSpacing?parseInt(t.letterSpacing):void 0),t.lineSpacing=this.adjustInputLineSpacingByConstraints(e,t.lineSpacing?parseInt(t.lineSpacing):void 0),t.strokeWidth=this.adjustInputTextStrokeWidth(e,t.strokeWidth),t.text&&(e.data.isProfanityCheckInvalid=!1,this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e))),this.removeAllAlertItems(),this.updateTextArea({item:e,info:t,side:i}),this.checkImagesSizeLimit()},getTextAreaItemInfo:function(e,t){if(e&&e.data&&e.data.isTextArea){var i=null;if(e.children.length>0){var n=e.children[0];i={};var a="string"==typeof n.strokeColor||n.strokeColor instanceof String;i.strokeColor=a||null===n.strokeColor?n.strokeColor:n.strokeColor.toCSS(!0),i.fillColor="string"==typeof n.fillColor||n.fillColor instanceof String?n.fillColor:n.fillColor.toCSS(!0),i.strokeWidth=n.strokeWidth,i.fontFamily=n.fontFamily,i.fontWeight=n.fontWeight,i.fontStretch=n.fontStretch,i.fontSize=n.fontSize,i.scaling=n.scaling,i.rotation=n.rotation,i.shadowColor=null,n.shadowColor&&(i.shadowColor="string"==typeof n.shadowColor||n.shadowColor instanceof String?n.shadowColor:n.shadowColor.toCSS(!0)),i.shadowBlur=n.shadowBlur,i.shadowDistance=this.getOffsetDistance(n.shadowOffset),i.shadowAngle=this.getOffsetAngle(n.shadowOffset)}i=i||{};var r=this.getItemConstraints(e);(t=t||{}).text=t.text||e.data.text;var o=e.data.textInfo||{};!r||r.get("canChangeFontColor")?(t.strokeColor=void 0!==t.strokeColor?t.strokeColor:void 0!==i.strokeColor?i.strokeColor:o.strokeColor,t.fillColor=null!=t.fillColor?t.fillColor:null!=i.fillColor?i.fillColor:o.fillColor):(t.strokeColor=void 0!==i.strokeColor?i.strokeColor:o.strokeColor,t.fillColor=null!=i.fillColor?i.fillColor:o.fillColor),t.strokeWidth=null!=t.strokeWidth?t.strokeWidth:null!=i.strokeWidth?i.strokeWidth:o.strokeWidth,!r||r.get("canChangeFontFamily")?t.fontFamily=null!=t.fontFamily?t.fontFamily:null!=i.fontFamily?i.fontFamily:o.fontFamily:t.fontFamily=null!=i.fontFamily?i.fontFamily:o.fontFamily,t.fontFamily=this.sanitizeFontFamilyName(t.fontFamily);var s=null!=t.fontWeight?t.fontWeight:null!=i.fontWeight?i.fontWeight:o.fontWeight;t.fontWeight=this.adjustInputFontWeightByConstraints(null!=i.fontWeight?i.fontWeight:o.fontWeight,s,r),t.fontStretch=null!=t.fontStretch?t.fontStretch:null!=i.fontStretch?i.fontStretch:o.fontStretch,!r||r.get("canChangeFontSize")?t.fontSize=null!=t.fontSize?t.fontSize:null!=i.fontSize?i.fontSize:o.fontSize:t.fontSize=null!=i.fontSize?i.fontSize:o.fontSize,t.scaling=null!=t.scaling?t.scaling:null!=i.scaling?i.scaling:o.scaling,t.scaling=t.scaling||1,t.justification=null!=t.justification?t.justification:null!=e.data.justification?e.data.justification:"justify",t.rotation=null!=i.rotation?i.rotation:o.rotation,t.rotation=t.rotation||0,t.isTextBox=e.data&&e.data.isTextBox,t.adaptText=null!=t.adaptText?t.adaptText:null!=e.data.adaptText&&e.data.adaptText,t.wrapTextOnAdaptText=this.canWrapTextOnAdaptText(e),!r||r.get("canChangeVerticalAlignment")?t.verticalAlignment=null!=t.verticalAlignment?t.verticalAlignment:null!=e.data.verticalAlignment?e.data.verticalAlignment:"top":t.verticalAlignment=null!=e.data.verticalAlignment?e.data.verticalAlignment:"top";null!=t.letterSpacing?t.letterSpacing:null!=e.data.letterSpacing&&e.data.letterSpacing;t.letterSpacing=this.adjustInputLetterSpacingByConstraints(e,t.letterSpacing);null!=t.lineSpacing?t.lineSpacing:null!=e.data.lineSpacing&&e.data.lineSpacing;return t.lineSpacing=this.adjustInputLineSpacingByConstraints(e,t.lineSpacing),!r||r.get("canChangeShadowColor")?t.shadowColor=void 0!==t.shadowColor?t.shadowColor:void 0!==i.shadowColor?i.shadowColor:o.shadowColor:t.shadowColor=void 0!==i.shadowColor?i.shadowColor:o.shadowColor,!r||r.get("canChangeShadowBlur")?t.shadowBlur=void 0!==t.shadowBlur?t.shadowBlur:null!=i.shadowBlur?i.shadowBlur:o.shadowBlur:t.shadowBlur=void 0!==i.shadowBlur?i.shadowBlur:o.shadowBlur,!r||r.get("canChangeShadowDistance")?t.shadowDistance=void 0!==t.shadowDistance?t.shadowDistance:null!=i.shadowDistance?i.shadowDistance:o.shadowDistance:t.shadowDistance=void 0!==i.shadowDistance?i.shadowDistance:o.shadowDistance,!r||r.get("canChangeShadowAngle")?t.shadowAngle=void 0!==t.shadowAngle?t.shadowAngle:null!=i.shadowAngle?i.shadowAngle:o.shadowAngle:t.shadowAngle=void 0!==i.shadowAngle?i.shadowAngle:o.shadowAngle,this.allowShadows()||(t.shadowColor=null,e.data.originalShadowColor=null),t.shadowBlur=this.adjustInputShadowBlur(e,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(e,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(e,t.shadowAngle),t}return null},setTextAreaItemInfo:function(e,t){e&&(e.data.textInfo=t)},updateTextArea:function(e){var t,i,n=e.item,a=e.info,r=e.side,o=e.isTextBoxClicked,s=void 0!==o&&o;if(n&&n.data&&n.data.isTextArea&&n.data.rect){var l=n.data.text||a.text,h=this.getTextAreaItemInfo(n),d=null,c=this.findDesignItemForItem(n);c&&(d=this.getDesignEffectForDesignItem(c));var u=null,g=null,f=null;a&&void 0!==a.strokeColor&&(u=a.strokeColor,u=this.forceColorInFixedPalette(n,u,h.strokeColor,r),a.strokeColor=this.applyDesignEffectToTextColor(d,u),n.data.originalStrokeColor=u),a&&null!=a.fillColor&&(g=a.fillColor,g=this.forceColorInFixedPalette(n,g,h.fillColor,r),a.fillColor=this.applyDesignEffectToTextColor(d,g),n.data.originalFillColor=g),a&&void 0!==a.shadowColor&&(f=a.shadowColor,f=this.forceColorInFixedPalette(n,f,h.shadowColor,r),a.shadowColor=this.applyDesignEffectToTextColor(d,f),n.data.originalShadowColor=f),this.beginDesignOperation();var p=n.bounds.clone();if(a=this.getTextAreaItemInfo(n,a)){!n.data.isTextBox&&(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.originalMatrix)&&(a.disableScaling=!0);var m=a.text;n.data.justification=a.justification,n.data.text=a.text,n.data.adaptText=a.adaptText,n.data.letterSpacing=a.letterSpacing,n.data.lineSpacing=a.lineSpacing,n.data.verticalAlignment=a.verticalAlignment;var v=a.rotation;a.scaling.x,a.scaling.y,n.matrix.clone();if(n.data.isTextBox){var I=n.data.rect.center.clone();n.rotate(-v,I)}else n.rotate(0-v);var y=n.bounds.clone();if(n.removeChildren(),n.data.isTextBox?n.data.adaptText?this.updateTextboxAdaptCanvas(n,l,a):(s&&(n.data.rect=y),this.updateTextboxCanvas(n,n.data.rect,a)):this.updateTextAreaCanvas(n,y,a),this.applyDesignEffectToItem(d,n),n.data.isTextBox){I=n.data.rect.center.clone();n.rotate(v,I)}else(null===(i=null==n?void 0:n.data)||void 0===i?void 0:i.originalMatrix)&&(this.paper.project.view.update(),this.setScaleRotationMatrix(n.matrix,n.data.originalMatrix));n.data.isTextBox||this.alignTextAreaItem(n,v,a.justification,p,m),n.data.isTextBox||(n.data.rect=n.bounds.clone()),this.setTextAreaItemInfo(n,a),this.updateSelectionState(),this.paper.project.view.update()}this.endDesignOperation()}},updateTextAreaCanvas:function(e,t,i){var n=this.createWrappedText(t,i,!1).textItems;if(this.hasTextItemsStroke(n)){var a=this.getExternalStrokeText(n);e.addChildren(a)}e.addChildren(n)},updateTextboxAdaptCanvas:function(e,t,i){var n=null;if(t&&t.length>0&&i.text&&Math.abs(t.length-i.text.length)>5){var a=Math.abs(t.length-i.text.length),r=i.fontSize,o=i.fontSize;for(t.length<i.text.length?(o=i.fontSize,(r=this.adjustTextFontSize(e,o-4*a))<1&&(r=1)):(r=i.fontSize,o=this.adjustTextFontSize(e,r+4*a)),i.fontSize=Math.round(r+(o-r)/2);i.fontSize-r>0&&o-i.fontSize>0;)n&&n.textItems.forEach(function(e){return e.remove()}),(n=this.createWrappedText(e.data.rect,i,!0)).limitsExceeded?o=i.fontSize:r=i.fontSize,i.fontSize=Math.round(r+(o-r)/2)}for(n||(n=this.createWrappedText(e.data.rect,i,!0));!n.limitsExceeded&&this.canSetTextFontSizePx(e,i.fontSize+1);)n.textItems.forEach(function(e){return e.remove()}),i.fontSize+=1,n=this.createWrappedText(e.data.rect,i,!0);for(;n.limitsExceeded&&i.fontSize>1&&this.canSetTextFontSizePx(e,i.fontSize-1);)n.textItems.forEach(function(e){return e.remove()}),i.fontSize-=1,n=this.createWrappedText(e.data.rect,i,!0);var s=n.textItems;if(this.hasTextItemsStroke(s)){var l=this.getExternalStrokeText(s);e.addChildren(l)}e.addChildren(s)},updateTextboxCanvas:function(e,t,i){var n=this.createWrappedText(t,i,!0).textItems;if(this.hasTextItemsStroke(n)){var a=this.getExternalStrokeText(n);e.addChildren(a)}e.addChildren(n)},hasTextItemsStroke:function(e){var t=!1;if(e.length>0){var i=e[0];i.strokeWidth>0&&i.strokeColor&&(t=!0)}return t},getExternalStrokeText:function(e){var t=[];return e.forEach(function(e){var i=e.clone(!1);t.push(i),e.strokeWidth=0,e.shadowColor=null,e.shadowBlur=0,e.shadowOffset=new paper.Point(0,0)}),t},setScaleRotationMatrix:function(e,t){var i=[t.a,t.b,t.c,t.d,e.tx,e.ty];e.set(i),this.paper.project.view.update()},alignTextAreaItem:function(e,t,i,n,a){if(null!=a){var r=new this.paper.Point(n.x+n.width/2,n.y+n.height/2);if("center"!=i&&"justify"!=i){var o=new this.paper.Point(n.left+e.bounds.width/2,n.top+e.bounds.height/2),s=new this.paper.Point(n.right-e.bounds.width/2,n.top+e.bounds.height/2),l=new this.paper.Point(n.left+e.bounds.width/2,n.bottom-e.bounds.height/2),h=new this.paper.Point(n.right-e.bounds.width/2,n.bottom-e.bounds.height/2);t>=0&&t<=90?r="left"==i?o:h:t>90&&t<=180?r="left"==i?s:l:t>=-90&&t<0?r="left"==i?l:s:t>-180&&t<-90&&(r="left"==i?h:o),e.position=r;var d=e.data.text.split("\n"),c=a.split("\n"),u=d.length-c.length;if(d.length!=c.length){var g=e.children[0].clone();g.visible=!1,g.rotate(0-t);var f=new this.paper.Path.Circle("left"==i?g.bounds.topLeft.clone():g.bounds.topRight.clone(),1);f.visible=!1,f.pivot=new this.paper.Point(g.position.x,g.position.y),f.rotate(t),f.pivot=null,t>=0&&t<=90?"left"==i?r.x-=(f.position.x-e.children[0].bounds.left)*u:r.y+=(e.children[0].bounds.bottom-f.position.y)*u:t>90&&t<=180?"left"==i?r.y-=(f.position.y-e.children[0].bounds.top)*u:r.x-=(f.position.x-e.children[0].bounds.left)*u:t>=-90&&t<0?"left"==i?r.y+=(e.children[0].bounds.bottom-f.position.y)*u:r.x+=(e.children[0].bounds.right-f.position.x)*u:t>-180&&t<-90&&("left"==i?r.x+=(e.children[0].bounds.right-f.position.x)*u:r.y-=(f.position.y-e.children[0].bounds.top)*u),f.remove(),g.remove()}}e.position=r}},onTextAreaGuidesUpdated:function(e){var t=this.getSelectedItems()[0];t&&t.data&&t.data.isTextArea&&(this.updateSelectionState(),this.updateTextArea({item:t}),t.data.isTextBox||(t.data.rect=this.findTextAreaGuide(t).bounds.clone()))},forceSelectedTextAreasToBounds:function(){for(var e=this.getSelectedTextAreaItems(),t=0;t<e.length;t++)this.forceTextAreaToBounds(e[t])},forceTextAreaToBounds:function(e){if(e&&e.data&&e.data.isTextArea&&e.data.rect&&!e.data.isTextBox){var t=e.bounds.clone();t.isEmpty()||(e.data.rect=t)}},createWrappedText:function(e,t,i,n){var a=this,r=this,o=!1,s=[],l=t.text,h=/[\u0590-\u05ff\u0600-\u06ff]/.test(l),d=null!=t.justification?t.justification:"justify";if(i){var c=this.createPointText(".",t);if(c.remove(),c.bounds.width>e.width+.001)return Logger.info("text area too small for even a single text char"),{limitsExceeded:o=!0,textItems:s}}var u=this.getLineHeight(t);if(u>e.height+.001)return Logger.info("text area too small for even a single text char"),{limitsExceeded:o=!0,textItems:s};var g=this.getSpaceWidth(t),f=this.getTextExtraSpace(t),p=null,m=[],v=[],I=[],y=e.width,C=e.x+e.width,M=e.y+e.height;i||(C=Number.MAX_VALUE),i||(M=Number.MAX_VALUE);var x=e.x,S=e.y+u,b=!1;(null==t?void 0:t.disableScaling)&&(t.scaling,t.scaling=new this.paper.Point(1,1),u=this.getLineHeight(t),g=this.getSpaceWidth(t),f=this.getTextExtraSpace(t));for(var w=function(e){if(null===e||0===e.length)return 0;if(e instanceof r.paper.PointText)return e.bounds.width;var t=e[0].bounds.x,i=e[e.length-1].bounds.right;return Math.abs(i-t)},A=function(e,i){if(e)if(r.isLetterSpacingSpecified(t)){if(e&&e.length>=0){var n=r.createPointText(i,t);n.justification="center";var a=function(e,i){if(!r.isLetterSpacingSpecified(t))return 0;var n=0,a=r.createPointText(i,t);a.justification="center",a.remove(),null!==e&&0!==e.length||(n=x+a.bounds.width/2);var o=e[e.length-1],s=r.createPointText(o.content+i,t);return s.remove(),n=o.point.x+(s.bounds.width-o.bounds.width/2-a.bounds.width/2),n+=f,n=Math.max(n,o.point.x)}(e,i);n.point=new r.paper.Point(a,S),e.push(n),s.push(n)}}else e.content+=i},P=function(e){if(e)if(r.isLetterSpacingSpecified(t)){if(e.length>0)for(var i=0;i<e.length;i++)e[i].remove(),s.pop()}else e.remove(),s.pop()},D=function(e){if(e&&e.length>0){var i=e[0],n=e[e.length-1],a=0,o=0;if(r.isLetterSpacingSpecified(t)){if(0==i.length)return 0;if(0==n.length)return 0;a=i[0].bounds.x,o=n[n.length-1].bounds.right}else a=i.bounds.x,o=n.bounds.right;return Math.abs(o-a)}return 0},k=function(){p=null,m=[],!0!==t.adaptText||!1!==t.wrapTextOnAdaptText?(x=e.x,(S+=u+r.getLineExtraSpace(t))>M&&(b=!0,o=!0)):o=!0},_=function(){m.push(p),1===m.length&&(v.push(m),1===v.length&&I.push(v))},T=function(e){var i=r.createPointText(e,t);this.paper.project.view.update(),r.isLetterSpacingSpecified(t)&&(i.justification="center");var n=i.bounds.width;if(x+n>C&&(m&&m.length>0?k():o=!0),b||o)i.remove();else{if(r.isLetterSpacingSpecified(t)?i.point=new r.paper.Point(x+i.bounds.width/2,S):i.point=new r.paper.Point(x,S),0==I.length&&i.bounds.bottom>S){var a=i.bounds.bottom-S;S-=a,M-=a,r.isLetterSpacingSpecified(t)?i.point=new r.paper.Point(x+i.bounds.width/2,S):i.point=new r.paper.Point(x,S)}p=r.isLetterSpacingSpecified(t)?[i]:i,s.push(i),_()}},z=function(e){if(A(p,e),x+w(p)>C+1e-4)if(1==m.length||t.adaptText)if(t.adaptText)m.pop(),P(p),o=!0;else{if(r.isLetterSpacingSpecified(t))p.pop().remove(),s.pop();else p.content=p.content.substring(0,p.content.length-1);k(),T(e)}else{var i=p;m.pop(),k(),p=i,b?P(p):(!function(e,i,n){if(e)if(r.isLetterSpacingSpecified(t)){if(e.length>0)for(var a=e[0].bounds.x-i,o=0;o<e.length;o++)e[o].point=new r.paper.Point(e[o].point.x-a,n)}else e.point=new r.paper.Point(i,n)}(p,x,S),_())}},O=function(e){p&&0!==p.length?z(e):T(e)},B=0;B<l.length&&!b&&!o;B++){var E=l[B];"\n"==E?(k(),v=[]):" "===E?(p&&(x+=w(p)),p=null,x+g<=C?x+=g+f:k()):O(E)}var R=void 0,F=void 0;for(B=0;B<I.length;B++)for(var L=I[B],G=0;G<L.length;G++){if(0!==(Z=L[G]).length){for(var U=0;U<Z.length;U++){var j=Z[U];j instanceof r.paper.PointText?(R=null==R?j.bounds.top:Math.min(R,j.bounds.top),F=null==F?j.bounds.bottom:Math.max(F,j.bounds.bottom)):j.length>0&&j.forEach(function(e){R=null==R?e.bounds.top:Math.min(R,e.bounds.top),F=null==F?e.bounds.bottom:Math.max(F,e.bounds.bottom)})}if("justify"!=d||G!=L.length-1){var N=D(Z);N>y&&(y=N),h&&this.invertLineRtlWords(Z,e.x,e.x+e.width,g,t),this.justifyLine(Z,e,e.x+N,d,t)}}}var W=null==R||null==F?0:e.height-Math.abs(F-R);if(i&&W>0&&("middle"==t.verticalAlignment||"bottom"==t.verticalAlignment)){"middle"==t.verticalAlignment&&(W/=2);for(B=0;B<I.length;B++)for(L=I[B],G=0;G<L.length;G++){var Z;if(0!==(Z=L[G]).length)for(U=0;U<Z.length;U++){var H=Z[U];H instanceof r.paper.PointText?H.point=new this.paper.Point(H.point.x,H.point.y+W):H.length>0&&H.forEach(function(e){e.point=new a.paper.Point(e.point.x,e.point.y+W)})}}}return i||(e.width=y),{limitsExceeded:o||b,textItems:s}},justifyLine:function(e,t,i,n,a){var r=this,o=function(e,t,i){if(e)if(e instanceof r.paper.PointText)e.point=new r.paper.Point(t,i);else if(e.length>0)for(var n=e[0].bounds.x-t,a=0;a<e.length;a++)e[a].point=new r.paper.Point(e[a].point.x-n,i)};if(e.length>0){var s=i-t.x,l=t.width-s;if("justify"==n){if(e.length>1)for(var h=l/(e.length-1),d=1;d<e.length;d++){if((c=e[d])instanceof r.paper.PointText)c.point=new this.paper.Point(c.point.x+h*d,c.point.y);else o(c,c[0].bounds.x+h*d,c[0].point.y)}}else if("right"==n)for(d=0;d<e.length;d++){if((c=e[d])instanceof r.paper.PointText)c.point=new this.paper.Point(c.point.x+l,c.point.y);else o(c,c[0].bounds.x+l,c[0].point.y)}else if("center"==n)for(d=0;d<e.length;d++){var c;if((c=e[d])instanceof r.paper.PointText)c.point=new this.paper.Point(c.point.x+l/2,c.point.y);else o(c,c[0].bounds.x+l/2,c[0].point.y)}}},invertLineRtlWords:function(e,t,i,n,a){var r=this,o=(n=this.getSpaceWidth(a),this.getTextExtraSpace(a)),s=function(e){if(null===e||0===e.length)return 0;if(e instanceof r.paper.PointText)return e.bounds.width;for(var t=[],i=0;i<e.length;i++)t[i]=e[i];t.sort(function(e,t){return e.point.x>t.point.x?1:t.point.x>e.point.x?-1:0});var n=t[0].bounds.x,a=t[t.length-1].bounds.right;return Math.abs(a-n)},l=function(e,t,i){if(e&&t)if(e instanceof r.paper.PointText)e.point=new r.paper.Point(i,e.point.y);else if(t&&t.length>0)for(var n=t[0].bounds.x-i,a=0;a<t.length;a++)t[a].point=new r.paper.Point(t[a].point.x-n,t[a].point.y)},h=function(e){var t="";if(!e||0==e.length)return t;if(e instanceof r.paper.PointText)return e.content;for(var i=0;i<e.length;i++)t+=e[i].content;return t},d=function(e){return/[\u0590-\u05ff\u0600-\u06ff]/.test(e)},c=function(e){return/[!,.:;?]/g.test(e)},u=function(e){var t=h(e),i=t,n="",a="";if(d(t)){for(var r=t.length-1;r>=0&&(a=t.substring(r),!d(a));r--)n=a,i=t.substring(0,r);i&&n&&(e.content=n+i)}else{for(r=t.length-1;r>=0&&(a=t[r],c(a));r--)n=t.substring(r),i=t.substring(0,r);i&&n&&(e.content=n+i)}return e},g=function(e){var t=h(e),i=-1;if(d(t)){for(var s=e.length-1;s>=0;s--)if(d(h(e.slice(s)))){i=s+1;break}}else for(s=e.length-1;s>=0;s--)if(!c(e[s].content)){i=s+1;break}var l=e.slice(0);if(i>=0){l=[];for(s=i;s<e.length;s++)l[s-i]=e[s];for(s=0;s<i&&s<e.length;s++)l[e.length-1-s]=e[s];var u=e[0].bounds.x,g=u,f=null,p=null;for(s=0;s<l.length;s++){if(f=l[s],0==s)g=u+f.bounds.width/2;else{p=l[s-1];var m=r.createPointText(p.content+f.content,a);m.remove(),g=p.point.x+(m.bounds.width-p.bounds.width/2-f.bounds.width/2),g+=n*o,g=Math.max(g,p.point.x)}f.point.x=g}}return l};if(e.length>1)for(var f=t,p=e.length-1;p>=0;p--){var m=e[p],v=m;v=!r.isLetterSpacingSpecified(a)&&m instanceof r.paper.PointText?u(m):g(m),p<e.length-1&&(f+=n+o),l(m,v,f),f+=s(v)}else 1==e.length&&(r.isLetterSpacingSpecified(a)?g(e[0]):u(e[0]))},getLineHeight:function(e){var t=this.createPointText("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",e);return t.remove(),t.bounds.height},getLineWidth:function(e,t){var i=this.createPointText(e,t);return i.remove(),i.bounds.width},getSpaceWidth:function(e){var t=this.createPointText(" ",e);return t.remove(),t.bounds.width},getFontAscent:function(e){var t=this.getShortcutFontProperty(e),i=this.fontAscentCache.hasOwnProperty(t)?this.fontAscentCache[t]:null,n=this.createPointText("M",e),a=n.bounds;n.remove();var r=Math.floor(a.width)+1,o=Math.floor(a.height)+1;if(!i){var s=$("<canvas>",{id:Math.floor(99999*Math.random()+1)}).attr({width:r,height:o})[0],l=s.getContext("2d");l.fillRect(0,0,s.width,s.height),l.textBaseline="top",l.fillStyle="white",l.font=t,l.fillText("M",0,0);for(var h=l.getImageData(0,0,s.width,s.height).data,d=-1,c=-1,u=0;u<s.height;u++)for(var g=0;g<s.width;g++){if(0!==h[4*(u*s.width+g)]){-1===d&&(d=u);break}if(g===s.width-1&&-1!==d){c=u,u=s.height;break}}i=c-d,this.fontAscentCache[t]=i}return i},getShortcutFontProperty:function(e){var t=e.fontSize+"px "+e.fontFamily;return e.fontStretch&&"normal"!=e.fontStretch&&(t=e.fontStretch+" "+t),e.fontWeight&&"normal"!=e.fontWeight&&(t=e.fontWeight+" "+t),e.fontStyle&&"normal"!=e.fontStyle&&(t=e.fontStyle+" "+t),t},getTextExtraSpace:function(e){return null!=e.letterSpacing?.75*e.letterSpacing:0},isLetterSpacingSpecified:function(e){return null!=e.letterSpacing&&0!=e.letterSpacing},getLineExtraSpace:function(e){return null!=e.lineSpacing?.75*e.lineSpacing:0},isLineSpacingSpecified:function(e){return null!=e.lineSpacing&&0!=e.lineSpacing},toggleSelectionTextOnPath:function(){for(var e=[],t=this.getSelectedTextItems(),i=0;i<t.length;i++){var n=this.toggleItemTextOnPath(t[i]);n&&e.push(n)}return e},convertSelectedTextItemsToTextOnPath:function(){return this.convertSelectionToTextOnPath()},convertSelectedTextOnPathItemsToText:function(){return this.convertSelectionToText()},convertSelectionToText:function(){for(var e=[],t=this.getSelectedTextItems(),i=0;i<t.length;i++){var n=this.convertToText(t[i]);n&&e.push(n)}return e},convertSelectionToTextOnPath:function(){for(var e=[],t=this.getSelectedTextItems(),i=0;i<t.length;i++){var n=this.convertToTextOnPath(t[i]);n&&(n.data.isTemplateElement=t[i].data&&t[i].data.isTemplateElement,e.push(n))}return e},convertSelectionToTextArea:function(){for(var e=[],t=this.getSelectedTextItems(),i=0;i<t.length;i++){var n=this.convertToTextArea(t[i]);n&&e.push(n)}return e},toggleItemTextOnPath:function(e){return e?e instanceof this.paper.TextItem||e&&e.data&&e.data.isTextArea?this.convertToTextOnPath(e):e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0?this.convertToTextArea(e):this.convertToText(e):null},convertToTextOnPath:function(e){return!this.canChangeItemTextPathMode(e)||e.data&&e.data.isTextOnPath?null:e&&e instanceof this.paper.TextItem?this.fromTextToTextOnPath(e):e&&e.data&&e.data.isTextArea&&e.data.rect?this.fromTextAreaToTextOnPath(e):void 0},convertToText:function(e){return!this.getItemIsTextArea(e)&&!this.canChangeItemTextPathMode(e)||this.getItemIsTextArea(e)&&!this.canChangeItemTextAreaMode(e)||e instanceof this.paper.TextItem?null:e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0?this.fromTextOnPathToText(e):e&&e.data&&e.data.isTextArea&&e.data.rect?this.fromTextAreaToText(e):void 0},convertToTextArea:function(e){return!this.canChangeItemTextAreaMode(e)||e.data&&e.data.isTextArea?null:e&&e instanceof this.paper.TextItem?this.fromTextToTextArea(e):e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0?this.fromTextOnPathToTextArea(e):void 0},fromTextToTextOnPath:function(e){if(!this.canChangeItemTextPathMode(e))return null;var t=null;if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid")),e.remove(),this.onItemRemoved(e);var r=null;e.shadowColor&&(r="string"==typeof e.shadowColor||e.shadowColor instanceof String?e.shadowColor:e.shadowColor.toCSS(!0));var o={};o.text=e.content,o.strokeColor=e.strokeColor,o.strokeWidth=e.strokeWidth,o.fillColor=e.fillColor,o.fontFamily=e.fontFamily,o.fontWeight=e.fontWeight,o.fontSize=e.fontSize,o.scaling=e.scaling,o.rotation=e.rotation,o.shadowColor=r,o.shadowBlur=e.shadowBlur,o.shadowDistance=this.getOffsetDistance(e.shadowOffset),o.shadowAngle=this.getOffsetAngle(e.shadowOffset),e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(o.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(o.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(o.shadowColor=e.data.originalShadowColor));var s=(t=this.addTextOnPathElement(e.position,o,!0)).position.clone();if(t.position.y=e.bounds.top+t.bounds.height/2,s.x=0-s.x+t.position.x,s.y=0-s.y+t.position.y,this.onTextOnPathMoved(t,s),this.updateTextOnPathGuide(t),n){var l=this.findDesignItemForItem(t);l&&l.setConstraintsFromSource(n)}this.onItemUpdated(t),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.updateItemSyncGuid(t,a)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(t),this.joinUndoChains(e,t),t},fromTextToTextArea:function(e){if(!this.canChangeItemTextAreaMode(e))return null;var t=null;if(this.beginDesignOperation(),e&&e instanceof this.paper.TextItem){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid"));var r=e.bounds.clone();r.bottom=r.bottom,r.bottom+=5*r.height,e.remove(),this.onItemRemoved(e);var o=null;e.shadowColor&&(o="string"==typeof e.shadowColor||e.shadowColor instanceof String?e.shadowColor:e.shadowColor.toCSS(!0));var s=null;e.strokeColor&&(s="string"==typeof e.strokeColor||e.strokeColor instanceof String?e.strokeColor:e.strokeColor.toCSS(!0));var l={};if(l.text=e.content,l.strokeWidth=e.strokeWidth,l.strokeColor=s,l.fillColor="string"==typeof e.fillColor||e.fillColor instanceof String?e.fillColor:e.fillColor.toCSS(!0),l.fontFamily=e.fontFamily,l.fontWeight=e.fontWeight,l.fontSize=e.fontSize,l.scaling=e.scaling,l.rotation=e.rotation,l.justification=e.data&&e.data.justification?e.data.justification:void 0!==e.justification?e.justification:"justify",l.shadowColor=o,l.shadowBlur=e.shadowBlur,l.shadowDistance=this.getOffsetDistance(e.shadowOffset),l.shadowAngle=this.getOffsetAngle(e.shadowOffset),l.lineSpacing=e.lineSpacing,l.letterSpacing=e.letterSpacing,e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(l.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(l.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(l.shadowColor=e.data.originalShadowColor)),r.left=e.bounds.left,r.right=e.bounds.right,r.top=e.bounds.top,(t=this.addTextAreaElement(r,l,!0)).position.y=r.top+t.bounds.height/2,t.position.x=r.left+e.bounds.width/2,t.data.rect=t.bounds.clone(),t.data.originalMatrix=t.matrix.clone(),(null==t?void 0:t.children.length)>0){var h=t.children[0],d=h.matrix.a,c=h.matrix.b,u=h.matrix.c,g=h.matrix.d,f=t.bounds.centerX,p=t.bounds.centerY;t.data.originalMatrix=new this.paper.Matrix(d,c,u,g,f,p)}if(this.updateTextAreaGuide(t),n){var m=this.findDesignItemForItem(t);m&&m.setConstraintsFromSource(n)}this.onItemUpdated(t),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.updateItemSyncGuid(t,a)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(t),this.joinUndoChains(e,t),t},fromTextOnPathToText:function(e){if(!this.canChangeItemTextPathMode(e))return null;var t=null;if(this.beginDesignOperation(),e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid")),e.remove(),this.onItemRemoved(e);var r=e.data.text;if(!r)for(var o=0;o<e.children.length;o++)r+=e.children[o].content;var s=null,l=e.children[0].shadowColor;l&&(s="string"==typeof l||l instanceof String?l:l.toCSS(!0));var h={};h.text=r,h.strokeColor=e.children[0].strokeColor,h.strokeWidth=e.children[0].strokeWidth,h.fillColor=e.children[0].fillColor,h.fontFamily=e.children[0].fontFamily,h.fontWeight=e.children[0].fontWeight,h.fontStretch=e.children[0].fontStretch,h.fontSize=e.children[0].fontSize,h.scaling=e.children[0].scaling,h.shadowColor=s,h.shadowBlur=e.children[0].shadowBlur,h.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),h.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset),e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(h.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(h.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(h.shadowColor=e.data.originalShadowColor));var d=e.data.points[0],c=(e.data.points[1],e.data.points[2].subtract(d)),u=d.add(c.divide(2));if(h.rotation=c.angle,t=this.addTextElement(u,h,!0),n){var g=this.findDesignItemForItem(t);g&&(g.setConstraintsFromSource(n),this.updateSelectionState(),this.paper.project.view.update())}this.updateItemSyncGuid(t,a)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(t),this.joinUndoChains(e,t),t},fromTextOnPathToTextArea:function(e){var t;if(!this.canChangeItemTextAreaMode(e)||!this.canChangeItemTextPathMode(e))return null;var i=null;if(this.beginDesignOperation(),e&&e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0){var n=this.findDesignItemForItem(e),a=null,r=null;n&&(a=n.get("constraints"),r=n.get("syncGuid"));var o=e.bounds.clone();o.bottom=o.bottom,o.bottom+=5*o.height,e.remove(),this.onItemRemoved(e);var s=e.data.text;if(!s)for(var l=0;l<e.children.length;l++)s+=e.children[l].content;var h=null,d=e.children[0].shadowColor;d&&(h="string"==typeof d||d instanceof String?d:d.toCSS(!0));var c={};c.text=s,c.strokeColor=e.children[0].strokeColor,c.strokeWidth=e.children[0].strokeWidth,c.fillColor=e.children[0].fillColor,c.fontFamily=e.children[0].fontFamily,c.fontWeight=e.children[0].fontWeight,c.fontStretch=e.children[0].fontStretch,c.fontSize=e.children[0].fontSize,c.scaling=e.children[0].scaling,c.justification=e.data&&e.data.justification?e.data.justification:"justify",c.shadowColor=h,c.shadowBlur=e.children[0].shadowBlur,c.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),c.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset);var u=null,g=null,f=!1,p=null;if(e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(c.strokeColor=e.data.originalStrokeColor,u=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(c.fillColor=e.data.originalFillColor,g=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(f=!0,c.shadowColor=e.data.originalShadowColor,p=e.data.originalShadowColor)),o.left=e.bounds.left,o.right=e.bounds.right,o.top=e.bounds.top,i=this.addTextAreaElement(o,c,!0),u&&(i.data.originalStrokeColor=u),g&&(i.data.originalFillColor=g),f&&(i.data.originalShadowColor=p),!(null===(t=null==i?void 0:i.data)||void 0===t?void 0:t.originalMatrix)&&(null==i?void 0:i.children)&&(null==i?void 0:i.children.length)>0){var m=i.children[0],v=m.matrix.a,I=m.matrix.b,y=m.matrix.c,C=m.matrix.d,M=i.bounds.centerX,x=i.bounds.centerY;i.data.originalMatrix=new this.paper.Matrix(v,I,y,C,M,x)}if(i.position.y=o.top+i.bounds.height/2,i.position.x=o.left+e.bounds.width/2,i.data.rect=i.bounds.clone(),i.data.isTemplateElement=e.data&&e.data.isTemplateElement,this.updateTextAreaGuide(i),a){var S=this.findDesignItemForItem(i);S&&S.setConstraintsFromSource(a)}this.onItemUpdated(i),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.updateItemSyncGuid(i,r)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(i),this.joinUndoChains(e,i),i},fromTextAreaToText:function(e){if(!this.canChangeItemTextAreaMode(e))return null;var t=null;if(this.beginDesignOperation(),e&&e.data&&e.data.isTextArea&&e.data.rect){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid")),e.remove(),this.onItemRemoved(e);var r=e.data.text;if(!r)for(var o=0;o<e.children.length;o++)o>0&&(r+=" "),r+=e.children[o].content;var s=null,l=e.children[0].shadowColor;l&&(s="string"==typeof l||l instanceof String?l:l.toCSS(!0));var h={};h.text=r,h.strokeColor=e.children[0].strokeColor,h.strokeWidth=e.children[0].strokeWidth,h.fillColor=e.children[0].fillColor,h.fontFamily=e.children[0].fontFamily,h.fontWeight=e.children[0].fontWeight,h.fontStretch=e.children[0].fontStretch,h.fontSize=e.children[0].fontSize,h.scaling=e.children[0].scaling,h.shadowColor=s,h.shadowBlur=e.children[0].shadowBlur,h.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),h.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset);var d=null,c=null,u=!1,g=null;e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(h.strokeColor=e.data.originalStrokeColor,d=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(h.fillColor=e.data.originalFillColor,c=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(u=!0,h.shadowColor=e.data.originalShadowColor,g=e.data.originalShadowColor));var f=e.children[0].point;if(t=this.addTextElement(f,h,!0),d&&(t.data.strokeColor=d),c&&(t.data.fillColor=c),u&&(t.data.originalShadowColor=g),n){var p=this.findDesignItemForItem(t);p&&(p.setConstraintsFromSource(n),this.updateSelectionState(),this.paper.project.view.update())}this.updateItemSyncGuid(t,a)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(t),this.joinUndoChains(e,t),t},fromTextAreaToTextOnPath:function(e){var t,i;if(!this.canChangeItemTextPathMode(e)||!this.canChangeItemTextAreaMode(e))return null;var n=null;if(this.beginDesignOperation(),e&&e.data&&e.data.isTextArea&&e.data.rect){var a=this.findDesignItemForItem(e),r=null,o=null;a&&(r=a.get("constraints"),o=a.get("syncGuid")),e.remove(),this.onItemRemoved(e);var s=e.data.text;if(!s)for(var l=0;l<e.children.length;l++)l>0&&(s+=" "),s+=e.children[l].content;var h=null,d=e.children[0].shadowColor;d&&(h="string"==typeof d||d instanceof String?d:d.toCSS(!0));var c={};c.text=s,c.strokeColor=null!==(i=null===(t=e.children[0].strokeColor)||void 0===t?void 0:t.toCSS(!0))&&void 0!==i?i:null,c.strokeWidth=e.children[0].strokeWidth,c.fillColor=e.children[0].fillColor.toCSS(!0),c.fontFamily=e.children[0].fontFamily,c.fontWeight=e.children[0].fontWeight,c.fontStretch=e.children[0].fontStretch,c.fontSize=e.children[0].fontSize,c.scaling=e.children[0].scaling,c.shadowColor=h,c.shadowBlur=e.children[0].shadowBlur,c.shadowDistance=this.getOffsetDistance(e.children[0].shadowOffset),c.shadowAngle=this.getOffsetAngle(e.children[0].shadowOffset);var u=null,g=null,f=!1,p=null;e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(c.strokeColor=e.data.originalStrokeColor,u=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(c.fillColor=e.data.originalFillColor,g=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(f=!0,c.shadowColor=e.data.originalShadowColor,p=e.data.originalShadowColor));var m=this.getItemRealBounds(e),v=new this.paper.Point(m.x+m.width/2,e.children[0].point.y);n=this.addTextOnPathElement(v,c,!0),u&&(n.data.originalStrokeColor=u),g&&(n.data.originalFillColor=g),f&&(n.data.originalShadowColor=p),e.data&&e.data.justification&&(n.data.justification=e.data.justification);var I=n.position.clone();if(n.position.y=e.bounds.top+n.bounds.height/2,I.x=0-I.x+n.position.x,I.y=0-I.y+n.position.y,this.onTextOnPathMoved(n,I),this.updateTextOnPathGuide(n),r){var y=this.findDesignItemForItem(n);y&&y.setConstraintsFromSource(r)}this.onItemUpdated(n),this.fireSelectionChangedEvent(),this.updateSelectionState(),this.paper.project.view.update(),this.updateItemSyncGuid(n,o)}return this.endDesignOperation(),this.mergeAllUndoItemsOperations(n),this.joinUndoChains(e,n),n},removeSideBackColor:function(){if(this.side&&this.design){var e=this.design.getDesignSide(this.side);e&&this.design.get("sides").remove(e);var t=this;this.updateImageItem(function(){t.isViewer||t.updateAreaItemsColor(),t.updateSelectionState()})}},setSideBackColor:function(e){if(this.side&&this.design){var t=this.design.getDesignSide(this.side);t||((t=new MPlaza.DesignSide).set("modelID",this.design.get("modelID")),t.set("colorID",this.side.getColorID()),t.set("sideID",this.side.getSideID()),this.design.get("sides").add(t)),t.set("fillColor",e);var i=this;this.updateImageItem(function(){i.isViewer||i.updateAreaItemsColor(),i.updateSelectionState()})}},adjustInputFontWeightByConstraints:function(e,t,i){var n=t||e;if(i&&(!i.get("canChangeFontWeight")||!i.get("canChangeFontItalic"))){if("number"==typeof e)return e;n=n+="";var a=e&&-1!=e.indexOf("bold"),r=e&&-1!=e.indexOf("italic"),o=i.get("canChangeFontWeight")?-1!=n.indexOf("bold"):a,s=i.get("canChangeFontItalic")?-1!=n.indexOf("italic"):r,l=[];l.push(s?"italic":"normal"),l.push(o?"bold":"normal"),n=l.join(" ")}return n},adjustInputTextByConstraints:function(e,t){var i=t;if(e&&null!=t&&null!=t){var n=this.getItemConstraints(e);if(n&&n.get("canEdit")&&(n.get("keepNrChars")||n.get("minNrChars")>0||n.get("maxNrChars")>0)){var a="";if(e.data&&e.data.isTextOnPath&&e.data.points&&"[object Array]"===Object.prototype.toString.call(e.data.points)&&3==e.data.points.length&&e.children.length>0){if(!(a=e.data.text))for(var r=0;r<e.children.length;r++)a+=e.children[r].content}else e instanceof this.paper.TextItem?a=e.content:e.data&&e.data.isTextArt&&(a=this.getTextArtItemText(e));var o=a.length,s=n.get("minNrChars"),l=n.get("maxNrChars");if(n.get("keepNrChars")&&(s=o,l=o),s>0&&t.length<s){var h=n.get("paddingString");n.get("paddingTypeID")==MPlaza.PaddingType.Start?i=t.padStart(s,h):n.get("paddingTypeID")==MPlaza.PaddingType.End?i=t.padEnd(s,h):n.get("paddingTypeID")==MPlaza.PaddingType.StartEnd&&(i=t.padStartEnd(s,h))}l>0&&i.length>l&&(i=i.substring(0,l)),0==i.trim().length&&0==n.get("canDelete")&&(i=this.isConfigurator?"⠀":a.substring(0,1))}}return this.isConfigurator&&""==i.trim()&&(i="⠀"),i},adjustInputLetterSpacingByConstraints:function(e,t){var i=t;if(e){var n=null!=e.data.letterSpacing?e.data.letterSpacing:0;null==i&&(i=n);var a=this.getItemConstraints(e);a&&(a.get("canEdit")&&a.get("canChangeLetterSpacing")&&"number"==typeof t?(null!=a.get("minLetterSpacing")&&null!=a.get("minLetterSpacing")&&(i=Math.max(i,a.get("minLetterSpacing"))),null!=a.get("maxLetterSpacing")&&null!=a.get("maxLetterSpacing")&&(i=Math.min(i,a.get("maxLetterSpacing")))):i=n)}return i},adjustInputLineSpacingByConstraints:function(e,t){var i=t;if(e){var n=null!=e.data.lineSpacing?e.data.lineSpacing:0;null==i&&(i=n);var a=this.getItemConstraints(e);a&&(a.get("canEdit")&&a.get("canChangeLineSpacing")&&"number"==typeof t?(null!=a.get("minLineSpacing")&&null!=a.get("minLineSpacing")&&(i=Math.max(i,a.get("minLineSpacing"))),null!=a.get("maxLineSpacing")&&null!=a.get("maxLineSpacing")&&(i=Math.min(i,a.get("maxLineSpacing")))):i=n)}return i},highlightsCanvasItemFromDesignItems:function(e){var t=this;e.forEach(function(e){var i=t.findItemByGuid(e.get("itemGuid"));i&&t.createMaskAlertForItem(i)})},setInvalidItemsForProfanityCheck:function(e){this.preventAreasAndIndexUpdate=!0;var t=this;e.forEach(function(e){var i=t.getPaperItemFromDesignItem(e);i&&(i.data.isProfanityCheckInvalid=!0,t.onItemUpdated(i),i.remove())}),this.preventAreasAndIndexUpdate=!1},replaceProfanityTextFromItem:function(e,t){this.preventAreasAndIndexUpdate=!0;var i=this.paper.importJSON(e.get("json"));if(i){var n="",a=null;if(this.getItemIsTextArea(i)||this.getItemIsTextOnPath(i)?(a=this.getTextItemInfo(i),n=a.text):this.getItemIsTextArt(i)&&(a=this.getTextArtItemInfo(i),n=a.text),t.profanityList){var r=0;t.profanityList.forEach(function(e){(n=n.replace(e,e.replace(/./g,"x")))!==i.data.text&&r++}),0===r&&(n=n.replace(/./g,"x"))}this.getItemIsTextArea(i)||this.getItemIsTextOnPath(i)?this.modifyTextElementsContent(i,n):this.getItemIsTextArt(i),this.onItemUpdated(i)}this.preventAreasAndIndexUpdate=!1},undoRedoSupported:function(){return 0==this.getAllGridItems().length},beginDesignOperation:function(){this.undoRedoSupported()&&(this.currentDesignOperation&&this.currentDesignOperation.itemOperations.length>0&&this.undoStack.push(this.currentDesignOperation),this.currentDesignOperation={operationId:MPlaza.generateUUID(),itemOperations:[]})},endDesignOperation:function(){this.undoRedoSupported()&&this.currentDesignOperation&&this.currentDesignOperation.itemOperations.length>0&&(this.undoStack.push(this.currentDesignOperation),this.resetRedo(),this.currentDesignOperation=null)},registerItemOperation:function(e,t,i,n){if(this.undoRedoSupported()&&!this.executingUndoRedo){if(i&&n){var a=!1;i.get("colors").length!=n.get("colors").length&&(a=!0),n.get("colors").each(function(e,t){var n=i.get("colors").find(function(t){return t.get("colorID")==e.get("colorID")});n?n.get("colorCode")!=e.get("colorCode")&&(a=!0):a=!0});var r=i.get("index")!=n.get("index");if(i.get("json")==n.get("json")&&!a&&!r)return}var o={itemGuid:t,type:e,oldDesignItem:i,newDesignItem:n},s=!1;this.currentDesignOperation||(this.beginDesignOperation(),s=!0),this.updateDesignOperation(this.currentDesignOperation,o),s&&this.endDesignOperation()}},registerRotationOperation:function(e,t){var i=!1;this.currentDesignOperation||(this.beginDesignOperation(),i=!0);var n={type:e,degrees:t};this.updateDesignOperation(this.currentDesignOperation,n),i&&this.endDesignOperation()},updateDesignOperation:function(e,t){for(var i=null,n=-1,a=0;a<e.itemOperations.length;a++){var r=e.itemOperations[a];if(r.itemGuid==t.itemGuid){n=a,i=r;break}}if(i&&n>=0){var o=this.mergeItemOperations(i,t);e.itemOperations[n]=o||t}else e.itemOperations.push(t)},mergeItemOperations:function(e,t){var i=null;return"create"===e.type?"update"===t.type&&(i={type:"create",itemGuid:e.itemGuid,oldDesignItem:null,newDesignItem:t.newDesignItem}):"update"===e.type&&"update"===t.type&&(i={type:"update",itemGuid:e.itemGuid,oldDesignItem:e.oldDesignItem,newDesignItem:t.newDesignItem}),i},undo:function(){return __awaiter(this,void 0,void 0,function(){var e,t,i;return __generator(this,function(n){switch(n.label){case 0:if(this.executiongUndoRedo)return[2];if(!(this.undoStack.count()>0))return[3,7];this.executingUndoRedo=!0,n.label=1;case 1:n.trys.push([1,,6,7]),e=this.undoStack.pop(),t=0,n.label=2;case 2:return t<e.itemOperations.length?(i=e.itemOperations[t],[4,this.undoItemOperation(i)]):[3,5];case 3:n.sent(),n.label=4;case 4:return t++,[3,2];case 5:return this.redoStack.push(e),[3,7];case 6:return this.executingUndoRedo=!1,[7];case 7:return[2]}})})},redo:function(){return __awaiter(this,void 0,void 0,function(){var e,t,i;return __generator(this,function(n){switch(n.label){case 0:if(this.executiongUndoRedo)return[2];if(!(this.redoStack.count()>0))return[3,7];this.executingUndoRedo=!0,n.label=1;case 1:n.trys.push([1,,6,7]),e=this.redoStack.pop(),t=0,n.label=2;case 2:return t<e.itemOperations.length?(i=e.itemOperations[t],[4,this.redoItemOperation(i)]):[3,5];case 3:n.sent(),n.label=4;case 4:return t++,[3,2];case 5:return this.undoStack.push(e),[3,7];case 6:return this.executingUndoRedo=!1,[7];case 7:return[2]}})})},undoItemOperation:function(e){return __awaiter(this,void 0,void 0,function(){var t,i,n,a;return __generator(this,function(r){switch(r.label){case 0:return this.getSelectedItems().map(function(e){return e.data.guid}),t=null,"create"!=e.type?[3,1]:((i=this.findItemByGuid(e.itemGuid))&&(i.remove(),this._onItemRemovedInternal(i)),[3,7]);case 1:return"update"!==e.type?[3,4]:(n=this.findDesignItemByGuid(e.itemGuid))?(n.resetColors(),n.copyAttributes(e.oldDesignItem),[4,this.createItemForDesignItem(n)]):[3,3];case 2:t=r.sent(),r.label=3;case 3:return[3,7];case 4:return"delete"!==e.type?[3,6]:(a=e.oldDesignItem.clone(),this.design.get("designItems").add(a),[4,this.createItemForDesignItem(a)]);case 5:return t=r.sent(),[3,7];case 6:"rotation"===e.type&&this.eventsToolsCustomizer.undoRotation(e.degrees),r.label=7;case 7:return this.updateItemsIndexes(),t&&this.isItemSelected(t)&&this.selectItems([t]),this.paper.project.view.update(),[2]}})})},redoItemOperation:function(e){return __awaiter(this,void 0,void 0,function(){var t,i,n,a;return __generator(this,function(r){switch(r.label){case 0:return t=null,"create"!=e.type?[3,2]:(i=e.newDesignItem.clone(),this.design.get("designItems").add(i),[4,this.createItemForDesignItem(i)]);case 1:return t=r.sent(),[3,6];case 2:return"update"!==e.type?[3,5]:(n=this.findDesignItemByGuid(e.itemGuid))?(n.resetColors(),n.copyAttributes(e.newDesignItem),[4,this.createItemForDesignItem(n)]):[3,4];case 3:t=r.sent(),r.label=4;case 4:return[3,6];case 5:"delete"===e.type?(a=this.findItemByGuid(e.itemGuid))&&(a.remove(),this._onItemRemovedInternal(a)):"rotation"===e.type&&this.eventsToolsCustomizer.redoRotation(e.degrees),r.label=6;case 6:return this.updateItemsIndexes(),t&&this.isItemSelected(t)&&this.selectItems([t]),this.paper.project.view.update(),[2]}})})},hasUndo:function(){return this.undoRedoSupported()&&this.undoStack.count()>0},hasRedo:function(){return this.undoRedoSupported()&&this.redoStack.count()>0},resetUndoRedo:function(){this.isConfigurator||this.isViewer||(this.detachUndoRedoEvents(),this.undoStack.clear(),this.redoStack.clear(),this.attachUndoRedoEvents(),this.fireUndoChangedEvent(),this.fireRedoChangedEvent())},resetUndo:function(){this.detachUndoRedoEvents(),this.undoStack.clear(),this.attachUndoRedoEvents(),this.fireUndoChangedEvent()},resetRedo:function(){this.detachUndoRedoEvents(),this.redoStack.clear(),this.attachUndoRedoEvents(),this.fireRedoChangedEvent()},removeLastUndoItemOperation:function(){if(this.undoStack.count()>0)return this.undoStack.pop()},removeFirstRedoItemOperation:function(){if(this.redoStack.count()>0)return this.redoStack.pop()},setupUndoRedoStacks:function(){this.attachUndoRedoEvents()},attachUndoRedoEvents:function(){this.undoStack.addChangedEventListener(this.bindedUndoStackChanged),this.redoStack.addChangedEventListener(this.bindedRedoStackChanged)},detachUndoRedoEvents:function(){this.undoStack.removeChangedEventListener(this.bindedUndoStackChanged),this.redoStack.removeChangedEventListener(this.bindedRedoStackChanged)},onUndoStackChanged:function(){this.fireUndoChangedEvent()},onRedoStackChanged:function(){this.fireRedoChangedEvent()},getUndoCount:function(){return this.undoStack.count()},getRedoCount:function(){return this.redoStack.count()},clearUndoForItem:function(e){this.clearOperationsStackForItem(this.undoStack,e)},clearRedoForItem:function(e){this.clearOperationsStackForItem(this.redoStack,e)},clearOperationsStackForItem:function(e,t){if(e&&t){for(var i=e.getAllData(),n=[],a=0;a<i.length;a++){for(var r=i[a],o=0;o<r.itemOperations.length;o++){r.itemOperations[o].itemGuid===t.data.guid&&r.itemOperations.splice(o--,1)}0==r.itemOperations.length&&n.push(r)}n.length>0&&e.removeDataArray(n)}},mergeAllUndoItemsOperations:function(e){if(e){for(var t=function(e,t){for(var i=0;i<e.itemOperations.length;i++)if(e.itemOperations[i].itemGuid==t.data.guid)return e.itemOperations[i];return null},i=function(e,t){for(var i=0;i<e.itemOperations.length;i++)e.itemOperations[i].itemGuid===t.data.guid&&e.itemOperations.splice(i--,1)},n=this.undoStack.getAllData(),a=[],r=null,o=null,s=n.length-1;s>=0;s--){var l=n[s],h=t(l,e);h&&(r&&o&&(this.updateDesignOperation(l,o),i(r,e),0==r.itemOperations.length&&a.push(r)),r=l,o=h)}a.length>0&&this.undoStack.removeDataArray(a)}},joinUndoChains:function(e,t){for(var i=function(e,t){for(var i=0;i<e.itemOperations.length;i++)if(e.itemOperations[i].itemGuid===t.data.guid)return!0;return!1},n=this.undoStack.getAllData(),a=null,r=null,o=0;o<n.length;o++){var s=n[o];i(s,e)&&(a=s),i(s,t)&&!r&&(r=s)}if(a&&r&&a!==r){var l=function(e,t){for(var i=0;i<e.itemOperations.length;i++)if(e.itemOperations[i].itemGuid==t.data.guid)return e.itemOperations[i];return null}(r,t);this.updateDesignOperation(a,l),function(e,t){for(var i=0;i<e.itemOperations.length;i++)e.itemOperations[i].itemGuid===t.data.guid&&e.itemOperations.splice(i--,1)}(r,t),0==r.itemOperations.length&&this.undoStack.removeData(r)}},getLastUndoOperationId:function(){var e=this.undoStack.getLastData();return e?e.operationId:null},mergeAllUndoOperationsAfterId:function(e){var t=null;if(e){var i=this.undoStack.getLastData(function(t){return t.operationId===e});t=this.undoStack.getAllDataAfter(i)}else t=this.undoStack.getAllData();t&&this.mergeUndoDesignOperations(t)},mergeUndoDesignOperations:function(e){var t=[];if(e.length>1)for(var i=e[0],n=1;n<e.length;n++){for(var a=e[n],r=0;r<a.itemOperations.length;r++){var o=a.itemOperations[r];this.updateDesignOperation(i,o),a.itemOperations.splice(r--,1)}t.push(a)}t.length>0&&this.undoStack.removeDataArray(t)},getUsedColorsWithCount:function(){var e=new Map;if(this.ignoreUsedColorsOnColorCheck)return e;for(var t=this.usedColorsItemsToCheck||this.getAllItems(),i=0;i<t.length;i++){var n=t[i],a=this.findDesignItemForItem(n);if(!a||!a.get("constraints")||0!=a.get("constraints").get("isPrintable")){var r;if(a&&a.get("colorMappings")&&a.get("colorMappings").length>0)a.get("colorMappings").toJSON().filter(function(e){return Boolean(e.dest)}).reduce(function(e,t){return e.add(t.dest)},new Set).forEach(function(t){return e.set(t,e.has(t)?e.get(t)+1:1)});if(this.getItemIsTextElement(n))(r=this.getTextItemInfo(n)).strokeColor&&r.strokeWidth>0&&e.set(r.strokeColor,e.has(r.strokeColor)?e.get(r.strokeColor)+1:1),r.fillColor&&e.set(r.fillColor,e.has(r.fillColor)?e.get(r.fillColor)+1:1),r.shadowColor&&e.set(r.shadowColor,e.has(r.shadowColor)?e.get(r.shadowColor)+1:1);if(this.getItemIsTextArt(n))(r=this.getTextArtItemInfo(n)).style.strokeColor&&r.style.strokeWidth>0&&e.set(r.style.strokeColor,e.has(r.style.strokeColor)?e.get(r.style.strokeColor)+1:1),r.style.fillColor&&e.set(r.style.fillColor,e.has(r.style.fillColor)?e.get(r.style.fillColor)+1:1),r.style.shadowColor&&e.set(r.style.shadowColor,e.has(r.style.shadowColor)?e.get(r.style.shadowColor)+1:1);if(this.isShape(n)||this.isMaskedImage(n)){var o=this.getShapeItemStyle(n);o&&(o.strokeColor&&o.strokeWidth>0&&e.set(o.strokeColor,e.has(o.strokeColor)?e.get(o.strokeColor)+1:1),o.fillColor&&e.set(o.fillColor,e.has(o.fillColor)?e.get(o.fillColor)+1:1))}if(n.data.isGroupForBackground){var s=n.children.find(function(e){return e.data.isAreaForBackground});if(s){if(s.strokeColor&&s.strokeWidth>0){var l=s.strokeColor instanceof paper.Color?s.strokeColor.toCSS(!0):s.strokeColor;e.set(l,e.has(l)?e.get(l)+1:1)}if(s.fillColor){l=s.fillColor instanceof paper.Color?s.fillColor.toCSS(!0):s.fillColor;e.set(l,e.has(l)?e.get(l)+1:1)}}}a&&a.get("colors").length>0&&(!a.get("colorMappings")||0==a.get("colorMappings").length)&&a.get("colors").forEach(function(t){var i=t.get("colorCode");e.set(i,e.has(i)?e.get(i)+1:1)})}}return e},getUsedColors:function(){return Array.from(this.getUsedColorsWithCount().keys())},_getPrintTypeColorLimits:function(e,t){void 0===t&&(t=null);var i={maxColors:void 0,palette:[]};if(!this.design||!this.side&&!t)return i;var n=null;if(t)n=this.design.getSelectedPrintTypeForArea(t.get("areas").at(0));else{var a=this.findDesignItemForItem(e),r=null;if(a&&a instanceof MPlaza.DesignItem&&a.get("areas").length>0){var o=a.get("areas").at(0);r=this.side.findAreaByID(o.get("areaID"))}else r=this.side.get("areas").getMaxArea();n=this.design.getSelectedPrintTypeForArea(r)}var s=this.getModelPrintType(n);if(!s)return i;var l=s.get("paletteColors"),h=void 0;return null!=s.get("maxColors")&&null!=s.get("maxColors")&&s.get("maxColors")>0&&(h=s.get("maxColors")),l&&l.length>0&&(h=h?Math.min(h,l.length):l.length),h?(i.maxColors=h,i.palette=l||[],i):i},getSelectableColors:function(e,t){if(void 0===t&&(t=null),this.design&&(this.side||t)){var i=this._getPrintTypeColorLimits(e,t);if(void 0!==i.maxColors&&null!==i.maxColor){var n=i.maxColors,a=i.palette,r=this.getUsedColors();return r.length<n?a.length>0?a:void 0:r}}},getImageDefaultColorMappings:function(e,t,i,n){return void 0===n&&(n=null),__awaiter(this,void 0,void 0,function(){var a,r,o,s,l,h,d;return __generator(this,function(c){switch(c.label){case 0:return this.design&&(this.side||n)?(a=this._getPrintTypeColorLimits(t,n),r=a.maxColors,o=a.palette,null==r||null==r?[2,[]]:(s=this.getUsedColors(),i?[3,2]:[4,Zakeke.Customizer.ImageProcessor.getImagePalette(e,10)])):[2,[]];case 1:i=c.sent(),c.label=2;case 2:for(l=[],h=function(){var e=i[d],t=e;s.find(function(t){return t===e})||(s.length<r?(o.length>0&&(t=Zakeke.Customizer.ImageProcessor.remapColor(e,o)),s.find(function(e){return e===t})||s.push(t)):t=Zakeke.Customizer.ImageProcessor.remapColor(e,s)),l.push({src:e,dest:t})},d=0;d<i.length;d++)h();return[2,l]}})})},_getColorMappingSourcePalette:function(e){return e.map(function(e){return e.src}).join(",")},_getColorMappingDestPalette:function(e){return e.map(function(e){return e.dest}).join(",")},createDesignEffectForRecoloring:function(e){var t=new MPlaza.DesignEffect;t.set("blendMode","normal"),t.set("opacity",1),t.set("imageEffectTypeName","reduce colors");var i=new MPlaza.ImageEffectParameterValue;return i.set("name","palette"),i.set("value",this._getColorMappingSourcePalette(e)),t.get("imageEffectParameterValues").add(i),(i=new MPlaza.ImageEffectParameterValue).set("name","replacementPalette"),i.set("value",this._getColorMappingDestPalette(e)),t.get("imageEffectParameterValues").add(i),t},recolorImage:function(e,t){return __awaiter(this,void 0,void 0,function(){var i;return __generator(this,function(n){switch(n.label){case 0:return i=this.createDesignEffectForRecoloring(t),[4,this.applyDesignEffectToImageUrl(i,e)];case 1:return[2,n.sent()]}})})},changeColorMapping:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h;return __generator(this,function(d){switch(d.label){case 0:i=this.getLastUndoOperationId(),this.beginDesignOperation(),n=this.getAllItems(),this.usedColorsItemsToCheck=[],a=0,d.label=1;case 1:return a<n.length?(r=n[a],this.getItemIsTextArt(r)&&((o=this.getTextArtItemInfo(r)).style.strokeColor==e&&(o.style.strokeColor=t),o.style.fillColor==e&&(o.style.fillColor=t),o.style.shadowColor==e&&(o.style.shadowColor=t),this.changeTextArtStyle(r,o.style),this.onItemUpdated(r)),this.getItemIsTextOnPath(r)&&((o=this.getTextItemInfo(r)).strokeColor==e&&(o.strokeColor=t),o.fillColor==e&&(o.fillColor=t),o.shadowColor==e&&(o.shadowColor=t),this.modifyTextOnPathInfo(r,{strokeColor:o.strokeColor,fillColor:o.fillColor,shadowColor:o.shadowColor}),this.onItemUpdated(r)),this.getItemIsTextArea(r)&&((o=this.getTextItemInfo(r)).strokeColor==e&&(o.strokeColor=t),o.fillColor==e&&(o.fillColor=t),o.shadowColor==e&&(o.shadowColor=t),this.modifyTextAreaInfo(r,{strokeColor:o.strokeColor,fillColor:o.fillColor,shadowColor:o.shadowColor}),this.onItemUpdated(r)),r instanceof this.paper.Raster||this.isMaskedImage(r)?[4,this.changeImageItemColorMapping(r,null,e,t)]:[3,3]):[3,5];case 2:d.sent(),d.label=3;case 3:(this.isShape(r)||this.isMaskedImage(r))&&(s=this.isShape(r)?r:this.getMaskedImageShapeItem(r),(l=this.getShapeItemStyle(s)).strokeColor==e&&(l.strokeColor=t),l.fillColor==e&&(l.fillColor=t),this.changeShapeStyle(r,l),this.onItemUpdated(r)),r.data.isGroupForBackground&&(h=r.children.find(function(e){return e.data.isAreaForBackground}))&&((h.strokeColor instanceof paper.Color?h.strokeColor.toCSS(!0):h.strokeColor)==e&&(h.strokeColor=t),(h.fillColor instanceof paper.Color?h.fillColor.toCSS(!0):h.fillColor)==e&&(h.fillColor=t),this.onItemUpdated(h)),this.usedColorsItemsToCheck.push(r),d.label=4;case 4:return a++,[3,1];case 5:return this.usedColorsItemsToCheck=null,this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(i),[2]}})})},changeImageItemColorMapping:function(e,t,i,n){var a,r;return __awaiter(this,void 0,void 0,function(){var o,s,l,h,d,c,u,g,f,p,m,v,I,y,C;return __generator(this,function(M){switch(M.label){case 0:return e?(o=this.getImageItemInfo(e),s=this.findDesignItemByGuid(e.data.guid),l=this.getMaskedImageRasterItem(e),h=!1,o&&s&&l?(this.beginDesignOperation(),d=o.url,c=this.getDesignEffectForDesignItem(s),d,[4,this.applyDesignEffectToImageUrl(c,d)]):[3,4]):[3,4];case 1:for(d=M.sent(),u=null!==(r=null===(a=s.get("colorMappings"))||void 0===a?void 0:a.toJSON())&&void 0!==r?r:[],g=0,f=u;g<f.length;g++)p=f[g],m=t&&p.src==t&&p.dest!=n,v=i&&p.dest==i,(m||v)&&(p.dest=n,h=!0);return h?(I=this.createDesignEffectForRecoloring(u),[4,this.applyDesignEffectToImageUrl(I,d)]):[2,e];case 2:return d=M.sent(),[4,this.changeRasterItem(l,d)];case 3:M.sent(),this.applyDesignEffectToItem(c,e),this.updateDesignItemColorMappings(s,u),this.endDesignOperation(),y=this.createDummyImageFromDesignItem(s),C=this.createDummyShapeFromDesignItem(s),this.onImageItemUpdated(e,y,C),this.updateSelectionState(),this.paper.project.view.update(),M.label=4;case 4:return[2,e]}})})},forceColorInFixedPalette:function(e,t,i,n){if(void 0===n&&(n=null),!t)return t;i||(i=t),t instanceof this.paper.Color&&(t=t.toCSS(!0)),i instanceof this.paper.Color&&(i=t instanceof this.paper.Color?t.toCSS(!0):t);var a=t,r=this.getSelectableColors(e,n),o=this.getUsedColorsWithCount(),s=!r||o.has(i)&&o.get(i)<=1&&-1!==r.indexOf(i);return r&&r.length>0&&!s&&(r.find(function(e){return e===t})||(a=Zakeke.Customizer.ImageProcessor.remapColor(t,r))),a},resetRecoloring:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l;return __generator(this,function(h){switch(h.label){case 0:i=this.getLastUndoOperationId(),this.beginDesignOperation(),this.usedColorsItemsToCheck=[],n=0,h.label=1;case 1:return n<e.length?(a=e[n],this.getItemIsTextArt(a)&&((r=this.getTextArtItemInfo(a)).style.strokeColor&&(r.style.strokeColor=this.forceColorInFixedPalette(a,r.style.strokeColor,null,t)),r.style.fillColor&&(r.style.fillColor=this.forceColorInFixedPalette(a,r.style.fillColor,null,t)),r.style.shadowColor&&(r.style.shadowColor=this.forceColorInFixedPalette(a,r.style.shadowColor,null,t)),this.changeTextArtStyle(a,r.style,t)),this.getItemIsTextOnPath(a)&&((r=this.getTextItemInfo(a)).strokeColor&&(r.strokeColor=this.forceColorInFixedPalette(a,r.strokeColor,null,t)),r.fillColor&&(r.fillColor=this.forceColorInFixedPalette(a,r.fillColor,null,t)),r.shadowColor&&(r.shadowColor=this.forceColorInFixedPalette(a,r.shadowColor,null,t)),this.modifyTextOnPathInfo(a,{strokeColor:r.strokeColor,fillColor:r.fillColor,shadowColor:r.shadowColor},t)),this.getItemIsTextArea(a)&&((r=this.getTextItemInfo(a)).strokeColor&&(r.strokeColor=this.forceColorInFixedPalette(a,r.strokeColor,null,t)),r.fillColor&&(r.fillColor=this.forceColorInFixedPalette(a,r.fillColor,null,t)),r.shadowColor&&(r.shadowColor=this.forceColorInFixedPalette(a,r.shadowColor,null,t)),this.modifyTextAreaInfo(a,{strokeColor:r.strokeColor,fillColor:r.fillColor,shadowColor:r.shadowColor},t)),a instanceof this.paper.Raster||this.isMaskedImage(a)?[4,this.resetImageColorMapping(a,t,null)]:[3,3]):[3,5];case 2:h.sent(),h.label=3;case 3:(this.isShape(a)||this.isMaskedImage(a))&&(o=this.isShape(a)?a:this.getMaskedImageShapeItem(a),(s=this.getShapeItemStyle(o)).strokeColor&&(s.strokeColor=this.forceColorInFixedPalette(a,s.strokeColor,null,t)),s.fillColor&&(s.fillColor=this.forceColorInFixedPalette(a,s.fillColor,null,t)),this.changeShapeStyle(a,s)),this.isAreaForBackground(a)&&(l=a.fillColor.toCSS(!0))&&(a.fillColor=this.forceColorInFixedPalette(a,l,null,t)),this.onItemUpdated(a),this.usedColorsItemsToCheck.push(a),h.label=4;case 4:return n++,[3,1];case 5:return this.usedColorsItemsToCheck=null,this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(i),[2]}})})},resetImageColorMapping:function(e,t,i){return void 0===t&&(t=null),__awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h;return __generator(this,function(d){switch(d.label){case 0:return e?(n=this.getImageItemInfo(e,t),a=this.findDesignItemByGuid(e.data.guid),r=this.getMaskedImageRasterItem(e),n&&a&&r?(this.beginDesignOperation(),o=n.url,s=this.getDesignEffectForDesignItem(a),o,[4,this.applyDesignEffectToImageUrl(s,o)]):[3,7]):[3,7];case 1:return o=d.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(o,e,null,t)];case 2:i=d.sent(),d.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(o,i)]:[3,5];case 4:o=d.sent(),d.label=5;case 5:return[4,this.changeRasterItem(r,o)];case 6:d.sent(),this.applyDesignEffectToItem(s,e),this.updateDesignItemColorMappings(a,i),this.endDesignOperation(),l=this.createDummyImageFromDesignItem(a),h=this.createDummyShapeFromDesignItem(a),this.onImageItemUpdated(e,l,h),this.updateSelectionState(),this.paper.project.view.update(),d.label=7;case 7:return[2,e]}})})},getDesignEffectForArea:function(e){var t=this.getModelPrintType(this.design.getSelectedPrintTypeForArea(e));if(t)return t.get("previewDesignEffect")},applyDesignEffectToImageUrl:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C;return __generator(this,function(M){switch(M.label){case 0:return i=t,e&&e instanceof MPlaza.DesignEffect&&e.get("imageEffectTypeName")?(n=this._getCachedImageEffectResult(t,e))?(i=n,[3,21]):[3,1]:[3,21];case 1:if(a=null,r=e.get("imageEffectParameterValues").getValue("overlay color"),o=void 0,r&&(o=this.hex2rgb(r)),s=e.get("imageEffectParameterValues").getValue("halftone"),l=Zakeke.Customizer.HalfoneType.None,s)switch(s.toLowerCase()){case"errordiffusion":l=Zakeke.Customizer.HalfoneType.ErrorDiffusion;break;case"dithering":l=Zakeke.Customizer.HalfoneType.Dithering;break;default:l=Zakeke.Customizer.HalfoneType.None}switch(h=e.get("imageEffectParameterValues").getValueNumber("threshold level"),d=null,null!=h&&!isNaN(h)&&h>=0&&h<=255&&(d=h),c=e.get("imageEffectParameterValues").getValueBoolean("invert"),u=e.get("imageEffectParameterValues").getValue("dark color"),g={red:0,green:0,blue:0},u&&(g=this.hex2rgb(u)),f=e.get("imageEffectParameterValues").getValue("light color"),p={red:255,green:255,blue:255},f&&(p=this.hex2rgb(f)),m=e.get("imageEffectParameterValues").getValueBoolean("remove white"),v=e.get("imageEffectTypeName").toLowerCase(),v){case"greyscale":return[3,2];case"contrasted greyscale":return[3,4];case"soft greyscale":return[3,6];case"hard greyscale":return[3,8];case"black and white":return[3,10];case"black and transparent":return[3,12];case"dark and light":return[3,14];case"silhouette":return[3,16];case"reduce colors":return[3,18]}return[3,20];case 2:return[4,Zakeke.Customizer.ImageProcessor.greyScale(t,l,c,o)];case 3:return a=M.sent(),[3,20];case 4:return[4,Zakeke.Customizer.ImageProcessor.greyScalePlus(t,l,c,o)];case 5:return a=M.sent(),[3,20];case 6:return[4,Zakeke.Customizer.ImageProcessor.desaturate(t,l,c,o)];case 7:return a=M.sent(),[3,20];case 8:return[4,Zakeke.Customizer.ImageProcessor.blackAndWhite(t,l,c,o)];case 9:return a=M.sent(),[3,20];case 10:return[4,Zakeke.Customizer.ImageProcessor.thresholding(t,d,c,o)];case 11:return a=M.sent(),[3,20];case 12:return[4,Zakeke.Customizer.ImageProcessor.thresholdingTransparentWhite(t,d,c,o)];case 13:return a=M.sent(),[3,20];case 14:return[4,Zakeke.Customizer.ImageProcessor.thresholdingDarkAndLight(t,d,c,g,p)];case 15:return a=M.sent(),[3,20];case 16:return[4,Zakeke.Customizer.ImageProcessor.overlapColor(t,o,m)];case 17:return a=M.sent(),[3,20];case 18:return I=e.get("imageEffectParameterValues").getValueNumber("colors"),y=e.get("imageEffectParameterValues").getValue("palette"),C=e.get("imageEffectParameterValues").getValue("replacementPalette"),[4,Zakeke.Customizer.ImageProcessor.reduce(t,I,y,C)];case 19:return a=M.sent(),[3,20];case 20:a&&(i=URL.createObjectURL(a)),this._cacheImageEffectResult(t,e,i),M.label=21;case 21:return[2,i]}})})},applyDesignEffectToTextColor:function(e,t){return t&&e&&e.get("textColor")?e.get("textColor"):t},applyDesignEffectToShapeColor:function(e,t){return t&&e&&e.get("textColor")?e.get("textColor"):t},applyDesignEffectToItem:function(e,t,i){void 0===i&&(i=!1);var n=-1!=navigator.userAgent.indexOf("Firefox");if(t){var a="normal",r=!1,o=1;if(e&&e instanceof MPlaza.DesignEffect){var s=e.get("blendMode")||"normal";a=this.supportedBlendModes.find(function(e){return e==s.toLowerCase()})||"normal",i&&n&&(a="normal"),r=e.get("enhanceBlendMode"),null!=(o=e.get("opacity"))&&null!=o||(o=1),o=Math.max(Math.min(1,o),0)}if(t.blendMode=a,t.enhanceBlendMode=r,t.opacity=o,this.isMaskedImage(t)){var l=this.getMaskedImageShapeItem(t),h=this.getMaskedImageRasterItem(t);this.applyDesignEffectToItem(e,l,i),this.applyDesignEffectToItem(e,h,i)}}},hex2rgb:function(e){var t=String(e).match(this.RGB_HEX)||[],i=t[1],n=t[2],a=[0,0,0];if(n){var r=Number.parseInt(n,16);a=[r>>16,r>>8&255,255&r]}else i&&(a=Array.from(i,function(e){return Number.parseInt(e,16)}).map(function(e){return e<<4|e}));return{red:a[0],green:a[1],blue:a[2]}},getOrCreateItemFromDesignItem:function(e){var t,i,n,a;return __awaiter(this,void 0,void 0,function(){var r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S,b,w,A,P,D,k,_,T,z,O,B=this;return __generator(this,function(E){switch(E.label){case 0:return r=null,o=e.get("itemGuid"),s=null,l=!1,h="",d=function(e){return"[object Array]"===Object.prototype.toString.call(e)&&e.length>0&&4==e.length&&"Color"==e[0]?e.slice(1,4):e},e&&e instanceof MPlaza.DesignItem?(h=e.get("json"),s=this.getDesignEffectForDesignItem(e),c=JSON.parse(h),this.updateAreaGuid(e,c),h=JSON.stringify(c),e.get("imageID")>0?"[object Array]"===Object.prototype.toString.call(c)&&2==c.length&&"Raster"==c[0]&&c[1].source?(I=c[1].source,c[1].data&&c[1].data.originalUrl&&(I=c[1].data.originalUrl),[4,this.applyDesignEffectToImageUrl(s,I)]):[3,4]:[3,10]):[3,11];case 1:return y=E.sent(),(C=null!==(i=null===(t=e.get("colorMappings"))||void 0===t?void 0:t.toJSON())&&void 0!==i?i:[])&&C.length>0?[4,this.recolorImage(y,C)]:[3,3];case 2:y=E.sent(),E.label=3;case 3:return c[1].source=y,h=JSON.stringify(c),[3,9];case 4:return"[object Array]"===Object.prototype.toString.call(c)&&2==c.length&&"Group"==c[0]&&c[1].data&&c[1].data.isMaskedImageMainGroup?((u=c[1].children.filter(function(e){return"[object Array]"===Object.prototype.toString.call(e)&&2==e.length&&"CompoundPath"==e[0]}))&&(g=u[0],(b=g[1].strokeColor)&&(b=new this.paper.Color(b).toCSS(!0)),g[1].data&&g[1].data.originalStrokeColor&&(b=g[1].data.originalStrokeColor),D=this.applyDesignEffectToTextColor(s,b),g[1].data&&(g[1].data.originalStrokeColor=new this.paper.Color(b).toCSS(!0)),M=void 0,D&&(M=new this.paper.Color(D).components),g[1].strokeColor=M),(f=c[1].children.filter(function(e){return"[object Array]"===Object.prototype.toString.call(e)&&2==e.length&&"Group"==e[0]}))?(p=f[0],m=p[1].children.filter(function(e){return"[object Array]"===Object.prototype.toString.call(e)&&2==e.length&&"Raster"==e[0]}),v=m[0],I=v[1].source,v[1].data&&v[1].data.originalUrl&&(I=v[1].data.originalUrl),[4,this.applyDesignEffectToImageUrl(s,I)]):[3,8]):[3,9];case 5:return y=E.sent(),(C=null!==(a=null===(n=e.get("colorMappings"))||void 0===n?void 0:n.toJSON())&&void 0!==a?a:[])&&C.length>0?[4,this.recolorImage(y,C)]:[3,7];case 6:y=E.sent(),E.label=7;case 7:c[1].source!==y&&(l=!0),v[1].source=y,E.label=8;case 8:h=JSON.stringify(c),E.label=9;case 9:return[3,11];case 10:"[object Array]"===Object.prototype.toString.call(c)&&2==c.length&&"CompoundPath"==c[0]?(b=c[1].strokeColor,w=c[1].fillColor,A=c[1].shadowColor,b&&(b=new this.paper.Color(b).toCSS(!0)),w&&(w=new this.paper.Color(w).toCSS(!0)),A&&(A=new this.paper.Color(A).toCSS(!0)),c[1].data&&(c[1].data.originalStrokeColor&&(b=c[1].data.originalStrokeColor),c[1].data.originalFillColor&&(w=c[1].data.originalFillColor),c[1].data.originalShadowColor&&(A=c[1].data.originalShadowColor)),D=this.applyDesignEffectToTextColor(s,b),k=this.applyDesignEffectToTextColor(s,w),_=this.applyDesignEffectToTextColor(s,A),c[1].data&&(c[1].data.originalStrokeColor=new this.paper.Color(b).toCSS(!0),c[1].data.originalFillColor=new this.paper.Color(w).toCSS(!0),c[1].data.originalShadowColor=new this.paper.Color(A).toCSS(!0)),M=void 0,x=void 0,S=void 0,D&&(M=new this.paper.Color(D).components),k&&(x=new this.paper.Color(k).components),_&&(S=new this.paper.Color(_).components),c[1].strokeColor=M,c[1].fillColor=x,c[1].shadowColor=S,h=JSON.stringify(c)):"[object Array]"===Object.prototype.toString.call(c)&&2==c.length&&"Group"==c[0]&&c[1].data&&(c[1].data.isTextArea||c[1].data.isTextOnPath)&&(b=null,c[1].data&&c[1].data.hasOwnProperty("originalStrokeColor")?b=c[1].data.originalStrokeColor:c[1].data&&c[1].data.textInfo&&c[1].data.textInfo.hasOwnProperty("strokeColor")&&(b=new this.paper.Color(d(c[1].data.textInfo.strokeColor)).toCSS(!0)),!b&&c[1].children&&"[object Array]"===Object.prototype.toString.call(c[1].children)&&c[1].children.length>0&&(P=c[1].children[0])&&"[object Array]"===Object.prototype.toString.call(P)&&2==P.length&&"PointText"==P[0]&&P[1].strokeColor&&(b=new this.paper.Color(P[1].strokeColor).toCSS(!0)),w=null,c[1].data&&c[1].data.hasOwnProperty("originalFillColor")?w=c[1].data.originalFillColor:c[1].data&&c[1].data.textInfo&&c[1].data.textInfo.hasOwnProperty("fillColor")?w=new this.paper.Color(d(c[1].data.textInfo.fillColor)).toCSS(!0):c[1].children&&"[object Array]"===Object.prototype.toString.call(c[1].children)&&c[1].children.length>0&&(P=c[1].children[0])&&"[object Array]"===Object.prototype.toString.call(P)&&2==P.length&&"PointText"==P[0]&&P[1].fillColor&&(w=new this.paper.Color(P[1].fillColor).toCSS(!0)),A=null,c[1].data&&c[1].data.hasOwnProperty("originalShadowColor")?A=c[1].data.originalShadowColor:c[1].data&&c[1].data.textInfo&&c[1].data.textInfo.hasOwnProperty("shadowColor")?A=new this.paper.Color(d(c[1].data.textInfo.shadowColor)).toCSS(!0):c[1].children&&"[object Array]"===Object.prototype.toString.call(c[1].children)&&c[1].children.length>0&&(P=c[1].children[0])&&"[object Array]"===Object.prototype.toString.call(P)&&2==P.length&&"PointText"==P[0]&&P[1].shadowColor&&(A=new this.paper.Color(P[1].shadowColor).toCSS(!0)),D=this.applyDesignEffectToTextColor(s,b),k=this.applyDesignEffectToTextColor(s,w),_=this.applyDesignEffectToTextColor(s,A),c[1].data&&(b&&(c[1].data.originalStrokeColor=new this.paper.Color(b).toCSS(!0)),c[1].data.originalFillColor=new this.paper.Color(w).toCSS(!0),A&&(c[1].data.originalShadowColor=new this.paper.Color(A).toCSS(!0))),T=void 0,z=void 0,O=void 0,D&&(T=new this.paper.Color(D).components),k&&(z=new this.paper.Color(k).components),_&&(O=new this.paper.Color(_).components),this.isViewer,c[1].data.textInfo&&(c[1].data.textInfo.strokeColor=T,c[1].data.textInfo.fillColor=z,c[1].data.textInfo.shadowColor=O),c[1].children&&"[object Array]"===Object.prototype.toString.call(c[1].children)&&c[1].children.length>0&&c[1].children.forEach(function(e){"[object Array]"===Object.prototype.toString.call(e)&&2==e.length&&"PointText"==e[0]&&(e[1].strokeColor=T,e[1].fillColor=z,e[1].shadowColor=O)}),h=JSON.stringify(c)),E.label=11;case 11:return[4,new Promise(function(t){var i=B.findItemByGuid(o);!i&&h&&((i=B.paper.project.activeLayer.importJSON(h)).data.guid=o,i.visible=!1,l&&e.set("json",h));var n=null,a=null;if(i){if(i&&i instanceof B.paper.TextItem?a=B.convertTextToTextArea(i):i instanceof B.paper.Raster&&(n=i),B.isMaskedImage(i)||B.isFilledShape(i)){n=B.getMaskedImageRasterItem(i);var r=B.getMaskedImageShapeItem(i);r.strokeColor||(r.strokeWidth=0)}B.isShape(i)&&B.isImagePlaceholder(i)&&B.updateShapeImagePlaceholder(i),a?t(a):n?n.onLoad=function(){t(i)}:t(i)}else t(i)})];case 12:return r=E.sent(),this.applyDesignEffectToItem(s,r),[2,r]}})})},updateAreaGuid:function(e,t){for(var i=0;i<e.get("areas").length;i++){var n=e.get("areas").at(i);if(this.side){var a=this.side.get("areas").getAreaByID(n.get("areaID"));if(a){var r=a.get("guid");t[1].data.areaGuid&&(t[1].data.areaGuid=r)}}}},convertTextToTextArea:function(e){var t=null;if(e&&e instanceof this.paper.TextItem){var i=this.findDesignItemForItem(e),n=null,a=null;i&&(n=i.get("constraints"),a=i.get("syncGuid"));var r=e.bounds.clone();r.bottom=r.bottom,r.bottom+=5*r.height,e.remove();var o=null;e.shadowColor&&(o="string"==typeof e.shadowColor||e.shadowColor instanceof String?e.shadowColor:e.shadowColor.toCSS(!0));var s=null;e.strokeColor&&(s="string"==typeof e.strokeColor||e.strokeColor instanceof String?e.strokeColor:e.strokeColor.toCSS(!0));var l={};if(l.text=e.content,l.strokeWidth=e.strokeWidth,l.strokeColor=s,l.fillColor="string"==typeof e.fillColor||e.fillColor instanceof String?e.fillColor:e.fillColor.toCSS(!0),l.fontFamily=e.fontFamily,l.fontWeight=e.fontWeight,l.fontSize=e.fontSize,l.scaling=e.scaling,l.rotation=e.rotation,l.justification=e.data&&e.data.justification?e.data.justification:void 0!==e.justification?e.justification:"justify",l.shadowColor=o,l.shadowBlur=e.shadowBlur,l.shadowDistance=this.getOffsetDistance(e.shadowOffset),l.shadowAngle=this.getOffsetAngle(e.shadowOffset),l.lineSpacing=e.lineSpacing,l.letterSpacing=e.letterSpacing,e.data&&(e.data.hasOwnProperty("originalStrokeColor")&&(l.strokeColor=e.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(l.fillColor=e.data.originalFillColor),e.data.hasOwnProperty("originalShadowColor")&&(l.shadowColor=e.data.originalShadowColor)),r.left=e.bounds.left,r.right=e.bounds.right,r.top=e.bounds.top,t=this.generateTextAreaFromText(r,l,e),this.masterGroup.addChild(t),t.position.y=r.top+t.bounds.height/2,t.position.x=r.left+e.bounds.width/2,t.data.rect=t.bounds.clone(),t.data.originalMatrix=t.matrix.clone(),(null==t?void 0:t.children.length)>0){var h=t.children[0],d=h.matrix.a,c=h.matrix.b,u=h.matrix.c,g=h.matrix.d,f=t.bounds.centerX,p=t.bounds.centerY;t.data.originalMatrix=new this.paper.Matrix(d,c,u,g,f,p)}if(n){var m=this.findDesignItemForItem(t);m&&m.setConstraintsFromSource(n)}t.data.guid=e.data.guid,this.updateDesignItem(t),this.paper.project.view.update(),this.updateItemSyncGuid(t,a)}return t},generateTextAreaFromText:function(e,t,i){var n=null;if(this.side&&(a=this.side.get("areas").getMaxArea())){if(!e&&this.side){var a=this.side.get("areas").getMaxArea(),r=this.findItemForArea(a);r&&(e=r.bounds.expand(-50))}if(!e)return;if(t&&t.text){var o=this.getDesignEffectForArea(a);this.allowShadows()||(t.shadowColor=null);var s=t.strokeColor||null,l=t.fillColor||"#000000",h=t.shadowColor||null;s=this.forceColorInFixedPalette(null,s),l=this.forceColorInFixedPalette(null,l),h=this.forceColorInFixedPalette(null,h),t.strokeColor=this.applyDesignEffectToTextColor(o,s),t.fillColor=this.applyDesignEffectToTextColor(o,l),t.shadowColor=this.applyDesignEffectToTextColor(o,h),t.shadowBlur=this.adjustInputShadowBlur(null,t.shadowBlur),t.shadowDistance=this.adjustInputShadowDistance(null,t.shadowDistance),t.shadowAngle=this.adjustInputShadowAngle(null,t.shadowAngle),t.letterSpacing=null!=t.letterSpacing?t.letterSpacing:0,t.lineSpacing=null!=t.lineSpacing?t.lineSpacing:0,t.strokeWidth=this.adjustInputTextStrokeWidth(null,t.strokeWidth),n=new this.paper.Group;var d=this.createWrappedText(e,t,!1).textItems;n.addChildren(d),this.applyDesignEffectToItem(o,n),e=n.bounds,n.data.rect=e,n.data.isTextArea=!0,n.data.text=t.text,n.data.justification=null!=t.justification?t.justification:"justify",n.data.originalStrokeColor=s,n.data.originalFillColor=l,n.data.originalShadowColor=h,n.data.letterSpacing=t.letterSpacing,n.data.lineSpacing=t.lineSpacing,n.rotation=t.rotation,n.position=e.center,n.data.needsTransformsDataUpdate=!0,this.updateTransformsData(n),this.forceTextAreaToBounds(n)}this.paper.project.view.update()}return n},getDesignEffectForDesignItem:function(e){var t=null;if(this.side&&e&&e instanceof MPlaza.DesignItem&&e.get("areas").length>0){var i=e.get("areas").at(0),n=this.side.findAreaByID(i.get("areaID"));t=this.getDesignEffectForArea(n)}return t},createRasterItem:function(e,t){var i=this;return void 0===t&&(t=!0),new Promise(function(n){var a=new i.paper.Raster({crossOrigin:"anonymous",source:e,visibile:t});a.onLoad=function(){a.onLoad=void 0,n(a)}})},changeRasterItem:function(e,t){return new Promise(function(i){e.crossOrigin="anonymous",e.source=t,e.onLoad=function(){e.onLoad=void 0,i()}})},convertColorToHex:function(e){var t=void 0;return e&&e instanceof this.paper.Color&&(t=e.toCSS(!0)),t},_getImageEffectCacheKey:function(e,t){var i="image_effect_"+e,n=JSON.stringify(t.toJSON());return i+="_"+CryptoJS.SHA1(n).toString()},_emptyImageEffectCache:function(){window.imageEffectCache={}},_getCachedImageEffectResult:function(e,t){var i=this._getImageEffectCacheKey(e,t);return window.imageEffectCache.hasOwnProperty(i)?window.imageEffectCache[i]:null},_cacheImageEffectResult:function(e,t,i){if(e&&t&&i){var n=this._getImageEffectCacheKey(e,t);window.imageEffectCache[n]=i}},isMaskedImage:function(e){return e&&e instanceof this.paper.Group&&e.data&&e.data.isMaskedImageMainGroup},isMaskedImageRasterItem:function(e){return this.isImage(e)&&this.isMaskedImageClipGroup(e.parent)},isImage:function(e){return e&&e instanceof this.paper.Raster},isMaskedImageClipGroup:function(e){return e&&e instanceof this.paper.Group&&e.data&&e.data.isMaskedImageClipGroup},isMaskedImageGuideRaster:function(e){return e&&e instanceof this.paper.Raster&&e.data&&e.data.isMaskedImageGuideRaster},isMaskedImageSelected:function(){var e=this;return this.getSelectedItems().some(function(t){return e.isMaskedImage(t)})},isMaskedImageShapeItem:function(e){return e&&e.data&&e.data.isMaskedImageShape},isMaskedImageMaskItem:function(e){return e&&e.data&&e.data.isMaskedImageMask},applyMaskToImageItemAsync:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r;return __generator(this,function(o){switch(o.label){case 0:return this.canEditItem(e)?this.isImage(e)&&!this.canMaskImages()?[2,e]:this.isImage(e)&&!this.canAddMask(e)?[2,e]:this.isMaskedImage(e)&&!this.canReplaceMask(e)?[2,e]:!this.isMaskedImage(e)||t||this.canDeleteMask(e)?(n=this.getLastUndoOperationId(),this.beginDesignOperation(),a=e,t?[3,1]:(a=this.removeMaskFromImage(e),[3,3])):[2,e]:[2,e];case 1:return[4,this._loadShapePathDataAsync(t)];case 2:r=o.sent(),e&&(this.isMaskedImage(e)?a=this.updateMaskedImage(e,t,r,i):e instanceof this.paper.Raster&&(a=this.createMaskedImage(e,t,r,i))),o.label=3;case 3:return this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n),[2,a]}})})},getMaskedImageRasterItem:function(e){var t=this;if(e&&e instanceof this.paper.Raster)return e;if(e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup){var i=e.children.find(function(e){return e instanceof t.paper.Group});if(i)return i.children.find(function(e){return e instanceof t.paper.Raster})}return e&&e instanceof this.paper.Group&&e.data.isMaskedImageClipGroup?e.children.find(function(e){return e instanceof t.paper.Raster}):null},getMaskedImageShapeItem:function(e){return e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup?e.children.find(function(e){return e.data&&e.data.isMaskedImageShape}):null},getMaskedImageMaskItem:function(e){var t=this;if(e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup){var i=e.children.find(function(e){return e instanceof t.paper.Group});if(i)return i.children.find(function(e){return e&&e.data&&e.data.isMaskedImageMask})}return e&&e instanceof this.paper.Group&&e.data.isMaskedImageClipGroup?e.children.find(function(e){return e&&e.data&&e.data.isMaskedImageMask}):null},getMaskedImageClipGroupItem:function(e){var t=this;return e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup?e.children.find(function(e){return e instanceof t.paper.Group}):e&&e instanceof this.paper.Group&&e.data.isMaskedImageClipGroup?e:null},getMaskedImageGuideRasterItem:function(e){return e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup?e.children.find(function(e){return e.data&&e.data.isMaskedImageGuideRaster}):null},getMaskedImageFromGuideRasterItem:function(e){if(e&&e instanceof this.paper.Raster&&e.data.isMaskedImageGuideRaster){var t=e.parent;if(t&&t instanceof this.paper.Group&&t.data&&t.data.isMaskedImageMainGroup)return t}return null},getMaskedImageGuideShapeItem:function(e){return e&&e instanceof this.paper.Group&&e.data.isMaskedImageMainGroup?e.children.find(function(e){return e.data&&e.data.isMaskedImageGuideShape}):null},getMaskedImageFromGuideShapeItem:function(e){if(e&&e instanceof this.paper.CompoundPath&&e.data.isMaskedImageGuideShapeItem){var t=e.parent;if(t&&t instanceof this.paper.Group&&t.data&&t.data.isMaskedImageMainGroup)return t}return null},getMaskedImageMaskPathStyle:function(e){var t=void 0;if(e){var i=this.getMaskedImageShapeItem(e);i&&(t={strokeColor:i.strokeColor?i.strokeColor.toCSS(!0):void 0,strokeWidth:i.strokeWidth,strokeCap:i.strokeCap,strokeJoin:i.strokeJoin,dashArray:i.dashArray,dashOffset:i.dashOffset},i.data.hasOwnProperty("originalStrokeColor")&&(t.strokeColor=i.data.originalStrokeColor))}return t},createMaskedImage:function(e,t,i,n){if(!this.canMaskImages()||!this.canAddMask(e))return e;if(e&&e instanceof this.paper.Raster&&i){var a=this.findDesignItemForItem(e);if(a){var r=this.getDesignEffectForDesignItem(a),o=this.isItemSelected(e),s=e.parent,l=e.bounds.width,h=e.bounds.height;delete e.data.selected;var d=this.boundPath(i,l,h),c=new this.paper.CompoundPath(d);c.position=e.position,c.data.isMaskedImageMask=!0;var u=c.clone();u.data.originalBounds=u.bounds,u.data.originalMatrix=new this.paper.Matrix,u.data.originalParentMatrix=new this.paper.Matrix,u.data.isMaskedImageShape=!0;var g=n.strokeColor;g=this.forceColorInFixedPalette(e,g),n.strokeColor=this.applyDesignEffectToTextColor(r,g),this.applyStyleToMaskShape(u,n),u.data.originalStrokeColor=g;var f=new this.paper.Group(c);f.clipped=!0,f.data.isMaskedImageClipGroup=!0;var p=new this.paper.Group(f,u);p.applyMatrix=!1,p.data.guid=e.data.guid,delete e.data.guid,p.data.isMaskedImageMainGroup=!0,p.data.originalBounds=u.bounds,p.data.originalMatrix=new this.paper.Matrix,e.data.maskPath&&e.data.maskPath.remove(),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),e.data.hasOwnProperty("isGridImage")&&(p.data.isGridImage=e.data.isGridImage,delete e.data.isGridImage),e.data.hasOwnProperty("gridBoxID")&&(p.data.gridBoxID=e.data.gridBoxID,delete e.data.gridBoxID),this.applyDesignEffectToItem(r,p,!0),s.addChild(p),p.insertAbove(e),f.addChild(e);var m=this.createDummyImageFromDesignItem(a);return this.onImageItemUpdated(p,m,t),e.data.selected=!1,p.data.selected=o,this.updateSelectionState(),p}}return e},updateMaskedImage:function(e,t,i,n){if(!this.canReplaceMask(e))return e;if(e&&this.isMaskedImage(e)){var a=this.findDesignItemForItem(e);if(a){var r=this.getDesignEffectForDesignItem(a),o=this.getMaskedImageShapeItem(e),s=this.getMaskedImageMaskItem(e),l=this.getMaskedImageRasterItem(e);if(o&&s&&l){delete l.data.selected;var h=n,d=this.getMaskedImageMaskPathStyle(e);this.canChangeMaskStrokeColor(e)&&h.strokeColor||(h.strokeColor=d.strokeColor),this.canChangeMaskStrokeWidth(e)&&h.strokeWidth||(h.strokeWidth=d.strokeWidth);var c=h.strokeColor;c=this.forceColorInFixedPalette(e,c),h.strokeColor=this.applyDesignEffectToTextColor(r,c);var u=o.bounds;if(o.data.originalBounds&&o.data.originalMatrix){u=o.data.originalBounds;var g=new this.paper.Path.Rectangle(0,0,u.width,u.height);g.visible=!1,g.matrix=o.data.originalMatrix.clone();var f=this.getRectangleItemSize(g);g.remove(),u=new this.paper.Rectangle(0,0,f.width,f.height)}else{var p=new this.paper.Path.Rectangle(0,0,l.width,l.height);p.remove(),p.scale(l.scaling),u=p.bounds}var m=l.position,v=o.data.originalParentMatrix?o.data.originalParentMatrix:o.matrix,I=u.width,y=u.height,C=this.boundPath(i,I,y),M=new this.paper.CompoundPath(C),x=M.clone();this.applyStyleToItem(x,h),s.removeChildren(),s.copyContent(M),o.removeChildren(),o.copyContent(x),o.data.originalStrokeColor=c,M.remove(),x.remove(),o.matrix=v.clone(),o.position=m.clone(),s.matrix=v.clone(),s.position=m.clone();var S=this.createDummyImageFromDesignItem(a);this.onImageItemUpdated(e,S,t),this.updateSelectionState()}}}},updateMakedImageMaskStyle:function(e,t){if(e&&this.isMaskedImage(e)){var i=this.findDesignItemForItem(e);if(i){var n=this.getDesignEffectForDesignItem(i),a=this.getMaskedImageShapeItem(e);if(a){this.beginDesignOperation();var r=this.getMaskedImageMaskPathStyle(e),o=r.strokeColor;this.canChangeMaskStrokeColor(e)&&null!=t.strokeColor&&(o=t.strokeColor),t.strokeColor=o;var s=r.strokeWidth;this.canChangeMaskStrokeWidth(e)&&null!=t.strokeWidth&&null!=t.strokeWidth&&(s=t.strokeWidth),t.strokeWidth=s,a.data.originalStrokeColor=null!=t.strokeWidth?t.strokeColor:void 0,a.data.originalStrokeColor=this.forceColorInFixedPalette(e,a.data.originalStrokeColor),t.strokeColor=this.applyDesignEffectToTextColor(n,a.data.originalStrokeColor),this.applyStyleToItem(a,t);var l=this.createDummyImageFromDesignItem(i),h=this.createDummyShapeFromDesignItem(i);this.onImageItemUpdated(e,l,h),this.endDesignOperation()}}}},removeMaskFromImage:function(e){var t=e;if(e&&this.isMaskedImage(e)&&!this.isFilledShape(e)){var i=this.isItemSelected(e),n=e.parent,a=this.findDesignItemForItem(e),r=this.getMaskedImageRasterItem(e);if(a&&r){var o=e.matrix;(t=r).data.guid=e.data.guid,n.insertChild(e.index,t),e.remove(),t.matrix.prepend(o),t.data.originalMatrix&&t.data.originalMatrix.prepend(o);var s=this.createDummyImageFromDesignItem(a);this.onImageItemUpdated(t,s,null),e.data.selected=!1,t.data.selected=i,this.updateSelectionState()}}return t},boundPath:function(e,t,i){var n=Raphael.pathBBox(e),a=t/n.width,r=i/n.height,o=Math.min(a,r);0===o&&(o=1);var s="s"+o+","+o+",0,0",l=Raphael.transformPath(e,"t"+-n.x+","+(i/o-n.y));return(l=Raphael.transformPath(l,s)).toString()},applyStyleToMaskShape:function(e,t){e&&e instanceof this.paper.Item&&(null!=t.strokeColor&&(e.strokeColor=t.strokeColor),null!=t.strokeWidth&&(e.strokeWidth=t.strokeWidth),t.strokeCap&&(e.strokeCap=t.strokeCap),t.strokeJoin&&(e.strokeJoin=t.strokeJoin),null!=t.dashOffset&&(e.dashOffset=t.dashOffset),t.dashArray&&(e.dashArray=t.dashArray))},getReferenceItemForSelectedItem:function(e){if(this.isMaskedImage(e)){var t=e;return this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster?t=this.getMaskedImageGuideRasterItem(e):this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask&&(t=this.getMaskedImageGuideShapeItem(e)),t}return e},getItemBounds:function(e){var t=e.bounds;if(this.isMaskedImage(e)){var i=this.getMaskedImageShapeItem(e);if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster){var n=this.getMaskedImageGuideRasterItem(e);n&&(i=n)}else if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask){var a=this.getMaskedImageGuideShapeItem(e);a&&(i=a)}if(i)if(e.applyMatrix)t=i.bounds;else{var r=i.clone();r.remove(),r.matrix=r.matrix.prepend(e.matrix),t=r.strokeBounds}}return t},getImageWidth:function(e){if(this.isMaskedImage(e)){var t=this.getMaskedImageShapeItem(e);if(t){if(!e.applyMatrix){var i=t.clone();return i.remove(),i.matrix=i.matrix.prepend(e.matrix),i.bounds.width}return t.bounds.width}}else if(this.isImage(e))return e.width;return 0},getImageHeight:function(e){if(this.isMaskedImage(e)){var t=this.getMaskedImageShape(e);if(t){if(!e.applyMatrix){var i=t.clone();return i.remove(),i.matrix=i.matrix.prepend(e.matrix),i.bounds.height}return t.bounds.height}}else if(this.isImage(e))return e.height;return 0},_loadShapePathDataAsync:function(e){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(i){switch(i.label){case 0:return e&&e instanceof MPlaza.Shape&&(t=e.get("pathDataUrl"))?[4,this._loadFileAsync(t,!1)]:[3,2];case 1:return[2,i.sent()];case 2:return[2]}})})},_loadFileAsync:function(e,t){return void 0===t&&(t=!0),new Promise(function(i,n){FileTools.LoadFile(e,function(e){i(e)},void 0,void 0,t,function(e,t){n(t)})})},_loadRandomShapeAsync:function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=Math.floor(3e3*Math.random())+1,[4,this._loadShapeByIdAsync(e)];case 1:return[2,t.sent()]}})})},_loadShapeByIdAsync:function(e){return new Promise(function(t,i){new MPlaza.Shape({shapeID:e}).fetch({success:function(e,i,n){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(i){return t(e),[2]})})},error:function(e,t,n){Logger.info("Error while loading shape"),i()},data:{}})})},createMaskedImageGuideRaster:function(e){if(this.isMaskedImage(e)){var t=this.getMaskedImageGuideRasterItem(e);if(t)return t;var i=this.getMaskedImageRasterItem(e);return i&&(t=i.clone(),i.data.originalBounds&&(t.data.originalBounds=i.data.originalBounds.clone()),i.data.originalMatrix&&(t.data.originalMatrix=i.data.originalMatrix.clone()),t.parent=e,t.sendToBack(),t.opacity=.3,t.data.isMaskedImageGuideRaster=!0),t}},createMaskedImageGuideShape:function(e){if(this.isMaskedImage(e)){var t=this.getMaskedImageGuideShapeItem(e);if(t)return t;var i=this.getMaskedImageShapeItem(e);if(i){(t=i.clone()).blendMode="normal",t.opacity=1,i.data.originalBounds&&(t.data.originalBounds=i.data.originalBounds.clone()),i.data.originalMatrix&&(t.data.originalMatrix=i.data.originalMatrix.clone()),t.parent=e,t.bringToFront();var n="red";n=i.strokeWidth>0&&i.strokeColor?MPlaza.getContrastYIQ(255*i.strokeColor.red,255*i.strokeColor.green,255*i.strokeColor.blue):this.getContrastedColor(i.bounds),t.strokeColor=n,t.strokeWidth=2,t.dashArray=[4,10],t.data.isMaskedImageGuideShape=!0}return t}},removeMaskedImageGuideRaster:function(e){var t=this.getMaskedImageGuideRasterItem(e);t&&t.remove()},removeMaskedImageGuideShape:function(e){var t=this.getMaskedImageGuideShapeItem(e);t&&t.remove()},updateMaskedImageGuides:function(e){for(var t=this.getAllImageItems(),i=0;i<t.length;i++){e=t[i];this.isItemSelected(e)?this.isMaskedImage(e)&&(this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element?(this.createMaskedImageGuideRaster(e),this.createMaskedImageGuideShape(e)):(this.removeMaskedImageGuideRaster(e),this.removeMaskedImageGuideShape(e))):(this.removeMaskedImageGuideRaster(e),this.removeMaskedImageGuideShape(e))}},getSubItemsToChange:function(e){var t=[];if(e)if(this.isMaskedImage(e)&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element){if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Raster){var i=this.getMaskedImageGuideRasterItem(e);i&&t.push(i);var n=this.getMaskedImageRasterItem(e);n&&t.push(n)}else if(this.maskedImageSelectionMode==MaskedImageSelectionMode.Mask){var a=this.getMaskedImageGuideShapeItem(e);a&&t.push(a);var r=this.getMaskedImageShapeItem(e);r&&t.push(r);var o=this.getMaskedImageMaskItem(e);o&&t.push(o)}}else t.push(e);return t},switchMaskedImageSelectionMode:function(e){this.hitTest(e.point),this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element?this.setMaskedImageSelectionMode(MaskedImageSelectionMode.Element):this.hitItem==this.selectionMaskMoveShape?this.setMaskedImageSelectionMode(MaskedImageSelectionMode.Mask):this.hitItem==this.selectionMaskMoveImage&&this.setMaskedImageSelectionMode(MaskedImageSelectionMode.Raster)},setMaskedImageSelectionMode:function(e){var t=this.getSelectedMaskedImageItems();if(t.length>0){var i=t[0],n=!0;this.canEditItem(i)?(e!==MaskedImageSelectionMode.Mask||this.canEditMask(i)||(n=!1),e!==MaskedImageSelectionMode.Raster||this.canEditMaskedImage(i)||(n=!1)):n=!1,n?(this.applyTransformationsToMaskImageSubItems(),this.maskedImageSelectionMode=e,this.updateSelectionState()):this.maskedImageSelectionMode=MaskedImageSelectionMode.Element}else this.maskedImageSelectionMode=MaskedImageSelectionMode.Element},applyTransformationsToMaskImageSubItems:function(){for(var e=this,t=this.getSelectedImageItems().filter(function(t){return e.isMaskedImage(t)}),i=0;i<t.length;i++){var n=t[i];if(!n.applyMatrix){var a=n.matrix.clone();n.matrix=new this.paper.Matrix;var r=[];r.push(this.getMaskedImageShapeItem(n)),r.push(this.getMaskedImageMaskItem(n)),r.push(this.getMaskedImageRasterItem(n)),r.forEach(function(e){e.matrix.prepend(a),e.data.originalMatrix&&e.data.originalMatrix.prepend(a),e.data.originalPosition&&(e.data.originalPosition=e.data.originalPosition.transform(a)),e.data.originalParentMatrix&&e.data.originalParentMatrix.prepend(a)})}}},insertRandomShape:function(e){return __awaiter(this,void 0,void 0,function(){var t,i;return __generator(this,function(n){switch(n.label){case 0:return t=e||{isImagePlaceholder:!0,style:{strokeColor:"black",strokeWidth:2,fillColor:"darkred"}},[4,this._loadRandomShapeAsync()];case 1:return i=n.sent(),[4,this.insertShape(i,t)];case 2:return[2,n.sent()]}})})},insertShape:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n,a,r,o,s,l,h,d,c,u,g,f,p,m,v;return __generator(this,function(I){switch(I.label){case 0:return i=null,t?this.canAddShape()?(this.beginDesignOperation(),[4,this._loadShapePathDataAsync(e)]):[2,i]:[2];case 1:return(n=I.sent())&&this.side&&(a=this.side.get("areas").getMaxArea())&&(r=this.getDesignEffectForArea(a),o=t.style.strokeColor,s=t.style.fillColor,o=this.forceColorInFixedPalette(null,o),s=this.forceColorInFixedPalette(null,s),t.style.strokeColor=this.applyDesignEffectToTextColor(r,o),t.style.fillColor=this.applyDesignEffectToTextColor(r,s),i=new this.paper.CompoundPath(n),this.applyStyleToItem(i,t.style),i.data={},i.data.isShape=!0,i.data.originalBounds=i.bounds,i.data.originalMatrix=new this.paper.Matrix,i.data.originalPosition=i.position,i.data.originalStrokeColor=o,i.data.originalFillColor=s,i.data.isImagePlaceholder=t.isImagePlaceholder,this.applyDesignEffectToItem(r,i),this.onShapeItemCreated(i,e,t),(l=this.findItemForArea(a))&&(h=l.position.subtract(i.position),i.position.x+=h.x,i.position.y+=h.y,d=(new this.paper.Matrix).translate(h.x,h.y),i.data.originalMatrix.prepend(d),i.data.originalPosition=i.data.originalPosition.transform(d),c=i.bounds,((u=l.bounds).intersects(c)||c.contains(u))&&((g=u.clone()).width*=.8,g.height*=.8,f=1,p=1,Math.abs(g.width)>1e-7&&(f=g.width/c.width),Math.abs(g.height)>1e-7&&(p=g.height/c.height),m=f>0?1:-1,v=p>0?1:-1,f=p=Math.min(Math.abs(f),Math.abs(p)),f*=m,p*=v,i.scale(f,p),d=(new this.paper.Matrix).scale(f,p),i.data.originalMatrix.prepend(d),i.data.originalPosition=i.data.originalPosition.transform(d),this.masterGroup.addChild(i),this.onItemUpdated(i),this.updateItemsIndexes(),this.onDesignItemChanged(i),this.fireShapeLoadedEvent(),this.mask&&this.mask.bringToFront()))),this.endDesignOperation(),[2,i]}})})},replaceSelectedShape:function(e,t){return __awaiter(this,void 0,void 0,function(){var i,n;return __generator(this,function(a){switch(a.label){case 0:return t&&this.design?(i=this.getSelectedShapeItems())&&i.length>0?(n=i[0],this.canEditItem(n)?[4,this.replaceShape(n,e,t)]:[2]):[3,2]:[2];case 1:a.sent(),a.label=2;case 2:return[2]}})})},replaceShapeByGuid:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(a){switch(a.label){case 0:return(n=this.findItemByGuid(e))?[4,this.replaceShape(n,t,i)]:[3,2];case 1:return[2,a.sent()];case 2:return[2,null]}})})},replaceShape:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x;return __generator(this,function(S){switch(S.label){case 0:return this.canEditItem(e)?(this.beginDesignOperation(),(n=this.isShape(e)?e:this.getMaskedImageShapeItem(e))?[4,this._loadShapePathDataAsync(t)]:[2,e]):[2,e];case 1:return(a=S.sent())&&(r=this.findDesignItemByGuid(e.data.guid))&&(o=this.getDesignEffectForDesignItem(r),s=this.getShapeItemStyle(n),l=s.strokeColor,this.canChangeShapeStrokeColor(e)&&null!=i.style.strokeColor&&(l=i.style.strokeColor),i.style.strokeColor=l,h=s.strokeWidth,this.canChangeShapeStrokeWidth(e)&&null!=i.style.strokeWidth&&null!=i.style.strokeWidth&&(h=i.style.strokeWidth),i.style.strokeWidth=h,d=s.fillColor,this.canChangeShapeFillColor(e)&&null!=i.style.fillColor&&(d=i.style.fillColor),i.style.fillColor=d,c=null!=i.style.strokeWidth?i.style.strokeColor:void 0,u=i.style.fillColor,c=this.forceColorInFixedPalette(e,c),u=this.forceColorInFixedPalette(e,u),i.style.strokeColor=this.applyDesignEffectToTextColor(o,c),i.style.fillColor=this.applyDesignEffectToTextColor(o,u),g=e.bounds.width,f=e.bounds.height,(p=new this.paper.CompoundPath(a)).visible=!1,this.applyStyleToItem(p,i.style),p.transform(e.data.originalMatrix),p.position=e.position,e.removeChildren(),e.copyContent(p),m=e.data,e.copyAttributes(p),e.data=m,e.visible=!0,e.data.originalStrokeColor=c,e.data.originalFillColor=u,e.data.isImagePlaceholder=i.isImagePlaceholder,p.remove(),v=e.bounds.width,I=e.bounds.height,y=1,C=1,v>0&&Math.abs(g)>1e-7&&(y=g/v),I>0&&Math.abs(f)>1e-7&&(C=f/I),e.scale(y,C),M=(new this.paper.Matrix).scale(y,C),e.data.originalMatrix.prepend(M),x=this.createDummyImageFromDesignItem(r),this.onShapeItemUpdated(e,t,x),this.updateSelectionState(),this.paper.project.view.update(),this.fireShapeLoadedEvent()),this.endDesignOperation(),[2]}})})},changeShapeStyle:function(e,t){if(this.canEditItem(e)&&(this.isShape(e)||this.isFilledShape(e))){var i=this.isShape(e)?e:this.getMaskedImageShapeItem(e);if(i){var n=this.getShapeItemStyle(i),a=n.strokeColor;this.canChangeShapeStrokeColor(e)&&null!=t.strokeColor&&(a=t.strokeColor),t.strokeColor=a;var r=n.strokeWidth;this.canChangeShapeStrokeWidth(e)&&null!=t.strokeWidth&&null!=t.strokeWidth&&(r=t.strokeWidth),t.strokeWidth=r;var o=n.fillColor;if(this.canChangeShapeFillColor(e)&&null!=t.fillColor&&(o=t.fillColor),t.fillColor=o,e&&e instanceof this.paper.Item){this.beginDesignOperation();var s=this.findDesignItemByGuid(e.data.guid),l=this.getDesignEffectForDesignItem(s),h=t.strokeColor,d=t.fillColor;h=this.forceColorInFixedPalette(e,h),d=this.forceColorInFixedPalette(e,d),t.strokeColor=this.applyDesignEffectToTextColor(l,h),t.fillColor=this.applyDesignEffectToTextColor(l,d),this.applyStyleToItem(e,t),i.data.originalStrokeColor=h,i.data.originalFillColor=d,this.isSetSideEnded&&s.set("isChanged",!0),this.onItemUpdated(e),this.endDesignOperation()}}}},updateShapeImagePlaceholders:function(e){var t=this;e.forEach(function(e){t.updateShapeImagePlaceholder(e)})},_removeShapesReferenceBounds:function(){this.shapesReferenceBounds&&this.shapesReferenceBounds.forEach(function(e){return e.remove()}),this.shapesReferenceBounds=[]},_updateShapesReferenceBounds:function(){this.removeShapesReferenceBounds();for(var e=this.getAllShapeItems(),t=0;t<e.length;t++){var i=e[t],n=null;if(this.isFilledShape(i)?n=this.getMaskedImageShapeItem(i):this.isShape(i)&&(n=i),n&&n.data&&n.data.originalBounds&&n.data.originalMatrix&&n.data.originalPosition){var a=new this.paper.Path.Rectangle(n.data.originalBounds);a.strokeColor="red",a.strokeWidth=3,a.matrix=n.data.originalMatrix,a.position=n.data.originalPosition.clone(),this.shapesReferenceBounds.push(a);var r=new this.paper.Path.Circle(n.data.originalPosition,5);r.fillColor="red",this.shapesReferenceBounds.push(r);var o=n.clone(),s=o.position.clone();o.rotate(-n.data.originalMatrix.rotation,s);var l=o.bounds;o.remove();var h=new this.paper.Path.Rectangle(l);h.strokeColor="blue",h.strokeWidth=3,h.rotate(n.data.originalMatrix.rotation,s),this.shapesReferenceBounds.push(h)}}},updateShapeImagePlaceholder:function(e){var t=this;if(this.removeShapeImagePlaceholder(e),e instanceof this.paper.CompoundPath&&e.data&&e.data.isShape&&e.data.isImagePlaceholder&&!e.data.isMaskedImageShape){var i=e.clone();delete i.data.guid,i.data.isShapePlaceholderPath=!0,i.guide=!0,i.data.shapeGuid=e.data.guid,i.opacity=1,i.blendMode="normal",i.strokeColor="none",i.strokeWidth=0,i.fillColor="#ededed",i.onMouseEnter=function(){return t.paper.project.view.element.style.setProperty("cursor","pointer")},i.onMouseLeave=function(){return t.paper.project.view.element.style.setProperty("cursor",null)};var n=i.interiorPoint,a=0,r=0,o=0;i.children.forEach(function(e){e.segments.forEach(function(e){a+=e.point.x,r+=e.point.y,o++})}),o>0&&(n=new paper.Point(a/o,r/o));var s=new this.paper.Path.Circle(n,this.shapeImagePlaceholderIconFillerSize);s.fillColor="#ededed",s.data.isShapePlaceholderIcon=!0,s.data.shapeGuid=e.data.guid,s.onMouseEnter=function(){return t.paper.project.view.element.style.setProperty("cursor","pointer")},s.onMouseLeave=function(){return t.paper.project.view.element.style.setProperty("cursor",null)},s.onMouseUp=function(){return t.fireFillShapeRequestedEvent({itemGuid:e.data.guid})};var l=new this.paper.CompoundPath(this.shapeImagePlaceholderIconPathd),h=i.bounds.width/l.bounds.width>6?2:1;l.data.isShapePlaceholderIcon=!0,l.data.shapeGuid=e.data.guid,l.fillColor="#222222";var d=this.paper.view.zoom>.25?this.paper.view.zoom:1.5*this.paper.view.zoom;l.scaling=new this.paper.Size(h/d,h/d),l.onMouseEnter=function(){return t.paper.project.view.element.style.setProperty("cursor","pointer")},l.onMouseLeave=function(){return t.paper.project.view.element.style.setProperty("cursor",null)},l.onMouseUp=function(){return t.fireFillShapeRequestedEvent({itemGuid:e.data.guid})},l.position=n,i.insertAbove(e),l.insertAbove(i),s.insertAbove(i)}},removeShapeImagePlaceholder:function(e){this.getShapeImagePlaceholderElements(e).forEach(function(e){return e.remove()})},getShapeImagePlaceholderElements:function(e){var t=[];if(e&&e.data&&e.data.guid)for(var i=function(n){if(n.data&&(n.data.isShapePlaceholderPath||n.data.isShapePlaceholderIcon)&&n.data.shapeGuid==e.data.guid&&t.push(n),n.children)for(var a=n.children.length-1;a>=0;a--){var r=n.children[a];i(r)}},n=0;n<this.paper.project.layers.length;n++){var a=this.paper.project.layers[n];a.guide||i(a)}return t},isShape:function(e){return e&&e.data&&e.data.isShape},getShapeItemStyle:function(e){var t=void 0;if(!e)return t;var i=this.isShape(e)?e:this.getMaskedImageShapeItem(e);return i&&(t={},e.strokeColor&&(t.strokeColor=i.strokeColor.toCSS(!0)),t.strokeWidth=i.strokeWidth,t.strokeCap=i.strokeCap,t.strokeJoin=i.strokeJoin,t.dashArray=i.dashArray,t.dashOffset=i.dashOffset,i.fillColor&&(t.fillColor=i.fillColor.toCSS(!0)),i.data.hasOwnProperty("originalStrokeColor")&&(t.strokeColor=i.data.originalStrokeColor),e.data.hasOwnProperty("originalFillColor")&&(t.fillColor=i.data.originalFillColor)),t},isFilledShape:function(e){return this.isMaskedImage(e)&&e.data&&e.data.isFilledShape},isImagePlaceholder:function(e){return this.isShape(e)&&!this.isFilledShape(e)&&e.data&&e.data.isImagePlaceholder},fillShapeItemWithImageAsync:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a;return __generator(this,function(r){switch(r.label){case 0:return this.canEditItem(e)&&(this.isShape(e)||this.isFilledShape(e))?(this.isImagePlaceholder(e)&&this.changeShapeImagePlaceholder(e,!1),n=this.getLastUndoOperationId(),this.beginDesignOperation(),a=e,t?[3,1]:(a=this.removeImageFromShape(e),[3,5])):[2,e];case 1:return this.isFilledShape(e)?[4,this.updateFilledShapeAsync(e,t,i)]:[3,3];case 2:return a=r.sent(),[3,5];case 3:return this.isShape(e)?[4,this.createFilledShapeAsync(e,t,i)]:[3,5];case 4:a=r.sent(),r.label=5;case 5:return this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(n),[2,a]}})})},createFilledShapeAsync:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v,I,y,C,M,x,S;return __generator(this,function(b){switch(b.label){case 0:return this.isShape(e)&&(t&&t instanceof MPlaza.Image&&(e.data&&e.data.isImagePlaceholder||this.canFillShape(e)))?(n="",!this.isImageScalingEnabled&&"svg"!=t.get("format").toLowerCase()&&"vector"!=t.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(e){return e==t.get("format").toLowerCase()})&&(n=t.get("url")),n||(n=t.get("previewUrl")),n?e&&e instanceof this.paper.CompoundPath&&e.data&&e.data.isShape&&(a=this.findDesignItemForItem(e))?(r=this.getDesignEffectForDesignItem(a),o=this.isItemSelected(e),e.parent,s=n,[4,this.applyDesignEffectToImageUrl(r,n)]):[3,7]:[2,e]):[2,e];case 1:return n=b.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(n,e)];case 2:i=b.sent(),b.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(n,i)]:[3,5];case 4:n=b.sent(),b.label=5;case 5:return[4,this.createRasterItem(n,!1)];case 6:return(l=b.sent()).data.originalUrl=s,this.applyDesignEffectToItem(r,l),h=e.bounds.clone(),d=new this.paper.Matrix,c=e.position,e.data.originalBounds&&e.data.originalMatrix&&e.data.originalPosition&&(u=e.clone(),g=u.position.clone(),u.rotate(-e.data.originalMatrix.rotation,g),f=u.bounds,h=f.clone(),u.remove(),(p=new this.paper.Path.Rectangle(f)).rotate(e.data.originalMatrix.rotation,g),c=p.position,p.remove(),d.rotate(e.data.originalMatrix.rotation),e.data.flips&&e.data.flips.forEach(function(e){return"X"==e?d.scale(-1,-1):d.scale(1,-1)})),m=1,v=1,h.width>1e-7&&l.bounds.width>0&&(m=h.width/l.bounds.width),h.height>1e-7&&l.bounds.height>0&&(v=h.height/l.bounds.height),m=v=Math.max(Math.abs(m),Math.abs(v)),l.scale(m,v),l.matrix.prepend(d),l.position=c,l.data.originalBounds=new this.paper.Rectangle(0,0,l.width,l.height),l.data.originalMatrix=l.matrix.clone(),e.fillColor=null,e.originalParentMatrix=new this.paper.Matrix,e.data.isMaskedImageShape=!0,(I=e.clone()).data={},I.position=e.position,I.data.isMaskedImageMask=!0,y=null!=e.data.originalStrokeColor?e.data.originalStrokeColor:void 0,y=this.forceColorInFixedPalette(e,y),C=this.applyDesignEffectToTextColor(r,y),e.strokeColor=C,e.data.originalStrokeColor=y,(M=new this.paper.Group(I,l)).clipped=!0,M.data.isMaskedImageClipGroup=!0,l.visibile=!0,(x=new this.paper.Group(M)).insertAbove(e),x.addChild(e),x.applyMatrix=!1,x.data.guid=e.data.guid,delete e.data.guid,x.data.isMaskedImageMainGroup=!0,x.data.isFilledShape=!0,x.data.originalBounds=e.bounds,x.data.originalMatrix=new this.paper.Matrix,x.data.isNewImageIntoShape=!0,e.data.maskPath&&e.data.maskPath.remove(),this.removeProfanityCheckInvalidOverlayAndEdgeForItem(e),this.applyDesignEffectToItem(r,x,!0),S=this.createDummyShapeFromDesignItem(a),this.onImageItemUpdated(x,t,S),e.data.selected=!1,x.data.selected=o,this.updateSelectionState(),this.updateShapeImagePlaceholder(x),this.updateItemsIndexes(),this.updateDesignItemColorMappings(a,i),[2,x];case 7:return[2,e]}})})},updateFilledShapeAsync:function(e,t,i){return __awaiter(this,void 0,void 0,function(){var n,a,r,o,s,l,h,d,c,u,g,f,p,m,v;return __generator(this,function(I){switch(I.label){case 0:return t&&t instanceof MPlaza.Image&&this.isFilledShape(e)?(n=this.getMaskedImageShapeItem(e),a=this.getMaskedImageRasterItem(e),n.data&&n.data.isImagePlaceholder||this.canReplaceShapeFilling(e)?(r="",!this.isImageScalingEnabled&&"svg"!=t.get("format").toLowerCase()&&"vector"!=t.get("type").toLowerCase()&&["png","jpg","jpeg"].find(function(e){return e==t.get("format").toLowerCase()})&&(r=t.get("url")),r||(r=t.get("previewUrl")),r?(this.applyTransformationsToMaskImageSubItems(e),(o=this.findDesignItemByGuid(e.data.guid))?o.get("imageID")===t.get("imageID")?[3,7]:a?(s=this.getDesignEffectForDesignItem(o),l=r,[4,this.applyDesignEffectToImageUrl(s,r)]):[3,7]:[3,7]):[2,e]):[2,e]):[2,e];case 1:return r=I.sent(),i?[3,3]:[4,this.getImageDefaultColorMappings(r,e)];case 2:i=I.sent(),I.label=3;case 3:return i&&i.length>0?[4,this.recolorImage(r,i)]:[3,5];case 4:r=I.sent(),I.label=5;case 5:return[4,this.changeRasterItem(a,r)];case 6:I.sent(),a.matrix=new this.paper.Matrix,a.data.originalUrl=l,this.applyDesignEffectToItem(s,e),h=e.bounds.clone(),d=new this.paper.Matrix,c=e.position,n.data.originalBounds&&n.data.originalMatrix&&n.data.originalPosition&&(u=n.clone(),g=u.position.clone(),u.rotate(-n.data.originalMatrix.rotation,g),f=u.bounds,h=f.clone(),u.remove(),(p=new this.paper.Path.Rectangle(f)).rotate(n.data.originalMatrix.rotation,g),c=p.position,p.remove(),d.rotate(n.data.originalMatrix.rotation),n.data.flips&&n.data.flips.forEach(function(e){return"X"==e?d.scale(-1,-1):d.scale(1,-1)})),m=1,v=1,h.width>1e-7&&a.bounds.width>0&&(m=h.width/a.bounds.width),h.height>1e-7&&a.bounds.height>0&&(v=h.height/a.bounds.height),m=v=Math.max(Math.abs(m),Math.abs(v)),a.scale(m,v),a.matrix.prepend(d),a.position=c,a.data.originalBounds=new this.paper.Rectangle(0,0,a.width,a.height),a.data.originalMatrix=a.matrix.clone(),this.onImageItemUpdated(e,t,this.createDummyShapeFromDesignItem(o)),this.updateDesignItemColorMappings(o,i),e.data.isNewImageIntoShape=!0,this.updateSelectionState(),this.paper.project.view.update(),this.fireImageLoadedEvent(),I.label=7;case 7:return[2,e]}})})},removeImageFromShape:function(e,t){var i=e;if(e&&this.isFilledShape(e)){var n=this.isItemSelected(e),a=e.parent,r=this.findDesignItemForItem(e),o=this.getMaskedImageShapeItem(e);if(!(o.data&&o.data.isImagePlaceholder||this.canDeleteShapeFilling(e)))return e;if(r&&o){var s=this.getDesignEffectForDesignItem(r),l=e.matrix;(i=o).data.guid=e.data.guid,a.addChild(i),e.remove();var h=o.data.originalStrokeColor||o.strokeColor,d=o.data.originalFillColor||o.fillColor;h=this.forceColorInFixedPalette(e,h),d=this.forceColorInFixedPalette(e,d),o.data.originalStrokeColor=h,o.data.originalFillColor=d,h=this.applyDesignEffectToTextColor(s,h),d=this.applyDesignEffectToTextColor(s,d),i.strokeColor=h,i.fillColor=d,i.data.isMaskedImageShape=!1,this.applyDesignEffectToItem(s,o),i.matrix.prepend(l),i.data.originalMatrix&&i.data.originalMatrix.prepend(l);var c=this.createDummyShapeFromDesignItem(r);this.onShapeItemUpdated(i,c,null),this.updateItemsIndexes(),this.updateDesignItemColorMappings(r,[]),n&&this.maskedImageSelectionMode!=MaskedImageSelectionMode.Element&&(this.maskedImageSelectionMode=MaskedImageSelectionMode.Element),e.data.selected=!1,i.data.selected=n,this.updateSelectionState(),this.changeShapeImagePlaceholder(i,!0),this.updateShapeDesignItem(i,r,c,null)}}return i},changeShapeImagePlaceholder:function(e,t){t?this.setImagePlaceholder(e):this.unsetImagePlaceholder(e)},setImagePlaceholder:function(e){if(this.isShape(e)||this.isFilledShape(e)){var t=this.findDesignItemForItem(e);if(t){var i=this.getLastUndoOperationId();this.beginDesignOperation();var n=this.isShape(e)?e:this.removeImageFromShape(e);if(n){n.data.isImagePlaceholder=!0;var a=this.createDummyImageFromDesignItem(t),r=this.createDummyShapeFromDesignItem(t);this.onShapeItemUpdated(e,r,a),this.updateSelectionState(),this.paper.project.view.update()}this.endDesignOperation(),this.mergeAllUndoOperationsAfterId(i)}}},unsetImagePlaceholder:function(e){if(this.isShape(e)&&e.data.isImagePlaceholder){var t=this.findDesignItemForItem(e);if(t){this.beginDesignOperation(),e.data.isImagePlaceholder=!1;var i=this.createDummyImageFromDesignItem(t),n=this.createDummyShapeFromDesignItem(t);this.onShapeItemUpdated(e,n,i),this.updateSelectionState(),this.paper.project.view.update(),this.endDesignOperation()}}},getItemIsShape:function(e){return this.isFilledShape(e)||this.isShape(e)},getOffsetDistance:function(e){return e&&e instanceof paper.Point?Math.round(e.length):0},getOffsetAngle:function(e){if(e&&e instanceof paper.Point){var t=e.angle;return t<0&&(t+=360),t=Math.round(t)}return 0},getOffsetByDistanceAngle:function(e,t){return null==e||null==t?new this.paper.Point(0,0):new this.paper.Point({length:e,angle:t})},updateTemplateItem:function(e){var t=JSON.parse(e.get("json"));if(t[1].data.isTemplateElement=!0,t[1].data.isTextArea&&t[1].data.text&&(t[1].data.defaultPlaceHolderText=t[1].data.text),t[1].data.isTextArt){var i=e.get("textArt");t[1].data.defaultPlaceHolderText=i.attributes.text}e.set("json",JSON.stringify(t))},applyDescToDesignAsync:function(e){return __awaiter(this,void 0,void 0,function(){var t,i,n,a,r=this;return __generator(this,function(o){switch(o.label){case 0:if(!this.design||!this.design.get("elementsDescs"))return[3,5];if(!(t=this.design.get("elementsDescs").getDescById(e)))return[3,5];i=this.getSelectedItems(),n=0,o.label=1;case 1:return n<t.get("elements").length?(a=t.get("elements").at(n),[4,this.applyDesignElementToDesignAsync(a)]):[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:this.deselectAll(),i.forEach(function(e){return r.setItemSelection(e,!0)}),o.label=5;case 5:return[2]}})})},applyDesignElementToDesignAsync:function(e){return __awaiter(this,void 0,void 0,function(){var t,i,n,a,r;return __generator(this,function(o){switch(o.label){case 0:if(!(e&&e instanceof MPlaza.DesignElement))return[3,4];t=e.get("tag"),i=this.findItemsByTag(t),n=0,a=i,o.label=1;case 1:return n<a.length?(r=a[n],[4,this.applyDesignElementToItemAsync(e,r)]):[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:return[2]}})})},applyDesignElementToItemAsync:function(e,t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(i){switch(i.label){case 0:return this.saveItemInitialInfo(t),this.getItemIsTextElement(t)?[4,this.applyDesignElementToTextItemAsync(e,t)]:[3,2];case 1:return i.sent(),[3,8];case 2:return this.getItemIsTextArt(t)?[4,this.applyDesignElementToTextArtItemAsync(e,t)]:[3,4];case 3:return i.sent(),[3,8];case 4:return this.getItemIsImage(t)?[4,this.applyDesignElementToImageItemAsync(e,t)]:[3,6];case 5:return i.sent(),[3,8];case 6:return this.getItemIsShape(t)?[4,this.applyDesignElementToShapeItemAsync(e,t)]:[3,8];case 7:i.sent(),i.label=8;case 8:return[2]}})})},applyDesignElementToTextItemAsync:function(e,t){var i=this.fromDesignElementToTextItemInfo(e);return i&&this.modifyTextElement(t,i,!1),Promise.resolve()},fromDesignElementToTextItemInfo:function(e){var t=null;if(e&&e.get("text")){for(var i in t=e.get("text").toJSON())null!==t[i]&&void 0!==t[i]||delete t[i];t.text=t.content,delete t.content}return t},applyDesignElementToTextArtItemAsync:function(e,t){return Promise.resolve()},applyDesignElementToImageItemAsync:function(e,t){return Promise.resolve()},applyDesignElementToShapeItemAsync:function(e,t){return Promise.resolve()},saveItemInitialInfo:function(e){if(e&&e.data&&e.data.guid&&!this.initialItemsInfo.hasOwnProperty(e.data.guid)){var t=null;this.getItemIsTextElement(e)?t=this.getTextItemInfo(e):this.getItemIsTextArt(e)?t=this.getTextArtItemInfo(e):this.getItemIsImage(e)?t=this.getImageItemInfo(e):this.getShapeItemInfo(e)&&(t=this.getShapeItemInfo(e)),this.initialItemsInfo[e.data.guid]=t}},resetItemsInitialStateAsync:function(){return __awaiter(this,void 0,void 0,function(){var e,t,i,n,a,r;return __generator(this,function(o){switch(o.label){case 0:if(!this.initialItemsInfo)return[3,4];for(i in e=this.initialItemsInfo,t=[],e)t.push(i);n=0,o.label=1;case 1:return n<t.length?(i=t[n])in e?(a=i,r=this.findItemByGuid(a),[4,this.resetSingleItemInitialStateAsync(r)]):[3,3]:[3,4];case 2:o.sent(),o.label=3;case 3:return n++,[3,1];case 4:return[2]}})})},resetSingleItemInitialStateAsync:function(e){if(e&&e.data&&e.data.guid){var t=null;this.initialItemsInfo.hasOwnProperty(e.data.guid)&&(t=this.initialItemsInfo[e.data.guid],this.getItemIsTextElement(e)?this.modifyTextElement(e,t,!1):this.getItemIsTextArt(e)||this.getItemIsImage(e)||this.getItemIsShape(e))}return Promise.resolve()},findItemsByTag:function(e){var t=[];if(this.design)for(var i=0,n=this.design.getDesignItemsByTag(e);i<n.length;i++){var a=n[i],r=this.findItemForDesignItem(a);r&&t.push(r)}return t},getBackgroundColorForArea:function(e){var t=this,i=null;return this.design.get("designItems").forEach(function(n){var a,r=JSON.parse(n.get("json"));r.length>1&&r[1].data&&r[1].data.isAreaForBackground&&r[1].fillColor&&e.get("guid")===r[1].data.areaGuid&&(i=(new((a=t.paper.Color).bind.apply(a,__spreadArray(__spreadArray([void 0],r[1].fillColor,!1),[0],!1)))).toCSS(!0))}),i},updateResizableProductSideImage:function(e,t,i,n){if(this.showSideImage){this.imageItem&&(this.imageItem.remove(),this.imageItem=null),this.resizableSideImageItem&&(this.resizableSideImageItem.remove(),this.resizableSideImageItem=null),this.resizableMeasuresItem&&(this.resizableMeasuresItem.remove(),this.resizableMeasuresItem=null),this.resizableSplitColumnsItem&&(this.resizableSplitColumnsItem.remove(),this.resizableSplitColumnsItem=null);var a=this.productImageGenerator.generateImage({width:e,height:t,scale:1/this.paper.view.zoom,shape:{borderColor:"#DDDDDD",borderRadius:0,fillColor:"#FFFFFF",shadowColor:"#00000055",shadowBlur:5,shadowOffset:{x:0,y:10}},splitColumns:{columns:i,rows:n,lineColor:"#CCC",lineWidth:1,lineDashArray:[10,10],marginHorizontal:0,marginVertical:0},measures:{lineColor:"#D2D5D8",lineWidth:1,lineDashArray:[4,4],widthDistance:10,heightDistance:10,widthLabel:Math.round(e/this.side.get("ppcm")/("cm"===this.unitOfMeasurement?1:2.54)*100)/100+this.unitOfMeasurement,heightLabel:Math.round(t/this.side.get("ppcm")/("cm"===this.unitOfMeasurement?1:2.54)*100)/100+this.unitOfMeasurement,labelFontSize:12,labelColor:"#8FA4AE",fontFamily:"Inter",fontWeight:"400",totalSizeLabel:"Total design size "}}),r=a.shape,o=a.splitColumns,s=a.measures;this.resizableSideImageItem=this.imageLayer.importJSON(r.json),this.resizableMeasuresItem=this.imageLayer.importJSON(s.json),this.resizableSplitColumnsItem=this.imageLayer.importJSON(o.json),this.hideAreaLabelResizableMode(),this.paper.project.view.update()}},setResizableProductSize:function(e,t,i,n,a){if(this.side&&this.masterGroup){this.paper.activate();this.side.get("ppcm");var r=this.side.get("areas").at(0),o=this.findItemForArea(r),s=this.masterGroup.children.find(function(e){return e.data&&e.data.isClippingArea});if(o&&s){var l=this.productAreaGenerator.generateArea({width:e,height:t,borderRadius:i}),h=this.paper.project.importJSON(l.json);h.remove();var d=__assign({},o.style),c=__assign({},o.data),u=__assign({},s.data);o instanceof this.paper.Path?o.copyContent(h):o instanceof this.paper.CompoundPath&&o.children[0].copyContent(h),s.children[0].copyContent(h),s.removeChildren(1),o.style=d,o.data=c,s.data=u,this.updateResizableProductSideImage(e,t,n,a)}}},restoreResizable:function(){var e,t,i,n;return __awaiter(this,void 0,void 0,function(){var a,r,o=this;return __generator(this,function(s){return(a=null===(e=this.side)||void 0===e?void 0:e.getColorID())&&(r=null===(t=this.design.get("options"))||void 0===t?void 0:t.find(function(e){return e.get("colorID")==a&&(e.get("sideID")==o.side.get("sideID")||null==e.get("sideID"))}))&&r.get("width")&&r.get("height")&&this.setResizableProductSize(r.get("width"),r.get("height"),0,null!==(i=r.get("columns"))&&void 0!==i?i:1,null!==(n=r.get("rows"))&&void 0!==n?n:1),[2]})})},isAreaForBackground:function(e){return e&&e.data&&e.data.isAreaForBackground}};var Zakeke;__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var a in t=arguments[i])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(a,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function s(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}l((n=n.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var i,n,a,r,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(o=0)),o;)try{if(i=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{i=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},__spreadArray=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,a=0,r=t.length;a<r;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){!function(e){var t=function(){function e(e){this.isRotating=!1,this.defaultRotationOptions={animation:!0,rotationButtonPressed:!1},this.isExecutionDesignOperation=!1,this.onRotationComplete=null,this.isRotationButtonPressed=!1,this.customizer=e}return Object.defineProperty(e.prototype,"paper",{get:function(){return this.customizer.paper},enumerable:!1,configurable:!0}),e.prototype.onRotateAreasAndImage=function(e,t,i){if(!this.isRotating){this.onRotationComplete=i,this.isRotating=!0;var n=this.getAreasAndImageRotationOptions(t);this.onRotate(e,n,t.rotationButtonPressed)}},e.prototype.getAreasAndImageRotationOptions=function(e){var t,i=[],n=this.customizer.imageLayer.children[0],a=new paper.Point(0,0);n&&(i.push(n),a=null!==(t=null==n?void 0:n.position)&&void 0!==t?t:new paper.Point(0,0));var r=this.getAreasItem();return i.push.apply(i,r),i.forEach(function(e){e.applyMatrix=!1}),__assign(__assign({},e),{rotationCenter:a,itemsToRotate:i})},e.prototype.onRotateAreas=function(e,t){if(void 0===t&&(t=this.defaultRotationOptions),!this.isRotating){this.isRotating=!0;var i=this.getAreasRotationOptions(t);this.onRotate(e,i,t.rotationButtonPressed)}},e.prototype.getAreasRotationOptions=function(e){var t,i=this.customizer.imageLayer.children[0],n=null!==(t=null==i?void 0:i.position)&&void 0!==t?t:new paper.Point(0,0),a=this.getAreasItem();return a.forEach(function(e){e.applyMatrix=!1}),__assign(__assign({},e),{rotationCenter:n,itemsToRotate:a})},e.prototype.getAreasItem=function(){var e=this.getClipAreas(),t=this.getLayersArea(),i=this.customizer.getAllAreaItems();return __spreadArray(__spreadArray(__spreadArray([],e,!0),t,!0),i,!0)},e.prototype.getClipAreas=function(){return this.customizer.getAreaLayerPaths(this.customizer.itemsLayer).filter(function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.isClippingArea})},e.prototype.getLayersArea=function(){var e,t=[];return(null===(e=this.customizer.areaLayersPaperLayer)||void 0===e?void 0:e.children)&&(t=this.customizer.areaLayersPaperLayer.children.filter(function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.isAreaLayer})),t},e.prototype.onRotate=function(e,t,i){this.isRotationButtonPressed=i;var n=t.animation,a=t.rotationCenter,r=t.itemsToRotate,o=this.customizer.getCanvasRotation(),s=0;o&&(s=o.degrees);var l=s;if(i&&(l=(s+e)%360),n){var h={itemsToRotate:r,degrees:e,rotationCenter:a,finalDegrees:l};this.onRotationFrame(h)}else{for(var d=0,c=r;d<c.length;d++){var u=c[d],g=null!=a?a:new paper.Point(0,0);u.rotate(e,g)}this.endRotation(l,r)}},e.prototype.onRotationFrame=function(e){var t,i=this,n=e.degrees,a=e.itemsToRotate,r=null!==(t=null==e?void 0:e.rotationCenter)&&void 0!==t?t:new paper.Point(0,0),o=0,s=!1,l=n/20;this.customizer.paper.view.onFrame=function(t){for(var h=0,d=a;h<d.length;h++){var c=d[h];if(Math.abs(o+l)<=Math.abs(n))c.rotate(l,r);else{var u=n-o;Math.abs(u)>0&&c.rotate(u,r),s=!0}}s&&(i.endRotation(e.finalDegrees,a),i.customizer.paper.view.onFrame=null),i.customizer.updateSelectionState(),o+=l}},e.prototype.endRotation=function(e,t){var i;return __awaiter(this,void 0,void 0,function(){return __generator(this,function(n){return t.forEach(function(e){e.applyMatrix=!0}),this.saveRotation(e),this.isExecutionDesignOperation||null===(i=this.onRotationComplete)||void 0===i||i.call(this),this.isRotationButtonPressed&&!this.customizer.isViewer&&this.customizer.fitToScreen(!0,!1),this.customizer.paper.project.view.update(),this.isRotating=!1,this.isExecutionDesignOperation=!1,[2]})})},e.prototype.saveRotation=function(e){var t=this.createRotationObj(Math.round(e)),i=this.customizer.side.getSideID();this.customizer.design.get("canvasRotation")||this.customizer.design.set("canvasRotation",[]);var n=this.customizer.design.get("canvasRotation");if(n){var a=n.findIndex(function(e){return e.sideID==i});a>-1?n[a]=t:n.push(t)}},e.prototype.createRotationObj=function(e){var t=e;e<0&&(t=360+e);var i={};return i.sideID=this.customizer.side.getSideID(),i.degrees=t,i},e.prototype.setDefaultRotation=function(){var e=this.customizer.imageLayer.children[0];if(e){var t=-1*e.rotation;-0===t&&0===t||this.onRotate(t,{animation:!1,rotationCenter:e.position,itemsToRotate:[]},!1)}this.saveRotation(0)},e.prototype.getRadians=function(e){return e*(Math.PI/180)},e.prototype.undoRotation=function(e){this.isExecutionDesignOperation=!0,this.onRotateAreasAndImage(-1*e,this.defaultRotationOptions,null)},e.prototype.redoRotation=function(e){this.isExecutionDesignOperation=!0,this.onRotateAreasAndImage(e,this.defaultRotationOptions,null)},e}();e.EventsToolsCustomizer=t}(e.Customizer||(e.Customizer={}))}(Zakeke||(Zakeke={}));
|