
/* Smart UI v14.0.71 (2022-05-30) 
Copyright (c) 2011-2021 jQWidgets. 
License: https://htmlelements.com/license/ */ //

Smart("smart-check-input",class extends Smart.MultiInput{static get properties(){return{inverted:{type:"boolean",value:!1}}}_performSelect(e){const t=this;if(!e)return void t.close();const s=e.target?e.target.closest("li"):e;if(!s)return;t._selectedItems||(t._selectedItems=[]),s.classList.toggle("selected");const l=s.classList.contains("selected"),a={label:s.getAttribute("data-label"),value:s.getAttribute("value")},i=t.$.menu.children;for(let e=0;e<i.length;e++)i[e].classList.remove("active");if(l)t._selectedItems.push(a),t._setActiveDescendant(s),s.classList.add("active"),s.setAttribute("aria-selected",!0);else{const e=t._selectedItems.findIndex((e=>e.label===a.label&&e.value===a.value));e>-1&&t._selectedItems.splice(e,1),s.classList.remove("active"),s.setAttribute("aria-selected",!1)}s.setAttribute("aria-selected",l);const n=t._selectedItems,c=t.value,r=t.$.input.dataValue;let[u,d]=[[],[]];for(let e=0;e<n.length;e++){const t=n[e];u.push(t.label),d.push(t.value)}t.set("selectedValues",n.map((e=>e.value))),u=u.join(", "),t.set("value",u),t.$.input.dataValue=d=d.join(", "),u===c&&d===r||t.$.fireEvent("change",{value:d,label:u,oldValue:r,oldLabel:c})}_render(e){const t=this,s=e.map((function(e){let s=e,l=e;"object"==typeof e&&(s=e.label,l=e.value||s);const a=document.createElement("li"),i=document.createElement("a");return i.href="#",a.id=t.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),a.setAttribute("data-label",s),a.setAttribute("value",l),a.setAttribute("role","option"),a.setAttribute("aria-selected",!1),a.setAttribute("aria-label",s),i.innerHTML=t.highlighter?t.highlighter(s):t._highlighter(s),i.setAttribute("aria-hidden",!0),e.icon&&(i.classList.add("icon"),i.classList.add(e.icon)),a.appendChild(i),a}));t.$.menu.innerHTML="";let l=[],a=[],i=t._selectedItems;i||(i=t._selectedItems=[]);const n=i.length;i.length&&i.forEach((e=>{a.push(e.label),l.push(e.value)})),l=l.concat((t.$.input.dataValue||t.$.input.value).split(",").map((e=>e.trim()))),a=a.concat(t.$.input.value.split(",").map((e=>e.trim())));for(let e=0;e<s.length;e++){const c=s[e],r=c.getAttribute("value"),u=c.getAttribute("data-label"),d=n?l.indexOf(r):a.indexOf(u);d>-1&&a[d]===u&&(c.classList.add("selected"),c.setAttribute("aria-selected",!0),t._setActiveDescendant(c),i.findIndex((e=>e.label===u&&e.value===r))<0&&i.push({label:c.getAttribute("data-label"),value:c.getAttribute("value")})),t.$.menu.appendChild(c)}t.set("selectedValues",i.map((e=>e.value)))}_next(){const e=this;let t=e._selectedItems?e._selectedItems[e._selectedItems.length-1]:void 0;t&&(t=e.$.menu.querySelector(`.active[data-label="${t.label}"][value="${t.value}"]`));const s=t||e.$.menu.querySelector(".active");if(!s){const t=e.$.menu.firstElementChild;return t.classList.add("active","focused"),void e._setActiveDescendant(t)}const l=e.$.menu.children;for(let e=0;e<l.length;e++)l[e].classList.remove("active","focused");e._setActiveDescendant();let a=s.nextElementSibling;a||(a=e.$.menu.firstElementChild),a.classList.add("active","focused"),e._setActiveDescendant(a),e.ensureVisible()}_prev(){const e=this;let t=e._selectedItems?e._selectedItems[e._selectedItems.length-1]:void 0;t&&(t=e.$.menu.querySelector(`.active[data-label="${t.label}"][value="${t.value}"]`));const s=t||e.$.menu.querySelector(".active");if(!s){const t=e.$.menu.firstElementChild;return t.classList.add("active","focused"),void e._setActiveDescendant(t)}const l=e.$.menu.children;for(let e=0;e<l.length;e++)l[e].classList.remove("active","focused");e._setActiveDescendant();let a=s.previousElementSibling;a||(a=e.$.menu.lastElementChild),a.classList.add("active","focused"),e._setActiveDescendant(a),e.ensureVisible()}_keyUpHandler(e){const t=this;if(!e.shiftKey)switch(e.keyCode){case 40:case 38:case 16:case 17:case 18:40===e.keyCode&&e.altKey&&t.open(),38===e.keyCode&&e.altKey&&t.close();break;case 9:case 13:if(!t.opened)return;t._performSelect(t.$.menu.querySelector(".active")),e.stopPropagation(),e.preventDefault();break;case 27:if(!t.opened)return;t.close(),e.stopPropagation(),e.preventDefault();break;default:t._lookup(e),!t.opened||e.ctrlKey||e.shiftKey||(e.stopPropagation(),e.preventDefault()),t.readonly||(t.$.input.dataValue=t.$.input.value)}}_createElement(){super._createElement(),this.$.menu.setAttribute("aria-multiselectable",!0),this.$.scrollView.classList.add("smart-check-input-drop-down-menu")}});