@fynd-design-engineering/fynd-one-v2 3.4.63 → 3.4.64

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.
Files changed (79) hide show
  1. package/dist/accordians/dropdown.js +1 -95
  2. package/dist/accordians/index.js +1 -391
  3. package/dist/cms-listing/index.js +1 -24
  4. package/dist/filters/clear-search.js +1 -32
  5. package/dist/filters/konnect.js +1 -165
  6. package/dist/filters/show-count.js +1 -66
  7. package/dist/form/country-dropdown.css +1 -160
  8. package/dist/form/cs-gated-redirection.js +1 -40
  9. package/dist/form/download-file.js +1 -70
  10. package/dist/form/validation.css +1 -1019
  11. package/dist/form/validation.js +7 -10611
  12. package/dist/global/anchor-scroll.js +1 -174
  13. package/dist/global/auth.js +1 -87
  14. package/dist/global/chat.js +1 -185
  15. package/dist/global/console-links.js +1 -89
  16. package/dist/global/contact-popup.js +2 -83
  17. package/dist/global/css/in-page-embed.css +1 -1043
  18. package/dist/global/css/in-project-settings.css +1 -173
  19. package/dist/global/css/temp.css +1 -89
  20. package/dist/global/custom-bg-video.js +1 -40
  21. package/dist/global/footer-accordion.js +1 -44
  22. package/dist/global/lazy-loader.js +1 -135
  23. package/dist/global/loader.js +2 -166
  24. package/dist/global/media-card.js +1 -166
  25. package/dist/global/miscellaneous.js +1 -136
  26. package/dist/global/number-count.js +1 -82
  27. package/dist/global/popup-video.js +1 -276
  28. package/dist/global/progressive-scroll.js +1 -222
  29. package/dist/global/responsive-video.js +1 -321
  30. package/dist/global/style.css +1 -1065
  31. package/dist/global/video-card.js +1 -50
  32. package/dist/hacktimus/2025.js +1 -177
  33. package/dist/hacktimus/styles.css +1 -91
  34. package/dist/home/index.js +1 -17
  35. package/dist/marquee/index.js +1 -3104
  36. package/dist/marquee/marquee-swiper.js +1 -36
  37. package/dist/navigation/announcement/index.js +1 -5169
  38. package/dist/navigation/context-menu/index.js +1 -31
  39. package/dist/navigation/desktop/index.js +1 -4603
  40. package/dist/navigation/initialization.js +1 -602
  41. package/dist/navigation/main.js +1 -4911
  42. package/dist/navigation/mobile/index.js +1 -286
  43. package/dist/navigation/scroll/index.js +1 -62
  44. package/dist/navigation/secondary-navigation/index.js +1 -437
  45. package/dist/navigation/style.css +1 -154
  46. package/dist/navigation/temp.css +0 -2
  47. package/dist/navigation/theme.css +1 -69
  48. package/dist/navigation-v2/index.js +1 -4990
  49. package/dist/navigation-v2/styles.css +1 -233
  50. package/dist/others/feature-detail.js +1 -75
  51. package/dist/others/geolocation.js +1 -50
  52. package/dist/others/hero-aniamtion.js +1 -53
  53. package/dist/others/hero-india-animation-2.js +1 -70
  54. package/dist/others/hero-india-animation.js +1 -93
  55. package/dist/others/home-solution-tab.js +1 -115
  56. package/dist/others/storefront-chat/index.js +1 -487
  57. package/dist/others/storefront-chat/styles.css +1 -107
  58. package/dist/playbook-2026/hero-reveal.js +1 -47
  59. package/dist/playbook-2026/index.js +1 -536
  60. package/dist/playbook-2026/styles.css +1 -110
  61. package/dist/posthog-and-ga/attributes.js +1 -190
  62. package/dist/posthog-and-ga/main.js +1 -528
  63. package/dist/progressive-scroll/index.js +1 -147
  64. package/dist/quick-fix/reload.js +1 -22
  65. package/dist/seo/schema.js +1 -465
  66. package/dist/slider/freescroll.js +1 -34
  67. package/dist/test/sample.js +1 -15
  68. package/dist/testimonials/index.js +1 -2654
  69. package/dist/timeline/index.js +1 -160
  70. package/dist/timeline/style.css +1 -42
  71. package/dist/tracking/custom-id.js +1 -75
  72. package/dist/tracking/fill-form-fields.js +1 -238
  73. package/dist/tracking/form-tracker.js +1 -146
  74. package/dist/tracking/page-categories.js +1 -20
  75. package/dist/tracking/user-journey.js +1 -839
  76. package/dist/tracking/utm-links.js +1 -194
  77. package/dist/utils/sample.js +1 -17
  78. package/dist/validations/localhost.js +1 -221
  79. package/package.json +1 -1
