PageSourceSearch

https://nochesrestaurantes.com/_next/static/chunks/4753-8437f83fd64d20ba.js

js nochesrestaurantes.com collected 2026-10-02 00:54:22 UTC 78,247 bytes, 9 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4753],{674:(e,t,o)=>{o.d(t,{d3:()=>a,iR:()=>d,mH:()=>c,lZ:()=>s});var i=o(87651),r=o(4163);function n(e,t){return!!e?.placeId&&!!t&&"00000000-0000-0000-0000-000000000000"!==e.placeId&&e.placeId===t}function a(e,t){return e?.find(e=>n(e,t))}function l(e){let t=(0,r.hW)(e);if(void 0!==t)return t?.appearance??null}function c(e,t){return!a(e,t)&&null==l(t)}function s(e){let{placeId:t,appearances:o,initialAppearance:r,initialAppearanceCompany:c,currentActiveAppearance:s,useCompanyBrandingFallback:d=!1}=e,p=a(o,t);if(p)return p;let u=l(t);return u&&n(u,t)?u:r&&n(r,t)?r:d&&c?c:s&&n(s,t)?s:i.F2}function d(e,t){return t.appearance?.placeId?[t.appearance,...e.filter(e=>e?.placeId!==t.appearance?.placeId)]:e}},3472:(e,t,o)=>{o.d(t,{Cf:()=>c,b:()=>a,ko:()=>l,l:()=>r,lI:()=>n});let i="landingPreselectTransition";function r(e){"u">typeof sessionStorage&&sessionStorage.setItem(i,JSON.stringify(e))}function n(){var e="u"<typeof sessionStorage?null:sessionStorage.getItem(i);if(!e)return null;try{let t=JSON.parse(e);if(t?.placeId&&("auto"===t.source||"manual"===t.source))return t}catch{}return{placeId:e,source:"auto"}}function a(){return n()?.source==="manual"}function l(){"u">typeof sessionStorage&&sessionStorage.removeItem(i)}function c(){return n()?.placeId??null}},4163:(e,t,o)=>{o.d(t,{hW:()=>s,Yy:()=>u,tb:()=>p});var i=o(9339);let r=(0,i.createServerReference)("6007fce41b5415bfb0e8a038189343264937b8f239",i.callServer,void 0,i.findSourceMapURL,"getPlaceStrapiBootstrapAction"),n=new Map,a=new Map,l=new Map,c={appearance:null,socialNetworks:null};function s(e){if(n.has(e))return n.get(e)??null}function d(e,t){let o;n.set(e,t),t&&(o=l.get(e),o?.size&&o.forEach(e=>e(t)))}function p(e,t){let o=l.get(e)??new Set;o.add(t),l.set(e,o);let i=s(e);return i&&t(i),()=>{let o=l.get(e);o&&(o.delete(t),o.size||l.delete(e))}}function u(e,t){let o=s(t);if(void 0!==o)return Promise.resolve(o);let i=a.get(t);if(i)return i;let n=r(e,t).then(e=>{let o=e??c;return d(t,o),o}).catch(()=>(d(t,c),c)).finally(()=>{a.delete(t)});return a.set(t,n),n}},7245:(e,t,o)=>{o.d(t,{Cz:()=>a,Wt:()=>n,pL:()=>s,sz:()=>c});var i=o(95894),r=o(81135);function n(e,t){if(!t.length)return!1;let o=(0,i.RV)(e),n="/"===o?[]:o.split("/").filter(Boolean),a=new Set(t.map(e=>(0,r.C5)(e?.name)).filter(Boolean));return n.some(e=>a.has(e))}function a(e,t){let o=l(e);return o?t.find(e=>(0,r.C5)(e?.name)===o)??null:null}function l(e){let t=(0,i.RV)(e);return("/"===t?[]:t.split("/").filter(Boolean))[0]??null}function c(e,t,o){if(!t?.name)return!1;let i=(0,r.C5)(t.name),n=l(e);return!!n&&n===i&&new Set(o.map(e=>(0,r.C5)(e?.name)).filter(Boolean)).has(n)}function s(e,t){let o=[e??"/"];return o.push(window.location.pathname),o.some(e=>n(e,t))}},10335:(e,t,o)=>{function i(e){let t=new Date().getDay(),o=e?.filter(e=>e.day_of_week===t);return!!o&&0!==o.length&&(!!o.some(e=>e.available_24_hour)||o.some(e=>{var t,o;let i,r,n,a;return t=e.init_time,o=e.end_time,i=new Date,r=new Date(`1/1/1999 ${i.getHours()}:${i.getMinutes()}`),n=new Date("1/1/1999 "+t),a=new Date("1/1/1999 "+o),r>=n&&a>=r}))}o.d(t,{O:()=>i})},29027:(e,t,o)=>{function i(e){return e&&Array.isArray(e)?e.map(e=>r(e)):[]}function r(e){return{...e,modifiers:(e.modifiers??[]).map(e=>({...e,children:i(e.children)}))}}function n(e){return(e??[]).map(e=>r(e))}function a(e){return e.some(e=>(e.modifiers??[]).some(e=>(e.children?.length??0)>0))}function l(e,t){return e.map(e=>{let o=t[e.modifierGroupId];if(!o?.modifiers?.length)return r(e);let n=o.modifiers.reduce((e,t)=>(t.modifierItemId&&t.children?.length&&(e[t.modifierItemId]=i(t.children)),e),{});return r({...e,modifiers:(e.modifiers??[]).map(e=>({...e,children:n[e.modifierItemId]??i(e.children)}))})})}o.d(t,{$Q:()=>c,BM:()=>n,JK:()=>_,K7:()=>m,MI:()=>p,Uc:()=>l,Y:()=>a,fz:()=>function e(t=[]){return t.reduce((t,o)=>t+function(t=[]){return t.reduce((t,o)=>{let i=o.children?e(o.children):0;return t+Number(o.price)*o.quantity+i},0)}(o.modifierItems),0)},iF:()=>s,tl:()=>u});function c(e=[]){return e.reduce((e,t)=>e+t.quantity,0)}function s(e){return e.required?Math.max(e.minimalOptionNumber,1):e.minimalOptionNumber}function d(e,t){let o=c(t?.modifierItems??[]),i=s(e);return i>=1&&o<i}function p(e,t){let o=[];
1return(e??[]).forEach(e=>{let i=t.find(t=>t.modifierId===e.modifierGroupId);!function e(t,o,i){for(let r of(d(t,o)&&i.push(t.modifierGroupId),t.modifiers??[])){let t=o?.modifierItems?.find(e=>e.modifierItemId===r.modifierItemId);if(t&&!(t.quantity<1))for(let o of r.children??[]){let r=t.children?.find(e=>e.modifierId===o.modifierGroupId);e(o,r,i)}}}(e,i,o)}),o}function u(e,t){return(e??[]).every(e=>{let o=t.find(t=>t.modifierId===e.modifierGroupId);return function e(t,o){if(d(t,o))return!1;for(let i of t.modifiers??[]){let t=o?.modifierItems?.find(e=>e.modifierItemId===i.modifierItemId);if(t&&!(t.quantity<1))for(let o of i.children??[]){let i=t.children?.find(e=>e.modifierId===o.modifierGroupId);if(!e(o,i))return!1}}return!0}(e,o)})}function m(e){return e.map(e=>{let{translations:t,externalReferenceId:o,...i}=e,r={...i,modifierItems:(e.modifierItems??[]).map(e=>(function(e){let{translations:t,externalReferenceId:o,...i}=e,r={...i};return o&&(r.externalReferenceId=o),e.children?.length&&(r.children=m(e.children)),r})(e))};return o&&(r.externalReferenceId=o),r})}function _(e=[],t=[]){return JSON.stringify(m(e))===JSON.stringify(m(t))}},35113:(e,t,o)=>{o.d(t,{Qj:()=>r,S0:()=>n,X8:()=>a});let i=new Map;function r(e,t){return i.get(`${e}:${t}`)}function n(e,t,o){i.set(`${e}:${t}`,o)}function a(){i.clear()}},35923:(e,t,o)=>{o.d(t,{$V:()=>_,$g:()=>l,B9:()=>n,DL:()=>r,Ek:()=>d,N6:()=>m,XM:()=>s,Zr:()=>c,dv:()=>a,yb:()=>f});var i=o(29027);function r(e,t,o){let i=[];return e?.forEach(e=>{e[t]===o?i.unshift(e):i.push(e)}),i}let n=e=>{if(!e||"string"!=typeof e)return!1;let t=e.trim();if(1!==(t.match(/@/g)||[]).length)return!1;let[o,i]=t.split("@");if(!o||o.length>64||0===o.length||o.startsWith(".")||o.endsWith(".")||!i||i.length>253||!i.includes("."))return!1;let r=i.split("."),n=r[r.length-1];if(!n||n.length<2||n.length>63||!/^[a-zA-Z]+$/.test(n))return!1;for(let e of r)if(!e||0===e.length||!/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(e))return!1;return!0},a=(e,t)=>(0,i.tl)(e,t),l=e=>{let t="string"==typeof e?parseFloat(e):e;return isNaN(t)?"0.00":t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})};function c(e){return e?.charAt(0)?.toUpperCase()+e?.slice(1)}let s=(e,t,o)=>e>=t&&e<=o,d=e=>Math.round(100*e),p=["mp4","mov","avi","webm","mkv"],u=(e="")=>e.split("?")[0].toLowerCase().split(".").pop()||"",m=(e="")=>{let t=u(e);return p.includes(t)},_=e=>!!e&&(!!e.mime?.includes("video")||[e.fileExtension,e.name,e.format?.original,e.format?.large].filter(Boolean).some(e=>{let t=u(e.replace(/^\./,"file."));return p.includes(t)})),f=(e,t="medium")=>{let o=e?.find(e=>e?.mainImage)||e?.[0];if(!o)return"";let i=_(o)?o?.format?.original||o?.format?.large||o?.format?.[t]||o?.name:o?.format?.[t]||o?.format?.large||o?.format?.original||o?.name;return`${o?.imagePath||""}${i||""}`}},54753:(e,t,o)=>{o.d(t,{p5:()=>g,NQ:()=>h});var i=o(12115);let r=(0,i.createContext)({});var n=o(95155),a=o(73321),l=o(81135),c=o(87651),s=o(73762),d=o(35113),p=o(7245),u=o(3472),m=o(674);function _(e,t,o){let i=o.appearance?(0,m.iR)(e.appearances??[],o):e.appearances,r=o.socialNetworks?[o.socialNetworks,...(e.socialNetworks??[]).filter(e=>e?.placeId!==o.socialNetworks?.placeId)]:e.socialNetworks,n=e.activePlace?.placeId===t;return{...e,appearances:i,socialNetworks:r,activeAppearance:n?o.appearance??e.activeAppearance:e.activeAppearance,activeSocialNetworks:n?o.socialNetworks??e.activeSocialNetworks:e.activeSocialNetworks}}var f=o(4163);let g=({host:e,initialCompany:t,initialAppearance:o,initialAppearanceCompany:g,initialActivePlace:h,initialWebsites:I,initialActiveSocialNetworks:y=null,hasServerBootstrap:w=!1,children:v})=>{let P=t?.places??[],b=P.length<=1?h:(0,p.Cz)(window.location.pathname,P)??h,A=I&&P.length?(0,l.Se)(I,P,b):null,S=g??o??c.F2,[q,F]=(0,i.useState)(()=>A?{host:e,company:t,places:t?.places??[],appearances:o?[o,...(A.appearances??[]).filter(e=>e?.placeId!==o.placeId)]:A.appearances??[],socialNetworks:y?[y,...(A.socialNetworks??[]).filter(e=>e?.placeId!==y.placeId)]:A.socialNetworks??[],websites:A.websites??[],splashes:I?.result?.splashes??[],activePlace:b??A.activePlace??null,activeAppearance:b?o??A.activeAppearance??c.F2:S,activeSocialNetworks:b?y??A.activeSocialNetworks??null:null,activeWebsite:b?A.activeWebsite??null:null,initialAppearanceCompany:g??void 0}:{host:e,company:t,places:t?.places,appearances:[],socialNetworks:[],websites:[],splashes:I?.result?.splashes??[],activePlace:b??null,activeAppearance:b?o??c.F2:g??c.F2,activeSocialNetworks:null,activeWebsite:null,initialAppearanceCompany:g??void 0}),[C,T]=(0,i.useState)(!1),[$,x]=(0,i.useState)(!t?.places?.length),[R,N]=(0,i.useState)(!1),E=(0,a.usePathname)(),D=(0,i.useRef)(new Map),O=(0,i.useCallback)((e,t,i)=>(0,m.lZ)({placeId:t,appearances:e.appearances??[],initialAppearance:o,initialAppearanceCompany:g??e.initialAppearanceCompany,currentActiveAppearance:e.activeAppearance,useCompanyBrandingFallback:i?.useCompanyBrandingFallback??!1}),[g,o]),k=(0,i.useCallback)((e,t)=>{let o=(0,f.hW)(t);if(void 0!==o){(o.appearance||o.socialNetworks)&&F(e=>_(e,t,o));return}if(!D.current.get(t)){let e=(0,f.tb)(t,e=>{(e.appearance||e.socialNetworks)&&F(o=>o.activePlace?.placeId!==t?o:_(o,t,e))});D.current.set(t,e)}(0,f.Yy)(e,t).then(e=>{(e?.appearance||e?.socialNetworks)&&F(o=>o.activePlace?.placeId!==t?o:_(o,t,e))})},[]);(0,i.useEffect)(()=>{let e=D.current;return()=>
1{e.forEach(e=>e()),e.clear()}},[]);let M=(0,i.useCallback)((e,t,o)=>({...e,activePlace:o?t.activePlace:e.activePlace,activeAppearance:o?t.activeAppearance??e.activeAppearance:e.activeAppearance,activeSocialNetworks:o?t.activeSocialNetworks??e.activeSocialNetworks:e.activeSocialNetworks,activeWebsite:o?t.activeWebsite??e.activeWebsite:e.activeWebsite}),[]),L=(0,i.useCallback)((e,t)=>{let o=e.places?.find(e=>e?.placeId===t);if(!o)return e;let i=O(e,t),r=e.socialNetworks.find(e=>e?.placeId===t),n=e.websites.find(e=>e?.placeId===t),a=(0,f.hW)(t);return{...a?.appearance||a?.socialNetworks?_(e,t,a):e,activePlace:o,activeAppearance:i,activeSocialNetworks:r??null,activeWebsite:n??null}},[O]),U=(0,i.useCallback)(()=>{let e=t?.places??[];if(e.length<=1)return;let o=E??window.location.pathname,i=(0,p.Cz)(o,e);if(i?.placeId){let e=i.placeId,o=t?.companyId;F(t=>t.activePlace?.placeId===e?t:L(t,e)),o&&k(o,e);return}let r=(0,p.pL)(o,e);if(!h&&!r)return;let n=(()=>{try{let e=sessionStorage.getItem("websiteState");return e?JSON.parse(e):null}catch(e){return console.error("Error parsing websiteState from sessionStorage:",e),null}})(),a=(0,u.Cf)(),l=n?.company?.companyId===t?.companyId,c=l&&n?.activePlace?.placeId||a||null;if(!c||r&&h?.placeId&&c!==h.placeId)return;F(e=>{if(e.activePlace?.placeId===c)return e;if(l&&n?.activePlace?.placeId===c){let t=!h||n.activePlace?.placeId===h?.placeId;return M(e,n,t)}return L(e,c)});let s=t?.companyId;s&&k(s,c)},[E,L,M,k,t?.companyId,t?.places,h]);(0,i.useLayoutEffect)(()=>{N(!0),U()},[U]),(0,i.useLayoutEffect)(()=>{let e=q.activePlace?.placeId,o=t?.companyId;if(!e||!o)return;let i=(0,f.hW)(e);(i?.appearance||i?.socialNetworks)&&F(t=>{let o=!!(0,m.d3)(t.appearances,e),r=t.activeAppearance?.placeId===e;return o&&r?t:_(t,e,i)})},[t?.companyId,q.activePlace?.placeId]),(0,i.useEffect)(()=>{R&&q?.activePlace&&sessionStorage.setItem("websiteState",JSON.stringify(q))},[q?.activePlace?.placeId,R]);let G=(0,i.useCallback)(e=>{s.T.getState().clearCatalogSeo(),e!==q.activePlace?.placeId&&(0,d.X8)();let t=q.places.find(t=>t?.placeId===e),o=(0,m.d3)(q.appearances,e),i=q.socialNetworks.find(t=>t?.placeId===e),r=q.websites.find(t=>t?.placeId===e);if(!t)return void x(!0);w||T(!!o?.splash);let n=(0,f.hW)(e),a=O(q,e),l=!q.company?.companyId||!(0,m.mH)(q.appearances,e);F({...n?.appearance||n?.socialNetworks?_(q,e,n):q,activePlace:t,activeAppearance:a,activeSocialNetworks:i??null,activeWebsite:r??null});let c=q.company?.companyId;c&&!l&&k(c,e)},[k,w,O,q]);return(0,n.jsx)(r.Provider,{value:{...q,isLoading:C,error:$,setIsLoading:T,setActivePlace:G,initialAppearanceCompany:g??q.initialAppearanceCompany},children:v})};function h(){return(0,i.useContext)(r)}},72599:(e,t,o)=>{o.d(t,{Dk:()=>d,ER:()=>u,V5:()=>l,eG:()=>c,f$:()=>a,i6:()=>p,k3:()=>s,kn:()=>i,pA:()=>r,zY:()=>n});let i={TAKEOUT:"Takeout orders",DELIVERY:"Delivery orders",CUSTOM_DELIVERY:"Custom delivery orders"},r="Takeout and delivery orders",n={PICKUP:"Pickup",DELIVERY:"Delivery",CUSTOM_DELIVERY:"CustomDelivery"},a={SCHEDULED:"Scheduled",ASAP:"ASAP"},l={INTEGRATED:"Integrated",OWN:"Own"},c={ASAP_ONLY:"ASAP only",SAME_DAY:"Same day",ONE_DAY_OUT:"One day out",TWO_DAY_OUT:"Two day out",THREE_DAY_OUT:"Three day out",FOUR_DAY_OUT:"Four day out",FIVE_DAY_OUT:"Five day out",SIX_DAY_OUT:"Six day out",ANY_DAY:"Any day of the week"},s={SUBMITTED:"submitted",PAID:"paid",SCHEDULED:"scheduled",ORDERED:"ordered",PREPARING:"preparing",READY:"ready",SHIPPED:"shipped",DELIVERED:"delivered",CANCELLED:"cancelled"},d={FLAT:"Flat ($)",PERCENTAGE:"Percentage (%)",PER_UNIT:"Per Unit ($/unit)"},p={SHIFT4:"Shift4",CLOVER:"Clover",EATSY_ORDERS:"EatsyOrders"},u={MICROSITES:"Microsites",CATERING:"Catering",WHITE_LABEL:"WhiteLabel"}},73762:(e,t,o)=>{o.d(t,{T:()=>a});var i=o(1934),r=o(49756);let n=(e,t,o)=>{let i={},n=(0,r._2)(e.translations,t,o),a=n?.title??e.title,l=n?.metaTagDescription??e.metaTagDescription;return a&&(i.title=a),l&&(i.description=l),i},a=(0,i.v)(e=>({placeId:null,seoByMenuId:{},seoByCategoryId:{},seoByArticleId:{},setCatalogSeoFromMenus:(t,o,i="en",r)=>{e(e=>{let a=e.placeId!==t?t:e.placeId,l=a!==e.placeId?{}:{...e.seoByMenuId},c=a!==e.placeId?{}:{...e.seoByCategoryId};for(let e of o){let t=n(e,i,r);for(let o of(e.slug&&(l[`${e.slug}_${i}`]=t),Object.keys(t).length>0&&e.categoryId&&(l[`${e.categoryId}_${i}`]=t),e.categoryChilds??[])){let e=n(o,i,r);o.slug&&(c[`${o.slug}_${i}`]=e),Object.keys(e).length>0&&o.categoryId&&(c[`${o.categoryId}_${i}`]=e)}}return{placeId:a,seoByMenuId:l,seoByCategoryId:c,seoByArticleId:a!==e.placeId?{}:e.seoByArticleId}})},setMenuSeo:(t,o,i)=>{let r=`${t}_${o}`;e(e=>({seoByMenuId:{...e.seoByMenuId,[r]:i}}))},setCategorySeo:(t,o,i)=>{let r=`${t}_${o}`;e(e=>({seoByCategoryId:{...e.seoByCategoryId,[r]:i}}))},setArticleSeo:(t,o,i)=>{let r=`${t}_${o}`;e(e=>({seoByArticleId:{...e.seoByArticleId,[r]:i}}))},clearCatalogSeo:()=>{e({placeId:null,seoByMenuId:{},seoByCategoryId:{},seoByArticleId:{}})}}))},81135:(e,t,o)=>{o.d(t,{C5:()=>y,ES:()=>w,Fq:()=>A,OJ:()=>m,PJ:()=>I,Se:()=>g,WD:()=>_,aA:()=>P,fC:()=>h,l6:()=>f,uU:()=>b,vX:()=>u,wo:()=>p,z8:()=>v});var i=o(27866),r=o.n(i),n=o(35923),a=o(29027),l=o(10335),c=o(87651),s=o(72599),d=o(98564);let p=(e,t)=>e?.length?e?.filter(e=>e.source===t):[],u=(e,t)=>
1e&&e.source===t?e:null,m=(e=[],t,o)=>{let i=e?.filter(e=>e.productCount>0&&e.isActive)??[];if(i?.length&&t&&!o){let e=i.some(e=>e?.slug===t);return(0,n.DL)(i,e?"slug":"categoryId",t)}if(i?.length&&o){let e=i?.find(e=>e?.slug===o||e?.categoryId===o);return e?[e]:[]}return i},_=(e,t,o,i,r,a)=>({articleId:e.articleId,externalReferenceId:e.externalReferenceId,clientId:"",modifiers:t,quantity:o,name:e.name,price:e.price,imageUrl:e?.articleImages?.length>0?(0,n.yb)(e.articleImages,"small"):"",translations:e?.translations??[],notes:i,parent:r,preparationTime:e.preparationTime,...(void 0!==a?a:r?.isCatering)!==void 0&&{isCatering:void 0!==a?a:r?.isCatering}});function f(e,t){var o;return{articleId:e.articleId,externalReferenceId:e.externalReferenceId,name:e.name,slug:"",price:e.price,dualPrice:e.dualPrice?.toFixed(2)??"0.00",description:e.notes??"",status:1,source:t,likesCount:0,tags:[],modifierGroups:[],attributesArticle:[],translations:e.translations??[],preparationTime:e.preparationTime,articleImages:(o=e.imageUrl)?[{alt:"",mainImage:!0,name:"",imagePath:"",articleCategoryImageId:"",format:{small:o,medium:o,large:o,thumb:o,original:o,extraLarge:o},translations:[]}]:[]}}let g=(e,t,o)=>{let i=(e?.result?.websites?.filter(e=>e?.website_pages?.some(e=>e?.active)&&t?.some(t=>t.placeId===e.placeId))??[]).map(e=>({...e,website_pages:e.website_pages.filter(e=>e.active).map(e=>({...e,seo:e?.seo,sections:e?.sections?.filter(e=>e.active)}))})),r=t??[],n=o?.placeId??(1===r.length?r[0]?.placeId:null),a=n?r.find(e=>e?.placeId===n)??null:1===r.length?r[0]:null,s=n?i.find(e=>e?.placeId===n)??null:1===i.length?i[0]:null,d=r.reduce((t,o)=>{let i=e?.result?.appearances?.find(e=>e?.placeId===o?.placeId);if(!i)return t;let r=e?.result?.splashes?.filter(e=>e?.placeId===o?.placeId),n=r?.filter(e=>e?.active)?.find(e=>(0,l.O)(e?.schedule)),a=n?.media?.[0]?.formats?.large?.url??n?.media?.[0]?.url,c=n?.media?.[0]?.mime??"";return t.push(((e,t="",o="")=>({placeId:e?.placeId||"",categoriesPosition:e?.categoriesPosition||"top",colorPrimary:e?.light?.main||"#ec6533",colorSecondary:e?.light?.contrast||"#273D4B",logo:e?.logo??{url:"/svgs/eatsy_logo.svg"},splash:t?String(t):"",mime:o}))(i,a,c)),t},[]),p=r.map(t=>e?.result?.socialNetworks?.find(e=>e?.placeId===t?.placeId)).filter(Boolean)??[];return{activePlace:a,activeAppearance:d.find(e=>e?.placeId===n)??c.F2,activeSocialNetworks:p.find(e=>e?.placeId===n)??null,activeWebsite:s,websites:i,appearances:d,socialNetworks:p,splashes:e?.result?.splashes??[],places:r}},h=e=>({coverageSettings:e?.coverageSettings?.filter(e=>e.isActive)??[],deliverySettings:e?.deliverySettings??null,orderSettings:e?.orderSettings?{...e?.orderSettings,surchargeAmount:e?.orderSettings?.surchargeAmount||0,surchargeType:e?.orderSettings?.surchargeType||null,onlineOrderSurchargeName:e?.orderSettings?.onlineOrderSurchargeName||"Surcharge"}:null,takeoutSettings:e?.takeoutSettings??null,customDeliverySettings:e?.customDeliverySettings??null,customDeliveryCoverageSettings:e?.customDeliveryCoverageSettings?.filter(e=>e?.isActive)??[]}),I=(e,t)=>e?.filter(e=>e.isAvailable)?.map(e=>{let[o,i]=e.startTime.split(":"),n=t.hour(Number(o)).minute(Number(i)).second(0).millisecond(0);return{displayRange:`${r()(`2000-01-01T${e.startTime}`).format("h:mm A")} - ${r()(`2000-01-01T${e.endTime}`).format("h:mm A")}`,fullDateISO:n.toISOString()}})??[],y=e=>e?.toLowerCase()?.replace(/\s+/g,"")?.replace(/[^a-z0-9]/g,""),w=(e,t)=>{if(!e)return null;let o=t===s.zY.DELIVERY;return{...e,address:o?e?.address??"":"",addressLine2:o?e?.addressLine2??"":"",city:o?e?.city??"":"",state:o?e?.state??"":"",country:o?e?.country??"":"",zipCode:o?e?.zipCode??"":""}},v=e=>({...e,city:e.city.longText,state:e.state.shortText??e.state.longText,country:e.country.shortText??e.country.longText,zipCode:e.zipCode,latitude:e.latitude??null,longitude:e.longitude??null}),P=e=>({clientId:e.phone,address:e.address,addressLine2:e.addressLine2,email:e.email,firstName:e.firstName,lastName:e.lastName,phone:e.phone,city:e?.city?.shortText??e?.city?.longText,country:e?.country?.shortText??e?.country?.longText,state:e?.state?.shortText??e?.state?.longText,zipCode:e?.zipCode}),b=(e,t,o,i,r,n,l)=>{let c=e.originalPrice||e.price,{promotions:p,promotion:u,...m}=e,_={...m,price:c,tax:i,clientId:r,shippingPrice:n?.coverageType===s.Dk.PER_UNIT?n.amount:o?0:l},f=[],g=[];if(e.isRewardArticle&&e.parentPromotionArticleId){let o=t.find(t=>!t.isRewardArticle&&(!!t.cartItemId&&t.cartItemId===e.parentPromotionArticleId||t.articleId===e.parentPromotionArticleId));o?0===(g=o.promotions||(o.promotion?[o.promotion]:[])).length&&(g=e.promotions||(e.promotion?[e.promotion]:[])):e.promotion?.promotion_type==="checkout_reward"&&(g=e.promotions||(e.promotion?[e.promotion]:[]))}else g=e.promotions||(e.promotion?[e.promotion]:[]);if(g.length>0){let t=!0===e.isRewardArticle;for(let e of g){let o="bogo"===e.promotion_type,i="checkout_reward"===e.promotion_type,r=o&&"other_product"===e.reward_type,n=o&&"same_product"===e.reward_type;
1if(r||n||i){if(t){let t=(0,d.O0)(e);t&&f.push(t)}}else{let t=(0,d.O0)(e);t&&f.push(t)}}t&&(_.isRewardArticle=!0,e.parentPromotionArticleId&&(_.parentPromotionArticleId=e.parentPromotionArticleId))}if(f.length>0&&(_.promotions=f),_.isRewardArticle&&_.parentPromotionArticleId){let e=t.find(e=>!e.isRewardArticle&&(!!e.cartItemId&&e.cartItemId===_.parentPromotionArticleId||e.articleId===_.parentPromotionArticleId));e?_.parentPromotionArticleId=e.articleId:delete _.parentPromotionArticleId}let{promotionTag:h,originalPrice:I,hasRequiredModifiers:y,cartItemId:w,isCatering:v,preparationTime:P,promotionDiscountedUnits:b,...A}=_;A.modifiers&&(A.modifiers=(0,a.K7)(A.modifiers));let S={...A};if((null===S.externalReferenceId||""===S.externalReferenceId)&&delete S.externalReferenceId,S.parent){let{isCatering:e,...t}=S.parent;S.parent=t}return S},A=e=>{if(!e||"string"!=typeof e)return null;let t=e.split(",").map(e=>e.trim());if(t.length<3)return null;let o=t[0]||"",i=t[1]||"",r=(t[2]||"").match(/^([A-Z]{2})\s+(\d{5}(?:-\d{4})?)$/);return{streetAddress:o,city:i,state:r?r[1]:"",zipCode:r?r[2]:"",country:"US"}}},87651:(e,t,o)=>{o.d(t,{Cs:()=>l,F2:()=>i,Km:()=>a,aw:()=>c,q:()=>n,w3:()=>r});let i={placeId:"",colorPrimary:"#ec6533",colorSecondary:"#273D4B",splash:"",logo:{url:"/svgs/eatsy_logo.svg"},restaurant_policies:"",categoriesPosition:"top",socialNetworks:[]},r={NONE:0,GVT_TOKEN:1,APPLE_PAY:2,GOOGLE_PAY:3,LOYALTY_ONLY:4,LOYALTY_WITH_MONEY:5},n={NONE:"NONE",SUCCESS:"SUCCESS",ADDRESS_INVALID:"ADDRESS_INVALID",AMOUNT_INVALID:"AMOUNT_INVALID"},a={WS_URL:"https://graphql.eatsyorders.com/graphql",WS_CMS_URL:"https://cms.eatsyorders.com",WS_CMS_TOKEN:"19d674bb3a2cbef79410a6674b869004d7a0825d29e82eb88f994679ee7a65967beccb9c128a355bee198f1f0c01e6552418918962bd90215005607923d99770473b17b7cd1b9705c0d03d68fe85459c36f2446844dd26d7e0bdd54c4356c2aecf712c0515c9080695f7e21f474e80b291c324ded683a85b44c86b1b5ce62568",AWS_IDENTITYPOOLID:"us-east-1:4eee1d69-554a-4e18-a046-e5eb5be33e47",AWS_REGION:"us-east-1",CLIENT_ID:"61q4tic9fteusb3diqmq1ta2l2",USER_POOL:"us-east-1_qSgoiOy7j",PUBLIC_KEY_NMI:"T6Ssf6-gDV5R4-GuxVF5-n3QFX5",PUBLIC_PRIVATE_KEY_MMI:"6JpzRzMyAc2wkx2XzNHV993McUc4Ecvk",CUSTOMERS_API_URL:"https://api.eatsyorders.com",EATSY_GA_MEASUREMENT_ID:"G-7PJHRT29QR"},l={I4GO_ADDRESS:!1,I4GO_WALLETS:!0},c=3e3},98564:(e,t,o)=>{o.d(t,{UI:()=>I,bC:()=>_,hk:()=>q,YP:()=>S,Ze:()=>s,EV:()=>c,cR:()=>f,getProductPromotions:()=>C,SP:()=>l,aA:()=>A,xB:()=>h,ai:()=>w,Zl:()=>v,IW:()=>g,bv:()=>F,DU:()=>b,qF:()=>P,Xq:()=>Z,pv:()=>X,Sl:()=>j,hJ:()=>Y,O0:()=>z,z$:()=>W,nQ:()=>R,U8:()=>J});var i=o(29027),r=o(10335),n=o(61892);let a=e=>e?.promotion_type==="bogo"&&"other_product"===e.reward_type&&!0===e.select_only_one_reward_article&&(e.reward_article_ids?.length||0)>1,l=(e,t,o)=>{if(!e)return"";let{offer:i,off:r,promotion_product_discount:l,promotion_product_simple:c,promotion_discount_applied:s,promotion_product_single:d,promotion_product_plural:p,promotion_choose_one_description:u,promotion_choose_one_description_fallback:m}=n.K[t].product;switch(e.promotion_type){case"bogo":if("same_product"===e.reward_type){let o=e.trigger_quantity||1;if("es"===t)return 1===o?"Compra 1, Lleva 1 Gratis":`Compra ${o}, Lleva 1 Gratis`;return 1===o?"Buy 1, Get 1 Free":`Buy ${o}, Get 1 Free`}if(a(e)){let i=e.trigger_quantity||1,r=e.reward_article_ids?.length||0;if(o?.length===r){let e,r,a;return u.replace("{trigger}",String(i)).replace("{rewards}",(e=o.slice(0,-1).join(", "),r=n.K[t].product,a=2===o.length?r.promotion_choose_one_list_two_separator:r.promotion_choose_one_list_many_separator,`${e}${a}${o[o.length-1]}`))}return m.replace("{trigger}",String(i))}if(o&&o.length>0){let i=e.trigger_quantity||1;if(1===o.length)return"es"===t?`Compra ${i}, Lleva 1 ${o[0]} Gratis`:`Buy ${i}, Get 1 ${o[0]} Free`;let r=2===o.length?`${o[0]} y ${o[1]}`:`${o.slice(0,-1).join(", ")}, y ${o[o.length-1]}`;return"es"===t?`Compra ${i}, Lleva 1 ${r} Gratis`:`Buy ${i}, Get 1 ${r} Free`}let _=e.trigger_quantity||1;return"es"===t?`Compra ${_}, Lleva 1 ${d} Gratis`:`Buy ${_}, Get 1 ${d} Free`;case"product":if(e.trigger_quantity){let t="percentage"===e.discount_type?`${e.discount_value}% ${r}`:`$${e.discount_value} ${r}`,o=1===e.trigger_quantity?d:p;return l.replace("{trigger}",String(e.trigger_quantity)).replace("{discount}",t).replace("{productWord}",o)}let f="percentage"===e.discount_type?`${e.discount_value}% ${r}`:`$${e.discount_value} ${r}`;return c.replace("{discount}",f);case"discount":let g="percentage"===e.discount_type?`${e.discount_value}% ${r}`:`$${e.discount_value} ${r}`;return s.replace("{discount}",g);default:return i}},c=e=>{let t=[],o=new Map,i=new Map,r=new Map;
1for(let o of e){if(o.isRewardArticle)continue;t.push(o),o.cartItemId&&i.set(o.cartItemId,o);let e=r.get(o.articleId)||[];e.push(o),r.set(o.articleId,e)}for(let t of e){if(!t.isRewardArticle)continue;let e=t.parentPromotionArticleId||"",n=t.promotion?.documentId||t.promotions&&t.promotions[0]?.documentId||"",a=e;if(e&&!i.has(e)){let i=r.get(e)||[];if(1===i.length&&i[0].cartItemId)a=i[0].cartItemId;else if(i.length>1){let e=i.find(e=>{if(!e.cartItemId)return!1;let i=`${t.articleId}-${e.cartItemId}-${n}`;return!o.has(i)});e?.cartItemId?a=e.cartItemId:i[0].cartItemId&&(a=i[0].cartItemId)}}let l=`${t.articleId}-${a}-${n}`,c=o.get(l),s=a!==e?{...t,parentPromotionArticleId:a}:t;if(!c){o.set(l,s);continue}let d=(s.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0)>(c.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0)?s:c;o.set(l,{...d,quantity:Math.max(s.quantity||0,c.quantity||0)})}return[...t,...o.values()]},s=e=>{let t=[],o=new Map;for(let i of e){if(!i?.isRewardArticle){t.push(i);continue}let e=i.promotions?.[0]?.documentId||"",r=`${i.articleId}-${i.parentPromotionArticleId||""}-${e}`,n=o.get(r);if(!n){o.set(r,i);continue}let a=(i.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0)>(n.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0)?i:n;o.set(r,{...a,quantity:Math.max(i.quantity||0,n.quantity||0)})}return[...t,...o.values()]},d=e=>parseFloat(e.price||"0")||0,p=e=>{let t=e.filter(e=>!e.isRewardArticle),o=e.filter(e=>e.isRewardArticle),i=new Map,r=e=>{if("bogo"!==e.promotion_type)return!1;let t=e.reward_article_ids?.length||0;return!("other_product"===e.reward_type&&t>1&&!0!==e.select_only_one_reward_article)};for(let e of t)for(let t of e.promotions||(e.promotion?[e.promotion]:[]))r(t)&&null!==t.reward_quantity&&void 0!==t.reward_quantity&&(i.has(t.documentId)||i.set(t.documentId,t.reward_quantity));let n=new Map,a=[];for(let e of o){let t=e.promotion?.documentId||e.promotions&&e.promotions[0]?.documentId||"";if(!t||!i.has(t)){a.push(e);continue}let o=i.get(t),r=n.get(t)||0,l=Math.max(0,o-r);if(l<=0)continue;let c=Math.max(0,e.quantity||0);if(c<=0)continue;let s=Math.min(c,l);a.push({...e,quantity:s}),n.set(t,r+s)}return[...t,...a]},u=e=>{let t=new Map;for(let o of e)if(!o.isRewardArticle)for(let e of o.promotions||(o.promotion?[o.promotion]:[]))("discount"===e.promotion_type||"product"===e.promotion_type)&&null!==e.reward_quantity&&void 0!==e.reward_quantity&&(t.has(e.documentId)||t.set(e.documentId,e.reward_quantity));if(0===t.size)return e;let o=new Map,i=[];return e.forEach((e,o)=>{let r=(e=>{if(!e.isRewardArticle)return(e.promotions||(e.promotion?[e.promotion]:[])).find(e=>("discount"===e.promotion_type||"product"===e.promotion_type)&&null!=e.reward_quantity&&t.has(e.documentId))})(e);r&&i.push({item:e,index:o,promotion:r})}),i.sort((e,t)=>d(e.item)-d(t.item)||e.index-t.index).forEach(({item:e,index:i,promotion:r})=>{let n=t.get(r.documentId)??0,a=Math.min(e.quantity||0,Math.max(0,n));t.set(r.documentId,n-a),o.set(i,a)}),e.map((e,t)=>o.has(t)?{...e,promotionDiscountedUnits:o.get(t)}:e)},m=(e,t=!0)=>{let o=e.promotions||(e.promotion?[e.promotion]:[]);if(e.isRewardArticle&&o.length>0){let i=o.filter(e=>!e.requires_registration||t);if(i.length>0){let t=i.find(e=>"bogo"===e.promotion_type&&100===e.discount_value);if(t)return T(e.originalPrice?parseFloat(e.originalPrice):parseFloat(e.price||"0"),t.discount_type,t.discount_value)}return parseFloat(e.price||"0")}if(0===o.length)return parseFloat(e.price||"0");let i=o.filter(e=>!e.requires_registration||t);if(0===i.length)return parseFloat(e.price||"0");let r=e.originalPrice?parseFloat(e.originalPrice):parseFloat(e.price||"0"),n=e.quantity,a=[...i].sort((e,t)=>"bogo"===e.promotion_type&&("discount"===t.promotion_type||"product"===t.promotion_type)?1:("discount"===e.promotion_type||"product"===e.promotion_type)&&"bogo"===t.promotion_type?-1:0),l=r;for(let t of a)switch(t.promotion_type){case"discount":{if(n<(t.trigger_quantity??1))continue;let o=void 0!==e.promotionDiscountedUnits?e.promotionDiscountedUnits:t.reward_quantity||n,i=Math.min(n,o),r=n-i;if(i>0){let e=T(l,t.discount_type,t.discount_value);l=r>0?(e*i+l*r)/n:e}break}case"product":if(n>=(t.trigger_quantity||1)){let e=t.reward_quantity,o=null!=e?Math.min(n,e):n,i=n-o;if(o>0){let e=T(l,t.discount_type,t.discount_value);l=(l*i+e*o)/n}}break;case"bogo":"same_product"===t.reward_type&&(l=r)}return l},_=(e,t=!0)=>(m(e,t)+(0,i.fz)(e.modifiers??[]))*e.quantity,f=(e,t=!0)=>{let o=e.originalPrice?parseFloat(e.originalPrice):parseFloat(e.price||"0"),i=e.promotions||(e.promotion?[e.promotion]:[]);if(0===i.length||e.isRewardArticle)return{hasDiscount:!1,discountedUnits:0,originalPrice
1:o,discountedPrice:o,discountPromotion:null,capSpentElsewhere:!1};let r=i.filter(e=>!e.requires_registration||t);if(0===r.length)return{hasDiscount:!1,discountedUnits:0,originalPrice:o,discountedPrice:o,discountPromotion:null,capSpentElsewhere:!1};let n=r.filter(e=>"discount"===e.promotion_type||"product"===e.promotion_type),a=r.filter(e=>"bogo"===e.promotion_type&&"same_product"===e.reward_type),l=e.quantity,c=m(e,t),s=0,d=o;if(n.length>0){let t=n[0];switch(t.promotion_type){case"discount":if(l>=(t.trigger_quantity??1)){let i=void 0!==e.promotionDiscountedUnits?e.promotionDiscountedUnits:t.reward_quantity||l;s=Math.min(l,i),d=T(o,t.discount_type,t.discount_value)}break;case"product":if(l>=(t.trigger_quantity||1)){if(void 0!==e.promotionDiscountedUnits)s=Math.min(l,e.promotionDiscountedUnits);else{let e=t.reward_quantity;s=null!=e?Math.min(l,e):l}d=T(o,t.discount_type,t.discount_value)}}}if(a.length>0){let e=a[0],t=e.trigger_quantity||1,o=e.reward_quantity;if(l>=t){if("same_product"===e.reward_type){let e=y(l,t,o);e>0&&(s=Math.max(s,e),d=0)}else if("other_product"===e.reward_type){let e=+Math.floor(l/t);o&&e>o&&(e=o),e>0&&(s=Math.max(s,e),d=0)}}}let p=n.length>0?n[0]:null;return{hasDiscount:c<o||s>0,discountedUnits:s,originalPrice:o,discountedPrice:c<o?c:s>0?d:o,discountPromotion:p||null,capSpentElsewhere:null!==p&&0===e.promotionDiscountedUnits&&0===s}},g=e=>{let t=[],o=new Map;return e.forEach((e,i)=>{let r=e.isRewardArticle&&e.promotion?.promotion_type==="checkout_reward";if(e.isRewardArticle&&e.parentPromotionArticleId&&!r){let t=e.parentPromotionArticleId;o.has(t)||o.set(t,[]),o.get(t)?.push(e)}else t.push({article:e,position:i,rewardArticles:[]})}),t.map(e=>{let t=e.article.cartItemId,i=e.article.articleId,r=t&&o.get(t)||[],n=o.get(i)||[],a=new Map;for(let e of[...r,...n]){let t=e.promotion?.documentId||e.promotions&&e.promotions[0]?.documentId||"",o=`${e.articleId}-${e.parentPromotionArticleId||""}-${t||"no-promo"}`,i=`${e.articleId}-${e.parentPromotionArticleId||""}`,r=a.get(o)||a.get(i);if(!r){a.set(o,e);continue}let n=e.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0,l=r.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0,c=r.promotion?.documentId||r.promotions&&r.promotions[0]?.documentId||"",s=n>l||!c&&t?e:r,d=t||c?`${s.articleId}-${s.parentPromotionArticleId||""}-${t||c}`:i;a.delete(o),a.delete(i),a.set(d,{...s,quantity:Math.max(e.quantity||0,r.quantity||0)})}let l=[...a.values()];return{...e,rewardArticles:l}})},h=(e,t="Oferta",o="OFF",i="Gratis",r="Obsequio",l,c)=>{if(!e)return t;switch(e.promotion_type){case"bogo":{let t=e.trigger_quantity||1,o="es"===l;if("same_product"===e.reward_type)if(o){if(1===t)return"Compra 1, Lleva 1\nGratis";return`Compra ${t}, Lleva 1
2Gratis`}else{if(1===t)return"Buy 1, Get 1\nFree";return`Buy ${t}, Get 1
3Free`}if(a(e))return n.K["es"===l?"es":"en"].product.promotion_choose_one_tag.replace("{trigger}",String(t));if(c&&c.length>0){if(1===c.length)if(o)return`Compra ${t}, Lleva 1
4Gratis`;else return`Buy ${t}, Get 1
5Free`;if(o)return`Compra ${t}, Lleva 1
6Gratis`;return`Buy ${t}, Get 1
7Free`}if(o){if(1===t)return"Compra 1, Lleva 1\nGratis";return`Compra ${t}, Lleva 1
8Gratis`}if(1===t)return"Buy 1, Get 1\nFree";return`Buy ${t}, Get 1
9Free`}case"product":case"discount":if("percentage"===e.discount_type)return`${e.discount_value}% ${o}`;return`$${e.discount_value} ${o}`;case"checkout_reward":return r;default:return t}},I=(e,t,o="Oferta",i="OFF",r="Gratis",n="Obsequio",a)=>{let l=Array.isArray(t)?t:t?[t]:[];if(0===l.length){let{promotion:t,promotions:o,promotionTag:i,...r}=e,n=e.originalPrice||e.price;return{...r,price:n,originalPrice:n}}let c=e.quantity,s=l.filter(e=>c>=(e.trigger_quantity||1));if(0===s.length){let{promotion:t,promotions:o,promotionTag:i,...r}=e,n=e.originalPrice||e.price;return{...r,price:n,originalPrice:n}}let d=e.originalPrice||e.price,p=parseFloat(d||"0")||0,u=s[0],_=p;return"product"===u.promotion_type||"discount"===u.promotion_type?_=m({...e,price:d,originalPrice:d,promotion:u},!0):"bogo"===u.promotion_type&&"same_product"===u.reward_type&&(_=p),{...e,price:_.toFixed(2),originalPrice
9:d,promotions:s.length>1?s:void 0,promotion:1===s.length?s[0]:void 0,promotionTag:1===s.length?h(s[0],o,i,r,n,a):void 0}},y=(e,t,o)=>{let i=Math.floor(e/t);return o&&i>o&&(i=o),i},w=(e,t,o,i,r)=>{if("bogo"!==t.promotion_type||"same_product"!==t.reward_type)return[];let n=t.trigger_quantity||1,a=t.reward_quantity;if(e.quantity<n)return[];let l=y(e.quantity,n,a);if(0===l)return[];let c=e.cartItemId||o||e.articleId,s=i?.find(o=>o.articleId===e.articleId&&o.parentPromotionArticleId===c&&o.promotion?.documentId===t.documentId);if(s)return[{...s,quantity:l}];if(null!=a&&r&&r.find(o=>o.isRewardArticle&&o.promotion?.documentId===t.documentId&&o.articleId===e.articleId))return[];let d=parseFloat(e.price||e.originalPrice||"0")||0,p=e.modifiers||[];return[{articleId:e.articleId,externalReferenceId:e.externalReferenceId||"",clientId:e.clientId||"",name:e.name,price:d.toFixed(2),originalPrice:d.toFixed(2),quantity:l,modifiers:p,translations:e.translations||[],notes:"",promotion:t,promotionTag:"Gratis",imageUrl:e.imageUrl||"",parentPromotionArticleId:c,isRewardArticle:!0,preparationTime:e.preparationTime,isCatering:e.isCatering,parent:e.parent}]},v=async(e,t,o,i,r,n,a,l,c,s)=>{if("bogo"!==t.promotion_type&&"checkout_reward"!==t.promotion_type||"other_product"!==t.reward_type||!t.reward_article_ids||0===t.reward_article_ids.length)return[];let d="checkout_reward"===t.promotion_type,p=d?1:t.trigger_quantity||1,u=d?void 0:t.reward_quantity;if(e.quantity<p)return[];let m=d?1:+Math.floor(e.quantity/p);if(u&&m>u&&(m=u),0===m)return[];let _=!0===t.select_only_one_reward_article&&(t.reward_article_ids?.length||0)>1;if((_||1===(t.reward_article_ids?.length||0))&&null!=u&&c&&c.find(e=>e.isRewardArticle&&e.promotion?.documentId===t.documentId&&t.reward_article_ids?.includes(e.articleId)))return[];let f=a||e.articleId;if(_){let a=l?.find(e=>e.parentPromotionArticleId===f&&e.promotion?.documentId===t.documentId&&t.reward_article_ids?.includes(e.articleId));if(!a){if(!s||!t.reward_article_ids?.includes(s))return[];try{let a=await o(s,i);if(!a?.result)return[];let l=r(a.result,n);if(!l)return[];let c=l.articleImages?.[0],d=c?`${c.imagePath}${c.format?.small||c.format?.large||""}`:"",p=parseFloat(l.price||"0")||0,u=l.modifierGroups?.some(e=>e?.minimalOptionNumber>=1)||!1;return[{articleId:l.articleId,externalReferenceId:l.externalReferenceId||"",clientId:e.clientId||"",name:l.name,price:"0.00",originalPrice:p.toFixed(2),quantity:m,modifiers:[],translations:l.translations||[],notes:"",promotion:t,promotionTag:"Gratis",imageUrl:d,parentPromotionArticleId:f,isRewardArticle:!0,hasRequiredModifiers:u,parent:e.parent,isCatering:e.isCatering}]}catch(e){return console.error("Error loading selected reward article:",e),[]}}return[{...a,price:"0.00",quantity:m,promotion:a.promotion||t,promotionTag:a.promotionTag||"Gratis"}]}let g=[];for(let a of t.reward_article_ids){let c=l?.find(e=>e.articleId===a&&e.parentPromotionArticleId===f&&e.promotion?.documentId===t.documentId);if(c||(c=l?.find(e=>e.articleId===a&&e.parentPromotionArticleId===f)),c)g.push({...c,price:"0.00",quantity:m,promotion:c.promotion||t,promotionTag:c.promotionTag||"Gratis"});else try{let l=await o(a,i);if(l?.result){let o=r(l.result,n);if(!o)continue;let i=o.articleImages?.[0],a=i?`${i.imagePath}${i.format?.small||i.format?.large||""}`:"",c=parseFloat(o.price||"0")||0,s=o.modifierGroups?.some(e=>e?.minimalOptionNumber>=1)||!1;g.push({articleId:o.articleId,externalReferenceId:o.externalReferenceId||"",clientId:e.clientId||"",name:o.name,price:"0.00",originalPrice:c.toFixed(2),quantity:m,modifiers:[],translations:o.translations||[],notes:"",promotion:t,promotionTag:"Gratis",imageUrl:a,parentPromotionArticleId:f,isRewardArticle:!0,hasRequiredModifiers:s,preparationTime:e.preparationTime,isCatering:e.isCatering,parent:e.parent})}}catch(e){console.error(`Error fetching reward article ${a}:`,e)}}return g},P=(e,t,o,i,n,a=new Date,l=!1)=>{if("active"!==e.state||!e.channel_ids.includes(o)||!e.article_ids.includes(t)||!l&&e.requires_registration&&!i||e.start_date&&a<new Date(e.start_date)||e.end_date&&a>new Date(e.end_date)||e.max_total_uses&&e.usage_count>=e.max_total_uses)return!1;if(e.requires_registration&&e.max_uses_per_customer&&n&&e.customer_usages){let t=e.customer_usages.find(e=>e.clientId===n);if(t&&t.usageCount>=e.max_uses_per_customer)return!1}
9return!!e.schedule&&0!==e.schedule.length&&!!(0,r.O)(e.schedule)},b=(e,t,o,i,n=new Date,a=!1)=>{if("checkout_reward"!==e.promotion_type||"active"!==e.state||!e.channel_ids.includes(t)||!a&&e.requires_registration&&!o||e.start_date&&n<new Date(e.start_date)||e.end_date&&n>new Date(e.end_date)||e.max_total_uses&&e.usage_count>=e.max_total_uses)return!1;if(e.requires_registration&&e.max_uses_per_customer&&i&&e.customer_usages){let t=e.customer_usages.find(e=>e.clientId===i);if(t&&t.usageCount>=e.max_uses_per_customer)return!1}return!!e.schedule&&0!==e.schedule.length&&!!(0,r.O)(e.schedule)},A=e=>{switch(e.promotion_type){case"bogo":case"checkout_reward":return 3;case"product":return 2;case"discount":return 1;default:return 0}},S=(e,t)=>{if(0===t.length)return!0;let o=!0===e.can_combine_with_other_promotions;return!!o&&(!o||t.every(e=>!0===e.can_combine_with_other_promotions))},q=(e,t)=>!t||!0===e.can_combine_with_coupons,F=e=>e.some(e=>{let t=e.promotions||(e.promotion?[e.promotion]:[]);return 0!==t.length&&t.some(e=>!1===e.can_combine_with_coupons||void 0===e.can_combine_with_coupons)}),C=async(e,t,o,i,r,n=0,a,l,c,s=[],d=0,p)=>{let u=new Date,m=e.filter(e=>{if("checkout_reward"===e.promotion_type)return!1;let n=P(e,t,o,i,r,u,!1);return n&&p?q(e,p):n});if(0===m.length)return[];let _=m.sort((e,t)=>{let o=A(e),i=A(t);if(o!==i)return i-o;if(o===i&&("product"===e.promotion_type||"discount"===e.promotion_type)){let o="percentage"===e.discount_type&&e.discount_value||0;return("percentage"===t.discount_type&&t.discount_value||0)-o}return 0}),f=_.filter(e=>!0===e.can_combine_with_other_promotions),g=_.filter(e=>!1===e.can_combine_with_other_promotions),h=s.some(e=>!0===e.can_combine_with_other_promotions),I=s.some(e=>!1===e.can_combine_with_other_promotions),y=s.filter(e=>!0===e.can_combine_with_other_promotions).length,w=f.length>0,v=y;w&&(v+=1);let b=(v+=d)>=2&&I;if(f.length>0&&g.length>0)if(A(g[0])>=A(f[0])){if(!h&&!I)return[g[0]];if(!h&&I||h)return[]}else{if(!I){let e=f.filter(e=>S(e,s));if(e.length>0)return e.every(t=>{let o=e.filter(e=>e.documentId!==t.documentId);return S(t,[...o,...s])})?e:[e[0]]}return[]}if(f.length>0){if(I&&!b)return[];let e=f.filter(e=>S(e,s));if(e.length>0){if(e.every(t=>{let o=e.filter(e=>e.documentId!==t.documentId);return S(t,[...o,...s])}))return e;let t=A(e[0]),o=e.filter(e=>A(e)===t);if(1===o.length)return[o[0]];if(o.length>1&&(2===t||1===t))return[o.reduce((e,t)=>{let o="percentage"===e.discount_type&&e.discount_value||0;return("percentage"===t.discount_type&&t.discount_value||0)>o?t:e})]}return[]}if(g.length>0){if(h&&b)return[];if(I){let e=s.find(e=>!1===e.can_combine_with_other_promotions);if(e){if(e.documentId===g[0].documentId)return[g[0]];let t=A(e),o=A(g[0]);if(o>t)return[g[0]];if(o===t&&("product"===g[0].promotion_type||"discount"===g[0].promotion_type)&&("percentage"===g[0].discount_type&&g[0].discount_value||0)>("percentage"===e.discount_type&&e.discount_value||0))return[g[0]]}return[]}return[g[0]]}return[]},T=(e,t,o)=>"percentage"===t?e*(1-o/100):Math.max(0,e-o),$=async(e,t,o,i,r,n,a,l)=>{if(!o){let{promotion:t,promotions:o,originalPrice:i,promotionTag:r,...n}=e,a=parseFloat(e.price||"0");return{articles:[{...n,price:a.toFixed(2)}],rewardArticles:[],discountAmount:0}}let c=t.findIndex(t=>t.articleId===e.articleId&&t.notes===e.notes&&(!e.modifiers.length||0===t.modifiers.length)),s=e.quantity;c>=0&&(s+=t[c].quantity);let d={...e,quantity:s},p=((e,t)=>{let o={articles:[],rewardArticles:[],appliedPromotion:t,discountAmount:0},i=e.originalPrice?parseFloat(e.originalPrice):parseFloat(e.price||"0"),r=e.quantity;switch(t.promotion_type){case"discount":let n=void 0!==e.promotionDiscountedUnits?e.promotionDiscountedUnits:t.reward_quantity||r,a=Math.min(r,n),l=r-a;if(a>0){var c,s;let n=T(i,t.discount_type,t.discount_value),d=(c=t.discount_type,s=t.discount_value,"percentage"===c?i*s/100*a:s*a);if(l>0){let c=(n*a+i*l)/r;o.articles.push({...e,price:c.toFixed(2),originalPrice:i.toFixed(2),promotion:t,promotionTag:"percentage"===t.discount_type?`${t.discount_value}% OFF`:`$${t.discount_value} OFF`})}
9else o.articles.push({...e,price:n.toFixed(2),originalPrice:i.toFixed(2),promotion:t,promotionTag:"percentage"===t.discount_type?`${t.discount_value}% OFF`:`$${t.discount_value} OFF`});o.discountAmount=d}else{let{promotion:t,promotions:r,originalPrice:n,promotionTag:a,...l}=e;o.articles.push({...l,price:i.toFixed(2)})}break;case"product":if(r>=(t.trigger_quantity||1)){let n=t.reward_quantity,a=null!=n?Math.min(r,n):r,l=r-a;if(a>0){let n="percentage"===t.discount_type?i*t.discount_value/100:t.discount_value,c=T(i,t.discount_type,t.discount_value),s=(i*l+c*a)/r;o.articles.push({...e,price:s.toFixed(2),originalPrice:i.toFixed(2),promotion:t,promotionTag:"percentage"===t.discount_type?`${t.discount_value}% OFF`:`$${t.discount_value} OFF`}),o.discountAmount=n*a}else{let{promotion:t,promotions:r,originalPrice:n,promotionTag:a,...l}=e;o.articles.push({...l,price:i.toFixed(2)})}}else{let{promotion:t,promotions:r,originalPrice:n,promotionTag:a,...l}=e;o.articles.push({...l,price:i.toFixed(2)})}break;case"bogo":if("same_product"===t.reward_type){o.articles.push({...e,price:i.toFixed(2),originalPrice:i.toFixed(2),promotion:t,promotionTag:`${t.trigger_quantity||1}x1`});let n=t.trigger_quantity||1;if(r>=n){let e=y(r,n,t.reward_quantity);e>0&&(o.discountAmount=i*e)}}else if("other_product"===t.reward_type){let n=t.trigger_quantity||1,a=t.reward_quantity;if(r>=n){let i=+Math.floor(r/n);a&&i>a&&(i=a),o.articles.push({...e,promotion:t,promotionTag:`${n}x1`}),t.reward_article_ids&&t.reward_article_ids.length>0&&t.reward_article_ids.forEach(e=>{for(let r=0;r<i;r++)o.rewardArticles.push({articleId:e,externalReferenceId:"",clientId:"",name:"",price:"0.00",quantity:1,modifiers:[],translations:[],notes:"",promotion:t,promotionTag:"Gratis",isRewardArticle:!0})}),o.discountAmount=0}else{let{promotion:t,promotions:r,originalPrice:n,promotionTag:a,...l}=e;o.articles.push({...l,price:i.toFixed(2)})}}break;case"checkout_reward":o.articles.push({...e,price:i.toFixed(2),originalPrice:i.toFixed(2),promotion:t,promotionTag:"Gratis"}),o.discountAmount=0}return o})(d,o);return"bogo"===o.promotion_type&&"other_product"===o.reward_type&&o.reward_article_ids&&o.reward_article_ids.length>0&&(p.rewardArticles=await v(d,o,i,r,n,a,l,t.filter(e=>e.isRewardArticle),t)),p},x=e=>{if(e.isRewardArticle||!e.promotion)return!1;let t=(()=>{try{let e=sessionStorage.getItem("rejectedRewardPromotions");if(!e)return new Set;return new Set(JSON.parse(e))}catch(e){return console.error("Error reading rejected reward promotions:",e),new Set}})();return!(t.size&&[e.cartItemId,e.articleId].filter(Boolean).some(o=>t.has(`${o}-${e.promotion?.documentId}`)))||"other_product"!==e.promotion.reward_type},R=async(e,t,o,i,r,n,a,l,c,s)=>{let d=new Date,p=[],u=e.filter(e=>x(e)).filter(e=>{let t;return t=e.promotion.trigger_quantity||1,(e.quantity||0)>=t}).map(e=>e.promotion).filter((e,t,o)=>t===o.findIndex(t=>t.documentId===e.documentId)),m=u.some(e=>!1===e.can_combine_with_other_promotions),_=u.filter(e=>!0===e.can_combine_with_other_promotions).length>=2&&m;for(let t of(u.filter(e=>"bogo"===e.promotion_type),e)){if(t.isRewardArticle)continue;if(!t.promotion){p.push(t);continue}let e=t.promotion;if(m&&!0===e.can_combine_with_other_promotions&&!_){let e=parseFloat(t.originalPrice||t.price||"0")||0;if(!t.originalPrice)try{let o=await n(t.articleId,a);if(o?.result){let t=l(o.result,c);t&&(e=parseFloat(t.price||"0")||0)}}catch(e){console.error(`Error fetching article ${t.articleId} for validation:`,e)}let{promotion:o,promotions:i,originalPrice:r,promotionTag:s,...d}=t;p.push({...d,price:e.toFixed(2),originalPrice:e.toFixed(2)});continue}let f=P(e,t.articleId,o,i,r,d),g=e.trigger_quantity||1,h=t.quantity>=g,I=u.filter(t=>t.documentId!==e.documentId),y=S(e,I),w=q(e,s);if(!f||!h||!y||!w){let e=parseFloat(t.originalPrice||t.price||"0")||0;if(!t.originalPrice)try{let o=await n(t.articleId,a);if(o?.result){let t=l(o.result,c);t&&(e=parseFloat(t.price||"0")||0)}}catch(e){console.error(`Error fetching article ${t.articleId} for validation:`,e)}let{promotion:o,promotions:i,originalPrice:r,promotionTag:s,...d}=t;
9p.push({...d,price:e.toFixed(2),originalPrice:e.toFixed(2)});continue}try{let o=await $({...t,price:t.originalPrice||t.price,originalPrice:t.originalPrice||t.price},[],e,n,a,l,c,t.articleId);if(o.articles.length>0){let e=o.articles[0];e.promotion?(p.push(e),o.rewardArticles.length>0&&p.push(...o.rewardArticles)):p.push(e)}else{let{promotion:e,promotions:o,originalPrice:i,promotionTag:r,...n}=t;p.push({...n,price:t.originalPrice||t.price})}}catch(a){console.error(`Error re-applying promotion for article ${t.articleId}:`,a);let{promotion:e,promotions:o,originalPrice:i,promotionTag:r,...n}=t;p.push({...n,price:t.originalPrice||t.price})}}let f=new Set(p.filter(e=>x(e)).map(e=>e.promotion.documentId)),g=e.filter(e=>e.isRewardArticle&&e.promotion).filter(e=>f.has(e.promotion.documentId));return p.push(...g),p},N=async(e,t,o,i,r,n,a)=>{let{revalidatedCart:l,mainArticles:c,hasNonCombinableActive:s}=e,d=l.reduce((e,t)=>e+(t.promotions||(t.promotion?[t.promotion]:[])).filter(e=>!0===e.can_combine_with_other_promotions).length,0),p=0,u=0;for(let e of c){if(l.some(t=>t.articleId===e.articleId)||e.articleId===t.articleId)continue;let o=(e.promotions||(e.promotion?[e.promotion]:[])).filter(e=>!0===e.can_combine_with_other_promotions).length;if(o>0)p+=o;else{let t=parseFloat(e.price||"0")||0;(await C(i,e.articleId,r,n,a,t,void 0,void 0,void 0,[],0)).some(e=>!0===e.can_combine_with_other_promotions)&&(u+=1)}}let m=l.some(e=>e.articleId===t.articleId),_=L(t).filter(e=>!0===e.can_combine_with_other_promotions).length,f=0;if(!m&&0===_){let e=parseFloat(t.price||"0")||0;(await C(i,t.articleId,r,n,a,e,void 0,void 0,void 0,[],0)).some(e=>!0===e.can_combine_with_other_promotions)&&(f=1)}let g=d+p+u+(m?0:_)+f,h=s||c.some(e=>e.articleId!==t.articleId&&(e.promotions||(e.promotion?[e.promotion]:[])).some(e=>!1===e.can_combine_with_other_promotions));return g>=2&&h},E=e=>{let{promotion:t,promotions:o,promotionTag:i,...r}=e,n=e.originalPrice||e.price;return{...r,price:n,originalPrice:n}},D=async(e,t,o,i,r,n,a,l,c,s)=>{if(e.promotion)return null;let d=parseFloat(e.price||"0")||0,p=t.activePromotions.filter(e=>!0===e.can_combine_with_other_promotions),u=(await C(o,e.articleId,i,r,n,d,void 0,void 0,void 0,p,0)).filter(e=>!0===e.can_combine_with_other_promotions);return u.length>0?I(e,u.length>1?u:u[0],a,l,c,s):null},O=async(e,t,o,i,r,n,a,l,c,s)=>{if(e.promotion)return null;let d=t.activePromotions.find(e=>!1===e.can_combine_with_other_promotions),p=t.activePromotions.find(e=>!0===e.can_combine_with_other_promotions);if(d&&!p){let p=parseFloat(e.price||"0")||0,u=await C(o,e.articleId,i,r,n,p,void 0,void 0,void 0,t.activePromotions,0),m=u.find(e=>!0===e.can_combine_with_other_promotions);if(m&&A(d)>=A(m)){let t=u.find(e=>!1===e.can_combine_with_other_promotions);return t?I(e,t,a,l,c,s):null}}let u=parseFloat(e.price||"0")||0,m=await C(o,e.articleId,i,r,n,u,void 0,void 0,void 0,t.activePromotions,0),_=t.activePromotions.filter(e=>!0===e.can_combine_with_other_promotions).length,f=t.activePromotions.filter(e=>!1===e.can_combine_with_other_promotions).length;if(1===_&&1===f){let o=t.activePromotions.find(e=>!0===e.can_combine_with_other_promotions),i=t.activePromotions.find(e=>!1===e.can_combine_with_other_promotions);if(o&&i){let t=A(o),r=A(i),n=m.find(e=>!0===e.can_combine_with_other_promotions),d=m.find(e=>!1===e.can_combine_with_other_promotions);if(r>t)return d?I(e,d,a,l,c,s):null;if(t>r)return n?I(e,n,a,l,c,s):null;if(d&&("product"===d.promotion_type||"discount"===d.promotion_type)){let t=n?.discount_type==="percentage"&&n.discount_value||0,o="percentage"===d.discount_type&&d.discount_value||0;if(o>t)return I(e,d,a,l,c,s);if(n&&t>=o)return I(e,n,a,l,c,s)}else if(d)return I(e,d,a,l,c,s);else if(n)return I(e,n,a,l,c,s)}}if(1===f&&0===_){let o=t.activePromotions.find(e=>!1===e.can_combine_with_other_promotions),i=m.find(e=>!0===e.can_combine_with_other_promotions);if(o&&i){let t=A(o),r=A(i);if(t>r){let t=m.find(e=>!1===e.can_combine_with_other_promotions);return t?I(e,t,a,l,c,s):null}if(r>t)return I(e,i,a,l,c,s);if("product"===o.promotion_type||"discount"===o.promotion_type){let t="percentage"===i.discount_type&&i.discount_value||0;if(!(("percentage"===o.discount_type&&o.discount_value||0)>t))return I(e,i,a,l,c,s);{let t=m.find(e=>!1===e.can_combine_with_other_promotions);return t?I(e,t,a,l,c,s):null}}{let t=m.find(e=>!1===e.can_combine_with_other_promotions);return t?I(e,t,a,l,c,s):null}}}return m.length>0&&!1===m[0].can_combine_with_other_promotions?I(e,m[0],a,l,c,s):null},k=async(e,t,o,i,r,n,a=!0)=>{let l=e.revalidatedCart.reduce((e,t)=>
9e+(t.promotions||(t.promotion?[t.promotion]:[])).filter(e=>!0===e.can_combine_with_other_promotions).length,0);for(let c of e.mainArticles){if(e.revalidatedCart.some(e=>e.articleId===c.articleId)||!a&&c.articleId===t)continue;if((c.promotions||(c.promotion?[c.promotion]:[])).some(e=>!0===e.can_combine_with_other_promotions)){l+=1;continue}let s=parseFloat(c.price||"0")||0;(await C(o,c.articleId,i,r,n,s,void 0,void 0,void 0,[],0)).filter(e=>!0===e.can_combine_with_other_promotions).length>0&&(l+=1)}return l},M=async(e,t,o,i,r,n,a,l,c,s)=>{var d,p,u;let m=parseFloat(e.price||"0")||0,_=L(e),f=_.length>0?_[0]:void 0,g=f?A(f):0,h=(d=t.mainArticles,p=t.revalidatedCart,u=e.articleId,[...d.filter(e=>e.articleId!==u).flatMap(e=>e.promotions||(e.promotion?[e.promotion]:[])),...p.filter(e=>e.articleId!==u).flatMap(e=>e.promotions||(e.promotion?[e.promotion]:[]))].filter((e,t,o)=>t===o.findIndex(t=>t.documentId===e.documentId))),y=new Set(_.map(e=>e.documentId)),w=t.activePromotions.filter(e=>!y.has(e.documentId)),v=await C(o,e.articleId,i,r,n,m,void 0,void 0,void 0,w,0);if(0===v.length)return null;let P=v[0],b=A(P),q=h.filter(e=>!P||e.documentId!==P.documentId);if(S(P,q),!0===P.can_combine_with_other_promotions){let a=h.filter(e=>!0===e.can_combine_with_other_promotions).length,l=0===a?await k(t,e.articleId,o,i,r,n,!0):a,c=h.some(e=>!1===e.can_combine_with_other_promotions)||t.mainArticles.some(t=>t.articleId!==e.articleId&&(t.promotions||(t.promotion?[t.promotion]:[])).some(e=>!1===e.can_combine_with_other_promotions));if(c&&!(l>=2&&c))return null}if(!1===P.can_combine_with_other_promotions&&await k(t,e.articleId,o,i,r,n,!0)>=2)return null;if(!f||b>g){let t=v.length>1&&v.every(e=>!0===e.can_combine_with_other_promotions)?v:[P];return I(e,t.length>1?t:t[0],a,l,c,s)}if(b===g&&f&&("product"===P.promotion_type||"discount"===P.promotion_type)&&("percentage"===P.discount_type&&P.discount_value||0)>("percentage"===f.discount_type&&f.discount_value||0)){let t=v.length>1&&v.every(e=>!0===e.can_combine_with_other_promotions)?v:[P];return I(e,t.length>1?t:t[0],a,l,c,s)}return null},L=e=>e.promotions&&e.promotions.length>0?e.promotions:e.promotion?[e.promotion]:[],U=async(e,t,o,i,r,n)=>{if(e.hasNonCombinableActive)return!0;for(let o of e.mainArticles){if(o.articleId===t)continue;let i=(o.promotions||(o.promotion?[o.promotion]:[])).find(e=>!1===e.can_combine_with_other_promotions);if(i&&e.activePromotions.some(e=>e.documentId===i.documentId))return!0}for(let o of e.revalidatedCart){if(o.articleId===t)continue;let i=(o.promotions||(o.promotion?[o.promotion]:[])).find(e=>!1===e.can_combine_with_other_promotions);if(i&&e.activePromotions.some(e=>e.documentId===i.documentId))return!0}return!1},G=async(e,t,o,i,r,n,a,l,c,s)=>{let d=L(e),p=d.length>0?d[0]:void 0;if(p&&p.requires_registration&&!r){let t=new Date;if(!P(p,e.articleId,i,r,n,t)){let{promotion:t,promotions:o,originalPrice:i,promotionTag:r,...n}=e,a=parseFloat(e.originalPrice||e.price||"0")||0;return{...n,price:a.toFixed(2),originalPrice:a.toFixed(2)}}}if(!p){let a=t.activePromotions.find(e=>!1===e.can_combine_with_other_promotions),l=t.activePromotions.find(e=>!0===e.can_combine_with_other_promotions);if(a&&!l){let l=parseFloat(e.price||"0")||0,c=(await C(o,e.articleId,i,r,n,l,void 0,void 0,void 0,t.activePromotions,0)).find(e=>!0===e.can_combine_with_other_promotions);if(c){let t=A(a),o=A(c);if(t>o)return e;if(t===o)if("product"!==a.promotion_type&&"discount"!==a.promotion_type)return e;else{let t="percentage"===c.discount_type&&c.discount_value||0;if(("percentage"===a.discount_type&&a.discount_value||0)>=t)return e}}}}let u=await U(t,e.articleId,o,i,r,n),m=await N(t,e,p,o,i,r,n);if(u&&m){let d=L(e).some(e=>!1===e.can_combine_with_other_promotions)?E(e):null;if(d)return d;if(!p){let d=await D(e,t,o,i,r,n,a,l,c,s);if(d)return d}}if(u&&!m){let d=await k(t,e.articleId,o,i,r,n,!0);if(d>=2){let t=L(e).some(e=>!0===e.can_combine_with_other_promotions)?E(e):null;if(t)return t}if(1===d){let o=t.activePromotions.find(e=>!0===e.can_combine_with_other_promotions),i=t.activePromotions.find(e=>!1===e.can_combine_with_other_promotions);if(o&&i){let r=A(o),n=A(i);if(n>r){if(p&&!0===p.can_combine_with_other_promotions){let{promotion:i,promotions:r,originalPrice
9:n,promotionTag:a,...l}=e,c=parseFloat(e.originalPrice||e.price||"0")||0;return t.activePromotions=t.activePromotions.filter(e=>e.documentId!==o.documentId),t.combinableActiveCount=0,t.hasNonCombinableActive=!0,{...l,price:c.toFixed(2),originalPrice:c.toFixed(2)}}if(!p)return e}if(r>n&&p&&!1===p.can_combine_with_other_promotions){let{promotion:o,promotions:r,originalPrice:n,promotionTag:a,...l}=e,c=parseFloat(e.originalPrice||e.price||"0")||0;return t.activePromotions=t.activePromotions.filter(e=>e.documentId!==i.documentId),t.combinableActiveCount=1,t.hasNonCombinableActive=!1,{...l,price:c.toFixed(2),originalPrice:c.toFixed(2)}}if(r===n)if("product"===i.promotion_type||"discount"===i.promotion_type){let r="percentage"===o.discount_type&&o.discount_value||0;if(("percentage"===i.discount_type&&i.discount_value||0)>r){if(p&&!0===p.can_combine_with_other_promotions){let{promotion:i,promotions:r,originalPrice:n,promotionTag:a,...l}=e,c=parseFloat(e.originalPrice||e.price||"0")||0;return t.activePromotions=t.activePromotions.filter(e=>e.documentId!==o.documentId),t.combinableActiveCount=0,t.hasNonCombinableActive=!0,{...l,price:c.toFixed(2),originalPrice:c.toFixed(2)}}if(!p)return e}else if(p&&!1===p.can_combine_with_other_promotions){let{promotion:o,promotions:r,originalPrice:n,promotionTag:a,...l}=e,c=parseFloat(e.originalPrice||e.price||"0")||0;return t.activePromotions=t.activePromotions.filter(e=>e.documentId!==i.documentId),t.combinableActiveCount=1,t.hasNonCombinableActive=!1,{...l,price:c.toFixed(2),originalPrice:c.toFixed(2)}}}else{if(p&&!0===p.can_combine_with_other_promotions){let{promotion:i,promotions:r,originalPrice:n,promotionTag:a,...l}=e,c=parseFloat(e.originalPrice||e.price||"0")||0;return t.activePromotions=t.activePromotions.filter(e=>e.documentId!==o.documentId),t.combinableActiveCount=0,t.hasNonCombinableActive=!0,{...l,price:c.toFixed(2),originalPrice:c.toFixed(2)}}if(!p)return e}}}if(!p){let d=await O(e,t,o,i,r,n,a,l,c,s);return d||e}let u=((e,t)=>{let o=L(e).find(e=>!1===e.can_combine_with_other_promotions);if(!o)return null;let i=t.activePromotions.find(e=>!1===e.can_combine_with_other_promotions&&e.documentId!==o.documentId);if(!i)return null;let r=A(o),n=A(i);if(n>r)return E(e);if(n===r&&("product"===o.promotion_type||"discount"===o.promotion_type)){let t="percentage"===o.discount_type&&o.discount_value||0;if(("percentage"===i.discount_type&&i.discount_value||0)>t)return E(e)}return null})(e,t);return u||e}if(!u&&!p){let d=t.activePromotions.find(e=>!1===e.can_combine_with_other_promotions),p=t.activePromotions.find(e=>!0===e.can_combine_with_other_promotions);if(d&&!p){let p=parseFloat(e.price||"0")||0,u=await C(o,e.articleId,i,r,n,p,void 0,void 0,void 0,t.activePromotions,0),m=u.find(e=>!0===e.can_combine_with_other_promotions);if(m&&A(d)>=A(m)){let t=u.find(e=>!1===e.can_combine_with_other_promotions);return t?I(e,t,a,l,c,s):e}}let u=parseFloat(e.price||"0")||0,m=await C(o,e.articleId,i,r,n,u,void 0,void 0,void 0,t.activePromotions,0),_=m.filter(e=>!0===e.can_combine_with_other_promotions);if(_.length>0)return I(e,_.length>1?_:_[0],a,l,c,s);let f=m.filter(e=>!1===e.can_combine_with_other_promotions);if(f.length>0){let d=await k(t,e.articleId,o,i,r,n,!0);if(d>=2)return e;if(1===d&&t.activePromotions.length>0){let o=t.activePromotions.find(e=>!0===e.can_combine_with_other_promotions);if(o){let i=f[0],r=A(o),n=A(i);if(r>n)return e;if(n>r){for(let e=0;e<t.revalidatedCart.length;e++){let i=t.revalidatedCart[e];if((i.promotions||(i.promotion?[i.promotion]:[])).some(e=>e.documentId===o.documentId&&!0===e.can_combine_with_other_promotions)){let{promotion:r,promotions:n,originalPrice:a,promotionTag:l,...c}=i,s=parseFloat(i.originalPrice||i.price||"0")||0;t.revalidatedCart[e]={...c,price:s.toFixed(2),originalPrice:s.toFixed(2)},t.activePromotions=t.activePromotions.filter(e=>e.documentId!==o.documentId),t.combinableActiveCount=t.activePromotions.filter(e=>!0===e.can_combine_with_other_promotions).length,t.hasNonCombinableActive=t.activePromotions.some(e=>!1===e.can_combine_with_other_promotions)}}return I(e,i,a,l,c,s)}{if("product"!==i.promotion_type&&"discount"!==i.promotion_type)return e;let r="percentage"===o.discount_type&&o.discount_value||0;if(!(("percentage"===i.discount_type&&i.discount_value||0)>r))return e;for(let e=0;e<t.revalidatedCart.length;e++){let i=t.revalidatedCart[e];if((i.promotions||(i.promotion?[i.promotion]:[])).some(e=>e.documentId===o.documentId&&!0===e.can_combine_with_other_promotions)){let{promotion:r,promotions:n,originalPrice
9:a,promotionTag:l,...c}=i,s=parseFloat(i.originalPrice||i.price||"0")||0;t.revalidatedCart[e]={...c,price:s.toFixed(2),originalPrice:s.toFixed(2)},t.activePromotions=t.activePromotions.filter(e=>e.documentId!==o.documentId),t.combinableActiveCount=t.activePromotions.filter(e=>!0===e.can_combine_with_other_promotions).length,t.hasNonCombinableActive=t.activePromotions.some(e=>!1===e.can_combine_with_other_promotions)}}return I(e,i,a,l,c,s)}}}return I(e,f[0],a,l,c,s)}}let _=await M(e,t,o,i,r,n,a,l,c,s);return _||e},B=async(e,t,o,i,r,n,a=!0,l)=>{let c=e.filter(e=>!e.isRewardArticle),s=e=>{let t=e.reward_article_ids?.length||0;return!("other_product"===e.reward_type&&t>1&&!0!==e.select_only_one_reward_article)},d=new Map;for(let l of e.filter(e=>!e.isRewardArticle))for(let p of(l.promotions||(l.promotion?[l.promotion]:[])).filter(e=>"bogo"===e.promotion_type)){if(p.requires_registration&&!a)continue;let u=p.trigger_quantity||1;if(l.quantity<u)continue;let m=Math.floor(l.quantity/u),_=s(p),f=_&&null!==p.reward_quantity&&void 0!==p.reward_quantity?p.reward_quantity:1/0,g=d.get(p.documentId)||0,h=Math.min(m,Math.max(0,f-g));if(!(h<=0)){if("other_product"===p.reward_type){let a=!0===p.select_only_one_reward_article&&(p.reward_article_ids?.length||0)>1,s=l.cartItemId||l.articleId,u=t.filter(e=>e.parentPromotionArticleId===s&&e.promotion?.documentId===p.documentId);if(0===u.length&&(u=t.filter(e=>e.parentPromotionArticleId===s&&p.reward_article_ids?.includes(e.articleId))),0===u.length){if(!t.some(e=>e.parentPromotionArticleId===s&&p.reward_article_ids?.includes(e.articleId))){let u=await v(l,p,o,i,r,n,s,t,e);if(u.length>0){if(a){let e=u.reduce((e,t)=>{let o=e.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0;return(t.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0)>o?t:e});c.push({...e,quantity:h})}else c.push(...u.map(e=>({...e,quantity:h})));_&&d.set(p.documentId,g+h)}}}else{if(a){let e=u.reduce((e,t)=>{let o=e.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0;return(t.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0)>o?t:e});c.push({...e,quantity:h})}else c.push(...u.map(e=>({...e,quantity:h})));_&&d.set(p.documentId,g+h)}}else if("same_product"===p.reward_type){let o=l.cartItemId||l.articleId,i=t.filter(e=>e.articleId===l.articleId&&e.parentPromotionArticleId===o&&e.promotion?.documentId===p.documentId);if(h>0)if(i.length>0){let e=i.reduce((e,t)=>{let o=e.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0;return(t.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0)>o?t:e});c.push({...e,quantity:h}),d.set(p.documentId,g+h)}else{let i=w(l,p,o,t,e);if(i.length>0){let e=i.reduce((e,t)=>{let o=e.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0;return(t.modifiers?.reduce((e,t)=>e+(t.modifierItems?.length||0),0)||0)>o?t:e});c.push({...e,quantity:h}),d.set(p.documentId,g+h)}}}}}return c},Y=async(e,t,o,r,n,a,l,s,d,m="Oferta",_="OFF",f="Gratis",g="Obsequio")=>{var h;let I,y,w;if(0===e.length)return e;let v=e.filter(e=>!e.isRewardArticle),P=e.filter(e=>e.isRewardArticle),b=v.flatMap(e=>x(e)?(e.promotions||(e.promotion?[e.promotion]:[])).filter(t=>{let o;return o=t.trigger_quantity||1,(e.quantity||0)>=o}):[]).filter((e,t,o)=>t===o.findIndex(t=>t.documentId===e.documentId));b.some(e=>!1===e.can_combine_with_other_promotions),b.filter(e=>!0===e.can_combine_with_other_promotions).length;let S=b.filter(e=>!0===e.can_combine_with_other_promotions),q=b.filter(e=>!1===e.can_combine_with_other_promotions);if(1===S.length&&1===q.length){let e=S[0],t=q[0],o=A(e),i=A(t),r=null;if(o>i)r=t;else if(i>o)r=e;else if("product"===t.promotion_type||"discount"===t.promotion_type){let o="percentage"===e.discount_type&&e.discount_value||0;r=("percentage"===t.discount_type&&t.discount_value||0)>o?e:t}else r=e;if(r){for(let e=0;e<v.length;e++){let t=v[e];if((t.promotions||(t.promotion?[t.promotion]:[])).some(e=>e.documentId===r.documentId)){let{promotion:o,promotions:i,originalPrice:r,promotionTag:n,...a}=t,l=parseFloat(t.originalPrice||t.price||"0")||0;
9v[e]={...a,price:l.toFixed(2),originalPrice:l.toFixed(2)}}}b=b.filter(e=>e.documentId!==r.documentId)}}let F=b.some(e=>!1===e.can_combine_with_other_promotions),C=b.filter(e=>!0===e.can_combine_with_other_promotions).length,T=[],$={mainArticles:v,activePromotions:b,hasNonCombinableActive:F,combinableActiveCount:C,revalidatedCart:T};for(let e of v){let i=await G(e,$,t,o,r,n,m,_,f,g);T.push(i);let a=i.promotions||(i.promotion?[i.promotion]:[]);if(a.length>0)for(let e of a)$.activePromotions.some(t=>t.documentId===e.documentId)||$.activePromotions.push(e);else for(let t of e.promotions||(e.promotion?[e.promotion]:[]))$.activePromotions=$.activePromotions.filter(e=>e.documentId!==t.documentId);$.combinableActiveCount=$.activePromotions.filter(e=>!0===e.can_combine_with_other_promotions).length,$.hasNonCombinableActive=$.activePromotions.some(e=>!1===e.can_combine_with_other_promotions)}let R=(h=await B(T,P,a,l,s,d,r,n),T.map(e=>e.articleId),I=P.filter(e=>{if(e.promotion?.promotion_type==="checkout_reward")return!0;if(!e.parentPromotionArticleId)return!1;let t=T.find(t=>!t.isRewardArticle&&(!!t.cartItemId&&t.cartItemId===e.parentPromotionArticleId||t.articleId===e.parentPromotionArticleId)),o=t?.promotion?.documentId||t?.promotions&&t.promotions[0]?.documentId,i=e.promotion?.documentId||e.promotions&&e.promotions[0]?.documentId;return!!t&&!!o&&o===i}),y=new Set(h.filter(e=>e.isRewardArticle).map(e=>{let t=e.promotion?.documentId||e.promotions&&e.promotions[0]?.documentId,o=JSON.stringify((0,i.K7)(e.modifiers||[]));return`${e.articleId}-${e.parentPromotionArticleId}-${t}-${o}`})),w=c([...h,...I.filter(e=>{let t=e.promotion?.documentId||e.promotions&&e.promotions[0]?.documentId,o=JSON.stringify((0,i.K7)(e.modifiers||[])),r=`${e.articleId}-${e.parentPromotionArticleId}-${t}-${o}`;return!y.has(r)})]).filter(e=>{if(!e.isRewardArticle||e.promotion?.promotion_type==="checkout_reward")return!0;if(!e.parentPromotionArticleId)return!1;let t=T.find(t=>!t.isRewardArticle&&(!!t.cartItemId&&t.cartItemId===e.parentPromotionArticleId||t.articleId===e.parentPromotionArticleId)),o=t?.promotion?.documentId||t?.promotions&&t.promotions[0]?.documentId,i=e.promotion?.documentId||e.promotions&&e.promotions[0]?.documentId;return!!t&&!!o&&o===i}),c(w));return u(p(c(R)))},W=e=>{if(e)return{documentId:e.documentId||"",company_id:"",place_id:"",name:e.name||null,description:e.description||null,promotion_type:e.promotionType||e.promotion_type,article_ids:[],channel_ids:[],state:e.state||"active",trigger_quantity:e.triggerQuantity??e.trigger_quantity??void 0,reward_type:e.rewardType||e.reward_type||void 0,reward_quantity:e.rewardQuantity??e.reward_quantity??void 0,reward_article_ids:[],discount_type:e.discountType||e.discount_type,discount_value:e.discountValue??e.discount_value??0,start_date:e.startDate||e.start_date||null,end_date:e.endDate||e.end_date||null,max_uses_per_customer:e.maxUsesPerCustomer??e.max_uses_per_customer??null,max_total_uses:e.maxTotalUses??e.max_total_uses??null,usage_count:e.usageCount??e.usage_count??0,customer_usages:[],requires_registration:e.requiresRegistration??e.requires_registration??!1,can_combine_with_other_promotions:void 0}},z=e=>{if(!e)return;let t={documentId:e.documentId,name:e.name||null,description:e.description||null,promotionType:e.promotion_type,discountType:e.discount_type,discountValue:e.discount_value,startDate:e.start_date||null,endDate:e.end_date||null,usageCount:e.usage_count??0,state:e.state,requiresRegistration:e.requires_registration??!1};return null!==e.trigger_quantity&&void 0!==e.trigger_quantity?t.triggerQuantity=e.trigger_quantity:t.triggerQuantity=null,e.reward_type?t.rewardType=e.reward_type:t.rewardType=null,null!==e.reward_quantity&&void 0!==e.reward_quantity?t.rewardQuantity=e.reward_quantity:t.rewardQuantity=null,null!==e.max_uses_per_customer&&void 0!==e.max_uses_per_customer?t.maxUsesPerCustomer=e.max_uses_per_customer:t.maxUsesPerCustomer=null,null!==e.max_total_uses&&void 0!==e.max_total_uses?t.maxTotalUses=e.max_total_uses:t.maxTotalUses=null,t},V=(e,t=new Date)=>!("active"!==e.state||e.start_date&&t<new Date(e.start_date)||e.end_date&&t>new Date(e.end_date))&&(!e.schedule||!(e.schedule.length>
90)||!!(0,r.O)(e.schedule)),J=(e,t,o,i,n,a=!1)=>{let l=new Date,s=[],d=new Map;t.forEach(e=>{d.set(e.documentId,e)});let m=new Set;for(let t of e){if(t.isRewardArticle)continue;if(!t.promotion&&(!t.promotions||0===t.promotions.length)){s.push(t);continue}let e=t.promotions||(t.promotion?[t.promotion]:[]),n=[];for(let c of e){let e=d.get(c.documentId);if(!e){a&&V(c,l)&&(n.push(c),m.add(c.documentId));continue}if(a){V(e,l)&&(n.push(e),m.add(c.documentId));continue}if(!("active"!==e.state||e.start_date&&l<new Date(e.start_date)||e.end_date&&l>new Date(e.end_date)))e.schedule&&0!==e.schedule.length&&(0,r.O)(e.schedule)&&e.channel_ids.includes(o)&&e.article_ids.includes(t.articleId)&&(!e.requires_registration||i)&&(n.push(e),m.add(c.documentId))}if(0===n.length){let e=t.originalPrice||t.price,{promotion:o,promotions:i,promotionTag:r,originalPrice:n,...a}=t;s.push({...a,price:e,originalPrice:e})}else{let e=t.originalPrice||t.price,o={...t,originalPrice:e,promotion:1===n.length?n[0]:void 0,promotions:n.length>1?n:void 0};s.push(o)}}for(let t of e){if(!t.isRewardArticle)continue;let e=t.promotion?.documentId||t.promotions&&t.promotions[0]?.documentId;if(e){let i=d.get(e);if(i){if(a){V(i,l)&&s.push({...t});continue}if("active"===i.state&&i.channel_ids.includes(o)&&i.article_ids.includes(t.articleId)){s.push({...t});continue}}if(m.has(e)){s.push({...t});continue}}if(t.promotion?.promotion_type==="checkout_reward"){s.push(t);continue}if(t.parentPromotionArticleId&&s.some(e=>!e.isRewardArticle&&(!!e.cartItemId&&e.cartItemId===t.parentPromotionArticleId||e.articleId===t.parentPromotionArticleId))){if(e){let i=d.get(e);if(a)if(i)if(V(i,l))s.push({...t});else{let{promotion:e,promotions:o,...i}=t;s.push({...i})}else if(a)s.push({...t});else{let{promotion:e,promotions:o,...i}=t;s.push({...i})}else if(i&&"active"===i.state&&i.channel_ids.includes(o)&&i.article_ids.includes(t.articleId))s.push({...t});else{let{promotion:e,promotions:o,...i}=t;s.push({...i})}}else s.push({...t});continue}if(a&&t.promotion){s.push({...t});continue}}return u(p(c(s)))},K=(e,t,o,i)=>{let r=A(e),n=new Set;return t.forEach(t=>{if(t.promotion&&t.promotion.documentId!==e.documentId&&!t.isRewardArticle){if(!1===t.promotion.can_combine_with_other_promotions){let o=A(t.promotion);r>o?n.add(t.promotion.documentId):r===o&&("product"===e.promotion_type||"discount"===e.promotion_type)&&("percentage"===e.discount_type&&e.discount_value||0)>("percentage"===t.promotion.discount_type&&t.promotion.discount_value||0)&&n.add(t.promotion.documentId)}else if(!i&&e&&!1===e.can_combine_with_other_promotions)if(1===o.filter(e=>!0===e.can_combine_with_other_promotions).length){let o=A(t.promotion),i=A(e);if(o>i);else if(i>o)n.add(t.promotion.documentId);else if("product"===e.promotion_type||"discount"===e.promotion_type){let o="percentage"===t.promotion.discount_type&&t.promotion.discount_value||0;("percentage"===e.discount_type&&e.discount_value||0)>o&&n.add(t.promotion.documentId)}}else n.add(t.promotion.documentId)}}),n},H=(e,t,o,i)=>e.filter(e=>!(e.isRewardArticle&&e.promotion&&o.has(e.promotion.documentId))).map(e=>{if(e.isRewardArticle)return e;if(e.promotion&&(!t||e.promotion.documentId!==t.documentId)&&(o.has(e.promotion.documentId)||!0===e.promotion.can_combine_with_other_promotions&&!i&&t&&!1===t.can_combine_with_other_promotions)){let{promotion:t,promotions:o,promotionTag:i,...r}=e,n=e.originalPrice||e.price;return{...r,price:n,originalPrice:n}}return e}),Q=(e,t,o,i,r,n,a,l,c,s)=>{let d=i.some(e=>!1===e.can_combine_with_other_promotions),p=e,u=t,m=o;if(p&&!1===p.can_combine_with_other_promotions){let e=i.find(e=>!1===e.can_combine_with_other_promotions);if(e){let t=A(e),o=A(p);o<=t&&(o===t&&("product"===p.promotion_type||"discount"===p.promotion_type)?("percentage"===p.discount_type&&p.discount_value||0)<=("percentage"===e.discount_type&&e.discount_value||0)&&(p=void 0,u=[],m=I(m,void 0,a,l,c,s)):(p=void 0,u=[],m=I(m,void 0,a,l,c,s)))}}else if(d){var _;let e,t,o,n=(_=u,e=i.filter(e=>!0===e.can_combine_with_other_promotions).length,t=_.some(e=>!0===e.can_combine_with_other_promotions),o=e,t?(o+=1,r>0&&(o+=1)):o+=r,o>=2&&d);if(p&&!0===p.can_combine_with_other_promotions){if(!n)if(1===i.filter(e=>!0===e.can_combine_with_other_promotions).length+ +(!0===p.can_combine_with_other_promotions)){let e=i.find(e=>!1===e.can_combine_with_other_promotions);if(e){let t=A(p),o=A(e);t>o||(o>t?(p=void 0,u=[],m=I(m,void 0,a,l,c,s)):("product"===p.promotion_type||"discount"===p.promotion_type)&&("percentage"===p.discount_type&&p.discount_value||0)>("percentage"===e.discount_type&&e.discount_value||0)||(p=void 0,u=[],m=I(m,void 0,a,l,c,s)))}else p=void 0,u=[],m=I(m,void 0,a,l,c,s)}else p=void 0,u=[],m=I(m,void 0,a,l,c,s)}else if(!p&&u.length>0){if(!0===u[0].can_combine_with_other_promotions){if(!n)if(1===i.filter(e=>!0===e.can_combine_with_other_promotions).length+ +(!0===u[0].can_combine_with_other_promotions)){let e=i.find(e=>!1===e.can_combine_with_other_promotions);if(e){let t=A(u[0]),o=A(e);t<=o&&(t===o&&("product"===u[0].promotion_type||"discount"===u[0].promotion_type)?("percentage"===u[0].discount_type&&u[0].discount_value||0)<=("percentage"===e.discount_type&&e.discount_value||0)&&(u=[]):u=[])}else u=[]}else u=[]}else if(!1===u[0].can_combine_with_other_promotions){let e=i.find(e=>!1===e.can_combine_with_other_promotions);if(e){let t=A(e);A(u[0])<=t&&(u=[])}}}}return{promotion:p,selectedPromotions:u,finalArticle:m}},Z=async(e,t,o,i,r,n,a,l,c,s,d,p)=>{let u,m=t.filter(e=>!e.isRewardArticle&&!e.promotion).length,_=await C(o,e.articleId,l,r,n,a,void 0,void 0,void 0,i,m),f=1===_.length?_[0]:void 0;f?.requires_registration&&!r&&(f=void 0),f&&t.find(t=>!t.isRewardArticle&&t.promotion?.documentId===f.documentId&&t.articleId!==e.articleId)&&(f=void 0,_=[]);let g=t.findIndex(t=>!t.isRewardArticle&&t.articleId===e.articleId&&t.notes===e.notes&&(!e.modifiers.length||0===t.modifiers.length)),h=t;if(g>=0){let o=t[g],i=o.originalPrice||o.price||e.price,r=o.cartItemId;u={...e,quantity:o.quantity+e.quantity,price:e.price,originalPrice
9:i,cartItemId:r};let n=r||e.articleId;h=t.filter((e,t)=>t!==g&&(!e.isRewardArticle||e.parentPromotionArticleId!==n))}else{let t=`${Date.now()}-${Math.random().toString(36).substr(2,9)}`;u={...e,price:e.price,originalPrice:e.price,cartItemId:t}}u=I(u,_.length>0?_:f,c,s,d,p);let y=h,w=i.some(e=>!1===e.can_combine_with_other_promotions);if(f&&!1===f.can_combine_with_other_promotions){let e=f.trigger_quantity||1;if(u.quantity>=e){let e=i.filter(e=>!0===e.can_combine_with_other_promotions).length,t=e+h.filter(e=>!e.isRewardArticle&&!e.promotion).length>=2&&w;if(1!==e||t){let e=K(f,h,i,t);y=H(h,f,e,t)}else{let e=i.find(e=>!0===e.can_combine_with_other_promotions);if(e){let o=A(e),r=A(f);if(o>r){let{promotion:e,promotions:t,promotionTag:o,...i}=u;u={...i,price:u.originalPrice||u.price,originalPrice:u.originalPrice||u.price},f=void 0,_=[],y=h}else if(r>o){let e=K(f,h,i,t);y=H(h,f,e,t)}else if("product"===f.promotion_type||"discount"===f.promotion_type){let o="percentage"===e.discount_type&&e.discount_value||0;if(("percentage"===f.discount_type&&f.discount_value||0)>o){let e=K(f,h,i,t);y=H(h,f,e,t)}else{let{promotion:e,promotions:t,promotionTag:o,...i}=u;u={...i,price:u.originalPrice||u.price,originalPrice:u.originalPrice||u.price},f=void 0,_=[],y=h}}else{let{promotion:e,promotions:t,promotionTag:o,...i}=u;u={...i,price:u.originalPrice||u.price,originalPrice:u.originalPrice||u.price},f=void 0,_=[],y=h}}else{let e=K(f,h,i,t);y=H(h,f,e,t)}}}else{let{promotion:e,promotions:t,promotionTag:o,...i}=u;u={...i,price:u.originalPrice||u.price,originalPrice:u.originalPrice||u.price},f=void 0,_=[]}}else if(w){let e=Q(f,_,u,i,m,h,c,s,d,p);f=e.promotion,_=e.selectedPromotions,u=e.finalArticle;let t=f||(_.length>0?_[0]:void 0);if(t&&!0===t.can_combine_with_other_promotions&&1===i.filter(e=>!0===e.can_combine_with_other_promotions).length+ +(!0===t.can_combine_with_other_promotions)){let e=i.find(e=>!1===e.can_combine_with_other_promotions);if(e){let o=A(t),i=A(e);if(o>i){let o=new Set;o.add(e.documentId),y=H(h,t,o,!1)}else if(o===i&&("product"===t.promotion_type||"discount"===t.promotion_type)&&("percentage"===t.discount_type&&t.discount_value||0)>("percentage"===e.discount_type&&e.discount_value||0)){let o=new Set;o.add(e.documentId),y=H(h,t,o,!1)}}}}return{cleanedCart:y,finalArticle:u,selectedPromotions:_}},j=async(e,t,o,i,r,n,a,l,c,s,d,p,u,m,_)=>{let f,g,h=e.isRewardArticle||t?.isRewardArticle||!1,y=[],w=!1;if(h){let i=t||o[r];f={...e,isRewardArticle:!0,parentPromotionArticleId:i?.parentPromotionArticleId||e.parentPromotionArticleId,promotion:i?.promotion||e.promotion,promotions:i?.promotions||e.promotions,promotionTag:i?.promotionTag||e.promotionTag,price:i?.price||s.toFixed(2),originalPrice:i?.originalPrice||s.toFixed(2),quantity:i?.quantity||e.quantity}}else{!e.cartItemId&&t?.cartItemId&&(e.cartItemId=t.cartItemId);let i=t?.promotion||t?.promotions?.[0];if(i?.promotion_type==="bogo"&&(i?.reward_type==="same_product"||i?.reward_type==="other_product"))y=[i],g=i;else{let t=o.filter((e,t)=>t!==r&&!e.isRewardArticle&&!e.promotion).length;g=1===(y=await C(n,e.articleId,d,l,c,s,void 0,void 0,void 0,a,t)).length?y[0]:void 0}g?.requires_registration&&!l&&(w=!0,g=void 0),(f=I(f={...e,quantity:e.quantity,cartItemId:e.cartItemId||t?.cartItemId,price:s.toFixed(2),originalPrice:s.toFixed(2)},y.length>0?y:g,p,u,m,_)).quantity=e.quantity,f.promotion||f.promotions||(f.price=s.toFixed(2),f.originalPrice=s.toFixed(2))}let v=i;
9if(!h){let e=a.some(e=>!1===e.can_combine_with_other_promotions);if(g&&!1===g.can_combine_with_other_promotions){let t=g.trigger_quantity||1;if(f.quantity>=t){let t=a.filter(e=>!0===e.can_combine_with_other_promotions).length+i.filter(e=>!e.isRewardArticle&&!e.promotion).length>=2&&e,o=K(g,i,a,t);v=H(i,g,o,t)}else{let{promotion:e,promotions:t,promotionTag:o,...i}=f;f={...i,price:f.originalPrice||f.price,originalPrice:f.originalPrice||f.price},g=void 0,y=[]}}else if(e){let e=Q(g,y,f,a,i.filter(e=>!e.isRewardArticle&&!e.promotion).length,i,p,u,m,_);g=e.promotion,y=e.selectedPromotions,f=e.finalArticle}}return{cleanedCart:v,updatedArticle:f,selectedPromotions:y,promotionRequiresLogin:w}},X=async(e,t,o,i,r,n,a,l,c,s,d,p,u,m,_)=>{let f=o[t],g=f?.promotion?.documentId,h=!!f?.isRewardArticle,I=o.filter((o,i)=>(o.articleId!==e||t!==i)&&(!o.isRewardArticle||o.parentPromotionArticleId!==e||o.promotion?.documentId!==g));return 0===I.length?[]:h?I:i.length>0?await Y(I,i,r,n,a,l,c,s,d,p,u,m,_):I}}}]);

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.