bootstrap5-toggle 5.3.1 → 5.3.3

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