@ikas/storefront 6.1.0-beta.317 → 6.1.0-beta.318

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{renderComponent as t}from"../components/page/index.js";import{IkasAttributeList as i}from"../models/ui/product-attribute-list/index.js";import{IkasBlogCategory as r}from"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import{IkasBlog as a}from"../models/data/blog/index.js";import{IkasBrand as o}from"../models/data/brand/index.js";import{IkasThemeJsonPageType as n,initIkasCategory as s,IkasThemeJsonComponentPropType as u,IkasProductAttributeType as l}from"@ikas/storefront-models";import"mobx";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as d}from"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import{IkasImage as p}from"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as c}from"../models/data/product/index.js";import{IkasRaffle as m}from"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as f}from"../models/data/theme-json/page/component/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasBlogList as g}from"../models/ui/blog-list/index.js";import{IkasBlogCategoryList as v}from"../models/ui/blog-category-list/index.js";import{IkasBrandList as P}from"../models/ui/brand-list/index.js";import{IkasCategoryList as V}from"../models/ui/category-list/index.js";import{IkasNavigationLink as h}from"../models/ui/navigation-link/index.js";import{IkasProductList as j}from"../models/ui/product-list/index.js";import{IkasAttributeDetail as C}from"../models/ui/product-attribute-detail/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import{IkasComponentRenderer as D}from"../models/ui/component-renderer/index.js";import{IkasRaffleList as L}from"../models/ui/raffle-list/index.js";import{IkasPageComponentPropValue as T,getPlaceholderBrand as x,getPlaceholderCategory as y,getPlaceholderProduct as I,getPlaceholderBlog as S,getPlaceholderBlogCategory as b,getPlaceholderRaffle as _,ProductDataBindingFields as E,ProductVariantDataBindingFields as O,CategoryDataBindingFields as R,BrandDataBindingFields as w}from"@ikas/storefront-providers";import A from"lodash/flatten";import{IkasBaseStore as B}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import{IkasProductVariantFunctions as N,stringToSlug as k}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as G}from"@ikas/storefront-config";import U from"react";var M=function(){function M(){}return M.setPageSpecificData=function(t,i,u){var l;if(this.pageType=i,this.isBrowser=u,t)switch(i){case n.PRODUCT:var p=t;M.pageSpecificData=new c(e(e({},p),{selectedVariantValues:p.selectedVariantValues||(null===(l=p.variants.find((function(e){return N.hasStock(e)})))||void 0===l?void 0:l.variantValues)||p.variants[0].variantValues})),u&&this._initProductOnBrowser(M.pageSpecificData);break;case n.CATEGORY:var f=t;s(f,G.getCurrentLocale()),M.pageSpecificData=new d(f);break;case n.BRAND:var g=t;M.pageSpecificData=new o(g);break;case n.BLOG:var v=t;M.pageSpecificData=new a(v);break;case n.BLOG_CATEGORY:var P=t;M.pageSpecificData=new r(P);break;case n.RAFFLE_DETAIL:var V=t;M.pageSpecificData=new m(V)}else this.pageSpecificData=void 0},M.isServer=function(){return"undefined"==typeof window},M.initPagePropValues=function(e,t,i,r,a){return this.flatCustomDataList=A(i.map((function(e){return e.flat}))),e.map((function(e){return M.initPageComponentPropValue(e,t,r,a)}))},M.initPageComponentPropValue=function(t,i,r,a){var o=i.find((function(e){return e.id===t.pageComponent.componentId})),n=null==o?void 0:o.props,s={};return null==n||n.map((function(e){var i=t.propValues[e.name];s[e.name]=M.initPropValue(e,i,r,a)})),new T(e(e({},t),{pageComponent:new f(e(e({},t.pageComponent),{propValues:s,componentId:o.id})),component:o,propValues:s}))},M.initPropValue=function(e,t,i,r){if(null==t)return null;switch(e.type){case u.TEXT:return M.initTextPropValue(t);case u.IMAGE:return M.initImagePropValue(t);case u.IMAGE_LIST:return M.initImageListPropValue(t);case u.BRAND:return M.initBrandPropValue(t);case u.BRAND_LIST:return M.initBrandListPropValue(t);case u.CATEGORY:return M.initCategoryPropValue(t);case u.CATEGORY_LIST:return M.initCategoryListPropValue(t);case u.PRODUCT_LIST:return M.initProductListPropValue(t);case u.PRODUCT_DETAIL:return M.initProductPropValue(t);case u.PRODUCT_ATTRIBUTE:return M.initAttributePropValue(t);case u.PRODUCT_ATTRIBUTE_LIST:return M.initAttributeListPropValue(t);case u.LINK:case u.LIST_OF_LINK:return M.initLinkPropValue(t);case u.COMPONENT:return M.initComponentPropValue(t,i,r);case u.COMPONENT_LIST:return M.initComponentListPropValue(t,i,r);case u.CUSTOM:return M.initCustomDataPropValue(t,i,r);case u.BLOG:return M.initBlogPropValue(t);case u.BLOG_LIST:return M.initBlogListPropValue(t);case u.BLOG_CATEGORY:return M.initBlogCategoryPropValue(t);case u.BLOG_LIST:return M.initBlogCategoryListPropValue(t);case u.RAFFLE:return M.initRafflePropValue(t);case u.RAFFLE_LIST:return M.initRaffleListPropValue(t);case u.SLIDER:return M.initSliderPropValue(t);case u.VIDEO:return M.initVideoPropValue(t);default:return t}},M.initTextPropValue=function(e){var t=this;function i(e){for(var t,i=/{{(.*?)}}|([^{}]+)/g,r=[];null!==(t=i.exec(e));)t[1]?r.push({value:t[1],isVariable:!0}):t[2]&&r.push({value:t[2],isVariable:!1});return r}return i(e).filter((function(e){return e.isVariable})).length?U.createElement("div",null,function(){for(var r,a,o,s,u=i(e),d=u.filter((function(e){return e.isVariable})),p={},c=B.getInstance().currentPageType,m=function(e){var i=e.value;if(c===n.PRODUCT){var u=t.pageSpecificData;if(i.includes(E.ATTRIBUTE_VALUE)){var d=i.split(E.ATTRIBUTE_VALUE)[1].split("_")[1],m=u.groupedAttributeValues.find((function(e){return e.attribute.id===d})),f=u.selectedVariant.groupedAttributeValues.find((function(e){return e.attribute.id===d}))||m;f?f.attribute.type===l.CHOICE?p[i]=(null===(r=f.values[0].productAttributeOption)||void 0===r?void 0:r.name)||"":f.attribute.type===l.MULTIPLE_CHOICE?p[i]=f.values.map((function(e){var t;return null===(t=e.productAttributeOption)||void 0===t?void 0:t.name})).join(", ")||"":p[i]=f.values[0].value||"":p[i]=""}else i.includes(E.NAME)?p[i]=u.name:i.includes(E.DESCRIPTION)?p[i]=u.description:i.includes(E.SHORT_DESCRIPTION)?p[i]=u.shortDescription:i.includes(E.CATEGORY_NAME)?p[i]=(null===(a=u.categories[0])||void 0===a?void 0:a.name)||"":i.includes(E.TAG)?p[i]=(null===(o=u.tags)||void 0===o?void 0:o.map((function(e){return e.name})).join(", "))||"":i.includes(O.BARCODE)?p[i]=(null===(s=u.selectedVariant.barcodeList)||void 0===s?void 0:s.length)?u.selectedVariant.barcodeList[0]:"":i.includes(O.SKU)?p[i]=u.selectedVariant.sku:i.includes(O.SELL_PRICE)?p[i]=u.selectedVariant.formattedSellPrice:i.includes(O.DISCOUNT_PRICE)?p[i]=u.selectedVariant.formattedDiscountPrice:i.includes(O.STOCK)?p[i]=u.selectedVariant.stock:p[i]=""}else if(c===n.CATEGORY){var g=t.pageSpecificData;i===R.NAME?p[i]=g.name:i===R.DESCRIPTION?p[i]=g.description:p[i]=""}else if(c===n.BRAND){var v=t.pageSpecificData;i===w.NAME?p[i]=v.name:p[i]=""}else p[i]=""},f=0,g=d;f<g.length;f++){m(g[f])}for(var v="",P=0,V=u;P<V.length;P++){var h=V[P];h.isVariable?v+=p[h.value]:v+=h.value}return v}()):e},M.initBrandPropValue=function(e){return e.brandPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.brand?new o(e.brand):x()},M.initBrandListPropValue=function(e){return new P(e)},M.initCategoryPropValue=function(t){var i,r;return t.categoryPropValue.usePageData&&this.pageSpecificData?((null===(i=t.categoryPropValue.excludedFieldsCategory)||void 0===i?void 0:i.length)&&(this.pageSpecificData.description=null),this.pageSpecificData):t.category?new d(e(e({},t.category),{description:(null===(r=t.categoryPropValue.excludedFieldsCategory)||void 0===r?void 0:r.length)?null:t.category.description})):y()},M.initCategoryListPropValue=function(e){return new V(e)},M.initProductListPropValue=function(t){var i,r,a,o=null===(i=null==t?void 0:t.productListPropValue)||void 0===i?void 0:i.id;if(o){var n=M._productListRegistry.get(o);if(n){if(n.propValue===t)return n.list;(null===(a=null===(r=n.list)||void 0===r?void 0:r.data)||void 0===a?void 0:a.length)&&n.list.data.forEach((function(e){var t;return null===(t=e.dispose)||void 0===t?void 0:t.call(e)}));try{var s=n.propValue;s&&(s.data=null,s.relatedProductData=null,s.recommendedProductData=null,s.viewedTogetherProductData=null,s.purchasedTogetherProductData=null)}catch(e){}}}var u=new j(e(e({},t),{pageSpecificData:this.pageSpecificData}),B.getInstance().router);return o&&M._productListRegistry.set(o,{list:u,propValue:t}),M.trimNextRouterCache(),M.installNextPrefetchCleaner(),u},M.installNextPrefetchCleaner=function(){if("undefined"!=typeof window&&!M._nextPrefetchCleanerInstalled)try{var e=B.getInstance().router;if(!e)return;if(e.sdc&&"object"==typeof e.sdc&&!e.sdc.__ikasCapped){var t=M.NEXT_SDC_MAX_ENTRIES,i=e.sdc,r=Object.keys(i),a=new Proxy(i,{set:function(e,i,a){if("string"==typeof i){if(i in e){var o=r.indexOf(i);-1!==o&&r.splice(o,1)}for(e[i]=a,r.push(i);r.length>t;){var n=r.shift();n&&n in e&&delete e[n]}return!0}return e[i]=a,!0},deleteProperty:function(e,t){if("string"==typeof t){var i=r.indexOf(t);-1!==i&&r.splice(i,1)}return delete e[t],!0}});try{Object.defineProperty(i,"__ikasCapped",{value:!0,enumerable:!1}),e.sdc=a}catch(e){}}e.events&&"function"==typeof e.events.on&&e.events.on("routeChangeComplete",(function(){M.trimNextRouterCache()})),M._nextPrefetchCleanerInstalled=!0}catch(e){}},M.trimNextRouterCache=function(){if("undefined"!=typeof window)try{var e=B.getInstance().router;if(!e)return;var t=e.asPath;if(e.sdc&&"object"==typeof e.sdc){var i=Object.keys(e.sdc),r=M.NEXT_SDC_MAX_ENTRIES,a=t&&i.find((function(e){return e.endsWith(t+".json")})),o=i.slice(-r),n=new Set(o);a&&n.add(a);for(var s=0,u=i;s<u.length;s++){var l=u[s];n.has(l)||delete e.sdc[l]}}var d=e.route;if(e.components&&"object"==typeof e.components)for(var p=Object.keys(e.components),c=0,m=p;c<m.length;c++){if((l=m[c])!==d&&"/_app"!==l){var f=e.components[l];f&&f.props&&f.props.pageProps&&(f.props.pageProps=null)}}var g=e.pageLoader;if(g){if(g.pageCache&&"object"==typeof g.pageCache)for(var v=Object.keys(g.pageCache),P=0,V=v;P<V.length;P++){if((l=V[P])!==d&&"/_app"!==l&&"/_error"!==l)try{delete g.pageCache[l]}catch(e){}}if(g.prefetched&&"object"==typeof g.prefetched&&e.sdc)for(var h=Object.keys(e.sdc),j=Object.keys(g.prefetched),C=function(e){if(!h.some((function(t){return t.includes(e)})))try{delete g.prefetched[e]}catch(e){}},D=0,L=j;D<L.length;D++){C(L[D])}}if("undefined"!=typeof document&&e.sdc){var T=Object.keys(e.sdc);document.querySelectorAll('link[rel="prefetch"][href$=".json"]').forEach((function(e){var t,i=e.href;if(i&&!T.some((function(e){return i.endsWith(e)})))try{null===(t=e.parentNode)||void 0===t||t.removeChild(e)}catch(e){}}))}}catch(e){}},M.initProductPropValue=function(t){var i=new c(I());if(t.productDetailPropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;i=new c(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return i},M._initProductOnBrowser=function(e){var t=new URLSearchParams(window.location.search),i=t.get("vid");if(i){var r=e.variants.find((function(e){return e.id===i}));r&&(e.selectedVariantValues=r.variantValues)}else{var a=e.variantTypes.map((function(e){return e.variantType.slug})),o=[];a.forEach((function(i,r){var a=e.variantTypes[r],n=k(t.get(decodeURIComponent(i))||"");if(n){var s=a.variantType.values.find((function(e){return e.slug===n}));s&&o.push(s)}})),o.length===e.selectedVariantValues.length&&(e.selectedVariantValues=o)}e.setOptionRealPrices()},M.initAttributePropValue=function(t){var i=null;if(t.attributePropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;i=new c(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return new C(i,t.attributePropValue)},M.initAttributeListPropValue=function(t){var r=null;if(t.attributeListPropValue.usePageData&&this.pageSpecificData)r=this.pageSpecificData;else if(t.productDetail){var a=t.productDetail;r=new c(e(e({},a),{selectedVariantValues:a.selectedVariantValues}))}return new i(r,t.attributeListPropValue)},M.initLinkPropValue=function(e){return Array.isArray(e)?e.map((function(e){return new h(e.href,e.label,e.subLinks,e.isExternal||void 0)})):e?new h(e.href,e.label,e.subLinks,e.isExternal||void 0):void 0},M.initImagePropValue=function(e){return new p(e)},M.initImageListPropValue=function(e){return e.map((function(e){return new p(e)}))},M.initCustomDataPropValue=function(e,t,i){if(e&&e.value&&e.customDataId){var r=this.flatCustomDataList.find((function(t){return t.id===e.customDataId}));if(r)return this._initCustomDataPropValue(e,r,t,i)}},M._initCustomDataPropValue=function(e,t,i,r){var a=this;if(!e)return null;var o=e.value;if(null==o)return null;switch(t.type){case u.TEXT:return this.initTextPropValue(o);case u.BRAND:return this.initBrandPropValue(o);case u.BRAND_LIST:return this.initBrandListPropValue(o);case u.CATEGORY_LIST:return this.initCategoryListPropValue(o);case u.CATEGORY:return this.initCategoryPropValue(o);case u.IMAGE_LIST:return this.initImageListPropValue(o);case u.IMAGE:return this.initImagePropValue(o);case u.LINK:return this.initLinkPropValue(o);case u.PRODUCT_DETAIL:return this.initProductPropValue(o);case u.PRODUCT_LIST:return this.initProductListPropValue(o);case u.PRODUCT_ATTRIBUTE:return this.initAttributePropValue(o);case u.PRODUCT_ATTRIBUTE_LIST:return this.initAttributeListPropValue(o);case u.BLOG:return this.initBlogPropValue(o);case u.BLOG_LIST:return this.initBlogListPropValue(o);case u.BLOG_CATEGORY:return this.initBlogCategoryPropValue(o);case u.BLOG_CATEGORY_LIST:return this.initBlogCategoryListPropValue(o);case u.RAFFLE:return this.initRafflePropValue(o);case u.RAFFLE_LIST:return this.initRaffleListPropValue(o);case u.SLIDER:return this.initSliderPropValue(o);case u.VIDEO:return M.initVideoPropValue(o);case u.OBJECT:for(var n={},s=function(e){var t=o[e.key],a=void 0;e.customDataId&&(a=l.flatCustomDataList.find((function(e){return e.id===t.customDataId}))),n[e.key]=l._initCustomDataPropValue(t,a||e,i,r)},l=this,d=0,p=t.nestedData||[];d<p.length;d++){s(p[d])}return n;case u.DYNAMIC_LIST:case u.STATIC_LIST:try{if(!o||!o.length)return null;var c=[],m=t.nestedData[0];return o.forEach((function(e){var t;m.customDataId&&(t=a.flatCustomDataList.find((function(t){return t.id===e.customDataId}))),c.push(a._initCustomDataPropValue(e,t||m,i,r))})),c}catch(e){return[]}case u.COMPONENT:return this.initComponentPropValue(o,i,r);case u.COMPONENT_LIST:return this.initComponentListPropValue(o,i,r);default:return o}},M.initComponentPropValue=function(e,t,i){return this._initComponentPropValue(e,t,i)},M._initComponentPropValue=function(e,i,r){var a=e.length?e[0]:void 0;if(a){var o=new T(a),n=M.initPageComponentPropValue(o,[o.component],i,r);if(n)return new D((function(){return t(n,i,-10)}))}},M.initComponentListPropValue=function(e,t,i){return this._initComponentListPropValue(e,t,i)},M._initComponentListPropValue=function(e,i,r){return e&&e.length?e.map((function(e){var a=new T(e),o=M.initPageComponentPropValue(a,[a.component],i,r);return new D((function(){return t(o,i,-1)}))})):[]},M.initBlogPropValue=function(e){return e.blogPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blog?new a(e.blog):S()},M.initBlogListPropValue=function(e){return new g(e)},M.initBlogCategoryPropValue=function(e){return e.blogCategoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blogCategory?new r(e.blogCategory):b()},M.initBlogCategoryListPropValue=function(e){return new v(e)},M.initRafflePropValue=function(e){return e.rafflePropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.raffle?new m(e.raffle):new m(_())},M.initRaffleListPropValue=function(e){return new L(e)},M.initSliderPropValue=function(e){return e},M.initVideoPropValue=function(t){return e(e({},t),{thumbnailImage:t.thumbnailImage?new p(t.thumbnailImage):null})},M.pageSpecificData={},M.flatCustomDataList=[],M.isBrowser=!1,M._productListRegistry=new Map,M._nextPrefetchCleanerInstalled=!1,M.NEXT_SDC_MAX_ENTRIES=20,M}();export{M as IkasPageDataInit};
1
+ import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{renderComponent as t}from"../components/page/index.js";import{IkasAttributeList as i}from"../models/ui/product-attribute-list/index.js";import{IkasBlogCategory as r}from"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import{IkasBlog as a}from"../models/data/blog/index.js";import{IkasBrand as o}from"../models/data/brand/index.js";import{IkasThemeJsonPageType as n,initIkasCategory as s,IkasThemeJsonComponentPropType as u,IkasProductAttributeType as d}from"@ikas/storefront-models";import"mobx";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as l}from"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import{IkasImage as p}from"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as c}from"../models/data/product/index.js";import{IkasRaffle as m}from"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as f}from"../models/data/theme-json/page/component/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasBlogList as g}from"../models/ui/blog-list/index.js";import{IkasBlogCategoryList as v}from"../models/ui/blog-category-list/index.js";import{IkasBrandList as P}from"../models/ui/brand-list/index.js";import{IkasCategoryList as V}from"../models/ui/category-list/index.js";import{IkasNavigationLink as h}from"../models/ui/navigation-link/index.js";import{IkasProductList as j}from"../models/ui/product-list/index.js";import{IkasAttributeDetail as C}from"../models/ui/product-attribute-detail/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import{IkasComponentRenderer as D}from"../models/ui/component-renderer/index.js";import{IkasRaffleList as L}from"../models/ui/raffle-list/index.js";import{IkasPageComponentPropValue as T,getPlaceholderBrand as x,getPlaceholderCategory as y,getPlaceholderProduct as I,getPlaceholderBlog as S,getPlaceholderBlogCategory as b,getPlaceholderRaffle as _,ProductDataBindingFields as w,ProductVariantDataBindingFields as E,CategoryDataBindingFields as O,BrandDataBindingFields as R}from"@ikas/storefront-providers";import A from"lodash/flatten";import{IkasBaseStore as B}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import{IkasProductVariantFunctions as k,stringToSlug as N}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as G}from"@ikas/storefront-config";import U from"react";var M=function(){function M(){}return M.setPageSpecificData=function(t,i,u){var d;if(this.pageType=i,this.isBrowser=u,t)switch(i){case n.PRODUCT:var p=t;M.pageSpecificData=new c(e(e({},p),{selectedVariantValues:p.selectedVariantValues||(null===(d=p.variants.find((function(e){return k.hasStock(e)})))||void 0===d?void 0:d.variantValues)||p.variants[0].variantValues})),u&&this._initProductOnBrowser(M.pageSpecificData);break;case n.CATEGORY:var f=t;s(f,G.getCurrentLocale()),M.pageSpecificData=new l(f);break;case n.BRAND:var g=t;M.pageSpecificData=new o(g);break;case n.BLOG:var v=t;M.pageSpecificData=new a(v);break;case n.BLOG_CATEGORY:var P=t;M.pageSpecificData=new r(P);break;case n.RAFFLE_DETAIL:var V=t;M.pageSpecificData=new m(V)}else this.pageSpecificData=void 0},M.isServer=function(){return"undefined"==typeof window},M.initPagePropValues=function(e,t,i,r,a){return this.flatCustomDataList=A(i.map((function(e){return e.flat}))),e.map((function(e){return M.initPageComponentPropValue(e,t,r,a)}))},M.initPageComponentPropValue=function(t,i,r,a){var o=i.find((function(e){return e.id===t.pageComponent.componentId})),n=null==o?void 0:o.props,s={};return null==n||n.map((function(e){var i=t.propValues[e.name];s[e.name]=M.initPropValue(e,i,r,a)})),new T(e(e({},t),{pageComponent:new f(e(e({},t.pageComponent),{propValues:s,componentId:o.id})),component:o,propValues:s}))},M.initPropValue=function(e,t,i,r){if(null==t)return null;switch(e.type){case u.TEXT:return M.initTextPropValue(t);case u.IMAGE:return M.initImagePropValue(t);case u.IMAGE_LIST:return M.initImageListPropValue(t);case u.BRAND:return M.initBrandPropValue(t);case u.BRAND_LIST:return M.initBrandListPropValue(t);case u.CATEGORY:return M.initCategoryPropValue(t);case u.CATEGORY_LIST:return M.initCategoryListPropValue(t);case u.PRODUCT_LIST:return M.initProductListPropValue(t);case u.PRODUCT_DETAIL:return M.initProductPropValue(t);case u.PRODUCT_ATTRIBUTE:return M.initAttributePropValue(t);case u.PRODUCT_ATTRIBUTE_LIST:return M.initAttributeListPropValue(t);case u.LINK:case u.LIST_OF_LINK:return M.initLinkPropValue(t);case u.COMPONENT:return M.initComponentPropValue(t,i,r);case u.COMPONENT_LIST:return M.initComponentListPropValue(t,i,r);case u.CUSTOM:return M.initCustomDataPropValue(t,i,r);case u.BLOG:return M.initBlogPropValue(t);case u.BLOG_LIST:return M.initBlogListPropValue(t);case u.BLOG_CATEGORY:return M.initBlogCategoryPropValue(t);case u.BLOG_LIST:return M.initBlogCategoryListPropValue(t);case u.RAFFLE:return M.initRafflePropValue(t);case u.RAFFLE_LIST:return M.initRaffleListPropValue(t);case u.SLIDER:return M.initSliderPropValue(t);case u.VIDEO:return M.initVideoPropValue(t);default:return t}},M.initTextPropValue=function(e){var t=this;function i(e){for(var t,i=/{{(.*?)}}|([^{}]+)/g,r=[];null!==(t=i.exec(e));)t[1]?r.push({value:t[1],isVariable:!0}):t[2]&&r.push({value:t[2],isVariable:!1});return r}return i(e).filter((function(e){return e.isVariable})).length?U.createElement("div",null,function(){for(var r,a,o,s,u=i(e),l=u.filter((function(e){return e.isVariable})),p={},c=B.getInstance().currentPageType,m=function(e){var i=e.value;if(c===n.PRODUCT){var u=t.pageSpecificData;if(i.includes(w.ATTRIBUTE_VALUE)){var l=i.split(w.ATTRIBUTE_VALUE)[1].split("_")[1],m=u.groupedAttributeValues.find((function(e){return e.attribute.id===l})),f=u.selectedVariant.groupedAttributeValues.find((function(e){return e.attribute.id===l}))||m;f?f.attribute.type===d.CHOICE?p[i]=(null===(r=f.values[0].productAttributeOption)||void 0===r?void 0:r.name)||"":f.attribute.type===d.MULTIPLE_CHOICE?p[i]=f.values.map((function(e){var t;return null===(t=e.productAttributeOption)||void 0===t?void 0:t.name})).join(", ")||"":p[i]=f.values[0].value||"":p[i]=""}else i.includes(w.NAME)?p[i]=u.name:i.includes(w.DESCRIPTION)?p[i]=u.description:i.includes(w.SHORT_DESCRIPTION)?p[i]=u.shortDescription:i.includes(w.CATEGORY_NAME)?p[i]=(null===(a=u.categories[0])||void 0===a?void 0:a.name)||"":i.includes(w.TAG)?p[i]=(null===(o=u.tags)||void 0===o?void 0:o.map((function(e){return e.name})).join(", "))||"":i.includes(E.BARCODE)?p[i]=(null===(s=u.selectedVariant.barcodeList)||void 0===s?void 0:s.length)?u.selectedVariant.barcodeList[0]:"":i.includes(E.SKU)?p[i]=u.selectedVariant.sku:i.includes(E.SELL_PRICE)?p[i]=u.selectedVariant.formattedSellPrice:i.includes(E.DISCOUNT_PRICE)?p[i]=u.selectedVariant.formattedDiscountPrice:i.includes(E.STOCK)?p[i]=u.selectedVariant.stock:p[i]=""}else if(c===n.CATEGORY){var g=t.pageSpecificData;i===O.NAME?p[i]=g.name:i===O.DESCRIPTION?p[i]=g.description:p[i]=""}else if(c===n.BRAND){var v=t.pageSpecificData;i===R.NAME?p[i]=v.name:p[i]=""}else p[i]=""},f=0,g=l;f<g.length;f++){m(g[f])}for(var v="",P=0,V=u;P<V.length;P++){var h=V[P];h.isVariable?v+=p[h.value]:v+=h.value}return v}()):e},M.initBrandPropValue=function(e){return e.brandPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.brand?new o(e.brand):x()},M.initBrandListPropValue=function(e){return new P(e)},M.initCategoryPropValue=function(t){var i,r;return t.categoryPropValue.usePageData&&this.pageSpecificData?((null===(i=t.categoryPropValue.excludedFieldsCategory)||void 0===i?void 0:i.length)&&(this.pageSpecificData.description=null),this.pageSpecificData):t.category?new l(e(e({},t.category),{description:(null===(r=t.categoryPropValue.excludedFieldsCategory)||void 0===r?void 0:r.length)?null:t.category.description})):y()},M.initCategoryListPropValue=function(e){return new V(e)},M.initProductListPropValue=function(t){var i,r,a,o=null===(i=null==t?void 0:t.productListPropValue)||void 0===i?void 0:i.id;if(o){var n=M._productListRegistry.get(o);if(n){if(n.propValue===t)return n.list;(null===(a=null===(r=n.list)||void 0===r?void 0:r.data)||void 0===a?void 0:a.length)&&n.list.data.forEach((function(e){var t;return null===(t=e.dispose)||void 0===t?void 0:t.call(e)}));try{var s=n.propValue;s&&(s.data=null,s.relatedProductData=null,s.recommendedProductData=null,s.viewedTogetherProductData=null,s.purchasedTogetherProductData=null)}catch(e){}}}var u=new j(e(e({},t),{pageSpecificData:this.pageSpecificData}),B.getInstance().router);return o&&M._productListRegistry.set(o,{list:u,propValue:t}),M.trimNextRouterCache(),M.installNextPrefetchCleaner(),u},M.installNextPrefetchCleaner=function(){if("undefined"!=typeof window&&!M._nextPrefetchCleanerInstalled)try{var e=B.getInstance().router;if(!e)return;if(!window.__ikasSdcSweepInterval){window.__ikasSdcSweepInterval=window.setInterval((function(){try{var e=B.getInstance().router;if(!e)return;var t=M.NEXT_SDC_MAX_ENTRIES;if(e.sdc&&"object"==typeof e.sdc){var i=Object.keys(e.sdc);if(i.length>t){var r=e.asPath,a=r&&i.find((function(e){return e.endsWith(r+".json")})),o=i.slice(-t),n=new Set(o);a&&n.add(a);for(var s=0,u=i;s<u.length;s++){var d=u[s];if(!n.has(d))try{delete e.sdc[d]}catch(e){}}var l=e.pageLoader;if(l&&l.prefetched&&"object"==typeof l.prefetched)for(var p=Object.keys(e.sdc),c=Object.keys(l.prefetched),m=function(e){if(!p.some((function(t){return t.includes(e)})))try{delete l.prefetched[e]}catch(e){}},f=0,g=c;f<g.length;f++){m(g[f])}}}}catch(e){}}),500)}e.events&&"function"==typeof e.events.on&&e.events.on("routeChangeComplete",(function(){M.trimNextRouterCache()})),M._nextPrefetchCleanerInstalled=!0}catch(e){}},M.trimNextRouterCache=function(){if("undefined"!=typeof window)try{var e=B.getInstance().router;if(!e)return;var t=e.asPath;if(e.sdc&&"object"==typeof e.sdc){var i=Object.keys(e.sdc),r=M.NEXT_SDC_MAX_ENTRIES,a=t&&i.find((function(e){return e.endsWith(t+".json")})),o=i.slice(-r),n=new Set(o);a&&n.add(a);for(var s=0,u=i;s<u.length;s++){var d=u[s];n.has(d)||delete e.sdc[d]}}var l=e.route;if(e.components&&"object"==typeof e.components)for(var p=Object.keys(e.components),c=0,m=p;c<m.length;c++){if((d=m[c])!==l&&"/_app"!==d){var f=e.components[d];f&&f.props&&f.props.pageProps&&(f.props.pageProps=null)}}var g=e.pageLoader;if(g){if(g.pageCache&&"object"==typeof g.pageCache)for(var v=Object.keys(g.pageCache),P=0,V=v;P<V.length;P++){if((d=V[P])!==l&&"/_app"!==d&&"/_error"!==d)try{delete g.pageCache[d]}catch(e){}}if(g.prefetched&&"object"==typeof g.prefetched&&e.sdc)for(var h=Object.keys(e.sdc),j=Object.keys(g.prefetched),C=function(e){if(!h.some((function(t){return t.includes(e)})))try{delete g.prefetched[e]}catch(e){}},D=0,L=j;D<L.length;D++){C(L[D])}}if("undefined"!=typeof document&&e.sdc){var T=Object.keys(e.sdc);document.querySelectorAll('link[rel="prefetch"][href$=".json"]').forEach((function(e){var t,i=e.href;if(i&&!T.some((function(e){return i.endsWith(e)})))try{null===(t=e.parentNode)||void 0===t||t.removeChild(e)}catch(e){}}))}}catch(e){}},M.initProductPropValue=function(t){var i=new c(I());if(t.productDetailPropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;i=new c(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return i},M._initProductOnBrowser=function(e){var t=new URLSearchParams(window.location.search),i=t.get("vid");if(i){var r=e.variants.find((function(e){return e.id===i}));r&&(e.selectedVariantValues=r.variantValues)}else{var a=e.variantTypes.map((function(e){return e.variantType.slug})),o=[];a.forEach((function(i,r){var a=e.variantTypes[r],n=N(t.get(decodeURIComponent(i))||"");if(n){var s=a.variantType.values.find((function(e){return e.slug===n}));s&&o.push(s)}})),o.length===e.selectedVariantValues.length&&(e.selectedVariantValues=o)}e.setOptionRealPrices()},M.initAttributePropValue=function(t){var i=null;if(t.attributePropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;i=new c(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return new C(i,t.attributePropValue)},M.initAttributeListPropValue=function(t){var r=null;if(t.attributeListPropValue.usePageData&&this.pageSpecificData)r=this.pageSpecificData;else if(t.productDetail){var a=t.productDetail;r=new c(e(e({},a),{selectedVariantValues:a.selectedVariantValues}))}return new i(r,t.attributeListPropValue)},M.initLinkPropValue=function(e){return Array.isArray(e)?e.map((function(e){return new h(e.href,e.label,e.subLinks,e.isExternal||void 0)})):e?new h(e.href,e.label,e.subLinks,e.isExternal||void 0):void 0},M.initImagePropValue=function(e){return new p(e)},M.initImageListPropValue=function(e){return e.map((function(e){return new p(e)}))},M.initCustomDataPropValue=function(e,t,i){if(e&&e.value&&e.customDataId){var r=this.flatCustomDataList.find((function(t){return t.id===e.customDataId}));if(r)return this._initCustomDataPropValue(e,r,t,i)}},M._initCustomDataPropValue=function(e,t,i,r){var a=this;if(!e)return null;var o=e.value;if(null==o)return null;switch(t.type){case u.TEXT:return this.initTextPropValue(o);case u.BRAND:return this.initBrandPropValue(o);case u.BRAND_LIST:return this.initBrandListPropValue(o);case u.CATEGORY_LIST:return this.initCategoryListPropValue(o);case u.CATEGORY:return this.initCategoryPropValue(o);case u.IMAGE_LIST:return this.initImageListPropValue(o);case u.IMAGE:return this.initImagePropValue(o);case u.LINK:return this.initLinkPropValue(o);case u.PRODUCT_DETAIL:return this.initProductPropValue(o);case u.PRODUCT_LIST:return this.initProductListPropValue(o);case u.PRODUCT_ATTRIBUTE:return this.initAttributePropValue(o);case u.PRODUCT_ATTRIBUTE_LIST:return this.initAttributeListPropValue(o);case u.BLOG:return this.initBlogPropValue(o);case u.BLOG_LIST:return this.initBlogListPropValue(o);case u.BLOG_CATEGORY:return this.initBlogCategoryPropValue(o);case u.BLOG_CATEGORY_LIST:return this.initBlogCategoryListPropValue(o);case u.RAFFLE:return this.initRafflePropValue(o);case u.RAFFLE_LIST:return this.initRaffleListPropValue(o);case u.SLIDER:return this.initSliderPropValue(o);case u.VIDEO:return M.initVideoPropValue(o);case u.OBJECT:for(var n={},s=function(e){var t=o[e.key],a=void 0;e.customDataId&&(a=d.flatCustomDataList.find((function(e){return e.id===t.customDataId}))),n[e.key]=d._initCustomDataPropValue(t,a||e,i,r)},d=this,l=0,p=t.nestedData||[];l<p.length;l++){s(p[l])}return n;case u.DYNAMIC_LIST:case u.STATIC_LIST:try{if(!o||!o.length)return null;var c=[],m=t.nestedData[0];return o.forEach((function(e){var t;m.customDataId&&(t=a.flatCustomDataList.find((function(t){return t.id===e.customDataId}))),c.push(a._initCustomDataPropValue(e,t||m,i,r))})),c}catch(e){return[]}case u.COMPONENT:return this.initComponentPropValue(o,i,r);case u.COMPONENT_LIST:return this.initComponentListPropValue(o,i,r);default:return o}},M.initComponentPropValue=function(e,t,i){return this._initComponentPropValue(e,t,i)},M._initComponentPropValue=function(e,i,r){var a=e.length?e[0]:void 0;if(a){var o=new T(a),n=M.initPageComponentPropValue(o,[o.component],i,r);if(n)return new D((function(){return t(n,i,-10)}))}},M.initComponentListPropValue=function(e,t,i){return this._initComponentListPropValue(e,t,i)},M._initComponentListPropValue=function(e,i,r){return e&&e.length?e.map((function(e){var a=new T(e),o=M.initPageComponentPropValue(a,[a.component],i,r);return new D((function(){return t(o,i,-1)}))})):[]},M.initBlogPropValue=function(e){return e.blogPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blog?new a(e.blog):S()},M.initBlogListPropValue=function(e){return new g(e)},M.initBlogCategoryPropValue=function(e){return e.blogCategoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blogCategory?new r(e.blogCategory):b()},M.initBlogCategoryListPropValue=function(e){return new v(e)},M.initRafflePropValue=function(e){return e.rafflePropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.raffle?new m(e.raffle):new m(_())},M.initRaffleListPropValue=function(e){return new L(e)},M.initSliderPropValue=function(e){return e},M.initVideoPropValue=function(t){return e(e({},t),{thumbnailImage:t.thumbnailImage?new p(t.thumbnailImage):null})},M.pageSpecificData={},M.flatCustomDataList=[],M.isBrowser=!1,M._productListRegistry=new Map,M._nextPrefetchCleanerInstalled=!1,M.NEXT_SDC_MAX_ENTRIES=20,M}();export{M as IkasPageDataInit};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "6.1.0-beta.317",
3
+ "version": "6.1.0-beta.318",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -23,11 +23,11 @@
23
23
  "swiper": "11.0.6"
24
24
  },
25
25
  "devDependencies": {
26
- "@ikas/storefront-api": "^6.1.0-beta.317",
27
- "@ikas/storefront-config": "^6.1.0-beta.317",
28
- "@ikas/storefront-model-functions": "^6.1.0-beta.317",
29
- "@ikas/storefront-models": "^6.1.0-beta.317",
30
- "@ikas/storefront-providers": "^6.1.0-beta.317",
26
+ "@ikas/storefront-api": "^6.1.0-beta.318",
27
+ "@ikas/storefront-config": "^6.1.0-beta.318",
28
+ "@ikas/storefront-model-functions": "^6.1.0-beta.318",
29
+ "@ikas/storefront-models": "^6.1.0-beta.318",
30
+ "@ikas/storefront-providers": "^6.1.0-beta.318",
31
31
  "@ikas/localized-address": "1.0.0-beta.6",
32
32
  "@adyen/adyen-web": "^5.57.0",
33
33
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -62,11 +62,11 @@
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@ikas/localized-address": "1.0.0-beta.6",
65
- "@ikas/storefront-api": "^6.1.0-beta.317",
66
- "@ikas/storefront-config": "^6.1.0-beta.317",
67
- "@ikas/storefront-model-functions": "^6.1.0-beta.317",
68
- "@ikas/storefront-models": "^6.1.0-beta.317",
69
- "@ikas/storefront-providers": "^6.1.0-beta.317",
65
+ "@ikas/storefront-api": "^6.1.0-beta.318",
66
+ "@ikas/storefront-config": "^6.1.0-beta.318",
67
+ "@ikas/storefront-model-functions": "^6.1.0-beta.318",
68
+ "@ikas/storefront-models": "^6.1.0-beta.318",
69
+ "@ikas/storefront-providers": "^6.1.0-beta.318",
70
70
  "mobx": "^6.1.3",
71
71
  "mobx-react-lite": "^3.1.5",
72
72
  "next": "12.2.0",