beer.min.js 9.5 KB

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