New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

multiple-select-vanilla

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multiple-select-vanilla - npm Package Compare versions

Comparing version 0.4.5 to 0.4.7

2

dist/cjs/multiple-select.js

@@ -25,3 +25,3 @@ "use strict";var T=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var q=(o,t,e)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var U=(o,t)=>{for(var e in t)T(o,e,{get:t[e],enumerable:!0})},K=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of G(t))!z.call(o,i)&&i!==e&&T(o,i,{get:()=>t[i],enumerable:!(s=P(t,i))||s.enumerable});return o};var V=o=>K(T({},"__esModule",{value:!0}),o);var a=(o,t,e)=>(q(o,typeof t!="symbol"?t+"":t,e),e);var tt={};U(tt,{BindingEventService:()=>A,MultipleSelectInstance:()=>L,VirtualScroll:()=>y,calculateAvailableSpace:()=>v,compareObjects:()=>k,createDomElement:()=>E,deepCopy:()=>D,findByParam:()=>g,findParent:()=>H,getElementOffset:()=>S,getElementSize:()=>b,htmlEncode:()=>x,insertAfter:()=>M,multipleSelect:()=>F,removeDiacritics:()=>f,removeUndefined:()=>C,setDataKeys:()=>w,stripScripts:()=>_,toggleElement:()=>B,toggleElementClass:()=>Q,windowScrollPosition:()=>N});module.exports=V(tt);var A=class{constructor(t){a(this,"_distinctEvent");a(this,"_boundedEvents",[]);this._distinctEvent=t?.distinctEvent??!1}get boundedEvents(){return this._boundedEvents}dispose(){this.unbindAll(),this._boundedEvents=[]}bind(t,e,s,i){let l=Array.isArray(e)?e:[e];if(t?.forEach)t?.forEach(n=>{for(let u of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(n,u))&&(n.addEventListener(u,s,i),this._boundedEvents.push({element:n,eventName:u,listener:s}))});else for(let n of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,n))&&(t.addEventListener(n,s,i),this._boundedEvents.push({element:t,eventName:n,listener:s}))}hasBinding(t,e){return this._boundedEvents.some(s=>s.element===t&&(!e||s.eventName===e))}unbind(t,e,s){if(t){let i=Array.isArray(t)?t:[t],l=Array.isArray(e)?e||"":[e||""];for(let n of i){s||(s=this._boundedEvents.find(u=>{if(u.element===n&&(!e||u.eventName===e))return u.listener}));for(let u of l)n?.removeEventListener?.(u,s)}}}unbindAll(){for(;this._boundedEvents.length>0;){let t=this._boundedEvents.pop(),{element:e,eventName:s,listener:i}=t;this.unbind(e,s,i)}}};var $=typeof window<"u"&&window.multipleSelect!==void 0?window.multipleSelect:{locales:{}};$.locales={"en-US":{formatSelectAll(){return"[Select all]"},formatAllSelected(){return"All selected"},formatCountSelected(o,t){return`${o} of ${t} selected`},formatNoMatchesFound(){return"No matches found"},formatOkButton(){return"OK"}}};var O=$.locales;var Y=50,J=4,I={name:"",placeholder:"",classes:"",classPrefix:"",data:void 0,locale:void 0,selectAll:!0,single:void 0,singleRadio:!1,multiple:!1,hideOptgroupCheckboxes:!1,multipleWidth:80,width:void 0,dropWidth:void 0,maxHeight:250,maxHeightUnit:"px",position:"bottom",displayValues:!1,displayTitle:!1,displayDelimiter:", ",minimumCountSelected:3,ellipsis:!1,isOpen:!1,keepOpen:!1,openOnHover:!1,container:null,filter:!1,filterGroup:!1,filterPlaceholder:"",filterAcceptOnEnter:!1,filterByDataLength:void 0,customFilter(o){let{text:t,label:e,search:s}=o;return(e||t||"").includes(s)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,styler:()=>!1,textTemplate:o=>o.innerHTML.trim(),labelTemplate:o=>o.label,onOpen:()=>!1,onClose:()=>!1,onCheckAll:()=>!1,onUncheckAll:()=>!1,onFocus:()=>!1,onBlur:()=>!1,onOptgroupClick:()=>!1,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},X=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(I,O["en-US"]);var Z={BLOCK_ROWS:Y,CLUSTER_BLOCKS:J,DEFAULTS:I,METHODS:X},d=Z;var y=class{constructor(t){a(this,"cache");a(this,"clusterRows");a(this,"dataStart");a(this,"dataEnd");a(this,"rows");a(this,"scrollEl");a(this,"blockHeight");a(this,"clusterHeight");a(this,"contentEl");a(this,"parentEl");a(this,"itemHeight");a(this,"lastCluster");a(this,"scrollTop");a(this,"destroy");a(this,"callback");a(this,"sanitizer");this.rows=t.rows,this.scrollEl=t.scrollEl,this.contentEl=t.contentEl,this.parentEl=t.contentEl.parentElement,this.callback=t.callback,this.cache={},this.scrollTop=this.scrollEl.scrollTop,this.initDOM(this.rows),this.scrollEl.scrollTop=this.scrollTop,this.lastCluster=0;let e=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",e,!1),this.destroy=()=>{this.contentEl.innerHTML="",this.scrollEl.removeEventListener("scroll",e,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let c=t[0]+t[0]+t[0];this.contentEl.innerHTML=this.sanitizer?this.sanitizer(`${c}`):`${c}`,this.cache.data=c,this.getRowsHeight()}let e=this.initData(t,this.getNum()),s=e.rows.join(""),i=this.checkChanges("data",s),l=this.checkChanges("top",e.topOffset),n=this.checkChanges("bottom",e.bottomOffset),u=[];i&&l?(e.topOffset&&u.push(this.getExtra("top",e.topOffset)),u.push(s),e.bottomOffset&&u.push(this.getExtra("bottom",e.bottomOffset)),this.contentEl.innerHTML=this.sanitizer?this.sanitizer(u.join("")):u.join("")):n&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${e.bottomOffset}px`)}getRowsHeight(){if(typeof this.itemHeight>"u"){let t=this.parentEl?.style.display||"";this.parentEl&&(t===""||t==="none")&&(this.parentEl.style.display="block");let e=this.contentEl.children,s=e[Math.floor(e.length/2)];this.itemHeight=s.offsetHeight,this.parentEl&&(this.parentEl.style.display=t)}this.blockHeight=this.itemHeight*d.BLOCK_ROWS,this.clusterRows=d.BLOCK_ROWS*d.CLUSTER_BLOCKS,this.clusterHeight=this.blockHeight*d.CLUSTER_BLOCKS}getNum(){this.scrollTop=this.scrollEl.scrollTop;let t=(this.clusterHeight||0)-(this.blockHeight||0);return t&&Math.floor(this.scrollTop/t)||0}initData(t,e){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let s=Math.max((this.clusterRows-d.BLOCK_ROWS)*e,0),i=s+this.clusterRows,l=Math.max(s*this.itemHeight,0),n=Math.max((t.length-i)*this.itemHeight,0),u=[],c=s;l<1&&c++;for(let r=s;r<i;r++)t[r]&&u.push(t[r]);return this.dataStart=s,this.dataEnd=i,{topOffset:l,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,e){let s=e!==this.cache[t];return this.cache[t]=e,s}getExtra(t,e){let s=document.createElement("li");return s.className=`virtual-scroll-${t}`,e&&(s.style.height=`${e}px`),s.outerHTML}};function v(o){let t=0,e=0,s=0,i=0,l=window.innerHeight??0,n=window.innerWidth??0,u=N(),c=u.top,r=u.left,h=S(o);if(h){let p=h.top??0,m=h.left??0;e=p-c,t=l-(p-c),s=m-r,i=n-(m-r)}return{top:e,bottom:t,left:s,right:i}}function E(o,t,e){let s=document.createElement(o);return t&&Object.keys(t).forEach(i=>{let l=t[i];typeof l=="object"?Object.assign(s[i],l):s[i]=t[i]}),e&&e.appendChild&&e.appendChild(s),s}function S(o){if(!o)return;let t=o?.getBoundingClientRect?.(),e=0,s=0,i=0,l=0;return t?.top!==void 0&&t.left!==void 0&&(e=t.top+window.pageYOffset,s=t.left+window.pageXOffset,l=t.right,i=t.bottom),{top:e,left:s,bottom:i,right:l}}function b(o,t,e){let s=parseFloat(o.style[e]);if(!s||isNaN(s)){switch(t){case"outer":s=o[e==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":s=o[e==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:s=o[e==="width"?"clientWidth":"clientHeight"];break}s=o.getBoundingClientRect()[e]}if(!s||isNaN(s)){let i=o.style.display,l=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[e];s=parseFloat(n),isNaN(s)&&(s=0),o.style.display=i,o.style.position=l}return s||0}function H(o,t){let e=null,s=o.parentElement;for(;s;){let[i,l,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))s.classList.contains(c)&&(l?s?.tagName.toLowerCase()===l&&(e=s):e=s);s=s.parentElement}return e}function M(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function x(o){let t=typeof o=="string"?o:String(o),e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return(t||"").toString().replace(/[&<>"']/g,s=>e[s])}function B(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function Q(o,t){if(o?.classList){let s=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[s]("selected")}}function N(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}function k(o,t,e=!1){let s=Object.keys(o),i=Object.keys(t);if(e&&s.length!==i.length)return!1;for(let l of s)if(i.includes(l)&&o[l]!==t[l])return!1;return!0}function D(o){let t=()=>{let i={};for(let l in o)Object.prototype.hasOwnProperty.call(o,l)&&(i[l]=D(o[l]));return i},e=()=>o.map(i=>D(i)),s=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return s==="object"?t():s==="array"?e():o}function w(o){let t=0;return o.forEach((e,s)=>{e.type==="optgroup"?(e._key=`group_${s}`,e.visible=typeof e.visible>"u"?!0:e.visible,e.children.forEach((i,l)=>{i&&(i.visible=typeof i?.visible>"u"?!0:i.visible,i.divider||(i._key=`option_${s}_${l}`,t+=1))})):(e.visible=typeof e.visible>"u"?!0:e.visible,e.divider||(e._key=`option_${s}`,t+=1))}),t}function g(o,t,e){if(Array.isArray(o))for(let s of o){if(s[t]===e||s[t]===`${+s[t]}`&&+s[t]===e)return s;if(s.type==="optgroup"){for(let i of s.children)if(i&&(i[t]===e||i[t]===`${+i[t]}`&&+i[t]===e))return i}}}function _(o){let t=document.createElement("div");t.innerHTML=o;let e=t.getElementsByTagName("script"),s=e.length;for(;s--;)e[s].parentNode?.removeChild(e[s]);return t.innerHTML}function C(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function f(o){return typeof o!="string"?o:o.normalize?o.normalize("NFD").replace(/[\u0300-\u036F]/g,""):[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}].reduce((e,{letters:s,base:i})=>e.replace(s,i),o)}var L=class{constructor(t,e){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"ulElm");a(this,"parentElm");a(this,"labelElm");a(this,"selectAllParentElm");a(this,"selectAllElm");a(this,"searchInputElm");a(this,"selectGroupElms");a(this,"selectItemElms");a(this,"disableItemElms");a(this,"noResultsElm");a(this,"options");a(this,"selectAllName","");a(this,"selectGroupName","");a(this,"selectItemName","");a(this,"tabIndex");a(this,"updateDataStart");a(this,"updateDataEnd");a(this,"virtualScroll");a(this,"locales",{});this.options=Object.assign({},d.DEFAULTS,this.elm.dataset,e),this._bindEventService=new A({distinctEvent:!0})}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.parentElm&&(this.options.onDestroy({hardDestroy:t}),t&&this.options.onHardDestroy(),this.elm.parentElement&&this.parentElm.parentElement&&this.elm.parentElement.insertBefore(this.elm,this.parentElm.parentElement.firstChild),this.elm.classList.remove("ms-offscreen"),this._bindEventService.unbindAll(),this.tabIndex&&(this.elm.tabIndex=+this.tabIndex),this.virtualScroll?.destroy(),this.dropElm?.remove(),this.parentElm.parentNode?.removeChild(this.parentElm),this.fromHtml&&(delete this.options.data,this.fromHtml=!1),this.options.onAfterDestroy({hardDestroy:t}),t&&(this.options.onAfterHardDestroy?.(),Object.keys(this.options).forEach(e=>delete this[e])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,e=this.options.locale.split(/-|_/);if(e[0]=e[0].toLowerCase(),e[1]&&(e[1]=e[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[e.join("-")])Object.assign(this.options,t[e.join("-")]);else if(t[e[0]])Object.assign(this.options,t[e[0]]);else throw new Error(`[multiple-select-vanilla] invalid locales "${this.options.locale}", make sure to import it before using it`)}}initContainer(){let t=this.elm.getAttribute("name")||this.options.name||"";this.options.classes&&this.elm.classList.add(this.options.classes),this.options.classPrefix&&(this.elm.classList.add(this.options.classPrefix),this.options.size&&this.elm.classList.add(`${this.options.classPrefix}-${this.options.size}`)),this.elm.style.display="none",this.labelElm=this.elm.closest("label"),!this.labelElm&&this.elm.id&&(this.labelElm=document.createElement("label"),this.labelElm.htmlFor=this.elm.id),this.labelElm?.querySelector("input")&&(this.labelElm=null),typeof this.options.single>"u"&&(this.options.single=!this.elm.multiple),this.parentElm=E("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let e=this.elm.getAttribute("title")||"";e&&(this.parentElm.title=e),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.getAttribute("tabindex");let s="";this.tabIndex!==null&&(this.elm.tabIndex=-1,s=this.tabIndex&&`tabindex="${this.tabIndex}"`),this.choiceElm=E("button",{className:"ms-choice",type:"button"},this.parentElm),isNaN(s)&&(this.choiceElm.tabIndex=+s),this.choiceElm.appendChild(E("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(E("div",{className:"icon-close"})),this.choiceElm.appendChild(E("div",{className:"icon-caret"})),this.dropElm=E("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let i=this.elm.getAttribute("data-test")||this.options.dataTest;i&&(this.parentElm.dataset.test=i,this.dropElm.dataset.test=i),this.closeElm=this.choiceElm.querySelector(".icon-close"),this.options.dropWidth&&(this.dropElm.style.width=typeof this.options.dropWidth=="string"?this.options.dropWidth:`${this.options.dropWidth}px`),M(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`data-name="selectAll${t}"`,this.selectGroupName=`data-name="selectGroup${t}"`,this.selectItemName=`data-name="selectItem${t}"`,this.options.keepOpen||(this._bindEventService.unbind(document.body,"click"),this._bindEventService.bind(document.body,"click",l=>{l.target===this.choiceElm||H(l.target,".ms-choice")===this.choiceElm||(l.target===this.dropElm||H(l.target,".ms-drop")!==this.dropElm&&l.target!==this.elm)&&this.options.isOpen&&this.close()}))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(e=>typeof e=="string"||typeof e=="number"?{text:e,value:e}:e);else if(typeof this.options.data=="object"){for(let[e,s]of Object.entries(this.options.data))t.push({value:e,text:`${s}`});this.data=t}}else this.elm.childNodes.forEach(e=>{this.initRow(e)&&t.push(this.initRow(e))}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=w(this.data||[])}initRow(t,e){let s={};return t.tagName?.toLowerCase()==="option"?(s.type="option",s.text=this.options.textTemplate(t),s.value=t.value,s.visible=!0,s.selected=!!t.selected,s.disabled=e||t.disabled,s.classes=t.getAttribute("class")||"",s.title=t.getAttribute("title")||"",t.dataset.value&&(s._value=t.dataset.value),Object.keys(t.dataset).length&&(s._data=t.dataset,s._data.divider&&(s.divider=s._data.divider)),s):t.tagName?.toLowerCase()==="optgroup"?(s.type="optgroup",s.label=this.options.labelTemplate(t),s.visible=!0,s.selected=!!t.selected,s.disabled=t.disabled,s.children=[],Object.keys(t.dataset).length&&(s._data=t.dataset),t.childNodes.forEach(i=>{s.children.push(this.initRow(i,s.disabled))}),s):null}initDrop(){this.initList(),this.update(!0),this.options.isOpen&&this.open(10),this.options.openOnHover&&this.parentElm&&(this._bindEventService.bind(this.parentElm,"mouseover",()=>this.open(null)),this._bindEventService.bind(this.parentElm,"mouseout",()=>this.close()))}initFilter(){if(this.filterText="",this.options.filter||!this.options.filterByDataLength)return;let t=0;for(let e of this.data||[])e.type==="optgroup"?t+=e.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=E("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(E("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=E("div",{className:"ms-select-all"});let e=document.createElement("label");E("input",{type:"checkbox",checked:this.allSelected,dataset:{name:`selectAll${t}`}},e),e.appendChild(E("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(e),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=E("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=this.getListRows(),e=0;if(this.options.selectAll&&!this.options.single&&(e=-1),t.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let s=this.dropElm.style.display!=="none";s||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let i=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+e,this.updateDataEnd=this.virtualScroll.dataEnd+e,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>(this.data?.length??0)&&(this.updateDataEnd=this.data?.length??0))};this.ulElm&&(this.virtualScroll=new y({rows:t,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{i(),this.events()}})),i(),s||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(this.ulElm.innerHTML=this.options.sanitizer?this.options.sanitizer(t.join("")):t.join("")),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;this.events()}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(e=>{t.push(...this.initListItem(e))}),t.push(`<li class="ms-no-results">${this.formatNoMatchesFound()}</li>`),t}initListItem(t,e=0){let s=this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml,i=t?.title?`title="${t.title}"`:"",l=this.options.multiple?"multiple":"",n=this.options.single?"radio":"checkbox",u="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(u="hide-radio "),t.selected&&(u+="selected "),t.type==="optgroup"){let h=this.options.styler(t),p=h?`style="${h}"`:"",m=[],j=this.options.hideOptgroupCheckboxes||this.options.single?`<span ${this.selectGroupName} data-key="${t._key}"></span>`:`<input type="checkbox"

</li>
`]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l&&l.selected&&!l.disabled&&l.visible).length;s.children.length&&(s.selected=!this.options.single&&i&&i===s.children.filter(l=>l&&!l.disabled&&l.visible&&!l.divider).length),e+=i}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=b(this.dropElm,"outer","width")+20)):t=b(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[${this.selectAllName}]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[${this.selectGroupName}],span[${this.selectGroupName}]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];if(this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&s.push(i)}),s.length){let[i]=this.selectItemName.split("=");s[0].hasAttribute(i)&&this.setSelects([s[0].value])}}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._checkGroup(l,i),this.options.onOptgroupClick(C({label:l.label,selected:l.selected,data:l._data,children:l.children.map(n=>{if(n)return C({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._check(l,i),this.options.onClick(C({text:l.text,value:l.value,selected:l.selected,data:l._data})),this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.data?.length||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let n=S(this.dropElm),u;this.options.container instanceof Node?u=this.options.container:typeof this.options.container=="string"&&(u=this.options.container==="body"?document.body:document.querySelector(this.options.container)),u.appendChild(this.dropElm),this.dropElm.style.top=`${n?.top??0}px`,this.dropElm.style.left=`${n?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${b(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;if(this.options.maxHeightUnit==="row"){let n=this.dropElm.querySelector("ul>li");e=b(n,"outer","height")*this.options.maxHeight}let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(n=>n.style.width=`${this.options.multipleWidth}px`),this.data?.length&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:n,top:u}=v(this.dropElm),c=this.dropElm.getBoundingClientRect().height;l=n<c&&u>n?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let i=this.choiceElm?.querySelector("span"),l=e.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?_(r):r}return s.join(this.options.displayDelimiter)};if(i){if(l===0){let r=this.options.placeholder||"";i.classList.add("ms-placeholder"),i.innerHTML=this.options.sanitizer?this.options.sanitizer(r):r}else l<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&l===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&l>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(l,this.dataTotal)&&l>this.options.minimumCountSelected?n=this.formatCountSelected(l,this.dataTotal):n=u();if(n!==null&&(i?.classList.remove("ms-placeholder"),this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml?i.innerHTML=this.options.sanitizer?this.options.sanitizer(n):n:i.textContent=n),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was replaced with `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";i.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects().join("");if(this.options.single)this.elm.value=c;else{let r=this.elm.options;for(let h=0,p=r.length;h<p;h++){let m=c.indexOf(r[h].value)>=0;r[h].selected=m}}t||this.elm.dispatchEvent(new Event("change"))}updateSelected(){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let s=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${s._key}]`);if(i){i.checked=s.selected;let l=i.closest("li");l&&(s.selected&&!l.classList.contains("selected")?l.classList.add("selected"):s.selected||l.classList.remove("selected"))}}let t=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,B(this.selectAllElm.closest("li"),!t)),B(this.noResultsElm,t),this.virtualScroll&&(this.virtualScroll.rows=this.getListRows())}getData(){return this.options.data}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?D(e):this.options}refreshOptions(t){k(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l?.selected);if(!i.length)continue;if(t==="value"||this.options.single)e.push(...i.map(l=>t==="value"&&l._value||l[t]));else{let l=[];l.push("["),l.push(s.label),l.push(`: ${i.map(n=>n[t]).join(", ")}`),l.push("]"),e.push(l.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let i=!1,l=n=>{for(let u of n){let c=!1;if(e==="text"){let r=document.createElement("div");r.innerHTML=u.text,c=t.includes(r.textContent?.trim()??"")}else c=t.includes(u._value||u.value),!c&&u.value===`${+u.value}`&&(c=t.includes(+u.value));u.selected!==c&&(i=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?l(n.children):l([n]);i&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=g(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=g(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(i=>{i&&!i.disabled&&!i.divider&&(s||i.visible)&&(i.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText!==s){this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let l=`${i?.label??""}`;if(i!=null){let n=this.options.customFilter({label:f(l.toLowerCase()),search:f(s),originalLabel:l,originalSearch:e,row:i});i.visible=n;for(let u of i.children)u&&(u.visible=n)}}else{for(let l of i.children)if(l!=null){let n=`${l?.text??""}`;l.visible=this.options.customFilter({text:f(n.toLowerCase()),search:f(s),originalText:n,originalSearch:e,row:l,parent:i})}i.visible=i.children.filter(l=>l?.visible).length>0}else{let l=`${i?.text??""}`;i.visible=this.options.customFilter({text:f(l.toLowerCase()),search:f(s),originalText:l,originalSearch:e,row:i})}this.initListItems(),this.initSelected(t),this.updateSelected(),t||this.options.onFilter(s)}}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,i=this.okButtonElm?.getBoundingClientRect().height??0,l=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+i+l+5,{bottom:u,top:c}=v(this.parentElm),r=this.options.maxHeight;if(e?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let h=this.dropElm?.querySelector("ul");return h&&(h.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:i}=v(this.dropElm),{top:l,left:n}=S(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,h=this.parentElm.getBoundingClientRect().width;if(s>u)e="bottom";else if(u>s&&i>s){if(this.options.container){let p=l-u;p<0&&(p=0),(p>0||t)&&(e="top",this.dropElm.style.top=`${p<0?0:p}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}if(r-c<n){let p=n-(c-h);this.dropElm.style.left=`${p}px`}}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),i=this.dropElm.querySelector("ul"),l=26,n=s?.clientWidth??0+l,c=i.scrollHeight>i.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(h=>{h.scrollWidth>r&&(r=h.scrollWidth)}),r+=l+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let i=s.offsetWidth;return t.parentNode?.removeChild(t),e-i}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var F=function(o,t){return typeof o=="string"?R(document.querySelectorAll(o),t):o instanceof Node?R([o],t):R(o,t)};function R(o,t){let e=Array.from(o),s=[];for(let i=0;i<e.length;i++){let l=e[i];try{l._multipleSelect!==void 0&&(l._multipleSelect.destroy(),delete l._multipleSelect),l._multipleSelect=new L(l,t||{}),l._multipleSelect.init();let n=l._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete l._multipleSelect,n.onAfterHardDestroyed=()=>s[i]=null,s.push(l._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}F.defaults=d.DEFAULTS;F.locales={...O};F.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=F);
`]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l&&l.selected&&!l.disabled&&l.visible).length;s.children.length&&(s.selected=!this.options.single&&i&&i===s.children.filter(l=>l&&!l.disabled&&l.visible&&!l.divider).length),e+=i}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=b(this.dropElm,"outer","width")+20)):t=b(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[${this.selectAllName}]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[${this.selectGroupName}],span[${this.selectGroupName}]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];if(this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&s.push(i)}),s.length){let[i]=this.selectItemName.split("=");s[0].hasAttribute(i)&&this.setSelects([s[0].value])}}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._checkGroup(l,i),this.options.onOptgroupClick(C({label:l.label,selected:l.selected,data:l._data,children:l.children.map(n=>{if(n)return C({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._check(l,i),this.options.onClick(C({text:l.text,value:l.value,selected:l.selected,data:l._data})),this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.data?.length||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let n=S(this.dropElm),u;this.options.container instanceof Node?u=this.options.container:typeof this.options.container=="string"&&(u=this.options.container==="body"?document.body:document.querySelector(this.options.container)),u.appendChild(this.dropElm),this.dropElm.style.top=`${n?.top??0}px`,this.dropElm.style.left=`${n?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${b(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;if(this.options.maxHeightUnit==="row"){let n=this.dropElm.querySelector("ul>li");e=b(n,"outer","height")*this.options.maxHeight}let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(n=>n.style.width=`${this.options.multipleWidth}px`),this.data?.length&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:n,top:u}=v(this.dropElm),c=this.dropElm.getBoundingClientRect().height;l=n<c&&u>n?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let i=this.choiceElm?.querySelector("span"),l=e.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?_(r):r}return s.join(this.options.displayDelimiter)};if(i){if(l===0){let r=this.options.placeholder||"";i.classList.add("ms-placeholder"),i.innerHTML=this.options.sanitizer?this.options.sanitizer(r):r}else l<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&l===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&l>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(l,this.dataTotal)&&l>this.options.minimumCountSelected?n=this.formatCountSelected(l,this.dataTotal):n=u();if(n!==null&&(i?.classList.remove("ms-placeholder"),this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml?i.innerHTML=this.options.sanitizer?this.options.sanitizer(n):n:i.textContent=n),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was replaced with `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";i.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects().join("");if(this.options.single)this.elm.value=c;else{let r=this.elm.options;for(let h=0,p=r.length;h<p;h++){let m=c===r[h].value;r[h].selected=m}}t||this.elm.dispatchEvent(new Event("change"))}updateSelected(){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let s=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${s._key}]`);if(i){i.checked=s.selected;let l=i.closest("li");l&&(s.selected&&!l.classList.contains("selected")?l.classList.add("selected"):s.selected||l.classList.remove("selected"))}}let t=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,B(this.selectAllElm.closest("li"),!t)),B(this.noResultsElm,t),this.virtualScroll&&(this.virtualScroll.rows=this.getListRows())}getData(){return this.options.data}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?D(e):this.options}refreshOptions(t){k(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l?.selected);if(!i.length)continue;if(t==="value"||this.options.single)e.push(...i.map(l=>t==="value"&&l._value||l[t]));else{let l=[];l.push("["),l.push(s.label),l.push(`: ${i.map(n=>n[t]).join(", ")}`),l.push("]"),e.push(l.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let i=!1,l=n=>{for(let u of n){let c=!1;if(e==="text"){let r=document.createElement("div");r.innerHTML=u.text,c=t.includes(r.textContent?.trim()??"")}else c=t.includes(u._value||u.value),!c&&u.value===`${+u.value}`&&(c=t.includes(+u.value));u.selected!==c&&(i=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?l(n.children):l([n]);i&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=g(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=g(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(i=>{i&&!i.disabled&&!i.divider&&(s||i.visible)&&(i.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText!==s){this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let l=`${i?.label??""}`;if(i!=null){let n=this.options.customFilter({label:f(l.toLowerCase()),search:f(s),originalLabel:l,originalSearch:e,row:i});i.visible=n;for(let u of i.children)u&&(u.visible=n)}}else{for(let l of i.children)if(l!=null){let n=`${l?.text??""}`;l.visible=this.options.customFilter({text:f(n.toLowerCase()),search:f(s),originalText:n,originalSearch:e,row:l,parent:i})}i.visible=i.children.filter(l=>l?.visible).length>0}else{let l=`${i?.text??""}`;i.visible=this.options.customFilter({text:f(l.toLowerCase()),search:f(s),originalText:l,originalSearch:e,row:i})}this.initListItems(),this.initSelected(t),this.updateSelected(),t||this.options.onFilter(s)}}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,i=this.okButtonElm?.getBoundingClientRect().height??0,l=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+i+l+5,{bottom:u,top:c}=v(this.parentElm),r=this.options.maxHeight;if(e?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let h=this.dropElm?.querySelector("ul");return h&&(h.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:i}=v(this.dropElm),{top:l,left:n}=S(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,h=this.parentElm.getBoundingClientRect().width;if(s>u)e="bottom";else if(u>s&&i>s){if(this.options.container){let p=l-u;p<0&&(p=0),(p>0||t)&&(e="top",this.dropElm.style.top=`${p<0?0:p}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}if(r-c<n){let p=n-(c-h);this.dropElm.style.left=`${p}px`}}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),i=this.dropElm.querySelector("ul"),l=26,n=s?.clientWidth??0+l,c=i.scrollHeight>i.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(h=>{h.scrollWidth>r&&(r=h.scrollWidth)}),r+=l+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let i=s.offsetWidth;return t.parentNode?.removeChild(t),e-i}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var F=function(o,t){return typeof o=="string"?R(document.querySelectorAll(o),t):o instanceof Node?R([o],t):R(o,t)};function R(o,t){let e=Array.from(o),s=[];for(let i=0;i<e.length;i++){let l=e[i];try{l._multipleSelect!==void 0&&(l._multipleSelect.destroy(),delete l._multipleSelect),l._multipleSelect=new L(l,t||{}),l._multipleSelect.init();let n=l._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete l._multipleSelect,n.onAfterHardDestroyed=()=>s[i]=null,s.push(l._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}F.defaults=d.DEFAULTS;F.locales={...O};F.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=F);
//# sourceMappingURL=multiple-select.js.map

@@ -25,3 +25,3 @@ var j=Object.defineProperty;var W=(o,t,e)=>t in o?j(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var a=(o,t,e)=>(W(o,typeof t!="symbol"?t+"":t,e),e);var A=class{constructor(t){a(this,"_distinctEvent");a(this,"_boundedEvents",[]);this._distinctEvent=t?.distinctEvent??!1}get boundedEvents(){return this._boundedEvents}dispose(){this.unbindAll(),this._boundedEvents=[]}bind(t,e,s,i){let l=Array.isArray(e)?e:[e];if(t?.forEach)t?.forEach(n=>{for(let u of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(n,u))&&(n.addEventListener(u,s,i),this._boundedEvents.push({element:n,eventName:u,listener:s}))});else for(let n of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,n))&&(t.addEventListener(n,s,i),this._boundedEvents.push({element:t,eventName:n,listener:s}))}hasBinding(t,e){return this._boundedEvents.some(s=>s.element===t&&(!e||s.eventName===e))}unbind(t,e,s){if(t){let i=Array.isArray(t)?t:[t],l=Array.isArray(e)?e||"":[e||""];for(let n of i){s||(s=this._boundedEvents.find(u=>{if(u.element===n&&(!e||u.eventName===e))return u.listener}));for(let u of l)n?.removeEventListener?.(u,s)}}}unbindAll(){for(;this._boundedEvents.length>0;){let t=this._boundedEvents.pop(),{element:e,eventName:s,listener:i}=t;this.unbind(e,s,i)}}};var M=typeof window<"u"&&window.multipleSelect!==void 0?window.multipleSelect:{locales:{}};M.locales={"en-US":{formatSelectAll(){return"[Select all]"},formatAllSelected(){return"All selected"},formatCountSelected(o,t){return`${o} of ${t} selected`},formatNoMatchesFound(){return"No matches found"},formatOkButton(){return"OK"}}};var y=M.locales;var P=50,G=4,k={name:"",placeholder:"",classes:"",classPrefix:"",data:void 0,locale:void 0,selectAll:!0,single:void 0,singleRadio:!1,multiple:!1,hideOptgroupCheckboxes:!1,multipleWidth:80,width:void 0,dropWidth:void 0,maxHeight:250,maxHeightUnit:"px",position:"bottom",displayValues:!1,displayTitle:!1,displayDelimiter:", ",minimumCountSelected:3,ellipsis:!1,isOpen:!1,keepOpen:!1,openOnHover:!1,container:null,filter:!1,filterGroup:!1,filterPlaceholder:"",filterAcceptOnEnter:!1,filterByDataLength:void 0,customFilter(o){let{text:t,label:e,search:s}=o;return(e||t||"").includes(s)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,styler:()=>!1,textTemplate:o=>o.innerHTML.trim(),labelTemplate:o=>o.label,onOpen:()=>!1,onClose:()=>!1,onCheckAll:()=>!1,onUncheckAll:()=>!1,onFocus:()=>!1,onBlur:()=>!1,onOptgroupClick:()=>!1,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},z=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(k,y["en-US"]);var q={BLOCK_ROWS:P,CLUSTER_BLOCKS:G,DEFAULTS:k,METHODS:z},d=q;var v=class{constructor(t){a(this,"cache");a(this,"clusterRows");a(this,"dataStart");a(this,"dataEnd");a(this,"rows");a(this,"scrollEl");a(this,"blockHeight");a(this,"clusterHeight");a(this,"contentEl");a(this,"parentEl");a(this,"itemHeight");a(this,"lastCluster");a(this,"scrollTop");a(this,"destroy");a(this,"callback");a(this,"sanitizer");this.rows=t.rows,this.scrollEl=t.scrollEl,this.contentEl=t.contentEl,this.parentEl=t.contentEl.parentElement,this.callback=t.callback,this.cache={},this.scrollTop=this.scrollEl.scrollTop,this.initDOM(this.rows),this.scrollEl.scrollTop=this.scrollTop,this.lastCluster=0;let e=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",e,!1),this.destroy=()=>{this.contentEl.innerHTML="",this.scrollEl.removeEventListener("scroll",e,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let c=t[0]+t[0]+t[0];this.contentEl.innerHTML=this.sanitizer?this.sanitizer(`${c}`):`${c}`,this.cache.data=c,this.getRowsHeight()}let e=this.initData(t,this.getNum()),s=e.rows.join(""),i=this.checkChanges("data",s),l=this.checkChanges("top",e.topOffset),n=this.checkChanges("bottom",e.bottomOffset),u=[];i&&l?(e.topOffset&&u.push(this.getExtra("top",e.topOffset)),u.push(s),e.bottomOffset&&u.push(this.getExtra("bottom",e.bottomOffset)),this.contentEl.innerHTML=this.sanitizer?this.sanitizer(u.join("")):u.join("")):n&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${e.bottomOffset}px`)}getRowsHeight(){if(typeof this.itemHeight>"u"){let t=this.parentEl?.style.display||"";this.parentEl&&(t===""||t==="none")&&(this.parentEl.style.display="block");let e=this.contentEl.children,s=e[Math.floor(e.length/2)];this.itemHeight=s.offsetHeight,this.parentEl&&(this.parentEl.style.display=t)}this.blockHeight=this.itemHeight*d.BLOCK_ROWS,this.clusterRows=d.BLOCK_ROWS*d.CLUSTER_BLOCKS,this.clusterHeight=this.blockHeight*d.CLUSTER_BLOCKS}getNum(){this.scrollTop=this.scrollEl.scrollTop;let t=(this.clusterHeight||0)-(this.blockHeight||0);return t&&Math.floor(this.scrollTop/t)||0}initData(t,e){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let s=Math.max((this.clusterRows-d.BLOCK_ROWS)*e,0),i=s+this.clusterRows,l=Math.max(s*this.itemHeight,0),n=Math.max((t.length-i)*this.itemHeight,0),u=[],c=s;l<1&&c++;for(let r=s;r<i;r++)t[r]&&u.push(t[r]);return this.dataStart=s,this.dataEnd=i,{topOffset:l,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,e){let s=e!==this.cache[t];return this.cache[t]=e,s}getExtra(t,e){let s=document.createElement("li");return s.className=`virtual-scroll-${t}`,e&&(s.style.height=`${e}px`),s.outerHTML}};function S(o){let t=0,e=0,s=0,i=0,l=window.innerHeight??0,n=window.innerWidth??0,u=U(),c=u.top,r=u.left,h=D(o);if(h){let p=h.top??0,m=h.left??0;e=p-c,t=l-(p-c),s=m-r,i=n-(m-r)}return{top:e,bottom:t,left:s,right:i}}function E(o,t,e){let s=document.createElement(o);return t&&Object.keys(t).forEach(i=>{let l=t[i];typeof l=="object"?Object.assign(s[i],l):s[i]=t[i]}),e&&e.appendChild&&e.appendChild(s),s}function D(o){if(!o)return;let t=o?.getBoundingClientRect?.(),e=0,s=0,i=0,l=0;return t?.top!==void 0&&t.left!==void 0&&(e=t.top+window.pageYOffset,s=t.left+window.pageXOffset,l=t.right,i=t.bottom),{top:e,left:s,bottom:i,right:l}}function b(o,t,e){let s=parseFloat(o.style[e]);if(!s||isNaN(s)){switch(t){case"outer":s=o[e==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":s=o[e==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:s=o[e==="width"?"clientWidth":"clientHeight"];break}s=o.getBoundingClientRect()[e]}if(!s||isNaN(s)){let i=o.style.display,l=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[e];s=parseFloat(n),isNaN(s)&&(s=0),o.style.display=i,o.style.position=l}return s||0}function O(o,t){let e=null,s=o.parentElement;for(;s;){let[i,l,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))s.classList.contains(c)&&(l?s?.tagName.toLowerCase()===l&&(e=s):e=s);s=s.parentElement}return e}function w(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function H(o){let t=typeof o=="string"?o:String(o),e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return(t||"").toString().replace(/[&<>"']/g,s=>e[s])}function x(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function ut(o,t){if(o?.classList){let s=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[s]("selected")}}function U(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}function _(o,t,e=!1){let s=Object.keys(o),i=Object.keys(t);if(e&&s.length!==i.length)return!1;for(let l of s)if(i.includes(l)&&o[l]!==t[l])return!1;return!0}function C(o){let t=()=>{let i={};for(let l in o)Object.prototype.hasOwnProperty.call(o,l)&&(i[l]=C(o[l]));return i},e=()=>o.map(i=>C(i)),s=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return s==="object"?t():s==="array"?e():o}function R(o){let t=0;return o.forEach((e,s)=>{e.type==="optgroup"?(e._key=`group_${s}`,e.visible=typeof e.visible>"u"?!0:e.visible,e.children.forEach((i,l)=>{i&&(i.visible=typeof i?.visible>"u"?!0:i.visible,i.divider||(i._key=`option_${s}_${l}`,t+=1))})):(e.visible=typeof e.visible>"u"?!0:e.visible,e.divider||(e._key=`option_${s}`,t+=1))}),t}function g(o,t,e){if(Array.isArray(o))for(let s of o){if(s[t]===e||s[t]===`${+s[t]}`&&+s[t]===e)return s;if(s.type==="optgroup"){for(let i of s.children)if(i&&(i[t]===e||i[t]===`${+i[t]}`&&+i[t]===e))return i}}}function $(o){let t=document.createElement("div");t.innerHTML=o;let e=t.getElementsByTagName("script"),s=e.length;for(;s--;)e[s].parentNode?.removeChild(e[s]);return t.innerHTML}function L(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function f(o){return typeof o!="string"?o:o.normalize?o.normalize("NFD").replace(/[\u0300-\u036F]/g,""):[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}].reduce((e,{letters:s,base:i})=>e.replace(s,i),o)}var F=class{constructor(t,e){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"ulElm");a(this,"parentElm");a(this,"labelElm");a(this,"selectAllParentElm");a(this,"selectAllElm");a(this,"searchInputElm");a(this,"selectGroupElms");a(this,"selectItemElms");a(this,"disableItemElms");a(this,"noResultsElm");a(this,"options");a(this,"selectAllName","");a(this,"selectGroupName","");a(this,"selectItemName","");a(this,"tabIndex");a(this,"updateDataStart");a(this,"updateDataEnd");a(this,"virtualScroll");a(this,"locales",{});this.options=Object.assign({},d.DEFAULTS,this.elm.dataset,e),this._bindEventService=new A({distinctEvent:!0})}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.parentElm&&(this.options.onDestroy({hardDestroy:t}),t&&this.options.onHardDestroy(),this.elm.parentElement&&this.parentElm.parentElement&&this.elm.parentElement.insertBefore(this.elm,this.parentElm.parentElement.firstChild),this.elm.classList.remove("ms-offscreen"),this._bindEventService.unbindAll(),this.tabIndex&&(this.elm.tabIndex=+this.tabIndex),this.virtualScroll?.destroy(),this.dropElm?.remove(),this.parentElm.parentNode?.removeChild(this.parentElm),this.fromHtml&&(delete this.options.data,this.fromHtml=!1),this.options.onAfterDestroy({hardDestroy:t}),t&&(this.options.onAfterHardDestroy?.(),Object.keys(this.options).forEach(e=>delete this[e])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,e=this.options.locale.split(/-|_/);if(e[0]=e[0].toLowerCase(),e[1]&&(e[1]=e[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[e.join("-")])Object.assign(this.options,t[e.join("-")]);else if(t[e[0]])Object.assign(this.options,t[e[0]]);else throw new Error(`[multiple-select-vanilla] invalid locales "${this.options.locale}", make sure to import it before using it`)}}initContainer(){let t=this.elm.getAttribute("name")||this.options.name||"";this.options.classes&&this.elm.classList.add(this.options.classes),this.options.classPrefix&&(this.elm.classList.add(this.options.classPrefix),this.options.size&&this.elm.classList.add(`${this.options.classPrefix}-${this.options.size}`)),this.elm.style.display="none",this.labelElm=this.elm.closest("label"),!this.labelElm&&this.elm.id&&(this.labelElm=document.createElement("label"),this.labelElm.htmlFor=this.elm.id),this.labelElm?.querySelector("input")&&(this.labelElm=null),typeof this.options.single>"u"&&(this.options.single=!this.elm.multiple),this.parentElm=E("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let e=this.elm.getAttribute("title")||"";e&&(this.parentElm.title=e),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.getAttribute("tabindex");let s="";this.tabIndex!==null&&(this.elm.tabIndex=-1,s=this.tabIndex&&`tabindex="${this.tabIndex}"`),this.choiceElm=E("button",{className:"ms-choice",type:"button"},this.parentElm),isNaN(s)&&(this.choiceElm.tabIndex=+s),this.choiceElm.appendChild(E("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(E("div",{className:"icon-close"})),this.choiceElm.appendChild(E("div",{className:"icon-caret"})),this.dropElm=E("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let i=this.elm.getAttribute("data-test")||this.options.dataTest;i&&(this.parentElm.dataset.test=i,this.dropElm.dataset.test=i),this.closeElm=this.choiceElm.querySelector(".icon-close"),this.options.dropWidth&&(this.dropElm.style.width=typeof this.options.dropWidth=="string"?this.options.dropWidth:`${this.options.dropWidth}px`),w(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`data-name="selectAll${t}"`,this.selectGroupName=`data-name="selectGroup${t}"`,this.selectItemName=`data-name="selectItem${t}"`,this.options.keepOpen||(this._bindEventService.unbind(document.body,"click"),this._bindEventService.bind(document.body,"click",l=>{l.target===this.choiceElm||O(l.target,".ms-choice")===this.choiceElm||(l.target===this.dropElm||O(l.target,".ms-drop")!==this.dropElm&&l.target!==this.elm)&&this.options.isOpen&&this.close()}))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(e=>typeof e=="string"||typeof e=="number"?{text:e,value:e}:e);else if(typeof this.options.data=="object"){for(let[e,s]of Object.entries(this.options.data))t.push({value:e,text:`${s}`});this.data=t}}else this.elm.childNodes.forEach(e=>{this.initRow(e)&&t.push(this.initRow(e))}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=R(this.data||[])}initRow(t,e){let s={};return t.tagName?.toLowerCase()==="option"?(s.type="option",s.text=this.options.textTemplate(t),s.value=t.value,s.visible=!0,s.selected=!!t.selected,s.disabled=e||t.disabled,s.classes=t.getAttribute("class")||"",s.title=t.getAttribute("title")||"",t.dataset.value&&(s._value=t.dataset.value),Object.keys(t.dataset).length&&(s._data=t.dataset,s._data.divider&&(s.divider=s._data.divider)),s):t.tagName?.toLowerCase()==="optgroup"?(s.type="optgroup",s.label=this.options.labelTemplate(t),s.visible=!0,s.selected=!!t.selected,s.disabled=t.disabled,s.children=[],Object.keys(t.dataset).length&&(s._data=t.dataset),t.childNodes.forEach(i=>{s.children.push(this.initRow(i,s.disabled))}),s):null}initDrop(){this.initList(),this.update(!0),this.options.isOpen&&this.open(10),this.options.openOnHover&&this.parentElm&&(this._bindEventService.bind(this.parentElm,"mouseover",()=>this.open(null)),this._bindEventService.bind(this.parentElm,"mouseout",()=>this.close()))}initFilter(){if(this.filterText="",this.options.filter||!this.options.filterByDataLength)return;let t=0;for(let e of this.data||[])e.type==="optgroup"?t+=e.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=E("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(E("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=E("div",{className:"ms-select-all"});let e=document.createElement("label");E("input",{type:"checkbox",checked:this.allSelected,dataset:{name:`selectAll${t}`}},e),e.appendChild(E("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(e),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=E("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=this.getListRows(),e=0;if(this.options.selectAll&&!this.options.single&&(e=-1),t.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let s=this.dropElm.style.display!=="none";s||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let i=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+e,this.updateDataEnd=this.virtualScroll.dataEnd+e,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>(this.data?.length??0)&&(this.updateDataEnd=this.data?.length??0))};this.ulElm&&(this.virtualScroll=new v({rows:t,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{i(),this.events()}})),i(),s||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(this.ulElm.innerHTML=this.options.sanitizer?this.options.sanitizer(t.join("")):t.join("")),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;this.events()}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(e=>{t.push(...this.initListItem(e))}),t.push(`<li class="ms-no-results">${this.formatNoMatchesFound()}</li>`),t}initListItem(t,e=0){let s=this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml,i=t?.title?`title="${t.title}"`:"",l=this.options.multiple?"multiple":"",n=this.options.single?"radio":"checkbox",u="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(u="hide-radio "),t.selected&&(u+="selected "),t.type==="optgroup"){let h=this.options.styler(t),p=h?`style="${h}"`:"",m=[],I=this.options.hideOptgroupCheckboxes||this.options.single?`<span ${this.selectGroupName} data-key="${t._key}"></span>`:`<input type="checkbox"

</li>
`]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l&&l.selected&&!l.disabled&&l.visible).length;s.children.length&&(s.selected=!this.options.single&&i&&i===s.children.filter(l=>l&&!l.disabled&&l.visible&&!l.divider).length),e+=i}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=b(this.dropElm,"outer","width")+20)):t=b(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[${this.selectAllName}]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[${this.selectGroupName}],span[${this.selectGroupName}]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];if(this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&s.push(i)}),s.length){let[i]=this.selectItemName.split("=");s[0].hasAttribute(i)&&this.setSelects([s[0].value])}}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._checkGroup(l,i),this.options.onOptgroupClick(L({label:l.label,selected:l.selected,data:l._data,children:l.children.map(n=>{if(n)return L({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._check(l,i),this.options.onClick(L({text:l.text,value:l.value,selected:l.selected,data:l._data})),this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.data?.length||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let n=D(this.dropElm),u;this.options.container instanceof Node?u=this.options.container:typeof this.options.container=="string"&&(u=this.options.container==="body"?document.body:document.querySelector(this.options.container)),u.appendChild(this.dropElm),this.dropElm.style.top=`${n?.top??0}px`,this.dropElm.style.left=`${n?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${b(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;if(this.options.maxHeightUnit==="row"){let n=this.dropElm.querySelector("ul>li");e=b(n,"outer","height")*this.options.maxHeight}let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(n=>n.style.width=`${this.options.multipleWidth}px`),this.data?.length&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:n,top:u}=S(this.dropElm),c=this.dropElm.getBoundingClientRect().height;l=n<c&&u>n?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let i=this.choiceElm?.querySelector("span"),l=e.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?$(r):r}return s.join(this.options.displayDelimiter)};if(i){if(l===0){let r=this.options.placeholder||"";i.classList.add("ms-placeholder"),i.innerHTML=this.options.sanitizer?this.options.sanitizer(r):r}else l<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&l===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&l>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(l,this.dataTotal)&&l>this.options.minimumCountSelected?n=this.formatCountSelected(l,this.dataTotal):n=u();if(n!==null&&(i?.classList.remove("ms-placeholder"),this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml?i.innerHTML=this.options.sanitizer?this.options.sanitizer(n):n:i.textContent=n),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was replaced with `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";i.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects().join("");if(this.options.single)this.elm.value=c;else{let r=this.elm.options;for(let h=0,p=r.length;h<p;h++){let m=c.indexOf(r[h].value)>=0;r[h].selected=m}}t||this.elm.dispatchEvent(new Event("change"))}updateSelected(){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let s=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${s._key}]`);if(i){i.checked=s.selected;let l=i.closest("li");l&&(s.selected&&!l.classList.contains("selected")?l.classList.add("selected"):s.selected||l.classList.remove("selected"))}}let t=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,x(this.selectAllElm.closest("li"),!t)),x(this.noResultsElm,t),this.virtualScroll&&(this.virtualScroll.rows=this.getListRows())}getData(){return this.options.data}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?C(e):this.options}refreshOptions(t){_(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l?.selected);if(!i.length)continue;if(t==="value"||this.options.single)e.push(...i.map(l=>t==="value"&&l._value||l[t]));else{let l=[];l.push("["),l.push(s.label),l.push(`: ${i.map(n=>n[t]).join(", ")}`),l.push("]"),e.push(l.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let i=!1,l=n=>{for(let u of n){let c=!1;if(e==="text"){let r=document.createElement("div");r.innerHTML=u.text,c=t.includes(r.textContent?.trim()??"")}else c=t.includes(u._value||u.value),!c&&u.value===`${+u.value}`&&(c=t.includes(+u.value));u.selected!==c&&(i=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?l(n.children):l([n]);i&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=g(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=g(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(i=>{i&&!i.disabled&&!i.divider&&(s||i.visible)&&(i.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText!==s){this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let l=`${i?.label??""}`;if(i!=null){let n=this.options.customFilter({label:f(l.toLowerCase()),search:f(s),originalLabel:l,originalSearch:e,row:i});i.visible=n;for(let u of i.children)u&&(u.visible=n)}}else{for(let l of i.children)if(l!=null){let n=`${l?.text??""}`;l.visible=this.options.customFilter({text:f(n.toLowerCase()),search:f(s),originalText:n,originalSearch:e,row:l,parent:i})}i.visible=i.children.filter(l=>l?.visible).length>0}else{let l=`${i?.text??""}`;i.visible=this.options.customFilter({text:f(l.toLowerCase()),search:f(s),originalText:l,originalSearch:e,row:i})}this.initListItems(),this.initSelected(t),this.updateSelected(),t||this.options.onFilter(s)}}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,i=this.okButtonElm?.getBoundingClientRect().height??0,l=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+i+l+5,{bottom:u,top:c}=S(this.parentElm),r=this.options.maxHeight;if(e?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let h=this.dropElm?.querySelector("ul");return h&&(h.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:i}=S(this.dropElm),{top:l,left:n}=D(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,h=this.parentElm.getBoundingClientRect().width;if(s>u)e="bottom";else if(u>s&&i>s){if(this.options.container){let p=l-u;p<0&&(p=0),(p>0||t)&&(e="top",this.dropElm.style.top=`${p<0?0:p}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}if(r-c<n){let p=n-(c-h);this.dropElm.style.left=`${p}px`}}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),i=this.dropElm.querySelector("ul"),l=26,n=s?.clientWidth??0+l,c=i.scrollHeight>i.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(h=>{h.scrollWidth>r&&(r=h.scrollWidth)}),r+=l+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let i=s.offsetWidth;return t.parentNode?.removeChild(t),e-i}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var T=function(o,t){return typeof o=="string"?B(document.querySelectorAll(o),t):o instanceof Node?B([o],t):B(o,t)};function B(o,t){let e=Array.from(o),s=[];for(let i=0;i<e.length;i++){let l=e[i];try{l._multipleSelect!==void 0&&(l._multipleSelect.destroy(),delete l._multipleSelect),l._multipleSelect=new F(l,t||{}),l._multipleSelect.init();let n=l._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete l._multipleSelect,n.onAfterHardDestroyed=()=>s[i]=null,s.push(l._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}T.defaults=d.DEFAULTS;T.locales={...y};T.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=T);export{A as BindingEventService,F as MultipleSelectInstance,v as VirtualScroll,S as calculateAvailableSpace,_ as compareObjects,E as createDomElement,C as deepCopy,g as findByParam,O as findParent,D as getElementOffset,b as getElementSize,H as htmlEncode,w as insertAfter,T as multipleSelect,f as removeDiacritics,L as removeUndefined,R as setDataKeys,$ as stripScripts,x as toggleElement,ut as toggleElementClass,U as windowScrollPosition};
`]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l&&l.selected&&!l.disabled&&l.visible).length;s.children.length&&(s.selected=!this.options.single&&i&&i===s.children.filter(l=>l&&!l.disabled&&l.visible&&!l.divider).length),e+=i}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=b(this.dropElm,"outer","width")+20)):t=b(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[${this.selectAllName}]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[${this.selectGroupName}],span[${this.selectGroupName}]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];if(this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&s.push(i)}),s.length){let[i]=this.selectItemName.split("=");s[0].hasAttribute(i)&&this.setSelects([s[0].value])}}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._checkGroup(l,i),this.options.onOptgroupClick(L({label:l.label,selected:l.selected,data:l._data,children:l.children.map(n=>{if(n)return L({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._check(l,i),this.options.onClick(L({text:l.text,value:l.value,selected:l.selected,data:l._data})),this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.data?.length||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let n=D(this.dropElm),u;this.options.container instanceof Node?u=this.options.container:typeof this.options.container=="string"&&(u=this.options.container==="body"?document.body:document.querySelector(this.options.container)),u.appendChild(this.dropElm),this.dropElm.style.top=`${n?.top??0}px`,this.dropElm.style.left=`${n?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${b(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;if(this.options.maxHeightUnit==="row"){let n=this.dropElm.querySelector("ul>li");e=b(n,"outer","height")*this.options.maxHeight}let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(n=>n.style.width=`${this.options.multipleWidth}px`),this.data?.length&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:n,top:u}=S(this.dropElm),c=this.dropElm.getBoundingClientRect().height;l=n<c&&u>n?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let i=this.choiceElm?.querySelector("span"),l=e.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?$(r):r}return s.join(this.options.displayDelimiter)};if(i){if(l===0){let r=this.options.placeholder||"";i.classList.add("ms-placeholder"),i.innerHTML=this.options.sanitizer?this.options.sanitizer(r):r}else l<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&l===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&l>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(l,this.dataTotal)&&l>this.options.minimumCountSelected?n=this.formatCountSelected(l,this.dataTotal):n=u();if(n!==null&&(i?.classList.remove("ms-placeholder"),this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml?i.innerHTML=this.options.sanitizer?this.options.sanitizer(n):n:i.textContent=n),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was replaced with `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";i.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects().join("");if(this.options.single)this.elm.value=c;else{let r=this.elm.options;for(let h=0,p=r.length;h<p;h++){let m=c===r[h].value;r[h].selected=m}}t||this.elm.dispatchEvent(new Event("change"))}updateSelected(){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let s=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${s._key}]`);if(i){i.checked=s.selected;let l=i.closest("li");l&&(s.selected&&!l.classList.contains("selected")?l.classList.add("selected"):s.selected||l.classList.remove("selected"))}}let t=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,x(this.selectAllElm.closest("li"),!t)),x(this.noResultsElm,t),this.virtualScroll&&(this.virtualScroll.rows=this.getListRows())}getData(){return this.options.data}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?C(e):this.options}refreshOptions(t){_(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l?.selected);if(!i.length)continue;if(t==="value"||this.options.single)e.push(...i.map(l=>t==="value"&&l._value||l[t]));else{let l=[];l.push("["),l.push(s.label),l.push(`: ${i.map(n=>n[t]).join(", ")}`),l.push("]"),e.push(l.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let i=!1,l=n=>{for(let u of n){let c=!1;if(e==="text"){let r=document.createElement("div");r.innerHTML=u.text,c=t.includes(r.textContent?.trim()??"")}else c=t.includes(u._value||u.value),!c&&u.value===`${+u.value}`&&(c=t.includes(+u.value));u.selected!==c&&(i=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?l(n.children):l([n]);i&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=g(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=g(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(i=>{i&&!i.disabled&&!i.divider&&(s||i.visible)&&(i.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText!==s){this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let l=`${i?.label??""}`;if(i!=null){let n=this.options.customFilter({label:f(l.toLowerCase()),search:f(s),originalLabel:l,originalSearch:e,row:i});i.visible=n;for(let u of i.children)u&&(u.visible=n)}}else{for(let l of i.children)if(l!=null){let n=`${l?.text??""}`;l.visible=this.options.customFilter({text:f(n.toLowerCase()),search:f(s),originalText:n,originalSearch:e,row:l,parent:i})}i.visible=i.children.filter(l=>l?.visible).length>0}else{let l=`${i?.text??""}`;i.visible=this.options.customFilter({text:f(l.toLowerCase()),search:f(s),originalText:l,originalSearch:e,row:i})}this.initListItems(),this.initSelected(t),this.updateSelected(),t||this.options.onFilter(s)}}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,i=this.okButtonElm?.getBoundingClientRect().height??0,l=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+i+l+5,{bottom:u,top:c}=S(this.parentElm),r=this.options.maxHeight;if(e?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let h=this.dropElm?.querySelector("ul");return h&&(h.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:i}=S(this.dropElm),{top:l,left:n}=D(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,h=this.parentElm.getBoundingClientRect().width;if(s>u)e="bottom";else if(u>s&&i>s){if(this.options.container){let p=l-u;p<0&&(p=0),(p>0||t)&&(e="top",this.dropElm.style.top=`${p<0?0:p}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}if(r-c<n){let p=n-(c-h);this.dropElm.style.left=`${p}px`}}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),i=this.dropElm.querySelector("ul"),l=26,n=s?.clientWidth??0+l,c=i.scrollHeight>i.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(h=>{h.scrollWidth>r&&(r=h.scrollWidth)}),r+=l+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let i=s.offsetWidth;return t.parentNode?.removeChild(t),e-i}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var T=function(o,t){return typeof o=="string"?B(document.querySelectorAll(o),t):o instanceof Node?B([o],t):B(o,t)};function B(o,t){let e=Array.from(o),s=[];for(let i=0;i<e.length;i++){let l=e[i];try{l._multipleSelect!==void 0&&(l._multipleSelect.destroy(),delete l._multipleSelect),l._multipleSelect=new F(l,t||{}),l._multipleSelect.init();let n=l._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete l._multipleSelect,n.onAfterHardDestroyed=()=>s[i]=null,s.push(l._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}T.defaults=d.DEFAULTS;T.locales={...y};T.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=T);export{A as BindingEventService,F as MultipleSelectInstance,v as VirtualScroll,S as calculateAvailableSpace,_ as compareObjects,E as createDomElement,C as deepCopy,g as findByParam,O as findParent,D as getElementOffset,b as getElementSize,H as htmlEncode,w as insertAfter,T as multipleSelect,f as removeDiacritics,L as removeUndefined,R as setDataKeys,$ as stripScripts,x as toggleElement,ut as toggleElementClass,U as windowScrollPosition};
//# sourceMappingURL=multiple-select.js.map

@@ -25,3 +25,3 @@ "use strict";var MultipleSelect=(()=>{var T=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var q=(o,t,e)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var U=(o,t)=>{for(var e in t)T(o,e,{get:t[e],enumerable:!0})},K=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of G(t))!z.call(o,i)&&i!==e&&T(o,i,{get:()=>t[i],enumerable:!(s=P(t,i))||s.enumerable});return o};var V=o=>K(T({},"__esModule",{value:!0}),o);var a=(o,t,e)=>(q(o,typeof t!="symbol"?t+"":t,e),e);var tt={};U(tt,{BindingEventService:()=>A,MultipleSelectInstance:()=>L,VirtualScroll:()=>y,calculateAvailableSpace:()=>v,compareObjects:()=>k,createDomElement:()=>E,deepCopy:()=>D,findByParam:()=>g,findParent:()=>H,getElementOffset:()=>S,getElementSize:()=>b,htmlEncode:()=>x,insertAfter:()=>M,multipleSelect:()=>F,removeDiacritics:()=>f,removeUndefined:()=>C,setDataKeys:()=>w,stripScripts:()=>_,toggleElement:()=>B,toggleElementClass:()=>Q,windowScrollPosition:()=>N});var A=class{constructor(t){a(this,"_distinctEvent");a(this,"_boundedEvents",[]);this._distinctEvent=t?.distinctEvent??!1}get boundedEvents(){return this._boundedEvents}dispose(){this.unbindAll(),this._boundedEvents=[]}bind(t,e,s,i){let l=Array.isArray(e)?e:[e];if(t?.forEach)t?.forEach(n=>{for(let u of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(n,u))&&(n.addEventListener(u,s,i),this._boundedEvents.push({element:n,eventName:u,listener:s}))});else for(let n of l)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,n))&&(t.addEventListener(n,s,i),this._boundedEvents.push({element:t,eventName:n,listener:s}))}hasBinding(t,e){return this._boundedEvents.some(s=>s.element===t&&(!e||s.eventName===e))}unbind(t,e,s){if(t){let i=Array.isArray(t)?t:[t],l=Array.isArray(e)?e||"":[e||""];for(let n of i){s||(s=this._boundedEvents.find(u=>{if(u.element===n&&(!e||u.eventName===e))return u.listener}));for(let u of l)n?.removeEventListener?.(u,s)}}}unbindAll(){for(;this._boundedEvents.length>0;){let t=this._boundedEvents.pop(),{element:e,eventName:s,listener:i}=t;this.unbind(e,s,i)}}};var $=typeof window<"u"&&window.multipleSelect!==void 0?window.multipleSelect:{locales:{}};$.locales={"en-US":{formatSelectAll(){return"[Select all]"},formatAllSelected(){return"All selected"},formatCountSelected(o,t){return`${o} of ${t} selected`},formatNoMatchesFound(){return"No matches found"},formatOkButton(){return"OK"}}};var O=$.locales;var Y=50,J=4,I={name:"",placeholder:"",classes:"",classPrefix:"",data:void 0,locale:void 0,selectAll:!0,single:void 0,singleRadio:!1,multiple:!1,hideOptgroupCheckboxes:!1,multipleWidth:80,width:void 0,dropWidth:void 0,maxHeight:250,maxHeightUnit:"px",position:"bottom",displayValues:!1,displayTitle:!1,displayDelimiter:", ",minimumCountSelected:3,ellipsis:!1,isOpen:!1,keepOpen:!1,openOnHover:!1,container:null,filter:!1,filterGroup:!1,filterPlaceholder:"",filterAcceptOnEnter:!1,filterByDataLength:void 0,customFilter(o){let{text:t,label:e,search:s}=o;return(e||t||"").includes(s)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,styler:()=>!1,textTemplate:o=>o.innerHTML.trim(),labelTemplate:o=>o.label,onOpen:()=>!1,onClose:()=>!1,onCheckAll:()=>!1,onUncheckAll:()=>!1,onFocus:()=>!1,onBlur:()=>!1,onOptgroupClick:()=>!1,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},X=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(I,O["en-US"]);var Z={BLOCK_ROWS:Y,CLUSTER_BLOCKS:J,DEFAULTS:I,METHODS:X},d=Z;var y=class{constructor(t){a(this,"cache");a(this,"clusterRows");a(this,"dataStart");a(this,"dataEnd");a(this,"rows");a(this,"scrollEl");a(this,"blockHeight");a(this,"clusterHeight");a(this,"contentEl");a(this,"parentEl");a(this,"itemHeight");a(this,"lastCluster");a(this,"scrollTop");a(this,"destroy");a(this,"callback");a(this,"sanitizer");this.rows=t.rows,this.scrollEl=t.scrollEl,this.contentEl=t.contentEl,this.parentEl=t.contentEl.parentElement,this.callback=t.callback,this.cache={},this.scrollTop=this.scrollEl.scrollTop,this.initDOM(this.rows),this.scrollEl.scrollTop=this.scrollTop,this.lastCluster=0;let e=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",e,!1),this.destroy=()=>{this.contentEl.innerHTML="",this.scrollEl.removeEventListener("scroll",e,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let c=t[0]+t[0]+t[0];this.contentEl.innerHTML=this.sanitizer?this.sanitizer(`${c}`):`${c}`,this.cache.data=c,this.getRowsHeight()}let e=this.initData(t,this.getNum()),s=e.rows.join(""),i=this.checkChanges("data",s),l=this.checkChanges("top",e.topOffset),n=this.checkChanges("bottom",e.bottomOffset),u=[];i&&l?(e.topOffset&&u.push(this.getExtra("top",e.topOffset)),u.push(s),e.bottomOffset&&u.push(this.getExtra("bottom",e.bottomOffset)),this.contentEl.innerHTML=this.sanitizer?this.sanitizer(u.join("")):u.join("")):n&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${e.bottomOffset}px`)}getRowsHeight(){if(typeof this.itemHeight>"u"){let t=this.parentEl?.style.display||"";this.parentEl&&(t===""||t==="none")&&(this.parentEl.style.display="block");let e=this.contentEl.children,s=e[Math.floor(e.length/2)];this.itemHeight=s.offsetHeight,this.parentEl&&(this.parentEl.style.display=t)}this.blockHeight=this.itemHeight*d.BLOCK_ROWS,this.clusterRows=d.BLOCK_ROWS*d.CLUSTER_BLOCKS,this.clusterHeight=this.blockHeight*d.CLUSTER_BLOCKS}getNum(){this.scrollTop=this.scrollEl.scrollTop;let t=(this.clusterHeight||0)-(this.blockHeight||0);return t&&Math.floor(this.scrollTop/t)||0}initData(t,e){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let s=Math.max((this.clusterRows-d.BLOCK_ROWS)*e,0),i=s+this.clusterRows,l=Math.max(s*this.itemHeight,0),n=Math.max((t.length-i)*this.itemHeight,0),u=[],c=s;l<1&&c++;for(let r=s;r<i;r++)t[r]&&u.push(t[r]);return this.dataStart=s,this.dataEnd=i,{topOffset:l,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,e){let s=e!==this.cache[t];return this.cache[t]=e,s}getExtra(t,e){let s=document.createElement("li");return s.className=`virtual-scroll-${t}`,e&&(s.style.height=`${e}px`),s.outerHTML}};function v(o){let t=0,e=0,s=0,i=0,l=window.innerHeight??0,n=window.innerWidth??0,u=N(),c=u.top,r=u.left,h=S(o);if(h){let p=h.top??0,m=h.left??0;e=p-c,t=l-(p-c),s=m-r,i=n-(m-r)}return{top:e,bottom:t,left:s,right:i}}function E(o,t,e){let s=document.createElement(o);return t&&Object.keys(t).forEach(i=>{let l=t[i];typeof l=="object"?Object.assign(s[i],l):s[i]=t[i]}),e&&e.appendChild&&e.appendChild(s),s}function S(o){if(!o)return;let t=o?.getBoundingClientRect?.(),e=0,s=0,i=0,l=0;return t?.top!==void 0&&t.left!==void 0&&(e=t.top+window.pageYOffset,s=t.left+window.pageXOffset,l=t.right,i=t.bottom),{top:e,left:s,bottom:i,right:l}}function b(o,t,e){let s=parseFloat(o.style[e]);if(!s||isNaN(s)){switch(t){case"outer":s=o[e==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":s=o[e==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:s=o[e==="width"?"clientWidth":"clientHeight"];break}s=o.getBoundingClientRect()[e]}if(!s||isNaN(s)){let i=o.style.display,l=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[e];s=parseFloat(n),isNaN(s)&&(s=0),o.style.display=i,o.style.position=l}return s||0}function H(o,t){let e=null,s=o.parentElement;for(;s;){let[i,l,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))s.classList.contains(c)&&(l?s?.tagName.toLowerCase()===l&&(e=s):e=s);s=s.parentElement}return e}function M(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function x(o){let t=typeof o=="string"?o:String(o),e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return(t||"").toString().replace(/[&<>"']/g,s=>e[s])}function B(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function Q(o,t){if(o?.classList){let s=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[s]("selected")}}function N(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}function k(o,t,e=!1){let s=Object.keys(o),i=Object.keys(t);if(e&&s.length!==i.length)return!1;for(let l of s)if(i.includes(l)&&o[l]!==t[l])return!1;return!0}function D(o){let t=()=>{let i={};for(let l in o)Object.prototype.hasOwnProperty.call(o,l)&&(i[l]=D(o[l]));return i},e=()=>o.map(i=>D(i)),s=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return s==="object"?t():s==="array"?e():o}function w(o){let t=0;return o.forEach((e,s)=>{e.type==="optgroup"?(e._key=`group_${s}`,e.visible=typeof e.visible>"u"?!0:e.visible,e.children.forEach((i,l)=>{i&&(i.visible=typeof i?.visible>"u"?!0:i.visible,i.divider||(i._key=`option_${s}_${l}`,t+=1))})):(e.visible=typeof e.visible>"u"?!0:e.visible,e.divider||(e._key=`option_${s}`,t+=1))}),t}function g(o,t,e){if(Array.isArray(o))for(let s of o){if(s[t]===e||s[t]===`${+s[t]}`&&+s[t]===e)return s;if(s.type==="optgroup"){for(let i of s.children)if(i&&(i[t]===e||i[t]===`${+i[t]}`&&+i[t]===e))return i}}}function _(o){let t=document.createElement("div");t.innerHTML=o;let e=t.getElementsByTagName("script"),s=e.length;for(;s--;)e[s].parentNode?.removeChild(e[s]);return t.innerHTML}function C(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function f(o){return typeof o!="string"?o:o.normalize?o.normalize("NFD").replace(/[\u0300-\u036F]/g,""):[{base:"A",letters:/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},{base:"AA",letters:/[\uA732]/g},{base:"AE",letters:/[\u00C6\u01FC\u01E2]/g},{base:"AO",letters:/[\uA734]/g},{base:"AU",letters:/[\uA736]/g},{base:"AV",letters:/[\uA738\uA73A]/g},{base:"AY",letters:/[\uA73C]/g},{base:"B",letters:/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},{base:"C",letters:/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},{base:"D",letters:/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},{base:"DZ",letters:/[\u01F1\u01C4]/g},{base:"Dz",letters:/[\u01F2\u01C5]/g},{base:"E",letters:/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},{base:"F",letters:/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},{base:"G",letters:/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},{base:"H",letters:/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},{base:"I",letters:/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},{base:"J",letters:/[\u004A\u24BF\uFF2A\u0134\u0248]/g},{base:"K",letters:/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},{base:"L",letters:/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},{base:"LJ",letters:/[\u01C7]/g},{base:"Lj",letters:/[\u01C8]/g},{base:"M",letters:/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},{base:"N",letters:/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},{base:"NJ",letters:/[\u01CA]/g},{base:"Nj",letters:/[\u01CB]/g},{base:"O",letters:/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},{base:"OI",letters:/[\u01A2]/g},{base:"OO",letters:/[\uA74E]/g},{base:"OU",letters:/[\u0222]/g},{base:"P",letters:/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},{base:"Q",letters:/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},{base:"R",letters:/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},{base:"S",letters:/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},{base:"T",letters:/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},{base:"TZ",letters:/[\uA728]/g},{base:"U",letters:/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},{base:"V",letters:/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},{base:"VY",letters:/[\uA760]/g},{base:"W",letters:/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},{base:"X",letters:/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},{base:"Y",letters:/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},{base:"Z",letters:/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},{base:"a",letters:/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},{base:"aa",letters:/[\uA733]/g},{base:"ae",letters:/[\u00E6\u01FD\u01E3]/g},{base:"ao",letters:/[\uA735]/g},{base:"au",letters:/[\uA737]/g},{base:"av",letters:/[\uA739\uA73B]/g},{base:"ay",letters:/[\uA73D]/g},{base:"b",letters:/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},{base:"c",letters:/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},{base:"d",letters:/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},{base:"dz",letters:/[\u01F3\u01C6]/g},{base:"e",letters:/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},{base:"f",letters:/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},{base:"g",letters:/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},{base:"h",letters:/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},{base:"hv",letters:/[\u0195]/g},{base:"i",letters:/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},{base:"j",letters:/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},{base:"k",letters:/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},{base:"l",letters:/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},{base:"lj",letters:/[\u01C9]/g},{base:"m",letters:/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},{base:"n",letters:/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},{base:"nj",letters:/[\u01CC]/g},{base:"o",letters:/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},{base:"oi",letters:/[\u01A3]/g},{base:"ou",letters:/[\u0223]/g},{base:"oo",letters:/[\uA74F]/g},{base:"p",letters:/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},{base:"q",letters:/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},{base:"r",letters:/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},{base:"s",letters:/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},{base:"t",letters:/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},{base:"tz",letters:/[\uA729]/g},{base:"u",letters:/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},{base:"v",letters:/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},{base:"vy",letters:/[\uA761]/g},{base:"w",letters:/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},{base:"x",letters:/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},{base:"y",letters:/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},{base:"z",letters:/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}].reduce((e,{letters:s,base:i})=>e.replace(s,i),o)}var L=class{constructor(t,e){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"ulElm");a(this,"parentElm");a(this,"labelElm");a(this,"selectAllParentElm");a(this,"selectAllElm");a(this,"searchInputElm");a(this,"selectGroupElms");a(this,"selectItemElms");a(this,"disableItemElms");a(this,"noResultsElm");a(this,"options");a(this,"selectAllName","");a(this,"selectGroupName","");a(this,"selectItemName","");a(this,"tabIndex");a(this,"updateDataStart");a(this,"updateDataEnd");a(this,"virtualScroll");a(this,"locales",{});this.options=Object.assign({},d.DEFAULTS,this.elm.dataset,e),this._bindEventService=new A({distinctEvent:!0})}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.parentElm&&(this.options.onDestroy({hardDestroy:t}),t&&this.options.onHardDestroy(),this.elm.parentElement&&this.parentElm.parentElement&&this.elm.parentElement.insertBefore(this.elm,this.parentElm.parentElement.firstChild),this.elm.classList.remove("ms-offscreen"),this._bindEventService.unbindAll(),this.tabIndex&&(this.elm.tabIndex=+this.tabIndex),this.virtualScroll?.destroy(),this.dropElm?.remove(),this.parentElm.parentNode?.removeChild(this.parentElm),this.fromHtml&&(delete this.options.data,this.fromHtml=!1),this.options.onAfterDestroy({hardDestroy:t}),t&&(this.options.onAfterHardDestroy?.(),Object.keys(this.options).forEach(e=>delete this[e])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,e=this.options.locale.split(/-|_/);if(e[0]=e[0].toLowerCase(),e[1]&&(e[1]=e[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[e.join("-")])Object.assign(this.options,t[e.join("-")]);else if(t[e[0]])Object.assign(this.options,t[e[0]]);else throw new Error(`[multiple-select-vanilla] invalid locales "${this.options.locale}", make sure to import it before using it`)}}initContainer(){let t=this.elm.getAttribute("name")||this.options.name||"";this.options.classes&&this.elm.classList.add(this.options.classes),this.options.classPrefix&&(this.elm.classList.add(this.options.classPrefix),this.options.size&&this.elm.classList.add(`${this.options.classPrefix}-${this.options.size}`)),this.elm.style.display="none",this.labelElm=this.elm.closest("label"),!this.labelElm&&this.elm.id&&(this.labelElm=document.createElement("label"),this.labelElm.htmlFor=this.elm.id),this.labelElm?.querySelector("input")&&(this.labelElm=null),typeof this.options.single>"u"&&(this.options.single=!this.elm.multiple),this.parentElm=E("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let e=this.elm.getAttribute("title")||"";e&&(this.parentElm.title=e),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.getAttribute("tabindex");let s="";this.tabIndex!==null&&(this.elm.tabIndex=-1,s=this.tabIndex&&`tabindex="${this.tabIndex}"`),this.choiceElm=E("button",{className:"ms-choice",type:"button"},this.parentElm),isNaN(s)&&(this.choiceElm.tabIndex=+s),this.choiceElm.appendChild(E("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(E("div",{className:"icon-close"})),this.choiceElm.appendChild(E("div",{className:"icon-caret"})),this.dropElm=E("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let i=this.elm.getAttribute("data-test")||this.options.dataTest;i&&(this.parentElm.dataset.test=i,this.dropElm.dataset.test=i),this.closeElm=this.choiceElm.querySelector(".icon-close"),this.options.dropWidth&&(this.dropElm.style.width=typeof this.options.dropWidth=="string"?this.options.dropWidth:`${this.options.dropWidth}px`),M(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`data-name="selectAll${t}"`,this.selectGroupName=`data-name="selectGroup${t}"`,this.selectItemName=`data-name="selectItem${t}"`,this.options.keepOpen||(this._bindEventService.unbind(document.body,"click"),this._bindEventService.bind(document.body,"click",l=>{l.target===this.choiceElm||H(l.target,".ms-choice")===this.choiceElm||(l.target===this.dropElm||H(l.target,".ms-drop")!==this.dropElm&&l.target!==this.elm)&&this.options.isOpen&&this.close()}))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(e=>typeof e=="string"||typeof e=="number"?{text:e,value:e}:e);else if(typeof this.options.data=="object"){for(let[e,s]of Object.entries(this.options.data))t.push({value:e,text:`${s}`});this.data=t}}else this.elm.childNodes.forEach(e=>{this.initRow(e)&&t.push(this.initRow(e))}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=w(this.data||[])}initRow(t,e){let s={};return t.tagName?.toLowerCase()==="option"?(s.type="option",s.text=this.options.textTemplate(t),s.value=t.value,s.visible=!0,s.selected=!!t.selected,s.disabled=e||t.disabled,s.classes=t.getAttribute("class")||"",s.title=t.getAttribute("title")||"",t.dataset.value&&(s._value=t.dataset.value),Object.keys(t.dataset).length&&(s._data=t.dataset,s._data.divider&&(s.divider=s._data.divider)),s):t.tagName?.toLowerCase()==="optgroup"?(s.type="optgroup",s.label=this.options.labelTemplate(t),s.visible=!0,s.selected=!!t.selected,s.disabled=t.disabled,s.children=[],Object.keys(t.dataset).length&&(s._data=t.dataset),t.childNodes.forEach(i=>{s.children.push(this.initRow(i,s.disabled))}),s):null}initDrop(){this.initList(),this.update(!0),this.options.isOpen&&this.open(10),this.options.openOnHover&&this.parentElm&&(this._bindEventService.bind(this.parentElm,"mouseover",()=>this.open(null)),this._bindEventService.bind(this.parentElm,"mouseout",()=>this.close()))}initFilter(){if(this.filterText="",this.options.filter||!this.options.filterByDataLength)return;let t=0;for(let e of this.data||[])e.type==="optgroup"?t+=e.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=E("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(E("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=E("div",{className:"ms-select-all"});let e=document.createElement("label");E("input",{type:"checkbox",checked:this.allSelected,dataset:{name:`selectAll${t}`}},e),e.appendChild(E("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(e),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=E("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=this.getListRows(),e=0;if(this.options.selectAll&&!this.options.single&&(e=-1),t.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let s=this.dropElm.style.display!=="none";s||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let i=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+e,this.updateDataEnd=this.virtualScroll.dataEnd+e,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>(this.data?.length??0)&&(this.updateDataEnd=this.data?.length??0))};this.ulElm&&(this.virtualScroll=new y({rows:t,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{i(),this.events()}})),i(),s||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(this.ulElm.innerHTML=this.options.sanitizer?this.options.sanitizer(t.join("")):t.join("")),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;this.events()}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(e=>{t.push(...this.initListItem(e))}),t.push(`<li class="ms-no-results">${this.formatNoMatchesFound()}</li>`),t}initListItem(t,e=0){let s=this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml,i=t?.title?`title="${t.title}"`:"",l=this.options.multiple?"multiple":"",n=this.options.single?"radio":"checkbox",u="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(u="hide-radio "),t.selected&&(u+="selected "),t.type==="optgroup"){let h=this.options.styler(t),p=h?`style="${h}"`:"",m=[],j=this.options.hideOptgroupCheckboxes||this.options.single?`<span ${this.selectGroupName} data-key="${t._key}"></span>`:`<input type="checkbox"

</li>
`]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l&&l.selected&&!l.disabled&&l.visible).length;s.children.length&&(s.selected=!this.options.single&&i&&i===s.children.filter(l=>l&&!l.disabled&&l.visible&&!l.divider).length),e+=i}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=b(this.dropElm,"outer","width")+20)):t=b(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[${this.selectAllName}]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[${this.selectGroupName}],span[${this.selectGroupName}]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];if(this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&s.push(i)}),s.length){let[i]=this.selectItemName.split("=");s[0].hasAttribute(i)&&this.setSelects([s[0].value])}}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._checkGroup(l,i),this.options.onOptgroupClick(C({label:l.label,selected:l.selected,data:l._data,children:l.children.map(n=>{if(n)return C({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._check(l,i),this.options.onClick(C({text:l.text,value:l.value,selected:l.selected,data:l._data})),this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.data?.length||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let n=S(this.dropElm),u;this.options.container instanceof Node?u=this.options.container:typeof this.options.container=="string"&&(u=this.options.container==="body"?document.body:document.querySelector(this.options.container)),u.appendChild(this.dropElm),this.dropElm.style.top=`${n?.top??0}px`,this.dropElm.style.left=`${n?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${b(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;if(this.options.maxHeightUnit==="row"){let n=this.dropElm.querySelector("ul>li");e=b(n,"outer","height")*this.options.maxHeight}let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(n=>n.style.width=`${this.options.multipleWidth}px`),this.data?.length&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:n,top:u}=v(this.dropElm),c=this.dropElm.getBoundingClientRect().height;l=n<c&&u>n?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let i=this.choiceElm?.querySelector("span"),l=e.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?_(r):r}return s.join(this.options.displayDelimiter)};if(i){if(l===0){let r=this.options.placeholder||"";i.classList.add("ms-placeholder"),i.innerHTML=this.options.sanitizer?this.options.sanitizer(r):r}else l<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&l===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&l>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(l,this.dataTotal)&&l>this.options.minimumCountSelected?n=this.formatCountSelected(l,this.dataTotal):n=u();if(n!==null&&(i?.classList.remove("ms-placeholder"),this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml?i.innerHTML=this.options.sanitizer?this.options.sanitizer(n):n:i.textContent=n),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was replaced with `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";i.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects().join("");if(this.options.single)this.elm.value=c;else{let r=this.elm.options;for(let h=0,p=r.length;h<p;h++){let m=c.indexOf(r[h].value)>=0;r[h].selected=m}}t||this.elm.dispatchEvent(new Event("change"))}updateSelected(){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let s=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${s._key}]`);if(i){i.checked=s.selected;let l=i.closest("li");l&&(s.selected&&!l.classList.contains("selected")?l.classList.add("selected"):s.selected||l.classList.remove("selected"))}}let t=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,B(this.selectAllElm.closest("li"),!t)),B(this.noResultsElm,t),this.virtualScroll&&(this.virtualScroll.rows=this.getListRows())}getData(){return this.options.data}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?D(e):this.options}refreshOptions(t){k(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l?.selected);if(!i.length)continue;if(t==="value"||this.options.single)e.push(...i.map(l=>t==="value"&&l._value||l[t]));else{let l=[];l.push("["),l.push(s.label),l.push(`: ${i.map(n=>n[t]).join(", ")}`),l.push("]"),e.push(l.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let i=!1,l=n=>{for(let u of n){let c=!1;if(e==="text"){let r=document.createElement("div");r.innerHTML=u.text,c=t.includes(r.textContent?.trim()??"")}else c=t.includes(u._value||u.value),!c&&u.value===`${+u.value}`&&(c=t.includes(+u.value));u.selected!==c&&(i=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?l(n.children):l([n]);i&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=g(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=g(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(i=>{i&&!i.disabled&&!i.divider&&(s||i.visible)&&(i.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText!==s){this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let l=`${i?.label??""}`;if(i!=null){let n=this.options.customFilter({label:f(l.toLowerCase()),search:f(s),originalLabel:l,originalSearch:e,row:i});i.visible=n;for(let u of i.children)u&&(u.visible=n)}}else{for(let l of i.children)if(l!=null){let n=`${l?.text??""}`;l.visible=this.options.customFilter({text:f(n.toLowerCase()),search:f(s),originalText:n,originalSearch:e,row:l,parent:i})}i.visible=i.children.filter(l=>l?.visible).length>0}else{let l=`${i?.text??""}`;i.visible=this.options.customFilter({text:f(l.toLowerCase()),search:f(s),originalText:l,originalSearch:e,row:i})}this.initListItems(),this.initSelected(t),this.updateSelected(),t||this.options.onFilter(s)}}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,i=this.okButtonElm?.getBoundingClientRect().height??0,l=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+i+l+5,{bottom:u,top:c}=v(this.parentElm),r=this.options.maxHeight;if(e?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let h=this.dropElm?.querySelector("ul");return h&&(h.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:i}=v(this.dropElm),{top:l,left:n}=S(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,h=this.parentElm.getBoundingClientRect().width;if(s>u)e="bottom";else if(u>s&&i>s){if(this.options.container){let p=l-u;p<0&&(p=0),(p>0||t)&&(e="top",this.dropElm.style.top=`${p<0?0:p}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}if(r-c<n){let p=n-(c-h);this.dropElm.style.left=`${p}px`}}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),i=this.dropElm.querySelector("ul"),l=26,n=s?.clientWidth??0+l,c=i.scrollHeight>i.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(h=>{h.scrollWidth>r&&(r=h.scrollWidth)}),r+=l+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let i=s.offsetWidth;return t.parentNode?.removeChild(t),e-i}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var F=function(o,t){return typeof o=="string"?R(document.querySelectorAll(o),t):o instanceof Node?R([o],t):R(o,t)};function R(o,t){let e=Array.from(o),s=[];for(let i=0;i<e.length;i++){let l=e[i];try{l._multipleSelect!==void 0&&(l._multipleSelect.destroy(),delete l._multipleSelect),l._multipleSelect=new L(l,t||{}),l._multipleSelect.init();let n=l._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete l._multipleSelect,n.onAfterHardDestroyed=()=>s[i]=null,s.push(l._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}F.defaults=d.DEFAULTS;F.locales={...O};F.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=F);return V(tt);})();
`]}initSelected(t=!1){let e=0;for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l&&l.selected&&!l.disabled&&l.visible).length;s.children.length&&(s.selected=!this.options.single&&i&&i===s.children.filter(l=>l&&!l.disabled&&l.visible&&!l.divider).length),e+=i}else e+=s.selected&&!s.disabled&&s.visible?1:0;this.allSelected=this.data?.filter(s=>s.selected&&!s.disabled&&s.visible).length===this.data?.filter(s=>!s.disabled&&s.visible&&!s.divider).length,t||(this.allSelected?this.options.onCheckAll():e===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=b(this.dropElm,"outer","width")+20)):t=b(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbind(this.okButtonElm),this._bindEventService.unbind(this.searchInputElm),this._bindEventService.unbind(this.selectAllElm),this._bindEventService.unbind(this.selectGroupElms),this._bindEventService.unbind(this.selectItemElms),this._bindEventService.unbind(this.disableItemElms),this._bindEventService.unbind(this.noResultsElm),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[${this.selectAllName}]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[${this.selectGroupName}],span[${this.selectGroupName}]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:enabled`),this.disableItemElms=this.dropElm.querySelectorAll(`input[${this.selectItemName}]:disabled`),this.noResultsElm=this.dropElm.querySelector(".ms-no-results");let t=e=>{e.preventDefault(),!e.target.classList.contains("icon-close")&&this[this.options.isOpen?"close":"open"]()};this.labelElm&&this._bindEventService.bind(this.labelElm,"click",e=>{e.target.nodeName.toLowerCase()==="label"&&(t(e),(!this.options.filter||!this.options.isOpen)&&this.focus(),e.stopPropagation())}),this._bindEventService.bind(this.choiceElm,"click",t),this.options.onFocus&&this._bindEventService.bind(this.choiceElm,"focus",this.options.onFocus),this.options.onBlur&&this._bindEventService.bind(this.choiceElm,"blur",this.options.onBlur),this._bindEventService.bind(this.parentElm,"keydown",e=>{e.code==="Escape"&&!this.options.keepOpen&&(this.close(),this.choiceElm.focus())}),this.closeElm&&this._bindEventService.bind(this.closeElm,"click",e=>{e.preventDefault(),this._checkAll(!1,!0),this.initSelected(!1),this.updateSelected(),this.update(),this.options.onClear()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()}),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let s=[];if(this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&s.push(i)}),s.length){let[i]=this.selectItemName.split("=");s[0].hasAttribute(i)&&this.setSelects([s[0].value])}}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()})),this.selectAllElm&&(this._bindEventService.unbind(this.selectAllElm,"click"),this._bindEventService.bind(this.selectAllElm,"click",e=>{this._checkAll(e.currentTarget?.checked)})),this.okButtonElm&&(this._bindEventService.unbind(this.okButtonElm,"click"),this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()})),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._checkGroup(l,i),this.options.onOptgroupClick(C({label:l.label,selected:l.selected,data:l._data,children:l.children.map(n=>{if(n)return C({text:n.text,value:n.value,selected:n.selected,disabled:n.disabled,data:n._data})})}))}),this._bindEventService.bind(this.selectItemElms,"click",e=>{let s=e.currentTarget,i=s.checked,l=g(this.data,"_key",s.dataset.key);this._check(l,i),this.options.onClick(C({text:l.text,value:l.value,selected:l.selected,data:l._data})),this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()})}open(t=0){if(t!==null&&t>=0){let e;clearTimeout(e),e=setTimeout(()=>this.openDrop(),t)}else this.openDrop()}openDrop(){if(this.choiceElm?.classList.contains("disabled"))return;if(this.options.isOpen=!0,this.parentElm.classList.add("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.add("open"),this.dropElm.style.display="block",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.data?.length||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let n=S(this.dropElm),u;this.options.container instanceof Node?u=this.options.container:typeof this.options.container=="string"&&(u=this.options.container==="body"?document.body:document.querySelector(this.options.container)),u.appendChild(this.dropElm),this.dropElm.style.top=`${n?.top??0}px`,this.dropElm.style.left=`${n?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${b(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,e=this.options.maxHeight;if(this.options.maxHeightUnit==="row"){let n=this.dropElm.querySelector("ul>li");e=b(n,"outer","height")*this.options.maxHeight}let s=this.dropElm.querySelector("ul");s&&(t&&(s.style.minHeight=`${t}px`),s.style.maxHeight=`${e}px`),this.dropElm.querySelectorAll(".multiple").forEach(n=>n.style.width=`${this.options.multipleWidth}px`),this.data?.length&&this.options.filter&&(this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter(!0)),this.options.autoAdjustDropWidthByTextSize&&this.adjustDropWidthByText();let l=this.options.position;if(this.options.autoAdjustDropHeight){if(this.options.autoAdjustDropPosition){let{bottom:n,top:u}=v(this.dropElm),c=this.dropElm.getBoundingClientRect().height;l=n<c&&u>n?"top":"bottom"}this.adjustDropHeight(l)}this.options.autoAdjustDropPosition&&this.adjustDropPosition(!0),this.options.onOpen()}close(){this.options.isOpen=!1,this.parentElm.classList.remove("ms-parent-open"),this.choiceElm?.querySelector("div")?.classList.remove("open"),this.dropElm.style.display="none",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}update(t=!1){let e=this.getSelects(),s=this.getSelects("text");this.options.displayValues&&(s=e);let i=this.choiceElm?.querySelector("span"),l=e.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=e.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?_(r):r}return s.join(this.options.displayDelimiter)};if(i){if(l===0){let r=this.options.placeholder||"";i.classList.add("ms-placeholder"),i.innerHTML=this.options.sanitizer?this.options.sanitizer(r):r}else l<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&l===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&l>this.options.minimumCountSelected?n=`${s.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(l,this.dataTotal)&&l>this.options.minimumCountSelected?n=this.formatCountSelected(l,this.dataTotal):n=u();if(n!==null&&(i?.classList.remove("ms-placeholder"),this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml?i.innerHTML=this.options.sanitizer?this.options.sanitizer(n):n:i.textContent=n),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was replaced with `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";i.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects().join("");if(this.options.single)this.elm.value=c;else{let r=this.elm.options;for(let h=0,p=r.length;h<p;h++){let m=c===r[h].value;r[h].selected=m}}t||this.elm.dispatchEvent(new Event("change"))}updateSelected(){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let s=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${s._key}]`);if(i){i.checked=s.selected;let l=i.closest("li");l&&(s.selected&&!l.classList.contains("selected")?l.classList.add("selected"):s.selected||l.classList.remove("selected"))}}let t=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,B(this.selectAllElm.closest("li"),!t)),B(this.noResultsElm,t),this.virtualScroll&&(this.virtualScroll.rows=this.getListRows())}getData(){return this.options.data}getOptions(t=!0){let e=Object.assign({},this.options);return delete e.data,t?D(e):this.options}refreshOptions(t){k(this.options,t,!0)||(this.options=Object.assign(this.options,t),this.destroy(!1),this.init())}getDropElement(){return this.dropElm}getParentElement(){return this.parentElm}getSelects(t="value"){let e=[];for(let s of this.data||[])if(s.type==="optgroup"){let i=s.children.filter(l=>l?.selected);if(!i.length)continue;if(t==="value"||this.options.single)e.push(...i.map(l=>t==="value"&&l._value||l[t]));else{let l=[];l.push("["),l.push(s.label),l.push(`: ${i.map(n=>n[t]).join(", ")}`),l.push("]"),e.push(l.join(""))}}else s.selected&&e.push(t==="value"&&s._value||s[t]);return e}setSelects(t,e="value",s=!1){let i=!1,l=n=>{for(let u of n){let c=!1;if(e==="text"){let r=document.createElement("div");r.innerHTML=u.text,c=t.includes(r.textContent?.trim()??"")}else c=t.includes(u._value||u.value),!c&&u.value===`${+u.value}`&&(c=t.includes(+u.value));u.selected!==c&&(i=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?l(n.children):l([n]);i&&(this.initSelected(s),this.updateSelected(),this.update(s))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let e=g(this.data,"value",t);e&&this._check(e,!0)}uncheck(t){let e=g(this.data,"value",t);e&&this._check(e,!1)}_check(t,e){this.options.single&&this._checkAll(!1,!0),t.selected=e,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,e){for(let s of this.data||[])s.type==="optgroup"?this._checkGroup(s,t,!0):!s.disabled&&!s.divider&&(e||s.visible)&&(s.selected=t);e||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,e,s){t.selected=e,t.children.forEach(i=>{i&&!i.disabled&&!i.divider&&(s||i.visible)&&(i.selected=e)}),s||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let e of t.children)e&&(e.divider||(e.selected=!e.selected));else t&&!t.divider&&(t.selected=!t.selected);this.initSelected(),this.updateSelected(),this.update()}}focus(){this.choiceElm?.focus(),this.options.onFocus()}blur(){this.choiceElm?.blur(),this.options.onBlur()}refresh(){this.destroy(!1),this.init()}filter(t){let e=this.searchInputElm?.value.trim()??"",s=e.toLowerCase();if(this.filterText!==s){this.filterText=s;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let l=`${i?.label??""}`;if(i!=null){let n=this.options.customFilter({label:f(l.toLowerCase()),search:f(s),originalLabel:l,originalSearch:e,row:i});i.visible=n;for(let u of i.children)u&&(u.visible=n)}}else{for(let l of i.children)if(l!=null){let n=`${l?.text??""}`;l.visible=this.options.customFilter({text:f(n.toLowerCase()),search:f(s),originalText:n,originalSearch:e,row:l,parent:i})}i.visible=i.children.filter(l=>l?.visible).length>0}else{let l=`${i?.text??""}`;i.visible=this.options.customFilter({text:f(l.toLowerCase()),search:f(s),originalText:l,originalSearch:e,row:i})}this.initListItems(),this.initSelected(t),this.updateSelected(),t||this.options.onFilter(s)}}adjustDropHeight(t){let e=t!=="top",s=this.filterParentElm?.getBoundingClientRect().height??0,i=this.okButtonElm?.getBoundingClientRect().height??0,l=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=s+i+l+5,{bottom:u,top:c}=v(this.parentElm),r=this.options.maxHeight;if(e?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let h=this.dropElm?.querySelector("ul");return h&&(h.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let e="bottom";if(this.dropElm&&this.parentElm){let{bottom:s,top:i}=v(this.dropElm),{top:l,left:n}=S(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,h=this.parentElm.getBoundingClientRect().width;if(s>u)e="bottom";else if(u>s&&i>s){if(this.options.container){let p=l-u;p<0&&(p=0),(p>0||t)&&(e="top",this.dropElm.style.top=`${p<0?0:p}px`)}else e="top",this.dropElm.classList.add(e);this.dropElm.classList.remove("bottom")}if(r-c<n){let p=n-(c-h);this.dropElm.style.left=`${p}px`}}return e}adjustDropWidthByText(){let e=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(e=this.options.dropWidth||this.options.width||0);let s=this.dropElm.querySelector(".ms-select-all span"),i=this.dropElm.querySelector("ul"),l=26,n=s?.clientWidth??0+l,c=i.scrollHeight>i.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(h=>{h.scrollWidth>r&&(r=h.scrollWidth)}),r+=l+c,r<n&&(r=n),this.options.maxWidth&&r>this.options.maxWidth&&(r=this.options.maxWidth),this.options.minWidth&&r<this.options.minWidth&&(r=this.options.minWidth),(e==="100%"||+e<r)&&(this.dropElm.style.width=`${r}px`,this.dropElm.style.maxWidth=`${r}px`)}getScrollbarWidth(){let t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",document.body.appendChild(t);let e=t.offsetWidth;t.style.overflow="scroll";let s=document.createElement("div");s.style.width="100%",t.appendChild(s);let i=s.offsetWidth;return t.parentNode?.removeChild(t),e-i}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,e){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${e}`):this.options.formatCountSelected(t,e)}formatNoMatchesFound(){return this.options.noMatchesFoundText||this.options.formatNoMatchesFound()}formatOkButton(){return this.options.okButtonText||this.options.formatOkButton()}formatSelectAll(){return this.options.selectAllText||this.options.formatSelectAll()}};var F=function(o,t){return typeof o=="string"?R(document.querySelectorAll(o),t):o instanceof Node?R([o],t):R(o,t)};function R(o,t){let e=Array.from(o),s=[];for(let i=0;i<e.length;i++){let l=e[i];try{l._multipleSelect!==void 0&&(l._multipleSelect.destroy(),delete l._multipleSelect),l._multipleSelect=new L(l,t||{}),l._multipleSelect.init();let n=l._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete l._multipleSelect,n.onAfterHardDestroyed=()=>s[i]=null,s.push(l._multipleSelect)}catch(n){console.error(n)}}return s.length===1?s[0]:s}F.defaults=d.DEFAULTS;F.locales={...O};F.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=F);return V(tt);})();
//# sourceMappingURL=multiple-select.js.map
{
"name": "multiple-select-vanilla",
"version": "0.4.5",
"version": "0.4.7",
"type": "module",

@@ -49,3 +49,3 @@ "exports": {

},
"gitHead": "6f5815e5e964b6300cf623fc90b9160b5a40a8a4"
"gitHead": "9dfd387df894cfee975c9bcab514059c3cc46b7d"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc