{"version":3,"file":"animations-bdc8e492-CCPbIOoW.js","sources":["../../../node_modules/@trv-tds/react/node_modules/@trv-tds/webcomponents/dist/esm/animations-bdc8e492.js"],"sourcesContent":["/**\n * Gets the target element from an element's attribute. Used by elements that 'trigger' another component\n * Target reference can be an id or a selector\n * Checks 3 atttributes\n * - aria-controls\n * - attribute, which defaults to 'data-target'\n * - href\n * @param element with the target or href attribute\n * @param attribute - The attribute to check after aria-controls. Defaults to 'data-target'\n * @return The target element found or null if not found\n */\nfunction getTargetElement(element, attribute) {\n    try {\n        const selector = getTargetSelector(element, attribute);\n        return document.getElementById(selector) || document.querySelector(selector) || null;\n    }\n    catch (err) {\n        return null;\n    }\n}\n/**\n * Returns an array of 'target' elements from an element's attribute.\n * Used by elements that 'trigger' one or more components.\n * Target reference can be an id or a selector\n * Checks 3 atttributes\n * - aria-controls\n * - attribute, which defaults to 'data-target'\n * - href\n * @param element with the target or href attribute\n * @param attribute - The attribute to check after aria-controls. Defaults to 'data-target'\n * @return The target element found or null if not found\n */\nfunction getTargetElements(element, attribute) {\n    try {\n        const selector = getTargetSelector(element, attribute);\n        const elements = Array.from(document.querySelectorAll(selector));\n        if (elements.length === 0) {\n            const element = document.getElementById(selector);\n            if (element) {\n                elements.push(element);\n            }\n        }\n        return elements;\n    }\n    catch (err) {\n        return [];\n    }\n}\n/**\n * Gets the selector (or id) for a target element from an element's attribute. Used by elements that 'trigger' another component\n * Target reference can be an id or a selector\n * Checks 3 atttributes\n * - aria-controls\n * - attribute, which defaults to 'data-target'\n * - href\n * @param element with the target or href attribute\n * @param attribute - The attribute to check after aria-controls. Defaults to 'data-target'\n * @return The target element found or null if not found\n * @param element\n * @param attribute\n */\nfunction getTargetSelector(element, attribute = 'data-target') {\n    let selector = element.getAttribute('aria-controls') || element.getAttribute(attribute);\n    if (!selector || selector === \"true\") {\n        const href = element.getAttribute('href');\n        selector = href && href[0] === '#' && href.length > 1 ? href.trim() : '';\n    }\n    return selector;\n}\n\nconst TRANSITION_END = 'transitionend';\nlet isBrowser = undefined;\nfunction onTransitionEnd(el, expectedDuration, callback, propertyName) {\n    let timeoutId;\n    // determining if running in a browser or in a virtual browser like jsdom\n    function eventHandler(event) {\n        if (event.target === el && (!propertyName || event.propertyName === propertyName)) {\n            run();\n        }\n    }\n    function run() {\n        clearTimeout(timeoutId);\n        el.removeEventListener(TRANSITION_END, eventHandler);\n        callback();\n    }\n    isBrowser = isBrowser === undefined ? /native code/.test(el.addEventListener.toString()) : isBrowser;\n    const isUnitTesting = false;\n    const delay = (isBrowser || isUnitTesting) ? expectedDuration + 100 : 0;\n    timeoutId = window.setTimeout(run, delay); //in case event never fires\n    el.addEventListener(TRANSITION_END, eventHandler);\n}\n/**\n * Drives basic steps of an animation: prep, set, complete.\n * @param el Drives the basic steps of running an animation: Prep, start, complete\n * @param expectedDuration The expected duration of the animation. Used to determine the setTimeout fallback\n * @param steps Implementation of each animation step\n * @param propertyName The name of the CSS property to listen for the transitionend event of.\n * If not set, calls `complete` on the first tranistionend event received. */\nfunction runAnimation(el, expectedDuration, steps, propertyName) {\n    const { prep, set, complete } = steps;\n    if (prep) {\n        prep(el);\n    }\n    window.setTimeout(() => {\n        onTransitionEnd(el, expectedDuration, () => {\n            if (complete) {\n                complete(el);\n            }\n        }, propertyName);\n        if (set) {\n            set(el);\n        }\n    }, 50);\n}\n\nexport { getTargetElement as a, getTargetElements as g, onTransitionEnd as o, runAnimation as r };\n\n//# sourceMappingURL=animations-bdc8e492.js.map"],"names":["getTargetElement","element","attribute","selector","getTargetSelector","getTargetElements","elements","href","TRANSITION_END","isBrowser","onTransitionEnd","el","expectedDuration","callback","propertyName","timeoutId","eventHandler","event","run","delay","runAnimation","steps","prep","set","complete"],"mappings":"AAWA,SAASA,EAAiBC,EAASC,EAAW,CAC1C,GAAI,CACA,MAAMC,EAAWC,EAAkBH,EAASC,CAAS,EACrD,OAAO,SAAS,eAAeC,CAAQ,GAAK,SAAS,cAAcA,CAAQ,GAAK,IACxF,MACgB,CAC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