Files
2026-04-11 23:11:35 +02:00

2 lines
12 KiB
JavaScript

const Z=[],H=new WeakSet,M=navigator.userAgent.includes("Chrome");navigator.userAgent.includes("Firefox");navigator.userAgent.includes("Safari");navigator.userAgent.includes("Windows");const Q=navigator.userAgent.includes("Macintosh");navigator.userAgent.includes("Linux");navigator.userAgent.includes("Android");const J=/iPad|iPhone|iPod/.test(navigator.userAgent);function kt(){return window==null?void 0:window.matchMedia("(prefers-color-scheme: dark)").matches}async function tt(t){await new Promise(n=>setTimeout(n,t))}function xt(){return"fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)})}function v(t,n){try{return typeof t=="string"?(n??document).querySelector(t):t}catch{return null}}function c(t,n){try{return typeof t=="string"?(n??document).querySelectorAll(t):t??Z}catch{return Z}}function u(t,n){return(t==null?void 0:t.classList.contains(n))??!1}function g(t,n){var e;return((e=t==null?void 0:t.tagName)==null?void 0:e.toLowerCase())===n}function C(t,n){var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())===n}function h(t,n){if(t instanceof NodeList)for(let e=0;e<t.length;e++)t[e].classList.add(n);else t==null||t.classList.add(n)}function p(t,n){if(t instanceof NodeList)for(let e=0;e<t.length;e++)t[e].classList.remove(n);else t==null||t.classList.remove(n)}function T(t,n,e,i=!0){t!=null&&t.addEventListener&&t.addEventListener(n,e,i)}function a(t,n,e,i=!0){Et(t),T(t,n,e,i)}function D(t,n,e,i=!0){t!=null&&t.removeEventListener&&t.removeEventListener(n,e,i)}function mt(t,n){var e;(e=n==null?void 0:n.parentNode)==null||e.insertBefore(t,n)}function q(t){return t==null?void 0:t.previousElementSibling}function O(t){return t==null?void 0:t.nextElementSibling}function E(t){return t==null?void 0:t.parentElement}function At(t){const n=document.createElement("div");for(let e=0,i=Object.keys(t),s=i.length;e<s;e++){const r=i[e],o=t[r];n.setAttribute(r,o)}return n}function $(){var t;(t=document.activeElement)==null||t.blur()}function wt(t){return c('[data-ui="#'+t+'"]')}function Ct(t){return v('[data-ui="#'+t+'"]')}function Tt(t){t.id&&u(t,"page")&&(t=Ct(t.id)??t);const n=E(t);if(!u(n,"tabs")&&!u(n,"tabbed")&&!g(n,"nav"))return;const e=c("a",n);for(let i=0;i<e.length;i++)p(e[i],"active");!g(t,"button")&&!u(t,"button")&&!u(t,"chip")&&h(t,"active")}function Et(t){H.has(t)||H.add(t)}function nt(){const t=getComputedStyle(document.documentElement).getPropertyValue("--size")||"16px";return t.includes("%")?parseInt(t)*16/100:t.includes("em")?parseInt(t)*16:parseInt(t)}function z(t){t.placeholder||(t.placeholder=" ")}function Lt(t){const n=t.currentTarget,e=E(n),i=v("input:not([type=file], [type=checkbox], [type=radio]), select, textarea",e);i&&i.focus()}function N(t){const n=t.currentTarget;L(n)}function R(t){const n=t.currentTarget;L(n)}function St(t){const n=t.currentTarget;K(n)}function It(t){const n=t.currentTarget;W(n)}function Mt(t){const n=t.currentTarget;K(n,t)}function Dt(t){const n=t.currentTarget;W(n,t)}function _t(t){var i;const n=t.currentTarget,e=v("input",E(n));e&&((i=n.textContent)!=null&&i.includes("visibility"))&&(e.type==="password"?(e.type="text",n.textContent="visibility_off"):(e.type="password",n.textContent="visibility"))}function Ft(t){const n=t.currentTarget;et(n)}function Pt(){const t=c(".field > label");for(let n=0;n<t.length;n++)a(t[n],"click",Lt)}function qt(){const t=c(".field > input:not([type=file], [type=color], [type=range])");for(let n=0;n<t.length;n++)a(t[n],"focus",N),a(t[n],"blur",R),L(t[n])}function Ot(){const t=c(".field > select");for(let n=0;n<t.length;n++)a(t[n],"focus",N),a(t[n],"blur",R)}function $t(){const t=c(".field > input[type=file]");for(let n=0;n<t.length;n++)a(t[n],"change",St),K(t[n])}function zt(){const t=c(".field > input[type=color]");for(let n=0;n<t.length;n++)a(t[n],"change",It),W(t[n])}function Nt(){const t=c(".field > textarea");for(let n=0;n<t.length;n++)a(t[n],"focus",N),a(t[n],"blur",R),z(t[n]),!(M&&!Q&&!J)&&(a(t[n],"input",Ft),et(t[n]))}function Rt(){const t=c(".field:has(> input[type=password]) > i, a");for(let n=0;n<t.length;n++)a(t[n],"click",_t)}function L(t){C(t,"number")&&!t.value&&(t.value=""),z(t)}function K(t,n){if((n==null?void 0:n.key)==="Enter"){const i=q(t);if(!C(i,"file"))return;i.click();return}const e=O(t);C(e,"text")&&(e.value=t.files?Array.from(t.files).map(i=>i.name).join(", "):"",e.readOnly=!0,a(e,"keydown",Mt,!1),L(e))}function W(t,n){if((n==null?void 0:n.key)==="Enter"){const i=q(t);if(!C(i,"color"))return;i.click();return}const e=O(t);C(e,"text")&&(e.readOnly=!0,e.value=t.value,a(e,"keydown",Dt,!1),L(e))}function et(t){if(z(t),t.hasAttribute("rows"))return;const n=nt();t.style.blockSize="auto",t.style.blockSize=`${t.scrollHeight-n}px`}function Kt(){Pt(),qt(),Ot(),$t(),zt(),Nt(),Rt()}function X(t){const n=t.target;!g(n,"input")&&!g(n,"select")||(n.type==="range"?(n.focus(),ot(n)):it())}function Wt(t){if(!window.matchMedia("(pointer: coarse)").matches)return;t.target.blur()}function it(){const t=document.body,n=c(".slider > input[type=range]");n.length?T(t,"input",X,!1):D(t,"input",X,!1);for(let e=0;e<n.length;e++)ot(n[e])}function ot(t){a(t,"change",Wt);const n=E(t),e=v("span",n),i=c("input",n);if(!i.length||!e)return;const s=nt(),r=u(n,"max")?0:.25*s*100/i[0].offsetWidth,o=[],f=[];for(let A=0,ht=i.length;A<ht;A++){const B=parseFloat(i[A].min)||0,vt=parseFloat(i[A].max)||100,U=parseFloat(i[A].value)||0,V=(U-B)*100/(vt-B),bt=r/2-r*V/100;o.push(V+bt),f.push(U)}let y=o[0],d=0,k=100-d-y,x=f[0],m=f[1]||0;i.length>1&&(y=Math.abs(o[1]-o[0]),d=o[1]>o[0]?o[0]:o[1],k=100-d-y,m>x&&(x=f[1]||0,m=f[0])),requestAnimationFrame(()=>n.style.cssText=`--_start: ${d}%; --_end: ${k}%; --_value1: '${x}'; --_value2: '${m}';`)}function jt(){it()}const l={light:"",dark:""};function I(){var t;return(t=document==null?void 0:document.body)!=null&&t.classList.contains("dark")?"dark":"light"}function Bt(){if(l.light&&l.dark)return l;const t=document.body,n=document.createElement("body");n.className="light",t.appendChild(n);const e=document.createElement("body");e.className="dark",t.appendChild(e);const i=getComputedStyle(n),s=getComputedStyle(e),r=["--primary","--on-primary","--primary-container","--on-primary-container","--secondary","--on-secondary","--secondary-container","--on-secondary-container","--tertiary","--on-tertiary","--tertiary-container","--on-tertiary-container","--error","--on-error","--error-container","--on-error-container","--background","--on-background","--surface","--on-surface","--surface-variant","--on-surface-variant","--outline","--outline-variant","--shadow","--scrim","--inverse-surface","--inverse-on-surface","--inverse-primary","--surface-dim","--surface-bright","--surface-container-lowest","--surface-container-low","--surface-container","--surface-container-high","--surface-container-highest"];for(let o=0,f=r.length;o<f;o++)l.light+=r[o]+":"+i.getPropertyValue(r[o])+";",l.dark+=r[o]+":"+s.getPropertyValue(r[o])+";";return t.removeChild(n),t.removeChild(e),l}async function Ut(t){const n=globalThis,e=document.body;return!t||!n.materialDynamicColors?Bt():t.light&&t.dark?(l.light=t.light,l.dark=t.dark,e.setAttribute("style",t[I()]),t):n.materialDynamicColors(t).then(i=>{const s=r=>{let o="";for(let f=0,y=Object.keys(r),d=y.length;f<d;f++){const k=y[f],x=r[k],m=k.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase();o+="--"+m+":"+x+";"}return o};return l.light=s(i.light),l.dark=s(i.dark),e.setAttribute("style",l[I()]),l})}function rt(t){const n=globalThis,e=document.body;if(!e)return t;if(!t)return I();t==="auto"&&(t=kt()?"dark":"light"),e.classList.remove("light","dark"),e.classList.add(t);const i=t==="light"?l.light:l.dark;return n.materialDynamicColors&&e.setAttribute("style",i),I()}const S=[];function at(t){if(t.key==="Escape"){const n=t.currentTarget;st(n,n)}}function Vt(t){(v("[autofocus]",t)??t).focus()}function ct(t,n){p(wt(t.id),"active"),p(t,"active"),p(n,"active"),t.close(),S.pop();const e=S[S.length-1];e&&e.focus()}async function Zt(t,n,e,i){!g(i,"button")&&!u(i,"button")&&!u(i,"chip")&&h(i,"active"),h(n,"active"),h(t,"active"),e?t.showModal():t.show(),await tt(90),e||T(t,"keydown",at,!1),S.push(t),Vt(t)}function Ht(t){const n=t.currentTarget,e=O(n);g(e,"dialog")&&ct(e,n)}async function st(t,n){$();let e=q(n);const i=u(n,"active")||n.open,s=u(n,"modal");s||D(n,"keydown",at,!1),u(e,"overlay")||(e=At({class:"overlay"}),mt(e,n),await tt(90)),s||a(e,"click",Ht,!1),i?ct(n,e):Zt(n,e,s,t)}let _;function ut(t){D(document.body,"click",ut);const n=t.target,e=c("menu.active");for(let i=0;i<e.length;i++)lt(n,e[i],t)}function Xt(t){setTimeout(()=>{const n=v(".field > input",t);n?n.focus():t.focus()},90)}function lt(t,n,e){_&&clearTimeout(_),_=setTimeout(()=>{T(document.body,"click",ut),g(document.activeElement,"input")||$();const i=u(n,"active"),s=(e==null?void 0:e.target)===t,r=!!t.closest("menu");if(!i&&r||i&&s){p(n,"active");return}p(c("menu.active"),"active"),h(n,"active"),Xt(n)},90)}let w;function Yt(t){const n=t.currentTarget;p(n,"active"),w&&clearTimeout(w)}function Gt(t,n){$();const e=c(".snackbar.active");for(let i=0;i<e.length;i++)p(e[i],"active");h(t,"active"),a(t,"click",Yt),w&&clearTimeout(w),n!==-1&&(w=setTimeout(()=>{p(t,"active")},n??6e3))}function Qt(t){const n=E(t);n&&p(c(":scope > .page",n),"active"),h(t,"active")}function Jt(t){ft(t)}function tn(t){(t==null?void 0:t.key)===" "&&ft(t)}function ft(t){const n=t instanceof MouseEvent,e=t.currentTarget,i=e.getBoundingClientRect(),s=Math.max(i.width,i.height),r=s/2,o=n?t.clientX-i.left-r:i.width/2-r,f=n?t.clientY-i.top-r:i.height/2-r,y=document.createElement("div");y.className="ripple-js";const d=document.createElement("div");d.style.inlineSize=d.style.blockSize=`${s}px`,d.style.left=`${o}px`,d.style.top=`${f}px`,a(d,"animationend",()=>{y.remove()}),y.appendChild(d),e.appendChild(y)}function nn(){const t=c(".slow-ripple, .ripple, .fast-ripple");for(let n=0;n<t.length;n++)a(t[n],"mousedown",Jt),a(t[n],"keydown",tn)}function Y(t){const n=t.target;g(n,"progress")?dt(n):pt()}function dt(t){requestAnimationFrame(()=>{if(!t.hasAttribute("value")&&!t.hasAttribute("max")){const n=u(t,"circle")?"50":"100";t.style.setProperty("--_value",n),t.setAttribute("value",n),t.setAttribute("max","100"),t.classList.add("indeterminate")}else t.style.setProperty("--_value",String(t.value))})}function pt(){if(M&&!Q&&!J)return;const t=document.body,n=c("progress");n.length?T(t,"input",Y,!1):D(t,"input",Y,!1);for(let e=0;e<n.length;e++)dt(n[e])}const b=globalThis;let F,P;function G(){F&&clearTimeout(F),F=setTimeout(async()=>await gt(),180)}async function j(t,n,e,i){if(!n&&(n=v(t.getAttribute("data-ui")),!n)){t.classList.toggle("active");return}if(Tt(t),g(n,"dialog")){requestAnimationFrame(()=>st(t,n));return}if(g(n,"menu")){requestAnimationFrame(()=>lt(t,n,i));return}if(u(n,"snackbar")){requestAnimationFrame(()=>Gt(n,e));return}if(u(n,"page")){requestAnimationFrame(()=>Qt(n));return}if(u(n,"active")){p(t,"active"),p(n,"active");return}h(n,"active")}function en(t){j(t.currentTarget,null,null,t)}function on(t){t.key==="Enter"&&j(t.currentTarget,null,null,t)}function yt(){b.ui||P||!b.MutationObserver||(P=new MutationObserver(G),P.observe(document.body,{childList:!0,subtree:!0}),G())}function rn(){const t=c("[data-ui]");for(let n=0,e=t.length;n<e;n++)a(t[n],"click",en),g(t[n],"a")&&!t[n].getAttribute("href")&&a(t[n],"keydown",on)}function gt(t,n){if(t){if(t==="setup"){yt();return}if(t==="guid")return xt();if(t==="mode")return rt(n);if(t==="theme")return Ut(n);const e=v(t);if(!e)return;j(e,e,n)}rn(),Kt(),nn(),jt(),pt()}function an(){var n;if(b.ui)return;const t=(n=b.document)==null?void 0:n.body;t&&!t.classList.contains("dark")&&!t.classList.contains("light")&&rt("auto"),yt(),b.ui=gt}an();const cn=b.ui;export{cn as default,cn as ui};