{"version":3,"file":"LifestyleDeepLink.DiRjsi6g.mjs","names":["useRef","useState","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","_e","c","J","init_jsx_runtime","ce","de","window","useRouter","init_framer_DxfB3JJo","useCurrentRouteId","setForwardedRef","ref","value","useLifestyleDestination","router","routeId","path","english","destination","route","href","keepEnglishHref","update","links","root","link","previous","observer","withStoredTab","localRef","disconnect","rememberTab","storageKey","tab","event","Component","node","forwardedRef","props","withHealthyLink","withLowSodiumLink","withMomKidsLink","withSeniorsLink","withBusinessLink","withTargetTab","variant","setVariant","variants","withLifestyleGroupLinks","rememberClickedTab","clickable","label","match","lifestyleTabByLabel","text","init_LifestyleTwoCardTest","titleKey","withLifestyleLinkByText","withHealthyCardLink","withLowSodiumCardLink","withMomKidsCardLink","withSeniorsCardLink","withBusinessCardLink","withMenuDetailFromCardText","title","withBlogDetailFromCardText","key","slug","blogSlugByTitle","init_LifestyleDeepLink"],"sources":["https:/framerusercontent.com/modules/wcJA0YeRUEgQN55ljr2r/J3YK4PRnzYazk4nhWKJg/LifestyleTwoCardTest.js","https:/framerusercontent.com/modules/crbZjpMNkO2okZuowGeF/GZVkAx4k3StEsCZ3GlLJ/LifestyleDeepLink.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef,useState}from\"react\";import{useRouter,useCurrentRouteId}from\"framer\";const storageKey=\"kitchi-lifestyle-tab\";function setForwardedRef(ref,value){if(typeof ref===\"function\"){ref(value);}else if(ref){ref.current=value;}}// Keep shared cards in the current language, including Framer Preview.\nfunction useLifestyleDestination(){const router=useRouter();const routeId=useCurrentRouteId();const path=router.routes?.[routeId]?.path||\"/\";const english=/^\\/en(?:\\/|$)/.test(path);const destination=Object.entries(router.routes||{}).find(([,route])=>route.path===(english?\"/en/target\":\"/target\"));const href=path===\"/en\"?\"./en/target\":\"./target\";return{router,english,destinationId:destination?.[0],href};}function keepEnglishHref(root,href){const update=()=>{const links=root.matches(\"a\")?[root]:Array.from(root.querySelectorAll(\"a\"));for(const link of links){const previous=link.getAttribute(\"href\")||\"\";if(/\\/target(?:[?#]|$)/.test(previous)&&previous!==href){link.setAttribute(\"href\",href);}}};update();const observer=new MutationObserver(update);observer.observe(root,{subtree:true,childList:true,attributes:true,attributeFilter:[\"href\"]});return()=>observer.disconnect();}function withStoredTab(Component,tab){return /*#__PURE__*/forwardRef((props,forwardedRef)=>{const localRef=useRef(null);const destination=useLifestyleDestination();useEffect(()=>{const root=localRef.current;if(!root)return;const disconnect=destination.english?keepEnglishHref(root,destination.href):()=>{};const rememberTab=event=>{window.sessionStorage.setItem(storageKey,tab);if(destination.english&&destination.destinationId&&!event.metaKey&&!event.ctrlKey&&!event.shiftKey&&!event.altKey&&event.button===0){event.preventDefault();event.stopPropagation();destination.router.navigate(destination.destinationId);}};root.addEventListener(\"click\",rememberTab,true);return()=>{root.removeEventListener(\"click\",rememberTab,true);disconnect();};},[destination.english,destination.destinationId,destination.href]);const attachRef=node=>{localRef.current=node;setForwardedRef(forwardedRef,node);};return /*#__PURE__*/_jsx(Component,{ref:attachRef,...props});});}export function withHealthyLink(Component){return withStoredTab(Component,\"healthy\");}export function withLowSodiumLink(Component){return withStoredTab(Component,\"low-sodium\");}export function withMomKidsLink(Component){return withStoredTab(Component,\"mom-kids\");}export function withSeniorsLink(Component){return withStoredTab(Component,\"seniors\");}export function withBusinessLink(Component){return withStoredTab(Component,\"business\");}export function withTargetTab(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[variant,setVariant]=useState(props.variant);useEffect(()=>{const tab=window.sessionStorage.getItem(storageKey);const variants={healthy:\"Healthy\",\"low-sodium\":\"Low Sodium\",\"mom-kids\":\"Mom & Kids\",seniors:\"Seniors\",business:\"Business\"};if(tab&&variants[tab]){setVariant(variants[tab]);}window.sessionStorage.removeItem(storageKey);},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props,variant:variant});});}const lifestyleTabByLabel=[[\"Healthy\",\"healthy\"],[\"Less Sodium\",\"low-sodium\"],[\"Low Sodium\",\"low-sodium\"],[\"Mom & Kids\",\"mom-kids\"],[\"Seniors\",\"seniors\"],[\"Restaurants\",\"business\"],[\"คนรักสุขภาพ\",\"healthy\"],[\"ผู้ที่ต้องควบคุมโซเดียม\",\"low-sodium\"],[\"คุณแม่และเด็ก\",\"mom-kids\"],[\"ผู้สูงอายุ\",\"seniors\"],[\"ธุรกิจร้านอาหาร\",\"business\"]];export function withLifestyleGroupLinks(Component){return /*#__PURE__*/forwardRef((props,forwardedRef)=>{const localRef=useRef(null);const destination=useLifestyleDestination();useEffect(()=>{const root=localRef.current;if(!root)return;const disconnect=destination.english?keepEnglishHref(root,destination.href):()=>{};const rememberClickedTab=event=>{const target=event.target;const clickable=target?.closest(\"a, button, [role='link']\");if(!clickable||!root.contains(clickable))return;const label=(clickable.textContent||\"\").replace(/\\s+/g,\" \").trim();const match=lifestyleTabByLabel.find(([text])=>label.includes(text));if(match){window.sessionStorage.setItem(storageKey,match[1]);if(destination.english&&destination.destinationId&&!event.metaKey&&!event.ctrlKey&&!event.shiftKey&&!event.altKey&&event.button===0){event.preventDefault();event.stopPropagation();destination.router.navigate(destination.destinationId);}}};root.addEventListener(\"click\",rememberClickedTab,true);return()=>{root.removeEventListener(\"click\",rememberClickedTab,true);disconnect();};},[destination.english,destination.destinationId,destination.href]);const attachRef=node=>{localRef.current=node;setForwardedRef(forwardedRef,node);};return /*#__PURE__*/_jsx(Component,{ref:attachRef,...props});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withBusinessLink\":{\"type\":\"reactHoc\",\"name\":\"withBusinessLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSeniorsLink\":{\"type\":\"reactHoc\",\"name\":\"withSeniorsLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLowSodiumLink\":{\"type\":\"reactHoc\",\"name\":\"withLowSodiumLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLifestyleGroupLinks\":{\"type\":\"reactHoc\",\"name\":\"withLifestyleGroupLinks\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHealthyLink\":{\"type\":\"reactHoc\",\"name\":\"withHealthyLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withTargetTab\":{\"type\":\"reactHoc\",\"name\":\"withTargetTab\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMomKidsLink\":{\"type\":\"reactHoc\",\"name\":\"withMomKidsLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LifestyleTwoCardTest.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef}from\"react\";import{withHealthyLink,withLowSodiumLink,withMomKidsLink,withSeniorsLink,withBusinessLink,withLifestyleGroupLinks}from\"https://framerusercontent.com/modules/wcJA0YeRUEgQN55ljr2r/J3YK4PRnzYazk4nhWKJg/LifestyleTwoCardTest.js\";const blogSlugByTitle={\"the-secret-behind-our-fresh-and-flavorful-dishes\":\"the-secret-behind-our-fresh-and-flavorful-dishes.\",\"5-must-try-signature-dishes-for-your-next-visit\":\"5-must-try-signature-dishes-for-your-next-visit.\",\"how-fresh-ingredients-transform-every-dishwe-erve\":\"how-fresh-ingredients-transform-every-dish-we-serve\",\"behind-the-kitchen-crafting-flavorful-dining-experiences\":\"behind-the-kitchen-crafting-flavorful-dining-experiences\"};function titleKey(value){return String(value??\"\").toLowerCase().trim().replace(/[^a-z0-9]+/g,\"-\").replace(/^-+|-+$/g,\"\");}export function withLifestyleFromUrl(Component){return Component;}export function withLifestyleLinkByText(Component){return withLifestyleGroupLinks(Component);}export function withHealthyCardLink(Component){return withHealthyLink(Component);}export function withLowSodiumCardLink(Component){return withLowSodiumLink(Component);}export function withMomKidsCardLink(Component){return withMomKidsLink(Component);}export function withSeniorsCardLink(Component){return withSeniorsLink(Component);}export function withBusinessCardLink(Component){return withBusinessLink(Component);}export function withMenuDetailLink(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const title=String(props.title??props.Title??\"\").trim();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,href:title?\"/menu/\"+encodeURIComponent(title):\"/menu\"});});}export function withMenuDetailNavigation(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const title=String(props.title??props.Title??\"\").trim();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,href:title?\"/menu/\"+encodeURIComponent(title):\"/menu\"});});}export function withMenuDetailNavigationRelative(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const title=String(props.title??props.Title??\"\").trim();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,href:title?\"./menu/\"+encodeURIComponent(title):\"./menu\"});});}export function withMenuDetailFromCardText(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const title=String(props.title??props.Title??\"\").trim();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,href:title?\"/menu/\"+encodeURIComponent(title):\"/menu\"});});}export function withBlogDetailFromCardText(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const key=titleKey(props.Title??props.title);const slug=blogSlugByTitle[key];return /*#__PURE__*/_jsx(Component,{ref:ref,...props,href:slug?\"/blog/\"+slug:\"/blog\"});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withLifestyleLinkByText\":{\"type\":\"reactHoc\",\"name\":\"withLifestyleLinkByText\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLowSodiumCardLink\":{\"type\":\"reactHoc\",\"name\":\"withLowSodiumCardLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBusinessCardLink\":{\"type\":\"reactHoc\",\"name\":\"withBusinessCardLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLifestyleFromUrl\":{\"type\":\"reactHoc\",\"name\":\"withLifestyleFromUrl\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMenuDetailNavigationRelative\":{\"type\":\"reactHoc\",\"name\":\"withMenuDetailNavigationRelative\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMenuDetailNavigation\":{\"type\":\"reactHoc\",\"name\":\"withMenuDetailNavigation\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSeniorsCardLink\":{\"type\":\"reactHoc\",\"name\":\"withSeniorsCardLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBlogDetailFromCardText\":{\"type\":\"reactHoc\",\"name\":\"withBlogDetailFromCardText\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHealthyCardLink\":{\"type\":\"reactHoc\",\"name\":\"withHealthyCardLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMomKidsCardLink\":{\"type\":\"reactHoc\",\"name\":\"withMomKidsCardLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMenuDetailLink\":{\"type\":\"reactHoc\",\"name\":\"withMenuDetailLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMenuDetailFromCardText\":{\"type\":\"reactHoc\",\"name\":\"withMenuDetailFromCardText\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"A,+MAA2L,SAASe,EAAgB,EAAI,EAAM,CAAI,OAAOC,GAAM,WAAYA,EAAIC,CAAK,EAAWD,IAAK,EAAI,QAAQC,EAAO,CACvS,SAASC,GAAyB,CAAC,IAAMC,EAAOP,EAAU,EAAQQ,EAAQN,EAAkB,EAAQO,EAAKF,EAAO,SAASC,EAAQ,EAAE,MAAM,IAAUE,EAAQ,gBAAgB,KAAKD,CAAI,EAAQE,EAAY,OAAO,QAAQJ,EAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAEK,KAASA,EAAM,QAAQF,EAAQ,aAAa,UAAU,EAAQG,EAAKJ,IAAO,MAAM,cAAc,WAAW,MAAM,CAAC,SAAO,UAAQ,cAAcE,IAAc,GAAG,MAAI,CAAE,CAAC,SAASG,EAAgB,EAAK,EAAK,CAAC,IAAMC,MAAW,CAAC,IAAMC,EAAMC,EAAK,QAAQ,GAAG,EAAE,CAACA,CAAI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