// http://spin.js.org/#v2.3.2
!function (a, b) { "object" == typeof module && module.exports ? module.exports = b() : "function" == typeof define && define.amd ? define(b) : a.Spinner = b() }(this, function () { "use strict"; function a(a, b) { var c, d = document.createElement(a || "div"); for (c in b) d[c] = b[c]; return d } function b(a) { for (var b = 1, c = arguments.length; c > b; b++) a.appendChild(arguments[b]); return a } function c(a, b, c, d) { var e = ["opacity", b, ~~(100 * a), c, d].join("-"), f = .01 + c / d * 100, g = Math.max(1 - (1 - a) / b * (100 - f), a), h = j.substring(0, j.indexOf("Animation")).toLowerCase(), i = h && "-" + h + "-" || ""; return m[e] || (k.insertRule("@" + i + "keyframes " + e + "{0%{opacity:" + g + "}" + f + "%{opacity:" + a + "}" + (f + .01) + "%{opacity:1}" + (f + b) % 100 + "%{opacity:" + a + "}100%{opacity:" + g + "}}", k.cssRules.length), m[e] = 1), e } function d(a, b) { var c, d, e = a.style; if (b = b.charAt(0).toUpperCase() + b.slice(1), void 0 !== e[b]) return b; for (d = 0; d < l.length; d++) if (c = l[d] + b, void 0 !== e[c]) return c } function e(a, b) { for (var c in b) a.style[d(a, c) || c] = b[c]; return a } function f(a) { for (var b = 1; b < arguments.length; b++) { var c = arguments[b]; for (var d in c) void 0 === a[d] && (a[d] = c[d]) } return a } function g(a, b) { return "string" == typeof a ? a : a[b % a.length] } function h(a) { this.opts = f(a || {}, h.defaults, n) } function i() { function c(b, c) { return a("<" + b + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', c) } k.addRule(".spin-vml", "behavior:url(#default#VML)"), h.prototype.lines = function (a, d) { function f() { return e(c("group", { coordsize: k + " " + k, coordorigin: -j + " " + -j }), { width: k, height: k }) } function h(a, h, i) { b(m, b(e(f(), { rotation: 360 / d.lines * a + "deg", left: ~~h }), b(e(c("roundrect", { arcsize: d.corners }), { width: j, height: d.scale * d.width, left: d.scale * d.radius, top: -d.scale * d.width >> 1, filter: i }), c("fill", { color: g(d.color, a), opacity: d.opacity }), c("stroke", { opacity: 0 })))) } var i, j = d.scale * (d.length + d.width), k = 2 * d.scale * j, l = -(d.width + d.length) * d.scale * 2 + "px", m = e(f(), { position: "absolute", top: l, left: l }); if (d.shadow) for (i = 1; i <= d.lines; i++) h(i, -2, "progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)"); for (i = 1; i <= d.lines; i++) h(i); return b(a, m) }, h.prototype.opacity = function (a, b, c, d) { var e = a.firstChild; d = d.shadow && d.lines || 0, e && b + d < e.childNodes.length && (e = e.childNodes[b + d], e = e && e.firstChild, e = e && e.firstChild, e && (e.opacity = c)) } } var j, k, l = ["webkit", "Moz", "ms", "O"], m = {}, n = { lines: 12, length: 7, width: 5, radius: 10, scale: 1, corners: 1, color: "#000", opacity: .25, rotate: 0, direction: 1, speed: 1, trail: 100, fps: 20, zIndex: 2e9, className: "spinner", top: "50%", left: "50%", shadow: !1, hwaccel: !1, position: "absolute" }; if (h.defaults = {}, f(h.prototype, { spin: function (b) { this.stop(); var c = this, d = c.opts, f = c.el = a(null, { className: d.className }); if (e(f, { position: d.position, width: 0, zIndex: d.zIndex, left: d.left, top: d.top }), b && b.insertBefore(f, b.firstChild || null), f.setAttribute("role", "progressbar"), c.lines(f, c.opts), !j) { var g, h = 0, i = (d.lines - 1) * (1 - d.direction) / 2, k = d.fps, l = k / d.speed, m = (1 - d.opacity) / (l * d.trail / 100), n = l / d.lines; !function o() { h++; for (var a = 0; a < d.lines; a++) g = Math.max(1 - (h + (d.lines - a) * n) % l * m, d.opacity), c.opacity(f, a * d.direction + i, g, d); c.timeout = c.el && setTimeout(o, ~~(1e3 / k)) }() } return c }, stop: function () { var a = this.el; return a && (clearTimeout(this.timeout), a.parentNode && a.parentNode.removeChild(a), this.el = void 0), this }, lines: function (d, f) { function h(b, c) { return e(a(), { position: "absolute", width: f.scale * (f.length + f.width) + "px", height: f.scale * f.width + "px", background: b, boxShadow: c, transformOrigin: "left", transform: "rotate(" + ~~(360 / f.lines * k + f.rotate) + "deg) translate(" + f.scale * f.radius + "px,0)", borderRadius: (f.corners * f.scale * f.width >> 1) + "px" }) } for (var i, k = 0, l = (f.lines - 1) * (1 - f.direction) / 2; k < f.lines; k++) i = e(a(), { position: "absolute", top: 1 + ~(f.scale * f.width / 2) + "px", transform: f.hwaccel ? "translate3d(0,0,0)" : "", opacity: f.opacity, animation: j && c(f.opacity, f.trail, l + k * f.direction, f.lines) + " " + 1 / f.speed + "s linear infinite" }), f.shadow && b(i, e(h("#000", "0 0 4px #000"), { top: "2px" })), b(d, b(i, h(g(f.color, k), "0 0 1px rgba(0,0,0,.1)"))); return d }, opacity: function (a, b, c) { b < a.childNodes.length && (a.childNodes[b].style.opacity = c) } }), "undefined" != typeof document) { k = function () { var c = a("style", { type: "text/css" }); return b(document.getElementsByTagName("head")[0], c), c.sheet || c.styleSheet }(); var o = e(a("group"), { behavior: "url(#default#VML)" }); !d(o, "transform") && o.adj ? i() : j = d(o, "animation") } return h });

(function(factory){
  if (typeof define === 'function' && define.amd) {
    define(['jquery', 'jquery-qubit'], factory);
  } else if (typeof exports === 'object') {
    factory(require('jquery'), require('jquery-qubit'));
  } else {
    factory(jQuery, jQuery.fn.qubit);
  }
}(function($, qubit) {
  $.fn.bonsai = function(options) {
    var args = arguments;
    return this.each(function() {
      var bonsai = $(this).data('bonsai');
      if (!bonsai) {
        bonsai = new Bonsai(this, options);
        $(this).data('bonsai', bonsai);
      }
      if (typeof options == 'string') {
        var method = options;
        return bonsai[method].apply(bonsai, [].slice.call(args, 1));
      }
    });
  };
  $.bonsai = {};
  $.bonsai.defaults = {
    expandAll: false, // expand all items
    expand: null, // optional function to expand an item
    collapse: null, // optional function to collapse an item
    addExpandAll: false, // add a link to expand all items
    addSelectAll: false, // add a link to select all checkboxes
    selectAllExclude: null, // a filter selector or function for selectAll
    idAttribute: 'id', // which attribute of the list items to use as an id

    // createInputs: create checkboxes or radio buttons for each list item
    // by setting createInputs to "checkbox" or "radio".
    //
    // The name and value for the inputs can be declared in the
    // markup using `data-name` and `data-value`.
    //
    // The name is inherited from parent items if not specified.
    //
    // Checked state can be indicated using `data-checked`.
    createInputs: false,
    // checkboxes: run qubit(this.options) on the root node (requires jquery.qubit)
    checkboxes: false,
    // handleDuplicateCheckboxes: update any other checkboxes that
    // have the same value
    handleDuplicateCheckboxes: false,
    // createRadioButtons: creates radio buttons for each list item.
    //
    // The name and value for the checkboxes can be declared in the
    // markup using `data-name` and `data-value`.
    //
    // The name is inherited from parent items if not specified.
    //
    // Checked state can be indicated using `data-checked`.
    createRadioButtons: false
  };
  var Bonsai = function(el, options) {
    var self = this;
    options = options || {};
    this.options = $.extend({}, $.bonsai.defaults, options);
    this.el = $(el).addClass('bonsai').data('bonsai', this);

    // store the scope in the options for child nodes
    if (!this.options.scope) {
      this.options.scope = this.el;
    }
    this.update();
    if (this.isRootNode()) {
      if (this.options.createCheckboxes) this.createInputs = 'checkbox';
      if (this.options.handleDuplicateCheckboxes) this.handleDuplicateCheckboxes();
      if (this.options.checkboxes) this.el.qubit(this.options);
      if (this.options.addExpandAll) this.addExpandAllLink();
      if (this.options.addSelectAll) this.addSelectAllLink();
      this.el.on('click', '.thumb', function(ev) {
        self.toggle($(ev.currentTarget).closest('li'));
      });
    }
    if (this.options.expandAll) this.expandAll();
  };
  Bonsai.prototype = {
    isRootNode: function() {
      return this.options.scope == this.el;
    },
    listItem: function(id) {
      if (typeof id === 'object') return $(id);
      return this.el.find('[' + this.options.idAttribute + '="' + id + '"]');
    },
    toggle: function(listItem) {
      if (!$(listItem).hasClass('expanded')) {
        return this.expand(listItem);
      }
      else {
        return this.collapse(listItem);
      }
    },
    expand: function(listItem) {
      return this.setExpanded(listItem, true);
    },
    collapse: function(listItem) {
      return this.setExpanded(listItem, false);
    },
    setExpanded: function(listItem, expanded) {
      var $li = this.listItem(listItem);
      if ($li.length > 1) {
        var self = this;
        $li.each(function() {
          self.setExpanded(this, expanded);
        });
        return;
      }
      if (expanded) {
        if (!$li.data('subList')) return;
        $li = $($li).addClass('expanded').removeClass('collapsed');
        $($li.data('subList')).css('height', 'auto');
      }
      else {
        $li = $($li).addClass('collapsed')
          .removeClass('expanded');
        $($li.data('subList')).height(0);
      }
      return $li;
    },
    expandAll: function() {
      this.expand(this.el.find('li'));
    },
    collapseAll: function() {
      this.collapse(this.el.find('li'));
    },
    expandTo: function(listItem) {
      var self = this;
      var $li = this.listItem(listItem);
      $li.parents('li').each(function () {
        self.expand($(this));
      });
      return $li;
    },
    update: function() {
      var self = this;
      // look for a nested list (if any)
      this.el.children().each(function() {
        var item = $(this);
        if (self.options.createInputs) self.insertInput(item);

        // insert a thumb if it doesn't already exist
        if (item.children().filter('.thumb').length == 0) {
          var thumb = $('<div class="thumb"></div>');
          item.prepend(thumb);
        }
        var subLists = item.children().filter('ol, ul');
        item.toggleClass('has-children', subLists.find('li').length > 0);
        // if there is a child list
        subLists.each(function() {
          // that's not empty
          if ($('li', this).length == 0) {
            return;
          }
          // then this el has children
          item.data('subList', this);
          // collapse the nested list
          if (item.hasClass('expanded')) {
            self.expand(item);
          }
          else {
            self.collapse(item);
          }
          // handle any deeper nested lists
          var exists = !!$(this).data('bonsai');
          $(this).bonsai(exists ? 'update' : self.options);
        });
      });

      this.expand = this.options.expand || this.expand;
      this.collapse = this.options.collapse || this.collapse;
    },
    serialize: function() {
      var idAttr = this.options.idAttribute;
      return this.el.find('li').toArray().reduce(function(acc, li) {
        var $li = $(li);
        var id = $li.attr(idAttr);
        // only items with IDs can be serialized
        if (id) {
          var state = $li.hasClass('expanded')
              ? 'expanded'
              : ($li.hasClass('collapsed') ? 'collapsed' : null);
          if (state) acc[$li.hasClass('expanded') ? 'expanded' : 'collapsed'].push(id);
        }
        return acc;
      }, {expanded: [], collapsed: [], version: 2});
    },
    restore: function(state) {
      var self = this;
      if (state.version > 1) {
        state.expanded.map(this.expand.bind(this));
        state.collapsed.map(this.collapse.bind(this));
      }
      else {
        Object.keys(state).forEach(function(id) {
          self.setExpanded(id, state[id] === 'expanded');
        });
      }
    },
    insertInput: function(listItem) {
      var type = this.options.createInputs;
      if (listItem.find('> input[type=' + type + ']').length) return;
      var id = this.inputIdFor(listItem);
      var checkbox = $('<input type="' + type + '" name="'
        + this.inputNameFor(listItem) + '" id="' + id + '" /> '
      );
      var children = listItem.children();
      // get the first text node for the label
      var text = listItem.contents().filter(function() {
        return this.nodeType == 3;
      }).first();
      checkbox.val(listItem.data('value'));
      checkbox.prop('checked', listItem.data('checked'))
      children.detach();
      listItem.append(checkbox)
        .append(
          $('<label for="' + id + '">').append(text.length > 0 ? text : children.first())
        )
        .append(text.length > 0 ? children : children.slice(1));
    },
    checkboxPrefix: 'bonsai-checkbox-',
    inputIdFor: function(listItem) {
      var id = $(listItem).data('id');
      while (!id || ($('#' + id).length > 0)) {
        id = this.checkboxPrefix + Bonsai.uniqueId++;
      }
      return id;
    },
    inputNameFor: function(listItem) {
      return listItem.data('name')
        || listItem.parents().filter('[data-name]').data('name');
    },
    handleDuplicateCheckboxes: function() {
      var self = this;
      self.el.on('change', 'input[type=checkbox]', function(ev) {
        var checkbox = $(ev.target);
        if (!checkbox.val()) return;
        // select all duplicate checkboxes that need to be updated
        var selector = 'input[type=checkbox]'
          + '[value="' + checkbox.val() + '"]'
          + (checkbox.attr('name') ? '[name="' + checkbox.attr('name') + '"]' : '')
          + (checkbox.prop('checked') ? ':not(:checked)' : ':checked');
        self.el.find(selector).prop({
          checked: checkbox.prop('checked'),
          indeterminate: checkbox.prop('indeterminate')
        }).trigger('change');
      });
    },
    addExpandAllLink: function() {
      var self = this;
      $('<div class="expand-all">')
        .append(
          $('<a class="all">Expand all</a>').on('click', function() {
            self.expandAll();
          })
        )
        .append('<i class="separator"></i>')
        .append(
          $('<a class="none">Collapse all</a>').on('click', function() {
            self.collapseAll();
          })
        )
        .insertBefore(this.el);
    },
    addSelectAllLink: function() {
      var scope = this.options.scope;
      var self = this;
      function getCheckboxes() {
        // return all checkboxes that are not in hidden list items
        return scope.find('li')
          .filter(self.options.selectAllExclude || function() {
            return $(this).css('display') != 'none';
          })
          .find('> input[type=checkbox]');
      }
      $('<div class="check-all">')
        .append($('<a class="all">Select all</a>')
          .css('cursor', 'pointer')
          .on('click', function() {
            getCheckboxes().prop({
              checked: true,
              indeterminate: false
            });
          }))
        .append('<i class="separator"></i>')
        .append($('<a class="none">Select none</a>')
          .css('cursor', 'pointer')
          .on('click', function() {
            getCheckboxes().prop({
              checked: false,
              indeterminate: false
            });
          })
      )
        .insertAfter(this.el);
    },
    setCheckedValues: function(values) {
      var all = this.options.scope.find('input[type=checkbox]');
      $.each(values, function(key, value) {
        all.filter('[value="' + value + '"]')
          .prop('checked', true)
          .trigger('change');
      });
    }
  };
  $.extend(Bonsai, {
    uniqueId: 0
  });
}));

var Gi=Object.defineProperty;var Mi=(C,p,f)=>p in C?Gi(C,p,{enumerable:!0,configurable:!0,writable:!0,value:f}):C[p]=f;var c=(C,p,f)=>(Mi(C,typeof p!="symbol"?p+"":p,f),f),yt=(C,p,f)=>{if(!p.has(C))throw TypeError("Cannot "+f)};var n=(C,p,f)=>(yt(C,p,"read from private field"),f?f.call(C):p.get(C)),r=(C,p,f)=>{if(p.has(C))throw TypeError("Cannot add the same private member more than once");p instanceof WeakSet?p.add(C):p.set(C,f)},b=(C,p,f,z)=>(yt(C,p,"write to private field"),z?z.call(C,f):p.set(C,f),f);var o=(C,p,f)=>(yt(C,p,"access private method"),f);(function(C,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(C=typeof globalThis<"u"?globalThis:C||self,C.Treeselect=p())})(this,function(){var P,y,H,x,pe,Ut,G,oe,me,zt,fe,Yt,M,re,B,q,Ce,Kt,be,Xt,ge,Jt,ke,Zt,we,Qt,Ee,es,ve,ts,Le,ss,ye,is,xe,ls,Se,ns,_e,as,Ae,os,Te,rs,Ne,cs,Oe,hs,Y,xt,F,V,_,K,Ie,ds,Pe,us,Be,ps,Ve,ms,De,fs,He,Cs,X,St,Ge,bs,Me,gs,Fe,ks,J,_t,je,ws,qe,Es,Re,vs,$e,Ls,We,ys,Ue,xs,ze,Ss,Ye,_s,Ke,As,Xe,Ts,Je,Ns,Z,At,Q,Tt,Ze,Os,u,m,R,ee,$,A,T,S,D,te,Nt,se,Ot,Qe,Is,et,Ps,tt,Bs,st,Vs,it,Ds,lt,Hs,ie,It,nt,Gs,at,Ms,ot,Fs,rt,js,le,Pt,ct,qs,W,gt,ne,Bt,U,kt,ht,Rs,ae,Vt,dt,$s,ut,Ws,pt,Us,mt,zs,ft,Ys;"use strict";const C="",p={arrowUp:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 15l-6-6-6 6"/></svg>',arrowDown:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>',arrowRight:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>',attention:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',clear:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>',cross:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>',check:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',partialCheck:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>'},f=(l,e)=>{if(e.innerHTML="",typeof l=="string")e.innerHTML=l;else{const t=l.cloneNode(!0);e.appendChild(t)}},z=l=>{const e=l?{...l}:{};return Object.keys(p).forEach(t=>{e[t]||(e[t]=p[t])}),e},Ks=l=>l.reduce((e,{name:t},s)=>(e+=t,s<l.length-1&&(e+=", "),e),"");class Xs{constructor({value:e,showTags:t,tagsCountText:s,clearable:i,isAlwaysOpened:a,searchable:h,placeholder:d,disabled:w,isSingleSelect:g,id:k,ariaLabel:E,iconElements:v,inputCallback:L,searchCallback:N,openCallback:O,closeCallback:j,keydownCallback:Ct,focusCallback:vt,blurCallback:Lt,nameChangeCallback:bt}){r(this,pe);r(this,G);r(this,me);r(this,fe);r(this,M);r(this,B);r(this,Ce);r(this,be);r(this,ge);r(this,ke);r(this,we);r(this,Ee);r(this,ve);r(this,Le);r(this,ye);r(this,xe);r(this,Se);r(this,_e);r(this,Ae);r(this,Te);r(this,Ne);r(this,Oe);r(this,Y);c(this,"value");c(this,"showTags");c(this,"tagsCountText");c(this,"clearable");c(this,"isAlwaysOpened");c(this,"searchable");c(this,"placeholder");c(this,"disabled");c(this,"isSingleSelect");c(this,"id");c(this,"ariaLabel");c(this,"iconElements");c(this,"isOpened");c(this,"searchText");c(this,"srcElement");r(this,P,void 0);r(this,y,void 0);r(this,H,void 0);r(this,x,void 0);c(this,"inputCallback");c(this,"searchCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"keydownCallback");c(this,"focusCallback");c(this,"blurCallback");c(this,"nameChangeCallback");this.value=e,this.showTags=t,this.tagsCountText=s,this.searchable=h,this.placeholder=d,this.clearable=i,this.isAlwaysOpened=a,this.disabled=w,this.isSingleSelect=g,this.id=k,this.ariaLabel=E,this.iconElements=v,this.isOpened=!1,this.searchText="",b(this,P,o(this,ge,Jt).call(this)),b(this,y,o(this,ye,is).call(this)),b(this,H,o(this,_e,as).call(this)),b(this,x,null),this.inputCallback=L,this.searchCallback=N,this.openCallback=O,this.closeCallback=j,this.keydownCallback=Ct,this.focusCallback=vt,this.blurCallback=Lt,this.nameChangeCallback=bt,this.srcElement=o(this,Ce,Kt).call(this,n(this,P),n(this,y),n(this,H)),o(this,pe,Ut).call(this)}focus(){setTimeout(()=>n(this,y).focus(),0)}blur(){this.isOpened&&o(this,B,q).call(this),this.clearSearch(),n(this,y).blur()}updateValue(e){this.value=e,o(this,G,oe).call(this),o(this,M,re).call(this)}removeItem(e){this.value=this.value.filter(t=>t.id!==e),o(this,Y,xt).call(this),o(this,G,oe).call(this),o(this,M,re).call(this)}clear(){this.value=[],o(this,Y,xt).call(this),o(this,G,oe).call(this),this.clearSearch()}openClose(){o(this,B,q).call(this)}clearSearch(){this.searchText="",this.searchCallback(""),o(this,M,re).call(this)}}P=new WeakMap,y=new WeakMap,H=new WeakMap,x=new WeakMap,pe=new WeakSet,Ut=function(){o(this,G,oe).call(this),o(this,M,re).call(this),o(this,me,zt).call(this)},G=new WeakSet,oe=function(){if(n(this,P).innerHTML="",this.showTags){n(this,P).append(...o(this,ke,Zt).call(this));const e=Ks(this.value);this.nameChangeCallback(e)}else{const e=o(this,Le,ss).call(this);n(this,P).appendChild(e),this.nameChangeCallback(e.innerText)}n(this,P).appendChild(n(this,y))},me=new WeakSet,zt=function(){const e=[];n(this,H).innerHTML="",this.clearable&&e.push(o(this,Ae,os).call(this)),this.isAlwaysOpened||e.push(o(this,Ne,cs).call(this,this.isOpened)),e.length&&n(this,H).append(...e)},fe=new WeakSet,Yt=function(){if(!this.isAlwaysOpened&&n(this,x)){const e=this.isOpened?this.iconElements.arrowUp:this.iconElements.arrowDown;f(e,n(this,x))}},M=new WeakSet,re=function(){var e;(e=this.value)!=null&&e.length?(n(this,y).removeAttribute("placeholder"),this.srcElement.classList.remove("treeselect-input--value-not-selected")):(n(this,y).setAttribute("placeholder",this.placeholder),this.srcElement.classList.add("treeselect-input--value-not-selected")),this.searchable?this.srcElement.classList.remove("treeselect-input--unsearchable"):this.srcElement.classList.add("treeselect-input--unsearchable"),this.isSingleSelect?this.srcElement.classList.add("treeselect-input--is-single-select"):this.srcElement.classList.remove("treeselect-input--is-single-select"),n(this,y).value=this.searchText},B=new WeakSet,q=function(){this.isOpened=!this.isOpened,o(this,fe,Yt).call(this),this.isOpened?this.openCallback():this.closeCallback()},Ce=new WeakSet,Kt=function(e,t,s){const i=document.createElement("div");return i.classList.add("treeselect-input"),i.setAttribute("tabindex","-1"),i.addEventListener("mousedown",a=>o(this,be,Xt).call(this,a)),i.addEventListener("focus",()=>this.focusCallback(),!0),i.addEventListener("blur",()=>this.blurCallback(),!0),e.appendChild(t),i.append(e,s),i},be=new WeakSet,Xt=function(e){e.stopPropagation(),this.isOpened||o(this,B,q).call(this),this.focus()},ge=new WeakSet,Jt=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__tags"),e},ke=new WeakSet,Zt=function(){return this.value.map(e=>{const t=document.createElement("div");t.classList.add("treeselect-input__tags-element"),t.setAttribute("tabindex","-1"),t.setAttribute("tag-id",e.id.toString()),t.setAttribute("title",e.name);const s=o(this,Ee,es).call(this,e.name),i=o(this,ve,ts).call(this);return t.addEventListener("mousedown",a=>o(this,we,Qt).call(this,a,e.id)),t.append(s,i),t})},we=new WeakSet,Qt=function(e,t){e.preventDefault(),e.stopPropagation(),this.removeItem(t),this.focus()},Ee=new WeakSet,es=function(e){const t=document.createElement("span");return t.classList.add("treeselect-input__tags-name"),t.textContent=e,t},ve=new WeakSet,ts=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__tags-cross"),f(this.iconElements.cross,e),e},Le=new WeakSet,ss=function(){const e=document.createElement("span");if(e.classList.add("treeselect-input__tags-count"),!this.value.length)return e.textContent="",e.setAttribute("title",""),e;const t=this.value.length===1?this.value[0].name:`${this.value.length} ${this.tagsCountText}`;return e.textContent=t,e.setAttribute("title",t),e},ye=new WeakSet,is=function(){const e=document.createElement("input");return e.classList.add("treeselect-input__edit"),this.id&&e.setAttribute("id",this.id),(!this.searchable||this.disabled)&&e.setAttribute("readonly","readonly"),this.disabled&&e.setAttribute("tabindex","-1"),this.ariaLabel.length&&e.setAttribute("aria-label",this.ariaLabel),e.addEventListener("keydown",t=>o(this,xe,ls).call(this,t)),e.addEventListener("input",t=>o(this,Se,ns).call(this,t,e)),e},xe=new WeakSet,ls=function(e){e.stopPropagation();const t=e.key;t==="Backspace"&&!this.searchText.length&&this.value.length&&!this.showTags&&this.clear(),t==="Backspace"&&!this.searchText.length&&this.value.length&&this.removeItem(this.value[this.value.length-1].id),e.code==="Space"&&(!this.searchText||!this.searchable)&&o(this,B,q).call(this),(t==="Enter"||t==="ArrowDown"||t==="ArrowUp")&&e.preventDefault(),this.keydownCallback(e),t!=="Tab"&&this.focus()},Se=new WeakSet,ns=function(e,t){e.stopPropagation();const s=this.searchText,i=t.value.trim();if(s.length===0&&i.length===0){t.value="";return}if(this.searchable){const a=e.target.value;this.searchCallback(a),this.isOpened||o(this,B,q).call(this)}else t.value="";this.searchText=t.value},_e=new WeakSet,as=function(){const e=document.createElement("div");return e.classList.add("treeselect-input__operators"),e},Ae=new WeakSet,os=function(){const e=document.createElement("span");return e.classList.add("treeselect-input__clear"),e.setAttribute("tabindex","-1"),f(this.iconElements.clear,e),e.addEventListener("mousedown",t=>o(this,Te,rs).call(this,t)),e},Te=new WeakSet,rs=function(e){e.preventDefault(),e.stopPropagation(),(this.searchText.length||this.value.length)&&this.clear(),this.focus()},Ne=new WeakSet,cs=function(e){b(this,x,document.createElement("span")),n(this,x).classList.add("treeselect-input__arrow");const t=e?this.iconElements.arrowUp:this.iconElements.arrowDown;return f(t,n(this,x)),n(this,x).addEventListener("mousedown",s=>o(this,Oe,hs).call(this,s)),n(this,x)},Oe=new WeakSet,hs=function(e){e.stopPropagation(),e.preventDefault(),this.focus(),o(this,B,q).call(this)},Y=new WeakSet,xt=function(){this.inputCallback(this.value)};const Dt=(l,e,t,s)=>{ei(e);const i=e.filter(a=>!a.disabled&&l.some(h=>h===a.id));if(t&&i.length){i[0].checked=!0;return}i.forEach(a=>{a.checked=!0;const h=wt(a,e,s);a.checked=h})},wt=({id:l,checked:e},t,s)=>{const i=t.find(h=>h.id===l);if(!i)return!1;if(s)return i.checked=i.disabled?!1:!!e,i.checked;const a=Ht(!!e,i,t);return Gt(i,t),a},Ht=(l,e,t)=>{if(!e.isGroup)return e.checked=e.disabled?!1:!!l,e.isPartialChecked=!1,e.checked;const s=t.filter(d=>d.childOf===e.id);return!l||e.disabled||e.isPartialChecked?(e.checked=!1,e.isPartialChecked=!1,Et(e,s,t),e.checked):Mt(s,t)?Ft(s)?(e.checked=!1,e.isPartialChecked=!1,e.disabled=!0,e.checked):(e.checked=!1,e.isPartialChecked=!0,s.forEach(d=>{Ht(l,d,t)}),e.checked):(e.checked=!0,e.isPartialChecked=!1,Et(e,s,t),e.checked)},Gt=(l,e)=>{const t=e.find(s=>s.id===l.childOf);t&&(Js(t,e),Gt(t,e))},Js=(l,e)=>{const t=ce(l,e);if(Ft(t)){l.checked=!1,l.isPartialChecked=!1,l.disabled=!0;return}if(Zs(t)){l.checked=!0,l.isPartialChecked=!1;return}if(Qs(t)){l.checked=!1,l.isPartialChecked=!0;return}l.checked=!1,l.isPartialChecked=!1},Et=({checked:l,disabled:e},t,s)=>{t.forEach(i=>{i.disabled=!!e||!!i.disabled,i.checked=!!l&&!i.disabled,i.isPartialChecked=!1;const a=ce(i,s);Et({checked:l,disabled:e},a,s)})},Mt=(l,e)=>l.some(i=>i.disabled)?!0:l.some(i=>{if(i.isGroup){const a=ce(i,e);return Mt(a,e)}return!1}),Ft=l=>l.every(e=>!!e.disabled),Zs=l=>l.every(e=>!!e.checked),Qs=l=>l.some(e=>!!e.checked||!!e.isPartialChecked),ei=l=>{l.forEach(e=>{e.checked=!1,e.isPartialChecked=!1})},ti=(l,e,t)=>{const s={level:0,groupId:""},i=jt(l,e,s.groupId,s.level);return ii(i,t)},jt=(l,e,t,s)=>l.reduce((i,a)=>{var g;const h=!!((g=a.children)!=null&&g.length),d=s>=e&&h,w=s>e;if(i.push({id:a.value,name:a.name,childOf:t,isGroup:h,checked:!1,isPartialChecked:!1,level:s,isClosed:d,hidden:w,disabled:a.disabled??!1}),h){const k=jt(a.children,e,a.value,s+1);i.push(...k)}return i},[]),ce=({id:l},e)=>e.filter(t=>t.childOf===l),si=l=>{const{ungroupedNodes:e,allGroupedNodes:t,allNodes:s}=l.reduce((a,h)=>(h.checked&&(a.allNodes.push(h),h.isGroup?a.allGroupedNodes.push(h):a.ungroupedNodes.push(h)),a),{ungroupedNodes:[],allGroupedNodes:[],allNodes:[]}),i=s.filter(a=>!t.some(({id:h})=>h===a.childOf));return{ungroupedNodes:e,groupedNodes:i,allNodes:s}},ii=(l,e)=>(l.filter(s=>!!s.disabled).forEach(({id:s})=>wt({id:s,checked:!1},l,e)),l),he=(l,{id:e,isClosed:t})=>{ce({id:e},l).forEach(i=>{i.hidden=t??!1,i.isGroup&&!i.isClosed&&he(l,{id:i.id,isClosed:t})})},li=l=>{l.filter(e=>e.isGroup&&!e.disabled&&(e.checked||e.isPartialChecked)).forEach(e=>{e.isClosed=!1,he(l,e)})},ni=(l,e)=>{const t=ai(l,e);l.forEach(s=>{t.some(({id:a})=>a===s.id)?(s.isGroup&&(s.isClosed=!1,he(l,s)),s.hidden=!1):s.hidden=!0})},ai=(l,e)=>l.reduce((t,s)=>{if(s.name.toLowerCase().includes(e.toLowerCase())){if(t.push(s),s.isGroup){const a=qt(s.id,l);t.push(...a)}if(s.childOf){const a=Rt(s.childOf,l);t.push(...a)}}return t},[]),qt=(l,e)=>e.reduce((t,s)=>(s.childOf===l&&(t.push(s),s.isGroup&&t.push(...qt(s.id,e))),t),[]),Rt=(l,e)=>e.reduce((t,s)=>(s.id===l&&(t.push(s),s.childOf&&t.push(...Rt(s.childOf,e))),t),[]),oi=l=>{const{duplications:e}=l.reduce((t,s)=>(t.allItems.some(i=>i.toString()===s.id.toString())&&t.duplications.push(s.id),t.allItems.push(s.id),t),{duplications:[],allItems:[]});e.length&&console.error(`Validation: You have duplicated values: ${e.join(", ")}! You should use unique values.`)},ri=(l,e,t,s,i,a,h,d,w,g)=>{Dt(l,e,i,w),d&&h&&li(e),de(e,t,s,a,g)},de=(l,e,t,s,i)=>{l.forEach(a=>{const h=e.querySelector(`[input-id="${a.id}"]`),d=I(h);h.checked=a.checked,ci(a,d,s),hi(a,d),di(a,d),ui(a,d,t),pi(a,d),fi(a,d,l,i),mi(a,h,t)}),Ci(l,e)},ci=(l,e,t)=>{l.checked?e.classList.add("treeselect-list__item--checked"):e.classList.remove("treeselect-list__item--checked"),Array.isArray(t)&&t[0]===l.id&&!l.disabled?e.classList.add("treeselect-list__item--single-selected"):e.classList.remove("treeselect-list__item--single-selected")},hi=(l,e)=>{l.isPartialChecked?e.classList.add("treeselect-list__item--partial-checked"):e.classList.remove("treeselect-list__item--partial-checked")},di=(l,e)=>{l.disabled?e.classList.add("treeselect-list__item--disabled"):e.classList.remove("treeselect-list__item--disabled")},ui=(l,e,t)=>{if(l.isGroup){const s=e.querySelector(".treeselect-list__item-icon"),i=l.isClosed?t.arrowRight:t.arrowDown;f(i,s),l.isClosed?e.classList.add("treeselect-list__item--closed"):e.classList.remove("treeselect-list__item--closed")}},pi=(l,e)=>{l.hidden?e.classList.add("treeselect-list__item--hidden"):e.classList.remove("treeselect-list__item--hidden")},mi=(l,e,t)=>{const i=e.parentNode.querySelector(".treeselect-list__item-checkbox-icon");l.checked?f(t.check,i):l.isPartialChecked?f(t.partialCheck,i):i.innerHTML=""},fi=(l,e,t,s)=>{const i=l.level===0,a=20,h=5;if(i){const d=t.some(k=>k.isGroup&&k.level===l.level),w=!l.isGroup&&d?`${a}px`:`${h}px`,g=l.isGroup?"0":w;s?e.style.paddingRight=g:e.style.paddingLeft=g}else{const d=l.isGroup?`${l.level*a}px`:`${l.level*a+a}px`;s?e.style.paddingRight=d:e.style.paddingLeft=d}e.setAttribute("level",l.level.toString()),e.setAttribute("group",l.isGroup.toString())},Ci=(l,e)=>{const t=l.some(i=>!i.hidden),s=e.querySelector(".treeselect-list__empty");t?s.classList.add("treeselect-list__empty--hidden"):s.classList.remove("treeselect-list__empty--hidden")},I=l=>l.parentNode.parentNode,$t=(l,e)=>e.find(t=>t.id.toString()===l),bi=l=>I(l).querySelector(".treeselect-list__item-icon"),gi=(l,e)=>{e&&Object.keys(e).forEach(t=>{const s=e[t];typeof s=="string"&&l.setAttribute(t,s)})};class ki{constructor({options:e,value:t,openLevel:s,listSlotHtmlComponent:i,emptyText:a,isSingleSelect:h,iconElements:d,showCount:w,disabledBranchNode:g,expandSelected:k,isIndependentNodes:E,rtl:v,listClassName:L,inputCallback:N,arrowClickCallback:O,mouseupCallback:j}){r(this,Ie);r(this,Pe);r(this,Be);r(this,Ve);r(this,De);r(this,He);r(this,X);r(this,Ge);r(this,Me);r(this,Fe);r(this,J);r(this,je);r(this,qe);r(this,Re);r(this,$e);r(this,We);r(this,Ue);r(this,ze);r(this,Ye);r(this,Ke);r(this,Xe);r(this,Je);r(this,Z);r(this,Q);r(this,Ze);c(this,"options");c(this,"value");c(this,"openLevel");c(this,"listSlotHtmlComponent");c(this,"emptyText");c(this,"isSingleSelect");c(this,"showCount");c(this,"disabledBranchNode");c(this,"expandSelected");c(this,"isIndependentNodes");c(this,"rtl");c(this,"listClassName");c(this,"iconElements");c(this,"searchText");c(this,"flattedOptions");c(this,"flattedOptionsBeforeSearch");c(this,"selectedNodes");c(this,"srcElement");c(this,"inputCallback");c(this,"arrowClickCallback");c(this,"mouseupCallback");r(this,F,null);r(this,V,!0);r(this,_,[]);r(this,K,!0);this.options=e,this.value=t,this.openLevel=s??0,this.listSlotHtmlComponent=i??null,this.emptyText=a??"No results found...",this.isSingleSelect=h??!1,this.showCount=w??!1,this.disabledBranchNode=g??!1,this.expandSelected=k??!1,this.isIndependentNodes=E??!1,this.rtl=v??!1,this.listClassName=L??"",this.iconElements=d,this.searchText="",this.flattedOptions=ti(this.options,this.openLevel,this.isIndependentNodes),this.flattedOptionsBeforeSearch=this.flattedOptions,this.selectedNodes={nodes:[],groupedNodes:[],allNodes:[]},this.srcElement=o(this,Be,ps).call(this),this.inputCallback=N,this.arrowClickCallback=O,this.mouseupCallback=j,oi(this.flattedOptions)}updateValue(e){this.value=e,b(this,_,this.isSingleSelect?this.value:[]),ri(e,this.flattedOptions,this.srcElement,this.iconElements,this.isSingleSelect,n(this,_),this.expandSelected,n(this,K),this.isIndependentNodes,this.rtl),b(this,K,!1),o(this,Q,Tt).call(this)}updateSearchValue(e){if(e===this.searchText)return;const t=this.searchText===""&&e!=="";this.searchText=e,t&&(this.flattedOptionsBeforeSearch=JSON.parse(JSON.stringify(this.flattedOptions))),this.searchText===""&&(this.flattedOptions=this.flattedOptionsBeforeSearch.map(s=>{const i=this.flattedOptions.find(a=>a.id===s.id);return i.isClosed=s.isClosed,i.hidden=s.hidden,i}),this.flattedOptionsBeforeSearch=[]),this.searchText&&ni(this.flattedOptions,e),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_),this.rtl),this.focusFirstListElement()}callKeyAction(e){b(this,V,!1);const t=this.srcElement.querySelector(".treeselect-list__item--focused");if(t==null?void 0:t.classList.contains("treeselect-list__item--hidden"))return;const i=e.key;i==="Enter"&&t&&t.dispatchEvent(new Event("mousedown")),(i==="ArrowLeft"||i==="ArrowRight")&&o(this,Ie,ds).call(this,t,e),(i==="ArrowDown"||i==="ArrowUp")&&o(this,Pe,us).call(this,t,i)}focusFirstListElement(){const e="treeselect-list__item--focused",t=this.srcElement.querySelector(`.${e}`),s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(a=>window.getComputedStyle(I(a)).display!=="none");if(!s.length)return;t&&t.classList.remove(e),I(s[0]).classList.add(e)}isLastFocusedElementExist(){return!!n(this,F)}}F=new WeakMap,V=new WeakMap,_=new WeakMap,K=new WeakMap,Ie=new WeakSet,ds=function(e,t){if(!e)return;const s=t.key,a=e.querySelector(".treeselect-list__item-checkbox").getAttribute("input-id"),h=$t(a,this.flattedOptions),d=e.querySelector(".treeselect-list__item-icon");s==="ArrowLeft"&&!h.isClosed&&h.isGroup&&(d.dispatchEvent(new Event("mousedown")),t.preventDefault()),s==="ArrowRight"&&h.isClosed&&h.isGroup&&(d.dispatchEvent(new Event("mousedown")),t.preventDefault())},Pe=new WeakSet,us=function(e,t){var i;const s=Array.from(this.srcElement.querySelectorAll(".treeselect-list__item-checkbox")).filter(a=>window.getComputedStyle(I(a)).display!=="none");if(s.length)if(!e)I(s[0]).classList.add("treeselect-list__item--focused");else{const a=s.findIndex(O=>I(O).classList.contains("treeselect-list__item--focused"));I(s[a]).classList.remove("treeselect-list__item--focused");const d=t==="ArrowDown"?a+1:a-1,w=t==="ArrowDown"?0:s.length-1,g=s[d]??s[w],k=!s[d],E=I(g);E.classList.add("treeselect-list__item--focused");const v=this.srcElement.getBoundingClientRect(),L=E.getBoundingClientRect();if(k&&t==="ArrowDown"){this.srcElement.scroll(0,0);return}if(k&&t==="ArrowUp"){this.srcElement.scroll(0,this.srcElement.scrollHeight);return}const N=((i=this.listSlotHtmlComponent)==null?void 0:i.clientHeight)??0;if(v.y+v.height<L.y+L.height+N){this.srcElement.scroll(0,this.srcElement.scrollTop+L.height);return}if(v.y>L.y){this.srcElement.scroll(0,this.srcElement.scrollTop-L.height);return}}},Be=new WeakSet,ps=function(){const e=o(this,Ve,ms).call(this),t=o(this,X,St).call(this,this.options);e.append(...t);const s=o(this,Me,gs).call(this);e.append(s);const i=o(this,Ge,bs).call(this);return i&&e.append(i),e},Ve=new WeakSet,ms=function(){const e=document.createElement("div");return e.classList.add("treeselect-list"),this.listClassName.length>0&&e.classList.add(this.listClassName),this.isSingleSelect&&e.classList.add("treeselect-list--single-select"),this.disabledBranchNode&&e.classList.add("treeselect-list--disabled-branch-node"),e.addEventListener("mouseout",t=>o(this,De,fs).call(this,t)),e.addEventListener("mousemove",()=>o(this,He,Cs).call(this)),e.addEventListener("mouseup",()=>this.mouseupCallback(),!0),e},De=new WeakSet,fs=function(e){e.stopPropagation(),n(this,F)&&n(this,V)&&n(this,F).classList.add("treeselect-list__item--focused")},He=new WeakSet,Cs=function(){b(this,V,!0)},X=new WeakSet,St=function(e){return e.reduce((t,s)=>{var a;if((a=s.children)!=null&&a.length){const h=o(this,Fe,ks).call(this,s),d=o(this,X,St).call(this,s.children);return h.append(...d),t.push(h),t}const i=o(this,J,_t).call(this,s,!1);return t.push(i),t},[])},Ge=new WeakSet,bs=function(){if(!this.listSlotHtmlComponent)return null;const e=document.createElement("div");return e.classList.add("treeselect-list__slot"),e.appendChild(this.listSlotHtmlComponent),e},Me=new WeakSet,gs=function(){const e=document.createElement("div");e.classList.add("treeselect-list__empty"),e.setAttribute("title",this.emptyText);const t=document.createElement("span");t.classList.add("treeselect-list__empty-icon"),f(this.iconElements.attention,t);const s=document.createElement("span");return s.classList.add("treeselect-list__empty-text"),s.textContent=this.emptyText,e.append(t,s),e},Fe=new WeakSet,ks=function(e){const t=document.createElement("div");t.setAttribute("group-container-id",e.value.toString()),t.classList.add("treeselect-list__group-container");const s=o(this,J,_t).call(this,e,!0);return t.appendChild(s),t},J=new WeakSet,_t=function(e,t){const s=o(this,je,ws).call(this,e);if(t){const h=o(this,We,ys).call(this);s.appendChild(h),s.classList.add("treeselect-list__item--group")}const i=o(this,ze,Ss).call(this,e),a=o(this,Ye,_s).call(this,e,t);return s.append(i,a),s},je=new WeakSet,ws=function(e){const t=document.createElement("div");return gi(t,e.htmlAttr),t.setAttribute("tabindex","-1"),t.setAttribute("title",e.name),t.classList.add("treeselect-list__item"),t.addEventListener("mouseover",()=>o(this,qe,Es).call(this,t),!0),t.addEventListener("mouseout",()=>o(this,Re,vs).call(this,t),!0),t.addEventListener("mousedown",s=>o(this,$e,Ls).call(this,s,e)),t},qe=new WeakSet,Es=function(e){n(this,V)&&o(this,Z,At).call(this,!0,e)},Re=new WeakSet,vs=function(e){n(this,V)&&(o(this,Z,At).call(this,!1,e),b(this,F,e))},$e=new WeakSet,Ls=function(e,t){var a;if(e.preventDefault(),e.stopPropagation(),(a=this.flattedOptions.find(h=>h.id===t.value))==null?void 0:a.disabled)return;const i=e.target.querySelector(".treeselect-list__item-checkbox");i.checked=!i.checked,o(this,Xe,Ts).call(this,i,t)},We=new WeakSet,ys=function(){const e=document.createElement("span");return e.setAttribute("tabindex","-1"),e.classList.add("treeselect-list__item-icon"),f(this.iconElements.arrowDown,e),e.addEventListener("mousedown",t=>o(this,Ue,xs).call(this,t)),e},Ue=new WeakSet,xs=function(e){e.preventDefault(),e.stopPropagation(),o(this,Je,Ns).call(this,e)},ze=new WeakSet,Ss=function(e){const t=document.createElement("div");t.classList.add("treeselect-list__item-checkbox-container");const s=document.createElement("span");s.classList.add("treeselect-list__item-checkbox-icon"),s.innerHTML="";const i=document.createElement("input");return i.setAttribute("tabindex","-1"),i.setAttribute("type","checkbox"),i.setAttribute("input-id",e.value.toString()),i.classList.add("treeselect-list__item-checkbox"),t.append(s,i),t},Ye=new WeakSet,_s=function(e,t){const s=document.createElement("label");if(s.textContent=e.name,s.classList.add("treeselect-list__item-label"),t&&this.showCount){const i=o(this,Ke,As).call(this,e);s.appendChild(i)}return s},Ke=new WeakSet,As=function(e){const t=document.createElement("span"),s=this.flattedOptions.filter(i=>i.childOf===e.value);return t.textContent=`(${s.length})`,t.classList.add("treeselect-list__item-label-counter"),t},Xe=new WeakSet,Ts=function(e,t){const s=this.flattedOptions.find(i=>i.id===t.value);if(s){if(s!=null&&s.isGroup&&this.disabledBranchNode){const i=bi(e);i==null||i.dispatchEvent(new Event("mousedown"));return}if(this.isSingleSelect){const[i]=n(this,_);if(s.id===i)return;b(this,_,[s.id]),Dt([s.id],this.flattedOptions,this.isSingleSelect,this.isIndependentNodes)}else{s.checked=e.checked;const i=wt(s,this.flattedOptions,this.isIndependentNodes);e.checked=i}de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_),this.rtl),o(this,Ze,Os).call(this)}},Je=new WeakSet,Ns=function(e){var a,h;const t=(h=(a=e.target)==null?void 0:a.parentNode)==null?void 0:h.querySelector("[input-id]"),s=(t==null?void 0:t.getAttribute("input-id"))??null,i=$t(s,this.flattedOptions);i&&(i.isClosed=!i.isClosed,he(this.flattedOptions,i),de(this.flattedOptions,this.srcElement,this.iconElements,n(this,_),this.rtl),this.arrowClickCallback(i.id,i.isClosed))},Z=new WeakSet,At=function(e,t){const s="treeselect-list__item--focused";if(e){const i=Array.from(this.srcElement.querySelectorAll(`.${s}`));i.length&&i.forEach(a=>a.classList.remove(s)),t.classList.add(s)}else t.classList.remove(s)},Q=new WeakSet,Tt=function(){const{ungroupedNodes:e,groupedNodes:t,allNodes:s}=si(this.flattedOptions);this.selectedNodes={nodes:e,groupedNodes:t,allNodes:s}},Ze=new WeakSet,Os=function(){o(this,Q,Tt).call(this),this.inputCallback(this.selectedNodes),this.value=this.selectedNodes.nodes.map(e=>e.id)};const Wt=({parentHtmlContainer:l,staticList:e,appendToBody:t,isSingleSelect:s,value:i,direction:a})=>{l||console.error("Validation: parentHtmlContainer prop is required!"),e&&t&&console.error("Validation: You should set staticList to false if you use appendToBody!"),s&&Array.isArray(i)&&console.error("Validation: if you use isSingleSelect prop, you should pass a single value!"),!s&&!Array.isArray(i)&&console.error("Validation: you should pass an array as a value!"),a&&a!=="auto"&&a!=="bottom"&&a!=="top"&&console.error("Validation: you should pass (auto | top | bottom | undefined) as a value for the direction prop!")},ue=l=>l.map(e=>e.id),wi=l=>l?Array.isArray(l)?l:[l]:[],Ei=(l,e)=>{if(e){const[t]=l;return t??null}return l};class vi{constructor({parentHtmlContainer:e,value:t,options:s,openLevel:i,appendToBody:a,alwaysOpen:h,showTags:d,tagsCountText:w,clearable:g,searchable:k,placeholder:E,grouped:v,isGroupedValue:L,listSlotHtmlComponent:N,disabled:O,emptyText:j,staticList:Ct,id:vt,ariaLabel:Lt,isSingleSelect:bt,showCount:Li,disabledBranchNode:yi,direction:xi,expandSelected:Si,saveScrollPosition:_i,isIndependentNodes:Ai,rtl:Ti,listClassName:Ni,iconElements:Oi,inputCallback:Ii,openCallback:Pi,closeCallback:Bi,nameChangeCallback:Vi,searchCallback:Di,openCloseGroupCallback:Hi}){r(this,te);r(this,se);r(this,Qe);r(this,et);r(this,tt);r(this,st);r(this,it);r(this,lt);r(this,ie);r(this,nt);r(this,at);r(this,ot);r(this,rt);r(this,le);r(this,ct);r(this,W);r(this,ne);r(this,U);r(this,ht);r(this,ae);r(this,dt);r(this,ut);r(this,pt);r(this,mt);r(this,ft);c(this,"parentHtmlContainer");c(this,"value");c(this,"options");c(this,"openLevel");c(this,"appendToBody");c(this,"alwaysOpen");c(this,"showTags");c(this,"tagsCountText");c(this,"clearable");c(this,"searchable");c(this,"placeholder");c(this,"grouped");c(this,"isGroupedValue");c(this,"listSlotHtmlComponent");c(this,"disabled");c(this,"emptyText");c(this,"staticList");c(this,"id");c(this,"ariaLabel");c(this,"isSingleSelect");c(this,"showCount");c(this,"disabledBranchNode");c(this,"direction");c(this,"expandSelected");c(this,"saveScrollPosition");c(this,"isIndependentNodes");c(this,"rtl");c(this,"listClassName");c(this,"iconElements");c(this,"inputCallback");c(this,"openCallback");c(this,"closeCallback");c(this,"nameChangeCallback");c(this,"searchCallback");c(this,"openCloseGroupCallback");c(this,"ungroupedValue");c(this,"groupedValue");c(this,"allValue");c(this,"isListOpened");c(this,"selectedName");c(this,"srcElement");r(this,u,null);r(this,m,null);r(this,R,null);r(this,ee,0);r(this,$,0);r(this,A,null);r(this,T,null);r(this,S,null);r(this,D,null);Wt({parentHtmlContainer:e,value:t,staticList:Ct,appendToBody:a,isSingleSelect:bt}),this.parentHtmlContainer=e,this.value=[],this.options=s??[],this.openLevel=i??0,this.appendToBody=a??!1,this.alwaysOpen=!!(h&&!O),this.showTags=d??!0,this.tagsCountText=w??"elements selected",this.clearable=g??!0,this.searchable=k??!0,this.placeholder=E??"Search...",this.grouped=v??!0,this.isGroupedValue=L??!1,this.listSlotHtmlComponent=N??null,this.disabled=O??!1,this.emptyText=j??"No results found...",this.staticList=!!(Ct&&!this.appendToBody),this.id=vt??"",this.ariaLabel=Lt??"",this.isSingleSelect=bt??!1,this.showCount=Li??!1,this.disabledBranchNode=yi??!1,this.direction=xi??"auto",this.expandSelected=Si??!1,this.saveScrollPosition=_i??!0,this.isIndependentNodes=Ai??!1,this.rtl=Ti??!1,this.listClassName=Ni??"",this.iconElements=z(Oi),this.inputCallback=Ii,this.openCallback=Pi,this.closeCallback=Bi,this.nameChangeCallback=Vi,this.searchCallback=Di,this.openCloseGroupCallback=Hi,this.ungroupedValue=[],this.groupedValue=[],this.allValue=[],this.isListOpened=!1,this.selectedName="",this.srcElement=null,o(this,te,Nt).call(this,t)}mount(){Wt({parentHtmlContainer:this.parentHtmlContainer,value:this.value,staticList:this.staticList,appendToBody:this.appendToBody,isSingleSelect:this.isSingleSelect}),this.iconElements=z(this.iconElements),o(this,te,Nt).call(this,this.value)}updateValue(e){const t=wi(e),s=n(this,u);s&&(s.updateValue(t),o(this,ie,It).call(this,s==null?void 0:s.selectedNodes))}destroy(){this.srcElement&&(o(this,le,Pt).call(this),this.srcElement.innerHTML="",this.srcElement=null,o(this,U,kt).call(this,!0))}focus(){n(this,m)&&n(this,m).focus()}toggleOpenClose(){n(this,m)&&(n(this,m).openClose(),n(this,m).focus())}scrollWindowHandler(){this.updateListPosition()}focusWindowHandler(e){var s,i,a;((s=this.srcElement)==null?void 0:s.contains(e.target))||((i=n(this,u))==null?void 0:i.srcElement.contains(e.target))||((a=n(this,m))==null||a.blur(),o(this,U,kt).call(this,!1),o(this,W,gt).call(this,!1))}blurWindowHandler(){var e;(e=n(this,m))==null||e.blur(),o(this,U,kt).call(this,!1),o(this,W,gt).call(this,!1)}updateListPosition(){var N;const e=this.srcElement,t=(N=n(this,u))==null?void 0:N.srcElement;if(!e||!t)return;const{height:s}=t.getBoundingClientRect(),{x:i,y:a,height:h,width:d}=e.getBoundingClientRect(),w=window.innerHeight,g=a,k=w-a-h;let E=g>k&&g>=s&&k<s;if(this.direction!=="auto"&&(E=this.direction==="top"),this.appendToBody){(t.style.top!=="0px"||t.style.left!=="0px")&&(t.style.top="0px",t.style.left="0px");const O=i+window.scrollX,j=E?a+window.scrollY-s:a+window.scrollY+h;t.style.transform=`translate(${O}px,${j}px)`,t.style.width=`${d}px`}const v=E?"top":"bottom";t.getAttribute("direction")!==v&&(t.setAttribute("direction",v),o(this,ct,qs).call(this,E,this.appendToBody))}}return u=new WeakMap,m=new WeakMap,R=new WeakMap,ee=new WeakMap,$=new WeakMap,A=new WeakMap,T=new WeakMap,S=new WeakMap,D=new WeakMap,te=new WeakSet,Nt=function(e){var a;this.destroy();const{container:t,list:s,input:i}=o(this,Qe,Is).call(this);this.srcElement=t,b(this,u,s),b(this,m,i),b(this,A,this.scrollWindowHandler.bind(this)),b(this,T,this.scrollWindowHandler.bind(this)),b(this,S,this.focusWindowHandler.bind(this)),b(this,D,this.blurWindowHandler.bind(this)),this.alwaysOpen&&((a=n(this,m))==null||a.openClose()),this.disabled?this.srcElement.classList.add("treeselect--disabled"):this.srcElement.classList.remove("treeselect--disabled"),this.updateValue(e??this.value)},se=new WeakSet,Ot=function({groupedNodes:e,nodes:t,allNodes:s}){this.ungroupedValue=t?ue(t):[],this.groupedValue=e?ue(e):[],this.allValue=s?ue(s):[];let i=[];this.isIndependentNodes||this.isSingleSelect?i=this.allValue:this.isGroupedValue?i=this.groupedValue:i=this.ungroupedValue,this.value=Ei(i,this.isSingleSelect)},Qe=new WeakSet,Is=function(){const e=this.parentHtmlContainer;e.classList.add("treeselect"),this.rtl&&e.setAttribute("dir","rtl");const t=new ki({value:[],options:this.options,openLevel:this.openLevel,listSlotHtmlComponent:this.listSlotHtmlComponent,emptyText:this.emptyText,isSingleSelect:this.isSingleSelect,showCount:this.showCount,disabledBranchNode:this.disabledBranchNode,expandSelected:this.expandSelected,isIndependentNodes:this.isIndependentNodes,rtl:this.rtl,listClassName:this.listClassName,iconElements:this.iconElements,inputCallback:i=>o(this,nt,Gs).call(this,i),arrowClickCallback:(i,a)=>o(this,at,Ms).call(this,i,a),mouseupCallback:()=>{var i;return(i=n(this,m))==null?void 0:i.focus()}}),s=new Xs({value:[],showTags:this.showTags,tagsCountText:this.tagsCountText,clearable:this.clearable,isAlwaysOpened:this.alwaysOpen,searchable:this.searchable,placeholder:this.placeholder,disabled:this.disabled,isSingleSelect:this.isSingleSelect,id:this.id,ariaLabel:this.ariaLabel,iconElements:this.iconElements,inputCallback:i=>o(this,et,Ps).call(this,i),searchCallback:i=>o(this,st,Vs).call(this,i),openCallback:()=>o(this,rt,js).call(this),closeCallback:()=>o(this,le,Pt).call(this),keydownCallback:i=>o(this,tt,Bs).call(this,i),focusCallback:()=>o(this,it,Ds).call(this),blurCallback:()=>o(this,lt,Hs).call(this),nameChangeCallback:i=>o(this,ot,Fs).call(this,i)});return this.appendToBody&&b(this,R,new ResizeObserver(()=>this.updateListPosition())),e.append(s.srcElement),{container:e,list:t,input:s}},et=new WeakSet,Ps=function(e){var i,a;const t=ue(e);(i=n(this,u))==null||i.updateValue(t);const s=((a=n(this,u))==null?void 0:a.selectedNodes)??{};o(this,se,Ot).call(this,s),o(this,ae,Vt).call(this)},tt=new WeakSet,Bs=function(e){var t;this.isListOpened&&((t=n(this,u))==null||t.callKeyAction(e))},st=new WeakSet,Vs=function(e){n(this,$)&&clearTimeout(n(this,$)),b(this,$,window.setTimeout(()=>{var t;(t=n(this,u))==null||t.updateSearchValue(e),this.updateListPosition()},350)),o(this,mt,zs).call(this,e)},it=new WeakSet,Ds=function(){o(this,W,gt).call(this,!0),n(this,S)&&n(this,S)&&n(this,D)&&(document.addEventListener("mousedown",n(this,S),!0),document.addEventListener("focus",n(this,S),!0),window.addEventListener("blur",n(this,D)))},lt=new WeakSet,Hs=function(){setTimeout(()=>{var s,i;const e=(s=n(this,m))==null?void 0:s.srcElement.contains(document.activeElement),t=(i=n(this,u))==null?void 0:i.srcElement.contains(document.activeElement);!e&&!t&&this.blurWindowHandler()},1)},ie=new WeakSet,It=function(e){var s;if(!e)return;let t=[];this.isIndependentNodes||this.isSingleSelect?t=e.allNodes:this.grouped?t=e.groupedNodes:t=e.nodes,(s=n(this,m))==null||s.updateValue(t),o(this,se,Ot).call(this,e)},nt=new WeakSet,Gs=function(e){var t,s,i;o(this,ie,It).call(this,e),this.isSingleSelect&&!this.alwaysOpen&&((t=n(this,m))==null||t.openClose(),(s=n(this,m))==null||s.clearSearch()),(i=n(this,m))==null||i.focus(),o(this,ae,Vt).call(this)},at=new WeakSet,Ms=function(e,t){var s;(s=n(this,m))==null||s.focus(),this.updateListPosition(),o(this,ft,Ys).call(this,e,t)},ot=new WeakSet,Fs=function(e){this.selectedName!==e&&(this.selectedName=e,o(this,dt,$s).call(this))},rt=new WeakSet,js=function(){var e;this.isListOpened=!0,n(this,A)&&n(this,T)&&(window.addEventListener("scroll",n(this,A),!0),window.addEventListener("resize",n(this,T))),!(!n(this,u)||!this.srcElement)&&(this.appendToBody?(document.body.appendChild(n(this,u).srcElement),(e=n(this,R))==null||e.observe(this.srcElement)):this.srcElement.appendChild(n(this,u).srcElement),this.updateListPosition(),o(this,ne,Bt).call(this,!0),o(this,ht,Rs).call(this),o(this,ut,Ws).call(this))},le=new WeakSet,Pt=function(){var t;this.alwaysOpen||(this.isListOpened=!1,n(this,A)&&n(this,T)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),!n(this,u)||!this.srcElement)||!(this.appendToBody?document.body.contains(n(this,u).srcElement):this.srcElement.contains(n(this,u).srcElement))||(b(this,ee,n(this,u).srcElement.scrollTop),this.appendToBody?(document.body.removeChild(n(this,u).srcElement),(t=n(this,R))==null||t.disconnect()):this.srcElement.removeChild(n(this,u).srcElement),o(this,ne,Bt).call(this,!1),o(this,pt,Us).call(this))},ct=new WeakSet,qs=function(e,t){if(!n(this,u)||!n(this,m))return;const s=t?"treeselect-list--top-to-body":"treeselect-list--top",i=t?"treeselect-list--bottom-to-body":"treeselect-list--bottom";e?(n(this,u).srcElement.classList.add(s),n(this,u).srcElement.classList.remove(i),n(this,m).srcElement.classList.add("treeselect-input--top"),n(this,m).srcElement.classList.remove("treeselect-input--bottom")):(n(this,u).srcElement.classList.remove(s),n(this,u).srcElement.classList.add(i),n(this,m).srcElement.classList.remove("treeselect-input--top"),n(this,m).srcElement.classList.add("treeselect-input--bottom"))},W=new WeakSet,gt=function(e){!n(this,m)||!n(this,u)||(e?(n(this,m).srcElement.classList.add("treeselect-input--focused"),n(this,u).srcElement.classList.add("treeselect-list--focused")):(n(this,m).srcElement.classList.remove("treeselect-input--focused"),n(this,u).srcElement.classList.remove("treeselect-list--focused")))},ne=new WeakSet,Bt=function(e){var t,s,i,a;e?(t=n(this,m))==null||t.srcElement.classList.add("treeselect-input--opened"):(s=n(this,m))==null||s.srcElement.classList.remove("treeselect-input--opened"),this.staticList?(i=n(this,u))==null||i.srcElement.classList.add("treeselect-list--static"):(a=n(this,u))==null||a.srcElement.classList.remove("treeselect-list--static")},U=new WeakSet,kt=function(e){!n(this,A)||!n(this,T)||!n(this,S)||!n(this,D)||((!this.alwaysOpen||e)&&(window.removeEventListener("scroll",n(this,A),!0),window.removeEventListener("resize",n(this,T))),document.removeEventListener("mousedown",n(this,S),!0),document.removeEventListener("focus",n(this,S),!0),window.removeEventListener("blur",n(this,D)))},ht=new WeakSet,Rs=function(){var t,s,i;const e=(t=n(this,u))==null?void 0:t.isLastFocusedElementExist();this.saveScrollPosition&&e?(s=n(this,u))==null||s.srcElement.scroll(0,n(this,ee)):(i=n(this,u))==null||i.focusFirstListElement()},ae=new WeakSet,Vt=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("input",{detail:this.value})),this.inputCallback&&this.inputCallback(this.value)},dt=new WeakSet,$s=function(){var e;(e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("name-change",{detail:this.selectedName})),this.nameChangeCallback&&this.nameChangeCallback(this.selectedName)},ut=new WeakSet,Ws=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("open",{detail:this.value})),this.openCallback&&this.openCallback(this.value))},pt=new WeakSet,Us=function(){var e;this.alwaysOpen||((e=this.srcElement)==null||e.dispatchEvent(new CustomEvent("close",{detail:this.value})),this.closeCallback&&this.closeCallback(this.value))},mt=new WeakSet,zs=function(e){var s;const t=(e==null?void 0:e.trim())??"";(s=this.srcElement)==null||s.dispatchEvent(new CustomEvent("search",{detail:t})),this.searchCallback&&this.searchCallback(t)},ft=new WeakSet,Ys=function(e,t){var s;(s=this.srcElement)==null||s.dispatchEvent(new CustomEvent("open-close-group",{detail:{groupId:e,isClosed:t}})),this.openCloseGroupCallback&&this.openCloseGroupCallback(e,t)},vi});

