{"version":3,"file":"localNav.js","sources":["../../../../s/BiNo.ReactApps/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/throttle.js","../../../../s/BiNo.ReactApps/apps/scripts/src/local-nav.ts"],"sourcesContent":["var debounce = require('./debounce'),\n isObject = require('./isObject');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/**\n * Creates a throttled function that only invokes `func` at most once per\n * every `wait` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed `func` invocations and a `flush` method to\n * immediately invoke them. Provide `options` to indicate whether `func`\n * should be invoked on the leading and/or trailing edge of the `wait`\n * timeout. The `func` is invoked with the last arguments provided to the\n * throttled function. Subsequent calls to the throttled function return the\n * result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the throttled function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.throttle` and `_.debounce`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to throttle.\n * @param {number} [wait=0] The number of milliseconds to throttle invocations to.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=true]\n * Specify invoking on the leading edge of the timeout.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * // Avoid excessively updating the position while scrolling.\n * jQuery(window).on('scroll', _.throttle(updatePosition, 100));\n *\n * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.\n * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });\n * jQuery(element).on('click', throttled);\n *\n * // Cancel the trailing throttled invocation.\n * jQuery(window).on('popstate', throttled.cancel);\n */\nfunction throttle(func, wait, options) {\n var leading = true,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (isObject(options)) {\n leading = 'leading' in options ? !!options.leading : leading;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n return debounce(func, wait, {\n 'leading': leading,\n 'maxWait': wait,\n 'trailing': trailing\n });\n}\n\nmodule.exports = throttle;\n","import throttle from 'lodash/throttle';\r\nimport { onReady } from './util/onReady';\r\n\r\ninterface Section extends HTMLElement {\r\n id: string;\r\n}\r\n\r\ninterface SectionLink extends HTMLElement {\r\n dataset: {\r\n id: string;\r\n };\r\n}\r\n\r\nlet animating = false;\r\n\r\nfunction setActiveSection(sectionLink: SectionLink | null): void {\r\n if (!sectionLink) return;\r\n document.querySelector('.section-link.active')?.classList.remove('active');\r\n sectionLink.classList.add('active');\r\n}\r\n\r\nfunction findSection(id: string, sections: Section[]): Section | undefined {\r\n return sections.find((sec) => sec.id === id);\r\n}\r\n\r\nfunction scrollToSection(section: Section): void {\r\n if (animating) return;\r\n animating = true;\r\n\r\n const top = section.offsetTop - 45;\r\n window.scrollTo({\r\n top,\r\n behavior: 'smooth',\r\n });\r\n\r\n setTimeout(() => {\r\n animating = false;\r\n document.querySelector('.js-child-nav')?.classList.remove('expanded');\r\n document.querySelector('.js-local-nav')?.classList.remove('expanded');\r\n\r\n const scrollPosBeforeHashChange = window.scrollY;\r\n window.location.hash = section.id;\r\n window.scrollTo(0, scrollPosBeforeHashChange);\r\n }, 1000);\r\n}\r\n\r\nfunction checkForInitialSection(sectionLinks: SectionLink[], navbarThreshold: number): void {\r\n if (window.location.hash.length <= 1) return;\r\n\r\n const decodedHash = decodeURI(window.location.hash).replace('#', '');\r\n const section = document.getElementById(decodedHash) as Section | undefined;\r\n if (!section) return;\r\n const sectionLink = sectionLinks.find((e) => e.dataset.id === decodedHash.slice(1));\r\n if (section && sectionLink) {\r\n scrollToSection(section);\r\n setActiveSection(sectionLink);\r\n toggleFixed(document.querySelector('.js-local-nav'), navbarThreshold);\r\n }\r\n}\r\n\r\nfunction toggleFixed(navbar: HTMLElement | null, threshold: number): void {\r\n if (!navbar) return;\r\n\r\n const windowY = window.scrollY;\r\n if (windowY >= threshold && !navbar.classList.contains('fixed')) {\r\n navbar.classList.add('fixed');\r\n }\r\n if (windowY <= threshold && navbar.classList.contains('fixed')) {\r\n document.querySelector('.active')?.classList.remove('active');\r\n navbar.classList.remove('fixed');\r\n }\r\n}\r\n\r\nfunction findActiveSection(sections: Section[]): Section | undefined {\r\n const LOCAL_NAV_HEIGHT = 78;\r\n const windowY = window.scrollY;\r\n return sections\r\n .slice()\r\n .reverse()\r\n .find((sec) => sec.offsetTop - LOCAL_NAV_HEIGHT < windowY);\r\n}\r\n\r\nfunction setupToggle(navbar: HTMLElement): void {\r\n document.querySelectorAll('.jump-to')?.forEach((el) => {\r\n el.addEventListener('click', (ev) => {\r\n ev.preventDefault();\r\n navbar.classList.toggle('expanded');\r\n });\r\n });\r\n}\r\n\r\nfunction setupChildNav(): void {\r\n const pageElementsWithBg = document.querySelectorAll('.rows [class*=\"block-\"], .rows [class*=\"bg-\"]');\r\n const wrapper = document.querySelector('.page-bg-wrapper');\r\n\r\n if (wrapper && pageElementsWithBg.length > 0) {\r\n const pageTopElementBGClass = Array.from(pageElementsWithBg[0].classList).find(\r\n (e) => e.startsWith('block-') || e.startsWith('bg-'),\r\n );\r\n\r\n if (pageTopElementBGClass) {\r\n wrapper.classList.add(pageTopElementBGClass);\r\n }\r\n }\r\n}\r\n\r\nfunction init(): void {\r\n const childNav = document.querySelector('.js-child-nav');\r\n if (childNav) {\r\n setupChildNav();\r\n return setupToggle(childNav);\r\n }\r\n const navbar = document.querySelector('.js-local-nav');\r\n if (!navbar) return;\r\n\r\n const header = document.querySelector('bi-navbar');\r\n const headerHeight = header ? header.offsetHeight : 80;\r\n const navbarThreshold = navbar.offsetTop - headerHeight;\r\n\r\n const sections = Array.from(document.querySelectorAll
('.section'));\r\n const links = Array.from(document.querySelectorAll('.section-link'));\r\n\r\n setTimeout(() => checkForInitialSection(links, navbarThreshold), 500);\r\n\r\n document.addEventListener(\r\n 'scroll',\r\n throttle(() => {\r\n if (!animating) {\r\n toggleFixed(navbar, navbarThreshold);\r\n }\r\n if (navbar.classList.contains('fixed')) {\r\n const section = findActiveSection(sections);\r\n if (!section) return;\r\n const link = links.find((el) => el.dataset.id === section.id);\r\n if (!link) return;\r\n setActiveSection(link);\r\n }\r\n }, 50),\r\n );\r\n\r\n setupToggle(navbar);\r\n\r\n document.querySelectorAll('.section-link').forEach((el) => {\r\n el.addEventListener('click', (ev) => {\r\n ev.preventDefault();\r\n if (!el.classList.contains('practical-info-link')) {\r\n setActiveSection(el);\r\n const activeSection = findSection(el.dataset.id, sections);\r\n if (activeSection) scrollToSection(activeSection);\r\n }\r\n });\r\n });\r\n\r\n document.querySelectorAll('.practical-info-link').forEach((el) => {\r\n el.addEventListener('click', (ev) => {\r\n ev.preventDefault();\r\n const practicalInfo = document.querySelector
('.practical-info');\r\n if (practicalInfo) scrollToSection(practicalInfo);\r\n });\r\n });\r\n\r\n const home = document.getElementById('home');\r\n if (home) {\r\n home.addEventListener('click', () => {\r\n if (sections[0]) scrollToSection(sections[0]);\r\n });\r\n }\r\n}\r\n\r\nonReady(() => init());\r\n"],"names":["debounce","require$$0","isObject","require$$1","FUNC_ERROR_TEXT","throttle","func","wait","options","leading","trailing","throttle_1","animating","setActiveSection","sectionLink","_a","findSection","id","sections","sec","scrollToSection","section","top","_b","scrollPosBeforeHashChange","checkForInitialSection","sectionLinks","navbarThreshold","decodedHash","e","toggleFixed","navbar","threshold","windowY","findActiveSection","setupToggle","el","ev","setupChildNav","pageElementsWithBg","wrapper","pageTopElementBGClass","init","childNav","header","headerHeight","links","link","activeSection","practicalInfo","home","onReady"],"mappings":"0IAAA,IAAIA,EAAWC,EAAqB,EAChCC,EAAWC,EAAqB,EAGhCC,EAAkB,sBA8CtB,SAASC,EAASC,EAAMC,EAAMC,EAAS,CACrC,IAAIC,EAAU,GACVC,EAAW,GA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