"use strict";{const e=self;(()=>{var t={d:(exports,definition)=>{for(var key in definition)t.o(definition,key)&&!t.o(exports,key)&&Object.defineProperty(exports,key,{enumerable:!0,get:definition[key]})},o:(obj,prop)=>Object.prototype.hasOwnProperty.call(obj,prop)},s={};const STYLE_CODE_EMPTY_RE=/\s+|\/\*([^*]+|\*(?!\/))*(\*\/|$)|@namespace[^;]+;|@charset[^;]+;/iuy;function styleCodeEmpty(sec){const{code}=sec;let res=!code;if(res||null!=(res=sec._empty))return res;const len=code.length,e=STYLE_CODE_EMPTY_RE;e.lastIndex=0;let t=0;for(;e.exec(code)&&(t=e.lastIndex)!==len;);return Object.defineProperty(sec,"_empty",{value:res=t===len,configurable:!0}),styleCodeEmpty.lastIndex=t,res}const KEY="importScriptsOnce",importScriptsOnce=e[KEY];let builderChain=Promise.resolve();const BUILDERS=Object.assign(Object.create(null),{default:{post(sections,vars){let varDef=Object.keys(vars).map(e=>`  --${e}: ${vars[e].value};\n`).join("");if(varDef){varDef=":root {\n"+varDef+"}\n";for(const section of sections)styleCodeEmpty(section)||spliceCssAfterGlobals(section,varDef,styleCodeEmpty.lastIndex)}}},stylus:{pre:(source,vars)=>(importScriptsOnce("stylus-lang.js"),new Promise((resolve,reject)=>{const varDef=Object.keys(vars).map(key=>`${key} = ${vars[key].value};\n`).join("");new StylusRenderer(varDef+source).render((err,output)=>err?reject(countVarLines(err,varDef)):resolve(output))}))},less:{async pre(source,vars){self.less||(self.document={currentScript:{}},self.window=self,self.less={logLevel:0,useFileCache:!1,onReady:!1}),importScriptsOnce("less.js");const varDefs=Object.keys(vars).map(key=>`@${key}:${vars[key].value};\n`).join("");try{return(await less.render(varDefs+source,{math:"parens-division"})).css}catch(e){throw countVarLines(e,varDefs)}}},uso:{pre(source,vars){importScriptsOnce("color-converter.js");const pool=Object.create(null);return doReplace(source);function doReplace(text){return text.replace(/(\/\*\[\[([\w-]+)]]\*\/)([0-9a-f]{2}(?=\W))?/gi,(e,cmt,name,alpha)=>{const key=alpha?name+"[A]":name;let val=pool[key];return void 0===val&&(val=pool[key]=getValue(name,null,alpha)),(null!=val?val:cmt)+(alpha||"")})}function getValue(name,isUsoRgb,alpha){const e=vars[name];if(!e)return name.endsWith("-rgb")?getValue(name.slice(0,-4),!0):null;let{value}=e;switch(e.type){case"color":if(value=colorConverter.parse(value)||null,value){alpha&&delete value.a;const isRgb=isUsoRgb||"rgb"===value.type||null!=value.a&&1!==value.a;value=colorConverter.format(value,isRgb?"rgb":"hex",{usoMode:isUsoRgb||!isRgb})}return value;case"dropdown":case"select":return pool[name]="",doReplace(value)}return value}}}});async function compileUsercss(preprocessor,code,vars){let builder=BUILDERS[preprocessor];builder||(builder=BUILDERS.default,null!=preprocessor&&console.warn(`Unknown preprocessor "${preprocessor}"`)),vars?simplifyUsercssVars(vars):vars={};const log=[];builder.pre&&(builderChain=builderChain.catch(()=>{}).then(async()=>{const logFn=console.log;console.log=(...args)=>log.push(args),code=await builder.pre(code,vars),console.log=logFn}),await builderChain),importScriptsOnce("moz-parser.js","parserlib.js");const res=extractSections({code});return builder.post&&builder.post(res.sections,vars),log.length&&(res.log=log),res}function countVarLines(err,str){return err._varLines=str.match(/^/gm).length,err}function simplifyUsercssVars(vars){for(const e of Object.values(vars)){let value=null!=e.value?e.value:e.default;switch(e.type){case"select":case"dropdown":case"image":for(const opt of e.options)if(opt.name===value){value=opt.value;break}break;case"number":case"range":value+=e.units||""}e.value=value}}function spliceCssAfterGlobals(section,newText,after){const{code}=section,e=/@import\s/gi;if(e.lastIndex=after,e.test(code)){importScriptsOnce("parserlib.js");const e=new parserlib.css.Parser({globalsOnly:!0});e.parse(code);const{col,line,offset}=e.stream.token||e.stream.peekCached();after=(code.indexOf("\r")+1||1e99)-1<offset?col+code.split("\n",line).reduce((len,e)=>len+e.length+1,0):offset+1}section.code=(after?code.slice(0,after)+"\n":"")+newText+code.slice(after)}t.d(s,{default:()=>compileUsercss}),self.compileUsercss=s.default})()}