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