UNPKG

flyonui

Version:

The easiest, free and open-source Tailwind CSS component library with semantic classes.

8 lines 50.5 kB
var t={179:(t,e,i)=>{i.d(e,{fp:()=>n,lP:()=>s});const s={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-start":"top-start","top-end":"top-end",bottom:"bottom","bottom-start":"bottom-start","bottom-end":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"},n=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Space","Tab"]},392:(t,e,i)=>{i.d(e,{JD:()=>l,PR:()=>s,ar:()=>n,en:()=>d,fc:()=>a,sg:()=>o,yd:()=>r}); /* * @version: 3.0.1 * @author: Preline Labs Ltd. * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html) * Copyright 2024 Preline Labs Ltd. */ const s=(t,e,i="auto",s=10,n=null)=>{const o=e.getBoundingClientRect(),l=n?n.getBoundingClientRect():null,r=window.innerHeight,a=l?o.top-l.top:o.top,d=(n?l.bottom:r)-o.bottom,c=t.clientHeight+s;return"bottom"===i?d>=c:"top"===i?a>=c:a>=c||d>=c},n=t=>document.activeElement===t,o=(t,e=200)=>{let i;return(...s)=>{clearTimeout(i),i=setTimeout((()=>{t.apply(void 0,s)}),e)}},l=(t,e,i=null)=>{const s=new CustomEvent(t,{detail:{payload:i},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(s)},r=(t,e)=>{const i=()=>{e(),t.removeEventListener("transitionend",i,!0)},s=window.getComputedStyle(t),n=s.getPropertyValue("transition-duration");"none"!==s.getPropertyValue("transition-property")&&parseFloat(n)>0?t.addEventListener("transitionend",i,!0):e()},a=t=>{const e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild},d=(t,e,i=" ",s="add")=>{t.split(i).forEach((t=>"add"===s?e.classList.add(t):e.classList.remove(t)))}},663:(t,e,i)=>{i.d(e,{ll:()=>_,rD:()=>Z,cY:()=>G});const s=Math.min,n=Math.max,o=Math.round,l=Math.floor,r=t=>({x:t,y:t});function a(t){return t.split("-")[0]}function d(t){return t.split("-")[1]}function c(t){return"y"===t?"height":"width"}function h(t){return["top","bottom"].includes(a(t))?"y":"x"}function p(t){return"x"===h(t)?"y":"x"}function u(t){const{x:e,y:i,width:s,height:n}=t;return{width:s,height:n,top:i,left:e,right:e+s,bottom:i+n,x:e,y:i}}function g(t,e,i){let{reference:s,floating:n}=t;const o=h(e),l=p(e),r=c(l),u=a(e),g="y"===o,m=s.x+s.width/2-n.width/2,f=s.y+s.height/2-n.height/2,v=s[r]/2-n[r]/2;let w;switch(u){case"top":w={x:m,y:s.y-n.height};break;case"bottom":w={x:m,y:s.y+s.height};break;case"right":w={x:s.x+s.width,y:f};break;case"left":w={x:s.x-n.width,y:f};break;default:w={x:s.x,y:s.y}}switch(d(e)){case"start":w[l]-=v*(i&&g?-1:1);break;case"end":w[l]+=v*(i&&g?-1:1)}return w}function m(){return"undefined"!=typeof window}function f(t){return y(t)?(t.nodeName||"").toLowerCase():"#document"}function v(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function w(t){var e;return null==(e=(y(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function y(t){return!!m()&&(t instanceof Node||t instanceof v(t).Node)}function I(t){return!!m()&&(t instanceof Element||t instanceof v(t).Element)}function b(t){return!!m()&&(t instanceof HTMLElement||t instanceof v(t).HTMLElement)}function T(t){return!(!m()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof v(t).ShadowRoot)}function x(t){const{overflow:e,overflowX:i,overflowY:s,display:n}=O(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+i)&&!["inline","contents"].includes(n)}function S(t){return["table","td","th"].includes(f(t))}function C(t){return[":popover-open",":modal"].some((e=>{try{return t.matches(e)}catch(t){return!1}}))}function L(t){const e=E(),i=I(t)?O(t):t;return["transform","translate","scale","rotate","perspective"].some((t=>!!i[t]&&"none"!==i[t]))||!!i.containerType&&"normal"!==i.containerType||!e&&!!i.backdropFilter&&"none"!==i.backdropFilter||!e&&!!i.filter&&"none"!==i.filter||["transform","translate","scale","rotate","perspective","filter"].some((t=>(i.willChange||"").includes(t)))||["paint","layout","strict","content"].some((t=>(i.contain||"").includes(t)))}function E(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function A(t){return["html","body","#document"].includes(f(t))}function O(t){return v(t).getComputedStyle(t)}function M(t){return I(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function F(t){if("html"===f(t))return t;const e=t.assignedSlot||t.parentNode||T(t)&&t.host||w(t);return T(e)?e.host:e}function D(t){const e=F(t);return A(e)?t.ownerDocument?t.ownerDocument.body:t.body:b(e)&&x(e)?e:D(e)}function $(t,e,i){var s;void 0===e&&(e=[]),void 0===i&&(i=!0);const n=D(t),o=n===(null==(s=t.ownerDocument)?void 0:s.body),l=v(n);if(o){const t=R(l);return e.concat(l,l.visualViewport||[],x(n)?n:[],t&&i?$(t):[])}return e.concat(n,$(n,[],i))}function R(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function q(t){const e=O(t);let i=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const n=b(t),l=n?t.offsetWidth:i,r=n?t.offsetHeight:s,a=o(i)!==l||o(s)!==r;return a&&(i=l,s=r),{width:i,height:s,$:a}}function P(t){return I(t)?t:t.contextElement}function k(t){const e=P(t);if(!b(e))return r(1);const i=e.getBoundingClientRect(),{width:s,height:n,$:l}=q(e);let a=(l?o(i.width):i.width)/s,d=(l?o(i.height):i.height)/n;return a&&Number.isFinite(a)||(a=1),d&&Number.isFinite(d)||(d=1),{x:a,y:d}}const W=r(0);function H(t){const e=v(t);return E()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:W}function N(t,e,i,s){void 0===e&&(e=!1),void 0===i&&(i=!1);const n=t.getBoundingClientRect(),o=P(t);let l=r(1);e&&(s?I(s)&&(l=k(s)):l=k(t));const a=function(t,e,i){return void 0===e&&(e=!1),!(!i||e&&i!==v(t))&&e}(o,i,s)?H(o):r(0);let d=(n.left+a.x)/l.x,c=(n.top+a.y)/l.y,h=n.width/l.x,p=n.height/l.y;if(o){const t=v(o),e=s&&I(s)?v(s):s;let i=t,n=R(i);for(;n&&s&&e!==i;){const t=k(n),e=n.getBoundingClientRect(),s=O(n),o=e.left+(n.clientLeft+parseFloat(s.paddingLeft))*t.x,l=e.top+(n.clientTop+parseFloat(s.paddingTop))*t.y;d*=t.x,c*=t.y,h*=t.x,p*=t.y,d+=o,c+=l,i=v(n),n=R(i)}}return u({width:h,height:p,x:d,y:c})}function V(t,e){const i=M(t).scrollLeft;return e?e.left+i:N(w(t)).left+i}function B(t,e,i){void 0===i&&(i=!1);const s=t.getBoundingClientRect();return{x:s.left+e.scrollLeft-(i?0:V(t,s)),y:s.top+e.scrollTop}}function U(t,e,i){let s;if("viewport"===e)s=function(t,e){const i=v(t),s=w(t),n=i.visualViewport;let o=s.clientWidth,l=s.clientHeight,r=0,a=0;if(n){o=n.width,l=n.height;const t=E();(!t||t&&"fixed"===e)&&(r=n.offsetLeft,a=n.offsetTop)}return{width:o,height:l,x:r,y:a}}(t,i);else if("document"===e)s=function(t){const e=w(t),i=M(t),s=t.ownerDocument.body,o=n(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),l=n(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let r=-i.scrollLeft+V(t);const a=-i.scrollTop;return"rtl"===O(s).direction&&(r+=n(e.clientWidth,s.clientWidth)-o),{width:o,height:l,x:r,y:a}}(w(t));else if(I(e))s=function(t,e){const i=N(t,!0,"fixed"===e),s=i.top+t.clientTop,n=i.left+t.clientLeft,o=b(t)?k(t):r(1);return{width:t.clientWidth*o.x,height:t.clientHeight*o.y,x:n*o.x,y:s*o.y}}(e,i);else{const i=H(t);s={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return u(s)}function j(t,e){const i=F(t);return!(i===e||!I(i)||A(i))&&("fixed"===O(i).position||j(i,e))}function K(t,e,i){const s=b(e),n=w(e),o="fixed"===i,l=N(t,!0,o,e);let a={scrollLeft:0,scrollTop:0};const d=r(0);function c(){d.x=V(n)}if(s||!s&&!o)if(("body"!==f(e)||x(n))&&(a=M(e)),s){const t=N(e,!0,o,e);d.x=t.x+e.clientLeft,d.y=t.y+e.clientTop}else n&&c();o&&!s&&n&&c();const h=!n||s||o?r(0):B(n,a);return{x:l.left+a.scrollLeft-d.x-h.x,y:l.top+a.scrollTop-d.y-h.y,width:l.width,height:l.height}}function z(t){return"static"===O(t).position}function Q(t,e){if(!b(t)||"fixed"===O(t).position)return null;if(e)return e(t);let i=t.offsetParent;return w(t)===i&&(i=i.ownerDocument.body),i}function J(t,e){const i=v(t);if(C(t))return i;if(!b(t)){let e=F(t);for(;e&&!A(e);){if(I(e)&&!z(e))return e;e=F(e)}return i}let s=Q(t,e);for(;s&&S(s)&&z(s);)s=Q(s,e);return s&&A(s)&&z(s)&&!L(s)?i:s||function(t){let e=F(t);for(;b(e)&&!A(e);){if(L(e))return e;if(C(e))return null;e=F(e)}return null}(t)||i}const Y={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:i,offsetParent:s,strategy:n}=t;const o="fixed"===n,l=w(s),a=!!e&&C(e.floating);if(s===l||a&&o)return i;let d={scrollLeft:0,scrollTop:0},c=r(1);const h=r(0),p=b(s);if((p||!p&&!o)&&(("body"!==f(s)||x(l))&&(d=M(s)),b(s))){const t=N(s);c=k(s),h.x=t.x+s.clientLeft,h.y=t.y+s.clientTop}const u=!l||p||o?r(0):B(l,d,!0);return{width:i.width*c.x,height:i.height*c.y,x:i.x*c.x-d.scrollLeft*c.x+h.x+u.x,y:i.y*c.y-d.scrollTop*c.y+h.y+u.y}},getDocumentElement:w,getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:o,strategy:l}=t;const r=[..."clippingAncestors"===i?C(e)?[]:function(t,e){const i=e.get(t);if(i)return i;let s=$(t,[],!1).filter((t=>I(t)&&"body"!==f(t))),n=null;const o="fixed"===O(t).position;let l=o?F(t):t;for(;I(l)&&!A(l);){const e=O(l),i=L(l);i||"fixed"!==e.position||(n=null),(o?!i&&!n:!i&&"static"===e.position&&n&&["absolute","fixed"].includes(n.position)||x(l)&&!i&&j(t,l))?s=s.filter((t=>t!==l)):n=e,l=F(l)}return e.set(t,s),s}(e,this._c):[].concat(i),o],a=r[0],d=r.reduce(((t,i)=>{const o=U(e,i,l);return t.top=n(o.top,t.top),t.right=s(o.right,t.right),t.bottom=s(o.bottom,t.bottom),t.left=n(o.left,t.left),t}),U(e,a,l));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}},getOffsetParent:J,getElementRects:async function(t){const e=this.getOffsetParent||J,i=this.getDimensions,s=await i(t.floating);return{reference:K(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:i}=q(t);return{width:e,height:i}},getScale:k,isElement:I,isRTL:function(t){return"rtl"===O(t).direction}};function X(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function _(t,e,i,o){void 0===o&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:d="function"==typeof ResizeObserver,layoutShift:c="function"==typeof IntersectionObserver,animationFrame:h=!1}=o,p=P(t),u=r||a?[...p?$(p):[],...$(e)]:[];u.forEach((t=>{r&&t.addEventListener("scroll",i,{passive:!0}),a&&t.addEventListener("resize",i)}));const g=p&&c?function(t,e){let i,o=null;const r=w(t);function a(){var t;clearTimeout(i),null==(t=o)||t.disconnect(),o=null}return function d(c,h){void 0===c&&(c=!1),void 0===h&&(h=1),a();const p=t.getBoundingClientRect(),{left:u,top:g,width:m,height:f}=p;if(c||e(),!m||!f)return;const v={rootMargin:-l(g)+"px "+-l(r.clientWidth-(u+m))+"px "+-l(r.clientHeight-(g+f))+"px "+-l(u)+"px",threshold:n(0,s(1,h))||1};let w=!0;function y(e){const s=e[0].intersectionRatio;if(s!==h){if(!w)return d();s?d(!1,s):i=setTimeout((()=>{d(!1,1e-7)}),1e3)}1!==s||X(p,t.getBoundingClientRect())||d(),w=!1}try{o=new IntersectionObserver(y,{...v,root:r.ownerDocument})}catch(t){o=new IntersectionObserver(y,v)}o.observe(t)}(!0),a}(p,i):null;let m,f=-1,v=null;d&&(v=new ResizeObserver((t=>{let[s]=t;s&&s.target===p&&v&&(v.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame((()=>{var t;null==(t=v)||t.observe(e)}))),i()})),p&&!h&&v.observe(p),v.observe(e));let y=h?N(t):null;return h&&function e(){const s=N(t);y&&!X(y,s)&&i();y=s,m=requestAnimationFrame(e)}(),i(),()=>{var t;u.forEach((t=>{r&&t.removeEventListener("scroll",i),a&&t.removeEventListener("resize",i)})),null==g||g(),null==(t=v)||t.disconnect(),v=null,h&&cancelAnimationFrame(m)}}const G=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var i,s;const{x:n,y:o,placement:l,middlewareData:r}=e,c=await async function(t,e){const{placement:i,platform:s,elements:n}=t,o=await(null==s.isRTL?void 0:s.isRTL(n.floating)),l=a(i),r=d(i),c="y"===h(i),p=["left","top"].includes(l)?-1:1,u=o&&c?-1:1,g=(f=t,"function"==typeof(m=e)?m(f):m);var m,f;let{mainAxis:v,crossAxis:w,alignmentAxis:y}="number"==typeof g?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return r&&"number"==typeof y&&(w="end"===r?-1*y:y),c?{x:w*u,y:v*p}:{x:v*p,y:w*u}}(e,t);return l===(null==(i=r.offset)?void 0:i.placement)&&null!=(s=r.arrow)&&s.alignmentOffset?{}:{x:n+c.x,y:o+c.y,data:{...c,placement:l}}}}},Z=(t,e,i)=>{const s=new Map,n={platform:Y,...i},o={...n.platform,_c:s};return(async(t,e,i)=>{const{placement:s="bottom",strategy:n="absolute",middleware:o=[],platform:l}=i,r=o.filter(Boolean),a=await(null==l.isRTL?void 0:l.isRTL(e));let d=await l.getElementRects({reference:t,floating:e,strategy:n}),{x:c,y:h}=g(d,s,a),p=s,u={},m=0;for(let i=0;i<r.length;i++){const{name:o,fn:f}=r[i],{x:v,y:w,data:y,reset:I}=await f({x:c,y:h,initialPlacement:s,placement:p,strategy:n,middlewareData:u,rects:d,platform:l,elements:{reference:t,floating:e}});c=null!=v?v:c,h=null!=w?w:h,u={...u,[o]:{...u[o],...y}},I&&m<=50&&(m++,"object"==typeof I&&(I.placement&&(p=I.placement),I.rects&&(d=!0===I.rects?await l.getElementRects({reference:t,floating:e,strategy:n}):I.rects),({x:c,y:h}=g(d,p,a))),i=-1)}return{x:c,y:h,placement:p,strategy:n,middlewareData:u}})(t,e,{...n,platform:o})}},709:(t,e,i)=>{i.d(e,{A:()=>s});class s{constructor(t,e,i){this.el=t,this.options=e,this.events=i,this.el=t,this.options=e,this.events={}}createCollection(t,e){var i;t.push({id:(null===(i=null==e?void 0:e.el)||void 0===i?void 0:i.id)||t.length+1,element:e})}fireEvent(t,e=null){if(this.events.hasOwnProperty(t))return this.events[t](e)}on(t,e){this.events[t]=e}}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var o=e[s]={exports:{}};return t[s](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s={};i.d(s,{A:()=>c});var n=i(392),o=i(663),l=i(709),r=i(179),a=function(t,e,i,s){return new(i||(i=Promise))((function(n,o){function l(t){try{a(s.next(t))}catch(t){o(t)}}function r(t){try{a(s.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(l,r)}a((s=s.apply(t,e||[])).next())}))};class d extends l.A{constructor(t,e){var i,s,n,o;super(t,e),this.optionId=0;const l=t.getAttribute("data-select"),r=l?JSON.parse(l):{},a=Object.assign(Object.assign({},r),e);this.value=(null==a?void 0:a.value)||this.el.value||null,this.placeholder=(null==a?void 0:a.placeholder)||"Select...",this.hasSearch=(null==a?void 0:a.hasSearch)||!1,this.minSearchLength=null!==(i=null==a?void 0:a.minSearchLength)&&void 0!==i?i:0,this.preventSearchFocus=(null==a?void 0:a.preventSearchFocus)||!1,this.mode=(null==a?void 0:a.mode)||"default",this.viewport=void 0!==(null==a?void 0:a.viewport)?document.querySelector(null==a?void 0:a.viewport):null,this.isOpened=Boolean(null==a?void 0:a.isOpened)||!1,this.isMultiple=this.el.hasAttribute("multiple")||!1,this.isDisabled=this.el.hasAttribute("disabled")||!1,this.selectedItems=[],this.apiUrl=(null==a?void 0:a.apiUrl)||null,this.apiQuery=(null==a?void 0:a.apiQuery)||null,this.apiOptions=(null==a?void 0:a.apiOptions)||null,this.apiSearchQueryKey=(null==a?void 0:a.apiSearchQueryKey)||null,this.apiDataPart=(null==a?void 0:a.apiDataPart)||null,this.apiFieldsMap=(null==a?void 0:a.apiFieldsMap)||null,this.apiIconTag=(null==a?void 0:a.apiIconTag)||null,this.wrapperClasses=(null==a?void 0:a.wrapperClasses)||null,this.toggleTag=(null==a?void 0:a.toggleTag)||null,this.toggleClasses=(null==a?void 0:a.toggleClasses)||null,this.toggleCountText=void 0===typeof(null==a?void 0:a.toggleCountText)?null:a.toggleCountText,this.toggleCountTextPlacement=(null==a?void 0:a.toggleCountTextPlacement)||"postfix",this.toggleCountTextMinItems=(null==a?void 0:a.toggleCountTextMinItems)||1,this.toggleCountTextMode=(null==a?void 0:a.toggleCountTextMode)||"countAfterLimit",this.toggleSeparators={items:(null===(s=null==a?void 0:a.toggleSeparators)||void 0===s?void 0:s.items)||", ",betweenItemsAndCounter:(null===(n=null==a?void 0:a.toggleSeparators)||void 0===n?void 0:n.betweenItemsAndCounter)||"and"},this.tagsItemTemplate=(null==a?void 0:a.tagsItemTemplate)||null,this.tagsItemClasses=(null==a?void 0:a.tagsItemClasses)||null,this.tagsInputId=(null==a?void 0:a.tagsInputId)||null,this.tagsInputClasses=(null==a?void 0:a.tagsInputClasses)||null,this.dropdownTag=(null==a?void 0:a.dropdownTag)||null,this.dropdownClasses=(null==a?void 0:a.dropdownClasses)||null,this.dropdownDirectionClasses=(null==a?void 0:a.dropdownDirectionClasses)||null,this.dropdownSpace=(null==a?void 0:a.dropdownSpace)||10,this.dropdownPlacement=(null==a?void 0:a.dropdownPlacement)||null,this.dropdownVerticalFixedPlacement=(null==a?void 0:a.dropdownVerticalFixedPlacement)||null,this.dropdownScope=(null==a?void 0:a.dropdownScope)||"parent",this.searchTemplate=(null==a?void 0:a.searchTemplate)||null,this.searchWrapperTemplate=(null==a?void 0:a.searchWrapperTemplate)||null,this.searchWrapperClasses=(null==a?void 0:a.searchWrapperClasses)||"bg-base-100 sticky top-0 mb-2 px-2 pt-3",this.searchId=(null==a?void 0:a.searchId)||null,this.searchLimit=(null==a?void 0:a.searchLimit)||1/0,this.isSearchDirectMatch=void 0===(null==a?void 0:a.isSearchDirectMatch)||(null==a?void 0:a.isSearchDirectMatch),this.searchClasses=(null==a?void 0:a.searchClasses)||"border-base-content/40 focus:border-primary focus:outline-primary bg-base-100 block w-full rounded-field border px-3 py-2 text-base focus:outline-1",this.searchPlaceholder=(null==a?void 0:a.searchPlaceholder)||"Search...",this.searchNoResultTemplate=(null==a?void 0:a.searchNoResultTemplate)||"<span></span>",this.searchNoResultText=(null==a?void 0:a.searchNoResultText)||"No results found",this.searchNoResultClasses=(null==a?void 0:a.searchNoResultClasses)||"block advance-select-option",this.optionAllowEmptyOption=void 0!==(null==a?void 0:a.optionAllowEmptyOption)&&(null==a?void 0:a.optionAllowEmptyOption),this.optionTemplate=(null==a?void 0:a.optionTemplate)||null,this.optionTag=(null==a?void 0:a.optionTag)||null,this.optionClasses=(null==a?void 0:a.optionClasses)||null,this.extraMarkup=(null==a?void 0:a.extraMarkup)||null,this.descriptionClasses=(null==a?void 0:a.descriptionClasses)||null,this.iconClasses=(null==a?void 0:a.iconClasses)||null,this.isAddTagOnEnter=null===(o=null==a?void 0:a.isAddTagOnEnter)||void 0===o||o,this.animationInProcess=!1,this.selectOptions=[],this.remoteOptions=[],this.tagsInputHelper=null,this.init()}wrapperClick(t){t.target.closest("[data-select-dropdown]")||t.target.closest("[data-tag-value]")||this.tagsInput.focus()}toggleClick(){if(this.isDisabled)return!1;this.toggleFn()}tagsInputFocus(){this.isOpened||this.open()}tagsInputInput(){this.calculateInputWidth()}tagsInputInputSecond(t){this.searchOptions(t.target.value)}tagsInputKeydown(t){if("Enter"===t.key&&this.isAddTagOnEnter){const e=t.target.value;if(this.selectOptions.find((t=>t.val===e)))return!1;this.addSelectOption(e,e),this.buildOption(e,e),this.dropdown.querySelector(`[data-value="${e}"]`).click(),this.resetTagsInputField()}}searchInput(t){const e=t.target.value;this.apiUrl?this.remoteSearch(e):this.searchOptions(e)}setValue(t){if(this.value=t,this.clearSelections(),Array.isArray(t))if("tags"===this.mode){this.unselectMultipleItems(),this.selectMultipleItems(),this.selectedItems=[];this.wrapper.querySelectorAll("[data-tag-value]").forEach((t=>t.remove())),this.setTagsItems(),this.reassignTagsInputPlaceholder(this.value.length?"":this.placeholder)}else this.toggleTextWrapper.innerHTML=this.value.length?this.stringFromValue():this.placeholder,this.unselectMultipleItems(),this.selectMultipleItems();else this.setToggleTitle(),this.toggle.querySelector("[data-icon]")&&this.setToggleIcon(),this.toggle.querySelector("[data-title]")&&this.setToggleTitle(),this.selectSingleItem()}init(){this.createCollection(window.$hsSelectCollection,this),this.build()}build(){if(this.el.style.display="none",this.el.children&&Array.from(this.el.children).filter((t=>this.optionAllowEmptyOption||!this.optionAllowEmptyOption&&t.value&&""!==t.value)).forEach((t=>{const e=t.getAttribute("data-select-option");this.selectOptions=[...this.selectOptions,{title:t.textContent,val:t.value,disabled:t.disabled,options:"undefined"!==e?JSON.parse(e):null}]})),this.isMultiple){const t=Array.from(this.el.children).filter((t=>t.selected));if(t){const e=[];t.forEach((t=>{e.push(t.value)})),this.value=e}}this.buildWrapper(),"tags"===this.mode?this.buildTags():this.buildToggle(),this.buildDropdown(),this.extraMarkup&&this.buildExtraMarkup()}buildWrapper(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("advance-select","relative"),"tags"===this.mode&&(this.onWrapperClickListener=t=>this.wrapperClick(t),this.wrapper.addEventListener("click",this.onWrapperClickListener)),this.wrapperClasses&&(0,n.en)(this.wrapperClasses,this.wrapper),this.el.before(this.wrapper),this.wrapper.append(this.el)}buildExtraMarkup(){const t=t=>{const e=(0,n.fc)(t);return this.wrapper.append(e),e},e=t=>{t.classList.contains("--prevent-click")||t.addEventListener("click",(t=>{t.stopPropagation(),this.toggleFn()}))};if(Array.isArray(this.extraMarkup))this.extraMarkup.forEach((i=>{const s=t(i);e(s)}));else{const i=t(this.extraMarkup);e(i)}}buildToggle(){var t,e;let i,s;this.toggleTextWrapper=document.createElement("span"),this.toggleTextWrapper.classList.add("truncate"),this.toggle=(0,n.fc)(this.toggleTag||"<div></div>"),i=this.toggle.querySelector("[data-icon]"),s=this.toggle.querySelector("[data-title]"),!this.isMultiple&&i&&this.setToggleIcon(),!this.isMultiple&&s&&this.setToggleTitle(),this.isMultiple?this.toggleTextWrapper.innerHTML=this.value.length?this.stringFromValue():this.placeholder:this.toggleTextWrapper.innerHTML=(null===(t=this.getItemByValue(this.value))||void 0===t?void 0:t.title)||this.placeholder,s||this.toggle.append(this.toggleTextWrapper),this.toggleClasses&&(0,n.en)(this.toggleClasses,this.toggle),this.isDisabled&&this.toggle.classList.add("disabled"),this.wrapper&&this.wrapper.append(this.toggle),(null===(e=this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.isOpened?this.toggle.ariaExpanded="true":this.toggle.ariaExpanded="false"),this.onToggleClickListener=()=>this.toggleClick(),this.toggle.addEventListener("click",this.onToggleClickListener)}setToggleIcon(){var t;const e=this.getItemByValue(this.value),i=this.toggle.querySelector("[data-icon]");if(i){i.innerHTML="";const s=(0,n.fc)(this.apiUrl&&this.apiIconTag?this.apiIconTag||"":(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.icon)||"");this.value&&this.apiUrl&&this.apiIconTag&&e[this.apiFieldsMap.icon]&&(s.src=e[this.apiFieldsMap.icon]||""),i.append(s),s?i.classList.remove("hidden"):i.classList.add("hidden")}}setToggleTitle(){var t,e;const i=this.toggle.querySelector("[data-title]");i?(i.innerHTML=(null===(t=this.getItemByValue(this.value))||void 0===t?void 0:t.title)||this.placeholder,i.classList.add("truncate"),this.toggle.append(i)):this.toggle.innerText=(null===(e=this.getItemByValue(this.value))||void 0===e?void 0:e.title)||this.placeholder}buildTags(){this.isDisabled&&this.wrapper.classList.add("disabled"),this.buildTagsInput(),this.setTagsItems()}reassignTagsInputPlaceholder(t){this.tagsInput.placeholder=t,this.tagsInputHelper.innerHTML=t,this.calculateInputWidth()}buildTagsItem(t){var e,i,s,o;const l=this.getItemByValue(t);let r,a,d,c;const h=document.createElement("div");if(h.setAttribute("data-tag-value",t),this.tagsItemClasses&&(0,n.en)(this.tagsItemClasses,h),this.tagsItemTemplate&&(r=(0,n.fc)(this.tagsItemTemplate),h.append(r)),(null===(e=null==l?void 0:l.options)||void 0===e?void 0:e.icon)||this.apiIconTag){const t=(0,n.fc)(this.apiUrl&&this.apiIconTag?this.apiIconTag:null===(i=null==l?void 0:l.options)||void 0===i?void 0:i.icon);this.apiUrl&&this.apiIconTag&&l[this.apiFieldsMap.icon]&&(t.src=l[this.apiFieldsMap.icon]||""),c=r?r.querySelector("[data-icon]"):document.createElement("span"),c.append(t),r||h.append(c)}!r||!r.querySelector("[data-icon]")||(null===(s=null==l?void 0:l.options)||void 0===s?void 0:s.icon)||this.apiUrl||this.apiIconTag||l[null===(o=this.apiFieldsMap)||void 0===o?void 0:o.icon]||r.querySelector("[data-icon]").classList.add("hidden"),a=r?r.querySelector("[data-title]"):document.createElement("span"),a.textContent=l.title||"",r||h.append(a),r?d=r.querySelector("[data-remove]"):(d=document.createElement("span"),d.textContent="X",h.append(d)),d.addEventListener("click",(()=>{this.value=this.value.filter((e=>e!==t)),this.selectedItems=this.selectedItems.filter((e=>e!==t)),this.value.length||this.reassignTagsInputPlaceholder(this.placeholder),this.unselectMultipleItems(),this.selectMultipleItems(),h.remove(),this.triggerChangeEventForNativeSelect()})),this.wrapper.append(h)}getItemByValue(t){return this.apiUrl?this.remoteOptions.find((e=>`${e[this.apiFieldsMap.val]}`===t||e[this.apiFieldsMap.title]===t)):this.selectOptions.find((e=>e.val===t))}setTagsItems(){this.value&&this.value.forEach((t=>{this.selectedItems.includes(t)||this.buildTagsItem(t),this.selectedItems=this.selectedItems.includes(t)?this.selectedItems:[...this.selectedItems,t]})),this.isOpened&&this.floatingUIInstance&&this.floatingUIInstance.update()}buildTagsInput(){this.tagsInput=document.createElement("input"),this.tagsInputId&&(this.tagsInput.id=this.tagsInputId),this.tagsInputClasses&&(0,n.en)(this.tagsInputClasses,this.tagsInput),this.onTagsInputFocusListener=()=>this.tagsInputFocus(),this.onTagsInputInputListener=()=>this.tagsInputInput(),this.onTagsInputInputSecondListener=(0,n.sg)((t=>this.tagsInputInputSecond(t))),this.onTagsInputKeydownListener=t=>this.tagsInputKeydown(t),this.tagsInput.addEventListener("focus",this.onTagsInputFocusListener),this.tagsInput.addEventListener("input",this.onTagsInputInputListener),this.tagsInput.addEventListener("input",this.onTagsInputInputSecondListener),this.tagsInput.addEventListener("keydown",this.onTagsInputKeydownListener),this.wrapper.append(this.tagsInput),setTimeout((()=>{this.adjustInputWidth(),this.reassignTagsInputPlaceholder(this.value.length?"":this.placeholder)}))}buildDropdown(){this.dropdown=(0,n.fc)(this.dropdownTag||"<div></div>"),this.dropdown.setAttribute("data-select-dropdown",""),"parent"===this.dropdownScope&&(this.dropdown.classList.add("absolute"),this.dropdownVerticalFixedPlacement||this.dropdown.classList.add("top-full")),this.dropdown.role="listbox",this.dropdown.tabIndex=-1,this.dropdown.ariaOrientation="vertical",this.isOpened||this.dropdown.classList.add("hidden"),this.dropdownClasses&&(0,n.en)(this.dropdownClasses,this.dropdown),this.wrapper&&this.wrapper.append(this.dropdown),this.dropdown&&this.hasSearch&&this.buildSearch(),this.selectOptions&&this.selectOptions.forEach(((t,e)=>this.buildOption(t.title,t.val,t.disabled,t.selected,t.options,`${e}`))),this.apiUrl&&this.optionsFromRemoteData(),"window"===this.dropdownScope&&this.buildFloatingUI()}buildFloatingUI(){document.body.appendChild(this.dropdown);const t="tags"===this.mode?this.wrapper:this.toggle,e={placement:r.lP[this.dropdownPlacement]||"bottom",strategy:"fixed",middleware:[(0,o.cY)(0)]},i=()=>{(0,o.rD)(t,this.dropdown,e).then((({x:t,y:e,placement:i})=>{Object.assign(this.dropdown.style,{position:"fixed",left:`${t}px`,top:`${e}px`}),this.dropdown.setAttribute("data-placement",i)}))};i();const s=(0,o.ll)(t,this.dropdown,i);this.floatingUIInstance={update:i,destroy:s}}updateDropdownWidth(){const t="tags"===this.mode?this.wrapper:this.toggle;this.dropdown.style.width=`${t.clientWidth}px`}buildSearch(){let t;this.searchWrapper=(0,n.fc)(this.searchWrapperTemplate||"<div></div>"),this.searchWrapperClasses&&(0,n.en)(this.searchWrapperClasses,this.searchWrapper),t=this.searchWrapper.querySelector("[data-input]");const e=(0,n.fc)(this.searchTemplate||'<input type="text">');this.search="INPUT"===e.tagName?e:e.querySelector(":scope input"),this.search.placeholder=this.searchPlaceholder,this.searchClasses&&(0,n.en)(this.searchClasses,this.search),this.searchId&&(this.search.id=this.searchId),this.onSearchInputListener=(0,n.sg)((t=>this.searchInput(t))),this.search.addEventListener("input",this.onSearchInputListener),t?t.append(e):this.searchWrapper.append(e),this.dropdown.append(this.searchWrapper)}buildOption(t,e,i=!1,s=!1,o,l="1",r){var a;let d=null,c=null,h=null,p=null;const u=(0,n.fc)(this.optionTag||"<div></div>");if(u.setAttribute("data-value",e),u.setAttribute("data-title-value",t),u.setAttribute("tabIndex",l),u.classList.add("cursor-pointer"),u.setAttribute("data-id",r||`${this.optionId}`),r||this.optionId++,i&&u.classList.add("disabled"),s&&(this.isMultiple?this.value=[...this.value,e]:this.value=e),this.optionTemplate&&(d=(0,n.fc)(this.optionTemplate),u.append(d)),d?(c=d.querySelector("[data-title]"),c.textContent=t||""):u.textContent=t||"",o){if(o.icon){const e=(0,n.fc)(null!==(a=this.apiIconTag)&&void 0!==a?a:o.icon);if(e.classList.add("max-w-full"),this.apiUrl&&(e.setAttribute("alt",t),e.setAttribute("src",o.icon)),d)h=d.querySelector("[data-icon]"),h.append(e);else{const t=(0,n.fc)("<div></div>");this.iconClasses&&(0,n.en)(this.iconClasses,t),t.append(e),u.append(t)}}if(o.description)if(d)p=d.querySelector("[data-description]"),p&&p.append(o.description);else{const t=(0,n.fc)("<div></div>");t.textContent=o.description,this.descriptionClasses&&(0,n.en)(this.descriptionClasses,t),u.append(t)}}d&&d.querySelector("[data-icon]")&&!o&&!(null==o?void 0:o.icon)&&d.querySelector("[data-icon]").classList.add("hidden"),this.value&&(this.isMultiple?this.value.includes(e):this.value===e)&&u.classList.add("selected"),i||u.addEventListener("click",(()=>this.onSelectOption(e))),this.optionClasses&&(0,n.en)(this.optionClasses,u),this.dropdown&&this.dropdown.append(u),s&&this.setNewValue()}buildOptionFromRemoteData(t,e,i=!1,s=!1,n="1",o,l){n?this.buildOption(t,e,i,s,l,n,o):alert("ID parameter is required for generating remote options! Please check your API endpoint have it.")}buildOptionsFromRemoteData(t){t.forEach(((t,e)=>{let i=null,s="",n="";const o={id:"",val:"",title:"",icon:null,description:null,rest:{}};Object.keys(t).forEach((e=>{var l;t[this.apiFieldsMap.id]&&(i=t[this.apiFieldsMap.id]),(t[this.apiFieldsMap.val]||t[this.apiFieldsMap.title])&&(n=t[this.apiFieldsMap.val]||t[this.apiFieldsMap.title]),t[this.apiFieldsMap.title]&&(s=t[this.apiFieldsMap.title]),t[this.apiFieldsMap.icon]&&(o.icon=t[this.apiFieldsMap.icon]),t[null===(l=this.apiFieldsMap)||void 0===l?void 0:l.description]&&(o.description=t[this.apiFieldsMap.description]),o.rest[e]=t[e]}));const l="string"==typeof this.value&&this.value===`${n}`||Array.isArray(this.value)&&this.value.includes(`${n}`);this.buildOriginalOption(s,`${n}`,i,!1,l,o),this.buildOptionFromRemoteData(s,`${n}`,!1,l,`${e}`,i,o)})),this.sortElements(this.el,"option"),this.sortElements(this.dropdown,"[data-value]")}optionsFromRemoteData(){return a(this,arguments,void 0,(function*(t=""){const e=yield this.apiRequest(t);this.remoteOptions=e,e.length?this.buildOptionsFromRemoteData(this.remoteOptions):console.log("There is no data were responded!")}))}apiRequest(){return a(this,arguments,void 0,(function*(t=""){try{let e=this.apiUrl;const i=this.apiSearchQueryKey?`${this.apiSearchQueryKey}=${t.toLowerCase()}`:null,s=`${this.apiQuery}`,n=this.apiOptions||{};i&&(e+=`?${i}`),this.apiQuery&&(e+=`${i?"&":"?"}${s}`);const o=yield fetch(e,n),l=yield o.json();return this.apiDataPart?l[this.apiDataPart]:l}catch(t){console.error(t)}}))}sortElements(t,e){const i=Array.from(t.querySelectorAll(e));i.sort(((t,e)=>{const i=t.classList.contains("selected")||t.hasAttribute("selected"),s=e.classList.contains("selected")||e.hasAttribute("selected");return i&&!s?-1:!i&&s?1:0})),i.forEach((e=>t.appendChild(e)))}remoteSearch(t){return a(this,void 0,void 0,(function*(){if(t.length<=this.minSearchLength){const t=yield this.apiRequest("");return this.remoteOptions=t,Array.from(this.dropdown.querySelectorAll("[data-value]")).forEach((t=>t.remove())),Array.from(this.el.querySelectorAll("option[value]")).forEach((t=>{t.remove()})),t.length?this.buildOptionsFromRemoteData(t):console.log("No data responded!"),!1}const e=yield this.apiRequest(t);this.remoteOptions=e;let i=e.map((t=>`${t.id}`)),s=null;const n=this.dropdown.querySelectorAll("[data-value]");this.el.querySelectorAll("[data-select-option]").forEach((t=>{var e;const s=t.getAttribute("data-id");i.includes(s)||(null===(e=this.value)||void 0===e?void 0:e.includes(t.value))||this.destroyOriginalOption(t.value)})),n.forEach((t=>{var e;const s=t.getAttribute("data-id");i.includes(s)||(null===(e=this.value)||void 0===e?void 0:e.includes(t.getAttribute("data-value")))?i=i.filter((t=>t!==s)):this.destroyOption(t.getAttribute("data-value"))})),s=e.filter((t=>i.includes(`${t.id}`))),s.length?this.buildOptionsFromRemoteData(s):console.log("There is no data were responded!")}))}destroyOption(t){const e=this.dropdown.querySelector(`[data-value="${t}"]`);if(!e)return!1;e.remove()}buildOriginalOption(t,e,i,s,o,l){const r=(0,n.fc)("<option></option>");r.setAttribute("value",e),s&&r.setAttribute("disabled","disabled"),o&&r.setAttribute("selected","selected"),i&&r.setAttribute("data-id",i),r.setAttribute("data-select-option",JSON.stringify(l)),r.innerText=t,this.el.append(r)}destroyOriginalOption(t){const e=this.el.querySelector(`[value="${t}"]`);if(!e)return!1;e.remove()}buildTagsInputHelper(){this.tagsInputHelper=document.createElement("span"),this.tagsInputHelper.style.fontSize=window.getComputedStyle(this.tagsInput).fontSize,this.tagsInputHelper.style.fontFamily=window.getComputedStyle(this.tagsInput).fontFamily,this.tagsInputHelper.style.fontWeight=window.getComputedStyle(this.tagsInput).fontWeight,this.tagsInputHelper.style.letterSpacing=window.getComputedStyle(this.tagsInput).letterSpacing,this.tagsInputHelper.style.visibility="hidden",this.tagsInputHelper.style.whiteSpace="pre",this.tagsInputHelper.style.position="absolute",this.wrapper.appendChild(this.tagsInputHelper)}calculateInputWidth(){this.tagsInputHelper.textContent=this.tagsInput.value||this.tagsInput.placeholder;const t=parseInt(window.getComputedStyle(this.tagsInput).paddingLeft)+parseInt(window.getComputedStyle(this.tagsInput).paddingRight),e=parseInt(window.getComputedStyle(this.tagsInput).borderLeftWidth)+parseInt(window.getComputedStyle(this.tagsInput).borderRightWidth),i=this.tagsInputHelper.offsetWidth+t+e,s=this.wrapper.offsetWidth-(parseInt(window.getComputedStyle(this.wrapper).paddingLeft)+parseInt(window.getComputedStyle(this.wrapper).paddingRight));this.tagsInput.style.width=`${Math.min(i,s)+2}px`}adjustInputWidth(){this.buildTagsInputHelper(),this.calculateInputWidth()}onSelectOption(t){if(this.clearSelections(),this.isMultiple?(this.value=this.value.includes(t)?Array.from(this.value).filter((e=>e!==t)):[...Array.from(this.value),t],this.selectMultipleItems(),this.setNewValue()):(this.value=t,this.selectSingleItem(),this.setNewValue()),this.fireEvent("change",this.value),"tags"===this.mode){const t=this.selectedItems.filter((t=>!this.value.includes(t)));t.length&&t.forEach((t=>{this.selectedItems=this.selectedItems.filter((e=>e!==t)),this.wrapper.querySelector(`[data-tag-value="${t}"]`).remove()})),this.resetTagsInputField()}this.isMultiple||(this.toggle.querySelector("[data-icon]")&&this.setToggleIcon(),this.toggle.querySelector("[data-title]")&&this.setToggleTitle(),this.close(!0)),this.value.length||"tags"!==this.mode||this.reassignTagsInputPlaceholder(this.placeholder),this.isOpened&&"tags"===this.mode&&this.tagsInput&&this.tagsInput.focus(),this.triggerChangeEventForNativeSelect()}triggerChangeEventForNativeSelect(){const t=new Event("change",{bubbles:!0});this.el.dispatchEvent(t),(0,n.JD)("change.advance.select",this.el,this.value)}addSelectOption(t,e,i,s,n){this.selectOptions=[...this.selectOptions,{title:t,val:e,disabled:i,selected:s,options:n}]}removeSelectOption(t,e=!1){if(!!!this.selectOptions.some((e=>e.val===t)))return!1;this.selectOptions=this.selectOptions.filter((e=>e.val!==t)),this.value=e?this.value.filter((e=>e!==t)):t}resetTagsInputField(){this.tagsInput.value="",this.reassignTagsInputPlaceholder(""),this.searchOptions("")}clearSelections(){Array.from(this.dropdown.children).forEach((t=>{t.classList.contains("selected")&&t.classList.remove("selected")})),Array.from(this.el.children).forEach((t=>{t.selected&&(t.selected=!1)}))}setNewValue(){var t;"tags"===this.mode?this.setTagsItems():(null===(t=this.value)||void 0===t?void 0:t.length)?this.toggleTextWrapper.innerHTML=this.stringFromValue():this.toggleTextWrapper.innerHTML=this.placeholder}stringFromValueBasic(t){var e;const i=[];let s="";if(t.forEach((t=>{this.isMultiple?this.value.includes(t.val)&&i.push(t.title):this.value===t.val&&i.push(t.title)})),void 0!==this.toggleCountText&&null!==this.toggleCountText&&i.length>=this.toggleCountTextMinItems)if("nItemsAndCount"===this.toggleCountTextMode){const t=i.slice(0,this.toggleCountTextMinItems-1),n=[t.join(this.toggleSeparators.items)],o=""+(i.length-t.length);if((null===(e=null==this?void 0:this.toggleSeparators)||void 0===e?void 0:e.betweenItemsAndCounter)&&n.push(this.toggleSeparators.betweenItemsAndCounter),this.toggleCountText)switch(this.toggleCountTextPlacement){case"postfix-no-space":n.push(`${o}${this.toggleCountText}`);break;case"prefix-no-space":n.push(`${this.toggleCountText}${o}`);break;case"prefix":n.push(`${this.toggleCountText} ${o}`);break;default:n.push(`${o} ${this.toggleCountText}`)}s=n.join(" ")}else s=`${i.length} ${this.toggleCountText}`;else s=i.join(this.toggleSeparators.items);return s}stringFromValueRemoteData(){const t=this.dropdown.querySelectorAll("[data-title-value]"),e=[];let i="";if(t.forEach((t=>{const i=t.getAttribute("data-value"),s=t.getAttribute("data-title-value");this.isMultiple?this.value.includes(i)&&e.push(s):this.value===i&&e.push(s)})),this.toggleCountText&&""!==this.toggleCountText&&e.length>=this.toggleCountTextMinItems)if("nItemsAndCount"===this.toggleCountTextMode){const t=e.slice(0,this.toggleCountTextMinItems-1);i=`${t.join(this.toggleSeparators.items)} ${this.toggleSeparators.betweenItemsAndCounter} ${e.length-t.length} ${this.toggleCountText}`}else i=`${e.length} ${this.toggleCountText}`;else i=e.join(this.toggleSeparators.items);return i}stringFromValue(){return this.apiUrl?this.stringFromValueRemoteData():this.stringFromValueBasic(this.selectOptions)}selectSingleItem(){Array.from(this.el.children).find((t=>this.value===t.value)).selected=!0;const t=Array.from(this.dropdown.children).find((t=>this.value===t.getAttribute("data-value")));t&&t.classList.add("selected")}selectMultipleItems(){Array.from(this.dropdown.children).filter((t=>this.value.includes(t.getAttribute("data-value")))).forEach((t=>t.classList.add("selected"))),Array.from(this.el.children).filter((t=>this.value.includes(t.value))).forEach((t=>t.selected=!0))}unselectMultipleItems(){Array.from(this.dropdown.children).forEach((t=>t.classList.remove("selected"))),Array.from(this.el.children).forEach((t=>t.selected=!1))}searchOptions(t){if(t.length<=this.minSearchLength){this.searchNoResult&&(this.searchNoResult.remove(),this.searchNoResult=null);return this.dropdown.querySelectorAll("[data-value]").forEach((t=>{t.classList.remove("hidden")})),!1}this.searchNoResult&&(this.searchNoResult.remove(),this.searchNoResult=null),this.searchNoResult=(0,n.fc)(this.searchNoResultTemplate),this.searchNoResult.innerText=this.searchNoResultText,(0,n.en)(this.searchNoResultClasses,this.searchNoResult);const e=this.dropdown.querySelectorAll("[data-value]");let i,s=!1;this.searchLimit&&(i=0),e.forEach((e=>{const n=e.getAttribute("data-title-value").toLocaleLowerCase();let o;if(this.isSearchDirectMatch)o=!n.includes(t.toLowerCase())||this.searchLimit&&i>=this.searchLimit;else{const e=t?t.split("").map((t=>/\w/.test(t)?`${t}[\\W_]*`:"\\W*")).join(""):"";o=!new RegExp(e,"i").test(n.trim())||this.searchLimit&&i>=this.searchLimit}o?e.classList.add("hidden"):(e.classList.remove("hidden"),s=!0,this.searchLimit&&i++)})),s||this.dropdown.append(this.searchNoResult)}eraseToggleIcon(){const t=this.toggle.querySelector("[data-icon]");t&&(t.innerHTML=null,t.classList.add("hidden"))}eraseToggleTitle(){const t=this.toggle.querySelector("[data-title]");t?t.innerHTML=this.placeholder:this.toggleTextWrapper.innerHTML=this.placeholder}toggleFn(){this.isOpened?this.close():this.open()}destroy(){this.wrapper&&this.wrapper.removeEventListener("click",this.onWrapperClickListener),this.toggle&&this.toggle.removeEventListener("click",this.onToggleClickListener),this.tagsInput&&(this.tagsInput.removeEventListener("focus",this.onTagsInputFocusListener),this.tagsInput.removeEventListener("input",this.onTagsInputInputListener),this.tagsInput.removeEventListener("input",this.onTagsInputInputSecondListener),this.tagsInput.removeEventListener("keydown",this.onTagsInputKeydownListener)),this.search&&this.search.removeEventListener("input",this.onSearchInputListener);const t=this.el.parentElement.parentElement;this.el.classList.add("hidden"),this.el.style.display="",t.prepend(this.el),t.querySelector(".advance-select").remove(),this.wrapper=null,window.$hsSelectCollection=window.$hsSelectCollection.filter((({element:t})=>t.el!==this.el))}open(){var t;const e=(null===(t=null===window||void 0===window?void 0:window.$hsSelectCollection)||void 0===t?void 0:t.find((t=>t.element.isOpened)))||null;if(e&&e.element.close(),this.animationInProcess)return!1;this.animationInProcess=!0,"window"===this.dropdownScope&&this.dropdown.classList.add("invisible"),this.dropdown.classList.remove("hidden"),this.recalculateDirection(),setTimeout((()=>{var t;(null===(t=null==this?void 0:this.toggle)||void 0===t?void 0:t.ariaExpanded)&&(this.toggle.ariaExpanded="true"),this.wrapper.classList.add("active"),this.dropdown.classList.add("opened"),this.dropdown.classList.contains("w-full")&&"window"===this.dropdownScope&&this.updateDropdownWidth(),this.floatingUIInstance&&"window"===this.dropdownScope&&(this.floatingUIInstance.update(),this.dropdown.classList.remove("invisible")),this.hasSearch&&!this.preventSearchFocus&&this.search.focus(),this.animationInProcess=!1})),this.isOpened=!0}close(t=!1){var e,i,s,o;if(this.animationInProcess)return!1;this.animationInProcess=!0,(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="false"),this.wrapper.classList.remove("active"),this.dropdown.classList.remove("opened","bottom-full","top-full"),(null===(i=this.dropdownDirectionClasses)||void 0===i?void 0:i.bottom)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.bottom),(null===(s=this.dropdownDirectionClasses)||void 0===s?void 0:s.top)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="",this.dropdown.style.marginBottom="",(0,n.yd)(this.dropdown,(()=>{this.dropdown.classList.add("hidden"),this.hasSearch&&(this.search.value="",this.search.dispatchEvent(new Event("input",{bubbles:!0})),this.search.blur()),t&&this.toggle.focus(),this.animationInProcess=!1})),null===(o=this.dropdown.querySelector(".select-option-highlighted"))||void 0===o||o.classList.remove("select-option-highlighted"),this.isOpened=!1}addOption(t){let e=`${this.selectOptions.length}`;const i=t=>{const{title:i,val:s,disabled:n,selected:o,options:l}=t;!!this.selectOptions.some((t=>t.val===s))||(this.addSelectOption(i,s,n,o,l),this.buildOption(i,s,n,o,l,e),this.buildOriginalOption(i,s,null,n,o,l),o&&!this.isMultiple&&this.onSelectOption(s))};Array.isArray(t)?t.forEach((t=>{i(t)})):i(t)}removeOption(t){const e=(t,e=!1)=>{!!this.selectOptions.some((e=>e.val===t))&&(this.removeSelectOption(t,e),this.destroyOption(t),this.destroyOriginalOption(t),this.value===t&&(this.value=null,this.eraseToggleTitle(),this.eraseToggleIcon()))};Array.isArray(t)?t.forEach((t=>{e(t,this.isMultiple)})):e(t,this.isMultiple),this.setNewValue()}recalculateDirection(){var t,e,i,s;if((null==this?void 0:this.dropdownVerticalFixedPlacement)&&(this.dropdown.classList.contains("bottom-full")||this.dropdown.classList.contains("top-full")))return!1;"top"===(null==this?void 0:this.dropdownVerticalFixedPlacement)?(this.dropdown.classList.add("bottom-full"),this.dropdown.style.marginBottom=`${this.dropdownSpace}px`):"bottom"===(null==this?void 0:this.dropdownVerticalFixedPlacement)?(this.dropdown.classList.add("top-full"),this.dropdown.style.marginTop=`${this.dropdownSpace}px`):(0,n.PR)(this.dropdown,this.toggle||this.tagsInput,"bottom",this.dropdownSpace,this.viewport)?(this.dropdown.classList.remove("bottom-full"),(null===(t=this.dropdownDirectionClasses)||void 0===t?void 0:t.bottom)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.bottom),this.dropdown.style.marginBottom="",this.dropdown.classList.add("top-full"),(null===(e=this.dropdownDirectionClasses)||void 0===e?void 0:e.top)&&this.dropdown.classList.add(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop=`${this.dropdownSpace}px`):(this.dropdown.classList.remove("top-full"),(null===(i=this.dropdownDirectionClasses)||void 0===i?void 0:i.top)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="",this.dropdown.classList.add("bottom-full"),(null===(s=this.dropdownDirectionClasses)||void 0===s?void 0:s.bottom)&&this.dropdown.classList.add(this.dropdownDirectionClasses.bottom),this.dropdown.style.marginBottom=`${this.dropdownSpace}px`)}static findInCollection(t){return window.$hsSelectCollection.find((e=>t instanceof d?e.element.el===t.el:"string"==typeof t?e.element.el===document.querySelector(t):e.element.el===t))||null}static getInstance(t,e){const i=window.$hsSelectCollection.find((e=>e.element.el===("string"==typeof t?document.querySelector(t):t)));return i?e?i:i.element:null}static autoInit(){window.$hsSelectCollection||(window.$hsSelectCollection=[],window.addEventListener("click",(t=>{const e=t.target;d.closeCurrentlyOpened(e)})),document.addEventListener("keydown",(t=>d.accessibility(t)))),window.$hsSelectCollection&&(window.$hsSelectCollection=window.$hsSelectCollection.filter((({element:t})=>document.contains(t.el)))),document.querySelectorAll("[data-select]:not(.--prevent-on-load-init)").forEach((t=>{if(!window.$hsSelectCollection.find((e=>{var i;return(null===(i=null==e?void 0:e.element)||void 0===i?void 0:i.el)===t}))){const e=t.getAttribute("data-select"),i=e?JSON.parse(e):{};new d(t,i)}}))}static open(t){const e=d.findInCollection(t);e&&!e.element.isOpened&&e.element.open()}static close(t){const e=d.findInCollection(t);e&&e.element.isOpened&&e.element.close()}static closeCurrentlyOpened(t=null){if(!t.closest(".advance-select.active")&&!t.closest("[data-select-dropdown].opened")){const t=window.$hsSelectCollection.filter((t=>t.element.isOpened))||null;t&&t.forEach((t=>{t.element.close()}))}}static accessibility(t){const e=window.$hsSelectCollection.find((t=>t.element.isOpened));if(e&&r.fp.includes(t.code)&&!t.metaKey)switch(t.code){case"Escape":t.preventDefault(),this.onEscape();break;case"ArrowUp":t.preventDefault(),t.stopImmediatePropagation(),this.onArrow();break;case"ArrowDown":t.preventDefault(),t.stopImmediatePropagation(),this.onArrow(!1);break;case"Tab":t.preventDefault(),t.stopImmediatePropagation(),this.onTab(t.shiftKey);break;case"Home":t.preventDefault(),t.stopImmediatePropagation(),this.onStartEnd();break;case"End":t.preventDefault(),t.stopImmediatePropagation(),this.onStartEnd(!1);break;case"Enter":t.preventDefault(),this.onEnter(t);break;case"Space":if((0,n.ar)(e.element.search))break;t.preventDefault(),this.onEnter(t)}}static onEscape(){const t=window.$hsSelectCollection.find((t=>t.element.isOpened));t&&t.element.close()}static onArrow(t=!0){const e=window.$hsSelectCollection.find((t=>t.element.isOpened));if(e){const i=e.element.dropdown;if(!i)return!1;const s=(t?Array.from(i.querySelectorAll(":scope > *:not(.hidden)")).reverse():Array.from(i.querySelectorAll(":scope > *:not(.hidden)"))).filter((t=>!t.classList.contains("disabled"))),n=i.querySelector(".select-option-highlighted")||i.querySelector(".selected");n||s[0].classList.add("select-option-highlighted");let o=s.findIndex((t=>t===n));o+1<s.length&&o++,s[o].focus(),n&&n.classList.remove("select-option-highlighted"),s[o].classList.add("select-option-highlighted")}}static onTab(t=!0){const e=window.$hsSelectCollection.find((t=>t.element.isOpened));if(e){const i=e.element.dropdown;if(!i)return!1;const s=(t?Array.from(i.querySelectorAll(":scope > *:not(.hidden)")).reverse():Array.from(i.querySelectorAll(":scope > *:not(.hidden)"))).filter((t=>!t.classList.contains("disabled"))),n=i.querySelector(".select-option-highlighted")||i.querySelector(".selected");n||s[0].classList.add("select-option-highlighted");let o=s.findIndex((t=>t===n));if(!(o+1<s.length))return n&&n.classList.remove("select-option-highlighted"),e.element.close(),e.element.toggle.focus(),!1;o++,s[o].focus(),n&&n.classList.remove("select-option-highlighted"),s[o].classList.add("select-option-highlighted")}}static onStartEnd(t=!0){const e=window.$hsSelectCollection.find((t=>t.element.isOpened));if(e){const i=e.element.dropdown;if(!i)return!1;const s=(t?Array.from(i.querySelectorAll(":scope > *:not(.hidden)")):Array.from(i.querySelectorAll(":scope > *:not(.hidden)")).reverse()).filter((t=>!t.classList.contains("disabled"))),n=i.querySelector(".select-option-highlighted");s.length&&(s[0].focus(),n&&n.classList.remove("select-option-highlighted"),s[0].classList.add("select-option-highlighted"))}}static onEnter(t){const e=t.target.previousSibling;if(window.$hsSelectCollection.find((t=>t.element.el===e))){const t=window.$hsSelectCollection.find((t=>t.element.isOpened)),i=window.$hsSelectCollection.find((t=>t.element.el===e));t.element.close(),t!==i&&i.ele