selective-ui 1.1.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +2 -0
  2. package/dist/selective-ui.css +7 -1
  3. package/dist/selective-ui.css.map +1 -1
  4. package/dist/selective-ui.esm.js +750 -39
  5. package/dist/selective-ui.esm.js.map +1 -1
  6. package/dist/selective-ui.esm.min.js +2 -2
  7. package/dist/selective-ui.esm.min.js.br +0 -0
  8. package/dist/selective-ui.min.css +1 -1
  9. package/dist/selective-ui.min.css.br +0 -0
  10. package/dist/selective-ui.min.js +2 -2
  11. package/dist/selective-ui.min.js.br +0 -0
  12. package/dist/selective-ui.umd.js +751 -40
  13. package/dist/selective-ui.umd.js.map +1 -1
  14. package/package.json +1 -1
  15. package/src/css/components/popup.css +7 -1
  16. package/src/ts/adapter/mixed-adapter.ts +12 -7
  17. package/src/ts/components/empty-state.ts +5 -4
  18. package/src/ts/components/loading-state.ts +4 -4
  19. package/src/ts/components/option-handle.ts +4 -4
  20. package/src/ts/components/popup.ts +42 -16
  21. package/src/ts/components/searchbox.ts +2 -0
  22. package/src/ts/components/selectbox.ts +9 -2
  23. package/src/ts/core/base/adapter.ts +8 -5
  24. package/src/ts/core/base/model.ts +19 -1
  25. package/src/ts/core/base/recyclerview.ts +3 -1
  26. package/src/ts/core/base/virtual-recyclerview.ts +762 -0
  27. package/src/ts/core/model-manager.ts +24 -16
  28. package/src/ts/core/search-controller.ts +4 -4
  29. package/src/ts/global.ts +5 -5
  30. package/src/ts/index.ts +4 -4
  31. package/src/ts/services/effector.ts +2 -2
  32. package/src/ts/types/components/state.box.type.ts +1 -18
  33. package/src/ts/types/core/base/adapter.type.ts +14 -0
  34. package/src/ts/types/core/base/model.type.ts +5 -0
  35. package/src/ts/types/core/base/recyclerview.type.ts +3 -1
  36. package/src/ts/types/core/base/view.type.ts +6 -0
  37. package/src/ts/types/core/base/virtual-recyclerview.type.ts +66 -0
  38. package/src/ts/types/utils/istorage.type.ts +1 -0
  39. package/src/ts/utils/istorage.ts +3 -2
  40. package/src/ts/utils/libs.ts +26 -25
  41. package/src/ts/utils/selective.ts +7 -7
  42. package/src/ts/views/option-view.ts +8 -8
