@fynd-design-engineering/fynd-one-v2 3.3.65 → 3.3.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(()=>{document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[custom-video]").forEach(a=>{let e=a.querySelector("video"),o=a.querySelector("img");if(!e||!o)return;e.muted=!0,e.loop=!0,e.autoplay=!0,e.preload="auto";let t=()=>{o.style.display="none",e.play().catch(()=>{e.muted=!0,e.play().catch(()=>{})}),e.removeEventListener("loadeddata",t)};e.readyState>=2?t():e.addEventListener("loadeddata",t)})});})();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../bin/live-reload.js", "../../src/global/custom-bg-video.ts"],
|
|
4
|
+
"sourcesContent": ["// Only enable live reload when running on localhost\nif (\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"127.0.0.1\"\n) {\n new EventSource(`${SERVE_ORIGIN}/esbuild`).addEventListener(\"change\", () =>\n location.reload()\n );\n} else {\n // console.log(\"Live reload disabled: not running on localhost\");\n}\n", "document.addEventListener(\"DOMContentLoaded\", () => {\n const wrappers = document.querySelectorAll<HTMLElement>(\"[custom-video]\");\n\n wrappers.forEach(wrapper => {\n const video = wrapper.querySelector<HTMLVideoElement>(\"video\");\n const img = wrapper.querySelector<HTMLImageElement>(\"img\");\n\n if (!video || !img) return;\n\n video.muted = true;\n video.loop = true;\n video.autoplay = true;\n video.preload = \"auto\"; // plays nicely with <link preload>\n\n const startPlayback = () => {\n img.style.display = \"none\";\n video.play().catch(() => {\n // autoplay might fail on some browsers if not muted early enough\n video.muted = true;\n video.play().catch(() => { });\n });\n video.removeEventListener(\"loadeddata\", startPlayback);\n };\n\n if (video.readyState >= 2) {\n startPlayback();\n } else {\n video.addEventListener(\"loadeddata\", startPlayback);\n }\n });\n});"],
|
|
5
|
+
"mappings": ";;;AACA,MACE,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa,aAC7B;AACA,QAAI,YAAY,GAAG,uBAAY,UAAU,EAAE;AAAA,MAAiB;AAAA,MAAU,MACpE,SAAS,OAAO;AAAA,IAClB;AAAA,EACF,OAAO;AAAA,EAEP;;;ACVA,WAAS,iBAAiB,oBAAoB,MAAM;AAChD,UAAM,WAAW,SAAS,iBAA8B,gBAAgB;AAExE,aAAS,QAAQ,aAAW;AACxB,YAAM,QAAQ,QAAQ,cAAgC,OAAO;AAC7D,YAAM,MAAM,QAAQ,cAAgC,KAAK;AAEzD,UAAI,CAAC,SAAS,CAAC,IAAK;AAEpB,YAAM,QAAQ;AACd,YAAM,OAAO;AACb,YAAM,WAAW;AACjB,YAAM,UAAU;AAEhB,YAAM,gBAAgB,MAAM;AACxB,YAAI,MAAM,UAAU;AACpB,cAAM,KAAK,EAAE,MAAM,MAAM;AAErB,gBAAM,QAAQ;AACd,gBAAM,KAAK,EAAE,MAAM,MAAM;AAAA,UAAE,CAAC;AAAA,QAChC,CAAC;AACD,cAAM,oBAAoB,cAAc,aAAa;AAAA,MACzD;AAEA,UAAI,MAAM,cAAc,GAAG;AACvB,sBAAc;AAAA,MAClB,OAAO;AACH,cAAM,iBAAiB,cAAc,aAAa;AAAA,MACtD;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(()=>{document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[media-card]").forEach(s=>{let e=s.getAttribute("media-card"),n=s.getAttribute("media-card-hover")!=="false";e==="image"?u(s,n):e==="video-on-hover"?f(s,n):e==="video-on-loop"&&p(s,n)})});function u(t,s){let e=t.querySelector("img");e&&(e.style.transition="transform 200ms ease",s&&(t.addEventListener("mouseenter",()=>{e.style.transform="scale(1.05)"}),t.addEventListener("mouseleave",()=>{e.style.transform="scale(1)"})))}function l(t,s=4){return t.play().catch(()=>new Promise((e,o)=>{if(s<=0){o();return}setTimeout(()=>{l(t,s-1).then(e).catch(o)},120)}))}function f(t,s){let e=t.querySelector("video"),o=t.querySelector("img");if(!e||!o||!!!(e.currentSrc||e.src))return;e.muted=!0,e.playsInline=!0,o.style.transition="opacity 200ms ease",e.style.transition="opacity 200ms ease, transform 200ms ease",e.style.transform="scale(1)",e.style.opacity="0",e.style.display="block",o.style.opacity="1";let a=!1,c=!1,i=()=>e.readyState>=HTMLMediaElement.HAVE_FUTURE_DATA,r=()=>{o.style.opacity="0",e.style.opacity="1"},m=()=>{o.style.opacity="1",e.style.opacity="0"},d=()=>{c=!0,a&&(e.loop=!0,l(e).catch(()=>{}))};e.addEventListener("ended",d),s&&(t.addEventListener("mouseenter",()=>{if(a=!0,e.style.transform="scale(1.05)",r(),i())l(e).catch(()=>{});else{let y=()=>{e.removeEventListener("canplay",y),r(),l(e).catch(()=>{})};e.addEventListener("canplay",y,{once:!0}),e.load()}}),t.addEventListener("mouseleave",()=>{a=!1,e.style.transform="scale(1)",e.loop=!1,e.pause(),m()}))}function p(t,s){let e=t.querySelector("video"),o=t.querySelector("img");if(!e||!!!(e.currentSrc||e.src))return;e.muted=!0,e.playsInline=!0,e.loop=!0,o&&(o.style.transition="opacity 200ms ease",o.style.opacity="1"),e.style.transition="opacity 200ms ease, transform 200ms ease",e.style.transform="scale(1)",e.style.opacity="0",e.style.display="block";let a=()=>e.readyState>=HTMLMediaElement.HAVE_FUTURE_DATA,c=()=>{o&&(o.style.opacity="0"),e.style.opacity="1"},i=()=>{c(),l(e).catch(()=>{})};if(a())i();else{let r=()=>{e.removeEventListener("canplay",r),i()};e.addEventListener("canplay",r,{once:!0}),e.load()}s&&(t.addEventListener("mouseenter",()=>{e.style.transform="scale(1.05)"}),t.addEventListener("mouseleave",()=>{e.style.transform="scale(1)"}))}})();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../bin/live-reload.js", "../../src/global/media-card.ts"],
|
|
4
|
+
"sourcesContent": ["// Only enable live reload when running on localhost\nif (\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"127.0.0.1\"\n) {\n new EventSource(`${SERVE_ORIGIN}/esbuild`).addEventListener(\"change\", () =>\n location.reload()\n );\n} else {\n // console.log(\"Live reload disabled: not running on localhost\");\n}\n", "document.addEventListener(\"DOMContentLoaded\", () => {\n const cards = document.querySelectorAll<HTMLElement>(\"[media-card]\");\n\n cards.forEach(card => {\n const type = card.getAttribute(\"media-card\");\n const hoverAttr = card.getAttribute(\"media-card-hover\");\n const enableHover = hoverAttr !== \"false\";\n\n if (type === \"image\") {\n setupImageHover(card, enableHover);\n } else if (type === \"video-on-hover\") {\n setupVideoHover(card, enableHover);\n } else if (type === \"video-on-loop\") {\n setupVideoLoop(card, enableHover);\n }\n });\n});\n\nfunction setupImageHover(card: HTMLElement, enableHover: boolean) {\n const img = card.querySelector<HTMLImageElement>(\"img\");\n if (!img) return;\n\n img.style.transition = \"transform 200ms ease\";\n\n if (!enableHover) return;\n\n card.addEventListener(\"mouseenter\", () => {\n img.style.transform = \"scale(1.05)\";\n });\n\n card.addEventListener(\"mouseleave\", () => {\n img.style.transform = \"scale(1)\";\n });\n}\n\n// Retry helper to make play() more reliable\nfunction attemptVideoPlay(video: HTMLVideoElement, retries = 4): Promise<void> {\n return video.play().catch(() => {\n return new Promise<void>((resolve, reject) => {\n if (retries <= 0) {\n reject();\n return;\n }\n\n setTimeout(() => {\n attemptVideoPlay(video, retries - 1).then(resolve).catch(reject);\n }, 120);\n });\n });\n}\n\nfunction setupVideoHover(card: HTMLElement, enableHover: boolean) {\n const video = card.querySelector<HTMLVideoElement>(\"video\");\n const img = card.querySelector<HTMLImageElement>(\"img\");\n if (!video || !img) return;\n\n const hasSrc = Boolean(video.currentSrc || video.src);\n if (!hasSrc) return;\n\n // Help autoplay and mobile behavior\n video.muted = true;\n video.playsInline = true;\n\n img.style.transition = \"opacity 200ms ease\";\n video.style.transition = \"opacity 200ms ease, transform 200ms ease\";\n video.style.transform = \"scale(1)\";\n\n video.style.opacity = \"0\";\n video.style.display = \"block\";\n img.style.opacity = \"1\";\n\n let hovering = false;\n let firstFullPlayDone = false;\n\n const isVideoReady = () =>\n video.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA;\n\n const showVideo = () => {\n img.style.opacity = \"0\";\n video.style.opacity = \"1\";\n };\n\n const showImage = () => {\n img.style.opacity = \"1\";\n video.style.opacity = \"0\";\n };\n\n // After first full play, loop if user is still hovering\n const onEnded = () => {\n firstFullPlayDone = true;\n if (hovering) {\n video.loop = true;\n attemptVideoPlay(video).catch(() => { });\n }\n };\n\n video.addEventListener(\"ended\", onEnded);\n\n if (!enableHover) {\n // No hover behavior at all if disabled\n return;\n }\n\n card.addEventListener(\"mouseenter\", () => {\n hovering = true;\n video.style.transform = \"scale(1.05)\";\n showVideo();\n\n // If already loaded enough, try to play with retries\n if (isVideoReady()) {\n attemptVideoPlay(video).catch(() => { });\n } else {\n const onCanPlay = () => {\n video.removeEventListener(\"canplay\", onCanPlay);\n showVideo();\n attemptVideoPlay(video).catch(() => { });\n };\n\n video.addEventListener(\"canplay\", onCanPlay, { once: true });\n\n // Force loading to start if it has not yet\n video.load();\n }\n });\n\n card.addEventListener(\"mouseleave\", () => {\n hovering = false;\n video.style.transform = \"scale(1)\";\n video.loop = false;\n\n // Pause, but keep currentTime so next hover resumes\n video.pause();\n showImage();\n });\n}\n\nfunction setupVideoLoop(card: HTMLElement, enableHover: boolean) {\n const video = card.querySelector<HTMLVideoElement>(\"video\");\n const img = card.querySelector<HTMLImageElement>(\"img\");\n if (!video) return;\n\n const hasSrc = Boolean(video.currentSrc || video.src);\n if (!hasSrc) return;\n\n video.muted = true;\n video.playsInline = true;\n video.loop = true;\n\n if (img) {\n img.style.transition = \"opacity 200ms ease\";\n img.style.opacity = \"1\";\n }\n\n video.style.transition = \"opacity 200ms ease, transform 200ms ease\";\n video.style.transform = \"scale(1)\";\n video.style.opacity = \"0\";\n video.style.display = \"block\";\n\n const isVideoReady = () =>\n video.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA;\n\n const showVideo = () => {\n if (img) {\n img.style.opacity = \"0\";\n }\n video.style.opacity = \"1\";\n };\n\n const startPlayback = () => {\n showVideo();\n attemptVideoPlay(video).catch(() => { });\n };\n\n if (isVideoReady()) {\n startPlayback();\n } else {\n const onCanPlay = () => {\n video.removeEventListener(\"canplay\", onCanPlay);\n startPlayback();\n };\n\n video.addEventListener(\"canplay\", onCanPlay, { once: true });\n video.load();\n }\n\n // Video still plays on loop; hover only controls scaling\n if (enableHover) {\n card.addEventListener(\"mouseenter\", () => {\n video.style.transform = \"scale(1.05)\";\n });\n\n card.addEventListener(\"mouseleave\", () => {\n video.style.transform = \"scale(1)\";\n });\n }\n}"],
|
|
5
|
+
"mappings": ";;;AACA,MACE,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa,aAC7B;AACA,QAAI,YAAY,GAAG,uBAAY,UAAU,EAAE;AAAA,MAAiB;AAAA,MAAU,MACpE,SAAS,OAAO;AAAA,IAClB;AAAA,EACF,OAAO;AAAA,EAEP;;;ACVA,WAAS,iBAAiB,oBAAoB,MAAM;AAChD,UAAM,QAAQ,SAAS,iBAA8B,cAAc;AAEnE,UAAM,QAAQ,UAAQ;AAClB,YAAM,OAAO,KAAK,aAAa,YAAY;AAC3C,YAAM,YAAY,KAAK,aAAa,kBAAkB;AACtD,YAAM,cAAc,cAAc;AAElC,UAAI,SAAS,SAAS;AAClB,wBAAgB,MAAM,WAAW;AAAA,MACrC,WAAW,SAAS,kBAAkB;AAClC,wBAAgB,MAAM,WAAW;AAAA,MACrC,WAAW,SAAS,iBAAiB;AACjC,uBAAe,MAAM,WAAW;AAAA,MACpC;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AAED,WAAS,gBAAgB,MAAmB,aAAsB;AAC9D,UAAM,MAAM,KAAK,cAAg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AM,MAAM,UAAU;AAEtB,UAAM,eAAe,MACjB,MAAM,cAAc,iBAAiB;AAEzC,UAAM,YAAY,MAAM;AACpB,UAAI,KAAK;AACL,YAAI,MAAM,UAAU;AAAA,MACxB;AACA,YAAM,MAAM,UAAU;AAAA,IAC1B;AAEA,UAAM,gBAAgB,MAAM;AACxB,gBAAU;AACV,uBAAiB,KAAK,EAAE,MAAM,MAAM;AAAA,MAAE,CAAC;AAAA,IAC3C;AAEA,QAAI,aAAa,GAAG;AAChB,oBAAc;AAAA,IAClB,OAAO;AACH,YAAM,YAAY,MAAM;AACpB,cAAM,oBAAoB,WAAW,SAAS;AAC9C,sBAAc;AAAA,MAClB;AAEA,YAAM,iBAAiB,WAAW,WAAW,EAAE,MAAM,KAAK,CAAC;AAC3D,YAAM,KAAK;AAAA,IACf;AAGA,QAAI,aAAa;AACb,WAAK,iBAAiB,cAAc,MAAM;AACtC,cAAM,MAAM,YAAY;AAAA,MAC5B,CAAC;AAED,WAAK,iBAAiB,cAAc,MAAM;AACtC,cAAM,MAAM,YAAY;AAAA,MAC5B,CAAC;AAAA,IACL;AAAA,EACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{async function h(){try{let e=await fetch("https://ipwho.is/");if(!e.ok)throw new Error("Failed to fetch geolocation");let n=await e.json();return n.success===!1?(console.error("Geolocation lookup failed:",n.message),null):{ip:n.ip,country:n.country,region:n.region,city:n.city,latitude:n.latitude,longitude:n.longitude,isp:n.connection?.isp||"",timezone:n.timezone?.id||""}}catch(e){return console.error("Error fetching geolocation:",e),null}}var b="geo:data:v1",d="geo_country",g=7*24*60*60*1e3;function w(e,n,t){document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(n)}; Max-Age=${t}; Path=/; SameSite=Lax; Secure`}function C(e){let n=`${encodeURIComponent(e)}=`,t=document.cookie.split("; ");for(let o of t)if(o.startsWith(n))return decodeURIComponent(o.slice(n.length));return null}function A(e){try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);return!t?.expiresAt||Date.now()>t.expiresAt?(localStorage.removeItem(e),null):t.data}catch{return localStorage.removeItem(e),null}}function B(e,n,t){let o={data:n,expiresAt:Date.now()+t};try{localStorage.setItem(e,JSON.stringify(o))}catch{}}async function f(e){if(typeof window>"u")return null;if(!(e?.forceRefresh??!1)){let o=A(b);if(o)return window.__GEO=o,C(d)||w(d,o.country??"",Math.floor(g/1e3)),o}let t=null;try{t=await h()}catch(o){console.warn("getGeolocation() failed; defaulting to India:",o)}return t||(t={country:"India"}),B(b,t,g),w(d,t.country??"",Math.floor(g/1e3)),window.__GEO=t,t}function v(){return C(d)}function x(e,n,t="auto"){let r=(window||{}).gsap;if(!r){console.warn("GSAP not found on window. Did you include it globally?");return}let i=document.querySelector(e),u=document.querySelector(n);if(!i||!u){console.warn("openBanner: Element(s) not found for selectors:",{mainSelector:e,innerSelector:n});return}r.set(i,{height:0,overflow:"hidden"}),r.set(u,{opacity:0});let s=r.timeline();return s.to(i,{height:t,duration:.5,ease:"power2.out"}),s.to(u,{opacity:1,duration:.3,ease:"power1.out"},.2),s}function S(e,n,t=0){let r=(window||{}).gsap;if(!r){console.warn("GSAP not found on window. Did you include it globally?");return}let i=document.querySelector(e),u=document.querySelector(n);if(!i||!u){console.warn("closeBanner: Element(s) not found for selectors:",{mainSelector:e,innerSelector:n});return}r.set(i,{overflow:"hidden"});let s=r.timeline();return s.to(u,{opacity:0,duration:.25,ease:"power1.out"}),s.to(i,{height:t,duration:.45,ease:"power2.inOut"},.2),s}function E(e,n,t){let o=new Date;o.setTime(o.getTime()+t*60*60*1e3),document.cookie=`${e}=${n}; expires=${o.toUTCString()}; path=/`}function T(e){let n=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return n?n[2]:null}function m(){let e=window.innerWidth;return e>=992?"desktop":e>=768?"tablet":e>=480?"mobileLandscape":"mobilePortrait"}var l=[{country:"united arab emirates",aliases:["uae","u.a.e","united arab emirates"],countryCode:"ae",url:"/ae",tagline:"You're in the UAE. Welcome!"},{country:"saudi arabia",aliases:["saudi","ksa","kingdom of saudi arabia"],countryCode:"sa",url:"/sa",tagline:"Hello Saudi Arabia!"},{country:"south africa",aliases:["rsa"],countryCode:"za",url:"/za",tagline:"Hi South Africa!"},{country:"malaysia",countryCode:"my",url:"/my",tagline:"Selamat datang, Malaysia!"},{country:"indonesia",aliases:["idn"],countryCode:"id",url:"/id",tagline:"Halo Indonesia!"},{country:"philippines",aliases:["phl","the philippines"],countryCode:"ph",url:"/ph",tagline:"Kumusta, Philippines!"},{country:"india",aliases:["bharat"],countryCode:"in",url:"/in",tagline:"This country is India. Hi some text"},{country:"global",aliases:["global","rest of world","others"],countryCode:"global",url:"/global",tagline:"This is rest of world. Hi some text"}];function c(e){return(e??"").trim().toLowerCase()}function k(e){let n=e.trim();return n?n.startsWith("/")?n:`/${n}`:"/"}async function $(){if(typeof window>"u")return null;let e=v();if(e)return c(e);let n=await f();return c(n?.country)}function L(e){let n=c(e);if(!n)return null;let t=l.find(i=>c(i.countryCode)===n);if(t)return t;let o=l.find(i=>c(i.country)===n);if(o)return o;let r=l.find(i=>(i.aliases??[]).some(u=>c(u)===n));return r||null}function p(){let e=l.find(n=>n.country==="global");if(!e)throw new Error("[geo-banner] Global config not found in COUNTRY_CONFIG");return e}function N(e){if(typeof window>"u")return;let n=c(e),t=l.find(r=>c(r.countryCode)===n)||p(),o=document.querySelector('[fynd-banner-field="link"]');if(o){let r=window.location.origin;o.href=`${r}${k(t.url)}`}}function R(e,n){let t=L(n)??l.find(s=>s.country==="global");if(!t)return console.warn("[geo-banner] No matching config for",n),!1;let o=t.countryCode,r=Array.from(e.options),i=r.find(s=>c(s.value)===c(o));if(!i)return console.warn("[geo-banner] No matching <option> for",o,"on",e),!1;let u=e.value;return e.value=i.value,e.value!==i.value&&(e.selectedIndex=r.indexOf(i)),r.forEach(s=>s.selected=s===i),u!==e.value&&(e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))),console.log("[geo-banner] Select updated \u2192",t.country,"(",t.countryCode,")"),!0}function q(e){if(typeof window>"u")return;let n=c(e),t=l.find(i=>c(i.countryCode)===n)||p(),o=document.querySelector("#geoswitch-select")||document.querySelector('[fynd-banner-field="geoswitch"]');o?(console.log(`country code is ${t.countryCode}`),R(o,t.countryCode),o.value=t.countryCode,o.dispatchEvent(new Event("change",{bubbles:!0}))):console.warn('[geo-banner] Select not found: #geoswitch-select / [fynd-banner-field="geoswitch"]');let r=document.querySelector('[fynd-banner-field="link"]');if(r){let i=window.location.origin;r.href=`${i}${k(t.url)}`}}async function G(){if(typeof window>"u")return p();document.readyState==="loading"&&await new Promise(r=>{document.addEventListener("DOMContentLoaded",()=>r(),{once:!0})});let e=await $(),t=L(e)??p();console.log("[geo-banner] rawCountry:",e,"\u2192 resolved:",t.countryCode),q(t.countryCode);let o=document.querySelector('[fynd-banner-field="geoswitch"]');return o&&!o.__geoHandlerAttached&&(o.addEventListener("change",r=>{let i=r.target.value;N(i)}),o.__geoHandlerAttached=!0),t}var I={"/global":{mode:"country",countries:["India"]},"/":{mode:"notCountry",countries:["India"]}},M='[fynd-navigation="ip-banner"]',D='[fynd-navigation="ip-banner-inner"]',F='[fynd-navigation="ip-banner-close"]',se=document.querySelector('[fynd-navigation="announcement-bar"]'),ce=document.querySelector('[fynd-navigation="announcement-list"]'),a={ipbanner:{visibility:!1,height:{desktop:"56px",tablet:"60px",mobileLandscape:"120px",mobilePortrait:"120px"}},announcementbar:{visibility:!
|
|
1
|
+
"use strict";(()=>{async function h(){try{let e=await fetch("https://ipwho.is/");if(!e.ok)throw new Error("Failed to fetch geolocation");let n=await e.json();return n.success===!1?(console.error("Geolocation lookup failed:",n.message),null):{ip:n.ip,country:n.country,region:n.region,city:n.city,latitude:n.latitude,longitude:n.longitude,isp:n.connection?.isp||"",timezone:n.timezone?.id||""}}catch(e){return console.error("Error fetching geolocation:",e),null}}var b="geo:data:v1",d="geo_country",g=7*24*60*60*1e3;function w(e,n,t){document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(n)}; Max-Age=${t}; Path=/; SameSite=Lax; Secure`}function C(e){let n=`${encodeURIComponent(e)}=`,t=document.cookie.split("; ");for(let o of t)if(o.startsWith(n))return decodeURIComponent(o.slice(n.length));return null}function A(e){try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);return!t?.expiresAt||Date.now()>t.expiresAt?(localStorage.removeItem(e),null):t.data}catch{return localStorage.removeItem(e),null}}function B(e,n,t){let o={data:n,expiresAt:Date.now()+t};try{localStorage.setItem(e,JSON.stringify(o))}catch{}}async function f(e){if(typeof window>"u")return null;if(!(e?.forceRefresh??!1)){let o=A(b);if(o)return window.__GEO=o,C(d)||w(d,o.country??"",Math.floor(g/1e3)),o}let t=null;try{t=await h()}catch(o){console.warn("getGeolocation() failed; defaulting to India:",o)}return t||(t={country:"India"}),B(b,t,g),w(d,t.country??"",Math.floor(g/1e3)),window.__GEO=t,t}function v(){return C(d)}function x(e,n,t="auto"){let r=(window||{}).gsap;if(!r){console.warn("GSAP not found on window. Did you include it globally?");return}let i=document.querySelector(e),u=document.querySelector(n);if(!i||!u){console.warn("openBanner: Element(s) not found for selectors:",{mainSelector:e,innerSelector:n});return}r.set(i,{height:0,overflow:"hidden"}),r.set(u,{opacity:0});let s=r.timeline();return s.to(i,{height:t,duration:.5,ease:"power2.out"}),s.to(u,{opacity:1,duration:.3,ease:"power1.out"},.2),s}function S(e,n,t=0){let r=(window||{}).gsap;if(!r){console.warn("GSAP not found on window. Did you include it globally?");return}let i=document.querySelector(e),u=document.querySelector(n);if(!i||!u){console.warn("closeBanner: Element(s) not found for selectors:",{mainSelector:e,innerSelector:n});return}r.set(i,{overflow:"hidden"});let s=r.timeline();return s.to(u,{opacity:0,duration:.25,ease:"power1.out"}),s.to(i,{height:t,duration:.45,ease:"power2.inOut"},.2),s}function E(e,n,t){let o=new Date;o.setTime(o.getTime()+t*60*60*1e3),document.cookie=`${e}=${n}; expires=${o.toUTCString()}; path=/`}function T(e){let n=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return n?n[2]:null}function m(){let e=window.innerWidth;return e>=992?"desktop":e>=768?"tablet":e>=480?"mobileLandscape":"mobilePortrait"}var l=[{country:"united arab emirates",aliases:["uae","u.a.e","united arab emirates"],countryCode:"ae",url:"/ae",tagline:"You're in the UAE. Welcome!"},{country:"saudi arabia",aliases:["saudi","ksa","kingdom of saudi arabia"],countryCode:"sa",url:"/sa",tagline:"Hello Saudi Arabia!"},{country:"south africa",aliases:["rsa"],countryCode:"za",url:"/za",tagline:"Hi South Africa!"},{country:"malaysia",countryCode:"my",url:"/my",tagline:"Selamat datang, Malaysia!"},{country:"indonesia",aliases:["idn"],countryCode:"id",url:"/id",tagline:"Halo Indonesia!"},{country:"philippines",aliases:["phl","the philippines"],countryCode:"ph",url:"/ph",tagline:"Kumusta, Philippines!"},{country:"india",aliases:["bharat"],countryCode:"in",url:"/in",tagline:"This country is India. Hi some text"},{country:"global",aliases:["global","rest of world","others"],countryCode:"global",url:"/global",tagline:"This is rest of world. Hi some text"}];function c(e){return(e??"").trim().toLowerCase()}function k(e){let n=e.trim();return n?n.startsWith("/")?n:`/${n}`:"/"}async function $(){if(typeof window>"u")return null;let e=v();if(e)return c(e);let n=await f();return c(n?.country)}function L(e){let n=c(e);if(!n)return null;let t=l.find(i=>c(i.countryCode)===n);if(t)return t;let o=l.find(i=>c(i.country)===n);if(o)return o;let r=l.find(i=>(i.aliases??[]).some(u=>c(u)===n));return r||null}function p(){let e=l.find(n=>n.country==="global");if(!e)throw new Error("[geo-banner] Global config not found in COUNTRY_CONFIG");return e}function N(e){if(typeof window>"u")return;let n=c(e),t=l.find(r=>c(r.countryCode)===n)||p(),o=document.querySelector('[fynd-banner-field="link"]');if(o){let r=window.location.origin;o.href=`${r}${k(t.url)}`}}function R(e,n){let t=L(n)??l.find(s=>s.country==="global");if(!t)return console.warn("[geo-banner] No matching config for",n),!1;let o=t.countryCode,r=Array.from(e.options),i=r.find(s=>c(s.value)===c(o));if(!i)return console.warn("[geo-banner] No matching <option> for",o,"on",e),!1;let u=e.value;return e.value=i.value,e.value!==i.value&&(e.selectedIndex=r.indexOf(i)),r.forEach(s=>s.selected=s===i),u!==e.value&&(e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))),console.log("[geo-banner] Select updated \u2192",t.country,"(",t.countryCode,")"),!0}function q(e){if(typeof window>"u")return;let n=c(e),t=l.find(i=>c(i.countryCode)===n)||p(),o=document.querySelector("#geoswitch-select")||document.querySelector('[fynd-banner-field="geoswitch"]');o?(console.log(`country code is ${t.countryCode}`),R(o,t.countryCode),o.value=t.countryCode,o.dispatchEvent(new Event("change",{bubbles:!0}))):console.warn('[geo-banner] Select not found: #geoswitch-select / [fynd-banner-field="geoswitch"]');let r=document.querySelector('[fynd-banner-field="link"]');if(r){let i=window.location.origin;r.href=`${i}${k(t.url)}`}}async function G(){if(typeof window>"u")return p();document.readyState==="loading"&&await new Promise(r=>{document.addEventListener("DOMContentLoaded",()=>r(),{once:!0})});let e=await $(),t=L(e)??p();console.log("[geo-banner] rawCountry:",e,"\u2192 resolved:",t.countryCode),q(t.countryCode);let o=document.querySelector('[fynd-banner-field="geoswitch"]');return o&&!o.__geoHandlerAttached&&(o.addEventListener("change",r=>{let i=r.target.value;N(i)}),o.__geoHandlerAttached=!0),t}var I={"/global":{mode:"country",countries:["India"]},"/":{mode:"notCountry",countries:["India"]}},M='[fynd-navigation="ip-banner"]',D='[fynd-navigation="ip-banner-inner"]',F='[fynd-navigation="ip-banner-close"]',se=document.querySelector('[fynd-navigation="announcement-bar"]'),ce=document.querySelector('[fynd-navigation="announcement-list"]'),a={ipbanner:{visibility:!1,height:{desktop:"56px",tablet:"60px",mobileLandscape:"120px",mobilePortrait:"120px"}},announcementbar:{visibility:!1,height:{desktop:"40px",tablet:"40px",mobileLandscape:"40px",mobilePortrait:"46px"}},default:{visibility:!0,height:{desktop:"70px",tablet:"64px",mobileLandscape:"40px",mobilePortrait:"64px"}}};window.navigationData=a;function y(e,n){let t=o=>{if(typeof o=="number")return o;let r=parseInt(o,10);return isNaN(r)?0:r};return`${t(e)+t(n)}px`}function H(e,n){let t=o=>{if(typeof o=="number")return o;let r=parseInt(o,10);return isNaN(r)?0:r};return`${t(e)-t(n)}px`}var P=e=>{try{let n=e.split("?")[0].split("#")[0];return n==="/"?"/":n.replace(/\/+$/,"")||"/"}catch{return"/"}};function U(e){let n=P(e),t="";for(let o of Object.keys(I)){let r=P(o);(n===r||n.startsWith(r+"/"))&&r.length>t.length&&(t=r)}return t?{key:t,rule:I[t]}:null}function Y(e,n){let t=U(e);if(!t)return!1;let{rule:o}=t,r=(n?.country||"").toLowerCase();switch(o.mode){case"always":return!0;case"country":return o.countries.some(i=>i.toLowerCase()===r);case"notCountry":return!o.countries.some(i=>i.toLowerCase()===r);case"predicate":return!!o.test?.(n);default:return!1}}function z(){let e=document.querySelector('[fynd-navigation="announcement-swiper"]');if(e&&!e.__swiperInstance)try{let n=window.Swiper,t=new n(e,{slidesPerView:1,spaceBetween:0,effect:"fade",fadeEffect:{crossFade:!0},autoplay:{delay:3e3,disableOnInteraction:!1},loop:!0,speed:1e3,allowTouchMove:!1,on:{init:function(){this.slides.length<=1&&this.autoplay&&typeof this.autoplay.stop=="function"&&this.autoplay.stop()}}});e.__swiperInstance=t}catch(n){console.warn("Announcement Swiper init failed:",n)}}function _(){let e='[fynd-navigation="dropdown-container"]',n=document.querySelector(e);if(!n){console.warn(`initDesktopDropdownMenu: element not found: ${e}`);return}let t=m?.()??"unknown";if(t!=="desktop"){n.style.transition=n.style.transition||"transform 0.3s ease",n.style.transform="translateY(0px)";return}let o=a.default.height?.[t],r=!1;if(a.announcementbar?.visibility){let i=a.announcementbar.height?.[t];o=y(o,i),o=H(o,"46px"),r=!0}a.ipbanner?.visibility&&(o=y(o,"0px"),r||(o=H(o,"46px"))),n.style.transform=`translateY(${o})`}function O(){let e=document.querySelector('[fynd-navigation="spacer"][data-wf--navigation-spacer--variant="dynamic"]');if(!e){console.warn("initNavigationSpacer: spacer element not found");return}let n=r=>{if(typeof r=="number")return r;if(typeof r=="string"){let i=parseFloat(r);return Number.isFinite(i)?i:0}return 0},t=m?.()??"desktop",o=a.default.height?.[t];if(a.announcementbar?.visibility){let r=a.announcementbar.height?.[t];o=y(o,r)}if(a.ipbanner?.visibility){let r=n(a.ipbanner.height?.[t]);o=y(o,r)}e.style.height=`${o}`}async function K(){if(T("ipBannerClosed")==="true"){a.ipbanner.visibility=!1;return}let n=await f(),t=window.location.pathname||"/",o=Y(t,n??void 0),r=await G();if(o&&r){x(M,D,a.ipbanner.height.desktop),a.ipbanner.visibility=!0;let i=document.querySelector(F);i&&i.addEventListener("click",()=>{S(M,D),E("ipBannerClosed","true",24),a.ipbanner.visibility=!1,_(),O()})}else a.ipbanner.visibility=!1}document.addEventListener("DOMContentLoaded",async()=>{await K(),z(),_(),O()});})();
|
package/package.json
CHANGED