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 1.1.0 to 1.1.1

2

dist/browser/multiple-select.js

@@ -1,2 +0,2 @@

var Z=Object.defineProperty;var Q=(o,t,s)=>t in o?Z(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s;var a=(o,t,s)=>(Q(o,typeof t!="symbol"?t+"":t,s),s);var S=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,s,e,l,i=""){let n=Array.isArray(s)?s:[s];if(typeof t?.forEach=="function")t.forEach(u=>{for(let c of n)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(u,c))&&(u.addEventListener(c,e,l),this._boundedEvents.push({element:u,eventName:c,listener:e,groupName:i}))});else for(let u of n)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,u))&&(t.addEventListener(u,e,l),this._boundedEvents.push({element:t,eventName:u,listener:e,groupName:i}))}hasBinding(t,s){return this._boundedEvents.some(e=>e.element===t&&(!s||e.eventName===s))}unbind(t,s,e){if(t){let l=Array.isArray(t)?t:[t],i=Array.isArray(s)?s||"":[s||""];for(let n of l){e||(e=this._boundedEvents.find(u=>{if(u.element===n&&(!s||u.eventName===s))return u.listener}));for(let u of i)n?.removeEventListener?.(u,e)}}}unbindAll(t){if(t){let s=Array.isArray(t)?t:[t];for(let e=this._boundedEvents.length-1;e>=0;--e){let l=this._boundedEvents[e];if(s.some(i=>i===l.groupName)){let{element:i,eventName:n,listener:u}=l;this.unbind(i,n,u),this._boundedEvents.splice(e,1)}}}else for(;this._boundedEvents.length>0;){let s=this._boundedEvents.pop(),{element:e,eventName:l,listener:i}=s;this.unbind(e,l,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 v=$.locales;var tt=50,et=4,j={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:s,search:e}=o;return(s||t||"").includes(e)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,cssStyler:()=>null,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,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},st=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(j,v["en-US"]);var it={BLOCK_ROWS:tt,CLUSTER_BLOCKS:et,DEFAULTS:j,METHODS:st},d=it;function G(o,t,s=!1){let e=Object.keys(o),l=Object.keys(t);if(s&&e.length!==l.length)return!1;for(let i of e)if(l.includes(i)&&o[i]!==t[i])return!1;return!0}function D(o){let t=()=>{let l={};for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&(l[i]=D(o[i]));return l},s=()=>o.map(l=>D(l)),e=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return e==="object"?t():e==="array"?s():o}function M(o){return o!=null&&o!==""}function U(o,t){return typeof o=="object"?Object.fromEntries(t?Object.entries(o).filter(([s,e])=>!M(e)&&!t.includes(s)||M(e)):Object.entries(o).filter(([s,e])=>M(e))):o}function K(o){let t=0;return o.forEach((s,e)=>{s.type==="optgroup"?(s._key=`group_${e}`,s.visible=typeof s.visible>"u"?!0:s.visible,s.children.forEach((l,i)=>{l&&(l.visible=typeof l?.visible>"u"?!0:l.visible,l.divider||(l._key=`option_${e}_${i}`,t+=1))})):(s.visible=typeof s.visible>"u"?!0:s.visible,s.divider||(s._key=`option_${e}`,t+=1))}),t}function b(o,t,s){if(Array.isArray(o))for(let e of o){if(e[t]===s||e[t]===`${+e[t]}`&&+e[t]===s)return e;if(e.type==="optgroup"){for(let l of e.children)if(l&&(l[t]===s||l[t]===`${+l[t]}`&&+l[t]===s))return l}}}function q(o){return o.replace(/(\b)(on[a-z]+)(\s*)=([^>]*)|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(&lt;|&#60;)(\/*)(script|script defer)(.*)(&#62;|&gt;|&gt;">)/gi,"")}function C(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function z(o){return o.replace(/[\W_]+(.)/g,(t,s)=>s.toUpperCase())}function m(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((s,{letters:e,base:l})=>s.replace(e,l),o)}function w(o){let t={};if(o){let s=o.replace(/\s/g,"").split(";");for(let e of s){let[l,i]=e.trim().split(":");l&&(t[z(l)]=i.trim())}console.warn("[multiple-select-vanilla] Please note that `styler` is deprecated, please migrate to `cssStyler` when possible.")}return t}function L(o){let t=0,s=0,e=0,l=0,i=window.innerHeight??0,n=window.innerWidth??0,u=lt(),c=u.top,r=u.left,p=F(o);if(p){let E=p.top??0,f=p.left??0;s=E-c,t=i-(E-c),e=f-r,l=n-(f-r)}return{top:s,bottom:t,left:e,right:l}}function h(o,t,s){let e=document.createElement(o);return t&&Object.keys(t).forEach(l=>{let i=t[l];typeof i=="object"?Object.assign(e[l],i):e[l]=t[l]}),s?.appendChild&&s.appendChild(e),e}function V(o,t,s){let e="";o.props?.innerHTML&&(e=o.props.innerHTML,delete o.props.innerHTML);let l=h(o.tagName,U(o.props,["className","title","style"]),t),i=s;if(i||(i=l),e&&(l.innerHTML=e),o.attrs)for(let n of Object.keys(o.attrs))l.setAttribute(n,o.attrs[n]);if(o.children)for(let n of o.children)V(n,l,i);return t?.appendChild(l),l}function g(o){return o.hasOwnProperty("tagName")?V(o):document.createElement("li")}function y(o){for(;o?.firstChild;)o.lastChild&&o.removeChild(o.lastChild);return o}function F(o){if(!o)return;let t=o?.getBoundingClientRect?.(),s=0,e=0,l=0,i=0;return t?.top!==void 0&&t.left!==void 0&&(s=t.top+window.pageYOffset,e=t.left+window.pageXOffset,i=t.right,l=t.bottom),{top:s,left:e,bottom:l,right:i}}function A(o,t,s){let e=parseFloat(o.style[s]);if(!e||isNaN(e)){switch(t){case"outer":e=o[s==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":e=o[s==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:e=o[s==="width"?"clientWidth":"clientHeight"];break}e=o.getBoundingClientRect()[s]}if(!e||isNaN(e)){let l=o.style.display,i=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[s];e=parseFloat(n),isNaN(e)&&(e=0),o.style.display=l,o.style.position=i}return e||0}function B(o,t){let s=null,e=o?.parentElement;for(;e;){let[l,i,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))e.classList.contains(c)&&(i?e?.tagName.toLowerCase()===i&&(s=e):s=e);e=e.parentElement}return s}function Y(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function _(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function dt(o,t){if(o?.classList){let e=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[e]("selected")}}function lt(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}var H=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 s=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",s,!1),this.destroy=()=>{y(this.contentEl),this.scrollEl.removeEventListener("scroll",s,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let n=g(t[0]);this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.cache.data=[t[0]],this.getRowsHeight()}let s=this.initData(t,this.getNum()),e=this.checkChanges("data",s.rows),l=this.checkChanges("top",s.topOffset),i=this.checkChanges("bottom",s.bottomOffset);y(this.contentEl),e&&l?(s.topOffset&&this.contentEl.appendChild(this.getExtra("top",s.topOffset)),s.rows.forEach(n=>this.contentEl.appendChild(g(n))),s.bottomOffset&&this.contentEl.appendChild(this.getExtra("bottom",s.bottomOffset))):i&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${s.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 s=this.contentEl.children,e=s[Math.floor(s.length/2)];this.itemHeight=e.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,s){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let e=Math.max((this.clusterRows-d.BLOCK_ROWS)*s,0),l=e+this.clusterRows,i=Math.max(e*this.itemHeight,0),n=Math.max((t.length-l)*this.itemHeight,0),u=[],c=e;i<1&&c++;for(let r=e;r<l;r++)t[r]&&u.push(t[r]);return this.dataStart=e,this.dataEnd=l,{topOffset:i,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,s){let e=s!==this.cache[t];return this.cache[t]=s,e}getExtra(t,s){let e=document.createElement("li");return e.className=`virtual-scroll-${t}`,s&&(e.style.height=`${s}px`),e}};var T=class{constructor(t,s){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"closeSearchElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"lastFocusedItemKey","");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,"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,s),this._bindEventService=new S({distinctEvent:!0})}get isRenderAsHtml(){return this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&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(s=>delete this[s])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,s=this.options.locale.split(/-|_/);if(s[0]=s[0].toLowerCase(),s[1]&&(s[1]=s[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[s.join("-")])Object.assign(this.options,t[s.join("-")]);else if(t[s[0]])Object.assign(this.options,t[s[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=h("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let s=this.elm.getAttribute("title")||"";s&&(this.parentElm.title=s),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.tabIndex;let e;this.tabIndex!==null&&(this.elm.tabIndex=-1,e=this.tabIndex),this.choiceElm=h("button",{className:"ms-choice",type:"button"},this.parentElm),e!==void 0&&(this.choiceElm.tabIndex=e),this.choiceElm.appendChild(h("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(h("div",{className:"icon-close"})),this.choiceElm.appendChild(h("div",{className:"icon-caret"})),this.dropElm=h("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let l=this.elm.getAttribute("data-test")||this.options.dataTest;l&&(this.parentElm.dataset.test=l,this.dropElm.dataset.test=l),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`),Y(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`selectAll${t}`,this.selectGroupName=`selectGroup${t}`,this.selectItemName=`selectItem${t}`,this.options.keepOpen||(this._bindEventService.unbindAll("body-click"),this._bindEventService.bind(document.body,"click",i=>{i.target===this.choiceElm||B(i.target,".ms-choice")===this.choiceElm||(i.target===this.dropElm||B(i.target,".ms-drop")!==this.dropElm&&i.target!==this.elm)&&this.options.isOpen&&this.close()},void 0,"body-click"))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(s=>typeof s=="string"||typeof s=="number"?{text:s,value:s}:s);else if(typeof this.options.data=="object"){for(let[s,e]of Object.entries(this.options.data))t.push({value:s,text:`${e}`});this.data=t}}else this.elm.childNodes.forEach(s=>{let e=this.initRow(s);e&&t.push(e)}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=K(this.data||[])}initRow(t,s){let e={};return t.tagName?.toLowerCase()==="option"?(e.type="option",e.text=this.options.textTemplate(t),e.value=t.value,e.visible=!0,e.selected=!!t.selected,e.disabled=s||t.disabled,e.classes=t.getAttribute("class")||"",e.title=t.getAttribute("title")||"",t.dataset.value&&(e._value=t.dataset.value),Object.keys(t.dataset).length&&(e._data=t.dataset,e._data.divider&&(e.divider=e._data.divider)),e):t.tagName?.toLowerCase()==="optgroup"?(e.type="optgroup",e.label=this.options.labelTemplate(t),e.visible=!0,e.selected=!!t.selected,e.disabled=t.disabled,e.children=[],Object.keys(t.dataset).length&&(e._data=t.dataset),t.childNodes.forEach(l=>{e.children.push(this.initRow(l,e.disabled))}),e):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 s of this.data||[])s.type==="optgroup"?t+=s.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=h("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(h("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"})),this.options.showSearchClear&&this.filterParentElm.appendChild(h("span",{className:"icon-close"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=h("div",{className:"ms-select-all",tabIndex:0});let s=document.createElement("label");h("input",{type:"checkbox",ariaChecked:String(this.allSelected),checked:this.allSelected,dataset:{name:`selectAll${t}`},tabIndex:-1},s),s.appendChild(h("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(s),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=h("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=0,s=this.getListRows();if(this.options.selectAll&&!this.options.single&&(t=-1),s.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let e=this.dropElm.style.display!=="none";e||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let l=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+t,this.updateDataEnd=this.virtualScroll.dataEnd+t,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>this.getDataLength()&&(this.updateDataEnd=this.getDataLength()))};this.ulElm&&(this.virtualScroll=new H({rows:s,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{l(),this.events()}})),l(),e||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(y(this.ulElm),s.forEach(e=>this.ulElm.appendChild(g(e)))),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;return this.events(),s}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(s=>t.push(...this.initListItem(s))),t.push({tagName:"li",props:{className:"ms-no-results",textContent:this.formatNoMatchesFound(),tabIndex:0}}),t}initListItem(t,s=0){let e=t?.title||"",l=this.options.multiple?"multiple":"",i=this.options.single?"radio":"checkbox",n="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(n="hide-radio "),t.selected&&(n+="selected "),t.type==="optgroup"){let k=[],J=this.options.hideOptgroupCheckboxes||this.options.single?{tagName:"span",props:{dataset:{name:this.selectGroupName,key:t._key}}}:{tagName:"input",props:{type:"checkbox",dataset:{name:this.selectGroupName,key:t._key},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:t.disabled,tabIndex:-1}};!n.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(n+="hide-radio ");let N={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(N.props,t.label);let x={tagName:"li",props:{className:`group ${n}`.trim(),tabIndex:n.includes("hide-radio")||t.disabled?-1:0},children:[{tagName:"label",props:{className:`optgroup${this.options.single||t.disabled?" disabled":""}`},children:[J,N]}]},W=this.options.cssStyler(t),P=String(this.options.styler(t)||"");return P&&(x.props.style=w(P)),W&&(x.props.style=W),k.push(x),t.children.forEach(X=>k.push(...this.initListItem(X,1))),k}if(n+=t.classes||"",s&&this.options.single&&(n+=`option-level-${s} `),t.divider)return[{tagName:"li",props:{className:"option-divider"}}];let u=l||n?(l+n).trim():"",c=`${t.disabled?"disabled":""}`,r={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(r.props,t.text);let p={tagName:"input",props:{type:i,value:encodeURI(t.value),dataset:{key:t._key,name:this.selectItemName},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:!!t.disabled,tabIndex:-1}};t.selected&&(p.attrs={checked:"checked"});let E={tagName:"li",props:{className:u,title:e,tabIndex:t.disabled?-1:0,dataset:{key:t._key}},children:[{tagName:"label",props:{className:c},children:[p,r]}]},f=this.options.cssStyler(t),I=String(this.options.styler(t)||"");return I&&(E.props.style=w(I)),f&&(E.props.style=f),[E]}initSelected(t=!1){let s=0;for(let e of this.data||[])if(e.type==="optgroup"){let l=e.children.filter(i=>i&&i.selected&&!i.disabled&&i.visible).length;e.children.length&&(e.selected=!this.options.single&&l&&l===e.children.filter(i=>i&&!i.disabled&&i.visible&&!i.divider).length),s+=l}else s+=e.selected&&!e.disabled&&e.visible?1:0;this.allSelected=this.data?.filter(e=>e.selected&&!e.disabled&&e.visible).length===this.data?.filter(e=>!e.disabled&&e.visible&&!e.divider).length,t||(this.allSelected?this.options.onCheckAll():s===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=A(this.dropElm,"outer","width")+20)):t=A(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbindAll(["ok-button","search-input","select-all-checkbox","input-checkbox-list","group-checkbox-list"]),this.closeSearchElm=this.filterParentElm?.querySelector(".icon-close"),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[data-name="${this.selectAllName}"]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectGroupName}"],span[data-name="${this.selectGroupName}"]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:enabled`),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.closeSearchElm&&this._bindEventService.bind(this.closeSearchElm,"click",e=>{e.preventDefault(),this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()},void 0,"search-input"),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let l=[];this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&l.push(i)}),l.length&&l[0].hasAttribute("data-name")&&this.setSelects([l[0].value])}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()},void 0,"search-input")),this.selectAllElm&&this._bindEventService.bind(this.selectAllElm,"click",e=>this._checkAll(e.currentTarget?.checked),void 0,"select-all-checkbox"),this.okButtonElm&&this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()},void 0,"ok-button"),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let l=e.currentTarget,i=l.checked,n=b(this.data,"_key",l.dataset.key);this._checkGroup(n,i),this.options.onOptgroupClick(C({label:n.label,selected:n.selected,data:n._data,children:n.children.map(u=>{if(u)return C({text:u.text,value:u.value,selected:u.selected,disabled:u.disabled,data:u._data})})}))},void 0,"group-checkbox-list"),this._bindEventService.bind(this.selectItemElms,"click",e=>{let l=e.currentTarget,i=l.checked,n=b(this.data,"_key",l.dataset.key),u=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(n)===!1){u();return}this._check(n,i),this.options.onClick(C({text:n.text,value:n.value,selected:n.selected,data:n._data})),u()},void 0,"input-checkbox-list"),this.lastFocusedItemKey&&this.dropElm.querySelector(`li[data-key=${this.lastFocusedItemKey}]`)?.focus();let s=Array.from(this.dropElm.querySelectorAll("div.ms-select-all, li"));this._bindEventService.unbindAll("tabindex-arrow"),this._bindEventService.bind(this.dropElm,"keydown",e=>{let l=e.target.closest(".ms-select-all")||e.target.closest("li");if(this.dropElm.contains(l)){let i=0,n=s.length;for(i=0;i<n&&!s[i].isEqualNode(l);i++);switch(e.key){case"ArrowUp":e.preventDefault(),i>0&&(this.lastFocusedItemKey=this.focusOnUpDownItem(s,i,e.key)?.dataset.key||"");break;case"ArrowDown":e.preventDefault(),i<s.length-1&&(this.lastFocusedItemKey=this.focusOnUpDownItem(s,i,e.key)?.dataset.key||"");break;case"Enter":case" ":e.preventDefault(),l.querySelector("input")?.click(),this.options.single&&(this.choiceElm.focus(),this.lastFocusedItemKey=this.choiceElm?.dataset.key||"");break;default:}}},void 0,"tabindex-arrow")}focusOnUpDownItem(t,s,e){let l=s,i;for(;i=t[e==="ArrowUp"?l-1:l+1];){if(i.classList.contains("option-divider")){e==="ArrowUp"?l--:l++;continue}break}return i?(i.focus(),i):null}open(t=0){if(t!==null&&t>=0){let s;clearTimeout(s),s=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.getDataLength()||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let i=F(this.dropElm),n;this.options.container instanceof Node?n=this.options.container:typeof this.options.container=="string"&&(n=this.options.container==="body"?document.body:document.querySelector(this.options.container)),n.appendChild(this.dropElm),this.dropElm.style.top=`${i?.top??0}px`,this.dropElm.style.left=`${i?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${A(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,s=this.options.maxHeight;this.options.maxHeightUnit==="row"&&(s=A(this.dropElm.querySelector("ul>li"),"outer","height")*this.options.maxHeight);let e=this.dropElm.querySelector("ul");e&&(t&&(e.style.minHeight=`${t}px`),e.style.maxHeight=`${s}px`),this.dropElm.querySelectorAll(".multiple").forEach(i=>i.style.width=`${this.options.multipleWidth}px`),this.getDataLength()&&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:i,top:n}=L(this.dropElm),u=this.dropElm.getBoundingClientRect().height;l=i<u&&n>i?"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()}applyAsTextOrHtmlWhenEnabled(t,s){t||(t={}),this.isRenderAsHtml?t.innerHTML=typeof this.options.sanitizer=="function"?this.options.sanitizer(s):s:t.textContent=s}update(t=!1){let s=this.getSelects(),e=this.getSelects("text");this.options.displayValues&&(e=s);let l=this.choiceElm?.querySelector("span"),i=s.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=s.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?q(r):r}return e.join(this.options.displayDelimiter)};if(l){if(i===0){let r=this.options.placeholder||"";l.classList.add("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,r)}else i<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&i===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&i>this.options.minimumCountSelected?n=`${e.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(i,this.dataTotal)&&i>this.options.minimumCountSelected?n=this.formatCountSelected(i,this.dataTotal):n=u();if(n!==null&&(l?.classList.remove("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,n)),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was deprecated and replaced by `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";l.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(p=>p===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(t){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let l=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${l._key}]`);if(i){i.checked=l.selected;let n=i.closest("li");n&&(l.selected&&!n.classList.contains("selected")?n.classList.add("selected"):l.selected||n.classList.remove("selected"))}}let s=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,_(this.selectAllElm.closest("li"),!s)),_(this.noResultsElm,s),this.virtualScroll&&(this.virtualScroll.rows=t??this.getListRows())}getData(){return this.options.data}getDataLength(){return this.data?.length??0}getOptions(t=!0){let s=Object.assign({},this.options);return delete s.data,t?D(s):this.options}refreshOptions(t){G(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 s=[];for(let e of this.data||[])if(e.type==="optgroup"){let l=e.children.filter(i=>i?.selected);if(!l.length)continue;if(t==="value"||this.options.single)s.push(...l.map(i=>t==="value"&&i._value||i[t]));else{let i=[];i.push("["),i.push(e.label),i.push(`: ${l.map(n=>n[t]).join(", ")}`),i.push("]"),s.push(i.join(""))}}else e.selected&&s.push(t==="value"&&e._value||e[t]);return s}setSelects(t,s="value",e=!1){let l=!1,i=n=>{for(let u of n){let c=!1;if(s==="text"){let r=document.createElement("div");this.applyAsTextOrHtmlWhenEnabled(r,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&&(l=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?i(n.children):i([n]);l&&(this.initSelected(e),this.updateSelected(),this.update(e))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let s=b(this.data,"value",t);s&&this._check(s,!0)}uncheck(t){let s=b(this.data,"value",t);s&&this._check(s,!1)}_check(t,s){this.options.single&&this._checkAll(!1,!0),t.selected=s,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,s){for(let e of this.data||[])e.type==="optgroup"?this._checkGroup(e,t,!0):!e.disabled&&!e.divider&&(s||e.visible)&&(e.selected=t);s||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,s,e){t.selected=s,t.children.forEach(l=>{l&&!l.disabled&&!l.divider&&(e||l.visible)&&(l.selected=s)}),e||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let s of t.children)s&&(s.divider||(s.selected=!s.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 s=this.searchInputElm?.value.trim()??"",e=s.toLowerCase();if(this.filterText===e)return;this.filterText=e;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let n=`${i?.label??""}`;if(i!=null){let u=this.options.customFilter({label:m(n.toString().toLowerCase()),search:m(e),originalLabel:n,originalSearch:s,row:i});i.visible=u;for(let c of i.children)c&&(c.visible=u)}}else{for(let n of i.children)if(n!=null){let u=`${n?.text??""}`;n.visible=this.options.customFilter({text:m(u.toString().toLowerCase()),search:m(e),originalText:u,originalSearch:s,row:n,parent:i})}i.visible=i.children.filter(n=>n?.visible).length>0}else{let n=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(n.toString().toLowerCase()),search:m(e),originalText:n,originalSearch:s,row:i})}let l=this.initListItems();this.initSelected(t),this.updateSelected(l),t||this.options.onFilter(s)}adjustDropHeight(t){let s=t!=="top",e=this.filterParentElm?.getBoundingClientRect().height??0,l=this.okButtonElm?.getBoundingClientRect().height??0,i=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=e+l+i+5,{bottom:u,top:c}=L(this.parentElm),r=this.options.maxHeight;if(s?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let p=this.dropElm?.querySelector("ul");return p&&(p.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let s="bottom";if(this.dropElm&&this.parentElm){let{bottom:e,top:l}=L(this.dropElm),{top:i,left:n}=F(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,p=this.parentElm.getBoundingClientRect().width;if(e>u)s="bottom";else if(u>e&&l>e){if(this.options.container){let E=i-u;E<0&&(E=0),(E>0||t)&&(s="top",this.dropElm.style.top=`${E<0?0:E}px`)}else s="top",this.dropElm.classList.add(s);this.dropElm.classList.remove("bottom")}r-c<n&&(this.dropElm.style.left=`${n-(c-p)}px`)}return s}adjustDropWidthByText(){let s=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(s=this.options.dropWidth||this.options.width||0);let e=this.dropElm.querySelector(".ms-select-all span"),l=this.dropElm.querySelector("ul"),i=26,n=e?.clientWidth??0+i,c=l.scrollHeight>l.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(p=>{p.scrollWidth>r&&(r=p.scrollWidth)}),r+=i+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),(s==="100%"||+s<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 s=t.offsetWidth;t.style.overflow="scroll";let e=document.createElement("div");e.style.width="100%",t.appendChild(e);let l=e.offsetWidth;return t.parentNode?.removeChild(t),s-l}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,s){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${s}`):this.options.formatCountSelected(t,s)}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 O=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 s=Array.from(o),e=[];for(let l=0;l<s.length;l++){let i=s[l];try{i._multipleSelect!==void 0&&(i._multipleSelect.destroy(),delete i._multipleSelect),i._multipleSelect=new T(i,t||{}),i._multipleSelect.init();let n=i._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete i._multipleSelect,n.onAfterHardDestroyed=()=>e[l]=null,e.push(i._multipleSelect)}catch(n){console.error(n)}}return e.length===1?e[0]:e}O.defaults=d.DEFAULTS;O.locales={...v};O.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=O);export{S as BindingEventService,T as MultipleSelectInstance,H as VirtualScroll,L as calculateAvailableSpace,G as compareObjects,g as convertItemRowToHtml,w as convertStringStyleToElementStyle,h as createDomElement,V as createDomStructure,D as deepCopy,y as emptyElement,b as findByParam,B as findParent,F as getElementOffset,A as getElementSize,Y as insertAfter,M as isDefined,O as multipleSelect,U as objectRemoveEmptyProps,m as removeDiacritics,C as removeUndefined,K as setDataKeys,q as stripScripts,z as toCamelCase,_ as toggleElement,dt as toggleElementClass,lt as windowScrollPosition};
var Z=Object.defineProperty;var Q=(o,t,s)=>t in o?Z(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s;var a=(o,t,s)=>(Q(o,typeof t!="symbol"?t+"":t,s),s);var S=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,s,e,l,i=""){let n=Array.isArray(s)?s:[s];if(typeof t?.forEach=="function")t.forEach(u=>{for(let c of n)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(u,c))&&(u.addEventListener(c,e,l),this._boundedEvents.push({element:u,eventName:c,listener:e,groupName:i}))});else for(let u of n)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,u))&&(t.addEventListener(u,e,l),this._boundedEvents.push({element:t,eventName:u,listener:e,groupName:i}))}hasBinding(t,s){return this._boundedEvents.some(e=>e.element===t&&(!s||e.eventName===s))}unbind(t,s,e){if(t){let l=Array.isArray(t)?t:[t],i=Array.isArray(s)?s||"":[s||""];for(let n of l){e||(e=this._boundedEvents.find(u=>{if(u.element===n&&(!s||u.eventName===s))return u.listener}));for(let u of i)n?.removeEventListener?.(u,e)}}}unbindAll(t){if(t){let s=Array.isArray(t)?t:[t];for(let e=this._boundedEvents.length-1;e>=0;--e){let l=this._boundedEvents[e];if(s.some(i=>i===l.groupName)){let{element:i,eventName:n,listener:u}=l;this.unbind(i,n,u),this._boundedEvents.splice(e,1)}}}else for(;this._boundedEvents.length>0;){let s=this._boundedEvents.pop(),{element:e,eventName:l,listener:i}=s;this.unbind(e,l,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 v=$.locales;var tt=50,et=4,j={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:s,search:e}=o;return(s||t||"").includes(e)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,cssStyler:()=>null,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,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},st=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(j,v["en-US"]);var it={BLOCK_ROWS:tt,CLUSTER_BLOCKS:et,DEFAULTS:j,METHODS:st},d=it;function G(o,t,s=!1){let e=Object.keys(o),l=Object.keys(t);if(s&&e.length!==l.length)return!1;for(let i of e)if(l.includes(i)&&o[i]!==t[i])return!1;return!0}function D(o){let t=()=>{let l={};for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&(l[i]=D(o[i]));return l},s=()=>o.map(l=>D(l)),e=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return e==="object"?t():e==="array"?s():o}function M(o){return o!=null&&o!==""}function U(o,t){return typeof o=="object"?Object.fromEntries(t?Object.entries(o).filter(([s,e])=>!M(e)&&!t.includes(s)||M(e)):Object.entries(o).filter(([s,e])=>M(e))):o}function K(o){let t=0;return o.forEach((s,e)=>{s.type==="optgroup"?(s._key=`group_${e}`,s.visible=typeof s.visible>"u"?!0:s.visible,s.children.forEach((l,i)=>{l&&(l.visible=typeof l?.visible>"u"?!0:l.visible,l.divider||(l._key=`option_${e}_${i}`,t+=1))})):(s.visible=typeof s.visible>"u"?!0:s.visible,s.divider||(s._key=`option_${e}`,t+=1))}),t}function b(o,t,s){if(Array.isArray(o))for(let e of o){if(e[t]===s||e[t]===`${+e[t]}`&&+e[t]===s)return e;if(e.type==="optgroup"){for(let l of e.children)if(l&&(l[t]===s||l[t]===`${+l[t]}`&&+l[t]===s))return l}}}function q(o){return o.replace(/(\b)(on[a-z]+)(\s*)=([^>]*)|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(&lt;|&#60;)(\/*)(script|script defer)(.*)(&#62;|&gt;|&gt;">)/gi,"")}function C(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function z(o){return o.replace(/[\W_]+(.)/g,(t,s)=>s.toUpperCase())}function m(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((s,{letters:e,base:l})=>s.replace(e,l),o)}function w(o){let t={};if(o){let s=o.replace(/\s/g,"").split(";");for(let e of s){let[l,i]=e.trim().split(":");l&&(t[z(l)]=i.trim())}console.warn("[multiple-select-vanilla] Please note that `styler` is deprecated, please migrate to `cssStyler` when possible.")}return t}function L(o){let t=0,s=0,e=0,l=0,i=window.innerHeight??0,n=window.innerWidth??0,u=lt(),c=u.top,r=u.left,p=F(o);if(p){let E=p.top??0,f=p.left??0;s=E-c,t=i-(E-c),e=f-r,l=n-(f-r)}return{top:s,bottom:t,left:e,right:l}}function h(o,t,s){let e=document.createElement(o);return t&&Object.keys(t).forEach(l=>{let i=t[l];typeof i=="object"?Object.assign(e[l],i):e[l]=t[l]}),s?.appendChild&&s.appendChild(e),e}function V(o,t,s){let e="";o.props?.innerHTML&&(e=o.props.innerHTML,delete o.props.innerHTML);let l=h(o.tagName,U(o.props,["className","title","style"]),t),i=s;if(i||(i=l),e&&(l.innerHTML=e),o.attrs)for(let n of Object.keys(o.attrs))l.setAttribute(n,o.attrs[n]);if(o.children)for(let n of o.children)V(n,l,i);return t?.appendChild(l),l}function g(o){return o.hasOwnProperty("tagName")?V(o):document.createElement("li")}function y(o){for(;o?.firstChild;)o.lastChild&&o.removeChild(o.lastChild);return o}function F(o){if(!o)return;let t=o?.getBoundingClientRect?.(),s=0,e=0,l=0,i=0;return t?.top!==void 0&&t.left!==void 0&&(s=t.top+window.pageYOffset,e=t.left+window.pageXOffset,i=t.right,l=t.bottom),{top:s,left:e,bottom:l,right:i}}function A(o,t,s){let e=parseFloat(o.style[s]);if(!e||isNaN(e)){switch(t){case"outer":e=o[s==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":e=o[s==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:e=o[s==="width"?"clientWidth":"clientHeight"];break}e=o.getBoundingClientRect()[s]}if(!e||isNaN(e)){let l=o.style.display,i=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[s];e=parseFloat(n),isNaN(e)&&(e=0),o.style.display=l,o.style.position=i}return e||0}function B(o,t){let s=null,e=o?.parentElement;for(;e;){let[l,i,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))e.classList.contains(c)&&(i?e?.tagName.toLowerCase()===i&&(s=e):s=e);e=e.parentElement}return s}function Y(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function _(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function dt(o,t){if(o?.classList){let e=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[e]("selected")}}function lt(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}var H=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 s=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",s,!1),this.destroy=()=>{y(this.contentEl),this.scrollEl.removeEventListener("scroll",s,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let n=g(t[0]);this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.cache.data=[t[0]],this.getRowsHeight()}let s=this.initData(t,this.getNum()),e=this.checkChanges("data",s.rows),l=this.checkChanges("top",s.topOffset),i=this.checkChanges("bottom",s.bottomOffset);y(this.contentEl),e&&l?(s.topOffset&&this.contentEl.appendChild(this.getExtra("top",s.topOffset)),s.rows.forEach(n=>this.contentEl.appendChild(g(n))),s.bottomOffset&&this.contentEl.appendChild(this.getExtra("bottom",s.bottomOffset))):i&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${s.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 s=this.contentEl.children,e=s[Math.floor(s.length/2)];this.itemHeight=e.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,s){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let e=Math.max((this.clusterRows-d.BLOCK_ROWS)*s,0),l=e+this.clusterRows,i=Math.max(e*this.itemHeight,0),n=Math.max((t.length-l)*this.itemHeight,0),u=[],c=e;i<1&&c++;for(let r=e;r<l;r++)t[r]&&u.push(t[r]);return this.dataStart=e,this.dataEnd=l,{topOffset:i,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,s){let e=s!==this.cache[t];return this.cache[t]=s,e}getExtra(t,s){let e=document.createElement("li");return e.className=`virtual-scroll-${t}`,s&&(e.style.height=`${s}px`),e}};var T=class{constructor(t,s){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"closeSearchElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"lastFocusedItemKey","");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,"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,s),this._bindEventService=new S({distinctEvent:!0})}get isRenderAsHtml(){return this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&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(s=>delete this[s])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,s=this.options.locale.split(/-|_/);if(s[0]=s[0].toLowerCase(),s[1]&&(s[1]=s[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[s.join("-")])Object.assign(this.options,t[s.join("-")]);else if(t[s[0]])Object.assign(this.options,t[s[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=h("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let s=this.elm.getAttribute("title")||"";s&&(this.parentElm.title=s),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.tabIndex;let e;this.tabIndex!==null&&(this.elm.tabIndex=-1,e=this.tabIndex),this.choiceElm=h("button",{className:"ms-choice",type:"button"},this.parentElm),e!==void 0&&(this.choiceElm.tabIndex=e),this.choiceElm.appendChild(h("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(h("div",{className:"icon-close"})),this.choiceElm.appendChild(h("div",{className:"icon-caret"})),this.dropElm=h("div",{className:`ms-drop ${this.options.position}`,ariaExpanded:"false"},this.parentElm),t&&(this.dropElm.dataset.name=t);let l=this.elm.getAttribute("data-test")||this.options.dataTest;l&&(this.parentElm.dataset.test=l,this.dropElm.dataset.test=l),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`),Y(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`selectAll${t}`,this.selectGroupName=`selectGroup${t}`,this.selectItemName=`selectItem${t}`,this.options.keepOpen||(this._bindEventService.unbindAll("body-click"),this._bindEventService.bind(document.body,"click",i=>{i.target===this.choiceElm||B(i.target,".ms-choice")===this.choiceElm||(i.target===this.dropElm||B(i.target,".ms-drop")!==this.dropElm&&i.target!==this.elm)&&this.options.isOpen&&this.close()},void 0,"body-click"))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(s=>typeof s=="string"||typeof s=="number"?{text:s,value:s}:s);else if(typeof this.options.data=="object"){for(let[s,e]of Object.entries(this.options.data))t.push({value:s,text:`${e}`});this.data=t}}else this.elm.childNodes.forEach(s=>{let e=this.initRow(s);e&&t.push(e)}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=K(this.data||[])}initRow(t,s){let e={};return t.tagName?.toLowerCase()==="option"?(e.type="option",e.text=this.options.textTemplate(t),e.value=t.value,e.visible=!0,e.selected=!!t.selected,e.disabled=s||t.disabled,e.classes=t.getAttribute("class")||"",e.title=t.getAttribute("title")||"",t.dataset.value&&(e._value=t.dataset.value),Object.keys(t.dataset).length&&(e._data=t.dataset,e._data.divider&&(e.divider=e._data.divider)),e):t.tagName?.toLowerCase()==="optgroup"?(e.type="optgroup",e.label=this.options.labelTemplate(t),e.visible=!0,e.selected=!!t.selected,e.disabled=t.disabled,e.children=[],Object.keys(t.dataset).length&&(e._data=t.dataset),t.childNodes.forEach(l=>{e.children.push(this.initRow(l,e.disabled))}),e):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 s of this.data||[])s.type==="optgroup"?t+=s.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=h("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(h("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"})),this.options.showSearchClear&&this.filterParentElm.appendChild(h("span",{className:"icon-close"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=h("div",{className:"ms-select-all",tabIndex:0});let s=document.createElement("label");h("input",{type:"checkbox",ariaChecked:String(this.allSelected),checked:this.allSelected,dataset:{name:`selectAll${t}`},tabIndex:-1},s),s.appendChild(h("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(s),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=h("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=0,s=this.getListRows();if(this.options.selectAll&&!this.options.single&&(t=-1),s.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let e=this.dropElm.style.display!=="none";e||(this.dropElm.style.left="-10000",this.dropElm.style.display="block",this.dropElm.ariaExpanded="true");let l=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+t,this.updateDataEnd=this.virtualScroll.dataEnd+t,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>this.getDataLength()&&(this.updateDataEnd=this.getDataLength()))};this.ulElm&&(this.virtualScroll=new H({rows:s,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{l(),this.events()}})),l(),e||(this.dropElm.style.left="0",this.dropElm.style.display="none",this.dropElm.ariaExpanded="false")}else this.ulElm&&(y(this.ulElm),s.forEach(e=>this.ulElm.appendChild(g(e)))),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;return this.events(),s}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(s=>t.push(...this.initListItem(s))),t.push({tagName:"li",props:{className:"ms-no-results",textContent:this.formatNoMatchesFound(),tabIndex:0}}),t}initListItem(t,s=0){let e=t?.title||"",l=this.options.multiple?"multiple":"",i=this.options.single?"radio":"checkbox",n="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(n="hide-radio "),t.selected&&(n+="selected "),t.type==="optgroup"){let x=[],J=this.options.hideOptgroupCheckboxes||this.options.single?{tagName:"span",props:{dataset:{name:this.selectGroupName,key:t._key}}}:{tagName:"input",props:{type:"checkbox",dataset:{name:this.selectGroupName,key:t._key},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:t.disabled,tabIndex:-1}};!n.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(n+="hide-radio ");let N={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(N.props,t.label);let k={tagName:"li",props:{className:`group ${n}`.trim(),tabIndex:n.includes("hide-radio")||t.disabled?-1:0},children:[{tagName:"label",props:{className:`optgroup${this.options.single||t.disabled?" disabled":""}`},children:[J,N]}]},W=this.options.cssStyler(t),P=String(this.options.styler(t)||"");return P&&(k.props.style=w(P)),W&&(k.props.style=W),x.push(k),t.children.forEach(X=>x.push(...this.initListItem(X,1))),x}if(n+=t.classes||"",s&&this.options.single&&(n+=`option-level-${s} `),t.divider)return[{tagName:"li",props:{className:"option-divider"}}];let u=l||n?(l+n).trim():"",c=`${t.disabled?"disabled":""}`,r={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(r.props,t.text);let p={tagName:"input",props:{type:i,value:encodeURI(t.value),dataset:{key:t._key,name:this.selectItemName},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:!!t.disabled,tabIndex:-1}};t.selected&&(p.attrs={checked:"checked"});let E={tagName:"li",props:{className:u,title:e,tabIndex:t.disabled?-1:0,dataset:{key:t._key}},children:[{tagName:"label",props:{className:c},children:[p,r]}]},f=this.options.cssStyler(t),I=String(this.options.styler(t)||"");return I&&(E.props.style=w(I)),f&&(E.props.style=f),[E]}initSelected(t=!1){let s=0;for(let e of this.data||[])if(e.type==="optgroup"){let l=e.children.filter(i=>i&&i.selected&&!i.disabled&&i.visible).length;e.children.length&&(e.selected=!this.options.single&&l&&l===e.children.filter(i=>i&&!i.disabled&&i.visible&&!i.divider).length),s+=l}else s+=e.selected&&!e.disabled&&e.visible?1:0;this.allSelected=this.data?.filter(e=>e.selected&&!e.disabled&&e.visible).length===this.data?.filter(e=>!e.disabled&&e.visible&&!e.divider).length,t||(this.allSelected?this.options.onCheckAll():s===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=A(this.dropElm,"outer","width")+20)):t=A(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbindAll(["ok-button","search-input","select-all-checkbox","input-checkbox-list","group-checkbox-list"]),this.closeSearchElm=this.filterParentElm?.querySelector(".icon-close"),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[data-name="${this.selectAllName}"]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectGroupName}"],span[data-name="${this.selectGroupName}"]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:enabled`),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.closeSearchElm&&this._bindEventService.bind(this.closeSearchElm,"click",e=>{e.preventDefault(),this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()},void 0,"search-input"),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let l=[];this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&l.push(i)}),l.length&&l[0].hasAttribute("data-name")&&this.setSelects([l[0].value])}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()},void 0,"search-input")),this.selectAllElm&&this._bindEventService.bind(this.selectAllElm,"click",e=>this._checkAll(e.currentTarget?.checked),void 0,"select-all-checkbox"),this.okButtonElm&&this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()},void 0,"ok-button"),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let l=e.currentTarget,i=l.checked,n=b(this.data,"_key",l.dataset.key);this._checkGroup(n,i),this.options.onOptgroupClick(C({label:n.label,selected:n.selected,data:n._data,children:n.children.map(u=>{if(u)return C({text:u.text,value:u.value,selected:u.selected,disabled:u.disabled,data:u._data})})}))},void 0,"group-checkbox-list"),this._bindEventService.bind(this.selectItemElms,"click",e=>{let l=e.currentTarget,i=l.checked,n=b(this.data,"_key",l.dataset.key),u=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(n)===!1){u();return}this._check(n,i),this.options.onClick(C({text:n.text,value:n.value,selected:n.selected,data:n._data})),u()},void 0,"input-checkbox-list"),this.lastFocusedItemKey&&this.dropElm.querySelector(`li[data-key=${this.lastFocusedItemKey}]`)?.focus();let s=Array.from(this.dropElm.querySelectorAll("div.ms-select-all, li"));this._bindEventService.unbindAll("tabindex-arrow"),this._bindEventService.bind(this.dropElm,"keydown",e=>{let l=e.target.closest(".ms-select-all")||e.target.closest("li");if(this.dropElm.contains(l)){let i=0,n=s.length;for(i=0;i<n&&!s[i].isEqualNode(l);i++);switch(e.key){case"ArrowUp":e.preventDefault(),i>0&&(this.lastFocusedItemKey=this.focusOnUpDownItem(s,i,e.key)?.dataset.key||"");break;case"ArrowDown":e.preventDefault(),i<s.length-1&&(this.lastFocusedItemKey=this.focusOnUpDownItem(s,i,e.key)?.dataset.key||"");break;case"Enter":case" ":e.preventDefault(),l.querySelector("input")?.click(),this.options.single&&(this.choiceElm.focus(),this.lastFocusedItemKey=this.choiceElm?.dataset.key||"");break;default:}}},void 0,"tabindex-arrow")}focusOnUpDownItem(t,s,e){let l=s,i;for(;i=t[e==="ArrowUp"?l-1:l+1];){if(i.classList.contains("option-divider")){e==="ArrowUp"?l--:l++;continue}break}return i?(i.focus(),i):null}open(t=0){if(t!==null&&t>=0){let s;clearTimeout(s),s=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.dropElm.ariaExpanded="true",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.getDataLength()||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let i=F(this.dropElm),n;this.options.container instanceof Node?n=this.options.container:typeof this.options.container=="string"&&(n=this.options.container==="body"?document.body:document.querySelector(this.options.container)),n.appendChild(this.dropElm),this.dropElm.style.top=`${i?.top??0}px`,this.dropElm.style.left=`${i?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${A(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,s=this.options.maxHeight;this.options.maxHeightUnit==="row"&&(s=A(this.dropElm.querySelector("ul>li"),"outer","height")*this.options.maxHeight);let e=this.dropElm.querySelector("ul");e&&(t&&(e.style.minHeight=`${t}px`),e.style.maxHeight=`${s}px`),this.dropElm.querySelectorAll(".multiple").forEach(i=>i.style.width=`${this.options.multipleWidth}px`),this.getDataLength()&&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:i,top:n}=L(this.dropElm),u=this.dropElm.getBoundingClientRect().height;l=i<u&&n>i?"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.dropElm.ariaExpanded="false",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}applyAsTextOrHtmlWhenEnabled(t,s){t||(t={}),this.isRenderAsHtml?t.innerHTML=typeof this.options.sanitizer=="function"?this.options.sanitizer(s):s:t.textContent=s}update(t=!1){let s=this.getSelects(),e=this.getSelects("text");this.options.displayValues&&(e=s);let l=this.choiceElm?.querySelector("span"),i=s.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=s.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?q(r):r}return e.join(this.options.displayDelimiter)};if(l){if(i===0){let r=this.options.placeholder||"";l.classList.add("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,r)}else i<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&i===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&i>this.options.minimumCountSelected?n=`${e.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(i,this.dataTotal)&&i>this.options.minimumCountSelected?n=this.formatCountSelected(i,this.dataTotal):n=u();if(n!==null&&(l?.classList.remove("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,n)),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was deprecated and replaced by `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";l.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(p=>p===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(t){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let l=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${l._key}]`);if(i){i.checked=l.selected;let n=i.closest("li");n&&(l.selected&&!n.classList.contains("selected")?n.classList.add("selected"):l.selected||n.classList.remove("selected"))}}let s=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,_(this.selectAllElm.closest("li"),!s)),_(this.noResultsElm,s),this.virtualScroll&&(this.virtualScroll.rows=t??this.getListRows())}getData(){return this.options.data}getDataLength(){return this.data?.length??0}getOptions(t=!0){let s=Object.assign({},this.options);return delete s.data,t?D(s):this.options}refreshOptions(t){G(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 s=[];for(let e of this.data||[])if(e.type==="optgroup"){let l=e.children.filter(i=>i?.selected);if(!l.length)continue;if(t==="value"||this.options.single)s.push(...l.map(i=>t==="value"&&i._value||i[t]));else{let i=[];i.push("["),i.push(e.label),i.push(`: ${l.map(n=>n[t]).join(", ")}`),i.push("]"),s.push(i.join(""))}}else e.selected&&s.push(t==="value"&&e._value||e[t]);return s}setSelects(t,s="value",e=!1){let l=!1,i=n=>{for(let u of n){let c=!1;if(s==="text"){let r=document.createElement("div");this.applyAsTextOrHtmlWhenEnabled(r,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&&(l=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?i(n.children):i([n]);l&&(this.initSelected(e),this.updateSelected(),this.update(e))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let s=b(this.data,"value",t);s&&this._check(s,!0)}uncheck(t){let s=b(this.data,"value",t);s&&this._check(s,!1)}_check(t,s){this.options.single&&this._checkAll(!1,!0),t.selected=s,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,s){for(let e of this.data||[])e.type==="optgroup"?this._checkGroup(e,t,!0):!e.disabled&&!e.divider&&(s||e.visible)&&(e.selected=t);s||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,s,e){t.selected=s,t.children.forEach(l=>{l&&!l.disabled&&!l.divider&&(e||l.visible)&&(l.selected=s)}),e||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let s of t.children)s&&(s.divider||(s.selected=!s.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 s=this.searchInputElm?.value.trim()??"",e=s.toLowerCase();if(this.filterText===e)return;this.filterText=e;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let n=`${i?.label??""}`;if(i!=null){let u=this.options.customFilter({label:m(n.toString().toLowerCase()),search:m(e),originalLabel:n,originalSearch:s,row:i});i.visible=u;for(let c of i.children)c&&(c.visible=u)}}else{for(let n of i.children)if(n!=null){let u=`${n?.text??""}`;n.visible=this.options.customFilter({text:m(u.toString().toLowerCase()),search:m(e),originalText:u,originalSearch:s,row:n,parent:i})}i.visible=i.children.filter(n=>n?.visible).length>0}else{let n=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(n.toString().toLowerCase()),search:m(e),originalText:n,originalSearch:s,row:i})}let l=this.initListItems();this.initSelected(t),this.updateSelected(l),t||this.options.onFilter(s)}adjustDropHeight(t){let s=t!=="top",e=this.filterParentElm?.getBoundingClientRect().height??0,l=this.okButtonElm?.getBoundingClientRect().height??0,i=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=e+l+i+5,{bottom:u,top:c}=L(this.parentElm),r=this.options.maxHeight;if(s?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let p=this.dropElm?.querySelector("ul");return p&&(p.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let s="bottom";if(this.dropElm&&this.parentElm){let{bottom:e,top:l}=L(this.dropElm),{top:i,left:n}=F(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,p=this.parentElm.getBoundingClientRect().width;if(e>u)s="bottom";else if(u>e&&l>e){if(this.options.container){let E=i-u;E<0&&(E=0),(E>0||t)&&(s="top",this.dropElm.style.top=`${E<0?0:E}px`)}else s="top",this.dropElm.classList.add(s);this.dropElm.classList.remove("bottom")}r-c<n&&(this.dropElm.style.left=`${n-(c-p)}px`)}return s}adjustDropWidthByText(){let s=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(s=this.options.dropWidth||this.options.width||0);let e=this.dropElm.querySelector(".ms-select-all span"),l=this.dropElm.querySelector("ul"),i=26,n=e?.clientWidth??0+i,c=l.scrollHeight>l.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(p=>{p.scrollWidth>r&&(r=p.scrollWidth)}),r+=i+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),(s==="100%"||+s<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 s=t.offsetWidth;t.style.overflow="scroll";let e=document.createElement("div");e.style.width="100%",t.appendChild(e);let l=e.offsetWidth;return t.parentNode?.removeChild(t),s-l}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,s){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${s}`):this.options.formatCountSelected(t,s)}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 O=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 s=Array.from(o),e=[];for(let l=0;l<s.length;l++){let i=s[l];try{i._multipleSelect!==void 0&&(i._multipleSelect.destroy(),delete i._multipleSelect),i._multipleSelect=new T(i,t||{}),i._multipleSelect.init();let n=i._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete i._multipleSelect,n.onAfterHardDestroyed=()=>e[l]=null,e.push(i._multipleSelect)}catch(n){console.error(n)}}return e.length===1?e[0]:e}O.defaults=d.DEFAULTS;O.locales={...v};O.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=O);export{S as BindingEventService,T as MultipleSelectInstance,H as VirtualScroll,L as calculateAvailableSpace,G as compareObjects,g as convertItemRowToHtml,w as convertStringStyleToElementStyle,h as createDomElement,V as createDomStructure,D as deepCopy,y as emptyElement,b as findByParam,B as findParent,F as getElementOffset,A as getElementSize,Y as insertAfter,M as isDefined,O as multipleSelect,U as objectRemoveEmptyProps,m as removeDiacritics,C as removeUndefined,K as setDataKeys,q as stripScripts,z as toCamelCase,_ as toggleElement,dt as toggleElementClass,lt as windowScrollPosition};
//# sourceMappingURL=multiple-select.js.map

@@ -1,2 +0,2 @@

var Z=Object.defineProperty;var Q=(o,t,s)=>t in o?Z(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s;var a=(o,t,s)=>(Q(o,typeof t!="symbol"?t+"":t,s),s);var S=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,s,e,l,i=""){let n=Array.isArray(s)?s:[s];if(typeof t?.forEach=="function")t.forEach(u=>{for(let c of n)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(u,c))&&(u.addEventListener(c,e,l),this._boundedEvents.push({element:u,eventName:c,listener:e,groupName:i}))});else for(let u of n)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,u))&&(t.addEventListener(u,e,l),this._boundedEvents.push({element:t,eventName:u,listener:e,groupName:i}))}hasBinding(t,s){return this._boundedEvents.some(e=>e.element===t&&(!s||e.eventName===s))}unbind(t,s,e){if(t){let l=Array.isArray(t)?t:[t],i=Array.isArray(s)?s||"":[s||""];for(let n of l){e||(e=this._boundedEvents.find(u=>{if(u.element===n&&(!s||u.eventName===s))return u.listener}));for(let u of i)n?.removeEventListener?.(u,e)}}}unbindAll(t){if(t){let s=Array.isArray(t)?t:[t];for(let e=this._boundedEvents.length-1;e>=0;--e){let l=this._boundedEvents[e];if(s.some(i=>i===l.groupName)){let{element:i,eventName:n,listener:u}=l;this.unbind(i,n,u),this._boundedEvents.splice(e,1)}}}else for(;this._boundedEvents.length>0;){let s=this._boundedEvents.pop(),{element:e,eventName:l,listener:i}=s;this.unbind(e,l,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 v=$.locales;var tt=50,et=4,j={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:s,search:e}=o;return(s||t||"").includes(e)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,cssStyler:()=>null,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,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},st=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(j,v["en-US"]);var it={BLOCK_ROWS:tt,CLUSTER_BLOCKS:et,DEFAULTS:j,METHODS:st},d=it;function G(o,t,s=!1){let e=Object.keys(o),l=Object.keys(t);if(s&&e.length!==l.length)return!1;for(let i of e)if(l.includes(i)&&o[i]!==t[i])return!1;return!0}function D(o){let t=()=>{let l={};for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&(l[i]=D(o[i]));return l},s=()=>o.map(l=>D(l)),e=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return e==="object"?t():e==="array"?s():o}function M(o){return o!=null&&o!==""}function U(o,t){return typeof o=="object"?Object.fromEntries(t?Object.entries(o).filter(([s,e])=>!M(e)&&!t.includes(s)||M(e)):Object.entries(o).filter(([s,e])=>M(e))):o}function K(o){let t=0;return o.forEach((s,e)=>{s.type==="optgroup"?(s._key=`group_${e}`,s.visible=typeof s.visible>"u"?!0:s.visible,s.children.forEach((l,i)=>{l&&(l.visible=typeof l?.visible>"u"?!0:l.visible,l.divider||(l._key=`option_${e}_${i}`,t+=1))})):(s.visible=typeof s.visible>"u"?!0:s.visible,s.divider||(s._key=`option_${e}`,t+=1))}),t}function b(o,t,s){if(Array.isArray(o))for(let e of o){if(e[t]===s||e[t]===`${+e[t]}`&&+e[t]===s)return e;if(e.type==="optgroup"){for(let l of e.children)if(l&&(l[t]===s||l[t]===`${+l[t]}`&&+l[t]===s))return l}}}function q(o){return o.replace(/(\b)(on[a-z]+)(\s*)=([^>]*)|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(&lt;|&#60;)(\/*)(script|script defer)(.*)(&#62;|&gt;|&gt;">)/gi,"")}function C(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function z(o){return o.replace(/[\W_]+(.)/g,(t,s)=>s.toUpperCase())}function m(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((s,{letters:e,base:l})=>s.replace(e,l),o)}function w(o){let t={};if(o){let s=o.replace(/\s/g,"").split(";");for(let e of s){let[l,i]=e.trim().split(":");l&&(t[z(l)]=i.trim())}console.warn("[multiple-select-vanilla] Please note that `styler` is deprecated, please migrate to `cssStyler` when possible.")}return t}function L(o){let t=0,s=0,e=0,l=0,i=window.innerHeight??0,n=window.innerWidth??0,u=lt(),c=u.top,r=u.left,p=F(o);if(p){let E=p.top??0,f=p.left??0;s=E-c,t=i-(E-c),e=f-r,l=n-(f-r)}return{top:s,bottom:t,left:e,right:l}}function h(o,t,s){let e=document.createElement(o);return t&&Object.keys(t).forEach(l=>{let i=t[l];typeof i=="object"?Object.assign(e[l],i):e[l]=t[l]}),s?.appendChild&&s.appendChild(e),e}function V(o,t,s){let e="";o.props?.innerHTML&&(e=o.props.innerHTML,delete o.props.innerHTML);let l=h(o.tagName,U(o.props,["className","title","style"]),t),i=s;if(i||(i=l),e&&(l.innerHTML=e),o.attrs)for(let n of Object.keys(o.attrs))l.setAttribute(n,o.attrs[n]);if(o.children)for(let n of o.children)V(n,l,i);return t?.appendChild(l),l}function g(o){return o.hasOwnProperty("tagName")?V(o):document.createElement("li")}function y(o){for(;o?.firstChild;)o.lastChild&&o.removeChild(o.lastChild);return o}function F(o){if(!o)return;let t=o?.getBoundingClientRect?.(),s=0,e=0,l=0,i=0;return t?.top!==void 0&&t.left!==void 0&&(s=t.top+window.pageYOffset,e=t.left+window.pageXOffset,i=t.right,l=t.bottom),{top:s,left:e,bottom:l,right:i}}function A(o,t,s){let e=parseFloat(o.style[s]);if(!e||isNaN(e)){switch(t){case"outer":e=o[s==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":e=o[s==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:e=o[s==="width"?"clientWidth":"clientHeight"];break}e=o.getBoundingClientRect()[s]}if(!e||isNaN(e)){let l=o.style.display,i=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[s];e=parseFloat(n),isNaN(e)&&(e=0),o.style.display=l,o.style.position=i}return e||0}function B(o,t){let s=null,e=o?.parentElement;for(;e;){let[l,i,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))e.classList.contains(c)&&(i?e?.tagName.toLowerCase()===i&&(s=e):s=e);e=e.parentElement}return s}function Y(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function _(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function dt(o,t){if(o?.classList){let e=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[e]("selected")}}function lt(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}var H=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 s=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",s,!1),this.destroy=()=>{y(this.contentEl),this.scrollEl.removeEventListener("scroll",s,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let n=g(t[0]);this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.cache.data=[t[0]],this.getRowsHeight()}let s=this.initData(t,this.getNum()),e=this.checkChanges("data",s.rows),l=this.checkChanges("top",s.topOffset),i=this.checkChanges("bottom",s.bottomOffset);y(this.contentEl),e&&l?(s.topOffset&&this.contentEl.appendChild(this.getExtra("top",s.topOffset)),s.rows.forEach(n=>this.contentEl.appendChild(g(n))),s.bottomOffset&&this.contentEl.appendChild(this.getExtra("bottom",s.bottomOffset))):i&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${s.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 s=this.contentEl.children,e=s[Math.floor(s.length/2)];this.itemHeight=e.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,s){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let e=Math.max((this.clusterRows-d.BLOCK_ROWS)*s,0),l=e+this.clusterRows,i=Math.max(e*this.itemHeight,0),n=Math.max((t.length-l)*this.itemHeight,0),u=[],c=e;i<1&&c++;for(let r=e;r<l;r++)t[r]&&u.push(t[r]);return this.dataStart=e,this.dataEnd=l,{topOffset:i,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,s){let e=s!==this.cache[t];return this.cache[t]=s,e}getExtra(t,s){let e=document.createElement("li");return e.className=`virtual-scroll-${t}`,s&&(e.style.height=`${s}px`),e}};var T=class{constructor(t,s){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"closeSearchElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"lastFocusedItemKey","");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,"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,s),this._bindEventService=new S({distinctEvent:!0})}get isRenderAsHtml(){return this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&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(s=>delete this[s])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,s=this.options.locale.split(/-|_/);if(s[0]=s[0].toLowerCase(),s[1]&&(s[1]=s[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[s.join("-")])Object.assign(this.options,t[s.join("-")]);else if(t[s[0]])Object.assign(this.options,t[s[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=h("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let s=this.elm.getAttribute("title")||"";s&&(this.parentElm.title=s),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.tabIndex;let e;this.tabIndex!==null&&(this.elm.tabIndex=-1,e=this.tabIndex),this.choiceElm=h("button",{className:"ms-choice",type:"button"},this.parentElm),e!==void 0&&(this.choiceElm.tabIndex=e),this.choiceElm.appendChild(h("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(h("div",{className:"icon-close"})),this.choiceElm.appendChild(h("div",{className:"icon-caret"})),this.dropElm=h("div",{className:`ms-drop ${this.options.position}`},this.parentElm),t&&(this.dropElm.dataset.name=t);let l=this.elm.getAttribute("data-test")||this.options.dataTest;l&&(this.parentElm.dataset.test=l,this.dropElm.dataset.test=l),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`),Y(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`selectAll${t}`,this.selectGroupName=`selectGroup${t}`,this.selectItemName=`selectItem${t}`,this.options.keepOpen||(this._bindEventService.unbindAll("body-click"),this._bindEventService.bind(document.body,"click",i=>{i.target===this.choiceElm||B(i.target,".ms-choice")===this.choiceElm||(i.target===this.dropElm||B(i.target,".ms-drop")!==this.dropElm&&i.target!==this.elm)&&this.options.isOpen&&this.close()},void 0,"body-click"))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(s=>typeof s=="string"||typeof s=="number"?{text:s,value:s}:s);else if(typeof this.options.data=="object"){for(let[s,e]of Object.entries(this.options.data))t.push({value:s,text:`${e}`});this.data=t}}else this.elm.childNodes.forEach(s=>{let e=this.initRow(s);e&&t.push(e)}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=K(this.data||[])}initRow(t,s){let e={};return t.tagName?.toLowerCase()==="option"?(e.type="option",e.text=this.options.textTemplate(t),e.value=t.value,e.visible=!0,e.selected=!!t.selected,e.disabled=s||t.disabled,e.classes=t.getAttribute("class")||"",e.title=t.getAttribute("title")||"",t.dataset.value&&(e._value=t.dataset.value),Object.keys(t.dataset).length&&(e._data=t.dataset,e._data.divider&&(e.divider=e._data.divider)),e):t.tagName?.toLowerCase()==="optgroup"?(e.type="optgroup",e.label=this.options.labelTemplate(t),e.visible=!0,e.selected=!!t.selected,e.disabled=t.disabled,e.children=[],Object.keys(t.dataset).length&&(e._data=t.dataset),t.childNodes.forEach(l=>{e.children.push(this.initRow(l,e.disabled))}),e):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 s of this.data||[])s.type==="optgroup"?t+=s.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=h("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(h("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"})),this.options.showSearchClear&&this.filterParentElm.appendChild(h("span",{className:"icon-close"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=h("div",{className:"ms-select-all",tabIndex:0});let s=document.createElement("label");h("input",{type:"checkbox",ariaChecked:String(this.allSelected),checked:this.allSelected,dataset:{name:`selectAll${t}`},tabIndex:-1},s),s.appendChild(h("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(s),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=h("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=0,s=this.getListRows();if(this.options.selectAll&&!this.options.single&&(t=-1),s.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let e=this.dropElm.style.display!=="none";e||(this.dropElm.style.left="-10000",this.dropElm.style.display="block");let l=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+t,this.updateDataEnd=this.virtualScroll.dataEnd+t,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>this.getDataLength()&&(this.updateDataEnd=this.getDataLength()))};this.ulElm&&(this.virtualScroll=new H({rows:s,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{l(),this.events()}})),l(),e||(this.dropElm.style.left="0",this.dropElm.style.display="none")}else this.ulElm&&(y(this.ulElm),s.forEach(e=>this.ulElm.appendChild(g(e)))),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;return this.events(),s}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(s=>t.push(...this.initListItem(s))),t.push({tagName:"li",props:{className:"ms-no-results",textContent:this.formatNoMatchesFound(),tabIndex:0}}),t}initListItem(t,s=0){let e=t?.title||"",l=this.options.multiple?"multiple":"",i=this.options.single?"radio":"checkbox",n="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(n="hide-radio "),t.selected&&(n+="selected "),t.type==="optgroup"){let k=[],J=this.options.hideOptgroupCheckboxes||this.options.single?{tagName:"span",props:{dataset:{name:this.selectGroupName,key:t._key}}}:{tagName:"input",props:{type:"checkbox",dataset:{name:this.selectGroupName,key:t._key},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:t.disabled,tabIndex:-1}};!n.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(n+="hide-radio ");let N={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(N.props,t.label);let x={tagName:"li",props:{className:`group ${n}`.trim(),tabIndex:n.includes("hide-radio")||t.disabled?-1:0},children:[{tagName:"label",props:{className:`optgroup${this.options.single||t.disabled?" disabled":""}`},children:[J,N]}]},W=this.options.cssStyler(t),P=String(this.options.styler(t)||"");return P&&(x.props.style=w(P)),W&&(x.props.style=W),k.push(x),t.children.forEach(X=>k.push(...this.initListItem(X,1))),k}if(n+=t.classes||"",s&&this.options.single&&(n+=`option-level-${s} `),t.divider)return[{tagName:"li",props:{className:"option-divider"}}];let u=l||n?(l+n).trim():"",c=`${t.disabled?"disabled":""}`,r={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(r.props,t.text);let p={tagName:"input",props:{type:i,value:encodeURI(t.value),dataset:{key:t._key,name:this.selectItemName},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:!!t.disabled,tabIndex:-1}};t.selected&&(p.attrs={checked:"checked"});let E={tagName:"li",props:{className:u,title:e,tabIndex:t.disabled?-1:0,dataset:{key:t._key}},children:[{tagName:"label",props:{className:c},children:[p,r]}]},f=this.options.cssStyler(t),I=String(this.options.styler(t)||"");return I&&(E.props.style=w(I)),f&&(E.props.style=f),[E]}initSelected(t=!1){let s=0;for(let e of this.data||[])if(e.type==="optgroup"){let l=e.children.filter(i=>i&&i.selected&&!i.disabled&&i.visible).length;e.children.length&&(e.selected=!this.options.single&&l&&l===e.children.filter(i=>i&&!i.disabled&&i.visible&&!i.divider).length),s+=l}else s+=e.selected&&!e.disabled&&e.visible?1:0;this.allSelected=this.data?.filter(e=>e.selected&&!e.disabled&&e.visible).length===this.data?.filter(e=>!e.disabled&&e.visible&&!e.divider).length,t||(this.allSelected?this.options.onCheckAll():s===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=A(this.dropElm,"outer","width")+20)):t=A(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbindAll(["ok-button","search-input","select-all-checkbox","input-checkbox-list","group-checkbox-list"]),this.closeSearchElm=this.filterParentElm?.querySelector(".icon-close"),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[data-name="${this.selectAllName}"]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectGroupName}"],span[data-name="${this.selectGroupName}"]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:enabled`),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.closeSearchElm&&this._bindEventService.bind(this.closeSearchElm,"click",e=>{e.preventDefault(),this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()},void 0,"search-input"),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let l=[];this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&l.push(i)}),l.length&&l[0].hasAttribute("data-name")&&this.setSelects([l[0].value])}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()},void 0,"search-input")),this.selectAllElm&&this._bindEventService.bind(this.selectAllElm,"click",e=>this._checkAll(e.currentTarget?.checked),void 0,"select-all-checkbox"),this.okButtonElm&&this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()},void 0,"ok-button"),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let l=e.currentTarget,i=l.checked,n=b(this.data,"_key",l.dataset.key);this._checkGroup(n,i),this.options.onOptgroupClick(C({label:n.label,selected:n.selected,data:n._data,children:n.children.map(u=>{if(u)return C({text:u.text,value:u.value,selected:u.selected,disabled:u.disabled,data:u._data})})}))},void 0,"group-checkbox-list"),this._bindEventService.bind(this.selectItemElms,"click",e=>{let l=e.currentTarget,i=l.checked,n=b(this.data,"_key",l.dataset.key),u=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(n)===!1){u();return}this._check(n,i),this.options.onClick(C({text:n.text,value:n.value,selected:n.selected,data:n._data})),u()},void 0,"input-checkbox-list"),this.lastFocusedItemKey&&this.dropElm.querySelector(`li[data-key=${this.lastFocusedItemKey}]`)?.focus();let s=Array.from(this.dropElm.querySelectorAll("div.ms-select-all, li"));this._bindEventService.unbindAll("tabindex-arrow"),this._bindEventService.bind(this.dropElm,"keydown",e=>{let l=e.target.closest(".ms-select-all")||e.target.closest("li");if(this.dropElm.contains(l)){let i=0,n=s.length;for(i=0;i<n&&!s[i].isEqualNode(l);i++);switch(e.key){case"ArrowUp":e.preventDefault(),i>0&&(this.lastFocusedItemKey=this.focusOnUpDownItem(s,i,e.key)?.dataset.key||"");break;case"ArrowDown":e.preventDefault(),i<s.length-1&&(this.lastFocusedItemKey=this.focusOnUpDownItem(s,i,e.key)?.dataset.key||"");break;case"Enter":case" ":e.preventDefault(),l.querySelector("input")?.click(),this.options.single&&(this.choiceElm.focus(),this.lastFocusedItemKey=this.choiceElm?.dataset.key||"");break;default:}}},void 0,"tabindex-arrow")}focusOnUpDownItem(t,s,e){let l=s,i;for(;i=t[e==="ArrowUp"?l-1:l+1];){if(i.classList.contains("option-divider")){e==="ArrowUp"?l--:l++;continue}break}return i?(i.focus(),i):null}open(t=0){if(t!==null&&t>=0){let s;clearTimeout(s),s=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.getDataLength()||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let i=F(this.dropElm),n;this.options.container instanceof Node?n=this.options.container:typeof this.options.container=="string"&&(n=this.options.container==="body"?document.body:document.querySelector(this.options.container)),n.appendChild(this.dropElm),this.dropElm.style.top=`${i?.top??0}px`,this.dropElm.style.left=`${i?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${A(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,s=this.options.maxHeight;this.options.maxHeightUnit==="row"&&(s=A(this.dropElm.querySelector("ul>li"),"outer","height")*this.options.maxHeight);let e=this.dropElm.querySelector("ul");e&&(t&&(e.style.minHeight=`${t}px`),e.style.maxHeight=`${s}px`),this.dropElm.querySelectorAll(".multiple").forEach(i=>i.style.width=`${this.options.multipleWidth}px`),this.getDataLength()&&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:i,top:n}=L(this.dropElm),u=this.dropElm.getBoundingClientRect().height;l=i<u&&n>i?"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()}applyAsTextOrHtmlWhenEnabled(t,s){t||(t={}),this.isRenderAsHtml?t.innerHTML=typeof this.options.sanitizer=="function"?this.options.sanitizer(s):s:t.textContent=s}update(t=!1){let s=this.getSelects(),e=this.getSelects("text");this.options.displayValues&&(e=s);let l=this.choiceElm?.querySelector("span"),i=s.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=s.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?q(r):r}return e.join(this.options.displayDelimiter)};if(l){if(i===0){let r=this.options.placeholder||"";l.classList.add("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,r)}else i<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&i===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&i>this.options.minimumCountSelected?n=`${e.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(i,this.dataTotal)&&i>this.options.minimumCountSelected?n=this.formatCountSelected(i,this.dataTotal):n=u();if(n!==null&&(l?.classList.remove("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,n)),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was deprecated and replaced by `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";l.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(p=>p===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(t){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let l=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${l._key}]`);if(i){i.checked=l.selected;let n=i.closest("li");n&&(l.selected&&!n.classList.contains("selected")?n.classList.add("selected"):l.selected||n.classList.remove("selected"))}}let s=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,_(this.selectAllElm.closest("li"),!s)),_(this.noResultsElm,s),this.virtualScroll&&(this.virtualScroll.rows=t??this.getListRows())}getData(){return this.options.data}getDataLength(){return this.data?.length??0}getOptions(t=!0){let s=Object.assign({},this.options);return delete s.data,t?D(s):this.options}refreshOptions(t){G(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 s=[];for(let e of this.data||[])if(e.type==="optgroup"){let l=e.children.filter(i=>i?.selected);if(!l.length)continue;if(t==="value"||this.options.single)s.push(...l.map(i=>t==="value"&&i._value||i[t]));else{let i=[];i.push("["),i.push(e.label),i.push(`: ${l.map(n=>n[t]).join(", ")}`),i.push("]"),s.push(i.join(""))}}else e.selected&&s.push(t==="value"&&e._value||e[t]);return s}setSelects(t,s="value",e=!1){let l=!1,i=n=>{for(let u of n){let c=!1;if(s==="text"){let r=document.createElement("div");this.applyAsTextOrHtmlWhenEnabled(r,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&&(l=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?i(n.children):i([n]);l&&(this.initSelected(e),this.updateSelected(),this.update(e))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let s=b(this.data,"value",t);s&&this._check(s,!0)}uncheck(t){let s=b(this.data,"value",t);s&&this._check(s,!1)}_check(t,s){this.options.single&&this._checkAll(!1,!0),t.selected=s,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,s){for(let e of this.data||[])e.type==="optgroup"?this._checkGroup(e,t,!0):!e.disabled&&!e.divider&&(s||e.visible)&&(e.selected=t);s||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,s,e){t.selected=s,t.children.forEach(l=>{l&&!l.disabled&&!l.divider&&(e||l.visible)&&(l.selected=s)}),e||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let s of t.children)s&&(s.divider||(s.selected=!s.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 s=this.searchInputElm?.value.trim()??"",e=s.toLowerCase();if(this.filterText===e)return;this.filterText=e;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let n=`${i?.label??""}`;if(i!=null){let u=this.options.customFilter({label:m(n.toString().toLowerCase()),search:m(e),originalLabel:n,originalSearch:s,row:i});i.visible=u;for(let c of i.children)c&&(c.visible=u)}}else{for(let n of i.children)if(n!=null){let u=`${n?.text??""}`;n.visible=this.options.customFilter({text:m(u.toString().toLowerCase()),search:m(e),originalText:u,originalSearch:s,row:n,parent:i})}i.visible=i.children.filter(n=>n?.visible).length>0}else{let n=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(n.toString().toLowerCase()),search:m(e),originalText:n,originalSearch:s,row:i})}let l=this.initListItems();this.initSelected(t),this.updateSelected(l),t||this.options.onFilter(s)}adjustDropHeight(t){let s=t!=="top",e=this.filterParentElm?.getBoundingClientRect().height??0,l=this.okButtonElm?.getBoundingClientRect().height??0,i=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=e+l+i+5,{bottom:u,top:c}=L(this.parentElm),r=this.options.maxHeight;if(s?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let p=this.dropElm?.querySelector("ul");return p&&(p.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let s="bottom";if(this.dropElm&&this.parentElm){let{bottom:e,top:l}=L(this.dropElm),{top:i,left:n}=F(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,p=this.parentElm.getBoundingClientRect().width;if(e>u)s="bottom";else if(u>e&&l>e){if(this.options.container){let E=i-u;E<0&&(E=0),(E>0||t)&&(s="top",this.dropElm.style.top=`${E<0?0:E}px`)}else s="top",this.dropElm.classList.add(s);this.dropElm.classList.remove("bottom")}r-c<n&&(this.dropElm.style.left=`${n-(c-p)}px`)}return s}adjustDropWidthByText(){let s=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(s=this.options.dropWidth||this.options.width||0);let e=this.dropElm.querySelector(".ms-select-all span"),l=this.dropElm.querySelector("ul"),i=26,n=e?.clientWidth??0+i,c=l.scrollHeight>l.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(p=>{p.scrollWidth>r&&(r=p.scrollWidth)}),r+=i+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),(s==="100%"||+s<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 s=t.offsetWidth;t.style.overflow="scroll";let e=document.createElement("div");e.style.width="100%",t.appendChild(e);let l=e.offsetWidth;return t.parentNode?.removeChild(t),s-l}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,s){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${s}`):this.options.formatCountSelected(t,s)}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 O=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 s=Array.from(o),e=[];for(let l=0;l<s.length;l++){let i=s[l];try{i._multipleSelect!==void 0&&(i._multipleSelect.destroy(),delete i._multipleSelect),i._multipleSelect=new T(i,t||{}),i._multipleSelect.init();let n=i._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete i._multipleSelect,n.onAfterHardDestroyed=()=>e[l]=null,e.push(i._multipleSelect)}catch(n){console.error(n)}}return e.length===1?e[0]:e}O.defaults=d.DEFAULTS;O.locales={...v};O.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=O);export{S as BindingEventService,T as MultipleSelectInstance,H as VirtualScroll,L as calculateAvailableSpace,G as compareObjects,g as convertItemRowToHtml,w as convertStringStyleToElementStyle,h as createDomElement,V as createDomStructure,D as deepCopy,y as emptyElement,b as findByParam,B as findParent,F as getElementOffset,A as getElementSize,Y as insertAfter,M as isDefined,O as multipleSelect,U as objectRemoveEmptyProps,m as removeDiacritics,C as removeUndefined,K as setDataKeys,q as stripScripts,z as toCamelCase,_ as toggleElement,dt as toggleElementClass,lt as windowScrollPosition};
var Z=Object.defineProperty;var Q=(o,t,s)=>t in o?Z(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s;var a=(o,t,s)=>(Q(o,typeof t!="symbol"?t+"":t,s),s);var S=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,s,e,l,i=""){let n=Array.isArray(s)?s:[s];if(typeof t?.forEach=="function")t.forEach(u=>{for(let c of n)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(u,c))&&(u.addEventListener(c,e,l),this._boundedEvents.push({element:u,eventName:c,listener:e,groupName:i}))});else for(let u of n)(!this._distinctEvent||this._distinctEvent&&!this.hasBinding(t,u))&&(t.addEventListener(u,e,l),this._boundedEvents.push({element:t,eventName:u,listener:e,groupName:i}))}hasBinding(t,s){return this._boundedEvents.some(e=>e.element===t&&(!s||e.eventName===s))}unbind(t,s,e){if(t){let l=Array.isArray(t)?t:[t],i=Array.isArray(s)?s||"":[s||""];for(let n of l){e||(e=this._boundedEvents.find(u=>{if(u.element===n&&(!s||u.eventName===s))return u.listener}));for(let u of i)n?.removeEventListener?.(u,e)}}}unbindAll(t){if(t){let s=Array.isArray(t)?t:[t];for(let e=this._boundedEvents.length-1;e>=0;--e){let l=this._boundedEvents[e];if(s.some(i=>i===l.groupName)){let{element:i,eventName:n,listener:u}=l;this.unbind(i,n,u),this._boundedEvents.splice(e,1)}}}else for(;this._boundedEvents.length>0;){let s=this._boundedEvents.pop(),{element:e,eventName:l,listener:i}=s;this.unbind(e,l,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 v=$.locales;var tt=50,et=4,j={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:s,search:e}=o;return(s||t||"").includes(e)},showClear:!1,autoAdjustDropHeight:!1,autoAdjustDropPosition:!1,autoAdjustDropWidthByTextSize:!1,adjustedHeightPadding:10,useSelectOptionLabel:!1,useSelectOptionLabelToHtml:!1,cssStyler:()=>null,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,onBeforeClick:()=>!0,onClick:()=>!1,onFilter:()=>!1,onClear:()=>!1,onAfterCreate:()=>!1,onDestroy:()=>!1,onAfterDestroy:()=>!1,onDestroyed:()=>!1},st=["init","getOptions","refreshOptions","getSelects","setSelects","enable","disable","open","close","check","uncheck","checkAll","uncheckAll","checkInvert","focus","blur","refresh","destroy"];Object.assign(j,v["en-US"]);var it={BLOCK_ROWS:tt,CLUSTER_BLOCKS:et,DEFAULTS:j,METHODS:st},d=it;function G(o,t,s=!1){let e=Object.keys(o),l=Object.keys(t);if(s&&e.length!==l.length)return!1;for(let i of e)if(l.includes(i)&&o[i]!==t[i])return!1;return!0}function D(o){let t=()=>{let l={};for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&(l[i]=D(o[i]));return l},s=()=>o.map(l=>D(l)),e=Object.prototype.toString.call(o).slice(8,-1).toLowerCase();return e==="object"?t():e==="array"?s():o}function M(o){return o!=null&&o!==""}function U(o,t){return typeof o=="object"?Object.fromEntries(t?Object.entries(o).filter(([s,e])=>!M(e)&&!t.includes(s)||M(e)):Object.entries(o).filter(([s,e])=>M(e))):o}function K(o){let t=0;return o.forEach((s,e)=>{s.type==="optgroup"?(s._key=`group_${e}`,s.visible=typeof s.visible>"u"?!0:s.visible,s.children.forEach((l,i)=>{l&&(l.visible=typeof l?.visible>"u"?!0:l.visible,l.divider||(l._key=`option_${e}_${i}`,t+=1))})):(s.visible=typeof s.visible>"u"?!0:s.visible,s.divider||(s._key=`option_${e}`,t+=1))}),t}function b(o,t,s){if(Array.isArray(o))for(let e of o){if(e[t]===s||e[t]===`${+e[t]}`&&+e[t]===s)return e;if(e.type==="optgroup"){for(let l of e.children)if(l&&(l[t]===s||l[t]===`${+l[t]}`&&+l[t]===s))return l}}}function q(o){return o.replace(/(\b)(on[a-z]+)(\s*)=([^>]*)|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(&lt;|&#60;)(\/*)(script|script defer)(.*)(&#62;|&gt;|&gt;">)/gi,"")}function C(o){return Object.keys(o).forEach(t=>o[t]===void 0?delete o[t]:""),o}function z(o){return o.replace(/[\W_]+(.)/g,(t,s)=>s.toUpperCase())}function m(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((s,{letters:e,base:l})=>s.replace(e,l),o)}function w(o){let t={};if(o){let s=o.replace(/\s/g,"").split(";");for(let e of s){let[l,i]=e.trim().split(":");l&&(t[z(l)]=i.trim())}console.warn("[multiple-select-vanilla] Please note that `styler` is deprecated, please migrate to `cssStyler` when possible.")}return t}function L(o){let t=0,s=0,e=0,l=0,i=window.innerHeight??0,n=window.innerWidth??0,u=lt(),c=u.top,r=u.left,p=F(o);if(p){let E=p.top??0,f=p.left??0;s=E-c,t=i-(E-c),e=f-r,l=n-(f-r)}return{top:s,bottom:t,left:e,right:l}}function h(o,t,s){let e=document.createElement(o);return t&&Object.keys(t).forEach(l=>{let i=t[l];typeof i=="object"?Object.assign(e[l],i):e[l]=t[l]}),s?.appendChild&&s.appendChild(e),e}function V(o,t,s){let e="";o.props?.innerHTML&&(e=o.props.innerHTML,delete o.props.innerHTML);let l=h(o.tagName,U(o.props,["className","title","style"]),t),i=s;if(i||(i=l),e&&(l.innerHTML=e),o.attrs)for(let n of Object.keys(o.attrs))l.setAttribute(n,o.attrs[n]);if(o.children)for(let n of o.children)V(n,l,i);return t?.appendChild(l),l}function g(o){return o.hasOwnProperty("tagName")?V(o):document.createElement("li")}function y(o){for(;o?.firstChild;)o.lastChild&&o.removeChild(o.lastChild);return o}function F(o){if(!o)return;let t=o?.getBoundingClientRect?.(),s=0,e=0,l=0,i=0;return t?.top!==void 0&&t.left!==void 0&&(s=t.top+window.pageYOffset,e=t.left+window.pageXOffset,i=t.right,l=t.bottom),{top:s,left:e,bottom:l,right:i}}function A(o,t,s){let e=parseFloat(o.style[s]);if(!e||isNaN(e)){switch(t){case"outer":e=o[s==="width"?"offsetWidth":"offsetHeight"];break;case"scroll":e=o[s==="width"?"scrollWidth":"scrollHeight"];break;case"inner":default:e=o[s==="width"?"clientWidth":"clientHeight"];break}e=o.getBoundingClientRect()[s]}if(!e||isNaN(e)){let l=o.style.display,i=o.style.position;o.style.display="block",o.style.position="absolute";let n=window.getComputedStyle(o)[s];e=parseFloat(n),isNaN(e)&&(e=0),o.style.display=l,o.style.position=i}return e||0}function B(o,t){let s=null,e=o?.parentElement;for(;e;){let[l,i,n,u]=t.match(/^([a-z]*)([#.]{1})([a-z\-]+)$/i)||[];if(n&&u)for(let c of u.replace(n,"").split(" "))e.classList.contains(c)&&(i?e?.tagName.toLowerCase()===i&&(s=e):s=e);e=e.parentElement}return s}function Y(o,t){o.parentNode?.insertBefore(t,o.nextSibling)}function _(o,t){o?.style&&(o.style.display=o.style.display==="none"&&t!==!1||t===!0?"block":"none")}function dt(o,t){if(o?.classList){let e=t===!0||!o.classList.contains("selected")?"add":"remove";o.classList[e]("selected")}}function lt(){return{left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0}}var H=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 s=()=>{this.lastCluster!==(this.lastCluster=this.getNum())&&(this.initDOM(this.rows),this.callback())};this.scrollEl.addEventListener("scroll",s,!1),this.destroy=()=>{y(this.contentEl),this.scrollEl.removeEventListener("scroll",s,!1)}}initDOM(t){if(typeof this.clusterHeight>"u"){this.cache.scrollTop=this.scrollEl.scrollTop;let n=g(t[0]);this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.contentEl.appendChild(n),this.cache.data=[t[0]],this.getRowsHeight()}let s=this.initData(t,this.getNum()),e=this.checkChanges("data",s.rows),l=this.checkChanges("top",s.topOffset),i=this.checkChanges("bottom",s.bottomOffset);y(this.contentEl),e&&l?(s.topOffset&&this.contentEl.appendChild(this.getExtra("top",s.topOffset)),s.rows.forEach(n=>this.contentEl.appendChild(g(n))),s.bottomOffset&&this.contentEl.appendChild(this.getExtra("bottom",s.bottomOffset))):i&&this.contentEl.lastChild&&(this.contentEl.lastChild.style.height=`${s.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 s=this.contentEl.children,e=s[Math.floor(s.length/2)];this.itemHeight=e.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,s){if(t.length<d.BLOCK_ROWS)return{topOffset:0,bottomOffset:0,rowsAbove:0,rows:t};let e=Math.max((this.clusterRows-d.BLOCK_ROWS)*s,0),l=e+this.clusterRows,i=Math.max(e*this.itemHeight,0),n=Math.max((t.length-l)*this.itemHeight,0),u=[],c=e;i<1&&c++;for(let r=e;r<l;r++)t[r]&&u.push(t[r]);return this.dataStart=e,this.dataEnd=l,{topOffset:i,bottomOffset:n,rowsAbove:c,rows:u}}checkChanges(t,s){let e=s!==this.cache[t];return this.cache[t]=s,e}getExtra(t,s){let e=document.createElement("li");return e.className=`virtual-scroll-${t}`,s&&(e.style.height=`${s}px`),e}};var T=class{constructor(t,s){this.elm=t;a(this,"_bindEventService");a(this,"allSelected",!1);a(this,"fromHtml",!1);a(this,"choiceElm");a(this,"closeElm");a(this,"closeSearchElm");a(this,"filterText","");a(this,"updateData",[]);a(this,"data",[]);a(this,"dataTotal");a(this,"dropElm");a(this,"okButtonElm");a(this,"filterParentElm");a(this,"lastFocusedItemKey","");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,"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,s),this._bindEventService=new S({distinctEvent:!0})}get isRenderAsHtml(){return this.options.renderOptionLabelAsHtml||this.options.useSelectOptionLabelToHtml}init(){this.initLocale(),this.initContainer(),this.initData(),this.initSelected(!0),this.initFilter(),this.initDrop(),this.initView(),this.options.onAfterCreate()}destroy(t=!0){this.elm&&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(s=>delete this[s])))}initLocale(){if(this.options.locale){let t=window.multipleSelect.locales,s=this.options.locale.split(/-|_/);if(s[0]=s[0].toLowerCase(),s[1]&&(s[1]=s[1].toUpperCase()),t[this.options.locale])Object.assign(this.options,t[this.options.locale]);else if(t[s.join("-")])Object.assign(this.options,t[s.join("-")]);else if(t[s[0]])Object.assign(this.options,t[s[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=h("div",{className:`ms-parent ${this.elm.className||""} ${this.options.classes}`,dataset:{test:"sel"}});let s=this.elm.getAttribute("title")||"";s&&(this.parentElm.title=s),this.options.placeholder=this.options.placeholder||this.elm.getAttribute("placeholder")||"",this.tabIndex=this.elm.tabIndex;let e;this.tabIndex!==null&&(this.elm.tabIndex=-1,e=this.tabIndex),this.choiceElm=h("button",{className:"ms-choice",type:"button"},this.parentElm),e!==void 0&&(this.choiceElm.tabIndex=e),this.choiceElm.appendChild(h("span",{className:"ms-placeholder",textContent:this.options.placeholder})),this.options.showClear&&this.choiceElm.appendChild(h("div",{className:"icon-close"})),this.choiceElm.appendChild(h("div",{className:"icon-caret"})),this.dropElm=h("div",{className:`ms-drop ${this.options.position}`,ariaExpanded:"false"},this.parentElm),t&&(this.dropElm.dataset.name=t);let l=this.elm.getAttribute("data-test")||this.options.dataTest;l&&(this.parentElm.dataset.test=l,this.dropElm.dataset.test=l),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`),Y(this.elm,this.parentElm),this.elm.disabled&&this.choiceElm.classList.add("disabled"),this.selectAllName=`selectAll${t}`,this.selectGroupName=`selectGroup${t}`,this.selectItemName=`selectItem${t}`,this.options.keepOpen||(this._bindEventService.unbindAll("body-click"),this._bindEventService.bind(document.body,"click",i=>{i.target===this.choiceElm||B(i.target,".ms-choice")===this.choiceElm||(i.target===this.dropElm||B(i.target,".ms-drop")!==this.dropElm&&i.target!==this.elm)&&this.options.isOpen&&this.close()},void 0,"body-click"))}initData(){let t=[];if(this.options.data){if(Array.isArray(this.options.data))this.data=this.options.data.map(s=>typeof s=="string"||typeof s=="number"?{text:s,value:s}:s);else if(typeof this.options.data=="object"){for(let[s,e]of Object.entries(this.options.data))t.push({value:s,text:`${e}`});this.data=t}}else this.elm.childNodes.forEach(s=>{let e=this.initRow(s);e&&t.push(e)}),this.options.data=t,this.data=t,this.fromHtml=!0;this.dataTotal=K(this.data||[])}initRow(t,s){let e={};return t.tagName?.toLowerCase()==="option"?(e.type="option",e.text=this.options.textTemplate(t),e.value=t.value,e.visible=!0,e.selected=!!t.selected,e.disabled=s||t.disabled,e.classes=t.getAttribute("class")||"",e.title=t.getAttribute("title")||"",t.dataset.value&&(e._value=t.dataset.value),Object.keys(t.dataset).length&&(e._data=t.dataset,e._data.divider&&(e.divider=e._data.divider)),e):t.tagName?.toLowerCase()==="optgroup"?(e.type="optgroup",e.label=this.options.labelTemplate(t),e.visible=!0,e.selected=!!t.selected,e.disabled=t.disabled,e.children=[],Object.keys(t.dataset).length&&(e._data=t.dataset),t.childNodes.forEach(l=>{e.children.push(this.initRow(l,e.disabled))}),e):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 s of this.data||[])s.type==="optgroup"?t+=s.children.length:t+=1;this.options.filter=t>this.options.filterByDataLength}initList(){if(this.options.filter&&(this.filterParentElm=h("div",{className:"ms-search"},this.dropElm),this.filterParentElm.appendChild(h("input",{autocomplete:"off",autocapitalize:"off",spellcheck:!1,type:"text",placeholder:this.options.filterPlaceholder||"\u{1F50E}\uFE0E"})),this.options.showSearchClear&&this.filterParentElm.appendChild(h("span",{className:"icon-close"}))),this.options.selectAll&&!this.options.single){let t=this.elm.getAttribute("name")||this.options.name||"";this.selectAllParentElm=h("div",{className:"ms-select-all",tabIndex:0});let s=document.createElement("label");h("input",{type:"checkbox",ariaChecked:String(this.allSelected),checked:this.allSelected,dataset:{name:`selectAll${t}`},tabIndex:-1},s),s.appendChild(h("span",{textContent:this.formatSelectAll()})),this.selectAllParentElm.appendChild(s),this.dropElm.appendChild(this.selectAllParentElm)}this.ulElm=document.createElement("ul"),this.dropElm.appendChild(this.ulElm),this.options.showOkButton&&!this.options.single&&(this.okButtonElm=h("button",{className:"ms-ok-button",type:"button",textContent:this.formatOkButton()},this.dropElm)),this.initListItems()}initListItems(){let t=0,s=this.getListRows();if(this.options.selectAll&&!this.options.single&&(t=-1),s.length>d.BLOCK_ROWS*d.CLUSTER_BLOCKS){this.virtualScroll?.destroy();let e=this.dropElm.style.display!=="none";e||(this.dropElm.style.left="-10000",this.dropElm.style.display="block",this.dropElm.ariaExpanded="true");let l=()=>{this.virtualScroll&&(this.updateDataStart=this.virtualScroll.dataStart+t,this.updateDataEnd=this.virtualScroll.dataEnd+t,this.updateDataStart<0&&(this.updateDataStart=0),this.updateDataEnd>this.getDataLength()&&(this.updateDataEnd=this.getDataLength()))};this.ulElm&&(this.virtualScroll=new H({rows:s,scrollEl:this.ulElm,contentEl:this.ulElm,sanitizer:this.options.sanitizer,callback:()=>{l(),this.events()}})),l(),e||(this.dropElm.style.left="0",this.dropElm.style.display="none",this.dropElm.ariaExpanded="false")}else this.ulElm&&(y(this.ulElm),s.forEach(e=>this.ulElm.appendChild(g(e)))),this.updateDataStart=0,this.updateDataEnd=this.updateData.length,this.virtualScroll=null;return this.events(),s}getListRows(){let t=[];return this.updateData=[],this.data?.forEach(s=>t.push(...this.initListItem(s))),t.push({tagName:"li",props:{className:"ms-no-results",textContent:this.formatNoMatchesFound(),tabIndex:0}}),t}initListItem(t,s=0){let e=t?.title||"",l=this.options.multiple?"multiple":"",i=this.options.single?"radio":"checkbox",n="";if(!t?.visible)return[];if(this.updateData.push(t),this.options.single&&!this.options.singleRadio&&(n="hide-radio "),t.selected&&(n+="selected "),t.type==="optgroup"){let x=[],J=this.options.hideOptgroupCheckboxes||this.options.single?{tagName:"span",props:{dataset:{name:this.selectGroupName,key:t._key}}}:{tagName:"input",props:{type:"checkbox",dataset:{name:this.selectGroupName,key:t._key},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:t.disabled,tabIndex:-1}};!n.includes("hide-radio")&&(this.options.hideOptgroupCheckboxes||this.options.single)&&(n+="hide-radio ");let N={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(N.props,t.label);let k={tagName:"li",props:{className:`group ${n}`.trim(),tabIndex:n.includes("hide-radio")||t.disabled?-1:0},children:[{tagName:"label",props:{className:`optgroup${this.options.single||t.disabled?" disabled":""}`},children:[J,N]}]},W=this.options.cssStyler(t),P=String(this.options.styler(t)||"");return P&&(k.props.style=w(P)),W&&(k.props.style=W),x.push(k),t.children.forEach(X=>x.push(...this.initListItem(X,1))),x}if(n+=t.classes||"",s&&this.options.single&&(n+=`option-level-${s} `),t.divider)return[{tagName:"li",props:{className:"option-divider"}}];let u=l||n?(l+n).trim():"",c=`${t.disabled?"disabled":""}`,r={tagName:"span",props:{}};this.applyAsTextOrHtmlWhenEnabled(r.props,t.text);let p={tagName:"input",props:{type:i,value:encodeURI(t.value),dataset:{key:t._key,name:this.selectItemName},ariaChecked:String(t.selected||!1),checked:!!t.selected,disabled:!!t.disabled,tabIndex:-1}};t.selected&&(p.attrs={checked:"checked"});let E={tagName:"li",props:{className:u,title:e,tabIndex:t.disabled?-1:0,dataset:{key:t._key}},children:[{tagName:"label",props:{className:c},children:[p,r]}]},f=this.options.cssStyler(t),I=String(this.options.styler(t)||"");return I&&(E.props.style=w(I)),f&&(E.props.style=f),[E]}initSelected(t=!1){let s=0;for(let e of this.data||[])if(e.type==="optgroup"){let l=e.children.filter(i=>i&&i.selected&&!i.disabled&&i.visible).length;e.children.length&&(e.selected=!this.options.single&&l&&l===e.children.filter(i=>i&&!i.disabled&&i.visible&&!i.divider).length),s+=l}else s+=e.selected&&!e.disabled&&e.visible?1:0;this.allSelected=this.data?.filter(e=>e.selected&&!e.disabled&&e.visible).length===this.data?.filter(e=>!e.disabled&&e.visible&&!e.divider).length,t||(this.allSelected?this.options.onCheckAll():s===0&&this.options.onUncheckAll())}initView(){let t;window.getComputedStyle?(t=window.getComputedStyle(this.elm).width,t==="auto"&&(t=A(this.dropElm,"outer","width")+20)):t=A(this.elm,"outer","width")+20,this.parentElm.style.width=`${this.options.width||t}px`,this.elm.classList.add("ms-offscreen")}events(){this._bindEventService.unbindAll(["ok-button","search-input","select-all-checkbox","input-checkbox-list","group-checkbox-list"]),this.closeSearchElm=this.filterParentElm?.querySelector(".icon-close"),this.searchInputElm=this.dropElm.querySelector(".ms-search input"),this.selectAllElm=this.dropElm.querySelector(`input[data-name="${this.selectAllName}"]`),this.selectGroupElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectGroupName}"],span[data-name="${this.selectGroupName}"]`),this.selectItemElms=this.dropElm.querySelectorAll(`input[data-name="${this.selectItemName}"]:enabled`),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.closeSearchElm&&this._bindEventService.bind(this.closeSearchElm,"click",e=>{e.preventDefault(),this.searchInputElm&&(this.searchInputElm.value="",this.searchInputElm.focus()),this.filter()}),this.searchInputElm&&(this._bindEventService.bind(this.searchInputElm,"keydown",e=>{e.code==="Tab"&&e.shiftKey&&this.close()},void 0,"search-input"),this._bindEventService.bind(this.searchInputElm,"keyup",e=>{if(this.options.filterAcceptOnEnter&&["Enter","Space"].includes(e.code)&&this.searchInputElm?.value){if(this.options.single){let l=[];this.selectItemElms?.forEach(i=>{i.closest("li")?.style.display!=="none"&&l.push(i)}),l.length&&l[0].hasAttribute("data-name")&&this.setSelects([l[0].value])}else this.selectAllElm?.click();this.close(),this.focus();return}this.filter()},void 0,"search-input")),this.selectAllElm&&this._bindEventService.bind(this.selectAllElm,"click",e=>this._checkAll(e.currentTarget?.checked),void 0,"select-all-checkbox"),this.okButtonElm&&this._bindEventService.bind(this.okButtonElm,"click",e=>{t(e),e.stopPropagation()},void 0,"ok-button"),this._bindEventService.bind(this.selectGroupElms,"click",e=>{let l=e.currentTarget,i=l.checked,n=b(this.data,"_key",l.dataset.key);this._checkGroup(n,i),this.options.onOptgroupClick(C({label:n.label,selected:n.selected,data:n._data,children:n.children.map(u=>{if(u)return C({text:u.text,value:u.value,selected:u.selected,disabled:u.disabled,data:u._data})})}))},void 0,"group-checkbox-list"),this._bindEventService.bind(this.selectItemElms,"click",e=>{let l=e.currentTarget,i=l.checked,n=b(this.data,"_key",l.dataset.key),u=()=>{this.options.single&&this.options.isOpen&&!this.options.keepOpen&&this.close()};if(this.options.onBeforeClick(n)===!1){u();return}this._check(n,i),this.options.onClick(C({text:n.text,value:n.value,selected:n.selected,data:n._data})),u()},void 0,"input-checkbox-list"),this.lastFocusedItemKey&&this.dropElm.querySelector(`li[data-key=${this.lastFocusedItemKey}]`)?.focus();let s=Array.from(this.dropElm.querySelectorAll("div.ms-select-all, li"));this._bindEventService.unbindAll("tabindex-arrow"),this._bindEventService.bind(this.dropElm,"keydown",e=>{let l=e.target.closest(".ms-select-all")||e.target.closest("li");if(this.dropElm.contains(l)){let i=0,n=s.length;for(i=0;i<n&&!s[i].isEqualNode(l);i++);switch(e.key){case"ArrowUp":e.preventDefault(),i>0&&(this.lastFocusedItemKey=this.focusOnUpDownItem(s,i,e.key)?.dataset.key||"");break;case"ArrowDown":e.preventDefault(),i<s.length-1&&(this.lastFocusedItemKey=this.focusOnUpDownItem(s,i,e.key)?.dataset.key||"");break;case"Enter":case" ":e.preventDefault(),l.querySelector("input")?.click(),this.options.single&&(this.choiceElm.focus(),this.lastFocusedItemKey=this.choiceElm?.dataset.key||"");break;default:}}},void 0,"tabindex-arrow")}focusOnUpDownItem(t,s,e){let l=s,i;for(;i=t[e==="ArrowUp"?l-1:l+1];){if(i.classList.contains("option-divider")){e==="ArrowUp"?l--:l++;continue}break}return i?(i.focus(),i):null}open(t=0){if(t!==null&&t>=0){let s;clearTimeout(s),s=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.dropElm.ariaExpanded="true",this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="block"),this.noResultsElm&&(this.noResultsElm.style.display="none"),this.getDataLength()||(this.selectAllElm?.parentElement&&(this.selectAllElm.parentElement.style.display="none"),this.noResultsElm&&(this.noResultsElm.style.display="block")),this.options.container){let i=F(this.dropElm),n;this.options.container instanceof Node?n=this.options.container:typeof this.options.container=="string"&&(n=this.options.container==="body"?document.body:document.querySelector(this.options.container)),n.appendChild(this.dropElm),this.dropElm.style.top=`${i?.top??0}px`,this.dropElm.style.left=`${i?.left??0}px`,this.dropElm.style.minWidth="auto",this.dropElm.style.width=`${A(this.parentElm,"outer","width")}px`}let t=this.options.minHeight,s=this.options.maxHeight;this.options.maxHeightUnit==="row"&&(s=A(this.dropElm.querySelector("ul>li"),"outer","height")*this.options.maxHeight);let e=this.dropElm.querySelector("ul");e&&(t&&(e.style.minHeight=`${t}px`),e.style.maxHeight=`${s}px`),this.dropElm.querySelectorAll(".multiple").forEach(i=>i.style.width=`${this.options.multipleWidth}px`),this.getDataLength()&&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:i,top:n}=L(this.dropElm),u=this.dropElm.getBoundingClientRect().height;l=i<u&&n>i?"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.dropElm.ariaExpanded="false",this.options.container&&(this.parentElm.appendChild(this.dropElm),this.dropElm.style.top="auto",this.dropElm.style.left="auto"),this.options.onClose()}applyAsTextOrHtmlWhenEnabled(t,s){t||(t={}),this.isRenderAsHtml?t.innerHTML=typeof this.options.sanitizer=="function"?this.options.sanitizer(s):s:t.textContent=s}update(t=!1){let s=this.getSelects(),e=this.getSelects("text");this.options.displayValues&&(e=s);let l=this.choiceElm?.querySelector("span"),i=s.length,n=null,u=()=>{if(this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml){let r=s.join(this.options.displayDelimiter);return this.options.useSelectOptionLabelToHtml?q(r):r}return e.join(this.options.displayDelimiter)};if(l){if(i===0){let r=this.options.placeholder||"";l.classList.add("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,r)}else i<this.options.minimumCountSelected?n=u():this.formatAllSelected()&&i===this.dataTotal?n=this.formatAllSelected():this.options.ellipsis&&i>this.options.minimumCountSelected?n=`${e.slice(0,this.options.minimumCountSelected).join(this.options.displayDelimiter)}...`:this.formatCountSelected(i,this.dataTotal)&&i>this.options.minimumCountSelected?n=this.formatCountSelected(i,this.dataTotal):n=u();if(n!==null&&(l?.classList.remove("ms-placeholder"),this.applyAsTextOrHtmlWhenEnabled(l,n)),this.options.displayTitle||this.options.addTitle){this.options.addTitle&&console.warn("[Multiple-Select-Vanilla] Please note that the `addTitle` option was deprecated and replaced by `displayTitle`.");let r=this.options.useSelectOptionLabel||this.options.useSelectOptionLabelToHtml?"value":"text";l.title=this.getSelects(r).join(this.options.displayDelimiter)}}let c=this.getSelects();this.options.single?this.elm.value=c.length?c[0]:"":Array.from(this.elm.options).forEach(r=>{r.selected=c.some(p=>p===r.value)}),t||this.elm.dispatchEvent(new Event("change"))}updateSelected(t){for(let e=this.updateDataStart;e<this.updateDataEnd;e++){let l=this.updateData[e],i=this.dropElm.querySelector(`input[data-key=${l._key}]`);if(i){i.checked=l.selected;let n=i.closest("li");n&&(l.selected&&!n.classList.contains("selected")?n.classList.add("selected"):l.selected||n.classList.remove("selected"))}}let s=this.data?.filter(e=>e.visible).length===0;this.selectAllElm&&(this.selectAllElm.checked=this.allSelected,_(this.selectAllElm.closest("li"),!s)),_(this.noResultsElm,s),this.virtualScroll&&(this.virtualScroll.rows=t??this.getListRows())}getData(){return this.options.data}getDataLength(){return this.data?.length??0}getOptions(t=!0){let s=Object.assign({},this.options);return delete s.data,t?D(s):this.options}refreshOptions(t){G(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 s=[];for(let e of this.data||[])if(e.type==="optgroup"){let l=e.children.filter(i=>i?.selected);if(!l.length)continue;if(t==="value"||this.options.single)s.push(...l.map(i=>t==="value"&&i._value||i[t]));else{let i=[];i.push("["),i.push(e.label),i.push(`: ${l.map(n=>n[t]).join(", ")}`),i.push("]"),s.push(i.join(""))}}else e.selected&&s.push(t==="value"&&e._value||e[t]);return s}setSelects(t,s="value",e=!1){let l=!1,i=n=>{for(let u of n){let c=!1;if(s==="text"){let r=document.createElement("div");this.applyAsTextOrHtmlWhenEnabled(r,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&&(l=!0),u.selected=c}};for(let n of this.data||[])n.type==="optgroup"?i(n.children):i([n]);l&&(this.initSelected(e),this.updateSelected(),this.update(e))}enable(){this.choiceElm?.classList.remove("disabled")}disable(){this.choiceElm?.classList.add("disabled")}check(t){let s=b(this.data,"value",t);s&&this._check(s,!0)}uncheck(t){let s=b(this.data,"value",t);s&&this._check(s,!1)}_check(t,s){this.options.single&&this._checkAll(!1,!0),t.selected=s,this.initSelected(),this.updateSelected(),this.update()}checkAll(){this._checkAll(!0)}uncheckAll(){this._checkAll(!1)}_checkAll(t,s){for(let e of this.data||[])e.type==="optgroup"?this._checkGroup(e,t,!0):!e.disabled&&!e.divider&&(s||e.visible)&&(e.selected=t);s||(this.initSelected(),this.updateSelected(),this.update())}_checkGroup(t,s,e){t.selected=s,t.children.forEach(l=>{l&&!l.disabled&&!l.divider&&(e||l.visible)&&(l.selected=s)}),e||(this.initSelected(),this.updateSelected(),this.update())}checkInvert(){if(!this.options.single){for(let t of this.data||[])if(t.type==="optgroup")for(let s of t.children)s&&(s.divider||(s.selected=!s.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 s=this.searchInputElm?.value.trim()??"",e=s.toLowerCase();if(this.filterText===e)return;this.filterText=e;for(let i of this.data||[])if(i.type==="optgroup")if(this.options.filterGroup){let n=`${i?.label??""}`;if(i!=null){let u=this.options.customFilter({label:m(n.toString().toLowerCase()),search:m(e),originalLabel:n,originalSearch:s,row:i});i.visible=u;for(let c of i.children)c&&(c.visible=u)}}else{for(let n of i.children)if(n!=null){let u=`${n?.text??""}`;n.visible=this.options.customFilter({text:m(u.toString().toLowerCase()),search:m(e),originalText:u,originalSearch:s,row:n,parent:i})}i.visible=i.children.filter(n=>n?.visible).length>0}else{let n=`${i?.text??""}`;i.visible=this.options.customFilter({text:m(n.toString().toLowerCase()),search:m(e),originalText:n,originalSearch:s,row:i})}let l=this.initListItems();this.initSelected(t),this.updateSelected(l),t||this.options.onFilter(s)}adjustDropHeight(t){let s=t!=="top",e=this.filterParentElm?.getBoundingClientRect().height??0,l=this.okButtonElm?.getBoundingClientRect().height??0,i=this.options.single?0:this.selectAllParentElm?.getBoundingClientRect().height??0,n=e+l+i+5,{bottom:u,top:c}=L(this.parentElm),r=this.options.maxHeight;if(s?r=u-n-this.options.adjustedHeightPadding:r=c-n-this.options.adjustedHeightPadding,!this.options.maxHeight||this.options.maxHeight&&r<this.options.maxHeight){let p=this.dropElm?.querySelector("ul");return p&&(p.style.maxHeight=`${r}px`),!0}return!1}adjustDropPosition(t){let s="bottom";if(this.dropElm&&this.parentElm){let{bottom:e,top:l}=L(this.dropElm),{top:i,left:n}=F(this.parentElm),u=this.dropElm.getBoundingClientRect().height,c=this.dropElm.getBoundingClientRect().width,r=document.body.offsetWidth||window.innerWidth,p=this.parentElm.getBoundingClientRect().width;if(e>u)s="bottom";else if(u>e&&l>e){if(this.options.container){let E=i-u;E<0&&(E=0),(E>0||t)&&(s="top",this.dropElm.style.top=`${E<0?0:E}px`)}else s="top",this.dropElm.classList.add(s);this.dropElm.classList.remove("bottom")}r-c<n&&(this.dropElm.style.left=`${n-(c-p)}px`)}return s}adjustDropWidthByText(){let s=this.parentElm.scrollWidth;(this.options.dropWidth||this.options.width)&&(s=this.options.dropWidth||this.options.width||0);let e=this.dropElm.querySelector(".ms-select-all span"),l=this.dropElm.querySelector("ul"),i=26,n=e?.clientWidth??0+i,c=l.scrollHeight>l.clientHeight?this.getScrollbarWidth():0,r=0;this.dropElm.querySelectorAll("li label").forEach(p=>{p.scrollWidth>r&&(r=p.scrollWidth)}),r+=i+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),(s==="100%"||+s<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 s=t.offsetWidth;t.style.overflow="scroll";let e=document.createElement("div");e.style.width="100%",t.appendChild(e);let l=e.offsetWidth;return t.parentNode?.removeChild(t),s-l}formatAllSelected(){return this.options.allSelectedText||this.options.formatAllSelected()}formatCountSelected(t,s){return this.options.countSelectedText?this.options.countSelectedText.replace("#",`${t}`).replace("%",`${s}`):this.options.formatCountSelected(t,s)}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 O=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 s=Array.from(o),e=[];for(let l=0;l<s.length;l++){let i=s[l];try{i._multipleSelect!==void 0&&(i._multipleSelect.destroy(),delete i._multipleSelect),i._multipleSelect=new T(i,t||{}),i._multipleSelect.init();let n=i._multipleSelect.getOptions(!1);n.onHardDestroy=()=>delete i._multipleSelect,n.onAfterHardDestroyed=()=>e[l]=null,e.push(i._multipleSelect)}catch(n){console.error(n)}}return e.length===1?e[0]:e}O.defaults=d.DEFAULTS;O.locales={...v};O.methods=d.METHODS;typeof window<"u"&&(window.multipleSelect=O);export{S as BindingEventService,T as MultipleSelectInstance,H as VirtualScroll,L as calculateAvailableSpace,G as compareObjects,g as convertItemRowToHtml,w as convertStringStyleToElementStyle,h as createDomElement,V as createDomStructure,D as deepCopy,y as emptyElement,b as findByParam,B as findParent,F as getElementOffset,A as getElementSize,Y as insertAfter,M as isDefined,O as multipleSelect,U as objectRemoveEmptyProps,m as removeDiacritics,C as removeUndefined,K as setDataKeys,q as stripScripts,z as toCamelCase,_ as toggleElement,dt as toggleElementClass,lt as windowScrollPosition};
//# sourceMappingURL=multiple-select.js.map
{
"name": "multiple-select-vanilla",
"version": "1.1.0",
"version": "1.1.1",
"main": "./dist/cjs/multiple-select.cjs",

@@ -54,3 +54,3 @@ "module": "./dist/esm/multiple-select.js",

},
"gitHead": "0d0fe14227f446e7e4a4cb4af15ebe52d4479fdb"
"gitHead": "d19de8e70d72f08349068b231ac715b3b3c332a1"
}

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

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