{"version":3,"sources":["jsdelivr-header.js","/npm/validation-output@0.1.5/validation-output.js"],"names":[],"mappings":"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","file":"/npm/validation-output@0.1.5/validation-output.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/validation-output@0.1.5/validation-output.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nclass ValidationOutput extends HTMLElement {\n    #template = null;\n    #for;\n    #internals;\n    #interacted = false;\n    #serverError = undefined;\n    #serverErrorValue = undefined;\n    constructor() {\n        super();\n        this.#internals = this.attachInternals();\n    }\n    connectedCallback() {\n        this.#initializeInput();\n        this.#initializeUsability();\n        this.#initializeTemplate();\n        this.#initializeServerError();\n        this.#for.addEventListener(\"input\", this.#handleInput);\n        this.#for.addEventListener(\"change\", this.#handleChange);\n        this.#for.addEventListener(\"invalid\", this.#handleInvalid);\n    }\n    disconnectedCallback() {\n        this.#for.removeEventListener(\"input\", this.#handleInput);\n        this.#for.removeEventListener(\"change\", this.#handleChange);\n        this.#for.removeEventListener(\"invalid\", this.#handleInvalid);\n    }\n    #initializeServerError() {\n        if (!this.innerHTML.trim())\n            return;\n        this.#interacted = true;\n        this.#serverError = this.innerHTML;\n        this.#serverErrorValue = this.#for.value;\n        if (this.hasAttribute(\"persistent\")) {\n            this.#for.setCustomValidity(this.#serverError);\n        }\n        requestAnimationFrame(() => {\n            this.#internals.states.add(\"has-error\");\n        });\n        this.#for.setAttribute(\"data-server-invalid\", \"true\");\n    }\n    #initializeInput() {\n        if (!this.hasAttribute(\"for\")) {\n            throw new Error('ValidationOutput: Missing \"for\" attribute');\n        }\n        const _for = document.getElementById(this.getAttribute(\"for\"));\n        if (!_for) {\n            throw new Error(\"ValidationOutput: No element with ID \" +\n                this.getAttribute(\"for\"));\n        }\n        this.#for = _for;\n    }\n    #initializeUsability() {\n        if (!this.hasAttribute(\"aria-live\")) {\n            this.setAttribute(\"aria-live\", \"polite\");\n        }\n        if (!this.hasAttribute(\"role\")) {\n            this.setAttribute(\"role\", \"alert\");\n        }\n    }\n    #initializeTemplate() {\n        if (!this.hasAttribute(\"template\"))\n            return;\n        const template = document.getElementById(this.getAttribute(\"template\"));\n        if (!(template instanceof HTMLTemplateElement)) {\n            throw new Error(\"Target template must be a <template> element\");\n        }\n        this.#template = template.content.cloneNode(true);\n    }\n    #handleInput = () => {\n        if (this.#for.matches(\":user-invalid\")) {\n            this.#interacted = true;\n        }\n        if (!this.#interacted) {\n            return;\n        }\n        this.#validate();\n    };\n    #handleChange = () => {\n        this.#interacted = true;\n        this.#validate();\n    };\n    #handleInvalid = (e) => {\n        this.#interacted = true;\n        this.#validate();\n        e.preventDefault();\n    };\n    #validate() {\n        this.#for.setCustomValidity(\"\");\n        if (this.#for.hasAttribute(\"data-server-invalid\")) {\n            this.#for.removeAttribute(\"data-server-invalid\");\n        }\n        if (this.#serverError &&\n            this.#for.value === this.#serverErrorValue &&\n            this.hasAttribute(\"persistent\")) {\n            this.#for.setCustomValidity(this.#serverError);\n            this.#setErrorMessage(this.#serverError);\n            return;\n        }\n        if (this.#for.matches(\":user-invalid\")) {\n            this.#setErrorMessage(this.#getCustomValidationMessage(this.#for.validity) ??\n                this.#for.validationMessage);\n            return;\n        }\n        if (!this.#internals.states.has(\"has-error\"))\n            return;\n        const transitionDuration = parseFloat(getComputedStyle(this).transitionDuration);\n        this.#internals.states.delete(\"has-error\");\n        if (transitionDuration === 0) {\n            this.innerHTML = \"\";\n            return;\n        }\n        const handleTransitionEnd = () => {\n            if (this.matches(\":user-invalid\"))\n                return;\n            this.innerHTML = \"\";\n        };\n        this.addEventListener(\"transitionend\", handleTransitionEnd, {\n            once: true,\n        });\n    }\n    #setErrorMessage(message) {\n        this.innerHTML = \"\";\n        if (message instanceof DocumentFragment) {\n            this.appendChild(message);\n        }\n        else {\n            this.innerHTML = message;\n        }\n        this.#internals.states.add(\"has-error\");\n    }\n    #getCustomValidationMessage(validity) {\n        if (!this.#template)\n            return null;\n        for (const key in validity) {\n            if (!validity[key])\n                continue;\n            const template = this.#template.querySelector(`template[data-validity=\"${key}\"]`);\n            if (template) {\n                return template.content.cloneNode(true);\n            }\n        }\n        return null;\n    }\n}\ncustomElements.define(\"validation-output\", ValidationOutput);\n"]}