@ikas/storefront 0.2.0-alpha.8 → 0.2.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/[slug]-e484ad76.js +1 -0
- package/build/cjs/analytics.js +1 -1
- package/build/cjs/api.js +1 -1
- package/build/cjs/{base-3f6c0c18.js → base-1fa38f9a.js} +1 -1
- package/build/cjs/{blog-category-list-301760cf.js → blog-category-list-2bc016a2.js} +1 -1
- package/build/cjs/{cart-cdd60c45.js → cart-90632b65.js} +1 -1
- package/build/cjs/components.js +1 -1
- package/build/cjs/{en-39787a68.js → en-a1fa5309.js} +0 -0
- package/build/cjs/{get-9a974b32.js → get-e74270ba.js} +0 -0
- package/build/cjs/{i18n-c9c8631c.js → i18n-23489f2d.js} +1 -1
- package/build/cjs/{index-0102eb01.js → index-4896761a.js} +1 -1
- package/build/cjs/{index-dfb3bc66.js → index-5114bb73.js} +1 -1
- package/build/cjs/{index-c5a4b4b2.js → index-681c2517.js} +1 -1
- package/build/cjs/{index-0e84ec4c.js → index-9a0c47b1.js} +1 -1
- package/build/cjs/{index-6b3fb1e9.js → index-a851ebb1.js} +1 -1
- package/build/cjs/{index-60458497.js → index-a8b07648.js} +1 -1
- package/build/cjs/{index-557eda08.js → index-ad398c13.js} +1 -1
- package/build/cjs/{index-bb1c2b0f.js → index-b8b2616a.js} +1 -1
- package/build/cjs/{index-346e3673.js → index-eceaf256.js} +1 -1
- package/build/cjs/index.js +1 -1
- package/build/cjs/models.js +1 -1
- package/build/cjs/pages/[slug]/index.d.ts +0 -3
- package/build/cjs/pages/[slug]/providers.d.ts +3 -0
- package/build/cjs/pages/index.d.ts +2 -1
- package/build/cjs/pages.js +1 -1
- package/build/cjs/store.js +1 -1
- package/build/cjs/{tr-b58ac020.js → tr-5b03d013.js} +0 -0
- package/build/cjs/utils.js +1 -1
- package/build/esm/[slug]-a90edd15.js +1 -0
- package/build/esm/analytics.js +1 -1
- package/build/esm/api.js +1 -1
- package/build/esm/{base-64b83211.js → base-46969f69.js} +1 -1
- package/build/esm/{blog-category-list-f9bde7de.js → blog-category-list-8bbfffa4.js} +1 -1
- package/build/esm/{cart-a5410bc1.js → cart-f58c6575.js} +1 -1
- package/build/esm/components.js +1 -1
- package/build/esm/{en-61fffa63.js → en-2122556b.js} +0 -0
- package/build/esm/{get-ade3f4d4.js → get-f6594d28.js} +0 -0
- package/build/esm/{i18n-faeafc92.js → i18n-88bbe1a1.js} +1 -1
- package/build/esm/{index-dbaba7ab.js → index-10011dee.js} +1 -1
- package/build/esm/{index-2108fd47.js → index-270f04f4.js} +1 -1
- package/build/esm/{index-9157d480.js → index-b6ebc78e.js} +1 -1
- package/build/esm/{index-413970db.js → index-b8245ce8.js} +1 -1
- package/build/esm/{index-3e13a5d9.js → index-c6779c48.js} +1 -1
- package/build/esm/{index-42f5840b.js → index-d47c16b6.js} +1 -1
- package/build/esm/{index-4adde2ba.js → index-df1da9c5.js} +1 -1
- package/build/esm/{index-7a9b2ec6.js → index-f0720041.js} +1 -1
- package/build/esm/{index-63a08778.js → index-f4c9dbad.js} +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/models.js +1 -1
- package/build/esm/pages/[slug]/index.d.ts +0 -3
- package/build/esm/pages/[slug]/providers.d.ts +3 -0
- package/build/esm/pages/index.d.ts +2 -1
- package/build/esm/pages.js +1 -1
- package/build/esm/store.js +1 -1
- package/build/esm/{tr-8305fadb.js → tr-26d6f603.js} +0 -0
- package/build/esm/utils.js +1 -1
- package/package.json +1 -1
- package/build/cjs/[slug]-256d483b.js +0 -1
- package/build/esm/[slug]-a5af448c.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./get-e74270ba.js"),t=require("react"),r=require("mobx-react-lite"),n=require("./index-a851ebb1.js"),o=require("./index-b8b2616a.js"),s=require("./storefront.js"),i=require("next/router"),a=require("next/dynamic"),c=require("next/error"),u=require("fs"),l=require("next/config"),d=require("./index-681c2517.js");require("mobx");var g=require("./i18n-23489f2d.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p,_=f(a),m=f(c),h=f(u),v=f(l),S=function(e){var t,r;void 0===e&&(e={}),this.id=e.id||"",this.name=e.name||"",this.priceListId=e.priceListId||"",this.stockLocations=(null===(t=e.stockLocations)||void 0===t?void 0:t.map((function(e){return new I(e)})))||[],this.paymentGateways=(null===(r=e.paymentGateways)||void 0===r?void 0:r.map((function(e){return new P(e)})))||[]},I=function(e){this.id=e.id||"",this.order=e.order||0},P=function(e){this.id=e.id||"",this.order=e.order||0},k=function(e){this.id=e.id||"",this.locale=e.locale||"",this.storefrontId=e.storefrontId||"",this.storefrontThemeId=e.storefrontThemeId||"",this.themeJson=e.themeJson?new d.IkasTheme(e.themeJson):new d.IkasTheme,this.privacyPolicy=e.privacyPolicy||null,this.returnPolicy=e.returnPolicy||null,this.termsOfService=e.termsOfService||null},C=function(){function t(){}return t.getStorefront=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r,s,i,a,c;return e.__generator(this,(function(u){switch(u.label){case 0:r=o.src(p||(p=e.__makeTemplateObject(["\n query getStorefront($id: String!) {\n getStorefront(id: $id) {\n createdAt\n emailSettingsId\n fbpId\n gtmId\n id\n localizations {\n createdAt\n id\n isDefault\n locale\n name\n }\n mainStorefrontThemeId\n name\n salesChannelId\n routings {\n countryCodes\n createdAt\n domain\n id\n locale\n path\n priceListId\n updatedAt\n }\n status\n themes {\n createdAt\n id\n isMainTheme\n name\n status\n themeId\n themeVersionId\n updatedAt\n }\n }\n }\n "],["\n query getStorefront($id: String!) {\n getStorefront(id: $id) {\n createdAt\n emailSettingsId\n fbpId\n gtmId\n id\n localizations {\n createdAt\n id\n isDefault\n locale\n name\n }\n mainStorefrontThemeId\n name\n salesChannelId\n routings {\n countryCodes\n createdAt\n domain\n id\n locale\n path\n priceListId\n updatedAt\n }\n status\n themes {\n createdAt\n id\n isMainTheme\n name\n status\n themeId\n themeVersionId\n updatedAt\n }\n }\n }\n "]))),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,o.apollo.getClient().query({query:r,variables:{id:t}})];case 2:return s=u.sent(),i=s.data,(a=s.errors)&&a.length&&console.log(a),i?[2,new n.IkasStorefront(i.getStorefront)]:[3,4];case 3:return c=u.sent(),console.log(c),[3,4];case 4:return[2]}}))}))},t}(),b=function(){function t(){}return t.readLocalTheme=function(){return new Promise((function(e,t){h.default.readFile("./src/theme.json",{flag:"a+"},(function(r,n){if(r)return t(r);var o=n.length?JSON.parse(n.toString()):{};e(new d.IkasTheme(o))}))}))},t.readSettingsFile=function(){return new Promise((function(e){var t=v.default().serverRuntimeConfig.SETTINGS;h.default.readFile(t,{flag:"a+"},(function(t,r){if(t)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(t),e(null);var n=r.length?JSON.parse(r.toString()):{};e(n)}))}))},t.getSettings=function(r){var o=this;return new Promise((function(i){return e.__awaiter(o,void 0,void 0,(function(){var o,a,c,u,l,d,g,f,p,_,m,v,I,P;return e.__generator(this,(function(e){switch(e.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?s.IkasStorefrontConfig.storefrontId?[4,C.getStorefront(s.IkasStorefrontConfig.storefrontId)]:(console.error("Missing storefrontId in the config.json file!"),[2,i(null)]):[3,3];case 1:return(o=e.sent())?(a=o,[4,t.readLocalTheme()]):[2,i(null)];case 2:return c=e.sent(),u=t.createColorScript(c.settings),i({storefront:a,themeLocalization:new k({themeJson:c}),salesChannel:new S({id:a.salesChannelId}),routing:a.routings.length?a.routings.find((function(e){return e.locale===r||e.id===r}))||a.routings[0]:new n.IkasStorefrontRouting({}),favicon:c.settings.favicon,stockPreference:c.settings.stockPreference,storefrontJSScripts:u?[u]:[],domain:"",productBackInStockSettings:{customerLoginRequired:!0},customerReviewSettings:{customerLoginRequired:!0,customerPurchaseRequired:!1}}),[3,5];case 3:return[4,t.readSettingsFile()];case 4:if(!(l=e.sent())||!l.localizationMap)return[2,i(null)];if(d=new n.IkasStorefront(l.storefront),g=new S(l.salesChannel),f=l.localizationMap,p=l.storefrontJSScripts||[],_=l.domain,m=l.productBackInStockSettings?{customerLoginRequired:l.productBackInStockSettings.customerLoginRequired}:null,v=l.customerReviewSettings?{customerLoginRequired:l.customerReviewSettings.customerLoginRequired,customerPurchaseRequired:l.customerReviewSettings.customerPurchaseRequired}:null,I=f[r],P=d.routings.find((function(e){return e.id===r||e.path===r})),!I||!P)return console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,i(null)];h.default.readFile(I,{flag:"a+"},(function(e,r){if(e)return console.error("THEME LOCALZIATION FILE READ ERROR!!!"),console.error(e),i(null);var n=r.length?JSON.parse(r.toString()):{},o=new k(n),s=o.themeJson.settings.favicon,a=o.themeJson.settings.stockPreference;if(o.themeJson.settings){var c=t.createColorScript(o.themeJson.settings);c&&p.push(c)}i({storefront:d,themeLocalization:o,salesChannel:g,routing:P,favicon:s,stockPreference:a,storefrontJSScripts:p,domain:_,productBackInStockSettings:m,customerReviewSettings:v})})),e.label=5;case 5:return[2]}}))}))}))},t.getPageData=function(r,i,a,c,u){var l,d;return e.__awaiter(this,void 0,void 0,(function(){var f,p,_,m,h,S,I,P,k,C,b,y,T,w,E,O,x,R,F,L,A,B,D,z,j,q;return e.__generator(this,(function(J){switch(J.label){case 0:return f="local"===process.env.NEXT_PUBLIC_ENV,p=!f&&u,_=v.default().serverRuntimeConfig,p?[3,7]:(m=r.locale)?[4,t.getSettings(m)]:[2,{props:{},notFound:!0}];case 1:return(h=J.sent())&&h.storefront.mainStorefrontThemeId&&h.storefront.salesChannelId?(S=h.storefront,I=h.themeLocalization,P=h.salesChannel,k=h.routing,C=h.favicon,b=h.stockPreference,y=h.storefrontJSScripts,T=h.domain,w=h.productBackInStockSettings,E=h.customerReviewSettings,s.IkasStorefrontConfig.storefrontId=S.id,s.IkasStorefrontConfig.storefrontRoutingId=k.id,s.IkasStorefrontConfig.storefrontThemeId=S.mainStorefrontThemeId,s.IkasStorefrontConfig.salesChannelId=S.salesChannelId,s.IkasStorefrontConfig.priceListId=k.priceListId||void 0,s.IkasStorefrontConfig.stockLocationIds=null===(l=P.stockLocations)||void 0===l?void 0:l.map((function(e){return e.id})),s.IkasStorefrontConfig.routings=S.routings,s.IkasStorefrontConfig.paymentGateways=P.paymentGateways||[],s.IkasStorefrontConfig.gtmId=S.gtmId||void 0,s.IkasStorefrontConfig.fbpId=S.fbpId||void 0,s.IkasStorefrontConfig.favicon=C||null,s.IkasStorefrontConfig.stockPreference=b||null,s.IkasStorefrontConfig.storefrontJSScripts=y||[],s.IkasStorefrontConfig.domain=T,s.IkasStorefrontConfig.productBackInStockSettings=w,s.IkasStorefrontConfig.customerReviewSettings=E,(O=new n.IkasPageDataProvider(I.themeJson,r.params,a)).possiblePageTypes=c,u?[3,3]:[4,O.getPageData()]):[2,{props:{},notFound:!0}];case 2:if(J.sent(),!O.page)return[2,{props:{},notFound:!0}];J.label=3;case 3:return x=u?O.theme.components.map((function(e){return e.id})):O.page.components.map((function(e){return e.componentId})),R=I.themeJson.components.filter((function(e){return u||x.includes(e.id)})),F=e.__spreadArrays(["common"],R.map((function(e){return e.dir}))),(a===o.IkasThemePageType.CHECKOUT||u)&&F.push("checkout-page"),L=_.nextI18nConf,A=k.locale,[4,new g.I18NFileReader(A,F,f?void 0:L.localePath).read()];case 4:return B=J.sent(),s.IkasStorefrontConfig.translations=B,D={},a!==o.IkasThemePageType.CHECKOUT?[3,6]:(z=null===(d=O.page)||void 0===d?void 0:d.components[0])?[4,o.IkasCheckoutAPI.listCheckoutSettings()]:[3,6];case 5:j=J.sent(),q={buttonBgColor:z.propValues.buttonBgColor,buttonTextColor:z.propValues.buttonTextColor,buttonDisabledBgColor:z.propValues.buttonDisabledBgColor,buttonDisabledTextColor:z.propValues.buttonDisabledTextColor,primaryTextColor:z.propValues.primaryTextColor,secondaryTextColor:z.propValues.secondaryTextColor,primaryBgColor:z.propValues.primaryBgColor,secondaryBgColor:z.propValues.secondaryBgColor,borderColor:z.propValues.borderColor,cardBgColor:z.propValues.cardBgColor,errorColor:z.propValues.errorColor,errorLightColor:z.propValues.errorLightColor,warningColor:z.propValues.warningColor,warningLightColor:z.propValues.warningLightColor,successColor:z.propValues.successColor,successLightColor:z.propValues.successLightColor},D.customizationProps=q,D.returnPolicy=I.returnPolicy,D.privacyPolicy=I.privacyPolicy,D.termsOfService=I.termsOfService,D.checkoutSettingsStr=(null==j?void 0:j.length)?JSON.stringify(j[0]):null,J.label=6;case 6:return i?[2,{props:e.__assign(e.__assign({},O.nextPageData.props),D)}]:[2,{props:e.__assign(e.__assign({},O.nextPageData.props),D),revalidate:60}];case 7:return[2,{props:{}}];case 8:return[2]}}))}))},t.getStaticProps=function(r,n,o,s){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,t.getPageData(r,!1,n,o,s)];case 1:return[2,e.sent()]}}))}))},t.getServerSideProps=function(r,n){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,t.getPageData(r,!0,n)];case 1:return[2,e.sent()]}}))}))},t.createColorScript=function(e){if(e.colors)return"<script>"+e.colors.map((function(e){return'document.documentElement.style.setProperty("'+e.key+'","'+e.color+'");'})).join("\r\n")+"<\/script> \n "},t}(),y=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),T=Object.freeze({__proto__:null,default:y,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.INDEX)];case 1:return[2,e.sent()]}}))}))}}),w=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r,{addOgpMetas:!0,reInitOnBrowser:!0}))})),E=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),O=Object.freeze({__proto__:null,default:E,getStaticPaths:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){var r,n;return e.__generator(this,(function(e){switch(e.label){case 0:return t.locales?[4,Promise.all(t.locales.map((function(e){return b.getSettings(e)})))]:[2,{paths:[],fallback:"blocking"}];case 1:return r=e.sent(),n=[],r.forEach((function(e){var t=e.themeLocalization,r=e.routing;t&&t.themeJson.pages.filter((function(e){return e.type===o.IkasThemePageType.CUSTOM})).forEach((function(e){e.slug&&!n.some((function(t){return t.params.slug===e.slug}))&&("local"===process.env.NEXT_PUBLIC_ENV?n.push({params:{slug:e.slug}}):n.push({params:{slug:e.slug},locale:r.path||r.id}))}))})),[2,{paths:n.map((function(e){return{params:e.params,locale:e.locale}})),fallback:"blocking"}]}}))}))},getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.CUSTOM)];case 1:return[2,e.sent()]}}))}))}}),x=r.observer((function(r){var a=r.merchantSettingsStr,c=r.checkoutSettingsStr,u=r.customizationProps,l=r.configJson,d=e.__rest(r,["merchantSettingsStr","checkoutSettingsStr","customizationProps","configJson"]),g=i.useRouter(),f=t.useState(),p=f[0],_=f[1];s.IkasStorefrontConfig.initWithJson(l);var m=s.IkasStorefrontConfig.store,h=t.useMemo((function(){return c?new o.IkasCheckoutSettings(JSON.parse(c)):new o.IkasCheckoutSettings}),[c]),v=t.useMemo((function(){return a?new o.IkasMerchantSettings(JSON.parse(a)):null}),[a]);t.useEffect((function(){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==u?void 0:u.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==u?void 0:u.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==u?void 0:u.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==u?void 0:u.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==u?void 0:u.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==u?void 0:u.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==u?void 0:u.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==u?void 0:u.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==u?void 0:u.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==u?void 0:u.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==u?void 0:u.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==u?void 0:u.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==u?void 0:u.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==u?void 0:u.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==u?void 0:u.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==u?void 0:u.successLightColor)||"#F6FFED")}),[u]),t.useEffect((function(){m.checkLocalization(),S(),o.initIkasEvents()}),[]);var S=t.useCallback((function(){return e.__awaiter(void 0,void 0,void 0,(function(){var t,r,n;return e.__generator(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("id"))?[4,o.IkasCheckoutAPI.getCheckoutById(r)]:[2,g.replace("/")];case 1:return(n=e.sent())?_(n):g.replace("/"),[2]}}))}))}),[]);return p?t.createElement(n.IkasCheckoutPage,e.__assign({checkout:p,merchantSettings:v,checkoutSettings:h,customizationProps:u},d)):t.createElement(n.FullscreenLoading,null)})),R=Object.freeze({__proto__:null,default:x,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.CHECKOUT)];case 1:return[2,e.sent()]}}))}))}}),F=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),L=Object.freeze({__proto__:null,default:F,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.ACCOUNT)];case 1:return[2,e.sent()]}}))}))}}),A=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),B=Object.freeze({__proto__:null,default:A,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.ADDRESSES)];case 1:return[2,e.sent()]}}))}))}}),D=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r,{addOgpMetas:!0}))})),z=Object.freeze({__proto__:null,default:D,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.ORDERS)];case 1:return[2,e.sent()]}}))}))}}),j=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),q=Object.freeze({__proto__:null,default:j,getServerSideProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getServerSideProps(t,o.IkasThemePageType.ORDER_DETAIL)];case 1:return[2,e.sent()]}}))}))}}),J=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),N=Object.freeze({__proto__:null,default:J,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.LOGIN)];case 1:return[2,e.sent()]}}))}))}}),V=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),M=Object.freeze({__proto__:null,default:V,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.REGISTER)];case 1:return[2,e.sent()]}}))}))}}),G=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),U=Object.freeze({__proto__:null,default:G,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.FORGOT_PASSWORD)];case 1:return[2,e.sent()]}}))}))}}),$=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),H=Object.freeze({__proto__:null,default:$,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.RECOVER_PASSWORD)];case 1:return[2,e.sent()]}}))}))}}),X=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),W=Object.freeze({__proto__:null,default:X,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.CART)];case 1:return[2,e.sent()]}}))}))}}),K=_.default((function(){return Promise.resolve().then((function(){return require("./components.js")})).then((function(e){return e.IkasPageEditor}))}),{ssr:!1}),Y=r.observer((function(e){var r=e.configJson,n=e.components;return r&&s.IkasStorefrontConfig.initWithJson(r),n&&(s.IkasStorefrontConfig.currentPageComponents=n),t.createElement(K,null)})),Z=Object.freeze({__proto__:null,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,void 0,void 0,!0)];case 1:return[2,e.sent()]}}))}))},default:Y}),Q=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r))})),ee=Object.freeze({__proto__:null,default:Q,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.FAVORITE_PRODUCTS)];case 1:return[2,e.sent()]}}))}))}}),te=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r,{addOgpMetas:!0,reInitOnBrowser:!0}))})),re=Object.freeze({__proto__:null,default:te,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.SEARCH)];case 1:return[2,e.sent()]}}))}))}}),ne=Object.freeze({__proto__:null,default:function(r){return r.propValuesStr?t.createElement(n.IkasPage,e.__assign({},r)):t.createElement(m.default,{statusCode:404})},getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){var r;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.NOT_FOUND)];case 1:return(r=e.sent()).notFound?[2,{props:{},revalidate:60}]:[2,r]}}))}))}}),oe=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r,{addOgpMetas:!0}))})),se=Object.freeze({__proto__:null,default:oe,getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,o.IkasThemePageType.BLOG_INDEX)];case 1:return[2,e.sent()]}}))}))}}),ie=r.observer((function(r){return t.createElement(n.IkasPage,e.__assign({},r,{addOgpMetas:!0,reInitOnBrowser:!0}))})),ae=Object.freeze({__proto__:null,default:ie,getStaticPaths:function(){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){return[2,{paths:[],fallback:"blocking"}]}))}))},getStaticProps:function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,void 0,[o.IkasThemePageType.BLOG,o.IkasThemePageType.BLOG_CATEGORY])];case 1:return[2,e.sent()]}}))}))}});exports._404=ne,exports._id_=q,exports._slug_=O,exports._slug_$1=ae,exports.addresses=B,exports.cart=W,exports.checkout=R,exports.editor=Z,exports.favoriteProducts=ee,exports.forgotPassword=U,exports.getStaticPaths=function(){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){return[2,{paths:[],fallback:"blocking"}]}))}))},exports.getStaticProps=function(t){return e.__awaiter(void 0,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,b.getStaticProps(t,void 0,[o.IkasThemePageType.BRAND,o.IkasThemePageType.CATEGORY,o.IkasThemePageType.PRODUCT])];case 1:return[2,e.sent()]}}))}))},exports.home=T,exports.index=w,exports.index$1=L,exports.index$2=z,exports.index$3=se,exports.login=N,exports.recoverPassword=H,exports.register=M,exports.search=re;
|
package/build/cjs/analytics.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-b8b2616a.js"),r=require("./index-5114bb73.js");require("./get-e74270ba.js"),require("./storefront.js"),require("mobx"),require("react"),exports.Analytics=e.Analytics,exports.AnalyticsBody=r.AnalyticsBody,exports.AnalyticsHead=r.AnalyticsHead;
|
package/build/cjs/api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-a8b07648.js"),t=require("./index-9a0c47b1.js"),r=require("./index-b8b2616a.js"),I=require("./index-eceaf256.js"),s=require("./index-ad398c13.js");require("./get-e74270ba.js"),require("./storefront.js"),require("mobx"),exports.IkasBlogAPI=e.IkasBlogAPI,exports.IkasBrandAPI=e.IkasBrandAPI,exports.IkasCategoryAPI=e.IkasCategoryAPI,exports.IkasCityAPI=e.IkasCityAPI,exports.IkasDistrictAPI=e.IkasDistrictAPI,exports.IkasStateAPI=e.IkasStateAPI,exports.IkasCartAPI=t.IkasCartAPI,exports.IkasCheckoutAPI=r.IkasCheckoutAPI,exports.IkasContactFormAPI=r.IkasContactFormAPI,exports.IkasCountryAPI=r.IkasCountryAPI,exports.IkasCustomerAPI=r.IkasCustomerAPI,exports.IkasCustomerReviewAPI=r.IkasCustomerReviewAPI,exports.IkasFavoriteProductAPI=r.IkasFavoriteProductAPI,exports.IkasMerchantAPI=r.IkasMerchantAPI,exports.IkasProductBackInStockReminderAPI=r.IkasProductBackInStockReminderAPI,exports.IkasProductSearchAPI=r.IkasProductSearchAPI,exports.apollo=r.apollo,exports.IkasHTMLMetaDataAPI=I.IkasHTMLMetaDataAPI,exports.IkasProductOptionSetAPI=I.IkasProductOptionSetAPI,exports.IkasProductAttributeAPI=s.IkasProductAttributeAPI,exports.IkasVariantTypeAPI=s.IkasVariantTypeAPI;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var o=require("./get-
|
|
1
|
+
"use strict";var o=require("./get-e74270ba.js"),t=require("mobx"),e=require("./index-b8b2616a.js"),n=require("./cart-90632b65.js"),r=require("./storefront.js");var i=function(o){return(null==o?0:o.length)?e._baseFlatten(o,1):[]};t.configure({enforceActions:"never"});var s=function(){function s(){this.currentPageType=null,this.localeOptions=[],this.showLocaleOptions=!1,this.currentCountryCode=null,this.localeChecked=!1,this.settingsSet=!1,this.customerStore=new e.IkasCustomerStore(this),this.cartStore=new n.IkasCartStore(this),t.makeObservable(this,{currentPageType:t.observable,localeOptions:t.observable,showLocaleOptions:t.observable,currentCountryCode:t.observable})}return s.prototype.checkLocalization=function(){return o.__awaiter(this,void 0,void 0,(function(){var t,n,s,u,a,c,l,d;return o.__generator(this,(function(o){switch(o.label){case 0:return this.localeChecked?[2]:void 0===typeof window?(console.warn("checkLocalization should be called on the client side!"),[2]):[4,e.IkasCountryAPI.getMyCountry()];case 1:return t=o.sent(),n=r.IkasStorefrontConfig.routings.find((function(o){return o.id===r.IkasStorefrontConfig.storefrontRoutingId})),this.currentCountryCode=t,n&&t?(s=!0,u=r.IkasStorefrontConfig.routings.find((function(o){var e;return null===(e=o.countryCodes)||void 0===e?void 0:e.includes(t)})),a=r.IkasStorefrontConfig.routings.find((function(o){var t;return!(null===(t=o.countryCodes)||void 0===t?void 0:t.length)})),u?n.id!==u.id&&(s=!1):a&&n.id!==a.id&&(s=!1),c=i(r.IkasStorefrontConfig.routings.map((function(o){return o.countryCodes||[]}))),[4,e.IkasCountryAPI.listCountries(c)]):[3,3];case 2:l=o.sent(),d=[],r.IkasStorefrontConfig.routings.map((function(o){var n;(null===(n=o.countryCodes)||void 0===n?void 0:n.length)?o.countryCodes.forEach((function(n){var r,i=l.find((function(o){return o.iso2===n}));d.push({id:e.v4(),countryName:(null==i?void 0:i.native)||(null==i?void 0:i.name)||"",routing:o,isRecommended:(null===(r=o.countryCodes)||void 0===r?void 0:r.includes(t))||!1})})):d.push({id:e.v4(),routing:o,isRecommended:!r.IkasStorefrontConfig.routings.some((function(o){var e;return null===(e=o.countryCodes)||void 0===e?void 0:e.includes(t)}))})})),this.localeOptions=e.sortBy_1(d,"countryName"),s||(this.showLocaleOptions=!0),this.localeChecked=!0,o.label=3;case 3:return[2]}}))}))},s.prototype.setLocalization=function(o){o.routing.domain?window.location.replace("https://"+o.routing.domain):window.location.replace(window.location.origin+(o.routing.path?"/"+o.routing.path:""))},s.prototype.setSettings=function(o){this.settingsSet||new e.IkasThemeSettings(JSON.parse(o)).colors.map((function(o){return document.documentElement.style.setProperty(o.key,o.color)}))},s}();exports.IkasBaseStore=s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("mobx"),i=require("./index-
|
|
1
|
+
"use strict";var t=require("mobx"),i=require("./index-681c2517.js");require("./index-b8b2616a.js");var s=function(i){this.email=i.email||"",this.firstName=i.firstName||"",this.lastName=i.lastName||"",this.message=i.message||"",t.makeAutoObservable(this)},a=function(i){this.brandId=null,this.usePageData=null,this.brandId=i.brandId,this.usePageData=i.usePageData,t.makeAutoObservable(this)},e=function(s){this.initialSort=null,this.initialLimit=null,this.brandCount=null,this.brandIds=null,this.brandListType=s.brandListType||i.IkasBrandListType.ALL,this.initialSort=s.initialSort||i.IkasBrandListSortType.A_Z,this.initialLimit=s.initialLimit||20,this.brandCount=s.brandCount,this.brandIds=s.brandIds,t.makeAutoObservable(this)},l=function(s){this.initialSort=null,this.initialLimit=null,this.productCount=null,this.productIds=null,this.usePageFilter=null,this.category=null,this.id=s.id||"",this.productListType=s.productListType||i.IkasProductListType.ALL,this.initialSort=s.initialSort||i.IkasProductListSortType.LAST_ADDED,this.initialLimit=s.initialLimit||20,this.productCount=s.productCount,this.productIds=s.productIds,this.category=s.category,this.usePageFilter=s.usePageFilter,t.makeAutoObservable(this)},o=function(i){this.productId=null,this.variantId=null,this.usePageData=null,this.productId=i.productId,this.variantId=i.variantId,this.usePageData=i.usePageData,t.makeAutoObservable(this)},r=function(i){this.categoryId=null,this.usePageData=null,this.categoryId=i.categoryId,this.usePageData=i.usePageData,t.makeAutoObservable(this)},u=function(s){this.initialSort=null,this.initialLimit=null,this.categoryCount=null,this.categoryIds=null,this.categoryListType=s.categoryListType||i.IkasCategoryListType.ALL,this.initialSort=s.initialSort||i.IkasCategoryListSortType.A_Z,this.initialLimit=s.initialLimit||20,this.categoryCount=s.categoryCount||null,this.categoryIds=s.categoryIds||null,t.makeAutoObservable(this)},n=function(i){this.blogId=null,this.usePageData=null,this.blogId=i.blogId,this.usePageData=i.usePageData,t.makeAutoObservable(this)},h=function(s){this.initialLimit=null,this.blogIds=null,this.usePageFilter=null,this.blogListType=s.blogListType||i.IkasBlogListType.ALL,this.initialLimit=s.initialLimit||20,this.blogIds=s.blogIds,this.categoryId=s.categoryId||null,this.usePageFilter=s.usePageFilter||null,t.makeAutoObservable(this)},g=function(i){this.blogCategoryId=null,this.usePageData=null,this.blogCategoryId=i.blogCategoryId,this.usePageData=i.usePageData,t.makeAutoObservable(this)},d=function(s){this.initialLimit=null,this.blogCategoryIds=null,this.blogCategoryListType=s.blogCategoryListType||i.IkasBlogCategoryListType.ALL,this.initialLimit=s.initialLimit||20,this.blogCategoryIds=s.blogCategoryIds,t.makeAutoObservable(this)};exports.IkasBlogCategoryListPropValue=d,exports.IkasBlogCategoryPropValue=g,exports.IkasBlogListPropValue=h,exports.IkasBlogPropValue=n,exports.IkasBrandListPropValue=e,exports.IkasBrandPropValue=a,exports.IkasCategoryListPropValue=u,exports.IkasCategoryPropValue=r,exports.IkasContactForm=s,exports.IkasProductDetailPropValue=o,exports.IkasProductListPropValue=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("./get-
|
|
1
|
+
"use strict";var t=require("./get-e74270ba.js"),e=require("mobx"),r=require("./storefront.js"),i=require("./index-9a0c47b1.js"),n=require("./index-b8b2616a.js"),o=function(){function o(o){var a=this;this.cart=null,this._checkoutId=null,this._isLoadingCart=!1,this._cartLoadFinished=!1,this.getCart=function(){return t.__awaiter(a,void 0,void 0,(function(){var e,r,n,o,a,s;return t.__generator(this,(function(t){switch(t.label){case 0:if(!this.isBrowser)return[2];t.label=1;case 1:return t.trys.push([1,6,7,8]),this._isLoadingCart=!0,e=null===(a=this.baseStore.customerStore.customer)||void 0===a?void 0:a.id,(r=(null===(s=this.cart)||void 0===s?void 0:s.id)||localStorage.getItem("cartId"))||e?[4,i.IkasCartAPI.getCart(r||void 0)]:[2];case 2:return(n=t.sent())?[4,this.setCart(n)]:[3,4];case 3:return t.sent(),[3,5];case 4:this.removeCart(),t.label=5;case 5:return[3,8];case 6:return o=t.sent(),console.log(o),[3,8];case 7:return this._isLoadingCart=!1,this._cartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(e){return t.__awaiter(a,void 0,void 0,(function(){var r;return t.__generator(this,(function(t){switch(t.label){case 0:return localStorage.setItem("cartId",e.id),this.cart=e,this._checkoutId||(this._checkoutId=localStorage.getItem("checkoutId")||void 0),this._checkoutId?[3,2]:[4,n.IkasCheckoutAPI.getCheckoutId(e.id)];case 1:r=t.sent(),this._checkoutId=r,r&&localStorage.setItem("checkoutId",r),t.label=2;case 2:return[2]}}))}))},this.beforeCartOperationCheck=function(){return t.__awaiter(a,void 0,void 0,(function(){var e;return t.__generator(this,(function(t){switch(t.label){case 0:return e=localStorage.getItem("cartId"),!this.cart||e?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!e?[3,3]:[4,this.getCart()];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},this.addItem=function(e,o,s){return void 0===s&&(s=1),t.__awaiter(a,void 0,void 0,(function(){var a,c,u,d,h,l,f,I,v,g;return t.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return t.sent(),this.cart&&(a=this.cart.items.find((function(t){return t.variant.id===e.id})),a)?[2,this.changeItemQuantity(a,a.quantity+1)]:(c=(null===(I=this.cart)||void 0===I?void 0:I.id)||localStorage.getItem("cartId"),u={cartId:c,customerId:(null===(v=this.cart)||void 0===v?void 0:v.customerId)||(null===(g=this.baseStore.customerStore.customer)||void 0===g?void 0:g.id)||null,item:{id:null,quantity:s,variant:{id:e.id,name:o.name}},priceListId:r.IkasStorefrontConfig.priceListId||null,salesChannelId:r.IkasStorefrontConfig.salesChannelId,storefrontId:r.IkasStorefrontConfig.storefrontId,storefrontRoutingId:r.IkasStorefrontConfig.storefrontRoutingId,storefrontThemeId:r.IkasStorefrontConfig.storefrontThemeId},[4,i.IkasCartAPI.saveItemToCart(u)]);case 2:return(d=t.sent())?[4,this.setCart(d)]:[3,4];case 3:t.sent(),t.label=4;case 4:return this.cart&&(h=this.cart.id+"-"+this.cart.updatedAt,(l=this.cart.items.find((function(t){return t.variant.id})))&&n.Analytics.addToCart(l,s,h,this.cart)),[3,6];case 5:return f=t.sent(),console.log(f),[3,6];case 6:return[2]}}))}))},this.changeItemQuantity=function(e,o){return t.__awaiter(a,void 0,void 0,(function(){var a,s,c,u,d,h,l,f;return t.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return t.sent(),a={cartId:(null===(h=this.cart)||void 0===h?void 0:h.id)||null,customerId:(null===(l=this.cart)||void 0===l?void 0:l.customerId)||(null===(f=this.baseStore.customerStore.customer)||void 0===f?void 0:f.id)||null,item:{id:e.id,quantity:o,variant:{id:e.variant.id,name:e.variant.name}},priceListId:r.IkasStorefrontConfig.priceListId||null,salesChannelId:r.IkasStorefrontConfig.salesChannelId,storefrontId:r.IkasStorefrontConfig.storefrontId,storefrontRoutingId:r.IkasStorefrontConfig.storefrontRoutingId,storefrontThemeId:r.IkasStorefrontConfig.storefrontThemeId},[4,i.IkasCartAPI.saveItemToCart(a)];case 2:return(s=t.sent())?[4,this.setCart(s)]:[3,4];case 3:t.sent(),t.label=4;case 4:return this.removeCardIfEmpty(),this.cart&&(c=this.cart.id+"-"+this.cart.updatedAt,(u=e.quantity)>o?n.Analytics.removeFromCart(e,u-o,this.cart):n.Analytics.addToCart(e,o-u,c,this.cart)),[3,6];case 5:return d=t.sent(),console.log(d),[3,6];case 6:return[2]}}))}))},this.removeItem=function(e){return t.__awaiter(a,void 0,void 0,(function(){return t.__generator(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(e,0)];case 1:return t.sent(),[2]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=a.cart)||void 0===t?void 0:t.itemCount)&&a.removeCart()},this.removeCart=function(){localStorage.removeItem("cartId"),localStorage.removeItem("checkoutId"),a.cart=void 0,a._checkoutId=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.cartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.baseStore=o,e.makeAutoObservable(this)}return Object.defineProperty(o.prototype,"isBrowser",{get:function(){return"undefined"!=typeof localStorage},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"cartLoadFinished",{get:function(){return this._cartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"checkoutId",{get:function(){return this._checkoutId},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"checkoutUrl",{get:function(){if(this._checkoutId)return"/checkout?id="+this._checkoutId+"&step=info"},enumerable:!1,configurable:!0}),o}();exports.CART_LS_KEY="cartId",exports.CHECKOUT_LS_KEY="checkoutId",exports.IkasCartStore=o;
|
package/build/cjs/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-a851ebb1.js"),r=require("./index-4896761a.js");require("mobx"),require("react"),require("mobx-react-lite"),require("next/router"),require("./index-b8b2616a.js"),require("./get-e74270ba.js"),require("./storefront.js"),require("crypto"),require("./i18n-23489f2d.js"),require("fs"),require("path"),require("next/config"),require("./index-a8b07648.js"),require("./index-681c2517.js"),require("./cart-90632b65.js"),require("./index-9a0c47b1.js"),require("next/head"),require("./index-eceaf256.js"),require("next/image"),require("next/link"),exports.IkasPage=e.IkasPage,exports.IkasPageHead=e.IkasPageHead,exports.Image=e.Image,exports.IkasPageEditor=r.IkasPageEditor;
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./get-
|
|
1
|
+
"use strict";var e=require("./get-e74270ba.js"),r=require("fs"),t=require("path"),n=require("next/config"),a=require("./storefront.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=i(r),s=i(t),o=i(n),l=function(){function r(e,r,t){this.locale=e,this.namespaces=r,this.localePath=t}return r.prototype.read=function(){return e.__awaiter(this,void 0,void 0,(function(){var r,t,n,a,i,l,c,f,h,v;return e.__generator(this,(function(e){switch(e.label){case 0:r=o.default().serverRuntimeConfig,t={},n=0,a=this.namespaces,e.label=1;case 1:if(!(n<a.length))return[3,12];i=a[n],e.label=2;case 2:return e.trys.push([2,10,,11]),l=this.localePath?s.default.join(this.localePath,this.locale,i+".json"):s.default.join(r.PROJECT_ROOT,"public","locales",this.locale,i+".json"),u.default.existsSync(l)?[4,this.readLocaleFile(l)]:[3,4];case 3:return c=e.sent(),t[i]=c,[3,9];case 4:return"checkout-page"!==i?[3,9]:(f={},"tr"!==this.locale?[3,6]:[4,Promise.resolve().then((function(){return require("./tr-5b03d013.js")})).then((function(e){return e.tr}))]);case 5:return h=e.sent(),f=h.default,[3,8];case 6:return[4,Promise.resolve().then((function(){return require("./en-a1fa5309.js")})).then((function(e){return e.en}))];case 7:h=e.sent(),f=h.default,e.label=8;case 8:t[i]=f,e.label=9;case 9:return[3,11];case 10:return v=e.sent(),console.error(v),[3,11];case 11:return n++,[3,1];case 12:return[2,t]}}))}))},r.prototype.readLocaleFile=function(r){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){return[2,new Promise((function(e,t){u.default.readFile(r,{flag:"r"},(function(r,n){if(r)return t(r);var a=n.length?JSON.parse(n.toString()):{};e(a)}))}))]}))}))},r}();function c(r,t){var n="common",i="",u=r.split(":");if(u.length>2)return r;2===u.length?(n=u[0],i=u[1]):i=u[0];var s=a.IkasStorefrontConfig.translations[n];if(!s)return r;var o=e.get_1(s,i);if(o){if(t){for(var l="",c=0,h=f(o);c<h.length;c++){var v=h[c];if(v.isVariable){var d=v.value.replace("{{","").replace("}}","").trim();t[d]?l+=t[d]:l+=v.value}else l+=v.value}return l}return o}return r}function f(r){var t=[];if(!r)return t;for(var n=e.findAllIndexes(r,"{{"),a=e.findAllIndexes(r,"}}"),i=n.map((function(e,r){return{start:e,end:a[r]+1}})),u=function(e){return i.some((function(r){return r.start<=e&&r.end>=e}))},s="",o=!1,l=0;l<r.length;l++){var c=r.charAt(l);o?u(l)?s+=c:(t.push({isVariable:!0,value:s}),s=c,o=!1):u(l)?(t.push({isVariable:!1,value:s}),s=c,o=!0):s+=c,l===r.length-1&&t.push({isVariable:o,value:s})}return t}exports.I18NFileReader=l,exports.createTranslationInputData=f,exports.formatMoney=function(e,r){var t="undefined"!=typeof navigator?navigator.languages:"en-GB";return new Intl.NumberFormat(t,{style:"currency",currency:r||"TRY"}).format(e)},exports.useTranslation=function(e){return{t:c}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),n=require("mobx-react-lite"),t=require("next/router"),o=require("./get-9a974b32.js"),i=require("mobx"),a=require("./index-6b3fb1e9.js"),r=require("./index-bb1c2b0f.js"),s=require("./storefront.js"),u=require("./index-c5a4b4b2.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=p(e);function c(e){var n=(void 0===e?{}:e).name;return d.default.createElement("div",{style:m},"Error! Please fill the component ",n," fields")}var l,m={lineHeight:"50px",textAlign:"center",fontSize:"16px",margin:"10px 0",border:"2px solid rgb(255, 0, 0)",backgroundColor:"rgba(255, 0, 0, 0.5)"},g=function(){function e(e){var n=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.locale="en",this.pageParams={},this.queryParams={},this.apiKey=null,this.pageDataProvider=null,this.startMessaging=function(){window.addEventListener("message",n.onMessage,!1),n.sendMessage(l.FRAME_DID_LOAD,"0.0.163-alpha.13")},this.onMessage=function(e){return o.__awaiter(n,void 0,void 0,(function(){var n,t;return o.__generator(this,(function(o){switch(o.label){case 0:switch(n=e.data.type,t=e.data.data,n){case l.UPDATE_FRAME_DATA:return[3,1];case l.UPDATE_PROP_VALUE:return[3,3];case l.UPDATE_PAGE_PARAMS:return[3,5];case l.UPDATE_PAGE_COMPONENT_ORDER:return[3,7];case l.ADD_COMPONENT:return[3,9];case l.DELETE_COMPONENT:return[3,10];case l.UPDATE_COMPONENT:return[3,11];case l.ADD_PAGE_COMPONENT:return[3,12];case l.DELETE_PAGE_COMPONENT:return[3,14];case l.SET_SELECTED_COMPONENT:return[3,15];case l.SET_HOVERED_COMPONENT:return[3,16];case l.SCROLL_TO_COMPONENT:return[3,17];case l.UPDATE_THEME_SETTINGS:return[3,18]}return[3,19];case 1:return[4,this.handleUpdateFrameData(t)];case 2:case 4:case 6:case 8:case 13:return o.sent(),[3,20];case 3:return[4,this.handleUpdatePropValue(t)];case 5:return[4,this.handleUpdatePageParams(t)];case 7:return[4,this.handleUpdatePageComponentOrder(t)];case 9:return this.handleAddNewComponent(t),[3,20];case 10:return this.handleDeleteComponent(t),[3,20];case 11:return this.handleUpdateComponent(t),[3,20];case 12:return[4,this.handleAddNewPageComponent(t)];case 14:return this.handleDeletePageComponent(t),[3,20];case 15:return this.handleSetSelectedComponent(t),[3,20];case 16:return this.handleSetHoveredComponent(t),[3,20];case 17:return this.handleScrollToComponent(t),[3,20];case 18:return this.updateThemeSettings(t),[3,20];case 19:return[3,20];case 20:return[2]}}))}))},this.onClick=function(e){n.sendMessage(l.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){n.sendMessage(l.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){n.sendMessage(l.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.sendMessage=function(e,n){window.parent.postMessage({type:e,data:n},"*")},this.getPagePropValues=function(){return o.__awaiter(n,void 0,void 0,(function(){var e,n,t,s,u=this;return o.__generator(this,(function(o){switch(o.label){case 0:return e=new a.IkasPageDataProvider(this.theme,this.pageParams,null===(n=this.page)||void 0===n?void 0:n.type),((null===(t=this.pageParams)||void 0===t?void 0:t.blogId)||(null===(s=this.pageParams)||void 0===s?void 0:s.blogCategoryId))&&(e.possiblePageTypes=[r.IkasThemePageType.BLOG,r.IkasThemePageType.BLOG_CATEGORY]),this.isLoading=!0,[4,e.getPageData()];case 1:return o.sent(),e.pageSpecificData&&a.IkasPageDataInit.setPageSpecificData(JSON.stringify(e.pageSpecificData),this.page.type,!0),e.pageComponentPropValues=a.IkasPageDataInit.initPropValues(JSON.stringify(e.pageComponentPropValues),this.router,JSON.stringify(this.theme.settings)),i.runInAction((function(){u.pageDataProvider=e,u.isLoading=!1})),[2]}}))}))},this.setComponentRef=function(e,t){n.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var n=e.getBoundingClientRect(),t=n.top,o=n.bottom;return t<window.innerHeight&&o>=0&&o<window.innerHeight&&t>0},this.handleUpdateFrameData=function(e){return o.__awaiter(n,void 0,void 0,(function(){var n,t,i,p=this;return o.__generator(this,(function(o){switch(o.label){case 0:return this.theme=new u.IkasTheme(e.theme),this.page=this.theme.pages.find((function(n){return n.id===e.selectedPage.id})),this.pageParams=e.pageParams,this.queryParams=e.queryParams,this.apiKey=e.apiKey,this.locale=e.locale||"en",this.translations=e.translations||void 0,(n=e.storefront)&&(t=new a.IkasStorefront(n),i=t.routings.find((function(e){return e.locale===p.locale})),s.IkasStorefrontConfig.storefrontId=t.id,s.IkasStorefrontConfig.storefrontRoutingId=null==i?void 0:i.id,t.mainStorefrontThemeId&&(s.IkasStorefrontConfig.storefrontThemeId=t.mainStorefrontThemeId),t.salesChannelId&&(s.IkasStorefrontConfig.salesChannelId=t.salesChannelId),(null==i?void 0:i.priceListId)&&(s.IkasStorefrontConfig.priceListId=i.priceListId),s.IkasStorefrontConfig.routings=t.routings,s.IkasStorefrontConfig.stockPreference=this.theme.settings.stockPreference),this.translations&&(s.IkasStorefrontConfig.translations=this.translations),s.IkasStorefrontConfig.isEditor=!0,r.apollo.createApolloClient(this.apiKey||void 0),window.editorApiKey=e.apiKey,[4,this.getPagePropValues()];case 1:return o.sent(),[2]}}))}))},this.handleUpdatePropValue=function(e){return o.__awaiter(n,void 0,void 0,(function(){var n,t,r,s,p,d,c,l,m=this;return o.__generator(this,(function(o){switch(o.label){case 0:return n=e.propName,t=e.value,(r=null===(c=null===(d=this.selectedComponent)||void 0===d?void 0:d.props)||void 0===c?void 0:c.find((function(e){return e.name===n})))&&this.selectedPageComponent?(s=null===(l=this.pageDataProvider)||void 0===l?void 0:l.pageComponentPropValues.find((function(e){return e.pageComponent.id===m.selectedPageComponentId})),this.selectedPageComponent.propValues[n]=t,this.pageDataProvider?[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,r)]:[2]):[2];case 1:return p=o.sent(),i.runInAction((function(){s&&(s.propValues[n]=p,r.type===u.IkasThemeComponentPropType.CUSTOM?a.IkasPageDataInit.initCustomDataPropValue(r,p,s,m.router,m.theme.settings,!0):r.type===u.IkasThemeComponentPropType.COMPONENT?a.IkasPageDataInit.initComponentPropValue(r,p,s,m.router,m.theme.settings,!0):r.type===u.IkasThemeComponentPropType.COMPONENT_LIST&&a.IkasPageDataInit.initComponentListPropValue(r,p,s,m.router,m.theme.settings,!0))})),[2]}}))}))},this.handleUpdatePageParams=function(e){return o.__awaiter(n,void 0,void 0,(function(){return o.__generator(this,(function(n){switch(n.label){case 0:return this.pageParams=e.pageParams,this.queryParams=e.queryParams,[4,this.getPagePropValues()];case 1:return n.sent(),[2]}}))}))},this.handleUpdatePageComponentOrder=function(e){return o.__awaiter(n,void 0,void 0,(function(){return o.__generator(this,(function(n){return this.specification?this.specification.components=e.pageComponents.map((function(e){return new r.IkasThemePageComponent(e)})):this.page.components=e.pageComponents.map((function(e){return new r.IkasThemePageComponent(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,o=new u.IkasThemeComponent(e.component);null===(t=n.theme)||void 0===t||t.components.push(o)},this.handleDeleteComponent=function(e){var t,o;(null===(t=n.theme)||void 0===t?void 0:t.components)&&(n.theme.components=n.theme.components.filter((function(n){return n.id!==e.componentId})));var i=n.pageComponents.filter((function(n){return n.componentId!==e.componentId}))||[];n.specification&&n.specification.components&&(n.specification.components=i),!n.specification&&(null===(o=n.page)||void 0===o?void 0:o.components)&&(n.page.components=i)},this.handleUpdateComponent=function(e){var t=n.theme.components.findIndex((function(n){return n.id===e.component.id}));-1!==t&&(n.theme.components[t]=new u.IkasThemeComponent(e.component))},this.handleAddNewPageComponent=function(e){return o.__awaiter(n,void 0,void 0,(function(){var n,t,s=this;return o.__generator(this,(function(o){switch(o.label){case 0:return n=new r.IkasThemePageComponent(e.pageComponent),this.pageComponents.some((function(e){return e.id===n.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(n)];case 1:return t=o.sent(),i.runInAction((function(){t.component.props.filter((function(e){return e.type===u.IkasThemeComponentPropType.CUSTOM})).forEach((function(e){a.IkasPageDataInit.initCustomDataPropValue(e,t.propValues[e.name],t,s.router,s.theme.settings,!0)})),s.pageDataProvider.pageComponentPropValues.push(t),s.pageComponents.push(n)})),[2]}}))}))},this.handleDeletePageComponent=function(e){n.specification?n.specification.components=n.pageComponents.filter((function(n){return n.id!==e.pageComponentId})):n.page.components=n.pageComponents.filter((function(n){return n.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){n.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){n.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,o=n.componentRefs[t];o&&(n.isScrolledIntoView(o)||window.scrollTo({top:o.offsetTop,behavior:"smooth"}))},this.updateThemeSettings=function(e){var t=e.settings;n.theme&&(n.theme.settings=new r.IkasThemeSettings(t))},this.router=e,i.makeAutoObservable(this),this.startMessaging()}return Object.defineProperty(e.prototype,"specification",{get:function(){var e,n,t,o,i,a,s=this,u=this.page;return(null==u?void 0:u.type)===r.IkasThemePageType.PRODUCT&&(a=null===(e=u.specifications)||void 0===e?void 0:e.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.productId)}))),(null==u?void 0:u.type)===r.IkasThemePageType.CATEGORY&&(a=null===(n=u.specifications)||void 0===n?void 0:n.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.categoryId)}))),(null==u?void 0:u.type)===r.IkasThemePageType.BRAND&&(a=null===(t=u.specifications)||void 0===t?void 0:t.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.brandId)}))),(null==u?void 0:u.type)===r.IkasThemePageType.BLOG&&(a=null===(o=u.specifications)||void 0===o?void 0:o.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.blogId)}))),(null==u?void 0:u.type)===r.IkasThemePageType.BLOG_CATEGORY&&(a=null===(i=u.specifications)||void 0===i?void 0:i.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.blogCategoryId)}))),a},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(n){return n.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedComponent",{get:function(){var e,n=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var t;return e.id===(null===(t=n.selectedPageComponent)||void 0===t?void 0:t.componentId)}))},enumerable:!1,configurable:!0}),e}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS"}(l||(l={}));var h=n.observer((function(n){var t,u,p,d=n.vm,l=n.pageComponent,m=e.useRef(null),g=s.IkasStorefrontConfig.store,h=s.IkasStorefrontConfig.currentPageComponents;e.useEffect((function(){d.setComponentRef(m.current,l)}),[]),e.useEffect((function(){var e;null===(e=d.theme)||void 0===e||e.settings.colors.map((function(e){return document.documentElement.style.setProperty(e.key,e.color)}))}),[null===(t=d.theme)||void 0===t?void 0:t.settings]);var P=i.computed((function(){return d.pageDataProvider.pageComponentPropValues.find((function(e){return e.pageComponent.id===l.id}))})),v=null===(u=P.get())||void 0===u?void 0:u.propValues;if(!v)return null;if(!h)return console.error("Components for the page not found."),null;var C=h[l.componentId];if((null===(p=d.page)||void 0===p?void 0:p.type)===r.IkasThemePageType.CHECKOUT){C=a.IkasCheckoutPage;var E={checkout:new r.IkasCheckout({cart:new r.IkasCart({items:[new r.IkasOrderLineItem({currencyCode:"₺",finalPrice:100,finalPriceWithQuantity:100,price:100,priceWithQuantity:100,quantity:1})]})}),checkoutSettings:new r.IkasCheckoutSettings,merchantSettings:null,customizationProps:o.__assign({},v),returnPolicy:"",privacyPolicy:"",termsOfService:""};v=E}var T=i.computed((function(){return d.selectedPageComponentId===l.id})),O=i.computed((function(){return d.hoveredPageComponentId===l.id})),_=i.computed((function(){var e;return null===(e=P.get())||void 0===e?void 0:e.component.props.some((function(e){if(e.isRequired){var n=(v||{})[e.name];return null===n||null==n}}))})),I=i.computed((function(){var n;return _.get()?e.createElement(c,null):e.createElement(C,o.__assign({store:g},v,{settings:null===(n=d.theme)||void 0===n?void 0:n.settings,pageSpecificData:a.IkasPageDataInit.pageSpecificData}))}));return e.createElement("div",{ref:m,style:{position:"relative"},onMouseEnter:function(){d.onMouseOver(l.id)},onMouseLeave:function(){d.onMouseLeave(l.id)},onClick:function(){d.onClick(l.id)}},I.get(),(T.get()||O.get())&&e.createElement("div",{style:f}))})),f={position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%",border:"4px solid rgb(0, 161, 255)",zIndex:1e19},P=n.observer((function(){var n,o,i,r=t.useRouter(),s=e.useState((function(){return new g(r)}))[0];if(s.isLoading)return null;var u=null===(n=s.pageComponents)||void 0===n?void 0:n.find((function(e){var n,t;return e.componentId===(null===(t=null===(n=s.theme)||void 0===n?void 0:n.headerComponent)||void 0===t?void 0:t.id)})),p=null===(o=s.pageComponents)||void 0===o?void 0:o.find((function(e){var n,t;return e.componentId===(null===(t=null===(n=s.theme)||void 0===n?void 0:n.footerComponent)||void 0===t?void 0:t.id)})),d=null===(i=s.pageComponents)||void 0===i?void 0:i.filter((function(e){var n,t,o,i;return e.componentId!==(null===(t=null===(n=s.theme)||void 0===n?void 0:n.headerComponent)||void 0===t?void 0:t.id)&&e.componentId!==(null===(i=null===(o=s.theme)||void 0===o?void 0:o.footerComponent)||void 0===i?void 0:i.id)}));return e.createElement(e.Fragment,null,!!s.page&&e.createElement(a.IkasPageHead,{pageType:s.page.type,pageTitle:s.page.pageTitle,pageDescription:s.page.description}),e.createElement("div",{style:v},e.createElement("div",null,!!u&&e.createElement(h,{key:u.id,vm:s,pageComponent:u}),null==d?void 0:d.map((function(n){return e.createElement(h,{key:n.id,vm:s,pageComponent:n})}))),!!p&&e.createElement(h,{key:p.id,vm:s,pageComponent:p})))})),v={minHeight:"100vh",width:"100vw",display:"flex",flexDirection:"column",justifyContent:"space-between"};exports.IkasPageEditor=P;
|
|
1
|
+
"use strict";var e=require("react"),n=require("mobx-react-lite"),t=require("next/router"),o=require("./get-e74270ba.js"),i=require("mobx"),a=require("./index-a851ebb1.js"),r=require("./index-b8b2616a.js"),s=require("./storefront.js"),u=require("./index-681c2517.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=p(e);function c(e){var n=(void 0===e?{}:e).name;return d.default.createElement("div",{style:m},"Error! Please fill the component ",n," fields")}var l,m={lineHeight:"50px",textAlign:"center",fontSize:"16px",margin:"10px 0",border:"2px solid rgb(255, 0, 0)",backgroundColor:"rgba(255, 0, 0, 0.5)"},g=function(){function e(e){var n=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.locale="en",this.pageParams={},this.queryParams={},this.apiKey=null,this.pageDataProvider=null,this.startMessaging=function(){window.addEventListener("message",n.onMessage,!1),n.sendMessage(l.FRAME_DID_LOAD,"0.0.163-alpha.13")},this.onMessage=function(e){return o.__awaiter(n,void 0,void 0,(function(){var n,t;return o.__generator(this,(function(o){switch(o.label){case 0:switch(n=e.data.type,t=e.data.data,n){case l.UPDATE_FRAME_DATA:return[3,1];case l.UPDATE_PROP_VALUE:return[3,3];case l.UPDATE_PAGE_PARAMS:return[3,5];case l.UPDATE_PAGE_COMPONENT_ORDER:return[3,7];case l.ADD_COMPONENT:return[3,9];case l.DELETE_COMPONENT:return[3,10];case l.UPDATE_COMPONENT:return[3,11];case l.ADD_PAGE_COMPONENT:return[3,12];case l.DELETE_PAGE_COMPONENT:return[3,14];case l.SET_SELECTED_COMPONENT:return[3,15];case l.SET_HOVERED_COMPONENT:return[3,16];case l.SCROLL_TO_COMPONENT:return[3,17];case l.UPDATE_THEME_SETTINGS:return[3,18]}return[3,19];case 1:return[4,this.handleUpdateFrameData(t)];case 2:case 4:case 6:case 8:case 13:return o.sent(),[3,20];case 3:return[4,this.handleUpdatePropValue(t)];case 5:return[4,this.handleUpdatePageParams(t)];case 7:return[4,this.handleUpdatePageComponentOrder(t)];case 9:return this.handleAddNewComponent(t),[3,20];case 10:return this.handleDeleteComponent(t),[3,20];case 11:return this.handleUpdateComponent(t),[3,20];case 12:return[4,this.handleAddNewPageComponent(t)];case 14:return this.handleDeletePageComponent(t),[3,20];case 15:return this.handleSetSelectedComponent(t),[3,20];case 16:return this.handleSetHoveredComponent(t),[3,20];case 17:return this.handleScrollToComponent(t),[3,20];case 18:return this.updateThemeSettings(t),[3,20];case 19:return[3,20];case 20:return[2]}}))}))},this.onClick=function(e){n.sendMessage(l.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){n.sendMessage(l.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){n.sendMessage(l.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.sendMessage=function(e,n){window.parent.postMessage({type:e,data:n},"*")},this.getPagePropValues=function(){return o.__awaiter(n,void 0,void 0,(function(){var e,n,t,s,u=this;return o.__generator(this,(function(o){switch(o.label){case 0:return e=new a.IkasPageDataProvider(this.theme,this.pageParams,null===(n=this.page)||void 0===n?void 0:n.type),((null===(t=this.pageParams)||void 0===t?void 0:t.blogId)||(null===(s=this.pageParams)||void 0===s?void 0:s.blogCategoryId))&&(e.possiblePageTypes=[r.IkasThemePageType.BLOG,r.IkasThemePageType.BLOG_CATEGORY]),this.isLoading=!0,[4,e.getPageData()];case 1:return o.sent(),e.pageSpecificData&&a.IkasPageDataInit.setPageSpecificData(JSON.stringify(e.pageSpecificData),this.page.type,!0),e.pageComponentPropValues=a.IkasPageDataInit.initPropValues(JSON.stringify(e.pageComponentPropValues),this.router,JSON.stringify(this.theme.settings)),i.runInAction((function(){u.pageDataProvider=e,u.isLoading=!1})),[2]}}))}))},this.setComponentRef=function(e,t){n.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var n=e.getBoundingClientRect(),t=n.top,o=n.bottom;return t<window.innerHeight&&o>=0&&o<window.innerHeight&&t>0},this.handleUpdateFrameData=function(e){return o.__awaiter(n,void 0,void 0,(function(){var n,t,i,p=this;return o.__generator(this,(function(o){switch(o.label){case 0:return this.theme=new u.IkasTheme(e.theme),this.page=this.theme.pages.find((function(n){return n.id===e.selectedPage.id})),this.pageParams=e.pageParams,this.queryParams=e.queryParams,this.apiKey=e.apiKey,this.locale=e.locale||"en",this.translations=e.translations||void 0,(n=e.storefront)&&(t=new a.IkasStorefront(n),i=t.routings.find((function(e){return e.locale===p.locale})),s.IkasStorefrontConfig.storefrontId=t.id,s.IkasStorefrontConfig.storefrontRoutingId=null==i?void 0:i.id,t.mainStorefrontThemeId&&(s.IkasStorefrontConfig.storefrontThemeId=t.mainStorefrontThemeId),t.salesChannelId&&(s.IkasStorefrontConfig.salesChannelId=t.salesChannelId),(null==i?void 0:i.priceListId)&&(s.IkasStorefrontConfig.priceListId=i.priceListId),s.IkasStorefrontConfig.routings=t.routings,s.IkasStorefrontConfig.stockPreference=this.theme.settings.stockPreference),this.translations&&(s.IkasStorefrontConfig.translations=this.translations),s.IkasStorefrontConfig.isEditor=!0,r.apollo.createApolloClient(this.apiKey||void 0),window.editorApiKey=e.apiKey,[4,this.getPagePropValues()];case 1:return o.sent(),[2]}}))}))},this.handleUpdatePropValue=function(e){return o.__awaiter(n,void 0,void 0,(function(){var n,t,r,s,p,d,c,l,m=this;return o.__generator(this,(function(o){switch(o.label){case 0:return n=e.propName,t=e.value,(r=null===(c=null===(d=this.selectedComponent)||void 0===d?void 0:d.props)||void 0===c?void 0:c.find((function(e){return e.name===n})))&&this.selectedPageComponent?(s=null===(l=this.pageDataProvider)||void 0===l?void 0:l.pageComponentPropValues.find((function(e){return e.pageComponent.id===m.selectedPageComponentId})),this.selectedPageComponent.propValues[n]=t,this.pageDataProvider?[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,r)]:[2]):[2];case 1:return p=o.sent(),i.runInAction((function(){s&&(s.propValues[n]=p,r.type===u.IkasThemeComponentPropType.CUSTOM?a.IkasPageDataInit.initCustomDataPropValue(r,p,s,m.router,m.theme.settings,!0):r.type===u.IkasThemeComponentPropType.COMPONENT?a.IkasPageDataInit.initComponentPropValue(r,p,s,m.router,m.theme.settings,!0):r.type===u.IkasThemeComponentPropType.COMPONENT_LIST&&a.IkasPageDataInit.initComponentListPropValue(r,p,s,m.router,m.theme.settings,!0))})),[2]}}))}))},this.handleUpdatePageParams=function(e){return o.__awaiter(n,void 0,void 0,(function(){return o.__generator(this,(function(n){switch(n.label){case 0:return this.pageParams=e.pageParams,this.queryParams=e.queryParams,[4,this.getPagePropValues()];case 1:return n.sent(),[2]}}))}))},this.handleUpdatePageComponentOrder=function(e){return o.__awaiter(n,void 0,void 0,(function(){return o.__generator(this,(function(n){return this.specification?this.specification.components=e.pageComponents.map((function(e){return new r.IkasThemePageComponent(e)})):this.page.components=e.pageComponents.map((function(e){return new r.IkasThemePageComponent(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,o=new u.IkasThemeComponent(e.component);null===(t=n.theme)||void 0===t||t.components.push(o)},this.handleDeleteComponent=function(e){var t,o;(null===(t=n.theme)||void 0===t?void 0:t.components)&&(n.theme.components=n.theme.components.filter((function(n){return n.id!==e.componentId})));var i=n.pageComponents.filter((function(n){return n.componentId!==e.componentId}))||[];n.specification&&n.specification.components&&(n.specification.components=i),!n.specification&&(null===(o=n.page)||void 0===o?void 0:o.components)&&(n.page.components=i)},this.handleUpdateComponent=function(e){var t=n.theme.components.findIndex((function(n){return n.id===e.component.id}));-1!==t&&(n.theme.components[t]=new u.IkasThemeComponent(e.component))},this.handleAddNewPageComponent=function(e){return o.__awaiter(n,void 0,void 0,(function(){var n,t,s=this;return o.__generator(this,(function(o){switch(o.label){case 0:return n=new r.IkasThemePageComponent(e.pageComponent),this.pageComponents.some((function(e){return e.id===n.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(n)];case 1:return t=o.sent(),i.runInAction((function(){t.component.props.filter((function(e){return e.type===u.IkasThemeComponentPropType.CUSTOM})).forEach((function(e){a.IkasPageDataInit.initCustomDataPropValue(e,t.propValues[e.name],t,s.router,s.theme.settings,!0)})),s.pageDataProvider.pageComponentPropValues.push(t),s.pageComponents.push(n)})),[2]}}))}))},this.handleDeletePageComponent=function(e){n.specification?n.specification.components=n.pageComponents.filter((function(n){return n.id!==e.pageComponentId})):n.page.components=n.pageComponents.filter((function(n){return n.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){n.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){n.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,o=n.componentRefs[t];o&&(n.isScrolledIntoView(o)||window.scrollTo({top:o.offsetTop,behavior:"smooth"}))},this.updateThemeSettings=function(e){var t=e.settings;n.theme&&(n.theme.settings=new r.IkasThemeSettings(t))},this.router=e,i.makeAutoObservable(this),this.startMessaging()}return Object.defineProperty(e.prototype,"specification",{get:function(){var e,n,t,o,i,a,s=this,u=this.page;return(null==u?void 0:u.type)===r.IkasThemePageType.PRODUCT&&(a=null===(e=u.specifications)||void 0===e?void 0:e.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.productId)}))),(null==u?void 0:u.type)===r.IkasThemePageType.CATEGORY&&(a=null===(n=u.specifications)||void 0===n?void 0:n.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.categoryId)}))),(null==u?void 0:u.type)===r.IkasThemePageType.BRAND&&(a=null===(t=u.specifications)||void 0===t?void 0:t.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.brandId)}))),(null==u?void 0:u.type)===r.IkasThemePageType.BLOG&&(a=null===(o=u.specifications)||void 0===o?void 0:o.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.blogId)}))),(null==u?void 0:u.type)===r.IkasThemePageType.BLOG_CATEGORY&&(a=null===(i=u.specifications)||void 0===i?void 0:i.find((function(e){var n;return e.id===(null===(n=s.pageParams)||void 0===n?void 0:n.blogCategoryId)}))),a},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(n){return n.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedComponent",{get:function(){var e,n=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var t;return e.id===(null===(t=n.selectedPageComponent)||void 0===t?void 0:t.componentId)}))},enumerable:!1,configurable:!0}),e}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS"}(l||(l={}));var h=n.observer((function(n){var t,u,p,d=n.vm,l=n.pageComponent,m=e.useRef(null),g=s.IkasStorefrontConfig.store,h=s.IkasStorefrontConfig.currentPageComponents;e.useEffect((function(){d.setComponentRef(m.current,l)}),[]),e.useEffect((function(){var e;null===(e=d.theme)||void 0===e||e.settings.colors.map((function(e){return document.documentElement.style.setProperty(e.key,e.color)}))}),[null===(t=d.theme)||void 0===t?void 0:t.settings]);var P=i.computed((function(){return d.pageDataProvider.pageComponentPropValues.find((function(e){return e.pageComponent.id===l.id}))})),v=null===(u=P.get())||void 0===u?void 0:u.propValues;if(!v)return null;if(!h)return console.error("Components for the page not found."),null;var C=h[l.componentId];if((null===(p=d.page)||void 0===p?void 0:p.type)===r.IkasThemePageType.CHECKOUT){C=a.IkasCheckoutPage;var E={checkout:new r.IkasCheckout({cart:new r.IkasCart({items:[new r.IkasOrderLineItem({currencyCode:"₺",finalPrice:100,finalPriceWithQuantity:100,price:100,priceWithQuantity:100,quantity:1})]})}),checkoutSettings:new r.IkasCheckoutSettings,merchantSettings:null,customizationProps:o.__assign({},v),returnPolicy:"",privacyPolicy:"",termsOfService:""};v=E}var T=i.computed((function(){return d.selectedPageComponentId===l.id})),O=i.computed((function(){return d.hoveredPageComponentId===l.id})),_=i.computed((function(){var e;return null===(e=P.get())||void 0===e?void 0:e.component.props.some((function(e){if(e.isRequired){var n=(v||{})[e.name];return null===n||null==n}}))})),I=i.computed((function(){var n;return _.get()?e.createElement(c,null):e.createElement(C,o.__assign({store:g},v,{settings:null===(n=d.theme)||void 0===n?void 0:n.settings,pageSpecificData:a.IkasPageDataInit.pageSpecificData}))}));return e.createElement("div",{ref:m,style:{position:"relative"},onMouseEnter:function(){d.onMouseOver(l.id)},onMouseLeave:function(){d.onMouseLeave(l.id)},onClick:function(){d.onClick(l.id)}},I.get(),(T.get()||O.get())&&e.createElement("div",{style:f}))})),f={position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%",border:"4px solid rgb(0, 161, 255)",zIndex:1e19},P=n.observer((function(){var n,o,i,r=t.useRouter(),s=e.useState((function(){return new g(r)}))[0];if(s.isLoading)return null;var u=null===(n=s.pageComponents)||void 0===n?void 0:n.find((function(e){var n,t;return e.componentId===(null===(t=null===(n=s.theme)||void 0===n?void 0:n.headerComponent)||void 0===t?void 0:t.id)})),p=null===(o=s.pageComponents)||void 0===o?void 0:o.find((function(e){var n,t;return e.componentId===(null===(t=null===(n=s.theme)||void 0===n?void 0:n.footerComponent)||void 0===t?void 0:t.id)})),d=null===(i=s.pageComponents)||void 0===i?void 0:i.filter((function(e){var n,t,o,i;return e.componentId!==(null===(t=null===(n=s.theme)||void 0===n?void 0:n.headerComponent)||void 0===t?void 0:t.id)&&e.componentId!==(null===(i=null===(o=s.theme)||void 0===o?void 0:o.footerComponent)||void 0===i?void 0:i.id)}));return e.createElement(e.Fragment,null,!!s.page&&e.createElement(a.IkasPageHead,{pageType:s.page.type,pageTitle:s.page.pageTitle,pageDescription:s.page.description}),e.createElement("div",{style:v},e.createElement("div",null,!!u&&e.createElement(h,{key:u.id,vm:s,pageComponent:u}),null==d?void 0:d.map((function(n){return e.createElement(h,{key:n.id,vm:s,pageComponent:n})}))),!!p&&e.createElement(h,{key:p.id,vm:s,pageComponent:p})))})),v={minHeight:"100vh",width:"100vw",display:"flex",flexDirection:"column",justifyContent:"space-between"};exports.IkasPageEditor=P;
|