@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 84 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[24],{539:function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(404),i=r(603),s=function(){function e(){}return Object.defineProperty(e,"iframeApiPromise",{get:function(){return this._iframeApiSubject.pipe(Object(i.a)(1)).toPromise()},enumerable:!1,configurable:!0}),e.loadCCScript=function(e,t){var r=this;if("undefined"!=typeof CustomersCanvas||document.body.querySelector("#CcIframeApiScript"))"undefined"!=typeof CustomersCanvas&&this._iframeApiSubject.next(CustomersCanvas);else{this._iframeApiSubject=new n.a(1);var i=document.createElement("script");i.type="text/javascript",i.id="CcIframeApiScript",i.onload=function(e){CustomersCanvas&&r._iframeApiSubject.next(CustomersCanvas)},i.onerror=function(e){r._iframeApiSubject.error(e)},i.src=e+t,document.body.appendChild(i)}return this.iframeApiPromise},e._iframeApiSubject=new n.a(1),e}()},540:function(e,t,r){"use strict";r.d(t,"a",(function(){return d}));var n=r(0),i=r(36),s=r(601),o=r(1),a=r(71),c=r(395),u=r(603),l=r(541),d=function(){function e(e,t,r,n){void 0===r&&(r=function(){return Promise.resolve()}),this._executedActions=[],this._lastJobKey="init",this._lastExecutedJobSubject=new l.a("init"),this._commands=e,this._onJobFinish=r,this.logger=new a.Category("command-executer_"+t+"_"+o.a.guid()),this.widget=n}return e.prototype._showLockPreloader=function(e,t,r){var i,s;if(e&&t&&e[t]&&e[t].lock&&this.widget){var o=Array.isArray(e[t].lock)?e[t].lock:[e[t].lock];try{for(var a=Object(n.k)(o),c=a.next();!c.done;c=a.next()){var u=c.value,l="main"===u?this.widget.auWizard:this.widget.auWizard.scope.$[u]||this.widget.jsonParamsFetcher.scope[u]||this.widget.jsonParamsFetcher.scope.$[u];l&&l.showPreloader(r)}}catch(d){i={error:d}}finally{try{c&&!c.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}}},e.prototype.executeActions=function(e,t,r){var s=this;t=t.filter((function(t){var r=!(!0===e[t].executeOnce&&-1!==s._executedActions.indexOf(t)),n=!0;return Array.isArray(e[t].executeOnlyAfter)&&(n=e[t].executeOnlyAfter.reduce((function(e,t){return-1===s._executedActions.indexOf(t)&&(e=!1),e}),!0)),r&&n}));var a=function(c){return Object(n.b)(s,void 0,void 0,(function(){var s,u,l,d,h,f,p,g,b,m,v,y,w;return Object(n.e)(this,(function(n){switch(n.label){case 0:if(this.logger.debug((function(){return"Start Execute '".concat(c,"'")})),s=performance.now(),u=Promise.resolve(),l=this._commands[c],d=Array.isArray(e[c])?e[c][0].message:e[c].message,h=(Array.isArray(e[c])?e[c][0].timeout:e[c].timeout)||10,!l||void 0===l.execute)return[3,8];if(d&&this.widget.showPreloader(!0,d,h),this._showLockPreloader(e,c,!0),u=l.execute(e[c],r[c]),-1===this._executedActions.indexOf(c)&&this._executedActions.push(c),!(f=e[c].after)&&Array.isArray(e[c])&&(p=e[c].find((function(e){return e.after})))&&(f=p.after),void 0===f)return[3,4];Object(i.a)(f)||(f=[f]),g=function(e,t,r){var n=r.indexOf(e);return r.indexOf(t)>n},b=0,n.label=1;case 1:return b<f.length?(m=f[b],g(c,m,t)?[3,3]:[4,u]):[3,4];case 2:n.sent(),u=a(m),n.label=3;case 3:return b++,[3,1];case 4:return!(v=e[c].onExecuted)&&Array.isArray(e[c])&&(y=e[c].find((function(e){return e.onExecuted})))&&(v=y.onExecuted),v?[4,u]:[3,7];case 5:return n.sent(),[4,o.a.functionWrapperConstructor(v)()];case 6:n.sent(),n.label=7;case 7:return[3,9];case 8:console.warn("Action ".concat(c," is not supported! Double check the config.")),n.label=9;case 9:return[4,u];case 10:return n.sent(),d&&this.widget.showPreloader(!1),this._showLockPreloader(e,c,!1),this.logger.debug((function(){return"Finish Execute '".concat(c,"'")})),w=performance.now(),this.widget.auWizard.telemetry.trackEvent("DE-"+c,w-s),[2,u]}}))}))},c=this.getJobReady(this._lastJobKey),u=this._lastJobKey=o.a.guid();return c.then((function(){return s.logger.debug((function(){return"Start actons: ".concat(t)})),o.a.recursiveJobPromise(t,a)})).then((function(){return s._onJobFinish()})).finally((function(){s.logger.debug((function(){return"End actons: ".concat(t)})),s._lastExecutedJobSubject.next(u)}))},e.prototype.getJobReady=function(e){return this._lastExecutedJobSubject.pipe(Object(c.a)((function(t){return t===e})),Object(u.a)(1)).toPromise()},e.prototype.getChangedActions=function(e,t){var r=Object.keys(e).filter((function(t){return o.a.isObjectNotEmpty(e[t])})).filter((function(r){return void 0===t[r]||(n=e[r],i=t[r],!(JSON.stringify(n)===JSON.stringify(i)));var n,i})),n=r.indexOf("actionsErrorToast");return-1!==n&&r.splice(n,1),(r=r.filter((function(t){var r=e[t];return Array.isArray(r)?r[0]&&!1!==r[0].autoCompile:!1!==r.autoCompile}))).indexOf("initial")>-1?["initial"].concat(Object(s.a)(r,"initial")):r},e}()},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(e,t,r){"use strict";r.r(t),r.d(t,"AuWidgetDesignEditor",(function(){return me})),r.d(t,"widget",(function(){return me}));var n=r(0),i=r(888),s=r(887),o=r(445),a=r(464),c=r(410),u=r(540),l=r(1),d=r(537),h=r(598),f=r(202),p=r(928),g=r(2),b=r(17),m=r(539),v=function(){function e(){this.promise=new Promise(function(e,t){this._resolve=e,this._reject=t}.bind(this))}return e.prototype.then=function(e){return this.promise.then(e)},e.prototype.catch=function(e){return this.promise.catch(e)},e.prototype.resolve=function(e){void 0===e&&(e=""),this._resolve(e)},e.prototype.reject=function(e){this._reject(e)},e}(),y=r(413),w=r(408),O=r(559),I=r(435),j=r(560),P=r(562),C=r(478),_=r(512),x=r(567),S=r(458),D=r(440),A=function(e){Object.assign(this,e)},M=r(404),k=r(603),E=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._customersCanvasSubject=new M.a(1),t}return Object(n.d)(t,e),t.prototype.customersCanvasPublish=function(e){this._customersCanvasSubject.next(e)},Object.defineProperty(t.prototype,"customersCanvasObservable",{get:function(){return this._customersCanvasSubject.asObservable()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"customersCanvasPromise",{get:function(){return this.customersCanvasObservable.pipe(Object(k.a)(1)).toPromise()},enumerable:!1,configurable:!0}),t.prototype.getProduct=function(){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.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()]}}))}))},t.prototype.getEditor=function(){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(e){switch(e.label){case 0:return[4,this._customersCanvasSubject.asObservable().pipe(Object(k.a)(1)).toPromise()];case 1:return[2,e.sent()]}}))}))},t.prototype.getDesignEditorItemModel=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a,c,u,h,f,p,g,b,m,v,M,k,E,R,N,T;return Object(n.e)(this,(function(n){switch(n.label){case 0:if(t=e.type===_.b.type,r=e.type===I.a.type||e.type===j.a.type||e.type===x.a.type||e.type===P.a.type||e.type===O.a.type,i=e.type===w.kb.type||e.type===w.gb.type||e.type===w.A.type||e.type===_.b.type,e.type,C.a.type,s=!1,o=!1,!e)return[2];switch(a={name:e.name},t&&(s=l.a.isNotNullOrUndefined(e.content)&&(e.content instanceof CustomersCanvas.DesignAtoms.ObjectModel.ImageItem||"ImageItem"===e.content.type),o=l.a.isNotNullOrUndefined(e.content)&&(e.content instanceof CustomersCanvas.DesignAtoms.ObjectModel.BarcodeItem||"BarcodeItem"===e.content.type)),!0){case t&&s&&!o&&null!==e.content.tags.sourceData&&void 0!==e.content.tags.sourceData:return[3,1];case t&&s:return[3,7];case r&&!!e.text:return[3,8]}return[3,9];case 1:return c=e.content,u=new D.a(e),h=u.getTransformedRectangle(),f=new S.b(c),p=f.getTransformedRectangle(),[4,this.getEditor()];case 2:g=n.sent(),b=300,n.label=3;case 3:return n.trys.push([3,5,,6]),[4,g.eval("var printArea = spEditor.productHandler.product.surfaces.elementAt(0).printAreas.elementAt(0);var config = spEditor.configuration.renderingConfig.getHiResRendering(printArea);config.dpi;")];case 4:return b=n.sent(),[3,6];case 5:return n.sent(),console.warn("Failed to get hires render config dpi"),[3,6];case 6:return a.tags=Object(d.a)(c.tags),a.value=c.tags.sourceData.name,a.placeholderContent={originalUrl:c.tags.sourceData.originalUrl,width:c.source.width,height:c.source.height,placeholderRectangle:h,contentRectangle:p,contentResizeMode:_.c[e.contentResizeMode].toLowerCase(),contentTransform:{angle:c.transform.angle,scaleX:c.transform.scaleX,scaleY:c.transform.scaleY,translateX:c.transform.translateX,translateY:c.transform.translateY},dpi:b},[3,9];case 7:return a={name:e.name,tags:Object(d.a)(e.tags)},[3,9];case 8:return v="",M=function(e){return(e/255).toFixed(7)},(m=e).color&&(m.color.colorSpace===y.ColorSpace.Rgb?(k=m.color,v="rgb(".concat(k.r,",").concat(k.g,",").concat(k.b,",").concat(M(k.alpha),")")):m.color.colorSpace===y.ColorSpace.Cmyk&&(E=m.color,v="cmyk(".concat(M(E.c),",").concat(M(E.m),",").concat(M(E.y),",").concat(M(E.k),",").concat(M(E.alpha),")"))),a={name:e.name,value:m.text,color:v,font:{postScriptName:m.font.postScriptName,size:m.font.size,fauxBold:m.font.fauxBold,fauxItalic:m.font.fauxItalic}},[3,9];case 9:return t&&(e.contentPermissions&&e.contentPermissions.imagePermissions&&(a.contentPermissions={imagePermissions:{allowChangeImage:e.contentPermissions.imagePermissions.allowChangeImage,allowEditImage:e.contentPermissions.imagePermissions.allowEditImage}}),e.placeholderPermissions&&(a.placeholderPermissions={allowEditContent:e.placeholderPermissions.allowEditContent,showHandleButton:e.placeholderPermissions.showHandleButton,showSelectButton:e.placeholderPermissions.showSelectButton})),e.visualizationPermissions&&(a.visualizationPermissions={noPrint:e.visualizationPermissions.noPrint,noShow:e.visualizationPermissions.noShow}),null!==e.locked&&(a.locked=e.locked),i?e.type===_.b.type?[3,11]:(N=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(e.fillColor),a.fillColor=N,R=a,[4,this.colorToHex(N)]):[3,13];case 10:return R.fillColorHex=n.sent(),[3,13];case 11:return N=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(e.contentFillColor),a.fillColor=N,T=a,[4,this.colorToHex(N)];case 12:T.fillColorHex=n.sent(),n.label=13;case 13:return[2,new A(a)]}}))}))},t.prototype.colorToHex=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o;return Object(n.e)(this,(function(a){switch(a.label){case 0:return!e||l.a.isNullOrUndefined(e.colorSpace)?[2,null]:(t=e.getData(),[4,this.getEditor()]);case 1:return[4,a.sent().eval((function(e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,spEditor.model._viewer.colorPreviewService.getPreviewAsync(e)];case 1:return[2,t.sent().getData()]}}))}))}),t)];case 2:return r=a.sent(),i=r.r.toString(16),s=r.g.toString(16),o=r.b.toString(16),[2,"#".concat(1===i.length?"0"+i:i)+"".concat(1===s.length?"0"+s:s).concat(1===o.length?"0"+o:o)]}}))}))},t}(r(160).c),R=function(e){this.widget=e},N=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){var t;return Object(n.b)(this,void 0,void 0,(function(){var r,i,s,o,a,c,u,l,d,h,f;return Object(n.e)(this,(function(p){switch(p.label){case 0:return e.surfaceToDuplicateId||(null===(t=e.surfacesToChangeIds)||void 0===t?void 0:t.length)>0?[4,this.widget.getProduct()]:[2];case 1:return[4,(r=p.sent()).getProductModel()];case 2:if(i=p.sent(),!(s=i.surfaces.get(e.surfaceToDuplicateId)))return console.error("There is no surface with index ".concat(e.surfaceToDuplicateId)),[2];try{for(o=Object(n.k)(e.surfacesToChangeIds),a=o.next();!a.done;a=o.next())(c=a.value)!==e.surfaceToDuplicateId&&((u=i.surfaces.get(c))?(l=u.name,(d=s.clone(!0)).name=l,i.surfaces.replaceAt(d,c)):console.warn("There is no surface with index ".concat(c)))}catch(g){h={error:g}}finally{try{a&&!a.done&&(f=o.return)&&f.call(o)}finally{if(h)throw h.error}}return r.setProductModel(i),[2]}}))}))},t}(R),T=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a,c,u,d,h,f,p,g,b,m,v=this;return Object(n.e)(this,(function(y){switch(y.label){case 0:if(0===(t=(Array.isArray(e)?e:[e]).filter((function(e){return e}))).length)return[2];this.widget.initDpApi(),y.label=1;case 1:y.trys.push([1,17,18,19]),r=Object(n.k)(t),i=r.next(),y.label=2;case 2:return i.done?[3,16]:(s=i.value,[4,this.widget.getProduct()]);case 3:return(o=y.sent()).updateSurfaces?1!==o.updateSurfaces.length?[3,13]:s.definition&&s.definition.surfaces?(a=s.definition.surfaces,[4,Promise.all(a.map((function(e){return Object(n.b)(v,void 0,void 0,(function(){var t,r,i,s;return Object(n.e)(this,(function(o){switch(o.label){case 0:return t=e.designVariant,r=Object(n.i)(e,["designVariant"]),""===(null==t?void 0:t.designResourceId)?[3,2]:[4,this.widget.createPrivateDesignFromResources(t.designResourceId)];case 1:return s=o.sent(),[3,4];case 2:return[4,this.widget.createPrivateDesignFromPublicDesign(t.designId)];case 3:s=o.sent(),o.label=4;case 4:return i=s,[2,Object(n.a)({stateId:i},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 c=y.sent(),s.definition,d=Object(n.i)(s,["definition"]),p=Object(n.a)({definition:{surfaces:c},updateSurfaceSize:!0,preserveUserChanges:!0,updateBehavior:"changeSurfaceLength"},d),[4,o.updateSurfaces(p)];case 5:return y.sent(),[3,12];case 6:return u=s.designVariant,d=Object(n.i)(s,["designVariant"]),l.a.isNullOrUndefined(u)?[2]:""===(null==u?void 0:u.designResourceId)?[3,8]:[4,this.widget.createPrivateDesignFromResources(u.designResourceId)];case 7:return f=y.sent(),[3,10];case 8:return[4,this.widget.createPrivateDesignFromPublicDesign(u.designId)];case 9:f=y.sent(),y.label=10;case 10:return h=f,p=Object(n.a)({definition:h,updateSurfaceSize:!0,preserveUserChanges:!0,updateBehavior:"changeSurfaceLength"},d),[4,o.updateSurfaces(p)];case 11:y.sent(),y.label=12;case 12:return[3,15];case 13:return[4,o.updateSurfaces(s.productDefinition||s.definition,s.options,s.sourceSurfaceIndexes,s.targetSurfaceIndexes)];case 14:y.sent(),y.label=15;case 15:return i=r.next(),[3,2];case 16:return[3,19];case 17:return g=y.sent(),b={error:g},[3,19];case 18:try{i&&!i.done&&(m=r.return)&&m.call(r)}finally{if(b)throw b.error}return[7];case 19:return[2]}}))}))},t}(R),z=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}Object(n.d)(t,e),t.prototype.execute=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(e){throw"Not Implemented"}))}))}}(R),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.widget.getProduct()];case 1:return t=n.sent(),r=e.data.map((function(e,r){return{mockup:e.mockup,previewMockups:e.previewMockups,surface:t.surfaces[r]}})),[4,t.setMockups(r,e.options)];case 2:return[2,n.sent()]}}))}))},t}(R)),U=r(407),F=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a,c,u,d,h,f,p,g,b,m,v,y;return Object(n.e)(this,(function(w){switch(w.label){case 0:return t=Array.isArray(e)?e:[e],[4,this.widget.getEditor()];case 1:return[4,(r=w.sent()).getProduct()];case 2:i=w.sent(),w.label=3;case 3:w.trys.push([3,8,9,10]),s=Object(n.k)(t),o=s.next(),w.label=4;case 4:return o.done?[3,7]:(a=o.value,l.a.isEmptyString(a.url)?[3,6]:(c=a.surfaceIndex,(l.a.isNullOrUndefined(c)||c<0||c>i.surfaces.length)&&((c=1===t.length?i.currentSurfaceIndex:t.indexOf(a))<0||c>i.surfaces.length)&&(c=i.currentSurfaceIndex),u=i.surfaces[c],d=u.width/2,h=u.height/2,a.size&&(a.size.width&&(d=a.size.width),a.size.height&&(h=a.size.height)),f=u.width/2-d/2,p=u.height/2-h/2,a.position&&(l.a.isNotNullOrUndefined(a.position.x)&&(f=a.position.x),l.a.isNotNullOrUndefined(a.position.y)&&(p=a.position.y)),(g=new window.CustomersCanvas.DesignAtoms.ObjectModel.ImageItem(null,new U.PointF(f,p),d,h)).name=a.name,[4,u.insertItem(g)]));case 5:w.sent(),w.label=6;case 6:return o=s.next(),[3,4];case 7:return[3,10];case 8:return b=w.sent(),v={error:b},[3,10];case 9:try{o&&!o.done&&(y=s.return)&&y.call(s)}finally{if(v)throw v.error}return[7];case 10:return m=t.reduce((function(e,t){return e[t.name]=t.url,e}),{}),[4,r.loadUserInfo(m)];case 11:return w.sent(),[2]}}))}))},t}(R),B=r(891),L=r(37),W=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){var t,r,i,s;return Object(n.b)(this,void 0,void 0,(function(){var o,a,c,u,d,h,f,p,g=this;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.widget.iframeApiPromise];case 1:if(n.sent(),e.editorConfig=e.editorConfig||{},e.onCustomButtonClicked&&(this.widget.customButtonCb=e.onCustomButtonClicked),"function"==typeof e.OnBoundsNotificationCb&&(this.widget._boundsNotificationCb=e.OnBoundsNotificationCb),"string"==typeof e.productDefinition&&(e.editorConfig.autoLoadUserInfo=!1,e.editorConfig.userInfo=null,this.widget._stateId=e.productDefinition,this.widget._userId=this.widget.driver.user.id),(o=this.widget.driver.user.data)&&Object.keys(o).length>0&&(e.editorConfig.userInfo=l.a.DeepMerge(e.editorConfig.userInfo||{},o),e.editorConfig.autoLoadUserInfo=!0),e.editorConfig=e.editorConfig||{},e.editorConfig.themeConfiguration=e.editorConfig.themeConfiguration||{},this.widget.driver.themeSettings?(e.editorConfig.themeConfiguration.primaryColor=this.widget.driver.themeSettings.primaryColor,e.editorConfig.themeConfiguration.logo=this.widget.driver.themeSettings.logo):(this.widget.auWizard.config.icons&&this.widget.auWizard.config.icons.preloader&&(e.editorConfig.themeConfiguration.logo=this.widget.auWizard.config.icons.preloader),e.editorConfig.themeConfiguration.primaryColor=getComputedStyle(document.documentElement).getPropertyValue("--theme-primary-color")),a=null===(r=null===(t=this.widget.driver)||void 0===t?void 0:t.localization)||void 0===r?void 0:r.find((function(e){return"design-editor"===e.app})),c={},u=this.widget.language.slice(0,2),!a)return[3,8];if(!l.a.isNotNullOrUndefined(a.url)||l.a.isEmptyString(a.url)||"string"!=typeof a.url)return[3,6];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,l.a.loadJson(a.url+"?ts="+Date.now())];case 3:return c=n.sent(),[3,5];case 4:return d=n.sent(),console.error(d),[3,5];case 5:return[3,7];case 6:l.a.isNotNullOrUndefined(a.data)&&"object"==typeof a.data&&0!==Object.keys(a.data).length&&(c=-1!==Object.keys(a.data).indexOf(u)?l.a.DeepMerge(c,a.data):l.a.DeepMerge(c,((p={})[u]=a.data,p))),n.label=7;case 7:e.editorConfig.translations=c,n.label=8;case 8:return h=e.maximizeAssetManager||e.galleryObserverEnable||this.widget.driver.config.displayInPopup,(null===(s=null===(i=null==e?void 0:e.editorConfig)||void 0===i?void 0:i.preloader)||void 0===s?void 0:s.enabled)||(e.editorConfig.preloader={enabled:!1}),[4,this.load(e.productDefinition,e.editorConfig,h,e.initSurfaceIndex)];case 9:return n.sent(),[4,this.widget.getViolationData()];case 10:if(n.sent(),!e.onInit)return[3,14];f=l.a.functionWrapperConstructor(e.onInit),n.label=11;case 11:return n.trys.push([11,13,,14]),[4,f()];case 12:case 13:return n.sent(),[3,14];case 14:return[2,L.Maybe.maybe(e).map((function(e){return e.viewerSettings})).caseOf({just:function(e){return g.widget.applyViewerSettings(e)},nothing:function(){return g.widget.customersCanvasPromise}})]}}))}))},t.prototype.load=function(e,t,r,i){return Object(n.b)(this,void 0,void 0,(function(){var s,o,a,c,u,d,h,f,p=this;return Object(n.e)(this,(function(g){switch(g.label){case 0:return s=this,e.surfaces&&Array.isArray(e.surfaces)&&e.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))})),s.widget.modifiedItem&&s.widget.updateModifiedItem({}),o=this.widget.shadowRoot.querySelector("#design-editor"),[4,CustomersCanvas.IframeApi.loadEditor(o,e,t)];case 1:a=g.sent(),g.label=2;case 2:return g.trys.push([2,5,,6]),[4,a.getProduct()];case 3:return[4,(c=g.sent()).switchTo(c.surfaces[0])];case 4:return c=g.sent(),[3,6];case 5:return u=g.sent(),console.error("Load failed with exception: ",u),s.widget.dispatchEvent(new CustomEvent("error",u)),[2];case 6:return l.a.isNotNullOrUndefined(i)?(d=Number(i),(Number.isNaN(d)||d<0||d>c.surfaces.length)&&(d=0),[4,c.switchTo(c.surfaces[d])]):[3,8];case 7:g.sent(),g.label=8;case 8:return s.widget.customersCanvasPublish(a),s.widget.dispatchEvent(new CustomEvent("ready",{detail:{product:c,customersCanvas:a}})),[4,this.widget.replaceInterpolationPlaceholder()];case 9:return g.sent(),h=[],f=function(e,t,r,i){void 0===r&&(r=!1),void 0===i&&(i=!1),h.push(e),a.subscribe(e,(function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];return Object(n.b)(p,void 0,void 0,(function(){var o,a,c;return Object(n.e)(this,(function(u){switch(u.label){case 0:return r?[4,this.widget.getViolationData()]:[3,2];case 1:u.sent(),u.label=2;case 2:return t?[4,t.apply(void 0,Object(n.j)([],Object(n.h)(s),!1))]:[3,4];case 3:u.sent(),u.label=4;case 4:return(o=(null===(a=this.widget.params)||void 0===a?void 0:a.initial)&&(this.widget.params.initial["on"+e]||(null===(c=this.widget.params)||void 0===c?void 0:c.initial[e])))?[4,l.a.functionWrapperConstructor(o).apply(window,s)]:[3,6];case 5:u.sent(),u.label=6;case 6:return i&&this.widget.emitChange(),[2]}}))}))}))},r&&(f(B.a.ModalClose,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Object(n.b)(p,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return[2,this.widget.toggleMaximizeMainPanel(!1)]}))}))})),f(B.a.ModalOpen,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Object(n.b)(p,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return[2,this.widget.toggleMaximizeMainPanel(!0)]}))}))})),f(B.a.AssetManagerClosed,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Object(n.b)(p,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return[2,this.widget.toggleMaximizeMainPanel(!1)]}))}))})),f(B.a.AssetManagerOpened,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Object(n.b)(p,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return[2,this.widget.toggleMaximizeMainPanel(!0)]}))}))}))),f(B.a.OriginalSize,(function(){return Object(n.b)(p,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return[2,this.widget.toggleMaximizeMainPanel(!1)]}))}))})),f(B.a.FullWindow,(function(){return Object(n.b)(p,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return[2,this.widget.toggleMaximizeMainPanel(!0)]}))}))})),f(B.a.BoundsNotification,(function(e){p.widget.selectedGroupBoundsData=e,p.widget._boundsNotificationCb&&p.widget._boundsNotificationCb(e)})),f(B.a.OnImageDpiChanged,null,!0),f(B.a.OnSurfaceChanged,(function(){return Object(n.b)(p,void 0,void 0,(function(){return Object(n.e)(this,(function(e){switch(e.label){case 0:return[4,this.widget.updateCurrentSurfaceData()];case 1:return[2,e.sent()]}}))}))})),f(B.a.ItemAdded,null,!0),f(B.a.ItemRemoved,null,!0),f(B.a.ItemChanged,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Object(n.b)(p,void 0,void 0,(function(){var t,r;return Object(n.e)(this,(function(n){switch(n.label){case 0:if(t=e[0],l.a.isNullOrUndefined(t))return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.widget.getDesignEditorItemModel(t)];case 2:return r=n.sent(),this.widget.updateModifiedItem(r),[3,4];case 3:return n.sent(),console.warn("Failed to transform item model"),[3,4];case 4:return[2]}}))}))}),!0),f(B.a.RevertProduct,null,!0,!0),f(B.a.UndoProduct,null,!0),f(B.a.RedoProduct,null,!0),f(B.a.CustomButtonClicked,(function(e){return Object(n.b)(p,void 0,void 0,(function(){return Object(n.e)(this,(function(t){return[2,this.widget.customButtonCb(e[0],e[1])]}))}))})),Object.keys(B.a).forEach((function(e){-1===h.indexOf(e)&&f(e,null)})),[2]}}))}))},t}(R),G=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var t,r;return Object(n.e)(this,(function(n){switch(n.label){case 0:return l.a.isEmptyObject(e)||l.a.isEmptyObject(e.data)?[2,Promise.resolve()]:[4,this.widget.getEditor()];case 1:t=n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,t.loadUserInfo(e.data,e.options)];case 3:return n.sent(),[3,5];case 4:return r=n.sent(),console.warn(r),[3,5];case 5:return[2]}}))}))},t}(R),V=r(471),H=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var r,i;return Object(n.e)(this,(function(n){switch(n.label){case 0:return l.a.isEmptyObject(e)||l.a.isEmptyObject(e.every)&&l.a.isEmptyObject(e.items)?[2,Promise.resolve()]:(e.items=e.items||{},l.a.isNotNullOrUndefined(t)&&(e=this._removeOldParams(e,t)),[4,this.widget.getEditor()]);case 1:return[4,(r=n.sent()).getProduct()];case 2:return i=n.sent(),[4,this._modifyItems(e,i,r)];case 3:return n.sent(),[4,this._applyUserInfo(r,e)];case 4:return n.sent(),[2]}}))}))},t.prototype._modifyItems=function(e,t,r){return Object(n.b)(this,void 0,void 0,(function(){var i,s,o,a,c,u,d,h,f,p;return Object(n.e)(this,(function(g){switch(g.label){case 0:return l.a.isNullOrUndefined(e)?[2]:l.a.isNotNullOrUndefined(e.items)?[4,this._applyBackgroundColor(e,t)]:[3,2];case 1:g.sent(),g.label=2;case 2:return[4,t.getProductModel()];case 3:i=g.sent(),s=i.getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!1}),g.label=4;case 4:g.trys.push([4,13,14,15]),o=Object(n.k)(s),a=o.next(),g.label=5;case 5:return a.done?[3,12]:(c=a.value,u=Object(n.a)(Object(n.a)({},e.every),e.items[c.name]),0===Object.keys(u).length?[3,11]:this.needApplyOnce(u,c)?this._isTextItem(c.type)?(this._updateTextItem(u,c),[3,10]):[3,6]:[3,11]);case 6:return c.type!==w.cb.type?[3,8]:[4,this._updatePlaceholderItem(u,c,r)];case 7:return g.sent(),[3,10];case 8:return this._isShapeItem(c)?[4,this._updateShapeItem(u,c)]:[3,10];case 9:g.sent(),g.label=10;case 10:this._updateVisualizationPermissions(u,c),this.setApplyOnce(u,c),g.label=11;case 11:return a=o.next(),[3,5];case 12:return[3,15];case 13:return d=g.sent(),f={error:d},[3,15];case 14:try{a&&!a.done&&(p=o.return)&&p.call(o)}finally{if(f)throw f.error}return[7];case 15:return h=t.currentSurfaceIndex>0?t.currentSurfaceIndex:0,[4,t.setProductModel(i)];case 16:return g.sent(),[4,r.getProduct()];case 17:return[4,(t=g.sent()).switchTo(t.surfaces[h])];case 18:return g.sent(),[2]}}))}))},t.prototype.needApplyOnce=function(e,t){return!(!0===e.once&&t&&t.tags.modifyItems&&!0===t.tags.modifyItems.once)},t.prototype.setApplyOnce=function(e,t){!0===e.once&&t&&(t.tags.modifyItems=t.tags.modifyItems||{},t.tags.modifyItems.once=!0)},t.prototype._isTextItem=function(e){return e===w.o.type||e===w.q.type||e===w.eb.type||e===w.x.type||e===w.g.type},t.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},t.prototype._applyBackgroundColor=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var r,i,s,o,a,c,u;return Object(n.e)(this,(function(l){switch(l.label){case 0:if(null==(r=e.items.background||e.items.Background)||null==r.color)return[3,8];if(null===(i=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(r.color)))return[3,8];l.label=1;case 1:l.trys.push([1,6,7,8]),s=Object(n.k)(t.surfaces),o=s.next(),l.label=2;case 2:return o.done?[3,5]:[4,o.value.changeBackground(i)];case 3:l.sent(),l.label=4;case 4:return o=s.next(),[3,2];case 5:return[3,8];case 6:return a=l.sent(),c={error:a},[3,8];case 7:try{o&&!o.done&&(u=s.return)&&u.call(s)}finally{if(c)throw c.error}return[7];case 8:return[2]}}))}))},t.prototype._updateTextItem=function(e,t){var r=e.text||e.value;if(null!=r&&(t.text=r,t.placeholders&&t.placeholders.length>0&&(t.placeholders.forEach((function(e){return e.value=r})),t.value=r)),null!=e.font){var n=e.font.bold||e.font.fauxBold;n&&(t.font.fauxBold=n);var i=e.font.italic||e.font.fauxItalic;i&&(t.font.fauxItalic=i);var s=e.font.family||e.font.postScriptName;s&&(t.font.postScriptName=s),e.font.size&&(t.font.size=e.font.size),e.font.underline&&(t.underline=e.font.underline);var o=e.color||e.font.color;o&&(t.color=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(o))}if(!0===e.locked&&(t.textPermissions.allowChangeText=!1,t.textPermissions.allowChangeTextBIU=!1),t.type===w.eb.type&&(l=e.position||e.location)){var a=0,c=0,u=t;t.alignment=w.qb.Left,l||(l={x:0,y:0}),a=l.x||u.baselineLocation.x,c=l.y||u.baselineLocation.y,u.baselineLocation=new window.CustomersCanvas.DesignAtoms.ObjectModel.PointF(a,c)}if(t.type===w.q.type||t.type===w.g.type){var l,d,h,f=t;if((l=e.position||e.location)||e.size)a=0,c=0,l||(l={x:0,y:0}),a=l.x||f.textRectangle.left,c=l.y||f.textRectangle.top,e.size||(e.size={width:0,height:0}),d=e.size.width||f.textRectangle.width,h=e.size.height||f.textRectangle.height,f.textRectangle.width=d,f.textRectangle.height=h,f.textRectangle.left=a,f.textRectangle.top=c}},t.prototype._updateVisualizationPermissions=function(e,t){e.visualizationPermissions&&(l.a.isNotNullOrUndefined(e.visualizationPermissions.noPrint)&&(t.visualizationPermissions.noPrint=e.visualizationPermissions.noPrint),l.a.isNotNullOrUndefined(e.visualizationPermissions.noShow)&&(t.visualizationPermissions.noShow=e.visualizationPermissions.noShow)),l.a.isNotNullOrUndefined(e.locked)&&(t.locked=e.locked)},t.prototype._updatePlaceholderItem=function(e,t,r){return Object(n.b)(this,void 0,void 0,(function(){var i,s,o,a,c,u,l,d,h,f,p,g;return Object(n.e)(this,(function(n){switch(n.label){case 0:return i=function(e){return e.placeholderContent&&e.tags&&e.tags.sourceData&&e.value===e.tags.sourceData.name},"ImagePlaceholder"!==e.type?[3,6]:i(e)?-1!==e.placeholderContent.originalUrl.indexOf("?x-cctoken=")?[3,2]:[4,this.widget.getToken()]:[3,4];case 1:""!==(s=n.sent())&&(e.placeholderContent.originalUrl+="?x-cctoken=".concat(s)),n.label=2;case 2:return o=e.placeholderContent.originalUrl,e.tags.sourceData.originalUrl=o,[4,r.configuration.getImageMetadata(o)];case 3:if(a=n.sent(),f=t.content,t.isStubContent=!1,f.setData)try{f.setData(a)}catch(b){V.a.setDataToImage(a,f)}else V.a.setDataToImage(a,f);return f.tags=e.tags,f.parentPlaceholder=t,p=new D.a(t),(g=new S.b(f)).updateRectangle(!1,t.contentResizeMode,p),c=p.getTransformedRectangle(),u=e.placeholderContent,(c.angle!==u.placeholderRectangle.angle||c.width!==u.placeholderRectangle.width||c.height!==u.placeholderRectangle.height||c.centerX!==u.placeholderRectangle.centerX||c.centerY!==u.placeholderRectangle.centerY)&&(l=new window.CustomersCanvas.DesignAtoms.ObjectModel.RotatedRectangleF(u.placeholderRectangle.centerX,u.placeholderRectangle.centerY,u.placeholderRectangle.width,u.placeholderRectangle.height,u.placeholderRectangle.angle),p.setTransformedRectangle(l)),((d=g.getTransformedRectangle()).angle!==u.contentRectangle.angle||d.width!==u.contentRectangle.width||d.height!==u.contentRectangle.height||d.centerX!==u.contentRectangle.centerX||d.centerY!==u.contentRectangle.centerY)&&(h=new window.CustomersCanvas.DesignAtoms.ObjectModel.RotatedRectangleF(u.contentRectangle.centerX,u.contentRectangle.centerY,u.contentRectangle.width,u.contentRectangle.height,u.contentRectangle.angle),g.setTransformedRectangle(h)),[3,5];case 4:if(!t.isStubContent){if((f=t.content).parentPlaceholder=t,f.setData)try{f.setData(t.stubStorageMeta)}catch(b){V.a.setDataToImage(t.stubStorageMeta,f)}else V.a.setDataToImage(t.stubStorageMeta,f);p=new D.a(t),(g=new S.b(f)).parentPlaceholder=p,g.updateRectangle(!1,t.contentResizeMode,p),t.isStubContent=!0}n.label=5;case 5:e.contentPermissions&&e.contentPermissions.imagePermissions&&(t.contentPermissions.imagePermissions.allowChangeImage=e.contentPermissions.imagePermissions.allowChangeImage,t.contentPermissions.imagePermissions.allowEditImage=e.contentPermissions.imagePermissions.allowEditImage),e.placeholderPermissions&&(t.placeholderPermissions.allowEditContent=e.placeholderPermissions.allowEditContent,t.placeholderPermissions.showHandleButton=e.placeholderPermissions.showHandleButton,t.placeholderPermissions.showSelectButton=e.placeholderPermissions.showSelectButton),n.label=6;case 6:return"BarcodePlaceholder"===e.type&&(e.value||t.isStubContent||(t.content.applyBarcodeData(new window.CustomersCanvas.DesignAtoms.ObjectModel.BarcodeData("")),t.isStubContent=!0)),[2]}}))}))},t.prototype._updateShapeItem=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var r,i,s,o,a,c;return Object(n.e)(this,(function(n){return(r=e.color||e.fillColor)&&(t.type!=w.cb.type?t.fillColor=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(r):t.contentFillColor=window.CustomersCanvas.DesignAtoms.ObjectModel.ColorFactory.createColor(r)),((i=e.position||e.location)||e.size)&&(i||(i={x:0,y:0}),s=i.x||t.sourceRectangle.left,o=i.y||t.sourceRectangle.top,e.size||(e.size={width:0,height:0}),a=e.size.width||t.sourceRectangle.width,c=e.size.height||t.sourceRectangle.height,t.type!=w.A.type?t.sourcePath=window.CustomersCanvas.DesignAtoms.ObjectModel.Path.rectangle(s,o,a,c):t.sourcePath=window.CustomersCanvas.DesignAtoms.ObjectModel.Path.ellipse(s,o,a,c)),[2]}))}))},t.prototype._applyUserInfo=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var r,i,s,o,a,c,u,d,h,f,p,g;return Object(n.e)(this,(function(b){switch(b.label){case 0:return r=function(e){return!!e.placeholderContent&&e.tags&&e.tags.sourceData&&e.value===e.tags.sourceData.name},[4,e.getProduct()];case 1:return[4,b.sent().getProductModel()];case 2:i=b.sent(),s=i.getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0}),o={},a=function(e){var n=t.items[e],i=s.find((function(t){return t.name===e}));return c.needApplyOnce(n,i)&&(n.value||"Text"===n.type||"InString"===n.type||n.image)?"ImagePlaceholder"===n.type&&r(n)?"continue":("BarcodePlaceholder"===n.type?n.barcodeSubType&&"None"!==n.barcodeSubType?"Url"===n.barcodeSubType?o[e]={BarcodeFormat:n.barcodeFormat,BarcodeSubType:n.barcodeSubType,Url:n.value}:"Phone"===n.barcodeSubType&&(o[e]={barcodeFormat:n.barcodeFormat,barcodeSubType:n.barcodeSubType,phone:n.value}):o[e]={barcodeFormat:n.barcodeFormat,barcodeValue:n.value}:o[e]=l.a.isNotNullOrUndefined(n.value)?n.value:n.image,void c.setApplyOnce(n,i)):"continue"},c=this;try{for(u=Object(n.k)(Object.keys(t.items)),d=u.next();!d.done;d=u.next())h=d.value,a(h)}catch(m){p={error:m}}finally{try{d&&!d.done&&(g=u.return)&&g.call(u)}finally{if(p)throw p.error}}if(l.a.isEmptyObject(o))return[2,Promise.resolve()];b.label=3;case 3:return b.trys.push([3,5,,6]),[4,e.loadUserInfo(o)];case 4:return b.sent(),[3,6];case 5:return f=b.sent(),this.widget.showToast("Error: Invalid data"),console.log(f),[3,6];case 6:return[2]}}))}))},t.prototype._isShapeItem=function(e){return[w.gb.type,w.kb.type,w.A.type,w.cb.type].includes(e.type)},t}(R),J=r(489),X=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a;return Object(n.e)(this,(function(n){switch(n.label){case 0:return e&&e.resizeParams&&0!==e.resizeParams.height&&0!==e.resizeParams.width?[4,this.widget.getEditor()]:[2];case 1:return t=n.sent(),(r=e.resizeParams).targets&&r.targets.length>0&&"string"==typeof r.targets[0]?[4,t.getProduct()]:[3,6];case 2:return[4,n.sent().getProductModel()];case 3:return[4,n.sent().getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0})];case 4:return i=n.sent(),s=i.filter((function(e){return r.targets.includes(e.name)})).map((function(e){return e.id})),(o=e.resizeParams).targetIds=s,[4,t.commandManager.execute(J.b.resize,o)];case 5:return n.sent(),[3,8];case 6:return"product"!==e.resizeParams.targetType&&(e.resizeParams.targetIds||0===e.resizeParams.targetIds.length)||(null===e.resizeParams.target||void 0===e.resizeParams.target)&&"product"!==e.resizeParams.targetType?[2]:(a=e.resizeParams,[4,t.commandManager.execute(J.b.resize,a)]);case 7:n.sent(),n.label=8;case 8:return n.trys.push([8,10,,11]),[4,t.eval("spEditor._canvasViewer._onResize()")];case 9:case 10:return n.sent(),[3,11];case 11:return[4,this.widget.ready()];case 12:return n.sent(),[2]}}))}))},t}(R),Y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,a,c,u,d,h,f,p,g,b,m,v,y,w,O,I;return Object(n.e)(this,(function(j){switch(j.label){case 0:return t=Array.isArray(e)?e:[e],[4,this.widget.getEditor()];case 1:return[4,(r=j.sent()).getProduct()];case 2:i=j.sent(),j.label=3;case 3:j.trys.push([3,14,15,16]),s=Object(n.k)(t),a=s.next(),j.label=4;case 4:return a.done?[3,13]:(c=a.value).url?[4,i.getProductModel()]:[3,12];case 5:return u=j.sent(),(null==(d=c.surfaceIndex)||d<0||d>i.surfaces.length)&&(d=1===t.length?i.currentSurfaceIndex:t.indexOf(c)),h=u.surfaces.get(d),l.a.isNullOrUndefined(h)?[3,12]:(f=h.printAreas.get(0),p=h.containers.first((function(e){return e.name===o.a.BG_CONTAINER_NAME})),g=p.items.get(0),l.a.isNullOrUndefined(g)&&((g=new window.CustomersCanvas.DesignAtoms.ObjectModel.PlaceholderItem).locked=!0,p.items.add(g)),l.a.isNullOrUndefined(g.content)&&(g.content=new window.CustomersCanvas.DesignAtoms.ObjectModel.ImageItem),b=g.content,[4,r.configuration.getImageMetadata(c.url)]);case 6:if((m=j.sent()).isVector=this._isVector(c.url),!0!==c.toTile)return[3,8];if((v=g.content||g).sourceRectangle.width=m.size.width,v.sourceRectangle.height=m.size.height,v.setData)try{v.setData(m)}catch(P){V.a.setDataToImage(m,v)}else V.a.setDataToImage(m,v);return v.source.isVector=m.isVector,p.items.setRange(this._getTiles(v,h)),[4,i.setProductModel(u)];case 7:return j.sent(),[3,10];case 8:return i.surfaces.length>d?[4,i.surfaces[d].changeBackground(m)]:[3,10];case 9:j.sent(),j.label=10;case 10:return c.url.startsWith("public:")||c.url.startsWith("user:")||!c.autoResize?[3,12]:((y=new window.CustomersCanvas.DesignAtoms.ObjectModel.ImageItem.ImageSource).url=c.url,y.isVector=this._isVector(c.url),b.source=y,h.width=b.sourceRectangle.width,h.height=b.sourceRectangle.height,f.bounds.width=h.width,f.bounds.height=h.height,[4,i.setProductModel(u)]);case 11:j.sent(),j.label=12;case 12:return a=s.next(),[3,4];case 13:return[3,16];case 14:return w=j.sent(),O={error:w},[3,16];case 15:try{a&&!a.done&&(I=s.return)&&I.call(s)}finally{if(O)throw O.error}return[7];case 16:return[4,this.widget.ready()];case 17:return j.sent(),[2]}}))}))},t.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},t.prototype._isVector=function(e){return e.endsWith(".pdf")||e.endsWith(".svg")},t}(R),q=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.widget.getProduct()];case 1:t=n.sent(),Array.isArray(e)||(e=[e]),r=0,n.label=2;case 2:return r<e.length?(i=e[r]).data?(s=t.currentSurface,"number"==typeof i.surfaceIndex&&(s=t.surfaces[i.surfaceIndex]),[4,s.setPrintAreas([i.data],i.options)]):[3,5]:[3,6];case 3:return t=n.sent(),[4,this.widget.replaceInterpolationPlaceholder()];case 4:n.sent(),n.label=5;case 5:return r++,[3,2];case 6:return[2]}}))}))},t}(R),K=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a,c,u,d,h,f,p,g,b;return Object(n.e)(this,(function(m){switch(m.label){case 0:return null==e?[2,Promise.resolve()]:[4,this.widget.getEditor()];case 1:return[4,(t=m.sent()).getProduct()];case 2:return[4,(r=m.sent()).getProductModel()];case 3:i=m.sent(),m.label=4;case 4:m.trys.push([4,9,10,11]),s=Object(n.k)(e),o=s.next(),m.label=5;case 5:return o.done?[3,8]:(a=o.value,l.a.isNullOrUndefined(a.url)||""===a.url?[3,7]:(c="number"==typeof a.surfaceIndex?i.surfaces.get(a.surfaceIndex):i.surfaces.first((function(e){return e.name===r.currentSurface.name})),(u="up"===a.mockup.toLowerCase()?c.mockup.overContainers:c.mockup.underContainers).empty?(console.warn("Cannot set mockup because MockupContainer is empty"),[3,7]):((d=u.get(0)).items.clear(),h=new window.CustomersCanvas.DesignAtoms.ObjectModel.ImageItem,[4,t.configuration.getImageMetadata(a.url)])));case 6:if((f=m.sent()).size={width:f.size.width||f.width,height:f.size.height||f.height},h.setData)try{h.setData(f)}catch(v){V.a.setDataToImage(f,h)}else V.a.setDataToImage(f,h);h.ratioWidthToHeight=d.size.width/d.size.height,h.SetWidth(d.size.width,!1),h.SetHeight(d.size.height,!1),d.items.add(h),m.label=7;case 7:return o=s.next(),[3,5];case 8:return[3,11];case 9:return p=m.sent(),g={error:p},[3,11];case 10:try{o&&!o.done&&(b=s.return)&&b.call(s)}finally{if(g)throw g.error}return[7];case 11:return[4,r.setProductModel(i)];case 12:return m.sent(),[2]}}))}))},t}(R),$=r(890),Z=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._serializer=new $.a,t}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t;return Object(n.e)(this,(function(r){switch(r.label){case 0:if(Object(c.l)(e.serializedProduct))throw"serializedProduct cannot be null or empty";return t=this._serializer.deserialize(e.serializedProduct),[4,this.widget.getProduct()];case 1:return[4,r.sent().setProductModel(t)];case 2:return r.sent(),[2]}}))}))},t}(R),Q=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){switch(t.label){case 0:return e&&e.surfaces&&0!==e.surfaces.length?e.surfaces.some((function(e){return 0===Object.keys(e).length}))?[2]:[4,this.widget.getEditor()]:[2];case 1:return[4,t.sent().getProduct()];case 2:return[4,t.sent().setSurfaces(e.surfaces)];case 3:return t.sent(),[4,this.widget.replaceInterpolationPlaceholder()];case 4:return t.sent(),[2]}}))}))},t}(R),ee=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){switch(t.label){case 0:return("string"==typeof e||void 0===e.theme)&&(e={theme:e}),[4,this.widget.getProduct()];case 1:return[4,t.sent().applyProductTheme(e.theme)];case 2:return[2,t.sent()]}}))}))},t}(R),te=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r;return Object(n.e)(this,(function(n){switch(n.label){case 0:return e?[4,this.widget.getEditor()]:[3,3];case 1:return t=n.sent(),r=Object.assign({},e),null!=e.scrollPosition&&(r.scrollingPosition={x:e.scrollPosition.X||e.scrollPosition.x,y:e.scrollPosition.Y||e.scrollPosition.y}),[4,t.setViewerSettings(r)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},t}(R),re=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a,c,u,d,h;return Object(n.e)(this,(function(f){switch(f.label){case 0:if(t=l.a.ensureArray(e).filter((function(e){return e})),0===t.length)return[2];f.label=1;case 1:f.trys.push([1,7,8,9]),r=Object(n.k)(t),i=r.next(),f.label=2;case 2:return i.done?[3,6]:(s=i.value,[4,this.widget.getProduct()]);case 3:return(o=f.sent()).swapSurfaces?(a=o.surfaces[s.lhsSurfaceIndex],c=o.surfaces[s.rhsSurfaceIndex],[4,o.swapSurfaces(a,c)]):(console.warn("Command unavailable for this version Customer's Canvas."),[2]);case 4:f.sent(),f.label=5;case 5:return i=r.next(),[3,2];case 6:return[3,9];case 7:return u=f.sent(),d={error:u},[3,9];case 8:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(d)throw d.error}return[7];case 9:return[2]}}))}))},t}(R),ne=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a,c,u,l,d;return Object(n.e)(this,(function(n){switch(n.label){case 0:return e&&e.translateParams?(t=e.translateParams,r=t.itemIds&&t.itemIds.length>0,i=e.translateParams,s=i.items&&0===i.items.length&&"string"!=typeof i.items[0],o=e.translateParams,a=o.items&&o.items.length>0&&"string"==typeof o.items[0],r||s||a?[4,this.widget.getEditor()]:[2]):[2];case 1:return c=n.sent(),a?[4,c.getProduct()]:[3,6];case 2:return[4,n.sent().getProductModel()];case 3:return[4,n.sent().getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0})];case 4:return u=n.sent(),l=u.filter((function(e){return o.items.includes(e.name)})).map((function(e){return e.id})),d={itemIds:l,translateX:o.translateX,translateY:o.translateY},[4,c.commandManager.execute(J.a.translateItems,d)];case 5:return n.sent(),[3,8];case 6:return[4,c.commandManager.execute(J.a.translateItems,e.translateParams)];case 7:n.sent(),n.label=8;case 8:return[4,this.widget.ready()];case 9:return n.sent(),[2]}}))}))},t}(R),ie=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a,c,u,l,d,h,f,p,g,b,m,v,y,w;return Object(n.e)(this,(function(O){switch(O.label){case 0:return null!=e&&e instanceof Array?[4,this.widget.getProduct()]:[2];case 1:t=O.sent(),O.label=2;case 2:O.trys.push([2,13,14,15]),r=Object(n.k)(e.entries()),i=r.next(),O.label=3;case 3:if(i.done)return[3,12];if(s=Object(n.h)(i.value,2),o=s[0],a=s[1],null==(c=t.surfaces[o]))return[3,11];O.label=4;case 4:O.trys.push([4,9,10,11]),y=void 0,u=Object(n.k)(Object.entries(a)),l=u.next(),O.label=5;case 5:return l.done?[3,8]:(d=Object(n.h)(l.value,2),h=d[0],f=d[1],null==(p=c.printAreas[0].getContainer(h))?[3,7]:[4,p.update(f)]);case 6:O.sent(),O.label=7;case 7:return l=u.next(),[3,5];case 8:return[3,11];case 9:return g=O.sent(),y={error:g},[3,11];case 10:try{l&&!l.done&&(w=u.return)&&w.call(u)}finally{if(y)throw y.error}return[7];case 11:return i=r.next(),[3,3];case 12:return[3,15];case 13:return b=O.sent(),m={error:b},[3,15];case 14:try{i&&!i.done&&(v=r.return)&&v.call(r)}finally{if(m)throw m.error}return[7];case 15:return[2]}}))}))},t}(R),se=r(25),oe=r(14),ae=function(){function e(){}return e.throw=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];throw"".concat(e,": ").concat(t.join(", "))},e.InvalidProcessorExpression="Invalid expression",e.CannotFoundType="Cannot found type",e.CannotFoundTypeConstructor="Cannot found constructor of type",e.CannotFoundStaticMethod="Cannot found static method",e.CannotFoundEnum="Cannot found enumeration",e.InvalidEnumValue="Enum does not contain value",e.DublicateTypesFound="Dublicate types have been detected",e.CommandNotFound="Command not found",e}(),ce=r(94),ue=r(425),le=r(444),de=function(){function e(){this._types=new Map;for(var e=[le,U,y],t=0;t<e.length;t++)this._loadModuleTypes(e[t]);this._loadModuleTypes({Collection:ue.a})}return e.prototype.fromConstructor=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];Object(c.l)(e)&&ae.throw("Invalid argument",e);var i=this._findFunction(e);this._isConstructor(i)||ae.throw(ae.CannotFoundTypeConstructor,e);var s=i;try{return new(s.bind.apply(s,Object(n.j)([void 0],Object(n.h)(t),!1)))}catch(o){throw console.error(o),o}},e.prototype._findFunction=function(e){var t=e.split(".");this._types.has(t[0])||ae.throw(ae.CannotFoundType,e);for(var r=this._types.get(t[0]),n=1;n<t.length;n++)null==r[t[n]]&&ae.throw(ae.CannotFoundTypeConstructor,e),r=r[t[n]];return r},e.prototype._isConstructor=function(e){return e instanceof Function&&null!=e.prototype.constructor},e.prototype.fromStaticMethod=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var i=this._findFunction(e);null!=i&&i instanceof Function||ae.throw(ae.CannotFoundStaticMethod,e);try{return i.apply(void 0,Object(n.j)([],Object(n.h)(t),!1))}catch(s){throw console.error(s),s}},e.prototype.fromProperties=function(e,t){var r=this.fromConstructor(e);return Object(c.e)(r,[t],{deep:!1,ignoreNull:!1})},e.prototype.fromEnum=function(e,t){this._types.has(e)||ae.throw(ae.CannotFoundEnum,e);var r=this._types.get(e);return r instanceof Object||ae.throw(ae.CannotFoundEnum,e),null==r[t]&&ae.throw(ae.InvalidEnumValue,{type:e,value:t}),r[t]},e.prototype._loadModuleTypes=function(e){var t,r;if(void 0!==e)try{for(var i=Object(n.k)(Object.entries(e)),s=i.next();!s.done;s=i.next()){var o=Object(n.h)(s.value,2),a=o[0],c=o[1];(c instanceof Function||c instanceof Object)&&(this._types.has(a)&&ae.throw(ae.DublicateTypesFound,a),this._types.set(a,c))}}catch(u){t={error:u}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},e}(),he=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.subProcessorAllocatorFactory=function(){var e=new ce.a;return e.register(new fe(this,new de)),e},t}(oe.a),fe=function(e){function t(t,r){var n=e.call(this,t)||this;return n._builder=r,n}return Object(n.d)(t,e),t.prototype.apply=function(e,t,r){var i,s;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 o={};try{for(var a=Object(n.k)(Object.entries(e)),c=a.next();!c.done;c=a.next()){var u=Object(n.h)(c.value,2),l=u[0],d=u[1];if(this._isNewExpression(l)||this._isCallExpression(l))return this._buildObjectModel(l,d,r);o[l]=this._buildModelProperty(d,r)}}catch(h){i={error:h}}finally{try{c&&!c.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}return o;case this._isEnumExpression(e):return this._parseEnum(e);default:return e}},t.prototype._buildModelProperty=function(e,t){switch(!0){case this.isObject(e):return t(e);case this._isEnumExpression(e):return this._parseEnum(e);default:return e}},t.prototype._parseArguments=function(e,t){var r=this;switch(!0){case Array.isArray(e):return e.map((function(e){return r._parseArguments(e,t)}));case this.isObject(e)&&this.canApply(e):return t(e);case this._isEnumExpression(e):return this._parseEnum(e);default:return e}},t.prototype._parseEnum=function(e){var t=this.splitOperandAndCondition(e);1===t.length&&null!=t[0].body||ae.throw(ae.InvalidProcessorExpression,e);var r=t[0].body.split(".");return 2==r.length?this._builder.fromEnum(r[0],r[1]):null},t.prototype._buildObjectModel=function(e,t,r){var n=this.splitOperandAndCondition(e);1==n.length&&null!=n[0].body||ae.throw(ae.InvalidProcessorExpression,e);var i=n[0].body;return this._isCallExpression(e)?this._buildObjectByFactory(i,t,r):this._createObjectModel(i,t,r)},t.prototype._buildObjectByFactory=function(e,t,r){var n=this,i=t;return Array.isArray(t)?i=t.map((function(e){return n._parseArguments(e,r)})):this.isObject(t)&&(i=r(t)),this._builder.fromStaticMethod(e,i)},t.prototype._createObjectModel=function(e,t,r){var i,s=this;switch(!0){case this.isObject(t):return this._builder.fromProperties(e,r(t));case Array.isArray(t):var o=t.map((function(e){return s._parseArguments(e,r)}));return(i=this._builder).fromConstructor.apply(i,Object(n.j)([e],Object(n.h)(o),!1));default:return this._builder.fromConstructor(e,t)}},t.prototype.canApply=function(e){var t=this;return this.isObject(e)&&void 0!==Object.entries(e).find((function(e){var r=Object(n.h)(e,2),i=r[0],s=r[1];return t._isNewExpression(i)||t._isCallExpression(i)||t._isEnumExpression(s)}))},t.prototype._isNewExpression=function(e){return/{{.*(#new).*/gi.test(e)},t.prototype._isCallExpression=function(e){return/{{.*(#call).*/gi.test(e)},t.prototype._isEnumExpression=function(e){return this.isString(e)&&/{{.*(#enum).*/gi.test(e)},t}(se.a),pe=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._configProcessor=new he,t}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a,u,d,h,f;return Object(n.e)(this,(function(p){switch(p.label){case 0:return t=this._configProcessor.process(e,{}),[4,this.widget.getProduct()];case 1:return[4,(r=p.sent()).getProductModel()];case 2:return[4,(i=p.sent()).getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0})];case 3:s=p.sent();try{for(o=Object(n.k)(s),a=o.next();!a.done;a=o.next())u=a.value,d=t.items[u.name],l.a.isNullOrUndefined(d)||Object(c.f)(u,d)}catch(g){h={error:g}}finally{try{a&&!a.done&&(f=o.return)&&f.call(o)}finally{if(h)throw h.error}}return[4,r.setProductModel(i)];case 4:return p.sent(),[2]}}))}))},t}(R),ge=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t.prototype.execute=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,a,c,u;return Object(n.e)(this,(function(l){switch(l.label){case 0:if(0===(t=(Array.isArray(e)?e:[e]).filter((function(e){return e}))).length)return[2];l.label=1;case 1:l.trys.push([1,9,10,11]),r=Object(n.k)(t),i=r.next(),l.label=2;case 2:return i.done?[3,8]:(s=i.value,[4,this.widget.getProduct()]);case 3:return(o=l.sent()).updateSurfaces?1!==o.updateSurfaces.length?[3,5]:[4,o.updateSurfaces(s)]:(console.warn("Command unavailable for this version Customer's Canvas. Please, use version 6.2.0 or above."),[2]);case 4:return l.sent(),[3,7];case 5:return[4,o.updateSurfaces(s.productDefinition||s.definition,s.options,s.sourceSurfaceIndexes,s.targetSurfaceIndexes)];case 6:l.sent(),l.label=7;case 7:return i=r.next(),[3,2];case 8:return[3,11];case 9:return a=l.sent(),c={error:a},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(c)throw c.error}return[7];case 11:return[2]}}))}))},t}(R),be=r(865),me=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._isRestoring=!1,t.isRestored=!1,t.modifiedItem=null,t._currentSurfaceName="",t._currentSurfaceIndex=0,t._surfaceCount=0,t.overallBounds={},t.itemsOnSurfacesCount=[],t._hiResUrls=[],t._proofImageUrls=[[]],t._proofPdfUrls=[],t._stateId="",t._userId="",t._privateDesignId="",t._userChanges={},t._variableData=[],t._allItems=[],t._depositPhotos=[],t._artLinkItems=[],t._tags={},t._identifyingString="",t._lastParams={},t._currentParams={},t._violationData=[],t.actionsFinished=!1,t.actionsFinishedPromise=new v,t.commands={initial:new W(t),changeMockup:new z(t),setPrintArea:new q(t),setTheme:new ee(t),setBackground:new Y(t),updateContainerSettings:new ie(t),setRemoteMockup:new K(t),modifyItems:new H(t),setViewerSettings:new te(t),updateItems:new pe(t),setSerializedProduct:new Z(t),setSurfaces:new Q(t),swapSurfaces:new re(t),resize:new X(t),translate:new ne(t),updateSurfaces:new ge(t),createImageItem:new F(t),loadUserInfo:new G(t),changeDesignVariant:new T(t),duplicateSurfaces:new N(t)},t.itemsData={},t._token="",t}return Object(n.d)(t,e),Object.defineProperty(t.prototype,"violationWarningData",{get:function(){return this._violationWarningData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"violationData",{get:function(){return this._violationData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"boundsData",{get:function(){return this._boundsData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentSurfaceName",{get:function(){return this._currentSurfaceName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentSurfaceIndex",{get:function(){return this._currentSurfaceIndex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"surfaceCount",{get:function(){return this._surfaceCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"proofImageUrls",{get:function(){return this._proofImageUrls},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"proofPdfUrls",{get:function(){return this._proofPdfUrls},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hiResUrls",{get:function(){return this._hiResUrls},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stateId",{get:function(){return this._stateId},set:function(e){this._stateId=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userChanges",{get:function(){return this._userChanges},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userId",{get:function(){return this._userId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"allItems",{get:function(){return this._allItems},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"variableData",{get:function(){return this._variableData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depositPhotos",{get:function(){return this._depositPhotos},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"artLinkItems",{get:function(){return this._artLinkItems},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourcedItems",{get:function(){return this._sourcedItems},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tags",{get:function(){return this._tags},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"identifyingString",{get:function(){return this._identifyingString},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"finishProductDesignResult",{get:function(){return this._finishProductDesignResult},enumerable:!1,configurable:!0}),t.prototype.calculateIdentifyingString=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,o,a;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.getProduct()];case 1:return[4,n.sent().getProductModel()];case 2:return[4,n.sent().getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0})];case 3:return t=n.sent(),r=new s.a({titleTemplate:e}),i=function(e){var t,r,n="";switch(!0){case e instanceof CustomersCanvas.DesignAtoms.ObjectModel.BaseTextItem:n=Object(c.k)(e.text);break;case e instanceof CustomersCanvas.DesignAtoms.ObjectModel.BarcodeItem:n=e.barcodeContent;break;case e instanceof CustomersCanvas.DesignAtoms.ObjectModel.ImageItem:n=null!==(t=e.displayName)&&void 0!==t?t:e.name;break;case e instanceof CustomersCanvas.DesignAtoms.ObjectModel.PlaceholderItem:e.imageContent&&(n=null!==(r=e.imageContent.displayName)&&void 0!==r?r:e.imageContent.name)}return{name:e.name,value:n}},o=t.reduce((function(e,t){var r=i(t);return e[r.name]=r.value,e}),{}),a=r.buildTitle(o),this._identifyingString=a,this.emitChange(),[2,a]}}))}))},t.prototype.isInstanceOf=function(e,t){var r,n=function(e){var t=[];return e.__proto__&&(t=t.concat(n(e.__proto__))),t.push(function(e){return e.constructor.type}(e)),t.filter((function(e){return e}))};return r=t,-1!==n(e).indexOf(r.type)},t.prototype.updateParams=function(e){if(void 0!==e.initial&&(e.initial.editorConfig||(e.initial.editorConfig={}),e.initial.editorConfig.defaultLanguage=this.driver.config.language||"en",this.driver)){this._initialOrder=this._initialOrder||Object(d.a)(this.driver.orders[0]);var t=this.driver.user.id;t&&(e.initial.editorConfig.userId=t);var r=this.driver.user.tokenId;r&&(e.initial.editorConfig.tokenId=r);var n=this.auWizard.scopeInternal.widgetsData,i=n&&n[this.name]?n[this.name].stateId:this._initialOrder.data.stateId;i&&""!==i&&!0!==this.auWizard.clearState&&(e.initial.productDefinition=i),e.initial.editorConfig.preloader={enabled:!1}}},t.prototype.exportWidgetData=function(e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){switch(t.label){case 0:return!0!==e?[3,2]:[4,this.finishProductDesign()];case 1:t.sent(),t.label=2;case 2:return[2,{stateId:this._stateId}]}}))}))},t.prototype.restoreWidgetFromData=function(e,t){var r,i,s,o;return void 0===t&&(t=!1),Object(n.b)(this,void 0,void 0,(function(){var a,c,u;return Object(n.e)(this,(function(n){switch(n.label){case 0:return!0!==t?[3,3]:((a=Object.assign({},(this.params||{}).initial||{})).productDefinition=e.stateId,c=null===(i=null===(r=this.driver)||void 0===r?void 0:r.user)||void 0===i?void 0:i.id,u=null===(o=null===(s=this.driver)||void 0===s?void 0:s.user)||void 0===o?void 0:o.tokenId,c&&u&&((null==a?void 0:a.initial)?(a.editorConfig.userId=c,a.editorConfig.tokenId=u):a.editorConfig={userId:c,tokenId:u}),"firefox"!==l.a.getBrowser()?[3,1]:(this.commands.initial.execute(a),[3,3]));case 1:return[4,this.commands.initial.execute(a)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},t.prototype.updateParamsAsync=function(t){return Object(n.b)(this,void 0,void 0,(function(){var r,i,s,o,a,c,u,h,f,p;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,e.prototype.updateParamsAsync.call(this,t)];case 1:if(n.sent(),0===(r=this._commandExecuter.getChangedActions(t,this._currentParams)).length)return[2,!1];-1!==r.indexOf("initial")&&(i=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,s=l.a.isNotNullOrUndefined(this._stateId)&&""!==this._stateId,(o=l.a.isNotNullOrUndefined(t.initial.productDefinition)&&t.initial.productDefinition.toString().match(i))&&(this._isRestoring=!0),a=!0===t.initial.executeOnce,!s&&!o||a||(r=["initial"])),this.actionsFinishedPromise=new v,this.actionsFinished=!1,this._isRestoring||this.emitChange(),c=r.every((function(e){var r=t[e];return Array.isArray(t[e])&&(r=t[e][0]),!1===r.showPreloader})),u=1===r.length&&-1!==r.indexOf("initial"),c||this.showPreloader(!0,this.getPreloaderMessage(t,u)),this._currentParams=Object(d.a)(t),n.label=2;case 2:return n.trys.push([2,5,6,7]),this._isRestoring&&!u?[3,4]:[4,this._commandExecuter.executeActions(t,r,this._lastParams)];case 3:n.sent(),n.label=4;case 4:return[3,7];case 5:return h=n.sent(),this.params.actionsErrorToast&&!0===this.params.actionsErrorToast.show&&(f="widgets.canvas.actions.error",(p=this.localize(f))===f&&(p="Something went wrong. Send the website support team information about your browser and steps to reproduce the problem."),this.showToast(p,this.params.actionsErrorToast.duration)),this.logger.error((function(){return"Failed to perform an action on Design Editor. "}),h),[3,7];case 6:return this.resetPreloaderState(),this._lastParams=t,this.actionsFinishedPromise.resolve(),this.actionsFinished=!0,this._isRestoring&&(this.getInitialParamsResolved(),this._isRestoring=!1,this.isRestored=!0),this.getSurfaceCount(),[7];case 7:return[2]}}))}))},t.prototype.connectedCallback=function(){var t=this;e.prototype.connectedCallback.call(this),this._commandExecuter=new u.a(this.commands,this.uniqWidgetName,(function(){return Promise.resolve()}),this),this.baseUrl=l.a.ensureEndsWith(this.driver.settings.customersCanvasBaseUrl,"/"),this.showPreloader(!0),this.iframeApiPromise=m.a.loadCCScript(this.baseUrl,l.a.CC_SCRIPT_RELATIVE_PATH),this.iframeApiPromise.then((function(){t.showPreloader(!1),CustomersCanvas.IframeApi.editorUrl=t.baseUrl}))},t.prototype.switchSurfaceTo=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t;return Object(n.e)(this,(function(r){switch(r.label){case 0:return[4,this.getProduct()];case 1:return t=r.sent(),e<0||e>t.surfaces.length-1?(console.error("Invalid surface index: ".concat(e)),[2,t]):[4,t.switchTo(t.surfaces[e])];case 2:return[2,r.sent()]}}))}))},t.prototype.removeSurface=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.getProduct()];case 1:return t=n.sent(),e<0||e>t.surfaces.length-1?(console.error("Invalid surface index: ".concat(e)),[2]):(r=t.surfaces[e],[4,t.removeSurface(r)]);case 2:return[2,n.sent()]}}))}))},t.prototype.addSurface=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(r){switch(r.label){case 0:return[4,this.getProduct()];case 1:return[4,r.sent().addSurface(e,t)];case 2:return[2,r.sent()]}}))}))},t.prototype.addSurfaces=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(r){switch(r.label){case 0:return[4,this.getProduct()];case 1:return[4,r.sent().addSurfaces(e,t)];case 2:return[2,r.sent()]}}))}))},t.prototype.updateSurfaces=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var r;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.getProduct()];case 1:switch(r=n.sent(),e.toLowerCase()){case"remove":return[3,2];case"add":return[3,4]}return[3,6];case 2:return[4,this.removeSurface(t)];case 3:case 5:return r=n.sent(),[3,6];case 4:return[4,this.addSurface(t)];case 6:return[2,r]}}))}))},t.prototype.swapSurfaces=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var r,i,s;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.getProduct()];case 1:return(r=n.sent()).swapSurfaces?(i=r.surfaces[e],s=r.surfaces[t],[2,r.swapSurfaces(i,s)]):(console.warn("Command unavailable for this version Customer's Canvas."),[2])}}))}))},t.prototype.updateModifiedItem=function(e){Object(h.a)(this.modifiedItem,e)||(this.modifiedItem=e,this.emitChange({modifiedItem:this.modifiedItem},!1))},t.prototype.updateOverallBounds=function(e){Object(h.a)(this.overallBounds,e)||(this.overallBounds=e,this.emitChange({overallBounds:this.overallBounds},!1))},t.prototype.updateCurrentSurfaceData=function(){return Object(n.b)(this,void 0,void 0,(function(){var e;return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,this.getProduct()];case 1:return e=t.sent(),this._currentSurfaceName=e.currentSurface.name,this._currentSurfaceIndex=e.surfaces.indexOf(e.currentSurface),this.emitChange(),[2]}}))}))},t.prototype.updateCurrentSurfaceName=function(){return Object(n.b)(this,void 0,void 0,(function(){var e;return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,this.getProduct()];case 1:return e=t.sent(),this._currentSurfaceName=e.currentSurface.name,this.emitChange(),[2]}}))}))},t.prototype.updateCurrentSurfaceIndex=function(){return Object(n.b)(this,void 0,void 0,(function(){var e;return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,this.getProduct()];case 1:return e=t.sent(),this._currentSurfaceIndex=e.surfaces.indexOf(e.currentSurface),this.emitChange(),[2]}}))}))},t.prototype.applyViewerSettings=function(e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){return[2,this.commands.setViewerSettings.execute(e)]}))}))},t.prototype.getProofImages=function(e,t,r,i,s,o,a,c,u){return void 0===e&&(e=800),void 0===t&&(t=800),void 0===r&&(r=!0),void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===o&&(o=1e3),void 0===a&&(a=1e3),Object(n.b)(this,void 0,void 0,(function(){var l,d,h,f,p;return Object(n.e)(this,(function(g){switch(g.label){case 0:return[4,this.getEditor()];case 1:return l=g.sent(),{},"object"==typeof r&&(c=r,r=!0),h=null!=u?u:{},d="object"==typeof e?e:Object(n.a)({maxWidth:e,maxHeight:t,pregeneratePreviewImages:r,generateProductProof:i,generateLargePreviews:s,largePreviewMaxWidth:o,largePreviewMaxHeight:a},h),[4,l.getProofImages(d,c)];case 2:return f=g.sent(),this._proofImageUrls=f.proofImageUrls,[4,l.getProduct()];case 3:return p=g.sent(),this._surfaceCount=p.surfaces.length,this.emitChange({urls:this.proofImageUrls},!1),[2,f.proofImageUrls.map((function(e){return e[0]}))]}}))}))},t.prototype.getProofPdf=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r=!1),Object(n.b)(this,void 0,void 0,(function(){var i,s,o,a,c;return Object(n.e)(this,(function(n){switch(n.label){case 0:return i=Object.assign({},t,{generateProductProof:!0}),[4,this.getEditor()];case 1:return[4,(s=n.sent()).getProofImages(i,e)];case 2:return o=n.sent(),a=o.proofImageUrls.map((function(e){return e[0]})),this._proofPdfUrls=a.filter((function(e){return e.endsWith(".pdf")})),[4,s.getProduct()];case 3:return c=n.sent(),this._surfaceCount=c.surfaces.length,this.emitChange({proofPdfUrls:this.proofPdfUrls},r),[2,this._proofPdfUrls]}}))}))},t.prototype.getHiResImages=function(e,t,r,i,s,o,a){return void 0===e&&(e=800),void 0===t&&(t=800),void 0===i&&(i=!1),Object(n.b)(this,void 0,void 0,(function(){var c,u,l,d;return Object(n.e)(this,(function(h){switch(h.label){case 0:return[4,this.getEditor()];case 1:return c=h.sent(),null!==r&&""!==r||(r=void 0),null!==s&&""!==s||(s=void 0),"object"==typeof r&&(o=r,r=void 0),u=null!=a?a:{},[4,c.finishProductDesign(Object(n.a)({stateId:r,proofMaxWidth:e,proofMaxHeight:t,pregeneratePreviewImages:i,fileName:s},u),o)];case 2:return l=h.sent(),this._stateId=l.stateId,this._userId=l.userId,this._hiResUrls=l.hiResOutputUrls,this._proofImageUrls=l.proofImageUrls,this._userChanges=l.userChanges,this._violationWarningData=l.violationWarningData,this._boundsData=l.boundsData,[4,c.getProduct()];case 3:return d=h.sent(),this._surfaceCount=d.surfaces.length,this.emitChange({urls:this.hiResUrls,proofs:this.proofImageUrls,stateId:this.stateId,userId:this.userId,userChanges:this.userChanges,violationWarningData:this.violationWarningData,boundsData:this.boundsData},!0),[2,l.hiResOutputUrls]}}))}))},t.prototype.finishProductDesign=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var r,i,s;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.getEditor()];case 1:return[4,(r=n.sent()).finishProductDesign(e,t)];case 2:return i=n.sent(),this._finishProductDesignResult=i,this._stateId=i.stateId,this._userId=i.userId,this._hiResUrls=i.hiResOutputUrls,this._proofImageUrls=i.proofImageUrls,this._userChanges=i.userChanges,this._violationWarningData=i.violationWarningData,this._boundsData=i.boundsData,[4,r.getProduct()];case 3:return s=n.sent(),this._surfaceCount=s.surfaces.length,this.emitChange(),[2,i]}}))}))},t.prototype.getVariableData=function(){return Object(n.b)(this,void 0,void 0,(function(){var e,t;return Object(n.e)(this,(function(r){switch(r.label){case 0:return[4,this.getProduct()];case 1:return e=r.sent(),t=this,[4,e.getVariableItems()];case 2:return t._variableData=r.sent().reverse(),this.emitChange({data:this.variableData}),[2,this.variableData]}}))}))},t.prototype.getAllItems=function(){return Object(n.b)(this,void 0,void 0,(function(){var e;return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,this.getProduct()];case 1:return[4,t.sent().getProductModel()];case 2:return e=t.sent(),this._allItems=e.getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0}).reverse(),this.emitChange(),[2,this.allItems]}}))}))},t.prototype.getDepositPhotos=function(){return Object(n.b)(this,void 0,void 0,(function(){var e;return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,this.getProduct()];case 1:return[4,t.sent().getProductModel()];case 2:return[4,t.sent().getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0})];case 3:return e=t.sent(),this.getDPItems(e),[2,this._depositPhotos]}}))}))},t.prototype.getDPItems=function(e){var t=[];return e.forEach((function(e){var r=e.tags.dp_data;if(Object(f.a)(r)){var n=function(e){return e&&e.tags&&null!==e.tags.sourceData&&"DepositPhotosSource"===e.tags.sourceType},i=function(e){return e.tags.sourceData};if(n(e)){var s=i(e);t.push({imageId:e.id,depositPhotosId:s.id})}else if(e.content&&n(e.content)){var o=i(e.content);t.push({imageId:e.id,depositPhotosId:o.id,data:o})}}else t.push({imageId:e.id,depositPhotosId:JSON.parse(r).id})})),this._depositPhotos=t.map((function(e){return{imageId:e.imageId,depositPhotosId:e.depositPhotosId}})),this.emitChange({data:this.depositPhotos}),t},t.prototype.getArtLinkImages=function(e){var t=[];return e.forEach((function(e){var r=null!=e.content?e.content:e;if(null!=r.source&&null!=r.source.origin&&"ArtLinkSource"===r.source.origin.type){var n=r.source.origin.data;t.push({imageId:e.id,artLinkId:n.id,data:n})}})),this._artLinkItems=t.map((function(e){return{imageId:e.imageId,artLinkId:e.artLinkId}})),this.emitChange({data:this.artLinkItems}),t},t.prototype.getArtLinkItems=function(){return Object(n.b)(this,void 0,void 0,(function(){var e;return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,this.getProduct()];case 1:return[4,t.sent().getProductModel()];case 2:return[4,t.sent().getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0})];case 3:return e=t.sent(),this.getArtLinkImages(e),[2,this._artLinkItems]}}))}))},t.prototype.getItemsBySource=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r;return Object(n.e)(this,(function(n){switch(n.label){case 0:return t=[],e?[4,this.getProduct()]:[2,{source:"unknown",items:t}];case 1:return[4,n.sent().getProductModel()];case 2:return[4,n.sent().getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0})];case 3:return r=n.sent(),"dp"==e.toLowerCase()||"depositphotos"==e.toLowerCase()?(this.getDPItems(r).forEach((function(e){t.push({imageId:e.imageId,sourceId:e.depositPhotosId,data:e.data})})),this._sourcedItems={source:e.toLowerCase(),items:t},this.emitChange({data:this.sourcedItems}),[2,this.sourcedItems]):"artlink"==e.toLowerCase()?(this.getArtLinkImages(r).forEach((function(e){t.push({imageId:e.imageId,sourceId:e.artLinkId,data:e.data})})),this._sourcedItems={source:e.toLowerCase(),items:t},this.emitChange({data:this.sourcedItems}),[2,this.sourcedItems]):[2,{source:"unknown",items:t}]}}))}))},t.prototype.getTags=function(){return Object(n.b)(this,void 0,void 0,(function(){var e,t;return Object(n.e)(this,(function(r){switch(r.label){case 0:return[4,this.getProduct()];case 1:return e=r.sent(),t=this,[4,e.getTags()];case 2:return t._tags=r.sent(),void 0===this._tags&&(this._tags={}),this.emitChange({tags:this.tags}),[2,this.tags]}}))}))},t.prototype.setTags=function(e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,this.getProduct()];case 1:return[4,t.sent().setTags(e)];case 2:return t.sent(),this._tags=e,this.emitChange({tags:this.tags}),[2]}}))}))},t.prototype.saveProduct=function(e,t){return Object(n.b)(this,void 0,void 0,(function(){var r,i,s;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.getEditor()];case 1:return[4,(r=n.sent()).saveProduct(e,t)];case 2:return i=n.sent(),this._stateId=i.stateId,this._userId=i.userId,[4,r.getProduct()];case 3:return s=n.sent(),this._surfaceCount=s.surfaces.length,[4,this.emitChange({stateId:this.stateId,userId:this.userId},!1)];case 4:return n.sent(),[2,i]}}))}))},t.prototype.replaceInterpolationPlaceholder=function(){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(e){switch(e.label){case 0:return this._currentParams.replaceInterpolationPlaceholders?[4,this.getEditor()]:[2,Promise.resolve()];case 1:return e.sent().replaceInterpolationPlaceholders(),[2]}}))}))},t.prototype.toggleMaximizeMainPanel=function(e){this.publishData({main:e},b.a.TOGGLE_SIZE_MAIN)},t.prototype.openAssetManagerFor=function(e){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,this.getEditor()];case 1:return[4,t.sent().openGalleryForItem(e)];case 2:return t.sent(),[2]}}))}))},t.prototype.openGalleryForBackground=function(){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(e){switch(e.label){case 0:return[4,this.getEditor()];case 1:return[4,e.sent().openGalleryForBackground()];case 2:return e.sent(),[2]}}))}))},t.prototype.getItemText=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.getEditor()];case 1:return[4,n.sent().getProduct()];case 2:return[4,n.sent().getProductModel()];case 3:return t=n.sent(),r=t.getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0}),i=r.find((function(t){return t.name===e})),s=Object(c.k)(i&&i instanceof CustomersCanvas.DesignAtoms.ObjectModel.BaseTextItem?i.text:""),this.itemsData[e]=this.itemsData[e]||{},this.itemsData[e].text=s,this.emitChange(),[2,s]}}))}))},Object.defineProperty(t.prototype,"token",{get:function(){return this._token},enumerable:!1,configurable:!0}),t.prototype.getToken=function(){return Object(n.b)(this,void 0,void 0,(function(){var e,t;return Object(n.e)(this,(function(r){switch(r.label){case 0:return[4,this.getEditor()];case 1:e=r.sent(),t="",r.label=2;case 2:return r.trys.push([2,4,,5]),[4,e.eval("spEditor.configuration.tokenId;")];case 3:return t=r.sent(),[3,5];case 4:return r.sent(),console.error("Failed to get user token"),[3,5];case 5:return this._token=t,this.emitChange(),[2,t]}}))}))},t.prototype.getSurfaceCount=function(){return Object(n.b)(this,void 0,void 0,(function(){var e,t;return Object(n.e)(this,(function(r){switch(r.label){case 0:return[4,this.getProduct()];case 1:return e=r.sent(),t=e.surfaces.length,this._surfaceCount=t,this.emitChange(),[2,t]}}))}))},t.prototype.getPreloaderMessage=function(e,t){var r,n,i,s;return t?null!==(n=null===(r=null==e?void 0:e.preloader)||void 0===r?void 0:r.initialMessage)&&void 0!==n?n:this.localize("common.loading.preload"):null!==(s=null===(i=null==e?void 0:e.preloader)||void 0===i?void 0:i.actionsMessage)&&void 0!==s?s:this.localize("common.loading.preload")},t.prototype.switchItemContent=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,a,c,u,d,h,f,p,g,b,m,v,y,w,O;return Object(n.e)(this,(function(n){switch(n.label){case 0:return l.a.isNullOrUndefined(e.to)||l.a.isNullOrUndefined(e.from)?[2]:[4,this.getProduct()];case 1:return[4,(t=n.sent()).getProductModel()];case 2:if(r=n.sent(),i=function(e){var t=r.surfaces.elementAt(e.surfaceIndex);return t?t.getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!0}).firstOrDefault((function(t){return t.name===e.name})):null},s=i(e.from),a=i(e.to),l.a.isNullOrUndefined(a)&&l.a.isNotNullOrUndefined(s)&&!0===e.to.force&&(a=s.clone(!0),(c=r.surfaces.elementAt(e.to.surfaceIndex))&&c.containers[o.a.MAIN_CONTAINER_NAME].items.add(a)),l.a.isNullOrUndefined(s)||l.a.isNullOrUndefined(a))return[2];if(s.type!==a.type)return console.warn("Items have not matching types"),[2];switch(!0){case s instanceof window.CustomersCanvas.DesignAtoms.ObjectModel.BaseTextItem:d=a,h=(u=s).text,f=d.text,u.text=f,d.text=h;break;case s instanceof window.CustomersCanvas.DesignAtoms.ObjectModel.PlaceholderItem:g=a,b=(p=s).content.source,m=g.content.source,p.content.source=m,g.content.source=b;break;case s instanceof window.CustomersCanvas.DesignAtoms.ObjectModel.ImageItem:y=a,w=(v=s).source,O=y.source,v.source=O,y.source=w}return[4,t.setProductModel(r)];case 3:return n.sent(),[2]}}))}))},t.prototype.countItemsOnSurfaces=function(e){return void 0===e&&(e=!1),Object(n.b)(this,void 0,void 0,(function(){var t,r,i,s,o,c,u,l,d,h;return Object(n.e)(this,(function(f){switch(f.label){case 0:return t=[],[4,this.getProduct()];case 1:return[4,(r=f.sent()).getProductModel()];case 2:i=f.sent(),s=function(i){var s,o,c,u;return Object(n.e)(this,(function(n){switch(n.label){case 0:return s=i.getAllItems({ignoreMockups:!0,flatGroupItems:!0,excludeGroupItems:!1,containerFilterFunc:function(e){return"Main"===e.name}}).select((function(e){return e.id})),e?[3,1]:(t.push(s.count()),[3,4]);case 1:return r.getItemRectangles?(o=i.printAreas.select((function(e){return e.getBounds(a.a.Total)})),[4,r.getItemRectangles(s.toArray())]):[3,3];case 2:return c=n.sent(),u=c.map((function(e){return e.bounds})).filter((function(e){return o.any((function(t){return t.intersectsWith(e)}))})),t.push(u.length),[3,4];case 3:t.push(s.count()),n.label=4;case 4:return[2]}}))},f.label=3;case 3:f.trys.push([3,8,9,10]),o=Object(n.k)(i.surfaces),c=o.next(),f.label=4;case 4:return c.done?[3,7]:(u=c.value,[5,s(u)]);case 5:f.sent(),f.label=6;case 6:return c=o.next(),[3,4];case 7:return[3,10];case 8:return l=f.sent(),d={error:l},[3,10];case 9:try{c&&!c.done&&(h=o.return)&&h.call(o)}finally{if(d)throw d.error}return[7];case 10:return this.itemsOnSurfacesCount=t,this.emitChange({itemsOnSurfacesCount:this.itemsOnSurfacesCount}),[2]}}))}))},t.prototype.getViolationData=function(){return Object(n.b)(this,void 0,void 0,(function(){var e,t,r;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,this.getEditor()];case 1:return[4,n.sent().getProduct()];case 2:return e=n.sent(),t=this,e.getViolationData?[4,e.getViolationData()]:[3,4];case 3:return r=n.sent(),[3,5];case 4:r=[],n.label=5;case 5:return t._violationData=r,this.emitChange(),[2,this._violationData]}}))}))},t.prototype._createDAApiClientConfig=function(){var e=new i.a;return e.apiUrl=l.a.removeTrailingSlash(this.driver.backOffice.backOfficeUrl),e.setAuthorizationToken(this.driver.backOffice.token),e},t.prototype.initDpApi=function(){this._dpApiClientConfig=this._createDAApiClientConfig(),this.dpApi=new i.b(this._dpApiClientConfig,l.a.removeTrailingSlash(this.driver.backOffice.assetProcessorUrl))},t.prototype._createDesignId=function(){return Object(p.a)()},t.prototype.createPrivateDesignFromResources=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t;return Object(n.e)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,5,,6]),l.a.isNullOrEmptyString(this._privateDesignId)?[4,this.dpApi.copyDesignFromPublicResource(this.driver.backOffice.tenantId,this.driver.user.id,{publicResourceId:e,resultDesignId:this._createDesignId()}).then((function(e){return e.id}))]:[3,2];case 1:return t=r.sent(),this._privateDesignId=t,this.stateId=t,[2,this._privateDesignId];case 2:return[4,this.dpApi.copyDesignFromPublicResource(this.driver.backOffice.tenantId,this.driver.user.id,{publicResourceId:e,resultDesignId:this._privateDesignId})];case 3:return r.sent(),[2,this._privateDesignId];case 4:return[3,6];case 5:return r.sent(),console.warn("Can not create design from resource! Resource id - ".concat(e,".")),[3,6];case 6:return[2]}}))}))},t.prototype.createPrivateDesignFromPublicDesign=function(e){return Object(n.b)(this,void 0,void 0,(function(){var t;return Object(n.e)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,5,,6]),l.a.isNullOrEmptyString(this._privateDesignId)?[4,this.dpApi.copyDesignFromPublicDesign(this.driver.backOffice.tenantId,this.driver.user.id,{publicDesignId:e,resultDesignId:this._createDesignId()}).then((function(e){return e.id}))]:[3,2];case 1:return t=r.sent(),this._privateDesignId=t,this.stateId=t,[2,this._privateDesignId];case 2:return[4,this.dpApi.copyDesignFromPublicDesign(this.driver.backOffice.tenantId,this.driver.user.id,{publicDesignId:e,resultDesignId:this._privateDesignId})];case 3:return r.sent(),[2,this._privateDesignId];case 4:return[3,6];case 5:return r.sent(),console.warn("Can not create private design from public design! State id - ".concat(e,".")),[3,6];case 6:return[2]}}))}))},Object(n.c)([Object(g.a)("au-widget-design-editor",be)],t)}(E)}}]);