@agentlang/lstudio 0.2.3 → 0.2.5

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.
@@ -1 +1 @@
1
- import{N as h,c as T,S as y,b as p,U as N,d as _,L as w,e as b,f as R,v as E,R as z,P as J,h as M,T as j}from"./index-Bdy7oQ1C.js";import{t as D,a as I,p as k,b as A,c as O,d as S,e as B}from"./normalizeProvider-EC8cbfMc.js";function U(f,t,e){if(e?.source){const i=e.source;if(typeof t=="number"&&(t>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER||i!==String(t)))return i.includes(".")?new h(i,"bigDecimal"):BigInt(i)}return t}const $=(f,t)=>T(f,t).then(e=>(t?.utf8Encoder??D)(e)),Q=(f,t)=>$(f,t).then(e=>{if(e.length)try{return JSON.parse(e)}catch(i){throw i?.name==="SyntaxError"&&Object.defineProperty(i,"$responseBodyText",{value:e}),i}return{}}),V=(f,t)=>{const e=(n,r)=>Object.keys(n).find(o=>o.toLowerCase()===r.toLowerCase()),i=n=>{let r=n;return typeof r=="number"&&(r=r.toString()),r.indexOf(",")>=0&&(r=r.split(",")[0]),r.indexOf(":")>=0&&(r=r.split(":")[0]),r.indexOf("#")>=0&&(r=r.split("#")[1]),r},s=e(f.headers,"x-amzn-errortype");if(s!==void 0)return i(f.headers[s]);if(t&&typeof t=="object"){const n=e(t,"code");if(n&&t[n]!==void 0)return i(t[n]);if(t.__type!==void 0)return i(t.__type)}};class L extends y{settings;constructor(t){super(),this.settings=t}async read(t,e){return this._read(t,typeof e=="string"?JSON.parse(e,U):await Q(e,this.serdeContext))}readObject(t,e){return this._read(t,e)}_read(t,e){const i=e!==null&&typeof e=="object",s=p.of(t);if(i){if(s.isStructSchema()){const r=s.isUnionSchema(),o={};let c;r&&(c=new N(e,o));for(const[a,m]of _(s,e,this.settings.jsonName?"jsonName":!1)){const u=this.settings.jsonName?m.getMergedTraits().jsonName??a:a;r&&c.mark(u),e[u]!=null&&(o[a]=this._read(m,e[u]))}return r&&c.writeUnknown(),o}if(Array.isArray(e)&&s.isListSchema()){const r=s.getValueSchema(),o=[],c=!!s.getMergedTraits().sparse;for(const a of e)(c||a!=null)&&o.push(this._read(r,a));return o}if(s.isMapSchema()){const r=s.getValueSchema(),o={},c=!!s.getMergedTraits().sparse;for(const[a,m]of Object.entries(e))(c||m!=null)&&(o[a]=this._read(r,m));return o}}if(s.isBlobSchema()&&typeof e=="string")return I(e);const n=s.getMergedTraits().mediaType;if(s.isStringSchema()&&typeof e=="string"&&n)return n==="application/json"||n.endsWith("+json")?w.from(e):e;if(s.isTimestampSchema()&&e!=null)switch(b(s,this.settings)){case 5:return O(e);case 6:return A(e);case 7:return k(e);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",e),new Date(e)}if(s.isBigIntegerSchema()&&(typeof e=="number"||typeof e=="string"))return BigInt(e);if(s.isBigDecimalSchema()&&e!=null){if(e instanceof h)return e;const r=e;return r.type==="bigDecimal"&&"string"in r?new h(r.string,r.type):new h(String(e),"bigDecimal")}if(s.isNumericSchema()&&typeof e=="string"){switch(e){case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return e}if(s.isDocumentSchema())if(i){const r=Array.isArray(e)?[]:{};for(const[o,c]of Object.entries(e))c instanceof h?r[o]=c:r[o]=this._read(s,c);return r}else return structuredClone(e);return e}}const l="Ν";class P{values=new Map;counter=0;stage=0;createReplacer(){if(this.stage===1)throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");if(this.stage===2)throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");return this.stage=1,(t,e)=>{if(e instanceof h){const i=`${l+"nv"+this.counter++}_`+e.string;return this.values.set(`"${i}"`,e.string),i}if(typeof e=="bigint"){const i=e.toString(),s=`${l+"b"+this.counter++}_`+i;return this.values.set(`"${s}"`,i),s}return e}}replaceInJson(t){if(this.stage===0)throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");if(this.stage===2)throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");if(this.stage=2,this.counter===0)return t;for(const[e,i]of this.values)t=t.replace(e,i);return t}}class F extends y{settings;buffer;useReplacer=!1;rootSchema;constructor(t){super(),this.settings=t}write(t,e){this.rootSchema=p.of(t),this.buffer=this._write(this.rootSchema,e)}writeDiscriminatedDocument(t,e){this.write(t,e),typeof this.buffer=="object"&&(this.buffer.__type=p.of(t).getName(!0))}flush(){const{rootSchema:t,useReplacer:e}=this;if(this.rootSchema=void 0,this.useReplacer=!1,t?.isStructSchema()||t?.isDocumentSchema()){if(!e)return JSON.stringify(this.buffer);const i=new P;return i.replaceInJson(JSON.stringify(this.buffer,i.createReplacer(),0))}return this.buffer}_write(t,e,i){const s=e!==null&&typeof e=="object",n=p.of(t);if(s){if(n.isStructSchema()){const r={};for(const[o,c]of R(n,e)){const a=this._write(c,e[o],n);if(a!==void 0){const m=c.getMergedTraits().jsonName,u=this.settings.jsonName?m??o:o;r[u]=a}}if(n.isUnionSchema()&&Object.keys(r).length===0){const{$unknown:o}=e;if(Array.isArray(o)){const[c,a]=o;r[c]=this._write(15,a)}}return r}if(Array.isArray(e)&&n.isListSchema()){const r=n.getValueSchema(),o=[],c=!!n.getMergedTraits().sparse;for(const a of e)(c||a!=null)&&o.push(this._write(r,a));return o}if(n.isMapSchema()){const r=n.getValueSchema(),o={},c=!!n.getMergedTraits().sparse;for(const[a,m]of Object.entries(e))(c||m!=null)&&(o[a]=this._write(r,m));return o}if(e instanceof Uint8Array&&(n.isBlobSchema()||n.isDocumentSchema()))return n===this.rootSchema?e:(this.serdeContext?.base64Encoder??S)(e);if(e instanceof Date&&(n.isTimestampSchema()||n.isDocumentSchema()))switch(b(n,this.settings)){case 5:return e.toISOString().replace(".000Z","Z");case 6:return B(e);case 7:return e.getTime()/1e3;default:return console.warn("Missing timestamp format, using epoch seconds",e),e.getTime()/1e3}e instanceof h&&(this.useReplacer=!0)}if(!(e===null&&i?.isStructSchema())){if(n.isStringSchema()){if(typeof e>"u"&&n.isIdempotencyToken())return E();const r=n.getMergedTraits().mediaType;return e!=null&&r&&(r==="application/json"||r.endsWith("+json"))?w.from(e):e}if(typeof e=="number"&&n.isNumericSchema())return Math.abs(e)===1/0||isNaN(e)?String(e):e;if(typeof e=="string"&&n.isBlobSchema())return n===this.rootSchema?e:(this.serdeContext?.base64Encoder??S)(e);if(typeof e=="bigint"&&(this.useReplacer=!0),n.isDocumentSchema())if(s){const r=Array.isArray(e)?[]:{};for(const[o,c]of Object.entries(e))c instanceof h?(this.useReplacer=!0,r[o]=c):r[o]=this._write(n,c);return r}else return structuredClone(e);return e}}}class q extends y{settings;constructor(t){super(),this.settings=t}createSerializer(){const t=new F(this.settings);return t.setSerdeContext(this.serdeContext),t}createDeserializer(){const t=new L(this.settings);return t.setSerdeContext(this.serdeContext),t}}class K extends z{serializer;deserializer;serviceTarget;codec;mixin;awsQueryCompatible;constructor({defaultNamespace:t,serviceTarget:e,awsQueryCompatible:i,jsonCodec:s}){super({defaultNamespace:t}),this.serviceTarget=e,this.codec=s??new q({timestampFormat:{useTrait:!0,default:7},jsonName:!1}),this.serializer=this.codec.createSerializer(),this.deserializer=this.codec.createDeserializer(),this.awsQueryCompatible=!!i,this.mixin=new J(this.awsQueryCompatible)}async serializeRequest(t,e,i){const s=await super.serializeRequest(t,e,i);return s.path.endsWith("/")||(s.path+="/"),Object.assign(s.headers,{"content-type":`application/x-amz-json-${this.getJsonRpcVersion()}`,"x-amz-target":`${this.serviceTarget}.${t.name}`}),this.awsQueryCompatible&&(s.headers["x-amzn-query-mode"]="true"),(M(t.input)==="unit"||!s.body)&&(s.body="{}"),s}getPayloadCodec(){return this.codec}async handleError(t,e,i,s,n){this.awsQueryCompatible&&this.mixin.setQueryCompatError(s,i);const r=V(i,s)??"Unknown",{errorSchema:o,errorMetadata:c}=await this.mixin.getErrorSchemaOrThrowBaseException(r,this.options.defaultNamespace,i,s,n,this.awsQueryCompatible?this.mixin.findQueryCompatibleError:void 0),a=p.of(o),m=s.message??s.Message??"Unknown",u=j.for(o[1]).getErrorCtor(o)??Error,x=new u(m),d={};for(const[g,C]of a.structIterator())s[g]!=null&&(d[g]=this.codec.createDeserializer().readObject(C,s[g]));throw this.awsQueryCompatible&&this.mixin.queryCompatOutput(s,d),this.mixin.decorateServiceException(Object.assign(x,c,{$fault:a.getMergedTraits().error,message:m},d),s)}}class Z extends K{constructor({defaultNamespace:t,serviceTarget:e,awsQueryCompatible:i,jsonCodec:s}){super({defaultNamespace:t,serviceTarget:e,awsQueryCompatible:i,jsonCodec:s})}getShapeId(){return"aws.protocols#awsJson1_1"}getJsonRpcVersion(){return"1.1"}getDefaultContentType(){return"application/x-amz-json-1.1"}}export{Z as A};
1
+ import{N as h,c as T,S as y,b as p,U as N,d as _,L as w,e as b,f as R,v as E,R as z,P as J,h as M,T as j}from"./index-Lo_XIkxp.js";import{t as D,a as I,p as k,b as A,c as O,d as S,e as B}from"./normalizeProvider-EC8cbfMc.js";function U(f,t,e){if(e?.source){const i=e.source;if(typeof t=="number"&&(t>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER||i!==String(t)))return i.includes(".")?new h(i,"bigDecimal"):BigInt(i)}return t}const $=(f,t)=>T(f,t).then(e=>(t?.utf8Encoder??D)(e)),Q=(f,t)=>$(f,t).then(e=>{if(e.length)try{return JSON.parse(e)}catch(i){throw i?.name==="SyntaxError"&&Object.defineProperty(i,"$responseBodyText",{value:e}),i}return{}}),V=(f,t)=>{const e=(n,r)=>Object.keys(n).find(o=>o.toLowerCase()===r.toLowerCase()),i=n=>{let r=n;return typeof r=="number"&&(r=r.toString()),r.indexOf(",")>=0&&(r=r.split(",")[0]),r.indexOf(":")>=0&&(r=r.split(":")[0]),r.indexOf("#")>=0&&(r=r.split("#")[1]),r},s=e(f.headers,"x-amzn-errortype");if(s!==void 0)return i(f.headers[s]);if(t&&typeof t=="object"){const n=e(t,"code");if(n&&t[n]!==void 0)return i(t[n]);if(t.__type!==void 0)return i(t.__type)}};class L extends y{settings;constructor(t){super(),this.settings=t}async read(t,e){return this._read(t,typeof e=="string"?JSON.parse(e,U):await Q(e,this.serdeContext))}readObject(t,e){return this._read(t,e)}_read(t,e){const i=e!==null&&typeof e=="object",s=p.of(t);if(i){if(s.isStructSchema()){const r=s.isUnionSchema(),o={};let c;r&&(c=new N(e,o));for(const[a,m]of _(s,e,this.settings.jsonName?"jsonName":!1)){const u=this.settings.jsonName?m.getMergedTraits().jsonName??a:a;r&&c.mark(u),e[u]!=null&&(o[a]=this._read(m,e[u]))}return r&&c.writeUnknown(),o}if(Array.isArray(e)&&s.isListSchema()){const r=s.getValueSchema(),o=[],c=!!s.getMergedTraits().sparse;for(const a of e)(c||a!=null)&&o.push(this._read(r,a));return o}if(s.isMapSchema()){const r=s.getValueSchema(),o={},c=!!s.getMergedTraits().sparse;for(const[a,m]of Object.entries(e))(c||m!=null)&&(o[a]=this._read(r,m));return o}}if(s.isBlobSchema()&&typeof e=="string")return I(e);const n=s.getMergedTraits().mediaType;if(s.isStringSchema()&&typeof e=="string"&&n)return n==="application/json"||n.endsWith("+json")?w.from(e):e;if(s.isTimestampSchema()&&e!=null)switch(b(s,this.settings)){case 5:return O(e);case 6:return A(e);case 7:return k(e);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",e),new Date(e)}if(s.isBigIntegerSchema()&&(typeof e=="number"||typeof e=="string"))return BigInt(e);if(s.isBigDecimalSchema()&&e!=null){if(e instanceof h)return e;const r=e;return r.type==="bigDecimal"&&"string"in r?new h(r.string,r.type):new h(String(e),"bigDecimal")}if(s.isNumericSchema()&&typeof e=="string"){switch(e){case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return e}if(s.isDocumentSchema())if(i){const r=Array.isArray(e)?[]:{};for(const[o,c]of Object.entries(e))c instanceof h?r[o]=c:r[o]=this._read(s,c);return r}else return structuredClone(e);return e}}const l="Ν";class P{values=new Map;counter=0;stage=0;createReplacer(){if(this.stage===1)throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");if(this.stage===2)throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");return this.stage=1,(t,e)=>{if(e instanceof h){const i=`${l+"nv"+this.counter++}_`+e.string;return this.values.set(`"${i}"`,e.string),i}if(typeof e=="bigint"){const i=e.toString(),s=`${l+"b"+this.counter++}_`+i;return this.values.set(`"${s}"`,i),s}return e}}replaceInJson(t){if(this.stage===0)throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");if(this.stage===2)throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");if(this.stage=2,this.counter===0)return t;for(const[e,i]of this.values)t=t.replace(e,i);return t}}class F extends y{settings;buffer;useReplacer=!1;rootSchema;constructor(t){super(),this.settings=t}write(t,e){this.rootSchema=p.of(t),this.buffer=this._write(this.rootSchema,e)}writeDiscriminatedDocument(t,e){this.write(t,e),typeof this.buffer=="object"&&(this.buffer.__type=p.of(t).getName(!0))}flush(){const{rootSchema:t,useReplacer:e}=this;if(this.rootSchema=void 0,this.useReplacer=!1,t?.isStructSchema()||t?.isDocumentSchema()){if(!e)return JSON.stringify(this.buffer);const i=new P;return i.replaceInJson(JSON.stringify(this.buffer,i.createReplacer(),0))}return this.buffer}_write(t,e,i){const s=e!==null&&typeof e=="object",n=p.of(t);if(s){if(n.isStructSchema()){const r={};for(const[o,c]of R(n,e)){const a=this._write(c,e[o],n);if(a!==void 0){const m=c.getMergedTraits().jsonName,u=this.settings.jsonName?m??o:o;r[u]=a}}if(n.isUnionSchema()&&Object.keys(r).length===0){const{$unknown:o}=e;if(Array.isArray(o)){const[c,a]=o;r[c]=this._write(15,a)}}return r}if(Array.isArray(e)&&n.isListSchema()){const r=n.getValueSchema(),o=[],c=!!n.getMergedTraits().sparse;for(const a of e)(c||a!=null)&&o.push(this._write(r,a));return o}if(n.isMapSchema()){const r=n.getValueSchema(),o={},c=!!n.getMergedTraits().sparse;for(const[a,m]of Object.entries(e))(c||m!=null)&&(o[a]=this._write(r,m));return o}if(e instanceof Uint8Array&&(n.isBlobSchema()||n.isDocumentSchema()))return n===this.rootSchema?e:(this.serdeContext?.base64Encoder??S)(e);if(e instanceof Date&&(n.isTimestampSchema()||n.isDocumentSchema()))switch(b(n,this.settings)){case 5:return e.toISOString().replace(".000Z","Z");case 6:return B(e);case 7:return e.getTime()/1e3;default:return console.warn("Missing timestamp format, using epoch seconds",e),e.getTime()/1e3}e instanceof h&&(this.useReplacer=!0)}if(!(e===null&&i?.isStructSchema())){if(n.isStringSchema()){if(typeof e>"u"&&n.isIdempotencyToken())return E();const r=n.getMergedTraits().mediaType;return e!=null&&r&&(r==="application/json"||r.endsWith("+json"))?w.from(e):e}if(typeof e=="number"&&n.isNumericSchema())return Math.abs(e)===1/0||isNaN(e)?String(e):e;if(typeof e=="string"&&n.isBlobSchema())return n===this.rootSchema?e:(this.serdeContext?.base64Encoder??S)(e);if(typeof e=="bigint"&&(this.useReplacer=!0),n.isDocumentSchema())if(s){const r=Array.isArray(e)?[]:{};for(const[o,c]of Object.entries(e))c instanceof h?(this.useReplacer=!0,r[o]=c):r[o]=this._write(n,c);return r}else return structuredClone(e);return e}}}class q extends y{settings;constructor(t){super(),this.settings=t}createSerializer(){const t=new F(this.settings);return t.setSerdeContext(this.serdeContext),t}createDeserializer(){const t=new L(this.settings);return t.setSerdeContext(this.serdeContext),t}}class K extends z{serializer;deserializer;serviceTarget;codec;mixin;awsQueryCompatible;constructor({defaultNamespace:t,serviceTarget:e,awsQueryCompatible:i,jsonCodec:s}){super({defaultNamespace:t}),this.serviceTarget=e,this.codec=s??new q({timestampFormat:{useTrait:!0,default:7},jsonName:!1}),this.serializer=this.codec.createSerializer(),this.deserializer=this.codec.createDeserializer(),this.awsQueryCompatible=!!i,this.mixin=new J(this.awsQueryCompatible)}async serializeRequest(t,e,i){const s=await super.serializeRequest(t,e,i);return s.path.endsWith("/")||(s.path+="/"),Object.assign(s.headers,{"content-type":`application/x-amz-json-${this.getJsonRpcVersion()}`,"x-amz-target":`${this.serviceTarget}.${t.name}`}),this.awsQueryCompatible&&(s.headers["x-amzn-query-mode"]="true"),(M(t.input)==="unit"||!s.body)&&(s.body="{}"),s}getPayloadCodec(){return this.codec}async handleError(t,e,i,s,n){this.awsQueryCompatible&&this.mixin.setQueryCompatError(s,i);const r=V(i,s)??"Unknown",{errorSchema:o,errorMetadata:c}=await this.mixin.getErrorSchemaOrThrowBaseException(r,this.options.defaultNamespace,i,s,n,this.awsQueryCompatible?this.mixin.findQueryCompatibleError:void 0),a=p.of(o),m=s.message??s.Message??"Unknown",u=j.for(o[1]).getErrorCtor(o)??Error,x=new u(m),d={};for(const[g,C]of a.structIterator())s[g]!=null&&(d[g]=this.codec.createDeserializer().readObject(C,s[g]));throw this.awsQueryCompatible&&this.mixin.queryCompatOutput(s,d),this.mixin.decorateServiceException(Object.assign(x,c,{$fault:a.getMergedTraits().error,message:m},d),s)}}class Z extends K{constructor({defaultNamespace:t,serviceTarget:e,awsQueryCompatible:i,jsonCodec:s}){super({defaultNamespace:t,serviceTarget:e,awsQueryCompatible:i,jsonCodec:s})}getShapeId(){return"aws.protocols#awsJson1_1"}getJsonRpcVersion(){return"1.1"}getDefaultContentType(){return"application/x-amz-json-1.1"}}export{Z as A};
@@ -1 +1 @@
1
- import{T as z}from"./index-KfLUFT2R.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-ChvoNxcO.js";import"./preload-helper-BlTxHScW.js";import"./__vite-browser-external-DLjrMatA.js";import"./inherits_browser-nmOknR35-Bp0mvRSL.js";import"./index-6mKfgpcs-DsgiI2lM.js";import"./_commonjsHelpers-B4e78b8K-W3E8ocG7.js";import"./index-DsIu-45t-Bejjlpz4.js";import"./index-DSosZ5sh-Ceejs_jv.js";import"./index-69shuAsh-DF18H7zf.js";import"./index-BJBOx-Z---hbiLl7B.js";import"./index.browser-BHPvGrwi-6Mh8eUw-.js";import"./_commonjs-dynamic-modules-BpilXLfW-DfYEAvWy.js";import"./_commonjs-dynamic-modules-B7n8ZNar.js";var S=Object.defineProperty,A=(r,e,n)=>e in r?S(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,g=(r,e,n)=>A(r,typeof e!="symbol"?e+"":e,n);function j(r,e){for(var n=0;n<e.length;n++){const o=e[n];if(typeof o!="string"&&!Array.isArray(o)){for(const t in o)if(t!=="default"&&!(t in r)){const i=Object.getOwnPropertyDescriptor(o,t);i&&Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}function v(r){return{isFile:()=>r.isFile(),isDirectory:()=>r.isDirectory(),isSymbolicLink:()=>r.isSymbolicLink(),size:r.size,mtime:r.mtime}}class x{async readFile(e){return(void 0)(e,"utf8")}async readFileBuffer(e){return(void 0)(e)}async writeFile(e,n){const o=(void 0)(e);return await this.ensureDir(o),(void 0)(e,n)}async exists(e){try{return await(void 0)(e),!0}catch{return!1}}async mkdir(e){try{await(void 0)(e)}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code!=="EEXIST")throw n}}async readdir(e){return(void 0)(e)}async stat(e){const n=await(void 0)(e);return v(n)}async lstat(e){const n=await(void 0)(e);return v(n)}async unlink(e){return(void 0)(e)}async rmdir(e){return(void 0)(e)}async copyFile(e,n){const o=(void 0)(n);return await this.ensureDir(o),(void 0)(e,n)}async moveFile(e,n){const o=(void 0)(n);return await this.ensureDir(o),(void 0)(e,n)}async ensureDir(e){try{await(void 0)(e,{recursive:!0})}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code!=="EEXIST")throw n}}async removeDir(e){return(void 0)(e,{recursive:!0,force:!0})}async readDirectory(e){return(void 0)(e)}async writeFileSystemFromTree(e,n,o){for(const t of e){const i=(void 0)(n,t.path);if(t.type==="directory")await this.ensureDir(i),t.children&&await this.writeFileSystemFromTree(t.children,n,o);else{const s=await o(t.path);await this.writeFile(i,s)}}}}function $(){return new x}function T(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var F,D;function E(){if(D)return F;D=1;function r(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}function e(t,i){for(var s="",c=0,u=-1,a=0,f,l=0;l<=t.length;++l){if(l<t.length)f=t.charCodeAt(l);else{if(f===47)break;f=47}if(f===47){if(!(u===l-1||a===1))if(u!==l-1&&a===2){if(s.length<2||c!==2||s.charCodeAt(s.length-1)!==46||s.charCodeAt(s.length-2)!==46){if(s.length>2){var d=s.lastIndexOf("/");if(d!==s.length-1){d===-1?(s="",c=0):(s=s.slice(0,d),c=s.length-1-s.lastIndexOf("/")),u=l,a=0;continue}}else if(s.length===2||s.length===1){s="",c=0,u=l,a=0;continue}}i&&(s.length>0?s+="/..":s="..",c=2)}else s.length>0?s+="/"+t.slice(u+1,l):s=t.slice(u+1,l),c=l-u-1;u=l,a=0}else f===46&&a!==-1?++a:a=-1}return s}function n(t,i){var s=i.dir||i.root,c=i.base||(i.name||"")+(i.ext||"");return s?s===i.root?s+c:s+t+c:c}var o={resolve:function(){for(var t="",i=!1,s,c=arguments.length-1;c>=-1&&!i;c--){var u;c>=0?u=arguments[c]:(s===void 0&&(s=process.cwd()),u=s),r(u),u.length!==0&&(t=u+"/"+t,i=u.charCodeAt(0)===47)}return t=e(t,!i),i?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(r(t),t.length===0)return".";var i=t.charCodeAt(0)===47,s=t.charCodeAt(t.length-1)===47;return t=e(t,!i),t.length===0&&!i&&(t="."),t.length>0&&s&&(t+="/"),i?"/"+t:t},isAbsolute:function(t){return r(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,i=0;i<arguments.length;++i){var s=arguments[i];r(s),s.length>0&&(t===void 0?t=s:t+="/"+s)}return t===void 0?".":o.normalize(t)},relative:function(t,i){if(r(t),r(i),t===i||(t=o.resolve(t),i=o.resolve(i),t===i))return"";for(var s=1;s<t.length&&t.charCodeAt(s)===47;++s);for(var c=t.length,u=c-s,a=1;a<i.length&&i.charCodeAt(a)===47;++a);for(var f=i.length,l=f-a,d=u<l?u:l,y=-1,h=0;h<=d;++h){if(h===d){if(l>d){if(i.charCodeAt(a+h)===47)return i.slice(a+h+1);if(h===0)return i.slice(a+h)}else u>d&&(t.charCodeAt(s+h)===47?y=h:h===0&&(y=0));break}var b=t.charCodeAt(s+h),I=i.charCodeAt(a+h);if(b!==I)break;b===47&&(y=h)}var p="";for(h=s+y+1;h<=c;++h)(h===c||t.charCodeAt(h)===47)&&(p.length===0?p+="..":p+="/..");return p.length>0?p+i.slice(a+y):(a+=y,i.charCodeAt(a)===47&&++a,i.slice(a))},_makeLong:function(t){return t},dirname:function(t){if(r(t),t.length===0)return".";for(var i=t.charCodeAt(0),s=i===47,c=-1,u=!0,a=t.length-1;a>=1;--a)if(i=t.charCodeAt(a),i===47){if(!u){c=a;break}}else u=!1;return c===-1?s?"/":".":s&&c===1?"//":t.slice(0,c)},basename:function(t,i){if(i!==void 0&&typeof i!="string")throw new TypeError('"ext" argument must be a string');r(t);var s=0,c=-1,u=!0,a;if(i!==void 0&&i.length>0&&i.length<=t.length){if(i.length===t.length&&i===t)return"";var f=i.length-1,l=-1;for(a=t.length-1;a>=0;--a){var d=t.charCodeAt(a);if(d===47){if(!u){s=a+1;break}}else l===-1&&(u=!1,l=a+1),f>=0&&(d===i.charCodeAt(f)?--f===-1&&(c=a):(f=-1,c=l))}return s===c?c=l:c===-1&&(c=t.length),t.slice(s,c)}else{for(a=t.length-1;a>=0;--a)if(t.charCodeAt(a)===47){if(!u){s=a+1;break}}else c===-1&&(u=!1,c=a+1);return c===-1?"":t.slice(s,c)}},extname:function(t){r(t);for(var i=-1,s=0,c=-1,u=!0,a=0,f=t.length-1;f>=0;--f){var l=t.charCodeAt(f);if(l===47){if(!u){s=f+1;break}continue}c===-1&&(u=!1,c=f+1),l===46?i===-1?i=f:a!==1&&(a=1):i!==-1&&(a=-1)}return i===-1||c===-1||a===0||a===1&&i===c-1&&i===s+1?"":t.slice(i,c)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return n("/",t)},parse:function(t){r(t);var i={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return i;var s=t.charCodeAt(0),c=s===47,u;c?(i.root="/",u=1):u=0;for(var a=-1,f=0,l=-1,d=!0,y=t.length-1,h=0;y>=u;--y){if(s=t.charCodeAt(y),s===47){if(!d){f=y+1;break}continue}l===-1&&(d=!1,l=y+1),s===46?a===-1?a=y:h!==1&&(h=1):a!==-1&&(h=-1)}return a===-1||l===-1||h===0||h===1&&a===l-1&&a===f+1?l!==-1&&(f===0&&c?i.base=i.name=t.slice(1,l):i.base=i.name=t.slice(f,l)):(f===0&&c?(i.name=t.slice(1,a),i.base=t.slice(1,l)):(i.name=t.slice(f,a),i.base=t.slice(f,l)),i.ext=t.slice(a,l)),f>0?i.dir=t.slice(0,f-1):c&&(i.dir="/"),i},sep:"/",delimiter:":",win32:null,posix:null};return o.posix=o,F=o,F}var k=E();const O=T(k),L=j({__proto__:null,default:O},[k]);function C(r){if(r&&typeof r=="object"){const e=r,n=typeof e.isFile=="function"?e.isFile():typeof e.isFile=="boolean"?e.isFile:e.type==="file"||!e.type&&!e.isDirectory,o=typeof e.isDirectory=="function"?e.isDirectory():typeof e.isDirectory=="boolean"?e.isDirectory:e.type==="dir"||e.type==="directory",t=typeof e.size=="number"?e.size:0;let i;return e.mtime instanceof Date?i=e.mtime:typeof e.mtime=="number"?i=new Date(e.mtime):typeof e.mtimeMs=="number"?i=new Date(e.mtimeMs):i=new Date,{isFile:()=>n,isDirectory:()=>o,isSymbolicLink:()=>!1,size:t,mtime:i}}return{isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1,size:0,mtime:new Date}}class R{constructor(){g(this,"fs"),g(this,"initialized",!1),g(this,"path",L)}async initialize(e={}){if(this.initialized)return;const n=e.name||"fs",o=new z(n,{wipe:e.wipe});this.fs=o.promises,this.initialized=!0}ensureInitialized(){if(!this.initialized)throw new Error("LightningFileSystem is not initialized. Call initialize() first.")}async readFile(e){return this.ensureInitialized(),(await this.fs.readFile(e,{encoding:"utf8"})).toString()}async readFileBuffer(e){return this.ensureInitialized(),this.fs.readFile(e)}async writeFile(e,n){this.ensureInitialized();const o=e.substring(0,e.lastIndexOf("/"));return o&&await this.ensureDir(o),this.fs.writeFile(e,n)}async exists(e){this.ensureInitialized();try{return await this.fs.stat(e),!0}catch{return!1}}async mkdir(e,n){this.ensureInitialized();try{return await this.fs.mkdir(e,n)}catch(o){if(o&&typeof o=="object"&&"code"in o&&o.code!=="EEXIST")throw o}}async readdir(e){return this.ensureInitialized(),this.fs.readdir(e)}async stat(e){this.ensureInitialized();const n=await this.fs.stat(e);return C(n)}async lstat(e){this.ensureInitialized();const n=await this.fs.stat(e);return C(n)}async unlink(e){return this.ensureInitialized(),this.fs.unlink(e)}async rmdir(e){return this.ensureInitialized(),this.fs.rmdir(e)}async copyFile(e,n){this.ensureInitialized();const o=n.substring(0,n.lastIndexOf("/"));o&&await this.ensureDir(o);const t=await this.readFileBuffer(e);return this.writeFile(n,t)}async moveFile(e,n){this.ensureInitialized();const o=n.substring(0,n.lastIndexOf("/"));o&&await this.ensureDir(o),await this.copyFile(e,n),await this.unlink(e)}async ensureDir(e){if(this.ensureInitialized(),!await this.exists(e))try{await this.fs.mkdir(e,{recursive:!0})}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code!=="EEXIST")throw n}}async removeDir(e){if(this.ensureInitialized(),!await this.exists(e))return;if((await this.stat(e)).isFile())return this.unlink(e);const n=await this.readdir(e);for(const o of n){const t=`${e}/${o}`;await this.removeDir(t)}return this.rmdir(e)}async readDirectory(e){return this.ensureInitialized(),this.fs.readdir(e)}async writeFileSystemFromTree(e,n,o){for(const t of e){const i=this.path.join(n,t.path);if(t.type==="directory")await this.mkdir(i,{recursive:!0}),t.children&&await this.writeFileSystemFromTree(t.children,n,o);else{const s=await o(t.path);await this.writeFile(i,s)}}}}async function P(r){const e=new R;return await e.initialize(r),e}function _(){return"http://localhost:4000"}const m=_();function w(r){let e=r.replace(/^\/+/,"");const n=e.split("/");return n.length>1&&(e=n.slice(1).join("/")),e}function B(){return{async readFile(r){const e=w(r),n=await fetch(`${m}/file?path=${encodeURIComponent(e)}`);if(!n.ok)throw new Error(`Failed to read file ${r}: ${n.statusText}`);const{content:o}=await n.json();return o},async readFileBuffer(r){const e=await this.readFile(r);return Buffer.from(e,"utf-8")},async writeFile(r,e){const n=w(r),o=typeof e=="string"?e:e.toString("utf-8"),t=await fetch(`${m}/file`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:o})});if(!t.ok)throw new Error(`Failed to write file ${r}: ${t.statusText}`)},async exists(r){const e=w(r);try{if((await fetch(`${m}/file?path=${encodeURIComponent(e)}`)).ok)return!0}catch{}try{if((await fetch(`${m}/files?path=${encodeURIComponent(e)}`)).ok)return!0}catch{}return!1},async mkdir(r){},async readdir(r){const e=w(r),n=await fetch(`${m}/files?path=${encodeURIComponent(e)}`);if(!n.ok)throw new Error(`Failed to read directory ${r}: ${n.statusText}`);return(await n.json()).map(o=>o.name)},async stat(r){const e=w(r);try{const n=await fetch(`${m}/file?path=${encodeURIComponent(e)}`);if(n.ok){const{content:o}=await n.json();return{isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1,size:o.length,mtime:new Date}}}catch{}try{if((await fetch(`${m}/files?path=${encodeURIComponent(e)}`)).ok)return{isFile:()=>!1,isDirectory:()=>!0,isSymbolicLink:()=>!1,size:0,mtime:new Date}}catch{}return{isFile:()=>!1,isDirectory:()=>!1,isSymbolicLink:()=>!1,size:0,mtime:new Date}},async lstat(r){return this.stat(r)},async unlink(r){throw new Error("File deletion not supported in CLI mode")},async rmdir(r){throw new Error("Directory deletion not supported in CLI mode")},async copyFile(r,e){const n=await this.readFile(r);await this.writeFile(e,n)},async moveFile(r,e){await this.copyFile(r,e)},async ensureDir(r){},async removeDir(r){throw new Error("Directory deletion not supported in CLI mode")},async readDirectory(r){return this.readdir(r)},async writeFileSystemFromTree(r,e,n){console.debug("writeFileSystemFromTree called - no-op in CLI mode")}}}async function te(r){return typeof window>"u"?$():r!=null&&r.useCliBackend?B():P(r)}export{B as createCliFS,te as createFS,P as createLightningFS,$ as createNodeFS};
1
+ import{T as z}from"./index-Cdypq0le.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-ChvoNxcO.js";import"./preload-helper-BlTxHScW.js";import"./__vite-browser-external-DLjrMatA.js";import"./inherits_browser-nmOknR35-Bp0mvRSL.js";import"./index-6mKfgpcs-DsgiI2lM.js";import"./_commonjsHelpers-B4e78b8K-W3E8ocG7.js";import"./index-DsIu-45t-Bejjlpz4.js";import"./index-DSosZ5sh-Ceejs_jv.js";import"./index-69shuAsh-DF18H7zf.js";import"./index-BJBOx-Z---hbiLl7B.js";import"./index.browser-BHPvGrwi-6Mh8eUw-.js";import"./_commonjs-dynamic-modules-BpilXLfW-DfYEAvWy.js";import"./_commonjs-dynamic-modules-B7n8ZNar.js";var S=Object.defineProperty,A=(r,e,n)=>e in r?S(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,g=(r,e,n)=>A(r,typeof e!="symbol"?e+"":e,n);function j(r,e){for(var n=0;n<e.length;n++){const o=e[n];if(typeof o!="string"&&!Array.isArray(o)){for(const t in o)if(t!=="default"&&!(t in r)){const i=Object.getOwnPropertyDescriptor(o,t);i&&Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}function v(r){return{isFile:()=>r.isFile(),isDirectory:()=>r.isDirectory(),isSymbolicLink:()=>r.isSymbolicLink(),size:r.size,mtime:r.mtime}}class x{async readFile(e){return(void 0)(e,"utf8")}async readFileBuffer(e){return(void 0)(e)}async writeFile(e,n){const o=(void 0)(e);return await this.ensureDir(o),(void 0)(e,n)}async exists(e){try{return await(void 0)(e),!0}catch{return!1}}async mkdir(e){try{await(void 0)(e)}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code!=="EEXIST")throw n}}async readdir(e){return(void 0)(e)}async stat(e){const n=await(void 0)(e);return v(n)}async lstat(e){const n=await(void 0)(e);return v(n)}async unlink(e){return(void 0)(e)}async rmdir(e){return(void 0)(e)}async copyFile(e,n){const o=(void 0)(n);return await this.ensureDir(o),(void 0)(e,n)}async moveFile(e,n){const o=(void 0)(n);return await this.ensureDir(o),(void 0)(e,n)}async ensureDir(e){try{await(void 0)(e,{recursive:!0})}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code!=="EEXIST")throw n}}async removeDir(e){return(void 0)(e,{recursive:!0,force:!0})}async readDirectory(e){return(void 0)(e)}async writeFileSystemFromTree(e,n,o){for(const t of e){const i=(void 0)(n,t.path);if(t.type==="directory")await this.ensureDir(i),t.children&&await this.writeFileSystemFromTree(t.children,n,o);else{const s=await o(t.path);await this.writeFile(i,s)}}}}function $(){return new x}function T(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var F,D;function E(){if(D)return F;D=1;function r(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}function e(t,i){for(var s="",c=0,u=-1,a=0,f,l=0;l<=t.length;++l){if(l<t.length)f=t.charCodeAt(l);else{if(f===47)break;f=47}if(f===47){if(!(u===l-1||a===1))if(u!==l-1&&a===2){if(s.length<2||c!==2||s.charCodeAt(s.length-1)!==46||s.charCodeAt(s.length-2)!==46){if(s.length>2){var d=s.lastIndexOf("/");if(d!==s.length-1){d===-1?(s="",c=0):(s=s.slice(0,d),c=s.length-1-s.lastIndexOf("/")),u=l,a=0;continue}}else if(s.length===2||s.length===1){s="",c=0,u=l,a=0;continue}}i&&(s.length>0?s+="/..":s="..",c=2)}else s.length>0?s+="/"+t.slice(u+1,l):s=t.slice(u+1,l),c=l-u-1;u=l,a=0}else f===46&&a!==-1?++a:a=-1}return s}function n(t,i){var s=i.dir||i.root,c=i.base||(i.name||"")+(i.ext||"");return s?s===i.root?s+c:s+t+c:c}var o={resolve:function(){for(var t="",i=!1,s,c=arguments.length-1;c>=-1&&!i;c--){var u;c>=0?u=arguments[c]:(s===void 0&&(s=process.cwd()),u=s),r(u),u.length!==0&&(t=u+"/"+t,i=u.charCodeAt(0)===47)}return t=e(t,!i),i?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(r(t),t.length===0)return".";var i=t.charCodeAt(0)===47,s=t.charCodeAt(t.length-1)===47;return t=e(t,!i),t.length===0&&!i&&(t="."),t.length>0&&s&&(t+="/"),i?"/"+t:t},isAbsolute:function(t){return r(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,i=0;i<arguments.length;++i){var s=arguments[i];r(s),s.length>0&&(t===void 0?t=s:t+="/"+s)}return t===void 0?".":o.normalize(t)},relative:function(t,i){if(r(t),r(i),t===i||(t=o.resolve(t),i=o.resolve(i),t===i))return"";for(var s=1;s<t.length&&t.charCodeAt(s)===47;++s);for(var c=t.length,u=c-s,a=1;a<i.length&&i.charCodeAt(a)===47;++a);for(var f=i.length,l=f-a,d=u<l?u:l,y=-1,h=0;h<=d;++h){if(h===d){if(l>d){if(i.charCodeAt(a+h)===47)return i.slice(a+h+1);if(h===0)return i.slice(a+h)}else u>d&&(t.charCodeAt(s+h)===47?y=h:h===0&&(y=0));break}var b=t.charCodeAt(s+h),I=i.charCodeAt(a+h);if(b!==I)break;b===47&&(y=h)}var p="";for(h=s+y+1;h<=c;++h)(h===c||t.charCodeAt(h)===47)&&(p.length===0?p+="..":p+="/..");return p.length>0?p+i.slice(a+y):(a+=y,i.charCodeAt(a)===47&&++a,i.slice(a))},_makeLong:function(t){return t},dirname:function(t){if(r(t),t.length===0)return".";for(var i=t.charCodeAt(0),s=i===47,c=-1,u=!0,a=t.length-1;a>=1;--a)if(i=t.charCodeAt(a),i===47){if(!u){c=a;break}}else u=!1;return c===-1?s?"/":".":s&&c===1?"//":t.slice(0,c)},basename:function(t,i){if(i!==void 0&&typeof i!="string")throw new TypeError('"ext" argument must be a string');r(t);var s=0,c=-1,u=!0,a;if(i!==void 0&&i.length>0&&i.length<=t.length){if(i.length===t.length&&i===t)return"";var f=i.length-1,l=-1;for(a=t.length-1;a>=0;--a){var d=t.charCodeAt(a);if(d===47){if(!u){s=a+1;break}}else l===-1&&(u=!1,l=a+1),f>=0&&(d===i.charCodeAt(f)?--f===-1&&(c=a):(f=-1,c=l))}return s===c?c=l:c===-1&&(c=t.length),t.slice(s,c)}else{for(a=t.length-1;a>=0;--a)if(t.charCodeAt(a)===47){if(!u){s=a+1;break}}else c===-1&&(u=!1,c=a+1);return c===-1?"":t.slice(s,c)}},extname:function(t){r(t);for(var i=-1,s=0,c=-1,u=!0,a=0,f=t.length-1;f>=0;--f){var l=t.charCodeAt(f);if(l===47){if(!u){s=f+1;break}continue}c===-1&&(u=!1,c=f+1),l===46?i===-1?i=f:a!==1&&(a=1):i!==-1&&(a=-1)}return i===-1||c===-1||a===0||a===1&&i===c-1&&i===s+1?"":t.slice(i,c)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return n("/",t)},parse:function(t){r(t);var i={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return i;var s=t.charCodeAt(0),c=s===47,u;c?(i.root="/",u=1):u=0;for(var a=-1,f=0,l=-1,d=!0,y=t.length-1,h=0;y>=u;--y){if(s=t.charCodeAt(y),s===47){if(!d){f=y+1;break}continue}l===-1&&(d=!1,l=y+1),s===46?a===-1?a=y:h!==1&&(h=1):a!==-1&&(h=-1)}return a===-1||l===-1||h===0||h===1&&a===l-1&&a===f+1?l!==-1&&(f===0&&c?i.base=i.name=t.slice(1,l):i.base=i.name=t.slice(f,l)):(f===0&&c?(i.name=t.slice(1,a),i.base=t.slice(1,l)):(i.name=t.slice(f,a),i.base=t.slice(f,l)),i.ext=t.slice(a,l)),f>0?i.dir=t.slice(0,f-1):c&&(i.dir="/"),i},sep:"/",delimiter:":",win32:null,posix:null};return o.posix=o,F=o,F}var k=E();const O=T(k),L=j({__proto__:null,default:O},[k]);function C(r){if(r&&typeof r=="object"){const e=r,n=typeof e.isFile=="function"?e.isFile():typeof e.isFile=="boolean"?e.isFile:e.type==="file"||!e.type&&!e.isDirectory,o=typeof e.isDirectory=="function"?e.isDirectory():typeof e.isDirectory=="boolean"?e.isDirectory:e.type==="dir"||e.type==="directory",t=typeof e.size=="number"?e.size:0;let i;return e.mtime instanceof Date?i=e.mtime:typeof e.mtime=="number"?i=new Date(e.mtime):typeof e.mtimeMs=="number"?i=new Date(e.mtimeMs):i=new Date,{isFile:()=>n,isDirectory:()=>o,isSymbolicLink:()=>!1,size:t,mtime:i}}return{isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1,size:0,mtime:new Date}}class R{constructor(){g(this,"fs"),g(this,"initialized",!1),g(this,"path",L)}async initialize(e={}){if(this.initialized)return;const n=e.name||"fs",o=new z(n,{wipe:e.wipe});this.fs=o.promises,this.initialized=!0}ensureInitialized(){if(!this.initialized)throw new Error("LightningFileSystem is not initialized. Call initialize() first.")}async readFile(e){return this.ensureInitialized(),(await this.fs.readFile(e,{encoding:"utf8"})).toString()}async readFileBuffer(e){return this.ensureInitialized(),this.fs.readFile(e)}async writeFile(e,n){this.ensureInitialized();const o=e.substring(0,e.lastIndexOf("/"));return o&&await this.ensureDir(o),this.fs.writeFile(e,n)}async exists(e){this.ensureInitialized();try{return await this.fs.stat(e),!0}catch{return!1}}async mkdir(e,n){this.ensureInitialized();try{return await this.fs.mkdir(e,n)}catch(o){if(o&&typeof o=="object"&&"code"in o&&o.code!=="EEXIST")throw o}}async readdir(e){return this.ensureInitialized(),this.fs.readdir(e)}async stat(e){this.ensureInitialized();const n=await this.fs.stat(e);return C(n)}async lstat(e){this.ensureInitialized();const n=await this.fs.stat(e);return C(n)}async unlink(e){return this.ensureInitialized(),this.fs.unlink(e)}async rmdir(e){return this.ensureInitialized(),this.fs.rmdir(e)}async copyFile(e,n){this.ensureInitialized();const o=n.substring(0,n.lastIndexOf("/"));o&&await this.ensureDir(o);const t=await this.readFileBuffer(e);return this.writeFile(n,t)}async moveFile(e,n){this.ensureInitialized();const o=n.substring(0,n.lastIndexOf("/"));o&&await this.ensureDir(o),await this.copyFile(e,n),await this.unlink(e)}async ensureDir(e){if(this.ensureInitialized(),!await this.exists(e))try{await this.fs.mkdir(e,{recursive:!0})}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code!=="EEXIST")throw n}}async removeDir(e){if(this.ensureInitialized(),!await this.exists(e))return;if((await this.stat(e)).isFile())return this.unlink(e);const n=await this.readdir(e);for(const o of n){const t=`${e}/${o}`;await this.removeDir(t)}return this.rmdir(e)}async readDirectory(e){return this.ensureInitialized(),this.fs.readdir(e)}async writeFileSystemFromTree(e,n,o){for(const t of e){const i=this.path.join(n,t.path);if(t.type==="directory")await this.mkdir(i,{recursive:!0}),t.children&&await this.writeFileSystemFromTree(t.children,n,o);else{const s=await o(t.path);await this.writeFile(i,s)}}}}async function P(r){const e=new R;return await e.initialize(r),e}function _(){return"http://localhost:4000"}const m=_();function w(r){let e=r.replace(/^\/+/,"");const n=e.split("/");return n.length>1&&(e=n.slice(1).join("/")),e}function B(){return{async readFile(r){const e=w(r),n=await fetch(`${m}/file?path=${encodeURIComponent(e)}`);if(!n.ok)throw new Error(`Failed to read file ${r}: ${n.statusText}`);const{content:o}=await n.json();return o},async readFileBuffer(r){const e=await this.readFile(r);return Buffer.from(e,"utf-8")},async writeFile(r,e){const n=w(r),o=typeof e=="string"?e:e.toString("utf-8"),t=await fetch(`${m}/file`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:o})});if(!t.ok)throw new Error(`Failed to write file ${r}: ${t.statusText}`)},async exists(r){const e=w(r);try{if((await fetch(`${m}/file?path=${encodeURIComponent(e)}`)).ok)return!0}catch{}try{if((await fetch(`${m}/files?path=${encodeURIComponent(e)}`)).ok)return!0}catch{}return!1},async mkdir(r){},async readdir(r){const e=w(r),n=await fetch(`${m}/files?path=${encodeURIComponent(e)}`);if(!n.ok)throw new Error(`Failed to read directory ${r}: ${n.statusText}`);return(await n.json()).map(o=>o.name)},async stat(r){const e=w(r);try{const n=await fetch(`${m}/file?path=${encodeURIComponent(e)}`);if(n.ok){const{content:o}=await n.json();return{isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1,size:o.length,mtime:new Date}}}catch{}try{if((await fetch(`${m}/files?path=${encodeURIComponent(e)}`)).ok)return{isFile:()=>!1,isDirectory:()=>!0,isSymbolicLink:()=>!1,size:0,mtime:new Date}}catch{}return{isFile:()=>!1,isDirectory:()=>!1,isSymbolicLink:()=>!1,size:0,mtime:new Date}},async lstat(r){return this.stat(r)},async unlink(r){throw new Error("File deletion not supported in CLI mode")},async rmdir(r){throw new Error("Directory deletion not supported in CLI mode")},async copyFile(r,e){const n=await this.readFile(r);await this.writeFile(e,n)},async moveFile(r,e){await this.copyFile(r,e)},async ensureDir(r){},async removeDir(r){throw new Error("Directory deletion not supported in CLI mode")},async readDirectory(r){return this.readdir(r)},async writeFileSystemFromTree(r,e,n){console.debug("writeFileSystemFromTree called - no-op in CLI mode")}}}async function te(r){return typeof window>"u"?$():r!=null&&r.useCliBackend?B():P(r)}export{B as createCliFS,te as createFS,P as createLightningFS,$ as createNodeFS};
@@ -1,4 +1,4 @@
1
- import{a as On,g as Tn}from"./_commonjsHelpers-D6-XlEtG.js";import{a as En,b as Nn,c as In,r as An}from"./winston-_L517l6d.js";import{c as it,r as Pe}from"./_commonjs-dynamic-modules-B7n8ZNar.js";import{r as Fr}from"./util-CLXELMCc.js";function Fn(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in e)){const u=Object.getOwnPropertyDescriptor(n,s);u&&Object.defineProperty(e,s,u.get?u:{enumerable:!0,get:()=>n[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Ut={exports:{}},Dr;function Rn(){return Dr||(Dr=1,(function(e,t){(function(r){e.exports=r()})(function(){return(function r(n,s,u){function g(L,j){if(!s[L]){if(!n[L]){var ee=typeof it=="function"&&it;if(!j&&ee)return ee(L,!0);if(T)return T(L,!0);throw new Error("Cannot find module '"+L+"'")}j=s[L]={exports:{}},n[L][0].call(j.exports,function(k){var Q=n[L][1][k];return g(Q||k)},j,j.exports,r,n,s,u)}return s[L].exports}for(var T=typeof it=="function"&&it,F=0;F<u.length;F++)g(u[F]);return g})({1:[function(r,n,s){(function(u,g,T,F,L,j,ee,k,Q){var M=r("crypto");function _(c,w){w=v(c,w);var o;return(o=w.algorithm!=="passthrough"?M.createHash(w.algorithm):new D).write===void 0&&(o.write=o.update,o.end=o.update),b(w,o).dispatch(c),o.update||o.end(""),o.digest?o.digest(w.encoding==="buffer"?void 0:w.encoding):(c=o.read(),w.encoding!=="buffer"?c.toString(w.encoding):c)}(s=n.exports=_).sha1=function(c){return _(c)},s.keys=function(c){return _(c,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},s.MD5=function(c){return _(c,{algorithm:"md5",encoding:"hex"})},s.keysMD5=function(c){return _(c,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var d=M.getHashes?M.getHashes().slice():["sha1","md5"],m=(d.push("passthrough"),["buffer","hex","binary","base64"]);function v(c,w){var o={};if(o.algorithm=(w=w||{}).algorithm||"sha1",o.encoding=w.encoding||"hex",o.excludeValues=!!w.excludeValues,o.algorithm=o.algorithm.toLowerCase(),o.encoding=o.encoding.toLowerCase(),o.ignoreUnknown=w.ignoreUnknown===!0,o.respectType=w.respectType!==!1,o.respectFunctionNames=w.respectFunctionNames!==!1,o.respectFunctionProperties=w.respectFunctionProperties!==!1,o.unorderedArrays=w.unorderedArrays===!0,o.unorderedSets=w.unorderedSets!==!1,o.unorderedObjects=w.unorderedObjects!==!1,o.replacer=w.replacer||void 0,o.excludeKeys=w.excludeKeys||void 0,c===void 0)throw new Error("Object argument required.");for(var f=0;f<d.length;++f)d[f].toLowerCase()===o.algorithm.toLowerCase()&&(o.algorithm=d[f]);if(d.indexOf(o.algorithm)===-1)throw new Error('Algorithm "'+o.algorithm+'" not supported. supported values: '+d.join(", "));if(m.indexOf(o.encoding)===-1&&o.algorithm!=="passthrough")throw new Error('Encoding "'+o.encoding+'" not supported. supported values: '+m.join(", "));return o}function S(c){if(typeof c=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(c))!=null}function b(c,w,o){o=o||[];function f(a){return w.update?w.update(a,"utf8"):w.write(a,"utf8")}return{dispatch:function(a){return this["_"+((a=c.replacer?c.replacer(a):a)===null?"null":typeof a)](a)},_object:function(a){var y,p=Object.prototype.toString.call(a),P=/\[object (.*)\]/i.exec(p);if(P=(P=P?P[1]:"unknown:["+p+"]").toLowerCase(),0<=(p=o.indexOf(a)))return this.dispatch("[CIRCULAR:"+p+"]");if(o.push(a),T!==void 0&&T.isBuffer&&T.isBuffer(a))return f("buffer:"),f(a);if(P==="object"||P==="function"||P==="asyncfunction")return p=Object.keys(a),c.unorderedObjects&&(p=p.sort()),c.respectType===!1||S(a)||p.splice(0,0,"prototype","__proto__","constructor"),c.excludeKeys&&(p=p.filter(function(U){return!c.excludeKeys(U)})),f("object:"+p.length+":"),y=this,p.forEach(function(U){y.dispatch(U),f(":"),c.excludeValues||y.dispatch(a[U]),f(",")});if(!this["_"+P]){if(c.ignoreUnknown)return f("["+P+"]");throw new Error('Unknown object type "'+P+'"')}this["_"+P](a)},_array:function(a,U){U=U!==void 0?U:c.unorderedArrays!==!1;var p=this;if(f("array:"+a.length+":"),!U||a.length<=1)return a.forEach(function(C){return p.dispatch(C)});var P=[],U=a.map(function(C){var R=new D,B=o.slice();return b(c,R,B).dispatch(C),P=P.concat(B.slice(o.length)),R.read().toString()});return o=o.concat(P),U.sort(),this._array(U,!1)},_date:function(a){return f("date:"+a.toJSON())},_symbol:function(a){return f("symbol:"+a.toString())},_error:function(a){return f("error:"+a.toString())},_boolean:function(a){return f("bool:"+a.toString())},_string:function(a){f("string:"+a.length+":"),f(a.toString())},_function:function(a){f("fn:"),S(a)?this.dispatch("[native]"):this.dispatch(a.toString()),c.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(a.name)),c.respectFunctionProperties&&this._object(a)},_number:function(a){return f("number:"+a.toString())},_xml:function(a){return f("xml:"+a.toString())},_null:function(){return f("Null")},_undefined:function(){return f("Undefined")},_regexp:function(a){return f("regex:"+a.toString())},_uint8array:function(a){return f("uint8array:"),this.dispatch(Array.prototype.slice.call(a))},_uint8clampedarray:function(a){return f("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(a))},_int8array:function(a){return f("int8array:"),this.dispatch(Array.prototype.slice.call(a))},_uint16array:function(a){return f("uint16array:"),this.dispatch(Array.prototype.slice.call(a))},_int16array:function(a){return f("int16array:"),this.dispatch(Array.prototype.slice.call(a))},_uint32array:function(a){return f("uint32array:"),this.dispatch(Array.prototype.slice.call(a))},_int32array:function(a){return f("int32array:"),this.dispatch(Array.prototype.slice.call(a))},_float32array:function(a){return f("float32array:"),this.dispatch(Array.prototype.slice.call(a))},_float64array:function(a){return f("float64array:"),this.dispatch(Array.prototype.slice.call(a))},_arraybuffer:function(a){return f("arraybuffer:"),this.dispatch(new Uint8Array(a))},_url:function(a){return f("url:"+a.toString())},_map:function(a){return f("map:"),a=Array.from(a),this._array(a,c.unorderedSets!==!1)},_set:function(a){return f("set:"),a=Array.from(a),this._array(a,c.unorderedSets!==!1)},_file:function(a){return f("file:"),this.dispatch([a.name,a.size,a.type,a.lastModfied])},_blob:function(){if(c.ignoreUnknown)return f("[blob]");throw Error(`Hashing Blob objects is currently not supported
1
+ import{a as On,g as Tn}from"./_commonjsHelpers-D6-XlEtG.js";import{a as En,b as Nn,c as In,r as An}from"./winston-CKrqq8ju.js";import{c as it,r as Pe}from"./_commonjs-dynamic-modules-B7n8ZNar.js";import{r as Fr}from"./util-dDeaEvHH.js";function Fn(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in e)){const u=Object.getOwnPropertyDescriptor(n,s);u&&Object.defineProperty(e,s,u.get?u:{enumerable:!0,get:()=>n[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Ut={exports:{}},Dr;function Rn(){return Dr||(Dr=1,(function(e,t){(function(r){e.exports=r()})(function(){return(function r(n,s,u){function g(L,j){if(!s[L]){if(!n[L]){var ee=typeof it=="function"&&it;if(!j&&ee)return ee(L,!0);if(T)return T(L,!0);throw new Error("Cannot find module '"+L+"'")}j=s[L]={exports:{}},n[L][0].call(j.exports,function(k){var Q=n[L][1][k];return g(Q||k)},j,j.exports,r,n,s,u)}return s[L].exports}for(var T=typeof it=="function"&&it,F=0;F<u.length;F++)g(u[F]);return g})({1:[function(r,n,s){(function(u,g,T,F,L,j,ee,k,Q){var M=r("crypto");function _(c,w){w=v(c,w);var o;return(o=w.algorithm!=="passthrough"?M.createHash(w.algorithm):new D).write===void 0&&(o.write=o.update,o.end=o.update),b(w,o).dispatch(c),o.update||o.end(""),o.digest?o.digest(w.encoding==="buffer"?void 0:w.encoding):(c=o.read(),w.encoding!=="buffer"?c.toString(w.encoding):c)}(s=n.exports=_).sha1=function(c){return _(c)},s.keys=function(c){return _(c,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},s.MD5=function(c){return _(c,{algorithm:"md5",encoding:"hex"})},s.keysMD5=function(c){return _(c,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var d=M.getHashes?M.getHashes().slice():["sha1","md5"],m=(d.push("passthrough"),["buffer","hex","binary","base64"]);function v(c,w){var o={};if(o.algorithm=(w=w||{}).algorithm||"sha1",o.encoding=w.encoding||"hex",o.excludeValues=!!w.excludeValues,o.algorithm=o.algorithm.toLowerCase(),o.encoding=o.encoding.toLowerCase(),o.ignoreUnknown=w.ignoreUnknown===!0,o.respectType=w.respectType!==!1,o.respectFunctionNames=w.respectFunctionNames!==!1,o.respectFunctionProperties=w.respectFunctionProperties!==!1,o.unorderedArrays=w.unorderedArrays===!0,o.unorderedSets=w.unorderedSets!==!1,o.unorderedObjects=w.unorderedObjects!==!1,o.replacer=w.replacer||void 0,o.excludeKeys=w.excludeKeys||void 0,c===void 0)throw new Error("Object argument required.");for(var f=0;f<d.length;++f)d[f].toLowerCase()===o.algorithm.toLowerCase()&&(o.algorithm=d[f]);if(d.indexOf(o.algorithm)===-1)throw new Error('Algorithm "'+o.algorithm+'" not supported. supported values: '+d.join(", "));if(m.indexOf(o.encoding)===-1&&o.algorithm!=="passthrough")throw new Error('Encoding "'+o.encoding+'" not supported. supported values: '+m.join(", "));return o}function S(c){if(typeof c=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(c))!=null}function b(c,w,o){o=o||[];function f(a){return w.update?w.update(a,"utf8"):w.write(a,"utf8")}return{dispatch:function(a){return this["_"+((a=c.replacer?c.replacer(a):a)===null?"null":typeof a)](a)},_object:function(a){var y,p=Object.prototype.toString.call(a),P=/\[object (.*)\]/i.exec(p);if(P=(P=P?P[1]:"unknown:["+p+"]").toLowerCase(),0<=(p=o.indexOf(a)))return this.dispatch("[CIRCULAR:"+p+"]");if(o.push(a),T!==void 0&&T.isBuffer&&T.isBuffer(a))return f("buffer:"),f(a);if(P==="object"||P==="function"||P==="asyncfunction")return p=Object.keys(a),c.unorderedObjects&&(p=p.sort()),c.respectType===!1||S(a)||p.splice(0,0,"prototype","__proto__","constructor"),c.excludeKeys&&(p=p.filter(function(U){return!c.excludeKeys(U)})),f("object:"+p.length+":"),y=this,p.forEach(function(U){y.dispatch(U),f(":"),c.excludeValues||y.dispatch(a[U]),f(",")});if(!this["_"+P]){if(c.ignoreUnknown)return f("["+P+"]");throw new Error('Unknown object type "'+P+'"')}this["_"+P](a)},_array:function(a,U){U=U!==void 0?U:c.unorderedArrays!==!1;var p=this;if(f("array:"+a.length+":"),!U||a.length<=1)return a.forEach(function(C){return p.dispatch(C)});var P=[],U=a.map(function(C){var R=new D,B=o.slice();return b(c,R,B).dispatch(C),P=P.concat(B.slice(o.length)),R.read().toString()});return o=o.concat(P),U.sort(),this._array(U,!1)},_date:function(a){return f("date:"+a.toJSON())},_symbol:function(a){return f("symbol:"+a.toString())},_error:function(a){return f("error:"+a.toString())},_boolean:function(a){return f("bool:"+a.toString())},_string:function(a){f("string:"+a.length+":"),f(a.toString())},_function:function(a){f("fn:"),S(a)?this.dispatch("[native]"):this.dispatch(a.toString()),c.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(a.name)),c.respectFunctionProperties&&this._object(a)},_number:function(a){return f("number:"+a.toString())},_xml:function(a){return f("xml:"+a.toString())},_null:function(){return f("Null")},_undefined:function(){return f("Undefined")},_regexp:function(a){return f("regex:"+a.toString())},_uint8array:function(a){return f("uint8array:"),this.dispatch(Array.prototype.slice.call(a))},_uint8clampedarray:function(a){return f("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(a))},_int8array:function(a){return f("int8array:"),this.dispatch(Array.prototype.slice.call(a))},_uint16array:function(a){return f("uint16array:"),this.dispatch(Array.prototype.slice.call(a))},_int16array:function(a){return f("int16array:"),this.dispatch(Array.prototype.slice.call(a))},_uint32array:function(a){return f("uint32array:"),this.dispatch(Array.prototype.slice.call(a))},_int32array:function(a){return f("int32array:"),this.dispatch(Array.prototype.slice.call(a))},_float32array:function(a){return f("float32array:"),this.dispatch(Array.prototype.slice.call(a))},_float64array:function(a){return f("float64array:"),this.dispatch(Array.prototype.slice.call(a))},_arraybuffer:function(a){return f("arraybuffer:"),this.dispatch(new Uint8Array(a))},_url:function(a){return f("url:"+a.toString())},_map:function(a){return f("map:"),a=Array.from(a),this._array(a,c.unorderedSets!==!1)},_set:function(a){return f("set:"),a=Array.from(a),this._array(a,c.unorderedSets!==!1)},_file:function(a){return f("file:"),this.dispatch([a.name,a.size,a.type,a.lastModfied])},_blob:function(){if(c.ignoreUnknown)return f("[blob]");throw Error(`Hashing Blob objects is currently not supported
2
2
  (see https://github.com/puleos/object-hash/issues/26)
3
3
  Use "options.replacer" or "options.ignoreUnknown"
4
4
  `)},_domwindow:function(){return f("domwindow")},_bigint:function(a){return f("bigint:"+a.toString())},_process:function(){return f("process")},_timer:function(){return f("timer")},_pipe:function(){return f("pipe")},_tcp:function(){return f("tcp")},_udp:function(){return f("udp")},_tty:function(){return f("tty")},_statwatcher:function(){return f("statwatcher")},_securecontext:function(){return f("securecontext")},_connection:function(){return f("connection")},_zlib:function(){return f("zlib")},_context:function(){return f("context")},_nodescript:function(){return f("nodescript")},_httpparser:function(){return f("httpparser")},_dataview:function(){return f("dataview")},_signal:function(){return f("signal")},_fsevent:function(){return f("fsevent")},_tlswrap:function(){return f("tlswrap")}}}function D(){return{buf:"",write:function(c){this.buf+=c},end:function(c){this.buf+=c},read:function(){return this.buf}}}s.writeToStream=function(c,w,o){return o===void 0&&(o=w,w={}),b(w=v(c,w),o).dispatch(c)}}).call(this,r("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},r("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(r,n,s){(function(u,g,T,F,L,j,ee,k,Q){(function(M){var _=typeof Uint8Array<"u"?Uint8Array:Array,d=43,m=47,v=48,S=97,b=65,D=45,c=95;function w(o){return o=o.charCodeAt(0),o===d||o===D?62:o===m||o===c?63:o<v?-1:o<v+10?o-v+26+26:o<b+26?o-b:o<S+26?o-S+26:void 0}M.toByteArray=function(o){var f,a;if(0<o.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var y=o.length,y=o.charAt(y-2)==="="?2:o.charAt(y-1)==="="?1:0,p=new _(3*o.length/4-y),P=0<y?o.length-4:o.length,U=0;function C(R){p[U++]=R}for(f=0;f<P;f+=4,0)C((16711680&(a=w(o.charAt(f))<<18|w(o.charAt(f+1))<<12|w(o.charAt(f+2))<<6|w(o.charAt(f+3))))>>16),C((65280&a)>>8),C(255&a);return y==2?C(255&(a=w(o.charAt(f))<<2|w(o.charAt(f+1))>>4)):y==1&&(C((a=w(o.charAt(f))<<10|w(o.charAt(f+1))<<4|w(o.charAt(f+2))>>2)>>8&255),C(255&a)),p},M.fromByteArray=function(o){var f,a,y,p,P=o.length%3,U="";function C(R){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(R)}for(f=0,y=o.length-P;f<y;f+=3)a=(o[f]<<16)+(o[f+1]<<8)+o[f+2],U+=C((p=a)>>18&63)+C(p>>12&63)+C(p>>6&63)+C(63&p);switch(P){case 1:U=(U+=C((a=o[o.length-1])>>2))+C(a<<4&63)+"==";break;case 2:U=(U=(U+=C((a=(o[o.length-2]<<8)+o[o.length-1])>>10))+C(a>>4&63))+C(a<<2&63)+"="}return U}})(s===void 0?this.base64js={}:s)}).call(this,r("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},r("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(r,n,s){(function(u,g,d,F,L,j,ee,k,Q){var M=r("base64-js"),_=r("ieee754");function d(i,l,h){if(!(this instanceof d))return new d(i,l,h);var O,x,I,$,se=typeof i;if(l==="base64"&&se=="string")for(i=($=i).trim?$.trim():$.replace(/^\s+|\s+$/g,"");i.length%4!=0;)i+="=";if(se=="number")O=V(i);else if(se=="string")O=d.byteLength(i,l);else{if(se!="object")throw new Error("First argument needs to be a number, array or string.");O=V(i.length)}if(d._useTypedArrays?x=d._augment(new Uint8Array(O)):((x=this).length=O,x._isBuffer=!0),d._useTypedArrays&&typeof i.byteLength=="number")x._set(i);else if(K($=i)||d.isBuffer($)||$&&typeof $=="object"&&typeof $.length=="number")for(I=0;I<O;I++)d.isBuffer(i)?x[I]=i.readUInt8(I):x[I]=i[I];else if(se=="string")x.write(i,0,l);else if(se=="number"&&!d._useTypedArrays&&!h)for(I=0;I<O;I++)x[I]=0;return x}function m(i,l,h,O){return d._charsWritten=ye((function(x){for(var I=[],$=0;$<x.length;$++)I.push(255&x.charCodeAt($));return I})(l),i,h,O)}function v(i,l,h,O){return d._charsWritten=ye((function(x){for(var I,$,se=[],ue=0;ue<x.length;ue++)$=x.charCodeAt(ue),I=$>>8,$=$%256,se.push($),se.push(I);return se})(l),i,h,O)}function S(i,l,h){var O="";h=Math.min(i.length,h);for(var x=l;x<h;x++)O+=String.fromCharCode(i[x]);return O}function b(i,l,h,I){I||(E(typeof h=="boolean","missing or invalid endian"),E(l!=null,"missing offset"),E(l+1<i.length,"Trying to read beyond buffer length"));var x,I=i.length;if(!(I<=l))return h?(x=i[l],l+1<I&&(x|=i[l+1]<<8)):(x=i[l]<<8,l+1<I&&(x|=i[l+1])),x}function D(i,l,h,I){I||(E(typeof h=="boolean","missing or invalid endian"),E(l!=null,"missing offset"),E(l+3<i.length,"Trying to read beyond buffer length"));var x,I=i.length;if(!(I<=l))return h?(l+2<I&&(x=i[l+2]<<16),l+1<I&&(x|=i[l+1]<<8),x|=i[l],l+3<I&&(x+=i[l+3]<<24>>>0)):(l+1<I&&(x=i[l+1]<<16),l+2<I&&(x|=i[l+2]<<8),l+3<I&&(x|=i[l+3]),x+=i[l]<<24>>>0),x}function c(i,l,h,O){if(O||(E(typeof h=="boolean","missing or invalid endian"),E(l!=null,"missing offset"),E(l+1<i.length,"Trying to read beyond buffer length")),!(i.length<=l))return O=b(i,l,h,!0),32768&O?-1*(65535-O+1):O}function w(i,l,h,O){if(O||(E(typeof h=="boolean","missing or invalid endian"),E(l!=null,"missing offset"),E(l+3<i.length,"Trying to read beyond buffer length")),!(i.length<=l))return O=D(i,l,h,!0),2147483648&O?-1*(4294967295-O+1):O}function o(i,l,h,O){return O||(E(typeof h=="boolean","missing or invalid endian"),E(l+3<i.length,"Trying to read beyond buffer length")),_.read(i,l,h,23,4)}function f(i,l,h,O){return O||(E(typeof h=="boolean","missing or invalid endian"),E(l+7<i.length,"Trying to read beyond buffer length")),_.read(i,l,h,52,8)}function a(i,l,h,O,x){if(x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+1<i.length,"trying to write beyond buffer length"),Lt(l,65535)),x=i.length,!(x<=h))for(var I=0,$=Math.min(x-h,2);I<$;I++)i[h+I]=(l&255<<8*(O?I:1-I))>>>8*(O?I:1-I)}function y(i,l,h,O,x){if(x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+3<i.length,"trying to write beyond buffer length"),Lt(l,4294967295)),x=i.length,!(x<=h))for(var I=0,$=Math.min(x-h,4);I<$;I++)i[h+I]=l>>>8*(O?I:3-I)&255}function p(i,l,h,O,x){x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+1<i.length,"Trying to write beyond buffer length"),Wt(l,32767,-32768)),i.length<=h||a(i,0<=l?l:65535+l+1,h,O,x)}function P(i,l,h,O,x){x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+3<i.length,"Trying to write beyond buffer length"),Wt(l,2147483647,-2147483648)),i.length<=h||y(i,0<=l?l:4294967295+l+1,h,O,x)}function U(i,l,h,O,x){x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+3<i.length,"Trying to write beyond buffer length"),Sr(l,34028234663852886e22,-34028234663852886e22)),i.length<=h||_.write(i,l,h,O,23,4)}function C(i,l,h,O,x){x||(E(l!=null,"missing value"),E(typeof O=="boolean","missing or invalid endian"),E(h!=null,"missing offset"),E(h+7<i.length,"Trying to write beyond buffer length"),Sr(l,17976931348623157e292,-17976931348623157e292)),i.length<=h||_.write(i,l,h,O,52,8)}s.Buffer=d,s.SlowBuffer=d,s.INSPECT_MAX_BYTES=50,d.poolSize=8192,d._useTypedArrays=(function(){try{var i=new ArrayBuffer(0),l=new Uint8Array(i);return l.foo=function(){return 42},l.foo()===42&&typeof l.subarray=="function"}catch{return!1}})(),d.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.isBuffer=function(i){return!(i==null||!i._isBuffer)},d.byteLength=function(i,l){var h;switch(i+="",l||"utf8"){case"hex":h=i.length/2;break;case"utf8":case"utf-8":h=de(i).length;break;case"ascii":case"binary":case"raw":h=i.length;break;case"base64":h=Te(i).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=2*i.length;break;default:throw new Error("Unknown encoding")}return h},d.concat=function(i,l){if(E(K(i),`Usage: Buffer.concat(list, [totalLength])