@@ -1,2 +1,2 @@
1
- /*! Selective UI v1.1.5 | MIT License */
2
- var t,i;t=this,i=function(t){"use strict";function i(t){return new g(t??null)}class s{constructor(){this.t={showPanel:!0,accessoryStyle:"top",multiple:!1,minWidth:"50px",width:"0px",offsetWidth:null,minHeight:"30px",height:"30px",panelHeight:"220px",panelMinHeight:"100px",disabled:!1,readonly:!1,selectall:!0,keepSelected:!0,placeholder:"Select value",altMask:"",autoclose:!1,autoscroll:!0,autofocus:!0,searchable:!0,loadingfield:!0,visible:!0,skipError:!1,customDelimiter:",",textLoading:"Processing...",textNoData:"No data available",textNotFound:"Not found",textSelectAll:"Select all",textDeselectAll:"Deselect all",textAccessoryDeselect:"Deselect: ",animationtime:200,delaysearchtime:200,allowHtml:!0,maxSelected:0,labelHalign:"left",labelValign:"center",imageMode:!1,imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",imagePosition:"right",ajax:null,on:{load:[],beforeShow:[],show:[],beforeChange:[],change:[],beforeClose:[],close:[]}},this.i=new Map,this.h=new Map,this.o=[]}}class e{static get l(){return this.u||(this.u=new s),this.u}static p(t){if(null===t||"object"!=typeof t)return t;const i=Array.isArray(t)?[]:{};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=this.p(t[s]));return i}static m(t=6){let i="";for(let s=0;s<t;s++)i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return i}static v(t){if(!t)return[];if("string"==typeof t){const i=document.querySelectorAll(t);return Array.from(i)}return t instanceof Element?[t]:t instanceof NodeList||Array.isArray(t)?Array.from(t):[]}static T(t={}){return this.O(document.createElement(t.node??"div"),t,!0)}static O(t=document.documentElement,i=null,s=!1){const e={...i??{}},n=s?t:this.C(t.cloneNode(!0)),h=e.classList;return"string"==typeof h?n.classList.add(h):Array.isArray(h)&&n.classList.add(...h),delete e.classList,["style","dataset"].forEach(t=>{const i=e[t];i&&"object"==typeof i&&Object.assign(n[t],i),delete e[t]}),e.role&&(n.setAttribute("role",e.role+""),delete e.role),e.ariaLive&&(n.setAttribute("aria-live",e.ariaLive+""),delete e.ariaLive),e.A&&(n.setAttribute("aria-labelledby",e.A+""),delete e.A),e.S&&(n.setAttribute("aria-controls",e.S+""),delete e.S),e.L&&(n.setAttribute("aria-haspopup",e.L+""),delete e.L),e.P&&(n.setAttribute("aria-multiselectable",e.P+""),delete e.P),e.M&&(n.setAttribute("aria-autocomplete",e.M+""),delete e.M),e.event&&"object"==typeof e.event&&(Object.entries(e.event).forEach(([t,i])=>{n.addEventListener(t,i)}),delete e.event),Object.entries(e).forEach(([t,i])=>{null===i?n.removeAttribute(t):n[t]=i}),n}static C(t){if(t instanceof Element)return t;throw new TypeError("Node is not an Element")}static H(t){return this.$(t)}static $(t,i=null,s=!1,e=!1,n={}){let h=null;for(const o in t){const l=t[o],r=l?.tag?.tagName?l.tag:this.T(l.tag);n[o]=r,l?.j&&this.$(l.j,r,!1,!1,n),i?s?i.prepend(r):i.append(r):e||h||(h=r)}return e||(n.id=this.m(7),i||(n={tags:n,view:h})),n}static I(t,i){const s=this.p(i);for(const e in s){const i=t[e];i?s[e]=i:void 0!==t?.dataset?.[e]&&(s[e]=t.dataset[e])}return s}static F(...t){if(0===t.length)return{};if(1===t.length)return this.p(t[0]);const i=this.p(t[0]);for(let s=1;s<t.length;s++){const e=t[s];for(const t in e)if("on"===t){const s=e[t];for(const e in s)i[t][e].push(s[e])}else i[t]=e[t]}return i}static V(t){if("boolean"==typeof t)return t;if("string"!=typeof t)return!!t;switch(t.trim().toLowerCase()){case"true":case"1":case"yes":case"on":return!0;default:return!1}}static k(t){return this.l.i.delete(t)}static R(t){return this.l.i.get(t)}static _(t,i){this.l.i.set(t,i)}static D(t){return this.l.h.delete(t)}static N(t){return this.l.h.get(t)}static B(t,i){this.l.h.set(t,i)}static G(){return this.l.t}static U(){return this.l.o}static W(t){if(null==t)return"";let i=(t+"").replace(/<`/g,"<").replace(/`>/g,">").replace(/\<\`/g,"<").replace(/\`\>/g,">").trim();const s=globalThis?.document;if(!s||"function"!=typeof s.createElement)return i=i.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<iframe\b[^>]*>[\s\S]*?<\/iframe>/gi,"").replace(/<(object|embed|link)\b[^>]*>[\s\S]*?<\/\1>/gi,""),i=i.replace(/\son[a-z]+\s*=\s*(['"]).*?\1/gi,""),i=i.replace(/\s([a-z-:]+)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,""),i;const e=s.createElement("div");return e.innerHTML=i,e.querySelectorAll("script, style, iframe, object, embed, link").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(const i in t.attributes){const s=t.attributes[i],e=s.name??"",n=s.value??"";if(/^on/i.test(e))return void t.removeAttribute(e);/^(href|src|xlink:href)$/i.test(e)&&/^javascript:/i.test(n)&&t.removeAttribute(e)}}),(e.innerHTML??"").trim()}static q(t){const i=document.createElement("DIV");i.innerHTML=t;const s=i.textContent??i.innerText??"";return i.remove(),s.trim()}static J(t){return null==t?"":(t+"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d").replace(/Đ/g,"d")}static K(t){const i=[];return Array.from(t.children).forEach(t=>{if("OPTGROUP"===t.tagName){const s=t;i.push(s),Array.from(s.children).forEach(t=>{t.__parentGroup=s,i.push(t)})}else"OPTION"===t.tagName&&i.push(t)}),i}static Y(){const t=navigator.userAgent;return/iP(hone|ad|od)/.test(t)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1}static X(t){const i=(t+"").trim();if(i.endsWith("px"))return i;if(i.endsWith("vh"))return window.innerHeight*parseFloat(i)/100+"px";if(i.endsWith("vw"))return window.innerWidth*parseFloat(i)/100+"px";const s=parseFloat(getComputedStyle(document.documentElement).fontSize);if(i.endsWith("rem"))return s*parseFloat(i)+"px";const e=this.T({node:"div",style:{height:i,opacity:"0"}});document.body.appendChild(e);const n=e.offsetHeight+"px";return e.remove(),n}}e.u=null,e.Z=new class{constructor(){this.tt=new Map,this.it=new Map}on(t,i,s={}){const e=s.st??50,n=s.once??!1;this.tt.has(t)||this.tt.set(t,[]),this.tt.get(t).push({et:i,timeout:e,once:n})}off(t){const i=this.it.get(t);if(i){for(const t of i.values())clearTimeout(t);i.clear(),this.it.delete(t)}this.tt.delete(t)}run(t,...i){const s=this.tt.get(t);if(!s)return;this.it.has(t)||this.it.set(t,new Map);const e=this.it.get(t);for(let n=0;n<s.length;n++){const t=s[n];if(!t)continue;const h=e.get(n);h&&clearTimeout(h);const o=setTimeout(()=>{if(t.et(i.length>0?i:null),t.once){s[n]=void 0;const t=e.get(n);t&&clearTimeout(t),e.delete(n)}},t.timeout);e.set(n,o)}}clear(t){if(void 0===t)for(const i of Array.from(this.tt.keys()))this.off(i);else this.off(t)}};class n{static nt(){const t={isContinue:!0,isCancel:!1};return{token:{get isContinue(){return t.isContinue},get isCancel(){return t.isCancel}},et:{stopPropagation(){t.isContinue=!1},cancel(){t.isCancel=!0,t.isContinue=!1}}}}static ht(t,...i){const{token:s,et:e}=this.nt();for(let n=0;n<i.length;n++){const h=i[n];if("function"==typeof h&&(t&&Array.isArray(t)?h(e,...t):h(e),s.isCancel||!s.isContinue))break}return s}static ot(t,i,s={bubbles:!0,cancelable:!0}){const e=new Event(i,s);return t.dispatchEvent(e),e}static lt(t,...i){if(Array.isArray(t))for(const s of t)"function"==typeof s&&s(...i)}}class h{static rt(t,i){const s=e.R(t);if(!s?.options)return;const n=s.options,h=n.minWidth,o=n.minHeight,l=Number.parseInt(n.width,10),r=Number.parseInt(n.height,10);let a=t.offsetWidth+"px",c=t.offsetHeight+"px";const u=getComputedStyle(t);"0px"===a&&"auto"!==u.width&&(a=u.width),"0px"===c&&"auto"!==u.height&&(c=u.height),l>0&&(a=n.width),r>0&&(c=n.height),Object.assign(i.style,{width:a,height:c,minWidth:h,minHeight:o})}}class o{constructor(t){this.node=null,this.ct=null,t&&this.init(t)}init(t){this.node=e.T({node:"div",classList:"selective-ui-placeholder",innerHTML:t.placeholder}),this.ct=t}get(){return this.ct?.placeholder??""}set(t,i=!0){if(!this.node||!this.ct)return;i&&(this.ct.placeholder=t);const s=e.W(t);this.node.innerHTML=this.ct.allowHtml?s:e.q(s)}}class l{constructor(){this.node=this.ut()}ut(){return e.T({node:"div",classList:"selective-ui-directive",role:"button",ariaLabel:"Toggle dropdown"})}dt(t){this.node.classList.toggle("drop-down",!!t)}}class r{constructor(t=null){this.gt=null,this.node=null,this.options=null,this.ft=[],this.bt=[],t&&this.init(t)}init(t){this.gt=e.$({wt:{tag:{node:"div",classList:["selective-ui-option-handle","hide"]},j:{yt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{n.lt(this.ft)}}},vt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{n.lt(this.bt)}}}}}}),this.node=this.gt.view,this.options=t}available(){return!!this.options&&e.V(this.options.multiple)&&e.V(this.options.selectall)}refresh(){this.node&&(this.available()?this.show():this.hide())}show(){this.node&&this.node.classList.remove("hide")}hide(){this.node&&this.node.classList.add("hide")}xt(t=null){"function"==typeof t&&this.ft.push(t)}Tt(t=null){"function"==typeof t&&this.bt.push(t)}}class a{constructor(t=null){this.node=null,this.options=null,t&&this.init(t)}init(t){this.options=t,this.node=e.T({node:"div",classList:["selective-ui-empty-state","hide"],role:"status",ariaLive:"polite"})}show(t="nodata"){this.node&&this.options&&(this.node.textContent="notfound"===t?this.options.textNotFound:this.options.textNoData,this.node.classList.remove("hide"))}hide(){this.node&&this.node.classList.add("hide")}get isVisible(){return!!this.node&&!this.node.classList.contains("hide")}}class c{constructor(t=null){this.node=null,this.options=null,t&&this.init(t)}init(t){this.options=t,this.node=e.T({node:"div",classList:["selective-ui-loading-state","hide"],textContent:t.textLoading,role:"status",ariaLive:"polite"})}show(t){this.node&&this.options&&(this.node.textContent=this.options.textLoading,this.node.classList.toggle("small",!!t),this.node.classList.remove("hide"))}hide(){this.node&&this.node.classList.add("hide")}get isVisible(){return!!this.node&&!this.node.classList.contains("hide")}}class u{constructor(){this.Ot=!1,this.element=null,this.Ct=null,this.At=null,this.Ot=!0,this.St=this.Lt.bind(this)}Pt(t){}Lt(){const t=this.element;if(!t||"function"!=typeof t.getBoundingClientRect)return void this.Pt({width:0,height:0,top:0,left:0,padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}});const i=t.getBoundingClientRect(),s="undefined"!=typeof window&&"function"==typeof window.getComputedStyle?window.getComputedStyle(t):null;this.Pt({width:i?.width??0,height:i?.height??0,top:i?.top??0,left:i?.left??0,padding:{top:parseFloat(s?.paddingTop??"0"),right:parseFloat(s?.paddingRight??"0"),bottom:parseFloat(s?.paddingBottom??"0"),left:parseFloat(s?.paddingLeft??"0")},border:{top:parseFloat(s?.borderTopWidth??"0"),right:parseFloat(s?.borderRightWidth??"0"),bottom:parseFloat(s?.borderBottomWidth??"0"),left:parseFloat(s?.borderLeftWidth??"0")},margin:{top:parseFloat(s?.marginTop??"0"),right:parseFloat(s?.marginRight??"0"),bottom:parseFloat(s?.marginBottom??"0"),left:parseFloat(s?.marginLeft??"0")}})}ot(){this.Lt()}connect(t){if(!(t instanceof Element))throw Error("Invalid element");this.element=t,this.Ct=new ResizeObserver(this.St),this.Ct.observe(t),this.At=new MutationObserver(this.St),this.At.observe(t,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("scroll",this.St,!0),window.addEventListener("resize",this.St),window.visualViewport&&(window.visualViewport.addEventListener("resize",this.St),window.visualViewport.addEventListener("scroll",this.St))}disconnect(){this.Ct?.disconnect(),this.At?.disconnect(),this.Pt=()=>{},window.removeEventListener("scroll",this.St,!0),window.removeEventListener("resize",this.St),window.visualViewport&&(window.visualViewport.removeEventListener("resize",this.St),window.visualViewport.removeEventListener("scroll",this.St)),this.Ct=null,this.At=null,this.element=null}}class d{constructor(t=null,i=null,s=null){this.options=null,this.Mt=!1,this.Ht=null,this.node=null,this.$t=null,this.jt=null,this.Et=null,this.It=null,this.Ft=null,this.Vt=null,this.kt=null,this.Rt=null,this._t=null,this.Dt=null,this.Nt=s,t&&i&&this.init(t,i)}init(t,i){if(!this.Nt)throw Error("Popup requires a ModelManager instance.");this.It=new r(i),this.Ft=new a(i),this.Vt=new c(i);const s=e.$({Bt:{tag:{node:"div",classList:"selective-ui-popup",style:{maxHeight:i.panelHeight}},j:{wt:{tag:this.It.node},zt:{tag:{id:i.Gt,node:"div",classList:"selective-ui-options-container",role:"listbox"}},Ut:{tag:this.Vt.node},Wt:{tag:this.Ft.node}}}},null);this.node=s.view,this.Rt=s.tags.zt,this.Et=e.R(t),this.options=i,this.Nt.load(this.Rt,{isMultiple:i.multiple});const n=this.Nt.qt();this.Ht=n.Jt,this.kt=n.kt,this.It.xt(()=>{n.Jt.Kt(!0)}),this.It.Tt(()=>{n.Jt.Kt(!1)}),this.Qt()}async Yt(){this.options&&this.Vt&&this.It&&this.Ht&&this.Nt&&(this.Dt&&clearTimeout(this.Dt),this.Nt.Xt(!0),!1!==e.V(this.options.loadingfield)&&(this.Zt({isEmpty:!1,ti:!0}),this.Vt.show(this.Ht.ii().ti),this.It.hide(),this.si()))}async ei(){this.options&&this.Vt&&this.Ht&&this.Nt&&(this.Dt&&clearTimeout(this.Dt),this.Dt=setTimeout(()=>{this.Nt?.Xt(!1),this.Vt?.hide();const t=this.Ht?.ii();this.Zt(t??void 0),this.si()},200))}Qt(){this.Ht&&(this.Ht.ni(t=>{this.Zt(t)}),this.Ht.hi("items",()=>{const t=this.Ht.ii();this.Zt(t),this.si()}))}Zt(t){if(!(this.Ht&&this.Ft&&this.It&&this.Rt))return;const i=t??this.Ht.ii();i.isEmpty?(this.Ft.show("nodata"),this.Rt.classList.add("hide"),this.It.hide()):i.ti?(this.Ft.hide(),this.Rt.classList.remove("hide"),this.It.refresh()):(this.Ft.show("notfound"),this.Rt.classList.add("hide"),this.It.hide())}oi(t,i){this.Ht?.li(t,i)}ri(t,i){this.Ht?.hi(t,i)}ai(t){this.$t=t}open(t=null,i){if(!(this.node&&this.options&&this.It&&this.Et&&this.$t))return;this.Mt||(document.body.appendChild(this.node),this.Mt=!0,this.jt=new u,this.$t.ci(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.It.refresh(),i&&this.Zt();const s=this.ui(),{position:e,top:n,maxHeight:h,di:o}=this.pi(s);this.$t.expand({duration:this.options.animationtime,display:"flex",width:s.width,left:s.left,top:n,maxHeight:h,di:o,position:e,gi:()=>{this.jt&&this.Et&&(this.jt.Pt=()=>{const t=this.ui();this.fi(t)},this.jt.connect(this.Et.container.tags.mi),t?.())}})}close(t=null){this.Mt&&this.options&&this.jt&&this.$t&&(this.jt.disconnect(),this.$t.collapse({duration:this.options.animationtime,gi:t??void 0}))}si(){this.Mt&&this.jt?.ot()}bi(t,i){this.node&&(this._t=async()=>{const i=t.wi();if(!i.yi)return;const s=this.node;if(s.scrollHeight-s.scrollTop-s.clientHeight<100&&!i.xi&&i.hasMore){const i=await t.Ti();!i.Oi&&i.message&&console.log("Load more:",i.message)}},this.node.addEventListener("scroll",this._t))}Ci(){this.Dt&&(clearTimeout(this.Dt),this.Dt=null),this.node&&this._t&&(this.node.removeEventListener("scroll",this._t),this._t=null);try{this.jt?.disconnect()}catch(t){}this.jt=null;try{this.$t?.ci?.(null)}catch(t){}if(this.$t=null,this.node)try{const t=this.node.cloneNode(!0);this.node.replaceWith(t),t.remove()}catch(t){this.node.remove()}this.node=null,this.Rt=null;try{this.Nt?.Xt?.(!1),this.kt?.clear?.(),this.kt=null,this.Ht=null,this.node.remove()}catch(t){}this.Nt=null,this.It=null,this.Ft=null,this.Vt=null,this.Et=null,this.options=null,this.Mt=!1}ui(){const t=this.Et.container.tags.mi,i=t.getBoundingClientRect(),s=window.getComputedStyle(t),n=window.visualViewport,h=e.Y();return{width:i.width,height:i.height,top:i.top-(n&&h?n.offsetTop:0),left:i.left-(n&&h?n.offsetLeft:0),padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},border:{top:parseFloat(s.borderTopWidth),right:parseFloat(s.borderRightWidth),bottom:parseFloat(s.borderBottomWidth),left:parseFloat(s.borderLeftWidth)}}}pi(t){const i=window.visualViewport,s=e.Y(),n=i?.height??window.innerHeight,h=i&&s?i.offsetTop:0,o=this.$t.Ai("flex").scrollHeight,l=parseFloat(this.options?.panelHeight??"220")||220,r=parseFloat(this.options?.panelMinHeight??"100")||100,a=n-(t.top+t.height)-3,c=t.top-3;let u="bottom",d=l,p=Math.min(o,d);const g=a-15;return(p>=r?g>=r:g>=p)?(u="bottom",d=Math.min(a-15,l)):c>=Math.max(p,r)?(u="top",d=Math.min(c-15,l)):a>=c?(u="bottom",d=Math.max(a-15,r)):(u="top",d=Math.max(c-15,r)),p=Math.min(o,d),{position:u,top:"bottom"===u?t.top+t.height+3+h:t.top-p-3+h,maxHeight:d,di:p,Si:o}}fi(t){if(!this.options||!this.$t)return;const{position:i,top:s,maxHeight:e,di:n}=this.pi(t);this.$t.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:s,maxHeight:e,di:n,position:i,animate:!0})}}class p{constructor(t=null){this.gt=null,this.node=null,this.Li=null,this.Pi=null,this.options=null,this.Mi=null,this.Hi=null,this.$i=null,this.options=t,t&&this.init(t)}init(t){this.gt=e.$({ji:{tag:{node:"div",classList:["selective-ui-searchbox","hide"]},j:{Li:{tag:{id:e.m(),node:"input",type:"search",classList:["selective-ui-searchbox-input"],placeholder:t.placeholder,role:"searchbox",S:t.Gt,M:"list"}}}}}),this.node=this.gt.view,this.Li=this.gt.tags.Li;let i=!1;const s=this.gt.tags.Li;s.addEventListener("mousedown",t=>{t.stopPropagation()}),s.addEventListener("mouseup",t=>{t.stopPropagation()}),s.addEventListener("keydown",t=>{i=!1,"ArrowDown"===t.key||"Tab"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.Mi?.(1)):"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.Mi?.(-1)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.Hi?.()):"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),i=!0,this.$i?.())}),s.addEventListener("input",()=>{i||this.Pi?.(s.value,!0)})}show(){this.node&&this.Li&&this.options&&(this.node.classList.remove("hide"),this.Li.readOnly=!this.options.searchable,this.options.searchable&&requestAnimationFrame(()=>{this.Li?.focus()}))}hide(){this.node&&this.node.classList.add("hide")}clear(t=!0){this.gt&&(this.gt.tags.Li.value="",this.Pi?.("",t))}Ei(t){this.Li&&(this.Li.placeholder=e.q(t))}Ii(t){this.Li&&this.Li.setAttribute("aria-activedescendant",t)}}class g{constructor(t=null){this.Fi=null,this.Vi=null,this.ki=!1,t&&this.ci(t)}ci(t){if("string"==typeof t){const i=document.querySelector(t);return void(i instanceof HTMLElement&&(this.element=i))}this.element=t}cancel(){return this.Fi&&(clearTimeout(this.Fi),this.Fi=null),this.Vi&&(clearTimeout(this.Vi),this.Vi=null),this.ki=!1,this}Ai(t="flex"){if(!this.element)return{width:0,height:0,scrollHeight:0};const i={display:this.element.style.display,visibility:this.element.style.visibility,position:this.element.style.position,height:this.element.style.height,width:this.element.style.width};Object.assign(this.element.style,{display:t,visibility:"hidden",position:"fixed",height:"fit-content",width:"fit-content"});const s=window.getComputedStyle(this.element),e=parseFloat(s.borderTopWidth),n=parseFloat(s.borderBottomWidth),h=this.element.scrollHeight+e+n,o=this.element.getBoundingClientRect(),l={width:o.width,height:o.height+e+n,scrollHeight:h};return Object.assign(this.element.style,i),l}expand(t){if(!this.element)return this;this.cancel(),this.ki=!0;const{duration:i=200,display:s="flex",width:e,left:n,top:h,maxHeight:o,di:l,position:r="bottom",gi:a}=t;return Object.assign(this.element.style,{display:s,width:e+"px",left:n+"px",top:("bottom"===r?h:h+l)+"px",maxHeight:o+"px",height:"0px",opacity:"0",overflow:"hidden",transition:"none"}),this.element.classList.toggle("position-top","top"===r),this.element.classList.toggle("position-bottom","bottom"===r),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`top ${i}ms, height ${i}ms, opacity ${i}ms`,top:h+"px",height:l+"px",opacity:"1",overflow:l>=o?"auto":"hidden"}),this.Fi=setTimeout(()=>{this.element.style.transition="none",this.ki=!1,a?.()},i)}),this}collapse(t){if(!this.element)return this;this.cancel(),this.ki=!0;const{duration:i=200,gi:s}=t,e=this.element.offsetHeight,n=this.element.offsetTop,h=this.element.classList.contains("position-top")?"top":"bottom",o=this.element.scrollHeight-this.element.offsetHeight>0,l="top"===h?n+e:n;return requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`height ${i}ms, top ${i}ms, opacity ${i}ms`,height:"0px",top:l+"px",opacity:"0",overflow:o?"auto":"hidden"}),this.Fi=setTimeout(()=>{Object.assign(this.element.style,{display:"none",transition:"none"}),this.ki=!1,s?.()},i)}),this}showSwipeWidth(t){if(!this.element)return this;this.cancel(),this.ki=!0;const{duration:i=200,display:s="block",gi:e}=t;Object.assign(this.element.style,{transition:"none",display:s,width:"fit-content"});const n=this.Ai(s).width;return Object.assign(this.element.style,{width:"0px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${i}ms`,width:n+"px",overflow:"hidden"})}),this.Fi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:""}),this.ki=!1,e?.()},i),this}hideSwipeWidth(t){if(!this.element)return this;this.cancel(),this.ki=!0;const{duration:i=200,gi:s}=t,e=this.Ai().width;return Object.assign(this.element.style,{transition:"none",width:e+"px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${i}ms`,width:"0px",overflow:"hidden"})}),this.Fi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:"",display:""}),this.ki=!1,s?.()},i),this}resize(t){if(!this.element)return this;this.Vi&&clearTimeout(this.Vi);const{duration:i=200,width:s,left:e,top:n,maxHeight:h,di:o,position:l="bottom",animate:r=!0,gi:a}=t,c=(this.element.classList.contains("position-top")?"top":"bottom")!==l,u=this.element.scrollHeight>h;return this.element.classList.toggle("position-top","top"===l),this.element.classList.toggle("position-bottom","bottom"===l),c&&(this.element.style.transition=`top ${i}ms ease-out, height ${i}ms ease-out, max-height ${i}ms ease-out;`),requestAnimationFrame(()=>{const t={width:s+"px",left:e+"px",top:n+"px",maxHeight:h+"px",height:o+"px",overflowY:u?"auto":"hidden"},l=Math.abs(this.element.offsetHeight-o);r&&(c||l>5)?t.transition=`height ${i}ms, top ${i}ms`:this.Vi=setTimeout(()=>{this.element?.style&&(this.element.style.transition="none")},i),Object.assign(this.element.style,t),r&&(c||l>1)?this.Vi=setTimeout(()=>{this.element.style.transition="none",c&&delete this.element.style.transition,a?.()},i):(c&&delete this.element.style.transition,a?.())}),this}get Ri(){return this.ki}}class f{get value(){return this.targetElement?.getAttribute("value")??null}constructor(t,i=null,s=null){this.targetElement=null,this.view=null,this.position=-1,this.Ot=!1,this.options=t,this.targetElement=i,this.view=s}update(t){this.targetElement=t,this._i()}_i(){}}class m extends f{constructor(t,i){super(t,i??null,null),this.label="",this.items=[],this.collapsed=!1,this.Di=[],i&&(this.label=i.label,this.collapsed=e.V(i.dataset?.collapsed))}get value(){return this.items.map(t=>t.value)}get Ni(){return this.items.filter(t=>t.selected)}get Bi(){return this.items.filter(t=>t.visible)}get zi(){return this.Bi.length>0}update(t){this.label=t.label,this.view?.Gi(this.label)}_i(){this.view&&(this.view.Gi(this.label),this.view.Ui(this.collapsed))}Wi(t){this.Di.push(t)}qi(){this.collapsed=!this.collapsed,this.view?.Ui(this.collapsed),n.ht([this,this.collapsed],...this.Di)}Ji(t){this.items.push(t),t.group=this}removeItem(t){const i=this.items.indexOf(t);i>-1&&(this.items.splice(i,1),t.group=null)}Ki(){this.view?.Ki()}}class b extends f{constructor(){super(...arguments),this.Qi=[],this.Yi=[],this.Xi=[],this.Zi=!0,this.ts=!1,this.group=null}get ss(){return this.dataset?.imgsrc||this.dataset?.image||""}get hasImage(){return!!this.ss}get value(){return this.targetElement?.value??""}get selected(){return!!this.targetElement?.selected}set selected(t){this.es=t,n.ht([this,t],...this.Qi)}get visible(){return this.Zi}set visible(t){if(this.Zi===t)return;this.Zi=t;const i=this.view?.ns?.();i&&i.classList.toggle("hide",!t),n.ht([this,t],...this.Xi)}get es(){return this.selected}set es(t){const i=this.view?.view?.tags?.hs,s=this.view?.ns?.();i&&(i.checked=t),s&&this.targetElement&&(s.classList.toggle("checked",!!t),s.setAttribute("aria-selected",t?"true":"false"),this.targetElement.toggleAttribute("selected",!!t)),this.targetElement&&(this.targetElement.selected=t),n.ht([this,t],...this.Yi)}get text(){const t=e.W(this.dataset?.mask??this.targetElement?.text??"");return this.options.allowHtml?t:e.q(t)}get textContent(){return this.options.allowHtml?e.q(this.text).trim():this.text.trim()}get dataset(){return this.targetElement?.dataset??{}}get ls(){return this.ts}set ls(t){const i=!!t,s=this.view?.ns?.();this.ts!==i&&(this.ts=i),s&&s.classList.toggle("highlight",i)}rs(t){this.Qi.push(t)}cs(t){this.Yi.push(t)}ni(t){this.Xi.push(t)}_i(){if(!this.view)return;const t=this.view.view.tags.us;t&&(this.options.allowHtml?t.innerHTML=this.text:t.textContent=this.textContent);const i=this.view.view.tags.ds;i&&this.hasImage&&(i.src=this.ss,i.alt=this.text),this.targetElement&&(this.es=this.targetElement.selected)}}class w{constructor(t){this.ps=[],this.gs=null,this.fs=null,this.bs=null,this.options=null,this.options=t}ws(t){this.ys=t}vs(t){this.xs=t}Ts(t){const i=this.Os(t),s=i!==this.bs;return s&&(this.bs=i),s}Os(t){return t.map(t=>{if("OPTGROUP"===t.tagName){const i=t,s=Array.from(i.children).map(t=>`${t.value}:${t.text}:${t.selected}`).join("\n");return`G:${i.label}:${s}`}return`O:${t.value}:${t.text}:${t.selected}`}).join("\n\n")}Cs(t){this.ps=[];let i=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)i=new m(this.options,t),this.ps.push(i);else if("OPTION"===t.tagName){const s=t,e=new b(this.options,s),n=s.__parentGroup;n&&i&&n===i.targetElement?(i.Ji(e),e.group=i):(this.ps.push(e),i=null)}}),this.ps}replace(t){this.bs=null,this.Cs(t),this.gs&&this.gs.As(this.ps),this.refresh()}notify(){this.gs&&this.refresh()}load(t,i={},s={}){this.gs=new this.ys(this.ps),Object.assign(this.gs,i),this.fs=new this.xs(t),this.fs.Ss(this.gs),Object.assign(this.fs,s)}update(t){if(!this.Ts(t))return;const i=this.ps,s=[],e=new Map,n=new Map;i.forEach(t=>{t instanceof m?e.set(t.label,t):t instanceof b&&n.set(`${t.value}::${t.textContent}`,t)});let h=null,o=0;t.forEach(t=>{if("OPTGROUP"===t.tagName){const i=t,n=e.get(i.label);n?(n.label!==i.label&&n.update(i),n.position=o,n.items=[],h=n,s.push(n),e.delete(i.label)):(h=new m(this.options,i),h.position=o,s.push(h)),o++}else if("OPTION"===t.tagName){const i=t,e=`${i.value}::${i.text}`,l=n.get(e);if(l)l.update(i),l.position=o,i.__parentGroup&&h?(h.Ji(l),l.group=h):(l.group=null,s.push(l)),n.delete(e);else{const t=new b(this.options,i);t.position=o,i.__parentGroup&&h?(h.Ji(t),t.group=h):s.push(t)}o++}}),e.forEach(t=>{t.view?.ns?.()?.remove?.()}),n.forEach(t=>{t.view?.ns?.()?.remove?.()}),this.ps=s,this.gs&&this.gs.Ls(this.ps),this.onUpdated(),this.refresh()}onUpdated(){}Xt(t){this.gs&&(this.gs.Ps=t)}refresh(){this.fs&&(this.fs.refresh(),this.onUpdated())}qt(){return{Ms:this.ps,Jt:this.gs,kt:this.fs}}Hs(t){this.gs?.$s(t)}js(t){this.gs?.Es(t)}}class y{constructor(t=null){this.Is=null,this.Jt=null,this.Is=t}Fs(t){this.Is=t}Ss(t){this.Jt=t,t.li("items",()=>{this.clear()}),t.hi("items",()=>{this.Vs()}),this.Vs()}clear(){this.Is&&this.Is.replaceChildren()}Vs(){this.Jt&&this.Is&&this.Jt.ks(this.Is)}refresh(){this.Vs()}}class v{constructor(t=null){this.gt=null,this.node=null,this.options=null,this.Rs=null,this._s=null,this.Ds=null,t&&this.init(t)}init(t){this.gt=e.$({Ns:{tag:{node:"div",classList:["selective-ui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.gt.view,this.options=t}Bs(t){this.Rs=t,this._s=t.parentElement,this.zs()}zs(){this._s&&this.node&&this.Rs&&this.options&&this._s.insertBefore(this.node,"top"===this.options.accessoryStyle?this.Rs:this.Rs.nextSibling)}Gs(t){this.Ds=t}Us(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?(this.node.classList.remove("hide"),t.forEach(t=>{e.$({Ws:{tag:{node:"div",classList:["accessory-item"]},j:{qs:{tag:{node:"span",classList:["accessory-item-button"],role:"button",ariaLabel:`${this.options.textAccessoryDeselect}${t.textContent}`,title:`${this.options.textAccessoryDeselect}${t.textContent}`,onclick:i=>{i.preventDefault(),this.Ds?.Hs?.("select"),setTimeout(()=>{t.selected=!1},10)}}},Js:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)})):this.node.classList.add("hide"),n.ot(window,"resize"))}}class x{constructor(t,i,s){this.Ks=null,this.Qs=null,this.Ys=null,this.Xs=null,this.Zs={currentPage:0,totalPages:1,hasMore:!1,xi:!1,te:"",yi:!1},this.ie=t,this.Nt=i,this.Xs=s}se(){return!!this.Ks}async ee(t){if(!this.Ks)return{Oi:!1,items:[],message:"Ajax not configured"};const i=Array.isArray(t)?t:[t];if(0===i.length)return{Oi:!0,items:[]};try{const t=this.Ks;let s,e;if(s="function"==typeof t.ne?t.ne(i):{values:i.join(","),he:"1",..."function"==typeof t.data?t.data.bind(this.Xs.oe.find(this.Xs.container.targetElement))("",0):t.data??{}},"POST"===(t.method??"GET")){const i=new URLSearchParams;Object.keys(s).forEach(t=>i.append(t,s[t]+"")),e=await fetch(t.url,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}else{const i=""+new URLSearchParams(s);e=await fetch(`${t.url}?${i}`)}if(!e.ok)throw Error("HTTP error! status: "+e.status);const n=await e.json();return{Oi:!0,items:this.le(n).items}}catch(s){return console.error("Load by values error:",s),{Oi:!1,message:s?.message,items:[]}}}re(t){const i=Array.from(this.ie.options).map(t=>t.value);return{ae:t.filter(t=>i.includes(t)),ce:t.filter(t=>!i.includes(t))}}ue(t){this.Ks=t}setPopup(t){this.Ys=t}wi(){return{...this.Zs}}de(){this.Zs={currentPage:0,totalPages:1,hasMore:!1,xi:!1,te:"",yi:this.Zs.yi}}clear(){this.Zs.te="";const{Ms:t}=this.Nt.qt(),i=[];for(const s of t)s instanceof b?i.push(s):s instanceof m&&Array.isArray(s.items)&&i.push(...s.items);i.forEach(t=>{t.visible=!0})}async search(t,i=!1){return this.Ks?this.pe(t,i):this.ge(t)}async Ti(){return this.Ks?this.Zs.xi?{Oi:!1,message:"Already loading"}:this.Zs.yi?this.Zs.hasMore?(this.Zs.currentPage++,this.pe(this.Zs.te,!0)):{Oi:!1,message:"No more data"}:{Oi:!1,message:"Pagination not enabled"}:{Oi:!1,message:"Ajax not enabled"}}async ge(t){this.fe(t)&&(this.Zs.te=t);const i=((t??"")+"").toLowerCase(),s=e.J(i),{Ms:n}=this.Nt.qt(),h=[];for(const e of n)e instanceof b?h.push(e):e instanceof m&&Array.isArray(e.items)&&h.push(...e.items);let o=!1;return h.forEach(t=>{const n=((t.textContent??t.text??"")+"").toLowerCase(),h=e.J(n),l=""===i||n.includes(i)||h.includes(s);t.visible=l,l&&(o=!0)}),{Oi:!0,me:o,isEmpty:0===h.length}}fe(t){return t!==this.Zs.te}async pe(t,i=!1){const s=this.Ks;this.fe(t)&&(this.de(),this.Zs.te=t,i=!1),this.Zs.xi=!0,this.Ys?.Yt(),this.Qs?.abort(),this.Qs=new AbortController;const e=this.Zs.currentPage,n=Array.from(this.ie.selectedOptions).map(t=>t.value).join(",");let h;"function"==typeof s.data?(h=s.data.bind(this.Xs.oe.find(this.Xs.container.targetElement))(t,e),h&&void 0===h.selectedValue&&(h.selectedValue=n)):h={search:t,page:e,selectedValue:n,...s.data??{}};try{let t;if("POST"===(s.method??"GET")){const i=new URLSearchParams;Object.keys(h).forEach(t=>i.append(t,h[t]+"")),t=await fetch(s.url,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:this.Qs.signal})}else{const i=""+new URLSearchParams(h);t=await fetch(`${s.url}?${i}`,{signal:this.Qs.signal})}const e=await t.json(),n=this.le(e);return n.be?(this.Zs.yi=!0,this.Zs.currentPage=n.page,this.Zs.totalPages=n.totalPages,this.Zs.hasMore=n.hasMore):this.Zs.yi=!1,this.we(n.items,!!s.keepSelected,i),this.Zs.xi=!1,this.Ys?.ei(),{Oi:!0,me:n.items.length>0,isEmpty:0===n.items.length,be:n.be,hasMore:n.hasMore,currentPage:n.page,totalPages:n.totalPages}}catch(o){return this.Zs.xi=!1,this.Ys?.ei(),"AbortError"===o?.name?{Oi:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Oi:!1,message:o?.message})}}le(t){let i=[],s=!1,e=0,n=1,h=!1;return t.object&&Array.isArray(t.object)?(i=t.object,void 0!==t.page&&(s=!0,e=parseInt(t.page??0,10),n=parseInt(t.totalPages??t.total_page??1,10),h=e<n-1)):t.data&&Array.isArray(t.data)?(i=t.data,void 0!==t.page&&(s=!0,e=parseInt(t.page??0,10),n=parseInt(t.totalPages??t.total_page??1,10),h=t.hasMore??e<n-1)):Array.isArray(t)?i=t:t.items&&Array.isArray(t.items)&&(i=t.items,t.pagination&&(s=!0,e=parseInt(t.pagination.page??0,10),n=parseInt(t.pagination.totalPages??t.pagination.total_page??1,10),h=t.pagination.hasMore??e<n-1)),{items:i.map(t=>{if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)return t;if("optgroup"===t.type||t.ye||t.group||t.label)return{type:"optgroup",label:t.label??t.name??t.title??"",data:t.data??{},options:(t.options??t.items??[]).map(t=>({value:t.value??t.id??t.key??"",text:t.text??t.label??t.name??t.title??"",selected:t.selected??!1,data:t.data??(t.imgsrc?{imgsrc:t.imgsrc}:{})}))};const i=t.data??{};return t?.imgsrc&&(i.imgsrc=t.imgsrc),{type:"option",value:t.value??t.id??t.key??"",text:t.text??t.label??t.name??t.title??"",selected:t.selected??!1,data:i}}),be:s,page:e,totalPages:n,hasMore:h}}we(t,i,s=!1){const e=this.ie;let n=[];i&&(n=Array.from(e.selectedOptions).map(t=>t.value)),s||(e.innerHTML=""),t.forEach(t=>{if("option"!==t.type&&t.type||""!==t.value||""!==t.text)if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)e.appendChild(t);else if("optgroup"===t.type){const s=document.createElement("optgroup");s.label=t.label,t.data&&Object.keys(t.data).forEach(i=>{s.dataset[i]=t.data[i]+""}),Array.isArray(t.options)&&t.options.forEach(t=>{const e=document.createElement("option");e.value=t.value,e.text=t.text,t.data&&Object.keys(t.data).forEach(i=>{e.dataset[i]=t.data[i]+""}),(t.selected||i&&n.includes(e.value))&&(e.selected=!0),s.appendChild(e)}),e.appendChild(s)}else{const s=document.createElement("option");s.value=t.value,s.text=t.text,t.data&&Object.keys(t.data).forEach(i=>{s.dataset[i]=t.data[i]+""}),(t.selected||i&&n.includes(s.value))&&(s.selected=!0),e.appendChild(s)}}),e.dispatchEvent(new CustomEvent("options:changed"))}}class T{constructor(t){this.ve=null,this.xe=null,this.Te=50,this.ie=t,this.xe=this.Oe(),this.Ce=new MutationObserver(()=>{this.ve&&clearTimeout(this.ve),this.ve=setTimeout(()=>{this.Ae()},this.Te)}),t.addEventListener("options:changed",()=>{this.ve&&clearTimeout(this.ve),this.ve=setTimeout(()=>{this.Ae()},this.Te)})}Oe(){const t=Array.from(this.ie.options);return{length:t.length,values:t.map(t=>t.value).join(","),Se:t.map(t=>t.text).join(","),selected:t.map(t=>t.selected+"").join(",")}}Le(){const t=this.Oe(),i=JSON.stringify(t)!==JSON.stringify(this.xe);return i&&(this.xe=t),i}Ae(){this.Le()&&this.Pt(this.ie)}connect(){this.Ce.observe(this.ie,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Pt(t){}disconnect(){this.ve&&clearTimeout(this.ve),this.ve=null,this.Ce.disconnect()}}class O{constructor(t){this.ve=null,this.Pe=t,this.Ce=new MutationObserver(t=>{let i=!1;for(const s of t)if("attributes"===s.type&&s.attributeName?.startsWith("data-")){i=!0;break}i&&(this.ve&&clearTimeout(this.ve),this.ve=setTimeout(()=>{this.Pt({...this.Pe.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Pt({...this.Pe.dataset})})}connect(){this.Ce.observe(this.Pe,{attributes:!0,attributeOldValue:!0})}Pt(t){}disconnect(){this.ve&&clearTimeout(this.ve),this.ve=null,this.Ce.disconnect()}}class C{constructor(t=[]){this.items=[],this.Me=e.m(12),this.Ps=!1,this.items=t,this.He()}He(){}$e(t,i,s){const e=i;t.Ot?e?.update?.():e?.Vs?.()}li(t,i){e.Z.on(`${t}ing_${this.Me}`,i,{st:1})}hi(t,i){e.Z.on(`${t}_${this.Me}`,i)}Es(t,...i){e.Z.run(`${t}_${this.Me}`,...i)}$s(t,...i){e.Z.run(`${t}ing_${this.Me}`,...i)}je(t,i){return null}Ee(){return this.items.length}Ie(t){this.$s("items",t),this.items=t,this.Es("items",t)}As(t){this.Ie(t)}ks(t){for(let i=0;i<this.Ee();i++){const s=this.items[i];let e=s.view;s.Ot||(e=this.je(t,s),s.view=e),this.$e(s,e,i),s.Ot=!0}}Ls(t){}}class A{constructor(t){this.parent=null,this.view=null,this.parent=t}Vs(){}update(){}ns(){if(!this.view?.view)throw Error("View is not mounted. Did you forget to set this.view?");return this.view.view}}class S extends A{constructor(){super(...arguments),this.view=null}Vs(){const t=e.m(7);this.view=e.H({Fe:{tag:{node:"div",classList:["selective-ui-group"],role:"group",A:`seui-${t}-header`,id:`seui-${t}-group`},j:{Ve:{tag:{node:"div",classList:["selective-ui-group-header"],role:"presentation",id:`seui-${t}-header`}},ke:{tag:{node:"div",classList:["selective-ui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view)}update(){this.Gi()}Gi(t=null){this.view&&null!==t&&(this.view.tags.Ve.textContent=t)}Re(){if(!this.view)throw Error("GroupView is not rendered.");return this.view.tags.ke}Ki(){if(!this.view)return;const t=Array.from(this.view.tags.ke.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",!(t.length>0))}Ui(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags.Ve.setAttribute("aria-expanded",t?"false":"true"))}}class L extends A{constructor(t){super(t),this.view=null,this._e=null,this.De=null,this.Ne=!1,this.Be()}Be(){const t=this;this._e={isMultiple:!1,hasImage:!1,imagePosition:"right",imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",labelValign:"center",labelHalign:"left"},this.De=new Proxy(this._e,{set(i,s,e){if("string"!=typeof s)return!0;const n=s,h=i[n];return h!==e&&(i[n]=e,t.Ne&&t.ze(n,e,h)),!0}})}get isMultiple(){return this._e.isMultiple}set isMultiple(t){this.De.isMultiple=!!t}get hasImage(){return this._e.hasImage}set hasImage(t){this.De.hasImage=!!t}get Ge(){return this.De}set Ge(t){if(!t||!this.De||!this._e)return;const i={};void 0!==t.imageWidth&&t.imageWidth!==this._e.imageWidth&&(i.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this._e.imageHeight&&(i.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this._e.imageBorderRadius&&(i.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this._e.imagePosition&&(i.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this._e.labelValign&&(i.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this._e.labelHalign&&(i.labelHalign=t.labelHalign),Object.keys(i).length>0&&Object.assign(this.De,i)}Vs(){const t=["selective-ui-option-view"],i=e.m(7),s="option_"+i;this._e.isMultiple&&t.push("multiple"),this._e.hasImage&&(t.push("has-image"),t.push("image-"+this._e.imagePosition));const n={hs:{tag:{node:"input",type:this._e.isMultiple?"checkbox":"radio",classList:"allow-choice",id:s}},...this._e.hasImage&&{ds:{tag:{node:"img",classList:"option-image",style:{width:this._e.imageWidth,height:this._e.imageHeight,borderRadius:this._e.imageBorderRadius}}}},Ue:{tag:{node:"label",htmlFor:s,classList:["align-vertical-"+this._e.labelValign,"align-horizontal-"+this._e.labelHalign]},j:{us:{tag:{node:"div"}}}}};this.view=e.H({We:{tag:{node:"div",id:`seui-${i}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},j:n}}),this.parent.appendChild(this.view.view),this.Ne=!0}ze(t,i,s){const e=this.view;if(!e||!e.view)return;const n=e.view,h=e.tags?.hs,o=e.tags?.Ue;switch(t){case"isMultiple":{const t=!!i;n.classList.toggle("multiple",t),h&&h.type!==(t?"checkbox":"radio")&&(h.type=t?"checkbox":"radio");break}case"hasImage":{const t=!!i;if(n.classList.toggle("has-image",t),t)n.classList.add("image-"+this._e.imagePosition),this.qe();else{n.className=n.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.ds;t&&(t.remove(),e.tags.ds=null)}break}case"imagePosition":this._e.hasImage&&(n.className=n.className.replace(/image-(top|right|bottom|left)/g,"").trim(),n.classList.add("image-"+i));break;case"imageWidth":case"imageHeight":case"imageBorderRadius":{const s=e.tags?.ds;if(s){const e="imageWidth"===t?"width":"imageHeight"===t?"height":"borderRadius",n=i+"";s.style[e]!==n&&(s.style[e]=n)}break}case"labelValign":case"labelHalign":if(o){const t=`align-vertical-${this._e.labelValign} align-horizontal-${this._e.labelHalign}`;o.className!==t&&(o.className=t)}}}qe(){const t=this.view;if(!t||!t.view)return;const i=t.tags?.ds;if(i)return;const s=t.view,e=t.tags?.Ue,n=document.createElement("img");n.className="option-image",n.style.width=this._e.imageWidth,n.style.height=this._e.imageHeight,n.style.borderRadius=this._e.imageBorderRadius,e&&e.parentElement?s.insertBefore(n,e):s.appendChild(n),t.tags.ds=n}}class P extends C{constructor(t=[]){super(t),this.isMultiple=!1,this.Je=[],this.Ke=-1,this.Qe=null,this.groups=[],this.Ye=[],this.Xe()}Xe(){this.Ye=[],this.groups=[],this.items.forEach(t=>{t instanceof m?(this.groups.push(t),this.Ye.push(...t.items)):t instanceof b&&this.Ye.push(t)})}je(t,i){return i instanceof m?new S(t):new L(t)}$e(t,i,s){t.position=s,t instanceof m?this.Ze(t,i,s):t instanceof b&&this.tn(t,i,s),t.Ot=!0}Ze(t,i,s){super.$e(t,i,s),t.view=i;const e=i.view.tags.Ve;e.textContent=t.label,t.Ot||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.qi()}),t.Wi((t,i,s)=>{i.items.forEach(t=>{const i=t.view?.ns?.();i&&(i.style.display=s?"none":"")}),this.sn(i,s)}));const n=i.Re();t.items.forEach((t,i)=>{let s=t.view;t.Ot&&s||(s=new L(n)),this.tn(t,s,i),t.Ot=!0}),i.Ui(t.collapsed),i.Ki()}tn(t,i,s){if(i.isMultiple=this.isMultiple,i.hasImage=t.hasImage,i.Ge={imageWidth:t.options.imageWidth,imageHeight:t.options.imageHeight,imageBorderRadius:t.options.imageBorderRadius,imagePosition:t.options.imagePosition,labelValign:t.options.labelValign,labelHalign:t.options.labelHalign},t.Ot||super.$e(t,i,s),t.view=i,t.hasImage){const s=i.view.tags.ds;s&&(s.src!==t.ss&&(s.src=t.ss),s.alt!==t.text&&(s.alt=t.text))}i.view.tags.us.innerHTML=t.text,t.Ot||(i.view.tags.We.addEventListener("click",i=>{i.stopPropagation(),i.preventDefault(),this.Ps||(this.isMultiple?(this.$s("select"),setTimeout(()=>{t.selected=!t.selected},5)):!0!==t.selected&&(this.$s("select"),setTimeout(()=>{this.Qe&&(this.Qe.selected=!1),t.selected=!0},5)))}),i.view.tags.We.title=t.textContent,i.view.tags.We.addEventListener("mouseenter",()=>{this.Ps||this.en(this.Ye.indexOf(t),!1)}),t.rs(()=>{this.Es("selected")}),t.cs((i,s,e)=>{e&&(this.Qe=t),this.Es("selected_internal")}),t.ni((t,i)=>{i.group?.Ki(),this.nn()})),t.selected&&(this.Qe=t,t.es=!0)}Ie(t){this.$s("items",t),this.items=t,this.Xe(),this.Es("items",t)}As(t){this.Ie(t)}Ls(t){this.items=t,this.Xe()}hn(){return this.Ye.filter(t=>t.selected)}ln(){return this.Ye.find(t=>t.selected)}Kt(t){this.isMultiple&&this.Ye.forEach(i=>{i.selected=t})}ni(t){this.Je.push(t)}nn(){const t=this.Ye.filter(t=>t.visible).length,i=this.Ye.length;this.Je.forEach(s=>{s({rn:t,an:i,ti:t>0,isEmpty:0===i})})}ii(){const t=this.Ye.filter(t=>t.visible).length,i=this.Ye.length;return{rn:t,an:i,ti:t>0,isEmpty:0===i}}cn(){this.en(0)}navigate(t,i=!0){const s=this.Ye.filter(t=>t.visible);if(0===s.length)return;let e=s.findIndex(t=>t===this.Ye[this.Ke]);-1===e&&(e=-1);let n=e+t;n>=s.length&&(n=0),n<0&&(n=s.length-1);const h=this.Ye.indexOf(s[n]);this.en(h,i)}un(){if(this.Ke>-1&&this.Ye[this.Ke]){const t=this.Ye[this.Ke];if(t.visible){const i=t.view?.ns?.();i&&i.click()}}}en(t,i=!0){let s=0;if("number"==typeof t)s=t;else if(t instanceof b){const i=this.Ye.indexOf(t);s=i>-1?i:0}else s=0;this.Ke>-1&&this.Ye[this.Ke]&&(this.Ye[this.Ke].ls=!1);for(let e=s;e<this.Ye.length;e++){const t=this.Ye[e];if(t.visible){if(t.ls=!0,this.Ke=e,i){const i=t.view?.ns?.();i&&i.scrollIntoView({block:"center",behavior:"smooth"})}return void this.dn(e,t.view?.ns?.()?.id)}}}dn(t,i){}sn(t,i){}}class M{constructor(t=null,i=null){this.container={},this.oldValue=null,this.node=null,this.options=null,this.pn=null,this.isOpen=!1,this.gn=!1,this.fn=!1,this.oe=null,t&&this.init(t,i)}get isDisabled(){return!!this.options?.disabled}set isDisabled(t){this.options&&this.node&&(this.options.disabled=t,this.node.classList.toggle("disabled",t),this.node.setAttribute("aria-disabled",t+""),this.container.tags?.mi?.setAttribute("aria-disabled",t+""))}get mn(){return!!this.options?.readonly}set mn(t){this.options&&this.node&&(this.options.readonly=t,this.node.classList.toggle("readonly",t))}get isVisible(){return!!this.options?.visible}set isVisible(t){this.options&&this.node&&(this.options.visible=t,this.node.classList.toggle("invisible",!t))}init(t,s){const n=e.R(t).options,r=new o(n),a=new l,c=new p(n),effector=i(),u=new w(n),g=new v(n),f=new x(t,u,this),m=new T(t),b=new O(t);this.oe=s,this.options=n,r.node&&(r.node.id=(n.bn??"")+"");const C=e.$({wn:{tag:{node:"div",classList:"selective-ui-MAIN"},j:{mi:{tag:{node:"div",classList:"selective-ui-view",tabIndex:0,onkeydown:t=>{"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.yn()?.open())}},j:{vn:{tag:r.node},xn:{tag:a.node},ji:{tag:c.node}}}}}},null);this.container=C,this.node=C.view,t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,C.tags.mi),g.Bs(C.tags.mi),g.Gs(u),C.tags.mi.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),h.rt(t,C.tags.mi),t.classList.add("init"),u.ws(P),u.vs(y),u.Cs(e.K(t)),u.onUpdated=()=>{C.Tn?.si?.()},this.pn=u,C.On=f,C.placeholder=r,C.Cn=a,C.An=c,C.effector=effector,C.targetElement=t,C.Sn=g,C.Ln=m,C.Pn=b,C.Tn=new d(t,n,u),C.Tn.ai(effector),C.Tn.bi(f,n),C.Tn.ri("selected",()=>{this.yn()?.change(null,!0)}),C.Tn.ri("selected_internal",()=>{this.yn()?.change(null,!1)}),C.Tn.oi("select",()=>{this.oldValue=this.yn()?.value??""}),this.yn()?.change(null,!1),m.connect(),m.Pt=t=>{u.update(e.K(t)),this.yn()?.refreshMask()},b.connect(),b.Pt=t=>{e.V(t.disabled)!==this.isDisabled&&(this.isDisabled=e.V(t.disabled)),e.V(t.readonly)!==this.mn&&(this.mn=e.V(t.readonly)),e.V(t.visible)!==this.isVisible&&(this.isVisible=e.V(t.visible??"1"))},t.addEventListener("options:changed",()=>{u.update(e.K(t)),this.yn()?.refreshMask(),C.Tn?.si?.()}),n.ajax&&f.ue(n.ajax);const A=C.Tn.Ht,S=(t,i)=>{i||""!==t?(""!==t&&(this.fn=!0),f.search(t).then(t=>{C.Tn?.si?.(),t?.me&&setTimeout(()=>{A.cn()},n.animationtime??0)}).catch(t=>{console.error("Search error:",t)})):f.clear()};let L=null;c.Pi=(t,i)=>{f.fe(t)&&(f.se()?(L&&clearTimeout(L),C.Tn?.Yt?.(),L=setTimeout(()=>{S(t,i)},n.delaysearchtime??0)):S(t,i))},f.setPopup(C.Tn),c.Mi=t=>{A.navigate(t)},c.Hi=()=>{A.un()},c.$i=()=>{this.yn()?.close(),C.tags.mi.focus()},A.dn=(t,i)=>{i&&c.Ii(i)},A.sn=()=>{C.Tn?.si?.()},this.isDisabled=e.V(n.disabled),this.mn=e.V(n.readonly)}Mn(){const t=this.container??{},{Ln:i,Pn:s}=t;i?.disconnect&&i.disconnect(),s?.disconnect&&s.disconnect()}yn(){const t=this.container,i=this,s=()=>this.oe.find(t.targetElement),h=e.R(t.targetElement);if(!h)return null;const o=h.options,l={get targetElement(){return t.targetElement},get placeholder(){return t.placeholder.get()},set placeholder(i){t.placeholder?.set(i),t.An?.Ei(i)},get oldValue(){return i.oldValue},set value(t){this.setValue(null,t,!0)},get value(){const t=this.valueArray,i=t.length;return i>1?t:0===i?"":t[0]},get valueArray(){const t=[];return i.Hn().forEach(i=>{i.selected&&t.push(i.value)}),t},get valueString(){return this.valueArray.join(o.customDelimiter)},get valueOptions(){const t=[];return i.Hn(!0).forEach(i=>{t.push(i)}),t},get mask(){const t=[];return i.Hn(!0).forEach(i=>{t.push(i.text)}),t},get valueText(){const t=[];i.Hn(!0).forEach(i=>{t.push(i.text)});const s=t.length;return s>1?t:0===s?"":t[0]},get isOpen(){return i.isOpen},getParent:()=>t.view.parentElement,valueDataset(t,s=null,e=!1){var n=[];if(i.Hn(!0).forEach(t=>{n.push(s?t.dataset[s]:t.dataset)}),!e){if(0==n.length)return"";if(1==n.length)return n[0]}return n},selectAll(t,e=!0){if(!(o.multiple&&o.maxSelected>0&&i.Hn().length>o.maxSelected)&&!this.disabled&&!this.readonly&&o.multiple){if(e){if(n.ht([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Hn().forEach(t=>{t.es=!0}),this.change(!1,e)}},deSelectAll(t,e=!0){if(!this.disabled&&!this.readonly&&o.multiple){if(e){if(n.ht([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Hn().forEach(t=>{t.es=!1}),this.change(!1,e)}},setValue(e=null,h,l=!0,r=!1){if(Array.isArray(h)||(h=[h]),0===(h=h.filter(t=>""!==t&&null!=t)).length)return i.Hn().forEach(t=>t.es=!1),void this.change(!1,l);if(o.multiple&&o.maxSelected>0&&h.length>o.maxSelected)console.warn(`Cannot select more than ${o.maxSelected} items`);else if(r||!this.disabled&&!this.readonly){if(t.On?.se?.()){const{ce:s}=t.On.re(h);if(s.length>0)return void(async()=>{o.loadingfield&&t.Tn?.Yt?.();try{t.On.de();const e=await t.On.ee(s);e.Oi&&e.items.length>0?(e.items.forEach(t=>{s.includes(t.value)&&(t.selected=!0)}),t.On.we?.(e.items,!0,!0),setTimeout(()=>{i.Hn().forEach(t=>{t.es=h.some(i=>i==t.value)}),this.change(!1,!1)},100)):s.length>0&&console.warn(`Could not load ${s.length} values:`,s)}catch(e){console.error("Error loading missing values:",e)}finally{o.loadingfield&&t.Tn?.ei?.()}})()}if(l){if(n.ht([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Hn().forEach(t=>{t.es=h.some(i=>i==t.value)}),!o.multiple&&h.length>0&&(t.targetElement.value=h[0]),this.change(!1,l)}},open(){if(i.isOpen)return;const e=i.oe?.find?.();if(e&&!e.isEmpty&&e.close().isCancel)return;if(this.disabled)return;if(n.ht([s()],...o.on.beforeShow).isCancel)return;i.isOpen=!0,t.Cn.dt(!0);const h=t.Tn.Ht,l=h.ln();l?h.en(l,!1):h.cn(),i.gn&&!i.fn||!o?.ajax?t.Tn.open(null,!0):(t.On.de(),t.Tn.Yt(),i.gn=!0,i.fn=!1,setTimeout(()=>{t.Tn&&t.On&&t.On.search("").then(()=>t.Tn?.si?.()).catch(t=>console.error("Initial ajax load error:",t))},o.animationtime),t.Tn.open(null,!1)),t.An.show();const r=t.tags.mi;r.setAttribute("aria-expanded","true"),r.setAttribute("aria-controls",o.Gt),r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-labelledby",o.bn),o.multiple&&r.setAttribute("aria-multiselectable","true"),n.ht([s()],...o.on.show)},close(){i.isOpen&&(n.ht([s()],...o.on.beforeClose).isCancel||(i.isOpen=!1,t.Cn.dt(!1),t.Tn.close(()=>{t.An.clear(!1)}),t.An.hide(),t.tags.mi.setAttribute("aria-expanded","false"),n.ht([s()],...o.on.close)))},toggle(){i.isOpen?this.close():this.open()},change(e=null,h=!0){if(h){if(o.multiple&&o.maxSelected>0&&this.valueArray.length>o.maxSelected&&this.setValue(null,this.oldValue,!1,!0),this.disabled||this.readonly)return void this.setValue(null,this.oldValue,!1,!0);if(n.ht([s(),this.value],...o.on.beforeChange).isCancel)return void this.setValue(null,this.oldValue,!1)}this.refreshMask(),t.Sn.Us(this.valueOptions),h&&(t.targetElement&&n.ot(t.targetElement,"change"),n.ht([s(),this.value],...o.on.change),i.options?.autoclose&&this.close())},refreshMask(){let s=o.placeholder;!o.multiple&&i.Hn().length>0&&(s=this.mask[0]),s??(s=o.placeholder),t.placeholder.set(s,!1),t.An.Ei(s)},on(t,i,s){o.on[i]||(o.on[i]=[]),o.on[i].push(s)},ajax(i,s){t.On.ue(s)},loadAjax:()=>new Promise((e,n)=>{t.Tn.Yt(),t.On.de(),i.gn=!0,i.fn=!1,t.Tn&&t.On?t.On.search("").then(()=>{t.Tn?.si?.(),e(s())}).catch(t=>{console.error("Initial ajax load error:",t),n(t)}):e(s())})};return this.$n(l,"disabled","isDisabled"),this.$n(l,"readonly","isReadOnly"),this.$n(l,"visible","isVisible"),l}$n(t,i,s){const e=this;Object.defineProperty(t,i,{get:()=>e[s],set(t){e[s]=!!t,e.container?.targetElement?.dataset&&(e.container.targetElement.dataset[i]=!!t+"")},enumerable:!0,configurable:!0})}Hn(t=null){if(!this.pn)return[];const{Ms:i}=this.pn.qt(),s=[];for(const e of i)e instanceof b?s.push(e):e instanceof m&&Array.isArray(e.items)&&e.items.length&&s.push(...e.items);return"boolean"==typeof t?s.filter(i=>i.selected===t):s}Ci(){this.container.Tn.Ci()}}class H{constructor(){this.jn=!1,this.Ce=null,this.En=[]}In(t){this.En.push(t)}Fn(){this.En=[]}start(t){if(this.jn)return;this.jn=!0;const i=t.toUpperCase(),s=t.toLowerCase();this.Ce=new MutationObserver(t=>{for(const e of t)e.addedNodes.forEach(t=>{if(1!==t.nodeType)return;const e=t;e.tagName===i&&this.Vn(e),e.querySelectorAll(s).forEach(t=>this.Vn(t))})}),this.Ce.observe(document.body,{childList:!0,subtree:!0})}stop(){this.jn&&(this.jn=!1,this.Ce?.disconnect(),this.Ce=null)}Vn(t){this.En.forEach(i=>i(t))}}class ${constructor(){this.kn=new Map}bind(t,i){const s=e.F(e.G(),i);s.on=s.on??{},s.on.load=s.on.load??[],this.kn.set(t,s);const h=e.m();e.Z.on(h,()=>{n.ht([this.find(t)],...s.on.load),e.Z.clear(h),s.on.load=[]}),e.v(t).forEach(t=>{(async()=>{"SELECT"===t.tagName&&(e.D(t),this.Rn(t,s)&&e.Z.run(h))})()}),e.U().includes(t)||e.U().push(t)}find(t="*"){const i={isEmpty:!0};if("*"===t&&""===(t=e.U().join(", ")))return i;const s=e.v(t);if(0===s.length)return i;const n=e.R(s[0]);if(!n||!n.action)return i;const h={};for(const e in n.action)h[e]=this._n(e,n.action);const o={isEmpty:!1};for(const e in h){const t=h[e];switch(t.type){case"get-set":this.Dn(o,t.name,s);break;case"func":this.Nn(o,t.name,s)}}return o}Bn(){this.zn=new H,this.zn.In(t=>{this.kn.forEach((i,s)=>{try{t.matches(s)&&this.Rn(t,i)}catch(e){console.warn("Invalid selector: "+s,e)}})}),this.zn.start("select")}destroy(t=null){null===t?this.Gn():"string"==typeof t?this.Un(t):t instanceof HTMLSelectElement&&this.Wn(t)}Gn(){e.U().forEach(t=>this.Un(t)),this.kn.clear(),e.U().length=0,this.zn?.stop()}Un(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.Wn(t)}),this.kn.delete(t);const i=e.U(),s=i.indexOf(t);s>-1&&i.splice(s,1)}Wn(t){const i=e.R(t);if(!i)return;const s=i.container?.Tn;s?.Ci(),e.B(t,i);const n=!!this.zn;n&&this.zn?.stop();try{i.self?.Mn?.()}catch(o){}const h=i.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.qn,h&&h.parentNode?h.parentNode.replaceChild(t,h):document.body.appendChild(t),e.k(t),n&&this.kn.size>0&&this.zn?.start("select")}rebind(t,i){this.Un(t),this.bind(t,i)}Rn(t,i){if(e.R(t)||e.N(t))return!1;const s=e.m(8),n=e.I(t,i);n.Jn=s,n.Gt=`seui-${s}-optionlist`,n.bn=`seui-${s}-placeholder`;const h={options:n};e._(t,h);const o=new M(t,this);return h.container=o.container,h.action=o.yn(),h.self=o,o.container.view.addEventListener("mouseup",()=>{h.action?.toggle?.()}),!0}_n(t,i){const s=Object.getOwnPropertyDescriptor(i,t);let e="variable";return s?.get||s?.set&&"function"!=typeof i[t]?e="get-set":"function"==typeof i[t]&&(e="func"),{type:e,name:t}}Dn(t,i,s){Object.defineProperty(t,i,{get(){const t=e.R(s[0]);return t.action?.[i]},set(t){s.forEach(s=>{const n=e.R(s);n?.action&&(n.action[i]=t)})},enumerable:!0,configurable:!0})}Nn(t,i,s){t[i]=(...h)=>{let o=null;for(let t=0;t<s.length;t++){const l=e.R(s[t]);if(!l?.action)continue;const r=n.nt();if(o??(o=l.action[i](r.et,...h)),!r.token.isContinue)break}return o??t}}}const j="1.1.5",E="SelectiveUI";if(void 0===globalThis.GLOBAL_SEUI){const F=new $;globalThis.GLOBAL_SEUI={version:j,name:E,bind:F.bind.bind(F),find:F.find.bind(F),destroy:F.destroy.bind(F),effector:i.bind(i),rebind:F.rebind.bind(F)};let V=!1;function k(){V||(V=!0,document.addEventListener("mousedown",()=>{const t=e.U();if(t.length>0){const i=F.find(t.join(", "));i.isEmpty||i.close()}}),F.Bn())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",k):k()),console.log(`[${E}] v${j} loaded successfully`)}else console.warn(`[${globalThis.GLOBAL_SEUI.name}] Already loaded (v${globalThis.GLOBAL_SEUI.version}). Using existing instance. Please remove duplicate <script> tags.`);const version=globalThis.GLOBAL_SEUI.version,I=globalThis.GLOBAL_SEUI.name;t.bind=(t,i={})=>{globalThis.GLOBAL_SEUI.bind(t,i)},t.destroy=(t=null)=>{globalThis.GLOBAL_SEUI.destroy(t)},t.effector=t=>globalThis.GLOBAL_SEUI.effector(t),t.find=t=>globalThis.GLOBAL_SEUI.find(t),t.name=I,t.rebind=(t,i={})=>{globalThis.GLOBAL_SEUI.rebind(t,i)},t.version=version},"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).SelectiveUI={});
1
+ /*! Selective UI v1.2.0 | MIT License */
2
+ var t,i;t=this,i=function(t){"use strict";function i(t){return new g(t??null)}class s{constructor(){this.t={showPanel:!0,virtualScroll:!0,accessoryStyle:"top",multiple:!1,minWidth:"50px",width:"0px",offsetWidth:null,minHeight:"30px",height:"30px",panelHeight:"220px",panelMinHeight:"100px",disabled:!1,readonly:!1,selectall:!0,keepSelected:!0,placeholder:"Select value",altMask:"",autoclose:!1,autoscroll:!0,autofocus:!0,searchable:!0,loadingfield:!0,visible:!0,skipError:!1,customDelimiter:",",textLoading:"Processing...",textNoData:"No data available",textNotFound:"Not found",textSelectAll:"Select all",textDeselectAll:"Deselect all",textAccessoryDeselect:"Deselect: ",animationtime:200,delaysearchtime:200,allowHtml:!0,maxSelected:0,labelHalign:"left",labelValign:"center",imageMode:!1,imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",imagePosition:"right",ajax:null,on:{load:[],beforeShow:[],show:[],beforeChange:[],change:[],beforeClose:[],close:[]}},this.i=new Map,this.h=new Map,this.o=[]}}class e{static get l(){return this.u||(this.u=new s),this.u}static p(t){if(null===t||"object"!=typeof t)return t;const i=Array.isArray(t)?[]:{};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=this.p(t[s]));return i}static m(t=6){let i="";for(let s=0;s<t;s++)i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return i}static v(t){if(!t)return[];if("string"==typeof t){const i=document.querySelectorAll(t);return Array.from(i)}return t instanceof Element?[t]:t instanceof NodeList||Array.isArray(t)?Array.from(t):[]}static T(t={}){return this.O(document.createElement(t.node??"div"),t,!0)}static O(t=document.documentElement,i=null,s=!1){const e={...i??{}},h=s?t:this.M(t.cloneNode(!0)),n=e.classList;return"string"==typeof n?h.classList.add(n):Array.isArray(n)&&h.classList.add(...n),delete e.classList,["style","dataset"].forEach(t=>{const i=e[t];i&&"object"==typeof i&&Object.assign(h[t],i),delete e[t]}),e.role&&(h.setAttribute("role",e.role+""),delete e.role),e.ariaLive&&(h.setAttribute("aria-live",e.ariaLive+""),delete e.ariaLive),e.A&&(h.setAttribute("aria-labelledby",e.A+""),delete e.A),e.C&&(h.setAttribute("aria-controls",e.C+""),delete e.C),e.S&&(h.setAttribute("aria-haspopup",e.S+""),delete e.S),e.H&&(h.setAttribute("aria-multiselectable",e.H+""),delete e.H),e.L&&(h.setAttribute("aria-autocomplete",e.L+""),delete e.L),e.event&&"object"==typeof e.event&&(Object.entries(e.event).forEach(([t,i])=>{h.addEventListener(t,i)}),delete e.event),Object.entries(e).forEach(([t,i])=>{null===i?h.removeAttribute(t):h[t]=i}),h}static M(t){if(t instanceof Element)return t;throw new TypeError("Node is not an Element")}static P(t){return this.I(t)}static I(t,i=null,s=!1,e=!1,h={}){let n=null;for(const o in t){const r=t[o],l=r?.tag?.tagName?r.tag:this.T(r.tag);h[o]=l,r?.F&&this.I(r.F,l,!1,!1,h),i?s?i.prepend(l):i.append(l):e||n||(n=l)}return e||(h.id=this.m(7),i||(h={tags:h,view:n})),h}static j(t,i){const s=this.p(i);for(const e in s){const i=t[e];i?s[e]=i:void 0!==t?.dataset?.[e]&&(s[e]=t.dataset[e])}return s}static $(...t){if(0===t.length)return{};if(1===t.length)return this.p(t[0]);const i=this.p(t[0]);for(let s=1;s<t.length;s++){const e=t[s];for(const t in e)if("on"===t){const s=e[t];for(const e in s)i[t][e].push(s[e])}else i[t]=e[t]}return i}static V(t){if("boolean"==typeof t)return t;if("string"!=typeof t)return!!t;switch(t.trim().toLowerCase()){case"true":case"1":case"yes":case"on":return!0;default:return!1}}static k(t){return this.l.i.delete(t)}static R(t){return this.l.i.get(t)}static _(t,i){this.l.i.set(t,i)}static D(t){return this.l.h.delete(t)}static N(t){return this.l.h.get(t)}static B(t,i){this.l.h.set(t,i)}static U(){return this.l.t}static G(){return this.l.o}static W(t){if(null==t)return"";let i=(t+"").replace(/<`/g,"<").replace(/`>/g,">").replace(/\<\`/g,"<").replace(/\`\>/g,">").trim();const s=globalThis?.document;if(!s||"function"!=typeof s.createElement)return i=i.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<iframe\b[^>]*>[\s\S]*?<\/iframe>/gi,"").replace(/<(object|embed|link)\b[^>]*>[\s\S]*?<\/\1>/gi,""),i=i.replace(/\son[a-z]+\s*=\s*(['"]).*?\1/gi,""),i=i.replace(/\s([a-z-:]+)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,""),i;const e=s.createElement("div");return e.innerHTML=i,e.querySelectorAll("script, style, iframe, object, embed, link").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(const i in t.attributes){const s=t.attributes[i],e=s.name??"",h=s.value??"";if(/^on/i.test(e))return void t.removeAttribute(e);/^(href|src|xlink:href)$/i.test(e)&&/^javascript:/i.test(h)&&t.removeAttribute(e)}}),(e.innerHTML??"").trim()}static q(t){const i=document.createElement("DIV");i.innerHTML=t;const s=i.textContent??i.innerText??"";return i.remove(),s.trim()}static J(t){return null==t?"":(t+"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d").replace(/Đ/g,"d")}static K(t){const i=[];return Array.from(t.children).forEach(t=>{if("OPTGROUP"===t.tagName){const s=t;i.push(s),Array.from(s.children).forEach(t=>{t.__parentGroup=s,i.push(t)})}else"OPTION"===t.tagName&&i.push(t)}),i}static Y(){const t=navigator.userAgent;return/iP(hone|ad|od)/.test(t)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1}static X(t){const i=(t+"").trim();if(i.endsWith("px"))return i;if(i.endsWith("vh"))return window.innerHeight*parseFloat(i)/100+"px";if(i.endsWith("vw"))return window.innerWidth*parseFloat(i)/100+"px";const s=parseFloat(getComputedStyle(document.documentElement).fontSize);if(i.endsWith("rem"))return s*parseFloat(i)+"px";const e=this.T({node:"div",style:{height:i,opacity:"0"}});document.body.appendChild(e);const h=e.offsetHeight+"px";return e.remove(),h}}e.u=null,e.Z=new class{constructor(){this.tt=new Map,this.it=new Map}on(t,i,s={}){const e=s.st??50,h=s.once??!1;this.tt.has(t)||this.tt.set(t,[]),this.tt.get(t).push({et:i,timeout:e,once:h})}off(t){const i=this.it.get(t);if(i){for(const t of i.values())clearTimeout(t);i.clear(),this.it.delete(t)}this.tt.delete(t)}run(t,...i){const s=this.tt.get(t);if(!s)return;this.it.has(t)||this.it.set(t,new Map);const e=this.it.get(t);for(let h=0;h<s.length;h++){const t=s[h];if(!t)continue;const n=e.get(h);n&&clearTimeout(n);const o=setTimeout(()=>{if(t.et(i.length>0?i:null),t.once){s[h]=void 0;const t=e.get(h);t&&clearTimeout(t),e.delete(h)}},t.timeout);e.set(h,o)}}clear(t){if(void 0===t)for(const i of Array.from(this.tt.keys()))this.off(i);else this.off(t)}};class h{static ht(){const t={isContinue:!0,isCancel:!1};return{token:{get isContinue(){return t.isContinue},get isCancel(){return t.isCancel}},et:{stopPropagation(){t.isContinue=!1},cancel(){t.isCancel=!0,t.isContinue=!1}}}}static nt(t,...i){const{token:s,et:e}=this.ht();for(let h=0;h<i.length;h++){const n=i[h];if("function"==typeof n&&(t&&Array.isArray(t)?n(e,...t):n(e),s.isCancel||!s.isContinue))break}return s}static ot(t,i,s={bubbles:!0,cancelable:!0}){const e=new Event(i,s);return t.dispatchEvent(e),e}static rt(t,...i){if(Array.isArray(t))for(const s of t)"function"==typeof s&&s(...i)}}class n{static lt(t,i){const s=e.R(t);if(!s?.options)return;const h=s.options,n=h.minWidth,o=h.minHeight,r=Number.parseInt(h.width,10),l=Number.parseInt(h.height,10);let a=t.offsetWidth+"px",c=t.offsetHeight+"px";const u=getComputedStyle(t);"0px"===a&&"auto"!==u.width&&(a=u.width),"0px"===c&&"auto"!==u.height&&(c=u.height),r>0&&(a=h.width),l>0&&(c=h.height),Object.assign(i.style,{width:a,height:c,minWidth:n,minHeight:o})}}class o{constructor(t){this.node=null,this.ct=null,t&&this.init(t)}init(t){this.node=e.T({node:"div",classList:"selective-ui-placeholder",innerHTML:t.placeholder}),this.ct=t}get(){return this.ct?.placeholder??""}set(t,i=!0){if(!this.node||!this.ct)return;i&&(this.ct.placeholder=t);const s=e.W(t);this.node.innerHTML=this.ct.allowHtml?s:e.q(s)}}class r{constructor(){this.node=this.ut()}ut(){return e.T({node:"div",classList:"selective-ui-directive",role:"button",ariaLabel:"Toggle dropdown"})}dt(t){this.node.classList.toggle("drop-down",!!t)}}class l{constructor(t=null){this.gt=null,this.node=null,this.options=null,this.ft=[],this.bt=[],t&&this.init(t)}init(t){this.gt=e.I({wt:{tag:{node:"div",classList:["selective-ui-option-handle","hide"]},F:{yt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{h.rt(this.ft)}}},vt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{h.rt(this.bt)}}}}}}),this.node=this.gt.view,this.options=t}available(){return!!this.options&&e.V(this.options.multiple)&&e.V(this.options.selectall)}refresh(){this.node&&(this.available()?this.show():this.hide())}show(){this.node&&this.node.classList.remove("hide")}hide(){this.node&&this.node.classList.add("hide")}xt(t=null){"function"==typeof t&&this.ft.push(t)}Tt(t=null){"function"==typeof t&&this.bt.push(t)}}class a{constructor(t=null){this.node=null,this.options=null,t&&this.init(t)}init(t){this.options=t,this.node=e.T({node:"div",classList:["selective-ui-empty-state","hide"],role:"status",ariaLive:"polite"})}show(t="nodata"){this.node&&this.options&&(this.node.textContent="notfound"===t?this.options.textNotFound:this.options.textNoData,this.node.classList.remove("hide"))}hide(){this.node&&this.node.classList.add("hide")}get isVisible(){return!!this.node&&!this.node.classList.contains("hide")}}class c{constructor(t=null){this.node=null,this.options=null,t&&this.init(t)}init(t){this.options=t,this.node=e.T({node:"div",classList:["selective-ui-loading-state","hide"],textContent:t.textLoading,role:"status",ariaLive:"polite"})}show(t){this.node&&this.options&&(this.node.textContent=this.options.textLoading,this.node.classList.toggle("small",!!t),this.node.classList.remove("hide"))}hide(){this.node&&this.node.classList.add("hide")}get isVisible(){return!!this.node&&!this.node.classList.contains("hide")}}class u{constructor(){this.Ot=!1,this.element=null,this.Mt=null,this.At=null,this.Ot=!0,this.Ct=this.St.bind(this)}Ht(t){}St(){const t=this.element;if(!t||"function"!=typeof t.getBoundingClientRect)return void this.Ht({width:0,height:0,top:0,left:0,padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}});const i=t.getBoundingClientRect(),s="undefined"!=typeof window&&"function"==typeof window.getComputedStyle?window.getComputedStyle(t):null;this.Ht({width:i?.width??0,height:i?.height??0,top:i?.top??0,left:i?.left??0,padding:{top:parseFloat(s?.paddingTop??"0"),right:parseFloat(s?.paddingRight??"0"),bottom:parseFloat(s?.paddingBottom??"0"),left:parseFloat(s?.paddingLeft??"0")},border:{top:parseFloat(s?.borderTopWidth??"0"),right:parseFloat(s?.borderRightWidth??"0"),bottom:parseFloat(s?.borderBottomWidth??"0"),left:parseFloat(s?.borderLeftWidth??"0")},margin:{top:parseFloat(s?.marginTop??"0"),right:parseFloat(s?.marginRight??"0"),bottom:parseFloat(s?.marginBottom??"0"),left:parseFloat(s?.marginLeft??"0")}})}ot(){this.St()}connect(t){if(!(t instanceof Element))throw Error("Invalid element");this.element=t,this.Mt=new ResizeObserver(this.Ct),this.Mt.observe(t),this.At=new MutationObserver(this.Ct),this.At.observe(t,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("scroll",this.Ct,!0),window.addEventListener("resize",this.Ct),window.visualViewport&&(window.visualViewport.addEventListener("resize",this.Ct),window.visualViewport.addEventListener("scroll",this.Ct))}disconnect(){this.Mt?.disconnect(),this.At?.disconnect(),this.Ht=()=>{},window.removeEventListener("scroll",this.Ct,!0),window.removeEventListener("resize",this.Ct),window.visualViewport&&(window.visualViewport.removeEventListener("resize",this.Ct),window.visualViewport.removeEventListener("scroll",this.Ct)),this.Mt=null,this.At=null,this.element=null}}class d{constructor(t=null,i=null,s=null){this.options=null,this.Lt=!1,this.Pt=null,this.node=null,this.It=null,this.Et=null,this.Ft=null,this.jt=null,this.$t=null,this.Vt=null,this.kt=null,this.Rt=null,this._t=null,this.Dt=null,this.Nt={Bt:36,Ut:8,zt:!0},this.Gt=s,t&&i&&this.init(t,i)}init(t,i){if(!this.Gt)throw Error("Popup requires a ModelManager instance.");this.jt=new l(i),this.$t=new a(i),this.Vt=new c(i);const s=e.I({Wt:{tag:{node:"div",classList:"selective-ui-popup",style:{maxHeight:i.panelHeight}},F:{wt:{tag:this.jt.node},qt:{tag:{id:i.Jt,node:"div",classList:"selective-ui-options-container",role:"listbox"}},Kt:{tag:this.Vt.node},Qt:{tag:this.$t.node}}}},null);this.node=s.view,this.Rt=s.tags.qt,this.Ft=e.R(t),this.options=i,this.Gt.load(this.Rt,{isMultiple:i.multiple},i.virtualScroll?{Yt:this.node,Bt:this.Nt.Bt,Ut:this.Nt.Ut,zt:this.Nt.zt}:{});const h=this.Gt.Xt();this.Pt=h.Zt,this.kt=h.kt,this.jt.xt(()=>{h.Zt.ti(!0)}),this.jt.Tt(()=>{h.Zt.ti(!1)}),this.ii()}async si(){this.options&&this.Vt&&this.jt&&this.Pt&&this.Gt&&(this.Dt&&clearTimeout(this.Dt),this.Gt.ei(!0),!1!==e.V(this.options.loadingfield)&&(this.$t.hide(),this.Vt.show(this.Pt.ni().hi),this.oi()))}async ri(){this.options&&this.Vt&&this.Pt&&this.Gt&&(this.Dt&&clearTimeout(this.Dt),this.Dt=setTimeout(()=>{this.Gt?.ei(!1),this.Vt?.hide();const t=this.Pt?.ni();this.li(t??void 0),this.oi()},200))}ii(){this.Pt&&(this.Pt.ai(t=>{this.li(t)}),this.Pt.ci("items",()=>{const t=this.Pt.ni();this.li(t),this.oi()}))}li(t){if(!(this.Pt&&this.$t&&this.jt&&this.Rt))return;const i=t??this.Pt.ni();i.isEmpty?(this.$t.show("nodata"),this.Rt.classList.add("hide"),this.jt.hide()):i.hi?(this.$t.hide(),this.Rt.classList.remove("hide"),this.jt.refresh()):(this.$t.show("notfound"),this.Rt.classList.add("hide"),this.jt.hide())}ui(t,i){this.Pt?.di(t,i)}pi(t,i){this.Pt?.ci(t,i)}gi(t){this.It=t}open(t=null,i){if(!(this.node&&this.options&&this.jt&&this.Ft&&this.It))return;this.Lt||(document.body.appendChild(this.node),this.Lt=!0,this.Et=new u,this.It.fi(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.jt.refresh(),i&&this.li();const s=this.mi(),{position:e,top:h,maxHeight:n,bi:o}=this.wi(s);this.It.expand({duration:this.options.animationtime,display:"flex",width:s.width,left:s.left,top:h,maxHeight:n,bi:o,position:e,yi:()=>{if(!this.Et||!this.Ft)return;this.Et.Ht=()=>{const t=this.mi();this.xi(t)},this.Et.connect(this.Ft.container.tags.Ti),t?.();const i=this.kt;i?.resume?.()}})}close(t=null){if(!(this.Lt&&this.options&&this.Et&&this.It))return;const i=this.kt;i?.suspend?.(),this.Et.disconnect(),this.It.collapse({duration:this.options.animationtime,yi:t??void 0})}oi(){this.Lt&&this.Et?.ot()}Oi(t,i){this.node&&(this._t=async()=>{const i=t.Mi();if(!i.Ai)return;const s=this.node;if(s.scrollHeight-s.scrollTop-s.clientHeight<100&&!i.Ci&&i.hasMore){const i=await t.Si();!i.Hi&&i.message&&console.log("Load more:",i.message)}},this.node.addEventListener("scroll",this._t))}Li(){this.Dt&&(clearTimeout(this.Dt),this.Dt=null),this.node&&this._t&&(this.node.removeEventListener("scroll",this._t),this._t=null);try{this.Et?.disconnect()}catch(t){}this.Et=null;try{this.It?.fi?.(null)}catch(t){}if(this.It=null,this.node)try{const t=this.node.cloneNode(!0);this.node.replaceWith(t),t.remove()}catch(t){this.node.remove()}this.node=null,this.Rt=null;try{this.Gt?.ei?.(!1),this.kt?.clear?.(),this.kt=null,this.Pt=null,this.node.remove()}catch(t){}this.Gt=null,this.jt=null,this.$t=null,this.Vt=null,this.Ft=null,this.options=null,this.Lt=!1}mi(){const t=this.Ft.container.tags.Ti,i=t.getBoundingClientRect(),s=window.getComputedStyle(t);return{width:i.width,height:i.height,top:i.top,left:i.left,padding:{top:parseFloat(s.paddingTop),right:parseFloat(s.paddingRight),bottom:parseFloat(s.paddingBottom),left:parseFloat(s.paddingLeft)},border:{top:parseFloat(s.borderTopWidth),right:parseFloat(s.borderRightWidth),bottom:parseFloat(s.borderBottomWidth),left:parseFloat(s.borderLeftWidth)}}}wi(t){const i=window.visualViewport,s=e.Y(),h=i?.height??window.innerHeight,n=this.It.Pi("flex").scrollHeight,o=parseFloat(this.options?.panelHeight??"220")||220,r=parseFloat(this.options?.panelMinHeight??"100")||100,l=h-(t.top+t.height)-3,a=t.top-3;let c="bottom",u=o,d=Math.min(n,u);const p=l-15;(d>=r?p>=r:p>=d)?(c="bottom",u=Math.min(l-15,o)):a>=Math.max(d,r)?(c="top",u=Math.min(a-15,o)):l>=a?(c="bottom",u=Math.max(l-15,r)):(c="top",u=Math.max(a-15,r)),d=Math.min(n,u);const g=i&&s?i.offsetTop:0;return{position:c,top:"bottom"===c?t.top+t.height+3+g:t.top-d-3+g,maxHeight:u,bi:d,Ii:n}}xi(t){if(!this.options||!this.It)return;const{position:i,top:s,maxHeight:e,bi:h}=this.wi(t);this.It.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:s,maxHeight:e,bi:h,position:i,animate:!0})}}class p{constructor(t=null){this.gt=null,this.node=null,this.Ei=null,this.Fi=null,this.options=null,this.ji=null,this.$i=null,this.Vi=null,this.options=t,t&&this.init(t)}init(t){this.gt=e.I({ki:{tag:{node:"div",classList:["selective-ui-searchbox","hide"]},F:{Ei:{tag:{id:e.m(),node:"input",type:"search",classList:["selective-ui-searchbox-input"],placeholder:t.placeholder,role:"searchbox",C:t.Jt,L:"list"}}}}}),this.node=this.gt.view,this.Ei=this.gt.tags.Ei;let i=!1;const s=this.gt.tags.Ei;s.addEventListener("mousedown",t=>{t.stopPropagation()}),s.addEventListener("mouseup",t=>{t.stopPropagation()}),s.addEventListener("keydown",t=>{i=!1,"ArrowDown"===t.key||"Tab"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.ji?.(1)):"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.ji?.(-1)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.$i?.()):"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),i=!0,this.Vi?.()),t.stopPropagation()}),s.addEventListener("input",()=>{i||this.Fi?.(s.value,!0)})}show(){this.node&&this.Ei&&this.options&&(this.node.classList.remove("hide"),this.Ei.readOnly=!this.options.searchable,this.options.searchable&&requestAnimationFrame(()=>{this.Ei?.focus()}))}hide(){this.node&&this.node.classList.add("hide")}clear(t=!0){this.gt&&(this.gt.tags.Ei.value="",this.Fi?.("",t))}Ri(t){this.Ei&&(this.Ei.placeholder=e.q(t))}_i(t){this.Ei&&this.Ei.setAttribute("aria-activedescendant",t)}}class g{constructor(t=null){this.Di=null,this.Ni=null,this.Bi=!1,t&&this.fi(t)}fi(t){if("string"==typeof t){const i=document.querySelector(t);return void(i instanceof HTMLElement&&(this.element=i))}this.element=t}cancel(){return this.Di&&(clearTimeout(this.Di),this.Di=null),this.Ni&&(clearTimeout(this.Ni),this.Ni=null),this.Bi=!1,this}Pi(t="flex"){if(!this.element)return{width:0,height:0,scrollHeight:0};const i={display:this.element.style.display,visibility:this.element.style.visibility,position:this.element.style.position,height:this.element.style.height,width:this.element.style.width};Object.assign(this.element.style,{display:t,visibility:"hidden",position:"fixed",height:"fit-content",width:"fit-content"});const s=window.getComputedStyle(this.element),e=parseFloat(s.borderTopWidth),h=parseFloat(s.borderBottomWidth),n=this.element.scrollHeight+e+h,o=this.element.getBoundingClientRect(),r={width:o.width,height:o.height+e+h,scrollHeight:n};return Object.assign(this.element.style,i),r}expand(t){if(!this.element)return this;this.cancel(),this.Bi=!0;const{duration:i=200,display:s="flex",width:e,left:h,top:n,maxHeight:o,bi:r,position:l="bottom",yi:a}=t;return Object.assign(this.element.style,{display:s,width:e+"px",left:h+"px",top:("bottom"===l?n:n+r)+"px",maxHeight:o+"px",height:"0px",opacity:"0",overflow:"hidden",transition:"none"}),this.element.classList.toggle("position-top","top"===l),this.element.classList.toggle("position-bottom","bottom"===l),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`top ${i}ms, height ${i}ms, opacity ${i}ms`,top:n+"px",height:r+"px",opacity:"1",overflow:r>=o?"auto":"hidden"}),this.Di=setTimeout(()=>{this.element.style.transition="none",this.Bi=!1,a?.()},i)}),this}collapse(t){if(!this.element)return this;this.cancel(),this.Bi=!0;const{duration:i=200,yi:s}=t,e=this.element.offsetHeight,h=this.element.offsetTop,n=this.element.classList.contains("position-top")?"top":"bottom",o=this.element.scrollHeight-this.element.offsetHeight>0,r="top"===n?h+e:h;return requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`height ${i}ms, top ${i}ms, opacity ${i}ms`,height:"0px",top:r+"px",opacity:"0",overflow:o?"auto":"hidden"}),this.Di=setTimeout(()=>{Object.assign(this.element.style,{display:"none",transition:"none"}),this.Bi=!1,s?.()},i)}),this}showSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Bi=!0;const{duration:i=200,display:s="block",yi:e}=t;Object.assign(this.element.style,{transition:"none",display:s,width:"fit-content"});const h=this.Pi(s).width;return Object.assign(this.element.style,{width:"0px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${i}ms`,width:h+"px",overflow:"hidden"})}),this.Di=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:""}),this.Bi=!1,e?.()},i),this}hideSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Bi=!0;const{duration:i=200,yi:s}=t,e=this.Pi().width;return Object.assign(this.element.style,{transition:"none",width:e+"px"}),requestAnimationFrame(()=>{Object.assign(this.element.style,{transition:`width ${i}ms`,width:"0px",overflow:"hidden"})}),this.Di=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:"",display:""}),this.Bi=!1,s?.()},i),this}resize(t){if(!this.element)return this;this.Ni&&clearTimeout(this.Ni);const{duration:i=200,width:s,left:e,top:h,maxHeight:n,bi:o,position:r="bottom",animate:l=!0,yi:a}=t,c=(this.element.classList.contains("position-top")?"top":"bottom")!==r,u=this.element.scrollHeight>n;return this.element.classList.toggle("position-top","top"===r),this.element.classList.toggle("position-bottom","bottom"===r),c&&(this.element.style.transition=`top ${i}ms ease-out, height ${i}ms ease-out, max-height ${i}ms ease-out;`),requestAnimationFrame(()=>{const t={width:s+"px",left:e+"px",top:h+"px",maxHeight:n+"px",height:o+"px",overflowY:u?"auto":"hidden"},r=Math.abs(this.element.offsetHeight-o);l&&(c||r>5)?t.transition=`height ${i}ms, top ${i}ms`:this.Ni=setTimeout(()=>{this.element?.style&&(this.element.style.transition="none")},i),Object.assign(this.element.style,t),l&&(c||r>1)?this.Ni=setTimeout(()=>{this.element.style.transition="none",c&&delete this.element.style.transition,a?.()},i):(c&&delete this.element.style.transition,a?.())}),this}get Ui(){return this.Bi}}class f{get value(){return this.targetElement?.getAttribute("value")??null}constructor(t,i=null,s=null){this.targetElement=null,this.view=null,this.position=-1,this.Ot=!1,this.zi=!1,this.options=t,this.targetElement=i,this.view=s}update(t){this.targetElement=t,this.Gi()}remove(){this.targetElement=null,this.view?.Wi()?.remove?.(),this.view=null,this.zi=!0,this.qi()}Gi(){}qi(){}}class m extends f{constructor(t,i){super(t,i??null,null),this.label="",this.items=[],this.collapsed=!1,this.Ji=[],i&&(this.label=i.label,this.collapsed=e.V(i.dataset?.collapsed))}get value(){return this.items.map(t=>t.value)}get Ki(){return this.items.filter(t=>t.selected)}get Qi(){return this.items.filter(t=>t.visible)}get Yi(){return this.Qi.length>0}update(t){this.label=t.label,this.view?.Xi(this.label)}Gi(){this.view&&(this.view.Xi(this.label),this.view.Zi(this.collapsed))}ts(t){this.Ji.push(t)}ss(){this.collapsed=!this.collapsed,this.view?.Zi(this.collapsed),h.nt([this,this.collapsed],...this.Ji)}es(t){this.items.push(t),t.group=this}removeItem(t){const i=this.items.indexOf(t);i>-1&&(this.items.splice(i,1),t.group=null)}hs(){this.view?.hs()}}class b extends f{constructor(){super(...arguments),this.ns=[],this.rs=[],this.ls=[],this.cs=!0,this.us=!1,this.group=null}get ds(){return this.dataset?.imgsrc||this.dataset?.image||""}get hasImage(){return!!this.ds}get value(){return this.targetElement?.value??""}get selected(){return!!this.targetElement?.selected}set selected(t){this.ps=t,h.nt([this,t],...this.ns)}get visible(){return this.cs}set visible(t){if(this.cs===t)return;this.cs=t;const i=this.view?.Wi?.();i&&i.classList.toggle("hide",!t),h.nt([this,t],...this.ls)}get ps(){return this.selected}set ps(t){const i=this.view?.view?.tags?.gs,s=this.view?.Wi?.();i&&(i.checked=t),s&&this.targetElement&&(s.classList.toggle("checked",!!t),s.setAttribute("aria-selected",t?"true":"false"),this.targetElement.toggleAttribute("selected",!!t)),this.targetElement&&(this.targetElement.selected=t),h.nt([this,t],...this.rs)}get text(){const t=e.W(this.dataset?.mask??this.targetElement?.text??"");return this.options.allowHtml?t:e.q(t)}get textContent(){return this.options.allowHtml?e.q(this.text).trim():this.text.trim()}get dataset(){return this.targetElement?.dataset??{}}get fs(){return this.us}set fs(t){const i=!!t,s=this.view?.Wi?.();this.us!==i&&(this.us=i),s&&s.classList.toggle("highlight",i)}bs(t){this.ns.push(t)}ws(t){this.rs.push(t)}ai(t){this.ls.push(t)}Gi(){if(!this.view)return;const t=this.view.view.tags.ys;t&&(this.options.allowHtml?t.innerHTML=this.text:t.textContent=this.textContent);const i=this.view.view.tags.vs;i&&this.hasImage&&(i.src=this.ds,i.alt=this.text),this.targetElement&&(this.ps=this.targetElement.selected)}}class w{constructor(t){this.xs=[],this.Ts=null,this.Os=null,this.Ms=null,this.options=null,this.options=t}As(t){this.Cs=t}Ss(t){this.Hs=t}Ls(t){const i=this.Ps(t),s=i!==this.Ms;return s&&(this.Ms=i),s}Ps(t){return t.map(t=>{if("OPTGROUP"===t.tagName){const i=t,s=Array.from(i.children).map(t=>`${t.value}:${t.text}:${t.selected}`).join("\n");return`G:${i.label}:${s}`}return`O:${t.value}:${t.text}:${t.selected}`}).join("\n\n")}Is(t){this.xs=[];let i=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)i=new m(this.options,t),this.xs.push(i);else if("OPTION"===t.tagName){const s=t,e=new b(this.options,s),h=s.__parentGroup;h&&i&&h===i.targetElement?(i.es(e),e.group=i):(this.xs.push(e),i=null)}}),this.xs}replace(t){this.Ms=null,this.Is(t),this.Ts&&this.Ts.Es(this.xs),this.refresh(!1)}notify(){this.Ts&&this.refresh(!1)}load(t,i={},s={}){this.Ts=new this.Cs(this.xs),Object.assign(this.Ts,i),this.Os=new this.Hs(t),Object.assign(this.Os,s),this.Os.Fs(this.Ts)}update(t){if(!this.Ls(t))return;const i=this.xs,s=[],e=new Map,h=new Map;i.forEach(t=>{t instanceof m?e.set(t.label,t):t instanceof b&&h.set(`${t.value}::${t.textContent}`,t)});let n=null,o=0;t.forEach(t=>{if("OPTGROUP"===t.tagName){const i=t,h=e.get(i.label);h?(h.label!==i.label&&h.update(i),h.position=o,h.items=[],n=h,s.push(h),e.delete(i.label)):(n=new m(this.options,i),n.position=o,s.push(n)),o++}else if("OPTION"===t.tagName){const i=t,e=`${i.value}::${i.text}`,r=h.get(e);if(r)r.update(i),r.position=o,i.__parentGroup&&n?(n.es(r),r.group=n):(r.group=null,s.push(r)),h.delete(e);else{const t=new b(this.options,i);t.position=o,i.__parentGroup&&n?(n.es(t),t.group=n):s.push(t)}o++}});let r=!0;e.forEach(t=>{r=!1,t.remove()}),h.forEach(t=>{r=!1,t.remove()}),this.xs=s,this.Ts&&this.Ts.js(this.xs),this.onUpdated(),this.refresh(r)}onUpdated(){}ei(t){this.Ts&&(this.Ts.$s=t)}refresh(t){this.Os&&(this.Os.refresh(t),this.onUpdated())}Xt(){return{Vs:this.xs,Zt:this.Ts,kt:this.Os}}ks(t){this.Ts?.Rs(t)}_s(t){this.Ts?.Ds(t)}}class y{constructor(t=null){this.Ns=null,this.Zt=null,this.Ns=t}Bs(t){this.Ns=t}Fs(t){this.Zt=t,t.di("items",()=>{this.clear()}),t.ci("items",()=>{this.Us()}),this.Us()}clear(){this.Ns&&this.Ns.replaceChildren()}Us(){this.Zt&&this.Ns&&this.Zt.zs(this.Ns)}refresh(t){this.Us()}}class v{constructor(t=null){this.gt=null,this.node=null,this.options=null,this.Gs=null,this.Ws=null,this.qs=null,t&&this.init(t)}init(t){this.gt=e.I({Js:{tag:{node:"div",classList:["selective-ui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.gt.view,this.options=t}Ks(t){this.Gs=t,this.Ws=t.parentElement,this.Qs()}Qs(){this.Ws&&this.node&&this.Gs&&this.options&&this.Ws.insertBefore(this.node,"top"===this.options.accessoryStyle?this.Gs:this.Gs.nextSibling)}Ys(t){this.qs=t}Xs(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?(this.node.classList.remove("hide"),t.forEach(t=>{e.I({Zs:{tag:{node:"div",classList:["accessory-item"]},F:{te:{tag:{node:"span",classList:["accessory-item-button"],role:"button",ariaLabel:`${this.options.textAccessoryDeselect}${t.textContent}`,title:`${this.options.textAccessoryDeselect}${t.textContent}`,onclick:i=>{i.preventDefault(),this.qs?.ks?.("select"),setTimeout(()=>{t.selected=!1},10)}}},ie:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)})):this.node.classList.add("hide"),h.ot(window,"resize"))}}class x{constructor(t,i,s){this.se=null,this.ee=null,this.he=null,this.ne=null,this.oe={currentPage:0,totalPages:1,hasMore:!1,Ci:!1,re:"",Ai:!1},this.le=t,this.Gt=i,this.ne=s}ae(){return!!this.se}async ce(t){if(!this.se)return{Hi:!1,items:[],message:"Ajax not configured"};const i=Array.isArray(t)?t:[t];if(0===i.length)return{Hi:!0,items:[]};try{const t=this.se;let s,e;if(s="function"==typeof t.ue?t.ue(i):{values:i.join(","),de:"1",..."function"==typeof t.data?t.data.bind(this.ne.pe.find(this.ne.container.targetElement))("",0):t.data??{}},"POST"===(t.method??"GET")){const i=new URLSearchParams;Object.keys(s).forEach(t=>i.append(t,s[t]+"")),e=await fetch(t.url,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded"}})}else{const i=""+new URLSearchParams(s);e=await fetch(`${t.url}?${i}`)}if(!e.ok)throw Error("HTTP error! status: "+e.status);const h=await e.json();return{Hi:!0,items:this.ge(h).items}}catch(s){return console.error("Load by values error:",s),{Hi:!1,message:s?.message,items:[]}}}fe(t){const i=Array.from(this.le.options).map(t=>t.value);return{me:t.filter(t=>i.includes(t)),be:t.filter(t=>!i.includes(t))}}we(t){this.se=t}setPopup(t){this.he=t}Mi(){return{...this.oe}}ye(){this.oe={currentPage:0,totalPages:1,hasMore:!1,Ci:!1,re:"",Ai:this.oe.Ai}}clear(){this.oe.re="";const{Vs:t}=this.Gt.Xt(),i=[];for(const s of t)s instanceof b?i.push(s):s instanceof m&&Array.isArray(s.items)&&i.push(...s.items);i.forEach(t=>{t.visible=!0})}async search(t,i=!1){return this.se?this.ve(t,i):this.xe(t)}async Si(){return this.se?this.oe.Ci?{Hi:!1,message:"Already loading"}:this.oe.Ai?this.oe.hasMore?(this.oe.currentPage++,this.ve(this.oe.re,!0)):{Hi:!1,message:"No more data"}:{Hi:!1,message:"Pagination not enabled"}:{Hi:!1,message:"Ajax not enabled"}}async xe(t){this.Te(t)&&(this.oe.re=t);const i=((t??"")+"").toLowerCase(),s=e.J(i),{Vs:h}=this.Gt.Xt(),n=[];for(const e of h)e instanceof b?n.push(e):e instanceof m&&Array.isArray(e.items)&&n.push(...e.items);let o=!1;return n.forEach(t=>{const h=((t.textContent??t.text??"")+"").toLowerCase(),n=e.J(h),r=""===i||h.includes(i)||n.includes(s);t.visible=r,r&&(o=!0)}),{Hi:!0,Oe:o,isEmpty:0===n.length}}Te(t){return t!==this.oe.re}async ve(t,i=!1){const s=this.se;this.Te(t)&&(this.ye(),this.oe.re=t,i=!1),this.oe.Ci=!0,this.he?.si(),this.ee?.abort(),this.ee=new AbortController;const e=this.oe.currentPage,h=Array.from(this.le.selectedOptions).map(t=>t.value).join(",");let n;"function"==typeof s.data?(n=s.data.bind(this.ne.pe.find(this.ne.container.targetElement))(t,e),n&&void 0===n.selectedValue&&(n.selectedValue=h)):n={search:t,page:e,selectedValue:h,...s.data??{}};try{let t;if("POST"===(s.method??"GET")){const i=new URLSearchParams;Object.keys(n).forEach(t=>i.append(t,n[t]+"")),t=await fetch(s.url,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded"},signal:this.ee.signal})}else{const i=""+new URLSearchParams(n);t=await fetch(`${s.url}?${i}`,{signal:this.ee.signal})}const e=await t.json(),h=this.ge(e);return h.Me?(this.oe.Ai=!0,this.oe.currentPage=h.page,this.oe.totalPages=h.totalPages,this.oe.hasMore=h.hasMore):this.oe.Ai=!1,this.Ae(h.items,!!s.keepSelected,i),this.oe.Ci=!1,this.he?.ri(),{Hi:!0,Oe:h.items.length>0,isEmpty:0===h.items.length,Me:h.Me,hasMore:h.hasMore,currentPage:h.page,totalPages:h.totalPages}}catch(o){return this.oe.Ci=!1,this.he?.ri(),"AbortError"===o?.name?{Hi:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Hi:!1,message:o?.message})}}ge(t){let i=[],s=!1,e=0,h=1,n=!1;return t.object&&Array.isArray(t.object)?(i=t.object,void 0!==t.page&&(s=!0,e=parseInt(t.page??0,10),h=parseInt(t.totalPages??t.total_page??1,10),n=e<h-1)):t.data&&Array.isArray(t.data)?(i=t.data,void 0!==t.page&&(s=!0,e=parseInt(t.page??0,10),h=parseInt(t.totalPages??t.total_page??1,10),n=t.hasMore??e<h-1)):Array.isArray(t)?i=t:t.items&&Array.isArray(t.items)&&(i=t.items,t.pagination&&(s=!0,e=parseInt(t.pagination.page??0,10),h=parseInt(t.pagination.totalPages??t.pagination.total_page??1,10),n=t.pagination.hasMore??e<h-1)),{items:i.map(t=>{if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)return t;if("optgroup"===t.type||t.Ce||t.group||t.label)return{type:"optgroup",label:t.label??t.name??t.title??"",data:t.data??{},options:(t.options??t.items??[]).map(t=>({value:t.value??t.id??t.key??"",text:t.text??t.label??t.name??t.title??"",selected:t.selected??!1,data:t.data??(t.imgsrc?{imgsrc:t.imgsrc}:{})}))};const i=t.data??{};return t?.imgsrc&&(i.imgsrc=t.imgsrc),{type:"option",value:t.value??t.id??t.key??"",text:t.text??t.label??t.name??t.title??"",selected:t.selected??!1,data:i}}),Me:s,page:e,totalPages:h,hasMore:n}}Ae(t,i,s=!1){const e=this.le;let h=[];i&&(h=Array.from(e.selectedOptions).map(t=>t.value)),s||(e.innerHTML=""),t.forEach(t=>{if("option"!==t.type&&t.type||""!==t.value||""!==t.text)if(t instanceof HTMLOptionElement||t instanceof HTMLOptGroupElement)e.appendChild(t);else if("optgroup"===t.type){const s=document.createElement("optgroup");s.label=t.label,t.data&&Object.keys(t.data).forEach(i=>{s.dataset[i]=t.data[i]+""}),Array.isArray(t.options)&&t.options.forEach(t=>{const e=document.createElement("option");e.value=t.value,e.text=t.text,t.data&&Object.keys(t.data).forEach(i=>{e.dataset[i]=t.data[i]+""}),(t.selected||i&&h.includes(e.value))&&(e.selected=!0),s.appendChild(e)}),e.appendChild(s)}else{const s=document.createElement("option");s.value=t.value,s.text=t.text,t.data&&Object.keys(t.data).forEach(i=>{s.dataset[i]=t.data[i]+""}),(t.selected||i&&h.includes(s.value))&&(s.selected=!0),e.appendChild(s)}}),e.dispatchEvent(new CustomEvent("options:changed"))}}class T{constructor(t){this.Se=null,this.He=null,this.Le=50,this.le=t,this.He=this.Pe(),this.Ie=new MutationObserver(()=>{this.Se&&clearTimeout(this.Se),this.Se=setTimeout(()=>{this.Ee()},this.Le)}),t.addEventListener("options:changed",()=>{this.Se&&clearTimeout(this.Se),this.Se=setTimeout(()=>{this.Ee()},this.Le)})}Pe(){const t=Array.from(this.le.options);return{length:t.length,values:t.map(t=>t.value).join(","),Fe:t.map(t=>t.text).join(","),selected:t.map(t=>t.selected+"").join(",")}}je(){const t=this.Pe(),i=JSON.stringify(t)!==JSON.stringify(this.He);return i&&(this.He=t),i}Ee(){this.je()&&this.Ht(this.le)}connect(){this.Ie.observe(this.le,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Ht(t){}disconnect(){this.Se&&clearTimeout(this.Se),this.Se=null,this.Ie.disconnect()}}class O{constructor(t){this.Se=null,this.$e=t,this.Ie=new MutationObserver(t=>{let i=!1;for(const s of t)if("attributes"===s.type&&s.attributeName?.startsWith("data-")){i=!0;break}i&&(this.Se&&clearTimeout(this.Se),this.Se=setTimeout(()=>{this.Ht({...this.$e.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Ht({...this.$e.dataset})})}connect(){this.Ie.observe(this.$e,{attributes:!0,attributeOldValue:!0})}Ht(t){}disconnect(){this.Se&&clearTimeout(this.Se),this.Se=null,this.Ie.disconnect()}}class M{constructor(t=[]){this.items=[],this.Ve=e.m(12),this.$s=!1,this.items=t,this.ke()}ke(){}Re(t,i,s){const e=i;t.Ot?e?.update?.():e?.Us?.()}di(t,i){e.Z.on(`${t}ing_${this.Ve}`,i,{st:1})}ci(t,i){e.Z.on(`${t}_${this.Ve}`,i)}Ds(t,...i){e.Z.run(`${t}_${this.Ve}`,...i)}Rs(t,...i){e.Z.run(`${t}ing_${this.Ve}`,...i)}_e(t,i){return null}De(){return this.items.length}Ne(t){this.Rs("items",t),this.items=t,this.Ds("items",t)}Es(t){this.Ne(t)}zs(t){for(let i=0;i<this.De();i++){const s=this.items[i];let e=s.view;s.Ot||(e=this._e(t,s),s.view=e),this.Re(s,e,i),s.Ot=!0}}js(t){}}class A{constructor(t){this.parent=null,this.view=null,this.parent=t}Us(){}update(){}Wi(){if(!this.view?.view)throw Error("View is not mounted. Did you forget to set this.view?");return this.view.view}}class C extends A{constructor(){super(...arguments),this.view=null}Us(){const t=e.m(7);this.view=e.P({Be:{tag:{node:"div",classList:["selective-ui-group"],role:"group",A:`seui-${t}-header`,id:`seui-${t}-group`},F:{Ue:{tag:{node:"div",classList:["selective-ui-group-header"],role:"presentation",id:`seui-${t}-header`}},ze:{tag:{node:"div",classList:["selective-ui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view)}update(){this.Xi()}Xi(t=null){this.view&&null!==t&&(this.view.tags.Ue.textContent=t)}Ge(){if(!this.view)throw Error("GroupView is not rendered.");return this.view.tags.ze}hs(){if(!this.view)return;const t=Array.from(this.view.tags.ze.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",!(t.length>0))}Zi(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags.Ue.setAttribute("aria-expanded",t?"false":"true"))}}class S extends A{constructor(t){super(t),this.view=null,this.We=null,this.qe=null,this.Je=!1,this.Ke()}Ke(){const t=this;this.We={isMultiple:!1,hasImage:!1,imagePosition:"right",imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",labelValign:"center",labelHalign:"left"},this.qe=new Proxy(this.We,{set(i,s,e){if("string"!=typeof s)return!0;const h=s,n=i[h];return n!==e&&(i[h]=e,t.Je&&t.Qe(h,e,n)),!0}})}get isMultiple(){return this.We.isMultiple}set isMultiple(t){this.qe.isMultiple=!!t}get hasImage(){return this.We.hasImage}set hasImage(t){this.qe.hasImage=!!t}get Ye(){return this.qe}set Ye(t){if(!t||!this.qe||!this.We)return;const i={};void 0!==t.imageWidth&&t.imageWidth!==this.We.imageWidth&&(i.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this.We.imageHeight&&(i.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this.We.imageBorderRadius&&(i.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this.We.imagePosition&&(i.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this.We.labelValign&&(i.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this.We.labelHalign&&(i.labelHalign=t.labelHalign),Object.keys(i).length>0&&Object.assign(this.qe,i)}Us(){const t=["selective-ui-option-view"],i=e.m(7),s="option_"+i;this.We.isMultiple&&t.push("multiple"),this.We.hasImage&&(t.push("has-image"),t.push("image-"+this.We.imagePosition));const h={gs:{tag:{node:"input",type:this.We.isMultiple?"checkbox":"radio",classList:"allow-choice",id:s}},...this.We.hasImage&&{vs:{tag:{node:"img",classList:"option-image",style:{width:this.We.imageWidth,height:this.We.imageHeight,borderRadius:this.We.imageBorderRadius}}}},Xe:{tag:{node:"label",htmlFor:s,classList:["align-vertical-"+this.We.labelValign,"align-horizontal-"+this.We.labelHalign]},F:{ys:{tag:{node:"div"}}}}};this.view=e.P({Ze:{tag:{node:"div",id:`seui-${i}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},F:h}}),this.parent.appendChild(this.view.view),this.Je=!0}Qe(t,i,s){const e=this.view;if(!e||!e.view)return;const h=e.view,n=e.tags?.gs,o=e.tags?.Xe;switch(t){case"isMultiple":{const t=!!i;h.classList.toggle("multiple",t),n&&n.type!==(t?"checkbox":"radio")&&(n.type=t?"checkbox":"radio");break}case"hasImage":{const t=!!i;if(h.classList.toggle("has-image",t),t)h.classList.add("image-"+this.We.imagePosition),this.th();else{h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.vs;t&&(t.remove(),e.tags.vs=null)}break}case"imagePosition":this.We.hasImage&&(h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim(),h.classList.add("image-"+i));break;case"imageWidth":case"imageHeight":case"imageBorderRadius":{const s=e.tags?.vs;if(s){const e="imageWidth"===t?"width":"imageHeight"===t?"height":"borderRadius",h=i+"";s.style[e]!==h&&(s.style[e]=h)}break}case"labelValign":case"labelHalign":if(o){const t=`align-vertical-${this.We.labelValign} align-horizontal-${this.We.labelHalign}`;o.className!==t&&(o.className=t)}}}th(){const t=this.view;if(!t||!t.view)return;const i=t.tags?.vs;if(i)return;const s=t.view,e=t.tags?.Xe,h=document.createElement("img");h.className="option-image",h.style.width=this.We.imageWidth,h.style.height=this.We.imageHeight,h.style.borderRadius=this.We.imageBorderRadius,e&&e.parentElement?s.insertBefore(h,e):s.appendChild(h),t.tags.vs=h}}class H extends M{constructor(t=[]){super(t),this.isMultiple=!1,this.ih=[],this.sh=-1,this.eh=null,this.groups=[],this.hh=[],this.nh()}nh(){this.hh=[],this.groups=[],this.items.forEach(t=>{t instanceof m?(this.groups.push(t),this.hh.push(...t.items)):t instanceof b&&this.hh.push(t)})}_e(t,i){return i instanceof m?new C(t):new S(t)}Re(t,i,s){t.position=s,t instanceof m?this.oh(t,i,s):t instanceof b&&this.rh(t,i,s),t.Ot=!0}oh(t,i,s){super.Re(t,i,s),t.view=i;const e=i.view.tags.Ue;e.textContent=t.label,t.Ot||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.ss()}),t.ts((t,i,s)=>{i.items.forEach(t=>{const i=t.view?.Wi?.();i&&(i.style.display=s?"none":"")}),this.ah(i,s)}));const h=i.Ge();t.items.forEach((t,i)=>{let s=t.view;t.Ot&&s||(s=new S(h)),this.rh(t,s,i),t.Ot=!0}),i.Zi(t.collapsed),i.hs()}rh(t,i,s){if(i.isMultiple=this.isMultiple,i.hasImage=t.hasImage,i.Ye={imageWidth:t.options.imageWidth,imageHeight:t.options.imageHeight,imageBorderRadius:t.options.imageBorderRadius,imagePosition:t.options.imagePosition,labelValign:t.options.labelValign,labelHalign:t.options.labelHalign},t.Ot||super.Re(t,i,s),t.view=i,t.hasImage){const s=i.view.tags.vs;s&&(s.src!==t.ds&&(s.src=t.ds),s.alt!==t.text&&(s.alt=t.text))}i.view.tags.ys.innerHTML=t.text,t.Ot||(i.view.tags.Ze.addEventListener("click",i=>{i.stopPropagation(),i.preventDefault(),this.$s||(this.isMultiple?(this.Rs("select"),setTimeout(()=>{t.selected=!t.selected},5)):!0!==t.selected&&(this.Rs("select"),setTimeout(()=>{this.eh&&(this.eh.selected=!1),t.selected=!0},5)))}),i.view.tags.Ze.title=t.textContent,i.view.tags.Ze.addEventListener("mouseenter",()=>{this.$s||this.uh(this.hh.indexOf(t),!1)}),t.bs(()=>{this.Ds("selected")}),t.ws((i,s,e)=>{e&&(this.eh=t),this.Ds("selected_internal")}),t.ai((t,i)=>{i.group?.hs(),this.dh()})),t.selected&&(this.eh=t,t.ps=!0)}Ne(t){this.Rs("items",t),this.items=t,this.nh(),this.Ds("items",t)}Es(t){this.Ne(t)}js(t){this.items=t,this.nh()}ph(){return this.hh.filter(t=>t.selected)}gh(){return this.hh.find(t=>t.selected)}ti(t){this.isMultiple&&this.hh.forEach(i=>{i.selected=t})}ai(t){this.ih.push(t)}dh(){const t=this.hh.filter(t=>t.visible).length,i=this.hh.length;this.ih.forEach(s=>{s({fh:t,mh:i,hi:t>0,isEmpty:0===i})})}ni(){const t=this.hh.filter(t=>t.visible).length,i=this.hh.length;return{fh:t,mh:i,hi:t>0,isEmpty:0===i}}bh(){this.uh(0)}navigate(t,i=!0){const s=this.hh.filter(t=>t.visible);if(0===s.length)return;let e=s.findIndex(t=>t===this.hh[this.sh]);-1===e&&(e=-1);let h=e+t;h>=s.length&&(h=0),h<0&&(h=s.length-1);const n=this.hh.indexOf(s[h]);this.uh(n,i)}wh(){if(this.sh>-1&&this.hh[this.sh]){const t=this.hh[this.sh];if(t.visible){const i=t.view?.Wi?.();i&&i.click()}}}uh(t,i=!0){let s=0;if("number"==typeof t)s=t;else if(t instanceof b){const i=this.hh.indexOf(t);s=i>-1?i:0}else s=0;this.sh>-1&&this.hh[this.sh]&&(this.hh[this.sh].fs=!1);for(let e=s;e<this.hh.length;e++){const t=this.hh[e];if(t?.visible){if(t.fs=!0,this.sh=e,i){const i=t.view?.Wi?.();i?i.scrollIntoView({block:"center",behavior:"smooth"}):this.kt?.yh?.(e,{scrollIntoView:!0})}return void this.xh(e,t.view?.Wi?.()?.id)}}}xh(t,i){}ah(t,i){}}class L{constructor(t=0){this.Th=[],this.n=0,this.reset(t)}reset(t){this.n=t,this.Th=Array(t+1).fill(0)}add(t,i){for(let s=t;s<=this.n;s+=s&-s)this.Th[s]+=i}Oh(t){let i=0;for(let s=t;s>0;s-=s&-s)i+=this.Th[s];return i}Mh(t,i){return i<t?0:this.Oh(i)-this.Oh(t-1)}Ah(t){this.reset(t.length),t.forEach((t,i)=>this.add(i+1,t))}Ch(t){let i=0,s=1;for(;s<<1<=this.n;)s<<=1;let e=0;for(let h=s;0!==h;h>>=1){const s=i+h;s<=this.n&&e+this.Th[s]<=t&&(i=s,e+=this.Th[s])}return i}}class P extends y{constructor(t=null){super(t),this.Sh={Yt:void 0,Bt:36,Ut:8,zt:!0,Hh:!0},this.Lh=[],this.Ph=new L(0),this.Ih=new Map,this.Eh=!1,this.start=0,this.end=-1,this.Fh=null,this.jh=null,this.$h=!1,this.Vh=!1,this.kh=0,this.Rh=!1,this._h=!1,this.Dh=0,this.Nh=0,this.Bh=0,this.Uh=0}configure(t){this.Sh={...this.Sh,...t}}Fs(t){if(this.Zt&&this.dispose(),super.Fs(t),t.kt=this,!this.Ns)return;this.Ns.replaceChildren();const i=e.I({zh:{tag:{node:"div",classList:"selective-ui-virtual-pad-top"}},Gh:{tag:{node:"div",classList:"selective-ui-virtual-items"}},Wh:{tag:{node:"div",classList:"selective-ui-virtual-pad-bottom"}}},this.Ns);if(this.zh=i.zh,this.Gh=i.Gh,this.Wh=i.Wh,this.Yt=this.Sh.Yt??this.Ns.closest(".selective-ui-popup")??this.Ns.parentElement,!this.Yt)throw Error("VirtualRecyclerView: scrollEl not found");this.qh=this.Jh.bind(this),this.Yt.addEventListener("scroll",this.qh,{passive:!0}),this.refresh(!1),this.Kh(),t?.ai?.(()=>this.Qh())}suspend(){this.Rh=!0,this.Yh(),this.Yt&&this.qh&&this.Yt.removeEventListener("scroll",this.qh),this.Xh&&(this.Xh.disconnect(),this._h=!0)}resume(){this.Rh=!1,this.Yt&&this.qh&&this.Yt.addEventListener("scroll",this.qh,{passive:!0}),this._h&&(this.Kh(),this._h=!1),this.Zh()}refresh(t){if(!this.Zt||!this.Ns)return;t||this.Qh();const i=this.Zt.De();this.kh=i,0!==i?(this.Lh.length=i,this.Eh||(this.tn(),this.Eh=!0),this.sn(i),this.Zh()):this.en()}yh(t,i){this.hn(t,t),i?.scrollIntoView&&this.nn(t)}nn(t){if((this.Zt?.De?.()??0)<=0)return;const i=this.rn(t),s=this.ln()+i,e=Math.max(0,this.Yt.scrollHeight-this.Yt.clientHeight);this.Yt.scrollTop=Math.min(Math.max(0,s),e)}dispose(){this.Yh(),this.Yt&&this.qh&&this.Yt.removeEventListener("scroll",this.qh),this.Xh?.disconnect(),this.Ih.forEach(t=>t.remove()),this.Ih.clear()}Qh(){if(!this.Zt)return;const t=this.Zt.De();t<=0||(this.suspend(),this.en(),this.an(),this.cn(t),this.sn(t),this.start=0,this.end=-1,this.resume())}Yh(){null!=this.Fh&&(cancelAnimationFrame(this.Fh),this.Fh=null),null!=this.jh&&(cancelAnimationFrame(this.jh),this.jh=null)}en(){this.Ih.forEach(t=>t.remove()),this.Ih.clear(),this.Lh=[],this.Ph.reset(0),this.zh.style.height="0px",this.Wh.style.height="0px",this.Eh=!1,this.Bh=0,this.Uh=0}tn(){this.un(0);const t=this.Ih.get(0);if(!t)return;const i=this.dn(t);if(isNaN(i)||(this.Sh.Bt=i),!this.Sh.zt){t.remove(),this.Ih.delete(0);const i=this.Zt.items[0];i&&(i.Ot=!1,i.view=null)}}pn(t){const i=this.Zt?.items?.[t];return i?.visible??!0}gn(t,i){for(let s=Math.max(0,t);s<i;s++)if(this.pn(s))return s;return-1}cn(t){this.Bh=0,this.Uh=0;for(let i=0;i<t;i++){if(!this.pn(i))continue;const t=this.Lh[i];null!=t&&(this.Bh+=t,this.Uh++)}}ln(){const t=this.Ns.getBoundingClientRect(),i=this.Yt.getBoundingClientRect();return t.top-i.top+this.Yt.scrollTop}fn(){const t=performance.now();if(t-this.Dh<16)return this.Nh;const i=this.Yt.querySelector(".selective-ui-option-handle:not(.hide)");return this.Nh=i?.offsetHeight??0,this.Dh=t,this.Nh}Zh(){null!=this.Fh||this.Rh||(this.Fh=requestAnimationFrame(()=>{this.Fh=null,this.mn()}))}dn(t){const i=t.getBoundingClientRect(),s=getComputedStyle(t);return Math.max(1,i.height+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}bn(){return this.Sh.Hh&&this.Uh>0?Math.max(1,this.Bh/this.Uh):this.Sh.Bt}sn(t){const i=this.bn(),s=Array.from({length:t},(t,s)=>this.pn(s)?this.Lh[s]??i:0);this.Ph.Ah(s)}wn(t,i){if(!this.pn(t))return!1;const s=this.bn(),e=this.Lh[t]??s;if(Math.abs(i-e)<=P.yn)return!1;const h=this.Lh[t];return null==h?(this.Bh+=i,this.Uh++):this.Bh+=i-h,this.Lh[t]=i,this.Ph.add(t+1,i-e),!0}vn(t,i){const s=this.Ph.Ch(Math.max(0,t)),e=Math.min(i-1,s),h=this.gn(e,i);return-1===h?Math.max(0,e):h}xn(t,i){i.setAttribute(P.Tn,t+"");const s=this.Ih.get(t-1);if(s?.parentElement===this.Gh)return void s.after(i);const e=this.Ih.get(t+1);if(e?.parentElement===this.Gh)return void this.Gh.insertBefore(i,e);const h=Array.from(this.Gh.children);for(const n of h){const s=n.getAttribute(P.Tn);if(s&&+s>t)return void this.Gh.insertBefore(i,n)}this.Gh.appendChild(i)}On(t,i){if(i.parentElement!==this.Gh)return void this.xn(t,i);i.setAttribute(P.Tn,t+"");const s=i.previousElementSibling,e=i.nextElementSibling;(s&&+s.getAttribute(P.Tn)>t||e&&+e.getAttribute(P.Tn)<t)&&(i.remove(),this.xn(t,i))}Kh(){this.Xh||(this.Xh=new ResizeObserver(()=>{this.Vh||this.Rh||!this.Zt||null!=this.jh||(this.jh=requestAnimationFrame(()=>{this.jh=null,this.Mn()}))}),this.Xh.observe(this.Gh))}Mn(){if(!this.Zt)return;const t=this.Zt.De();if(t<=0)return;let i=!1;for(let s=this.start;s<=this.end;s++){if(!this.pn(s))continue;const t=this.Zt.items[s],e=t?.view?.Wi?.();if(!e)continue;const h=this.dn(e);this.wn(s,h)&&(i=!0)}i&&(this.Sh.Hh&&this.sn(t),this.Zh())}Jh(){this.Zh()}mn(){if(!this.$h&&!this.Rh){this.$h=!0;try{if(!this.Zt)return;const t=this.Zt.De();if(t<=0)return;this.kh!==t&&(this.kh=t,this.Lh.length=t,this.sn(t));const i=this.ln(),s=Math.max(0,this.Yt.scrollTop-i),e=this.fn(),h=Math.max(0,this.Yt.clientHeight-e),n=this.vn(s,t),o=i+this.rn(n)-this.Yt.scrollTop,r=this.vn(s,t);if(-1===r)return void this.en();const l=this.bn(),a=this.Sh.Ut*l;let c=this.gn(Math.min(t-1,this.Ph.Ch(Math.max(0,s-a))),t)??r,u=Math.min(t-1,this.Ph.Ch(s+h+a));if(c===this.start&&u===this.end)return;this.start=c,this.end=u,this.Vh=!0;try{this.hn(this.start,this.end),this.An(this.start,this.end),this.Sh.zt&&this.Mn();const i=this.rn(this.start),s=this.Cn(this.start,this.end),e=this.Sn(t),h=Math.max(0,e-i-s);this.zh.style.height=i+"px",this.Wh.style.height=h+"px"}finally{this.Vh=!1}const d=this.rn(n),p=this.ln()+d-o,g=Math.max(0,this.Yt.scrollHeight-this.Yt.clientHeight),f=Math.min(Math.max(0,p),g);Math.abs(this.Yt.scrollTop-f)>.5&&(this.Yt.scrollTop=f)}finally{this.$h=!1}}}hn(t,i){for(let s=t;s<=i;s++)this.un(s)}un(t){if(!this.pn(t)){const i=this.Ih.get(t);return i?.parentElement===this.Gh&&i.remove(),void this.Ih.delete(t)}const i=this.Zt.items[t],s=this.Ih.get(t);if(s)return void(i?.view?(this.On(t,s),this.Zt.Re(i,i.view,t)):(s.remove(),this.Ih.delete(t)));if(i.Ot)i.view&&this.Zt.Re(i,i.view,t);else{const s=this.Zt._e(this.Gh,i);i.view=s,this.Zt.Re(i,s,t),i.Ot=!0}const e=i.view?.Wi?.();e&&(this.On(t,e),this.Ih.set(t,e))}An(t,i){this.Ih.forEach((s,e)=>{(e<t||e>i)&&(s.parentElement===this.Gh&&s.remove(),this.Ih.delete(e))})}an(){this.Ih.forEach((t,i)=>{this.pn(i)||(t.parentElement===this.Gh&&t.remove(),this.Ih.delete(i))})}rn(t){return this.Ph.Oh(t)}Cn(t,i){return this.Ph.Mh(t+1,i+1)}Sn(t){return this.Ph.Oh(t)}}P.yn=.5,P.Tn="data-vindex";class I{constructor(t=null,i=null){this.container={},this.oldValue=null,this.node=null,this.options=null,this.Hn=null,this.isOpen=!1,this.Ln=!1,this.Pn=!1,this.pe=null,t&&this.init(t,i)}get isDisabled(){return!!this.options?.disabled}set isDisabled(t){this.options&&this.node&&(this.options.disabled=t,this.node.classList.toggle("disabled",t),this.node.setAttribute("aria-disabled",t+""),this.container.tags?.Ti?.setAttribute("aria-disabled",t+""))}get In(){return!!this.options?.readonly}set In(t){this.options&&this.node&&(this.options.readonly=t,this.node.classList.toggle("readonly",t))}get isVisible(){return!!this.options?.visible}set isVisible(t){this.options&&this.node&&(this.options.visible=t,this.node.classList.toggle("invisible",!t))}init(t,s){const h=e.R(t).options,l=new o(h),a=new r,c=new p(h),effector=i(),u=new w(h),g=new v(h),f=new x(t,u,this),m=new T(t),b=new O(t);this.pe=s,this.options=h,l.node&&(l.node.id=(h.En??"")+"");const M=e.I({Fn:{tag:{node:"div",classList:"selective-ui-MAIN"},F:{Ti:{tag:{node:"div",classList:"selective-ui-view",tabIndex:0,onkeydown:t=>{"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.jn()?.open())}},F:{$n:{tag:l.node},Vn:{tag:a.node},ki:{tag:c.node}}}}}},null);this.container=M,this.node=M.view,t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,M.tags.Ti),g.Ks(M.tags.Ti),g.Ys(u),M.tags.Ti.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),n.lt(t,M.tags.Ti),t.classList.add("init"),u.As(H),u.Ss(h.virtualScroll?P:y),u.Is(e.K(t)),u.onUpdated=()=>{M.kn?.oi?.()},this.Hn=u,M.Rn=f,M.placeholder=l,M._n=a,M.Dn=c,M.effector=effector,M.targetElement=t,M.Nn=g,M.Bn=m,M.Un=b,M.kn=new d(t,h,u),M.kn.gi(effector),M.kn.Oi(f,h),M.kn.pi("selected",()=>{this.jn()?.change(null,!0)}),M.kn.pi("selected_internal",()=>{this.jn()?.change(null,!1)}),M.kn.ui("select",()=>{this.oldValue=this.jn()?.value??""}),this.jn()?.change(null,!1),m.connect(),m.Ht=t=>{u.update(e.K(t)),this.jn()?.refreshMask()},b.connect(),b.Ht=t=>{e.V(t.disabled)!==this.isDisabled&&(this.isDisabled=e.V(t.disabled)),e.V(t.readonly)!==this.In&&(this.In=e.V(t.readonly)),e.V(t.visible)!==this.isVisible&&(this.isVisible=e.V(t.visible??"1"))},t.addEventListener("options:changed",()=>{u.update(e.K(t)),this.jn()?.refreshMask(),M.kn?.oi?.()}),h.ajax&&f.we(h.ajax);const A=M.kn.Pt,C=(t,i)=>{i||""!==t?(""!==t&&(this.Pn=!0),f.search(t).then(t=>{M.kn?.oi?.(),t?.Oe&&setTimeout(()=>{M.kn?.oi?.(),A.bh()},h.animationtime?h.animationtime+10:0)}).catch(t=>{console.error("Search error:",t)})):f.clear()};let S=null;c.Fi=(t,i)=>{f.Te(t)&&(f.ae()?(S&&clearTimeout(S),M.kn?.si?.(),S=setTimeout(()=>{C(t,i)},h.delaysearchtime??0)):C(t,i))},f.setPopup(M.kn),c.ji=t=>{A.navigate(t)},c.$i=()=>{A.wh()},c.Vi=()=>{this.jn()?.close(),M.tags.Ti.focus()},A.xh=(t,i)=>{i&&c._i(i)},A.ah=()=>{M.kn?.oi?.()},this.isDisabled=e.V(h.disabled),this.In=e.V(h.readonly)}zn(){const t=this.container??{},{Bn:i,Un:s}=t;i?.disconnect&&i.disconnect(),s?.disconnect&&s.disconnect()}jn(){const t=this.container,i=this,s=()=>this.pe.find(t.targetElement),n=e.R(t.targetElement);if(!n)return null;const o=n.options,r={get targetElement(){return t.targetElement},get placeholder(){return t.placeholder.get()},set placeholder(i){t.placeholder?.set(i),t.Dn?.Ri(i)},get oldValue(){return i.oldValue},set value(t){this.setValue(null,t,!0)},get value(){const t=this.valueArray,i=t.length;return i>1?t:0===i?"":t[0]},get valueArray(){const t=[];return i.Gn().forEach(i=>{i.selected&&t.push(i.value)}),t},get valueString(){return this.valueArray.join(o.customDelimiter)},get valueOptions(){const t=[];return i.Gn(!0).forEach(i=>{t.push(i)}),t},get mask(){const t=[];return i.Gn(!0).forEach(i=>{t.push(i.text)}),t},get valueText(){const t=[];i.Gn(!0).forEach(i=>{t.push(i.text)});const s=t.length;return s>1?t:0===s?"":t[0]},get isOpen(){return i.isOpen},getParent:()=>t.view.parentElement,valueDataset(t,s=null,e=!1){var h=[];if(i.Gn(!0).forEach(t=>{h.push(s?t.dataset[s]:t.dataset)}),!e){if(0==h.length)return"";if(1==h.length)return h[0]}return h},selectAll(t,e=!0){if(!(o.multiple&&o.maxSelected>0&&i.Gn().length>o.maxSelected)&&!this.disabled&&!this.readonly&&o.multiple){if(e){if(h.nt([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Gn().forEach(t=>{t.ps=!0}),this.change(!1,e)}},deSelectAll(t,e=!0){if(!this.disabled&&!this.readonly&&o.multiple){if(e){if(h.nt([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Gn().forEach(t=>{t.ps=!1}),this.change(!1,e)}},setValue(e=null,n,r=!0,l=!1){if(Array.isArray(n)||(n=[n]),0===(n=n.filter(t=>""!==t&&null!=t)).length)return i.Gn().forEach(t=>t.ps=!1),void this.change(!1,r);if(o.multiple&&o.maxSelected>0&&n.length>o.maxSelected)console.warn(`Cannot select more than ${o.maxSelected} items`);else if(l||!this.disabled&&!this.readonly){if(t.Rn?.ae?.()){const{be:s}=t.Rn.fe(n);if(s.length>0)return void(async()=>{o.loadingfield&&t.kn?.si?.();try{t.Rn.ye();const e=await t.Rn.ce(s);e.Hi&&e.items.length>0?(e.items.forEach(t=>{s.includes(t.value)&&(t.selected=!0)}),t.Rn.Ae?.(e.items,!0,!0),setTimeout(()=>{i.Gn().forEach(t=>{t.ps=n.some(i=>i==t.value)}),this.change(!1,!1)},100)):s.length>0&&console.warn(`Could not load ${s.length} values:`,s)}catch(e){console.error("Error loading missing values:",e)}finally{o.loadingfield&&t.kn?.ri?.()}})()}if(r){if(h.nt([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Gn().forEach(t=>{t.ps=n.some(i=>i==t.value)}),!o.multiple&&n.length>0&&(t.targetElement.value=n[0]),this.change(!1,r)}},open(){if(i.isOpen)return;const e=i.pe?.find?.();if(e&&!e.isEmpty&&e.close().isCancel)return;if(this.disabled)return;if(h.nt([s()],...o.on.beforeShow).isCancel)return;i.isOpen=!0,t._n.dt(!0);const n=t.kn.Pt,r=n.gh();r?n.uh(r,!1):n.bh(),i.Ln&&!i.Pn||!o?.ajax?t.kn.open(null,!0):(t.Rn.ye(),t.kn.si(),i.Ln=!0,i.Pn=!1,setTimeout(()=>{t.kn&&t.Rn&&t.Rn.search("").then(()=>t.kn?.oi?.()).catch(t=>console.error("Initial ajax load error:",t))},o.animationtime),t.kn.open(null,!1)),t.Dn.show();const l=t.tags.Ti;l.setAttribute("aria-expanded","true"),l.setAttribute("aria-controls",o.Jt),l.setAttribute("aria-haspopup","listbox"),l.setAttribute("aria-labelledby",o.En),o.multiple&&l.setAttribute("aria-multiselectable","true"),h.nt([s()],...o.on.show)},close(){i.isOpen&&(h.nt([s()],...o.on.beforeClose).isCancel||(i.isOpen=!1,t._n.dt(!1),t.kn.close(()=>{t.Dn.clear(!1)}),t.Dn.hide(),t.tags.Ti.setAttribute("aria-expanded","false"),h.nt([s()],...o.on.close)))},toggle(){i.isOpen?this.close():this.open()},change(e=null,n=!0){if(n){if(o.multiple&&o.maxSelected>0&&this.valueArray.length>o.maxSelected&&this.setValue(null,this.oldValue,!1,!0),this.disabled||this.readonly)return void this.setValue(null,this.oldValue,!1,!0);if(h.nt([s(),this.value],...o.on.beforeChange).isCancel)return void this.setValue(null,this.oldValue,!1)}this.refreshMask(),t.Nn.Xs(this.valueOptions),n&&(t.targetElement&&h.ot(t.targetElement,"change"),h.nt([s(),this.value],...o.on.change),i.options?.autoclose&&this.close())},refreshMask(){let s=o.placeholder;!o.multiple&&i.Gn().length>0&&(s=this.mask[0]),s??(s=o.placeholder),t.placeholder.set(s,!1),t.Dn.Ri(s)},on(t,i,s){o.on[i]||(o.on[i]=[]),o.on[i].push(s)},ajax(i,s){t.Rn.we(s)},loadAjax:()=>new Promise((e,h)=>{t.kn.si(),t.Rn.ye(),i.Ln=!0,i.Pn=!1,t.kn&&t.Rn?t.Rn.search("").then(()=>{t.kn?.oi?.(),e(s())}).catch(t=>{console.error("Initial ajax load error:",t),h(t)}):e(s())})};return this.Wn(r,"disabled","isDisabled"),this.Wn(r,"readonly","isReadOnly"),this.Wn(r,"visible","isVisible"),r}Wn(t,i,s){const e=this;Object.defineProperty(t,i,{get:()=>e[s],set(t){e[s]=!!t,e.container?.targetElement?.dataset&&(e.container.targetElement.dataset[i]=!!t+"")},enumerable:!0,configurable:!0})}Gn(t=null){if(!this.Hn)return[];const{Vs:i}=this.Hn.Xt(),s=[];for(const e of i)e instanceof b?s.push(e):e instanceof m&&Array.isArray(e.items)&&e.items.length&&s.push(...e.items);return"boolean"==typeof t?s.filter(i=>i.selected===t):s}Li(){this.container.kn.Li()}}class E{constructor(){this.qn=!1,this.Ie=null,this.Jn=[]}Kn(t){this.Jn.push(t)}Qn(){this.Jn=[]}start(t){if(this.qn)return;this.qn=!0;const i=t.toUpperCase(),s=t.toLowerCase();this.Ie=new MutationObserver(t=>{for(const e of t)e.addedNodes.forEach(t=>{if(1!==t.nodeType)return;const e=t;e.tagName===i&&this.Yn(e),e.querySelectorAll(s).forEach(t=>this.Yn(t))})}),this.Ie.observe(document.body,{childList:!0,subtree:!0})}stop(){this.qn&&(this.qn=!1,this.Ie?.disconnect(),this.Ie=null)}Yn(t){this.Jn.forEach(i=>i(t))}}class F{constructor(){this.Xn=new Map}bind(t,i){const s=e.$(e.U(),i);s.on=s.on??{},s.on.load=s.on.load??[],this.Xn.set(t,s);const n=e.m();e.Z.on(n,()=>{h.nt([this.find(t)],...s.on.load),e.Z.clear(n),s.on.load=[]}),e.v(t).forEach(t=>{(async()=>{"SELECT"===t.tagName&&(e.D(t),this.Zn(t,s)&&e.Z.run(n))})()}),e.G().includes(t)||e.G().push(t)}find(t="*"){const i={isEmpty:!0};if("*"===t&&""===(t=e.G().join(", ")))return i;const s=e.v(t);if(0===s.length)return i;const h=e.R(s[0]);if(!h||!h.action)return i;const n={};for(const e in h.action)n[e]=this.io(e,h.action);const o={isEmpty:!1};for(const e in n){const t=n[e];switch(t.type){case"get-set":this.so(o,t.name,s);break;case"func":this.eo(o,t.name,s)}}return o}ho(){this.no=new E,this.no.Kn(t=>{this.Xn.forEach((i,s)=>{try{t.matches(s)&&this.Zn(t,i)}catch(e){console.warn("Invalid selector: "+s,e)}})}),this.no.start("select")}destroy(t=null){null===t?this.oo():"string"==typeof t?this.ro(t):t instanceof HTMLSelectElement&&this.lo(t)}oo(){e.G().forEach(t=>this.ro(t)),this.Xn.clear(),e.G().length=0,this.no?.stop()}ro(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.lo(t)}),this.Xn.delete(t);const i=e.G(),s=i.indexOf(t);s>-1&&i.splice(s,1)}lo(t){const i=e.R(t);if(!i)return;const s=i.container?.kn;s?.Li(),e.B(t,i);const h=!!this.no;h&&this.no?.stop();try{i.self?.zn?.()}catch(o){}const n=i.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.ao,n&&n.parentNode?n.parentNode.replaceChild(t,n):document.body.appendChild(t),e.k(t),h&&this.Xn.size>0&&this.no?.start("select")}rebind(t,i){this.ro(t),this.bind(t,i)}Zn(t,i){if(e.R(t)||e.N(t))return!1;const s=e.m(8),h=e.j(t,i);h.co=s,h.Jt=`seui-${s}-optionlist`,h.En=`seui-${s}-placeholder`;const n={options:h};e._(t,n);const o=new I(t,this);return n.container=o.container,n.action=o.jn(),n.self=o,o.container.view.addEventListener("mouseup",()=>{n.action?.toggle?.()}),!0}io(t,i){const s=Object.getOwnPropertyDescriptor(i,t);let e="variable";return s?.get||s?.set&&"function"!=typeof i[t]?e="get-set":"function"==typeof i[t]&&(e="func"),{type:e,name:t}}so(t,i,s){Object.defineProperty(t,i,{get(){const t=e.R(s[0]);return t.action?.[i]},set(t){s.forEach(s=>{const h=e.R(s);h?.action&&(h.action[i]=t)})},enumerable:!0,configurable:!0})}eo(t,i,s){t[i]=(...n)=>{let o=null;for(let t=0;t<s.length;t++){const r=e.R(s[t]);if(!r?.action)continue;const l=h.ht();if(o??(o=r.action[i](l.et,...n)),!l.token.isContinue)break}return o??t}}}if(void 0===globalThis.GLOBAL_SEUI){const $=new F;globalThis.GLOBAL_SEUI={version:"1.2.0",name:"SelectiveUI",bind:$.bind.bind($),find:$.find.bind($),destroy:$.destroy.bind($),effector:i.bind(i),rebind:$.rebind.bind($)};let V=!1;function k(){V||(V=!0,document.addEventListener("mousedown",()=>{const t=e.G();if(t.length>0){const i=$.find(t.join(", "));i.isEmpty||i.close()}}),$.ho())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",k):k()),console.log("[SelectiveUI] v1.2.0 loaded successfully")}else console.warn(`[${globalThis.GLOBAL_SEUI.name}] Already loaded (v${globalThis.GLOBAL_SEUI.version}). Using existing instance. Please remove duplicate <script> tags.`);const version=globalThis.GLOBAL_SEUI.version,j=globalThis.GLOBAL_SEUI.name;t.bind=(t,i={})=>{globalThis.GLOBAL_SEUI.bind(t,i)},t.destroy=(t=null)=>{globalThis.GLOBAL_SEUI.destroy(t)},t.effector=t=>globalThis.GLOBAL_SEUI.effector(t),t.find=t=>globalThis.GLOBAL_SEUI.find(t),t.name=j,t.rebind=(t,i={})=>{globalThis.GLOBAL_SEUI.rebind(t,i)},t.version=version},"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).SelectiveUI={});
Binary file