{"version":3,"file":"URLVariantSwitch.2ohVL-RE.mjs","names":[],"sources":["https:/framerusercontent.com/modules/JHRT65KzPC530Ji07SQw/7HnTyNuqbHzrhClpixdc/URLVariantSwitch.js"],"sourcesContent":["// URL Variant Switch — Amo\n// Code Override: reads a URL query parameter on page load and switches\n// the component's variant, accounting for screen size (desktop/tablet/mobile).\n//\n// On the shop page: apply withURLVariant to your variant component.\n// On the home page: apply withCoffeeLink / withApparelLink / withMerchLink to your buttons.\n//\n// Variant naming convention: \"desktop - coffee\", \"tablet - all\", \"mobile - merch\", etc.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";// ─── CONFIG ───────────────────────────────────────────────\n// Change these to match your setup:\nconst PARAM_KEY=\"category\"// the URL query param to read\n;const DEFAULT_CATEGORY=\"all\"// category shown when no param is present\n;const VALID_CATEGORIES=[\"coffee\",\"apparel\",\"merch\"]// must be lowercase\n;// Breakpoints — adjust these to match your Framer breakpoints\nconst TABLET_MAX=1024// tablet is <= this width\n;const MOBILE_MAX=767// mobile is <= this width\n;// ──────────────────────────────────────────────────────────\nfunction getDeviceLabel(){const width=window.innerWidth;if(width<=MOBILE_MAX)return\"mobile\";if(width<=TABLET_MAX)return\"tablet\";return\"desktop\";}const VALID_DEVICES=[\"desktop\",\"tablet\",\"mobile\"];function getInitialVariant(){try{const params=new URLSearchParams(window.location.search);// Use device from URL if passed, otherwise detect\nconst urlDevice=params.get(\"device\")?.toLowerCase();const device=urlDevice&&VALID_DEVICES.includes(urlDevice)?urlDevice:getDeviceLabel();const value=params.get(PARAM_KEY)?.toLowerCase();if(value&&VALID_CATEGORIES.includes(value)){return`${device} - ${value}`;}return`${device} - ${DEFAULT_CATEGORY}`;}catch{return`desktop - ${DEFAULT_CATEGORY}`;}}function getCategory(){try{const params=new URLSearchParams(window.location.search);const value=params.get(PARAM_KEY)?.toLowerCase();if(value&&VALID_CATEGORIES.includes(value))return value;}catch{}return DEFAULT_CATEGORY;}export function withURLVariant(Component){return props=>{const category=useRef(getCategory());const[variant,setVariant]=useState(getInitialVariant);const[ready,setReady]=useState(false);useEffect(()=>{// Show after one frame — variant is already set, this just\n// waits for React to commit the correct variant to the DOM\nrequestAnimationFrame(()=>setReady(true));const handleResize=()=>{const device=getDeviceLabel();setVariant(`${device} - ${category.current}`);};window.addEventListener(\"resize\",handleResize);return()=>window.removeEventListener(\"resize\",handleResize);},[]);return /*#__PURE__*/_jsx(Component,{...props,variant:variant,style:{...props.style,opacity:ready?1:0,transition:\"opacity 0.15s ease\"}});};}// ─── HOME PAGE BUTTON OVERRIDES ──────────────────────────\n// Apply these to your home page buttons instead of using Framer's link field.\n// They navigate using the current domain so they work on any staging/production URL.\nfunction navigateWithCategory(category){const device=getDeviceLabel();window.location.href=`${window.location.origin}/shop?category=${category}&device=${device}`;}export function withCoffeeLink(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,onClick:()=>navigateWithCategory(\"coffee\")});};}export function withApparelLink(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,onClick:()=>navigateWithCategory(\"apparel\")});};}export function withMerchLink(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,onClick:()=>navigateWithCategory(\"merch\")});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withURLVariant\":{\"type\":\"reactHoc\",\"name\":\"withURLVariant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCoffeeLink\":{\"type\":\"reactHoc\",\"name\":\"withCoffeeLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withApparelLink\":{\"type\":\"reactHoc\",\"name\":\"withApparelLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMerchLink\":{\"type\":\"reactHoc\",\"name\":\"withMerchLink\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./URLVariantSwitch.map"],"mappings":"yHAiBA,SAAS,GAAgB,CAAC,IAAM,EAAM,EAAO,WAAmF,OAArE,GAAO,EAAiB,SAAY,GAAO,EAAiB,SAAe,SAAU,CAMhJ,SAAS,EAAqB,EAAS,CAAC,IAAM,EAAO,EAAe,EAAE,EAAO,SAAS,KAAK,GAAG,EAAO,SAAS,OAAO,iBAAiB,EAAS,UAAU,GAAS,CAAC,SAAgB,EAAe,EAAU,CAAC,MAAO,IAA4B,EAAK,EAAU,CAAC,GAAG,EAAM,YAAY,EAAqB,QAAQ,CAAC,CAAC,CAAI,CAAC,SAAgB,EAAgB,EAAU,CAAC,MAAO,IAA4B,EAAK,EAAU,CAAC,GAAG,EAAM,YAAY,EAAqB,SAAS,CAAC,CAAC,CAAI,CAAC,SAAgB,EAAc,EAAU,CAAC,MAAO,IAA4B,EAAK,EAAU,CAAC,GAAG,EAAM,YAAY,EAAqB,OAAO,CAAC,CAAC,CAAI,yBAf1jB,IAA6C,EAMjF,EAAW,KACV,EAAW"}