UNPKG

@aurigma/ui-framework

Version:

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

1 lines 24.9 kB
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[40],{488:function(t,e,n){n.d(e,"a",function(){return i}),n.d(e,"b",function(){return r});var i=function(t){t&&(this.id=t.id,this.productVersionId=t.productVersionId,this.productId=t.productId,this.tenantId=t.tenantId,this.storefrontProductVariantId=t.storefrontProductVariantId,this.options=t.productVariantOptions.map(function(t){return new r(t)}),this.price=t.price)},r=function(t){t&&(this.productOptionId=t.productOptionId,this.productOptionValueId=t.productOptionValueId,this.productOptionType=t.productOptionType,this.productOptionTraits=t.productOptionTraits,this.productOptionTitle=t.productOptionTitle,this.productOptionValueTitle=t.productOptionValueTitle)}},541:function(t,e,n){n.d(e,"a",function(){return r});var i,e=n(26),n=n(127),r=(i=n.a,Object(e.a)(o,i),Object.defineProperty(o.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),o.prototype._subscribe=function(t){var e=i.prototype._subscribe.call(this,t);return e.closed||t.next(this._value),e},o.prototype.getValue=function(){var t=this,e=t.hasError,n=t._value;if(e)throw t.thrownError;return this._throwIfClosed(),n},o.prototype.next=function(t){i.prototype.next.call(this,this._value=t)},o);function o(t){var e=i.call(this)||this;return e._value=t,e}},595:function(t,e,n){n.d(e,"a",function(){return i});var r=n(535),o=n(488),i=function(t){var e,n,i;t&&(this.id="".concat(t.productVariantId,":").concat(t.designId),this.productVariantId=t.productVariantId,this.productVersionId=t.productVersionId,this.productId=t.productId,this.sku=t.storefrontProductVariantId,this.designId=t.designId,this.designName=t.designName,this.designGroup=t.designGroup,i=null!=(i=t.productVariantOptions)?i:[],this.options=i.map(function(t){return new o.b(t)}),i=null!=(i=t.productVariantResources)?i:[],this.resources=i.map(function(t){return new s(t)}),n=i.find(function(t){return t.type===r.d.Preview}),i=i.find(function(t){return t.type===r.d.EditorModel}),this.previewUrl=null!=(e=null==n?void 0:n.url)?e:"",this.designResourceId=null!=(e=null==i?void 0:i.resourceId)?e:"",this.previewResourceId=null!=(i=null==n?void 0:n.resourceId)?i:"",this.price=t.price)},s=function(t){t&&(this.resourceId=t.resourceId,this.name=t.name,this.url=t.url,this.type=t.type,this.resourcePreview=t.resourcePreview)}},603:function(t,e,n){n.d(e,"a",function(){return i});var e=n(161),r=new e.a(function(t){return t.complete()});var o=n(122),s=n(123);function i(i){return i<=0?function(){return r}:Object(o.a)(function(t,e){var n=0;t.subscribe(new s.a(e,function(t){++n<=i&&(e.next(t),i<=n)&&e.complete()}))})}},927:function(t,e,n){n.r(e),n.d(e,"AuWidgetProductInformationAJAX",function(){return D}),n.d(e,"widget",function(){return D});var p=n(0),i=n(535),e=n(2),r=n(403),o=n(1),s=n(541),u=n(147),c=Object(u.a)(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}}),a=n(395),l=n(603),d=n(122),h=n(123);function f(){return new c}var b,v,g,m=n(216);function y(o,t){var e=2<=arguments.length;return function(n){return n.pipe(o?Object(a.a)(function(t,e){return o(t,e,n)}):m.a,Object(l.a)(1),e?(r=t,Object(d.a)(function(t,e){var n=!1;t.subscribe(new h.a(e,function(t){n=!0,e.next(t)},function(){n||e.next(r),e.complete()}))})):(void 0===(i=function(){return new c})&&(i=f),Object(d.a)(function(t,e){var n=!1;t.subscribe(new h.a(e,function(t){n=!0,e.next(t)},function(){return n?e.complete():e.error(i())}))})));var i,r}}(u=b=b||{}).Preselect="Preselect",u.Filter="Filter",(u=g=g||{})[u.Template=1]="Template",u[u.OptionBasedProduct=2]="OptionBasedProduct",(g=v=v||{})[g.Custom=0]="Custom",g[g.ShopifyLegacy=1]="ShopifyLegacy",g[g.DocketManager=2]="DocketManager",g[g.Auth0Saml=3]="Auth0Saml",g[g.NopCommerce=4]="NopCommerce",g[g.WooCommerce=5]="WooCommerce",g[g.Magento=6]="Magento",g[g.BigCommerce=7]="BigCommerce",g[g.Shopify=8]="Shopify",g[g.ShopifyCustom=9]="ShopifyCustom";var u=n(160),O=function(t){var e;this.values=[],this.selected=[],t&&(this.id=t.id,this.name=t.title,this.isMultiSelect=!(null==(e=t.traits)||!e.includes("AllowsMultiselect")),this.values=t.productOptionValues.map(function(t){return new _(t)}),this.image=t.image,this.description=t.description,this.tooltip=t.tooltip,this.appearanceDataItems=null==(e=t.appearanceData)?void 0:e.items,this.type=((t,e)=>{if(e)return"checkbox";switch(t){case i.b.Radio:return"radio";case i.b.Chips:return"chips";case i.b.Dropdown:return"dropdown";case i.b.ColorGrid:return"color-grid";case i.b.ColorList:return"color-list";case i.b.ImageGrid:return"image-grid";case i.b.ImageList:return"image-list";default:return console.warn("Option type ".concat(t," is not supported")),"radio"}})(null==(e=t.appearanceData)?void 0:e.type,this.isMultiSelect),this.selected=this.isMultiSelect?this.values.filter(function(t){return t.isDefault}):[this.values.find(function(t){return t.isDefault})])},_=function(t){var e;this.disabled=!1,this.isDefault=!1,t&&(this.id=t.id,this.name=t.title,this.additionalText=t.description,this.color=t.colors[0]||null,this.imageUrl=(null==(e=t.image)?void 0:e.url)||null,this.isDefault=t.isDefault)};var I=function(){},k=function(t){var e;this.enabled=!1,t&&(this.enabled=null!=(e=t.enabled)&&e,this.skip=t.skip,this.take=t.take,this.productFilterId=t.productFilterId)},j=function(t){this.onError=function(t){},this.onSuccess=function(t){},t&&(this.onError=t.onError,this.onSuccess=t.onSuccess)},V=(w.prototype.getOptionValue=function(t){return this.options[t]},w);function w(t){var e;this.settings={mockups:new k,designs:new k,variants:new k},this.eventsCallbacks={options:new j,mockups:new j,designs:new j,variants:new j},this.productId=null==t?void 0:t.productId,this.productVersionId=null==t?void 0:t.productVersionId,this.productLinkId=null==t?void 0:t.productLinkId,this.options=null!=(e=null==t?void 0:t.options)?e:{},this.choices=null!=(e=null==t?void 0:t.choices)?e:void 0,this.currentSku=null==t?void 0:t.currentSku,this.settings.mockups=new k(null==(e=null==t?void 0:t.settings)?void 0:e.mockups),this.settings.designs=new k(null==(e=null==t?void 0:t.settings)?void 0:e.designs),this.settings.variants=new k(null==(e=null==t?void 0:t.settings)?void 0:e.variants),this.eventsCallbacks.designs=new j(null==(e=null==t?void 0:t.eventsCallbacks)?void 0:e.designs),this.eventsCallbacks.mockups=new j(null==(e=null==t?void 0:t.eventsCallbacks)?void 0:e.mockups),this.eventsCallbacks.options=new j(null==(e=null==t?void 0:t.eventsCallbacks)?void 0:e.options),this.eventsCallbacks.variants=new j(null==(e=null==t?void 0:t.eventsCallbacks)?void 0:e.variants)}var S,C=n(595),P=n(488),A=function(t){t&&(this.productVariantId=t.productVariantId,this.productVersionId=t.productVersionId,this.productId=t.productId,this.tenantId=t.productVersionId,this.sku=t.storefrontProductVariantId,this.mockupId=t.mockupId,this.mockupName=t.mockupName,this.mockupType=t.mockupType,this.surfaceIndex=t.surfaceIndex,this.surfaceUsageType=t.surfaceUsageType,this.options=t.productVariantOptions.map(function(t){return new P.b(t)}))},T=function(t){t&&(this.id=t.productId,this.versionId=t.productVersionId,this.linkId=t.productLinkId,this.name=t.name,this.description=t.description,this.customFields=t.customFields,this.tags=t.tags)},D=(S=u.a,Object(p.d)(M,S),Object.defineProperty(M.prototype,"productInfo",{get:function(){return this._productInfo},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"selectionStrategy",{get:function(){var t;return null==(t=this.auWizard.driver.backOffice.optionBasedProductInfo)?void 0:t.selectionStrategy},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"selectedVariantSku",{get:function(){var t;return null==(t=this.auWizard.driver.backOffice.optionBasedProductInfo)?void 0:t.selectedVariantSku},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"isPreselectSelectionStrategy",{get:function(){return this.selectionStrategy===b.Preselect},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"driverChoices",{get:function(){var t;return(null==(t=this.auWizard.driver.backOffice.optionBasedProductInfo)?void 0:t.choices)||null},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"priceIsFetching",{get:function(){return this._priceIsFetching},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"options",{get:function(){return!(this.name in this.auWizard.scopeInternal.widgetsData)||this._isRestored?this._output.options:[]},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"variants",{get:function(){var t;return this._params.choices?null==(t=this._filteredOutput)?void 0:t.variants:this._output.variants},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"designs",{get:function(){var t;return this._params.choices?null==(t=this._filteredOutput)?void 0:t.designs:this._output.designs},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"mockups",{get:function(){var t;return this._params.choices?null==(t=this._filteredOutput)?void 0:t.mockups:this._output.mockups},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"backOfficeUrl",{get:function(){return o.a.removeTrailingSlash(this.auWizard.driver.backOffice.backOfficeUrl)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"tenantId",{get:function(){return this.auWizard.driver.backOffice.tenantId},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"token",{get:function(){return this.auWizard.driver.backOffice.token},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"storefrontId",{get:function(){return this.auWizard.driver.backOffice.storefrontId},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"reference",{get:function(){return this.auWizard.driver.backOffice.externalProductId},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"storefrontUserId",{get:function(){return this.auWizard.driver.user.id},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"currencyCode",{get:function(){return this.auWizard.driver.settings.currency},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"quantity",{get:function(){return this.auWizard.driver.orders.current.quantity},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"productLinkId",{get:function(){var t;return this._params.productLinkId||(null==(t=this.auWizard.driver.backOffice.optionBasedProductInfo)?void 0:t.productLinkId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"productId",{get:function(){var t;return this._params.productId||(null==(t=this.auWizard.driver.backOffice.optionBasedProductInfo)?void 0:t.productId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"productVersionId",{get:function(){var t;return this._params.productVersionId||(null==(t=this.auWizard.driver.backOffice.optionBasedProductInfo)?void 0:t.productVersionId)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"costDetails",{get:function(){return this._costDetails},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"price",{get:function(){var t;return this._costDetails?null==(t=this._costDetails)?void 0:t.productCost:null},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"variantsSettings",{get:function(){return this._params.settings.variants},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"mockupsSettings",{get:function(){return this._params.settings.mockups},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"designsSettings",{get:function(){return this._params.settings.designs},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"currentChoices",{get:function(){return this._getChoices(this._output.options)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"variantsHashMap",{get:function(){var t=this._output.variants.map(function(t){var e={};return t.options.forEach(function(t){e[t.productOptionId]=[t.productOptionValueId]}),e});return 0==t.length&&console.warn("There are no available variants"),t},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"summary",{get:function(){var t,n;return 0<(null==(t=this.options)?void 0:t.length)?(n=[],this.options.forEach(function(t){var e={};e.name=t.name,e.value=t.selected.map(function(t){return t.name}),n.push(e)}),n):[]},enumerable:!1,configurable:!0}),M.prototype.getProductVariants=function(e,n){return Object(p.b)(this,void 0,void 0,function(){return Object(p.e)(this,function(t){return[2,this._productsApi.getProductVariants(e,null,n.skip,n.take,null,n.productFilterId,!0,this.isPreselectSelectionStrategy?null:this.selectedVariantSku,this.tenantId)]})})},M.prototype.getDesignVariants=function(e,n){return Object(p.b)(this,void 0,void 0,function(){return Object(p.e)(this,function(t){switch(t.label){case 0:return[4,this._productsApi.getProductVariantDesigns(e,+this.productVersionId,null,null,null,null,n.skip,n.take,null,n.productFilterId,!0,this.isPreselectSelectionStrategy?null:this.selectedVariantSku,this.tenantId)];case 1:return[2,t.sent()]}})})},M.prototype.getMockupVariants=function(e,n){return Object(p.b)(this,void 0,void 0,function(){return Object(p.e)(this,function(t){switch(t.label){case 0:return[4,this._productsApi.getProductVariantMockups(e,+this.productVersionId,null,null,null,null,n.skip,n.take,null,n.productFilterId,!0,this.isPreselectSelectionStrategy?null:this.selectedVariantSku,this.tenantId)];case 1:return[2,t.sent()]}})})},M.prototype.updateParams=function(t){},M.prototype.updateParamsAsync=function(o){var s;return Object(p.b)(this,void 0,void 0,function(){var e,n,i,r;return Object(p.e)(this,function(t){switch(t.label){case 0:return this._params?[3,5]:(this._params=new V(o),this.productId?[4,this._getOptionsAndVariantsSimultaneously()]:[3,2]);case 1:return e=t.sent(),[3,4];case 2:return[4,this._getOptionsAndVariants()];case 3:e=t.sent(),t.label=4;case 4:n=(i=e).options,i=i.variants,n=this._selectAvailableVariant(n,i),n=this._disableUnavailableOptions(n,i),this._output.options=n,this.emitChange({options:this._output.options},!1),this._output.variants=i,this.emitChange({variants:this._output.variants},!1),this._optionsAreLoaded.next(!0),t.label=5;case 5:if(this.auWizard._isRestoring)return[2];if(o.choices&&!Array.isArray(o.choices)&&this._isNewChoices(o.choices)){if(n=null==(s=Object.keys(o.choices))?void 0:s.length,i=this.variantsHashMap[0],r=null==(s=Object.keys(i))?void 0:s.length,n!=r)return console.warn("The number of choices is not equal to the number of options."),[2];this._selectValuesBy(o.choices),this.emitChange({filterOutput:this._filteredOutput,options:this._output.options},!1,!0)}return o.currentSku&&o.currentSku!==this._params.currentSku?(this._cancelTokenSource&&this._cancelTokenSource.cancel("Operation canceled"),[4,this.getPrice(o.currentSku)]):[3,7];case 6:t.sent(),t.label=7;case 7:return[2]}})})},M.prototype.connectedCallback=function(){return Object(p.b)(this,void 0,void 0,function(){return Object(p.e)(this,function(t){return S.prototype.connectedCallback.call(this),[2]})})},M.prototype.disconnectedCallback=function(){S.prototype.disconnectedCallback.call(this)},M.prototype.exportWidgetData=function(t){var e;return Object(p.b)(this,void 0,void 0,function(){return Object(p.e)(this,function(t){return[2,null!=(e=this._params)&&e.choices?{choices:null==(e=this._params)?void 0:e.choices}:null]})})},M.prototype.restoreWidgetFromData=function(n,t){return Object(p.b)(this,void 0,void 0,function(){var e=this;return Object(p.e)(this,function(t){return n&&this._optionsAreLoaded.pipe(y(function(t){return!0===t})).subscribe(function(){var t=null==n?void 0:n.choices;e._params.choices=t,e._selectValuesBy(t),e._isRestored=!0,e.emitChange({filterOutput:e._filteredOutput,options:e._output.options},!1,!0)}),[2]})})},M.prototype.getPrice=function(i){return Object(p.b)(this,void 0,void 0,function(){var e,n=this;return Object(p.e)(this,function(t){switch(t.label){case 0:return i?o.a.isEmptyString(this.reference)||o.a.isEmptyString(this.storefrontId)?[3,2]:(e=r.a.CancelToken,this._cancelTokenSource=e.source(),this._params.currentSku=i,this._priceIsFetching=!0,[4,this._productsReferenceApi.getProductCostDetails(this.reference,i,this.storefrontId,null,this.currencyCode,this.quantity,this.tenantId,this._cancelTokenSource.token).then(function(t){n._costDetails=t,n._priceIsFetching=!1,n.emitChange({costDetails:n._costDetails},!1)}).catch(function(t){"Operation canceled"!==t.message&&console.error(t.message)})]):[2,null];case 1:return t.sent(),[3,3];case 2:return console.warn("To get current item price you need reference and storefrontId"),[2,null];case 3:return[2]}})})},M.prototype.filterModel=function(t,n){return Object.values(t).forEach(function(e){Array.isArray(e)?e.length<1||(n=n.filter(function(t){return null==(t=t.options)?void 0:t.some(function(t){return e.includes(t.productOptionValueId)})})):n=n.filter(function(t){return null==(t=t.options)?void 0:t.some(function(t){return e===t.productOptionValueId})})}),n},M.prototype.filterVariants=function(t){t&&this._output&&(this._filteredOutput=Object.assign({},this._output),this._filteredOutput.designs&&(this._filteredOutput.designs=this.filterModel(t,this._filteredOutput.designs)),this._filteredOutput.mockups&&(this._filteredOutput.mockups=this.filterModel(t,this._filteredOutput.mockups)),this._filteredOutput.variants)&&(this._filteredOutput.variants=this.filterModel(t,this._filteredOutput.variants))},M.prototype._createProductApiClientConfig=function(){var t=new i.a;return t.apiUrl=this.backOfficeUrl,t.setAuthorizationToken(this.token),t},M.prototype._getChoices=function(t){var e={};return t.forEach(function(t){e[t.id]=t.selected.map(function(t){return t.id})}),e},M.prototype._selectValuesBy=function(t){this.filterVariants(t),this._params.choices=t;t=this._applyChoices(this._output.options,t);this._output.options=this._disableUnavailableOptions(t,this._output.variants)},M.prototype._getOptionsAndVariants=function(){return Object(p.b)(this,void 0,void 0,function(){var e,n;return Object(p.e)(this,function(t){switch(t.label){case 0:return[4,this._getOptions()];case 1:return e=t.sent(),[4,this._getVariants()];case 2:return n=t.sent(),[2,{options:e,variants:n}]}})})},M.prototype._getOptionsAndVariantsSimultaneously=function(){return Object(p.b)(this,void 0,void 0,function(){var e;return Object(p.e)(this,function(t){switch(t.label){case 0:return[4,Promise.all([this._getOptions(),this._getVariants()])];case 1:return e=p.h.apply(void 0,[t.sent(),2]),[2,{options:e[0],variants:e[1]}]}})})},M.prototype._selectAvailableVariant=function(t,e){var i;return this._isSelectedVariantAvailable(t,e)?t:(i=this._getVariantsHashMap(e)[0],t.map(function(e){var n=[e.values.find(function(t){return t.id===i[e.id][0]}).id];return e.selected=e.isMultiSelect?e.values.filter(function(e){return null==n?void 0:n.some(function(t){return t===e.id})}):[e.values.find(function(t){return null==n?void 0:n.includes(t.id)})],e}))},M.prototype._isSelectedVariantAvailable=function(t,e){var n=this._getChoices(t);return this._getVariantsHashMap(e).some(function(t){return JSON.stringify(t)===JSON.stringify(n)})},M.prototype._disableUnavailableOptions=function(t,e){var n,i,r=this;if(this._getAllVariantsCount(t)===(null==e?void 0:e.length))return t;var o=this._getChoices(t),s=this._getVariantsHashMap(e),u=[];if(1===(null==(e=Object.keys(o))?void 0:e.length))u.push.apply(u,Object(p.j)([],Object(p.h)(s),!1));else try{for(var c=Object(p.k)(Object.entries(o)),a=c.next();!a.done;a=c.next()){var l=Object(p.h)(a.value,2);((e,n)=>{var t=s.filter(function(t){return t[e][0]==n[0]&&r._getDifferentOptionsCount(t,o)<=1});u.push.apply(u,Object(p.j)([],Object(p.h)(t),!1))})(l[0],l[1])}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}return t.map(function(n){return n.values.map(function(e){var t=u.some(function(t){return t[n.id][0]===e.id});return e.disabled=!t,e}),n})},M.prototype._getAllVariantsCount=function(t){return t.reduce(function(t,e){return t*e.values.length},1)},M.prototype._getDifferentOptionsCount=function(t,e){var n,i,r=0;try{for(var o=Object(p.k)(Object.entries(t)),s=o.next();!s.done;s=o.next()){var u=Object(p.h)(s.value,2),c=u[0],a=u[1],l=e[c];Array.isArray(l)?l[0]!=a[0]&&r++:l!=a[0]&&r++}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return r},M.prototype._applyChoices=function(t,e){return t.map(function(t){var n=e[null==t?void 0:t.id];return t.selected=t.isMultiSelect?t.values.filter(function(e){return null==n?void 0:n.some(function(t){return t===e.id})}):[t.values.find(function(t){return null==n?void 0:n.includes(t.id)})],t})},M.prototype._getVariantsHashMap=function(t){t=t.map(function(t){var e={};return t.options.forEach(function(t){e[t.productOptionId]=[t.productOptionValueId]}),e});return 0==t.length&&console.warn("There are no available variants"),t},M.prototype._getProductSummary=function(){return Object(p.b)(this,void 0,void 0,function(){return Object(p.e)(this,function(t){if(o.a.isEmptyString(this.reference)||o.a.isEmptyString(this.storefrontId)){if(null!=this.productId)return[2,this._productsApi.getProductSummary(Number.isFinite(Number(this.productId))?Number(this.productId):null,Number.isFinite(Number(this.productVersionId))?Number(this.productVersionId):null,Number.isFinite(Number(this.productLinkId))?Number(this.productLinkId):null,null,this.selectedVariantSku,this.tenantId)];throw new Error("There is not enough data to initialize. Use the following data combinations for initialization: productReferenceId and storefrontId or productId.")}return[2,this._productsReferenceApi.getProductSummary(this.reference,Number.isFinite(Number(this.storefrontId))?Number(this.storefrontId):null,null,this.selectedVariantSku,this.tenantId)]})})},M.prototype._getOptions=function(){var i;return Object(p.b)(this,void 0,void 0,function(){var e,n;return Object(p.e)(this,function(t){switch(t.label){case 0:e=[],t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getProductSummary()];case 2:return n=t.sent(),this._productInfo=new T(n),e=null==(i=n.options)?void 0:i.map(function(t){return new O(t)}),this.driverChoices&&(e=this._applyChoices(e,this.driverChoices)),this._params.eventsCallbacks.options.onSuccess(e),[3,4];case 3:return n=t.sent(),this._params.eventsCallbacks.options.onError(n),[3,4];case 4:return[2,e]}})})},M.prototype._getVariants=function(){return Object(p.b)(this,void 0,void 0,function(){var e,n,i=this;return Object(p.e)(this,function(t){switch(t.label){case 0:e=[],t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getProductVariants(+this.productId,this.variantsSettings)];case 2:return n=t.sent(),e=n.items.map(function(t){return new P.a(t)}),this._params.eventsCallbacks.variants.onSuccess(e),(o.a.isNullOrUndefined(e)||0==(null==e?void 0:e.length))&&this.selectedVariantSku&&console.warn("There are no product variants with this SKU: ".concat(this.selectedVariantSku)),[3,4];case 3:return n=t.sent(),this._params.eventsCallbacks.variants.onError(null==n?void 0:n.message),[3,4];case 4:return this.designsSettings.enabled&&this.getDesignVariants(+this.productId,this.designsSettings).then(function(t){i._output.designs=t.items.map(function(t){return new C.a(t)}),i._params.eventsCallbacks.designs.onSuccess(i._output.designs),!i._filteredOutput.designs&&i._params.choices&&(i._filteredOutput.designs=i.filterModel(i._params.choices,i._output.designs)),i.emitChange({designs:i._output.designs},!1)}).catch(function(t){return i._params.eventsCallbacks.designs.onError(t)}),this.mockupsSettings.enabled&&this.getMockupVariants(+this.productId,this.mockupsSettings).then(function(t){i._output.mockups=t.items.map(function(t){return new A(t)}),i._params.eventsCallbacks.mockups.onSuccess(i._output.mockups),!i._filteredOutput.mockups&&i._params.choices&&(i._filteredOutput.mockups=i.filterModel(i._params.choices,i._output.mockups)),i.emitChange({mockups:i._output.mockups},!1)}).catch(function(t){return i._params.eventsCallbacks.mockups.onError(t)}),[2,e]}})})},M.prototype._isNewChoices=function(e){var n;return Object(p.b)(this,void 0,void 0,function(){return Object(p.e)(this,function(t){return[2,JSON.stringify(e)!==JSON.stringify(null==(n=this._params)?void 0:n.choices)]})})},Object(p.c)([Object(e.a)("au-widget-pim-ajax"),Object(p.g)("design:paramtypes",[])],M));function M(){var t=S.call(this)||this;return t._priceIsFetching=!1,t._output=new I,t._filteredOutput=null,t._isRestored=!1,t._optionsAreLoaded=new s.a(!1),t._productInfo=null,t._productApiClientConfig=t._createProductApiClientConfig(),t._productsApi=new i.e(t._productApiClientConfig,t.backOfficeUrl),t._productsReferenceApi=new i.c(t._productApiClientConfig,t.backOfficeUrl),t}}}]);