Files
web/vendor/bootstrap5-toggle/bootstrap5-toggle.jquery.min.js
0153772cf5 Swap remaining jQuery plugins for Bootstrap 5-compatible versions
- DataTables: replace the combined BS3 download-builder bundles with
  the official core + Bootstrap 5 styling-adapter package pairs
  (datatables.net(-buttons/-select) + datatables.net-bs5/-buttons-bs5/
  -select-bs5), loaded core-then-adapter.
- bootstrap-select -> Tom Select: bootstrap-select has no Bootstrap 5
  build. Add utils.createGroupSelect(), a small wrapper around Tom
  Select that recreates bootstrap-select's actionsBox (Select all/
  Select none) via a couple of buttons injected into the dropdown, and
  use it for all four "assign to group(s)" multi-selects (groups,
  groups/clients, groups/domains, groups/lists). Two behavioral fixes
  were needed to match the old widget: `hideSelected: false` (Tom
  Select refuses to open its dropdown once every option is already
  selected, which made the actions box unreachable) and
  `dropdownParent: "body"` (otherwise the dropdown is clipped by the
  surrounding .table-responsive/.card ancestors' overflow, same reason
  bootstrap-select was configured with container: "body").
- bootstrap-toggle -> bootstrap5-toggle: drop-in replacement, same
  $.fn.bootstrapToggle() API and onstyle/offstyle option names (all
  call sites already used Bootstrap 5-valid color names).
- select2: bump to 4.1.0 and add the select2-bootstrap-5-theme package
  for correct Bootstrap 5 styling; wire theme: "bootstrap-5" into both
  call sites.
- Remove now-dead bootstrap-select cleanup code (the
  "$('body > .bootstrap-select.dropdown').remove()" DataTables
  drawCallback lines across 8 files) and dead icheck/bootstrap-select
  CSS in pi-hole.css.

Also fixed a Phase 1 regression surfaced by this pass: utils.js's
loadingOverlay() still targeted the old ".wrapper" class instead of
".app-wrapper", throwing whenever a settings page triggered the
Save & Apply overlay.

Verified against a live container: groups/clients' per-row Tom Select
multiselect (open dropdown, Select all/none, Apply, restore-on-cancel),
bootstrap5-toggle switches on groups, select2 filters on the query log,
and DataTables' select/export button row on groups/lists all work with
zero console errors. Settings pages' Save & Apply overlay confirmed
fixed and no longer throwing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
2026-07-17 22:39:57 +01:00

15 lines
21 KiB
JavaScript

