map.meshcore.dev/lib/beer.min.js
2025-07-18 14:49:10 +02:00

1 line
No EOL
11 KiB
JavaScript

const V=[];function S(){return window.matchMedia("(pointer: coarse)").matches}function lt(){return window.matchMedia("(prefers-color-scheme: dark)").matches}async function W(t){await new Promise(n=>setTimeout(n,t))}function ft(){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 h(t,n){try{return typeof t=="string"?(n??document).querySelector(t):t}catch{return null}}function s(t,n){try{return typeof t=="string"?(n??document).querySelectorAll(t):t??V}catch{return V}}function u(t,n){return(t==null?void 0:t.classList.contains(n))??!1}function y(t,n){var e;return((e=t==null?void 0:t.tagName)==null?void 0:e.toLowerCase())===n}function T(t,n){var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())===n}function g(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 o(t,n,e,i=!0){t!=null&&t.addEventListener&&t.addEventListener(n,e,i)}function F(t,n,e,i=!0){t!=null&&t.removeEventListener&&t.removeEventListener(n,e,i)}function dt(t,n){var e;(e=n==null?void 0:n.parentNode)==null||e.insertBefore(t,n)}function O(t){return t==null?void 0:t.previousElementSibling}function $(t){return t==null?void 0:t.nextElementSibling}function v(t){return t==null?void 0:t.parentElement}function pt(t){const n=document.createElement("div");for(let e=0,i=Object.keys(t),a=i.length;e<a;e++){const c=i[e],r=t[c];n.setAttribute(c,r)}return n}function _(){var t;(t=document.activeElement)==null||t.blur()}function yt(t){return s('[data-ui="#'+t+'"]')}function gt(t){return h('[data-ui="#'+t+'"]')}function ht(t){t.id&&u(t,"page")&&(t=gt(t.id)??t);const n=v(t);if(!u(n,"tabs")&&!u(n,"tabbed")&&!y(n,"nav"))return;const e=s("a",n);for(let i=0;i<e.length;i++)p(e[i],"active");g(t,"active")}function X(t){t.placeholder||(t.placeholder=" ")}function vt(t){const n=t.currentTarget,e=v(n),i=h("input:not([type=file], [type=checkbox], [type=radio]), select, textarea",e);i&&i.focus()}function z(t){const n=t.currentTarget;L(n)}function N(t){const n=t.currentTarget;L(n)}function bt(t){const n=t.currentTarget;R(n)}function xt(t){const n=t.currentTarget;q(n)}function kt(t){const n=t.currentTarget;R(n,t)}function mt(t){const n=t.currentTarget;q(n,t)}function wt(t){const n=t.currentTarget;Y(n)}function Ct(t){var i;const n=t.currentTarget,e=h("input",v(n));e&&((i=n.textContent)!=null&&i.includes("visibility"))&&(e.type=e.type==="password"?"text":"password")}function Tt(){const t=s(".field > label");for(let n=0;n<t.length;n++)o(t[n],"click",vt)}function Lt(){const t=s(".field > input:not([type=file], [type=color], [type=range])");for(let n=0;n<t.length;n++)o(t[n],"focus",z),o(t[n],"blur",N),L(t[n])}function At(){const t=s(".field > select");for(let n=0;n<t.length;n++)o(t[n],"focus",z),o(t[n],"blur",N)}function Et(){const t=s(".field > input[type=file]");for(let n=0;n<t.length;n++)o(t[n],"change",bt),R(t[n])}function St(){const t=s(".field > input[type=color]");for(let n=0;n<t.length;n++)o(t[n],"change",xt),q(t[n])}function Dt(){const t=s(".field.textarea > textarea");for(let n=0;n<t.length;n++)o(t[n],"focus",z),o(t[n],"blur",N),o(t[n],"input",wt),Y(t[n])}function It(){const t=s("input[type=password] ~ :is(i, a)");for(let n=0;n<t.length;n++)o(t[n],"click",Ct)}function L(t){T(t,"number")&&!t.value&&(t.value=""),X(t)}function R(t,n){if((n==null?void 0:n.key)==="Enter"){const i=O(t);if(!T(i,"file"))return;i.click();return}const e=$(t);T(e,"text")&&(e.value=t.files?Array.from(t.files).map(i=>i.name).join(", "):"",e.readOnly=!0,o(e,"keydown",kt,!1),L(e))}function q(t,n){if((n==null?void 0:n.key)==="Enter"){const i=O(t);if(!T(i,"color"))return;i.click();return}const e=$(t);T(e,"text")&&(e.readOnly=!0,e.value=t.value,o(e,"keydown",mt,!1),L(e))}function Y(t){X(t);const n=v(t);n.removeAttribute("style"),u(n,"min")&&n.style.setProperty("---size",`${Math.min(192,Math.max(t.scrollHeight,n.offsetHeight))}px`)}function Mt(){Tt(),Lt(),At(),Et(),St(),Dt(),It()}function H(t){const n=t.target;!y(n,"input")&&!y(n,"select")||(n.type==="range"?(n.focus(),Q(n)):G())}function Pt(t){if(!S())return;const n=t.target,e=v(n);u(e,"vertical")&&document.body.classList.add("no-scroll")}function Ft(t){if(!S())return;const n=t.target,e=v(n);u(e,"vertical")&&document.body.classList.remove("no-scroll")}function G(){const t=document.body,n=s(".slider > input[type=range]");n.length?o(t,"input",H,!1):F(t,"input",H,!1);for(let e=0;e<n.length;e++)Q(n[e])}function Ot(){const t=getComputedStyle(document.documentElement).getPropertyValue("--size")||"16px";return t.includes("%")?parseInt(t)*16/100:t.includes("em")?parseInt(t)*16:parseInt(t)}function Q(t){o(t,"focus",Pt),o(t,"blur",Ft);const n=v(t),e=h("span",n),i=s("input",n);if(!i.length||!e)return;const a=Ot(),c=u(n,"max")?0:.25*a*100/i[0].offsetWidth,r=[],l=[];for(let x=0,at=i.length;x<at;x++){const j=parseFloat(i[x].min)||0,st=parseFloat(i[x].max)||100,K=parseFloat(i[x].value)||0,U=(K-j)*100/(st-j),ut=c/2-c*U/100;r.push(U+ut),l.push(K)}let f=r[0],b=0,A=100-b-f,k=l[0],m=l[1]||0;i.length>1&&(f=Math.abs(r[1]-r[0]),b=r[1]>r[0]?r[0]:r[1],A=100-b-f,m>k&&(k=l[1]||0,m=l[0])),n.style.setProperty("---start",`${b}%`),n.style.setProperty("---end",`${A}%`),n.style.setProperty("---value1",`'${k}'`),n.style.setProperty("---value2",`'${m}'`)}function $t(){G()}const d={light:"",dark:""};function P(){var t;return(t=document==null?void 0:document.body)!=null&&t.classList.contains("dark")?"dark":"light"}function _t(){if(d.light&&d.dark)return d;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),a=getComputedStyle(e),c=["--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 r=0,l=c.length;r<l;r++)d.light+=c[r]+":"+i.getPropertyValue(c[r])+";",d.dark+=c[r]+":"+a.getPropertyValue(c[r])+";";return t.removeChild(n),t.removeChild(e),d}function zt(t){const n=globalThis,e=document.body;if(!t||!n.materialDynamicColors)return _t();const i=P();return t.light&&t.dark?(d.light=t.light,d.dark=t.dark,e.setAttribute("style",t[i]),t):n.materialDynamicColors(t).then(a=>{const c=r=>{let l="";for(let f=0,b=Object.keys(r),A=b.length;f<A;f++){const k=b[f],m=r[k],x=k.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase();l+="--"+x+":"+m+";"}return l};return d.light=c(a.light),d.dark=c(a.dark),e.setAttribute("style",d[i]),d})}function J(t){const n=globalThis,e=document.body;if(!e)return t;if(!t)return P();t==="auto"&&(t=lt()?"dark":"light"),e.classList.remove("light","dark"),e.classList.add(t);const i=t==="light"?d.light:d.dark;return n.materialDynamicColors&&e.setAttribute("style",i),P()}const E=[];function tt(t){if(t.key==="Escape"){const n=t.currentTarget;et(n,n)}}function Nt(t){(h("[autofocus]",t)??t).focus()}function nt(t,n){p(yt(t.id),"active"),p(t,"active"),p(n,"active"),t.close(),E.pop();const e=E[E.length-1];e?e.focus():S()&&document.body.classList.remove("no-scroll")}async function Rt(t,n,e,i){!y(i,"button")&&!u(i,"button")&&!u(i,"chip")&&g(i,"active"),g(n,"active"),g(t,"active"),e?t.showModal():t.show(),await W(90),e||o(t,"keydown",tt,!1),E.push(t),S()&&document.body.classList.add("no-scroll"),Nt(t)}function qt(t){const n=t.currentTarget,e=$(n);y(e,"dialog")&&nt(e,n)}async function et(t,n){_();let e=O(n);const i=u(n,"active")||n.open,a=u(n,"modal");a||F(n,"keydown",tt,!1),u(e,"overlay")||(e=pt({class:"overlay"}),dt(e,n),await W(90)),a||o(e,"click",qt,!1),i?nt(n,e):Rt(n,e,a,t)}let D;function it(t){F(document.body,"click",it);const n=t.target,e=s("menu.active");for(let i=0;i<e.length;i++)ot(n,e[i],t)}function Bt(t){setTimeout(()=>{const n=h(".field > input",t);n?n.focus():t.focus()},90)}function ot(t,n,e){D&&clearTimeout(D),D=setTimeout(()=>{o(document.body,"click",it),y(document.activeElement,"input")||_();const i=u(n,"active"),a=(e==null?void 0:e.target)===t,c=!!t.closest("menu");if(!i&&c||i&&a){p(n,"active");return}p(s("menu.active"),"active"),g(n,"active"),Bt(n)},90)}let w;function jt(t){const n=t.currentTarget;p(n,"active"),w&&clearTimeout(w)}function Kt(t,n){_();const e=s(".snackbar.active");for(let i=0;i<e.length;i++)p(e[i],"active");g(t,"active"),o(t,"click",jt),w&&clearTimeout(w),n!==-1&&(w=setTimeout(()=>{p(t,"active")},n??6e3))}function Ut(t){const n=v(t);n&&p(s(":scope > .page",n),"active"),g(t,"active")}function Vt(t){Ht(t)}function Ht(t){const n=t.currentTarget,e=n.getBoundingClientRect(),i=Math.max(e.width,e.height),a=i/2,c=t.clientX-e.left-a,r=t.clientY-e.top-a,l=document.createElement("div");l.className="ripple-js";const f=document.createElement("div");f.style.inlineSize=f.style.blockSize=`${i}px`,f.style.left=`${c}px`,f.style.top=`${r}px`,f.addEventListener("animationend",()=>{l.remove()}),l.appendChild(f),n.appendChild(l)}function Zt(){const t=s(".slow-ripple, .ripple, .fast-ripple");for(let n=0;n<t.length;n++)o(t[n],"pointerdown",Vt)}const C=globalThis;let I,M;function Z(){I&&clearTimeout(I),I=setTimeout(async()=>await ct(),180)}async function B(t,n,e,i){if(!(!n&&(n=h(t.getAttribute("data-ui")),!n))){if(ht(t),y(n,"dialog")){await et(t,n);return}if(y(n,"menu")){ot(t,n,i);return}if(u(n,"snackbar")){Kt(n,e);return}if(u(n,"page")){Ut(n);return}if(u(n,"active")){p(t,"active"),p(n,"active");return}g(n,"active")}}function Wt(t){B(t.currentTarget,null,null,t)}function Xt(t){t.key==="Enter"&&B(t.currentTarget,null,null,t)}function rt(){C.ui||M||(M=new MutationObserver(Z),M.observe(document.body,{childList:!0,subtree:!0}),Z())}function Yt(){const t=s("[data-ui]");for(let n=0,e=t.length;n<e;n++)o(t[n],"click",Wt),y(t[n],"a")&&!t[n].getAttribute("href")&&o(t[n],"keydown",Xt)}function ct(t,n){if(t){if(t==="setup"){rt();return}if(t==="guid")return ft();if(t==="mode")return J(n);if(t==="theme")return zt(n);const e=h(t);if(!e)return;B(e,e,n)}Yt(),Mt(),$t(),Zt()}function Gt(){var n;if(C.ui)return;const t=(n=C.document)==null?void 0:n.body;t&&!t.classList.contains("dark")&&!t.classList.contains("light")&&J("auto"),rt(),C.ui=ct}Gt();const Qt=C.ui;export{Qt as default,Qt as ui};