tesses-backup/TessesDedupWeb/wwwroot/js/beer.min.js

3 lines
8.5 KiB
JavaScript

let m,S,M,P;const d={light:"",dark:""},j=[];async function U(t){return await new Promise(e=>setTimeout(e,t))}function X(){return"fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function x(t,e){try{return typeof t=="string"?(e!=null?e:document).querySelector(t):t}catch{return null}}function y(t,e){try{return typeof t=="string"?(e!=null?e:document).querySelectorAll(t):t!=null?t:j}catch{return j}}function g(t,e){var n,r;return(r=(n=t==null?void 0:t.classList)==null?void 0:n.contains(e))!=null?r:!1}function L(t,e){var n;return((n=t==null?void 0:t.tagName)==null?void 0:n.toLowerCase())===e}function C(t,e){var n;return((n=t==null?void 0:t.type)==null?void 0:n.toLowerCase())===e}function h(t,e){var n;(n=t==null?void 0:t.classList)==null||n.add(e)}function f(t,e){var n;(n=t==null?void 0:t.classList)==null||n.remove(e)}function p(t,e,n,r=!0){t==null||t.addEventListener(e,n,r)}function H(t,e,n,r=!0){t==null||t.removeEventListener(e,n,r)}function Y(t,e){var n;(n=e==null?void 0:e.parentNode)==null||n.insertBefore(t,e)}function N(t){return t==null?void 0:t.previousElementSibling}function K(t){return t==null?void 0:t.nextElementSibling}function k(t){return t==null?void 0:t.parentElement}function J(t){const e=document.createElement("div");for(let n=0,r=Object.keys(t),a=r.length;n<a;n++){const c=r[n];e.setAttribute(c,t[c])}return e}function w(t){const e=t;C(e,"number")&&!e.value&&(e.value=""),e.placeholder||(e.placeholder=" "),t.getAttribute("data-ui")&&D(t,null)}function tt(t){D(t.currentTarget,null,null,t)}function et(t){const e=t.currentTarget,n=k(e),r=x("input:not([type=file], [type=checkbox], [type=radio]), select, textarea",n);r&&r.focus()}function nt(t){const e=t.currentTarget;w(e)}function rt(t){const e=t.currentTarget;w(e)}function R(t){H(document.body,"click",R);const e=t.target,n=y("menu.active");for(let r=0,a=n.length;r<a;r++)I(e,n[r],t)}function it(t){const e=t.currentTarget;f(e,"active"),m&&clearTimeout(m)}function at(t){const e=t.currentTarget;$(e)}function ot(t){const e=t.currentTarget;_(e)}function ct(t){const e=t.currentTarget;$(e,t)}function ut(t){const e=t.currentTarget;_(e,t)}function st(t){const e=t.currentTarget;Z(e)}function B(){S&&clearTimeout(S),S=setTimeout(()=>{A()},180)}function $(t,e){if(e&&e.key==="Enter"){const a=N(t);return C(a,"file")?a.click():void 0}const n=t,r=K(t);!C(r,"text")||(r.value=n.files?Array.from(n.files).map(a=>a.name).join(", "):"",r.readOnly=!0,p(r,"keydown",ct,!1),w(r))}function _(t,e){if(e&&e.key==="Enter"){const a=N(t);return C(a,"color")?a.click():void 0}const n=t,r=K(t);!C(r,"text")||(r.readOnly=!0,r.value=n.value,p(r,"keydown",ut,!1),w(r))}function Z(t){const e=k(t),n=k(t);e.removeAttribute("style"),g(e,"min")&&e.style.setProperty("---size",`${Math.max(t.scrollHeight,n.offsetHeight)}px`)}function V(t){const e=k(t),n=x("span",e),r=y("input",e);if(!r.length||!n)return;const a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--size"))||16,c=g(e,"max")?0:.25*a*100/r[0].offsetWidth,o=[],l=[];for(let T=0,W=r.length;T<W;T++){const O=parseFloat(r[T].min)||0,G=parseFloat(r[T].max)||100,q=parseFloat(r[T].value)||0,z=(q-O)*100/(G-O),Q=c/2-c*z/100;o.push(z+Q),l.push(q)}let i=o[0],u=0,s=100-u-i,v=l[0],b=l[1]||0;r.length>1&&(i=Math.abs(o[1]-o[0]),u=o[1]>o[0]?o[0]:o[1],s=100-u-i,b>v&&(v=l[1]||0,b=l[0])),e.style.setProperty("---start",`${u}%`),e.style.setProperty("---end",`${s}%`),e.style.setProperty("---value1",`'${v}'`),e.style.setProperty("---value2",`'${b}'`)}function F(t){if(t){const n=t.target;if(n.type==="range")return V(n)}const e=y(".slider > input[type=range]");e.length?p(globalThis,"input",F,!1):H(globalThis,"input",F,!1);for(let n=0,r=e.length;n<r;n++)V(e[n])}async function D(t,e,n,r){if(!(!e&&(e=x(t.getAttribute("data-ui")),!e))){if(L(e,"dialog"))return await ft(t,e);if(L(e,"menu"))return I(t,e,r);if(g(e,"snackbar"))return dt(t,e,n);if(g(e,"page"))return lt(t,e);if(E(t),g(e,"active"))return f(e,"active");h(e,"active")}}function E(t){t.id&&g(t,"page")&&(t=x(`[data-ui="#${t.id}"]`));const e=k(t);if(!g(e,"tabs"))return;const n=y("a",e);for(let r=0,a=n.length;r<a;r++)f(n[r],"active");h(t,"active")}function lt(t,e){E(t);const n=k(e);if(n)for(let r=0,a=n.children.length;r<a;r++)g(n.children[r],"page")&&f(n.children[r],"active");h(e,"active")}function I(t,e,n){M&&clearTimeout(M),M=setTimeout(()=>{var a,c;if(p(document.body,"click",R),E(t),g(e,"active")){if(!n)return f(e,"active");const o=n.target,l=x((a=o.getAttribute("data-ui"))!=null?a:""),i=o.closest("menu"),u=!x("menu",(c=o.closest("[data-ui]"))!=null?c:void 0);return l&&l!==i?I(o,l):!l&&!u&&i?!1:f(e,"active")}const r=y("menu.active");for(let o=0,l=r.length;o<l;o++)f(r[o],"active");h(e,"active")},90)}async function ft(t,e){var i;(i=document.activeElement)==null||i.blur(),E(t);let n=N(e);const r=e,a=g(e,"active")||r.open,c=g(e,"modal"),o=k(e),l=L(o,"nav");if(g(n,"overlay")||(n=J({class:"overlay"}),Y(n,e),await U(90)),n.onclick=()=>{c||(f(t,"active"),f(e,"active"),f(n,"active"),r.close())},l){const u=y("dialog, a, .overlay",o);for(let s=0,v=u.length;s<v;s++){const b=u[s];f(b,"active"),b.open&&b.close()}}a?(f(t,"active"),f(n,"active"),f(e,"active"),r.close()):(!L(t,"button")&&!g(t,"button")&&!g(t,"chip")&&h(t,"active"),h(n,"active"),h(e,"active"),c?r.showModal():r.show())}function dt(t,e,n){var a;(a=document.activeElement)==null||a.blur(),E(t);const r=y(".snackbar.active");for(let c=0,o=r.length;c<o;c++)f(r[c],"active");h(e,"active"),p(e,"click",it),m&&clearTimeout(m),n!==-1&&(m=setTimeout(()=>{f(e,"active")},n!=null?n:6e3))}function gt(){if(d.light&&d.dark)return d;const t=document.createElement("body");t.className="light",document.body.appendChild(t);const e=document.createElement("body");e.className="dark",document.body.appendChild(e);const n=getComputedStyle(t),r=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 c=0,o=a.length;c<o;c++)d.light+=a[c]+":"+n.getPropertyValue(a[c])+";",d.dark+=a[c]+":"+r.getPropertyValue(a[c])+";";return document.body.removeChild(t),document.body.removeChild(e),d}function yt(t){if(!t||!globalThis.materialDynamicColors)return gt();const e=/dark/i.test(document.body.className)?"dark":"light";return t.light&&t.dark?(d.light=t.light,d.dark=t.dark,document.body.setAttribute("style",t[e]),t):globalThis.materialDynamicColors(t).then(n=>{const r=a=>{let c="";for(let o=0,l=Object.keys(a),i=l.length;o<i;o++){const u=l[o],s=a[u],v=u.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase();c+="--"+v+":"+s+";"}return c};return d.light=r(n.light),d.dark=r(n.dark),document.body.setAttribute("style",d[e]),d})}function pt(t){if(!t)return/dark/i.test(document.body.className)?"dark":"light";document.body.classList.remove("light","dark"),document.body.classList.add(t);const e=t==="light"?d.light:d.dark;return globalThis.materialDynamicColors&&document.body.setAttribute("style",e),t}function ht(){P||(P=new MutationObserver(B),P.observe(document.body,{childList:!0,subtree:!0}),B())}function A(t,e){if(t){if(t==="setup")return ht();if(t==="guid")return X();if(t==="mode")return pt(e);if(t==="theme")return yt(e);const i=x(t);if(!i)return;D(i,i,e)}const n=y("[data-ui]");for(let i=0,u=n.length;i<u;i++)p(n[i],"click",tt);const r=y(".field > label");for(let i=0,u=r.length;i<u;i++)p(r[i],"click",et);const a=y(".field > input:not([type=file], [type=color], [type=range]), .field > select, .field > textarea");for(let i=0,u=a.length;i<u;i++){const s=a[i];p(s,"focus",nt),p(s,"blur",rt),w(s)}const c=y(".field > input[type=file]");for(let i=0,u=c.length;i<u;i++){const s=c[i];p(s,"change",at),$(s)}const o=y(".field > input[type=color]");for(let i=0,u=o.length;i<u;i++){const s=o[i];p(s,"change",ot),_(s)}const l=y(".field.textarea > textarea");for(let i=0,u=l.length;i<u;i++){const s=l[i];p(s,"input",st),Z(s)}F()}globalThis.addEventListener&&globalThis.addEventListener("load",async()=>await A("setup"));globalThis.beercss=A;globalThis.ui=A;
export default globalThis.ui;