{"version":3,"file":"toggle.module.js","sources":["../../../.config/config.js","../../../src/core/api.js","../../../src/component/toggle/script/toggle/toggle-input.js","../../../src/component/toggle/script/toggle/toggle-status-label.js","../../../src/component/toggle/script/toggle/toggle-selector.js","../../../src/component/toggle/index.js","../../../src/component/toggle/main.js"],"sourcesContent":["const config = {\r\n prefix: 'fr',\r\n namespace: 'dsfr',\r\n organisation: '@gouvfr',\r\n version: '1.11.2'\r\n};\r\n\r\nexport default config;\r\n","import config from './config.js';\nconst api = window[config.namespace];\nexport default api;\n","import api from '../../api.js';\n\nclass ToggleInput extends api.core.Instance {\n static get instanceClassName () {\n return 'ToggleInput';\n }\n\n get isChecked () {\n return this.node.checked;\n }\n}\n\nexport { ToggleInput };\n","import api from '../../api.js';\nimport { ToggleInput } from './toggle-input.js';\n\nclass ToggleStatusLabel extends api.core.Instance {\n static get instanceClassName () {\n return 'ToggleStatusLabel';\n }\n\n init () {\n this.register(`input[id=\"${this.getAttribute('for')}\"]`, ToggleInput);\n this.update();\n this.isSwappingFont = true;\n }\n\n get proxy () {\n const scope = this;\n return Object.assign(super.proxy, {\n update: scope.update.bind(scope)\n });\n }\n\n get input () {\n return this.getRegisteredInstances('ToggleInput')[0];\n }\n\n update () {\n this.node.style.removeProperty('--toggle-status-width');\n const checked = this.input.isChecked;\n\n const style = getComputedStyle(this.node, ':before');\n let maxWidth = parseFloat(style.width);\n this.input.node.checked = !checked;\n\n const style2 = getComputedStyle(this.node, ':before');\n const width = parseFloat(style2.width);\n if (width > maxWidth) maxWidth = width;\n this.input.node.checked = checked;\n\n this.node.style.setProperty('--toggle-status-width', (maxWidth / 16) + 'rem');\n }\n\n swapFont (families) {\n this.update();\n }\n}\n\nexport { ToggleStatusLabel };\n","import api from '../../api.js';\n\nexport const ToggleSelector = {\n STATUS_LABEL: `${api.internals.ns.selector('toggle__label')}${api.internals.ns.attr.selector('checked-label')}${api.internals.ns.attr.selector('unchecked-label')}`\n};\n","import api from './api.js';\nimport { ToggleStatusLabel } from './script/toggle/toggle-status-label.js';\nimport { ToggleSelector } from './script/toggle/toggle-selector.js';\n// import { ToggleInput } from './script/toggle/toggle-input.js';\n\napi.toggle = {\n ToggleStatusLabel: ToggleStatusLabel,\n ToggleSelector: ToggleSelector\n};\n\nexport default api;\n","import api from './index.js';\n\napi.internals.register(api.toggle.ToggleSelector.STATUS_LABEL, api.toggle.ToggleStatusLabel);\n\nexport default api;\n"],"names":[],"mappings":";;AAAA,MAAM,MAAM,GAAG;AACf,EAAE,MAAM,EAAE,IAAI;AACd,EAAE,SAAS,EAAE,MAAM;AACnB,EAAE,YAAY,EAAE,SAAS;AACzB,EAAE,OAAO,EAAE,QAAQ;AACnB,CAAC;;ACJD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;;ACCpC,MAAM,WAAW,SAAS,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC5C,EAAE,WAAW,iBAAiB,CAAC,GAAG;AAClC,IAAI,OAAO,aAAa,CAAC;AACzB,GAAG;AACH;AACA,EAAE,IAAI,SAAS,CAAC,GAAG;AACnB,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;AAC7B,GAAG;AACH;;ACPA,MAAM,iBAAiB,SAAS,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;AAClD,EAAE,WAAW,iBAAiB,CAAC,GAAG;AAClC,IAAI,OAAO,mBAAmB,CAAC;AAC/B,GAAG;AACH;AACA,EAAE,IAAI,CAAC,GAAG;AACV,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;AAC1E,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;AAClB,IAAI,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;AAC/B,GAAG;AACH;AACA,EAAE,IAAI,KAAK,CAAC,GAAG;AACf,IAAI,MAAM,KAAK,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