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