@@ -1,602 +1 @@
1
- "use strict";
2
- (() => {
3
- // bin/live-reload.js
4
- if (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") {
5
- new EventSource(`${"http://localhost:3000"}/esbuild`).addEventListener(
6
- "change",
7
- () => location.reload()
8
- );
9
- } else {
10
- }
11
-
12
- // src/global/geolocation/main.ts
13
- async function getGeolocation() {
14
- try {
15
- const response = await fetch("https://ipwho.is/");
16
- if (!response.ok) {
17
- throw new Error("Failed to fetch geolocation");
18
- }
19
- const data = await response.json();
20
- if (data.success === false) {
21
- console.error("Geolocation lookup failed:", data.message);
22
- return null;
23
- }
24
- return {
25
- ip: data.ip,
26
- country: data.country,
27
- region: data.region,
28
- city: data.city,
29
- latitude: data.latitude,
30
- longitude: data.longitude,
31
- isp: data.connection?.isp || "",
32
- timezone: data.timezone?.id || ""
33
- };
34
- } catch (error) {
35
- console.error("Error fetching geolocation:", error);
36
- return null;
37
- }
38
- }
39
-
40
- // src/global/geolocation/geolocation-cached.ts
41
- var GEO_CACHE_KEY = "geo:data:v1";
42
- var GEO_COOKIE_KEY = "geo_country";
43
- var GEO_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
44
- function setCookie(name, value, maxAgeSec) {
45
- document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(
46
- value
47
- )}; Max-Age=${maxAgeSec}; Path=/; SameSite=Lax; Secure`;
48
- }
49
- function getCookie(name) {
50
- const key = `${encodeURIComponent(name)}=`;
51
- const parts = document.cookie.split("; ");
52
- for (const p of parts) {
53
- if (p.startsWith(key)) return decodeURIComponent(p.slice(key.length));
54
- }
55
- return null;
56
- }
57
- function readCache(key) {
58
- try {
59
- const raw = localStorage.getItem(key);
60
- if (!raw) return null;
61
- const parsed = JSON.parse(raw);
62
- if (!parsed?.expiresAt || Date.now() > parsed.expiresAt) {
63
- localStorage.removeItem(key);
64
- return null;
65
- }
66
- return parsed.data;
67
- } catch {
68
- localStorage.removeItem(key);
69
- return null;
70
- }
71
- }
72
- function writeCache(key, data, ttlMs) {
73
- const payload = { data, expiresAt: Date.now() + ttlMs };
74
- try {
75
- localStorage.setItem(key, JSON.stringify(payload));
76
- } catch {
77
- }
78
- }
79
- async function getGeolocationCached(options) {
80
- if (typeof window === "undefined") return null;
81
- const forceRefresh = options?.forceRefresh ?? false;
82
- if (!forceRefresh) {
83
- const cached = readCache(GEO_CACHE_KEY);
84
- if (cached) {
85
- window.__GEO = cached;
86
- if (!getCookie(GEO_COOKIE_KEY)) {
87
- setCookie(
88
- GEO_COOKIE_KEY,
89
- cached.country ?? "",
90
- Math.floor(GEO_TTL_MS / 1e3)
91
- );
92
- }
93
- return cached;
94
- }
95
- }
96
- let geo = null;
97
- try {
98
- geo = await getGeolocation();
99
- } catch (e) {
100
- console.warn("getGeolocation() failed; defaulting to India:", e);
101
- }
102
- if (!geo) {
103
- geo = { country: "India" };
104
- }
105
- writeCache(GEO_CACHE_KEY, geo, GEO_TTL_MS);
106
- setCookie(GEO_COOKIE_KEY, geo.country ?? "", Math.floor(GEO_TTL_MS / 1e3));
107
- window.__GEO = geo;
108
- return geo;
109
- }
110
- function getGeoCountryFromCookie() {
111
- return getCookie(GEO_COOKIE_KEY);
112
- }
113
-
114
- // src/global/animation/toggle-banner.ts
115
- function openBanner(mainSelector, innerSelector, targetHeight = "auto") {
116
- const w = window || {};
117
- const gsap = w.gsap;
118
- if (!gsap) {
119
- console.warn("GSAP not found on window. Did you include it globally?");
120
- return;
121
- }
122
- const mainEl = document.querySelector(mainSelector);
123
- const innerEl = document.querySelector(innerSelector);
124
- if (!mainEl || !innerEl) {
125
- console.warn("openBanner: Element(s) not found for selectors:", {
126
- mainSelector,
127
- innerSelector
128
- });
129
- return;
130
- }
131
- gsap.set(mainEl, { height: 0, overflow: "hidden" });
132
- gsap.set(innerEl, { opacity: 0 });
133
- const tl = gsap.timeline();
134
- tl.to(mainEl, {
135
- height: targetHeight,
136
- duration: 0.5,
137
- ease: "power2.out"
138
- });
139
- tl.to(
140
- innerEl,
141
- {
142
- opacity: 1,
143
- duration: 0.3,
144
- ease: "power1.out"
145
- },
146
- 0.2
147
- );
148
- return tl;
149
- }
150
- function closeBanner(mainSelector, innerSelector, targetHeight = 0) {
151
- const w = window || {};
152
- const gsap = w.gsap;
153
- if (!gsap) {
154
- console.warn("GSAP not found on window. Did you include it globally?");
155
- return;
156
- }
157
- const mainEl = document.querySelector(mainSelector);
158
- const innerEl = document.querySelector(innerSelector);
159
- if (!mainEl || !innerEl) {
160
- console.warn("closeBanner: Element(s) not found for selectors:", {
161
- mainSelector,
162
- innerSelector
163
- });
164
- return;
165
- }
166
- gsap.set(mainEl, { overflow: "hidden" });
167
- const tl = gsap.timeline();
168
- tl.to(innerEl, {
169
- opacity: 0,
170
- duration: 0.25,
171
- ease: "power1.out"
172
- });
173
- tl.to(
174
- mainEl,
175
- {
176
- height: targetHeight,
177
- duration: 0.45,
178
- ease: "power2.inOut"
179
- },
180
- 0.2
181
- );
182
- return tl;
183
- }
184
-
185
- // src/utils/cookies.ts
186
- function setCookie2(name, value, hours) {
187
- const date = /* @__PURE__ */ new Date();
188
- date.setTime(date.getTime() + hours * 60 * 60 * 1e3);
189
- document.cookie = `${name}=${value}; expires=${date.toUTCString()}; path=/`;
190
- }
191
- function getCookie2(name) {
192
- const match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
193
- return match ? match[2] : null;
194
- }
195
-
196
- // src/global/screen-type.ts
197
- function getScreenType() {
198
- const width = window.innerWidth;
199
- if (width >= 992) {
200
- return "desktop";
201
- } else if (width >= 768) {
202
- return "tablet";
203
- } else if (width >= 480) {
204
- return "mobileLandscape";
205
- } else {
206
- return "mobilePortrait";
207
- }
208
- }
209
-
210
- // src/navigation/country-detection/main.ts
211
- var COUNTRY_CONFIG = [
212
- {
213
- country: "united arab emirates",
214
- aliases: ["uae", "u.a.e", "united arab emirates"],
215
- countryCode: "ae",
216
- url: "/ae",
217
- tagline: "You're in the UAE. Welcome!"
218
- },
219
- {
220
- country: "saudi arabia",
221
- aliases: ["saudi", "ksa", "kingdom of saudi arabia"],
222
- countryCode: "sa",
223
- url: "/sa",
224
- tagline: "Hello Saudi Arabia!"
225
- },
226
- {
227
- country: "south africa",
228
- aliases: ["rsa"],
229
- countryCode: "za",
230
- url: "/za",
231
- tagline: "Hi South Africa!"
232
- },
233
- {
234
- country: "malaysia",
235
- countryCode: "my",
236
- url: "/my",
237
- tagline: "Selamat datang, Malaysia!"
238
- },
239
- {
240
- country: "indonesia",
241
- aliases: ["idn"],
242
- countryCode: "id",
243
- url: "/id",
244
- tagline: "Halo Indonesia!"
245
- },
246
- {
247
- country: "philippines",
248
- aliases: ["phl", "the philippines"],
249
- countryCode: "ph",
250
- url: "/ph",
251
- tagline: "Kumusta, Philippines!"
252
- },
253
- {
254
- country: "india",
255
- aliases: ["bharat"],
256
- countryCode: "in",
257
- url: "/in",
258
- tagline: "This country is India. Hi some text"
259
- },
260
- // 👇 fallback
261
- {
262
- country: "global",
263
- aliases: ["global", "rest of world", "others"],
264
- countryCode: "global",
265
- // keep lowercase for consistency
266
- url: "/global",
267
- tagline: "This is rest of world. Hi some text"
268
- }
269
- ];
270
- function norm(s) {
271
- return (s ?? "").trim().toLowerCase();
272
- }
273
- function toPath(path) {
274
- const p = path.trim();
275
- if (!p) return "/";
276
- return p.startsWith("/") ? p : `/${p}`;
277
- }
278
- async function getUserCountry() {
279
- if (typeof window === "undefined") return null;
280
- const cookieCountry = getGeoCountryFromCookie();
281
- if (cookieCountry) return norm(cookieCountry);
282
- const geo = await getGeolocationCached();
283
- return norm(geo?.country);
284
- }
285
- function findCountryConfig(input) {
286
- const v = norm(input);
287
- if (!v) return null;
288
- const byCode = COUNTRY_CONFIG.find((c) => norm(c.countryCode) === v);
289
- if (byCode) return byCode;
290
- const byName = COUNTRY_CONFIG.find((c) => norm(c.country) === v);
291
- if (byName) return byName;
292
- const byAlias = COUNTRY_CONFIG.find((c) => (c.aliases ?? []).some((a) => norm(a) === v));
293
- if (byAlias) return byAlias;
294
- return null;
295
- }
296
- function getGlobalConfig() {
297
- const g = COUNTRY_CONFIG.find((c) => c.country === "global");
298
- if (!g) throw new Error("[geo-banner] Global config not found in COUNTRY_CONFIG");
299
- return g;
300
- }
301
- function updateBannerLink(countryCode) {
302
- if (typeof window === "undefined") return;
303
- const code = norm(countryCode);
304
- const conf = COUNTRY_CONFIG.find((c) => norm(c.countryCode) === code) || getGlobalConfig();
305
- const linkEl = document.querySelector('[fynd-banner-field="link"]');
306
- if (linkEl) {
307
- const base = window.location.origin;
308
- linkEl.href = `${base}${toPath(conf.url)}`;
309
- }
310
- }
311
- function setSelectValueSafely(selectEl, desired) {
312
- const conf = findCountryConfig(desired) ?? COUNTRY_CONFIG.find((c) => c.country === "global");
313
- if (!conf) {
314
- console.warn("[geo-banner] No matching config for", desired);
315
- return false;
316
- }
317
- const desiredCode = conf.countryCode;
318
- const opts = Array.from(selectEl.options);
319
- const opt = opts.find((o) => norm(o.value) === norm(desiredCode));
320
- if (!opt) {
321
- console.warn("[geo-banner] No matching <option> for", desiredCode, "on", selectEl);
322
- return false;
323
- }
324
- const prev = selectEl.value;
325
- selectEl.value = opt.value;
326
- if (selectEl.value !== opt.value) {
327
- selectEl.selectedIndex = opts.indexOf(opt);
328
- }
329
- opts.forEach((o) => o.selected = o === opt);
330
- if (prev !== selectEl.value) {
331
- selectEl.dispatchEvent(new Event("input", { bubbles: true }));
332
- selectEl.dispatchEvent(new Event("change", { bubbles: true }));
333
- }
334
- console.log("[geo-banner] Select updated \u2192", conf.country, "(", conf.countryCode, ")");
335
- return true;
336
- }
337
- function updateBannerContent(countryCode) {
338
- if (typeof window === "undefined") return;
339
- const code = norm(countryCode);
340
- const conf = COUNTRY_CONFIG.find((c) => norm(c.countryCode) === code) || getGlobalConfig();
341
- const selectEl = document.querySelector("#geoswitch-select") || document.querySelector('[fynd-banner-field="geoswitch"]');
342
- if (selectEl) {
343
- console.log(`country code is ${conf.countryCode}`);
344
- setSelectValueSafely(selectEl, conf.countryCode);
345
- selectEl.value = conf.countryCode;
346
- selectEl.dispatchEvent(new Event("change", { bubbles: true }));
347
- } else {
348
- console.warn('[geo-banner] Select not found: #geoswitch-select / [fynd-banner-field="geoswitch"]');
349
- }
350
- const linkEl = document.querySelector('[fynd-banner-field="link"]');
351
- if (linkEl) {
352
- const base = window.location.origin;
353
- linkEl.href = `${base}${toPath(conf.url)}`;
354
- }
355
- }
356
- async function initCountryDetection() {
357
- if (typeof window === "undefined") return getGlobalConfig();
358
- if (document.readyState === "loading") {
359
- await new Promise((resolve) => {
360
- document.addEventListener("DOMContentLoaded", () => resolve(), { once: true });
361
- });
362
- }
363
- const rawCountry = await getUserCountry();
364
- const match = findCountryConfig(rawCountry);
365
- const resolved = match ?? getGlobalConfig();
366
- console.log("[geo-banner] rawCountry:", rawCountry, "\u2192 resolved:", resolved.countryCode);
367
- updateBannerContent(resolved.countryCode);
368
- const selectEl = document.querySelector('[fynd-banner-field="geoswitch"]');
369
- if (selectEl && !selectEl.__geoHandlerAttached) {
370
- selectEl.addEventListener("change", (e) => {
371
- const value = e.target.value;
372
- updateBannerLink(value);
373
- });
374
- selectEl.__geoHandlerAttached = true;
375
- }
376
- return resolved;
377
- }
378
-
379
- // src/navigation/initialization.ts
380
- var bannerRouteRules = {
381
- "/global": { mode: "country", countries: ["India"] },
382
- "/": { mode: "notCountry", countries: ["India"] }
383
- };
384
- var ipBannerMain = '[fynd-navigation="ip-banner"]';
385
- var ipBannerInner = '[fynd-navigation="ip-banner-inner"]';
386
- var closeIpBanner = '[fynd-navigation="ip-banner-close"]';
387
- var announcementBar = document.querySelector(
388
- '[fynd-navigation="announcement-bar"]'
389
- );
390
- var announcementList = document.querySelector(
391
- '[fynd-navigation="announcement-list"]'
392
- );
393
- var navigationData = {
394
- ipbanner: {
395
- visibility: false,
396
- height: {
397
- desktop: "56px",
398
- tablet: "60px",
399
- mobileLandscape: "120px",
400
- mobilePortrait: "120px"
401
- }
402
- },
403
- announcementbar: {
404
- visibility: true,
405
- height: {
406
- desktop: "40px",
407
- tablet: "40px",
408
- mobileLandscape: "40px",
409
- mobilePortrait: "46px"
410
- }
411
- },
412
- default: {
413
- visibility: true,
414
- height: {
415
- desktop: "70px",
416
- tablet: "64px",
417
- mobileLandscape: "40px",
418
- mobilePortrait: "64px"
419
- }
420
- }
421
- };
422
- window.navigationData = navigationData;
423
- function addPx(a, b) {
424
- const toNumber = (val) => {
425
- if (typeof val === "number") return val;
426
- const num = parseInt(val, 10);
427
- return isNaN(num) ? 0 : num;
428
- };
429
- return `${toNumber(a) + toNumber(b)}px`;
430
- }
431
- function subtractPx(a, b) {
432
- const toNumber = (val) => {
433
- if (typeof val === "number") return val;
434
- const num = parseInt(val, 10);
435
- return isNaN(num) ? 0 : num;
436
- };
437
- return `${toNumber(a) - toNumber(b)}px`;
438
- }
439
- var normalizePath = (p) => {
440
- try {
441
- const urlPath = p.split("?")[0].split("#")[0];
442
- if (urlPath === "/") return "/";
443
- return urlPath.replace(/\/+$/, "") || "/";
444
- } catch {
445
- return "/";
446
- }
447
- };
448
- function getMatchingRule(pathname) {
449
- const path = normalizePath(pathname);
450
- let bestKey = "";
451
- for (const key of Object.keys(bannerRouteRules)) {
452
- const normKey = normalizePath(key);
453
- if (path === normKey || path.startsWith(normKey + "/")) {
454
- if (normKey.length > bestKey.length) bestKey = normKey;
455
- }
456
- }
457
- return bestKey ? { key: bestKey, rule: bannerRouteRules[bestKey] } : null;
458
- }
459
- function shouldOpenBannerForPage(pathname, geo) {
460
- const match = getMatchingRule(pathname);
461
- if (!match) return false;
462
- const { rule } = match;
463
- const visitorCountry = (geo?.country || "").toLowerCase();
464
- switch (rule.mode) {
465
- case "always":
466
- return true;
467
- case "country":
468
- return rule.countries.some((c) => c.toLowerCase() === visitorCountry);
469
- case "notCountry":
470
- return !rule.countries.some((c) => c.toLowerCase() === visitorCountry);
471
- case "predicate":
472
- return !!rule.test?.(geo);
473
- default:
474
- return false;
475
- }
476
- }
477
- function initAnnouncementBar() {
478
- const swiperEl = document.querySelector(
479
- '[fynd-navigation="announcement-swiper"]'
480
- );
481
- if (swiperEl && !swiperEl.__swiperInstance) {
482
- try {
483
- const Swiper = window.Swiper;
484
- const swiper = new Swiper(swiperEl, {
485
- slidesPerView: 1,
486
- spaceBetween: 0,
487
- effect: "fade",
488
- fadeEffect: { crossFade: true },
489
- autoplay: { delay: 3e3, disableOnInteraction: false },
490
- loop: true,
491
- speed: 1e3,
492
- allowTouchMove: false,
493
- on: {
494
- init: function() {
495
- if (this.slides.length <= 1 && this.autoplay && typeof this.autoplay.stop === "function") {
496
- this.autoplay.stop();
497
- }
498
- }
499
- }
500
- });
501
- swiperEl.__swiperInstance = swiper;
502
- } catch (err) {
503
- console.warn("Announcement Swiper init failed:", err);
504
- }
505
- }
506
- }
507
- function initDesktopDropdownMenu() {
508
- const selector = '[fynd-navigation="dropdown-container"]';
509
- const el = document.querySelector(selector);
510
- if (!el) {
511
- console.warn(`initDesktopDropdownMenu: element not found: ${selector}`);
512
- return;
513
- }
514
- const screenType = getScreenType?.() ?? "unknown";
515
- if (screenType !== "desktop") {
516
- el.style.transition = el.style.transition || "transform 0.3s ease";
517
- el.style.transform = "translateY(0px)";
518
- return;
519
- }
520
- let total = navigationData.default.height?.[screenType];
521
- let subtractFlag = false;
522
- if (navigationData.announcementbar?.visibility) {
523
- const h = navigationData.announcementbar.height?.[screenType];
524
- total = addPx(total, h);
525
- total = subtractPx(total, "46px");
526
- subtractFlag = true;
527
- }
528
- if (navigationData.ipbanner?.visibility) {
529
- const h = "0px";
530
- total = addPx(total, h);
531
- if (!subtractFlag) {
532
- total = subtractPx(total, "46px");
533
- }
534
- }
535
- el.style.transform = `translateY(${total})`;
536
- }
537
- function initNavigationSpacer() {
538
- const spacer = document.querySelector(
539
- '[fynd-navigation="spacer"][data-wf--navigation-spacer--variant="dynamic"]'
540
- );
541
- if (!spacer) {
542
- return;
543
- }
544
- const toPx = (v) => {
545
- if (typeof v === "number") return v;
546
- if (typeof v === "string") {
547
- const n = parseFloat(v);
548
- return Number.isFinite(n) ? n : 0;
549
- }
550
- return 0;
551
- };
552
- const screenType = getScreenType?.() ?? "desktop";
553
- let total = navigationData.default.height?.[screenType];
554
- if (navigationData.announcementbar?.visibility) {
555
- const h = navigationData.announcementbar.height?.[screenType];
556
- total = addPx(total, h);
557
- }
558
- if (navigationData.ipbanner?.visibility) {
559
- const h = toPx(navigationData.ipbanner.height?.[screenType]);
560
- total = addPx(total, h);
561
- }
562
- spacer.style.height = `${total}`;
563
- }
564
- async function initIpBanner() {
565
- const ipClosed = getCookie2("ipBannerClosed") === "true";
566
- if (ipClosed) {
567
- navigationData.ipbanner.visibility = false;
568
- return;
569
- }
570
- const geo = await getGeolocationCached();
571
- const path = window.location.pathname || "/";
572
- const allowByRoute = shouldOpenBannerForPage(path, geo ?? void 0);
573
- const countryReady = await initCountryDetection();
574
- if (allowByRoute && countryReady) {
575
- openBanner(
576
- ipBannerMain,
577
- ipBannerInner,
578
- navigationData.ipbanner.height.desktop
579
- );
580
- navigationData.ipbanner.visibility = true;
581
- const closeBtn = document.querySelector(closeIpBanner);
582
- if (closeBtn) {
583
- closeBtn.addEventListener("click", () => {
584
- closeBanner(ipBannerMain, ipBannerInner);
585
- setCookie2("ipBannerClosed", "true", 24);
586
- navigationData.ipbanner.visibility = false;
587
- initDesktopDropdownMenu();
588
- initNavigationSpacer();
589
- });
590
- }
591
- } else {
592
- navigationData.ipbanner.visibility = false;
593
- }
594
- }
595
- document.addEventListener("DOMContentLoaded", async () => {
596
- await initIpBanner();
597
- initAnnouncementBar();
598
- initDesktopDropdownMenu();
599
- initNavigationSpacer();
600
- });
601
- })();
602
- //# sourceMappingURL=initialization.js.map
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 R(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 N(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}`),N(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;R(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:!0,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)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()});})();