1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[28],{9910:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{ey:()=>withServerCache});var node_cache__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(45972),node_cache__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(node_cache__WEBPACK_IMPORTED_MODULE_0__),_lib_utils_cache_cache_flags__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(25319),_lib_utils_cache_invalidation_epoch__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(14653),_lib_cache_fs_telemetry__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(18198),process=__webpack_require__(99742),Buffer=__webpack_require__(82909).Buffer;let IS_NODE_RUNTIME=void 0!==process&&!!process.versions?.node,IS_BUILD_PHASE="phase-production-build"===process.env.NEXT_PHASE,nodeRequire=IS_NODE_RUNTIME?eval("require"):void 0,fs=nodeRequire?nodeRequire("fs"):void 0,os=nodeRequire?nodeRequire("os"):void 0,path=nodeRequire?nodeRequire("path"):void 0,crypto=nodeRequire?nodeRequire("crypto"):void 0,DEFAULT_TTL=60,L1_MAX_TTL=300,CLOCK_SAFETY_MS=2e3,parsePositive=(t,e)=>{let r=Number(t);return Number.isFinite(r)&&r>0?r:e},L1_MAX_BYTES=parsePositive(process.env.SSR_CACHE_L1_MAX_BYTES,0x40000000),L2_MAX_BYTES=parsePositive(process.env.SSR_CACHE_MAX_BYTES,0xc80000000),L2_MAX_FILES=parsePositive(process.env.SSR_CACHE_MAX_FILES,3e5),L2_PRUNE_PROBABILITY=.005,L2_PRUNE_MIN_INTERVAL_MS=6e4,FILE_SUFFIX=".json",lastPruneAt=0,resolveCacheDir=()=>{if(!IS_NODE_RUNTIME)return"";if(process.env.SSR_CACHE_DIR)return process.env.SSR_CACHE_DIR;try{if(fs.existsSync("/home/data"))return"/home/data/ssr-cache"}catch{}return path.join(os.tmpdir(),"sarstedt-ssr-cache")},CACHE_DIR=resolveCacheDir(),L1=new(node_cache__WEBPACK_IMPORTED_MODULE_0___default())({stdTTL:L1_MAX_TTL,checkperiod:2*L1_MAX_TTL,useClones:!1}),INFLIGHT=new Map,PENDING_WRITES=new Map,L2_STATS={hits:0,misses:0,writes:0,errors:0,prunes:0},L1_STATS={bytes:0,evictions:0,oversized:0,flushedHits:0,flushedMisses:0},L1_SIZES=new Map,byteLength=t=>IS_NODE_RUNTIME?Buffer.byteLength(t):t.length,isMeasuredSize=t=>"number"==typeof t&&Number.isInteger(t)&&t>=0,forgetL1Size=t=>{let e=L1_SIZES.get(t);void 0!==e&&(L1_SIZES.delete(t),L1_STATS.bytes-=e)},touchL1=t=>{let e=L1_SIZES.get(t);void 0!==e&&(L1_SIZES.delete(t),L1_SIZES.set(t,e))},enforceL1Budget=t=>{for(let e of L1_SIZES.keys()){if(L1_STATS.bytes<=L1_MAX_BYTES)return;e!==t&&(L1.del(e),L1_STATS.evictions++)}},setL1=(t,e,r,a)=>{if(forgetL1Size(t),null===a)return void L1.del(t);if(a>L1_MAX_BYTES){L1.del(t),L1_STATS.oversized++;return}L1.set(t,e,r),L1_SIZES.set(t,a),L1_STATS.bytes+=a,enforceL1Budget(t)};L1.on("del",forgetL1Size),L1.on("expired",forgetL1Size),L1.on("flush",()=>{L1_SIZES.clear(),L1_STATS.bytes=0});let flushL1=()=>{let t=L1.getStats();L1_STATS.flushedHits+=t.hits,L1_STATS.flushedMisses+=t.misses,L1.flushAll()};if(IS_NODE_RUNTIME)try{fs.mkdirSync(CACHE_DIR,{recursive:!0})}catch{}let cloneWithSize=t=>{if(null===t||"object"!=typeof t){let e=JSON.stringify(t);return{snapshot:t,bytes:"string"==typeof e?byteLength(e):0}}try{let e=JSON.stringify(t);return{snapshot:JSON.parse(e),bytes:byteLength(e)}}catch{return{snapshot:t,bytes:null}}},cloneValue=t=>cloneWithSize(t).snapshot,buildKey=t=>t.map(t=>void 0===t?"undefined":null===t?"null":String(t)).join("::"),hashKey=t=>crypto.createHash("sha256").update(t).digest("hex"),dirForHash=t=>path.join(CACHE_DIR,t.slice(0,2)),expiryFromFilename=t=>{if(!t.endsWith(FILE_SUFFIX))return null;let e=t.slice(0,-FILE_SUFFIX.length),r=e.lastIndexOf(".");if(r<0)return null;let a=Number(e.slice(r+1));return Number.isFinite(a)?a:null},buildFilename=(t,e)=>`${t}.${e}${FILE_SUFFIX}`,findCacheFile=async t=>{let e,r=dirForHash(t);try{e=await fs.promises.readdir(r)}catch{return null}let a=null;for(let s of e){if(!s.startsWith(`${t}.`))continue;let e=expiryFromFilename(s);null!==e&&(!a||e>a.expiresAt)&&(a={file:path.join(r,s),expiresAt:e})}return a},ASSET_URL_ID=/(?:images|assets|videos|downloads)\.ctfassets\.net\/[^/"'\s]+\/([^/"'\s]+)\//g,collectAssetIdsFromString=(t,e)=>{if(t.includes("ctfassets.net"))for(let r of t.matchAll(ASSET_URL_ID))r[1]&&e.add(r[1])},extractEntryIds=t=>{let e=new Set;if("string"==typeof t)return collectAssetIdsFromString(t,e),Array.from(e);if(!t||"object"!=typeof t)return[];let r=new WeakSet,a=t=>{if("string"==typeof t)return void collectAssetIdsFromString(t,e);if(!t||"object"!=typeof t||r.has(t))return;if(r.add(t),Array.isArray(t)){for(let e of t)a(e);return}let s=t,i=s.sys;for(let t of(i&&"string"==typeof i.id&&e.add(i.id),"string"==typeof s.pageId&&s.pageId&&e.add(s.pageId),Object.values(s)))("string"==typeof t||t&&"object"==typeof t)&&a(t)};return a(t),Array.from(e)},collectAssetIds=t=>{let e=new Set,r=new WeakSet,a=t=>{if("string"==typeof t)return collectAssetIdsFromString(t,e);if(!t||"object"!=typeof t||r.has(t))return;r.add(t);let s=t,i=s.sys;for(let t of((i?.linkType==="Asset"||i?.type==="Asset")&&"string"==typeof i.id&&e.add(i.id),Object.values(s)))a(t)};return a(t),Array.from(e)},isFreshValue=(t,e,r,a,s)=>{if(Date.now()-t>=1e3*e||(a||s&&!r?.length)&&(0,_lib_utils_cache_invalidation_epoch__WEBPACK_IMPORTED_MODULE_2__.tv)()>t)return!1;if(r?.length){for(let e of r)if((0,_lib_utils_cache_invalidation_epoch__WEBPACK_IMPORTED_MODULE_2__.Kk)(e)>t)return!1}return!0},readFs=async t=>{let e=performance.now();try{return await readFsInner(t)}finally{(0,_lib_cache_fs_telemetry__WEBPACK_IMPORTED_MODULE_3__.aC)("read",e,hashKey(t))}},readFsInner=async t=>{let e=hashKey(t),r=await findCacheFile(e);
1if(!r)return void L2_STATS.misses++;if(r.expiresAt<Date.now()){fs.promises.unlink(r.file).catch(()=>void 0),L2_STATS.misses++;return}try{let t=await fs.promises.readFile(r.file,"utf8"),e=JSON.parse(t);return L2_STATS.hits++,{value:e.value,writtenAt:e.writtenAt??0,bytes:isMeasuredSize(e.bytes)?e.bytes:byteLength(t),entryIds:e.entryIds,tracked:e.tracked}}catch(t){"ENOENT"!==t?.code&&L2_STATS.errors++,L2_STATS.misses++;return}},writeFs=async(t,e,r,a,s,i,n)=>{let o=performance.now(),u=hashKey(t),c=Date.now()+1e3*r,l=dirForHash(u),d=path.join(l,buildFilename(u,c)),p=`${d}.${process.pid}.${crypto.randomBytes(4).toString("hex")}.tmp`,y={key:t,value:e,writtenAt:a};s?.length&&(y.entryIds=s),n&&(y.tracked=!0),isMeasuredSize(i)&&(y.bytes=i);try{await fs.promises.mkdir(l,{recursive:!0}),await fs.promises.writeFile(p,JSON.stringify(y)),await fs.promises.rename(p,d),L2_STATS.writes++,removeStaleSiblings(l,u,d).catch(()=>void 0)}catch{L2_STATS.errors++,fs.promises.unlink(p).catch(()=>void 0)}finally{(0,_lib_cache_fs_telemetry__WEBPACK_IMPORTED_MODULE_3__.aC)("write",o,u)}},trackPendingWrite=(t,e)=>{let r=PENDING_WRITES.get(t)??new Set;r.add(e),PENDING_WRITES.set(t,r),e.finally(()=>{let r=PENDING_WRITES.get(t);r&&(r.delete(e),0===r.size&&PENDING_WRITES.delete(t))})},awaitPendingWrites=async t=>{let e=[];for(let[r,a]of PENDING_WRITES.entries())(!t||t(r))&&e.push(...a);0!==e.length&&await Promise.allSettled(e)},removeStaleSiblings=async(t,e,r)=>{for(let a of(await fs.promises.readdir(t).catch(()=>[]))){if(!a.startsWith(`${e}.`))continue;let s=path.join(t,a);s!==r&&await fs.promises.unlink(s).catch(()=>void 0)}},writeCacheValue=(t,e,r,a,s,i,n)=>{if(!(a?a(e):void 0!==e))return;let{snapshot:o,bytes:u}=cloneWithSize(e),c=(n??Date.now())-CLOCK_SAFETY_MS;setL1(t,{value:o,writtenAt:c,entryIds:s,tracked:i},Math.min(r,L1_MAX_TTL),u);let l=writeFs(t,o,r,c,s,u,i);trackPendingWrite(t,l),l.catch(()=>void 0),maybeSchedulePrune()};async function withServerCache(t,e){if(!IS_NODE_RUNTIME||IS_BUILD_PHASE||t.skip||(0,_lib_utils_cache_cache_flags__WEBPACK_IMPORTED_MODULE_1__.RU)())return e();let r=buildKey(t.key),a=t.ttl??DEFAULT_TTL,s=L1.get(r);if(void 0!==s){if(isFreshValue(s.writtenAt,a,s.entryIds,t.invalidateOnPublish,s.tracked))return touchL1(r),cloneValue(s.value);L1.del(r)}let i=INFLIGHT.get(r);if(i)return cloneValue(await i);let n=(async()=>{await awaitPendingWrites(t=>t===r);let s=await readFs(r);if(void 0!==s&&isFreshValue(s.writtenAt,a,s.entryIds,t.invalidateOnPublish,s.tracked))return setL1(r,{value:s.value,writtenAt:s.writtenAt||Date.now(),entryIds:s.entryIds,tracked:s.tracked},Math.min(a,L1_MAX_TTL),s.bytes),s.value;let i=Date.now(),n=await e(),o=t.entryIdsFrom?t.entryIdsFrom(n).filter(Boolean):t.trackEntryIds?extractEntryIds(n):void 0,u=t.trackEntryIds||!!t.entryIdsFrom;return writeCacheValue(r,n,a,t.shouldCache,o,u,i),n})();INFLIGHT.set(r,n);try{let t=await n;return cloneValue(t)}finally{INFLIGHT.delete(r)}}let walkCacheFiles=async function*(t){let e;try{e=await fs.promises.readdir(t,{withFileTypes:!0})}catch{return}for(let r of e){let e=path.join(t,r.name);r.isDirectory()?yield*walkCacheFiles(e):r.isFile()&&r.name.endsWith(FILE_SUFFIX)&&(yield e)}};async function pruneL2(){if(!IS_NODE_RUNTIME)return{deleted:0,finalBytes:0,finalFiles:0};let t=[];for await(let e of walkCacheFiles(CACHE_DIR))try{let r=await fs.promises.stat(e),a=expiryFromFilename(path.basename(e))??0;t.push({path:e,size:r.size,mtime:r.mtimeMs,expiresAt:a})}catch{}let e=0,r=Date.now(),a=[];for(let s of t)if(s.expiresAt>0&&s.expiresAt<r)try{await fs.promises.unlink(s.path),e++}catch{}else a.push(s);let s=a.reduce((t,e)=>t+e.size,0);if(s>L2_MAX_BYTES||a.length>L2_MAX_FILES)for(a.sort((t,e)=>t.mtime-e.mtime);a.length>L2_MAX_FILES||s>L2_MAX_BYTES;){let t=a.shift();if(!t)break;try{await fs.promises.unlink(t.path),s-=t.size,e++}catch{}}return L2_STATS.prunes++,{deleted:e,finalBytes:s,finalFiles:a.length}}function maybeSchedulePrune(){let t=Date.now();!(t-lastPruneAt<L2_PRUNE_MIN_INTERVAL_MS)&&(Math.random()>L2_PRUNE_PROBABILITY||(lastPruneAt=t,pruneL2().then(t=>{t.deleted}).catch(()=>void 0)))}async function getServerCacheValue(t){if(!IS_NODE_RUNTIME||IS_BUILD_PHASE||(0,_lib_utils_cache_cache_flags__WEBPACK_IMPORTED_MODULE_1__.RU)())return null;let e=buildKey(t.key),r=t.ttl??DEFAULT_TTL,a=L1.get(e);if(void 0!==a)return touchL1(e),{value:cloneValue(a.value),isStale:!isFreshValue(a.writtenAt,r,a.entryIds,t.invalidateOnPublish,a.tracked),writtenAt:a.writtenAt};await awaitPendingWrites(t=>t===e);let s=await readFs(e);return s?(setL1(e,{value:s.value,writtenAt:s.writtenAt||Date.now(),entryIds:s.entryIds,tracked:s.tracked},L1_MAX_TTL,s.bytes),{value:cloneValue(s.value),isStale:!isFreshValue(s.writtenAt,r,s.entryIds,t.invalidateOnPublish,s.tracked),writtenAt:s.writtenAt}):null}async function setServerCacheValue(t,e,r={}){if(!IS_NODE_RUNTIME||IS_BUILD_PHASE||(0,_lib_utils_cache_cache_flags__WEBPACK_IMPORTED_MODULE_1__.RU)())return;let a=buildKey(t),s=r.ttl??DEFAULT_TTL,i=r.trackEntryIds?extractEntryIds(e):void 0;writeCacheValue(a,e,s,r.shouldCache,i,r.trackEntryIds,r.fetchedAt)}async function deleteServerCacheValue(t){let e;if(!IS_NODE_RUNTIME)return;let r=buildKey(t);L1.del(r),INFLIGHT.delete(r),await awaitPendingWrites(t=>t===r);let a=hashKey(r),s=dirForHash(a);try{e=await fs.promises.readdir(s)}catch{return}await Promise.all(e.filter(t=>t.startsWith(`${a}.`)).map(t=>fs.promises.unlink(path.join(s,t)).catch(()=>void 0)))}async function clearServerCacheL1(t){if(!IS_NODE_RUNTIME){let e=L1.keys().filter(e=>e.includes(t));return e.forEach(t=>L1.del(t)),e.length}await awaitPendingWrites(e=>e.includes(t));let e=L1.keys().filter(e=>e.includes(t));return e.forEach(t=>L1.del(t)),INFLIGHT.forEach((e,r)=>{r.includes(t)&&INFLIGHT.delete(r)}),e.length}async function clearServerCache(t){if(!IS_NODE_RUNTIME){flushL1(),INFLIGHT.clear();return}if(!t){await awaitPendingWrites(),flushL1(),INFLIGHT.clear();try{await fs.promises.rm(CACHE_DIR,{recursive:!0,force:!0}),await fs.promises.mkdir(CACHE_DIR,{recursive:!0})}catch{}return}for await(let e of(await awaitPendingWrites(e=>e.includes(t)),L1.keys().filter(e=>
1e.includes(t)).forEach(t=>L1.del(t)),walkCacheFiles(CACHE_DIR)))try{let r=await fs.promises.readFile(e,"utf8"),a=JSON.parse(r);a.key&&a.key.includes(t)&&await fs.promises.unlink(e).catch(()=>void 0)}catch{}}let getServerCacheStats=()=>{let t=L1.getStats();return{l1:{...t,...L1_STATS,hits:L1_STATS.flushedHits+t.hits,misses:L1_STATS.flushedMisses+t.misses,keys:L1.keys().length,maxBytes:L1_MAX_BYTES},l2:{...L2_STATS,dir:CACHE_DIR},inflight:INFLIGHT.size}}},10028:(t,e,r)=>{r.d(e,{c:()=>S});var a=r(61799),s=r(66131),i=r(2791),n=r(20539),o=r(96499),u=r(47497),c=r(27786);function l({paymentMethod:t,purchaseOrderNumber:e,billingCountry:r}){let a=[],s=t?.trim(),i=e?.trim();return s||a.push("paymentMethod"),!i&&(0,c.E)(r,s)&&a.push("purchaseOrderNumber"),a}var d=r(90657),p=r(23904),y=r(9910),h=r(85474),g=r(95536);class f extends Error{constructor(t,e){super(e||t),this.name="RegistrationError",this.code=t}}var m=r(82909).Buffer;function _(t,e){let r={addressGroup:t};return e&&(r.internalNumber=e),{type:{typeId:"type",key:"address-custom-fields"},fields:r}}let E=t=>{let e=t?.masterData;return e?{...t,masterData:{current:e.current,published:e.published,hasStagedChanges:e.hasStagedChanges}}:t},I=t=>t.replace(/[^0-9a-zA-Z._-]/g,""),A=t=>t.map(t=>`"${t.id}"`).join(",");function v(t){let e=t,r=e?.body?.errors;return!!r?.length&&r.some(t=>t?.code==="DuplicateField"&&t?.field==="email")}let T=(...t)=>{if("function"!=typeof globalThis.fetch)throw Error("fetch is not available in current runtime");return globalThis.fetch(...t)};function C(t){let e={host:t.authUrl,projectKey:t.projectKey,scopes:[t.scopes],credentials:{clientId:t.clientId,clientSecret:t.clientSecret},fetch:T},r={host:t.apiUrl,fetch:T};return new i.zN().withClientCredentialsFlow(e).withHttpMiddleware(r).build()}let N=null;class w{constructor(t){let e=C(t);this.api=(0,s.WG)(e).withProjectKey({projectKey:t.projectKey})}async getCustomerByEmail(t){try{let e=t.replace(/["()[\]~!*&$#%^`]/g,"");return(await this.api.customers().get({queryArgs:{where:[`lowercaseEmail = "${e}"`]}}).execute()).body.results.at(0)??null}catch(e){throw a.v.error({error:(0,n.u)(e),email:t},"failed to get customer by email"),e}}async getCartByCustomerId(t){let e=this.api.carts().withCustomerId({customerId:t}).get();try{let{body:t}=await e.execute();return{success:!0,data:t}}catch(e){return a.v.error({error:(0,n.u)(e),customerId:t},"failed to get cart by customer id"),{success:!1,data:null}}}async getActiveCartsByCustomerId({customerId:t,storeKey:e}){try{let r=this.api.inStoreKeyWithStoreKeyValue({storeKey:e}).carts(),s=[`customerId="${t}"`,'cartState="Active"'],i=100,n=0,o=0,u=10,c=0,l=[];do{let{body:t}=await r.get({queryArgs:{where:s,limit:i,offset:n}}).execute();o=t.total??t.results.length,l.push(...t.results),n+=i,c++}while(n<o&&c<u);return a.v.info({customerId:t,storeKey:e,total:o,fetched:l.length},"active carts fetched by customer id"),{success:!0,data:l}}catch(r){return a.v.error({error:(0,n.u)(r),customerId:t,storeKey:e},"failed to get active carts by customer id"),{success:!1,data:null}}}async getCustomer({id:t,storeKey:e}){if(e)try{let{body:r}=await this.api.inStoreKeyWithStoreKeyValue({storeKey:e}).customers().withId({ID:t}).get().execute();return{success:!0,data:r}}catch{}try{let{body:e}=await this.api.customers().withId({ID:t}).get().execute();return{success:!0,data:e}}catch(e){return a.v.error({error:(0,n.u)(e),customerId:t},"failed to get customer"),{success:!1,data:null}}}shoppingListsApi(t){return t?this.api.inStoreKeyWithStoreKeyValue({storeKey:t}).shoppingLists():this.api.shoppingLists()}async createShoppingList({customerId:t,storeKey:e}){let r=this.shoppingListsApi(e).post({body:{name:{en:"shopping list"},customer:{typeId:"customer",id:t}}});try{let{body:t}=await r.execute();return{success:!0,data:t}}catch(r){return a.v.error({error:(0,n.u)(r),customerId:t,storeKey:e},"failed to create shopping list"),{success:!1,data:null}}}async addLineItemToShoppingList(t,e,r,s){let i=this.shoppingListsApi(s).withId({ID:t}).post({body:{version:r,actions:[{action:"addLineItem",sku:e,quantity:1}]}});try{let{body:t}=await i.execute();return{success:!0,data:t}}catch(r){return a.v.error({error:(0,n.u)(r),shoppingListsId:t,variantSKU:e,storeKey:s},"failed to add line item to shopping list"),{success:!1,data:null}}}async removeLineItemFromShoppingList(t,e,r,s){let i=this.shoppingListsApi(s).withId({ID:t}).post({body:{version:r,actions:[{action:"removeLineItem",lineItemId:e}]}});try{let{body:t}=await i.execute();return{success:!0,data:t}}catch(r){return a.v.error({error:(0,n.u)(r),shoppingListsId:t,lineItemId:e,storeKey:s},"failed to remove line item from shopping list"),{success:!1,data:null}}}async getShoppingList(t,e){let r=this.shoppingListsApi(e).get({queryArgs:{where:`customer(id="${t}")`}});try{let{body:a}=await r.execute();if(a.count>0)return{success:!0,data:a.results[0]};return this.createShoppingList({customerId:t,storeKey:e})}catch(r){return a.v.error({error:(0,n.u)(r),customerId:t,storeKey:e},"failed to get shopping list"),{success:!1,data:null}}}async getProducts(t={}){return(0,y.ey)({key:["commercetools","products",JSON.stringify(t)],ttl:60},async()=>{t.limit??=500;let e=this.api.products().get({queryArgs:t});try{let{body:t}=await e.execute();return{success:!0,data:t.results}}catch(t){return a.v.error({error:(0,n.u)(t)},"failed to get products"),{success:!1,data:null}}})}async getProduct(t){let e=this.api.products().withId({ID:t}).get();try{let{body:t}=await e.execute();return{success:!0,data:t}}catch(e){return a.v.error({error:(0,n.u)(e),productId:t},"failed to get product"),{success:!1,data:null}}}async getProductVariantAndSiblings(t,e){let r=await this.getProduct(t);if(!r.success)return r;let a=r.data,s=a.masterData.current.variants.concat(a.masterData.current.masterVariant),i=s.find(t=>t.sku===e),n=s.filter(t=>t!==i);return i?{success:!0,data:{productVariant:i,siblingVariants:n}}:{success:!1,data:null}}async getProductByName(t,e){let r=S.api.products().get({queryArgs:{where:`masterData(current(name(${e}="${t}")))`,limit:1}});try{let{body:t}=await r.execute();if(0===t.count)throw Error("No product found");return{success:!0,data:t.results[0]}}catch{return{success:!1,data:null}}}async getProductBySlug(t,e){try{return(0,y.ey)({key:["commercetools","productBySlug",t,e],ttl:120},async()=>{let r=this.api.products().get({queryArgs:{where:`masterData(current(slug(${e}="${t}")))`,limit:1}});try{let{body:t}=await r.execute();if(0===t.count)throw Error("No product found");return{success:!0,data:E(t.results[0])}}catch{return{success:!1,data:null}}})}catch(r){return a.v.error({error:(0,n.u)(r),slug:t,locale:e},"failed to get product by slug"),{success:!1,data:null}}}async getProductsByIds(t){let e=t.filter(t=>t?.trim());if(!e.length)return{success:!0,data:[]};let r=this.api.products().get({queryArgs:{where:`id in ("${e.join('","')}")`}});try{let{body:t}=await r.execute();return{success:!0,data:t.results}}catch(t){return a.v.error({error:(0,n.u)(t)},"failed to get products by ids"),{success:!1,data:null}}}async isVariantInShop(t,e){if(!e)return a.v.error({},"shop name could not be found in environment variables"),!1;try{let r=Object.entries(p.w).find(([,{sel:t}])=>t===e);if(!r)return!1;let[a]=r;return Object.entries(t.attributes).some(([t,e])=>t===a&&"1"===e)}catch(t){return a.v.error({error:(0,n.u)(t),shopName:e},"failed to check variant in shop"),!1}}async getProductVariant(t,e){let r=await this.getProduct(t);if(!r.success)return r;let a=r.data,s=a.masterData.current.variants.concat(a.masterData.current.masterVariant).find(t=>t.sku===e);return s?{success:!0,data:{productVariant:s}}:{success:!1,data:null}}async getProductsBySKUs(t,e=!0){e&&(t=t.map(I));try{let e=this.api.products().get({queryArgs:{where:'masterData(current(masterVariant(sku in ("'+t.join('","')+'")))) or masterData(current(variants(sku in ("'+t.join('","')+'"))))'}}),{body:r}=await e.execute();return{success:!0,data:r.results}}catch(t){return a.v.error({error:(0,n.u)(t)},"failed to get products by skus"),{success:!1,data:null}}}async getBatchPurchaseUnits(t){if(!t.length)return{};let e=t.map(I);try{let t=e.map(t=>`"${t}"`).join(","),r=`variants.sku:${t}`,{body:a}=await this.api.productProjections().search().get({queryArgs:{filter:[r],staged:!1,limit:500}}).execute(),s={};
1return a.results.forEach(t=>{[t.masterVariant,...t.variants||[]].forEach(t=>{if(t.sku&&e.includes(t.sku)){let e=t.attributes?.find(t=>"purchase_unit"===t.name)?.value;e&&(s[t.sku]=e.toString())}})}),s}catch(t){return a.v.error({error:(0,n.u)(t)},"failed to get batch purchase units"),{}}}async getCachedToken(){let t=Date.now();if(N&&N.expiresAt>t+3e5)return N.token;let e=await fetch(`${o.K.CTP_AUTH_URL}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${m.from(`${o.K.CTP_CLIENT_ID}:${o.K.CTP_CLIENT_SECRET}`).toString("base64")}`},body:`grant_type=client_credentials&scope=${o.K.CTP_SCOPES}`});if(!e.ok)throw Error("Authentication failed");let{access_token:r,expires_in:a}=await e.json();return N={token:r,expiresAt:t+1e3*a},r}async getBatchPurchaseUnitsWithTailoring(t,e,r){if(!t.length)return{};let s=t.map(I);try{let t=s.map(t=>`"${t}"`).join(","),i=`variants.sku:${t}`,{body:u}=await this.api.productProjections().search().get({queryArgs:{filter:[i],staged:!1,limit:500}}).execute(),c=Array.from(new Set(u.results.map(t=>t.id)));if(0===c.length)return r||null;let l={},d={};u.results.forEach(t=>{[t.masterVariant,...t.variants||[]].forEach(e=>{if(e.sku&&s.includes(e.sku)){d[t.id]??={},d[t.id][e.id]=e.sku;let r=e.attributes?.find(t=>"purchase_unit"===t.name)?.value;r&&(l[e.sku]=r.toString())}})});let p=await this.getCachedToken(),y=c.map(async t=>{try{let r=await fetch(`${o.K.CTP_API_URL}/${o.K.CTP_PROJECT_KEY}/in-store/key=${e}/products/${t}/product-tailoring`,{headers:{Authorization:`Bearer ${p}`,"Content-Type":"application/json"}});if(!r.ok){if(404===r.status)return{productId:t,tailoring:null};throw Error(`HTTP ${r.status}`)}return{productId:t,tailoring:await r.json()}}catch(r){return a.v.warn({error:(0,n.u)(r),productId:t,storeKey:e},"failed to fetch product tailoring"),{productId:t,tailoring:null}}}),h=await Promise.all(y),g={...l};return h.forEach(({productId:t,tailoring:e})=>
1{if(!e)return;let r=d[t]??{},a=e.current,s=a?.masterVariant||(a?.variants?.length??0)>0||(a?.attributes?.length??0)>0?a:e.staged||a,i=s?.attributes?.find(t=>"purchase_unit"===t.name)?.value,n=s?.masterVariant?[s.masterVariant]:[],o=s?.variants||[],u=[...n,...o];u.forEach(t=>{let e=r[t.id],a=t.attributes?.find(t=>"purchase_unit"===t.name)?.value??i;e&&a&&(g[e]=a.toString())}),0===u.length&&i&&Object.values(r).forEach(t=>{g[t]=i.toString()})}),r&&s.forEach(t=>{!g[t]&&r[t]&&(g[t]=r[t])}),g}catch(t){return a.v.error({error:(0,n.u)(t),storeKey:e},"failed to get batch purchase units with tailoring"),r||null}}async getPurchaseUnitsForSkus(t,e,r){return await this.getBatchPurchaseUnitsWithTailoring(t,e,r)||{}}async getBatchPlAttributes(t){if(!t.length)return{};let e=t.map(I),r={};try{let t=e.map(t=>`"${t}"`).join(","),a=`variants.sku:${t}`,{body:s}=await this.api.productProjections().search().get({queryArgs:{filter:[a],staged:!1,limit:500}}).execute();return s.results.forEach(t=>{[t.masterVariant,...t.variants||[]].forEach(t=>{if(!t.sku||!e.includes(t.sku))return;let a=t.attributes?.find(t=>"PL_attributes"===t.name)?.value;if(a)try{let e=JSON.parse(a);r[t.sku]={priceUnit:e.priceUnit,tax:e.tax}}catch{r[t.sku]={}}})}),r}catch(t){return a.v.error({error:(0,n.u)(t)},"failed to get batch PL attributes"),r}}async getInventoryEntry(t){let e=this.api.inventory().get({queryArgs:{where:`sku="${t}"`}});try{let{body:t}=await e.execute();return{success:!0,data:{quantityOnStock:t.results[0].quantityOnStock}}}catch(e){return a.v.error({error:(0,n.u)(e),sku:t},"failed to get inventory entry"),{success:!1,data:null}}}async createOrGetGuestCustomer(t,{firstName:e,lastName:r,storeKey:a,country:s}={}){let i=await this.findUser(t);if(i.success)return i.data;let n=await this.createCustomerNumber(),{body:o}=await this.api.customers().post({body:{email:t,authenticationMode:"ExternalAuth",customerNumber:n,firstName:e,lastName:r,stores:a?[{key:a,typeId:"store"}]:[],custom:{type:{key:"customer-custom-fields",typeId:"type"},fields:{preregistered:"Gast",sarstedtTaxExcluded:!1,privacyOpt:!1,country:s??""}}}}).execute();return o.customer}async upgradeGuestCustomer(t,e,r=[]){if(t.externalId)throw new f("EMAIL_ALREADY_EXISTS");let a=0,s=0,i=[e.externalId?{action:"setExternalId",externalId:e.externalId}:{action:"setAuthenticationMode",authMode:"Password",password:e.password},{action:"setCustomType",type:{typeId:"type",key:"customer-custom-fields"},fields:{sarstedtTaxExcluded:!1,country:e.country,privacyOpt:e.privacyOptIn??!1,privacyOpt2:e.privacyOptIn2??!1,preregistered:e.preregistered&&"Gast"!==e.preregistered?e.preregistered:"false",phone:e.phone,invoiceEmail:e.invoiceEmail,invoiceOperatorCode:e.invoiceOperatorCode,organizationLegalForm:e.organizationLegalForm,customerGroup:e.customerGroup,industry:e.industry,registratedCustomerNumber:e.customerNr,membersClubOptIn:e.membersClubOptIn,department:e.department}},{action:"setFirstName",firstName:e.firstName}
1,{action:"setLastName",lastName:e.lastName},{action:"setSalutation",salutation:e.salutation},{action:"setCompanyName",companyName:e.company},{action:"setVatId",vatId:e.taxID||void 0},{action:"addAddress",address:{country:e.country,streetName:e.streetName,additionalStreetInfo:e.additionalStreetInfo,postalCode:e.postalCode,city:e.city,company:e.company,firstName:e.firstName,lastName:e.lastName,salutation:e.salutation,state:e.state,phone:"PL"===e.country&&e.phone||void 0,email:"PL"===e.country&&e.email||void 0}}];for(let t of r)i.push({action:"addStore",store:{key:t,typeId:"store"}});e.billingAddress&&e.handleBillingToggle&&(i.push({action:"addAddress",address:{country:e.billingAddress?.billingcountry,streetName:e.billingAddress?.billingstreetName,additionalStreetInfo:e.billingAddress?.billingadditionalStreetInfo,postalCode:e.billingAddress?.billingpostalCode,city:e.billingAddress?.billingcity,company:e.billingAddress?.billingcompany,firstName:e.billingAddress?.billingfirstName,lastName:e.billingAddress?.billinglastName,salutation:e.salutation,state:e.billingAddress?.billingstate,custom:_("company",e.billingAddress.billinginternalNumber)}}),a=1),e.shippingAddress&&e.handleShippingToggle&&(i.push({action:"addAddress",address:{country:e.shippingAddress?.shippingcountry,streetName:e.shippingAddress?.shippingstreetName,additionalStreetInfo:e.shippingAddress?.shippingadditionalStreetInfo,postalCode:e.shippingAddress?.shippingpostalCode,city:e.shippingAddress?.shippingcity,company:e.shippingAddress?.shippingcompany,firstName:e.shippingAddress?.shippingfirstName,lastName:e.shippingAddress?.shippinglastName,salutation:e.salutation,state:e.shippingAddress?.shippingstate,phone:"PL"===e.country&&e.shippingAddress?.shippingphone||void 0,email:"PL"===e.country&&e.shippingAddress?.shippingemail||void 0,custom:_("company",e.shippingAddress.shippinginternalNumber)}}),s=a+1);let n="PL"===e.country&&!!e.nip,o=await this.updateCustomer(t.id,i);if(!o.data)return;n&&await this.updateCustomer(t.id,[{action:"setCustomType",type:{key:"customer-pl-fields",typeId:"type"},fields:{phone:e.phone,invoiceEmail:e.invoiceEmail,invoiceOperatorCode:e.invoiceOperatorCode,organizationLegalForm:e.organizationLegalForm,customerGroup:e.customerGroup,industry:e.industry,country:e.country,privacyOpt:e.privacyOptIn,privacyOpt2:e.privacyOptIn2,preregistered:e.preregistered,registratedCustomerNumber:e.customerNr,nip:e.nip,vatGroup:e.vatGroup||!1,territorialSelfGovernmentUnit:e.territorialSelfGovernmentUnit||!1}}]);let u=await this.updateCustomer(t.id,[{action:"setDefaultBillingAddress",addressId:o.data.addresses[a].id},{action:"setDefaultShippingAddress",addressId:o.data.addresses[s].id}]);return u.data?u.data:void 0}async createCustomer(t,e,r=[]){let s=await this.findUser(t.email);if(s.success){if(s.data.custom?.fields?.preregistered!=="Gast")throw new f("EMAIL_ALREADY_EXISTS");return this.upgradeGuestCustomer(s.data,t,r)}let i=await this.createCustomerNumber(),n=[],o=0,u=0;n.push({country:t.country,streetName:t.streetName,additionalStreetInfo:t.additionalStreetInfo,postalCode:t.postalCode,city:t.city,company:t.company,firstName:t.firstName,lastName:t.lastName,salutation:t.salutation,state:t.state,phone:"PL"===t.country&&t.phone||void 0,email:"PL"===t.country&&t.email||void 0}),t.billingAddress&&t.handleBillingToggle&&(n.push({country:t.billingAddress.billingcountry,streetName:t.billingAddress.billingstreetName,additionalStreetInfo:t.billingAddress.billingadditionalStreetInfo,postalCode:t.billingAddress.billingpostalCode,city:t.billingAddress.billingcity,company:t.billingAddress.billingcompany,firstName:t.billingAddress.billingfirstName,lastName:t.billingAddress.billinglastName,state:t.billingAddress.billingstate,custom:_("company",t.billingAddress.billinginternalNumber)}),o=1),t.shippingAddress&&t.handleShippingToggle&&(n.push({country:t.shippingAddress.shippingcountry,streetName:t.shippingAddress.shippingstreetName,additionalStreetInfo:t.shippingAddress.shippingadditionalStreetInfo,postalCode:t.shippingAddress.shippingpostalCode,city:t.shippingAddress.shippingcity,company:t.shippingAddress.shippingcompany,firstName:t.shippingAddress.shippingfirstName,lastName:t.shippingAddress.shippinglastName,state:t.shippingAddress.shippingstate,phone:"PL"===t.country&&t.shippingAddress.shippingphone||void 0,email:"PL"===t.country&&t.shippingAddress.shippingemail||void 0,custom:_("company",t.shippingAddress.shippinginternalNumber)}),u=o+1);let c="PL"===t.country&&!!t.nip,l={registratedCustomerNumber:t.customerNr,country:t.country,privacyOpt:t.privacyOptIn,privacyOpt2:t.privacyOptIn2,membersClubOptIn:t.membersClubOptIn,preregistered:t.preregistered,phone:t.phone,invoiceEmail:t.invoiceEmail,invoiceOperatorCode:t.invoiceOperatorCode,organizationLegalForm:t.organizationLegalForm,customerGroup:t.customerGroup,industry:t.industry,department:t.department,sarstedtTaxExcluded:!1,priceChannelReference:{typeId:"channel",id:e}},d=c?{...l,nip:t.nip,vatGroup:t.vatGroup||!1,territorialSelfGovernmentUnit:t.territorialSelfGovernmentUnit||!1}:l;try{let{body:e}=await this.api.customers().post({body:{email:t.email,salutation:t.salutation,firstName:t.firstName,lastName:t.lastName,companyName:t.company,authenticationMode:t.externalId?"ExternalAuth":"Password",externalId:t.externalId||void 0,password:t.externalId?void 0:t.password,addresses:n,defaultBillingAddress:o,defaultShippingAddress:u,customerNumber:i,vatId:t.taxID||void 0,stores:r.map(t=>({key:t,typeId:"store"})),custom:{type:{key:c?"customer-pl-fields":"customer-custom-fields",typeId:"type"},fields:d}}}).execute();return a.v.info({customerId:e.customer.id,email:t.email},"customer created"),e.customer}catch(t){if(v(t))throw new f("EMAIL_ALREADY_EXISTS");throw t}}async findUser(t){try{let e,r;if(-1==t.indexOf("@"))try{e=await this.api.customers().withId({ID:t}).get().execute()}catch(t){}if(e?.statusCode===200)return{success:!0,data:e.body};{let e=await this.api.customers().get({queryArgs:{where:`email="${t}"`}}).execute();if(e.body?.count===1)return r=e.body.results[0],{success:!0,data:r};return a.v.error({idOrEmail:t},"customer not found or not unique"),{success:!1,data:null}}}catch(e){return a.v.error({error:(0,n.u)(e),idOrEmail:t},"failed to find user"),{success:!1,data:null}}}async deleteCustomer(t,e=!1){try{let r=(await this.findUser(t)).data;if(!r)return a.v.error({customerId:t},"no commercetools customer found for cleanup"),{success:!1,data:null};let s=this.api.customers().withId({ID:r.id}).delete({queryArgs:{version:r.version,dataErasure:e}}),{body:i}=await s.execute();return{success:!0,data:i}}catch(e){return a.v.error({error:(0,n.u)(e),customerId:t},"failed to delete customer"),{success:!1,data:null}}}async getCart(t,e){let r=this.api.inStoreKeyWithStoreKeyValue({storeKey:e}).carts().withId({ID:t}).get({queryArgs:{expand:["discountCodes[*].discountCode"]}});try{let{body:s}=await r.execute();if(!s)return a.v.error({cartId:t,storeKey:e},"get cart returned null body"),{success:!1,data:null};return{success:!0,data:s}}catch(r){return a.v.error({error:(0,n.u)(r),cartId:t,storeKey:e},"failed to get cart"),{success:!1,data:null}}}async getCategories(){try{let t=(await this.api.categories().get({queryArgs:{limit:200}}).execute()).body;if(!t?.results.length)throw Error("No results found");return{success:!0,data:t.results}}catch(t){return a.v.error({error:(0,n.u)(t)},"failed to get categories"),{success:!1,data:null}}}async getCategoryByKey(t){try{let e=(await this.api.categories().get({queryArgs:{where:`key = "${t}"`,expand:"ancestors[*]"}}).execute()).body;if(!e?.results.length)throw Error(`No results found for ${t}`);return{success:!0,data:e.results[0]}}catch(e){return a.v.error({error:(0,n.u)(e),categoryKey:t},"failed to get category by key"),{success:!1,data:null}}}async getCategoryById({id:t}){try{return this.api.categories().withId({ID:t}).get({queryArgs:{expand:"ancestors[*]"}}).execute()}catch(e){return a.v.error({error:(0,n.u)(e),categoryId:t},"failed to get category by id"),{body:null}}}async getCategoryBySlug(t,e){let r=this.api.categories().get({queryArgs:{where:`slug(${e}="${t}")`,limit:1,expand:"ancestors[*]"}});try{let{body:t}=await r.execute();if(0===t.count)throw Error("No category found");return{success:!0,data:t.results[0]}}catch{return{success:!1,data:null}}}async getAvailableIdsFromSelection(t,e){try{let{body:r}=await this.api.productSelections().withKey({key:e}).products().get({queryArgs:{where:`product(id in ("${t.join('","')}"))`,limit:500,expand:["product"]}}).execute(),[a]=Object.entries(p.w).find(([,{sel:t}])=>t===e)||[];return{productIDs:r.results.map(t=>t.product.id)||[],variantSelectionSKUs:r.results.flatMap(t=>t.variantSelection?.type==="includeOnly"?t.variantSelection.skus.filter(e=>{let r=t.product.obj?.masterData.current.variants.find(t=>t.sku===e)?.attributes;return r?.some(t=>t.name===a&&"1"===t.value)}):[]).filter(t=>void 0!==t),variantExclusionSKUs:r.results.flatMap(t=>t.product.obj?.masterData.current.variants?t.product.obj?.masterData.current.variants.concat(t.product.obj.masterData.current.masterVariant).filter(t=>{let e=(0,g.x2)(t,"en-GB")||{};return"1"!==e[a||""]}).map(t=>t.sku):[]).filter(t=>void 0!==t)}}catch(t){return a.v.error({error:(0,n.u)(t),shopName:e},"failed to get available ids from selection"),{productIDs:[],variantExclusionSKUs:[],variantSelectionSKUs:[]}}}async getCategoryBySlugWithProducts(t,e){let r=await this.getCategoryBySlug(t,e);if(!r.success)return{category:null,products:[]};let a=await this.api.productProjections().get({queryArgs:{limit:500,where:`categories(id="${r.data?.id}")`}}).execute();return{category:r.data,products:a.body.results}}async getCategoryByKeyWithProducts(t){try{let e=await this.getCategoryByKey(t);if(!e.success)return{category:null,products:[]};let r=await this.api.productProjections().get({queryArgs:{limit:500,where:`categories(id="${e.data?.id}")`}}).execute();return{category:e.data,products:r.body.results}}catch(e){return a.v.error({error:(0,n.u)(e),key:t},"failed to get category by key with products"),{category:null,products:[]}}}async createCart(t){let e=this.api.inStoreKeyWithStoreKeyValue({storeKey:t.storeKey}).carts();try{let{body:r}=await e.post({body:t.cart}).execute();return a.v.info({cartId:r.id,storeKey:t.storeKey},"cart created"),{success:!0,data:r}}catch(e){return a.v.error({error:(0,n.u)(e),storeKey:t.storeKey},"failed to create cart"),{success:!1,data:null}}}async updateCart(t){let e=this.api.inStoreKeyWithStoreKeyValue({storeKey:t.storeKey}).carts(),r=async r=>{let a=Array.isArray(t.actions)?t.actions:await t.actions(r),{body:s}=await e.withId({ID:r.id}).post({body:{version:r.version,actions:a}}).execute();return s};try{let{success:e,data:s}=await this.getCart(t.cartId,t.storeKey);if(!e||!s)return a.v.error({cartId:t.cartId,storeKey:t.storeKey},"update cart failed: could not fetch cart"),{success:!1,data:null};let i=await r(s);return a.v.info({cartId:i.id,storeKey:t.storeKey},"cart updated"),{success:!0,data:i}}catch(s){let e=s;if(e?.statusCode===409&&t.retryOn409){let{success:e,data:s}=await this.getCart(t.cartId,t.storeKey);if(e&&s)try{let e=await r(s);return a.v.info({cartId:e.id,storeKey:t.storeKey},"cart updated after version conflict retry"),{success:!0,data:e}}catch(r){let e=r;return a.v.error({error:(0,n.u)(r),cartId:t.cartId,storeKey:t.storeKey},"failed to update cart after version conflict retry"),{success:!1,data:null,error:e}}}return a.v.error({error:(0,n.u)(s),cartId:t.cartId,storeKey:t.storeKey,statusCode:e?.statusCode},"failed to update cart"),{success:!1,data:null,error:e}}}async updateCartDirect(t){let e=this.api.inStoreKeyWithStoreKeyValue({storeKey:t.storeKey}).carts();try{if(!t.cart)throw Error("cart is missing");let{body:r}=await e.withId({ID:t.cart.id}).post({body:{version:t.cart.version,actions:t.actions}}).execute();return{success:!0,data:r}}catch(e){return a.v.error({error:(0,n.u)(e),cartId:t.cart?.id,storeKey:t.storeKey},"failed to update cart directly"),{success:!1,data:null}}}async getOrder(t){let e=this.api.orders().withOrderNumber({orderNumber:t}).get();try{let{body:t}=await e.execute();return{success:!0,data:t}}catch(e){return a.v.error({error:(0,n.u)(e),orderNumber:t},"failed to get order"),{success:!1,data:null}}}async createOrder(t){let e=null;try{if(!t.cart)throw Error("Could not create Order. No Cart found");let r=await this.createOrderNumber(t.cart.customerId||""),s=e=>{let a=e.shippingAddress?.country,s=e.custom?.fields?.sarstedtCustomerNumber?(0,u.eL)(e.custom.fields.sarstedtCustomerNumber,a):void 0,i=e.custom?.fields?.isShippingCostExempt,n=(0,d.rD)({preregistered:t.preregistered,sarstedtCustomerNumber:s});return{cart:{id:e.id,typeId:"cart"},version:e.version,orderNumber:r,paymentState:t.paymentState,custom:t.carrierCode||t.customerGroup||t.preregistered||s||i||t.gclid||t.gbraid||t.wbraid?{type:{typeId:"type",key:"order-custom-fields"},fields:{...t.carrierCode&&{carrierCode:t.carrierCode},...t.customerGroup&&{customerGroup:t.customerGroup},customerStatus:n,...s&&{sarstedtCustomerNumber:s},...i&&{isShippingCostExempt:i},variantSKU:e.custom?.fields?.variantSKU,transactionId:t.stripePaymentId,...e.custom?.fields?.paymentMethod&&{paymentMethod:e.custom.fields.paymentMethod},...e.custom?.fields?.purchaseOrderNumber&&{purchaseOrderNumber:e.custom.fields.purchaseOrderNumber},...e.custom?.fields?.industry&&{industry:e.custom.fields.industry},...t.gclid&&{gclid:t.gclid},...t.gbraid&&{gbraid:t.gbraid},...t.wbraid&&{wbraid:t.wbraid},...t.clickIdCapturedAt&&{clickIdCapturedAt:t.clickIdCapturedAt}}}:void 0}};e=async e=>{if(l({paymentMethod:e.custom?.fields?.paymentMethod,purchaseOrderNumber:e.custom?.fields?.purchaseOrderNumber,billingCountry:e.billingAddress?.country}).length>0)throw{code:"ORDER_FIELDS_MISSING",message:"Cart is missing required fields for order creation"};let r=this.api.inStoreKeyWithStoreKeyValue({storeKey:t.storeKey}).orders().post({body:s(e)}),{body:a}=await r.execute();return a};let i=await e(t.cart);return a.v.info({orderId:i.id,orderNumber:i.orderNumber,cartId:t.cart.id,storeKey:t.storeKey},"order created"),{success:!0,data:i}}catch(s){let r=s;if(r?.statusCode===409&&t.cart?.id&&e){let{success:r,data:s}=await this.getCart(t.cart.id,t.storeKey);if(r&&s)try{let r=await e(s);return a.v.info({orderId:r.id,orderNumber:r.orderNumber,cartId:t.cart.id,storeKey:t.storeKey},"order created after version conflict retry"),{success:!0,data:r}}catch(r){let e=r;return a.v.error({error:(0,n.u)(r),cartId:t.cart.id,storeKey:t.storeKey},"failed to create order after version conflict retry"),{success:!1,data:null,error:e}}}return a.v.error({error:(0,n.u)(s),cartId:t.cart?.id,storeKey:t.storeKey,statusCode:r?.statusCode},"failed to create order"),{success:!1,data:null,error:r}}}async createCustomerNumber(){let{body:t}=await this.api.customObjects().post({body:{container:"global-config",key:"customer-number-generator",value:{updated:new Date().toISOString()}}}).execute(),e=new Date;return`WS-${e.getFullYear()}-${t.version}`}generateRandomId(t){return t<=0?"":Math.random().toString(36).substring(2,2+t).padEnd(t,"0")}async createOrderNumber(t){let e=await this.getNextOrderCounter(),r=new Date,a=(r.getFullYear()%100).toString().padStart(2,"0"),s=(r.getMonth()+1).toString().padStart(2,"0"),i=16,n=6,o=e.toString(),u=i-n-o.length-1,c="";return(u>0&&(c=t&&""!==t.trim()?t.slice(-u):this.generateRandomId(u)),c)?`${a}-${s}-${o}-${c}`:`${a}-${s}-${o}`}async getNextOrderCounter(){let t=this.api.customObjects().post({body:{container:"global-config",key:"order-number-generator",value:{updated:new Date().toISOString()}}}).execute();return(await t).body.version}async getProductProjectionById(t){let e=(await this.api.productProjections().withId({ID:t}).get().execute()).body,r=null;if(e){let t=e.categories[0].id,a=(await this.api.categories().get({queryArgs:{where:`id = "${t}"`}}).execute()).body;a.results.length&&(r=a.results[0])}return{product:e,category:r}}async getCustomerOrders(t){let{body:e}=await this.api.orders().get({queryArgs:{where:`customerId="${t}"`,limit:100,sort:"createdAt desc"}}).execute();return e.results}async parseAlgoliaProductVariants(t,e){try{let a=await Promise.all(t.map(t=>this.api.productProjections().get({queryArgs:{where:` 2 masterVariant(sku="${t}") 3 or 4 variants(sku="${t}") 5 `}}).execute().then(e=>{let r=e.body.results[0],a=r?.v
5ariants.concat(r.masterVariant);return[r?.id,r,a?.find(e=>e.sku===t)]}))),{unpackVariantDataset:s}=await Promise.resolve().then(r.bind(r,72983));return a.reduce((t,[r,a,i])=>{if(!i)return t;let n="";n=e&&a.slug?.[e]?a.slug[e]:a.slug?.["en-GB"]||a.slug?.["en-US"]||a.slug?.["de-DE"]||a.slug?.[Object.keys(a.slug||{})[0]]||"";let o=s(e||"en-GB",i);return[...t,{...o,productId:r,slug:n}]},[])}catch(t){return a.v.error({error:(0,n.u)(t)},"failed to parse algolia product variants"),[]}}async updateCustomer(t,e){let r=this.api.customers();try{let{success:s,data:i}=await this.getCustomer({id:t});if(!s)return{success:!1,data:null};let{body:n}=await r.withId({ID:i.id}).post({body:{version:i.version,actions:e}}).execute();return a.v.info({customerId:t},"customer updated"),{success:!0,data:n}}catch(e){return a.v.error({error:(0,n.u)(e),customerId:t},"failed to update customer"),{success:!1,data:null}}}async updateCustomerLastLogin(t,e){let r=t.custom?.type?.id;if(!r)return{success:!1,data:null};let s=t.custom?.fields??{},i={...s,sarstedtTaxExcluded:s.sarstedtTaxExcluded??!1,privacyOpt:s.privacyOpt??!1,country:s.country||e||t.addresses?.[0]?.country||"",lastLogin:new Date().toISOString()};try{let{body:e}=await this.api.customers().withId({ID:t.id}).post({body:{version:t.version,actions:[{action:"setCustomType",type:{typeId:"type",id:r},fields:i}]}}).execute();return{success:!0,data:e}}catch(e){return a.v.error({error:(0,n.u)(e),customerId:t.id},"failed to update lastLogin"),{success:!1,data:null}}}async addAddress(t,e,r,a){let s=await this.updateCustomer(t,[{action:"addAddress",address:e}]);if(!s.success)return{success:!1,data:null};let i=s.data.addresses.at(-1);if(!a||!i)return{success:!0,data:s.data};let n=[];for(let[t,e]of Object.entries(a)){if("both"===t){n.push({action:"addBillingAddressId",addressId:i.id}),n.push({action:"addShippingAddressId",addressId:i.id}),e&&(n.push({action:"setDefaultBillingAddress",addressId:i.id}),n.push({action:"setDefaultShippingAddress",addressId:i.id}));break}if("billing"===t){n.push({action:"addBillingAddressId",addressId:i.id}),e&&n.push({action:"setDefaultBillingAddress",addressId:i.id});continue}"shipping"===t&&(n.push({action:"addShippingAddressId",addressId:i.id}),e&&n.push({action:"setDefaultShippingAddress",addressId:i.id}))}let o=await this.updateCustomer(t,n);return o.success?{success:!0,data:o.data}:{success:!1,data:null}}async getShops(){let{body:t}=await this.api.stores().get({queryArgs:{limit:500}}).execute();return t.results}async getStoreByKey(t){return(await this.api.stores().withKey({key:t}).get().execute()).body}async getChannel(t){return(await this.api.channels().withId({ID:t}).get().execute()).body}async replicateCart(t,e){return(await this.api.inStoreKeyWithStoreKeyValue({storeKey:e}).carts().replicate().post({body:{reference:{typeId:"order",id:t}}}).execute()).body}async getCustomerCountry(t){let e=await this.getCustomer({id:t});if(!e.success)return e;let{addresses:r,billingAddressIds:a}=e.data;if(!a||a.length<1)return{success:!1,data:null};let s=r.find(t=>t.id===a[0]);return s?{success:!0,data:s.country}:{success:!1,data:null}}async getChannelByKey(t){let e=this.api.channels().get({queryArgs:{limit:1,where:`key="${t}"`}});try{let{body:t}=await e.execute();if(t.results.length<1)throw Error("Channel not found");return{success:!0,data:t.results[0]}}catch{return{success:!1,data:null}}}async getStandalonePrice(t,e,r,a){let s=r?`sku="${t}" and (channel(id="${e}") or channel(id="${r}"))`:`sku="${t}" and channel(id="${e}")`,i=a?`${s} and value(currencyCode="${a}")`:s,n=this.api.standalonePrices().get({queryArgs:{where:i}});try{let{body:t}=await n.execute();if(t.results.length<1)return{success:!1,data:null};if(r){let e=t.results.find(t=>t.channel?.id===r);if(e)return{success:!0,data:e}}let a=t.results.find(t=>t.channel?.id===e);if(a)return{success:!0,data:a};return{success:!1,data:null}}catch(t){return{success:!1,data:null}}}async getBatchStandalonePrices(t,e,r,s){if(!t.length)return{};let i=t.map(t=>`"${t}"`).join(","),o=r?`sku in (${i}) and (channel(id="${e}") or channel(id="${r}"))`:`sku in (${i}) and channel(id="${e}")`;s&&(o+=` and value(currencyCode="${s}")`);try{let{body:a}=await this.api.standalonePrices().get({queryArgs:{where:o,limit:500}}).execute(),s={};return t.forEach(t=>{s[t]=null}
5),a.results.forEach(t=>{t.sku&&s.hasOwnProperty(t.sku)&&(r&&t.channel?.id===r?s[t.sku]=t:s[t.sku]||t.channel?.id!==e||(s[t.sku]=t))}),s}catch(r){return a.v.error({error:(0,n.u)(r),channelId:e},"failed to get batch standalone prices"),t.reduce((t,e)=>({...t,[e]:null}),{})}}async getAvailableVariantQuantity(t,e){try{let{supplyChannels:r,custom:a}=await this.getStoreByKey(e),{unlimitedStock:s}=a?.fields;if(!r.length)throw Error(`No supply channels found for store ${e}`);let i=await this.getInventoryEntriesForSku(t,A(r)),n=i.reduce((t,e)=>t+e.availableQuantity,0);if((0,h.u)(s)){if(0===i.length)return Number.MAX_SAFE_INTEGER;return 0===n?0:Number.MAX_SAFE_INTEGER}return n}catch(r){throw a.v.error({error:(0,n.u)(r),variantSKU:t,storeKey:e},"failed to get available variant quantity"),r}}async getBackorderAllowedForVariant(t,e){let{supplyChannels:r}=await this.getStoreByKey(e);if(!r.length)throw Error(`No supply channels found for store ${e}`);let a=await this.getInventoryEntriesForSku(t,A(r));return!!a.length&&a[0].custom?.fields?.LastStock!==1}async getBatchAvailableVariantQuantities(t,e){try{if(!t.length)return{};let{supplyChannels:r}
5=await this.getStoreByKey(e);if(!r.length)throw Error(`No supply channels found for store ${e}`);let a=t.map(t=>`"${t}"`).join(","),s=A(r),{body:i}=await this.api.inventory().get({queryArgs:{where:`sku in (${a}) and supplyChannel(id in (${s}))`,limit:500}}).execute(),n={};return t.forEach(t=>{n[t]=0}),i.results.forEach(t=>{t.sku&&n.hasOwnProperty(t.sku)&&(n[t.sku]+=t.availableQuantity)}),n}catch(t){throw a.v.error({error:(0,n.u)(t),storeKey:e},"failed to get batch available variant quantities"),t}}async getBatchBackorderAllowedForVariants(t,e){try{if(!t.length)return{};let{supplyChannels:r}=await this.getStoreByKey(e);if(!r.length)throw Error(`No supply channels found for store ${e}`);let a=t.map(t=>`"${t}"`).join(","),s=A(r),{body:i}=await this.api.inventory().get({queryArgs:{where:`sku in (${a}) and supplyChannel(id in (${s}))`,limit:500}}).execute(),n={};return t.forEach(t=>{n[t]=!1}),i.results.forEach(t=>{if(t.sku&&n.hasOwnProperty(t.sku)){let e=t.custom?.fields?.LastStock!==1;n[t.sku]=e}}),n}catch(t){throw a.v.error({error:(0,n.u)(t),storeKey:e},"failed to get batch backorder allowed for variants"),t}}async getBatchInventoryData(t,e){try{if(!t.length)return{quantities:{},backorders:{},expirationDates:{},unlimitedStock:!1};let{supplyChannels:r,custom:s}
5=await this.getStoreByKey(e),i=(0,h.u)(s?.fields?.unlimitedStock),n={},o={},u={};if(t.forEach(t=>{n[t]=void 0,o[t]=!1,u[t]=void 0}),!r.length)return a.v.warn({storeKey:e},"no supply channels found for store, returning default inventory values"),{quantities:n,backorders:o,expirationDates:u,unlimitedStock:i};let c=t.map(t=>`"${t}"`).join(","),l=A(r),{body:d}=await this.api.inventory().get({queryArgs:{where:`sku in (${c}) and supplyChannel(id in (${l}))`,limit:500}}).execute();return d.results.forEach(t=>{if(t.sku&&n.hasOwnProperty(t.sku)){void 0===n[t.sku]&&(n[t.sku]=0),n[t.sku]+=t.availableQuantity;let e=t.custom?.fields?.LastStock!==1;o[t.sku]=e;let r=t.custom?.fields?.expirationDate;"string"==typeof r&&r.trim()&&!u[t.sku]&&(u[t.sku]=r)}}),{quantities:n,backorders:o,expirationDates:u,unlimitedStock:i}}catch(t){throw a.v.error({error:(0,n.u)(t),storeKey:e},"failed to get batch inventory data"),t}}async getShippingMethods(t){try{let e=await this.api.shippingMethods().matchingLocation().get({queryArgs:{country:t}}).execute();if(!e.body)throw Error("Fehler in getShippingMethods");return{success:!0,data:e.body}}catch(t){return{success:!1,data:null}}}async getDiscountCode(t){try{let e=await this.api.discountCodes().withId({ID:t}).get().execute();if(!e.body)throw Error("Fehler in getDiscountCode");return{success:!0,data:e.body}}catch(t){return{success:!1,data:null}}}async getDiscountCodeByCode(t){try{let e=await this.api.discountCodes().get({queryArgs:{where:`code="${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,limit:1}}).execute(),r=e.body?.results?.[0];if(!r)return{success:!1,data:null};return{success:!0,data:r}}catch(t){return a.v.error({error:(0,n.u)(t)},"failed to get discount code by code"),{success:!1,data:null}}}async getCartDiscount(t){try{let e=await this.api.cartDiscounts().withId({ID:t}).get().execute();if(!e.body)return{success:!1,data:null};return{success:!0,data:e.body}}catch(e){return a.v.error({error:(0,n.u)(e),id:t},"failed to get cart discount"),{success:!1,data:null}}}async getLowStockItemsFromCart(t,e){try{let{success:r,data:a}=await this.getCart(t,e);if(!r)return{success:!1,data:null};let s=a.lineItems.map(t=>t.variant.sku).filter(Boolean),i=await this.getPurchaseUnitsForSkus(s,e),n=a.lineItems.map(async t=>{if(!t.variant.sku)return null;let r=await this.getAvailableVariantQuantity(t.variant.sku,e),a=parseInt(i[t.variant.sku]||"1",10)||1,s=t.quantity*a;return r<s?t:null}),o=(await Promise.all(n)).filter(t=>null!==t);return{success:!0,data:o}}catch(r){return a.v.error({error:(0,n.u)(r),cartId:t,storeKey:e},"failed to get low stock items from cart"),{success:!1,data:null}}}async getInventoryEntriesForSku(t,e){let{body:r}=await this.api.inventory().get({queryArgs:{where:`sku="${t}" and supplyChannel(id in (${e}))`}}).execute();return r.results}async planInventoryDeductions(t,e,r,s){let i=new Map;for(let r of t.lineItems){let t=r.variant.sku;if(!t)continue;let n=e[t];if(void 0===n)return a.v.error({...s,sku:t},"purchase unit missing, leaving the order inventory untouched"),{status:"purchase_unit_invalid"};let o=parseInt(n,10);if(!(o>0))return a.v.error({...s,sku:t,purchaseUnit:n},"invalid purchase unit, leaving the order inventory untouched"),{status:"purchase_unit_invalid"};let u=i.get(t)||0;i.set(t,u+r.quantity*o)}let o=[];for(let[t,e]of i){let i=await this.getInventoryEntriesForSku(t,r).catch(e=>(a.v.error({...s,error:(0,n.u)(e),sku:t},"failed to read inventory for sku, leaving the order inventory untouched"),null));if(!i)return{status:"inventory_unavailable"};let u=i.reduce((t,e)=>t+Math.max(e.availableQuantity,0),0);e>u&&a.v.warn({...s,sku:t,requiredPieces:e,availablePieces:u},"sku is short on stock, clamping available stock to zero instead of going negative");let c=e;for(let t of i){let e=Math.min(c,Math.max(t.availableQuantity,0));e<=0||(o.push({inventoryEntryId:t.id,version:t.version,quantity:e}),c-=e)}}return{status:"ready",deductions:o}}async adjustInventoryForPurchaseUnits(t,e){let r={orderId:t.id,orderNumber:t.orderNumber,storeKey:e};try{let s=t.lineItems.map(t=>t.variant.sku).filter(Boolean);if(!s.length)return;let{supplyChannels:i,custom:o}
5=await this.getStoreByKey(e);if((0,h.u)(o?.fields?.unlimitedStock))return void a.v.info(r,"store has unlimited stock, skipping inventory adjustment");if(!i.length)return void a.v.error(r,"no supply channels found for store, skipping inventory adjustment");let u=await this.getBatchPurchaseUnitsWithTailoring(s,e);if(!u)return void a.v.error(r,"could not resolve purchase units, leaving the order inventory untouched");let c=await this.planInventoryDeductions(t,u,A(i),r);if("ready"!==c.status)return void a.v.warn({...r,reason:c.status},"leaving order inventory untouched");for(let t of c.deductions)try{await this.api.inventory().withId({ID:t.inventoryEntryId}).post({body:{version:t.version,actions:[{action:"removeQuantity",quantity:t.quantity}]}}).execute()}catch(e){a.v.error({...r,error:(0,n.u)(e),inventoryEntryId:t.inventoryEntryId},"failed to deduct inventory entry")}}catch(t){a.v.error({...r,error:(0,n.u)(t)},"failed to adjust inventory for purchase units")}}async createBackInStockNotification({value:t,sku:e,variantName:r,email:s,channelId:i,confirmed:o=!1,locale:u,domain:c}){try{if(!(await this.api.customObjects().post({body:{container:"back-in-stock-subscriptions",key:`back-in-stock-notification-${e}-${i}`,value:[...t,{sku:e,variantName:r,email:s,channelId:i,confirmed:o,locale:u,domain:c}]}}).execute()).body)throw Error("Fehler in createBackInStockNotification");return{success:!0,data:null}}catch(t){return a.v.error({error:(0,n.u)(t),sku:e,channelId:i},"failed to create back in stock notification"),{success:!1,data:null}}}async getBackInStockNotification(t,e){try{let r=await this.api.customObjects().get({queryArgs:{where:`key = "back-in-stock-notification-${t}-${e}"`}}).execute();if(!r.body)throw Error("Error in getBackInStockNotification");return{success:!0,data:r}}catch(r){return a.v.error({error:(0,n.u)(r),sku:t,channelId:e},"failed to get back in stock notification"),{success:!1,data:null}}}async updateBackInStockNotification({sku:t,email:e,channelId:r}){let{success:a,data:s}=await this.getBackInStockNotification(t,r);if(!a)return{success:!1,data:null};let i=s.body.results[0]?.value.find(t=>t.email===e);if(!a||0===s.body.results.length||!i)return{success:!1,data:null};let n=(s.body.results[0]?.value||[]).map(t=>t.email===e?{...t,confirmed:!0}:t);try{let a=await this.api.customObjects().post({body:{container:"back-in-stock-subscriptions",key:`back-in-stock-notification-${t}-${r}`,value:n}}).execute();if(!a.body)throw Error("Fehler in createBackInStockNotification");return{success:!0,data:a.body.value.find(t=>t.email===e)}}catch(t){return{success:!1,data:null}}}async getProductTailoring(t,e,r){try{let a=await fetch(`${o.K.CTP_AUTH_URL}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${m.from(`${o.K.CTP_CLIENT_ID}:${o.K.CTP_CLIENT_SECRET}`).toString("base64")}`},body:`grant_type=client_credentials&scope=${o.K.CTP_SCOPES}`});if(!a.ok)throw Error(`Auth error! status: ${a.status}`);let{access_token:s}=await a.json(),i=await fetch(`${o.K.CTP_API_URL}/${o.K.CTP_PROJECT_KEY}/in-store/key=${r}/products/${t}/product-tailoring`,{headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"}});if(!i.ok&&404!==i.status)throw Error(`HTTP error! status: ${i.status}`);let n=await i.json(),u=(n.current?.variants?.length&&n.current.variants||n.staged?.variants||[]).find(t=>t.id===e),c=u?.attributes?.find(t=>"purchase_unit"===t.name);return{success:!0,data:{id:t,purchase_unit:c?.value||null}}}catch(s){return a.v.error({error:(0,n.u)(s),productId:t,variantId:e,storeKey:r},"failed to get product tailoring"),{success:!1,data:null}}}async getCustomVariants(t){let e=t?.custom?.fields?.variantSKU,r=e?.split(",")||[],a=[];for(let t of r){let{success:e,data:r}=await this.getProductsBySKUs([t],!1);if(e&&r?.length>0){let e=r?.map(e=>e.masterData.current.variants.concat(e.masterData.current.masterVariant).find(e=>e.sku===t))[0];a.push(e)}}return a}async getCustomVariantsFromCart(t){let{parseCartCookie:e}=await Promise.resolve().then(r.bind(r,30841)),a=e(t.req.cookies)?.id,{getCustomerLocationCookie:s}=await r.e(8274).then(r.bind(r,5893)),i=s(t.req.cookies)?.storeKey||"",n=null;if(a&&i){let{success:t,data:e}=await this.getCart(a,i);t&&(n=e)}return this.getCustomVariants(n)}async getCustomObject({container:t,key:e}){try{let r=await this.api.customObjects().withContainerAndKey({container:t,key:e}).get().execute();return{success:!0,data:r.body}}catch{return{success:!1,data:null}}}async queryCustomObjectsByContainerAndValue({container:t,valueField:e,value:r,limit:a=5}){try{let s=t.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),n=await this.api.customObjects().get({queryArgs:{where:`container="${s}" and value(${e}="${i}")`,limit:a}}).execute();return{success:!0,data:n.body.results}}catch{return{success:!1,data:null}}}async createOrUpdateCustomObject({container:t,key:e,value:r,version:s}){try{let a={container:t,key:e,value:r};void 0!==s&&(a.version=s);let i=await this.api.customObjects().post({body:a}).execute();return{success:!0,data:i.body}}catch(r){return a.v.error({error:(0,n.u)(r),container:t,key:e},"failed to create or update custom object"),{success:!1,data:null}}}async deleteCustomObject({container:t,key:e}){try{let r=await this.api.customObjects().withContainerAndKey({container:t,key:e}).delete().execute();return{success:!0,data:r.body}}catch{return{success:!1,data:null}}}}let S=new w({projectKey:o.K.CTP_PROJECT_KEY,clientId:o.K.CTP_CLIENT_ID,clientSecret:o.K.CTP_CLIENT_SECRET,scopes:o.K.CTP_SCOPES,authUrl:o.K.CTP_AUTH_URL,apiUrl:o.K.CTP_API_URL}
5)},14653:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{Kk:()=>getEntryPublishedAt,tv:()=>getLastPublishAt});var _lib_cache_fs_telemetry__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(18198),_lib_contentful_contentful_cache_config__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(72911),process=__webpack_require__(99742);let IS_NODE_RUNTIME=void 0!==process&&!!process.versions?.node,nodeRequire=IS_NODE_RUNTIME?eval("require"):void 0,fs=nodeRequire?nodeRequire("fs"):void 0,path=nodeRequire?nodeRequire("path"):void 0,SNAPSHOT_TTL_MS=5e3,ENTRY_RETENTION_MS=(_lib_contentful_contentful_cache_config__WEBPACK_IMPORTED_MODULE_1__.dF.CONTENT_PAGES+86400)*1e3,PRUNE_PER_REFRESH=100,SAFE_ENTRY_ID=/^[A-Za-z0-9._-]+$/;function baseDir(){return process.cwd().includes("/home/site/wwwroot")?path.join("/home","next-cache","epochs"):path.join(process.cwd(),".next","cache","epochs")}let marksDir=()=>path.join(baseDir(),"marks"),clockFile=()=>path.join(baseDir(),"content-published-at"),entriesSnapshot={},entriesLoadedAt=0,clockValue=0,clockLoadedAt=0;function refreshEntriesSnapshot(){let t=Date.now();if(t-entriesLoadedAt<SNAPSHOT_TTL_MS)return;entriesLoadedAt=t;let e=performance.now();try{let e={},r=0;for(let a of fs.readdirSync(marksDir())){let s=a.indexOf(".");if(s<=0)continue;let i=Number(a.slice(0,s)),n=a.slice(s+1);if(n&&Number.isFinite(i)){if(t-i>ENTRY_RETENTION_MS){if(r++<PRUNE_PER_REFRESH)try{fs.unlinkSync(path.join(marksDir(),a))}catch{}continue}i>(e[n]??0)&&(e[n]=i)}}entriesSnapshot=e}catch{}finally{(0,_lib_cache_fs_telemetry__WEBPACK_IMPORTED_MODULE_0__.aC)("epochStat",e,"entry-marks")}}function ensureDir(t){fs.existsSync(t)||fs.mkdirSync(t,{recursive:!0})}function getEntryPublishedAt(t){return IS_NODE_RUNTIME?(refreshEntriesSnapshot(),entriesSnapshot[t]??0):0}function markEntryPublished(t){let e=Date.now();if(!IS_NODE_RUNTIME||!SAFE_ENTRY_ID.test(t))return e;try{ensureDir(marksDir()),fs.writeFileSync(path.join(marksDir(),`${e}.${t}`),"","utf-8"),entriesSnapshot[t]=e}catch(e){console.error(`Failed to mark entry published ${t}:`,e)}return e}function getLastPublishAt(){if(!IS_NODE_RUNTIME)return 0;let t=Date.now();if(t-clockLoadedAt<SNAPSHOT_TTL_MS)return clockValue;clockLoadedAt=t;let e=performance.now();try{let t=Number(fs.readFileSync(clockFile(),"utf-8").trim());Number.isFinite(t)&&t>0&&(clockValue=t)}catch(t){"ENOENT"===t?.code&&(clockValue=0)}finally{(0,_lib_cache_fs_telemetry__WEBPACK_IMPORTED_MODULE_0__.aC)("epochStat",e,"content-clock")}return clockValue}function markContentPublished(){let t=Date.now();if(!IS_NODE_RUNTIME)return t;try{ensureDir(baseDir()),fs.writeFileSync(clockFile(),String(t),"utf-8"),clockValue=t,clockLoadedAt=t}catch(t){console.error("Failed to move the content publish clock:",t)}return t}},18198:(t,e,r)=>{r.d(e,{aC:()=>f});var a=r(61799),s=r(99742);let i=a.v.child({component:"ssr-cache"}),n="phase-production-build"===s.env.NEXT_PHASE,o=function(t,e){let r=Number(t);return Number.isFinite(r)&&r>0?r:500}(s.env.SSR_SLOW_FS_LOG_MS,500),u=1e4,c=10,l=()=>({count:0,slow:0,msTotal:0,maxMs:0}),d={read:l(),write:l(),epochStat:l()},p=0,y=0,h=0;function g(t,e,r){if(n)return;let a=Date.now();if(a-p>=u&&(p=a,y=0,h>0&&(i.info({msg:"slow_fs_op_suppressed",suppressed:h}),h=0)),y>=c)return void h++;y++,i.info({msg:"slow_fs_op",op:t,ms:e,file:r})}function f(t,e,r){let a=Math.round(performance.now()-e),s=d[t];s.count++,s.msTotal+=a,a>s.maxMs&&(s.maxMs=a),a>=o&&(s.slow++,g(t,a,r))}},25319:(t,e,r)=>{r.d(e,{RU:()=>n});var a=r(99742);let s=t=>"true"===t,i=()=>!1,n=()=>i()&&s(a.env.DEV_DISABLE_CACHE)},61799:(t,e,r)=>{r.d(e,{v:()=>c});var a=r(91123),s=r.n(a),i=r(99742);let n=!1,o=i.env.LOG_LEVEL??(n?"debug":"info"),u=[{level:o,stream:i.stdout}],c=s()({level:o,base:{service:"webshop-next",env:"production"}},s().multistream(u))},72911:(t,e,r)=>{r.d(e,{dF:()=>i});var a=r(99742);let s=2592e3,i={DEFAULT:86400,LONG:86400,CONTENT_PAGES:function(t){let e=Number(t);return Number.isFinite(e)&&e>0?e:s}(a.env.CONTENT_PAGES_TTL_SECONDS)}},96499:(t,e,r)=>{r.d(e,{K:()=>ENV});var a=r(22442);throw r(99742),a.Ik({CONTENTFUL_SPACE_ID:a.Yj(),CONTENTFUL_MANAGEMENT_API_ACCESS_TOKEN:a.Yj(),CONTENTFUL_DELIVERY_API_ACCESS_TOKEN:a.Yj(),CONTENTFUL_PREVIEW_API_ACCESS_TOKEN:a.Yj(),CONTENTFUL_PREVIEW_SECRET:a.Yj(),CONTENTFUL_ENVIRONMENT_ID:a.Yj(),CONTENTFUL_START_PAGE_ID:a.Yj(),CONTENTFUL_SHOPPING_START_PAGE_ID:a.Yj().optional(),CONTENTFUL_START_PAGE_ID_IE:a.Yj().optional(),CONTENTFUL_START_PAGE_ID_FI:a.Yj().optional(),CONTENTFUL_START_PAGE_ID_SE:a.Yj().optional(),CONTENTFUL_START_PAGE_ID_NO:a.Yj().optional(),CONTENTFUL_START_PAGE_ID_PL:a.Yj().optional(),CONTENTFUL_FAQ_PAGE_ID_IE:a.Yj().optional(),CONTENTFUL_PRIVACY_POLICY_PAGE_ID_IE:a.Yj().optional(),CONTENTFUL_TERMS_OF_USE_PAGE_ID_IE:a.Yj().optional(),CONTENTFUL_TERMS_OF_SALE_PAGE_ID_IE:a.Yj().optional(),CONTENTFUL_IMPRINT_PAGE_ID_IE:a.Yj().optional(),CONTENTFUL_FAQ_PAGE_ID_FI:a.Yj().optional(),CONTENTFUL_PRIVACY_POLICY_PAGE_ID_FI:a.Yj().optional(),CONTENTFUL_TERMS_OF_USE_PAGE_ID_FI:a.Yj().optional(),CONTENTFUL_TERMS_OF_SALE_PAGE_ID_FI:a.Yj().optional(),CONTENTFUL_IMPRINT_PAGE_ID_FI:a.Yj().optional(),CONTENTFUL_FAQ_PAGE_ID_SE:a.Yj().optional(),CONTENTFUL_PRIVACY_POLICY_PAGE_ID_SE:a.Yj().optional(),CONTENTFUL_TERMS_OF_USE_PAGE_ID_SE:a.Yj().optional(),CONTENTFUL_TERMS_OF_SALE_PAGE_ID_SE:a.Yj().optional(),CONTENTFUL_IMPRINT_PAGE_ID_SE:a.Yj().optional(),CONTENTFUL_FAQ_PAGE_ID_NO:a.Yj().optional(),CONTENTFUL_PRIVACY_POLICY_PAGE_ID_NO:a.Yj().optional(),CONTENTFUL_TERMS_OF_USE_PAGE_ID_NO:a.Yj().optional(),CONTENTFUL_TERMS_OF_SALE_PAGE_ID_NO:a.Yj().optional(),CONTENTFUL_IMPRINT_PAGE_ID_NO:a.Yj().optional(),CONTENTFUL_FAQ_PAGE_ID_PL:a.Yj().optional(),CONTENTFUL_PRIVACY_POLICY_PAGE_ID_PL:a.Yj().optional(),CONTENTFUL_TERMS_OF_USE_PAGE_ID_PL:a.Yj().optional(),CONTENTFUL_TERMS_OF_SALE_PAGE_ID_PL:a.Yj().optional(),CONTENTFUL_IMPRINT_PAGE_ID_PL:a.Yj().optional(),LAUNCHED_WEBSHOP_COUNTRIES:a.Yj().optional(),CONTENTFUL_MAIN_NAVIGATION_ID:a.Yj(),CONTENTFUL_META_NAVIGATION_ID:a.Yj(),CONTENTFUL_META_SERVICE_NAVIGATION_ID:a.Yj(),CONTENTFUL_FOOTER_NAVIGATION_ID:a.Yj(),CONTENTFUL_FOOTER_SERVICE_NAVIGATION_ID:a.Yj(),CONTENTFUL_FOOTER_QUALITYSEAL_INFO_ID:a.Yj(),CONTENTFUL_CATEGORY_STAGE_MEDIA_ID:a.Yj(),CONTENTFUL_CATEGORY_STAGE_ID:a.Yj(),CONTENTFUL_CHARGEN_CERTS_ID:a.Yj(),NEXT_PUBLIC_CERT_BYPASS_PREFILLED_CERTIFICATES:a.Yj(),CONTENTFUL_CERTMAPPING_ID:a.Yj(),CONTENTFUL_SEARCH_RESULT_TEMPLATE_ID:a.Yj(),CONTENTFUL_CONTACT_PAGE:a.Yj(),CONTENTFUL_PIPETTE_COMPATABILITY_ID:a.Yj(),CONTENTFUL_PCR_COMPATABILITY_ID:a.Yj(),CONTENTFUL_MEDICAL_PROFESSIONALTEXT:a.Yj(),CONTENTFUL_DOWNLOADS_ASIDE_NAVIGATION_ID:a.Yj(),NEXT_PUBLIC_CONTENTFUL_QUALITY_SEAL_BIOSPHERE_URL:a.Yj(),NEXT_PUBLIC_CONTENTFUL_QUALITY_SEAL_BIOSPHERE_PLUS_URL:a.Yj(),NEXT_PUBLIC_CONTENTFUL_QUALITY_SEAL_CRYO_URL:a.Yj(),NEXT_PUBLIC_CONTENTFUL_QUALITY_SEAL_PCR_URL:a.Yj(),NEXT_PUBLIC_CONTENTFUL_QUALITY_SEAL_TC_URL:a.Yj(),CTP_PROJECT_KEY:a.Yj(),CTP_CLIENT_SECRET:a.Yj(),CTP_CLIENT_ID:a.Yj(),CTP_CUSTOMER_CLIENT_SECRET:a.Yj(),CTP_CUSTOMER_CLIENT_ID:a.Yj(),CTP_AUTH_URL:a.Yj(),CTP_API_URL:a.Yj(),CTP_SCOPES:a.Yj(),CTP_PREANALYSIS_CAT_KEY:a.Yj(),SHARPS_RESTRICTED_CATEGORY_KEYS:a.Yj().optional().default(""),SHARPS_RESTRICTED_STORE_KEYS:a.Yj().optional().default(""),NEXT_PUBLIC_GLOBAL_SHOP:a.Yj(),NEXT_PUBLIC_CHANNEL_IE_EPS_ID:a.Yj().optional(),ALGOLIA_APP_ID:a.Yj(),ALGOLIA_API_KEY:a.Yj(),ALGOLIA_CTP_INDEX:a.Yj(),ALGOLIA_SUGGEST_INDEX:a.Yj(),ALGOLIA_DOCUMENT_INDEX:a.Yj(),ALGOLIA_CONTENT_INDEX:a.Yj(),NEXT_PUBLIC_ALGOLIA_APP_ID:a.Yj().optional(),NEXT_PUBLIC_ALGOLIA_SEARCH_KEY:a.Yj().optional(),ALGOLIA_SANDBOX_APP_ID:a.Yj().optional(),ALGOLIA_SANDBOX_API_KEY:a.Yj().optional(),ALGOLIA_SANDBOX_WRITE_API_KEY:a.Yj().optional(),NEXT_PUBLIC_ALGOLIA_SANDBOX_APP_ID:a.Yj().optional(),NEXT_PUBLIC_ALGOLIA_SANDBOX_SEARCH_KEY:a.Yj().optional(),NEXT_PUBLIC_ALGOLIA_USE_SANDBOX:a.Yj().optional(),NEXT_PUBLIC_ALGOLIA_INDEXED_BY_LANGUAGE:a.Yj().optional(),AWS_REGION:a.Yj().optional(),_AWS_CLIENT_ID:a.Yj(),_AWS_CLIENT_SECRET:a.Yj(),STRIPE_SECRET_KEY_US:a.Yj(),STRIPE_SECRET_KEY_IE:a.Yj(),STRIPE_SECRET_KEY_PL:a.Yj(),AVALARA_ENV:a.Yj(),AVALARA_ID:a.Yj(),AVALARA_KEY:a.Yj(),GOOGLE_MAPS_API_KEY:a.Yj(),NEXT_PUBLIC_GOOGLE_TAG_MANAGER:a.Yj(),NEXT_PUBLIC_COOKIEBOT_ID:a.Yj().optional(),GOOGLE_CLOUD_PROJECT_ID:a.Yj(),GOOGLE_CLOUD_RECAPTCHA_API_KEY:a.Yj(),NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITE_KEY:a.Yj(),BREVO_API_KEY:a.Yj(),BREVO_FROM_
5EMAIL:a.Yj(),BREVO_FROM_NAME:a.Yj(),BREVO_NEWSLETTER_LIST_ID:a.Yj(),NEWSLETTER_DOI_SECRET:a.Yj(),SMTP_HOST:a.Yj().optional(),SMTP_PORT:a.Yj().optional(),SMTP_SECURE:a.Yj().optional(),SMTP_USER:a.Yj().optional(),SMTP_PASSWORD:a.Yj().optional(),SMTP_FROM:a.Yj().optional(),COSMOSDB_ENDPOINT:a.Yj().optional().default(""),COSMOSDB_KEY:a.Yj().optional().default(""),COSMOSDB_DATABASE:a.Yj().optional().default("")}),Error("This file should not be used in the browser")}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.