mirror of
https://github.com/SupertigerDev/waybar-online.git
synced 2026-03-24 08:06:37 +00:00
3 lines
9.0 KiB
JavaScript
3 lines
9.0 KiB
JavaScript
function _(e){Object.defineProperty(e,"__esModule",{value:!0,configurable:!0})}function A(e,c,a,o){Object.defineProperty(e,c,{get:a,set:o,enumerable:!0,configurable:!0})}var R={};_(R);A(R,"default",()=>U);class U extends Error{constructor(c,a,o,m,s){super(c+":"+o+":"+m+": "+a),this.reason=a,this.filename=c,this.line=o,this.column=m,this.source=s}}var z={};_(z);A(z,"default",()=>H);class H{constructor(c,a,o){this.start=c,this.end=a,this.source=o}}var oe={};A(oe,"CssTypes",()=>x);var x=function(e){return e.stylesheet="stylesheet",e.rule="rule",e.declaration="declaration",e.comment="comment",e.container="container",e.charset="charset",e.document="document",e.customMedia="custom-media",e.fontFace="font-face",e.host="host",e.import="import",e.keyframes="keyframes",e.keyframe="keyframe",e.layer="layer",e.media="media",e.namespace="namespace",e.page="page",e.startingStyle="starting-style",e.supports="supports",e}({});const Q=1e4,N=(e,c,a)=>{let o=a,m=Q;do{const s=c.map(h=>e.indexOf(h,o));s.push(e.indexOf("\\",o));const $=s.filter(h=>h!==-1);if($.length===0)return-1;const r=Math.min(...$);if(e[r]==="\\")o=r+2,m--;else return r}while(m>0);throw new Error("Too many escaping")},E=(e,c,a)=>{let o=a,m=Q;do{const s=c.map(i=>e.indexOf(i,o));s.push(e.indexOf("(",o)),s.push(e.indexOf('"',o)),s.push(e.indexOf("'",o)),s.push(e.indexOf("\\",o));const $=s.filter(i=>i!==-1);if($.length===0)return-1;const r=Math.min(...$);switch(e[r]){case"\\":o=r+2;break;case"(":{const i=E(e,[")"],r+1);if(i===-1)return-1;o=i+1}break;case'"':{const i=N(e,['"'],r+1);if(i===-1)return-1;o=i+1}break;case"'":{const i=N(e,["'"],r+1);if(i===-1)return-1;o=i+1}break;default:return r}m--}while(m>0);throw new Error("Too many escaping")},ce=(e,c)=>{const a=[];let o=0;for(;o<e.length;){const m=E(e,c,o);if(m===-1)return a.push(e.substring(o)),a;a.push(e.substring(o,m)),o=m+1}return a},L=/\/\*[^]*?(?:\*\/|$)/g,se=(e,c)=>{c=c||{};let a=1,o=1;function m(n){const t=n.match(/\n/g);t&&(a+=t.length);const u=n.lastIndexOf(`
|
|
`);o=~u?n.length-u:o+n.length}function s(){const n={line:a,column:o};return function(t){return t.position=new H(n,{line:a,column:o},c?.source||""),b(),t}}const $=[];function r(n){const t=new U(c?.source||"",n,a,o,e);if(c?.silent)$.push(t);else throw t}function h(){const n=y();return{type:x.stylesheet,stylesheet:{source:c?.source,rules:n,parsingErrors:$}}}function i(){const n=/^{\s*/.exec(e);return n?(f(n),!0):!1}function d(){const n=/^}/.exec(e);return n?(f(n),!0):!1}function y(){let n;const t=[];for(b(),p(t);e.length&&e.charAt(0)!=="}"&&(n=ne()||re());)n&&(t.push(n),p(t));return t}function f(n){const t=n[0];return m(t),e=e.slice(t.length),n}function b(){const n=/^\s*/.exec(e);n&&f(n)}function p(n){let t;for(n=n||[];t=V();)t&&n.push(t);return n}function V(){const n=s();if(e.charAt(0)!=="/"||e.charAt(1)!=="*")return;const t=/^\/\*[^]*?\*\//.exec(e);return t?(f(t),n({type:x.comment,comment:t[0].slice(2,-2)})):r("End of comment missing")}function S(){const n=/^([^{]+)/.exec(e);if(!n)return;f(n);const t=w(n[0]).replace(L,"");return ce(t,[","]).map(u=>w(u))}function k(){const n=s(),t=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(e);if(!t)return;f(t);const u=w(t[0]),l=/^:\s*/.exec(e);if(!l)return r("property missing ':'");f(l);let g="";const v=E(e,[";","}"]);v!==-1&&(g=e.substring(0,v),f([g]),g=w(g).replace(L,""));const M=n({type:x.declaration,property:u.replace(L,""),value:g}),F=/^[;\s]*/.exec(e);return F&&f(F),M}function I(){const n=[];if(!i())return r("missing '{'");p(n);let t;for(;t=k();)t&&(n.push(t),p(n));return d()?n:r("missing '}'")}function j(){let n;const t=[],u=s();for(;n=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e);){const l=f(n);t.push(l[1]);const g=/^,\s*/.exec(e);g&&f(g)}if(t.length)return u({type:x.keyframe,values:t,declarations:I()||[]})}function B(){const n=s(),t=/^@([-\w]+)?keyframes\s*/.exec(e);if(!t)return;const u=f(t)[1],l=/^([-\w]+)\s*/.exec(e);if(!l)return r("@keyframes missing name");const g=f(l)[1];if(!i())return r("@keyframes missing '{'");let v,M=p();for(;v=j();)M.push(v),M=M.concat(p());return d()?n({type:x.keyframes,name:g,vendor:u,keyframes:M}):r("@keyframes missing '}'")}function W(){const n=s(),t=/^@supports *([^{]+)/.exec(e);if(!t)return;const u=w(f(t)[1]);if(!i())return r("@supports missing '{'");const l=p().concat(y());return d()?n({type:x.supports,supports:u,rules:l}):r("@supports missing '}'")}function q(){const n=s(),t=/^@host\s*/.exec(e);if(!t)return;if(f(t),!i())return r("@host missing '{'");const u=p().concat(y());return d()?n({type:x.host,rules:u}):r("@host missing '}'")}function D(){const n=s(),t=/^@container *([^{]+)/.exec(e);if(!t)return;const u=w(f(t)[1]);if(!i())return r("@container missing '{'");const l=p().concat(y());return d()?n({type:x.container,container:u,rules:l}):r("@container missing '}'")}function G(){const n=s(),t=/^@layer *([^{;@]+)/.exec(e);if(!t)return;const u=w(f(t)[1]);if(!i()){const g=/^[;\s]*/.exec(e);return g&&f(g),n({type:x.layer,layer:u})}const l=p().concat(y());return d()?n({type:x.layer,layer:u,rules:l}):r("@layer missing '}'")}function J(){const n=s(),t=/^@media *([^{]+)/.exec(e);if(!t)return;const u=w(f(t)[1]);if(!i())return r("@media missing '{'");const l=p().concat(y());return d()?n({type:x.media,media:u,rules:l}):r("@media missing '}'")}function K(){const n=s(),t=/^@custom-media\s+(--\S+)\s+([^{;\s][^{;]*);/.exec(e);if(!t)return;const u=f(t);return n({type:x.customMedia,name:w(u[1]),media:w(u[2])})}function X(){const n=s(),t=/^@page */.exec(e);if(!t)return;f(t);const u=S()||[];if(!i())return r("@page missing '{'");let l=p(),g;for(;g=k();)l.push(g),l=l.concat(p());return d()?n({type:x.page,selectors:u,declarations:l}):r("@page missing '}'")}function Y(){const n=s(),t=/^@([-\w]+)?document *([^{]+)/.exec(e);if(!t)return;const u=f(t),l=w(u[1]),g=w(u[2]);if(!i())return r("@document missing '{'");const v=p().concat(y());return d()?n({type:x.document,document:g,vendor:l,rules:v}):r("@document missing '}'")}function Z(){const n=s(),t=/^@font-face\s*/.exec(e);if(!t)return;if(f(t),!i())return r("@font-face missing '{'");let u=p(),l;for(;l=k();)u.push(l),u=u.concat(p());return d()?n({type:x.fontFace,declarations:u}):r("@font-face missing '}'")}function C(){const n=s(),t=/^@starting-style\s*/.exec(e);if(!t)return;if(f(t),!i())return r("@starting-style missing '{'");const u=p().concat(y());return d()?n({type:x.startingStyle,rules:u}):r("@starting-style missing '}'")}const T=P("import"),ee=P("charset"),te=P("namespace");function P(n){const t=new RegExp("^@"+n+`\\s*((?::?[^;'"]|"(?:\\\\"|[^"])*?"|'(?:\\\\'|[^'])*?')+)(?:;|$)`);return function(){const u=s(),l=t.exec(e);if(!l)return;const g=f(l),v={type:n};return v[n]=g[1].trim(),u(v)}}function ne(){if(e[0]==="@")return B()||J()||K()||W()||T()||ee()||te()||Y()||X()||q()||Z()||D()||C()||G()}function re(){const n=s(),t=S();return t?(p(),n({type:x.rule,selectors:t,declarations:I()||[]})):r("selector missing")}return O(h())};function w(e){return e?e.trim():""}function O(e,c){const a=e&&typeof e.type=="string",o=a?e:c;for(const m in e){const s=e[m];Array.isArray(s)?s.forEach($=>{O($,o)}):s&&typeof s=="object"&&O(s,o)}return a&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:c||null}),e}var ae=se;const ie=ae,ue=(e,c,a)=>Math.min(Math.max(e,c),a),fe=async()=>await fetch("/waybar-online/fontawesome/css/fontawesome.min.css").then(c=>c.text()),le=await fe();function me(){const e=new Map;return ie(le).stylesheet.rules.forEach(a=>{if(a.type===x.rule){const o=a.declarations[0];if(o.type===x.declaration){if(o.property!=="--fa")return;a.selectors[0];const m=o.value.slice(1,-1);try{const s=String.fromCodePoint(parseInt(m.slice(1),16));if(!Number.isNaN(parseInt(s)))return;e.set(s,m)}catch{}}}}),e}const de=[...me().keys()],pe=new RegExp(de.map(e=>`\\${e}`).join("|"),"g"),he=e=>e.replace(pe,a=>`<span class="fa">${a}</span>`),ye=e=>{let c="";const a=()=>{if(e.config)return c||e.config?.format||void 0},o=h=>c=h||"format",m=document.createElement("span");return e.update&&setInterval(e.update,e.interval),{element:m,set:h=>{const i=a();if(!i)return console.error("No format found"),"N/A";const d=i.replace(/\{(\w+)\}/g,(y,f)=>h[f]!==void 0?h[f]:y);m.innerHTML=he(d)},getIcon:(h,i,d=0)=>{const y=e.config?.["format-icons"],f=y?.length||0,b=ue(h/((d==0?100:d)/f),0,f-1),p=y?.[Math.round(b)];return p||""},getState:(h,i)=>{const d=e.config?.states;if(typeof d!="object")return"";const y=Object.entries(d);y.sort((b,p)=>i?b[1]-p[1]:p[1]-b[1]);let f="";return y.forEach(b=>{(i?h<=b[1]:h>=b[1])&&!f?(e.module.element.classList.add(b[0]),f=b[0]):e.module.element.classList.remove(b[0])}),f},setFormat:o}},xe=(e,c)=>{const a=ye({interval:1e3,update:()=>s(),config:c,module:e});e.element.appendChild(a.element);const o=$=>{let r="Unknown";return r="Charging",r};let m="Unknown";const s=async()=>{const r=Math.round({level:.1}.level*100),h=o();e.element.classList.remove(m.toLowerCase()),e.element.classList.add(h.toLowerCase()),m=h,e.element.title=h;const i=a.getState(r,!0);if(c){const d=h.toLowerCase();let y="";i&&c["format-"+d+"-"+i]?y=c["format-"+d+"-"+i]:c["format-"+d]?y=c["format-"+d]:i&&c["format-"+i]&&(y=c["format-"+i]),a.setFormat(y)}a.set({capacity:r,icon:a.getIcon(r)})};s()};export{xe as createBatteryModule};
|