xv-webcomponents 1.2.10-qa.0 → 1.3.2-qa.0

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.
@@ -78428,20 +78428,45 @@ const XvMegaMenu = class {
78428
78428
  if (typeof fetch !== 'function')
78429
78429
  return [];
78430
78430
  try {
78431
- this.loading = true;
78432
78431
  const isBrowser = typeof window !== 'undefined';
78433
- const isLocalhost = isBrowser && /^(localhost|127\.0\.0\.1)$/i.test(window.location.hostname);
78434
- // Use QA Front Door when local; otherwise same-origin.
78435
- const baseUrl = isLocalhost
78436
- ? 'https://qa.crossvertise.com'
78437
- : (isBrowser ? window.location.origin : '');
78438
- const apiBase = `${baseUrl}/api-fd/v1`;
78439
- const response = await fetch(`${apiBase}/home/menu`, {
78432
+ if (!isBrowser)
78433
+ return [];
78434
+ const hostname = window.location.hostname;
78435
+ // --- Map hostnames to environment names ---
78436
+ const envMap = {
78437
+ 'qa.crossvertise.com': 'qa',
78438
+ 'komsa-test.crossvertise.com': 'qa',
78439
+ 'staging.crossvertise.com': 'staging',
78440
+ 'market.crossvertise.com': 'release',
78441
+ 'allianz.crossvertise.com': 'release',
78442
+ 'philips.crossvertise.com': 'release',
78443
+ 'komsa.crossvertise.com': 'release',
78444
+ };
78445
+ const matchedKey = Object.keys(envMap).find(h => hostname.includes(h));
78446
+ const env = matchedKey ? envMap[matchedKey] : 'qa';
78447
+ const subdomain = hostname.split('.')[0];
78448
+ const shouldUseBlob = subdomain === 'www' ||
78449
+ subdomain === 'market' ||
78450
+ (['qa', 'staging'].includes(env) &&
78451
+ document.cookie.includes('ConfigOverride=Xv'));
78452
+ let dataUrl = '';
78453
+ if (shouldUseBlob) {
78454
+ // --- Use blob storage ---
78455
+ const blobEnv = env === 'qa' || env === 'staging' ? env : 'release';
78456
+ dataUrl = `https://crossvertise.blob.core.windows.net/nav-sync-${blobEnv}/mega-menu.json`;
78457
+ }
78458
+ else {
78459
+ // --- Use API Front Door ---
78460
+ const isLocalhost = /^(localhost|127\.0\.0\.1)$/i.test(hostname);
78461
+ const baseUrl = isLocalhost
78462
+ ? 'https://qa.crossvertise.com'
78463
+ : window.location.origin;
78464
+ dataUrl = `${baseUrl}/api-fd/v1/home/menu`;
78465
+ }
78466
+ // --- Fetch menu data ---
78467
+ const response = await fetch(dataUrl, {
78440
78468
  method: 'GET',
78441
- headers: {
78442
- Accept: 'application/json',
78443
- },
78444
- // include cookies if your auth relies on them
78469
+ headers: { Accept: 'application/json' },
78445
78470
  credentials: 'include',
78446
78471
  });
78447
78472
  if (!response.ok) {
@@ -78449,24 +78474,21 @@ const XvMegaMenu = class {
78449
78474
  return [];
78450
78475
  }
78451
78476
  const result = await response.json();
78452
- return (_a = result === null || result === void 0 ? void 0 : result.data) !== null && _a !== void 0 ? _a : [];
78477
+ return (_a = result === null || result === void 0 ? void 0 : result.data) !== null && _a !== void 0 ? _a : result;
78453
78478
  }
78454
78479
  catch (error) {
78455
78480
  console.error('fetchMenuData error', error);
78456
78481
  return [];
78457
78482
  }
78458
- finally {
78459
- this.loading = false;
78460
- }
78461
78483
  }
78462
78484
  render() {
78463
- return (index.h(index.Host, { key: '19a2112363e3a2bf20048ea0bc65a1c723b31805' }, index.h("nav", { key: 'fc06506c111c5a237b124650473ee0c9bcdb305b', class: { 'xv-menu': true, open: this.open } }, this.loading && (index.h("div", { key: 'a511ab437ffee1dafce45b3b054491849646a7d3', class: { 'xv-menu-loader': true, open: this.open } }, index.h("xv-loader-v2", { key: 'e40e2ad3cfadcf7e5e6d73e050ba6a5abed4e616' }))), index.h("ul", { key: 'b5fb628b6c1fd700f0b946c6b442925b81b9f09b', class: { menu: true, open: this.open } }, this.menuItems.map((menuItem) => {
78485
+ return (index.h(index.Host, { key: 'a60b11b5822a52349d354f601ebaf6e124f919fc' }, index.h("nav", { key: 'f014c77038ee8cebd2b0ece2744dbd45e7e3ab41', class: { 'xv-menu': true, open: this.open } }, this.loading && (index.h("div", { key: '0e80752b79c0a78da74f37acb23cf8cc1fe088ed', class: { 'xv-menu-loader': true, open: this.open } }, index.h("xv-loader-v2", { key: '7878547839f70bf00fcc2cf345dee7f2ea51499a' }))), index.h("ul", { key: 'd5608c780b79b6488d6ad3afaab9e2c480ddcddd', class: { menu: true, open: this.open } }, this.menuItems.map((menuItem) => {
78464
78486
  var _a;
78465
78487
  return (index.h("li", { class: { 'menu-item': true, active: menuItem.id === ((_a = this.activeItem) === null || _a === void 0 ? void 0 : _a.id) } }, index.h("p", { class: "menu-item-label", onClick: () => this.setActiveItem(menuItem) }, menuItem === null || menuItem === void 0 ? void 0 : menuItem.label), index.h("ul", { class: "menu-item-groups" }, menuItem.groups.map((group) => {
78466
78488
  var _a, _b;
78467
78489
  return (index.h("li", { class: { group: true, active: ((_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id) === group.id } }, group.label && (index.h("div", { class: "group-label", onClick: () => this.setActiveGroup(group) }, index.h("span", { class: "group-label-text" }, group.label), index.h("span", { class: "group-label-icon" }))), index.h("div", { class: "group-container" }, index.h("div", { class: { 'group-container-absolute': true, noLabel: !group.label && (((_b = menuItem.groups) === null || _b === void 0 ? void 0 : _b.length) || 0) < 2 } }, index.h("div", { class: "group-menus" }, index.h("ul", { class: { 'group-menus-categories': true, inline: group.layout === 'inline' } }, group.categories.map((category) => (index.h("li", { class: "category" }, index.h("p", { class: "category-label" }, category.label), index.h("ul", { class: "category-routes" }, category.routes.map((route) => (index.h("li", { class: "route" }, index.h("xv-link-v2", { size: "lg", variant: "ghost", href: route.route || '#' }, route.label), route.tag && (index.h("xv-tag-v2", { class: "route-tag", size: "sm", color: "#161616", bg: "#E0E0E0" }, route.tag)))))))))), index.h("ul", { class: "group-menus-actions" }, group.actions.map((action) => (index.h("li", { class: "action" }, action.type === 'link' && (index.h("xv-link-v2", { variant: "standalone", href: action === null || action === void 0 ? void 0 : action.url }, action.label, index.h("span", { class: "link-chevron", slot: "icon-right" }, "\u2192"))), action.type === 'button' && index.h("xv-button-v2", { onClick: () => this.navActionClick(action), block: true, variant: "tertiary" }, action.label)))))), (group === null || group === void 0 ? void 0 : group.card) && (index.h("div", { class: "group-card" }, index.h("xv-card-v2", { media: group.card.image, variant: this.isMobile ? 'horizontal' : 'vertical' }, index.h("h5", { slot: "header", class: "group-card-title" }, group.card.title), index.h("p", { slot: "body", class: "group-card-desc" }, group.card.description), group.card.linkLabel && (index.h("xv-link-v2", { slot: "footer", variant: "standalone", href: group.card.linkUrl || '#' }, group.card.linkLabel, index.h("span", { class: "link-chevron", slot: "icon-right" }, "\u2192"))))))))));
78468
78490
  }))));
78469
- }), index.h("li", { key: 'd0eaab4f37ffd626ef381554db4be5957a99722f', class: "menu--right" }, index.h("slot", { key: '007d5a461d72dc495d29753bb7d8f32a54ba82bd', name: "menu-right" })), this.open && (index.h("li", { key: '936487e54c2e436bd148eee06ba9f9e2c4b84987', class: "menu--backdrop", onClick: () => this.handleClose() }))))));
78491
+ }), index.h("li", { key: 'a5338da25a0d60552c8d044e13d3b0a4039d2b74', class: "menu--right" }, index.h("slot", { key: 'c5031d2f7e5721c656226ee80b34f7381823b9a1', name: "menu-right" })), this.open && (index.h("li", { key: '74189665d20a041a152771718d15f09f9f8c05cc', class: "menu--backdrop", onClick: () => this.handleClose() }))))));
78470
78492
  }
78471
78493
  get el() { return index.getElement(this); }
78472
78494
  };