{"version":3,"file":"bootstrap5-toggle.mjs","sources":["../src/main/js/core/StateReducer.types.js","../src/main/js/core/Tools.js","../src/main/js/core/OptionResolver.types.js","../src/main/js/core/OptionResolver.js","../src/main/js/types/ToggleEvents.js","../src/main/js/core/DOMBuilder.js","../src/main/js/core/StateReducer.js","../src/main/js/types/ToggleMethods.js","../src/main/js/BootstrapToggle.js"],"sourcesContent":["export var ToggleStateValue;\n(function (ToggleStateValue) {\n    ToggleStateValue[\"ON\"] = \"on\";\n    ToggleStateValue[\"OFF\"] = \"off\";\n    ToggleStateValue[\"MIXED\"] = \"mixed\";\n})(ToggleStateValue || (ToggleStateValue = {}));\nexport var ToggleStateStatus;\n(function (ToggleStateStatus) {\n    ToggleStateStatus[\"ENABLED\"] = \"enabled\";\n    ToggleStateStatus[\"DISABLED\"] = \"disabled\";\n    ToggleStateStatus[\"READONLY\"] = \"readonly\";\n})(ToggleStateStatus || (ToggleStateStatus = {}));\nexport var ToggleActionType;\n(function (ToggleActionType) {\n    ToggleActionType[\"NEXT\"] = \"next\";\n    ToggleActionType[\"ON\"] = \"on\";\n    ToggleActionType[\"OFF\"] = \"off\";\n    ToggleActionType[\"TOGGLE\"] = \"toggle\";\n    ToggleActionType[\"DETERMINATE\"] = \"determinate\";\n    ToggleActionType[\"INDETERMINATE\"] = \"indeterminate\";\n    ToggleActionType[\"READONLY\"] = \"readonly\";\n    ToggleActionType[\"DISABLE\"] = \"disable\";\n    ToggleActionType[\"ENABLE\"] = \"enable\";\n})(ToggleActionType || (ToggleActionType = {}));\n","export var SanitizeMode;\n(function (SanitizeMode) {\n    SanitizeMode[\"HTML\"] = \"HTML\";\n    SanitizeMode[\"TEXT\"] = \"TEXT\";\n})(SanitizeMode || (SanitizeMode = {}));\n/**\n * Sanitizes a given text string according to the provided options.\n * If the input text is null, it will return null.\n * If the input text is not null, it will sanitize the text according to the provided mode.\n * If the mode is HTML, it will sanitize the text using the sanitizeHTML function.\n * If the mode is TEXT, it will sanitize the text using the sanitizeText function.\n * @param text The text string to sanitize.\n * @param opts The options to use for sanitizing the text.\n * @return The sanitized text string, or null if the input text was null.\n */\nexport function sanitize(text, opts) {\n    if (!text)\n        return text;\n    switch (opts.mode) {\n        case SanitizeMode.HTML:\n            return sanitizeHTML(text);\n        case SanitizeMode.TEXT:\n            return sanitizeText(text);\n    }\n}\n/**\n * Sanitizes a given text string, replacing special characters with their HTML entities.\n * If the input text is null, it will return null.\n * @param text The text string to sanitize.\n * @return The sanitized text string, or null if the input text was null.\n */\nfunction sanitizeText(text) {\n    const map = {\n        \"&\": \"&amp;\",\n        \"<\": \"&lt;\",\n        \">\": \"&gt;\",\n        '\"': \"&quot;\",\n        \"'\": \"&#39;\",\n        \"/\": \"&#x2F;\"\n    };\n    // Using replace with regex for single-pass character mapping compatible with ES5\n    return text.replace(/[&<>\"'/]/g, (m) => map[m]);\n}\n/**\n * Sanitizes HTML content using an allow-list approach to prevent XSS attacks.\n *\n * @param html The HTML string to sanitize\n * @param options Configuration options for allowed tags and attributes\n * @returns Sanitized HTML string\n */\nfunction sanitizeHTML(html) {\n    const config = {\n        allowedTags: [\"b\", \"i\", \"strong\", \"em\", \"span\", \"small\", \"sup\", \"sub\", \"img\"],\n        allowedAttributes: [\"class\", \"style\", \"src\", \"alt\", \"title\", \"data-*\"]\n    };\n    // Implementation using DOMParser for browser compatibility\n    const parser = new DOMParser();\n    const doc = parser.parseFromString(html, \"text/html\");\n    // Sanitize all nodes in the document body\n    const bodyChildren = Array.from(doc.body.childNodes);\n    bodyChildren.forEach((node) => sanitizeNode(node, config));\n    return doc.body.innerHTML;\n}\n/**\n * Sanitizes a single node in the document tree.\n *\n * For element nodes, it removes disallowed tags and attributes.\n * For text nodes, it keeps them as is.\n *\n * Recursively sanitizes all children of an element node.\n *\n * @param node The node to sanitize\n * @param config Configuration options for allowed tags and attributes\n */\nfunction sanitizeNode(node, config) {\n    const sanitizeNodeRecursive = (node) => {\n        var _a;\n        if (node.nodeType === Node.ELEMENT_NODE) {\n            const element = node;\n            const tagName = element.tagName.toLowerCase();\n            // Remove disallowed tags\n            if (!config.allowedTags.includes(tagName)) {\n                // Replace disallowed element with its text content\n                const fragment = document.createDocumentFragment();\n                Array.from(element.childNodes).forEach(child => {\n                    fragment.appendChild(child.cloneNode(true));\n                });\n                (_a = element.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(fragment, element);\n                return;\n            }\n            // Remove disallowed attributes\n            Array.from(element.attributes).forEach(attr => {\n                const attrName = attr.name.toLowerCase();\n                const isAllowed = config.allowedAttributes.some(allowed => allowed.endsWith(\"*\") ? attrName.startsWith(allowed.slice(0, -1)) : attrName === allowed);\n                if (isAllowed) {\n                    sanitizeAllowedAttr(element, attr, attrName);\n                }\n                else {\n                    element.removeAttribute(attr.name);\n                }\n            });\n            // Recursively sanitize children\n            const children = Array.from(element.childNodes);\n            children.forEach(sanitizeNodeRecursive);\n        }\n        else if (node.nodeType === Node.TEXT_NODE) {\n            // Text nodes are safe, keep them as is\n            return;\n        }\n    };\n    sanitizeNodeRecursive(node);\n}\n/**\n * Sanitizes an allowed attribute by removing it if its value is a dangerous protocol.\n * Only works for \"src\" and \"href\" attributes.\n * @param element The element to check for the attribute.\n * @param attr The attribute to check the value of.\n * @param attrName The name of the attribute to check (either \"src\" or \"href\").\n */\nfunction sanitizeAllowedAttr(element, attr, attrName) {\n    if (attrName !== \"src\" && attrName !== \"href\")\n        return;\n    const value = attr.value.toLowerCase();\n    // sonar typescript:S1523 - This is security detection, not execution\n    const isDangerousProtocol = value.startsWith(\"javascript:\") ||\n        value.startsWith(\"vbscript:\") ||\n        (value.startsWith(\"data:\") && !value.startsWith(\"data:image/\"));\n    if (isDangerousProtocol) {\n        element.removeAttribute(attr.name);\n    }\n}\n;\n/**\n * Checks if the given string is a valid numeric value.\n *\n * A valid numeric value is a `string` that starts with an optional plus or minus sign,\n * followed by one or more digits, optionally followed by a decimal point and\n * one or more digits.\n *\n * Examples of valid numeric values include \"123\", \"-123\", \"+123.45\", \"-123.45\", etc.\n * Examples of invalid numeric values include \"abc\", \"123abc\", \"123.abc\", etc.\n * @param {string | number} value The string or number to check for being a valid numeric value.\n * @returns {boolean} `true` if the string contains a valid numeric value, `false` otherwise.\n */\nexport function isNumeric(value) {\n    return /^[+-]?\\d+(\\.\\d+)?$/.test(value.toString().trim());\n}\n","export var PlacementOptions;\n(function (PlacementOptions) {\n    PlacementOptions[\"TOP\"] = \"top\";\n    PlacementOptions[\"BOTTOM\"] = \"bottom\";\n    PlacementOptions[\"LEFT\"] = \"left\";\n    PlacementOptions[\"RIGHT\"] = \"right\";\n})(PlacementOptions || (PlacementOptions = {}));\n","import { isNumeric, sanitize, SanitizeMode } from \"./Tools\";\nimport { PlacementOptions, } from \"./OptionResolver.types\";\n/**\n * OptionResolver is responsible for reading HTML attributes and user options\n * to build a complete ToggleOptions object.\n * It also handles deprecated options.\n */\nexport class OptionResolver {\n    /**\n   * Gets a sanitized attribute value from an HTML element\n   * @param element HTMLInputElement to read\n   * @param attrName Attribute name\n   * @param options method options\n   * @param options.sanitized Flag to indicate if the sanitized mode needs to be used (default: `TEXT`)\n   * @returns Sanitized attribute value or null\n   */\n    static getAttr(element, attrName, opts) {\n        const { sanitized = SanitizeMode.TEXT } = opts !== null && opts !== void 0 ? opts : {};\n        const value = element.getAttribute(attrName);\n        return sanitize(value, { mode: sanitized });\n        ;\n    }\n    /**\n   * Returns the value of an attribute, user-provided value, or default value\n   * @param element HTMLInputElement to read\n   * @param attrName Attribute name\n   * @param userValue Value provided by the user\n   * @param defaultValue Default value if neither attribute nor user value exists\n   * @param sanitized Flag to indicate if the sanitized mode needs to be used (default: `TEXT`)\n   * @returns Final attribute value\n   */\n    static getAttrOrDefault(element, attrName, userValue, defaultValue, sanitized = SanitizeMode.TEXT) {\n        const sanitizedUserValue = typeof userValue === \"string\" ? sanitize(userValue, { mode: sanitized }) : userValue;\n        return OptionResolver.getAttr(element, attrName, { sanitized }) ||\n            sanitizedUserValue ||\n            defaultValue;\n    }\n    /**\n   * Returns the value of an attribute, user-provided value, or marks as deprecated\n   * @param element HTMLInputElement to read\n   * @param attrName Attribute name\n   * @param userValue Value provided by the user\n   * @param sanitized Flag to indicate if the sanitized mode needs to be used (default: `TEXT`)\n   * @returns Final attribute value or DeprecationConfig.value if not found\n   */\n    static getAttrOrDeprecation(element, attrName, userValue, sanitized = SanitizeMode.TEXT) {\n        const sanitizedUserValue = typeof userValue === \"string\" ? sanitize(userValue, { mode: sanitized }) : userValue;\n        return OptionResolver.getAttr(element, attrName, { sanitized }) ||\n            sanitizedUserValue ||\n            DeprecationConfig.value;\n    }\n    /**\n   * Resolves all toggle options from the element and user options\n   * @param element HTMLInputElement representing the toggle\n   * @param userOptions Options provided by the user\n   * @returns Complete ToggleOptions object\n   */\n    static resolve(element, userOptions = {}) {\n        var _a;\n        const options = {\n            onlabel: this.getAttrOrDeprecation(element, \"data-onlabel\", userOptions.onlabel, SanitizeMode.HTML),\n            offlabel: this.getAttrOrDeprecation(element, \"data-offlabel\", userOptions.offlabel, SanitizeMode.HTML),\n            onstyle: this.getAttrOrDefault(element, \"data-onstyle\", userOptions.onstyle, OptionResolver.DEFAULT.onstyle),\n            offstyle: this.getAttrOrDefault(element, \"data-offstyle\", userOptions.offstyle, OptionResolver.DEFAULT.offstyle),\n            onvalue: this.getAttr(element, \"value\") || this.getAttrOrDefault(element, \"data-onvalue\", userOptions.onvalue, OptionResolver.DEFAULT.onvalue),\n            offvalue: this.getAttrOrDefault(element, \"data-offvalue\", userOptions.offvalue, OptionResolver.DEFAULT.offvalue),\n            ontitle: this.getAttrOrDefault(element, \"data-ontitle\", userOptions.ontitle, OptionResolver.getAttr(element, \"title\") ||\n                OptionResolver.DEFAULT.ontitle),\n            offtitle: this.getAttrOrDefault(element, \"data-offtitle\", userOptions.offtitle, OptionResolver.getAttr(element, \"title\") ||\n                OptionResolver.DEFAULT.offtitle),\n            size: this.getAttrOrDefault(element, \"data-size\", userOptions.size, this.DEFAULT.size),\n            style: this.getAttrOrDefault(element, \"data-style\", userOptions.style, this.DEFAULT.style),\n            width: this.getAttrOrDefault(element, \"data-width\", userOptions.width, this.DEFAULT.width),\n            height: this.getAttrOrDefault(element, \"data-height\", userOptions.height, this.DEFAULT.height),\n            tabindex: Number(this.getAttrOrDefault(element, \"tabindex\", userOptions.tabindex, this.DEFAULT.tabindex)),\n            tristate: element.hasAttribute(\"tristate\") ||\n                userOptions.tristate ||\n                OptionResolver.DEFAULT.tristate,\n            name: this.getAttrOrDefault(element, \"name\", userOptions.name, this.DEFAULT.name),\n            aria: {\n                label: this.getAttrOrDefault(element, \"aria-label\", (_a = userOptions.aria) === null || _a === void 0 ? void 0 : _a.label, this.DEFAULT.aria.label),\n            },\n            tooltip: OptionResolver.resolveTooltipOptions(element, userOptions),\n        };\n        if (options.width && isNumeric(options.width))\n            options.width = `${options.width}px`;\n        if (options.height && isNumeric(options.height))\n            options.height = `${options.height}px`;\n        DeprecationConfig.handle(options, element, userOptions);\n        return options;\n    }\n    /**\n     * Resolve tooltip options from element attributes and user options.\n     * @param element HTMLInputElement representing the toggle\n     * @param userOptions Options provided by the user\n     * @returns Resolved tooltip options or undefined if not found.\n     */\n    static resolveTooltipOptions(element, userOptions) {\n        var _a, _b, _c, _d;\n        const getTitle = (attr, userOption) => this.getAttrOrDefault(element, attr, userOption, null, SanitizeMode.HTML) || this.getAttr(element, \"data-tooltip-title\", { sanitized: SanitizeMode.HTML });\n        const titleOn = getTitle(\"data-tooltip-title-on\", (_a = userOptions.tooltip) === null || _a === void 0 ? void 0 : _a.title.on);\n        const titleOff = getTitle(\"data-tooltip-title-off\", (_b = userOptions.tooltip) === null || _b === void 0 ? void 0 : _b.title.off);\n        const titleMixed = getTitle(\"data-tooltip-title-mixed\", (_c = userOptions.tooltip) === null || _c === void 0 ? void 0 : _c.title.mixed);\n        if (!titleOn || !titleOff)\n            return OptionResolver.DEFAULT.tooltip;\n        const placement = this.getAttrOrDefault(element, \"data-tooltip-placement\", (_d = userOptions.tooltip) === null || _d === void 0 ? void 0 : _d.placement, PlacementOptions.TOP);\n        return {\n            placement: Object.values(PlacementOptions).includes(placement) ? placement : PlacementOptions.TOP,\n            title: {\n                on: titleOn,\n                off: titleOff,\n                mixed: titleMixed !== null && titleMixed !== void 0 ? titleMixed : undefined,\n            },\n        };\n    }\n}\n/** Default values for all toggle options */\nOptionResolver.DEFAULT = {\n    onlabel: \"On\",\n    onstyle: \"primary\",\n    onvalue: null,\n    ontitle: null,\n    offlabel: \"Off\",\n    offstyle: \"secondary\",\n    offvalue: null,\n    offtitle: null,\n    size: \"\",\n    style: \"\",\n    width: null,\n    height: null,\n    tabindex: 0,\n    tristate: false,\n    name: null,\n    aria: { label: \"Toggle\", },\n    tooltip: undefined,\n};\n/** Types of deprecation source */\nvar OptionType;\n(function (OptionType) {\n    OptionType[\"ATTRIBUTE\"] = \"attribute\";\n    OptionType[\"OPTION\"] = \"option\";\n})(OptionType || (OptionType = {}));\n/**\n * Handles deprecated attributes and options for Bootstrap Toggle.\n */\nclass DeprecationConfig {\n    /**\n   * Processes deprecated options and attributes and logs warnings\n   * @param options ToggleOptions object to update\n   * @param element HTMLInputElement to read deprecated attributes from\n   * @param userOptions UserOptions provided by the user\n   */\n    static handle(options, element, userOptions) {\n        this.deprecatedOptions.forEach(({ currentOpt, deprecatedAttr, deprecatedOpt, mode }) => {\n            if (options[currentOpt] === DeprecationConfig.value) {\n                const deprecatedAttrSanitized = sanitize(element.getAttribute(deprecatedAttr), { mode });\n                if (deprecatedAttrSanitized) {\n                    this.log(OptionType.ATTRIBUTE, deprecatedAttr, `data-${currentOpt}`);\n                    options[currentOpt] = deprecatedAttrSanitized;\n                }\n                else if (userOptions[deprecatedOpt]) {\n                    this.log(OptionType.OPTION, deprecatedOpt, currentOpt);\n                    options[currentOpt] = userOptions[deprecatedOpt];\n                }\n                else {\n                    options[currentOpt] = OptionResolver.DEFAULT[currentOpt];\n                }\n            }\n        });\n    }\n    /**\n   * Logs a deprecation warning to the console\n   * @param type Source of the deprecated option (ATTRIBUTE | OPTION)\n   * @param oldLabel Deprecated attribute or option name\n   * @param newLabel Recommended replacement option name\n   */\n    static log(type, oldLabel, newLabel) {\n        console.warn(`Bootstrap Toggle deprecation warning: Using ${oldLabel} ${type} is deprecated. Use ${newLabel} instead.`);\n    }\n}\n/** Unique string used to detect deprecated placeholders */\nDeprecationConfig.value = \"BOOTSTRAP TOGGLE DEPRECATION CHECK -- a0Jhux0QySypjjs4tLtEo8xT2kx0AbYaq9K6mgNjWSs0HF0L8T8J0M0o3Kr7zkm7 --\";\n/** Mapping of current option, deprecated attribute, and deprecated user option */\nDeprecationConfig.deprecatedOptions = [\n    {\n        currentOpt: \"onlabel\",\n        deprecatedAttr: \"data-on\",\n        deprecatedOpt: \"on\",\n        mode: SanitizeMode.HTML\n    },\n    {\n        currentOpt: \"offlabel\",\n        deprecatedAttr: \"data-off\",\n        deprecatedOpt: \"off\",\n        mode: SanitizeMode.HTML\n    },\n];\n","var ToggleEvents;\n(function (ToggleEvents) {\n    ToggleEvents[\"ON\"] = \"toggle:on\";\n    ToggleEvents[\"OFF\"] = \"toggle:off\";\n    ToggleEvents[\"MIXED\"] = \"toggle:mixed\";\n    ToggleEvents[\"ENABLED\"] = \"toggle:enabled\";\n    ToggleEvents[\"DISABLED\"] = \"toggle:disabled\";\n    ToggleEvents[\"READONLY\"] = \"toggle:readonly\";\n})(ToggleEvents || (ToggleEvents = {}));\nexport default ToggleEvents;\n","import { ToggleStateStatus, ToggleStateValue, } from \"./StateReducer.types\";\nexport class DOMBuilder {\n    /**\n   * Initializes a new instance of the DOMBuilder class.\n   * This renders the toggle if the parent element is visible, otherwise defers rendering until it becomes visible.\n   * @param checkbox HTMLInputElement element representing the toggle.\n   * @param options ToggleOptions object containing options for the toggle.\n   * @param state ToggleState object containing the initial state of the toggle.\n   */\n    constructor(checkbox, options, state) {\n        this.isBuilt = false;\n        this.lastState = state;\n        this.onStyle = `btn-${options.onstyle}`;\n        this.offStyle = `btn-${options.offstyle}`;\n        this.name = options.name;\n        this.checkbox = checkbox;\n        if (options.onvalue)\n            this.checkbox.value = options.onvalue;\n        this.invCheckbox = options.offvalue\n            ? this.createInvCheckbox(options.offvalue)\n            : null;\n        this.sizeClass = DOMBuilder.sizeResolver(options.size);\n        this.toggleOn = this.createToggleSpan(options.onlabel, this.onStyle, options.ontitle);\n        this.toggleOff = this.createToggleSpan(options.offlabel, this.offStyle, options.offtitle);\n        this.toggleHandle = this.createToggleHandle();\n        this.toggleGroup = this.createToggleGroup();\n        this.toggle = document.createElement(\"div\");\n        if (options.tooltip) {\n            this.tooltipLabels = options.tooltip.title;\n        }\n        if (this.isVisible()) {\n            this.renderToggle(options);\n            this.render(state);\n        }\n        else {\n            this.deferRender(options);\n        }\n    }\n    /**\n   * Checks if the parent element of the checkbox is visible.\n   * A parent element is considered visible if its `offsetWidth` and `offsetHeight` are greater than `0`.\n   * @returns boolean indicating whether the parent element is visible or not.\n   */\n    isVisible() {\n        const parent = this.checkbox.parentElement;\n        return !!parent && parent.offsetWidth > 0 && parent.offsetHeight > 0;\n    }\n    /**\n   * Defer rendering the toggle until the parent element is visible.\n   * It does this by observing the parent element's bounding rectangle and only rendering the toggle once the width and height of the bounding rectangle are greater than 0.\n   * @param options ToggleOptions object containing options for the toggle.\n   */\n    deferRender(options) {\n        this.resizeObserver = new ResizeObserver(entries => {\n            if (this.isBuilt) {\n                this.resizeObserver.disconnect();\n                return;\n            }\n            for (const entry of entries) {\n                if (entry.contentRect.width > 0 && entry.contentRect.height > 0) {\n                    this.renderToggle(options);\n                    this.render(this.lastState);\n                    this.isBuilt = true;\n                    this.resizeObserver.disconnect();\n                    return;\n                }\n            }\n        });\n        this.resizeObserver.observe(this.checkbox.parentElement);\n    }\n    /**\n   * Resolves the size class for the toggle based on the provided size.\n   * If size is not provided or is invalid, returns an empty string.\n   * @param size ToggleSize value representing the size of the toggle.\n   * @returns string representing the size class for the toggle.\n   */\n    static sizeResolver(size) {\n        var _a;\n        const sizeMap = {\n            large: \"btn-lg\",\n            lg: \"btn-lg\",\n            small: \"btn-sm\",\n            sm: \"btn-sm\",\n            mini: \"btn-xs\",\n            xs: \"btn-xs\",\n        };\n        return (_a = sizeMap[size]) !== null && _a !== void 0 ? _a : \"\";\n    }\n    /**\n   * Creates an inverted checkbox element that is used in the toggle.\n   * This checkbox is used to create the toggle's \"off\" state.\n   * @param offValue The value of the checkbox when the toggle is in the \"off\" state.\n   * @returns An HTMLInputElement representing the inverted checkbox element.\n   */\n    createInvCheckbox(offValue) {\n        const invCheckbox = this.checkbox.cloneNode(true);\n        invCheckbox.value = offValue;\n        invCheckbox.dataset.toggle = \"invert-toggle\";\n        invCheckbox.removeAttribute(\"id\");\n        return invCheckbox;\n    }\n    /**\n   * Renders the toggle element and its children.\n   * Sets the class attribute of the toggle with the provided style and size class.\n   * Sets the tabindex attribute of the toggle with the provided tabindex.\n   * Inserts the toggle element before the original checkbox element.\n   * Appends the checkbox, inverted checkbox (if exists) and toggle group elements to the toggle element.\n   * Handles the toggle size by setting the width and height attributes of the toggle element.\n   * @param options - ToggleOptions object containing the style, width, height and tabindex for the toggle.\n   */\n    renderToggle({ style, width, height, tabindex, aria, tooltip, }) {\n        var _a;\n        this.toggle.className = `toggle btn ${this.sizeClass} ${style}`;\n        this.toggle.dataset.toggle = \"toggle\";\n        this.toggle.tabIndex = tabindex;\n        this.toggle.role = \"switch\";\n        this.checkbox.tabIndex = -1;\n        if (this.invCheckbox)\n            this.invCheckbox.tabIndex = -1;\n        (_a = this.checkbox.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(this.toggle, this.checkbox);\n        this.toggle.appendChild(this.checkbox);\n        if (this.invCheckbox)\n            this.toggle.appendChild(this.invCheckbox);\n        this.toggle.appendChild(this.toggleGroup);\n        this.handleLabels(aria);\n        this.handleToggleSize(width, height);\n        if (tooltip)\n            this.createTooltip(tooltip);\n        this.isBuilt = true;\n    }\n    /**\n   * Creates a div element representing the toggle group.\n   * The toggle group contains the on, off, and handle elements of the toggle.\n   * @returns An HTMLElement representing the toggle group element.\n   */\n    createToggleGroup() {\n        const toggleGroup = document.createElement(\"div\");\n        toggleGroup.className = \"toggle-group\";\n        toggleGroup.appendChild(this.toggleOn);\n        toggleGroup.appendChild(this.toggleOff);\n        toggleGroup.appendChild(this.toggleHandle);\n        return toggleGroup;\n    }\n    /**\n   * Creates a span element representing a toggle option (on/off).\n   * The span element is given a class attribute with the provided style and size class.\n   * The innerHTML of the span element is set to the provided label.\n   * If a title is provided, the span element is given a title attribute with the provided title.\n   * @param label The text to be displayed in the toggle option.\n   * @param style The style of the toggle option (primary, secondary, etc.).\n   * @param title The title of the toggle option.\n   * @returns An HTMLElement representing the toggle option element.\n   */\n    createToggleSpan(label, style, title) {\n        const toggleSpan = document.createElement(\"span\");\n        toggleSpan.className = `btn ${this.sizeClass} ${style}`;\n        toggleSpan.innerHTML = label;\n        if (title)\n            toggleSpan.title = title;\n        return toggleSpan;\n    }\n    /**\n   * Creates a span element representing the toggle handle.\n   * The span element is given a class attribute with the provided size class.\n   * @returns An HTMLElement representing the toggle handle element.\n   */\n    createToggleHandle() {\n        const toggleHandle = document.createElement(\"span\");\n        toggleHandle.className = `toggle-handle btn ${this.sizeClass}`;\n        return toggleHandle;\n    }\n    /**\n   * Sets the width and height of the toggle element.\n   * If a width or height is not provided, the toggle element will be given a minimum width and height\n   * that is calculated based on the size of the toggle on and off options.\n   * @param width The width of the toggle element.\n   * @param height The height of the toggle element.\n   */\n    handleToggleSize(width, height) {\n        this.cancelPendingAnimationFrame();\n        if (typeof requestAnimationFrame === \"function\") {\n            this.requestAnimationFrameId = requestAnimationFrame(() => {\n                try {\n                    this.calculateToggleSize(width, height);\n                }\n                catch (error) {\n                    console.warn(\"Error calculating toggle size:\", error);\n                }\n            });\n        }\n        else {\n            // Fallback if requestAnimationFrame is not supported\n            this.calculateToggleSize(width, height);\n        }\n    }\n    calculateToggleSize(width, height) {\n        if (width) {\n            this.toggle.style.width = width;\n        }\n        else {\n            this.toggle.style.minWidth = \"100px\"; // First approach for better calculation\n            this.toggle.style.minWidth = `${Math.max(this.toggleOn.getBoundingClientRect().width, this.toggleOff.getBoundingClientRect().width) +\n                this.toggleHandle.getBoundingClientRect().width / 2}px`;\n        }\n        if (height) {\n            this.toggle.style.height = height;\n        }\n        else {\n            this.toggle.style.minHeight = \"36px\"; // First approach for better calculation\n            this.toggle.style.minHeight = `${Math.max(this.toggleOn.getBoundingClientRect().height, this.toggleOff.getBoundingClientRect().height)}px`;\n        }\n        // B: Apply on/off class\n        this.toggleOn.classList.add(\"toggle-on\");\n        this.toggleOff.classList.add(\"toggle-off\");\n        // C: Finally, set lineHeight if needed\n        if (height) {\n            this.toggleOn.style.lineHeight = DOMBuilder.calcH(this.toggleOn) + \"px\";\n            this.toggleOff.style.lineHeight = DOMBuilder.calcH(this.toggleOff) + \"px\";\n        }\n    }\n    /**\n     * Calculates the height of the toggle element that should be used for the line-height property.\n     * This calculation is used when the toggle element is given a height that is not explicitly set.\n     * The calculation takes into account the height of the toggle element, the border-top and border-bottom widths,\n     * and the padding-top and padding-bottom of the toggle element.\n     * @param toggleSpan The HTMLElement that represents the toggle element.\n     * @returns The height of the toggle element that should be used for the line-height property.\n     */\n    static calcH(toggleSpan) {\n        const styles = globalThis.window.getComputedStyle(toggleSpan);\n        const height = toggleSpan.offsetHeight;\n        const borderTopWidth = Number.parseFloat(styles.borderTopWidth);\n        const borderBottomWidth = Number.parseFloat(styles.borderBottomWidth);\n        const paddingTop = Number.parseFloat(styles.paddingTop);\n        const paddingBottom = Number.parseFloat(styles.paddingBottom);\n        return (height - borderBottomWidth - borderTopWidth - paddingTop - paddingBottom);\n    }\n    /**\n     * Cancels any pending animation frame request if one exists.\n     * This is used to prevent unnecessary calculations when the toggle size is being changed.\n     */\n    cancelPendingAnimationFrame() {\n        if (this.requestAnimationFrameId !== undefined && typeof cancelAnimationFrame === \"function\") {\n            cancelAnimationFrame(this.requestAnimationFrameId);\n            this.requestAnimationFrameId = undefined;\n        }\n    }\n    /**\n     * Handles the aria-labelledby and aria-label attributes of the toggle element.\n     * If the checkbox element has a labels property and the length of the labels property is greater than 0,\n     * the aria-labelledby attribute of the toggle element is set to the id of the labels elements.\n     * Otherwise, the aria-label attribute of the toggle element is set to the label property of the ariaOpts object.\n     * @param {AriaToggleOptions} ariaOpts - The object containing the label property to be used for the aria-label attribute.\n     */\n    handleLabels(ariaOpts) {\n        var _a;\n        if ((_a = this.checkbox.labels) === null || _a === void 0 ? void 0 : _a.length) {\n            const ids = Array.from(this.checkbox.labels)\n                .map(l => l.id)\n                .filter(Boolean);\n            if (ids.length) {\n                this.toggle.setAttribute(\"aria-labelledby\", ids.join(\" \"));\n            }\n        }\n        else {\n            this.toggle.setAttribute(\"aria-label\", ariaOpts.label);\n        }\n    }\n    /**\n     * Creates a tooltip for the toggle element.\n     * If the tooltip is successfully created, it is stored in the `tooltip` property of the DOMBuilder instance.\n     * @param {TooltipOptions} tooltip - The options for the tooltip.\n     */\n    createTooltip(tooltip) {\n        try {\n            this.tooltip = new globalThis.window.bootstrap.Tooltip(this.toggle, { placement: tooltip.placement, html: true, title: tooltip.title.on });\n        }\n        catch (error) {\n            console.error(\"Error creating tooltip:\", error);\n        }\n    }\n    /**\n   * Renders the toggle element based on the provided state if the toggle is already built.\n   * This method should be called whenever the state of the toggle changes.\n   * @param {ToggleState} state The state of the toggle element.\n   */\n    render(state) {\n        this.lastState = state;\n        if (!this.isBuilt)\n            return;\n        this.updateToggleByValue(state);\n        this.updateToggleByChecked(state);\n        this.updateToggleByState(state);\n        this.updateAria(state);\n        this.updateTooltip(state);\n    }\n    /**\n     * Updates the class of the toggle element based on the provided state.\n     * Removes any existing on/off/indeterminate classes and adds the appropriate class based on the state.\n     * If the state is indeterminate, adds the 'indeterminate' class and either the on or off class based on the checked attribute.\n     * @param {ToggleState} state The state of the toggle element.\n     */\n    updateToggleByValue(state) {\n        this.toggle.classList.remove(this.onStyle, this.offStyle, \"off\", \"indeterminate\");\n        switch (state.value) {\n            case ToggleStateValue.ON:\n                this.toggle.classList.add(this.onStyle);\n                break;\n            case ToggleStateValue.OFF:\n                this.toggle.classList.add(this.offStyle, \"off\");\n                break;\n            case ToggleStateValue.MIXED:\n                this.toggle.classList.add(\"indeterminate\");\n                if (state.checked) {\n                    this.toggle.classList.add(this.onStyle);\n                }\n                else {\n                    this.toggle.classList.add(this.offStyle, \"off\");\n                }\n                break;\n        }\n    }\n    /**\n     * Updates the toggle element based on the provided state.\n     * Calls {@link DOMBuilder.updateCheckboxByChecked} and {@link DOMBuilder.updateInvCheckboxByChecked} to update the checkbox and inverted checkbox elements respectively.\n     * @param {ToggleState} state The state of the toggle element.\n     */\n    updateToggleByChecked(state) {\n        this.updateCheckboxByChecked(state);\n        this.updateInvCheckboxByChecked(state);\n    }\n    /**\n     * Updates the checkbox element based on the provided state.\n     * Sets the checked attribute of the checkbox based on the state's checked attribute.\n     * Sets the disabled and readonly attributes of the checkbox based on the state's status.\n     * Adds or removes the 'disabled' class from the toggle element based on the state's status.\n     * @param {ToggleState} state The state of the toggle element.\n     */\n    updateCheckboxByChecked(state) {\n        this.checkbox.checked = state.checked;\n        switch (state.status) {\n            case ToggleStateStatus.ENABLED:\n                this.checkbox.disabled = false;\n                this.checkbox.readOnly = false;\n                this.toggle.classList.remove(\"disabled\");\n                this.toggle.removeAttribute(\"disabled\");\n                break;\n            case ToggleStateStatus.DISABLED:\n                this.checkbox.disabled = true;\n                this.checkbox.readOnly = false;\n                this.toggle.classList.add(\"disabled\");\n                this.toggle.setAttribute(\"disabled\", \"\");\n                break;\n            case ToggleStateStatus.READONLY:\n                this.checkbox.disabled = false;\n                this.checkbox.readOnly = true;\n                this.toggle.classList.add(\"disabled\");\n                this.toggle.setAttribute(\"disabled\", \"\");\n                break;\n        }\n    }\n    /**\n     * Updates the inverted checkbox element based on the provided state.\n     * Sets the checked attribute of the inverted checkbox to the opposite of the state's checked attribute.\n     * Sets the disabled and readonly attributes of the inverted checkbox based on the state's status.\n     * @param {ToggleState} state The state of the toggle element.\n     */\n    updateInvCheckboxByChecked(state) {\n        if (!this.invCheckbox)\n            return;\n        this.invCheckbox.checked = !state.checked;\n        switch (state.status) {\n            case ToggleStateStatus.ENABLED:\n                this.invCheckbox.disabled = false;\n                this.invCheckbox.readOnly = false;\n                break;\n            case ToggleStateStatus.DISABLED:\n                this.invCheckbox.disabled = true;\n                this.invCheckbox.readOnly = false;\n                break;\n            case ToggleStateStatus.READONLY:\n                this.invCheckbox.disabled = false;\n                this.invCheckbox.readOnly = true;\n                break;\n        }\n    }\n    /**\n     * Updates the indeterminate attribute of the checkbox and inverted checkbox elements based on the provided state.\n     * If the state is indeterminate, sets the indeterminate attribute of the checkbox and inverted checkbox to true and removes the name attribute.\n     * If the state is not indeterminate, sets the indeterminate attribute of the checkbox and inverted checkbox to false and sets the name attribute to the provided name.\n     * @param {ToggleState} state The state of the toggle element.\n     */\n    updateToggleByState(state) {\n        if (state.indeterminate) {\n            this.checkbox.indeterminate = true;\n            this.checkbox.removeAttribute(\"name\");\n            if (this.invCheckbox)\n                this.invCheckbox.indeterminate = true;\n            if (this.invCheckbox)\n                this.invCheckbox.removeAttribute(\"name\");\n        }\n        else {\n            this.checkbox.indeterminate = false;\n            if (this.name)\n                this.checkbox.name = this.name;\n            if (this.invCheckbox)\n                this.invCheckbox.indeterminate = false;\n            if (this.invCheckbox && this.name)\n                this.invCheckbox.name = this.name;\n        }\n    }\n    /**\n     * Updates the aria attributes of the toggle element based on the provided state.\n     * Sets aria-checked to \"mixed\" if the state is indeterminate, otherwise sets it to the string representation of the state's checked attribute.\n     * Sets aria-disabled to the string representation of whether the state's status is disabled.\n     * Sets aria-readonly to the string representation of whether the state's status is readonly.\n     * @param {ToggleState} state The state of the toggle element.\n     */\n    updateAria(state) {\n        if (state.indeterminate) {\n            this.toggle.setAttribute(\"aria-checked\", \"mixed\");\n        }\n        else {\n            this.toggle.setAttribute(\"aria-checked\", String(state.checked));\n        }\n        this.toggle.setAttribute(\"aria-disabled\", String(state.status === ToggleStateStatus.DISABLED));\n        this.toggle.setAttribute(\"aria-readonly\", String(state.status === ToggleStateStatus.READONLY));\n    }\n    /**\n     * Updates the tooltip of the toggle element based on the provided state.\n     * Sets the content of the tooltip to the corresponding label based on the state's value.\n     * If the tooltip or tooltipLabels are not set, does nothing.\n     * @param {ToggleState} state The state of the toggle element.\n     */\n    updateTooltip(state) {\n        if (!this.tooltip || !this.tooltipLabels)\n            return;\n        switch (state.value) {\n            case ToggleStateValue.ON:\n                this.tooltip.setContent({ \".tooltip-inner\": this.tooltipLabels.on });\n                return;\n            case ToggleStateValue.OFF:\n                this.tooltip.setContent({ \".tooltip-inner\": this.tooltipLabels.off });\n                return;\n            case ToggleStateValue.MIXED:\n                if (this.tooltipLabels.mixed)\n                    this.tooltip.setContent({ \".tooltip-inner\": this.tooltipLabels.mixed });\n                return;\n        }\n    }\n    /**\n   * Returns the root element of the toggle, which is the container of all toggle elements.\n   * @returns {HTMLElement} The root element of the toggle.\n   */\n    get root() {\n        return this.toggle;\n    }\n    /**\n   * Destroys the toggle by removing the toggle element from the DOM and\n   * inserting the original checkbox element back into its original position.\n   * Also disconnects the ResizeObserver if it was used.\n   */\n    destroy() {\n        var _a, _b;\n        this.cancelPendingAnimationFrame();\n        if (this.tooltip) {\n            this.tooltip.dispose();\n            this.tooltip = undefined;\n        }\n        (_a = this.toggle.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(this.checkbox, this.toggle);\n        this.toggle.remove();\n        (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();\n        this.resizeObserver = undefined;\n        this.isBuilt = false;\n    }\n}\n","import { ToggleActionType, ToggleStateStatus, ToggleStateValue, } from \"./StateReducer.types\";\nexport class StateReducer {\n    /**\n   * Constructor for the StateReducer class.\n   * @param element The HTMLInputElement which represents the toggle.\n   * @param isTristate A boolean indicating whether the toggle is tristate.\n   * Initializes the toggle state with the given element and tristate value.\n   */\n    constructor(element, isTristate) {\n        this.isTristate = isTristate;\n        this.state = this.getElementState(element);\n    }\n    /**\n   * Retrieves the current state of the toggle based on the HTMLInputElement.\n   * The state is determined by the following:\n   * - The checked property of the input element\n   * - The disabled property of the input element\n   * - The readonly property of the input element\n   * - The indeterminate property of the input element if the toggle is tristate\n   * @returns An object containing the state of the toggle.\n   */\n    getElementState(element) {\n        const checked = element.checked;\n        let status;\n        if (element.disabled) {\n            status = ToggleStateStatus.DISABLED;\n        }\n        else if (element.readOnly) {\n            status = ToggleStateStatus.READONLY;\n        }\n        else {\n            status = ToggleStateStatus.ENABLED;\n        }\n        const indeterminate = this.isTristate && element.indeterminate;\n        let value;\n        if (indeterminate) {\n            value = ToggleStateValue.MIXED;\n        }\n        else if (checked) {\n            value = ToggleStateValue.ON;\n        }\n        else {\n            value = ToggleStateValue.OFF;\n        }\n        return {\n            value,\n            checked,\n            status,\n            indeterminate,\n        };\n    }\n    /**\n   * Get the current toggle state.\n   * @returns An immutable copy of the current toggle state.\n   */\n    get() {\n        return Object.freeze(Object.assign({}, this.state));\n    }\n    /**\n   * Determines whether the toggle is enabled and can be interacted with.\n   * @returns True if the toggle is enabled and can be interacted with, false otherwise.\n   */\n    canInteract() {\n        return this.state.status === ToggleStateStatus.ENABLED;\n    }\n    /**\n   * Synchronizes the internal state of the toggle with the provided HTMLInputElement.\n   * This method is useful when you need to update the internal state of the toggle\n   * manually, such as when the toggle is updated programmatically.\n   * @param element The HTMLInputElement to synchronize the toggle state with.\n   */\n    sync(element) {\n        this.state = this.getElementState(element);\n    }\n    /**\n   * Apply a toggle action to the toggle state.\n   * @param action The toggle action to apply.\n   * @returns A boolean indicating whether the action was successful.\n   * If the toggle is disabled, any action execpect {@code ToggleActionType.ENABLE} will return {@code false}.\n   * If the toggle is currently in the target state of the action, the action will return {@code false}.\n   * If the toggle is in the indeterminate state and the action is {@code ToggleActionType.DETERMINATE},\n   * the toggle will be set to the checked state.\n   * If the action is {@code ToggleActionType.NEXT} :\n   *  - For a tristate toggle, the toggle will do ON -> INDETERMINATE -> OFF -> INDETERMINATE -> ON.\n   *  - For a non-tristate toggle, the toggle will do ON -> OFF -> ON.\n   */\n    do(action) {\n        const actionsRequiringInteract = [\n            ToggleActionType.ON,\n            ToggleActionType.OFF,\n            ToggleActionType.TOGGLE,\n            ToggleActionType.INDETERMINATE,\n            ToggleActionType.DETERMINATE,\n            ToggleActionType.NEXT,\n            ToggleActionType.READONLY,\n        ];\n        if (actionsRequiringInteract.includes(action) && !this.canInteract())\n            return false;\n        switch (action) {\n            case ToggleActionType.ON:\n                return this.setValueIfChanged(ToggleStateValue.ON, true, false);\n            case ToggleActionType.OFF:\n                return this.setValueIfChanged(ToggleStateValue.OFF, false, false);\n            case ToggleActionType.TOGGLE:\n                if (this.state.value === ToggleStateValue.ON)\n                    return this.do(ToggleActionType.OFF);\n                if (this.state.value === ToggleStateValue.OFF)\n                    return this.do(ToggleActionType.ON);\n                return false;\n            case ToggleActionType.INDETERMINATE:\n                return this.setValueIfChanged(ToggleStateValue.MIXED, undefined, true);\n            case ToggleActionType.DETERMINATE:\n                if (this.state.value != ToggleStateValue.MIXED)\n                    return false;\n                return this.setValue(this.state.checked ? ToggleStateValue.ON : ToggleStateValue.OFF, this.state.checked, false);\n            case ToggleActionType.NEXT:\n                return this.doNext();\n            case ToggleActionType.DISABLE:\n                return this.setStatusIfChanged(ToggleStateStatus.DISABLED);\n            case ToggleActionType.ENABLE:\n                return this.setStatusIfChanged(ToggleStateStatus.ENABLED);\n            case ToggleActionType.READONLY:\n                return this.setStatus(ToggleStateStatus.READONLY);\n        }\n    }\n    /**\n     * Sets the state of the toggle to the provided value.\n     * If checked or indeterminate is provided, sets the corresponding property of the state to the provided value.\n     * Otherwise, leaves the property unchanged.\n     * @param value The value of the toggle to set.\n     * @param checked The checked state of the toggle to set. If not provided, the property is left unchanged.\n     * @param indeterminate The indeterminate state of the toggle to set. If not provided, the property is left unchanged.\n     * @returns A boolean indicating whether the state was updated.\n     */\n    setValue(value, checked, indeterminate) {\n        this.state = Object.assign(Object.assign({}, this.state), { value, checked: checked !== null && checked !== void 0 ? checked : this.state.checked, indeterminate: indeterminate !== null && indeterminate !== void 0 ? indeterminate : this.state.indeterminate });\n        return true;\n    }\n    /**\n     * Sets the state of the toggle to the provided value if the value is different from the current state.\n     * If checked or indeterminate is provided, sets the corresponding property of the state to the provided value.\n     * Otherwise, leaves the property unchanged.\n     * @returns A boolean indicating whether the state was updated.\n     */\n    setValueIfChanged(value, checked, indeterminate) {\n        if (this.state.value === value)\n            return false;\n        return this.setValue(value, checked, indeterminate);\n    }\n    /**\n     * Sets the status of the toggle to the provided value.\n     * @param status The new status of the toggle.\n     * @returns A boolean indicating whether the state was updated.\n     */\n    setStatus(status) {\n        this.state = Object.assign(Object.assign({}, this.state), { status });\n        return true;\n    }\n    /**\n     * Sets the status of the toggle to the provided value if the value is different from the current status.\n     * @param status The new status of the toggle.\n     * @returns A boolean indicating whether the state was updated.\n     */\n    setStatusIfChanged(status) {\n        if (this.state.status === status)\n            return false;\n        return this.setStatus(status);\n    }\n    /**\n     * Applies the next action based on the current state of the toggle.\n     * If the toggle is tristate, cycles through the on, off, and indeterminate states.\n     * If the toggle is not tristate, cycles through the on and off states.\n     * @returns A boolean indicating whether the state was updated.\n     */\n    doNext() {\n        if (this.isTristate) {\n            if (this.state.value === ToggleStateValue.ON || this.state.value === ToggleStateValue.OFF) {\n                return this.do(ToggleActionType.INDETERMINATE);\n            }\n            if (this.state.value === ToggleStateValue.MIXED) {\n                return this.state.checked\n                    ? this.do(ToggleActionType.OFF)\n                    : this.do(ToggleActionType.ON);\n            }\n        }\n        else {\n            return this.state.value === ToggleStateValue.ON\n                ? this.do(ToggleActionType.OFF)\n                : this.do(ToggleActionType.ON);\n        }\n        return false;\n    }\n}\n","export var ToggleMethods;\n(function (ToggleMethods) {\n    ToggleMethods[\"ON\"] = \"on\";\n    ToggleMethods[\"OFF\"] = \"off\";\n    ToggleMethods[\"TOGGLE\"] = \"toggle\";\n    ToggleMethods[\"DETERMINATE\"] = \"determinate\";\n    ToggleMethods[\"INDETERMINATE\"] = \"indeterminate\";\n    ToggleMethods[\"ENABLE\"] = \"enable\";\n    ToggleMethods[\"DISABLE\"] = \"disable\";\n    ToggleMethods[\"READONLY\"] = \"readonly\";\n    ToggleMethods[\"DESTROY\"] = \"destroy\";\n    ToggleMethods[\"RERENDER\"] = \"rerender\";\n})(ToggleMethods || (ToggleMethods = {}));\n","import { DOMBuilder } from \"./core/DOMBuilder\";\nimport { OptionResolver } from \"./core/OptionResolver\";\nimport { StateReducer } from \"./core/StateReducer\";\nimport { ToggleActionType, ToggleStateValue } from \"./core/StateReducer.types\";\nimport ToggleEvents from \"./types/ToggleEvents\";\nexport class Toggle {\n    /**\n   * Initializes a new instance of the BootstrapToggle class.\n   * @param element The HTMLInputElement element which represents the toggle.\n   * @param options The options for the toggle.\n   * @returns The constructed BootstrapToggle instance.\n   */\n    constructor(element, options) {\n        this.pointer = null;\n        this.SCROLL_THRESHOLD = 10;\n        this.eventsBound = false;\n        this.suppressExternalSync = false;\n        this.originalDescriptors = new Map();\n        /**\n         * Handles the change event of the input element of the toggle.\n         * This event listener is responsible for detecting when the input element\n         * of the toggle changes its state and triggering the update method to keep the toggle in sync.\n         */\n        this.onExternalChange = () => {\n            this.update();\n        };\n        this.onFormReset = () => {\n            setTimeout(() => this.onExternalChange(), 0);\n        };\n        /**\n       * Handles pointer down events by initiating the toggle action and setting up\n       * listeners for pointer movement, release, and cancellation.\n       *\n       * The method early exits if:\n       * - the pointer event is not a primary mouse button click\n       * - the toggle cannot be interacted with (`disabled` or `readonly`)\n       * @param e The PointerEvent object representing the pointer down event.\n       */\n        this.onPointerDown = (e) => {\n            if (e.pointerType === \"mouse\" && e.button !== 0)\n                return;\n            if (!this.stateReducer.canInteract())\n                return;\n            this.pointer = { x: e.clientX, y: e.clientY };\n            this.domBuilder.root.addEventListener(\"pointermove\", this.onPointerMove, {\n                passive: true,\n            });\n            this.domBuilder.root.addEventListener(\"pointerup\", this.onPointerUp, {\n                passive: true,\n            });\n            this.domBuilder.root.addEventListener(\"pointercancel\", this.onPointerCancel, { passive: true });\n        };\n        /**\n       * Handles pointer move events by checking the distance moved from the initial pointer down position.\n       * If the pointer has moved beyond a certain threshold, the pointer interaction is cancelled.\n       *\n       * Allows dragging within the width of the toggle but cancels if vertical movement exceeds the scroll threshold.\n       * @param e The PointerEvent object representing the pointer move event.\n       */\n        this.onPointerMove = (e) => {\n            const dx = Math.abs(e.clientX - this.pointer.x);\n            const dy = Math.abs(e.clientY - this.pointer.y);\n            if (dy > this.SCROLL_THRESHOLD || dx > this.domBuilder.root.offsetWidth) {\n                this.onPointerCancel();\n            }\n        };\n        /**\n       * Handles pointer up events by determining if the pointer interaction\n       * should trigger a toggle action based on the distance moved.\n       *\n       * If the pointer has moved beyond a certain threshold, the pointer interaction is cancelled.\n       * Allows dragging within the width of the toggle but cancels if vertical movement exceeds the scroll threshold.\n       * Finally, it cleans up by calling the pointer cancel handler.\n       *\n       * If the pointer event is not a primary mouse button click, the interaction is cancelled.\n       * @param e The PointerEvent object representing the pointer up event.\n       */\n        this.onPointerUp = (e) => {\n            if (e.pointerType === \"mouse\" && e.button !== 0) {\n                this.onPointerCancel();\n                return;\n            }\n            const dx = Math.abs(e.clientX - this.pointer.x);\n            const dy = Math.abs(e.clientY - this.pointer.y);\n            if (dy <= this.SCROLL_THRESHOLD && dx <= this.domBuilder.root.offsetWidth) {\n                this.apply(ToggleActionType.NEXT);\n            }\n            this.onPointerCancel();\n        };\n        /**\n       * Cleans up pointer event listeners after a pointer interaction is completed or cancelled.\n       *\n       * This method removes the `pointermove`, `pointerup`, and `pointercancel` event listeners\n       * from the root element of the toggle.\n       * However, `pointerdown` listener remains active for future interactions.\n       */\n        this.onPointerCancel = () => {\n            this.domBuilder.root.removeEventListener(\"pointermove\", this.onPointerMove);\n            this.domBuilder.root.removeEventListener(\"pointerup\", this.onPointerUp);\n            this.domBuilder.root.removeEventListener(\"pointercancel\", this.onPointerCancel);\n        };\n        this.handlerKeyboardEvent = (e) => {\n            if (e.key === \" \" || e.key === \"Enter\") {\n                e.preventDefault();\n                this.apply(ToggleActionType.NEXT);\n            }\n        };\n        this.handlerLabelEvent = (e) => {\n            e.preventDefault();\n            this.apply(ToggleActionType.NEXT);\n            this.domBuilder.root.focus();\n        };\n        this.element = element;\n        this.userOptions = options;\n        this.options = OptionResolver.resolve(element, options);\n        this.stateReducer = new StateReducer(element, this.options.tristate);\n        this.domBuilder = new DOMBuilder(element, this.options, this.stateReducer.get());\n        this.bindEventListeners();\n        this.interceptInputProperties();\n        this.element.bsToggle = this;\n    }\n    /**\n     * Intercepts the following input properties to detect external changes:\n     * - checked\n     * - disabled\n     * - readonly\n     * - indeterminate\n     * This method is used to detect changes made to the input element directly,\n     * rather than through the BootstrapToggle API. It is used to maintain the\n     * state of the toggle in cases where the user changes the input element\n     * directly, rather than through the API.\n     * @returns void\n     */\n    interceptInputProperties() {\n        const props = [\"checked\", \"disabled\", \"readOnly\", \"indeterminate\"];\n        props.forEach((prop) => {\n            const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.element), prop);\n            if (!(descriptor === null || descriptor === void 0 ? void 0 : descriptor.set))\n                return;\n            this.originalDescriptors.set(prop, descriptor);\n            Object.defineProperty(this.element, prop, {\n                configurable: true,\n                get: () => descriptor.get.call(this.element),\n                set: (value) => {\n                    descriptor.set.call(this.element, value);\n                    if (this.suppressExternalSync)\n                        return;\n                    this.onExternalChange();\n                },\n            });\n        });\n    }\n    /**\n     * Restores the original input properties of the toggle element.\n     * This method is used to restore the original descriptors of the input properties\n     * which were intercepted by the BootstrapToggle to detect external changes.\n     * @returns void\n     */\n    restoreInputProperties() {\n        this.originalDescriptors.forEach((descriptor, prop) => {\n            Object.defineProperty(this.element, prop, descriptor);\n        });\n        this.originalDescriptors.clear();\n    }\n    /**\n   * Binds event listeners to the toggle element.\n   * This method is called by the constructor and is responsible for\n   * binding the following event listeners:\n   * - Pointer events (click, touchstart, touchend)\n   * - Keyboard events (keydown, keyup)\n   * - Label events (click)\n   * If the event listeners are already bound (i.e. this.eventsBound is true),\n   * this method does nothing.\n   * @returns void\n   */\n    bindEventListeners() {\n        if (this.eventsBound)\n            return;\n        this.bindFormResetListener();\n        this.bindPointerEventListener();\n        this.bindKeyboardEventListener();\n        this.bindLabelEventListener();\n        this.eventsBound = true;\n    }\n    /**\n   * Unbinds all event listeners from the toggle element.\n   * This method is called by the destructor and is responsible for\n   * unbinding the following event listeners:\n   * - Pointer events (click, touchstart, touchend)\n   * - Keyboard events (keydown, keyup)\n   * - Label events (click)\n   * If the event listeners are not bound (i.e. this.eventsBound is false),\n   * this method does nothing.\n   * @returns void\n   */\n    unbindEventListeners() {\n        if (!this.eventsBound)\n            return;\n        this.unbindFormResetListener();\n        this.unbindPointerEventListener();\n        this.unbindKeyboardEventListener();\n        this.unbindLabelEventListener();\n        this.eventsBound = false;\n    }\n    bindFormResetListener() {\n        const form = this.element.form;\n        if (!form)\n            return;\n        form.addEventListener(\"reset\", this.onFormReset);\n    }\n    unbindFormResetListener() {\n        const form = this.element.form;\n        if (!form)\n            return;\n        form.removeEventListener(\"reset\", this.onFormReset);\n    }\n    /**\n   * Binds a pointerdown event listener to the root element of the toggle.\n   * The event listener is responsible for handling pointer events (e.g. mouse clicks, touch events)\n   * and triggering the toggle's state change when a pointer event occurs.\n   * The event listener is bound with the passive option, which means that it will not block\n   * other event listeners from being triggered.\n   */\n    bindPointerEventListener() {\n        this.domBuilder.root.addEventListener(\"pointerdown\", this.onPointerDown, {\n            passive: true,\n        });\n    }\n    /**\n   * Unbinds the pointerdown event listener from the root element of the toggle.\n   * This method is responsible for unbinding the pointerdown event listener that was\n   * previously bound by the bindPointerEventListener method.\n   * If the event listener is not bound (i.e. this.eventsBound is false), this method does nothing.\n   * @returns void\n   */\n    unbindPointerEventListener() {\n        this.domBuilder.root.removeEventListener(\"pointerdown\", this.onPointerDown);\n    }\n    /**\n   * Binds a keydown event listener to the root element of the toggle.\n   * The event listener is responsible for handling keydown events\n   * and triggering the toggle's state change when a keydown event occurs.\n   */\n    bindKeyboardEventListener() {\n        this.domBuilder.root.addEventListener(\"keydown\", this.handlerKeyboardEvent, { passive: false });\n    }\n    /**\n   * Unbinds the keydown event listener from the root element of the toggle.\n   * This method is responsible for unbinding the keydown event listener that was\n   * previously bound by the bindKeyboardEventListener method.\n   * If the event listener is not bound (i.e. this.eventsBound is false), this method does nothing.\n   * @returns void\n   */\n    unbindKeyboardEventListener() {\n        this.domBuilder.root.removeEventListener(\"keydown\", this.handlerKeyboardEvent);\n    }\n    /**\n   * Binds a click event listener to all labels that are associated with the toggle's input element.\n   * The event listener is responsible for handling click events and triggering the toggle's state change when a click event occurs.\n   * The event listener is bound with the passive option set to false, which means that it will block other event listeners from being triggered until it has finished its execution.\n   * This method is called by the constructor and is responsible for binding the event listener to the toggle's labels.\n   * If the toggle's input element does not have an id (i.e. this.element.id is null or undefined), this method does nothing.\n   * @returns void\n   */\n    bindLabelEventListener() {\n        if (this.element.id) {\n            document\n                .querySelectorAll('label[for=\"' + this.element.id + '\"]')\n                .forEach((label) => {\n                label.addEventListener(\"click\", this.handlerLabelEvent, {\n                    passive: false,\n                });\n            });\n        }\n    }\n    /**\n   * Unbinds the click event listener from all labels that are associated with the toggle's input element.\n   * This method is responsible for unbinding the event listener that was previously bound by the bindLabelEventListener method.\n   * If the toggle's input element does not have an id (i.e. this.element.id is null or undefined), this method does nothing.\n   * @returns void\n   */\n    unbindLabelEventListener() {\n        if (this.element.id) {\n            document\n                .querySelectorAll('label[for=\"' + this.element.id + '\"]')\n                .forEach((label) => {\n                label.removeEventListener(\"click\", this.handlerLabelEvent);\n            });\n        }\n    }\n    /**\n   * Applies a toggle action to the toggle state and renders the toggle element.\n   * If the action is successful, this method will render the toggle element with the new state.\n   * If the silent parameter is false, this method will also trigger the change event.\n   * @param action The toggle action to apply.\n   * @param silent A boolean indicating whether to trigger the change event after applying the action.\n   */\n    apply(action, silent = false) {\n        if (!this.stateReducer.do(action))\n            return;\n        this.suppressExternalSync = true;\n        try {\n            const state = this.stateReducer.get();\n            this.domBuilder.render(state);\n            if (!silent)\n                this.trigger(action, state);\n        }\n        finally {\n            this.suppressExternalSync = false;\n        }\n    }\n    /**\n   * Toggles the state of the toggle.\n   * If the toggle is currently in the on state, it will be set to the off state.\n   * If the toggle is currently in the off state, it will be set to the on state.\n   * If the toggle is currently in the indeterminate state, it will be set to the on state.\n   * If the silent parameter is false, this method will also trigger the change event.\n   * @param silent A boolean indicating whether to trigger the change event after applying the action.\n   */\n    toggle(silent = false) {\n        this.apply(ToggleActionType.TOGGLE, silent);\n    }\n    /**\n   * Sets the toggle state to on.\n   * If the silent parameter is false, this method will also trigger the change event.\n   * @param silent A boolean indicating whether to trigger the change event after applying the action.\n   */\n    on(silent = false) {\n        this.apply(ToggleActionType.ON, silent);\n    }\n    /**\n   * Sets the toggle state to off.\n   * If the silent parameter is false, this method will also trigger the change event.\n   * @param silent A boolean indicating whether to trigger the change event after applying the action.\n   */\n    off(silent = false) {\n        this.apply(ToggleActionType.OFF, silent);\n    }\n    /**\n   * Sets the toggle state to indeterminate.\n   * If the silent parameter is false, this method will also trigger the change event.\n   * @param {boolean} silent A boolean indicating whether to trigger the change event after applying the action.\n   */\n    indeterminate(silent = false) {\n        this.apply(ToggleActionType.INDETERMINATE, silent);\n    }\n    /**\n   * Sets the toggle state to determinate.\n   * If the silent parameter is false, this method will also trigger the change event.\n   * @param {boolean} silent A boolean indicating whether to trigger the change event after applying the action.\n   */\n    determinate(silent = false) {\n        this.apply(ToggleActionType.DETERMINATE, silent);\n    }\n    /**\n   * Enables the toggle.\n   * If the toggle is currently disabled, this method will set the toggle state to enabled.\n   * If the silent parameter is false, this method will also trigger the change event.\n   * @param {boolean} silent A boolean indicating whether to trigger the change event after applying the action.\n   * @returns void\n   */\n    enable(silent = false) {\n        this.apply(ToggleActionType.ENABLE, silent);\n    }\n    /**\n   * Disables the toggle.\n   * If the toggle is currently enabled, this method will set the toggle state to disabled.\n   * If the silent parameter is false, this method will also trigger the change event.\n   * @param {boolean} silent A boolean indicating whether to trigger the change event after applying the action.\n   */\n    disable(silent = false) {\n        this.apply(ToggleActionType.DISABLE, silent);\n    }\n    /**\n   * Sets the toggle state to readonly.\n   * If the toggle is currently disabled or enabled, this method will set the toggle state to readonly.\n   * If the silent parameter is false, this method will also trigger the change event.\n   * @param {boolean} silent A boolean indicating whether to trigger the change event after applying the action.\n   * @returns void\n   */\n    readonly(silent = false) {\n        this.apply(ToggleActionType.READONLY, silent);\n    }\n    /**\n     * Synchronizes the toggle state with the input element and renders the toggle.\n     */\n    update() {\n        this.suppressExternalSync = true;\n        try {\n            this.stateReducer.sync(this.element);\n            this.domBuilder.render(this.stateReducer.get());\n        }\n        finally {\n            this.suppressExternalSync = false;\n        }\n    }\n    /**\n     * Triggers the change event on the toggle's input element and the appropriate toggle event.\n     * This method is called after a toggle action is applied to notify listeners of the state change.\n     * @param {ToggleActionType} action The toggle action that was applied.\n     * @param {ToggleState} state The state of the toggle once the action was applied.\n     */\n    trigger(action, state) {\n        this.element.dispatchEvent(new Event(\"change\", { bubbles: true }));\n        const eventName = this.getEventForAction(action, state);\n        const detail = { state: state };\n        this.element.dispatchEvent(new CustomEvent(eventName, {\n            bubbles: true,\n            detail: detail\n        }));\n    }\n    /**\n     * Returns the corresponding toggle event for the given toggle action and state.\n     * This method is used to determine which toggle event to trigger after a toggle action is applied.\n     * @param {ToggleActionType} action The toggle action that was applied.\n     * @param {ToggleState} state The previous state of the toggle before the action was applied.\n     * @returns {ToggleEvents} The corresponding toggle event for the given toggle action and state.\n     */\n    getEventForAction(action, state) {\n        switch (action) {\n            case ToggleActionType.ON:\n                return ToggleEvents.ON;\n            case ToggleActionType.OFF:\n                return ToggleEvents.OFF;\n            case ToggleActionType.INDETERMINATE:\n                return ToggleEvents.MIXED;\n            case ToggleActionType.ENABLE:\n                return ToggleEvents.ENABLED;\n            case ToggleActionType.DISABLE:\n                return ToggleEvents.DISABLED;\n            case ToggleActionType.READONLY:\n                return ToggleEvents.READONLY;\n            case ToggleActionType.DETERMINATE:\n            case ToggleActionType.TOGGLE:\n            case ToggleActionType.NEXT:\n                return this.getValueEvent(state);\n        }\n    }\n    /**\n     * Returns the corresponding toggle event for the given toggle state.\n     * This method is used to determine which toggle event to trigger after a toggle action is applied.\n     * @param {ToggleState} state The previous state of the toggle before the action was applied.\n     * @returns {ToggleEvents} The corresponding toggle event for the given toggle state.\n     */\n    getValueEvent(state) {\n        switch (state.value) {\n            case ToggleStateValue.ON:\n                return ToggleEvents.ON;\n            case ToggleStateValue.OFF:\n                return ToggleEvents.OFF;\n            case ToggleStateValue.MIXED:\n                return ToggleEvents.MIXED;\n        }\n    }\n    /**\n   * Destroys the toggle element and unbinds all event listeners.\n   *This method is useful when you need to remove the toggle element from the DOM.\n   *After calling this method, the toggle element will be removed from the DOM and all event listeners will be unbound.\n   */\n    destroy() {\n        this.restoreInputProperties();\n        this.unbindEventListeners();\n        this.domBuilder.destroy();\n        delete this.element.bsToggle;\n    }\n    /**\n     * Rebuilds the toggle component in-place without destroying the current instance.\n     *\n     * This method is useful when you need to reinitialize the toggle element with the same options,\n     * for example after HTML attribute changes or when the DOM structure has been modified externally.\n     *\n     * The method follows this sequence:\n     * 1. Restores original input properties (checked, disabled, readOnly, indeterminate)\n     * 2. Unbinds all event listeners (pointer, keyboard, label, form reset)\n     * 3. Destroys the DOM builder (removes toggle DOM, restores original checkbox)\n     * 4. Re-resolves options from the element and user options\n     * 5. Creates a fresh StateReducer with the updated tristate value\n     * 6. Builds new toggle DOM structure\n     * 7. Re-binds all event listeners\n     * 8. Re-intercepts input properties for external change detection\n     *\n     * Important: The instance identity is preserved (this.element.bsToggle remains unchanged),\n     * making it safe for external code that holds references to this instance.\n     *\n     * @returns void\n     */\n    rerender() {\n        this.restoreInputProperties();\n        this.unbindEventListeners();\n        this.domBuilder.destroy();\n        this.options = OptionResolver.resolve(this.element, this.userOptions);\n        this.stateReducer = new StateReducer(this.element, this.options.tristate);\n        this.domBuilder = new DOMBuilder(this.element, this.options, this.stateReducer.get());\n        this.bindEventListeners();\n        this.interceptInputProperties();\n    }\n}\n"],"names":["ToggleStateValue","ToggleStateStatus","ToggleActionType","SanitizeMode","PlacementOptions","OptionType","ToggleEvents","DOMBuilder","constructor","checkbox","options","state","this","isBuilt","lastState","onStyle","onstyle","offStyle","offstyle","name","onvalue","value","invCheckbox","offvalue","createInvCheckbox","sizeClass","sizeResolver","size","toggleOn","createToggleSpan","onlabel","ontitle","toggleOff","offlabel","offtitle","toggleHandle","createToggleHandle","toggleGroup","createToggleGroup","toggle","document","createElement","tooltip","tooltipLabels","title","isVisible","renderToggle","render","deferRender","parent","parentElement","offsetWidth","offsetHeight","resizeObserver","ResizeObserver","entries","disconnect","entry","contentRect","width","height","observe","_a","large","lg","small","sm","mini","xs","offValue","cloneNode","dataset","removeAttribute","style","tabindex","aria","className","tabIndex","role","insertBefore","appendChild","handleLabels","handleToggleSize","createTooltip","label","toggleSpan","innerHTML","cancelPendingAnimationFrame","requestAnimationFrame","requestAnimationFrameId","calculateToggleSize","error","console","warn","minWidth","Math","max","getBoundingClientRect","minHeight","classList","add","lineHeight","calcH","styles","globalThis","window","getComputedStyle","borderTopWidth","Number","parseFloat","borderBottomWidth","paddingTop","paddingBottom","undefined","cancelAnimationFrame","ariaOpts","labels","length","ids","Array","from","map","l","id","filter","Boolean","setAttribute","join","bootstrap","Tooltip","placement","html","on","updateToggleByValue","updateToggleByChecked","updateToggleByState","updateAria","updateTooltip","remove","ON","OFF","MIXED","checked","updateCheckboxByChecked","updateInvCheckboxByChecked","status","ENABLED","disabled","readOnly","DISABLED","READONLY","indeterminate","String","setContent","off","mixed","root","destroy","_b","dispose","parentNode","sanitize","text","opts","mode","HTML","config","allowedTags","allowedAttributes","doc","DOMParser","parseFromString","body","childNodes","forEach","node","sanitizeNodeRecursive","nodeType","Node","ELEMENT_NODE","element","tagName","toLowerCase","includes","fragment","createDocumentFragment","child","replaceChild","attributes","attr","attrName","some","allowed","endsWith","startsWith","slice","sanitizeAllowedAttr","TEXT_NODE","sanitizeNode","sanitizeHTML","TEXT","replace","m","sanitizeText","isNumeric","test","toString","trim","OptionResolver","getAttr","sanitized","getAttribute","getAttrOrDefault","userValue","defaultValue","sanitizedUserValue","getAttrOrDeprecation","DeprecationConfig","resolve","userOptions","DEFAULT","tristate","hasAttribute","resolveTooltipOptions","handle","_c","_d","getTitle","userOption","titleOn","titleOff","titleMixed","TOP","Object","values","deprecatedOptions","currentOpt","deprecatedAttr","deprecatedOpt","deprecatedAttrSanitized","log","ATTRIBUTE","OPTION","type","oldLabel","newLabel","StateReducer","isTristate","getElementState","get","freeze","assign","canInteract","sync","action","TOGGLE","INDETERMINATE","DETERMINATE","NEXT","setValueIfChanged","do","setValue","doNext","DISABLE","setStatusIfChanged","ENABLE","setStatus","ToggleMethods","Toggle","pointer","SCROLL_THRESHOLD","eventsBound","suppressExternalSync","originalDescriptors","Map","onExternalChange","update","onFormReset","setTimeout","onPointerDown","e","pointerType","button","stateReducer","x","clientX","y","clientY","domBuilder","addEventListener","onPointerMove","passive","onPointerUp","onPointerCancel","dx","abs","apply","removeEventListener","handlerKeyboardEvent","key","preventDefault","handlerLabelEvent","focus","bindEventListeners","interceptInputProperties","bsToggle","prop","descriptor","getOwnPropertyDescriptor","getPrototypeOf","set","defineProperty","configurable","call","restoreInputProperties","clear","bindFormResetListener","bindPointerEventListener","bindKeyboardEventListener","bindLabelEventListener","unbindEventListeners","unbindFormResetListener","unbindPointerEventListener","unbindKeyboardEventListener","unbindLabelEventListener","form","querySelectorAll","silent","trigger","determinate","enable","disable","readonly","dispatchEvent","Event","bubbles","eventName","getEventForAction","detail","CustomEvent","getValueEvent","rerender"],"mappings":";;;;;;;;;;;;AAAO,IAAIA,EAMAC,EAMAC,ECZAC,ECAAC,ECyIPC,ECzIAC,GJCJ,SAAWN,GACPA,EAAqB,GAAI,KACzBA,EAAsB,IAAI,MAC1BA,EAAwB,MAAI,O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