@wener/utils 1.1.10 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- function pe(e,t=null,r=R){return Object.fromEntries(t===null?Object.entries(e).map(([n,o])=>[n,r(o)]):t.map(n=>[n,r(n)]))}function R(e){return Array.isArray(e)?e[0]:e}function he(e){return Array.isArray(e)?e[e.length-1]:e}function ge(e){return Array.isArray(e)?e:e==null?[]:[e]}async function we(e){const t=[];for await(const r of e)t.push(r);return t}function U(e){if(typeof e!="string")return Array.isArray(e)?e:[e];const t=e.split(".");if(!e.includes("["))return t;const r=[];for(const n of t)if(!n.endsWith("]"))r.push(n);else{const o=n.split("[");for(let i of o)i.endsWith("]")&&(i=i.slice(0,-1)),r.push(i)}return r}function T(e,t,r){const n=U(t);let o=e;for(const i of n)o=o?o[i]:void 0;return o===void 0?r:o}function me(e,t,r,n=!0){const o=U(t);let i=0;const a=o.length;let s=e,c,l;for(;i<a&&(l=o[i++],!(l==="__proto__"||l==="constructor"||l==="prototype"));)s=s[l]=i===a?n?S(s[l],r):r:typeof(c=s[l])==typeof o?c:o[i]*0!==0||~(""+o[i]).indexOf(".")?{}:[]}function S(e,t){let r;if(typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t))for(r=0;r<t.length;r++)e[r]=S(e[r],t[r]);else for(r in t){if(r==="__proto__"||r==="constructor"||r==="prototype")break;e[r]=S(e[r],t[r])}return e}return t}function I(e){return e&&(e instanceof Promise||e.then&&e.catch)}function be(e){const t={resolve(n){throw new Error("pending resolve")},reject(n){throw new Error("pending reject")}},r=Object.assign(new Promise((n,o)=>{t.reject=o,t.resolve=n}),{resolve(n){t.resolve(n)},reject(n){t.resolve(n)}});if(e){const n=t.resolve;let o=!0;t.resolve=s=>{o=!1,n(s)};const i=r.then.bind(r);r.then=(...s)=>{if(o){o=!1;try{const c=e(t.resolve,t.reject);I(c)?c.then(t.resolve,t.reject):c!==void 0&&t.resolve(c)}catch(c){t.reject(c)}}return i(...s)};const a=t;return a.then=r.then,a.catch=r.catch.bind(r),r.finally&&(a.finally=r.finally),Object.defineProperty(a,Symbol.species,{get(){return Promise}}),a}return r}function Ae(e,t,r=t){let n;const o=async()=>{await e(),n=setTimeout(o,t)};return n=setTimeout(o,r),()=>n}function ve(e){clearTimeout(e==null?void 0:e())}const Be=e=>new Promise(t=>setTimeout(t,e));function je(e,t){const r=new z;let n;return Promise.race([e,new Promise((o,i)=>{n=setTimeout(()=>i(r),t)})]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}class z extends Error{constructor(){super("TimeoutError")}}function xe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(t,r[n])||!Object.is(e[r[n]],t[r[n]]))return!1;return!0}const F=Object.prototype.hasOwnProperty,Ee=typeof Element<"u";function W(e,t,r){for(r of e.keys())if(v(r,t))return r}function v(e,t){let r,n,o;if(e===t)return!0;if(e&&t&&(r=e.constructor)===t.constructor){if(r===Date)return e.getTime()===t.getTime();if(r===RegExp)return e.toString()===t.toString();if(r===Array){if((n=e.length)===t.length)for(;n--&&v(e[n],t[n]););return n===-1}if(r===Set){if(e.size!==t.size)return!1;for(n of e)if(o=n,o&&typeof o=="object"&&(o=W(t,o),!o)||!t.has(o))return!1;return!0}if(r===Map){if(e.size!==t.size)return!1;for(n of e)if(o=n[0],o&&typeof o=="object"&&(o=W(t,o),!o)||!v(n[1],t.get(o)))return!1;return!0}if(r===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(r===DataView){if((n=e.byteLength)===t.byteLength)for(;n--&&e.getInt8(n)===t.getInt8(n););return n===-1}if(ArrayBuffer.isView(e)){if((n=e.byteLength)===t.byteLength)for(;n--&&e[n]===t[n];);return n===-1}if(Ee&&e instanceof Element)return!1;if(!r||typeof e=="object"){n=0;for(r in e)if(!((r==="_owner"||r==="__v"||r==="__o")&&e.$$typeof)&&(F.call(e,r)&&++n&&!F.call(t,r)||!(r in t)||!v(e[r],t[r])))return!1;return Object.keys(t).length===n}}return e!==e&&t!==t}function B(e){return Object.prototype.toString.call(e).slice(8,-1)}function Oe(e){return e&&(Array.isArray(e)?e.slice():typeof e=="object"?Object.assign({},e):e)}function $e(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}function Ce(e){return e!=null}function Z(e){return B(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function Ue(e){return Z(e)&&Object.keys(e).length===0}function Te(e,t=!1){if(typeof e=="boolean")return e;if(typeof e=="string")switch(e.toLowerCase()){case"f":case"false":case"0":return!1;case"1":case"t":case"true":return!0}else if(typeof e=="number")switch(e){case 0:return!1;case 1:return!0}if(!t)return Boolean(e)}function Se(e,...t){return e instanceof Function?e(...t):e}function ke(e,{resolver:t=(...r)=>JSON.stringify(r)}={}){if(typeof e!="function")throw new Error("`callback` should be a function");if(t!==void 0&&typeof t!="function")throw new Error("`resolver` should be a function");const r={},n=function(){const o=Array.prototype.slice.call(arguments),i=t.apply(this,o);return i in r||(r[i]=e.apply(this,o)),r[i]};return n.cache=r,n}function Pe(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function Me(e){if(e){if(e instanceof Date)return e;if(typeof e=="string"&&/^[0-9.]+$/.test(e)){let t=parseFloat(e);return Math.floor(t).toString().length<=11&&(t*=1e3),new Date(t)}else if(typeof e=="string"){const t=new Date(e);if(!isNaN(+t))return t}throw new Error(`parseTimestamp: invalid "${e}"`)}}const _e=/^(?<n>(?:@(?<org>[a-z0-9-~][a-z0-9-._~]*)\/)?(?<pkg>[a-z0-9-~][a-z0-9-._~]*))(?:@(?<v>[-a-z0-9><=_.^~]+))?(?<p>\/[^\r\n]*)?$/;function De(e){var t;const r=(t=e.match(_e))==null?void 0:t.groups;if(!r)return;const{n,v:o,p:i,org:a,pkg:s}=r,c=Boolean(a),l=/^\d+\.\d+\.\d+/.test(o)?o:void 0,g=o||"latest",A={id:`${n}@${g}`,name:n,range:g,scoped:c,pkg:s,org:a,versioned:Boolean(o)};return l&&(A.version=l),i&&(A.path=i),A.scoped||delete A.org,A}function Le(e){return e&&e[Symbol.toStringTag]==="Module"}function k(e=({level:r,values:n,...o})=>{var i;({values:n,...o}=Ve(o,n)),(i=console[r])==null||i.call(console,...n,o)},t={}){return{trace:(...r)=>e({...t,level:"trace",values:r}),debug:(...r)=>e({...t,level:"debug",values:r}),info:(...r)=>e({...t,level:"info",values:r}),warn:(...r)=>e({...t,level:"warn",values:r}),error:(...r)=>e({...t,level:"error",values:r}),child:r=>k(e,{...t,...r})}}function Ve(e,t){return t[0]&&typeof t[0]=="object"?{...e,...t[0],values:t.slice(1)}:{...e,values:t}}function q(){const e=(...t)=>{};return{trace:e,debug:e,info:e,warn:e,error:e,child:()=>q()}}function Ne(e,t){return e.child?e.child(t):k(r=>{const{level:n,values:o,...i}=r;Object.keys(i).length?e[n](i,...o):e[n](...o)},t)}function Re(e){let t=!1,r=!1,n=!1;for(let o=0;o<e.length;o++){const i=e[o];t&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(e=e.slice(0,o)+"-"+e.slice(o),t=!1,n=r,r=!0,o++):r&&n&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(e=e.slice(0,o-1)+"-"+e.slice(o-1),n=r,r=!1,t=!0):(t=i.toLowerCase()===i&&i.toUpperCase()!==i,n=r,r=i.toUpperCase()===i&&i.toLowerCase()!==i)}return e}function Ie(e){return G(e,{pascalCase:!0})}function G(e,t={pascalCase:!1}){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");const r=n=>t.pascalCase?n.charAt(0).toUpperCase()+n.slice(1):n;return Array.isArray(e)?e=e.map(n=>n.trim()).filter(n=>n.length).join("-"):e=e.trim(),e.length===0?"":e.length===1?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=Re(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(n,o)=>o.toUpperCase()).replace(/\d+(\w|$)/g,n=>n.toUpperCase()),r(e))}function H(e,t,r="js"){let n;return t?typeof t=="function"?n=t:n=o=>T(t,o):n=()=>"",typeof r=="string"&&(r=J[r]||J.js),e.replace(r,(o,i)=>n(i.trim()))}const J={js:/\${(.*?)}/g,common:/{{(.*?)}}/g};function ze(e,t=!1,r=1){const n=t?1e3:1024;if(Math.abs(e)<n)return`${e} B`;const o=t?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let i=-1;const a=10**r;do e/=n,++i;while(Math.round(Math.abs(e)*a)/a>=n&&i<o.length-1);return e.toFixed(r)+" "+o[i]}function Fe(e){let t="";const r=e||{},n=o=>{if(Array.isArray(o))return o;const i=o.split(/[_-]/);return i.length>1?[o,i[0]]:[o]};return{locale(o){return t=o||t},dict:(o,i)=>{if(i){r[o]=Object.assign(r[o]||{},i);return}return r[o]},t(o,i,a){let s;for(const c of n(a||t))if(s=T(r[c],o,""),s)break;return typeof s=="function"?s(i):typeof s=="string"?H(s,i,"common"):s}}}function j(e){var t,r;return(r=(t=e==null?void 0:e.constructor)==null?void 0:t.isBuffer)==null?void 0:r.call(t,e)}function We(e){return K||=Ze(),K.some(t=>e instanceof t)}let K;function Ze(){const e=globalThis.window||globalThis||global;return[e.ArrayBuffer,e.MessagePort,e.ReadableStream,e.WritableStream,e.TransformStream,e.AudioData,e.ImageBitmap,e.VideoFrame,e.OffscreenCanvas,e.RTCDataChannel].filter(Boolean)}const w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",x=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<w.length;e++)x[w.charCodeAt(e)]=e;function qe(e){const t=new Uint8Array(e),r=t.length;let n="";for(let o=0;o<r;o+=3)n+=w[t[o]>>2],n+=w[(t[o]&3)<<4|t[o+1]>>4],n+=w[(t[o+1]&15)<<2|t[o+2]>>6],n+=w[t[o+2]&63];return r%3===2?n=n.substring(0,n.length-1)+"=":r%3===1&&(n=n.substring(0,n.length-2)+"=="),n}function Ge(e){const t=e.length;let r=e.length*.75,n,o=0,i,a,s,c;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);const l=new ArrayBuffer(r),g=new Uint8Array(l);for(n=0;n<t;n+=4)i=x[e.charCodeAt(n)],a=x[e.charCodeAt(n+1)],s=x[e.charCodeAt(n+2)],c=x[e.charCodeAt(n+3)],g[o++]=i<<2|a>>4,g[o++]=(a&15)<<4|s>>2,g[o++]=(s&3)<<6|c&63;return l}var Y=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},P=(e,t,r)=>(Y(e,t,"read from private field"),r?r.call(e):t.get(e)),Q=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},X=(e,t,r,n)=>(Y(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),$,E;const u=class{static isNativeBufferAvailable(){var t,r;return P(this,E)??X(this,E,!((r=(t=globalThis.Buffer)==null?void 0:t.isPollyfill)!=null&&r.call(t)))}static isNativeBufferAllowed(){return P(this,$)&&P(this,E)}static setNativeBufferAllowed(t){X(this,$,t)}};let f=u;$=new WeakMap,E=new WeakMap,Q(f,$,!0),Q(f,E,void 0),f.isArrayBuffer=e=>e instanceof ArrayBuffer,f.slice=(e,t,r)=>j(e)?Uint8Array.prototype.slice.call(e,t,r):e.slice(t,r),f.asView=(e,t,r,n)=>t instanceof e&&(r??0)===0&&n===void 0?t:ArrayBuffer.isView(t)||j(t)?u.isNativeBufferAllowed()&&e===Buffer?Buffer.from(t.buffer,r,n):new e(t.buffer,t.byteOffset+(r??0),n??t.byteLength):new e(t,r,n),f.toString=(e,t="utf8")=>{if(typeof e=="string")switch(t){case"base64":return btoa(e);case"utf-8":case"utf8":return e;default:throw new Error(`[ArrayBuffers.toString] Unsupported encoding for string: ${t}`)}if(u.isNativeBufferAllowed())return Buffer.from(u.asView(Uint8Array,e)).toString(t);switch(t){case"hex":return[...u.asView(Uint8Array,e)].map(r=>He[r]).join("");case"base64":return qe(u.asView(Uint8Array,e));case"utf8":case"utf-8":return new TextDecoder().decode(e);case"ascii":{const r=u.asView(Uint8Array,e);return String.fromCharCode(...r.map(n=>n&127))}case"latin1":case"binary":{const r=u.asView(Uint8Array,e);return String.fromCharCode(...r)}case"ucs2":case"ucs-2":case"utf16le":{const r=u.asView(Uint8Array,e);let n="";for(let o=0;o<r.length-1;o+=2)n+=String.fromCharCode(r[o]+r[o+1]*256);return n}default:throw new Error(`[ArrayBuffers.toString] Unknown encoding: ${t}`)}},f.toJSON=(e,t)=>JSON.parse(u.toString(e),t),f.alloc=(e,t,r)=>t!==void 0?typeof t=="number"?new Uint8Array(e).fill(t):u.asView(Uint8Array,u.from(t,r)).slice(0,e):new ArrayBuffer(e),f.from=(e,t="utf8")=>{if(!e)return new ArrayBuffer(0);if(typeof e=="string"){if(u.isNativeBufferAllowed())return Buffer.from(e,t);switch(t){case"utf-8":case"utf8":return new TextEncoder().encode(e).buffer;case"base64":return Ge(e.replace(/[^0-9a-zA-Z=+/_]/g,""));default:throw new Error(`[ArrayBuffers.from] Unknown encoding: ${t}`)}}if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)||j(e)){if(e.byteOffset!==0)throw new Error("ArrayBuffers.from do not support view with offset");return e.buffer}if(Array.isArray(e))return new Uint8Array(e);const r=B(e);throw new TypeError(`ArrayBuffers.from unsupported type ${r}`)},f.isEncoding=e=>{switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":return!0;default:return!1}},f.concat=(e,t,r=0)=>{const n=e.reduce((i,a)=>i+a.byteLength,0),o=t?new Uint8Array(t):new Uint8Array(n);for(const i of e){if(!(i!=null&&i.byteLength))continue;let a;if(i instanceof ArrayBuffer)a=new Uint8Array(i);else if(ArrayBuffer.isView(i))a=new Uint8Array(i.buffer,i.byteOffset,i.byteLength);else throw new Error(`ArrayBuffers.concat unsupported type ${B(i)}`);o.set(a,r),r+=i.byteLength}return o.buffer};const He=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=r*16;for(let o=0;o<16;++o)t[n+o]=e[r]+e[o]}return t}(),M=class extends Uint8Array{static get isPolyfill(){return!0}static isBuffer(e){return e instanceof M||j(e)}static from(e,t){return new M(f.from(e,t))}toString(e){return f.toString(this,e)}};let ee=M;ee.isEncoding=f.isEncoding;let _;function Je(){let e;function t(){return navigator.userAgent.match(/ipad|iphone/i)}function r(i){e=document.createElement("textArea"),e.value=i,document.body.appendChild(e)}function n(){let i,a;if(t()){if(i=document.createRange(),i.selectNodeContents(e),a=window.getSelection(),a===null){console.error("no selection");return}a.removeAllRanges(),a.addRange(i),e.setSelectionRange(0,999999)}else e.select()}function o(){document.execCommand("copy"),document.body.removeChild(e)}_=i=>{r(i),n(),o()}}function Ke(e){var t,r;return(r=(t=window.navigator)==null?void 0:t.clipboard)!=null&&r.writeText?window.navigator.clipboard.writeText(e):(_||Je(),_(e))}function Ye(e,t,{type:r="application/octet-stream",raw:n=!1}={}){const o=document.createElement("a");let i=()=>null;try{if(o.download=e,typeof t=="string"&&/^(https?:|data:)/.test(t)&&!n?o.href=t:typeof t=="string"&&(t=new TextEncoder().encode(t)),t instanceof Uint8Array&&(t=new Blob([t],{type:r})),t instanceof File||t instanceof Blob||t instanceof MediaSource)o.href=URL.createObjectURL(t),i=()=>URL.revokeObjectURL(o.href);else throw console.error("invalid download data",t),new Error(`can not download ${Object.getPrototypeOf(t)}`);o.click()}finally{i()}}function te(e,t,r,n){e.onload=()=>t(e),e.onerror=i=>{e.remove(),r(i)};const{attributes:o={}}=n||{};Object.entries(o).forEach(([i,a])=>e.setAttribute(i,a)),document.head.appendChild(e)}function re(e,t){if(Array.isArray(e))return Promise.resolve().then(async()=>{const n=[];for(const o of e)n.push(await re(o));return n});const r=document.querySelector(`script[src="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const i=document.createElement("script");i.src=e,te(i,n,o,t)})}function Qe(e,t){const r=document.querySelector(`link[href="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const i=document.createElement("link");i.rel="stylesheet",i.href=e,te(i,n,o,t)})}function Xe(e){var t;if(!e)return{};const r=e.items??[];if(r.length>=2&&r[0].kind==="string"&&r[1].kind==="file"){const n=e.getData("text"),o=r[1].getAsFile()??((t=e.files)==null?void 0:t.item(0));return o?{file:o,name:n}:(console.error(`no file ${n}`,r[1]),{})}else if(r[0].kind==="file"){const n=r[0].getAsFile();return n?{file:n,name:n.name}:(console.error("no file",r[0]),{})}else console.debug("file item not match",Array.from(r).map(n=>({type:n.type,kind:n.kind})));return{}}const et=()=>{if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global `this`")},tt=globalThis.structuredClone||m;function ne(e,t,r){typeof r.value=="object"&&(r.value=m(r.value)),!r.enumerable||r.get||r.set||!r.configurable||!r.writable||t==="__proto__"?Object.defineProperty(e,t,r):e[t]=r.value}function m(e){if(typeof e!="object")return e;let t=0,r,n,o;const i=B(e);switch(i){case"Array":o=Array(e.length);break;case"Object":o=Object.create(e.__proto__||null);break;case"Set":o=new Set,e.forEach(function(a){o.add(m(a))});break;case"Map":o=new Map,e.forEach(function(a,s){o.set(m(s),m(a))});break;case"Date":o=new Date(+e);break;case"RegExp":o=new RegExp(e.source,e.flags);break;case"DataView":o=new e.constructor(m(e.buffer));break;case"ArrayBuffer":o=e.slice(0);break;default:i.endsWith("Array")&&(o=new e.constructor(e))}if(o){for(n=Object.getOwnPropertySymbols(e);t<n.length;t++)ne(o,n[t],Object.getOwnPropertyDescriptor(e,n[t]));for(t=0,n=Object.getOwnPropertyNames(e);t<n.length;t++)Object.hasOwnProperty.call(o,r=n[t])&&o[r]===e[r]||ne(o,r,Object.getOwnPropertyDescriptor(e,r))}return o||e}var oe,ie;const rt=((ie=(oe=globalThis.crypto)==null?void 0:oe.randomUUID)==null?void 0:ie.bind(globalThis.crypto))||nt;function nt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var ae,se,ce,le;let d;if(typeof window>"u")try{typeof require>"u"?import("node:crypto").then(e=>d=e.default):d=require("node:crypto")}catch{}let D=((se=(ae=globalThis.crypto)==null?void 0:ae.getRandomValues)==null?void 0:se.bind(globalThis.crypto))||((le=(ce=globalThis.msCrypto)==null?void 0:ce.getRandomValues)==null?void 0:le.bind(globalThis.msCrypto))||ot;function ot(e){var t,r,n;if((t=d==null?void 0:d.webcrypto)!=null&&t.getRandomValues)return D=(n=(r=d==null?void 0:d.webcrypto)==null?void 0:r.getRandomValues)==null?void 0:n.bind(d==null?void 0:d.webcrypto),d.webcrypto.getRandomValues(e);if(d!=null&&d.randomBytes){if(!(e instanceof Uint8Array))throw new TypeError("expected Uint8Array");if(e.length>65536){const i=new Error;throw i.code=22,i.message=`Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length (${e.length}) exceeds the number of bytes of entropy available via this API (65536).`,i.name="QuotaExceededError",i}const o=d.randomBytes(e.length);return e.set(o),e}throw new Error("[getRandomValues]: No secure random number generator available.")}function it(e){return C("SHA-1",e)}function at(e){return C("SHA-256",e)}function st(e){return C("SHA-384",e)}function ct(e){return C("SHA-512",e)}function C(e,t){return crypto.subtle.digest(e,lt(t))}function lt(e){return typeof e=="string"?new TextEncoder().encode(e):e}function ft(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}function y(e){const t=new Error(e);return t.source="ulid",t}const p="0123456789ABCDEFGHJKMNPQRSTVWXYZ",h=p.length,L=Math.pow(2,48)-1,b=10,V=16;function ut(e){return(e==null?void 0:e.length)===26&&/^[0-9A-HJKMNP-TV-Z]{26}$/i.test(e)}function fe(e,t,r){return t>e.length-1?e:e.substr(0,t)+r+e.substr(t+1)}function dt(e){let t,r=e.length,n,o;const i=h-1;for(;!t&&r-->=0;){if(n=e[r],o=p.indexOf(n),o===-1)throw y("incorrectly encoded string");if(o===i){e=fe(e,r,p[0]);continue}t=fe(e,r,p[o+1])}if(typeof t=="string")return t;throw y("cannot increment this string")}function yt(e){let t=Math.floor(e()*h);return t===h&&(t=h-1),p.charAt(t)}function N(e,t){if(isNaN(e))throw new Error(`${e} must be a number`);if(e>L)throw y(`cannot encode time greater than ${L}`);if(e<0)throw y("time must be positive");if(!Number.isInteger(e))throw y("time must be an integer");let r,n="";for(;t>0;t--)r=e%h,n=p.charAt(r)+n,e=(e-r)/h;return n}function ue(e,t){let r="";for(;e>0;e--)r=yt(t)+r;return r}function pt(e){if(e.length!==b+V)throw y("malformed ulid");const t=e.substr(0,b).split("").reverse().reduce((r,n,o)=>{const i=p.indexOf(n);if(i===-1)throw y("invalid character found: "+n);return r+=i*Math.pow(h,o)},0);if(t>L)throw y("malformed ulid, timestamp too large");return{timestamp:t,random:e.substring(b)}}function ht(){return()=>{const e=new Uint8Array(1);return D(e),e[0]/255}}function de({monotonic:e=!0,random:t=ht(),now:r=Date.now}={}){if(!e)return function(i){return i||=r(),N(i,b)+ue(V,t)};let n=0,o;return function(i){if(i||=r(),i<=n&&o){const s=o=dt(o);return N(n,b)+s}n=i;const a=o=ue(V,t);return N(i,b)+a}}let ye=(...e)=>O?O(...e):(O=de(),ye=O,O(...e)),O;class gt{static decode(t){const r=t.match(/^-----BEGIN (?<type>[^\r\n-]+)-----$\r?\n(?<headers>(^[^:\r\n]+:[^\n\r]+\r?\n)+\r?\n)?(?<data>[a-zA-Z0-9/_=\n\r+]+?)^-----END \1-----$\r?\n?/ms);if(!(r!=null&&r.groups))throw new Error("Invalid PEM data");const{type:n,headers:o="",data:i}=r.groups,a=o.split(`
1
+ function pe(e,t=null,r=R){return Object.fromEntries(t===null?Object.entries(e).map(([n,o])=>[n,r(o)]):t.map(n=>[n,r(n)]))}function R(e){return Array.isArray(e)?e[0]:e}function he(e){return Array.isArray(e)?e[e.length-1]:e}function ge(e){return Array.isArray(e)?e:e==null?[]:[e]}async function we(e){const t=[];for await(const r of e)t.push(r);return t}function C(e){if(typeof e!="string")return Array.isArray(e)?e:[e];const t=e.split(".");if(!e.includes("["))return t;const r=[];for(const n of t)if(!n.endsWith("]"))r.push(n);else{const o=n.split("[");for(let i of o)i.endsWith("]")&&(i=i.slice(0,-1)),r.push(i)}return r}function U(e,t,r){const n=C(t);let o=e;for(const i of n)o=o?o[i]:void 0;return o===void 0?r:o}function me(e,t,r,n=!0){const o=C(t);let i=0;const a=o.length;let s=e,c,l;for(;i<a&&(l=o[i++],!(l==="__proto__"||l==="constructor"||l==="prototype"));)s=s[l]=i===a?n?T(s[l],r):r:typeof(c=s[l])==typeof o?c:o[i]*0!==0||~(""+o[i]).indexOf(".")?{}:[]}function T(e,t){let r;if(typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t))for(r=0;r<t.length;r++)e[r]=T(e[r],t[r]);else for(r in t){if(r==="__proto__"||r==="constructor"||r==="prototype")break;e[r]=T(e[r],t[r])}return e}return t}function I(e){return e&&(e instanceof Promise||e.then&&e.catch)}function be(e){const t={resolve(n){throw new Error("pending resolve")},reject(n){throw new Error("pending reject")}},r=Object.assign(new Promise((n,o)=>{t.reject=o,t.resolve=n}),{resolve(n){t.resolve(n)},reject(n){t.resolve(n)}});if(e){const n=t.resolve;let o=!0;t.resolve=s=>{o=!1,n(s)};const i=r.then.bind(r);r.then=(...s)=>{if(o){o=!1;try{const c=e(t.resolve,t.reject);I(c)?c.then(t.resolve,t.reject):c!==void 0&&t.resolve(c)}catch(c){t.reject(c)}}return i(...s)};const a=t;return a.then=r.then,a.catch=r.catch.bind(r),r.finally&&(a.finally=r.finally),Object.defineProperty(a,Symbol.species,{get(){return Promise}}),a}return r}function Ae(e,t,r=t){let n;const o=async()=>{await e(),n=setTimeout(o,t)};return n=setTimeout(o,r),()=>n}function ve(e){clearTimeout(e==null?void 0:e())}const Be=e=>new Promise(t=>setTimeout(t,e));function je(e,t){const r=new z;let n;return Promise.race([e,new Promise((o,i)=>{n=setTimeout(()=>i(r),t)})]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}class z extends Error{constructor(){super("TimeoutError")}}function xe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(t,r[n])||!Object.is(e[r[n]],t[r[n]]))return!1;return!0}const F=Object.prototype.hasOwnProperty,Ee=typeof Element<"u";function W(e,t,r){for(r of e.keys())if(A(r,t))return r}function A(e,t){let r,n,o;if(e===t)return!0;if(e&&t&&(r=e.constructor)===t.constructor){if(r===Date)return e.getTime()===t.getTime();if(r===RegExp)return e.toString()===t.toString();if(r===Array){if((n=e.length)===t.length)for(;n--&&A(e[n],t[n]););return n===-1}if(r===Set){if(e.size!==t.size)return!1;for(n of e)if(o=n,o&&typeof o=="object"&&(o=W(t,o),!o)||!t.has(o))return!1;return!0}if(r===Map){if(e.size!==t.size)return!1;for(n of e)if(o=n[0],o&&typeof o=="object"&&(o=W(t,o),!o)||!A(n[1],t.get(o)))return!1;return!0}if(r===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(r===DataView){if((n=e.byteLength)===t.byteLength)for(;n--&&e.getInt8(n)===t.getInt8(n););return n===-1}if(ArrayBuffer.isView(e)){if((n=e.byteLength)===t.byteLength)for(;n--&&e[n]===t[n];);return n===-1}if(Ee&&e instanceof Element)return!1;if(!r||typeof e=="object"){n=0;for(r in e)if(!((r==="_owner"||r==="__v"||r==="__o")&&e.$$typeof)&&(F.call(e,r)&&++n&&!F.call(t,r)||!(r in t)||!A(e[r],t[r])))return!1;return Object.keys(t).length===n}}return e!==e&&t!==t}function v(e){return Object.prototype.toString.call(e).slice(8,-1)}function Oe(e){return e&&(Array.isArray(e)?e.slice():typeof e=="object"?Object.assign({},e):e)}function $e(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}function Ce(e){return e!=null}function Z(e){return v(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function Ue(e){return Z(e)&&Object.keys(e).length===0}function Te(e,t=!1){if(typeof e=="boolean")return e;if(typeof e=="string")switch(e.toLowerCase()){case"f":case"false":case"0":return!1;case"1":case"t":case"true":return!0}else if(typeof e=="number")switch(e){case 0:return!1;case 1:return!0}if(!t)return Boolean(e)}function Se(e,...t){return e instanceof Function?e(...t):e}function ke(e,{resolver:t=(...r)=>JSON.stringify(r)}={}){if(typeof e!="function")throw new Error("`callback` should be a function");if(t!==void 0&&typeof t!="function")throw new Error("`resolver` should be a function");const r={},n=function(){const o=Array.prototype.slice.call(arguments),i=t.apply(this,o);return i in r||(r[i]=e.apply(this,o)),r[i]};return n.cache=r,n}function Pe(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function Me(e){if(e){if(e instanceof Date)return e;if(typeof e=="string"&&/^[0-9.]+$/.test(e)){let t=parseFloat(e);return Math.floor(t).toString().length<=11&&(t*=1e3),new Date(t)}else if(typeof e=="string"){const t=new Date(e);if(!isNaN(+t))return t}throw new Error(`parseTimestamp: invalid "${e}"`)}}const _e=/^(?<n>(?:@(?<org>[a-z0-9-~][a-z0-9-._~]*)\/)?(?<pkg>[a-z0-9-~][a-z0-9-._~]*))(?:@(?<v>[-a-z0-9><=_.^~]+))?(?<p>\/[^\r\n]*)?$/;function De(e){var t;const r=(t=e.match(_e))==null?void 0:t.groups;if(!r)return;const{n,v:o,p:i,org:a,pkg:s}=r,c=Boolean(a),l=/^\d+\.\d+\.\d+/.test(o)?o:void 0,h=o||"latest",b={id:`${n}@${h}`,name:n,range:h,scoped:c,pkg:s,org:a,versioned:Boolean(o)};return l&&(b.version=l),i&&(b.path=i),b.scoped||delete b.org,b}function Le(e){return e&&e[Symbol.toStringTag]==="Module"}function S(e=({level:r,values:n,...o})=>{var i;({values:n,...o}=Ve(o,n)),(i=console[r])==null||i.call(console,...n,o)},t={}){return{trace:(...r)=>e({...t,level:"trace",values:r}),debug:(...r)=>e({...t,level:"debug",values:r}),info:(...r)=>e({...t,level:"info",values:r}),warn:(...r)=>e({...t,level:"warn",values:r}),error:(...r)=>e({...t,level:"error",values:r}),child:r=>S(e,{...t,...r})}}function Ve(e,t){return t[0]&&typeof t[0]=="object"?{...e,...t[0],values:t.slice(1)}:{...e,values:t}}function q(){const e=(...t)=>{};return{trace:e,debug:e,info:e,warn:e,error:e,child:()=>q()}}function Ne(e,t){return e.child?e.child(t):S(r=>{const{level:n,values:o,...i}=r;Object.keys(i).length?e[n](i,...o):e[n](...o)},t)}function Re(e){let t=!1,r=!1,n=!1;for(let o=0;o<e.length;o++){const i=e[o];t&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(e=e.slice(0,o)+"-"+e.slice(o),t=!1,n=r,r=!0,o++):r&&n&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(e=e.slice(0,o-1)+"-"+e.slice(o-1),n=r,r=!1,t=!0):(t=i.toLowerCase()===i&&i.toUpperCase()!==i,n=r,r=i.toUpperCase()===i&&i.toLowerCase()!==i)}return e}function Ie(e){return G(e,{pascalCase:!0})}function G(e,t={pascalCase:!1}){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");const r=n=>t.pascalCase?n.charAt(0).toUpperCase()+n.slice(1):n;return Array.isArray(e)?e=e.map(n=>n.trim()).filter(n=>n.length).join("-"):e=e.trim(),e.length===0?"":e.length===1?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=Re(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(n,o)=>o.toUpperCase()).replace(/\d+(\w|$)/g,n=>n.toUpperCase()),r(e))}function H(e,t,r="js"){let n;return t?typeof t=="function"?n=t:n=o=>U(t,o):n=()=>"",typeof r=="string"&&(r=J[r]||J.js),e.replace(r,(o,i)=>n(i.trim()))}const J={js:/\${(.*?)}/g,common:/{{(.*?)}}/g};function ze(e,t=!1,r=1){const n=t?1e3:1024;if(Math.abs(e)<n)return`${e} B`;const o=t?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let i=-1;const a=10**r;do e/=n,++i;while(Math.round(Math.abs(e)*a)/a>=n&&i<o.length-1);return e.toFixed(r)+" "+o[i]}function Fe(e){let t="";const r=e||{},n=o=>{if(Array.isArray(o))return o;const i=o.split(/[_-]/);return i.length>1?[o,i[0]]:[o]};return{locale(o){return t=o||t},dict:(o,i)=>{if(i){r[o]=Object.assign(r[o]||{},i);return}return r[o]},t(o,i,a){let s;for(const c of n(a||t))if(s=U(r[c],o,""),s)break;return typeof s=="function"?s(i):typeof s=="string"?H(s,i,"common"):s}}}function B(e){var t,r;return(r=(t=e==null?void 0:e.constructor)==null?void 0:t.isBuffer)==null?void 0:r.call(t,e)}function We(e){return K||=Ze(),K.some(t=>e instanceof t)}let K;function Ze(){const e=globalThis.window||globalThis||global;return[e.ArrayBuffer,e.MessagePort,e.ReadableStream,e.WritableStream,e.TransformStream,e.AudioData,e.ImageBitmap,e.VideoFrame,e.OffscreenCanvas,e.RTCDataChannel].filter(Boolean)}const g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",j=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<g.length;e++)j[g.charCodeAt(e)]=e;function qe(e){const t=new Uint8Array(e),r=t.length;let n="";for(let o=0;o<r;o+=3)n+=g[t[o]>>2],n+=g[(t[o]&3)<<4|t[o+1]>>4],n+=g[(t[o+1]&15)<<2|t[o+2]>>6],n+=g[t[o+2]&63];return r%3===2?n=n.substring(0,n.length-1)+"=":r%3===1&&(n=n.substring(0,n.length-2)+"=="),n}function Ge(e){const t=e.length;let r=e.length*.75,n,o=0,i,a,s,c;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);const l=new ArrayBuffer(r),h=new Uint8Array(l);for(n=0;n<t;n+=4)i=j[e.charCodeAt(n)],a=j[e.charCodeAt(n+1)],s=j[e.charCodeAt(n+2)],c=j[e.charCodeAt(n+3)],h[o++]=i<<2|a>>4,h[o++]=(a&15)<<4|s>>2,h[o++]=(s&3)<<6|c&63;return l}var Y=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},k=(e,t,r)=>(Y(e,t,"read from private field"),r?r.call(e):t.get(e)),Q=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},X=(e,t,r,n)=>(Y(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),O,x;const u=class{static isNativeBufferAvailable(){var t,r;return k(this,x)??X(this,x,!((r=(t=globalThis.Buffer)==null?void 0:t.isPollyfill)!=null&&r.call(t)))}static isNativeBufferAllowed(){return k(this,O)&&k(this,x)}static setNativeBufferAllowed(t){X(this,O,t)}};let f=u;O=new WeakMap,x=new WeakMap,Q(f,O,!0),Q(f,x,void 0),f.isArrayBuffer=e=>e instanceof ArrayBuffer,f.slice=(e,t,r)=>B(e)?Uint8Array.prototype.slice.call(e,t,r):e.slice(t,r),f.asView=(e,t,r,n)=>t instanceof e&&(r??0)===0&&n===void 0?t:ArrayBuffer.isView(t)||B(t)?u.isNativeBufferAllowed()&&e===Buffer?Buffer.from(t.buffer,r,n):new e(t.buffer,t.byteOffset+(r??0),n??t.byteLength):new e(t,r,n),f.toString=(e,t="utf8")=>{if(typeof e=="string")switch(t){case"base64":return btoa(e);case"utf-8":case"utf8":return e;default:throw new Error(`[ArrayBuffers.toString] Unsupported encoding for string: ${t}`)}if(u.isNativeBufferAllowed())return Buffer.from(u.asView(Uint8Array,e)).toString(t);switch(t){case"hex":return[...u.asView(Uint8Array,e)].map(r=>He[r]).join("");case"base64":return qe(u.asView(Uint8Array,e));case"utf8":case"utf-8":return new TextDecoder().decode(e);case"ascii":{const r=u.asView(Uint8Array,e);return String.fromCharCode(...r.map(n=>n&127))}case"latin1":case"binary":{const r=u.asView(Uint8Array,e);return String.fromCharCode(...r)}case"ucs2":case"ucs-2":case"utf16le":{const r=u.asView(Uint8Array,e);let n="";for(let o=0;o<r.length-1;o+=2)n+=String.fromCharCode(r[o]+r[o+1]*256);return n}default:throw new Error(`[ArrayBuffers.toString] Unknown encoding: ${t}`)}},f.toJSON=(e,t)=>JSON.parse(u.toString(e),t),f.alloc=(e,t,r)=>t!==void 0?typeof t=="number"?new Uint8Array(e).fill(t):u.asView(Uint8Array,u.from(t,r)).slice(0,e):new ArrayBuffer(e),f.from=(e,t="utf8")=>{if(!e)return new ArrayBuffer(0);if(typeof e=="string"){if(u.isNativeBufferAllowed())return Buffer.from(e,t);switch(t){case"utf-8":case"utf8":return new TextEncoder().encode(e).buffer;case"base64":return Ge(e.replace(/[^0-9a-zA-Z=+/_]/g,""));default:throw new Error(`[ArrayBuffers.from] Unknown encoding: ${t}`)}}if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)||B(e)){if(e.byteOffset!==0)throw new Error("ArrayBuffers.from do not support view with offset");return e.buffer}if(Array.isArray(e))return new Uint8Array(e);const r=v(e);throw new TypeError(`ArrayBuffers.from unsupported type ${r}`)},f.isEncoding=e=>{switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":return!0;default:return!1}},f.concat=(e,t,r=0)=>{const n=e.reduce((i,a)=>i+a.byteLength,0),o=t?new Uint8Array(t):new Uint8Array(n);for(const i of e){if(!(i!=null&&i.byteLength))continue;let a;if(i instanceof ArrayBuffer)a=new Uint8Array(i);else if(ArrayBuffer.isView(i))a=new Uint8Array(i.buffer,i.byteOffset,i.byteLength);else throw new Error(`ArrayBuffers.concat unsupported type ${v(i)}`);o.set(a,r),r+=i.byteLength}return o.buffer};const He=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=r*16;for(let o=0;o<16;++o)t[n+o]=e[r]+e[o]}return t}(),P=class extends Uint8Array{static get isPolyfill(){return!0}static isBuffer(e){return e instanceof P||B(e)}static from(e,t){return new P(f.from(e,t))}toString(e){return f.toString(this,e)}};let ee=P;ee.isEncoding=f.isEncoding;let M;function Je(){let e;function t(){return navigator.userAgent.match(/ipad|iphone/i)}function r(i){e=document.createElement("textArea"),e.value=i,document.body.appendChild(e)}function n(){let i,a;if(t()){if(i=document.createRange(),i.selectNodeContents(e),a=window.getSelection(),a===null){console.error("no selection");return}a.removeAllRanges(),a.addRange(i),e.setSelectionRange(0,999999)}else e.select()}function o(){document.execCommand("copy"),document.body.removeChild(e)}M=i=>{r(i),n(),o()}}function Ke(e){var t,r;return(r=(t=window.navigator)==null?void 0:t.clipboard)!=null&&r.writeText?window.navigator.clipboard.writeText(e):(M||Je(),M(e))}function Ye(e,t,{type:r="application/octet-stream",raw:n=!1}={}){const o=document.createElement("a");let i=()=>null;try{if(o.download=e,typeof t=="string"&&/^(https?:|data:)/.test(t)&&!n?o.href=t:typeof t=="string"&&(t=new TextEncoder().encode(t)),t instanceof Uint8Array&&(t=new Blob([t],{type:r})),t instanceof File||t instanceof Blob||t instanceof MediaSource)o.href=URL.createObjectURL(t),i=()=>URL.revokeObjectURL(o.href);else throw console.error("invalid download data",t),new Error(`can not download ${Object.getPrototypeOf(t)}`);o.click()}finally{i()}}function te(e,t,r,n){e.onload=()=>t(e),e.onerror=i=>{e.remove(),r(i)};const{attributes:o={}}=n||{};Object.entries(o).forEach(([i,a])=>e.setAttribute(i,a)),document.head.appendChild(e)}function re(e,t){if(Array.isArray(e))return Promise.resolve().then(async()=>{const n=[];for(const o of e)n.push(await re(o));return n});const r=document.querySelector(`script[src="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const i=document.createElement("script");i.src=e,te(i,n,o,t)})}function Qe(e,t){const r=document.querySelector(`link[href="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const i=document.createElement("link");i.rel="stylesheet",i.href=e,te(i,n,o,t)})}function Xe(e){var t;if(!e)return{};const r=e.items??[];if(r.length>=2&&r[0].kind==="string"&&r[1].kind==="file"){const n=e.getData("text"),o=r[1].getAsFile()??((t=e.files)==null?void 0:t.item(0));return o?{file:o,name:n}:(console.error(`no file ${n}`,r[1]),{})}else if(r[0].kind==="file"){const n=r[0].getAsFile();return n?{file:n,name:n.name}:(console.error("no file",r[0]),{})}else console.debug("file item not match",Array.from(r).map(n=>({type:n.type,kind:n.kind})));return{}}const et=()=>{if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global `this`")},tt=globalThis.structuredClone||w;function ne(e,t,r){typeof r.value=="object"&&(r.value=w(r.value)),!r.enumerable||r.get||r.set||!r.configurable||!r.writable||t==="__proto__"?Object.defineProperty(e,t,r):e[t]=r.value}function w(e){if(typeof e!="object")return e;let t=0,r,n,o;const i=v(e);switch(i){case"Array":o=Array(e.length);break;case"Object":o=Object.create(e.__proto__||null);break;case"Set":o=new Set,e.forEach(function(a){o.add(w(a))});break;case"Map":o=new Map,e.forEach(function(a,s){o.set(w(s),w(a))});break;case"Date":o=new Date(+e);break;case"RegExp":o=new RegExp(e.source,e.flags);break;case"DataView":o=new e.constructor(w(e.buffer));break;case"ArrayBuffer":o=e.slice(0);break;default:i.endsWith("Array")&&(o=new e.constructor(e))}if(o){for(n=Object.getOwnPropertySymbols(e);t<n.length;t++)ne(o,n[t],Object.getOwnPropertyDescriptor(e,n[t]));for(t=0,n=Object.getOwnPropertyNames(e);t<n.length;t++)Object.hasOwnProperty.call(o,r=n[t])&&o[r]===e[r]||ne(o,r,Object.getOwnPropertyDescriptor(e,r))}return o||e}var oe,ie;const rt=((ie=(oe=globalThis.crypto)==null?void 0:oe.randomUUID)==null?void 0:ie.bind(globalThis.crypto))||nt;function nt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}let _;if(typeof window>"u")try{typeof require>"u"?import("crypto").then(e=>_=e.default):_=require("crypto")}catch{}function ot(){return _}var ae,se,ce,le;let D=((se=(ae=globalThis.crypto)==null?void 0:ae.getRandomValues)==null?void 0:se.bind(globalThis.crypto))||((le=(ce=globalThis.msCrypto)==null?void 0:ce.getRandomValues)==null?void 0:le.bind(globalThis.msCrypto))||it;function it(e){var t,r,n;const o=ot();if((t=o==null?void 0:o.webcrypto)!=null&&t.getRandomValues)return D=(n=(r=o==null?void 0:o.webcrypto)==null?void 0:r.getRandomValues)==null?void 0:n.bind(o==null?void 0:o.webcrypto),o.webcrypto.getRandomValues(e);if(o!=null&&o.randomBytes){if(!(e instanceof Uint8Array))throw new TypeError("expected Uint8Array");if(e.length>65536){const a=new Error;throw a.code=22,a.message=`Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length (${e.length}) exceeds the number of bytes of entropy available via this API (65536).`,a.name="QuotaExceededError",a}const i=o.randomBytes(e.length);return e.set(i),e}throw new Error("[getRandomValues]: No secure random number generator available.")}function at(e){return $("SHA-1",e)}function st(e){return $("SHA-256",e)}function ct(e){return $("SHA-384",e)}function lt(e){return $("SHA-512",e)}function $(e,t){return crypto.subtle.digest(e,ft(t))}function ft(e){return typeof e=="string"?new TextEncoder().encode(e):e}function ut(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}function d(e){const t=new Error(e);return t.source="ulid",t}const y="0123456789ABCDEFGHJKMNPQRSTVWXYZ",p=y.length,L=Math.pow(2,48)-1,m=10,V=16;function dt(e){return(e==null?void 0:e.length)===26&&/^[0-9A-HJKMNP-TV-Z]{26}$/i.test(e)}function fe(e,t,r){return t>e.length-1?e:e.substr(0,t)+r+e.substr(t+1)}function yt(e){let t,r=e.length,n,o;const i=p-1;for(;!t&&r-->=0;){if(n=e[r],o=y.indexOf(n),o===-1)throw d("incorrectly encoded string");if(o===i){e=fe(e,r,y[0]);continue}t=fe(e,r,y[o+1])}if(typeof t=="string")return t;throw d("cannot increment this string")}function pt(e){let t=Math.floor(e()*p);return t===p&&(t=p-1),y.charAt(t)}function N(e,t){if(isNaN(e))throw new Error(`${e} must be a number`);if(e>L)throw d(`cannot encode time greater than ${L}`);if(e<0)throw d("time must be positive");if(!Number.isInteger(e))throw d("time must be an integer");let r,n="";for(;t>0;t--)r=e%p,n=y.charAt(r)+n,e=(e-r)/p;return n}function ue(e,t){let r="";for(;e>0;e--)r=pt(t)+r;return r}function ht(e){if(e.length!==m+V)throw d("malformed ulid");const t=e.substr(0,m).split("").reverse().reduce((r,n,o)=>{const i=y.indexOf(n);if(i===-1)throw d("invalid character found: "+n);return r+=i*Math.pow(p,o)},0);if(t>L)throw d("malformed ulid, timestamp too large");return{timestamp:t,random:e.substring(m)}}function gt(){return()=>{const e=new Uint8Array(1);return D(e),e[0]/255}}function de({monotonic:e=!0,random:t=gt(),now:r=Date.now}={}){if(!e)return function(i){return i||=r(),N(i,m)+ue(V,t)};let n=0,o;return function(i){if(i||=r(),i<=n&&o){const s=o=yt(o);return N(n,m)+s}n=i;const a=o=ue(V,t);return N(i,m)+a}}let ye=(...e)=>E?E(...e):(E=de(),ye=E,E(...e)),E;class wt{static decode(t){const r=t.match(/^-----BEGIN (?<type>[^\r\n-]+)-----$\r?\n(?<headers>(^[^:\r\n]+:[^\n\r]+\r?\n)+\r?\n)?(?<data>[a-zA-Z0-9/_=\n\r+]+?)^-----END \1-----$\r?\n?/ms);if(!(r!=null&&r.groups))throw new Error("Invalid PEM data");const{type:n,headers:o="",data:i}=r.groups,a=o.split(`
2
2
  `).filter(s=>s.trim()).map(s=>{const[c,...l]=s.split(":");return[c.trim(),l.join(":").trim()]}).reduce((s,[c,l])=>({...s,[c]:l}),{});return{block:{type:n,header:a,bytes:f.from(i.replace(/[\r\n]/g,""),"base64")},head:t.slice(0,r.index||0),tail:t.slice((r.index||0)+r[0].length)}}static encode(t){var r;const{type:n,header:o,bytes:i}=t,a=Object.entries(o||{}).map(([s,c])=>`${s}: ${c}`).join(`
3
3
  `);return`-----BEGIN ${n}-----
4
4
  ${a}${a.length?`
@@ -6,5 +6,5 @@ ${a}${a.length?`
6
6
  `:""}${((r=f.toString(i,"base64").match(/.{1,64}/g))==null?void 0:r.join(`
7
7
  `))||""}
8
8
  -----END ${n}-----
9
- `}}function wt(e={}){let t=typeof e.seed=="string"?0:e.seed??0;if(typeof e.seed=="string"){let r=0;for(let n=0;n<e.seed.length;n++)r+=e.seed.charCodeAt(n);t=r}return()=>{const r=Math.sin(t++)*1e4;return r-Math.floor(r)}}export{f as ArrayBuffers,ee as Buffer,gt as PEM,z as TimeoutError,we as arrayFromAsync,ge as arrayOfMaybeArray,G as camelCase,B as classOf,ve as clearAsyncInterval,Ke as copy,Ne as createChildLogger,be as createLazyPromise,k as createLogger,q as createNoopLogger,wt as createRandom,Fe as createTranslate,de as createULID,v as deepEqual,Ye as download,R as firstOfMaybeArray,ze as formatBytes,T as get,Xe as getFileFromDataTransfer,et as getGlobalThis,D as getRandomValues,ft as hex,j as isBuffer,$e as isClass,Ce as isDefined,Ue as isEmptyObject,Le as isModule,Z as isPlainObject,I as isPromise,We as isTransferable,ut as isULID,Pe as isUUID,he as lastOfMaybeArray,re as loadScripts,Qe as loadStyles,Se as maybeFunction,ke as memoize,pe as objectOfMaybeArray,Te as parseBoolean,De as parseModuleId,U as parseObjectPath,Me as parseTimestamp,pt as parseULID,Ie as pascalCase,rt as randomUUID,H as renderTemplate,me as set,Ae as setAsyncInterval,it as sha1,at as sha256,st as sha384,ct as sha512,Oe as shallowClone,xe as shallowEqual,Be as sleep,tt as structuredClone,je as timeout,ye as ulid};
9
+ `}}function mt(e={}){let t=typeof e.seed=="string"?0:e.seed??0;if(typeof e.seed=="string"){let r=0;for(let n=0;n<e.seed.length;n++)r+=e.seed.charCodeAt(n);t=r}return()=>{const r=Math.sin(t++)*1e4;return r-Math.floor(r)}}export{f as ArrayBuffers,ee as Buffer,wt as PEM,z as TimeoutError,we as arrayFromAsync,ge as arrayOfMaybeArray,G as camelCase,v as classOf,ve as clearAsyncInterval,Ke as copy,Ne as createChildLogger,be as createLazyPromise,S as createLogger,q as createNoopLogger,mt as createRandom,Fe as createTranslate,de as createULID,A as deepEqual,Ye as download,R as firstOfMaybeArray,ze as formatBytes,U as get,Xe as getFileFromDataTransfer,et as getGlobalThis,D as getRandomValues,ut as hex,B as isBuffer,$e as isClass,Ce as isDefined,Ue as isEmptyObject,Le as isModule,Z as isPlainObject,I as isPromise,We as isTransferable,dt as isULID,Pe as isUUID,he as lastOfMaybeArray,re as loadScripts,Qe as loadStyles,Se as maybeFunction,ke as memoize,pe as objectOfMaybeArray,Te as parseBoolean,De as parseModuleId,C as parseObjectPath,Me as parseTimestamp,ht as parseULID,Ie as pascalCase,rt as randomUUID,H as renderTemplate,me as set,Ae as setAsyncInterval,at as sha1,st as sha256,ct as sha384,lt as sha512,Oe as shallowClone,xe as shallowEqual,Be as sleep,tt as structuredClone,je as timeout,ye as ulid};
10
10
  //# sourceMappingURL=index.js.map