11 lines
30 KiB
JavaScript
11 lines
30 KiB
JavaScript
function mt(){import.meta.url,import("_").catch(()=>1),(async function*(){})().next()}function Ue(t){return typeof t=="function"?t:Be(t)}function Be(t){if(t==null)return()=>!1;if(t==="fatal")return e=>e.level==="fatal";if(t==="error")return e=>e.level==="fatal"||e.level==="error";if(t==="warning")return e=>e.level==="fatal"||e.level==="error"||e.level==="warning";if(t==="info")return e=>e.level==="fatal"||e.level==="error"||e.level==="warning"||e.level==="info";if(t==="debug")return e=>e.level==="fatal"||e.level==="error"||e.level==="warning"||e.level==="info"||e.level==="debug";if(t==="trace")return()=>!0;throw new TypeError(`Invalid log level: ${t}.`)}const se=["trace","debug","info","warning","error","fatal"];function ae(t,e){const n=se.indexOf(t);if(n<0)throw new TypeError(`Invalid log level: ${JSON.stringify(t)}.`);const r=se.indexOf(e);if(r<0)throw new TypeError(`Invalid log level: ${JSON.stringify(e)}.`);return n-r}function Me(t=[]){return F.getLogger(t)}const V=Symbol.for("logtape.rootLogger");var F=class I{parent;children;category;sinks;parentSinks="inherit";filters;lowestLevel="trace";contextLocalStorage;static getLogger(e=[]){let n=V in globalThis?globalThis[V]??null:null;return n==null&&(n=new I(null,[]),globalThis[V]=n),typeof e=="string"?n.getChild(e):e.length===0?n:n.getChild(e)}constructor(e,n){this.parent=e,this.children={},this.category=n,this.sinks=[],this.filters=[]}getChild(e){const n=typeof e=="string"?e:e[0],r=this.children[n];let l=r instanceof I?r:r?.deref();return l==null&&(l=new I(this,[...this.category,n]),this.children[n]="WeakRef"in globalThis?new WeakRef(l):l),typeof e=="string"||e.length===1?l:l.getChild(e.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks="inherit";this.filters.length>0;)this.filters.shift();this.lowestLevel="trace"}resetDescendants(){for(const e of Object.values(this.children)){const n=e instanceof I?e:e.deref();n?.resetDescendants()}this.reset()}with(e){return new Ee(this,{...e})}filter(e){for(const n of this.filters)if(!n(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||ae(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks==="inherit")for(const n of this.parent.getSinks(e))yield n;for(const n of this.sinks)yield n}}emit(e,n){const r="category"in e?e:{...e,category:this.category};if(!(this.lowestLevel===null||ae(r.level,this.lowestLevel)<0||!this.filter(r))){for(const l of this.getSinks(r.level))if(!n?.has(l))try{l(r)}catch(i){const o=new Set(n);o.add(l),Fe.log("fatal","Failed to emit a log record to sink {sink}: {error}",{sink:l,error:i,record:r},o)}}}log(e,n,r,l){const i=I.getLogger().contextLocalStorage?.getStore()??{};let o;const s=typeof r=="function"?{category:this.category,level:e,timestamp:Date.now(),get message(){return fe(n,this.properties)},rawMessage:n,get properties(){return o==null&&(o={...i,...r()}),o}}:{category:this.category,level:e,timestamp:Date.now(),message:fe(n,{...i,...r}),rawMessage:n,properties:{...i,...r}};this.emit(s,l)}logLazily(e,n,r={}){const l=I.getLogger().contextLocalStorage?.getStore()??{};let i,o;function s(){if((o==null||i==null)&&(o=n((a,...c)=>(i=a,ce(a,c))),i==null))throw new TypeError("No log record was made.");return[o,i]}this.emit({category:this.category,level:e,get message(){return s()[0]},get rawMessage(){return s()[1]},timestamp:Date.now(),properties:{...l,...r}})}logTemplate(e,n,r,l={}){const i=I.getLogger().contextLocalStorage?.getStore()??{};this.emit({category:this.category,level:e,message:ce(n,r),rawMessage:n,timestamp:Date.now(),properties:{...i,...l}})}trace(e,...n){typeof e=="string"?this.log("trace",e,n[0]??{}):typeof e=="function"?this.logLazily("trace",e):Array.isArray(e)?this.logTemplate("trace",e,n):this.log("trace","{*}",e)}debug(e,...n){typeof e=="string"?this.log("debug",e,n[0]??{}):typeof e=="function"?this.logLazily("debug",e):Array.isArray(e)?this.logTemplate("debug",e,n):this.log("debug","{*}",e)}info(e,...n){typeof e=="string"?this.log("info",e,n[0]??{}):typeof e=="function"?this.logLazily("info",e):Array.isArray(e)?this.logTemplate("info",e,n):this.log("info","{*}",e)}warn(e,...n){typeof e=="string"?this.log("warning",e,n[0]??{}):typeof e=="function"?this.logLazily("warning",e):Array.isArray(e)?this.logTemplate("warning",e,n):this.log("warning","{*}",e)}warning(e,...n){this.warn(e,...n)}error(e,...n){typeof e=="string"?this.log("error",e,n[0]??{}):typeof e=="function"?this.logLazily("error",e):Array.isArray(e)?this.logTemplate("error",e,n):this.log("error","{*}",e)}fatal(e,...n){typeof e=="string"?this.log("fatal",e,n[0]??{}):typeof e=="function"?this.logLazily("fatal",e):Array.isArray(e)?this.logTemplate("fatal",e,n):this.log("fatal","{*}",e)}},Ee=class Le{logger;properties;constructor(e,n){this.logger=e,this.properties=n}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(e){return new Le(this.logger,{...this.properties,...e})}log(e,n,r,l){this.logger.log(e,n,typeof r=="function"?()=>({...this.properties,...r()}):{...this.properties,...r},l)}logLazily(e,n){this.logger.logLazily(e,n,this.properties)}logTemplate(e,n,r){this.logger.logTemplate(e,n,r,this.properties)}emit(e){const n={...e,properties:{...this.properties,...e.properties}};this.logger.emit(n)}trace(e,...n){typeof e=="string"?this.log("trace",e,n[0]??{}):typeof e=="function"?this.logLazily("trace",e):Array.isArray(e)?this.logTemplate("trace",e,n):this.log("trace","{*}",e)}debug(e,...n){typeof e=="string"?this.log("debug",e,n[0]??{}):typeof e=="function"?this.logLazily("debug",e):Array.isArray(e)?this.logTemplate("debug",e,n):this.log("debug","{*}",e)}info(e,...n){typeof e=="string"?this.log("info",e,n[0]??{}):typeof e=="function"?this.logLazily("info",e):Array.isArray(e)?this.logTemplate("info",e,n):this.log("info","{*}",e)}warn(e,...n){typeof e=="string"?this.log("warning",e,n[0]??{}):typeof e=="function"?this.logLazily("warning",e):Array.isArray(e)?this.logTemplate("warning",e,n):this.log("warning","{*}",e)}warning(e,...n){this.warn(e,...n)}error(e,...n){typeof e=="string"?this.log("error",e,n[0]??{}):typeof e=="function"?this.logLazily("error",e):Array.isArray(e)?this.logTemplate("error",e,n):this.log("error","{*}",e)}fatal(e,...n){typeof e=="string"?this.log("fatal",e,n[0]??{}):typeof e=="function"?this.logLazily("fatal",e):Array.isArray(e)?this.logTemplate("fatal",e,n):this.log("fatal","{*}",e)}};const Fe=F.getLogger(["logtape","meta"]);function Ne(t){return t.includes(".")||t.includes("[")||t.includes("?.")}function De(t,e){if(!(e==="__proto__"||e==="prototype"||e==="constructor")&&(typeof t=="object"||typeof t=="function")&&t!==null)return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function Pe(t,e){const n=t.length;let r=e;if(r>=n)return null;let l;if(t[r]==="["){if(r++,r>=n)return null;if(t[r]==='"'||t[r]==="'"){const i=t[r];r++;let o="";for(;r<n&&t[r]!==i;)if(t[r]==="\\"){if(r++,r<n){const s=t[r];switch(s){case"n":o+=`
|
|
`;break;case"t":o+=" ";break;case"r":o+="\r";break;case"b":o+="\b";break;case"f":o+="\f";break;case"v":o+="\v";break;case"0":o+="\0";break;case"\\":o+="\\";break;case'"':o+='"';break;case"'":o+="'";break;case"u":if(r+4<n){const a=t.slice(r+1,r+5),c=Number.parseInt(a,16);Number.isNaN(c)?o+=s:(o+=String.fromCharCode(c),r+=4)}else o+=s;break;default:o+=s}r++}}else o+=t[r],r++;if(r>=n)return null;l=o,r++}else{const i=r;for(;r<n&&t[r]!=="]"&&t[r]!=="'"&&t[r]!=='"';)r++;if(r>=n)return null;const o=t.slice(i,r);if(o.length===0)return null;const s=Number(o);l=Number.isNaN(s)?o:s}for(;r<n&&t[r]!=="]";)r++;r<n&&r++}else{const i=r;for(;r<n&&t[r]!=="."&&t[r]!=="["&&t[r]!=="?"&&t[r]!=="]";)r++;if(l=t.slice(i,r),l.length===0)return null}return r<n&&t[r]==="."&&r++,{segment:l,nextIndex:r}}function ze(t,e){if(typeof e=="string")return De(t,e);if(Array.isArray(t)&&e>=0&&e<t.length)return t[e]}function je(t,e){if(t==null||e.length===0||e.endsWith("."))return;let n=t,r=0;const l=e.length;for(;r<l;){if(e.slice(r,r+2)==="?."){if(r+=2,n==null)return}else if(n==null)return;const o=Pe(e,r);if(o===null)return;const{segment:s,nextIndex:a}=o;if(r=a,n=ze(n,s),n===void 0)return}return n}function fe(t,e){const n=t.length;if(n===0)return[""];if(!t.includes("{"))return[t];const r=[];let l=0;for(let o=0;o<n;o++){const s=t[o];if(s==="{"){if((o+1<n?t[o+1]:"")==="{"){o++;continue}const c=t.indexOf("}",o+1);if(c===-1)continue;const g=t.slice(l,o);r.push(g.replace(/{{/g,"{").replace(/}}/g,"}"));const h=t.slice(o+1,c);let b;const p=h.trim();p==="*"?b=h in e?e[h]:"*"in e?e["*"]:e:(h!==p?b=h in e?e[h]:e[p]:b=e[h],b===void 0&&Ne(p)&&(b=je(e,p))),r.push(b),o=c,l=o+1}else s==="}"&&o+1<n&&t[o+1]==="}"&&o++}const i=t.slice(l);return r.push(i.replace(/{{/g,"{").replace(/}}/g,"}")),r}function ce(t,e){const n=[];for(let r=0;r<t.length;r++)n.push(t[r]),r<e.length&&n.push(e[r]);return n}function te(t,e){const n=e?.compact===!0?void 0:2;return JSON.stringify(t,null,n)}const We=Object.freeze(Object.defineProperty({__proto__:null,inspect:te},Symbol.toStringTag,{value:"Module"})),Ce={trace:"TRC",debug:"DBG",info:"INF",warning:"WRN",error:"ERR",fatal:"FTL"},ge=typeof document<"u"||typeof navigator<"u"&&navigator.product==="ReactNative"?t=>JSON.stringify(t):"Deno"in globalThis&&"inspect"in globalThis.Deno&&typeof globalThis.Deno.inspect=="function"?(t,e)=>globalThis.Deno.inspect(t,{strAbbreviateSize:1/0,iterableLimit:1/0,...e}):We!=null&&typeof te=="function"?(t,e)=>te(t,{...e}):t=>JSON.stringify(t);function d(t){return t<10?`0${t}`:`${t}`}function B(t){return t<10?`00${t}`:t<100?`0${t}`:`${t}`}const J={"date-time-timezone":t=>{const e=new Date(t),n=e.getUTCFullYear(),r=d(e.getUTCMonth()+1),l=d(e.getUTCDate()),i=d(e.getUTCHours()),o=d(e.getUTCMinutes()),s=d(e.getUTCSeconds()),a=B(e.getUTCMilliseconds());return`${n}-${r}-${l} ${i}:${o}:${s}.${a} +00:00`},"date-time-tz":t=>{const e=new Date(t),n=e.getUTCFullYear(),r=d(e.getUTCMonth()+1),l=d(e.getUTCDate()),i=d(e.getUTCHours()),o=d(e.getUTCMinutes()),s=d(e.getUTCSeconds()),a=B(e.getUTCMilliseconds());return`${n}-${r}-${l} ${i}:${o}:${s}.${a} +00`},"date-time":t=>{const e=new Date(t),n=e.getUTCFullYear(),r=d(e.getUTCMonth()+1),l=d(e.getUTCDate()),i=d(e.getUTCHours()),o=d(e.getUTCMinutes()),s=d(e.getUTCSeconds()),a=B(e.getUTCMilliseconds());return`${n}-${r}-${l} ${i}:${o}:${s}.${a}`},"time-timezone":t=>{const e=new Date(t),n=d(e.getUTCHours()),r=d(e.getUTCMinutes()),l=d(e.getUTCSeconds()),i=B(e.getUTCMilliseconds());return`${n}:${r}:${l}.${i} +00:00`},"time-tz":t=>{const e=new Date(t),n=d(e.getUTCHours()),r=d(e.getUTCMinutes()),l=d(e.getUTCSeconds()),i=B(e.getUTCMilliseconds());return`${n}:${r}:${l}.${i} +00`},time:t=>{const e=new Date(t),n=d(e.getUTCHours()),r=d(e.getUTCMinutes()),l=d(e.getUTCSeconds()),i=B(e.getUTCMilliseconds());return`${n}:${r}:${l}.${i}`},date:t=>{const e=new Date(t),n=e.getUTCFullYear(),r=d(e.getUTCMonth()+1),l=d(e.getUTCDate());return`${n}-${r}-${l}`},rfc3339:t=>new Date(t).toISOString(),none:()=>null},M={ABBR:Ce,abbr:{trace:"trc",debug:"dbg",info:"inf",warning:"wrn",error:"err",fatal:"ftl"},FULL:{trace:"TRACE",debug:"DEBUG",info:"INFO",warning:"WARNING",error:"ERROR",fatal:"FATAL"},full:{trace:"trace",debug:"debug",info:"info",warning:"warning",error:"error",fatal:"fatal"},L:{trace:"T",debug:"D",info:"I",warning:"W",error:"E",fatal:"F"},l:{trace:"t",debug:"d",info:"i",warning:"w",error:"e",fatal:"f"}};function xe(t={}){const e=(()=>{const o=t.timestamp;return o==null?J["date-time-timezone"]:o==="disabled"?J.none:typeof o=="string"&&o in J?J[o]:o})(),n=t.category??"·",r=t.value?o=>t.value(o,ge):ge,l=(()=>{const o=t.level;return o==null||o==="ABBR"?s=>M.ABBR[s]:o==="abbr"?s=>M.abbr[s]:o==="FULL"?s=>M.FULL[s]:o==="full"?s=>M.full[s]:o==="L"?s=>M.L[s]:o==="l"?s=>M.l[s]:o})(),i=t.format??(({timestamp:o,level:s,category:a,message:c})=>`${o?`${o} `:""}[${s}] ${a}: ${c}`);return o=>{const s=o.message,a=s.length;let c;if(a===1)c=s[0];else if(a<=6){c="";for(let T=0;T<a;T++)c+=T%2===0?s[T]:r(s[T])}else{const T=new Array(a);for(let u=0;u<a;u++)T[u]=u%2===0?s[u]:r(s[u]);c=T.join("")}const g=e(o.timestamp),h=l(o.level),b=typeof n=="function"?n(o.category):o.category.join(n);return`${i({timestamp:g,level:h,category:b,message:c,record:o})}
|
|
`}}xe();const Z="\x1B[0m",Q={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},X={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",strikethrough:"\x1B[9m"},Je={trace:null,debug:"blue",info:"green",warning:"yellow",error:"red",fatal:"magenta"};function Ge(t={}){const e=t.format,n=typeof t.timestampStyle>"u"?"dim":t.timestampStyle,r=t.timestampColor??null,l=`${n==null?"":X[n]}${r==null?"":Q[r]}`,i=n==null&&r==null?"":Z,o=typeof t.levelStyle>"u"?"bold":t.levelStyle,s=t.levelColors??Je,a=typeof t.categoryStyle>"u"?"dim":t.categoryStyle,c=t.categoryColor??null,g=`${a==null?"":X[a]}${c==null?"":Q[c]}`,h=a==null&&c==null?"":Z;return xe({timestamp:"date-time-tz",value(b,p){return p(b,{colors:!0})},...t,format({timestamp:b,level:p,category:T,message:u,record:v}){const f=s[v.level];return b=`${l}${b}${i}`,p=`${o==null?"":X[o]}${f==null?"":Q[f]}${p}${o==null&&f==null?"":Z}`,e==null?`${b} ${p} ${g}${T}:${h} ${u}`:e({timestamp:b,level:p,category:`${g}${T}${h}`,message:u,record:v})}})}Ge();function Ye(t={}){if(!t.categorySeparator&&!t.message&&!t.properties)return o=>{if(o.message.length===3)return JSON.stringify({"@timestamp":new Date(o.timestamp).toISOString(),level:o.level==="warning"?"WARN":o.level.toUpperCase(),message:o.message[0]+JSON.stringify(o.message[1])+o.message[2],logger:o.category.join("."),properties:o.properties})+`
|
|
`;if(o.message.length===1)return JSON.stringify({"@timestamp":new Date(o.timestamp).toISOString(),level:o.level==="warning"?"WARN":o.level.toUpperCase(),message:o.message[0],logger:o.category.join("."),properties:o.properties})+`
|
|
`;let s=o.message[0];for(let a=1;a<o.message.length;a++)s+=a&1?JSON.stringify(o.message[a]):o.message[a];return JSON.stringify({"@timestamp":new Date(o.timestamp).toISOString(),level:o.level==="warning"?"WARN":o.level.toUpperCase(),message:s,logger:o.category.join("."),properties:o.properties})+`
|
|
`};const e=t.message==="template",n=t.properties??"nest:properties";let r;if(typeof t.categorySeparator=="function")r=t.categorySeparator;else{const o=t.categorySeparator??".";r=s=>s.join(o)}let l;if(n==="flatten")l=o=>o;else if(n.startsWith("prepend:")){const o=n.substring(8);if(o==="")throw new TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);l=s=>{const a={};for(const c in s)a[`${o}${c}`]=s[c];return a}}else if(n.startsWith("nest:")){const o=n.substring(5);l=s=>({[o]:s})}else throw new TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let i;return e?i=o=>{if(typeof o.rawMessage=="string")return o.rawMessage;let s="";for(let a=0;a<o.rawMessage.length;a++)s+=a%2<1?o.rawMessage[a]:"{}";return s}:i=o=>{const s=o.message.length;if(s===1)return o.message[0];let a="";for(let c=0;c<s;c++)a+=c%2<1?o.message[c]:JSON.stringify(o.message[c]);return a},o=>JSON.stringify({"@timestamp":new Date(o.timestamp).toISOString(),level:o.level==="warning"?"WARN":o.level.toUpperCase(),message:i(o),logger:r(o.category),...l(o.properties)})+`
|
|
`}Ye();const _e={trace:"background-color: gray; color: white;",debug:"background-color: gray; color: white;",info:"background-color: white; color: black;",warning:"background-color: orange; color: black;",error:"background-color: red; color: white;",fatal:"background-color: maroon; color: white;"};function He(t){let e="";const n=[];for(let i=0;i<t.message.length;i++)i%2===0?e+=t.message[i]:(e+="%o",n.push(t.message[i]));const r=new Date(t.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,"0")}:${r.getUTCMinutes().toString().padStart(2,"0")}:${r.getUTCSeconds().toString().padStart(2,"0")}.${r.getUTCMilliseconds().toString().padStart(3,"0")}`} %c${Ce[t.level]}%c %c${t.category.join("·")} %c${e}`,"color: gray;",_e[t.level],"background-color: default;","color: gray;","color: default;",...n]}function $e(t={}){const e=t.formatter??He,n={trace:"debug",debug:"debug",info:"info",warning:"warn",error:"error",fatal:"error",...t.levelMap??{}},r=t.console??globalThis.console,l=f=>{const L=e(f),O=n[f.level];if(O===void 0)throw new TypeError(`Invalid log level: ${f.level}.`);if(typeof L=="string"){const S=L.replace(/\r?\n$/,"");r[O](S)}else r[O](...L)};if(!t.nonBlocking)return l;const i=t.nonBlocking===!0?{}:t.nonBlocking,o=i.bufferSize??100,s=i.flushInterval??100,a=[];let c=null,g=!1,h=!1;const b=o*2;function p(){if(a.length===0)return;const f=a.splice(0);for(const L of f)try{l(L)}catch{}}function T(){h||(h=!0,setTimeout(()=>{h=!1,p()},0))}function u(){c!==null||g||(c=setInterval(()=>{p()},s))}const v=f=>{g||(a.length>=b&&a.shift(),a.push(f),a.length>=o?T():c===null&&u())};return v[Symbol.dispose]=()=>{g=!0,c!==null&&(clearInterval(c),c=null),p()},v}let le=null;const Ae=new Set,_=new Set,qe=new Set;function Ke(t){return t.category.length===0||t.category.length===1&&t.category[0]==="logtape"||t.category.length===2&&t.category[0]==="logtape"&&t.category[1]==="meta"}function Ve(t){if(le!=null&&!t.reset)throw new R("Already configured; if you want to reset, turn on the reset flag.");if(qe.size>0)throw new R("Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().");ue();try{Ze(t,!1)}catch(e){throw e instanceof R&&ue(),e}}function Ze(t,e){le=t;let n=!1;const r=new Set;for(const i of t.loggers){Ke(i)&&(n=!0);const o=Array.isArray(i.category)?JSON.stringify(i.category):JSON.stringify([i.category]);if(r.has(o))throw new R(`Duplicate logger configuration for category: ${o}. Each category can only be configured once.`);r.add(o);const s=F.getLogger(i.category);for(const a of i.sinks??[]){const c=t.sinks[a];if(!c)throw new R(`Sink not found: ${a}.`);s.sinks.push(c)}s.parentSinks=i.parentSinks??"inherit",i.lowestLevel!==void 0&&(s.lowestLevel=i.lowestLevel);for(const a of i.filters??[]){const c=t.filters?.[a];if(c===void 0)throw new R(`Filter not found: ${a}.`);s.filters.push(Ue(c))}Ae.add(s)}F.getLogger().contextLocalStorage=t.contextLocalStorage;for(const i of Object.values(t.sinks)){if(Symbol.asyncDispose in i)throw new R("Async disposables cannot be used with configureSync().");Symbol.dispose in i&&_.add(i)}for(const i of Object.values(t.filters??{}))if(!(i==null||typeof i=="string")){if(Symbol.asyncDispose in i)throw new R("Async disposables cannot be used with configureSync().");Symbol.dispose in i&&_.add(i)}if(typeof globalThis.EdgeRuntime!="string"&&"process"in globalThis&&!("Deno"in globalThis)){const i=globalThis.process,o=i?.on;typeof o=="function"&&o.call(i,"exit",ne)}else addEventListener("unload",ne);const l=F.getLogger(["logtape","meta"]);n||l.sinks.push($e()),l.info("LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger purposes to log internal errors such as sink exceptions. If you are seeing this message, the meta logger is automatically configured. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.",{metaLoggerCategory:["logtape","meta"],dismissLevel:"info"})}function ue(){ne(),Qe()}function Qe(){const t=F.getLogger([]);t.resetDescendants(),delete t.contextLocalStorage,Ae.clear(),le=null}function ne(){for(const t of _)t[Symbol.dispose]();_.clear()}var R=class extends Error{constructor(t){super(t),this.name="ConfigureError"}};const ee=10,he=(t=0)=>e=>`\x1B[${e+t}m`,pe=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,ye=(t=0)=>(e,n,r)=>`\x1B[${38+t};2;${e};${n};${r}m`,m={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(m.modifier);const Xe=Object.keys(m.color),et=Object.keys(m.bgColor);[...Xe,...et];function tt(){const t=new Map;for(const[e,n]of Object.entries(m)){for(const[r,l]of Object.entries(n))m[r]={open:`\x1B[${l[0]}m`,close:`\x1B[${l[1]}m`},n[r]=m[r],t.set(l[0],l[1]);Object.defineProperty(m,e,{value:n,enumerable:!1})}return Object.defineProperty(m,"codes",{value:t,enumerable:!1}),m.color.close="\x1B[39m",m.bgColor.close="\x1B[49m",m.color.ansi=he(),m.color.ansi256=pe(),m.color.ansi16m=ye(),m.bgColor.ansi=he(ee),m.bgColor.ansi256=pe(ee),m.bgColor.ansi16m=ye(ee),Object.defineProperties(m,{rgbToAnsi256:{value(e,n,r){return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(e){const n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!n)return[0,0,0];let[r]=n;r.length===3&&(r=[...r].map(i=>i+i).join(""));const l=Number.parseInt(r,16);return[l>>16&255,l>>8&255,l&255]},enumerable:!1},hexToAnsi256:{value:e=>m.rgbToAnsi256(...m.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let n,r,l;if(e>=232)n=((e-232)*10+8)/255,r=n,l=n;else{e-=16;const s=e%36;n=Math.floor(e/36)/5,r=Math.floor(s/6)/5,l=s%6/5}const i=Math.max(n,r,l)*2;if(i===0)return 30;let o=30+(Math.round(l)<<2|Math.round(r)<<1|Math.round(n));return i===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,n,r)=>m.ansi256ToAnsi(m.rgbToAnsi256(e,n,r)),enumerable:!1},hexToAnsi:{value:e=>m.ansi256ToAnsi(m.hexToAnsi256(e)),enumerable:!1}}),m}const A=tt(),de=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const t=navigator.userAgentData.brands.find(({brand:e})=>e==="Chromium");if(t&&t.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),ve=de!==0&&{level:de},nt={stdout:ve,stderr:ve};function rt(t,e,n){let r=t.indexOf(e);if(r===-1)return t;const l=e.length;let i=0,o="";do o+=t.slice(i,r)+e+n,i=r+l,r=t.indexOf(e,i);while(r!==-1);return o+=t.slice(i),o}function ot(t,e,n,r){let l=0,i="";do{const o=t[r-1]==="\r";i+=t.slice(l,o?r-1:r)+e+(o?`\r
|
|
`:`
|
|
`)+n,l=r+1,r=t.indexOf(`
|
|
`,l)}while(r!==-1);return i+=t.slice(l),i}const{stdout:me,stderr:be}=nt,re=Symbol("GENERATOR"),N=Symbol("STYLER"),z=Symbol("IS_EMPTY"),we=["ansi","ansi","ansi256","ansi16m"],D=Object.create(null),it=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const n=me?me.level:0;t.level=e.level===void 0?n:e.level},lt=t=>{const e=(...n)=>n.join(" ");return it(e,t),Object.setPrototypeOf(e,j.prototype),e};function j(t){return lt(t)}Object.setPrototypeOf(j.prototype,Function.prototype);for(const[t,e]of Object.entries(A))D[t]={get(){const n=H(this,ie(e.open,e.close,this[N]),this[z]);return Object.defineProperty(this,t,{value:n}),n}};D.visible={get(){const t=H(this,this[N],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const oe=(t,e,n,...r)=>t==="rgb"?e==="ansi16m"?A[n].ansi16m(...r):e==="ansi256"?A[n].ansi256(A.rgbToAnsi256(...r)):A[n].ansi(A.rgbToAnsi(...r)):t==="hex"?oe("rgb",e,n,...A.hexToRgb(...r)):A[n][t](...r),st=["rgb","hex","ansi256"];for(const t of st){D[t]={get(){const{level:n}=this;return function(...r){const l=ie(oe(t,we[n],"color",...r),A.color.close,this[N]);return H(this,l,this[z])}}};const e="bg"+t[0].toUpperCase()+t.slice(1);D[e]={get(){const{level:n}=this;return function(...r){const l=ie(oe(t,we[n],"bgColor",...r),A.bgColor.close,this[N]);return H(this,l,this[z])}}}}const at=Object.defineProperties(()=>{},{...D,level:{enumerable:!0,get(){return this[re].level},set(t){this[re].level=t}}}),ie=(t,e,n)=>{let r,l;return n===void 0?(r=t,l=e):(r=n.openAll+t,l=e+n.closeAll),{open:t,close:e,openAll:r,closeAll:l,parent:n}},H=(t,e,n)=>{const r=(...l)=>ft(r,l.length===1?""+l[0]:l.join(" "));return Object.setPrototypeOf(r,at),r[re]=t,r[N]=e,r[z]=n,r},ft=(t,e)=>{if(t.level<=0||!e)return t[z]?"":e;let n=t[N];if(n===void 0)return e;const{openAll:r,closeAll:l}=n;if(e.includes("\x1B"))for(;n!==void 0;)e=rt(e,n.close,n.open),n=n.parent;const i=e.indexOf(`
|
|
`);return i!==-1&&(e=ot(e,l,r,i)),r+e+l};Object.defineProperties(j.prototype,D);const E=j();j({level:be?be.level:0});function Oe(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var G={exports:{}},ct=G.exports,Se;function gt(){return Se||(Se=1,(function(t){(function(e,n){t.exports?t.exports=n():e.log=n()})(ct,function(){var e=function(){},n="undefined",r=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),l=["trace","debug","info","warn","error"],i={},o=null;function s(u,v){var f=u[v];if(typeof f.bind=="function")return f.bind(u);try{return Function.prototype.bind.call(f,u)}catch{return function(){return Function.prototype.apply.apply(f,[u,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(u){return u==="debug"&&(u="log"),typeof console===n?!1:u==="trace"&&r?a:console[u]!==void 0?s(console,u):console.log!==void 0?s(console,"log"):e}function g(){for(var u=this.getLevel(),v=0;v<l.length;v++){var f=l[v];this[f]=v<u?e:this.methodFactory(f,u,this.name)}if(this.log=this.debug,typeof console===n&&u<this.levels.SILENT)return"No console available for logging"}function h(u){return function(){typeof console!==n&&(g.call(this),this[u].apply(this,arguments))}}function b(u,v,f){return c(u)||h.apply(this,arguments)}function p(u,v){var f=this,L,O,S,C="loglevel";typeof u=="string"?C+=":"+u:typeof u=="symbol"&&(C=void 0);function K(y){var w=(l[y]||"silent").toUpperCase();if(!(typeof window===n||!C)){try{window.localStorage[C]=w;return}catch{}try{window.document.cookie=encodeURIComponent(C)+"="+w+";"}catch{}}}function W(){var y;if(!(typeof window===n||!C)){try{y=window.localStorage[C]}catch{}if(typeof y===n)try{var w=window.document.cookie,U=encodeURIComponent(C),P=w.indexOf(U+"=");P!==-1&&(y=/^([^;]+)/.exec(w.slice(P+U.length+1))[1])}catch{}return f.levels[y]===void 0&&(y=void 0),y}}function x(){if(!(typeof window===n||!C)){try{window.localStorage.removeItem(C)}catch{}try{window.document.cookie=encodeURIComponent(C)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function k(y){var w=y;if(typeof w=="string"&&f.levels[w.toUpperCase()]!==void 0&&(w=f.levels[w.toUpperCase()]),typeof w=="number"&&w>=0&&w<=f.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+y)}f.name=u,f.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},f.methodFactory=v||b,f.getLevel=function(){return S??O??L},f.setLevel=function(y,w){return S=k(y),w!==!1&&K(S),g.call(f)},f.setDefaultLevel=function(y){O=k(y),W()||f.setLevel(y,!1)},f.resetLevel=function(){S=null,x(),g.call(f)},f.enableAll=function(y){f.setLevel(f.levels.TRACE,y)},f.disableAll=function(y){f.setLevel(f.levels.SILENT,y)},f.rebuild=function(){if(o!==f&&(L=k(o.getLevel())),g.call(f),o===f)for(var y in i)i[y].rebuild()},L=k(o?o.getLevel():"WARN");var $=W();$!=null&&(S=k($)),g.call(f)}o=new p,o.getLogger=function(v){if(typeof v!="symbol"&&typeof v!="string"||v==="")throw new TypeError("You must supply a name when creating a logger.");var f=i[v];return f||(f=i[v]=new p(v,o.methodFactory)),f};var T=typeof window!==n?window.log:void 0;return o.noConflict=function(){return typeof window!==n&&window.log===o&&(window.log=T),o},o.getLoggers=function(){return i},o.default=o,o})})(G)),G.exports}var ut=gt();const ht=Oe(ut);var Y={exports:{}},pt=Y.exports,Te;function yt(){return Te||(Te=1,(function(t){(function(e,n){t.exports?t.exports=n():e.prefix=n(e)})(pt,function(e){var n=function(g){for(var h=1,b=arguments.length,p;h<b;h++)for(p in arguments[h])Object.prototype.hasOwnProperty.call(arguments[h],p)&&(g[p]=arguments[h][p]);return g},r={template:"[%t] %l:",levelFormatter:function(g){return g.toUpperCase()},nameFormatter:function(g){return g||"root"},timestampFormatter:function(g){return g.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},l,i={},o=function(g){if(!g||!g.getLogger)throw new TypeError("Argument is not a root logger");l=g},s=function(g,h){if(!g||!g.setLevel)throw new TypeError("Argument is not a logger");var b=g.methodFactory,p=g.name||"",T=i[p]||i[""]||r;function u(v,f,L){var O=b(v,f,L),S=i[L]||i[""],C=S.template.indexOf("%t")!==-1,K=S.template.indexOf("%l")!==-1,W=S.template.indexOf("%n")!==-1;return function(){for(var x="",k=arguments.length,$=Array(k),y=0;y<k;y++)$[y]=arguments[y];if(p||!i[L]){var w=S.timestampFormatter(new Date),U=S.levelFormatter(v),P=S.nameFormatter(L);S.format?x+=S.format(U,P,w):(x+=S.template,C&&(x=x.replace(/%t/,w)),K&&(x=x.replace(/%l/,U)),W&&(x=x.replace(/%n/,P))),$.length&&typeof $[0]=="string"?$[0]=x+" "+$[0]:$.unshift(x)}O.apply(void 0,$)}}return i[p]||(g.methodFactory=u),h=h||{},h.template&&(h.format=void 0),i[p]=n({},T,h),g.setLevel(g.getLevel()),l||g.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),g},a={reg:o,apply:s},c;return e&&(c=e.prefix,a.noConflict=function(){return e.prefix===a&&(e.prefix=c),a}),a})})(Y)),Y.exports}var dt=yt();const ke=Oe(dt),vt={DEBUG:E.cyan,ERROR:E.red,INFO:E.blue,TRACE:E.magenta,WARN:E.yellow},q=ht.noConflict();q.enableAll(!0);q.setDefaultLevel("DEBUG");ke.reg(q);ke.apply(q,{format(t,e,n){return`${E.gray(`[${n}]`)} ${vt[t.toUpperCase()](t)}`}});const Ie="haiku-atelier";Ve({loggers:[{category:Ie,lowestLevel:"warning",sinks:["console"]}],sinks:{console:$e()}});const bt=Me(Ie);export{mt as __vite_legacy_guard,q as l,bt as n};
|