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