UNPKG

@aurigma/ui-framework

Version:

A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.

1 lines 82.6 kB
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[24],{539:function(e,t,r){r.d(t,"a",function(){return s});var i=r(404),n=r(603),s=(Object.defineProperty(o,"iframeApiPromise",{get:function(){return this._iframeApiSubject.pipe(Object(n.a)(1)).toPromise()},enumerable:!1,configurable:!0}),o.loadCCScript=function(e,t){var r,n=this;return"undefined"!=typeof CustomersCanvas||document.body.querySelector("#CcIframeApiScript")?"undefined"!=typeof CustomersCanvas&&this._iframeApiSubject.next(CustomersCanvas):(this._iframeApiSubject=new i.a(1),(r=document.createElement("script")).type="text/javascript",r.id="CcIframeApiScript",r.onload=function(e){CustomersCanvas&&n._iframeApiSubject.next(CustomersCanvas)},r.onerror=function(e){n._iframeApiSubject.error(e)},r.src=e+t,document.body.appendChild(r)),this.iframeApiPromise},o._iframeApiSubject=new i.a(1),o);function o(){}},540:function(e,t,r){r.d(t,"a",function(){return c});var g=r(0),b=r(36),i=r(601),m=r(1),s=r(71),n=r(395),o=r(603),a=r(541),c=(u.prototype._showLockPreloader=function(e,t,r){var n,i;if(e&&t&&e[t]&&e[t].lock&&this.widget){e=Array.isArray(e[t].lock)?e[t].lock:[e[t].lock];try{for(var s=Object(g.k)(e),o=s.next();!o.done;o=s.next()){var a=o.value,c="main"===a?this.widget.auWizard:this.widget.auWizard.scope.$[a]||this.widget.jsonParamsFetcher.scope[a]||this.widget.jsonParamsFetcher.scope.$[a];c&&c.showPreloader(r)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}}},u.prototype.executeActions=function(d,h,f){var n=this,p=(h=h.filter(function(e){var t=!(!0===d[e].executeOnce&&-1!==n._executedActions.indexOf(e)),r=!0;return Array.isArray(d[e].executeOnlyAfter)&&(r=d[e].executeOnlyAfter.reduce(function(e,t){return e=-1===n._executedActions.indexOf(t)?!1:e},!0)),t&&r}),function(l){return Object(g.b)(n,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u;return Object(g.e)(this,function(e){switch(e.label){case 0:if(this.logger.debug(function(){return"Start Execute '".concat(l,"'")}),t=performance.now(),r=Promise.resolve(),s=this._commands[l],n=(Array.isArray(d[l])?d[l][0]:d[l]).message,i=(Array.isArray(d[l])?d[l][0]:d[l]).timeout||10,!s||void 0===s.execute)return[3,8];if(n&&this.widget.showPreloader(!0,n,i),this._showLockPreloader(d,l,!0),r=s.execute(d[l],f[l]),-1===this._executedActions.indexOf(l)&&this._executedActions.push(l),void 0===(i=!(i=d[l].after)&&Array.isArray(d[l])&&(s=d[l].find(function(e){return e.after}))?s.after:i))return[3,4];Object(b.a)(i)||(i=[i]),s=function(e,t,r){return r.indexOf(e)<r.indexOf(t)},o=0,e.label=1;case 1:return o<i.length?(a=i[o],s(l,a,h)?[3,3]:[4,r]):[3,4];case 2:e.sent(),r=p(a),e.label=3;case 3:return o++,[3,1];case 4:return(c=!(c=d[l].onExecuted)&&Array.isArray(d[l])&&(u=d[l].find(function(e){return e.onExecuted}))?u.onExecuted:c)?[4,r]:[3,7];case 5:return e.sent(),[4,m.a.functionWrapperConstructor(c)()];case 6:e.sent(),e.label=7;case 7:return[3,9];case 8:console.warn("Action ".concat(l," is not supported! Double check the config.")),e.label=9;case 9:return[4,r];case 10:return e.sent(),n&&this.widget.showPreloader(!1),this._showLockPreloader(d,l,!1),this.logger.debug(function(){return"Finish Execute '".concat(l,"'")}),u=performance.now(),this.widget.auWizard.telemetry.trackEvent("DE-"+l,u-t),[2,r]}})})}),e=this.getJobReady(this._lastJobKey),t=this._lastJobKey=m.a.guid();return e.then(function(){return n.logger.debug(function(){return"Start actons: ".concat(h)}),m.a.recursiveJobPromise(h,p)}).then(function(){return n._onJobFinish()}).finally(function(){n.logger.debug(function(){return"End actons: ".concat(h)}),n._lastExecutedJobSubject.next(t)})},u.prototype.getJobReady=function(t){return this._lastExecutedJobSubject.pipe(Object(n.a)(function(e){return e===t}),Object(o.a)(1)).toPromise()},u.prototype.getChangedActions=function(r,n){var e=Object.keys(r).filter(function(e){return m.a.isObjectNotEmpty(r[e])}).filter(function(e){return void 0===n[e]||(t=r[e],e=n[e],!(JSON.stringify(t)===JSON.stringify(e)));var t}),t=e.indexOf("actionsErrorToast");return-1!==t&&e.splice(t,1),-1<(e=e.filter(function(e){e=r[e];return Array.isArray(e)?e[0]&&!1!==e[0].autoCompile:!1!==e.autoCompile})).indexOf("initial")?["initial"].concat(Object(i.a)(e,"initial")):e},u);function u(e,t,r,n){void 0===r&&(r=function(){return Promise.resolve()}),this._executedActions=[],this._lastJobKey="init",this._lastExecutedJobSubject=new a.a("init"),this._commands=e,this._onJobFinish=r,this.logger=new s.Category("command-executer_"+t+"_"+m.a.guid()),this.widget=n}},865:function(e,t){e.exports="<style>\n :host {\n width: 100%;\n height: 100%;\n display: block;\n position: initial;\n }\n\n #design-editor {\n position: absolute;\n height: 1px;\n min-height: 100%;\n width: 1px;\n min-width: 100%;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n border: none;\n background-color: transparent;\n }\n</style>\n<iframe id='design-editor' allowfullscreen></iframe>\n"},924:function(T,e,t){t.r(e),t.d(e,"AuWidgetDesignEditor",function(){return pt}),t.d(e,"widget",function(){return pt});var y=t(0),z=t(888),U=t(887),F=t(445),B=t(464),h=t(410),L=t(540),w=t(1),O=t(537),W=t(598),G=t(202),V=t(928),e=t(2),H=t(17),J=t(539),X=(r.prototype.then=function(e){return this.promise.then(e)},r.prototype.catch=function(e){return this.promise.catch(e)},r.prototype.resolve=function(e){this._resolve(e=void 0===e?"":e)},r.prototype.reject=function(e){this._reject(e)},r);function r(){this.promise=new Promise(function(e,t){this._resolve=e,this._reject=t}.bind(this))}var n,Y=t(413),I=t(408),q=t(559),K=t(435),$=t(560),Z=t(562),Q=t(478),j=t(512),ee=t(567),te=t(458),re=t(440),ne=function(e){Object.assign(this,e)},ie=t(404),se=t(603),oe=t(160),oe=(n=oe.c,Object(y.d)(i,n),i.prototype.customersCanvasPublish=function(e){this._customersCanvasSubject.next(e)},Object.defineProperty(i.prototype,"customersCanvasObservable",{get:function(){return this._customersCanvasSubject.asObservable()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"customersCanvasPromise",{get:function(){return this.customersCanvasObservable.pipe(Object(se.a)(1)).toPromise()},enumerable:!1,configurable:!0}),i.prototype.getProduct=function(){return Object(y.b)(this,void 0,void 0,function(){return Object(y.e)(this,function(e){switch(e.label){case 0:return[4,this.getEditor()];case 1:return[4,e.sent().getProduct()];case 2:return[2,e.sent()]}})})},i.prototype.getEditor=function(){return Object(y.b)(this,void 0,void 0,function(){return Object(y.e)(this,function(e){switch(e.label){case 0:return[4,this._customersCanvasSubject.asObservable().pipe(Object(se.a)(1)).toPromise()];case 1:return[2,e.sent()]}})})},i.prototype.getDesignEditorItemModel=function(v){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u,l,d,h,f,p,g,b,m;return Object(y.e)(this,function(e){switch(e.label){case 0:if(t=v.type===j.b.type,h=v.type===K.a.type||v.type===$.a.type||v.type===ee.a.type||v.type===Z.a.type||v.type===q.a.type,r=v.type===I.kb.type||v.type===I.gb.type||v.type===I.A.type||v.type===j.b.type,Q.a.type,s=a=!1,!v)return[2];switch(n={name:v.name},t&&(a=w.a.isNotNullOrUndefined(v.content)&&(v.content instanceof CustomersCanvas.DesignAtoms.ObjectModel.ImageItem||"ImageItem"===v.content.type),s=w.a.isNotNullOrUndefined(v.content)&&(v.content instanceof CustomersCanvas.DesignAtoms.ObjectModel.BarcodeItem||"BarcodeItem"===v.content.type)),!0){case t&&a&&!s&&null!=v.content.tags.sourceData:return[3,1];case t&&a:return[3,7];case h&&!!v.text:return[3,8]}return[3,9];case 1:return i=v.content,s=new re.a(v),o=s.getTransformedRectangle(),a=new te.b(i),c=a.getTransformedRectangle(),[4,this.getEditor()];case 2:u=e.sent(),l=300,e.label=3;case 3:return e.trys.push([3,5,,6]),[4,u.eval("var printArea = spEditor.productHandler.product.surfaces.elementAt(0).printAreas.elementAt(0);var config = spEditor.configuration.renderingConfig.getHiResRendering(printArea);config.dpi;")];case 4:return l=e.sent(),[3,6];case 5:return e.sent(),console.warn("Failed to get hires render config dpi"),[3,6];case 6:return n.tags=Object(O.a)(i.tags),n.value=i.tags.sourceData.name,n.placeholderContent={originalUrl:i.tags.sourceData.originalUrl,width:i.source.width,height:i.source.height,placeholderRectangle:o,contentRectangle:c,contentResizeMode:j.c[v.contentResizeMode].toLowerCase(),contentTransform:{angle:i.transform.angle,scaleX:i.transform.scaleX,scaleY:i.transform.scaleY,translateX:i.transform.translateX,translateY:i.transform.translateY},dpi:l},[3,9];case 7:return n={name:v.name,tags:Object(O.a)(v.tags)},[3,9];case 8:return h="",f=function(e){return(e/255).toFixed(7)},(d=v).color&&(d.color.colorSpace===Y.ColorSpace.Rgb?(p=d.color,h="rgb(".concat(p.r,",").concat(p.g,",").concat(p.b,",").concat(f(p.alpha),")")):d.color.colorSpace===Y.ColorSpace.Cmyk&&(p=d.color,h="cmyk(".concat(f(p.c),",").concat(f(p.m),",").concat(f(p.y),",").concat(f(p.k),",").concat(f(p.alpha),")"))),n={name:v.name,value:d.text,color:h,font:{postScriptName:d.font.postScriptName,size:d.font.size,fauxBold:d.font.fauxBold,fauxItalic:d.font.fauxItalic}},[3,9];case 9:return(t&&(v.contentPermissions&&v.contentPermissions.imagePermissions&&(n.contentPermissions={imagePermissions:{allowChangeImage:v.contentPermissions.imagePermissions.allowChangeImage,allowEditImage:v.contentPermissions.imagePermissions.allowEditImage}}),v.placeholderPermissions)&&(n.placeholderPermissions={allowEditContent:v.placeholderPermissions.allowEditContent,showHandleButton:v.placeholderPermissions.showHandleButton,showSelectButton:v.placeholderPermissions.showSelectButton}),v.visualizationPermissions&&(n.visualizationPermissions={noPrint:v.visualizationPermissions.noPrint,noShow:v.visualizationPermissions.noShow}),null!==v.locked&&(n.locked=v.locked),r)?v.type===j.b.type?[3,11]:(b=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(v.fillColor),n.fillColor=b,g=n,[4,this.colorToHex(b)]):[3,13];case 10:return g.fillColorHex=e.sent(),[3,13];case 11:return b=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(v.contentFillColor),n.fillColor=b,m=n,[4,this.colorToHex(b)];case 12:m.fillColorHex=e.sent(),e.label=13;case 13:return[2,new ne(n)]}})})},i.prototype.colorToHex=function(s){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i;return Object(y.e)(this,function(e){switch(e.label){case 0:return!s||w.a.isNullOrUndefined(s.colorSpace)?[2,null]:(t=s.getData(),[4,this.getEditor()]);case 1:return[4,e.sent().eval(function(t){return Object(y.b)(this,void 0,void 0,function(){return Object(y.e)(this,function(e){switch(e.label){case 0:return[4,spEditor.model._viewer.colorPreviewService.getPreviewAsync(t)];case 1:return[2,e.sent().getData()]}})})},t)];case 2:return i=e.sent(),r=i.r.toString(16),n=i.g.toString(16),i=i.b.toString(16),[2,"#".concat(1===r.length?"0"+r:r)+"".concat(1===n.length?"0"+n:n).concat(1===i.length?"0"+i:i)]}})})},i);function i(){var e=null!==n&&n.apply(this,arguments)||this;return e._customersCanvasSubject=new ie.a(1),e}function s(e){this.widget=e}o=s,Object(y.d)(ce,o),ce.prototype.execute=function(h){var f;return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u,l,d;return Object(y.e)(this,function(e){switch(e.label){case 0:return h.surfaceToDuplicateId||0<(null==(f=h.surfacesToChangeIds)?void 0:f.length)?[4,this.widget.getProduct()]:[2];case 1:return[4,(t=e.sent()).getProductModel()];case 2:if(r=e.sent(),n=r.surfaces.get(h.surfaceToDuplicateId)){try{for(i=Object(y.k)(h.surfacesToChangeIds),s=i.next();!s.done;s=i.next())(o=s.value)!==h.surfaceToDuplicateId&&((a=r.surfaces.get(o))?(c=a.name,(u=n.clone(!0)).name=c,r.surfaces.replaceAt(u,o)):console.warn("There is no surface with index ".concat(o)))}catch(e){l={error:e}}finally{try{s&&!s.done&&(d=i.return)&&d.call(i)}finally{if(l)throw l.error}}t.setProductModel(r)}else console.error("There is no surface with index ".concat(h.surfaceToDuplicateId));return[2]}})})};var o,ae=ce;function ce(){return null!==o&&o.apply(this,arguments)||this}a=s,Object(y.d)(le,a),le.prototype.execute=function(g){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u,l,d,h,f,p=this;return Object(y.e)(this,function(e){switch(e.label){case 0:if(0===(t=(Array.isArray(g)?g:[g]).filter(function(e){return e})).length)return[2];this.widget.initDpApi(),e.label=1;case 1:e.trys.push([1,17,18,19]),r=Object(y.k)(t),n=r.next(),e.label=2;case 2:return n.done?[3,16]:(i=n.value,[4,this.widget.getProduct()]);case 3:return(s=e.sent()).updateSurfaces?1!==s.updateSurfaces.length?[3,13]:i.definition&&i.definition.surfaces?(o=i.definition.surfaces,[4,Promise.all(o.map(function(s){return Object(y.b)(p,void 0,void 0,function(){var t,r,n,i;return Object(y.e)(this,function(e){switch(e.label){case 0:return t=s.designVariant,r=Object(y.i)(s,["designVariant"]),""===(null==t?void 0:t.designResourceId)?[3,2]:[4,this.widget.createPrivateDesignFromResources(t.designResourceId)];case 1:return i=e.sent(),[3,4];case 2:return[4,this.widget.createPrivateDesignFromPublicDesign(t.designId)];case 3:i=e.sent(),e.label=4;case 4:return n=i,[2,Object(y.a)({stateId:n},r)]}})})}))]):[3,6]:(console.warn("Command unavailable for this version Customer's Canvas. Please, use version 6.2.0 or above."),[2]);case 4:return o=e.sent(),i.definition,c=Object(y.i)(i,["definition"]),l=Object(y.a)({definition:{surfaces:o},updateSurfaceSize:!0,preserveUserChanges:!0,updateBehavior:"changeSurfaceLength"},c),[4,s.updateSurfaces(l)];case 5:return e.sent(),[3,12];case 6:return a=i.designVariant,c=Object(y.i)(i,["designVariant"]),w.a.isNullOrUndefined(a)?[2]:""===(null==a?void 0:a.designResourceId)?[3,8]:[4,this.widget.createPrivateDesignFromResources(a.designResourceId)];case 7:return u=e.sent(),[3,10];case 8:return[4,this.widget.createPrivateDesignFromPublicDesign(a.designId)];case 9:u=e.sent(),e.label=10;case 10:return d=u,l=Object(y.a)({definition:d,updateSurfaceSize:!0,preserveUserChanges:!0,updateBehavior:"changeSurfaceLength"},c),[4,s.updateSurfaces(l)];case 11:e.sent(),e.label=12;case 12:return[3,15];case 13:return[4,s.updateSurfaces(i.productDefinition||i.definition,i.options,i.sourceSurfaceIndexes,i.targetSurfaceIndexes)];case 14:e.sent(),e.label=15;case 15:return n=r.next(),[3,2];case 16:return[3,19];case 17:return d=e.sent(),h={error:d},[3,19];case 18:try{n&&!n.done&&(f=r.return)&&f.call(r)}finally{if(h)throw h.error}return[7];case 19:return[2]}})})};var a,ue=le;function le(){return null!==a&&a.apply(this,arguments)||this}var c;c=s,Object(y.d)(de,c),de.prototype.execute=function(e,t){return Object(y.b)(this,void 0,void 0,function(){return Object(y.e)(this,function(e){throw"Not Implemented"})})};function de(){return null!==c&&c.apply(this,arguments)||this}u=s,Object(y.d)(fe,u),fe.prototype.execute=function(n){return Object(y.b)(this,void 0,void 0,function(){var r,t;return Object(y.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.getProduct()];case 1:return r=e.sent(),t=n.data.map(function(e,t){return{mockup:e.mockup,previewMockups:e.previewMockups,surface:r.surfaces[t]}}),[4,r.setMockups(t,n.options)];case 2:return[2,e.sent()]}})})};var u,he=fe;function fe(){return null!==u&&u.apply(this,arguments)||this}var l,pe=t(407),ge=(l=s,Object(y.d)(be,l),be.prototype.execute=function(p){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u,l,d,h,f;return Object(y.e)(this,function(e){switch(e.label){case 0:return t=Array.isArray(p)?p:[p],[4,this.widget.getEditor()];case 1:return[4,(r=e.sent()).getProduct()];case 2:n=e.sent(),e.label=3;case 3:e.trys.push([3,8,9,10]),i=Object(y.k)(t),s=i.next(),e.label=4;case 4:return s.done?[3,7]:(o=s.value,w.a.isEmptyString(o.url)?[3,6]:(a=o.surfaceIndex,(w.a.isNullOrUndefined(a)||a<0||a>n.surfaces.length)&&((a=1===t.length?n.currentSurfaceIndex:t.indexOf(o))<0||a>n.surfaces.length)&&(a=n.currentSurfaceIndex),a=n.surfaces[a],d=a.width/2,c=a.height/2,o.size&&(o.size.width&&(d=o.size.width),o.size.height)&&(c=o.size.height),u=a.width/2-d/2,l=a.height/2-c/2,o.position&&(w.a.isNotNullOrUndefined(o.position.x)&&(u=o.position.x),w.a.isNotNullOrUndefined(o.position.y))&&(l=o.position.y),(u=new window.CustomersCanvas.DesignAtoms.ObjectModel.ImageItem(null,new pe.PointF(u,l),d,c)).name=o.name,[4,a.insertItem(u)]));case 5:e.sent(),e.label=6;case 6:return s=i.next(),[3,4];case 7:return[3,10];case 8:return l=e.sent(),h={error:l},[3,10];case 9:try{s&&!s.done&&(f=i.return)&&f.call(i)}finally{if(h)throw h.error}return[7];case 10:return d=t.reduce(function(e,t){return e[t.name]=t.url,e},{}),[4,r.loadUserInfo(d)];case 11:return e.sent(),[2]}})})},be);function be(){return null!==l&&l.apply(this,arguments)||this}var d,f=t(891),me=t(37),ve=(d=s,Object(y.d)(p,d),p.prototype.execute=function(c){var u,l;return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a=this;return Object(y.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.iframeApiPromise];case 1:if(e.sent(),c.editorConfig=c.editorConfig||{},c.onCustomButtonClicked&&(this.widget.customButtonCb=c.onCustomButtonClicked),"function"==typeof c.OnBoundsNotificationCb&&(this.widget._boundsNotificationCb=c.OnBoundsNotificationCb),"string"==typeof c.productDefinition&&(c.editorConfig.autoLoadUserInfo=!1,c.editorConfig.userInfo=null,this.widget._stateId=c.productDefinition,this.widget._userId=this.widget.driver.user.id),(t=this.widget.driver.user.data)&&0<Object.keys(t).length&&(c.editorConfig.userInfo=w.a.DeepMerge(c.editorConfig.userInfo||{},t),c.editorConfig.autoLoadUserInfo=!0),c.editorConfig=c.editorConfig||{},c.editorConfig.themeConfiguration=c.editorConfig.themeConfiguration||{},this.widget.driver.themeSettings?(c.editorConfig.themeConfiguration.primaryColor=this.widget.driver.themeSettings.primaryColor,c.editorConfig.themeConfiguration.logo=this.widget.driver.themeSettings.logo):(this.widget.auWizard.config.icons&&this.widget.auWizard.config.icons.preloader&&(c.editorConfig.themeConfiguration.logo=this.widget.auWizard.config.icons.preloader),c.editorConfig.themeConfiguration.primaryColor=getComputedStyle(document.documentElement).getPropertyValue("--theme-primary-color")),t=null==(u=null==(u=this.widget.driver)?void 0:u.localization)?void 0:u.find(function(e){return"design-editor"===e.app}),r={},n=this.widget.language.slice(0,2),!t)return[3,8];if(!w.a.isNotNullOrUndefined(t.url)||w.a.isEmptyString(t.url)||"string"!=typeof t.url)return[3,6];e.label=2;case 2:return e.trys.push([2,4,,5]),[4,w.a.loadJson(t.url+"?ts="+Date.now())];case 3:return r=e.sent(),[3,5];case 4:return o=e.sent(),console.error(o),[3,5];case 5:return[3,7];case 6:w.a.isNotNullOrUndefined(t.data)&&"object"==typeof t.data&&0!==Object.keys(t.data).length&&(r=-1!==Object.keys(t.data).indexOf(n)?w.a.DeepMerge(r,t.data):w.a.DeepMerge(r,((o={})[n]=t.data,o))),e.label=7;case 7:c.editorConfig.translations=r,e.label=8;case 8:return i=c.maximizeAssetManager||c.galleryObserverEnable||this.widget.driver.config.displayInPopup,null!=(l=null==(u=null==c?void 0:c.editorConfig)?void 0:u.preloader)&&l.enabled||(c.editorConfig.preloader={enabled:!1}),[4,this.load(c.productDefinition,c.editorConfig,i,c.initSurfaceIndex)];case 9:return e.sent(),[4,this.widget.getViolationData()];case 10:if(e.sent(),!c.onInit)return[3,14];s=w.a.functionWrapperConstructor(c.onInit),e.label=11;case 11:return e.trys.push([11,13,,14]),[4,s()];case 12:return e.sent(),[3,14];case 13:return e.sent(),[3,14];case 14:return[2,me.Maybe.maybe(c).map(function(e){return e.viewerSettings}).caseOf({just:function(e){return a.widget.applyViewerSettings(e)},nothing:function(){return a.widget.customersCanvasPromise}})]}})})},p.prototype.load=function(u,l,d,h){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,a,o,c=this;return Object(y.e)(this,function(e){switch(e.label){case 0:return t=this,u.surfaces&&Array.isArray(u.surfaces)&&u.surfaces.forEach(function(e){"object"==typeof e&&void 0!==e.width&&void 0!==e.height&&(e.width=Number(e.width),e.height=Number(e.height))}),t.widget.modifiedItem&&t.widget.updateModifiedItem({}),i=this.widget.shadowRoot.querySelector("#design-editor"),[4,CustomersCanvas.IframeApi.loadEditor(i,u,l)];case 1:r=e.sent(),e.label=2;case 2:return e.trys.push([2,5,,6]),[4,r.getProduct()];case 3:return[4,(n=e.sent()).switchTo(n.surfaces[0])];case 4:return n=e.sent(),[3,6];case 5:return i=e.sent(),console.error("Load failed with exception: ",i),t.widget.dispatchEvent(new CustomEvent("error",i)),[2];case 6:return w.a.isNotNullOrUndefined(h)?(s=Number(h),(Number.isNaN(s)||s<0||s>n.surfaces.length)&&(s=0),[4,n.switchTo(n.surfaces[s])]):[3,8];case 7:e.sent(),e.label=8;case 8:return t.widget.customersCanvasPublish(r),t.widget.dispatchEvent(new CustomEvent("ready",{detail:{product:n,customersCanvas:r}})),[4,this.widget.replaceInterpolationPlaceholder()];case 9:return e.sent(),a=[],o=function(n,i,s,o){void 0===s&&(s=!1),void 0===o&&(o=!1),a.push(n),r.subscribe(n,function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return Object(y.b)(c,void 0,void 0,function(){var t;return Object(y.e)(this,function(e){switch(e.label){case 0:return s?[4,this.widget.getViolationData()]:[3,2];case 1:e.sent(),e.label=2;case 2:return i?[4,i.apply(void 0,Object(y.j)([],Object(y.h)(r),!1))]:[3,4];case 3:e.sent(),e.label=4;case 4:return(t=(null==(t=this.widget.params)?void 0:t.initial)&&(this.widget.params.initial["on"+n]||(null==(t=this.widget.params)?void 0:t.initial[n])))?[4,w.a.functionWrapperConstructor(t).apply(window,r)]:[3,6];case 5:e.sent(),e.label=6;case 6:return o&&this.widget.emitChange(),[2]}})})})},d&&(o(f.a.ModalClose,function(){for(var e=0;e<arguments.length;e++)e,0;return Object(y.b)(c,void 0,void 0,function(){return Object(y.e)(this,function(e){return[2,this.widget.toggleMaximizeMainPanel(!1)]})})}),o(f.a.ModalOpen,function(){for(var e=0;e<arguments.length;e++)e,0;return Object(y.b)(c,void 0,void 0,function(){return Object(y.e)(this,function(e){return[2,this.widget.toggleMaximizeMainPanel(!0)]})})}),o(f.a.AssetManagerClosed,function(){for(var e=0;e<arguments.length;e++)e,0;return Object(y.b)(c,void 0,void 0,function(){return Object(y.e)(this,function(e){return[2,this.widget.toggleMaximizeMainPanel(!1)]})})}),o(f.a.AssetManagerOpened,function(){for(var e=0;e<arguments.length;e++)e,0;return Object(y.b)(c,void 0,void 0,function(){return Object(y.e)(this,function(e){return[2,this.widget.toggleMaximizeMainPanel(!0)]})})})),o(f.a.OriginalSize,function(){return Object(y.b)(c,void 0,void 0,function(){return Object(y.e)(this,function(e){return[2,this.widget.toggleMaximizeMainPanel(!1)]})})}),o(f.a.FullWindow,function(){return Object(y.b)(c,void 0,void 0,function(){return Object(y.e)(this,function(e){return[2,this.widget.toggleMaximizeMainPanel(!0)]})})}),o(f.a.BoundsNotification,function(e){c.widget.selectedGroupBoundsData=e,c.widget._boundsNotificationCb&&c.widget._boundsNotificationCb(e)}),o(f.a.OnImageDpiChanged,null,!0),o(f.a.OnSurfaceChanged,function(){return Object(y.b)(c,void 0,void 0,function(){return Object(y.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.updateCurrentSurfaceData()];case 1:return[2,e.sent()]}})})}),o(f.a.ItemAdded,null,!0),o(f.a.ItemRemoved,null,!0),o(f.a.ItemChanged,function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return Object(y.b)(c,void 0,void 0,function(){var t,r;return Object(y.e)(this,function(e){switch(e.label){case 0:if(t=n[0],w.a.isNullOrUndefined(t))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.widget.getDesignEditorItemModel(t)];case 2:return r=e.sent(),this.widget.updateModifiedItem(r),[3,4];case 3:return e.sent(),console.warn("Failed to transform item model"),[3,4];case 4:return[2]}})})},!0),o(f.a.RevertProduct,null,!0,!0),o(f.a.UndoProduct,null,!0),o(f.a.RedoProduct,null,!0),o(f.a.CustomButtonClicked,function(t){return Object(y.b)(c,void 0,void 0,function(){return Object(y.e)(this,function(e){return[2,this.widget.customButtonCb(t[0],t[1])]})})}),Object.keys(f.a).forEach(function(e){-1===a.indexOf(e)&&o(e,null)}),[2]}})})},p);function p(){return null!==d&&d.apply(this,arguments)||this}g=s,Object(y.d)(we,g),we.prototype.execute=function(n,e){return Object(y.b)(this,void 0,void 0,function(){var t,r;return Object(y.e)(this,function(e){switch(e.label){case 0:return w.a.isEmptyObject(n)?[2,Promise.resolve()]:w.a.isEmptyObject(n.data)?[2,Promise.resolve()]:[4,this.widget.getEditor()];case 1:t=e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,t.loadUserInfo(n.data,n.options)];case 3:return e.sent(),[3,5];case 4:return r=e.sent(),console.warn(r),[3,5];case 5:return[2]}})})};var g,ye=we;function we(){return null!==g&&g.apply(this,arguments)||this}var b,P=t(471),Oe=(b=s,Object(y.d)(m,b),m.prototype.execute=function(n,i){return Object(y.b)(this,void 0,void 0,function(){var t,r;return Object(y.e)(this,function(e){switch(e.label){case 0:return w.a.isEmptyObject(n)||w.a.isEmptyObject(n.every)&&w.a.isEmptyObject(n.items)?[2,Promise.resolve()]:(n.items=n.items||{},w.a.isNotNullOrUndefined(i)&&(n=this._removeOldParams(n,i)),[4,this.widget.getEditor()]);case 1:return[4,(t=e.sent()).getProduct()];case 2:return r=e.sent(),[4,this._modifyItems(n,r,t)];case 3:return e.sent(),[4,this._applyUserInfo(t,n)];case 4:return e.sent(),[2]}})})},m.prototype._modifyItems=function(l,d,h){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u;return Object(y.e)(this,function(e){switch(e.label){case 0:return w.a.isNullOrUndefined(l)?[2]:w.a.isNotNullOrUndefined(l.items)?[4,this._applyBackgroundColor(l,d)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[4,d.getProductModel()];case 3:t=e.sent(),r=t.getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!1}),e.label=4;case 4:e.trys.push([4,13,14,15]),n=Object(y.k)(r),i=n.next(),e.label=5;case 5:return i.done?[3,12]:(s=i.value,o=Object(y.a)(Object(y.a)({},l.every),l.items[s.name]),0!==Object.keys(o).length&&this.needApplyOnce(o,s)?this._isTextItem(s.type)?(this._updateTextItem(o,s),[3,10]):[3,6]:[3,11]);case 6:return s.type!==I.cb.type?[3,8]:[4,this._updatePlaceholderItem(o,s,h)];case 7:return e.sent(),[3,10];case 8:return this._isShapeItem(s)?[4,this._updateShapeItem(o,s)]:[3,10];case 9:e.sent(),e.label=10;case 10:this._updateVisualizationPermissions(o,s),this.setApplyOnce(o,s),e.label=11;case 11:return i=n.next(),[3,5];case 12:return[3,15];case 13:return c=e.sent(),c={error:c},[3,15];case 14:try{i&&!i.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}return[7];case 15:return a=0<d.currentSurfaceIndex?d.currentSurfaceIndex:0,[4,d.setProductModel(t)];case 16:return e.sent(),[4,h.getProduct()];case 17:return[4,(d=e.sent()).switchTo(d.surfaces[a])];case 18:return e.sent(),[2]}})})},m.prototype.needApplyOnce=function(e,t){return!(!0===e.once&&t&&t.tags.modifyItems&&!0===t.tags.modifyItems.once)},m.prototype.setApplyOnce=function(e,t){!0===e.once&&t&&(t.tags.modifyItems=t.tags.modifyItems||{},t.tags.modifyItems.once=!0)},m.prototype._isTextItem=function(e){return e===I.o.type||e===I.q.type||e===I.eb.type||e===I.x.type||e===I.g.type},m.prototype._removeOldParams=function(e,t){for(var r in e.items){var n=t.items[r],i=e.items[r];JSON.stringify(n)===JSON.stringify(i)&&!0!==i.force&&delete e.items[r]}return e},m.prototype._applyBackgroundColor=function(o,a){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s;return Object(y.e)(this,function(e){switch(e.label){case 0:if(null==(t=o.items.background||o.items.Background)||null==t.color)return[3,8];if(null===(t=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(t.color)))return[3,8];e.label=1;case 1:e.trys.push([1,6,7,8]),r=Object(y.k)(a.surfaces),n=r.next(),e.label=2;case 2:return n.done?[3,5]:[4,n.value.changeBackground(t)];case 3:e.sent(),e.label=4;case 4:return n=r.next(),[3,2];case 5:return[3,8];case 6:return i=e.sent(),i={error:i},[3,8];case 7:try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(i)throw i.error}return[7];case 8:return[2]}})})},m.prototype._updateTextItem=function(e,t){var r,n,i,s,o,a=e.text||e.value;null!=a&&(t.text=a,t.placeholders)&&0<t.placeholders.length&&(t.placeholders.forEach(function(e){return e.value=a}),t.value=a),null!=e.font&&((r=e.font.bold||e.font.fauxBold)&&(t.font.fauxBold=r),(r=e.font.italic||e.font.fauxItalic)&&(t.font.fauxItalic=r),(r=e.font.family||e.font.postScriptName)&&(t.font.postScriptName=r),e.font.size&&(t.font.size=e.font.size),e.font.underline&&(t.underline=e.font.underline),r=e.color||e.font.color)&&(t.color=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(r)),!0===e.locked&&(t.textPermissions.allowChangeText=!1,t.textPermissions.allowChangeTextBIU=!1),t.type===I.eb.type&&(n=e.position||e.location)&&(s=i=0,t.alignment=I.qb.Left,i=(n=n||{x:0,y:0}).x||t.baselineLocation.x,s=n.y||t.baselineLocation.y,t.baselineLocation=new window.CustomersCanvas.DesignAtoms.ObjectModel.PointF(i,s)),(t.type===I.q.type||t.type===I.g.type)&&(r=t,(n=e.position||e.location)||e.size)&&(o=t=s=i=0,i=(n=n||{x:0,y:0}).x||r.textRectangle.left,s=n.y||r.textRectangle.top,e.size||(e.size={width:0,height:0}),t=e.size.width||r.textRectangle.width,o=e.size.height||r.textRectangle.height,r.textRectangle.width=t,r.textRectangle.height=o,r.textRectangle.left=i,r.textRectangle.top=s)},m.prototype._updateVisualizationPermissions=function(e,t){e.visualizationPermissions&&(w.a.isNotNullOrUndefined(e.visualizationPermissions.noPrint)&&(t.visualizationPermissions.noPrint=e.visualizationPermissions.noPrint),w.a.isNotNullOrUndefined(e.visualizationPermissions.noShow))&&(t.visualizationPermissions.noShow=e.visualizationPermissions.noShow),w.a.isNotNullOrUndefined(e.locked)&&(t.locked=e.locked)},m.prototype._updatePlaceholderItem=function(c,u,l){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a;return Object(y.e)(this,function(e){switch(e.label){case 0:return(t=function(e){return e.placeholderContent&&e.tags&&e.tags.sourceData&&e.value===e.tags.sourceData.name},"ImagePlaceholder"!==c.type)?[3,6]:t(c)?-1!==c.placeholderContent.originalUrl.indexOf("?x-cctoken=")?[3,2]:[4,this.widget.getToken()]:[3,4];case 1:""!==(t=e.sent())&&(c.placeholderContent.originalUrl+="?x-cctoken=".concat(t)),e.label=2;case 2:return r=c.placeholderContent.originalUrl,c.tags.sourceData.originalUrl=r,[4,l.configuration.getImageMetadata(r)];case 3:if(r=e.sent(),s=u.content,u.isStubContent=!1,s.setData)try{s.setData(r)}catch(e){P.a.setDataToImage(r,s)}else P.a.setDataToImage(r,s);return s.tags=c.tags,s.parentPlaceholder=u,o=new re.a(u),(a=new te.b(s)).updateRectangle(!1,u.contentResizeMode,o),i=o.getTransformedRectangle(),n=c.placeholderContent,(i.angle!==n.placeholderRectangle.angle||i.width!==n.placeholderRectangle.width||i.height!==n.placeholderRectangle.height||i.centerX!==n.placeholderRectangle.centerX||i.centerY!==n.placeholderRectangle.centerY)&&(i=new window.CustomersCanvas.DesignAtoms.ObjectModel.RotatedRectangleF(n.placeholderRectangle.centerX,n.placeholderRectangle.centerY,n.placeholderRectangle.width,n.placeholderRectangle.height,n.placeholderRectangle.angle),o.setTransformedRectangle(i)),i=a.getTransformedRectangle(),(i.angle!==n.contentRectangle.angle||i.width!==n.contentRectangle.width||i.height!==n.contentRectangle.height||i.centerX!==n.contentRectangle.centerX||i.centerY!==n.contentRectangle.centerY)&&(i=new window.CustomersCanvas.DesignAtoms.ObjectModel.RotatedRectangleF(n.contentRectangle.centerX,n.contentRectangle.centerY,n.contentRectangle.width,n.contentRectangle.height,n.contentRectangle.angle),a.setTransformedRectangle(i)),[3,5];case 4:if(!u.isStubContent){if((s=u.content).parentPlaceholder=u,s.setData)try{s.setData(u.stubStorageMeta)}catch(e){P.a.setDataToImage(u.stubStorageMeta,s)}else P.a.setDataToImage(u.stubStorageMeta,s);o=new re.a(u),(a=new te.b(s)).parentPlaceholder=o,a.updateRectangle(!1,u.contentResizeMode,o),u.isStubContent=!0}e.label=5;case 5:c.contentPermissions&&c.contentPermissions.imagePermissions&&(u.contentPermissions.imagePermissions.allowChangeImage=c.contentPermissions.imagePermissions.allowChangeImage,u.contentPermissions.imagePermissions.allowEditImage=c.contentPermissions.imagePermissions.allowEditImage),c.placeholderPermissions&&(u.placeholderPermissions.allowEditContent=c.placeholderPermissions.allowEditContent,u.placeholderPermissions.showHandleButton=c.placeholderPermissions.showHandleButton,u.placeholderPermissions.showSelectButton=c.placeholderPermissions.showSelectButton),e.label=6;case 6:return"BarcodePlaceholder"!==c.type||c.value||u.isStubContent||(u.content.applyBarcodeData(new window.CustomersCanvas.DesignAtoms.ObjectModel.BarcodeData("")),u.isStubContent=!0),[2]}})})},m.prototype._updateShapeItem=function(s,o){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i;return Object(y.e)(this,function(e){return(r=s.color||s.fillColor)&&(o.type!=I.cb.type?o.fillColor=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(r):o.contentFillColor=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(r)),((r=s.position||s.location)||s.size)&&(0,t=(r=r||{x:0,y:0}).x||o.sourceRectangle.left,r=r.y||o.sourceRectangle.top,s.size||(s.size={width:0,height:0}),n=s.size.width||o.sourceRectangle.width,i=s.size.height||o.sourceRectangle.height,o.type!=I.A.type?o.sourcePath=window.CustomersCanvas.DesignAtoms.ObjectModel.Path.rectangle(t,r,n,i):o.sourcePath=window.CustomersCanvas.DesignAtoms.ObjectModel.Path.ellipse(t,r,n,i)),[2]})})},m.prototype._applyUserInfo=function(h,f){return Object(y.b)(this,void 0,void 0,function(){var n,i,s,t,o,r,a,c,u,l,d;return Object(y.e)(this,function(e){switch(e.label){case 0:return n=function(e){return!!e.placeholderContent&&e.tags&&e.tags.sourceData&&e.value===e.tags.sourceData.name},[4,h.getProduct()];case 1:return[4,e.sent().getProductModel()];case 2:u=e.sent(),i=u.getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0}),s={},t=function(t){var e=f.items[t],r=i.find(function(e){return e.name===t});return!o.needApplyOnce(e,r)||!e.value&&"Text"!==e.type&&"InString"!==e.type&&!e.image||"ImagePlaceholder"===e.type&&n(e)?"continue":("BarcodePlaceholder"===e.type?e.barcodeSubType&&"None"!==e.barcodeSubType?"Url"===e.barcodeSubType?s[t]={BarcodeFormat:e.barcodeFormat,BarcodeSubType:e.barcodeSubType,Url:e.value}:"Phone"===e.barcodeSubType&&(s[t]={barcodeFormat:e.barcodeFormat,barcodeSubType:e.barcodeSubType,phone:e.value}):s[t]={barcodeFormat:e.barcodeFormat,barcodeValue:e.value}:s[t]=w.a.isNotNullOrUndefined(e.value)?e.value:e.image,void o.setApplyOnce(e,r))},o=this;try{for(r=Object(y.k)(Object.keys(f.items)),a=r.next();!a.done;a=r.next())c=a.value,t(c)}catch(e){l={error:e}}finally{try{a&&!a.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}}if(w.a.isEmptyObject(s))return[2,Promise.resolve()];e.label=3;case 3:return e.trys.push([3,5,,6]),[4,h.loadUserInfo(s)];case 4:return e.sent(),[3,6];case 5:return u=e.sent(),this.widget.showToast("Error: Invalid data"),console.log(u),[3,6];case 6:return[2]}})})},m.prototype._isShapeItem=function(e){return[I.gb.type,I.kb.type,I.A.type,I.cb.type].includes(e.type)},m);function m(){return null!==b&&b.apply(this,arguments)||this}var v,C=t(489),Ie=(v=s,Object(y.d)(je,v),je.prototype.execute=function(s){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i;return Object(y.e)(this,function(e){switch(e.label){case 0:return s&&s.resizeParams&&0!==s.resizeParams.height&&0!==s.resizeParams.width?[4,this.widget.getEditor()]:[2];case 1:return(t=e.sent(),(r=s.resizeParams).targets&&0<r.targets.length&&"string"==typeof r.targets[0])?[4,t.getProduct()]:[3,6];case 2:return[4,e.sent().getProductModel()];case 3:return[4,e.sent().getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0})];case 4:return i=e.sent(),i=i.filter(function(e){return r.targets.includes(e.name)}).map(function(e){return e.id}),(n=s.resizeParams).targetIds=i,[4,t.commandManager.execute(C.b.resize,n)];case 5:return e.sent(),[3,8];case 6:return"product"===s.resizeParams.targetType||!s.resizeParams.targetIds&&0!==s.resizeParams.targetIds.length?null==s.resizeParams.target&&"product"!==s.resizeParams.targetType?[2]:(i=s.resizeParams,[4,t.commandManager.execute(C.b.resize,i)]):[2];case 7:e.sent(),e.label=8;case 8:return e.trys.push([8,10,,11]),[4,t.eval("spEditor._canvasViewer._onResize()")];case 9:return e.sent(),[3,11];case 10:return e.sent(),[3,11];case 11:return[4,this.widget.ready()];case 12:return e.sent(),[2]}})})},je);function je(){return null!==v&&v.apply(this,arguments)||this}_=s,Object(y.d)(x,_),x.prototype.execute=function(v){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u,l,d,h,f,p,g,b,m;return Object(y.e)(this,function(e){switch(e.label){case 0:return t=Array.isArray(v)?v:[v],[4,this.widget.getEditor()];case 1:return[4,(r=e.sent()).getProduct()];case 2:n=e.sent(),e.label=3;case 3:e.trys.push([3,14,15,16]),i=Object(y.k)(t),s=i.next(),e.label=4;case 4:return s.done?[3,13]:(o=s.value).url?[4,n.getProductModel()]:[3,12];case 5:return(a=e.sent(),(null==(c=o.surfaceIndex)||c<0||c>n.surfaces.length)&&(c=1===t.length?n.currentSurfaceIndex:t.indexOf(o)),u=a.surfaces.get(c),w.a.isNullOrUndefined(u))?[3,12]:(l=u.printAreas.get(0),d=u.containers.first(function(e){return e.name===F.a.BG_CONTAINER_NAME}),h=d.items.get(0),w.a.isNullOrUndefined(h)&&((h=new window.CustomersCanvas.DesignAtoms.ObjectModel.PlaceholderItem).locked=!0,d.items.add(h)),w.a.isNullOrUndefined(h.content)&&(h.content=new window.CustomersCanvas.DesignAtoms.ObjectModel.ImageItem),f=h.content,[4,r.configuration.getImageMetadata(o.url)]);case 6:if((p=e.sent()).isVector=this._isVector(o.url),!0!==o.toTile)return[3,8];if((g=h.content||h).sourceRectangle.width=p.size.width,g.sourceRectangle.height=p.size.height,g.setData)try{g.setData(p)}catch(e){P.a.setDataToImage(p,g)}else P.a.setDataToImage(p,g);return g.source.isVector=p.isVector,d.items.setRange(this._getTiles(g,u)),[4,n.setProductModel(a)];case 7:return e.sent(),[3,10];case 8:return n.surfaces.length>c?[4,n.surfaces[c].changeBackground(p)]:[3,10];case 9:e.sent(),e.label=10;case 10:return o.url.startsWith("public:")||o.url.startsWith("user:")||!o.autoResize?[3,12]:((g=new window.CustomersCanvas.DesignAtoms.ObjectModel.ImageItem.ImageSource).url=o.url,g.isVector=this._isVector(o.url),f.source=g,u.width=f.sourceRectangle.width,u.height=f.sourceRectangle.height,l.bounds.width=u.width,l.bounds.height=u.height,[4,n.setProductModel(a)]);case 11:e.sent(),e.label=12;case 12:return s=i.next(),[3,4];case 13:return[3,16];case 14:return b=e.sent(),b={error:b},[3,16];case 15:try{s&&!s.done&&(m=i.return)&&m.call(i)}finally{if(b)throw b.error}return[7];case 16:return[4,this.widget.ready()];case 17:return e.sent(),[2]}})})},x.prototype._getTiles=function(e,t){for(var r=[],n=0,i=0;i<t.height;){for(;n<t.width;){var s=e.clone();s.values=[],s.transform.setTranslateX(n),s.transform.setTranslateY(i),s.locked=!0,r.push(s),n+=e.source.width}n=0,i+=e.source.height}return r},x.prototype._isVector=function(e){return e.endsWith(".pdf")||e.endsWith(".svg")};var _,Pe=x;function x(){return null!==_&&_.apply(this,arguments)||this}S=s,Object(y.d)(_e,S),_e.prototype.execute=function(s){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i;return Object(y.e)(this,function(e){switch(e.label){case 0:return[4,this.widget.getProduct()];case 1:t=e.sent(),Array.isArray(s)||(s=[s]),r=0,e.label=2;case 2:return r<s.length?(n=s[r]).data?(i=t.currentSurface,[4,(i="number"==typeof n.surfaceIndex?t.surfaces[n.surfaceIndex]:i).setPrintAreas([n.data],n.options)]):[3,5]:[3,6];case 3:return t=e.sent(),[4,this.widget.replaceInterpolationPlaceholder()];case 4:e.sent(),e.label=5;case 5:return r++,[3,2];case 6:return[2]}})})};var S,Ce=_e;function _e(){return null!==S&&S.apply(this,arguments)||this}D=s,Object(y.d)(Se,D),Se.prototype.execute=function(h){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u,l,d;return Object(y.e)(this,function(e){switch(e.label){case 0:return null==h?[2,Promise.resolve()]:[4,this.widget.getEditor()];case 1:return[4,(t=e.sent()).getProduct()];case 2:return[4,(r=e.sent()).getProductModel()];case 3:n=e.sent(),e.label=4;case 4:e.trys.push([4,9,10,11]),i=Object(y.k)(h),s=i.next(),e.label=5;case 5:return s.done?[3,8]:(u=s.value,w.a.isNullOrUndefined(u.url)||""===u.url?[3,7]:(c="number"==typeof u.surfaceIndex?n.surfaces.get(u.surfaceIndex):n.surfaces.first(function(e){return e.name===r.currentSurface.name}),(c="up"===u.mockup.toLowerCase()?c.mockup.overContainers:c.mockup.underContainers).empty?(console.warn("Cannot set mockup because MockupContainer is empty"),[3,7]):((o=c.get(0)).items.clear(),a=new window.CustomersCanvas.DesignAtoms.ObjectModel.ImageItem,[4,t.configuration.getImageMetadata(u.url)])));case 6:if((c=e.sent()).size={width:c.size.width||c.width,height:c.size.height||c.height},a.setData)try{a.setData(c)}catch(e){P.a.setDataToImage(c,a)}else P.a.setDataToImage(c,a);a.ratioWidthToHeight=o.size.width/o.size.height,a.SetWidth(o.size.width,!1),a.SetHeight(o.size.height,!1),o.items.add(a),e.label=7;case 7:return s=i.next(),[3,5];case 8:return[3,11];case 9:return u=e.sent(),l={error:u},[3,11];case 10:try{s&&!s.done&&(d=i.return)&&d.call(i)}finally{if(l)throw l.error}return[7];case 11:return[4,r.setProductModel(n)];case 12:return e.sent(),[2]}})})};var D,xe=Se;function Se(){return null!==D&&D.apply(this,arguments)||this}var De,Ae=t(890),Me=(De=s,Object(y.d)(ke,De),ke.prototype.execute=function(r){return Object(y.b)(this,void 0,void 0,function(){var t;return Object(y.e)(this,function(e){switch(e.label){case 0:if(Object(h.l)(r.serializedProduct))throw"serializedProduct cannot be null or empty";return t=this._serializer.deserialize(r.serializedProduct),[4,this.widget.getProduct()];case 1:return[4,e.sent().setProductModel(t)];case 2:return e.sent(),[2]}})})},ke);function ke(){var e=null!==De&&De.apply(this,arguments)||this;return e._serializer=new Ae.a,e}Ee=s,Object(y.d)(Ne,Ee),Ne.prototype.execute=function(t){return Object(y.b)(this,void 0,void 0,function(){return Object(y.e)(this,function(e){switch(e.label){case 0:return t&&t.surfaces&&0!==t.surfaces.length?t.surfaces.some(function(e){return 0===Object.keys(e).length})?[2]:[4,this.widget.getEditor()]:[2];case 1:return[4,e.sent().getProduct()];case 2:return[4,e.sent().setSurfaces(t.surfaces)];case 3:return e.sent(),[4,this.widget.replaceInterpolationPlaceholder()];case 4:return e.sent(),[2]}})})};var Ee,Re=Ne;function Ne(){return null!==Ee&&Ee.apply(this,arguments)||this}Te=s,Object(y.d)(Ue,Te),Ue.prototype.execute=function(t){return Object(y.b)(this,void 0,void 0,function(){return Object(y.e)(this,function(e){switch(e.label){case 0:return"string"!=typeof t&&void 0!==t.theme||(t={theme:t}),[4,this.widget.getProduct()];case 1:return[4,e.sent().applyProductTheme(t.theme)];case 2:return[2,e.sent()]}})})};var Te,ze=Ue;function Ue(){return null!==Te&&Te.apply(this,arguments)||this}Fe=s,Object(y.d)(Le,Fe),Le.prototype.execute=function(n){return Object(y.b)(this,void 0,void 0,function(){var t,r;return Object(y.e)(this,function(e){switch(e.label){case 0:return n?[4,this.widget.getEditor()]:[3,3];case 1:return t=e.sent(),r=Object.assign({},n),null!=n.scrollPosition&&(r.scrollingPosition={x:n.scrollPosition.X||n.scrollPosition.x,y:n.scrollPosition.Y||n.scrollPosition.y}),[4,t.setViewerSettings(r)];case 2:e.sent(),e.label=3;case 3:return[2]}})})};var Fe,Be=Le;function Le(){return null!==Fe&&Fe.apply(this,arguments)||this}We=s,Object(y.d)(Ve,We),Ve.prototype.execute=function(l){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u;return Object(y.e)(this,function(e){switch(e.label){case 0:if(0===(t=w.a.ensureArray(l).filter(function(e){return e})).length)return[2];e.label=1;case 1:e.trys.push([1,7,8,9]),r=Object(y.k)(t),n=r.next(),e.label=2;case 2:return n.done?[3,6]:(i=n.value,[4,this.widget.getProduct()]);case 3:return(a=e.sent()).swapSurfaces?(s=a.surfaces[i.lhsSurfaceIndex],o=a.surfaces[i.rhsSurfaceIndex],[4,a.swapSurfaces(s,o)]):(console.warn("Command unavailable for this version Customer's Canvas."),[2]);case 4:e.sent(),e.label=5;case 5:return n=r.next(),[3,2];case 6:return[3,9];case 7:return a=e.sent(),c={error:a},[3,9];case 8:try{n&&!n.done&&(u=r.return)&&u.call(r)}finally{if(c)throw c.error}return[7];case 9:return[2]}})})};var We,Ge=Ve;function Ve(){return null!==We&&We.apply(this,arguments)||this}He=s,Object(y.d)(Xe,He),Xe.prototype.execute=function(a){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o;return Object(y.e)(this,function(e){switch(e.label){case 0:return a&&a.translateParams?(i=a.translateParams,i=i.itemIds&&0<i.itemIds.length,s=(s=a.translateParams).items&&0===s.items.length&&"string"!=typeof s.items[0],r=(t=a.translateParams).items&&0<t.items.length&&"string"==typeof t.items[0],i||s||r?[4,this.widget.getEditor()]:[2]):[2];case 1:return(n=e.sent(),r)?[4,n.getProduct()]:[3,6];case 2:return[4,e.sent().getProductModel()];case 3:return[4,e.sent().getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0})];case 4:return i=e.sent(),s=i.filter(function(e){return t.items.includes(e.name)}).map(function(e){return e.id}),o={itemIds:s,translateX:t.translateX,translateY:t.translateY},[4,n.commandManager.execute(C.a.translateItems,o)];case 5:return e.sent(),[3,8];case 6:return[4,n.commandManager.execute(C.a.translateItems,a.translateParams)];case 7:e.sent(),e.label=8;case 8:return[4,this.widget.ready()];case 9:return e.sent(),[2]}})})};var He,Je=Xe;function Xe(){return null!==He&&He.apply(this,arguments)||this}Ye=s,Object(y.d)(Ke,Ye),Ke.prototype.execute=function(p,e){return Object(y.b)(this,void 0,void 0,function(){var t,r,n,i,s,o,a,c,u,l,d,h,f;return Object(y.e)(this,function(e){switch(e.label){case 0:return null!=p&&p instanceof Array?[4,this.widget.getProduct()]:[2];case 1:t=e.sent(),e.label=2;case 2:e.trys.push([2,13,14,15]),r=Object(y.k)(p.entries()),n=r.next(),e.label=3;case 3:if(n.done)return[3,12];if(i=Object(y.h)(n.value,2),s=i[0],i=i[1],null==(s=t.surfaces[s]))return[3,11];e.label=4;case 4:e.trys.push([4,9,10,11]),h=void 0,o=Object(y.k)(Object.entries(i)),a=o.next(),e.label=5;case 5:return a.done?[3,8]:(u=Object(y.h)(a.value,2),c=u[0],u=u[1],null==(c=s.printAreas[0].getContainer(c))?[3,7]:[4,c.update(u)]);case 6:e.sent(),e.label=7;case 7:return a=o.next(),[3,5];case 8:return[3,11];case 9:return c=e.sent(),h={error:c},[3,11];case 10:try{a&&!a.done&&(f=o.return)&&f.call(o)}finally{if(h)throw h.error}return[7];case 11:return n=r.next(),[3,3];case 12:return[3,15];case 13:return u=e.sent(),l={error:u},[3,15];case 14:try{n&&!n.done&&(d=r.return)&&d.call(r)}finally{if(l)throw l.error}return[7];case 15:return[2]}})})};var Ye,qe=Ke;function Ke(){return null!==Ye&&Ye.apply(this,arguments)||this}var $e=t(25),Ze=t(14),A=(M.throw=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];throw"".concat(e,": ").concat(t.join(", "))},M.InvalidProcessorExpression="Invalid expression",M.CannotFoundType="Cannot found type",M.CannotFoundTypeConstructor="Cannot found constructor of type",M.CannotFoundStaticMethod="Cannot found static method",M.CannotFoundEnum="Cannot found enumeration",M.InvalidEnumValue="Enum does not contain value",M.DublicateTypesFound="Dublicate types have been detected",M.CommandNotFound="Command not found",M);function M(){}var Qe=t(94),et=t(425),tt=t(444),rt=(k.prototype.fromConstructor=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];Object(h.l)(e)&&A.throw("Invalid argument",e);var n=this._findFunction(e),e=(this._isConstructor(n)||A.throw(A.CannotFoundTypeConstructor,e),n);try{return new(e.bind.apply(e,Object(y.j)([void 0],Object(y.h)(t),!1)))}catch(e){throw console.error(e),e}},k.prototype._findFunction=function(e){for(var t=e.split("."),r=(this._types.has(t[0])||A.throw(A.CannotFoundType,e),this._types.get(t[0])),n=1;n<t.length;n++)null==r[t[n]]&&A.throw(A.CannotFoundTypeConstructor,e),r=r[t[n]];return r},k.prototype._isConstructor=function(e){return e instanceof Function&&null!=e.prototype.constructor},k.prototype.fromStaticMethod=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=this._findFunction(e);null!=n&&n instanceof Function||A.throw(A.CannotFoundStaticMethod,e);try{return n.apply(void 0,Object(y.j)([],Object(y.h)(t),!1))}catch(e){throw console.error(e),e}},k.prototype.fromProperties=function(e,t){e=this.fromConstructor(e);return Object(h.e)(e,[t],{deep:!1,ignoreNull:!1})},k.prototype.fromEnum=function(e,t){this._types.has(e)||A.throw(A.CannotFoundEnum,e);var r=this._types.get(e);return r instanceof Object||A.throw(A.CannotFoundEnum,e),null==r[t]&&A.throw(A.InvalidEnumValue,{type:e,value:t}),r[t]},k.prototype._loadModuleTypes=function(e){var t,r;if(void 0!==e)try{for(var n=Object(y.k)(Object.entries(e)),i=n.next();!i.done;i=n.next()){var s=Object(y.h)(i.value,2),o=s[0],a=s[1];(a instanceof Function||a instanceof Object)&&(this._types.has(o)&&A.throw(A.DublicateTypesFound,o),this._types.set(o,a))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},k);function k(){this._types=new Map;for(var e=[tt,pe,Y],t=0;t<e.length;t++)this._loadModuleTypes(e[t]);this._loadModuleTypes({Collection:et.a})}nt=Ze.a,Object(y.d)(st,nt),st.prototype.subProcessorAllocatorFactory=function(){var e=new Qe.a;return e.register(new at(this,new rt)),e};var nt,it=st;function st(){return null!==nt&&nt.apply(this,arguments)||this}ot=$e.a,Object(y.d)(E,ot),E.prototype.apply=function(e,t,r){var n,i;switch(void 0===r&&(r=function(e){return e}),!0){case Array.isArray(e):return e.map(function(e){return r(e)});case this.isObject(e):var s={};try{for(var o=Object(y.k)(Object.entries(e)),a=o.next();!a.done;a=o.next()){var c=Object(y.h)(a.value,2),u=c[0],l=c[1];if(this._isNewExpression(u)||this._isCallExpression(u))return this._buildObjectModel(u,l,r);s[u]=this._buildModelProperty(l,r)}}catch(e){n={error:e}}fina