selective-ui 1.2.2 → 1.2.4
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.
- package/dist/selective-ui.css.map +1 -1
- package/dist/selective-ui.esm.js +2178 -695
- package/dist/selective-ui.esm.js.map +1 -1
- package/dist/selective-ui.esm.min.js +2 -2
- package/dist/selective-ui.esm.min.js.br +0 -0
- package/dist/selective-ui.min.js +2 -2
- package/dist/selective-ui.min.js.br +0 -0
- package/dist/selective-ui.umd.js +2179 -696
- package/dist/selective-ui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/ts/adapter/mixed-adapter.ts +167 -80
- package/src/ts/components/accessorybox.ts +155 -34
- package/src/ts/components/directive.ts +62 -11
- package/src/ts/components/option-handle.ts +124 -28
- package/src/ts/components/placeholder.ts +73 -16
- package/src/ts/components/popup/empty-state.ts +126 -0
- package/src/ts/components/popup/loading-state.ts +120 -0
- package/src/ts/components/{popup.ts → popup/popup.ts} +169 -72
- package/src/ts/components/searchbox.ts +82 -16
- package/src/ts/components/selectbox.ts +207 -115
- package/src/ts/core/base/adapter.ts +121 -55
- package/src/ts/core/base/lifecycle.ts +175 -0
- package/src/ts/core/base/model.ts +63 -32
- package/src/ts/core/base/recyclerview.ts +56 -18
- package/src/ts/core/base/view.ts +56 -19
- package/src/ts/core/base/virtual-recyclerview.ts +322 -128
- package/src/ts/core/model-manager.ts +18 -11
- package/src/ts/core/search-controller.ts +148 -25
- package/src/ts/global.ts +5 -5
- package/src/ts/index.ts +5 -5
- package/src/ts/models/group-model.ts +27 -6
- package/src/ts/models/option-model.ts +29 -6
- package/src/ts/services/ea-observer.ts +6 -6
- package/src/ts/services/effector.ts +2 -2
- package/src/ts/services/select-observer.ts +1 -8
- package/src/ts/types/components/searchbox.type.ts +1 -1
- package/src/ts/types/core/base/adapter.type.ts +2 -1
- package/src/ts/types/core/base/lifecycle.type.ts +62 -0
- package/src/ts/types/core/base/model.type.ts +3 -1
- package/src/ts/types/core/base/recyclerview.type.ts +2 -8
- package/src/ts/types/core/base/view.type.ts +36 -24
- package/src/ts/utils/callback-scheduler.ts +38 -18
- package/src/ts/utils/istorage.ts +1 -1
- package/src/ts/utils/selective.ts +153 -36
- package/src/ts/views/group-view.ts +59 -21
- package/src/ts/views/option-view.ts +137 -68
- package/src/ts/components/empty-state.ts +0 -68
- package/src/ts/components/loading-state.ts +0 -66
- /package/src/css/components/{empty-state.css → popup/empty-state.css} +0 -0
- /package/src/css/components/{loading-state.css → popup/loading-state.css} +0 -0
- /package/src/css/components/{popup.css → popup/popup.css} +0 -0
- /package/src/css/{components/optgroup.css → views/group-view.css} +0 -0
- /package/src/css/{components/option.css → views/option-view.css} +0 -0
package/dist/selective-ui.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! Selective UI v1.2.
|
|
2
|
-
var t,i;t=this,i=function(t){"use strict";function i(t){return new g(t??null)}class s{constructor(){this.t={accessoryVisible:!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]="boolean"==typeof s[e]?this.$(i):i:void 0!==t?.dataset?.[e]&&(s[e]="boolean"==typeof s[e]?this.$(t.dataset[e]):t.dataset[e])}return s}static V(...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 $(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 D(t,i){this.l.i.set(t,i)}static _(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.options=null,t&&this.init(t)}init(t){this.node=e.T({node:"div",classList:"selective-ui-placeholder",innerHTML:t.placeholder}),this.options=t}get(){return this.options?.placeholder??""}set(t,i=!0){if(!this.node||!this.options)return;i&&(this.options.placeholder=t);const s=e.W(t);this.node.innerHTML=this.options.allowHtml?s:e.q(s)}}class r{constructor(){this.node=this.init()}init(){return e.T({node:"div",classList:"selective-ui-directive",role:"button",ariaLabel:"Toggle dropdown"})}ct(t){this.node.classList.toggle("drop-down",!!t)}}class l{constructor(t=null){this.ut=null,this.node=null,this.options=null,this.dt=[],this.gt=[],t&&this.init(t)}init(t){this.ut=e.I({ft:{tag:{node:"div",classList:["selective-ui-option-handle","hide"]},F:{bt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{h.rt(this.dt)}}},wt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{h.rt(this.gt)}}}}}}),this.node=this.ut.view,this.options=t}available(){return!!this.options&&e.$(this.options.multiple)&&e.$(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")}yt(t=null){"function"==typeof t&&this.dt.push(t)}vt(t=null){"function"==typeof t&&this.gt.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.xt=!1,this.element=null,this.Tt=null,this.Ot=null,this.xt=!0,this.Mt=this.At.bind(this)}Ct(t){}At(){const t=this.element;if(!t||"function"!=typeof t.getBoundingClientRect)return void this.Ct({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.Ct({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.At()}connect(t){if(!(t instanceof Element))throw Error("Invalid element");this.element=t,this.Tt=new ResizeObserver(this.Mt),this.Tt.observe(t),this.Ot=new MutationObserver(this.Mt),this.Ot.observe(t,{attributes:!0,attributeFilter:["style","class"]}),window.addEventListener("scroll",this.Mt,!0),window.addEventListener("resize",this.Mt),window.visualViewport&&(window.visualViewport.addEventListener("resize",this.Mt),window.visualViewport.addEventListener("scroll",this.Mt))}disconnect(){this.Tt?.disconnect(),this.Ot?.disconnect(),this.Ct=()=>{},window.removeEventListener("scroll",this.Mt,!0),window.removeEventListener("resize",this.Mt),window.visualViewport&&(window.visualViewport.removeEventListener("resize",this.Mt),window.visualViewport.removeEventListener("scroll",this.Mt)),this.Tt=null,this.Ot=null,this.element=null}}class d{constructor(t=null,i=null,s=null){this.options=null,this.St=!1,this.Ht=null,this.node=null,this.Lt=null,this.Pt=null,this.parent=null,this.It=null,this.Et=null,this.Ft=null,this.jt=null,this.$t=null,this.Vt=null,this.kt=null,this.Rt={Dt:36,_t:8,Nt:!0},this.Bt=s,t&&i&&this.init(t,i)}init(t,i){if(!this.Bt)throw Error("Popup requires a ModelManager instance.");this.It=new l(i),this.Et=new a(i),this.Ft=new c(i);const s=e.I({Ut:{tag:{node:"div",classList:"selective-ui-popup",style:{maxHeight:i.panelHeight}},F:{ft:{tag:this.It.node},zt:{tag:{id:i.Gt,node:"div",classList:"selective-ui-options-container",role:"listbox"}},Wt:{tag:this.Ft.node},qt:{tag:this.Et.node}}}},null);this.node=s.view,this.$t=s.tags.zt,this.parent=e.R(t),this.options=i,this.Bt.load(this.$t,{isMultiple:i.multiple},i.virtualScroll?{Jt:this.node,Dt:this.Rt.Dt,_t:this.Rt._t,Nt:this.Rt.Nt}:{});const h=this.Bt.Kt();this.Ht=h.Qt,this.jt=h.jt,this.It.yt(()=>{h.Qt.Yt(!0)}),this.It.vt(()=>{h.Qt.Yt(!1)}),this.Xt()}async Zt(){this.options&&this.Ft&&this.It&&this.Ht&&this.Bt&&(this.kt&&clearTimeout(this.kt),this.Bt.ti(!0),!1!==e.$(this.options.loadingfield)&&(this.Et.hide(),this.Ft.show(this.Ht.si().ii),this.ei()))}async hi(){this.options&&this.Ft&&this.Ht&&this.Bt&&(this.kt&&clearTimeout(this.kt),this.kt=setTimeout(()=>{this.Bt?.ti(!1),this.Ft?.hide();const t=this.Ht?.si();this.ni(t??void 0),this.ei()},200))}Xt(){this.Ht&&(this.Ht.oi(t=>{this.ni(t)}),this.Ht.ri("items",()=>{const t=this.Ht.si();this.ni(t),this.ei()}))}ni(t){if(!(this.Ht&&this.Et&&this.It&&this.$t))return;const i=t??this.Ht.si();i.isEmpty?(this.Et.show("nodata"),this.$t.classList.add("hide"),this.It.hide()):i.ii?(this.Et.hide(),this.$t.classList.remove("hide"),this.It.refresh()):(this.Et.show("notfound"),this.$t.classList.add("hide"),this.It.hide())}li(t,i){this.Ht?.ai(t,i)}ci(t,i){this.Ht?.ri(t,i)}ui(t){this.Lt=t}open(t=null,i){if(!(this.node&&this.options&&this.It&&this.parent&&this.Lt))return;this.St||(document.body.appendChild(this.node),this.St=!0,this.Pt=new u,this.Lt.di(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.It.refresh(),i&&this.ni();const s=this.pi(),{position:e,top:h,maxHeight:n,gi:o}=this.fi(s);this.Lt.expand({duration:this.options.animationtime,display:"flex",width:s.width,left:s.left,top:h,maxHeight:n,gi:o,position:e,mi:()=>{if(!this.Pt||!this.parent)return;this.Pt.Ct=()=>{const t=this.pi();this.bi(t)},this.Pt.connect(this.parent.container.tags.wi),t?.();const i=this.jt;i?.resume?.()}})}close(t=null){if(!(this.St&&this.options&&this.Pt&&this.Lt))return;const i=this.jt;i?.suspend?.(),this.Pt.disconnect(),this.Lt.collapse({duration:this.options.animationtime,mi:t??void 0})}ei(){this.St&&this.Pt?.ot()}yi(t,i){this.node&&(this.Vt=async()=>{const i=t.xi();if(!i.Ti)return;const s=this.node;if(s.scrollHeight-s.scrollTop-s.clientHeight<100&&!i.Oi&&i.hasMore){const i=await t.Mi();!i.Ai&&i.message&&console.log("Load more:",i.message)}},this.node.addEventListener("scroll",this.Vt))}Ci(){this.kt&&(clearTimeout(this.kt),this.kt=null),this.node&&this.Vt&&(this.node.removeEventListener("scroll",this.Vt),this.Vt=null);try{this.Pt?.disconnect()}catch(t){}this.Pt=null;try{this.Lt?.di?.(null)}catch(t){}if(this.Lt=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.$t=null;try{this.Bt?.ti?.(!1),this.jt?.clear?.(),this.jt=null,this.Ht=null,this.node.remove()}catch(t){}this.Bt=null,this.It=null,this.Et=null,this.Ft=null,this.parent=null,this.options=null,this.St=!1}pi(){const t=this.parent.container.tags.wi,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)}}}fi(t){const i=window.visualViewport,s=e.Y(),h=i?.height??window.innerHeight,n=this.Lt.Si("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,gi:d,Hi:n}}bi(t){if(!this.options||!this.Lt)return;const{position:i,top:s,maxHeight:e,gi:h}=this.fi(t);this.Lt.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:s,maxHeight:e,gi:h,position:i,animate:!0})}}class p{constructor(t=null){this.ut=null,this.node=null,this.Li=null,this.Pi=null,this.options=null,this.Ii=null,this.Ei=null,this.Fi=null,this.options=t,t&&this.init(t)}init(t){this.ut=e.I({ji:{tag:{node:"div",classList:["selective-ui-searchbox","hide"]},F:{Li:{tag:{id:e.m(),node:"input",type:"search",classList:["selective-ui-searchbox-input"],placeholder:t.placeholder,role:"searchbox",C:t.Gt,L:"list"}}}}}),this.node=this.ut.view,this.Li=this.ut.tags.Li;let i=!1;const s=this.ut.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.Ii?.(1)):"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.Ii?.(-1)):"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),i=!0,this.Ei?.()):"Escape"===t.key&&(t.preventDefault(),t.stopPropagation(),i=!0,this.Fi?.()),t.stopPropagation()}),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.ut&&(this.ut.tags.Li.value="",this.Pi?.("",t))}$i(t){this.Li&&(this.Li.placeholder=e.q(t))}Vi(t){this.Li&&this.Li.setAttribute("aria-activedescendant",t)}}class g{constructor(t=null){this.ki=null,this.Ri=null,this.Di=!1,t&&this.di(t)}di(t){if("string"==typeof t){const i=document.querySelector(t);return void(i instanceof HTMLElement&&(this.element=i))}this.element=t}cancel(){return this.ki&&(clearTimeout(this.ki),this.ki=null),this.Ri&&(clearTimeout(this.Ri),this.Ri=null),this.Di=!1,this}Si(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.Di=!0;const{duration:i=200,display:s="flex",width:e,left:h,top:n,maxHeight:o,gi:r,position:l="bottom",mi: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.ki=setTimeout(()=>{this.element.style.transition="none",this.Di=!1,a?.()},i)}),this}collapse(t){if(!this.element)return this;this.cancel(),this.Di=!0;const{duration:i=200,mi: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.ki=setTimeout(()=>{Object.assign(this.element.style,{display:"none",transition:"none"}),this.Di=!1,s?.()},i)}),this}showSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Di=!0;const{duration:i=200,display:s="block",mi:e}=t;Object.assign(this.element.style,{transition:"none",display:s,width:"fit-content"});const h=this.Si(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.ki=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:""}),this.Di=!1,e?.()},i),this}hideSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Di=!0;const{duration:i=200,mi:s}=t,e=this.Si().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.ki=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:"",display:""}),this.Di=!1,s?.()},i),this}resize(t){if(!this.element)return this;this.cancel();const{duration:i=200,width:s,left:e,top:h,maxHeight:n,gi:o,position:r="bottom",animate:l=!0,mi: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;`),setTimeout(()=>{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.Ri=setTimeout(()=>{this.element?.style&&(this.element.style.transition=null)},i),Object.assign(this.element.style,t),l&&(c||r>1)?this.Ri=setTimeout(()=>{this.element.style.transition=null,c&&delete this.element.style.transition,a?.()},i):(c&&delete this.element.style.transition,a?.())},20),this}get _i(){return this.Di}}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.xt=!1,this.Ni=!1,this.options=t,this.targetElement=i,this.view=s}update(t){this.targetElement=t,this.Bi()}remove(){this.targetElement=null,this.view?.Ui()?.remove?.(),this.view=null,this.Ni=!0,this.zi()}Bi(){}zi(){}}class m extends f{constructor(t,i){super(t,i??null,null),this.label="",this.items=[],this.collapsed=!1,this.Gi=[],i&&(this.label=i.label,this.collapsed=e.$(i.dataset?.collapsed))}get value(){return this.items.map(t=>t.value)}get Wi(){return this.items.filter(t=>t.selected)}get qi(){return this.items.filter(t=>t.visible)}get Ji(){return this.qi.length>0}update(t){this.label=t.label,this.view?.Ki(this.label)}Bi(){this.view&&(this.view.Ki(this.label),this.view.Qi(this.collapsed))}Yi(t){this.Gi.push(t)}Xi(){this.collapsed=!this.collapsed,this.view?.Qi(this.collapsed),h.nt([this,this.collapsed],...this.Gi)}Zi(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)}ts(){this.view?.ts()}}class b extends f{constructor(t,i=null,s=null){super(t,i,s),this.ss=[],this.es=[],this.hs=[],this.ns=!0,this.rs=!1,this.group=null,(async()=>{this.ls=e.J(this.textContent.toLowerCase())})()}get cs(){return this.dataset?.imgsrc||this.dataset?.image||""}get hasImage(){return!!this.cs}get value(){return this.targetElement?.value??""}get selected(){return!!this.targetElement?.selected}set selected(t){this.us=t,h.nt([this,t],...this.ss)}get visible(){return this.ns}set visible(t){if(this.ns===t)return;this.ns=t;const i=this.view?.Ui?.();i&&i.classList.toggle("hide",!t),h.nt([this,t],...this.hs)}get us(){return this.selected}set us(t){const i=this.view?.view?.tags?.ds,s=this.view?.Ui?.();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.es)}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 ps(){return this.rs}set ps(t){const i=!!t,s=this.view?.Ui?.();this.rs!==i&&(this.rs=i),s&&s.classList.toggle("highlight",i)}gs(t){this.ss.push(t)}fs(t){this.es.push(t)}oi(t){this.hs.push(t)}Bi(){if(this.ls=e.J(this.textContent.toLowerCase()),!this.view)return;const t=this.view.view.tags.bs;t&&(this.options.allowHtml?t.innerHTML=this.text:t.textContent=this.textContent);const i=this.view.view.tags.ws;i&&this.hasImage&&(i.src=this.cs,i.alt=this.text),this.targetElement&&(this.us=this.targetElement.selected)}}class w{constructor(t){this.ys=[],this.vs=null,this.xs=null,this.Ts=null,this.options=null,this.options=t}Os(t){this.Ms=t}As(t){this.Cs=t}Ss(t){const i=this.Hs(t),s=i!==this.Ts;return s&&(this.Ts=i),s}Hs(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")}Ls(t){this.ys=[];let i=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)i=new m(this.options,t),this.ys.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.Zi(e),e.group=i):(this.ys.push(e),i=null)}}),this.ys}replace(t){this.Ts=null,this.Ls(t),this.vs&&this.vs.Ps(this.ys),this.refresh(!1)}notify(){this.vs&&this.refresh(!1)}load(t,i={},s={}){this.vs=new this.Ms(this.ys),Object.assign(this.vs,i),this.xs=new this.Cs(t),Object.assign(this.xs,s),this.xs.Is(this.vs)}update(t){if(!this.Ss(t))return;const i=this.ys,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.Zi(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.Zi(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.ys=s,this.vs&&this.vs.Es(this.ys),this.onUpdated(),this.refresh(r)}onUpdated(){}ti(t){this.vs&&(this.vs.Fs=t)}refresh(t){this.xs&&(this.xs.refresh(t),this.onUpdated())}Kt(){return{js:this.ys,Qt:this.vs,jt:this.xs}}$s(t){this.vs?.Vs(t)}ks(t){this.vs?.Rs(t)}}class y{constructor(t=null){this.Ds=null,this.Qt=null,this.Ds=t}_s(t){this.Ds=t}Is(t){this.Qt=t,t.ai("items",()=>{this.clear()}),t.ri("items",()=>{this.Ns()}),this.Ns()}clear(){this.Ds&&this.Ds.replaceChildren()}Ns(){this.Qt&&this.Ds&&this.Qt.Bs(this.Ds)}refresh(t){this.Ns()}}class v{constructor(t=null){this.ut=null,this.node=null,this.options=null,this.Us=null,this.zs=null,this.Bt=null,this.Gs=[],t&&this.init(t)}init(t){this.ut=e.I({Ws:{tag:{node:"div",classList:["selective-ui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.ut.view,this.options=t}qs(t){this.Us=t,this.zs=t.parentElement,this.Js()}Js(){this.zs&&this.node&&this.Us&&this.options&&this.zs.insertBefore(this.node,"top"===this.options.accessoryStyle?this.Us:this.Us.nextSibling)}Ks(t){this.Bt=t}Qs(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?t.forEach(t=>{e.I({Ys:{tag:{node:"div",classList:["accessory-item"]},F:{Xs:{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.Bt?.$s?.("select"),setTimeout(()=>{t.selected=!1},10)}}},Zs:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)}):t=[],this.Gs=t,this.te(),h.ot(window,"resize"))}te(){this.options?.accessoryVisible&&this.Gs.length>0&&this.options.multiple?this.show():this.hide()}show(){this.node.classList.remove("hide")}hide(){this.node.classList.add("hide")}}class x{constructor(t,i,s){this.ie=null,this.se=null,this.ee=null,this.he=null,this.ne={currentPage:0,totalPages:1,hasMore:!1,Oi:!1,oe:"",Ti:!1},this.select=t,this.Bt=i,this.he=s}re(){return!!this.ie}async le(t){if(!this.ie)return{Ai:!1,items:[],message:"Ajax not configured"};const i=Array.isArray(t)?t:[t];if(0===i.length)return{Ai:!0,items:[]};try{const t=this.ie;let s,e;if(s="function"==typeof t.ae?t.ae(i):{values:i.join(","),ce:"1",..."function"==typeof t.data?t.data.bind(this.he.ue.find(this.he.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{Ai:!0,items:this.de(h).items}}catch(s){return console.error("Load by values error:",s),{Ai:!1,message:s?.message,items:[]}}}pe(t){const i=Array.from(this.select.options).map(t=>t.value);return{ge:t.filter(t=>i.includes(t)),fe:t.filter(t=>!i.includes(t))}}me(t){this.ie=t}setPopup(t){this.ee=t}xi(){return{...this.ne}}be(){this.ne={currentPage:0,totalPages:1,hasMore:!1,Oi:!1,oe:"",Ti:this.ne.Ti}}clear(){this.ne.oe="";const{js:t}=this.Bt.Kt(),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.ie?this.we(t,i):this.ye(t)}async Mi(){return this.ie?this.ne.Oi?{Ai:!1,message:"Already loading"}:this.ne.Ti?this.ne.hasMore?(this.ne.currentPage++,this.we(this.ne.oe,!0)):{Ai:!1,message:"No more data"}:{Ai:!1,message:"Pagination not enabled"}:{Ai:!1,message:"Ajax not enabled"}}async ye(t){this.ve(t)&&(this.ne.oe=t);const i=((t??"")+"").toLowerCase(),s=e.J(i),{js:h}=this.Bt.Kt(),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 e=""===i||t.ls.includes(s);t.visible=e,e&&(o=!0)}),{Ai:!0,xe:o,isEmpty:0===n.length}}ve(t){return t!==this.ne.oe}async we(t,i=!1){const s=this.ie;this.ve(t)&&(this.be(),this.ne.oe=t,i=!1),this.ne.Oi=!0,this.ee?.Zt(),this.se?.abort(),this.se=new AbortController;const e=this.ne.currentPage,h=Array.from(this.select.selectedOptions).map(t=>t.value).join(",");let n;"function"==typeof s.data?(n=s.data.bind(this.he.ue.find(this.he.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.se.signal})}else{const i=""+new URLSearchParams(n);t=await fetch(`${s.url}?${i}`,{signal:this.se.signal})}const e=await t.json(),h=this.de(e);return h.Te?(this.ne.Ti=!0,this.ne.currentPage=h.page,this.ne.totalPages=h.totalPages,this.ne.hasMore=h.hasMore):this.ne.Ti=!1,this.Oe(h.items,!!s.keepSelected,i),this.ne.Oi=!1,this.ee?.hi(),{Ai:!0,xe:h.items.length>0,isEmpty:0===h.items.length,Te:h.Te,hasMore:h.hasMore,currentPage:h.page,totalPages:h.totalPages}}catch(o){return this.ne.Oi=!1,this.ee?.hi(),"AbortError"===o?.name?{Ai:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Ai:!1,message:o?.message})}}de(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.Me||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}}),Te:s,page:e,totalPages:h,hasMore:n}}Oe(t,i,s=!1){const e=this.select;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.Ae=null,this.Ce=null,this.Se=50,this.select=t,this.Ce=this.He(),this.Le=new MutationObserver(()=>{this.Ae&&clearTimeout(this.Ae),this.Ae=setTimeout(()=>{this.Pe()},this.Se)}),t.addEventListener("options:changed",()=>{this.Ae&&clearTimeout(this.Ae),this.Ae=setTimeout(()=>{this.Pe()},this.Se)})}He(){const t=Array.from(this.select.options);return{length:t.length,values:t.map(t=>t.value).join(","),Ie:t.map(t=>t.text).join(","),selected:t.map(t=>t.selected+"").join(",")}}Ee(){const t=this.He(),i=JSON.stringify(t)!==JSON.stringify(this.Ce);return i&&(this.Ce=t),i}Pe(){this.Ee()&&this.Ct(this.select)}connect(){this.Le.observe(this.select,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Ct(t){}disconnect(){this.Ae&&clearTimeout(this.Ae),this.Ae=null,this.Le.disconnect()}}class O{constructor(t){this.Ae=null,this.element=t,this.Le=new MutationObserver(t=>{let i=!1;for(const s of t)if("attributes"===s.type&&s.attributeName?.startsWith("data-")){i=!0;break}i&&(this.Ae&&clearTimeout(this.Ae),this.Ae=setTimeout(()=>{this.Ct({...this.element.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Ct({...this.element.dataset})})}connect(){this.Le.observe(this.element,{attributes:!0,attributeOldValue:!0})}Ct(t){}disconnect(){this.Ae&&clearTimeout(this.Ae),this.Ae=null,this.Le.disconnect()}}class M{constructor(t=[]){this.items=[],this.Fe=e.m(12),this.Fs=!1,this.items=t,this.je()}je(){}$e(t,i,s){const e=i;t.xt?e?.update?.():e?.Ns?.()}ai(t,i){e.Z.on(`${t}ing_${this.Fe}`,i,{st:1})}ri(t,i){e.Z.on(`${t}_${this.Fe}`,i)}Rs(t,...i){e.Z.run(`${t}_${this.Fe}`,...i)}Vs(t,...i){e.Z.run(`${t}ing_${this.Fe}`,...i)}Ve(t,i){return null}ke(){return this.items.length}Re(t){this.Vs("items",t),this.items=t,this.Rs("items",t)}Ps(t){this.Re(t)}Bs(t){for(let i=0;i<this.ke();i++){const s=this.items[i];let e=s.view;s.xt||(e=this.Ve(t,s),s.view=e),this.$e(s,e,i),s.xt=!0}}Es(t){}}class A{constructor(t){this.parent=null,this.view=null,this.parent=t}Ns(){}update(){}Ui(){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}Ns(){const t=e.m(7);this.view=e.P({De:{tag:{node:"div",classList:["selective-ui-group"],role:"group",A:`seui-${t}-header`,id:`seui-${t}-group`},F:{_e:{tag:{node:"div",classList:["selective-ui-group-header"],role:"presentation",id:`seui-${t}-header`}},Ne:{tag:{node:"div",classList:["selective-ui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view)}update(){this.Ki()}Ki(t=null){this.view&&null!==t&&(this.view.tags._e.textContent=t)}Be(){if(!this.view)throw Error("GroupView is not rendered.");return this.view.tags.Ne}ts(){if(!this.view)return;const t=Array.from(this.view.tags.Ne.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",!(t.length>0))}Qi(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags._e.setAttribute("aria-expanded",t?"false":"true"))}}class S extends A{constructor(t){super(t),this.view=null,this.config=null,this.Ue=null,this.ze=!1,this.Ge()}Ge(){const t=this;this.config={isMultiple:!1,hasImage:!1,imagePosition:"right",imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",labelValign:"center",labelHalign:"left"},this.Ue=new Proxy(this.config,{set(i,s,e){if("string"!=typeof s)return!0;const h=s,n=i[h];return n!==e&&(i[h]=e,t.ze&&t.We(h,e,n)),!0}})}get isMultiple(){return this.config.isMultiple}set isMultiple(t){this.Ue.isMultiple=!!t}get hasImage(){return this.config.hasImage}set hasImage(t){this.Ue.hasImage=!!t}get qe(){return this.Ue}set qe(t){if(!t||!this.Ue||!this.config)return;const i={};void 0!==t.imageWidth&&t.imageWidth!==this.config.imageWidth&&(i.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this.config.imageHeight&&(i.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this.config.imageBorderRadius&&(i.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this.config.imagePosition&&(i.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this.config.labelValign&&(i.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this.config.labelHalign&&(i.labelHalign=t.labelHalign),Object.keys(i).length>0&&Object.assign(this.Ue,i)}Ns(){const t=["selective-ui-option-view"],i=e.m(7),s="option_"+i;this.config.isMultiple&&t.push("multiple"),this.config.hasImage&&(t.push("has-image"),t.push("image-"+this.config.imagePosition));const h={ds:{tag:{node:"input",type:this.config.isMultiple?"checkbox":"radio",classList:"allow-choice",id:s}},...this.config.hasImage&&{ws:{tag:{node:"img",classList:"option-image",style:{width:this.config.imageWidth,height:this.config.imageHeight,borderRadius:this.config.imageBorderRadius}}}},Je:{tag:{node:"label",htmlFor:s,classList:["align-vertical-"+this.config.labelValign,"align-horizontal-"+this.config.labelHalign]},F:{bs:{tag:{node:"div"}}}}};this.view=e.P({Ke:{tag:{node:"div",id:`seui-${i}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},F:h}}),this.parent.appendChild(this.view.view),this.ze=!0}We(t,i,s){const e=this.view;if(!e||!e.view)return;const h=e.view,n=e.tags?.ds,o=e.tags?.Je;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.config.imagePosition),this.Qe();else{h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.ws;t&&(t.remove(),e.tags.ws=null)}break}case"imagePosition":this.config.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?.ws;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.config.labelValign} align-horizontal-${this.config.labelHalign}`;o.className!==t&&(o.className=t)}}}Qe(){const t=this.view;if(!t||!t.view)return;const i=t.tags?.ws;if(i)return;const s=t.view,e=t.tags?.Je,h=document.createElement("img");h.className="option-image",h.style.width=this.config.imageWidth,h.style.height=this.config.imageHeight,h.style.borderRadius=this.config.imageBorderRadius,e&&e.parentElement?s.insertBefore(h,e):s.appendChild(h),t.tags.ws=h}}class H extends M{constructor(t=[]){super(t),this.isMultiple=!1,this.Ye=[],this.Xe=-1,this.Ze=null,this.groups=[],this.th=[],this.ih(),e.Z.on("sche_vis_"+this.Fe,()=>{const t=this.th.filter(t=>t.visible).length,i=this.th.length;this.Ye.forEach(s=>{s({sh:t,eh:i,ii:t>0,isEmpty:0===i})}),e.Z.run("sche_vis_proxy_"+this.Fe)},{st:10})}ih(){this.th=[],this.groups=[],this.items.forEach(t=>{t instanceof m?(this.groups.push(t),this.th.push(...t.items)):t instanceof b&&this.th.push(t)})}Ve(t,i){return i instanceof m?new C(t):new S(t)}$e(t,i,s){t.position=s,t instanceof m?this.hh(t,i,s):t instanceof b&&this.nh(t,i,s),t.xt=!0}hh(t,i,s){super.$e(t,i,s),t.view=i;const e=i.view.tags._e;e.textContent=t.label,t.xt||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.Xi()}),t.Yi((t,i,s)=>{i.items.forEach(t=>{const i=t.view?.Ui?.();i&&(i.style.display=s?"none":"")}),this.oh(i,s)}));const h=i.Be();t.items.forEach((t,i)=>{let s=t.view;t.xt&&s||(s=new S(h)),this.nh(t,s,i),t.xt=!0}),i.Qi(t.collapsed),i.ts()}nh(t,i,s){if(i.isMultiple=this.isMultiple,i.hasImage=t.hasImage,i.qe={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.xt||super.$e(t,i,s),t.view=i,t.hasImage){const s=i.view.tags.ws;s&&(s.src!==t.cs&&(s.src=t.cs),s.alt!==t.text&&(s.alt=t.text))}i.view.tags.bs.innerHTML=t.text,t.xt||(i.view.tags.Ke.addEventListener("click",i=>{i.stopPropagation(),i.preventDefault(),this.Fs||(this.isMultiple?(this.Vs("select"),setTimeout(()=>{t.selected=!t.selected},5)):!0!==t.selected&&(this.Vs("select"),setTimeout(()=>{this.Ze&&(this.Ze.selected=!1),t.selected=!0},5)))}),i.view.tags.Ke.title=t.textContent,i.view.tags.Ke.addEventListener("mouseenter",()=>{this.Fs||this.rh(this.th.indexOf(t),!1)}),t.gs(()=>{this.Rs("selected")}),t.fs((i,s,e)=>{e&&(this.Ze=t),this.Rs("selected_internal")}),t.oi((t,i)=>{i.group?.ts(),this.ah()})),t.selected&&(this.Ze=t,t.us=!0)}Re(t){this.Vs("items",t),this.items=t,this.ih(),this.Rs("items",t)}Ps(t){this.Re(t)}Es(t){this.items=t,this.ih()}uh(){return this.th.filter(t=>t.selected)}dh(){return this.th.find(t=>t.selected)}Yt(t){this.isMultiple&&this.th.forEach(i=>{i.selected=t})}oi(t){this.Ye.push(t)}ah(){e.Z.run("sche_vis_"+this.Fe)}si(){const t=this.th.filter(t=>t.visible).length,i=this.th.length;return{sh:t,eh:i,ii:t>0,isEmpty:0===i}}ph(){this.rh(0)}navigate(t,i=!0){const s=this.th.filter(t=>t.visible);if(0===s.length)return;let e=s.findIndex(t=>t===this.th[this.Xe]);-1===e&&(e=-1);let h=e+t;h>=s.length&&(h=0),h<0&&(h=s.length-1);const n=this.th.indexOf(s[h]);this.rh(n,i)}gh(){if(this.Xe>-1&&this.th[this.Xe]){const t=this.th[this.Xe];if(t.visible){const i=t.view?.Ui?.();i&&i.click()}}}rh(t,i=!0){let s=0;if("number"==typeof t)s=t;else if(t instanceof b){const i=this.th.indexOf(t);s=i>-1?i:0}else s=0;this.Xe>-1&&this.th[this.Xe]&&(this.th[this.Xe].ps=!1);for(let e=s;e<this.th.length;e++){const t=this.th[e];if(t?.visible){if(t.ps=!0,this.Xe=e,i){const i=t.view?.Ui?.();i?i.scrollIntoView({block:"center",behavior:"smooth"}):this.jt?.fh?.(e,{scrollIntoView:!0})}return void this.mh(e,t.view?.Ui?.()?.id)}}}mh(t,i){}oh(t,i){}}class L{constructor(t=0){this.bh=[],this.n=0,this.reset(t)}reset(t){this.n=t,this.bh=Array(t+1).fill(0)}add(t,i){for(let s=t;s<=this.n;s+=s&-s)this.bh[s]+=i}wh(t){let i=0;for(let s=t;s>0;s-=s&-s)i+=this.bh[s];return i}yh(t,i){return i<t?0:this.wh(i)-this.wh(t-1)}xh(t){this.reset(t.length),t.forEach((t,i)=>this.add(i+1,t))}Th(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.bh[s]<=t&&(i=s,e+=this.bh[s])}return i}}class P extends y{constructor(t=null){super(t),this.Oh={Jt:void 0,Dt:36,_t:8,Nt:!0,Mh:!0},this.Ah=[],this.Ch=new L(0),this.Sh=new Map,this.Hh=!1,this.start=0,this.end=-1,this.Lh=null,this.Ph=null,this.updating=!1,this.Ih=!1,this.Eh=0,this.Fh=!1,this.jh=!1,this.$h=0,this.Vh=0,this.kh=0,this.Rh=0}configure(t){this.Oh={...this.Oh,...t}}Is(t){if(this.Qt&&this.dispose(),super.Is(t),t.jt=this,!this.Ds)return;this.Ds.replaceChildren();const i=e.I({Dh:{tag:{node:"div",classList:"selective-ui-virtual-pad-top"}},_h:{tag:{node:"div",classList:"selective-ui-virtual-items"}},Nh:{tag:{node:"div",classList:"selective-ui-virtual-pad-bottom"}}},this.Ds);if(this.Dh=i.Dh,this._h=i._h,this.Nh=i.Nh,this.Jt=this.Oh.Jt??this.Ds.closest(".selective-ui-popup")??this.Ds.parentElement,!this.Jt)throw Error("VirtualRecyclerView: scrollEl not found");this.Bh=this.Uh.bind(this),this.Jt.addEventListener("scroll",this.Bh,{passive:!0}),this.refresh(!1),this.zh(),t?.oi?.(()=>this.Gh())}suspend(){this.Fh=!0,this.Wh(),this.Jt&&this.Bh&&this.Jt.removeEventListener("scroll",this.Bh),this.qh&&(this.qh.disconnect(),this.jh=!0)}resume(){this.Fh=!1,this.Jt&&this.Bh&&this.Jt.addEventListener("scroll",this.Bh,{passive:!0}),this.jh&&(this.zh(),this.jh=!1),this.Jh()}refresh(t){if(!this.Qt||!this.Ds)return;t||this.Gh();const i=this.Qt.ke();this.Eh=i,0!==i?(this.Ah.length=i,this.Hh||(this.Kh(),this.Hh=!0),this.Qh(i),this.Jh()):this.Yh()}fh(t,i){this.Xh(t,t),i?.scrollIntoView&&this.Zh(t)}Zh(t){if((this.Qt?.ke?.()??0)<=0)return;const i=this.tn(t),s=this.sn()+i,e=Math.max(0,this.Jt.scrollHeight-this.Jt.clientHeight);this.Jt.scrollTop=Math.min(Math.max(0,s),e)}dispose(){this.Wh(),this.Jt&&this.Bh&&this.Jt.removeEventListener("scroll",this.Bh),this.qh?.disconnect(),this.Sh.forEach(t=>t.remove()),this.Sh.clear()}Gh(){if(!this.Qt)return;const t=this.Qt.ke();t<=0||(this.suspend(),this.Yh(),this.en(),this.hn(t),this.Qh(t),this.start=0,this.end=-1,this.resume())}Wh(){null!=this.Lh&&(cancelAnimationFrame(this.Lh),this.Lh=null),null!=this.Ph&&(cancelAnimationFrame(this.Ph),this.Ph=null)}Yh(){this.Sh.forEach(t=>t.remove()),this.Sh.clear(),this.Ah=[],this.Ch.reset(0),this.Dh.style.height="0px",this.Nh.style.height="0px",this.Hh=!1,this.kh=0,this.Rh=0}Kh(){this.nn(0);const t=this.Sh.get(0);if(!t)return;const i=this.rn(t);if(isNaN(i)||(this.Oh.Dt=i),!this.Oh.Nt){t.remove(),this.Sh.delete(0);const i=this.Qt.items[0];i&&(i.xt=!1,i.view=null)}}ln(t){const i=this.Qt?.items?.[t];return i?.visible??!0}an(t,i){for(let s=Math.max(0,t);s<i;s++)if(this.ln(s))return s;return-1}hn(t){this.kh=0,this.Rh=0;for(let i=0;i<t;i++){if(!this.ln(i))continue;const t=this.Ah[i];null!=t&&(this.kh+=t,this.Rh++)}}sn(){const t=this.Ds.getBoundingClientRect(),i=this.Jt.getBoundingClientRect();return t.top-i.top+this.Jt.scrollTop}cn(){const t=performance.now();if(t-this.$h<16)return this.Vh;const i=this.Jt.querySelector(".selective-ui-option-handle:not(.hide)");return this.Vh=i?.offsetHeight??0,this.$h=t,this.Vh}Jh(){null!=this.Lh||this.Fh||(this.Lh=requestAnimationFrame(()=>{this.Lh=null,this.un()}))}rn(t){const i=t.getBoundingClientRect(),s=getComputedStyle(t);return Math.max(1,i.height+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}dn(){return this.Oh.Mh&&this.Rh>0?Math.max(1,this.kh/this.Rh):this.Oh.Dt}Qh(t){const i=this.dn(),s=Array.from({length:t},(t,s)=>this.ln(s)?this.Ah[s]??i:0);this.Ch.xh(s)}pn(t,i){if(!this.ln(t))return!1;const s=this.dn(),e=this.Ah[t]??s;if(Math.abs(i-e)<=P.gn)return!1;const h=this.Ah[t];return null==h?(this.kh+=i,this.Rh++):this.kh+=i-h,this.Ah[t]=i,this.Ch.add(t+1,i-e),!0}fn(t,i){const s=this.Ch.Th(Math.max(0,t)),e=Math.min(i-1,s),h=this.an(e,i);return-1===h?Math.max(0,e):h}mn(t,i){i.setAttribute(P.bn,t+"");const s=this.Sh.get(t-1);if(s?.parentElement===this._h)return void s.after(i);const e=this.Sh.get(t+1);if(e?.parentElement===this._h)return void this._h.insertBefore(i,e);const h=Array.from(this._h.children);for(const n of h){const s=n.getAttribute(P.bn);if(s&&+s>t)return void this._h.insertBefore(i,n)}this._h.appendChild(i)}wn(t,i){if(i.parentElement!==this._h)return void this.mn(t,i);i.setAttribute(P.bn,t+"");const s=i.previousElementSibling,e=i.nextElementSibling;(s&&+s.getAttribute(P.bn)>t||e&&+e.getAttribute(P.bn)<t)&&(i.remove(),this.mn(t,i))}zh(){this.qh||(this.qh=new ResizeObserver(()=>{this.Ih||this.Fh||!this.Qt||null!=this.Ph||(this.Ph=requestAnimationFrame(()=>{this.Ph=null,this.yn()}))}),this.qh.observe(this._h))}yn(){if(!this.Qt)return;const t=this.Qt.ke();if(t<=0)return;let i=!1;for(let s=this.start;s<=this.end;s++){if(!this.ln(s))continue;const t=this.Qt.items[s],e=t?.view?.Ui?.();if(!e)continue;const h=this.rn(e);this.pn(s,h)&&(i=!0)}i&&(this.Oh.Mh&&this.Qh(t),this.Jh())}Uh(){this.Jh()}un(){if(!this.updating&&!this.Fh){this.updating=!0;try{if(!this.Qt)return;const t=this.Qt.ke();if(t<=0)return;this.Eh!==t&&(this.Eh=t,this.Ah.length=t,this.Qh(t));const i=this.sn(),s=Math.max(0,this.Jt.scrollTop-i),e=this.cn(),h=Math.max(0,this.Jt.clientHeight-e),n=this.fn(s,t),o=i+this.tn(n)-this.Jt.scrollTop,r=this.fn(s,t);if(-1===r)return void this.Yh();const l=this.dn(),a=this.Oh._t*l;let c=this.an(Math.min(t-1,this.Ch.Th(Math.max(0,s-a))),t)??r,u=Math.min(t-1,this.Ch.Th(s+h+a));if(c===this.start&&u===this.end)return;this.start=c,this.end=u,this.Ih=!0;try{this.Xh(this.start,this.end),this.vn(this.start,this.end),this.Oh.Nt&&this.yn();const i=this.tn(this.start),s=this.xn(this.start,this.end),e=this.Tn(t),h=Math.max(0,e-i-s);this.Dh.style.height=i+"px",this.Nh.style.height=h+"px"}finally{this.Ih=!1}const d=this.tn(n),p=this.sn()+d-o,g=Math.max(0,this.Jt.scrollHeight-this.Jt.clientHeight),f=Math.min(Math.max(0,p),g);Math.abs(this.Jt.scrollTop-f)>.5&&(this.Jt.scrollTop=f)}finally{this.updating=!1}}}Xh(t,i){for(let s=t;s<=i;s++)this.nn(s)}nn(t){if(!this.ln(t)){const i=this.Sh.get(t);return i?.parentElement===this._h&&i.remove(),void this.Sh.delete(t)}const i=this.Qt.items[t];if(!i)return;const s=this.Sh.get(t);if(s)return void(i?.view?(this.wn(t,s),this.Qt.$e(i,i.view,t)):(s.remove(),this.Sh.delete(t)));if(i.xt)i.view&&this.Qt.$e(i,i.view,t);else{const s=this.Qt.Ve(this._h,i);i.view=s,this.Qt.$e(i,s,t),i.xt=!0}const e=i.view?.Ui?.();e&&(this.wn(t,e),this.Sh.set(t,e))}vn(t,i){this.Sh.forEach((s,e)=>{(e<t||e>i)&&(s.parentElement===this._h&&s.remove(),this.Sh.delete(e))})}en(){this.Sh.forEach((t,i)=>{this.ln(i)||(t.parentElement===this._h&&t.remove(),this.Sh.delete(i))})}tn(t){return this.Ch.wh(t)}xn(t,i){return this.Ch.yh(t+1,i+1)}Tn(t){return this.Ch.wh(t)}}P.gn=.5,P.bn="data-vindex";class I{constructor(t=null,i=null){this.container={},this.oldValue=null,this.node=null,this.options=null,this.On=null,this.isOpen=!1,this.Mn=!1,this.An=!1,this.ue=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?.wi?.setAttribute("aria-disabled",t+""))}get Cn(){return!!this.options?.readonly}set Cn(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.ue=s,this.options=h,l.node&&(l.node.id=(h.Sn??"")+"");const M=e.I({Hn:{tag:{node:"div",classList:"selective-ui-MAIN"},F:{wi:{tag:{node:"div",classList:"selective-ui-view",tabIndex:0,onkeydown:t=>{"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.Ln()?.open())}},F:{Pn:{tag:l.node},In:{tag:a.node},ji:{tag:c.node}}}}}},null);this.container=M,this.node=M.view,t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,M.tags.wi),g.qs(M.tags.wi),g.Ks(u),M.tags.wi.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),n.lt(t,M.tags.wi),t.classList.add("init"),u.Os(H),u.As(h.virtualScroll?P:y),u.Ls(e.K(t)),u.onUpdated=()=>{M.ee?.ei?.()},this.On=u,M.En=f,M.placeholder=l,M.Fn=a,M.jn=c,M.effector=effector,M.targetElement=t,M.$n=g,M.Vn=m,M.kn=b,M.ee=new d(t,h,u),M.ee.ui(effector),M.ee.yi(f,h),M.ee.ci("selected",()=>{this.Ln()?.change(null,!0)}),M.ee.ci("selected_internal",()=>{this.Ln()?.change(null,!1)}),M.ee.li("select",()=>{this.oldValue=this.Ln()?.value??""}),this.Ln()?.change(null,!1),m.connect(),m.Ct=t=>{u.update(e.K(t)),this.Ln()?.refreshMask()},b.connect(),b.Ct=t=>{e.$(t.disabled)!==this.isDisabled&&(this.isDisabled=e.$(t.disabled)),e.$(t.readonly)!==this.Cn&&(this.Cn=e.$(t.readonly)),e.$(t.visible)!==this.isVisible&&(this.isVisible=e.$(t.visible??"1"))},t.addEventListener("options:changed",()=>{u.update(e.K(t)),this.Ln()?.refreshMask(),M.ee?.ei?.()}),h.ajax&&f.me(h.ajax);const A=M.ee.Ht;let C=null;const S=(t,i)=>{i||""!==t?(""!==t&&(this.An=!0),f.search(t).then(t=>{clearTimeout(C),e.Z.clear("sche_vis_proxy_"+A.Fe),e.Z.on("sche_vis_proxy_"+A.Fe,()=>{M.ee?.ei?.(),t?.xe&&(C=setTimeout(()=>{A.ph(),M.ee?.ei?.()},h.animationtime??0))},{st:10})}).catch(t=>{console.error("Search error:",t)})):f.clear()};let L=null;c.Pi=(t,i)=>{f.ve(t)&&(L&&clearTimeout(L),f.re()?(M.ee?.Zt?.(),L=setTimeout(()=>{S(t,i)},h.delaysearchtime??0)):L=setTimeout(()=>{S(t,i)},10))},f.setPopup(M.ee),c.Ii=t=>{A.navigate(t)},c.Ei=()=>{A.gh()},c.Fi=()=>{this.Ln()?.close(),M.tags.wi.focus()},A.mh=(t,i)=>{i&&c.Vi(i)},A.oh=()=>{M.ee?.ei?.()},this.isDisabled=e.$(h.disabled),this.Cn=e.$(h.readonly)}Rn(){const t=this.container??{},{Vn:i,kn:s}=t;i?.disconnect&&i.disconnect(),s?.disconnect&&s.disconnect()}Ln(){const t=this.container,i=this,s=()=>this.ue.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.jn?.$i(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.Dn().forEach(i=>{i.selected&&t.push(i.value)}),t},get valueString(){return this.valueArray.join(o.customDelimiter)},get valueOptions(){const t=[];return i.Dn(!0).forEach(i=>{t.push(i)}),t},get mask(){const t=[];return i.Dn(!0).forEach(i=>{t.push(i.text)}),t},get valueText(){const t=[];i.Dn(!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.Dn(!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.Dn().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.Dn().forEach(t=>{t.us=!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.Dn().forEach(t=>{t.us=!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.Dn().forEach(t=>t.us=!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.En?.re?.()){const{fe:s}=t.En.pe(n);if(s.length>0)return void(async()=>{o.loadingfield&&t.ee?.Zt?.();try{t.En.be();const e=await t.En.le(s);e.Ai&&e.items.length>0?(e.items.forEach(t=>{s.includes(t.value)&&(t.selected=!0)}),t.En.Oe?.(e.items,!0,!0),setTimeout(()=>{i.Dn().forEach(t=>{t.us=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.ee?.hi?.()}})()}if(r){if(h.nt([s()],...o.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Dn().forEach(t=>{t.us=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.ue?.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.Fn.ct(!0);const n=t.ee.Ht,r=n.dh();r?n.rh(r,!1):n.ph(),i.Mn&&!i.An||!o?.ajax?t.ee.open(null,!0):(t.En.be(),t.ee.Zt(),i.Mn=!0,i.An=!1,setTimeout(()=>{t.ee&&t.En&&t.En.search("").then(()=>t.ee?.ei?.()).catch(t=>console.error("Initial ajax load error:",t))},o.animationtime),t.ee.open(null,!1)),t.jn.show();const l=t.tags.wi;l.setAttribute("aria-expanded","true"),l.setAttribute("aria-controls",o.Gt),l.setAttribute("aria-haspopup","listbox"),l.setAttribute("aria-labelledby",o.Sn),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.Fn.ct(!1),t.ee.close(()=>{t.jn.clear(!1)}),t.jn.hide(),t.tags.wi.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.$n.Qs(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.Dn().length>0&&(s=this.mask[0]),s??(s=o.placeholder),t.placeholder.set(s,!1),t.jn.$i(s)},on(t,i,s){o.on[i]||(o.on[i]=[]),o.on[i].push(s)},ajax(i,s){t.En.me(s)},loadAjax:()=>new Promise((e,h)=>{t.ee.Zt(),t.En.be(),i.Mn=!0,i.An=!1,t.ee&&t.En?t.En.search("").then(()=>{t.ee?.ei?.(),e(s())}).catch(t=>{console.error("Initial ajax load error:",t),h(t)}):e(s())})};return this._n(r,"disabled","isDisabled"),this._n(r,"readonly","isReadOnly"),this._n(r,"visible","isVisible"),r}_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})}Dn(t=null){if(!this.On)return[];const{js:i}=this.On.Kt(),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.ee.Ci()}}class E{constructor(){this.isActive=!1,this.Le=null,this.actions=[]}Nn(t){this.actions.push(t)}Bn(){this.actions=[]}start(t){if(this.isActive)return;this.isActive=!0;const i=t.toUpperCase(),s=t.toLowerCase();this.Le=new MutationObserver(t=>{for(const e of t)e.addedNodes.forEach(t=>{if(1!==t.nodeType)return;const e=t;e.tagName===i&&this.Un(e),e.querySelectorAll(s).forEach(t=>this.Un(t))})}),this.Le.observe(document.body,{childList:!0,subtree:!0})}stop(){this.isActive&&(this.isActive=!1,this.Le?.disconnect(),this.Le=null)}Un(t){this.actions.forEach(i=>i(t))}}class F{constructor(){this.zn=new Map}bind(t,i){const s=e.V(e.U(),i);s.on=s.on??{},s.on.load=s.on.load??[],this.zn.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._(t),this.Gn(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.Wn(e,h.action);const o={isEmpty:!1};for(const e in n){const t=n[e];switch(t.type){case"get-set":this.qn(o,t.name,s);break;case"func":this.Jn(o,t.name,s)}}return o}Kn(){this.Qn=new E,this.Qn.Nn(t=>{this.zn.forEach((i,s)=>{try{t.matches(s)&&this.Gn(t,i)}catch(e){console.warn("Invalid selector: "+s,e)}})}),this.Qn.start("select")}destroy(t=null){null===t?this.Yn():"string"==typeof t?this.Xn(t):t instanceof HTMLSelectElement&&this.Zn(t)}Yn(){e.G().forEach(t=>this.Xn(t)),this.zn.clear(),e.G().length=0,this.Qn?.stop()}Xn(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.Zn(t)}),this.zn.delete(t);const i=e.G(),s=i.indexOf(t);s>-1&&i.splice(s,1)}Zn(t){const i=e.R(t);if(!i)return;const s=i.container?.ee;s?.Ci(),e.B(t,i);const h=!!this.Qn;h&&this.Qn?.stop();try{i.self?.Rn?.()}catch(o){}const n=i.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.io,n&&n.parentNode?n.parentNode.replaceChild(t,n):document.body.appendChild(t),e.k(t),h&&this.zn.size>0&&this.Qn?.start("select")}rebind(t,i){this.Xn(t),this.bind(t,i)}Gn(t,i){if(e.R(t)||e.N(t))return!1;const s=e.m(8),h=e.j(t,i);h.so=s,h.Gt=`seui-${s}-optionlist`,h.Sn=`seui-${s}-placeholder`;const n={options:h};e.D(t,n);const o=new I(t,this);return n.container=o.container,n.action=o.Ln(),n.self=o,o.container.view.addEventListener("mouseup",()=>{n.action?.toggle?.()}),!0}Wn(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}}qn(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})}Jn(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.2",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()}}),$.Kn())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",k):k()),console.log("[SelectiveUI] v1.2.2 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={});
|
|
1
|
+
/*! Selective UI v1.2.4 | MIT License */
|
|
2
|
+
var t,i;t=this,i=function(t){"use strict";function i(t){return new m(t??null)}class s{constructor(){this.t={accessoryVisible:!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:!1,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 O(t={}){return this.M(document.createElement(t.node??"div"),t,!0)}static M(t=document.documentElement,i=null,s=!1){const e={...i??{}},h=s?t:this.T(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.S&&(h.setAttribute("aria-controls",e.S+""),delete e.S),e.H&&(h.setAttribute("aria-haspopup",e.H+""),delete e.H),e.C&&(h.setAttribute("aria-multiselectable",e.C+""),delete e.C),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 T(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.O(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]="boolean"==typeof s[e]?this.$(i):i:void 0!==t?.dataset?.[e]&&(s[e]="boolean"==typeof s[e]?this.$(t.dataset[e]):t.dataset[e])}return s}static V(...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 $(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 D(t,i){this.l.i.set(t,i)}static _(t){return this.l.h.delete(t)}static N(t){return this.l.h.get(t)}static U(t,i){this.l.h.set(t,i)}static B(){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.O({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||0===s.length)return Promise.resolve();this.it.has(t)||this.it.set(t,new Map);const e=this.it.get(t),h=[];for(let n=0;n<s.length;n++){const t=s[n];if(!t)continue;const o=e.get(n);o&&clearTimeout(o);const r=new Promise(h=>{const o=setTimeout(async()=>{try{const s=t.et(i.length>0?i:null);s instanceof Promise&&await s}catch{}finally{if(t.once){s[n]=void 0;const t=e.get(n);t&&clearTimeout(t),e.delete(n)}h()}},t.timeout);e.set(n,o)});h.push(r)}return Promise.all(h).then(()=>{})}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})}}var o;(t=>{t.NEW="new",t.INITIALIZED="initialized",t.MOUNTED="mounted",t.UPDATED="updated",t.DESTROYED="destroyed"})(o||(o={}));class r{constructor(){this.state=o.NEW,this.ct=new Map,this.ct.set("onInit",new Set),this.ct.set("onMount",new Set),this.ct.set("onUpdate",new Set),this.ct.set("onDestroy",new Set)}on(t,i){return this.ct.get(t).add(i),this}off(t,i){return this.ct.get(t).delete(i),this}emit(t,i){const s={state:this.state,ut:i};for(const h of this.ct.get(t))try{h(s)}catch(e){this.dt(e,t)}}dt(t,i){console.error(`[Lifecycle:${i}]`,t)}init(){if(this.state!==o.NEW)return;const t=this.state;this.state=o.INITIALIZED,this.emit("onInit",t)}mount(){if(this.state!==o.INITIALIZED)return;const t=this.state;this.state=o.MOUNTED,this.emit("onMount",t)}update(){if(this.state!==o.MOUNTED&&this.state!==o.UPDATED)return;const t=this.state;this.state=o.UPDATED,this.emit("onUpdate",t)}destroy(){if(this.state===o.DESTROYED)return;const t=this.state;this.state=o.DESTROYED,this.emit("onDestroy",t),this.gt()}getState(){return this.state}is(t){return this.state===t}gt(){for(const t of this.ct.values())t.clear()}}class l extends r{constructor(t){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.node=e.O({node:"div",classList:"selective-ui-placeholder",innerHTML:t.placeholder}),this.options=t,this.init()}get(){return this.options?.placeholder??""}set(t,i=!0){if(!this.node||!this.options)return;i&&(this.options.placeholder=t);const s=e.W(t);this.node.innerHTML=this.options.allowHtml?s:e.q(s)}destroy(){this.is(o.DESTROYED)||(this.node?.remove(),this.node=null,this.options=null,super.destroy())}}class a extends r{constructor(){super(),this.init()}init(){this.node=e.O({node:"div",classList:"selective-ui-directive",role:"button",ariaLabel:"Toggle dropdown"}),super.init(),this.mount()}ft(t){this.node.classList.toggle("drop-down",!!t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.node=null,super.destroy())}}class c extends r{constructor(t=null){super(),this.bt=null,this.node=null,this.options=null,this.yt=[],this.wt=[],t&&this.initialize(t)}initialize(t){this.bt=e.I({vt:{tag:{node:"div",classList:["selective-ui-option-handle","hide"]},F:{xt:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textSelectAll,onclick:()=>{h.rt(this.yt)}}},Ot:{tag:{node:"a",classList:"selective-ui-option-handle-item",textContent:t.textDeselectAll,onclick:()=>{h.rt(this.wt)}}}}}}),this.node=this.bt.view,this.options=t,this.init()}available(){return!!this.options&&e.$(this.options.multiple)&&e.$(this.options.selectall)}update(){this.node&&(this.available()?this.show():this.hide()),super.update()}show(){this.node&&this.node.classList.remove("hide")}hide(){this.node&&this.node.classList.add("hide")}Mt(t=null){"function"==typeof t&&this.yt.push(t)}Tt(t=null){"function"==typeof t&&this.wt.push(t)}destroy(){this.is(o.DESTROYED)||(this.node.remove(),this.options=null,this.yt=null,this.wt=null,this.node=null,super.destroy())}}class u extends r{constructor(t=null){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.options=t,this.node=e.O({node:"div",classList:["selective-ui-empty-state","hide"],role:"status",ariaLive:"polite"}),this.init()}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")}destroy(){this.is(o.DESTROYED)||(this.options=null,this.node?.remove(),this.node=null,super.destroy())}}class d extends r{constructor(t=null){super(),this.node=null,this.options=null,t&&this.initialize(t)}initialize(t){this.options=t,this.node=e.O({node:"div",classList:["selective-ui-loading-state","hide"],textContent:t.textLoading,role:"status",ariaLive:"polite"}),this.init()}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")}destroy(){this.is(o.DESTROYED)||(this.options=null,this.node?.remove(),this.node=null,super.destroy())}}class p{constructor(){this.At=!1,this.element=null,this.St=null,this.Ht=null,this.At=!0,this.Ct=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.St=new ResizeObserver(this.Ct),this.St.observe(t),this.Ht=new MutationObserver(this.Ct),this.Ht.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.St?.disconnect(),this.Ht?.disconnect(),this.Pt=()=>{},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.St=null,this.Ht=null,this.element=null}}class g extends r{constructor(t=null,i=null,s=null){super(),this.options=null,this.It=!1,this.Et=null,this.node=null,this.Ft=null,this.jt=null,this.parent=null,this.$t=null,this.Vt=null,this.kt=null,this.Rt=null,this.Dt=null,this.zt=null,this._t=null,this.Nt={Ut:36,Bt:8,Gt:!0},this.Wt=s,t&&i&&this.initialize(t,i)}initialize(t,i){if(!this.Wt)throw Error("Popup requires a ModelManager instance.");this.$t=new c(i),this.Vt=new u(i),this.kt=new d(i);const s=e.I({qt:{tag:{node:"div",classList:"selective-ui-popup",style:{maxHeight:i.panelHeight}},F:{vt:{tag:this.$t.node},Jt:{tag:{id:i.Kt,node:"div",classList:"selective-ui-options-container",role:"listbox"}},Qt:{tag:this.kt.node},Yt:{tag:this.Vt.node}}}},null);this.node=s.view,this.Dt=s.tags.Jt,this.parent=e.R(t),this.options=i,this.init(),this.Wt.load(this.Dt,{isMultiple:i.multiple},i.virtualScroll?{Xt:this.node,Ut:this.Nt.Ut,Bt:this.Nt.Bt,Gt:this.Nt.Gt}:{});const h=this.Wt.Zt();this.Et=h.ti,this.Rt=h.Rt,this.$t.Mt(()=>{h.ti.ii(!0)}),this.$t.Tt(()=>{h.ti.ii(!1)}),this.si(),this.mount()}async ei(){this.options&&this.kt&&this.$t&&this.Et&&this.Wt&&(this._t&&clearTimeout(this._t),this.Wt.hi(!0),!1!==e.$(this.options.loadingfield)&&(this.Vt.hide(),this.kt.show(this.Et.oi().ni),this.ri()))}async li(){this.options&&this.kt&&this.Et&&this.Wt&&(this._t&&clearTimeout(this._t),this._t=setTimeout(()=>{this.Wt?.hi(!1),this.kt?.hide();const t=this.Et?.oi();this.ai(t??void 0),this.ri()},this.options.animationtime))}si(){this.Et&&(this.Et.ci(t=>{this.ai(t)}),this.Et.ui("items",()=>{const t=this.Et.oi();this.ai(t),this.ri()}))}ai(t){if(!(this.Et&&this.Vt&&this.$t&&this.Dt))return;const i=t??this.Et.oi();i.isEmpty?(this.Vt.show("nodata"),this.Dt.classList.add("hide"),this.$t.hide()):i.ni?(this.Vt.hide(),this.Dt.classList.remove("hide"),this.$t.update()):(this.Vt.show("notfound"),this.Dt.classList.add("hide"),this.$t.hide())}di(t,i){this.Et?.pi(t,i)}gi(t,i){this.Et?.ui(t,i)}fi(t){this.Ft=t}open(t=null,i){if(!(this.node&&this.options&&this.$t&&this.parent&&this.Ft))return;this.It||(document.body.appendChild(this.node),this.It=!0,this.jt=new p,this.Ft.mi(this.node),this.node.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()})),this.$t.update(),i&&this.ai();const s=this.bi(),{position:e,top:h,maxHeight:n,yi:o}=this.wi(s);this.Ft.expand({duration:this.options.animationtime,display:"flex",width:s.width,left:s.left,top:h,maxHeight:n,yi:o,position:e,xi:()=>{if(!this.jt||!this.parent)return;this.jt.Pt=()=>{const t=this.bi();this.Oi(t)},this.jt.connect(this.parent.container.tags.Mi),t?.();const i=this.Rt;i?.resume?.()}})}close(t=null){if(!(this.It&&this.options&&this.jt&&this.Ft))return;const i=this.Rt;i?.suspend?.(),this.jt.disconnect(),this.Ft.collapse({duration:this.options.animationtime,xi:t??void 0})}ri(){this.It&&this.jt?.ot()}Ti(t,i){this.node&&(this.zt=async()=>{const i=t.Ai();if(!i.Si)return;const s=this.node;if(s.scrollHeight-s.scrollTop-s.clientHeight<100&&!i.Hi&&i.hasMore){const i=await t.Ci();!i.Li&&i.message&&console.log("Load more:",i.message)}},this.node.addEventListener("scroll",this.zt))}destroy(){if(!this.is(o.DESTROYED)){this._t&&(clearTimeout(this._t),this._t=null),this.node&&this.zt&&(this.node.removeEventListener("scroll",this.zt),this.zt=null),this.Vt.destroy(),this.kt.destroy(),this.$t.destroy(),this.Rt.destroy();try{this.jt?.disconnect()}catch(t){}this.jt=null;try{this.Ft?.mi?.(null)}catch(t){}if(this.Ft=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.Dt=null;try{this.Wt?.hi?.(!1),this.Rt?.clear?.(),this.Rt=null,this.Et=null,this.node.remove()}catch(t){}this.Wt=null,this.$t=null,this.Vt=null,this.kt=null,this.parent=null,this.options=null,this.It=!1,super.destroy()}}bi(){const t=this.parent.container.tags.Mi,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.Ft.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,yi:d,Ii:n}}Oi(t){if(!this.options||!this.Ft)return;const{position:i,top:s,maxHeight:e,yi:h}=this.wi(t);this.Ft.resize({duration:this.options.animationtime,width:t.width,left:t.left,top:s,maxHeight:e,yi:h,position:i,animate:!0})}}class f extends r{constructor(t=null){super(),this.bt=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.initialize(t)}initialize(t){this.bt=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",S:t.Kt,L:"list"}}}}}),this.node=this.bt.view,this.Ei=this.bt.tags.Ei;let i=!1;const s=this.bt.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)}),this.init()}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.bt&&(this.bt.tags.Ei.value="",this.Fi?.("",t))}Ri(t){this.Ei&&(this.Ei.placeholder=e.q(t))}Di(t){this.Ei&&this.Ei.setAttribute("aria-activedescendant",t)}destroy(){this.is(o.DESTROYED)||(this.node?.remove(),this.bt=null,this.node=null,this.Ei=null,this.Fi=null,this.options=null,this.ji=null,this.$i=null,this.Vi=null,super.destroy())}}class m{constructor(t=null){this.zi=null,this._i=null,this.Ni=!1,t&&this.mi(t)}mi(t){if("string"==typeof t){const i=document.querySelector(t);return void(i instanceof HTMLElement&&(this.element=i))}this.element=t}cancel(){return this.zi&&(clearTimeout(this.zi),this.zi=null),this._i&&(clearTimeout(this._i),this._i=null),this.Ni=!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.Ni=!0;const{duration:i=200,display:s="flex",width:e,left:h,top:n,maxHeight:o,yi:r,position:l="bottom",xi: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.zi=setTimeout(()=>{this.element.style.transition="none",this.Ni=!1,a?.()},i)}),this}collapse(t){if(!this.element)return this;this.cancel(),this.Ni=!0;const{duration:i=200,xi: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.zi=setTimeout(()=>{Object.assign(this.element.style,{display:"none",transition:"none"}),this.Ni=!1,s?.()},i)}),this}showSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Ni=!0;const{duration:i=200,display:s="block",xi: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.zi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:""}),this.Ni=!1,e?.()},i),this}hideSwipeWidth(t){if(!this.element)return this;this.cancel(),this.Ni=!0;const{duration:i=200,xi: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.zi=setTimeout(()=>{Object.assign(this.element.style,{width:"",overflow:"",transition:"",display:""}),this.Ni=!1,s?.()},i),this}resize(t){if(!this.element)return this;this.cancel();const{duration:i=200,width:s,left:e,top:h,maxHeight:n,yi:o,position:r="bottom",animate:l=!0,xi: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._i=setTimeout(()=>{this.element?.style&&(this.element.style.transition=null)},i),Object.assign(this.element.style,t),l&&(c||r>1)?this._i=setTimeout(()=>{this.element.style.transition=null,c&&delete this.element.style.transition,a?.()},i):(c&&delete this.element.style.transition,a?.())}),this}get Ui(){return this.Ni}}class b extends r{get value(){return this.targetElement?.getAttribute("value")??null}constructor(t,i=null,s=null){super(),this.targetElement=null,this.view=null,this.position=-1,this.At=!1,this.Bi=!1,this.options=t,this.targetElement=i,this.view=s,this.init()}Gi(t){this.targetElement=t,this.update()}Wi(){}destroy(){this.is(o.DESTROYED)||(this.targetElement=null,this.view?.destroy(),this.view=null,this.Bi=!0,super.destroy())}}class y extends b{constructor(t,i){super(t,i??null,null),this.label="",this.items=[],this.collapsed=!1,this.qi=[]}init(){this.targetElement&&(this.label=this.targetElement.label,this.collapsed=e.$(this.targetElement.dataset?.collapsed)),super.init(),this.mount()}get value(){return this.items.map(t=>t.value)}get Ji(){return this.items.filter(t=>t.selected)}get Ki(){return this.items.filter(t=>t.visible)}get Qi(){return this.Ki.length>0}Gi(t){this.label=t.label,this.view?.Yi(this.label),this.update()}update(){this.view&&(this.view.Yi(this.label),this.view.Xi(this.collapsed)),super.update()}destroy(){this.is(o.DESTROYED)||(this.items.forEach(t=>{t.destroy()}),this.items=[],super.destroy())}Zi(t){this.qi.push(t)}ts(){this.collapsed=!this.collapsed,this.view?.Xi(this.collapsed),h.nt([this,this.collapsed],...this.qi)}ss(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)}es(){this.view?.es()}}class w extends b{constructor(t,i=null,s=null){super(t,i,s),this.hs=[],this.ns=[],this.rs=[],this.ls=!0,this.cs=!1,this.group=null}init(){this.us=e.J(this.textContent.toLowerCase()),super.init(),this.mount()}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.hs)}get visible(){return this.ls}set visible(t){if(this.ls===t)return;this.ls=t;const i=this.view?.gs?.();i&&i.classList.toggle("hide",!t),h.nt([this,t],...this.rs)}get ps(){return this.selected}set ps(t){const i=this.view?.view?.tags?.fs,s=this.view?.gs?.();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.ns)}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 bs(){return this.cs}set bs(t){const i=!!t,s=this.view?.gs?.();this.cs!==i&&(this.cs=i),s&&s.classList.toggle("highlight",i)}ys(t){this.hs.push(t)}ws(t){this.ns.push(t)}ci(t){this.rs.push(t)}update(){if(this.us=e.J(this.textContent.toLowerCase()),!this.view)return void super.update();const t=this.view.view.tags.vs;t&&(this.options.allowHtml?t.innerHTML=this.text:t.textContent=this.textContent);const i=this.view.view.tags.xs;i&&this.hasImage&&(i.src=this.ds,i.alt=this.text),this.targetElement&&(this.ps=this.targetElement.selected),super.update()}destroy(){this.is(o.DESTROYED)||(this.hs=[],this.ns=[],this.rs=[],this.group=null,this.us=null,super.destroy())}}class v{constructor(t){this.Os=[],this.Ms=null,this.Ts=null,this.As=null,this.options=null,this.Ss=0,this.options=t}Hs(t){this.Cs=t}Ls(t){this.Ps=t}Is(t){const i=this.Es(t),s=i!==this.As;return s&&(this.As=i),s}Es(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")}Fs(t){this.Os=[];let i=null;return t.forEach(t=>{if("OPTGROUP"===t.tagName)i=new y(this.options,t),this.Os.push(i);else if("OPTION"===t.tagName){const s=t,e=new w(this.options,s),h=s.__parentGroup;h&&i&&h===i.targetElement?(i.ss(e),e.group=i):(this.Os.push(e),i=null)}}),this.Os}async replace(t){this.As=null,this.Fs(t),this.Ms&&await this.Ms.js(this.Os),this.refresh(!1)}notify(){this.Ms&&this.refresh(!1)}load(t,i={},s={}){this.Ms=new this.Cs(this.Os),Object.assign(this.Ms,i),this.Ts=new this.Ps(t),Object.assign(this.Ts,s),this.Ts.$s(this.Ms)}update(t){if(!this.Is(t))return;const i=this.Os,s=[],e=new Map,h=new Map;i.forEach(t=>{t instanceof y?e.set(t.label,t):t instanceof w&&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.Gi(i),h.position=o,h.items=[],n=h,s.push(h),e.delete(i.label)):(n=new y(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.Gi(i),r.position=o,i.__parentGroup&&n?(n.ss(r),r.group=n):(r.group=null,s.push(r)),h.delete(e);else{const t=new w(this.options,i);t.position=o,i.__parentGroup&&n?(n.ss(t),t.group=n):s.push(t)}o++}});let r=!0;0==this.Ss&&(r=!1),this.Ss=o,e.forEach(t=>{r=!1,t.destroy()}),h.forEach(t=>{r=!1,t.destroy()}),this.Os=s,this.Ms&&this.Ms.Vs(this.Os),this.refresh(r)}onUpdated(){}hi(t){this.Ms&&(this.Ms.ks=t)}refresh(t){this.Ts&&(this.Ts.refresh(t),this.onUpdated())}Zt(){return{Rs:this.Os,ti:this.Ms,Rt:this.Ts}}Ds(t){return this.Ms?.zs(t)}_s(t){return this.Ms?.Ns(t)}}class x extends r{constructor(t=null){super(),this.Us=null,this.ti=null,this.Us=t,this.init()}$s(t){this.ti=t,t.pi("items",()=>{this.clear()}),t.ui("items",()=>{this.Bs()}),t.mount(),this.mount(),this.Bs()}clear(){this.Us&&this.Us.replaceChildren()}Bs(){this.ti&&this.Us&&(this.ti.Gs(this.Us),this.update())}refresh(t){this.Bs()}destroy(){this.is(o.DESTROYED)||(this.ti?.destroy?.(),this.Us=null,this.ti=null,super.destroy())}}class O extends r{constructor(t=null){super(),this.bt=null,this.node=null,this.options=null,this.Ws=null,this.qs=null,this.Wt=null,this.Js=[],t&&this.initialize(t)}initialize(t){this.options=t,this.init()}init(){this.state===o.NEW&&(this.bt=e.I({Ks:{tag:{node:"div",classList:["selective-ui-accessorybox","hide"],onmouseup:t=>{t.stopPropagation()}}}}),this.node=this.bt.view,super.init())}Qs(t){this.Ws=t,this.qs=t.parentElement,this.Ys(),this.mount()}mount(){this.is(o.INITIALIZED)&&super.mount()}Ys(){this.qs&&this.node&&this.Ws&&this.options&&this.qs.insertBefore(this.node,"top"===this.options.accessoryStyle?this.Ws:this.Ws.nextSibling)}Xs(t){this.Wt=t}Zs(t){this.node&&this.options&&(this.node.replaceChildren(),t.length>0&&this.options.multiple?t.forEach(t=>{e.I({te:{tag:{node:"div",classList:["accessory-item"]},F:{ie:{tag:{node:"span",classList:["accessory-item-button"],role:"button",ariaLabel:`${this.options.textAccessoryDeselect}${t.textContent}`,title:`${this.options.textAccessoryDeselect}${t.textContent}`,onclick:async i=>{i.preventDefault(),await(this.Wt?.Ds?.("select")),t.selected=!1}}},se:{tag:{node:"span",classList:["accessory-item-content"],innerHTML:t.text}}}}},this.node)}):t=[],this.Js=t,this.ee(),this.update(),h.ot(window,"resize"))}update(){this.state===o.MOUNTED&&super.update()}ee(){this.options?.accessoryVisible&&this.Js.length>0&&this.options.multiple?this.show():this.hide()}show(){this.node?.classList.remove("hide")}hide(){this.node?.classList.add("hide")}destroy(){this.state!==o.DESTROYED&&(this.node?.remove(),this.bt=null,this.node=null,this.options=null,this.Ws=null,this.qs=null,this.Wt=null,this.Js=[],super.destroy())}}class M extends r{constructor(t,i,s){super(),this.he=null,this.ne=null,this.oe=null,this.re=null,this.le={currentPage:0,totalPages:1,hasMore:!1,Hi:!1,ae:"",Si:!1},this.initialize(t,i,s)}initialize(t,i,s){this.select=t,this.Wt=i,this.re=s,this.init()}ce(){return!!this.he}async ue(t){if(!this.he)return{Li:!1,items:[],message:"Ajax not configured"};const i=Array.isArray(t)?t:[t];if(0===i.length)return{Li:!0,items:[]};try{const t=this.he;let s,e;if(s="function"==typeof t.de?t.de(i):{values:i.join(","),pe:"1",..."function"==typeof t.data?t.data.bind(this.re.ge.find(this.re.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(),n=this.fe(h);return this.update(),{Li:!0,items:n.items}}catch(s){return console.error("Load by values error:",s),{Li:!1,message:s?.message,items:[]}}}me(t){const i=Array.from(this.select.options).map(t=>t.value);return{be:t.filter(t=>i.includes(t)),ye:t.filter(t=>!i.includes(t))}}we(t){this.he=t}setPopup(t){this.oe=t}Ai(){return{...this.le}}ve(){this.le={currentPage:0,totalPages:1,hasMore:!1,Hi:!1,ae:"",Si:this.le.Si}}clear(){this.le.ae="";const{Rs:t}=this.Wt.Zt(),i=[];for(const s of t)s instanceof w?i.push(s):s instanceof y&&Array.isArray(s.items)&&i.push(...s.items);i.forEach(t=>{t.visible=!0})}async search(t,i=!1){return this.he?this.xe(t,i):this.Oe(t)}async Ci(){return this.he?this.le.Hi?{Li:!1,message:"Already loading"}:this.le.Si?this.le.hasMore?(this.le.currentPage++,this.xe(this.le.ae,!0)):{Li:!1,message:"No more data"}:{Li:!1,message:"Pagination not enabled"}:{Li:!1,message:"Ajax not enabled"}}async Oe(t){this.Me(t)&&(this.le.ae=t);const i=((t??"")+"").toLowerCase(),s=e.J(i),{Rs:h}=this.Wt.Zt(),n=[];for(const e of h)e instanceof w?n.push(e):e instanceof y&&Array.isArray(e.items)&&n.push(...e.items);let o=!1;return n.forEach(t=>{const e=""===i||t.us.includes(s);t.visible=e,e&&(o=!0)}),this.update(),{Li:!0,Te:o,isEmpty:0===n.length}}Me(t){return t!==this.le.ae}async xe(t,i=!1){const s=this.he;this.Me(t)&&(this.ve(),this.le.ae=t,i=!1),this.le.Hi=!0,this.oe?.ei(),this.ne?.abort(),this.ne=new AbortController;const e=this.le.currentPage,h=Array.from(this.select.selectedOptions).map(t=>t.value).join(",");let n;"function"==typeof s.data?(n=s.data.bind(this.re.ge.find(this.re.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.ne.signal})}else{const i=""+new URLSearchParams(n);t=await fetch(`${s.url}?${i}`,{signal:this.ne.signal})}const e=await t.json(),h=this.fe(e);return h.Ae?(this.le.Si=!0,this.le.currentPage=h.page,this.le.totalPages=h.totalPages,this.le.hasMore=h.hasMore):this.le.Si=!1,this.Se(h.items,!!s.keepSelected,i),this.le.Hi=!1,this.oe?.li(),this.update(),{Li:!0,Te:h.items.length>0,isEmpty:0===h.items.length,Ae:h.Ae,hasMore:h.hasMore,currentPage:h.page,totalPages:h.totalPages}}catch(o){return this.le.Hi=!1,this.oe?.li(),"AbortError"===o?.name?{Li:!1,message:"Request aborted"}:(console.error("Ajax search error:",o),{Li:!1,message:o?.message})}}fe(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.He||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}}),Ae:s,page:e,totalPages:h,hasMore:n}}Se(t,i,s=!1){const e=this.select;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)}})}destroy(){this.is(o.DESTROYED)||(this.select=null,this.Wt=null,this.he=null,this.ne=null,this.oe=null,this.re=null,super.destroy())}}class T{constructor(t){this.Ce=null,this.Le=null,this.Pe=50,this.select=t,this.Le=this.Ie(),this.Ee=new MutationObserver(()=>{this.Ce&&clearTimeout(this.Ce),this.Ce=setTimeout(()=>{this.Fe()},this.Pe)})}Ie(){const t=Array.from(this.select.options);return{length:t.length,values:t.map(t=>t.value).join(","),je:t.map(t=>t.text).join(","),selected:t.map(t=>t.selected+"").join(",")}}$e(){const t=this.Ie(),i=JSON.stringify(t)!==JSON.stringify(this.Le);return i&&(this.Le=t),i}Fe(){this.$e()&&this.Pt(this.select)}connect(){this.Ee.observe(this.select,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["selected","value","disabled"]})}Pt(t){}disconnect(){this.Ce&&clearTimeout(this.Ce),this.Ce=null,this.Ee.disconnect()}}class A{constructor(t){this.Ce=null,this.element=t,this.Ee=new MutationObserver(t=>{let i=!1;for(const s of t)if("attributes"===s.type&&s.attributeName?.startsWith("data-")){i=!0;break}i&&(this.Ce&&clearTimeout(this.Ce),this.Ce=setTimeout(()=>{this.Pt({...this.element.dataset})},50))}),t.addEventListener("dataset:changed",()=>{this.Pt({...this.element.dataset})})}connect(){this.Ee.observe(this.element,{attributes:!0,attributeOldValue:!0})}Pt(t){}disconnect(){this.Ce&&clearTimeout(this.Ce),this.Ce=null,this.Ee.disconnect()}}class S extends r{constructor(t=[]){super(),this.items=[],this.Ve=e.m(12),this.ks=!1,this.items=t,this.init()}ke(t,i,s){const e=i;t.At?e?.update?.():e?.mount?.()}pi(t,i){e.Z.on(`${t}ing_${this.Ve}`,i,{st:0})}ui(t,i){e.Z.on(`${t}_${this.Ve}`,i,{st:0})}Ns(t,...i){return e.Z.run(`${t}_${this.Ve}`,...i)}zs(t,...i){return e.Z.run(`${t}ing_${this.Ve}`,...i)}Re(t,i){return null}De(){return this.items.length}async ze(t){await this.zs("items",t),this.items=t,await this.Ns("items",t),this.update()}async js(t){await this.ze(t)}Gs(t){for(let i=0;i<this.De();i++){const s=this.items[i];let e=s.view;s.At||(e=this.Re(t,s),s.view=e),this.ke(s,e,i),s.At=!0}}Vs(t){}destroy(){this.is(o.DESTROYED)||(this.Rt=null,this.items.forEach(t=>{t?.destroy?.()}),this.items=[])}}class H extends r{constructor(t){super(),this.parent=null,this.view=null,this.parent=t,this.init()}gs(){if(!this.view?.view)throw Error("View is not mounted. Did you forget to set this.view?");return this.view.view}destroy(){this.is(o.DESTROYED)||(this.gs()?.remove?.(),this.parent=null,this.view=null,super.destroy())}}class C extends H{constructor(){super(...arguments),this.view=null}mount(){const t=e.m(7);this.view=e.P({_e:{tag:{node:"div",classList:["selective-ui-group"],role:"group",A:`seui-${t}-header`,id:`seui-${t}-group`},F:{Ne:{tag:{node:"div",classList:["selective-ui-group-header"],role:"presentation",id:`seui-${t}-header`}},Ue:{tag:{node:"div",classList:["selective-ui-group-items"],role:"group"}}}}}),this.parent.appendChild(this.view.view),super.mount()}update(){this.Yi(),super.update()}Yi(t=null){this.view&&null!==t&&(this.view.tags.Ne.textContent=t)}Be(){if(!this.view)throw Error("GroupView has not been rendered.");return this.view.tags.Ue}es(){if(!this.view)return;const t=Array.from(this.view.tags.Ue.children).filter(t=>!t.classList.contains("hide"));this.view.view.classList.toggle("hide",0===t.length)}Xi(t){this.view&&(this.view.view.classList.toggle("collapsed",t),this.view.tags.Ne.setAttribute("aria-expanded",t?"false":"true"))}}class L extends H{constructor(t){super(t),this.view=null,this.config=null,this.Ge=null,this.We=!1,this.initialize()}initialize(){const t=this;this.config={isMultiple:!1,hasImage:!1,imagePosition:"right",imageWidth:"60px",imageHeight:"60px",imageBorderRadius:"4px",labelValign:"center",labelHalign:"left"},this.Ge=new Proxy(this.config,{set(i,s,e){if("string"!=typeof s)return!0;const h=s,n=i[h];return n!==e&&(i[h]=e,t.We&&t.qe(h,e,n)),!0}}),this.init()}get isMultiple(){return this.config.isMultiple}set isMultiple(t){this.Ge.isMultiple=!!t}get hasImage(){return this.config.hasImage}set hasImage(t){this.Ge.hasImage=!!t}get Je(){return this.Ge}set Je(t){if(!t||!this.Ge||!this.config)return;const i={};void 0!==t.imageWidth&&t.imageWidth!==this.config.imageWidth&&(i.imageWidth=t.imageWidth),void 0!==t.imageHeight&&t.imageHeight!==this.config.imageHeight&&(i.imageHeight=t.imageHeight),void 0!==t.imageBorderRadius&&t.imageBorderRadius!==this.config.imageBorderRadius&&(i.imageBorderRadius=t.imageBorderRadius),void 0!==t.imagePosition&&t.imagePosition!==this.config.imagePosition&&(i.imagePosition=t.imagePosition),void 0!==t.labelValign&&t.labelValign!==this.config.labelValign&&(i.labelValign=t.labelValign),void 0!==t.labelHalign&&t.labelHalign!==this.config.labelHalign&&(i.labelHalign=t.labelHalign),Object.keys(i).length>0&&Object.assign(this.Ge,i)}mount(){const t=["selective-ui-option-view"],i=e.m(7),s="option_"+i;this.config.isMultiple&&t.push("multiple"),this.config.hasImage&&t.push("has-image","image-"+this.config.imagePosition);const h={fs:{tag:{node:"input",type:this.config.isMultiple?"checkbox":"radio",classList:"allow-choice",id:s}},...this.config.hasImage&&{xs:{tag:{node:"img",classList:"option-image",style:{width:this.config.imageWidth,height:this.config.imageHeight,borderRadius:this.config.imageBorderRadius}}}},Ke:{tag:{node:"label",htmlFor:s,classList:["align-vertical-"+this.config.labelValign,"align-horizontal-"+this.config.labelHalign]},F:{vs:{tag:{node:"div"}}}}};this.view=e.P({Qe:{tag:{node:"div",id:`seui-${i}-option`,classList:t,role:"option",ariaSelected:"false",tabIndex:"-1"},F:h}}),this.parent.appendChild(this.view.view),this.We=!0,super.mount()}qe(t,i,s){const e=this.view;if(!e||!e.view)return;const h=e.view,n=e.tags?.fs,o=e.tags?.Ke;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.config.imagePosition),this.Ye();else{h.className=h.className.replace(/image-(top|right|bottom|left)/g,"").trim();const t=e.tags?.xs;t?.remove(),e.tags.xs=null}break}case"imagePosition":this.config.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?.xs;s&&(s.style["imageWidth"===t?"width":"imageHeight"===t?"height":"borderRadius"]=i+"");break}case"labelValign":case"labelHalign":o&&(o.className=`align-vertical-${this.config.labelValign} align-horizontal-`+this.config.labelHalign)}}Ye(){const t=this.view;if(!t||!t.view)return;if(t.tags?.xs)return;const i=t.view,s=t.tags?.Ke,e=document.createElement("img");e.className="option-image",e.style.width=this.config.imageWidth,e.style.height=this.config.imageHeight,e.style.borderRadius=this.config.imageBorderRadius,s?.parentElement?i.insertBefore(e,s):i.appendChild(e),t.tags.xs=e}}class P extends S{constructor(t=[]){super(t),this.isMultiple=!1,this.Xe=[],this.Ze=-1,this.th=null,this.groups=[],this.ih=[],this.sh()}init(){e.Z.on("sche_vis_"+this.Ve,()=>{const t=this.ih.filter(t=>t.visible).length,i=this.ih.length;this.Xe.forEach(s=>{s({eh:t,hh:i,ni:t>0,isEmpty:0===i})}),e.Z.run("sche_vis_proxy_"+this.Ve)},{st:10}),super.init(),this.mount()}sh(){this.ih=[],this.groups=[],this.items.forEach(t=>{t instanceof y?(this.groups.push(t),this.ih.push(...t.items)):t instanceof w&&this.ih.push(t)})}Re(t,i){return i instanceof y?new C(t):new L(t)}ke(t,i,s){t.position=s,t instanceof y?this.nh(t,i,s):t instanceof w&&this.oh(t,i,s),t.At=!0}nh(t,i,s){super.ke(t,i,s),t.view=i;const e=i.view.tags.Ne;e.textContent=t.label,t.At||(e.style.cursor="pointer",e.addEventListener("click",()=>{t.ts()}),t.Zi((t,i,s)=>{i.items.forEach(t=>{const i=t.view?.gs?.();i&&(i.style.display=s?"none":"")}),this.rh(i,s)}));const h=i.Be();t.items.forEach((t,i)=>{let s=t.view;t.At&&s||(s=new L(h)),this.oh(t,s,i),t.At=!0}),i.Xi(t.collapsed),i.es()}oh(t,i,s){if(i.isMultiple=this.isMultiple,i.hasImage=t.hasImage,i.Je={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.At||super.ke(t,i,s),t.view=i,t.hasImage){const s=i.view.tags.xs;s&&(s.src!==t.ds&&(s.src=t.ds),s.alt!==t.text&&(s.alt=t.text))}i.view.tags.vs.innerHTML=t.text,t.At||(i.view.tags.Qe.addEventListener("click",async i=>{i.stopPropagation(),i.preventDefault(),this.ks||(this.isMultiple?(await this.zs("select"),t.selected=!t.selected):!0!==t.selected&&(await this.zs("select"),this.th&&(this.th.selected=!1),t.selected=!0))}),i.view.tags.Qe.title=t.textContent,i.view.tags.Qe.addEventListener("mouseenter",()=>{this.ks||this.ah(this.ih.indexOf(t),!1)}),t.ys(()=>{this.Ns("selected")}),t.ws((i,s,e)=>{e&&(this.th=t),this.Ns("selected_internal")}),t.ci((t,i)=>{i.group?.es(),this.uh()})),t.selected&&(this.th=t,t.ps=!0)}async ze(t){await this.zs("items",t),this.items=t,this.sh(),await this.Ns("items",t),this.update()}async js(t){await this.ze(t)}Vs(t){this.items=t,this.sh(),this.update()}destroy(){this.is(o.DESTROYED)||(e.Z.clear("sche_vis_"+this.Ve),this.groups.forEach(t=>{t.destroy()}),this.Xe=[],this.Ze=-1,this.th=null,this.groups=[],this.ih=[],super.destroy())}dh(){return this.ih.filter(t=>t.selected)}ph(){return this.ih.find(t=>t.selected)}ii(t){this.isMultiple&&this.ih.forEach(i=>{i.selected=t})}ci(t){this.Xe.push(t)}uh(){e.Z.run("sche_vis_"+this.Ve)}oi(){const t=this.ih.filter(t=>t.visible).length,i=this.ih.length;return{eh:t,hh:i,ni:t>0,isEmpty:0===i}}gh(){this.ah(0)}navigate(t,i=!0){const s=this.ih.filter(t=>t.visible);if(0===s.length)return;let e=s.findIndex(t=>t===this.ih[this.Ze]);-1===e&&(e=-1);let h=e+t;h>=s.length&&(h=0),h<0&&(h=s.length-1);const n=this.ih.indexOf(s[h]);this.ah(n,i)}fh(){if(this.Ze>-1&&this.ih[this.Ze]){const t=this.ih[this.Ze];if(t.visible){const i=t.view?.gs?.();i&&i.click()}}}ah(t,i=!0){let s=0;if("number"==typeof t)s=t;else if(t instanceof w){const i=this.ih.indexOf(t);s=i>-1?i:0}else s=0;this.Ze>-1&&this.ih[this.Ze]&&(this.ih[this.Ze].bs=!1);for(let e=s;e<this.ih.length;e++){const t=this.ih[e];if(t?.visible){if(t.bs=!0,this.Ze=e,i){const i=t.view?.gs?.();i?i.scrollIntoView({block:"center",behavior:"smooth"}):this.Rt?.mh?.(e,{scrollIntoView:!0})}return void this.bh(e,t.view?.gs?.()?.id)}}}bh(t,i){}rh(t,i){}}class I extends r{constructor(t=0){super(),this.yh=[],this.wh=0,this.initialize(t)}initialize(t){this.init(),this.reset(t)}reset(t){this.wh=t,this.yh=Array(t+1).fill(0)}add(t,i){for(let s=t;s<=this.wh;s+=s&-s)this.yh[s]+=i}xh(t){let i=0;for(let s=t;s>0;s-=s&-s)i+=this.yh[s];return i}Oh(t,i){return i<t?0:this.xh(i)-this.xh(t-1)}Mh(t){this.reset(t.length),t.forEach((t,i)=>this.add(i+1,t))}Th(t){let i=0,s=1;for(;s<<1<=this.wh;)s<<=1;let e=0;for(let h=s;0!==h;h>>=1){const s=i+h;s<=this.wh&&e+this.yh[s]<=t&&(i=s,e+=this.yh[s])}return i}}class E extends x{constructor(t=null){super(t),this.Ah={Xt:void 0,Ut:36,Bt:8,Gt:!0,Sh:!0},this.Hh=[],this.Ch=new I(0),this.Lh=new Map,this.Ph=!1,this.start=0,this.end=-1,this.Ih=null,this.Eh=null,this.updating=!1,this.Fh=!1,this.jh=0,this.$h=!1,this.Vh=!1,this.kh=0,this.Rh=0,this.Dh=0,this.zh=0}configure(t){this.Ah={...this.Ah,...t}}$s(t){if(this.ti&&this.dispose(),super.$s(t),t.Rt=this,!this.Us)return;this.Us.replaceChildren();const i=e.I({_h:{tag:{node:"div",classList:"selective-ui-virtual-pad-top"}},Nh:{tag:{node:"div",classList:"selective-ui-virtual-items"}},Uh:{tag:{node:"div",classList:"selective-ui-virtual-pad-bottom"}}},this.Us);if(this._h=i._h,this.Nh=i.Nh,this.Uh=i.Uh,this.Xt=this.Ah.Xt??this.Us.closest(".selective-ui-popup")??this.Us.parentElement,!this.Xt)throw Error("VirtualRecyclerView: scrollEl not found");this.Bh=this.Gh.bind(this),this.Xt.addEventListener("scroll",this.Bh,{passive:!0}),this.refresh(!1),this.Wh(),t?.ci?.(()=>this.qh())}suspend(){this.$h=!0,this.Jh(),this.Xt&&this.Bh&&this.Xt.removeEventListener("scroll",this.Bh),this.Kh&&(this.Kh.disconnect(),this.Vh=!0)}resume(){this.$h=!1,this.Xt&&this.Bh&&this.Xt.addEventListener("scroll",this.Bh,{passive:!0}),this.Vh&&(this.Wh(),this.Vh=!1),this.Qh()}refresh(t){if(!this.ti||!this.Us)return;t||this.qh();const i=this.ti.De();if(this.jh=i,0===i)return this.Yh(),void this.update();this.Hh.length=i,this.Ph||(this.Xh(),this.Ph=!0),this.Zh(i),this.Qh(),this.update()}mh(t,i){this.tn(t,t),i?.scrollIntoView&&this.sn(t)}sn(t){if((this.ti?.De?.()??0)<=0)return;const i=this.en(t),s=this.hn()+i,e=Math.max(0,this.Xt.scrollHeight-this.Xt.clientHeight);this.Xt.scrollTop=Math.min(Math.max(0,s),e)}dispose(){this.Jh(),this.Xt&&this.Bh&&this.Xt.removeEventListener("scroll",this.Bh),this.Kh?.disconnect(),this.Lh.forEach(t=>t.remove()),this.Lh.clear()}destroy(){this.is(o.DESTROYED)||(this.Yh(),this.dispose(),this._h.remove(),this.Nh.remove(),this.Uh.remove(),this._h=null,this.Nh=null,this.Uh=null,super.destroy())}qh(){if(!this.ti)return;const t=this.ti.De();t<=0||(this.suspend(),this.Yh(),this.nn(),this.rn(t),this.Zh(t),this.start=0,this.end=-1,this.resume())}Jh(){null!=this.Ih&&(cancelAnimationFrame(this.Ih),this.Ih=null),null!=this.Eh&&(cancelAnimationFrame(this.Eh),this.Eh=null)}Yh(){this.Lh.forEach(t=>t.remove()),this.Lh.clear(),this.Hh=[],this.Ch.reset(0),this._h.style.height="0px",this.Uh.style.height="0px",this.Ph=!1,this.Dh=0,this.zh=0}Xh(){this.ln(0);const t=this.Lh.get(0);if(!t)return;const i=this.an(t);if(isNaN(i)||(this.Ah.Ut=i),!this.Ah.Gt){t.remove(),this.Lh.delete(0);const i=this.ti.items[0];i&&(i.At=!1,i.view=null)}}cn(t){const i=this.ti?.items?.[t];return i?.visible??!0}un(t,i){for(let s=Math.max(0,t);s<i;s++)if(this.cn(s))return s;return-1}rn(t){this.Dh=0,this.zh=0;for(let i=0;i<t;i++){if(!this.cn(i))continue;const t=this.Hh[i];null!=t&&(this.Dh+=t,this.zh++)}}hn(){const t=this.Us.getBoundingClientRect(),i=this.Xt.getBoundingClientRect();return Math.max(0,t.top-i.top+this.Xt.scrollTop)}dn(){const t=performance.now();if(t-this.kh<16)return this.Rh;const i=this.Xt.querySelector(".selective-ui-option-handle:not(.hide)");return this.Rh=i?.offsetHeight??0,this.kh=t,this.Rh}Qh(){null!=this.Ih||this.$h||(this.Ih=requestAnimationFrame(()=>{this.Ih=null,this.pn()}))}an(t){const i=t.getBoundingClientRect(),s=getComputedStyle(t);return Math.max(1,i.height+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}gn(){return this.Ah.Sh&&this.zh>0?Math.max(1,this.Dh/this.zh):this.Ah.Ut}Zh(t){const i=this.gn(),s=Array.from({length:t},(t,s)=>this.cn(s)?this.Hh[s]??i:0);this.Ch.Mh(s)}fn(t,i){if(!this.cn(t))return!1;const s=this.gn(),e=this.Hh[t]??s;if(Math.abs(i-e)<=E.mn)return!1;const h=this.Hh[t];return null==h?(this.Dh+=i,this.zh++):this.Dh+=i-h,this.Hh[t]=i,this.Ch.add(t+1,i-e),!0}bn(t,i){const s=this.Ch.Th(Math.max(0,t)),e=Math.min(i-1,s),h=this.un(e,i);return-1===h?Math.max(0,e):h}yn(t,i){i.setAttribute(E.wn,t+"");const s=this.Lh.get(t-1);if(s?.parentElement===this.Nh)return void s.after(i);const e=this.Lh.get(t+1);if(e?.parentElement===this.Nh)return void this.Nh.insertBefore(i,e);const h=Array.from(this.Nh.children);for(const n of h){const s=n.getAttribute(E.wn);if(s&&+s>t)return void this.Nh.insertBefore(i,n)}this.Nh.appendChild(i)}vn(t,i){if(i.parentElement!==this.Nh)return void this.yn(t,i);i.setAttribute(E.wn,t+"");const s=i.previousElementSibling,e=i.nextElementSibling;(s&&+s.getAttribute(E.wn)>t||e&&+e.getAttribute(E.wn)<t)&&(i.remove(),this.yn(t,i))}Wh(){this.Kh||(this.Kh=new ResizeObserver(()=>{this.Fh||this.$h||!this.ti||null!=this.Eh||(this.Eh=requestAnimationFrame(()=>{this.Eh=null,this.xn()}))}),this.Kh.observe(this.Nh))}xn(){if(!this.ti)return;const t=this.ti.De();if(t<=0)return;let i=!1;for(let s=this.start;s<=this.end;s++){if(!this.cn(s))continue;const t=this.ti.items[s],e=t?.view?.gs?.();if(!e)continue;const h=this.an(e);this.fn(s,h)&&(i=!0)}i&&(this.Ah.Sh&&this.Zh(t),this.Qh())}Gh(){this.Qh()}pn(){if(!this.updating&&!this.$h){this.updating=!0;try{if(!this.ti)return;const t=this.ti.De();if(t<=0)return;this.jh!==t&&(this.jh=t,this.Hh.length=t,this.Zh(t));const i=this.hn(),s=Math.max(0,this.Xt.scrollTop-i),e=this.dn(),h=Math.max(0,this.Xt.clientHeight-e),n=this.bn(s,t),o=this.en(n),r=i+o-this.Xt.scrollTop,l=this.bn(s,t);if(-1===l)return void this.Yh();const a=this.gn(),c=this.Ah.Bt*a;let u=this.un(Math.min(t-1,this.Ch.Th(Math.max(0,s-c))),t)??l,d=Math.min(t-1,this.Ch.Th(s+h+c));if(u===this.start&&d===this.end)return;this.start=u,this.end=d,this.Fh=!0;try{this.tn(this.start,this.end),this.On(this.start,this.end),this.Ah.Gt&&this.xn();const i=this.en(this.start),s=this.Mn(this.start,this.end),e=this.Tn(t),h=Math.max(0,e-i-s);this._h.style.height=i+"px",this.Uh.style.height=h+"px"}finally{this.Fh=!1}const p=this.en(n),g=this.hn()+p-r,f=Math.max(0,this.Xt.scrollHeight-this.Xt.clientHeight),m=Math.min(Math.max(0,g),f),b=Math.abs(p-o)>1,y=Math.abs(this.Xt.scrollTop-m);b&&y>.5&&y<100&&(this.Xt.scrollTop=m)}finally{this.updating=!1}}}tn(t,i){for(let s=t;s<=i;s++)this.ln(s)}ln(t){if(!this.cn(t)){const i=this.Lh.get(t);return i?.parentElement===this.Nh&&i.remove(),void this.Lh.delete(t)}const i=this.ti.items[t];if(!i)return;const s=this.Lh.get(t);if(s)return void(i?.view?(this.vn(t,s),this.ti.ke(i,i.view,t)):(s.remove(),this.Lh.delete(t)));if(i.At)i.view&&this.ti.ke(i,i.view,t);else{const s=this.ti.Re(this.Nh,i);i.view=s,this.ti.ke(i,s,t),i.At=!0}const e=i.view?.gs?.();e&&(this.vn(t,e),this.Lh.set(t,e))}On(t,i){this.Lh.forEach((s,e)=>{(e<t||e>i)&&(s.parentElement===this.Nh&&s.remove(),this.Lh.delete(e))})}nn(){this.Lh.forEach((t,i)=>{this.cn(i)||(t.parentElement===this.Nh&&t.remove(),this.Lh.delete(i))})}en(t){return this.Ch.xh(t)}Mn(t,i){return this.Ch.Oh(t+1,i+1)}Tn(t){return this.Ch.xh(t)}}E.mn=.5,E.wn="data-vindex";class F extends r{constructor(t=null,i=null){super(),this.container={},this.oldValue=null,this.node=null,this.options=null,this.An=null,this.isOpen=!1,this.Sn=!1,this.Hn=!1,this.ge=null,t&&i&&this.initialize(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 Cn(){return!!this.options?.readonly}set Cn(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))}initialize(t,i){const s=e.R(t);this.options=s.options,this.ge=i,this.init(t)}init(t){if(this.state!==o.NEW)return;if(!t||!this.options)return;const s=this.options,h=new l(s),n=new a,r=new f(s),effector=i(),c=new v(s),u=new O(s),d=new M(t,c,this),p=new T(t),m=new A(t);h.node&&(h.node.id=(s.Ln??"")+"");const b=e.I({Pn:{tag:{node:"div",classList:"selective-ui-MAIN"},F:{Mi:{tag:{node:"div",classList:"selective-ui-view",tabIndex:0,onkeydown:t=>{"Enter"!==t.key&&" "!==t.key&&"ArrowDown"!==t.key||(t.preventDefault(),this.In()?.open())}},F:{En:{tag:h.node},Fn:{tag:n.node},ki:{tag:r.node}}}}}},null);this.container=b,this.node=b.view,b.jn=d,b.placeholder=h,b.$n=n,b.Vn=r,b.effector=effector,b.targetElement=t,b.kn=u,b.Rn=p,b.Dn=m,c.Hs(P),c.Ls(s.virtualScroll?E:x),c.Fs(e.K(t)),c.onUpdated=()=>{b.oe?.ri?.()},this.An=c,b.oe=new g(t,s,c),b.oe.fi(effector),b.oe.Ti(d,s),b.oe.gi("selected",()=>{this.In()?.change(null,!0)}),b.oe.gi("selected_internal",()=>{this.In()?.change(null,!1)}),b.oe.di("select",()=>{this.oldValue=this.In()?.value??""}),u.Qs(b.tags.Mi),u.Xs(c),this.zn(t,b,s,d,r),this._n(p,m,t,c),this.isDisabled=e.$(s.disabled),this.Cn=e.$(s.readonly),super.init()}mount(){if(this.state!==o.INITIALIZED)return;if(!this.node||!this.container.targetElement)return;const t=this.container.targetElement,i=this.container;t.parentNode?.insertBefore(this.node,t),this.node.insertBefore(t,i.tags.Mi),i.tags.Mi.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),n.lt(t,i.tags.Mi),t.classList.add("init"),this.In()?.change(null,!1),super.mount()}update(){this.state===o.MOUNTED&&(this.container.oe?.ri?.(),super.update())}zn(t,i,s,h,n){const o=i.oe.Et;let r=null;const l=(t,n)=>{n||""!==t?(""!==t&&(this.Hn=!0),h.search(t).then(t=>{clearTimeout(r),e.Z.clear("sche_vis_proxy_"+o.Ve),e.Z.on("sche_vis_proxy_"+o.Ve,()=>{i.oe?.ri?.(),t?.Te&&(r=setTimeout(()=>{o.gh(),i.oe?.ri?.()},s.animationtime??0))},{st:10})}).catch(t=>{console.error("Search error:",t)})):h.clear()};let a=null;n.Fi=(t,e)=>{h.Me(t)&&(a&&clearTimeout(a),h.ce()?(i.oe?.ei?.(),a=setTimeout(()=>{l(t,e)},s.delaysearchtime??0)):a=setTimeout(()=>{l(t,e)},10))},h.setPopup(i.oe),n.ji=t=>{o.navigate(t)},n.$i=()=>{o.fh()},n.Vi=()=>{this.In()?.close(),i.tags.Mi.focus()},o.bh=(t,i)=>{i&&n.Di(i)},o.rh=()=>{i.oe?.ri?.()},s.ajax&&h.we(s.ajax)}_n(t,i,s,h){t.connect(),t.Pt=t=>{h.update(e.K(t)),this.In()?.refreshMask()},i.connect(),i.Pt=t=>{e.$(t.disabled)!==this.isDisabled&&(this.isDisabled=e.$(t.disabled)),e.$(t.readonly)!==this.Cn&&(this.Cn=e.$(t.readonly)),e.$(t.visible)!==this.isVisible&&(this.isVisible=e.$(t.visible??"1"))}}Nn(){const t=this.container??{},{Rn:i,Dn:s}=t;i?.disconnect&&i.disconnect(),s?.disconnect&&s.disconnect()}destroy(){if(this.is(o.DESTROYED))return;this.Nn();const t=this.container;t.jn.destroy(),t.$n.destroy(),t.oe.destroy(),t.kn.destroy(),t.placeholder.destroy(),t.Vn.destroy(),this.node?.remove(),this.container={},this.node=null,this.options=null,this.An=null,this.ge=null,this.oldValue=null,this.isOpen=!1,this.Sn=!1,this.Hn=!1,super.destroy()}In(){const t=this.container,i=this,s=()=>this.ge.find(t.targetElement),n=e.R(t.targetElement);if(!n)return null;const r=n.options,l={get targetElement(){return t.targetElement},get placeholder(){return t.placeholder.get()},set placeholder(i){t.placeholder?.set(i),t.Vn?.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.Un().forEach(i=>{i.selected&&t.push(i.value)}),t},get valueString(){return this.valueArray.join(r.customDelimiter)},get valueOptions(){const t=[];return i.Un(!0).forEach(i=>{t.push(i)}),t},get mask(){const t=[];return i.Un(!0).forEach(i=>{t.push(i.text)}),t},get valueText(){const t=[];i.Un(!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.Un(!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(!(r.multiple&&r.maxSelected>0&&i.Un().length>r.maxSelected)&&!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.nt([s()],...r.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Un().forEach(t=>{t.ps=!0}),this.change(!1,e)}},deSelectAll(t,e=!0){if(!this.disabled&&!this.readonly&&r.multiple){if(e){if(h.nt([s()],...r.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Un().forEach(t=>{t.ps=!1}),this.change(!1,e)}},setValue(e=null,n,o=!0,l=!1){if(Array.isArray(n)||(n=[n]),0===(n=n.filter(t=>""!==t&&null!=t)).length)return i.Un().forEach(t=>t.ps=!1),void this.change(!1,o);if(r.multiple&&r.maxSelected>0&&n.length>r.maxSelected)console.warn(`Cannot select more than ${r.maxSelected} items`);else if(l||!this.disabled&&!this.readonly){if(t.jn?.ce?.()){const{ye:s}=t.jn.me(n);if(s.length>0)return void(async()=>{r.loadingfield&&t.oe?.ei?.();try{t.jn.ve();const e=await t.jn.ue(s);e.Li&&e.items.length>0?(e.items.forEach(t=>{s.includes(t.value)&&(t.selected=!0)}),t.jn.Se?.(e.items,!0,!0),setTimeout(()=>{i.Un().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{r.loadingfield&&t.oe?.li?.()}})()}if(o){if(h.nt([s()],...r.on.beforeChange).isCancel)return;i.oldValue=this.value}i.Un().forEach(t=>{t.ps=n.some(i=>i==t.value)}),!r.multiple&&n.length>0&&(t.targetElement.value=n[0]),this.change(!1,o)}},open(){if(i.isOpen)return;const e=i.ge?.find?.();if(e&&!e.isEmpty&&e.close().isCancel)return;if(this.disabled)return;if(h.nt([s()],...r.on.beforeShow).isCancel)return;i.isOpen=!0,t.$n.ft(!0);const n=t.oe.Et,o=n.ph();o?n.ah(o,!1):n.gh(),i.Sn&&!i.Hn||!r?.ajax?t.oe.open(null,!0):(t.jn.ve(),t.oe.ei(),i.Sn=!0,i.Hn=!1,setTimeout(()=>{t.oe&&t.jn&&t.jn.search("").then(()=>t.oe?.ri?.()).catch(t=>console.error("Initial ajax load error:",t))},r.animationtime),t.oe.open(null,!1)),t.Vn.show();const l=t.tags.Mi;l.setAttribute("aria-expanded","true"),l.setAttribute("aria-controls",r.Kt),l.setAttribute("aria-haspopup","listbox"),l.setAttribute("aria-labelledby",r.Ln),r.multiple&&l.setAttribute("aria-multiselectable","true"),h.nt([s()],...r.on.show)},close(){i.isOpen&&(h.nt([s()],...r.on.beforeClose).isCancel||(i.isOpen=!1,t.$n.ft(!1),t.oe.close(()=>{t.Vn.clear(!1)}),t.Vn.hide(),t.tags.Mi.setAttribute("aria-expanded","false"),h.nt([s()],...r.on.close)))},toggle(){i.isOpen?this.close():this.open()},change(e=null,n=!0){if(n){if(r.multiple&&r.maxSelected>0&&this.valueArray.length>r.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],...r.on.beforeChange).isCancel)return void this.setValue(null,this.oldValue,!1)}this.refreshMask(),t.kn.Zs(this.valueOptions),n&&(t.targetElement&&h.ot(t.targetElement,"change"),h.nt([s(),this.value],...r.on.change),i.options?.autoclose&&this.close()),i.is(o.MOUNTED)&&i.update()},refreshMask(){let s=r.placeholder;!r.multiple&&i.Un().length>0&&(s=this.mask[0]),s??(s=r.placeholder),t.placeholder.set(s,!1),t.Vn.Ri(s)},on(t,i,s){r.on[i]||(r.on[i]=[]),r.on[i].push(s)},ajax(i,s){t.jn.we(s)},loadAjax:()=>new Promise((e,h)=>{t.oe.ei(),t.jn.ve(),i.Sn=!0,i.Hn=!1,t.oe&&t.jn?t.jn.search("").then(()=>{t.oe?.ri?.(),e(s())}).catch(t=>{console.error("Initial ajax load error:",t),h(t)}):e(s())})};return this.Bn(l,"disabled","isDisabled"),this.Bn(l,"readonly","isReadOnly"),this.Bn(l,"visible","isVisible"),l}Bn(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})}Un(t=null){if(!this.An)return[];const{Rs:i}=this.An.Zt(),s=[];for(const e of i)e instanceof w?s.push(e):e instanceof y&&Array.isArray(e.items)&&e.items.length&&s.push(...e.items);return"boolean"==typeof t?s.filter(i=>i.selected===t):s}}class j{constructor(){this.isActive=!1,this.Ee=null,this.actions=[]}Gn(t){this.actions.push(t)}Wn(){this.actions=[]}connect(t){if(this.isActive)return;this.isActive=!0;const i=t.toUpperCase(),s=t.toLowerCase();this.Ee=new MutationObserver(t=>{for(const e of t)e.addedNodes.forEach(t=>{if(1!==t.nodeType)return;const e=t;e.tagName===i&&this.qn(e),e.querySelectorAll(s).forEach(t=>this.qn(t))})}),this.Ee.observe(document.body,{childList:!0,subtree:!0})}disconnect(){this.isActive&&(this.isActive=!1,this.Ee?.disconnect(),this.Ee=null)}qn(t){this.actions.forEach(i=>i(t))}}class $ extends r{constructor(){super(),this.Jn=new Map,this.init()}init(){this.is(o.NEW)&&(this.Jn=new Map,super.init())}bind(t,i){this.is(o.NEW)&&this.init();const s=e.V(e.B(),i);s.on=s.on??{},s.on.load=s.on.load??[],this.Jn.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=[]});const r=e.v(t);let l=!1;r.forEach(t=>{(async()=>{"SELECT"===t.tagName&&(e._(t),this.Kn(t,s)&&(l=!0,e.Z.run(n)))})()}),e.G().includes(t)||e.G().push(t),this.is(o.INITIALIZED)&&l&&this.mount(),this.is(o.MOUNTED)&&this.update()}mount(){this.state===o.INITIALIZED&&super.mount()}update(){this.state===o.MOUNTED&&super.update()}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.Qn(e,h.action);const o={isEmpty:!1};for(const e in n){const t=n[e];switch(t.type){case"get-set":this.Yn(o,t.name,s);break;case"func":this.Xn(o,t.name,s)}}return o}Zn(){this.io||(this.io=new j,this.io.Gn(t=>{this.Jn.forEach((i,s)=>{try{t.matches(s)&&(this.Kn(t,i),this.is(o.MOUNTED)&&this.update())}catch(e){console.warn("Invalid selector: "+s,e)}})})),this.io.connect("select")}destroy(t=null){null===t?this.so():"string"==typeof t?this.eo(t):t instanceof HTMLSelectElement&&this.ho(t),null!==t&&this.is(o.MOUNTED)&&this.update()}so(){this.state!==o.DESTROYED&&(e.G().forEach(t=>this.eo(t)),this.Jn.clear(),e.G().length=0,this.io?.disconnect(),super.destroy())}eo(t){e.v(t).forEach(t=>{"SELECT"===t.tagName&&this.ho(t)}),this.Jn.delete(t);const i=e.G(),s=i.indexOf(t);s>-1&&i.splice(s,1)}ho(t){const i=e.R(t);if(!i)return;const s=i.self;e.U(t,i);const h=!!this.io;h&&this.io?.disconnect();try{i.self?.Nn?.()}catch(o){}const n=i.container?.element??t.parentElement;t.style.display="",t.style.visibility="",t.disabled=!1,delete t.dataset.no,n&&n.parentNode?n.parentNode.replaceChild(t,n):t.appendChild(t),e.k(t),h&&this.Jn.size>0&&this.io?.connect("select"),s?.destroy?.()}rebind(t,i){this.eo(t),this.bind(t,i),this.is(o.MOUNTED)&&this.update()}Kn(t,i){if(e.R(t)||e.N(t))return!1;const s=e.m(8),h=e.j(t,i);h.oo=s,h.Kt=`seui-${s}-optionlist`,h.Ln=`seui-${s}-placeholder`;const n={options:h};e.D(t,n);const o=new F(t,this);return o.on("onMount",()=>{o.container.view&&o.container.view.addEventListener("mouseup",()=>{n.action?.toggle?.()})}),o.mount(),n.container=o.container,n.action=o.In(),n.self=o,!0}Qn(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}}Yn(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})}Xn(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 k=new $;globalThis.GLOBAL_SEUI={version:"1.2.4",name:"SelectiveUI",bind:k.bind.bind(k),find:k.find.bind(k),destroy:k.destroy.bind(k),effector:i.bind(i),rebind:k.rebind.bind(k)};let R=!1;function D(){R||(R=!0,document.addEventListener("mousedown",()=>{const t=e.G();if(t.length>0){const i=k.find(t.join(", "));i.isEmpty||i.close()}}),k.Zn())}"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",D):D()),console.log("[SelectiveUI] v1.2.4 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,V=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=V,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
|