/*
* Copyright Notice
* bootstrap5-toggle v5.4.1
* https://palcarazm.github.io/bootstrap5-toggle/
* @author 2011-2014 Min Hur (https://github.com/minhur)
* @author 2018-2019 Brent Ely (https://github.com/gitbrent)
* @author 2022 Pablo Alcaraz Martínez (https://github.com/palcarazm)
* @funding GitHub Sponsors
* @see https://github.com/sponsors/palcarazm
* @license MIT
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
*/
!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";var t,e,i,s,n,o,a;!function(t){t.ON="on",t.OFF="off",t.MIXED="mixed"}(t||(t={})),function(t){t.ENABLED="enabled",t.DISABLED="disabled",t.READONLY="readonly"}(e||(e={})),function(t){t.NEXT="next",t.ON="on",t.OFF="off",t.TOGGLE="toggle",t.DETERMINATE="determinate",t.INDETERMINATE="indeterminate",t.READONLY="readonly",t.DISABLE="disable",t.ENABLE="enable"}(i||(i={}));class r{constructor(t,e,i){this.isBuilt=!1,this.lastState=i,this.onStyle=`btn-${e.onstyle}`,this.offStyle=`btn-${e.offstyle}`,this.name=e.name,this.checkbox=t,e.onvalue&&(this.checkbox.value=e.onvalue),this.invCheckbox=e.offvalue?this.createInvCheckbox(e.offvalue):null,this.sizeClass=r.sizeResolver(e.size),this.toggleOn=this.createToggleSpan(e.onlabel,this.onStyle,e.ontitle),this.toggleOff=this.createToggleSpan(e.offlabel,this.offStyle,e.offtitle),this.toggleHandle=this.createToggleHandle(),this.toggleGroup=this.createToggleGroup(),this.toggle=document.createElement("div"),e.tooltip&&(this.tooltipLabels=e.tooltip.title),this.isVisible()?(this.renderToggle(e),this.render(i)):this.deferRender(e)}isVisible(){const t=this.checkbox.parentElement;return!!t&&t.offsetWidth>0&&t.offsetHeight>0}deferRender(t){this.resizeObserver=new ResizeObserver(e=>{if(this.isBuilt)this.resizeObserver.disconnect();else for(const i of e)if(i.contentRect.width>0&&i.contentRect.height>0)return this.renderToggle(t),this.render(this.lastState),this.isBuilt=!0,void this.resizeObserver.disconnect()}),this.resizeObserver.observe(this.checkbox.parentElement)}static sizeResolver(t){var e;return null!==(e={large:"btn-lg",lg:"btn-lg",small:"btn-sm",sm:"btn-sm",mini:"btn-xs",xs:"btn-xs"}[t])&&void 0!==e?e:""}createInvCheckbox(t){const e=this.checkbox.cloneNode(!0);return e.value=t,e.dataset.toggle="invert-toggle",e.removeAttribute("id"),e}renderToggle({style:t,width:e,height:i,tabindex:s,aria:n,tooltip:o}){var a;this.toggle.className=`toggle btn ${this.sizeClass} ${t}`,this.toggle.dataset.toggle="toggle",this.toggle.tabIndex=s,this.toggle.role="switch",this.checkbox.tabIndex=-1,this.invCheckbox&&(this.invCheckbox.tabIndex=-1),null===(a=this.checkbox.parentElement)||void 0===a||a.insertBefore(this.toggle,this.checkbox),this.toggle.appendChild(this.checkbox),this.invCheckbox&&this.toggle.appendChild(this.invCheckbox),this.toggle.appendChild(this.toggleGroup),this.handleLabels(n),this.handleToggleSize(e,i),o&&this.createTooltip(o),this.isBuilt=!0}createToggleGroup(){const t=document.createElement("div");return t.className="toggle-group",t.appendChild(this.toggleOn),t.appendChild(this.toggleOff),t.appendChild(this.toggleHandle),t}createToggleSpan(t,e,i){const s=document.createElement("span");return s.className=`btn ${this.sizeClass} ${e}`,s.innerHTML=t,i&&(s.title=i),s}createToggleHandle(){const t=document.createElement("span");return t.className=`toggle-handle btn ${this.sizeClass}`,t}handleToggleSize(t,e){this.cancelPendingAnimationFrame(),"function"==typeof requestAnimationFrame?this.requestAnimationFrameId=requestAnimationFrame(()=>{try{this.calculateToggleSize(t,e)}catch(t){console.warn("Error calculating toggle size:",t)}}):this.calculateToggleSize(t,e)}calculateToggleSize(t,e){t?this.toggle.style.width=t:(this.toggle.style.minWidth="100px",this.toggle.style.minWidth=`${Math.max(this.toggleOn.getBoundingClientRect().width,this.toggleOff.getBoundingClientRect().width)+this.toggleHandle.getBoundingClientRect().width/2}px`),e?this.toggle.style.height=e:(this.toggle.style.minHeight="36px",this.toggle.style.minHeight=`${Math.max(this.toggleOn.getBoundingClientRect().height,this.toggleOff.getBoundingClientRect().height)}px`),this.toggleOn.classList.add("toggle-on"),this.toggleOff.classList.add("toggle-off"),e&&(this.toggleOn.style.lineHeight=r.calcH(this.toggleOn)+"px",this.toggleOff.style.lineHeight=r.calcH(this.toggleOff)+"px")}static calcH(t){const e=globalThis.window.getComputedStyle(t),i=t.offsetHeight,s=Number.parseFloat(e.borderTopWidth);return i-Number.parseFloat(e.borderBottomWidth)-s-Number.parseFloat(e.paddingTop)-Number.parseFloat(e.paddingBottom)}cancelPendingAnimationFrame(){void 0!==this.requestAnimationFrameId&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(this.requestAnimationFrameId),this.requestAnimationFrameId=void 0)}handleLabels(t){var e;if(null===(e=this.checkbox.labels)||void 0===e?void 0:e.length){const t=Array.from(this.checkbox.labels).map(t=>t.id).filter(Boolean);t.length&&this.toggle.setAttribute("aria-labelledby",t.join(" "))}else this.toggle.setAttribute("aria-label",t.label)}createTooltip(t){try{this.tooltip=new globalThis.window.bootstrap.Tooltip(this.toggle,{placement:t.placement,html:!0,title:t.title.on})}catch(t){console.error("Error creating tooltip:",t)}}render(t){this.lastState=t,this.isBuilt&&(this.updateToggleByValue(t),this.updateToggleByChecked(t),this.updateToggleByState(t),this.updateAria(t),this.updateTooltip(t))}updateToggleByValue(e){switch(this.toggle.classList.remove(this.onStyle,this.offStyle,"off","indeterminate"),e.value){case t.ON:this.toggle.classList.add(this.onStyle);break;case t.OFF:this.toggle.classList.add(this.offStyle,"off");break;case t.MIXED:this.toggle.classList.add("indeterminate"),e.checked?this.toggle.classList.add(this.onStyle):this.toggle.classList.add(this.offStyle,"off")}}updateToggleByChecked(t){this.updateCheckboxByChecked(t),this.updateInvCheckboxByChecked(t)}updateCheckboxByChecked(t){switch(this.checkbox.checked=t.checked,t.status){case e.ENABLED:this.checkbox.disabled=!1,this.checkbox.readOnly=!1,this.toggle.classList.remove("disabled"),this.toggle.removeAttribute("disabled");break;case e.DISABLED:this.checkbox.disabled=!0,this.checkbox.readOnly=!1,this.toggle.classList.add("disabled"),this.toggle.setAttribute("disabled","");break;case e.READONLY:this.checkbox.disabled=!1,this.checkbox.readOnly=!0,this.toggle.classList.add("disabled"),this.toggle.setAttribute("disabled","")}}updateInvCheckboxByChecked(t){if(this.invCheckbox)switch(this.invCheckbox.checked=!t.checked,t.status){case e.ENABLED:this.invCheckbox.disabled=!1,this.invCheckbox.readOnly=!1;break;case e.DISABLED:this.invCheckbox.disabled=!0,this.invCheckbox.readOnly=!1;break;case e.READONLY:this.invCheckbox.disabled=!1,this.invCheckbox.readOnly=!0}}updateToggleByState(t){t.indeterminate?(this.checkbox.indeterminate=!0,this.checkbox.removeAttribute("name"),this.invCheckbox&&(this.invCheckbox.indeterminate=!0),this.invCheckbox&&this.invCheckbox.removeAttribute("name")):(this.checkbox.indeterminate=!1,this.name&&(this.checkbox.name=this.name),this.invCheckbox&&(this.invCheckbox.indeterminate=!1),this.invCheckbox&&this.name&&(this.invCheckbox.name=this.name))}updateAria(t){t.indeterminate?this.toggle.setAttribute("aria-checked","mixed"):this.toggle.setAttribute("aria-checked",String(t.checked)),this.toggle.setAttribute("aria-disabled",String(t.status===e.DISABLED)),this.toggle.setAttribute("aria-readonly",String(t.status===e.READONLY))}updateTooltip(e){if(this.tooltip&&this.tooltipLabels)switch(e.value){case t.ON:return void this.tooltip.setContent({".tooltip-inner":this.tooltipLabels.on});case t.OFF:return void this.tooltip.setContent({".tooltip-inner":this.tooltipLabels.off});case t.MIXED:return void(this.tooltipLabels.mixed&&this.tooltip.setContent({".tooltip-inner":this.tooltipLabels.mixed}))}}get root(){return this.toggle}destroy(){var t,e;this.cancelPendingAnimationFrame(),this.tooltip&&(this.tooltip.dispose(),this.tooltip=void 0),null===(t=this.toggle.parentNode)||void 0===t||t.insertBefore(this.checkbox,this.toggle),this.toggle.remove(),null===(e=this.resizeObserver)||void 0===e||e.disconnect(),this.resizeObserver=void 0,this.isBuilt=!1}}function l(t,e){if(!t)return t;switch(e.mode){case s.HTML:return function(t){const e={allowedTags:["b","i","strong","em","span","small","sup","sub","img"],allowedAttributes:["class","style","src","alt","title","data-*"]},i=(new DOMParser).parseFromString(t,"text/html");return Array.from(i.body.childNodes).forEach(t=>function(t,e){const i=t=>{var s;if(t.nodeType===Node.ELEMENT_NODE){const n=t,o=n.tagName.toLowerCase();if(!e.allowedTags.includes(o)){const t=document.createDocumentFragment();return Array.from(n.childNodes).forEach(e=>{t.appendChild(e.cloneNode(!0))}),void(null===(s=n.parentNode)||void 0===s||s.replaceChild(t,n))}Array.from(n.attributes).forEach(t=>{const i=t.name.toLowerCase();e.allowedAttributes.some(t=>t.endsWith("*")?i.startsWith(t.slice(0,-1)):i===t)?function(t,e,i){if("src"!==i&&"href"!==i)return;const s=e.value.toLowerCase();(s.startsWith("javascript:")||s.startsWith("vbscript:")||s.startsWith("data:")&&!s.startsWith("data:image/"))&&t.removeAttribute(e.name)}(n,t,i):n.removeAttribute(t.name)});Array.from(n.childNodes).forEach(i)}else if(t.nodeType===Node.TEXT_NODE)return};i(t)}(t,e)),i.body.innerHTML}(t);case s.TEXT:return function(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};return t.replace(/[&<>"'/]/g,t=>e[t])}(t)}}function h(t){return/^[+-]?\d+(\.\d+)?$/.test(t.toString().trim())}!function(t){t.HTML="HTML",t.TEXT="TEXT"}(s||(s={})),function(t){t.TOP="top",t.BOTTOM="bottom",t.LEFT="left",t.RIGHT="right"}(n||(n={}));class d{static getAttr(t,e,i){const{sanitized:n=s.TEXT}=null!=i?i:{};return l(t.getAttribute(e),{mode:n})}static getAttrOrDefault(t,e,i,n,o=s.TEXT){const a="string"==typeof i?l(i,{mode:o}):i;return d.getAttr(t,e,{sanitized:o})||a||n}static getAttrOrDeprecation(t,e,i,n=s.TEXT){const o="string"==typeof i?l(i,{mode:n}):i;return d.getAttr(t,e,{sanitized:n})||o||c.value}static resolve(t,e={}){var i;const n={onlabel:this.getAttrOrDeprecation(t,"data-onlabel",e.onlabel,s.HTML),offlabel:this.getAttrOrDeprecation(t,"data-offlabel",e.offlabel,s.HTML),onstyle:this.getAttrOrDefault(t,"data-onstyle",e.onstyle,d.DEFAULT.onstyle),offstyle:this.getAttrOrDefault(t,"data-offstyle",e.offstyle,d.DEFAULT.offstyle),onvalue:this.getAttr(t,"value")||this.getAttrOrDefault(t,"data-onvalue",e.onvalue,d.DEFAULT.onvalue),offvalue:this.getAttrOrDefault(t,"data-offvalue",e.offvalue,d.DEFAULT.offvalue),ontitle:this.getAttrOrDefault(t,"data-ontitle",e.ontitle,d.getAttr(t,"title")||d.DEFAULT.ontitle),offtitle:this.getAttrOrDefault(t,"data-offtitle",e.offtitle,d.getAttr(t,"title")||d.DEFAULT.offtitle),size:this.getAttrOrDefault(t,"data-size",e.size,this.DEFAULT.size),style:this.getAttrOrDefault(t,"data-style",e.style,this.DEFAULT.style),width:this.getAttrOrDefault(t,"data-width",e.width,this.DEFAULT.width),height:this.getAttrOrDefault(t,"data-height",e.height,this.DEFAULT.height),tabindex:Number(this.getAttrOrDefault(t,"tabindex",e.tabindex,this.DEFAULT.tabindex)),tristate:t.hasAttribute("tristate")||e.tristate||d.DEFAULT.tristate,name:this.getAttrOrDefault(t,"name",e.name,this.DEFAULT.name),aria:{label:this.getAttrOrDefault(t,"aria-label",null===(i=e.aria)||void 0===i?void 0:i.label,this.DEFAULT.aria.label)},tooltip:d.resolveTooltipOptions(t,e)};return n.width&&h(n.width)&&(n.width=`${n.width}px`),n.height&&h(n.height)&&(n.height=`${n.height}px`),c.handle(n,t,e),n}static resolveTooltipOptions(t,e){var i,o,a,r;const l=(e,i)=>this.getAttrOrDefault(t,e,i,null,s.HTML)||this.getAttr(t,"data-tooltip-title",{sanitized:s.HTML}),h=l("data-tooltip-title-on",null===(i=e.tooltip)||void 0===i?void 0:i.title.on),c=l("data-tooltip-title-off",null===(o=e.tooltip)||void 0===o?void 0:o.title.off),g=l("data-tooltip-title-mixed",null===(a=e.tooltip)||void 0===a?void 0:a.title.mixed);if(!h||!c)return d.DEFAULT.tooltip;const u=this.getAttrOrDefault(t,"data-tooltip-placement",null===(r=e.tooltip)||void 0===r?void 0:r.placement,n.TOP);return{placement:Object.values(n).includes(u)?u:n.TOP,title:{on:h,off:c,mixed:null!=g?g:void 0}}}}d.DEFAULT={onlabel:"On",onstyle:"primary",onvalue:null,ontitle:null,offlabel:"Off",offstyle:"secondary",offvalue:null,offtitle:null,size:"",style:"",width:null,height:null,tabindex:0,tristate:!1,name:null,aria:{label:"Toggle"},tooltip:void 0},function(t){t.ATTRIBUTE="attribute",t.OPTION="option"}(o||(o={}));class c{static handle(t,e,i){this.deprecatedOptions.forEach(({currentOpt:s,deprecatedAttr:n,deprecatedOpt:a,mode:r})=>{if(t[s]===c.value){const h=l(e.getAttribute(n),{mode:r});h?(this.log(o.ATTRIBUTE,n,`data-${s}`),t[s]=h):i[a]?(this.log(o.OPTION,a,s),t[s]=i[a]):t[s]=d.DEFAULT[s]}})}static log(t,e,i){console.warn(`Bootstrap Toggle deprecation warning: Using ${e} ${t} is deprecated. Use ${i} instead.`)}}c.value="BOOTSTRAP TOGGLE DEPRECATION CHECK -- a0Jhux0QySypjjs4tLtEo8xT2kx0AbYaq9K6mgNjWSs0HF0L8T8J0M0o3Kr7zkm7 --",c.deprecatedOptions=[{currentOpt:"onlabel",deprecatedAttr:"data-on",deprecatedOpt:"on",mode:s.HTML},{currentOpt:"offlabel",deprecatedAttr:"data-off",deprecatedOpt:"off",mode:s.HTML}];class g{constructor(t,e){this.isTristate=e,this.state=this.getElementState(t)}getElementState(i){const s=i.checked;let n;n=i.disabled?e.DISABLED:i.readOnly?e.READONLY:e.ENABLED;const o=this.isTristate&&i.indeterminate;let a;return a=o?t.MIXED:s?t.ON:t.OFF,{value:a,checked:s,status:n,indeterminate:o}}get(){return Object.freeze(Object.assign({},this.state))}canInteract(){return this.state.status===e.ENABLED}sync(t){this.state=this.getElementState(t)}do(s){if([i.ON,i.OFF,i.TOGGLE,i.INDETERMINATE,i.DETERMINATE,i.NEXT,i.READONLY].includes(s)&&!this.canInteract())return!1;switch(s){case i.ON:return this.setValueIfChanged(t.ON,!0,!1);case i.OFF:return this.setValueIfChanged(t.OFF,!1,!1);case i.TOGGLE:return this.state.value===t.ON?this.do(i.OFF):this.state.value===t.OFF&&this.do(i.ON);case i.INDETERMINATE:return this.setValueIfChanged(t.MIXED,void 0,!0);case i.DETERMINATE:return this.state.value==t.MIXED&&this.setValue(this.state.checked?t.ON:t.OFF,this.state.checked,!1);case i.NEXT:return this.doNext();case i.DISABLE:return this.setStatusIfChanged(e.DISABLED);case i.ENABLE:return this.setStatusIfChanged(e.ENABLED);case i.READONLY:return this.setStatus(e.READONLY)}}setValue(t,e,i){return this.state=Object.assign(Object.assign({},this.state),{value:t,checked:null!=e?e:this.state.checked,indeterminate:null!=i?i:this.state.indeterminate}),!0}setValueIfChanged(t,e,i){return this.state.value!==t&&this.setValue(t,e,i)}setStatus(t){return this.state=Object.assign(Object.assign({},this.state),{status:t}),!0}setStatusIfChanged(t){return this.state.status!==t&&this.setStatus(t)}doNext(){return this.isTristate?this.state.value===t.ON||this.state.value===t.OFF?this.do(i.INDETERMINATE):this.state.value===t.MIXED&&(this.state.checked?this.do(i.OFF):this.do(i.ON)):this.state.value===t.ON?this.do(i.OFF):this.do(i.ON)}}!function(t){t.ON="toggle:on",t.OFF="toggle:off",t.MIXED="toggle:mixed",t.ENABLED="toggle:enabled",t.DISABLED="toggle:disabled",t.READONLY="toggle:readonly"}(a||(a={}));var u,p=a;class b{constructor(t,e){this.pointer=null,this.SCROLL_THRESHOLD=10,this.eventsBound=!1,this.suppressExternalSync=!1,this.originalDescriptors=new Map,this.onExternalChange=()=>{this.update()},this.onFormReset=()=>{setTimeout(()=>this.onExternalChange(),0)},this.onPointerDown=t=>{"mouse"===t.pointerType&&0!==t.button||this.stateReducer.canInteract()&&(this.pointer={x:t.clientX,y:t.clientY},this.domBuilder.root.addEventListener("pointermove",this.onPointerMove,{passive:!0}),this.domBuilder.root.addEventListener("pointerup",this.onPointerUp,{passive:!0}),this.domBuilder.root.addEventListener("pointercancel",this.onPointerCancel,{passive:!0}))},this.onPointerMove=t=>{const e=Math.abs(t.clientX-this.pointer.x);(Math.abs(t.clientY-this.pointer.y)>this.SCROLL_THRESHOLD||e>this.domBuilder.root.offsetWidth)&&this.onPointerCancel()},this.onPointerUp=t=>{if("mouse"===t.pointerType&&0!==t.button)return void this.onPointerCancel();const e=Math.abs(t.clientX-this.pointer.x);Math.abs(t.clientY-this.pointer.y)<=this.SCROLL_THRESHOLD&&e<=this.domBuilder.root.offsetWidth&&this.apply(i.NEXT),this.onPointerCancel()},this.onPointerCancel=()=>{this.domBuilder.root.removeEventListener("pointermove",this.onPointerMove),this.domBuilder.root.removeEventListener("pointerup",this.onPointerUp),this.domBuilder.root.removeEventListener("pointercancel",this.onPointerCancel)},this.handlerKeyboardEvent=t=>{" "!==t.key&&"Enter"!==t.key||(t.preventDefault(),this.apply(i.NEXT))},this.handlerLabelEvent=t=>{t.preventDefault(),this.apply(i.NEXT),this.domBuilder.root.focus()},this.element=t,this.userOptions=e,this.options=d.resolve(t,e),this.stateReducer=new g(t,this.options.tristate),this.domBuilder=new r(t,this.options,this.stateReducer.get()),this.bindEventListeners(),this.interceptInputProperties(),this.element.bsToggle=this}interceptInputProperties(){["checked","disabled","readOnly","indeterminate"].forEach(t=>{const e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.element),t);(null==e?void 0:e.set)&&(this.originalDescriptors.set(t,e),Object.defineProperty(this.element,t,{configurable:!0,get:()=>e.get.call(this.element),set:t=>{e.set.call(this.element,t),this.suppressExternalSync||this.onExternalChange()}}))})}restoreInputProperties(){this.originalDescriptors.forEach((t,e)=>{Object.defineProperty(this.element,e,t)}),this.originalDescriptors.clear()}bindEventListeners(){this.eventsBound||(this.bindFormResetListener(),this.bindPointerEventListener(),this.bindKeyboardEventListener(),this.bindLabelEventListener(),this.eventsBound=!0)}unbindEventListeners(){this.eventsBound&&(this.unbindFormResetListener(),this.unbindPointerEventListener(),this.unbindKeyboardEventListener(),this.unbindLabelEventListener(),this.eventsBound=!1)}bindFormResetListener(){const t=this.element.form;t&&t.addEventListener("reset",this.onFormReset)}unbindFormResetListener(){const t=this.element.form;t&&t.removeEventListener("reset",this.onFormReset)}bindPointerEventListener(){this.domBuilder.root.addEventListener("pointerdown",this.onPointerDown,{passive:!0})}unbindPointerEventListener(){this.domBuilder.root.removeEventListener("pointerdown",this.onPointerDown)}bindKeyboardEventListener(){this.domBuilder.root.addEventListener("keydown",this.handlerKeyboardEvent,{passive:!1})}unbindKeyboardEventListener(){this.domBuilder.root.removeEventListener("keydown",this.handlerKeyboardEvent)}bindLabelEventListener(){this.element.id&&document.querySelectorAll('label[for="'+this.element.id+'"]').forEach(t=>{t.addEventListener("click",this.handlerLabelEvent,{passive:!1})})}unbindLabelEventListener(){this.element.id&&document.querySelectorAll('label[for="'+this.element.id+'"]').forEach(t=>{t.removeEventListener("click",this.handlerLabelEvent)})}apply(t,e=!1){if(this.stateReducer.do(t)){this.suppressExternalSync=!0;try{const i=this.stateReducer.get();this.domBuilder.render(i),e||this.trigger(t,i)}finally{this.suppressExternalSync=!1}}}toggle(t=!1){this.apply(i.TOGGLE,t)}on(t=!1){this.apply(i.ON,t)}off(t=!1){this.apply(i.OFF,t)}indeterminate(t=!1){this.apply(i.INDETERMINATE,t)}determinate(t=!1){this.apply(i.DETERMINATE,t)}enable(t=!1){this.apply(i.ENABLE,t)}disable(t=!1){this.apply(i.DISABLE,t)}readonly(t=!1){this.apply(i.READONLY,t)}update(){this.suppressExternalSync=!0;try{this.stateReducer.sync(this.element),this.domBuilder.render(this.stateReducer.get())}finally{this.suppressExternalSync=!1}}trigger(t,e){this.element.dispatchEvent(new Event("change",{bubbles:!0}));const i=this.getEventForAction(t,e),s={state:e};this.element.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:s}))}getEventForAction(t,e){switch(t){case i.ON:return p.ON;case i.OFF:return p.OFF;case i.INDETERMINATE:return p.MIXED;case i.ENABLE:return p.ENABLED;case i.DISABLE:return p.DISABLED;case i.READONLY:return p.READONLY;case i.DETERMINATE:case i.TOGGLE:case i.NEXT:return this.getValueEvent(e)}}getValueEvent(e){switch(e.value){case t.ON:return p.ON;case t.OFF:return p.OFF;case t.MIXED:return p.MIXED}}destroy(){this.restoreInputProperties(),this.unbindEventListeners(),this.domBuilder.destroy(),delete this.element.bsToggle}rerender(){this.restoreInputProperties(),this.unbindEventListeners(),this.domBuilder.destroy(),this.options=d.resolve(this.element,this.userOptions),this.stateReducer=new g(this.element,this.options.tristate),this.domBuilder=new r(this.element,this.options,this.stateReducer.get()),this.bindEventListeners(),this.interceptInputProperties()}}!function(t){t.ON="on",t.OFF="off",t.TOGGLE="toggle",t.DETERMINATE="determinate",t.INDETERMINATE="indeterminate",t.ENABLE="enable",t.DISABLE="disable",t.READONLY="readonly",t.DESTROY="destroy",t.RERENDER="rerender"}(u||(u={})),function(i){globalThis.window.BootstrapToggle=globalThis.window.BootstrapToggle||{},Object.assign(globalThis.window.BootstrapToggle,{Events:p,Methods:u,StateValue:t,StateStatus:e});let s=i.fn.bootstrapToggle;i.fn.bootstrapToggle=function(t,e){return Array.prototype.slice.call(arguments,1)[0],this.each(function(){i(this);let s=this.bsToggle||new b(this,t&&"string"!=typeof t?t:{});if(t&&"string"==typeof t)switch(t.toLowerCase()){case u.TOGGLE:s.toggle(e);break;case u.ON:s.on(e);break;case u.OFF:s.off(e);break;case u.INDETERMINATE:s.indeterminate(e);break;case u.DETERMINATE:s.determinate(e);break;case u.ENABLE:s.enable(e);break;case u.DISABLE:s.disable(e);break;case u.READONLY:s.readonly(e);break;case u.DESTROY:s.destroy();break;case u.RERENDER:s.rerender()}})},i.fn.bootstrapToggle.Constructor=b,i.fn.toggle.noConflict=function(){return i.fn.bootstrapToggle=s,this},i(function(){i("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()})}(jQuery)});
//# sourceMappingURL=bootstrap5-toggle.jquery.min.js.map