UNPKG

lu2

Version:

Simple and flexible UI component library based on native HTML and JavaScript

1 lines 166 kB
!function(t,e){if(e.isKeyEventBind||!t.addEventListener)return{};var i=navigator.platform||navigator.userAgent,s="windows";/mac/i.test(i)&&(s="mac");var a="chrome";void 0!==t.mozFullScreen?a="moz":void 0===t.msHidden&&void 0!==t.hidden||(a="ie");var n={windows:{ctrlKey:!1,altKey:!0,shiftKey:!1},mac:{ctrlKey:!0,altKey:!0,shiftKey:!1}}[s],r=null,o=function(){clearTimeout(r);var e=t.querySelectorAll(".AK_Tips");[].slice.call(e).forEach((function(e){e.fromTarget&&(e.fromTarget.hasTipsShow=null),t.body.removeChild(e)})),t.hasTipsShow=null};t.addEventListener("keydown",(function(e){var i=!1,s=e.target||t.activeElement,l=s.tagName.toLowerCase();("textarea"==l||"input"==l&&0==/checkbox|radio|select|file|button|image|hidden/i.test(s.type))&&(i=!0);var d=t.querySelectorAll("a[accesskey],area[accesskey],button[accesskey],input[accesskey],label[accesskey],legend[accesskey],textarea[accesskey]");if(0!=d.length){var c=[].slice.call(d),h=c.map((function(t){return t.getAttribute("accesskey")})),u=-1;if(h.forEach((function(t,i){if(e.key&&e.key==t||e.keyIdentifier&&parseInt(e.keyIdentifier.toLowerCase().replace("u+",""),16)==parseInt(function(t,e){if(!t)return"";e=e||"x";for(var i,s="",a=0;a<t.length;a+=1)t.charCodeAt(a)>=55296&&t.charCodeAt(a)<=56319?(i=(65536+1024*(Number(t.charCodeAt(a))-55296)+Number(t.charCodeAt(a+1))-56320).toString(16),a+=1):i=t.charCodeAt(a).toString(16),s+=e+i;return s.substr(e.length)}(t),16))return u=i,!1})),0==e.altKey&&0==e.shiftKey&&0==e.ctrlKey){if(i)return;c[u]&&(setTimeout((function(){c[u].focus()}),1),e.preventDefault())}else 0==e.altKey&&1==e.shiftKey&&0==e.ctrlKey?191!=e.keyCode||i||(t.hasTipsShow?o():function(e){if(!t.hasTipsShow){var i=t.documentElement.scrollTop||t.body.scrollTop,s=t.documentElement.scrollLeft||t.body.scrollLeft;e.forEach((function(e){if(e.clientHeight*e.clientWidth!=0){var a=e.getAttribute("accesskey"),r=[];for(var o in n)n[o]&&r.push(o);r.push(a);var l=e.getBoundingClientRect(),d=t.createElement("div");d.className="ui-kbd-tips AK_Tips",d.setAttribute("style","top:"+(l.top+i)+"px;left:"+(l.left+s)+"px;"),d.innerHTML=r.map((function(t){return"<kbd>"+t.replace("Key","")+"</kbd>"})).join("+"),t.body.appendChild(d),d.fromTarget=e}})),t.hasTipsShow=!0,r=setTimeout((function(){o()}),3e3)}}(c)):!c[u]||i||"ie"!=a&&"moz"!=a||!e.altKey||e.shiftKey||e.ctrlKey||c[u].click()}})),t.addEventListener("mousedown",(function(){o()}));var l={37:"left",38:"up",39:"right",40:"down",13:"enter",9:"tab",27:"esc"},d="ui-outline",c={add:function(t){t.classList.add(d)},remove:function(t){t.classList.remove(d)},removeAll:function(){[].slice.call(t.querySelectorAll(".ui-outline")).forEach((function(t){c.remove(t)}))},has:function(t){t.classList.contains(d)}},h=null;e.isKeyEvent=!1,t.addEventListener("keydown",(function(i){e.isKeyEvent=!0,clearTimeout(h),h=setTimeout((function(){e.isKeyEvent=!1}),100);var s=l[i.keyCode];if(s){var a=t.activeElement;if(a&&!/body/i.test(a.tagName)){if("enter"==s&&(/^radio|checkbox$/i.test(a.type)||"0"==a.getAttribute("tabindex")))return a.click(),void i.preventDefault();var n=null,r=t.querySelectorAll(".ESC");"esc"==s&&r.length&&[].slice.call(r).forEach((function(e){var i=e.id;(n=i&&t.querySelector('[data-target="'+i+'"],[data-target2="'+i+'"],ui-drop[target="'+i+'"]'))&&"none"!==e.style.display&&e.clientHeight>0?n.hide?n.hide():n["ui-drop"]?n["ui-drop"].hide():n.click():e==document.activeElement&&e.click&&e.click()}));var o=a.getAttribute("data-focus"),d=a.getAttribute("data-target"),u=null;if((o||d)&&(o?u=t.getElementById(o):d&&(u=t.getElementById(d)),u&&(0!=u.clientWidth||0!=u.clientHeight))){if("tab"==s){c.removeAll();var p=u;return u.getAttribute("tabindex")||(p=u.querySelector("a[href], button:not(:disabled), input:not(:disabled)")),void(p&&p.focus())}if("enter"==s){var m=u.querySelector(".ui-outline");if(m&&o)return i.preventDefault(),void m.click();if(d)return}if("esc"==s)return n=t.querySelector('a[data-target="'+d+'"],input[data-target="'+d+'"]'),void(o?a.blur():n&&0==/ESC/.test(n.className)&&n.click());var g=[].slice.call(u.querySelectorAll("a[href], button:not(:disabled), input:not(:disabled)")),f=-1;0!=g.length&&(g.forEach((function(t,e){o?c.has(t)&&(f=e):a==t&&(f=e),c.remove(t)})),i.preventDefault(),"left"==s||"up"==s?--f<0&&(f=-1):"right"!=s&&"down"!=s||++f>g.length-1&&(f=g.length),g[f]&&(o?c.add(g[f]):g[f].focus()))}}}})),t.addEventListener("mousedown",(function(t){var e=t.target;e&&!c.has(e)&&c.removeAll()})),t.addEventListener("click",(function(i){var s=i.target,a=t.activeElement,n=s.getAttribute("tabindex")||"-1";s&&s==a&&(/^radio|checkbox$/i.test(a.type)||n>=0)&&0==e.isKeyEvent&&0==/none/.test(getComputedStyle(s).outline)&&a.blur()})),t.addEventListener("focusin",(function(t){var i=t.target;if(i&&(/^javascript/.test(i.href)&&!i.getAttribute("role")&&i.setAttribute("role","button"),e.isKeyEvent)){var s=window.getComputedStyle(i);!/none|auto/.test(s.outlineStyle)||t.path&&t.path[0]!==i||c.add(i)}})),t.addEventListener("focusout",(function(t){var e=t.target;e&&c.remove(e)})),e.isKeyEventBind=!0}(document,window),HTMLElement.prototype.follow=function(t,e){let i={offsets:{x:0,y:0},safeArea:[0,0,0,0],position:"4-1",edgeAdjust:!0};for(var s in t&&"[object Object]"===Object.prototype.toString.call(t)&&(e=t,t=null),e||(e={}))void 0===e[s]&&delete e[s];let a=Object.assign({},i,e);if(!t){let e=this.getAttribute("is-follow")||this.dataset.target;if(!e)return;if(!(t=document.getElementById(e)||document.querySelector("."+e)||document.querySelector(e)))return}let n=["4-1","1-4","5-7","2-3","2-1","6-8","3-4","4-3","8-6","1-2","7-5","3-2"],r=this.dataset.offsets,o=[];a.offsets.map&&a.offsets.length?o=a.offsets:"string"==typeof a.offsets&&(o=a.offsets.trim().split(/,\s*|\s+/)),r&&!e.offsets&&(o=r.trim().split(/,\s*|\s+/)),o.length&&(a.offsets={},a.offsets.x=o[0],a.offsets.y=o[1]||o[0]);let l=this.dataset.offsetX,d=this.dataset.offsetY;l&&(a.offsets.x=l),d&&(a.offsets.y=d),a.offsets.x*=1,a.offsets.y*=1;let c=this.dataset.position,h=this.dataset.align,u=n.some((t=>t===h));!c&&h&&u&&(c=h),!c||e&&e.position||(a.position=c);let p=this.dataset.edgeAdjust||a.edgeAdjust,m=!("0"===p||"none"===p||"false"===p||!1===p);"string"==typeof p&&"boolean"!=typeof a.edgeAdjust&&(a.edgeAdjust=m);let g=t.style.position;"absolute"!=g&&(t.style.position="absolute");let f=this.getBoundingClientRect(),v=t.getBoundingClientRect();if(v.width*v.height==0)return t.style.position=g||"",void window.console.warn((t.id?"id为"+t.id+"的":"")+"目前元素尺寸为0,无法定位");const b=this.dataset.scroller;let y,E=null;b&&(E=this.closest(b)||this.closest("#"+b),y=E,y&&!y.contains(t)&&(y=null)),y||(y=document.scrollingElement||document.documentElement);let w=y.scrollTop,A=y.scrollLeft;const $=window.innerWidth,L=window.innerHeight;(f.left<0&&f.right<0||f.top<0&&f.bottom<0||f.left>$&&f.right>$||f.top>L&&f.bottom>L)&&(a.edgeAdjust=m=!1);const x=t.offsetParent||y,C=x.getBoundingClientRect(),S={follow:t};this.element=this.element?Object.assign(this.element,S):S,this.params=this.params?Object.assign(this.params,a):a;let T=a.offsets,M=C.top+w,k=C.left+A;x===document.body&&"static"===window.getComputedStyle(x).position?(M=0,k=0):x==E&&E&&(M=C.top,k=C.left);let j,D,H=a.position,O=function(){let e=window.getComputedStyle(t),i=Number(e.zIndex),s=19;x.childNodes.forEach((e=>{if(1!==e.nodeType)return;let i=window.getComputedStyle(e),a=1*i.zIndex;a&&t!==e&&"none"!==i.display&&(s=Math.max(a+1,s))})),s!==i&&(t.style.zIndex=s)};if("string"!=typeof H&&2===H.length){let e=H;return j=e[0]+T.x,D=e[1]+T.y,!0===a.edgeAdjust&&(j+v.width>$+A&&(j=$+A-v.width-T.x),D+v.height>L+w&&(D=L+w-v.height-T.y)),t.style.left=`${j}px`,t.style.top=`${D}px`,t.dataset.align="3-1",void O()}!1===n.some((t=>t===H))&&(H=i.position);let q=this.dataset.safeArea||getComputedStyle(t).getPropertyValue("--safe-area")||a.safeArea;"string"==typeof q&&(q=q.trim().split(/(?:,\s*|\s+)/)),q=q.map((function(t){return parseFloat(t)||0})),1==q.length?q=q.concat(q[0],q[0],q[0]):2==q.length?(q.push(q[0]),q.push(q[1])):3==q.length&&q.push(q[1]);const N=v.width+T.x+q[3]>f.left,I=f.top-(v.height+T.y+q[0])<0,P=f.right+v.width+T.x+q[1]>$,R=f.bottom+v.height+T.y+q[2]>L;v.width,T.x,q[3],f.right,f.left,v.width,T.x,q[1],v.height,T.y,q[0],f.bottom,f.top,v.height,T.y,q[2];let V="bottom";var F=()=>{switch(H){case"1-4":case"5-7":case"2-3":D=f.top-v.height,j="1-4"===H?f.left:"5-7"===H?f.left-(v.width-f.width)/2:f.left-(v.width-f.width),V="top",m&&I&&(R?N&&P||(H={"1-4":"2-1","5-7":"6-8","2-3":"3-4"}[H],F()):(H={"1-4":"4-1","5-7":"7-5","2-3":"3-2"}[H],F()));break;case"2-1":case"6-8":case"3-4":j=f.right,D="2-1"===H?f.top:"6-8"===H?f.top-(v.height-f.height)/2:f.top-(v.height-f.height),V="right",m&&P&&(N?I&&R||(H={"2-1":"1-4","6-8":"5-7","3-4":"2-3"}[H],F()):(H={"2-1":"1-2","6-8":"8-6","3-4":"4-3"}[H],F()));break;case"4-1":case"7-5":case"3-2":D=f.bottom,j="4-1"===H?f.left:"7-5"===H?f.left-(v.width-f.width)/2:f.left-(v.width-f.width),V="bottom",m&&R&&(I?N&&P||(H={"4-1":"2-1","7-5":"6-8","3-2":"3-4"}[H],F()):(H={"4-1":"1-4","7-5":"5-7","3-2":"2-3"}[H],F()));break;case"1-2":case"8-6":case"4-3":j=f.left-v.width,D="1-2"===H?f.top:"8-6"===H?f.top-(v.height-f.height)/2:f.top-(v.height-f.height),V="left",m&&N&&(P?I&&R||(H={"1-2":"1-4","8-6":"5-7","4-3":"2-3"}[H],F()):(H={"1-2":"2-1","8-6":"6-8","4-3":"3-4"}[H],F()))}};F(),j=j+T.x-k,D=D+T.y-M,m&&("top"==V?D-=q[2]:"bottom"==V?D+=q[0]:"left"==V?j-=q[1]:j+=q[3]),D+=w,j+=A,t.style.left=`${Math.round(j)}px`,t.style.top=`${Math.round(D)}px`,v=t.getBoundingClientRect(),m&&("top"==V||"bottom"==V?v.left<q[3]?j+=q[3]-v.left:v.right+q[1]>$&&(j-=v.right+q[1]-$):v.top<q[0]?D+=q[0]-v.top:v.bottom+q[2]>L&&(D-=v.bottom+q[2]-L),t.style.left=`${Math.round(j)}px`,t.style.top=`${Math.round(D)}px`),t.dataset.align=H,t.dataset.direction=V,O(),t.zIndex||(t.zIndex=O)},[NodeList.prototype,HTMLCollection.prototype].forEach((t=>{t.follow=function(){[...this].forEach((t=>{1===t.nodeType&&t.follow.apply(t,this.arguments)}))}}));class Tab extends HTMLElement{static get observedAttributes(){return["open"]}static get defaults(){return{eventType:"click",history:!1,autoplay:3e3}}constructor(t,e){super();let i=null;if("string"==typeof t?i=document.getElementById(t):"object"==typeof t&&(t.tagName?i=t:e||(e=t)),e=e||{},i){let t=i.getAttribute("is-tab");const s=i.dataset.name;if(s&&("prev"==t||"next"==t))return i.addEventListener("click",(()=>{const e=document.querySelectorAll('ui-tab[name="'+s+'"]'),i=[...e].findIndex((t=>t.open));"prev"==t?(e[i-1]||e[e.length-1]).switch():(e[i+1]||e[0]).switch()})),i.addEventListener("mouseenter",(()=>{document.querySelectorAll('ui-tab[name="'+s+'"][autoplay]').forEach((t=>{clearTimeout(t.timer)}))})),void i.addEventListener("mouseout",(()=>{[...document.querySelectorAll('ui-tab[name="'+s+'"][autoplay]')].some((t=>{if(t.open)return t.autoSwitch(),!0}))}));let a=i.id;a||(a=("lulu_"+Math.random()).replace("0.",""),i.id=a,this.htmlFor=a),i.getAttribute("name")&&(this.name=i.getAttribute("name")),i.hasAttribute("open")&&(this.open=!0);for(let t in Tab.defaults)void 0!==i.dataset[t.toLowerCase()]?this[t]=i.dataset[t.toLowerCase()]:void 0!==e[t]&&(this[t]=i.dataset[t.toLowerCase()]=e[t]);t&&!i.dataset.target&&(i.dataset.target=t),-1==i.tabIndex&&i.setAttribute("tabindex",0)}let s=this.element||{};if(this.element=new Proxy(s,{get:(t,e)=>{if("target"==e){let t=this.target,e=null,i=this.element.trigger;return!t&&i&&(t=i.dataset.target||i.getAttribute("href"),t&&/#/.test(t)&&(t=t.split("#")[1])),t&&(e=document.getElementById(t)),e}return"trigger"==e?this.htmlFor&&document.getElementById(this.htmlFor)||this:t[e]},set:(t,e,i)=>{if("string"==typeof i&&(i=document.getElementById(i)||document.querySelector(i)),i&&"number"!=typeof i.nodeType)return!1;if(t[e]=i,"target"==e&&i){let t=i,e=t.id;e||(e=("lulu_"+Math.random()).replace("0.",""),t.id=e),this.element.trigger==this?this.target!=e&&(this.target=e):this.element.trigger&&this.element.trigger.setAttribute("data-target",e)}return!0}}),this.setParams(e),i&&!this.parentElement&&i!=this){let t=document.querySelector('body > div[hidden="tab"]');t||(t=document.createElement("div"),t.setAttribute("hidden","tab"),document.body.append(t)),t.append(this)}}get eventType(){let t=this.getAttribute("eventtype")||Tab.defaults.eventType;return"hover"==t&&(t="mouseenter"),t}set eventType(t){this.setAttribute("eventtype",t)}get history(){return this.hasAttribute("history")||Tab.defaults.history}set history(t){this.toggleAttribute("history",t)}get autoplay(){let t=this.getAttribute("autoplay");return"string"==typeof t&&(/^\d+$/.test(t)?1*t:Tab.defaults.autoplay)}set autoplay(t){t||""===t?this.setAttribute("autoplay",t):this.removeAttribute("autoplay")}get name(){return this.getAttribute("name")}set name(t){this.setAttribute("name",t)}get htmlFor(){return this.getAttribute("for")}set htmlFor(t){this.setAttribute("for",t)}get target(){return this.getAttribute("target")}set target(t){this.setAttribute("target",t)}get open(){return this.hasAttribute("open")}set open(t){this.toggleAttribute("open",t)}setParams(t){this.params=this.params||{},t=t||{},Object.assign(this.params,t)}switch(){let t=this.name,e=[];t?(e=document.querySelectorAll('ui-tab[name="'+t+'"]'),this.open||(e.forEach((t=>{t.open&&(t.open=!1)})),this.open=!0)):this.open=!this.open;const i=window.location;if(1==this.history&&t&&0==/tab\d{10,16}/.test(t)){if(!this.element.target)return;let e=this.element.target.id;const s=new URLSearchParams(i.search);s.set(t,e);let a=i.hash;e==a&&(i.hash=a=""),window.history.replaceState(null,document.title,i.href.split("?")[0]+"?"+s.toString()+a)}}autoSwitch(){let t=this.autoplay,e=this.name;if(t&&e){let i=document.querySelectorAll('ui-tab[name="'+e+'"]');if(clearTimeout(this.timer),t&&e&&i.length>1){let e=[].slice.call(i).findIndex((t=>t==this));e++,e>=i.length&&(e=0),this.timer=setTimeout((()=>{i[e].switch(),i[e].autoSwitch()}),t)}}}events(){if("mouseover"!=this.eventType&&"mouseenter"!=this.eventType||(this.element.trigger.addEventListener(this.eventType,(()=>{Tab.hoverTimer=setTimeout((()=>{this.switch()}),150)}),!1),this.element.trigger.addEventListener(this.eventType.replace("over","out").replace("enter","leave"),(()=>{clearTimeout(Tab.hoverTimer)}))),this.element.trigger.addEventListener("click",(t=>{/^(:?javas|#)/.test(t.target.getAttribute("href"))&&t.preventDefault(),this.switch()}),!1),this.autoplay&&this.name){[this.element.trigger,this.element.target].forEach((t=>{t.addEventListener("mouseenter",(()=>{clearTimeout(this.timer)})),t.addEventListener("mouseleave",(()=>{this.autoSwitch()}))}));let t=document.querySelector('ui-tab[name="'+this.name+'"][open]');t&&t.autoSwitch()}}connectedCallback(){this.closest("a, button")||this.querySelector("a, button")||this.setAttribute("tabindex","0");let t=this.element.target,e=this.element.trigger;e&&e.setAttribute("role","tab"),t&&t.setAttribute("role","tabpanel"),this.events(),new URLSearchParams(window.location.search).forEach(((i,s)=>{e&&t&&this.name==s&&t.id==i&&!e.hasAttribute("open")&&e.click()})),this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-tab"}})),this.isConnectedCallback=!0,this.dispatchEvent(new CustomEvent("DOMContentLoaded")),e!=this&&(e.dispatchEvent(new CustomEvent("DOMContentLoaded")),e.hasAttribute("is-tab")&&(e.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-tab"}})),e.setAttribute("defined","")))}attributeChangedCallback(t,e,i){if(this.element&&"open"===t&&typeof e!=typeof i){const t=this.element.target;if(!t)return;this.open?(t.classList.add("active"),this.setAttribute("aria-selected","true"),this.dispatchEvent(new CustomEvent("show",{detail:{type:"ui-tab"}}))):(t.classList.remove("active"),this.setAttribute("aria-selected","false"),this.dispatchEvent(new CustomEvent("hide",{detail:{type:"ui-tab"}})));let e=this.element.trigger;e&&e!=this&&e.toggleAttribute("open",this.open),e&&this.name&&/ui-tab/.test(e.className)&&(e.parentElement.style.setProperty("--ui-tab-width",e.clientWidth),e.parentElement.style.setProperty("--ui-tab-left",e.offsetLeft)),this.dispatchEvent(new CustomEvent("switch"))}}}NodeList.prototype.tab=function(t={}){const e=this;let i=t.name||"";for(var s of e)!i&&s.getAttribute("name")&&(i=s.getAttribute("name"));i||(i=("tab"+Math.random()).replace("0.",""));for(let s of e)s.setAttribute("name",i),s["ui-tab"]=new Tab(s,t)},customElements.get("ui-tab")||customElements.define("ui-tab",Tab),window.Tab=Tab,function(){function t(){document.querySelectorAll("[is-tab]").forEach((function(t){t["ui-tab"]||(t["ui-tab"]=new Tab(t))})),new MutationObserver((function(t){t.forEach((function(t){t.addedNodes.forEach((function(t){t.tagName&&(t.hasAttribute("is-tab")?t["ui-tab"]||(t["ui-tab"]=new Tab(t)):t.querySelectorAll("[is-tab]").forEach((function(t){t["ui-tab"]||(t["ui-tab"]=new Tab(t))})))}))}))})).observe(document.body,{childList:!0,subtree:!0})}"loading"!=document.readyState?t():window.addEventListener("DOMContentLoaded",t)}();const isSupportPopover=HTMLElement.prototype.hasOwnProperty("popover"),isSupportAnchor=CSS.supports("justify-self","anchor-center");class Select extends HTMLSelectElement{static get observedAttributes(){return["multiple","disabled","width"]}constructor(){super(),this.element||(this.element={button:null,combobox:null,datalist:null}),this.observer=null,this.resizeObserver=null,this.setProperty()}static addClass(){return["ui","select"].concat([].slice.call(arguments)).join("-")}set multiple(t){return this.toggleAttribute("multiple",Boolean(t))}get multiple(){return this.hasAttribute("multiple")}render(){this.create(),this.refresh(),this.events()}remove(){this.parentElement&&this.parentElement.removeChild(this),this.element.combobox&&this.element.combobox.remove()}getData(){if(!this.options.length)return[{html:""}];let t=this.querySelectorAll("optgroup"),e=!!this.querySelector("optgroup[label]");if(t.length){let i=[];return t.forEach((t=>{i.push({html:t.label,disabled:t.disabled,className:t.className,divide:!e}),t.querySelectorAll("option").forEach((s=>{i.push({html:s.innerHTML,value:s.value,selected:s.selected,disabled:t.disabled||s.disabled,className:s.className,intent:e})}))})),i}const i=this.querySelectorAll("option, hr");return[].slice.call(i).map((t=>t.matches("hr")?{divide:!0}:{html:t.innerHTML,value:t.value,selected:t.selected,disabled:t.disabled,className:t.className}))}get width(){let t=this.getAttribute("width");return t&&Number(t)===parseFloat(t)&&(t+="px"),t}set width(t){0!=/\d/.test(t)&&this.setAttribute("width",t)}getWidth(){return this.style.width||this.width||this.offsetWidth+"px"}setWidth(){if(this.element.combobox){const t=this.getWidth();this.element.combobox.style.width=t,this.style.transform="",-1!==t.lastIndexOf("%")&&"absolute"!=this.originPosition&&"fixed"!=this.originPosition&&(this.style.transform=`scaleX(${this.parentElement.clientWidth*parseFloat(t)*.01/this.offsetWidth})`)}}create(){if(this.element&&this.element.combobox)return;const t=("lulu_"+(this.id||Math.random())).replace("0.",""),e=Select.addClass("button"),i=Select.addClass("datalist"),s=window.getComputedStyle(this).position;this.originPosition=s;const a=this.dataset.cssPosition||this.hasAttribute("is-css-position"),n=/windows/i.test(navigator.userAgent),r=!a&&isSupportPopover,o=isSupportAnchor&&!a&&(this.hasAttribute("is-anchor")||this.dataset.anchor);this.insertAdjacentHTML("afterend",`<div style="width: ${this.getWidth()}">\n ${this.multiple?"":`<button\n type="button"\n class="${e}"\n ${r?"popovertarget":"data-target"}="${t}"\n aria-owns="${t}"\n aria-expanded="false"\n style="display: ${this.multiple?"none":"block"};anchor-name: --${t}"\n ${this.disabled?"disabled ":""}\n /></button>`}\n <ui-select-list\n id="${t}" ${r?"popover":""}\n role="listbox"\n aria-expanded="false"\n class="${i}"\n ${this.multiple?"":'aria-hidden="true"'}\n data-custom-scroll="${n}"\n ${o?'data-anchor="true"':""}\n style="position-anchor:--${t};"\n ></ui-select-list>\n </div>`);let l=this.nextElementSibling;Object.assign(this.element,{combobox:l,button:l.querySelector(`.${e}`),datalist:l.querySelector(`.${i}`)}),"fixed"!=s&&(this.style.position="absolute"),this.dispatchEvent(new CustomEvent("DOMContentLoaded"))}refresh(t){const e=this.multiple,i=this,s=this.element.combobox,a=this.element.button,n=this.element.datalist;if(!n)return;const r=n.id;if(t=t||this.getData(),s.className=`${i.className} ${Select.addClass()}`.trim(),e)s.style.height=i.style.height||i.offsetHeight+"px";else if(i[i.selectedIndex]){const t=i[i.selectedIndex].innerHTML;a.innerHTML=`<span class="${Select.addClass("text")}">${t}</span><i class="${Select.addClass("icon")}" aria-hidden="true"></i>`,a.dataset.value=i[i.selectedIndex].value}let o=-1;n.innerHTML=t.map((t=>{let i=[Select.addClass("datalist","li"),t.className];return t.selected&&i.push("selected"),t.disabled&&i.push("disabled"),void 0!==t.divide?t.divide?(i=[Select.addClass("datalist","hr"),t.className],`<div class="${i.join(" ")}"></div>`):`<div class="${i.join(" ")}" role="heading">${t.html}</div>`:(o++,t.intent&&i.push(Select.addClass("intent")),t.html?e?`<a class="${i.join(" ")}" data-index=${o}>${t.html}</a>`:`<a\n ${t.disabled?"":' href="javascript:" '}\n class="${i.join(" ")}"\n data-index=${o}\n data-target="${r}"\n role="option"\n aria-selected="${t.selected}"\n >${t.html}</a>`:`<span class="${i.join(" ")} disabled"></span>`)})).join("")}events(){this.multiple?this.createMultipleEvent():this.createNormalEvent()}zIndex(){let t=this.element.datalist,e=window.getComputedStyle(t),i=Number(e.zIndex),s=19;document.body.childNodes.forEach((e=>{if(1!==e.nodeType)return;let i=window.getComputedStyle(e),a=1*i.zIndex;a&&t!==e&&"none"!==i.display&&(s=Math.max(a+1,s))})),s!==i&&(t.style.zIndex=s)}position(){const t=this.element,e=t.combobox,i=t.button,s=t.datalist;if(!e.classList.contains("active"))return;const a=i.getBoundingClientRect(),n=document.scrollingElement.scrollTop;e.contains(s)&&!i.popoverTargetElement||(s.style.left=a.left+document.scrollingElement.scrollLeft+"px",s.style.top=a.bottom+n-1+"px",s.style.width=e.getBoundingClientRect().width+"px",s.classList.add("active"),this.zIndex());const r=s.getBoundingClientRect();var o=r.bottom+(s.popover?0:n)>Math.max(document.body.clientHeight,window.innerHeight);e.classList[o?"add":"remove"]("reverse"),!o||this.dataset.cssPosition||this.hasAttribute("is-css-position")||(s.style.top=a.top+n-r.height+1+"px")}createNormalEvent(){const t=this.element;let e=t.combobox,i=t.button,s=t.datalist;i.addEventListener("click",(()=>{if(this.disabled)return!1;if(e.classList.toggle("active"),e.classList.contains("active")){this.dataset.cssPosition||this.hasAttribute("is-css-position")||isSupportPopover?e.appendChild(s):document.body.appendChild(s),this.position(),i.setAttribute("aria-expanded","true"),s.removeAttribute("aria-hidden");var t=e.dataScrollTop,a=s.querySelector(".selected");t&&a&&t[1]===a.getAttribute("data-index")&&t[2]===a.innerText&&(s.scrollTop=t[0],delete e.dataScrollTop)}else e.classList.remove("reverse"),i.setAttribute("aria-expanded","false"),s.remove()})),s.addEventListener("click",(t=>{var a=t.target;if(a&&a.closest){var n=a,r=null,o=n.classList.contains("disabled"),l=n.getAttribute("data-index"),d=s.scrollTop;e.dataScrollTop=[d,l,n.innerText],o||(r=this[l])&&(r.selected=!0),e.classList.remove("active"),i.setAttribute("aria-expanded","false"),s.remove(),i.focus(),i.blur(),o||(this.refresh(),this.dispatchEvent(new CustomEvent("change",{bubbles:!0})))}}));const a=[],n=t=>{t!=document.body&&("auto"==window.getComputedStyle(t).overflow&&a.push(t),n(t.parentElement))};this.dataset.cssPosition||this.hasAttribute("is-css-position")||isSupportPopover||(n(i.parentElement),a.forEach((t=>{t.addEventListener("scroll",(()=>{this.position()}))}))),document.isSelectMouseEvent||(document.addEventListener("mouseup",(t=>{var e=t.target;if(!e)return;const i=document.querySelector("select+.ui-select.active");if(!i)return;const s=i.previousElementSibling,a=s.element&&s.element.datalist;a.contains(e)||i.contains(e)||(i.classList.remove("active"),i.classList.remove("reverse"),a.remove())})),document.isSelectMouseEvent=!0)}createMultipleEvent(){const t=this.element.datalist;this.addEventListener("change",(()=>{this.refresh()})),this.addEventListener("scroll",(()=>{t.scrollTop=this.scrollTop})),this.addEventListener("mousedown",(()=>{this.setAttribute("data-active","true")})),this.addEventListener("mousemove",(e=>{if(this.getAttribute("data-active"))this.refresh();else for(var i=e.clientY,s=e.clientX,a=document.elementsFromPoint(s,i),n=t.querySelectorAll("a"),r=0;r<n.length;r++){var o=n[r];if(o.removeAttribute("href"),[...a].includes(o)){o.classList.contains("selected")||o.classList.contains("disabled")||(o.href="javascript:");break}}})),this.addEventListener("mouseout",(()=>{t.querySelectorAll("a[href]").forEach((function(t){t.removeAttribute("href")}))})),document.addEventListener("mouseup",(()=>{this.removeAttribute("data-active")}))}setProperty(){Object.defineProperty(this,"value",{configurable:!0,enumerable:!0,writeable:!0,get:()=>[...this.selectedOptions].map((t=>t.value)).join(),set:t=>{[...this.options].some((e=>{if(t.split(",").includes(e.value)){if(e.selected=!0,!this.multiple)return!0}else this.multiple&&(e.selected=!1)}))}});const t=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"selectedIndex");Object.defineProperty(HTMLSelectElement.prototype,"selectedIndex",{...t,set(t){this.options[t]&&(this.options[t].selected=!0)}})}attributeChangedCallback(t){const e=this.element.button;if("disabled"===t){if(!e)return;e.disabled=this.disabled}else"multiple"===t?this.element.combobox&&(this.element.combobox.remove(),this.render()):"width"==t&&this.setWidth()}connectedCallback(){this.observer=new MutationObserver((t=>{let e=!0;t.forEach((t=>{"attributes"==t.type&&t.target.hasAttribute("selected")&&(t.target.selected=!0,e=!1)})),e&&this.refresh()})),this.resizeObserver=new ResizeObserver((()=>{this.setWidth(),this.position()})),this.observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["selected"]}),this.resizeObserver.observe(this),this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-select"}})),this.isConnectedCallback=!0,this.render()}disconnectedCallback(){this.observer&&this.resizeObserver&&(this.remove(),this.observer.disconnect(),this.resizeObserver.disconnect())}}const propOptionSelected=Object.getOwnPropertyDescriptor(HTMLOptionElement.prototype,"selected");Object.defineProperty(HTMLOptionElement.prototype,"selected",{...propOptionSelected,set(t){propOptionSelected.set.call(this,t),this.parentElement&&this.parentElement.refresh&&this.parentElement.refresh()}}),customElements.get("ui-select")||customElements.define("ui-select",Select,{extends:"select"});class Drop extends HTMLElement{static get observedAttributes(){return["open","target"]}static get defaults(){return{eventtype:"click",position:"7-5"}}constructor(t,e,i){super(),i=i||{},this.params=this.params||{},this.params=new Proxy(this.params,{get:(t,e)=>{if(!e)return;let i=t[e=e.toLowerCase()],s=this.element.trigger;return void 0===i&&(i=s.getAttribute(e)||s.dataset[e],"width"==e&&(i=s!==this?s.dataset[e]:s.getAttribute(e)),void 0===i&&Drop.defaults[e]&&(i=Drop.defaults[e])),i},set:(t,e,i)=>(t[e.toLowerCase()]=i,!0)});let s=this.element||{};this.element=new Proxy(s,{get:(t,e)=>{if("target"==e){let i=this.getAttribute("target"),s=t[e];return!s&&i&&(s=document.getElementById(i)),s}return"trigger"==e?t[e]||this:t[e]},set:(t,e,i)=>{if("string"==typeof i&&(i=document.getElementById(i)||document.querySelector(i)),i&&"number"!=typeof i.nodeType)return!1;if(t[e]=i,"target"==e&&i){let t=i,e=t.id;e||(e=("lulu_"+Math.random()).replace("0.",""),t.id=e);let s=this.element.trigger;if(s==this)this.target!=e&&(this.target=e);else if(s){let t=s.dataset.target;t&&document.querySelector('datalist[id="'+t+'"]')?s.setAttribute("data-target2",e):s.setAttribute("data-target",e)}}return!0}}),[...arguments].forEach((function(t){"object"==typeof t&&t&&!t.tagName&&(i=t)})),t&&(this.element.trigger=t),(t=this.element.trigger)&&(e&&e!==i?this.element.target=e:!e&&t.dataset&&t.dataset.target&&(this.element.target=t.dataset.target)),this.setParams(i),this.open&&("loading"!=document.readyState?this.show():window.addEventListener("DOMContentLoaded",(()=>{this.show()}))),t!==this&&(this.addEventListener("connected",(function(){this.remove()})),t["ui-drop"]=this,document.body.append(this))}get htmlFor(){return this.getAttribute("for")}set htmlFor(t){this.setAttribute("for",t)}get target(){return this.getAttribute("target")}set target(t){this.setAttribute("target",t)}get eventType(){return this.getAttribute("eventtype")||"click"}set eventType(t){this.setAttribute("eventtype",t)}get open(){return this.hasAttribute("open")}set open(t){this.toggleAttribute("open",t)}setParams(t){let e=(t=t||{}).onShow,i=t.onHide;"function"==typeof e&&(this.addEventListener("show",(function(t){e.call(this,t),this.position()})),delete t.onShow),"function"==typeof i&&(this.addEventListener("hide",(function(t){i.call(this,t)})),delete t.onHide),Object.assign(this.params,t||{})}events(t){let e=this.element.trigger,i=this.element.target;if(!i&&!t)return;if(i&&i.matches("datalist"))return;const s=this.params,a=t=>{if(!s.selector)return null;const i=t.closest(s.selector);return 0==e.contains(i)?null:i};switch(s.eventType){case"null":default:break;case"hover":case"mouseover":case"mouseenter":if(!i)return void setTimeout((()=>{this.element.target&&this.events()}),1);i.timerHover=null,i.timerHold=null,e.isBindDropEvents||(e.addEventListener("mouseover",(t=>{if(t.relatedTarget!==t.target){const e=a(t.target);e&&(this.element.trigger=e),s.selector&&!e||(i.timerHover=setTimeout((()=>{this.show()}),150),clearTimeout(i.timerHold))}})),e.addEventListener("mouseout",(t=>{(this.element.trigger==t.target||this.element.trigger.contains(t.target))&&(clearTimeout(i.timerHover),i.timerHold=setTimeout((()=>{this.hide()}),200))})),i&&!i.isBindDropHover&&(i.addEventListener("mouseenter",(()=>{clearTimeout(i.timerHold)})),i.addEventListener("mouseleave",(()=>{i.timerHold=setTimeout((()=>{let t=i.element.trigger;t&&"hover"==t.eventType&&t.hide()}),100)})),i.isBindDropHover=!0),e.addEventListener("click",(t=>{if(!window.isKeyEvent)return;t.preventDefault();const e=a(t.target);e&&(this.element.trigger=e),s.selector&&!e||(this.open?this.hide():this.show())})),"hover"!=this.eventType&&(this.eventType="hover"));break;case"click":case"contextmenu":e.isBindDropEvents&&e.isBindDropEvents===s.eventType||e.addEventListener(s.eventType,(t=>{t.preventDefault();const e=a(t.target);if(e&&(this.element.trigger=e),!s.selector||e){if("contextmenu"==s.eventType)return s.position=[t.pageX,t.pageY],void this.show();this.open?this.hide():this.show()}}))}"null"==s.eventType||e.isBindDocMouseUp||(document.addEventListener("mouseup",(t=>{let e=t&&t.target;if(!e||!this.open)return;let i=this.element.trigger,s=this.element.target;0!=i.contains(e)||s&&0!=s.contains(e)||this.hide()})),e.isBindDocMouseUp=!0),e.isBindDropEvents=s.eventType||!0,window.addEventListener("resize",(()=>{this.position()})),this.dispatchEvent(new CustomEvent("DOMContentLoaded")),e!=this&&e.dispatchEvent(new CustomEvent("DOMContentLoaded"))}position(){let t=this.element.trigger,e=this.element.target;return this.open&&e&&"none"!=window.getComputedStyle(t).display&&t.follow(e,{offsets:this.params.offsets,position:this.params.position,edgeAdjust:this.params.edgeAdjust}),this}show(){let t=this.element.trigger,e=this.element.target;return e&&0==document.body.contains(e)&&document.body.appendChild(e),e&&(e.style.position="absolute",e.style.display="inline",e.classList.add("ESC"),e.tabIndex=-1,e.focus({preventScroll:!0}),e.element=e.element||{},e.element.trigger=this),t.setAttribute("aria-expanded","true"),this.open||(this.open=!0),this.position(),this.dispatchEvent(new CustomEvent("show")),t!=this&&t.dispatchEvent(new CustomEvent("show",{detail:{type:"ui-drop"}})),this}hide(){let t=this.element.trigger,e=this.element.target;return e&&(e.style.display="none",e.classList.remove("ESC"),e.element&&delete e.element.trigger),t.setAttribute("aria-expanded","false"),window.isKeyEvent&&t.focus(),this.open&&(this.open=!1),this.dispatchEvent(new CustomEvent("hide")),t!=this&&t.dispatchEvent(new CustomEvent("hide",{detail:{type:"ui-drop"}})),this}list(t,e,i){const s=function(t){let e={id:t.id||t.value,value:t.innerHTML||t.value,className:t.className,disabled:t.disabled,label:t.label,accessKey:t.accessKey},i=t.closest("optgroup");return i&&i.disabled&&(e.disabled=!0),t.hasAttribute("href")&&(e.href=t.getAttribute("href")),e};if([...arguments].forEach((a=>{const n=typeof a;"string"===n?t=document.getElementById(a)||document.querySelector(a):"function"===n?e=a:"object"===n&&("number"==typeof a.nodeType?a.matches("datalist")?(e=function(){let t=a.querySelectorAll("optgroup"),e=!!a.querySelector("optgroup[label]");if(t.length){let i=[];return t.forEach((t=>{e?i.push({id:"-1",value:t.label,disabled:t.disabled,className:t.className,heading:!0}):i.push({}),t.querySelectorAll("option").forEach((t=>{i.push(s(t))}))})),i}return[...a.querySelectorAll("option")].map(((t,e)=>{let i=s(t);return i.value?(i.id||(i.id=e),i):{}}))},t==a&&(t=null)):t=a:a.map?e=a:i=a)})),t&&"number"!=typeof t.nodeType&&(t=null),!(t=t||this.element.trigger))return this;e||(e=[]);const a={eventType:"click",offsets:{x:0,y:0},position:"4-1",selector:"",width:"",onShow:()=>{},onHide:()=>{},onSelect:()=>{}},n={};i=i||{},Object.keys(a).forEach((t=>{n[t]=i[t]||this.params[t]||a[t]}));const r="selected",o=function(){return["ui-droplist"].concat([].slice.call(arguments)).join("-")};let l="innerHTML";t.matches("input")&&(l="value");let d=document.createElement("div");d.setAttribute("role","listbox"),d.setAttribute("tabindex","-1"),/^\d+$/.test(n.width)?d.style.width=n.width+"px":d.style.width=n.width,d.className=o("x"),this.data=e;let c=e,h=e=>{let i="-1",s=!1,a=(e,n)=>{e&&e.length&&e.forEach(((e,r)=>{const o=n.concat(r);e&&e.data?a(e.data,o):(e&&e.selected&&!e.disabled&&e.value&&(t[l]=e.value,i=o.join("-")),e&&e.selected&&(s=!0))}))};a(e,[]);const n=(t[l]||"").trim();return 0==s&&n&&(a=(t,e)=>{t&&t.length&&t.forEach(((t,s)=>{const r=e.concat(s);t&&t.data?a(t.data,r):"string"==typeof t.value&&t.value.trim()==n&&(i=r.join("-"),t.selected=!0)}))},a(e,[])),i},u=-1;"function"!=typeof e&&e.length&&e.map&&(u=h(c));const p=(t,e)=>{"function"==typeof e&&(e=e(),u=h(e));let i=(e=e&&e.length?e.map((t=>"string"==typeof t&&"-"!==t?{value:t}:t)):[{value:"没有数据",disabled:!0}]).some((t=>t&&t.selected));t.innerHTML=(()=>{let t="";const s=(t,e)=>{let a="";return t.forEach(((t,n)=>{if("-"==t||null===t||"{}"==JSON.stringify(t))return void(a+='<hr class="'+o("hr")+'">');const l=e.concat(n);let d=t.href;"string"!=typeof d?d="javascript:":d||(d=location.href.split("#")[0]);let c="";t.target&&(c=' target="'+t.target+'"');let h="";t.data&&(h=" data-sublist");let p="";t.label&&(p=' aria-label="'+t.label+'"');let m="";t.accessKey&&(m=` accesskey="${t.accessKey}"`),0==i&&u==l.join("-")&&(t.selected=!0);let g=o("li")+" "+t.className;if(t.selected&&(g=g+" "+r),g=g.trim(),1==t.heading)return t.disabled&&(g+=" disabled"),void(a+='<div class="'+g+'"'+p+' role="heading">'+t.value+"</div>");1!=t.disabled?(a+='<a href="'+d+'"'+c+p+m+' class="'+g+'" data-index="'+l.join("-")+'" role="option" aria-selected="'+(t.selected||"false")+'" '+h+">"+t.value+"</a>",t.data&&(a+='<div class="'+o("xx")+'"><div class="'+o("x")+'" role="listbox">'+s(t.data,l)+"</div></div>")):a+='<span class="'+g+'"'+p+m+">"+t.value+"</span>"})),a};return t+=s(e,[]),t})(),t.listData=e};return this.setParams({eventType:n.eventType,offsets:n.offsets,selector:n.selector,position:n.position,onShow:function(){p.call(this,d,this.data),n.onShow.apply(this,arguments)},onHide:n.onHide}),this.element.trigger=t,this.element.target=d,this.events(),d.addEventListener("click",(e=>{if(1!=e.target.nodeType||!e.target.closest)return;const i=e.target.closest("a");if(!i)return;const s=d.listData,a=i.getAttribute("data-index");if(!a)return;let c=null;if(a.split("-").forEach((t=>{c=null===c?s[t]:c.data?c.data[t]:c[t]})),c){if("string"==typeof i.getAttribute("data-sublist")){i.classList.add(r);const t=i.nextElementSibling.querySelector("."+o("x"));if(!t)return;t.style.transform="",t.classList.remove("reverse");const e=t.getBoundingClientRect();e.right>document.documentElement.clientWidth&&t.classList.add("reverse");let s=0;return e.bottom>window.innerHeight&&(s=window.innerHeight-e.bottom),void(t.style.transform="translateY("+s+"px)")}if(a!=u){let t=null;"-1"!=u&&(u.split("-").forEach((e=>{t=null===t?s[e]:t.data?t.data[e]:t[e]})),t&&delete t.selected),c.selected=!0,u=a}(this.params.onSelect||n.onSelect).call(this,c,i),this.dispatchEvent(new CustomEvent("select",{detail:{data:c,target:i}})),t!=this&&t.dispatchEvent(new CustomEvent("select",{detail:{type:"ui-drop",data:c,target:i}})),"contextmenu"==n.eventType||""!=n.selector||c.href||(t[l]=c.value),this.hide()}})),d.addEventListener("mouseover",(t=>{if(1!=t.target.nodeType||!t.target.closest)return;const e=t.target.closest("a");if(!e)return;const i=e.parentElement.querySelector(".selected[data-sublist]");i&&i!=e&&i.classList.remove(r),0==e.classList.contains(r)&&"string"==typeof e.getAttribute("data-sublist")&&e.click()})),this}panel(t,e){if(2===arguments.length)t=arguments[0],e=arguments[1];else if(1===arguments.length){if((e=arguments[0]).matches&&e.matches("dialog")){let t=e,s=t.dataset.buttons;var i=[];if(""!==s&&"null"!==s&&"false"!==s){s=s||"";let e=[];if(s.includes("{")||s.includes("}"))try{e=new Function("return ["+s+"]")()}catch(t){console.error("按钮解析失败",t),e=[]}else e=s.split(",").map((t=>({value:t.trim()})));i=[{...e[0]||{},events:()=>{t.dispatchEvent(new CustomEvent("ensure",{detail:{drop:this}}))}},{...e[1]||{},events:()=>{t.dispatchEvent(new CustomEvent("cancel",{detail:{drop:this}})),this.hide()}}]}e={content:t.innerHTML,title:t.title,buttons:i},"false"==t.dataset.closable&&(e.closable=!1)}t=null}if("string"==typeof t&&(t=document.querySelector(t)),!(t=t||this.element.trigger))return this;e=e||{},["width","eventType","selector","offsets","position","closable"].forEach((function(i){const s=t.getAttribute(i)||t.dataset[i.toLowerCase()];s&&void 0===e[i]&&(e[i]=s)}));const s=Object.assign({},{title:"",content:"",buttons:[{},{}],width:"auto",eventType:"click",selector:"",offsets:{x:0,y:0},position:"4-1",onShow:()=>{},onHide:()=>{}},e),a={add:function(){return["ui-dropanel"].concat([].slice.call(arguments)).join("-")},toString:()=>"ui-dropanel"},n=document.createElement("div");n.className=a.add("x"),/^\d+$/.test(s.width)?n.style.width=s.width+"px":/^\d+\D+$/.test(s.width)&&(n.style.width=s.width);const r=document.createElement("h5");r.className=a.add("title"),r.innerHTML=s.title;const o=document.createElement("button");o.setAttribute("aria-label","关闭"),o.className=a.add("close");const l=document.createElement("content");l.className=a.add("content"),l.innerHTML=s.content;const d=document.createElement("div");return d.className=a.add("footer"),n.appendChild(r),!1!==s.closable&&"false"!=s.closable&&n.appendChild(o),n.appendChild(l),n.appendChild(d),this.setParams({eventType:s.eventType,offsets:s.offsets,selector:s.selector,position:s.position,onShow:s.onShow,onHide:s.onHide}),Object.assign(this.element,{trigger:t,target:n,panel:n,title:r,close:o,content:l,footer:d}),this.events(),o.addEventListener("click",(()=>{this.hide()}),!1),s.buttons.forEach(((t,e)=>{let i=(t=t||{}).type||"";i||0!=e||(i=s.buttons.length>1?"danger":"primary");let n=t.value;n||(n=["确定","取消"][e]);let r=t.events||{click:()=>{this.hide()}};"function"==typeof r&&(r={click:r});let o=null;t.for?(o=document.createElement("label"),o.setAttribute("for",t.for),o.setAttribute("role","button")):t.form?(o.setAttribute("form",t.form),o.type="submit"):(o=document.createElement("button"),this.element["button"+e]=o),o.innerHTML=n,o.className=String(a).replace("dropanel","button")+" "+a.add("button")+" "+(t.className||""),o.setAttribute("data-type",i||"normal"),this.element["button"+e]=o;for(let t in r)o.addEventListener(t,(e=>{e.drop=this,r[t](e)}),!1);this.element.footer.appendChild(o)})),this}connectedCallback(){let t=this.element.target,e=this.element.trigger;e.open?e.setAttribute("aria-expanded","true"):e.setAttribute("aria-expanded","false"),t?t.matches("datalist")?this.list(t):t.matches("dialog")?this.panel(t):this.events():this.events(e===this),this.querySelector("a, button")||this.closest("a, button")||(this.tabIndex=0,this.role="button"),this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-drop"}})),e!=this&&e.hasAttribute("is-drop")&&(e.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-drop"}})),e.setAttribute("defined","")),this.isConnectedCallback=!0}attributeChangedCallback(t,e,i){if("target"==t){let t=document.getElementById(i);t&&(this.element.target=t)}else if("open"==t){let t=this.element.trigger.getAttribute("aria-expanded");this.open&&"false"==t?this.show():this.open||"true"!=t||this.hide()}}}window.Drop=Drop,customElements.get("ui-drop")||customElements.define("ui-drop",Drop),HTMLElement.prototype.drop=function(t,e){return this.matches("ui-drop, [is-drop]")||this["ui-drop"]||(this["ui-drop"]=new Drop(this,t,e)),this};const initAllIsDropAttrAction=t=>{(t||document.querySelectorAll("[is-drop]")).forEach((t=>{let e=t.getAttribute("is-drop");e&&!t.dataset.target&&(t.dataset.target=e),e=t.dataset.target;let i=e&&document.getElementById(e);i&&!t["ui-drop"]&&(t["ui-drop"]=new Drop(t,i))}))},autoInitAndWatchingIsDropAttr=()=>{initAllIsDropAttrAction();new MutationObserver((t=>{t.forEach((t=>{t.addedNodes&&t.addedNodes.forEach((t=>{t.tagName&&(t.hasAttribute("is-drop")?initAllIsDropAttrAction([t]):initAllIsDropAttrAction(t.querySelectorAll("[is-drop]")))}))}))})).observe(document.body,{childList:!0,subtree:!0})};"loading"!=document.readyState?autoInitAndWatchingIsDropAttr():window.addEventListener("DOMContentLoaded",autoInitAndWatchingIsDropAttr);class Tips extends HTMLElement{static get observedAttributes(){return["title","reverse","for","eventType","align"]}constructor(t,e,i){if(super(),"string"==typeof t&&/^#?\w+(?:[-_]\w+)*$/.test(t)&&(t=document.getElementById(t.replace("#",""))),t&&t.tips)return t.tips(e,i),t["ui-tips"];this.target=null}get title(){let t=this.getAttribute("title");return t?(this.setAttribute("data-title",t),this.removeAttribute("title")):t=this.getAttribute("data-title")||"",t}set title(t){this.setAttribute("data-title",t),this.setAttribute("aria-label",t)}get reverse(){return null!==this.getAttribute("reverse")||this.classList.contains("reverse")}set reverse(t){t?this.setAttribute("reverse",""):this.removeAttribute("reverse")}get htmlFor(){return this.getAttribute("for")}set htmlFor(t){this.setAttribute("for",t)}get align(){return this.getAttribute("align")||"auto"}set align(t){this.setAttribute("align",t)}get eventType(){return this.getAttribute("eventtype")||"hover"}set eventType(t){this.setAttribute("eventtype",t)}get trigger(){const t=this.htmlFor;let e;return t&&(e=document.getElementById(t)),e||this}create(){let t=this.trigger,e=this.title,i=document.createElement("div");if(i.classList.add("ui-tips-x"),i.innerHTML=e,!t.getAttribute("aria-label")){const e="lulu_"+(Math.random()+"").replace("0.","");t.setAttribute("aria-labelledby",e)}document.body.appendChild(i),this.target=i,this.dispatchEvent(new CustomEvent("DOMContentLoaded")),t!=this&&t.dispatchEvent(new CustomEvent("DOMContentLoaded"))}show(){let t=this.trigger,e=this.title;this.target?this.target.innerHTML=e:this.create(),this.target.style.display="block";let i="5-7",s=this.align;const a=this.reverse;"auto"===s&&(s=t.dataset.align||t.dataset.position||"center"),"center"===s?i=a?"7-5":"5-7":"left"===s?i=a?"4-1":"1-4":"right"===s?i=a?"3-2":"2-3":/^\d-\d$/.test(s)&&(i=s),t.follow(this.target,{position:i,edgeAdjust:!1}),this.target.style.setProperty("--ui-width",t.offsetWidth),this.target.style.setProperty("--ui-height",t.offsetHeight),t.dispatchEvent(new CustomEvent("show",{detail:{type:"ui-tips"}}))}hide(){this.target&&(this.target.style.display="none",this.trigger.dispatchEvent(new CustomEvent("hide",{detail:{type:"ui-tips"}})))}events(){let t=this.trigger;this.timerTips=null,this.handleMouseEnter=()=>{this.timerTips=setTimeout((()=>{this.show()}),100)},this.handleMouseLeave=()=>{clearTimeout(this.timerTips),this.hide()},this.handleFocus=()=>{window.isKeyEvent&&this.show()},this.handleMouseUp=e=>{const i=e.target;t.contains(i)||this.target.contains(i)||this.hide()},"hover"===this.eventType?(t.addEventListener("mouseenter",this.handleMouseEnter),t.addEventListener("mouseleave",this.handleMouseLeave),t.addEventListener("focus",this.handleFocus),t.addEventListener("blur",this.hide)):"click"===this.eventType?(t.addEventListener("click",this.show),document.addEventListener("mouseup",this.handleMouseUp)):this.show()}connectedCallback(){let t=this.trigger;t.originTitle=this.title,this.isConnectedCallback||(/^a|input|button|area$/i.test(t.tagName)||(t.setAttribute("tabindex","0"),t.setAttribute("role","tooltip")),this.events(),this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-tips"}})),t!=this&&t.hasAttribute("is-tips")&&(t.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-tips"}})),t.setAttribute("defined","")),this.isConnectedCallback=!0)}}customElements.get("ui-tips")||customElements.define("ui-tips",Tips),window.Tips=Tips,HTMLElement.prototype.tips=function(t,e={}){if("css"===this.getAttribute("is-tips")||this.classList.contains("ui-tips"))return void(this.title&&(this.setAttribute("data-title",this.title),this.setAttribute("aria-label",this.title),this.removeAttribute("title")));"string"!=typeof t&&(e=t||{});const i=this.hasAttribute("reverse")||this.classList.contains("reverse");if(this["ui-tips"])return this["ui-tips"].toggleAttribute("reverse",i),void(void 0!==e.eventType&&"hover"!=e.eventType&&"click"!=e.eventType&&this["ui-tips"].show());let s=document.createElement("ui-tips");s.title="string"==typeof t?t:this.getAttribute("title")||e.content||"",s.toggleAttribute("reverse",i),this.removeAttribute("title"),this.id||(this.id="lulu_"+(Math.random()+"").replace("0.","")),s.htmlFor=this.id,e.eventType&&(s.eventType=e.eventType),e.align&&(s.align=e.align),this["ui-tips"]=s,s.addEventListener("connected",(function(){this.remove()})),document.body.appendChild(s)},function(){let t=function(){const t=".ui-tips, [is-tips]";document.querySelectorAll(t).forEach((t=>{t.tips&&t.tips()})),new MutationObserver((function(e){e.forEach((function(e){var i=e.addedNodes,s=e.removedNodes;i.length&&i.forEach((function(e){e.matches&&(e.matches(t)?e.tips():e.querySelectorAll(t).forEach((t=>{t.tips()})))})),s.length&&s.forEach((function(e){e.matches&&(e["ui-tips"]&&e["ui-tips"].target?e["ui-tips"].target.remove():e.querySelectorAll(t).forEach((function(t){t["ui-tips"]&&t["ui-tips"].target&&t["ui-tips"].target.remove()})))}))}))})).observe(document.body,{childList:!0,subtree:!0})};"loading"!=document.readyState?t():window.addEventListener("DOMContentLoaded",t)}();class LightTip extends HTMLElement{static get observedAttributes(){return["open"]}constructor(){super(),arguments.length&&LightTip.custom.apply(this,arguments)}get type(){return this.getAttribute("type")}get time(){let t=this.getAttribute("time");return isNaN(t)||isNaN(parseFloat(t))?3e3:Number(t)}set type(t){this.setAttribute("type",t)}set time(t){this.setAttribute("time",t)}get open(){return this.hasAttribute("open")}set open(t){this.toggleAttribute("open",t)}connectedCallback(){this.setAttribute("tabIndex",0),this.setAttribute("role","tooltip"),this.closeMode||(this.closeMode="hide"),this.addEventListener("click",(()=>{this[this.closeMode]()})),this.dispatchEvent(new CustomEvent("connected",{detail:{type:"ui-lighttip"}})),this.isConnectedCallback=!0}attributeChangedCallback(t,e,i){"open"==t&&typeof e!=typeof i&&("string"==typeof i?(clearTimeout(this.timer),this.timer=setTimeout((()=>{this.isTimeHide=!0,this[this.closeMode](),this.position()}),this.time),this.setAttribute("data-tid",this.timer),this.classList.add("ESC"),this.zIndex(),this.position()):this.classList.remove("ESC"),this.tabIndex(),this.isTimeHide=null)}zIndex(){var t=19;this.parentElement&&[...this.parentElement.childNodes].forEach((function(e){if(1==e.nodeType){var i=window.getComputedStyle(e),s=1*i.zIndex;s&&"none"!=i.display&&(t=Math.max(s+1,t))}})),this.style.zIndex=t}position(){var t=[...document.querySelectorAll('ui-lighttip[open]:not([type="loading"])')].sort((function(t,e){return(t.getAttribute("data-tid")||0)-(e.getAttribute("data-tid")||0)})),e={},i=-1;t.forEach((t=>{let s=t.textContent;void 0===e[s]&&(i++,e[s]=i),t.style.setProperty("--ui-sort-index",e[s])}))}tabIndex(){var t=LightTip.lastActiveElement;if(1==this.open){var e=document.activeElement;e&&!e.closest("[keepfocus]")&&(this!==e&&(LightTip.lastActiveElement=e),this.focus())}else t&&!t.matches("body")&&(t.focus({preventScroll:!0}),window.isKeyEvent||this.isTimeHide||t.blur(),LightTip.lastActiveElement=null);return this}static success(t,e=3e3){return this.custom(t,"success",e)}static error(t,e=3e3){return this.custom(t,"error",e)}static normal(t,e=3e3){return this.custom(t,"normal",e)}static loading(t){return t=t||"正在加载中...",this.custom(t,"loading")}static custom(t="",e,i){if(!this.matches||!this.matches("ui-lighttip"))return LightTip.custom.apply(document.createElement("ui-lighttip"),arguments);if("object"==typeof t&&(e=t,t=""),"string"!=typeof t)return this;if(this.closeMode="remove",e&&"object"==typeof e)LightTip