{"version":3,"file":"script.js","sources":["../../../dev/components/video-wistia/_script.js","../../../dev/assets/js/utilities.js","../../../dev/components/ctas/trip/_script.js","../../../dev/components/subpage-layout/_script.js","../../../dev/components/enso/_script.js","../../../dev/components/slideshow-old/_script.js","../../../dev/components/hero/_video.js","../../../dev/components/slideshow/_script.js","../../../dev/components/modal/_script.js","../../../dev/components/modal/slideshow-accommodation/_script.js","../../../dev/components/breadcrumbs/_script.js","../../../dev/assets/js/global-form-functions.js","../../../dev/components/modal/custom/_script.js","../../../dev/components/modal/private/_script.js","../../../dev/components/lists/country-list/_country-list.js","../../../dev/assets/js/smartypants.js","../../../dev/components/olark/_script.js","../../../dev/components/modal/pdf/_script.js","../../../dev/components/modal/ask/_script.js","../../../dev/components/nav/_script.js","../../../dev/components/masthead/_script.js","../../../dev/components/masthead/nav/_script.js","../../../dev/components/modal/catalog/_script.js","../../../dev/components/modal/enews/_script.js","../../../dev/components/modal/message/_script.js","../../../dev/components/modal/refer/_script.js","../../../dev/components/modal/digital/_script.js","../../../dev/components/modal/youtube/_script.js","../../../dev/components/modal/eBook/_script.js","../../../dev/components/ctas/magic/_script.js","../../../dev/components/masthead/favorites/_script.js","../../../dev/templates/trip-accommodations/script.js"],"sourcesContent":["export function isWistiaVideoPlaying() {\n\tlet isVideoPlaying = false;\n\n\tfunction wistiaVideo() {\n\t\tconst videoID = document.querySelector(\".js-wistia-video-id\").textContent;\n\t\tconst wistiaSrc = `https://fast.wistia.net/embed/iframe/${videoID}?videoFoam=true`;\n\n\t\tif (wistiaSrc === \"https://fast.wistia.net/embed/iframe/?videoFoam=true\") {\n\t\t\treturn;\n\t\t}\n\n\t\tconst wistiaIframe = document.querySelector(\".js-wistia-video\");\n\t\twistiaIframe.setAttribute(\"src\", wistiaSrc);\n\n\t\twindow._wq = window._wq || [];\n\t\tconst videoTitles = document.querySelector(\".js-video\");\n\t\tvideoTitles.addEventListener(\"click\", function (ev) {\n\t\t\tvideoTitles.classList.add(\"hide\");\n\t\t\tplayVideo();\n\t\t});\n\t\tfunction playVideo() {\n\t\t\tlet playStatus;\n\t\t\t_wq.push({\n\t\t\t\tid: \"_all\",\n\t\t\t\tonReady: function (video) {\n\t\t\t\t\tvideo.play();\n\t\t\t\t\tvideo.bind(\"play\", function () {\n\t\t\t\t\t\tplayStatus = true;\n\t\t\t\t\t\tvideoPlayStatus(playStatus);\n\t\t\t\t\t});\n\t\t\t\t\tvideo.bind(\"pause\", function () {\n\t\t\t\t\t\tplayStatus = false;\n\t\t\t\t\t\tvideoPlayStatus(playStatus);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\twistiaVideo();\n\n\tfunction videoPlayStatus(status) {\n\t\tisVideoPlaying = status;\n\t}\n\treturn isVideoPlaying;\n}\n","import { isWistiaVideoPlaying } from \"../../components/video-wistia/_script.js\";\n\nexport function isAdmin() {\n\tconst ensoElement = document.querySelector(\"[enso]\");\n\tconst ensoElementAttribute = ensoElement.getAttribute(\"enso\");\n\treturn Boolean(ensoElementAttribute);\n}\n\nexport function showForAdmin() {\n\tif (!isAdmin()) return;\n\n\tif (window.matchMedia(\"(max-width : 768px)\").matches) return;\n\n\tconst elements = document.querySelectorAll(\"[js-show-for-admin]\");\n\tfor (const element of elements) {\n\t\tconst getDisplayType = element.getAttribute(\"js-show-for-admin\");\n\t\telement.classList.remove(\"hide\");\n\t\telement.style.display = `${getDisplayType}`; // to pick up edge cases during migration\n\t}\n}\n\nexport function cleanupAnchorTags() {\n\t// Remove a tag if href is missing or undefined\n\t$(\"a\").each(function () {\n\t\tif ($(this).attr(\"href\") == \"\" || $(this).attr(\"href\") == \"undefined\") {\n\t\t\t$(this).remove();\n\t\t}\n\t});\n}\n\n// Check all a links to find target = _blank see above\nexport function cleanupAnchorTagsBlankTarget() {\n\tdocument.querySelectorAll(\"a\").forEach(function (link) {\n\t\tif (!link.hasAttribute(\"href\")) link.remove();\n\n\t\tconst linkHref = link.getAttribute(\"href\");\n\n\t\t// Add _blank to all links that go to Monster Campaigns so they open on top of our pages instead of being redirected to Monsty\n\t\tif (linkHref && linkHref.includes(\"https://app.monstercampaigns.com/\")) {\n\t\t\tlink.setAttribute(\"target\", \"_blank\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Remove all _blank from a tags on mobile and tablet\n\t\tif (document.documentElement.clientWidth < 1025) {\n\t\t\tlink.setAttribute(\"target\", \"_self\");\n\t\t}\n\t});\n}\n\nexport function pushEvent(item, action, label) {\n\ttry {\n\t\tdataLayer.push({\n\t\t\tevent: item,\n\t\t\taction: action,\n\t\t\tlabel: label\n\t\t});\n\t\tconsole.log(\"Success: Pushed Event via data layer:\", item, action, label);\n\t} catch (error) {\n\t\tconsole.log(\"Failed: Pushed Event:\", item, action, label, \"-\", error);\n\t}\n}\n\nexport function pushEventFacebook() {\n\ttry {\n\t\tfbq(\"track\", \"Lead\");\n\t} catch (error) {\n\t\tconsole.log(\"Failed : pushEventFacebook\");\n\t}\n}\n\nexport function pushEventBing() {\n\ttry {\n\t\twindow.uetq = window.uetq || [];\n\t\twindow.uetq.push({\n\t\t\tec: \"Lead\",\n\t\t\tea: \"Catalog_Request\"\n\t\t});\n\t} catch (error) {\n\t\t// console.log(\"Failed : pushEventBing\");\n\t}\n}\n\n// Function: get user's device size. This function is intentionally duplicated here to be available for global use. Second instance lives in resize-img.js\nexport function getBrowserDevice() {\n\tif (window.matchMedia(\"(max-width : 767px)\").matches) return \"mobile\";\n\tif (window.matchMedia(\"(min-width : 768px) AND (max-width : 1023px)\").matches) return \"tablet\";\n\tif (window.matchMedia(\"(min-width : 1024px)\").matches) return \"desktop\";\n\treturn \"unsure\";\n}\n\n// EVENT - Check for country local storage, set if not already set\nexport async function saveUserCountryToLocalStorage() {\n\tlet userCountry = localStorage.getItem(\"country\");\n\tif (userCountry === null) {\n\t\tuserCountry = await setUserCountry();\n\t}\n}\n\n// set user country in local storage\nasync function setUserCountry() {\n\ttry {\n\t\tlet response = await fetch(\"https://ipinfo.io/json?token=5ddc6962f801d5\");\n\t\tlet data = await response.json();\n\t\tlet userCountry = data.country || \"unknown\";\n\t\tlocalStorage.setItem(\"country\", userCountry);\n\t\treturn userCountry;\n\t} catch (err) {\n\t\tconsole.error(\"Failed to fetch user country.\", err);\n\t\treturn \"unknown\"; // Return a default value in case of an error\n\t}\n}\n\n// Function: check if any modal is open\nexport function checkForOpenModals() {\n\tconst isOpen = sessionStorage.getItem(\"modalOpen\") === \"true\";\n\treturn isOpen;\n}\n\n// Function: check if a wistia video is playing\nexport function checkIfWistiaVideoPlaying() {\n\tconst wistiaVideo = document.querySelector(\".js-video\");\n\tif (wistiaVideo && isWistiaVideoPlaying() !== undefined) {\n\t\treturn true;\n\t} else {\n\t\treturn false;\n\t}\n}\n\n// vanilla wrapper to get cookie value\nexport function getCookie(name) {\n\tlet value = `; ${document.cookie}`;\n\tlet parts = value.split(`; ${name}=`);\n\tif (parts.length === 2) return parts.pop().split(\";\").shift();\n}\n\n// Utility to copy text to clipboard\nexport async function copyToClipboard(val) {\n\ttry {\n\t\tawait navigator.clipboard.writeText(val);\n\t} catch (err) {\n\t\tconsole.error(\"Failed to copy: \", err);\n\t}\n}\n\n// Utility to track browser size for Google Analytics -- are we using this?\nexport function browserSize() {\n\tlet width = window.innerWidth || document.body.clientWidth;\n\tlet height = window.innerHeight || document.body.clientHeight;\n\tlet size = width + \"x\" + height;\n\n\tlet browserSizeCookie = Cookies.get(\"browserSize\");\n\tif (browserSizeCookie === \"blocked\" || browserSizeCookie == null || browserSizeCookie != size) {\n\t\tbrowserSizeCookie = size;\n\t\tCookies.set(\"browserSize\", size, {\n\t\t\texpires: 365\n\t\t});\n\t\tpushEvent(\"Browser Size\", \"Range\", size);\n\t}\n}\n\n// Function: show hero photo credit if name has been entered in CMS\nexport function showHeroPhotoCredit() {\n\tconst photoCredit = document.querySelector(\"[js-hero-photo-credit]\");\n\tif (photoCredit) {\n\t\tconst creditText = photoCredit.textContent.trim();\n\t\tif (creditText.length > 2) {\n\t\t\tphotoCredit.classList.remove(\"hide\");\n\t\t} else {\n\t\t\tphotoCredit.classList.add(\"hide\");\n\t\t}\n\t}\n}\n\n// Need to run on page load but not a huge priority\nexport function setFavIcon() {\n\tconst favicon = document.querySelector(\"[js-set-favicon]\");\n\tconst mediaQuery = window.matchMedia(\"(prefers-color-scheme: dark)\");\n\tif (!favicon) return;\n\tfunction updateFavicon() {\n\t\tfavicon.setAttribute(\"href\", mediaQuery.matches ? \"/assets/images/icons/favicon-dark-mode.png\" : \"/assets/images/icons/favicon-light-mode.png\");\n\t}\n\tupdateFavicon();\n\tmediaQuery.addEventListener(\"change\", updateFavicon);\n}\n\n// Track social icon clicks for GA\nexport function trackSocialClicks(links, area) {\n\tlet socialLinks = document.querySelectorAll(`[${links}]`);\n\tsocialLinks.forEach(function (link) {\n\t\tlink.addEventListener(\"click\", function () {\n\t\t\tlet platform = link.getAttribute(`${links}`);\n\t\t\tpushEvent(\"Clicks\", `Social ${area}`, `${platform}`);\n\t\t});\n\t});\n}\n\n// Functions: check if elements exist\nconst ensureElementExists = (elementSelector, limit) =>\n\tnew Promise((resolve, reject) => {\n\t\tlet count = 0;\n\t\tfunction waitForElement() {\n\t\t\tconst element = document.querySelector(elementSelector);\n\t\t\tif (element) return resolve(element);\n\t\t\tif (limit && count > limit) return false;\n\t\t\tcount += 1;\n\t\t\tsetTimeout(waitForElement, 100);\n\t\t}\n\t\twaitForElement();\n\t});\n\nexport const waitUntilElementExists = async (elementSelector, limit) => {\n\tconst response = await ensureElementExists(elementSelector, limit);\n\treturn response;\n};\n\nexport function addEnsoExample(selector) {\n\tconst element = document.querySelector(selector);\n\tconst elementText = element.innerText;\n\n\tif (element && elementText === \"\") element.classList.add(\"js-enso-example\");\n}\n\nexport function removeMissingImage() {\n\tconst images = document.querySelectorAll(\"[js-remove-missing-image]\");\n\timages.forEach((img) => {\n\t\tif (img.naturalWidth === 0) {\n\t\t\timg.remove();\n\t\t}\n\t});\n}\n","import { pushEvent } from \"../../../assets/js/utilities.js\";\n\n// Book NOW Button - Set URL\nexport function bookNowButton() {\n\tlet finalSegment = window.location.pathname.split(\"/\");\n\tfinalSegment.pop();\n\tfinalSegment.shift();\n\tfinalSegment.shift();\n\tfinalSegment = `https://book.nathab.com/book-now/adventure/${finalSegment[0]}/`;\n\n\tconst bookButtons = document.querySelectorAll(\".js-book-init\");\n\tfor (const button of bookButtons) {\n\t\tbutton.setAttribute(\"href\", finalSegment);\n\t\tbutton.addEventListener(\"click\", function () {\n\t\t\tpushEvent(\"Misc\", \"Book Now\", \"Open\");\n\t\t});\n\t}\n}\n","// Auto-Scroll Trip Subpages\nexport function autoScroll() {\n\tconst mqSmall = window.matchMedia(\"(max-width : 767px)\");\n\tconst subpage = document.querySelector(\"[subpage~='autoscroll']\");\n\n\tif (!mqSmall.matches && subpage) {\n\t\tconst subpageTop = getOffsetTop(subpage);\n\t\tconst offset = 150;\n\n\t\twindow.scrollTo({\n\t\t\ttop: subpageTop - offset,\n\t\t\tbehavior: \"smooth\"\n\t\t});\n\t}\n}\n\n// helper function for autoScroll;\n// If the element or any of its parents are positioned non-statically (relative, absolute, fixed, or sticky),\n// you'll need to calculate the element's position manually by adding up the offsetTop values of the element\n// and all of its offset parents.\nfunction getOffsetTop(element) {\n\tlet offsetTop = 0;\n\twhile (element) {\n\t\toffsetTop += element.offsetTop;\n\t\telement = element.offsetParent;\n\t}\n\treturn offsetTop;\n}\n\n// For sub sub itinereray nav links\nexport function setTripItinerarySubSubClass() {\n\tconst links = document.querySelectorAll(\"[tripnav='nav'] a\");\n\tlinks.forEach(function (link) {\n\t\tif (link.href.includes(\"-itin\")) {\n\t\t\tlink.parentElement.classList.add(\"removeSubSub\");\n\t\t}\n\t});\n}\n\n// remove .active form parent itinerary page if child itinerary has active\nexport function removeActiveFromOtherLi() {\n\tlet activeLiElements = document.querySelectorAll(\"[tripnav~='nav'] li.active\");\n\n\tif (activeLiElements.length > 1) {\n\t\tactiveLiElements[0].classList.remove(\"active\");\n\t}\n}\n\n// Call the function to remove .active from the first li.active element if there is more than one\n\nexport function showBookOrCatalogOnMobileNav() {\n\tconst isBookOff = document.querySelector(\".booknowoff\");\n\tconst isAllBookOff = document.querySelector(\".disallow-book-now\");\n\tconst navbarMobileCatalog = document.querySelector(\"[nav-site-link--mobile~='catalog']\");\n\tconst navbarBook = document.querySelector(\"[nav-site-link--mobile~='book']\");\n\tconst mobileOnly = window.matchMedia(\"(max-width : 767px)\");\n\n\tif (mobileOnly.matches) {\n\t\tif (isBookOff || isAllBookOff) {\n\t\t\tnavbarMobileCatalog.classList.add(\"js-show-when-book-off\");\n\t\t\tnavbarBook.classList.add(\"hide\");\n\t\t}\n\t}\n}\n","//\n\n// Is there a better way to handle this like [enso].js-enso-on?\n\n// Function - Modernize Enso\nexport function enso() {\n\tconst ensoElements = [...document.querySelectorAll(\".enso-overlay-link\")];\n\n\tif (!ensoElements) return;\n\tfor (const element of ensoElements) {\n\t\tlet ensoOverlayContentElement = element.closest(\".enso-overlay-content\");\n\t\tlet ensoElement = ensoOverlayContentElement.closest(\"[enso]\");\n\t\tcopyEnsoLinkToParentAttribute(element);\n\t\telement.remove();\n\t\tunWrap(ensoOverlayContentElement);\n\t\tensoOverlayContentElement.remove();\n\t\taddTabKeyDownEvent(ensoElement);\n\t}\n}\n\n// FUNCTION - Move Enso Link to parent element with enso attribute\nfunction copyEnsoLinkToParentAttribute(element) {\n\tlet getLink = element.getAttribute(\"onclick\");\n\tgetLink = getLink.replace('self.location.href=\"', \"\").replace('\"', \"\");\n\tlet targetEnso = element.closest(\"[enso]\");\n\tif (targetEnso) {\n\t\ttargetEnso.setAttribute(\"enso\", getLink);\n\t}\n}\n\n// Function - Upwrap element\nfunction unWrap(element) {\n\tconst parent = element.parentNode;\n\twhile (element.firstChild) {\n\t\tparent.insertBefore(element.firstChild, element);\n\t}\n}\n\n// Function - Add in tab keydown event\nfunction addTabKeyDownEvent(element) {\n\tlet overlayVisible = false;\n\tdocument.addEventListener(\"keydown\", (event) => {\n\t\tif (event.key === \"Tab\" && element) {\n\t\t\tevent.preventDefault();\n\t\t\toverlayVisible = !overlayVisible;\n\t\t\tif (overlayVisible) {\n\t\t\t\telement.classList.add(\"js-enso-on\");\n\t\t\t\taddEnsoClickListener(element);\n\t\t\t} else {\n\t\t\t\telement.classList.remove(\"js-enso-on\");\n\t\t\t\tremoveEnsoClickListener(element);\n\t\t\t}\n\t\t}\n\t});\n}\n\n// Function - Setup link href\nfunction setupLink(e) {\n\te.preventDefault();\n\tlet goToUrl = this.getAttribute(\"enso\"); // this was the key\n\twindow.location.href = goToUrl;\n}\n\n// Function - Add click event listener\nfunction addEnsoClickListener(element) {\n\telement.addEventListener(\"click\", setupLink, false);\n}\n\n// Function - Remove click event listener\nfunction removeEnsoClickListener(element) {\n\telement.removeEventListener(\"click\", setupLink);\n}\n","export function convertOldSlideshowToNew() {\n\tconst imageContainers = document.querySelectorAll(\".js-old-slideshow-images\");\n\tif (!imageContainers.length) return;\n\n\tlet slides = \"\";\n\n\tfor (const imageContainer of imageContainers) {\n\t\tconst images = imageContainer.querySelectorAll(\"img\");\n\t\tif (!images.length) continue;\n\n\t\tfor (const image of images) {\n\t\t\tconst alt = image.getAttribute(\"alt\") || \" \";\n\t\t\tlet src = image.getAttribute(\"src\") || image.getAttribute(\"data-src\");\n\n\t\t\tif (!src) continue;\n\n\t\t\tconst domain = \"https://www.nathab.com\";\n\t\t\tconst cdn = \"https://cdn.filestackcontent.com/A6dTpd53SmIg0pBfJJhgAz/resize=width:1600,fit:max/quality=value:60/cache=expiry:31536000/compress/\";\n\t\t\tconst doubleDomain = domain + domain;\n\n\t\t\tsrc = domain + src;\n\t\t\tsrc = src.replace(doubleDomain, domain);\n\t\t\tsrc = cdn + src;\n\n\t\t\tslides += `\n\t\t\t\t