@prismatic-io/components-sftp 0.1.0 → 0.1.1
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/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -217,7 +217,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
217
217
|
|
|
218
218
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function l(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;l(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let u=new Set([`type`,`properties`,`required`,`additionalProperties`]),d=[`oneOf`,`anyOf`];function f(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function p(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!u.has(e))return null;t.push(n)}let r={},i=new Set;for(let e of t){for(let i in e.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let e=[];for(let n of t){let t=n.properties?.[i]??f(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}let a=e.length===1?e[0]:p(e)??{allOf:e};(0,n.assignProp)(r,i,a)}for(let t of e.required??[])i.add(t)}let a={type:`object`,properties:r};if(i.size&&(a.required=[...i]),t.every(e=>e.additionalProperties===!1))a.additionalProperties=!1;else{let e=[];for(let n of t){let t=f(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?a.additionalProperties=e[0]:e.length>1&&(a.additionalProperties={allOf:e})}return a}function m(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of u)if(t in e)return;let n=t.filter(e=>d.some(t=>Array.isArray(e[t]))),i=null;if(!n.length)i=p(t);else{let e=n[0],r=d.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[r].map(e=>p([...a,e]));if(o.some(e=>!e))return;i={[r]:o}}i&&(delete e.allOf,r(e,i))}function h(t,i){let a=t.seen.get(i);if(!a)throw Error(`Unprocessed schema. This is a bug in Zod.`);let o=e=>{let n=t.seen.get(e);if(n.ref===null)return;let i=n.def??n.schema,a={...i},s=n.ref;if(n.ref=null,s){o(s);let n=t.seen.get(s),c=n.schema;if(c.$ref&&(t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(c)):r(i,c),r(i,a),e._zod.parent===s)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(c.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let c=e._zod.parent;if(c&&c!==s){o(c);let e=t.seen.get(c);if(e?.schema.$ref&&(i.$ref=e.schema.$ref,e.def))for(let t in i)t===`$ref`||t===`allOf`||t in e.def&&JSON.stringify(i[t])===JSON.stringify(e.def[t])&&delete i[t]}t.override({zodSchema:e,jsonSchema:i,path:n.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(let e of[...t.seen.entries()].reverse())o(e[0]);if(t.target!==`openapi-3.0`)for(let e of t.seen.entries())l(e[1].def??e[1].schema);for(let e of t.deferred)e();if(t.intersections.length){let e=new Map;for(let n of t.seen.values())for(let t of[n.schema,n.def]){let n=t?.allOf;if(!Array.isArray(n))continue;let r=e.get(n);r?r.push(t):e.set(n,[t])}for(let n of t.intersections)for(let t of e.get(n)??[])m(t)}}let s={};if(t.target===`draft-2020-12`?s.$schema=`https://json-schema.org/draft/2020-12/schema`:t.target===`draft-07`?s.$schema=`http://json-schema.org/draft-07/schema#`:t.target===`draft-04`?s.$schema=`http://json-schema.org/draft-04/schema#`:t.target,t.external?.uri){let e=t.external.registry.get(i)?.id;if(!e)throw Error("Schema is missing an `id` property");s.$id=t.external.uri(e)}r(s,a.defId?a.schema:a.def??a.schema);let c=t.metadataRegistry.get(i)?.id;c!==void 0&&s.id===c&&delete s.id;let u=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(let e of t.seen.entries()){let t=e[1];t.def&&t.defId&&(t.def.id===t.defId&&delete t.def.id,(0,n.assignProp)(u,t.defId,t.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(u).length>0&&(t.target===`draft-2020-12`?s.$defs=u:s.definitions=u);try{let n=JSON.parse(JSON.stringify(s));return Object.defineProperty(n,"~standard",{value:{...i[`~standard`],jsonSchema:{input:(0,e.createStandardJSONSchemaMethod)(i,`input`,t.processors),output:(0,e.createStandardJSONSchemaMethod)(i,`output`,t.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function g(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return g(r.element,n);if(r.type===`set`)return g(r.valueType,n);if(r.type===`lazy`)return g(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return g(r.innerType,n);if(r.type===`intersection`)return g(r.left,n)||g(r.right,n);if(r.type===`record`||r.type===`map`)return g(r.keyType,n)||g(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:g(r.in,n)||g(r.out,n);if(r.type===`object`){for(let e in r.shape)if(g(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(g(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(g(e,n))return!0;return!!(r.rest&&g(r.rest,n))}return!1}e.createToJSONSchemaMethod=(e,t={})=>n=>{let r=i({...n,processors:t});return o(e,r),c(r,e),h(r,e)},e.createStandardJSONSchemaMethod=(e,t,n={})=>r=>{let{libraryOptions:a,target:s}=r??{},l=i({...a??{},target:s,io:t,processors:n});return o(e,l),c(l,e),h(l,e)},(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),Xp=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.allProcessors=e.lazyProcessor=e.optionalProcessor=e.promiseProcessor=e.readonlyProcessor=e.pipeProcessor=e.catchProcessor=e.prefaultProcessor=e.defaultProcessor=e.nonoptionalProcessor=e.nullableProcessor=e.recordProcessor=e.tupleProcessor=e.intersectionProcessor=e.unionProcessor=e.objectProcessor=e.arrayProcessor=e.setProcessor=e.mapProcessor=e.transformProcessor=e.functionProcessor=e.customProcessor=e.successProcessor=e.fileProcessor=e.templateLiteralProcessor=e.nanProcessor=e.literalProcessor=e.enumProcessor=e.dateProcessor=e.unknownProcessor=e.anyProcessor=e.neverProcessor=e.voidProcessor=e.undefinedProcessor=e.nullProcessor=e.symbolProcessor=e.bigintProcessor=e.booleanProcessor=e.numberProcessor=e.stringProcessor=void 0,e.aggregateChecks=y,e.toJSONSchema=k;let i=r(Af()),a=Pf(),o=Yp(),s=$(),c=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},l=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},u=(e,t)=>{c(e,`minimum`,t),l(e,`maximum`,t)},d=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},f=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},p=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},m=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},h=(e,t)=>c(e,`minimum`,t.minimum),g=(e,t)=>l(e,`maximum`,t.maximum),_=e=>(t,n)=>{m(t,n.format);let[r,i]=e[n.format];c(t,`minimum`,r),l(t,`maximum`,i)},v={greater_than:(e,t)=>c(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>l(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>d(e,t.value),number_format:_(s.NUMBER_FORMAT_RANGES),bigint_format:_(s.BIGINT_FORMAT_RANGES),min_length:h,max_length:g,length_equals:(e,t)=>u(e,t.length),min_size:h,max_size:g,size_equals:(e,t)=>u(e,t.size),string_format:(e,t)=>{m(e,t.format),t.pattern&&f(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>p(e,t.mime)};function y(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)v[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&c(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&c(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&l(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&l(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&d(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&p(t,i.mime);for(let e of i.patterns??[])f(t,e);return t}let b={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},x=new Map([[a.base64Charset,i.base64],[a.base64urlCharset,i.base64url]]),S=e=>x.get(e)??e;e.stringProcessor=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=y(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=b[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(S);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},e.numberProcessor=(e,t,n,r)=>{let i=n,{minimum:a,maximum:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u,isInt:d}=y(e);i.type=d?`integer`:`number`;let f=typeof u==`number`&&u>=(a??-1/0),p=typeof l==`number`&&l<=(s??1/0),m=t.target===`draft-04`||t.target===`openapi-3.0`;if(f?m?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),p?m?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof s==`number`&&(i.maximum=s),c){let n=new Set;for(let a of c)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):(0,o.handleUnrepresentable)(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...s]=n;a!==void 0&&(i.multipleOf=a),s.length&&(i.allOf=[...i.allOf??[],...s.map(e=>({multipleOf:e}))])}},e.booleanProcessor=(e,t,n,r)=>{n.type=`boolean`},e.bigintProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},e.symbolProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},e.nullProcessor=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},e.undefinedProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},e.voidProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`Void cannot be represented in JSON Schema`)},e.neverProcessor=(e,t,n,r)=>{n.not={}},e.anyProcessor=(e,t,n,r)=>{},e.unknownProcessor=(e,t,n,r)=>{},e.dateProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`Date cannot be represented in JSON Schema`)},e.enumProcessor=(e,t,n,r)=>{let i=e._zod.def,a=(0,s.getEnumValues)(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},e.literalProcessor=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let s of i.values)if(s===void 0){if((0,o.handleUnrepresentable)(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==`bigint`){if((0,o.handleUnrepresentable)(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(s))}else a.push(s);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},e.nanProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`NaN cannot be represented in JSON Schema`)},e.templateLiteralProcessor=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},e.fileProcessor=(e,t,n,r)=>{let i=n;i.type=`string`,i.format=`binary`,i.contentEncoding=`binary`;let{minimum:a,maximum:o,mime:s}=y(e);a!==void 0&&(i.minLength=a),o!==void 0&&(i.maxLength=o),s&&(s.length===0?i.not={}:s.length===1?i.contentMediaType=s[0]:i.anyOf=s.map(e=>({contentMediaType:e})))},e.successProcessor=(e,t,n,r)=>{n.type=`boolean`},e.customProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},e.functionProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`Function types cannot be represented in JSON Schema`)},e.transformProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},e.mapProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`Map cannot be represented in JSON Schema`)},e.setProcessor=(e,t,n,r)=>{(0,o.handleUnrepresentable)(e,t,n,r,`Set cannot be represented in JSON Schema`)},e.arrayProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:s,maximum:c}=y(e);typeof s==`number`&&(i.minItems=s),typeof c==`number`&&(i.maxItems=c),i.type=`array`,i.items=(0,o.processSchema)(a.element,t,{...r,path:[...r.path,`items`]})};function C(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?C(t.out):t.type===`catch`?C(t.innerType):e._zod.optin}e.objectProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def,c=a.shape;if(Object.getOwnPropertySymbols(c).length&&(0,o.handleUnrepresentable)(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in c)(0,s.assignProp)(i.properties,e,(0,o.processSchema)(c[e],t,{...r,path:[...r.path,`properties`,e]}));let l=[];for(let e of Object.keys(c)){let n=a.shape[e];(t.io===`input`?C(n)===void 0:n._zod.optout===void 0)&&l.push(e)}l.length>0&&(i.required=l),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=(0,o.processSchema)(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},e.unionProcessor=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,s=i.options.map((e,n)=>(0,o.processSchema)(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=s:n.anyOf=s},e.intersectionProcessor=(e,t,n,r)=>{let i=e._zod.def,a=(0,o.processSchema)(i.left,t,{...r,path:[...r.path,`allOf`,0]}),s=(0,o.processSchema)(i.right,t,{...r,path:[...r.path,`allOf`,1]}),c=e=>`allOf`in e&&Object.keys(e).length===1,l=[...c(a)?a.allOf:[a],...c(s)?s.allOf:[s]];n.allOf=l,t.intersections.push(l)},e.tupleProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let s=t.target===`draft-2020-12`?`prefixItems`:`items`,c=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,l=a.items.map((e,n)=>(0,o.processSchema)(e,t,{...r,path:[...r.path,s,n]})),u=a.rest?(0,o.processSchema)(a.rest,t,{...r,path:[...r.path,c,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,d=a.items.length;for(;d>0;){let e=a.items[d-1];if(!(t.io===`input`?C(e)!==void 0:e._zod.optout===`optional`))break;d--}let f=a.items.length,p=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=l,p?i.items=!1:u&&(i.items=u),d>0&&(i.minItems=d),p&&(i.maxItems=f)):t.target===`openapi-3.0`?(i.items={anyOf:l},u&&i.items.anyOf.push(u),d>0&&(i.minItems=d),p&&(i.maxItems=f)):(i.items=l,p?i.additionalItems=!1:u&&(i.additionalItems=u),d>0&&(i.minItems=d),p&&(i.maxItems=f));let{minimum:m,maximum:h}=y(e);typeof m==`number`&&(i.minItems=m),typeof h==`number`&&(i.maxItems=h)};function w(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=w(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>w(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],a=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),o=t.enum??(t.const===void 0?void 0:[t.const]);if(!a&&!o?.some(e=>typeof e==`number`))return t;let{minimum:s,maximum:c,exclusiveMinimum:l,exclusiveMaximum:u,multipleOf:d,format:f,id:p,...m}=t;return m.enum?m.enum=m.enum.map(e=>typeof e==`number`?String(e):e):typeof m.const==`number`&&(m.const=String(m.const)),a?(m.type=`string`,o||(m.pattern=(r.includes(`number`)?i.number:i.integer).source),m):m}let T=new WeakMap;function E(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of T.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=w(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}e.recordProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let c=a.keyType,l=y(c).patterns;if(a.mode===`loose`&&l&&l.size>0){let e=(0,o.processSchema)(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of l)(0,s.assignProp)(i.patternProperties,S(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=(0,o.processSchema)(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=T.get(t);n||(n=[],T.set(t,n),t.deferred.push(()=>E(t))),n.push(e)}i.additionalProperties=(0,o.processSchema)(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let u=c._zod.values,d=t.io===`input`&&C(a.valueType)!==void 0;if(u&&!a.partial&&!d){let e=[...u].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},e.nullableProcessor=(e,t,n,r)=>{let i=e._zod.def,a=(0,o.processSchema)(i.innerType,t,r),s=t.seen.get(e);t.target===`openapi-3.0`?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},e.nonoptionalProcessor=(e,t,n,r)=>{let i=e._zod.def;(0,o.processSchema)(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType};let D=Symbol();function O(e,t,n,r,i){let a=!1,s=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?((0,o.handleUnrepresentable)(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),D):JSON.parse(s)}e.defaultProcessor=(e,t,n,r)=>{let i=e._zod.def;(0,o.processSchema)(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let s=O(i.defaultValue,e,t,n,r);s!==D&&(n.default=s)},e.prefaultProcessor=(e,t,n,r)=>{let i=e._zod.def;(0,o.processSchema)(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let s=O(i.defaultValue,e,t,n,r);s!==D&&(n._prefault=s)},e.catchProcessor=(e,t,n,r)=>{let i=e._zod.def;(0,o.processSchema)(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{(0,o.handleUnrepresentable)(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=s},e.pipeProcessor=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),s=t.io===`input`?a?i.out:i.in:i.out;(0,o.processSchema)(s,t,r);let c=t.seen.get(e);c.ref=s},e.readonlyProcessor=(e,t,n,r)=>{let i=e._zod.def;(0,o.processSchema)(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},e.promiseProcessor=(e,t,n,r)=>{let i=e._zod.def;(0,o.processSchema)(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},e.optionalProcessor=(e,t,n,r)=>{let i=e._zod.def;(0,o.processSchema)(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},e.lazyProcessor=(e,t,n,r)=>{let i=e._zod.innerType;(0,o.processSchema)(i,t,r);let a=t.seen.get(e);a.ref=i},e.allProcessors={string:e.stringProcessor,number:e.numberProcessor,boolean:e.booleanProcessor,bigint:e.bigintProcessor,symbol:e.symbolProcessor,null:e.nullProcessor,undefined:e.undefinedProcessor,void:e.voidProcessor,never:e.neverProcessor,any:e.anyProcessor,unknown:e.unknownProcessor,date:e.dateProcessor,enum:e.enumProcessor,literal:e.literalProcessor,nan:e.nanProcessor,template_literal:e.templateLiteralProcessor,file:e.fileProcessor,success:e.successProcessor,custom:e.customProcessor,function:e.functionProcessor,transform:e.transformProcessor,map:e.mapProcessor,set:e.setProcessor,array:e.arrayProcessor,object:e.objectProcessor,union:e.unionProcessor,intersection:e.intersectionProcessor,tuple:e.tupleProcessor,record:e.recordProcessor,nullable:e.nullableProcessor,nonoptional:e.nonoptionalProcessor,default:e.defaultProcessor,prefault:e.prefaultProcessor,catch:e.catchProcessor,pipe:e.pipeProcessor,readonly:e.readonlyProcessor,promise:e.promiseProcessor,optional:e.optionalProcessor,lazy:e.lazyProcessor};function k(t,n){if(`_idmap`in t){let r=t,i=(0,o.initializeContext)({...n,processors:e.allProcessors}),a={};for(let e of r._idmap.entries()){let[t,n]=e;(0,o.processSchema)(n,i)}let c={};i.external={registry:r,uri:n?.uri,defs:a};for(let e of r._idmap.entries()){let[t,n]=e;(0,o.extractDefs)(i,n),(0,s.assignProp)(c,t,(0,o.finalize)(i,n))}return Object.keys(a).length>0&&(c.__shared={[i.target===`draft-2020-12`?`$defs`:`definitions`]:a}),{schemas:c}}let r=(0,o.initializeContext)({...n,processors:e.allProcessors});return(0,o.processSchema)(t,r),(0,o.extractDefs)(r,t),(0,o.finalize)(r,t)}(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),Zp=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.JSONSchemaGenerator=void 0;let t=Xp(),n=Yp();e.JSONSchemaGenerator=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let r=e?.target??`draft-2020-12`;r===`draft-4`&&(r=`draft-04`),r===`draft-7`&&(r=`draft-07`),this.ctx=(0,n.initializeContext)({processors:t.allProcessors,target:r,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,t={path:[],schemaPath:[]}){return(0,n.processSchema)(e,this.ctx,t)}emit(e,t){t&&(t.cycles&&(this.ctx.cycles=t.cycles),t.reused&&(this.ctx.reused=t.reused),t.external&&(this.ctx.external=t.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,(0,n.extractDefs)(this.ctx,e);let{"~standard":r,...i}=(0,n.finalize)(this.ctx,e);return i}},(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),Qp=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),$p=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)},i=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.JSONSchema=e.JSONSchemaGenerator=e.toJSONSchema=e.locales=e.regexes=e.toZod=e.util=void 0,r(Df(),e),r(kf(),e),r(Of(),e),r(Pf(),e),r(Ff(),e),r(jf(),e),r(Nf(),e),e.util=i($());var a=$();Object.defineProperty(e,"toZod",{enumerable:!0,get:function(){return a.toZod}}),e.regexes=i(Af()),e.locales=i(Gp()),r(Kp(),e),r(Mf(),e),r(qp(),e),r(Jp(),e),r(Yp(),e);var o=Xp();Object.defineProperty(e,"toJSONSchema",{enumerable:!0,get:function(){return o.toJSONSchema}});var s=Zp();Object.defineProperty(e,"JSONSchemaGenerator",{enumerable:!0,get:function(){return s.JSONSchemaGenerator}}),e.JSONSchema=i(Qp()),(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),em=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.slugify=e.toUpperCase=e.toLowerCase=e.trim=e.normalize=e.overwrite=e.mime=e.properties=e.property=e.endsWith=e.startsWith=e.includes=e.uppercase=e.lowercase=e.regex=e.length=e.minLength=e.maxLength=e.size=e.minSize=e.maxSize=e.multipleOf=e.nonnegative=e.nonpositive=e.negative=e.positive=e.gte=e.gt=e.lte=e.lt=void 0;var t=$p();Object.defineProperty(e,"lt",{enumerable:!0,get:function(){return t._lt}}),Object.defineProperty(e,"lte",{enumerable:!0,get:function(){return t._lte}}),Object.defineProperty(e,"gt",{enumerable:!0,get:function(){return t._gt}}),Object.defineProperty(e,"gte",{enumerable:!0,get:function(){return t._gte}}),Object.defineProperty(e,"positive",{enumerable:!0,get:function(){return t._positive}}),Object.defineProperty(e,"negative",{enumerable:!0,get:function(){return t._negative}}),Object.defineProperty(e,"nonpositive",{enumerable:!0,get:function(){return t._nonpositive}}),Object.defineProperty(e,"nonnegative",{enumerable:!0,get:function(){return t._nonnegative}}),Object.defineProperty(e,"multipleOf",{enumerable:!0,get:function(){return t._multipleOf}}),Object.defineProperty(e,"maxSize",{enumerable:!0,get:function(){return t._maxSize}}),Object.defineProperty(e,"minSize",{enumerable:!0,get:function(){return t._minSize}}),Object.defineProperty(e,"size",{enumerable:!0,get:function(){return t._size}}),Object.defineProperty(e,"maxLength",{enumerable:!0,get:function(){return t._maxLength}}),Object.defineProperty(e,"minLength",{enumerable:!0,get:function(){return t._minLength}}),Object.defineProperty(e,"length",{enumerable:!0,get:function(){return t._length}}),Object.defineProperty(e,"regex",{enumerable:!0,get:function(){return t._regex}}),Object.defineProperty(e,"lowercase",{enumerable:!0,get:function(){return t._lowercase}}),Object.defineProperty(e,"uppercase",{enumerable:!0,get:function(){return t._uppercase}}),Object.defineProperty(e,"includes",{enumerable:!0,get:function(){return t._includes}}),Object.defineProperty(e,"startsWith",{enumerable:!0,get:function(){return t._startsWith}}),Object.defineProperty(e,"endsWith",{enumerable:!0,get:function(){return t._endsWith}}),Object.defineProperty(e,"property",{enumerable:!0,get:function(){return t._property}}),Object.defineProperty(e,"properties",{enumerable:!0,get:function(){return t._properties}}),Object.defineProperty(e,"mime",{enumerable:!0,get:function(){return t._mime}}),Object.defineProperty(e,"overwrite",{enumerable:!0,get:function(){return t._overwrite}}),Object.defineProperty(e,"normalize",{enumerable:!0,get:function(){return t._normalize}}),Object.defineProperty(e,"trim",{enumerable:!0,get:function(){return t._trim}}),Object.defineProperty(e,"toLowerCase",{enumerable:!0,get:function(){return t._toLowerCase}}),Object.defineProperty(e,"toUpperCase",{enumerable:!0,get:function(){return t._toUpperCase}}),Object.defineProperty(e,"slugify",{enumerable:!0,get:function(){return t._slugify}}),(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),tm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.ZodRealError=e.ZodError=void 0;let i=r($p()),a=$p(),o=r($()),s=new WeakSet([Object.prototype,Error.prototype]);function c(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let l=(e,t)=>{a.$ZodError.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);s.has(n)||(s.add(n),c(n,`format`,e=>t=>i.formatError(e,t)),c(n,`flatten`,e=>t=>i.flattenError(e,t)),c(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,o.jsonStringifyReplacer,2)}),c(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,o.jsonStringifyReplacer,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};e.ZodError=i.$constructor(`ZodError`,l),e.ZodRealError=i.$constructor(`ZodError`,l,void 0,{Parent:Error}),(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),nm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.safeDecodeAsync=e.safeEncodeAsync=e.safeDecode=e.safeEncode=e.decodeAsync=e.encodeAsync=e.decode=e.encode=e.validateAsync=e.validate=e.safeParseAsync=e.safeParse=e.parseAsync=e.parse=void 0;let i=r($p()),a=tm();e.parse=i._parse(a.ZodRealError),e.parseAsync=i._parseAsync(a.ZodRealError),e.safeParse=i._safeParse(a.ZodRealError),e.safeParseAsync=i._safeParseAsync(a.ZodRealError);var o=$p();Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return o.validate}}),Object.defineProperty(e,"validateAsync",{enumerable:!0,get:function(){return o.validateAsync}}),e.encode=i._encode(a.ZodRealError),e.decode=i._decode(a.ZodRealError),e.encodeAsync=i._encodeAsync(a.ZodRealError),e.decodeAsync=i._decodeAsync(a.ZodRealError),e.safeEncode=i._safeEncode(a.ZodRealError),e.safeDecode=i._safeDecode(a.ZodRealError),e.safeEncodeAsync=i._safeEncodeAsync(a.ZodRealError),e.safeDecodeAsync=i._safeDecodeAsync(a.ZodRealError),(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),rm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.ZodIntersection=e.ZodDiscriminatedUnion=e.ZodXor=e.ZodUnion=e.ZodObject=e.ZodArray=e.ZodDate=e.ZodVoid=e.ZodNever=e.ZodUnknown=e.ZodAny=e.ZodNull=e.ZodUndefined=e.ZodSymbol=e.ZodBigIntFormat=e.ZodBigInt=e.ZodBoolean=e.ZodNumberFormat=e.ZodNumber=e.ZodCustomStringFormat=e.ZodJWT=e.ZodIBAN=e.ZodCreditCard=e.ZodE164=e.ZodBase64URL=e.ZodBase64=e.ZodCIDRv6=e.ZodCIDRv4=e.ZodIPv6=e.ZodMAC=e.ZodIPv4=e.ZodKSUID=e.ZodXID=e.ZodULID=e.ZodCUID2=e.ZodCUID=e.ZodNanoID=e.ZodEmoji=e.ZodURL=e.ZodUUID=e.ZodGUID=e.ZodEmail=e.ZodISODuration=e.ZodISOTime=e.ZodISODate=e.ZodISODateTime=e.ZodStringFormat=e.ZodString=e._ZodString=e.ZodType=void 0,e.stringbool=e.ZodInstanceOf=e.meta=e.describe=e.ZodCustom=e.ZodFunction=e.ZodPromise=e.ZodLazy=e.ZodTemplateLiteral=e.ZodReadonly=e.ZodPreprocess=e.ZodCodec=e.ZodPipe=e.ZodNaN=e.ZodCatch=e.ZodSuccess=e.ZodNonOptional=e.ZodPrefault=e.ZodDefault=e.ZodNullable=e.ZodExactOptional=e.ZodOptional=e.ZodTransform=e.ZodFile=e.ZodLiteral=e.ZodEnum=e.ZodSet=e.ZodMap=e.ZodRecord=e.ZodTuple=void 0,e.string=h,e.email=g,e.guid=_,e.uuid=v,e.uuidv4=y,e.uuidv6=b,e.uuidv7=x,e.url=S,e.httpUrl=C,e.emoji=w,e.nanoid=T,e.cuid=E,e.cuid2=D,e.ulid=O,e.xid=k,e.ksuid=A,e.ipv4=j,e.mac=M,e.ipv6=N,e.cidrv4=P,e.cidrv6=F,e.base64=I,e.base64url=L,e.e164=R,e.creditCard=z,e.iban=B,e.jwt=V,e.stringFormat=H,e.hostname=U,e.hex=W,e.currencyCode=G,e.hash=ee,e.number=K,e.int=q,e.float32=te,e.float64=ne,e.int32=re,e.uint32=ie,e.boolean=ae,e.bigint=J,e.int64=oe,e.uint64=se,e.symbol=ce,e.undefined=Y,e.null=le,e.any=ue,e.unknown=de,e.never=fe,e.void=pe,e.date=me,e.array=he,e.keyof=ge,e.object=_e,e.strictObject=ve,e.looseObject=ye,e.union=be,e.xor=xe,e.discriminatedUnion=Se,e.intersection=Ce,e.tuple=we,e.record=Te,e.partialRecord=Ee,e.looseRecord=De,e.map=Oe,e.set=ke,e.enum=Ae,e.nativeEnum=je,e.literal=Me,e.file=Ne,e.transform=Pe,e.optional=Fe,e.exactOptional=Ie,e.nullable=Le,e.nullish=Re,e._default=ze,e.prefault=X,e.nonoptional=Be,e.success=Ve,e.catch=He,e.nan=Ue,e.pipe=We,e.codec=Ge,e.invertCodec=Ke,e.readonly=qe,e.templateLiteral=Je,e.lazy=Ye,e.promise=Xe,e._function=Ze,e.function=Ze,e._function=Ze,e.function=Ze,e.check=Qe,e.custom=$e,e.refine=et,e.superRefine=tt,e.instanceof=nt,e.json=rt,e.preprocess=it;let a=r($p()),o=$p(),s=r(Xp()),c=r(Af()),l=Yp(),u=i(qf()),d=r(em()),f=r(nm());function p(){a.globalConfig.localeError||a.config((0,u.default)())}function m(){a.globalConfig.memoizer||a.config({memoizer:a.memoizer()})}e.ZodType=a.$constructor(`ZodType`,(e,t)=>(p(),a.$ZodType.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(o.util.mergeDefs(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return a.clone(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(et(e,t))},superRefine(e,t){return this.check(tt(e,t))},overwrite(e){return this.check(d.overwrite(e))},optional(){return Fe(this)},exactOptional(){return Ie(this)},nullable(){return Le(this)},nullish(){return Fe(Le(this))},nonoptional(e){return Be(this,e)},array(){return he(this)},or(e){return be([this,e])},and(e){return Ce(this,e)},transform(e){return We(this,Pe(e))},default(e){return ze(this,e)},prefault(e){return X(this,e)},catch(e){return He(this,e)},pipe(e){return We(this,e)},readonly(){return qe(this)},describe(e){let t=this.clone();return a.globalRegistry.add(t,{description:e}),t},meta(...e){if(e.length===0)return a.globalRegistry.get(this);let t=this.clone();return a.globalRegistry.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return o.util.hide(this,`~standard`,{...a.standardProps(this),jsonSchema:{input:(0,l.createStandardJSONSchemaMethod)(this,`input`),output:(0,l.createStandardJSONSchemaMethod)(this,`output`)}})},set"~standard"(e){o.util.own(this,`~standard`,e)},parse:function e(t,n){return f.parse(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await f.parseAsync(this,t,n,{callee:e})},safeParse(e,t){return f.safeParse(this,e,t)},async safeParseAsync(e,t){return f.safeParseAsync(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){o.util.own(this,`spa`,e)},validate(e,t){return f.validate(this,e,t)},validateAsync(e,t){return f.validateAsync(this,e,t)},encode:function e(t,n){return f.encode(this,t,n,{callee:e})},decode:function e(t,n){return f.decode(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await f.encodeAsync(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await f.decodeAsync(this,t,n,{callee:e})},safeEncode(e,t){return f.safeEncode(this,e,t)},safeDecode(e,t){return f.safeDecode(this,e,t)},async safeEncodeAsync(e,t){return f.safeEncodeAsync(this,e,t)},async safeDecodeAsync(e,t){return f.safeDecodeAsync(this,e,t)},toJSONSchema(e){return(0,l.createToJSONSchemaMethod)(this,{})(e)},get description(){return a.globalRegistry.get(this)?.description},get _def(){return this._zod.def}}),e._ZodString=a.$constructor(`_ZodString`,(t,n)=>{a.$ZodString.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.stringProcessor(t,e,n,r)},o.util.derived({format:e=>s.aggregateChecks(e).format??null,minLength:e=>s.aggregateChecks(e).minimum??null,maxLength:e=>s.aggregateChecks(e).maximum??null},{regex(...e){return this.check(d.regex(...e))},includes(...e){return this.check(d.includes(...e))},startsWith(...e){return this.check(d.startsWith(...e))},endsWith(...e){return this.check(d.endsWith(...e))},min(...e){return this.check(d.minLength(...e))},max(...e){return this.check(d.maxLength(...e))},length(...e){return this.check(d.length(...e))},nonempty(...e){return this.check(d.minLength(1,...e))},lowercase(e){return this.check(d.lowercase(e))},uppercase(e){return this.check(d.uppercase(e))},trim(){return this.check(d.trim())},normalize(...e){return this.check(d.normalize(...e))},toLowerCase(){return this.check(d.toLowerCase())},toUpperCase(){return this.check(d.toUpperCase())},slugify(){return this.check(d.slugify())}})),e.ZodString=a.$constructor(`ZodString`,(t,n)=>{a.$ZodString.init(t,n),e._ZodString.init(t,n)},{email(t){return this.check(a._email(e.ZodEmail,t))},url(t){return this.check(a._url(e.ZodURL,t))},jwt(t){return this.check(a._jwt(e.ZodJWT,t))},emoji(t){return this.check(a._emoji(e.ZodEmoji,t))},guid(t){return this.check(a._guid(e.ZodGUID,t))},uuid(t){return this.check(a._uuid(e.ZodUUID,t))},uuidv4(t){return this.check(a._uuidv4(e.ZodUUID,t))},uuidv6(t){return this.check(a._uuidv6(e.ZodUUID,t))},uuidv7(t){return this.check(a._uuidv7(e.ZodUUID,t))},nanoid(t){return this.check(a._nanoid(e.ZodNanoID,t))},cuid(t){return this.check(a._cuid(e.ZodCUID,t))},cuid2(t){return this.check(a._cuid2(e.ZodCUID2,t))},ulid(t){return this.check(a._ulid(e.ZodULID,t))},base64(t){return this.check(a._base64(e.ZodBase64,t))},base64url(t){return this.check(a._base64url(e.ZodBase64URL,t))},xid(t){return this.check(a._xid(e.ZodXID,t))},ksuid(t){return this.check(a._ksuid(e.ZodKSUID,t))},ipv4(t){return this.check(a._ipv4(e.ZodIPv4,t))},ipv6(t){return this.check(a._ipv6(e.ZodIPv6,t))},cidrv4(t){return this.check(a._cidrv4(e.ZodCIDRv4,t))},cidrv6(t){return this.check(a._cidrv6(e.ZodCIDRv6,t))},e164(t){return this.check(a._e164(e.ZodE164,t))},datetime(t){return this.check(a._isoDateTime(e.ZodISODateTime,t))},date(t){return this.check(a._isoDate(e.ZodISODate,t))},time(t){return this.check(a._isoTime(e.ZodISOTime,t))},duration(t){return this.check(a._isoDuration(e.ZodISODuration,t))}});function h(t){return a._string(e.ZodString,t)}e.ZodStringFormat=a.$constructor(`ZodStringFormat`,(t,n)=>{a.$ZodStringFormat.init(t,n),e._ZodString.init(t,n)}),e.ZodISODateTime=a.$constructor(`ZodISODateTime`,(t,n)=>{a.$ZodISODateTime.init(t,n),e.ZodStringFormat.init(t,n)}),e.ZodISODate=a.$constructor(`ZodISODate`,(t,n)=>{a.$ZodISODate.init(t,n),e.ZodStringFormat.init(t,n)}),e.ZodISOTime=a.$constructor(`ZodISOTime`,(t,n)=>{a.$ZodISOTime.init(t,n),e.ZodStringFormat.init(t,n)}),e.ZodISODuration=a.$constructor(`ZodISODuration`,(t,n)=>{a.$ZodISODuration.init(t,n),e.ZodStringFormat.init(t,n)}),e.ZodEmail=a.$constructor(`ZodEmail`,(t,n)=>{a.$ZodEmail.init(t,n),e.ZodStringFormat.init(t,n)});function g(t){return a._email(e.ZodEmail,t)}e.ZodGUID=a.$constructor(`ZodGUID`,(t,n)=>{a.$ZodGUID.init(t,n),e.ZodStringFormat.init(t,n)});function _(t){return a._guid(e.ZodGUID,t)}e.ZodUUID=a.$constructor(`ZodUUID`,(t,n)=>{a.$ZodUUID.init(t,n),e.ZodStringFormat.init(t,n)});function v(t){return a._uuid(e.ZodUUID,t)}function y(t){return a._uuidv4(e.ZodUUID,t)}function b(t){return a._uuidv6(e.ZodUUID,t)}function x(t){return a._uuidv7(e.ZodUUID,t)}e.ZodURL=a.$constructor(`ZodURL`,(t,n)=>{a.$ZodURL.init(t,n),e.ZodStringFormat.init(t,n)});function S(t){return a._url(e.ZodURL,t)}function C(t){return a._url(e.ZodURL,{protocol:c.httpProtocol,hostname:c.domain,...o.util.normalizeParams(t)})}e.ZodEmoji=a.$constructor(`ZodEmoji`,(t,n)=>{a.$ZodEmoji.init(t,n),e.ZodStringFormat.init(t,n)});function w(t){return a._emoji(e.ZodEmoji,t)}e.ZodNanoID=a.$constructor(`ZodNanoID`,(t,n)=>{a.$ZodNanoID.init(t,n),e.ZodStringFormat.init(t,n)});function T(t){return a._nanoid(e.ZodNanoID,t)}e.ZodCUID=a.$constructor(`ZodCUID`,(t,n)=>{a.$ZodCUID.init(t,n),e.ZodStringFormat.init(t,n)});function E(t){return a._cuid(e.ZodCUID,t)}e.ZodCUID2=a.$constructor(`ZodCUID2`,(t,n)=>{a.$ZodCUID2.init(t,n),e.ZodStringFormat.init(t,n)});function D(t){return a._cuid2(e.ZodCUID2,t)}e.ZodULID=a.$constructor(`ZodULID`,(t,n)=>{a.$ZodULID.init(t,n),e.ZodStringFormat.init(t,n)});function O(t){return a._ulid(e.ZodULID,t)}e.ZodXID=a.$constructor(`ZodXID`,(t,n)=>{a.$ZodXID.init(t,n),e.ZodStringFormat.init(t,n)});function k(t){return a._xid(e.ZodXID,t)}e.ZodKSUID=a.$constructor(`ZodKSUID`,(t,n)=>{a.$ZodKSUID.init(t,n),e.ZodStringFormat.init(t,n)});function A(t){return a._ksuid(e.ZodKSUID,t)}e.ZodIPv4=a.$constructor(`ZodIPv4`,(t,n)=>{a.$ZodIPv4.init(t,n),e.ZodStringFormat.init(t,n)});function j(t){return a._ipv4(e.ZodIPv4,t)}e.ZodMAC=a.$constructor(`ZodMAC`,(t,n)=>{a.$ZodMAC.init(t,n),e.ZodStringFormat.init(t,n)});function M(t){return a._mac(e.ZodMAC,t)}e.ZodIPv6=a.$constructor(`ZodIPv6`,(t,n)=>{a.$ZodIPv6.init(t,n),e.ZodStringFormat.init(t,n)});function N(t){return a._ipv6(e.ZodIPv6,t)}e.ZodCIDRv4=a.$constructor(`ZodCIDRv4`,(t,n)=>{a.$ZodCIDRv4.init(t,n),e.ZodStringFormat.init(t,n)});function P(t){return a._cidrv4(e.ZodCIDRv4,t)}e.ZodCIDRv6=a.$constructor(`ZodCIDRv6`,(t,n)=>{a.$ZodCIDRv6.init(t,n),e.ZodStringFormat.init(t,n)});function F(t){return a._cidrv6(e.ZodCIDRv6,t)}e.ZodBase64=a.$constructor(`ZodBase64`,(t,n)=>{a.$ZodBase64.init(t,n),e.ZodStringFormat.init(t,n)});function I(t){return a._base64(e.ZodBase64,t)}e.ZodBase64URL=a.$constructor(`ZodBase64URL`,(t,n)=>{a.$ZodBase64URL.init(t,n),e.ZodStringFormat.init(t,n)});function L(t){return a._base64url(e.ZodBase64URL,t)}e.ZodE164=a.$constructor(`ZodE164`,(t,n)=>{a.$ZodE164.init(t,n),e.ZodStringFormat.init(t,n)});function R(t){return a._e164(e.ZodE164,t)}e.ZodCreditCard=a.$constructor(`ZodCreditCard`,(t,n)=>{a.$ZodCreditCard.init(t,n),e.ZodStringFormat.init(t,n)});function z(t){return a._creditCard(e.ZodCreditCard,t)}e.ZodIBAN=a.$constructor(`ZodIBAN`,(t,n)=>{a.$ZodIBAN.init(t,n),e.ZodStringFormat.init(t,n)});function B(t){return a._iban(e.ZodIBAN,t)}e.ZodJWT=a.$constructor(`ZodJWT`,(t,n)=>{a.$ZodJWT.init(t,n),e.ZodStringFormat.init(t,n)});function V(t){return a._jwt(e.ZodJWT,t)}e.ZodCustomStringFormat=a.$constructor(`ZodCustomStringFormat`,(t,n)=>{a.$ZodCustomStringFormat.init(t,n),e.ZodStringFormat.init(t,n)});function H(t,n,r={}){return a._stringFormat(e.ZodCustomStringFormat,t,n,r)}function U(t){return a._stringFormat(e.ZodCustomStringFormat,`hostname`,c.hostname,t)}function W(t){return a._stringFormat(e.ZodCustomStringFormat,`hex`,c.hex,t)}function G(t){return a._stringFormat(e.ZodCustomStringFormat,`currency_code`,c.currencyCode,t)}function ee(t,n){let r=`${t}_${n?.enc??`hex`}`,i=a.regexes[r];if(!i)throw Error(`Unrecognized hash format: ${r}`);return a._stringFormat(e.ZodCustomStringFormat,r,i,n)}e.ZodNumber=a.$constructor(`ZodNumber`,(t,n)=>{a.$ZodNumber.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.numberProcessor(t,e,n,r),t.isFinite=!0},o.util.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=s.aggregateChecks(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=s.aggregateChecks(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=s.aggregateChecks(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>s.aggregateChecks(e).format??null},{gt(e,t){return this.check(d.gt(e,t))},gte(e,t){return this.check(d.gte(e,t))},min(e,t){return this.check(d.gte(e,t))},lt(e,t){return this.check(d.lt(e,t))},lte(e,t){return this.check(d.lte(e,t))},max(e,t){return this.check(d.lte(e,t))},int(e){return this.check(q(e))},safe(e){return this.check(q(e))},positive(e){return this.check(d.gt(0,e))},nonnegative(e){return this.check(d.gte(0,e))},negative(e){return this.check(d.lt(0,e))},nonpositive(e){return this.check(d.lte(0,e))},multipleOf(e,t){return this.check(d.multipleOf(e,t))},step(e,t){return this.check(d.multipleOf(e,t))},finite(){return this}}));function K(t){return a._number(e.ZodNumber,t)}e.ZodNumberFormat=a.$constructor(`ZodNumberFormat`,(t,n)=>{a.$ZodNumberFormat.init(t,n),e.ZodNumber.init(t,n)});function q(t){return a._int(e.ZodNumberFormat,t)}function te(t){return a._float32(e.ZodNumberFormat,t)}function ne(t){return a._float64(e.ZodNumberFormat,t)}function re(t){return a._int32(e.ZodNumberFormat,t)}function ie(t){return a._uint32(e.ZodNumberFormat,t)}e.ZodBoolean=a.$constructor(`ZodBoolean`,(t,n)=>{a.$ZodBoolean.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.booleanProcessor(t,e,n,r)});function ae(t){return a._boolean(e.ZodBoolean,t)}e.ZodBigInt=a.$constructor(`ZodBigInt`,(t,n)=>{a.$ZodBigInt.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.bigintProcessor(t,e,n,r)},o.util.derived({minValue:e=>s.aggregateChecks(e).minimum??null,maxValue:e=>s.aggregateChecks(e).maximum??null,format:e=>s.aggregateChecks(e).format??null},{gte(e,t){return this.check(d.gte(e,t))},min(e,t){return this.check(d.gte(e,t))},gt(e,t){return this.check(d.gt(e,t))},lt(e,t){return this.check(d.lt(e,t))},lte(e,t){return this.check(d.lte(e,t))},max(e,t){return this.check(d.lte(e,t))},positive(e){return this.check(d.gt(BigInt(0),e))},negative(e){return this.check(d.lt(BigInt(0),e))},nonpositive(e){return this.check(d.lte(BigInt(0),e))},nonnegative(e){return this.check(d.gte(BigInt(0),e))},multipleOf(e,t){return this.check(d.multipleOf(e,t))}}));function J(t){return a._bigint(e.ZodBigInt,t)}e.ZodBigIntFormat=a.$constructor(`ZodBigIntFormat`,(t,n)=>{a.$ZodBigIntFormat.init(t,n),e.ZodBigInt.init(t,n)});function oe(t){return a._int64(e.ZodBigIntFormat,t)}function se(t){return a._uint64(e.ZodBigIntFormat,t)}e.ZodSymbol=a.$constructor(`ZodSymbol`,(t,n)=>{a.$ZodSymbol.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.symbolProcessor(t,e,n,r)});function ce(t){return a._symbol(e.ZodSymbol,t)}e.ZodUndefined=a.$constructor(`ZodUndefined`,(t,n)=>{a.$ZodUndefined.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.undefinedProcessor(t,e,n,r)});function Y(t){return a._undefined(e.ZodUndefined,t)}e.ZodNull=a.$constructor(`ZodNull`,(t,n)=>{a.$ZodNull.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.nullProcessor(t,e,n,r)});function le(t){return a._null(e.ZodNull,t)}e.ZodAny=a.$constructor(`ZodAny`,(t,n)=>{a.$ZodAny.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.anyProcessor(t,e,n,r)});function ue(){return a._any(e.ZodAny)}e.ZodUnknown=a.$constructor(`ZodUnknown`,(t,n)=>{a.$ZodUnknown.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.unknownProcessor(t,e,n,r)});function de(){return a._unknown(e.ZodUnknown)}e.ZodNever=a.$constructor(`ZodNever`,(t,n)=>{a.$ZodNever.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.neverProcessor(t,e,n,r)});function fe(t){return a._never(e.ZodNever,t)}e.ZodVoid=a.$constructor(`ZodVoid`,(t,n)=>{a.$ZodVoid.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.voidProcessor(t,e,n,r)});function pe(t){return a._void(e.ZodVoid,t)}e.ZodDate=a.$constructor(`ZodDate`,(t,n)=>{a.$ZodDate.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.dateProcessor(t,e,n,r),t.min=(e,n)=>t.check(d.gte(e,n)),t.max=(e,n)=>t.check(d.lte(e,n))},o.util.derived({minDate:e=>{let{minimum:t}=s.aggregateChecks(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=s.aggregateChecks(e);return t?new Date(t):null}},{}));function me(t){return a._date(e.ZodDate,t)}e.ZodArray=a.$constructor(`ZodArray`,(t,n)=>{m(),a.$ZodArray.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.arrayProcessor(t,e,n,r),t.element=n.element},{min(e,t){return this.check(d.minLength(e,t))},nonempty(e){return this.check(d.minLength(1,e))},max(e,t){return this.check(d.maxLength(e,t))},length(e,t){return this.check(d.length(e,t))},unwrap(){return this.element}});function he(t,n){return a._array(e.ZodArray,t,n)}function ge(e){let t=e._zod.def.shape;return Ae(Object.keys(t))}e.ZodObject=a.$constructor(`ZodObject`,(t,n)=>{m(),a.$ZodObjectJIT.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.objectProcessor(t,e,n,r),o.util.installLazyProp(t,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ae(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(o.util.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(o.util.mergeDefs(this._zod.def,{catchall:de()}))},loose(){return this.clone(o.util.mergeDefs(this._zod.def,{catchall:de()}))},strict(){return this.clone(o.util.mergeDefs(this._zod.def,{catchall:fe()}))},strip(){return this.clone(o.util.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return o.util.extend(this,e)},safeExtend(e){return o.util.safeExtend(this,e)},merge(e){return o.util.merge(this,e)},pick(e){return o.util.pick(this,e)},omit(e){return o.util.omit(this,e)},partial(...t){return o.util.partial(e.ZodOptional,this,t[0])},exactPartial(...t){return o.util.partial(e.ZodExactOptional,this,t[0],`exactPartial`)},required(...t){return o.util.required(e.ZodNonOptional,this,t[0])}});function _e(t,n){let r={type:`object`,shape:t??{},...o.util.normalizeParams(n)};return new e.ZodObject(r)}function ve(t,n){return new e.ZodObject({type:`object`,shape:t,catchall:fe(),...o.util.normalizeParams(n)})}function ye(t,n){return new e.ZodObject({type:`object`,shape:t,catchall:de(),...o.util.normalizeParams(n)})}e.ZodUnion=a.$constructor(`ZodUnion`,(t,n)=>{a.$ZodUnion.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.unionProcessor(t,e,n,r),t.options=n.options});function be(t,n){return new e.ZodUnion({type:`union`,options:t,...o.util.normalizeParams(n)})}e.ZodXor=a.$constructor(`ZodXor`,(t,n)=>{e.ZodUnion.init(t,n),a.$ZodXor.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.unionProcessor(t,e,n,r),t.options=n.options});function xe(t,n){return new e.ZodXor({type:`union`,options:t,inclusive:!1,...o.util.normalizeParams(n)})}e.ZodDiscriminatedUnion=a.$constructor(`ZodDiscriminatedUnion`,(t,n)=>{e.ZodUnion.init(t,n),a.$ZodDiscriminatedUnion.init(t,n)});function Se(t,n,r){return new e.ZodDiscriminatedUnion({type:`union`,options:n,discriminator:t,...o.util.normalizeParams(r)})}e.ZodIntersection=a.$constructor(`ZodIntersection`,(t,n)=>{a.$ZodIntersection.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.intersectionProcessor(t,e,n,r)});function Ce(t,n){return new e.ZodIntersection({type:`intersection`,left:t,right:n})}e.ZodTuple=a.$constructor(`ZodTuple`,(t,n)=>{m(),a.$ZodTuple.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.tupleProcessor(t,e,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let t=this._zod.def;if(t.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...t,items:t.items.map(t=>new e.ZodOptional({type:`optional`,innerType:t}))})}});function we(t,n,r){let i=n instanceof a.$ZodType,s=i?r:n,c=i?n:null;return new e.ZodTuple({type:`tuple`,items:t,rest:c,...o.util.normalizeParams(s)})}e.ZodRecord=a.$constructor(`ZodRecord`,(t,n)=>{m(),a.$ZodRecord.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.recordProcessor(t,e,n,r),t.keyType=n.keyType,t.valueType=n.valueType});function Te(t,n,r){return!n||!n._zod?new e.ZodRecord({type:`record`,keyType:h(),valueType:t,...o.util.normalizeParams(n)}):new e.ZodRecord({type:`record`,keyType:t,valueType:n,...o.util.normalizeParams(r)})}function Ee(t,n,r){return new e.ZodRecord({type:`record`,keyType:t,valueType:n,...o.util.normalizeParams(r),partial:!0})}function De(t,n,r){return new e.ZodRecord({type:`record`,keyType:t,valueType:n,mode:`loose`,...o.util.normalizeParams(r)})}e.ZodMap=a.$constructor(`ZodMap`,(t,n)=>{m(),a.$ZodMap.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.mapProcessor(t,e,n,r),t.keyType=n.keyType,t.valueType=n.valueType,t.min=(...e)=>t.check(a._minSize(...e)),t.nonempty=e=>t.check(a._minSize(1,e)),t.max=(...e)=>t.check(a._maxSize(...e)),t.size=(...e)=>t.check(a._size(...e))});function Oe(t,n,r){return new e.ZodMap({type:`map`,keyType:t,valueType:n,...o.util.normalizeParams(r)})}e.ZodSet=a.$constructor(`ZodSet`,(t,n)=>{m(),a.$ZodSet.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.setProcessor(t,e,n,r),t.min=(...e)=>t.check(a._minSize(...e)),t.nonempty=e=>t.check(a._minSize(1,e)),t.max=(...e)=>t.check(a._maxSize(...e)),t.size=(...e)=>t.check(a._size(...e))});function ke(t,n){return new e.ZodSet({type:`set`,valueType:t,...o.util.normalizeParams(n)})}e.ZodEnum=a.$constructor(`ZodEnum`,(t,n)=>{a.$ZodEnum.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.enumProcessor(t,e,n,r),t.enum=n.entries,t.options=[...t._zod.values];let r=new Set(Object.keys(n.entries));t.extract=(t,i)=>{let a={};for(let e of t)if(r.has(e))a[e]=n.entries[e];else throw Error(`Key ${e} not found in enum`);return new e.ZodEnum({...n,checks:[],...o.util.normalizeParams(i),entries:a})},t.exclude=(t,i)=>{let a={...n.entries};for(let e of t)if(r.has(e))delete a[e];else throw Error(`Key ${e} not found in enum`);return new e.ZodEnum({...n,checks:[],...o.util.normalizeParams(i),entries:a})}});function Ae(t,n){let r=Array.isArray(t)?Object.fromEntries(t.map(e=>[e,e])):t;return new e.ZodEnum({type:`enum`,entries:r,...o.util.normalizeParams(n)})}function je(t,n){return new e.ZodEnum({type:`enum`,entries:t,...o.util.normalizeParams(n)})}e.ZodLiteral=a.$constructor(`ZodLiteral`,(t,n)=>{a.$ZodLiteral.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.literalProcessor(t,e,n,r),t.values=new Set(n.values),Object.defineProperty(t,"value",{get(){if(n.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function Me(t,n){return new e.ZodLiteral({type:`literal`,values:Array.isArray(t)?t:[t],...o.util.normalizeParams(n)})}e.ZodFile=a.$constructor(`ZodFile`,(t,n)=>{a.$ZodFile.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.fileProcessor(t,e,n,r),t.min=(e,n)=>t.check(a._minSize(e,n)),t.max=(e,n)=>t.check(a._maxSize(e,n)),t.mime=(e,n)=>t.check(a._mime(Array.isArray(e)?e:[e],n))});function Ne(t){return a._file(e.ZodFile,t)}e.ZodTransform=a.$constructor(`ZodTransform`,(t,n)=>{m(),a.$ZodTransform.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.transformProcessor(t,e,n,r),t._zod.parse=(e,r)=>{if(r.direction===`backward`)throw new a.$ZodEncodeError(t.constructor.name);e.addIssue=r=>{if(typeof r==`string`)e.issues.push(o.util.issue(r,e.value,n));else{let n=r;n.fatal&&(n.continue=!1),n.code??=`custom`,`input`in n||(n.input=e.value),n.inst??=t,e.issues.push(o.util.issue(n))}};let i=n.transform(e.value,e);return i instanceof Promise?i.then(t=>(e.value=t,e)):(e.value=i,e)}});function Pe(t){return new e.ZodTransform({type:`transform`,transform:t})}e.ZodOptional=a.$constructor(`ZodOptional`,(t,n)=>{a.$ZodOptional.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.optionalProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType});function Fe(t){return new e.ZodOptional({type:`optional`,innerType:t})}e.ZodExactOptional=a.$constructor(`ZodExactOptional`,(t,n)=>{a.$ZodExactOptional.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.optionalProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType});function Ie(t){return new e.ZodExactOptional({type:`optional`,innerType:t})}e.ZodNullable=a.$constructor(`ZodNullable`,(t,n)=>{a.$ZodNullable.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.nullableProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType});function Le(t){return new e.ZodNullable({type:`nullable`,innerType:t})}function Re(e){return Fe(Le(e))}e.ZodDefault=a.$constructor(`ZodDefault`,(t,n)=>{a.$ZodDefault.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.defaultProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function ze(t,n){return new e.ZodDefault({type:`default`,innerType:t,get defaultValue(){return typeof n==`function`?n():o.util.shallowClone(n)}})}e.ZodPrefault=a.$constructor(`ZodPrefault`,(t,n)=>{a.$ZodPrefault.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.prefaultProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType});function X(t,n){return new e.ZodPrefault({type:`prefault`,innerType:t,get defaultValue(){return typeof n==`function`?n():o.util.shallowClone(n)}})}e.ZodNonOptional=a.$constructor(`ZodNonOptional`,(t,n)=>{a.$ZodNonOptional.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.nonoptionalProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType});function Be(t,n){return new e.ZodNonOptional({type:`nonoptional`,innerType:t,...o.util.normalizeParams(n)})}e.ZodSuccess=a.$constructor(`ZodSuccess`,(t,n)=>{a.$ZodSuccess.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.successProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType});function Ve(t){return new e.ZodSuccess({type:`success`,innerType:t})}e.ZodCatch=a.$constructor(`ZodCatch`,(t,n)=>{a.$ZodCatch.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.catchProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function He(t,n){return new e.ZodCatch({type:`catch`,innerType:t,catchValue:typeof n==`function`?n:a.util.constantCatch(n)})}e.ZodNaN=a.$constructor(`ZodNaN`,(t,n)=>{a.$ZodNaN.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.nanProcessor(t,e,n,r)});function Ue(t){return a._nan(e.ZodNaN,t)}e.ZodPipe=a.$constructor(`ZodPipe`,(t,n)=>{a.$ZodPipe.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.pipeProcessor(t,e,n,r),t.in=n.in,t.out=n.out});function We(t,n){return new e.ZodPipe({type:`pipe`,in:t,out:n})}e.ZodCodec=a.$constructor(`ZodCodec`,(t,n)=>{e.ZodPipe.init(t,n),a.$ZodCodec.init(t,n)});function Ge(t,n,r){return new e.ZodCodec({type:`pipe`,in:t,out:n,transform:r.decode,reverseTransform:r.encode})}function Ke(t){let n=t._zod.def;return new e.ZodCodec({type:`pipe`,in:n.out,out:n.in,transform:n.reverseTransform,reverseTransform:n.transform})}e.ZodPreprocess=a.$constructor(`ZodPreprocess`,(t,n)=>{e.ZodPipe.init(t,n),a.$ZodPreprocess.init(t,n)}),e.ZodReadonly=a.$constructor(`ZodReadonly`,(t,n)=>{a.$ZodReadonly.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.readonlyProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType});function qe(t){return new e.ZodReadonly({type:`readonly`,innerType:t})}e.ZodTemplateLiteral=a.$constructor(`ZodTemplateLiteral`,(t,n)=>{a.$ZodTemplateLiteral.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.templateLiteralProcessor(t,e,n,r)});function Je(t,n){return new e.ZodTemplateLiteral({type:`template_literal`,parts:t,...o.util.normalizeParams(n)})}e.ZodLazy=a.$constructor(`ZodLazy`,(t,n)=>{a.$ZodLazy.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.lazyProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.getter()});function Ye(t){return new e.ZodLazy({type:`lazy`,getter:t})}e.ZodPromise=a.$constructor(`ZodPromise`,(t,n)=>{a.$ZodPromise.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.promiseProcessor(t,e,n,r),t.unwrap=()=>t._zod.def.innerType});function Xe(t){return new e.ZodPromise({type:`promise`,innerType:t})}e.ZodFunction=a.$constructor(`ZodFunction`,(t,n)=>{a.$ZodFunction.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.functionProcessor(t,e,n,r)});function Ze(t){return new e.ZodFunction({type:`function`,input:Array.isArray(t?.input)?we(t?.input):t?.input??he(de()),output:t?.output??de()})}e.ZodCustom=a.$constructor(`ZodCustom`,(t,n)=>{a.$ZodCustom.init(t,n),e.ZodType.init(t,n),t._zod.processJSONSchema=(e,n,r)=>s.customProcessor(t,e,n,r)});function Qe(e){let t=new a.$ZodCheck({check:`custom`});return t._zod.check=e,t}function $e(t,n){return a._custom(e.ZodCustom,t??(()=>!0),n)}function et(t,n={}){return a._refine(e.ZodCustom,t,n)}function tt(e,t){return a._superRefine(e,t)}e.describe=a.describe,e.meta=a.meta,e.ZodInstanceOf=a.$constructor(`ZodInstanceOf`,(t,n)=>{e.ZodCustom.init(t,n)},{properties(e,t){return this.check(a._properties(e,t))}});function nt(t,n={}){let r=new e.ZodInstanceOf({type:`custom`,check:`custom`,fn:e=>e instanceof t,abort:!0,...o.util.normalizeParams(n)});return r._zod.bag.Class=t,r._zod.check=e=>{e.value instanceof t||e.issues.push({code:`invalid_type`,expected:t.name,input:e.value,inst:r,path:[...r._zod.def.path??[]]})},r}e.stringbool=(...t)=>a._stringbool({Codec:e.ZodCodec,Boolean:e.ZodBoolean,String:e.ZodString},...t);function rt(e){let t=Ye(()=>be([h(e),K(),ae(),le(),he(t),Te(h(),t)]));return t}function it(t,n){return new e.ZodPreprocess({type:`pipe`,in:Pe(t),out:n})}(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),im=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.ZodFirstPartyTypeKind=e.config=e.$brand=e.ZodIssueCode=void 0,e.setErrorMap=o,e.getErrorMap=s;let i=r($p());e.ZodIssueCode={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};var a=$p();Object.defineProperty(e,"$brand",{enumerable:!0,get:function(){return a.$brand}}),Object.defineProperty(e,"config",{enumerable:!0,get:function(){return a.config}});function o(e){i.config({customError:e})}function s(){return i.config().customError}var c;c||(e.ZodFirstPartyTypeKind=c={}),(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),am=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.ZodISOTime=e.ZodISODuration=e.ZodISODateTime=e.ZodISODate=void 0,e.datetime=s,e.date=c,e.time=l,e.duration=u;let i=r($p()),a=rm();var o=rm();Object.defineProperty(e,"ZodISODate",{enumerable:!0,get:function(){return o.ZodISODate}}),Object.defineProperty(e,"ZodISODateTime",{enumerable:!0,get:function(){return o.ZodISODateTime}}),Object.defineProperty(e,"ZodISODuration",{enumerable:!0,get:function(){return o.ZodISODuration}}),Object.defineProperty(e,"ZodISOTime",{enumerable:!0,get:function(){return o.ZodISOTime}});function s(e){return i._isoDateTime(a.ZodISODateTime,e)}function c(e){return i._isoDate(a.ZodISODate,e)}function l(e){return i._isoTime(a.ZodISOTime,e)}function u(e){return i._isoDuration(a.ZodISODuration,e)}(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),om=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.fromJSONSchema=T;let i=Kp(),a=$(),o=r(em()),s=r(am()),c={...r(rm()),...o,iso:s},l=new Set(`$schema.$ref.$defs.definitions.$id.id.$comment.$anchor.$vocabulary.$dynamicRef.$dynamicAnchor.type.enum.const.anyOf.oneOf.allOf.not.properties.required.additionalProperties.patternProperties.propertyNames.minProperties.maxProperties.items.prefixItems.additionalItems.minItems.maxItems.uniqueItems.contains.minContains.maxContains.minLength.maxLength.pattern.format.minimum.maximum.exclusiveMinimum.exclusiveMaximum.multipleOf.description.default.contentEncoding.contentMediaType.contentSchema.unevaluatedItems.unevaluatedProperties.if.then.else.dependentSchemas.dependentRequired.nullable.readOnly`.split(`.`));function u(e,t){let n=e.$schema;return n===`https://json-schema.org/draft/2020-12/schema`?`draft-2020-12`:n===`http://json-schema.org/draft-07/schema#`?`draft-7`:n===`http://json-schema.org/draft-04/schema#`?`draft-4`:t??`draft-2020-12`}function d(e,t){return e.map((e,n)=>n<t?e:e.optional())}function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function p(e,t){if(!e.startsWith(`#`))throw Error(`External $ref is not supported, only local refs (#/...) are allowed`);let n=e.slice(1).split(`/`).filter(Boolean);if(n.length===0)return t.rootSchema;let r=t.version===`draft-2020-12`?`$defs`:`definitions`;if(n[0]===r){let r=n[1]===void 0?void 0:f(n[1]);if(!r||!t.defs[r])throw Error(`Reference not found: ${e}`);return t.defs[r]}throw Error(`Reference not found: ${e}`)}function m(e,t){return c.transform(e=>e).check(n=>{let r=n.value;if(typeof r!=`object`||!r||Array.isArray(r))return;let i=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&i.length<t.minProperties&&n.issues.push({origin:`object`,code:`too_small`,minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&n.issues.push({origin:`object`,code:`too_big`,maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let e of i){let r=t.keySchema.safeParse(e);r.success||n.issues.push({code:`invalid_key`,origin:`record`,issues:r.error.issues,input:e,path:[e],continue:!0})}}).pipe(e)}function h(e,t){if(e===null)return`z`;let n=typeof e;if(n!==`object`){if(n===`number`&&Number.isNaN(e))return null;let t=String(e);return`${n[0]}${t.length}:${t}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let n=[];for(let r of e){let e=h(r,t);if(e===null)return null;n.push(e)}return`a${n.length}:[${n.join(`,`)}]`}let n=Object.keys(e).sort(),r=[];for(let i of n){let n=h(e[i],t);if(n===null)return null;r.push(`${i.length}:${i}=${n}`)}return`o${r.length}:{${r.join(`,`)}}`}finally{t.delete(e)}}let g=new Set([`items`,`prefixItems`,`additionalItems`,`additionalProperties`,`contains`,`propertyNames`,`not`,`if`,`then`,`else`,`allOf`,`anyOf`,`oneOf`,`unevaluatedItems`,`unevaluatedProperties`,`contentSchema`]),_=new Set([`properties`,`patternProperties`,`dependentSchemas`,`dependencies`,`$defs`,`definitions`]);function v(e){return typeof e!=`object`||!e?!1:Array.isArray(e)?e.some(v):typeof e.$ref==`string`||Object.entries(e).some(([e,t])=>g.has(e)?v(t):!_.has(e)||typeof t!=`object`||!t?!1:Object.values(t).some(v))}function y(e){return e===1?`element`:`elements`}function b(e,t){return c.transform(e=>e).check(e=>{let n=e.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let t=new Map;for(let r=0;r<n.length;r++){let i=h(n[r],new Set);if(i===null)continue;let a=t.get(i);if(a===void 0){t.set(i,r);continue}e.issues.push({code:`custom`,message:`Array items must be unique: element at index ${r} duplicates the one at index ${a}`,input:n,path:[r],continue:!0})}}if(t.containsSchema){let r=t.minContains??1,i=t.maxContains===void 0?1/0:t.maxContains+1,a=0;for(let e of n)if(t.containsSchema.safeParse(e).success&&++a>=i)break;a<r&&e.issues.push({code:`custom`,message:`Array must contain at least ${r} matching ${y(r)}; found ${a}`,input:n,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&e.issues.push({code:`custom`,message:`Array must contain at most ${t.maxContains} matching ${y(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function x(e,t){if(e!==!1)return e===void 0||e===!0?c.any():w(e,t)}let S=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function C(e,t){if(e.not!==void 0){if(typeof e.not==`object`&&Object.keys(e.not).length===0)return c.never();throw Error(`not is not supported in Zod (except { not: {} } for never)`)}if(e.unevaluatedItems!==void 0)throw Error(`unevaluatedItems is not supported`);if(e.unevaluatedProperties!==void 0)throw Error(`unevaluatedProperties is not supported`);if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error(`Conditional schemas (if/then/else) are not supported`);if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error(`dependentSchemas and dependentRequired are not supported`);if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return c.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let r=w(p(n,t),t);return t.refs.set(n,r),t.processing.delete(n),r}if(e.enum!==void 0){let n=e.enum;if(t.version===`openapi-3.0`&&e.nullable===!0&&n.length===1&&n[0]===null)return c.null();if(n.length===0)return c.never();if(n.length===1)return c.literal(n[0]);if(n.every(e=>typeof e==`string`))return c.enum(n);let r=n.map(e=>c.literal(e));return r.length<2?r[0]:c.union([r[0],r[1],...r.slice(2)])}if(e.const!==void 0)return c.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(n=>C({...e,type:n},t));return r.length===0?c.never():r.length===1?r[0]:c.union(r)}if(!n)return c.any();let r;switch(n){case`string`:{let t=c.string();if(e.format){let n=e.format;n===`email`?t=t.check(c.email()):n===`uri`||n===`uri-reference`?t=t.check(c.url()):n===`uuid`||n===`guid`?t=t.check(c.uuid()):n===`date-time`?t=t.check(c.iso.datetime({offset:!0})):n===`date`?t=t.check(c.iso.date()):n===`time`?t=t.check(c.regex(S)):n===`duration`?t=t.check(c.iso.duration()):n===`hostname`?t=t.check(c.hostname()):n===`ipv4`?t=t.check(c.ipv4()):n===`ipv6`?t=t.check(c.ipv6()):n===`mac`?t=t.check(c.mac()):n===`cidr`?t=t.check(c.cidrv4()):n===`cidr-v6`?t=t.check(c.cidrv6()):n===`base64`?t=t.check(c.base64()):n===`base64url`?t=t.check(c.base64url()):n===`e164`?t=t.check(c.e164()):n===`credit_card`?t=t.check(c.creditCard()):n===`iban`?t=t.check(c.iban()):n===`jwt`?t=t.check(c.jwt()):n===`emoji`?t=t.check(c.emoji()):n===`nanoid`?t=t.check(c.nanoid()):n===`cuid`?t=t.check(c.cuid()):n===`cuid2`?t=t.check(c.cuid2()):n===`ulid`?t=t.check(c.ulid()):n===`xid`?t=t.check(c.xid()):n===`ksuid`&&(t=t.check(c.ksuid()))}typeof e.minLength==`number`&&(t=t.min(e.minLength)),typeof e.maxLength==`number`&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),r=t;break}case`number`:case`integer`:{let t=n===`integer`?c.number().int():c.number();typeof e.minimum==`number`&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum==`number`&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum==`number`?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum==`number`&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum==`number`?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum==`number`&&(t=t.lt(e.maximum)),typeof e.multipleOf==`number`&&(t=t.multipleOf(e.multipleOf)),r=t;break}case`boolean`:r=c.boolean();break;case`null`:r=c.null();break;case`object`:{let n={},i=e.properties||{},o=new Set(e.required||[]),s=typeof e.additionalProperties==`object`?w(e.additionalProperties,t):void 0;for(let[e,r]of Object.entries(i)){let i=w(r,t);(0,a.assignProp)(n,e,o.has(e)?i:i.optional())}if(e.patternProperties){let i=e.patternProperties,o=Object.keys(i),s=[];for(let e of o){let n=w(i[e],t),r=c.string().regex(new RegExp(e));s.push(c.looseRecord(r,n))}let l=[];if(Object.keys(n).length>0&&l.push(c.object(n).passthrough()),l.push(...s),l.length===0)r=c.object({}).passthrough();else if(l.length===1)r=l[0];else{let e=c.intersection(l[0],l[1]);for(let t=2;t<l.length;t++)e=c.intersection(e,l[t]);r=e}if(e.additionalProperties===!1){let e=Object.keys(n),t=o.map(e=>new RegExp(e)),i=r;r=r.check(n=>{if(!(0,a.isPlainObject)(n.value))return;let r=[];for(let i of Object.keys(n.value))e.includes(i)||t.some(e=>e.test(i))||r.push(i);r.length&&n.issues.push({code:`unrecognized_keys`,keys:r,input:n.value,inst:i})})}}else{let t=c.object(n);r=e.additionalProperties===!1?t.strict():s?t.catchall(s):t.passthrough()}let l=e.propertyNames!==void 0&&e.propertyNames!==!0,u=typeof e.minProperties==`number`?e.minProperties:void 0,d=typeof e.maxProperties==`number`?e.maxProperties:void 0;if(l||u!==void 0||d!==void 0){let n;l&&(n=w(typeof e.propertyNames==`object`&&e.propertyNames.type===void 0?{type:`string`,...e.propertyNames}:e.propertyNames,t)),r=m(r,{keySchema:n,minProperties:u,maxProperties:d})}break}case`array`:{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems==`number`?e.minItems:0,o=d(n.map(e=>w(e,t)),a),s=Array.isArray(i)?void 0:x(i,t),l=c.tuple(o);r=s?l.rest(s):l,typeof e.minItems==`number`&&(r=r.check(c.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(c.maxLength(e.maxItems)))}else if(Array.isArray(i)){let n=typeof e.minItems==`number`?e.minItems:0,a=d(i.map(e=>w(e,t)),n),o=x(e.additionalItems,t),s=c.tuple(a);r=o?s.rest(o):s,typeof e.minItems==`number`&&(r=r.check(c.minLength(e.minItems))),typeof e.maxItems==`number`&&(r=r.check(c.maxLength(e.maxItems)))}else if(i!==void 0){let n=w(i,t),a=c.array(n);typeof e.minItems==`number`&&(a=a.min(e.minItems)),typeof e.maxItems==`number`&&(a=a.max(e.maxItems)),r=a}else r=c.array(c.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=b(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains===void 0?void 0:w(e.contains,t),minContains:typeof e.minContains==`number`?e.minContains:void 0,maxContains:typeof e.maxContains==`number`?e.maxContains:void 0}));break}default:throw Error(`Unsupported type: ${n}`)}return r}function w(e,t){if(typeof e==`boolean`)return e?c.any():c.never();let n=C(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let i=e.anyOf.map(e=>w(e,t)),a=c.union(i);n=r?c.intersection(n,a):a}if(e.oneOf&&Array.isArray(e.oneOf)){let i=e.oneOf.map(e=>w(e,t)),a=c.xor(i);n=r?c.intersection(n,a):a}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:c.any();else{let i=r?n:w(e.allOf[0],t),a=+!r;for(let n=a;n<e.allOf.length;n++)i=c.intersection(i,w(e.allOf[n],t));n=i}e.nullable===!0&&t.version===`openapi-3.0`&&(n=c.nullable(n)),e.readOnly===!0&&(n=c.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let i={};for(let t of[`$id`,`id`,`$comment`,`$anchor`,`$vocabulary`,`$dynamicRef`,`$dynamicAnchor`])t in e&&(i[t]=e[t]);for(let t of[`contentEncoding`,`contentMediaType`,`contentSchema`])t in e&&(i[t]=e[t]);if(e.type===`object`&&e.$ref===void 0){e.propertyNames!==void 0&&!v(e.propertyNames)&&(i.propertyNames=e.propertyNames);for(let t of[`minProperties`,`maxProperties`])e[t]!==void 0&&(i[t]=e[t])}if(e.type===`array`&&e.$ref===void 0){e.contains!==void 0&&!v(e.contains)&&(i.contains=e.contains);for(let t of[`uniqueItems`,`minContains`,`maxContains`])e[t]!==void 0&&(i[t]=e[t])}for(let t of Object.keys(e))l.has(t)||(0,a.assignProp)(i,t,e[t]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function T(e,t){if(typeof e==`boolean`)return e?c.any():c.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw Error(`fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas`)}let r={version:u(n,t?.defaultTarget),defs:n.$defs||n.definitions||{},refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??i.globalRegistry};return w(n,r)}(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),sm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.visit=s;let i=r(Pf()),a=$(),o=Symbol(`z.visit/resolving`);function s(e,t){let n=typeof t==`function`?t:(e,n)=>{let r=t[e._zod.def.type];return r?r(e,n):e},r=new Map;function s(e){let t=r.get(e);if(t===o)return new i.$ZodLazy({type:`lazy`,getter:()=>r.get(e)});if(t!==void 0)return t;r.set(e,o);let a=c(e),s=n(a,a!==e);return r.set(e,s),s}function c(e){let t=e._zod.def;switch(t.type){case`object`:{let n=t.shape,r=Object.keys(n),i=!1,o={};for(let e of r){let t=s(n[e]);t!==n[e]&&(i=!0),o[e]=t}let c=t.catchall;return t.catchall&&(c=s(t.catchall),c!==t.catchall&&(i=!0)),i?(0,a.clone)(e,{...t,shape:o,catchall:c}):e}case`array`:{let n=s(t.element);return n===t.element?e:(0,a.clone)(e,{...t,element:n})}case`tuple`:{let n=t.items,r=!1,i=[];for(let e of n){let t=s(e);t!==e&&(r=!0),i.push(t)}let o=t.rest;return t.rest&&(o=s(t.rest),o!==t.rest&&(r=!0)),r?(0,a.clone)(e,{...t,items:i,rest:o}):e}case`record`:case`map`:{let n=s(t.keyType),r=s(t.valueType);return n===t.keyType&&r===t.valueType?e:(0,a.clone)(e,{...t,keyType:n,valueType:r})}case`set`:{let n=s(t.valueType);return n===t.valueType?e:(0,a.clone)(e,{...t,valueType:n})}case`union`:{let n=t.options,r=!1,i=[];for(let e of n){let t=s(e);t!==e&&(r=!0),i.push(t)}return r?(0,a.clone)(e,{...t,options:i}):e}case`intersection`:{let n=s(t.left),r=s(t.right);return n===t.left&&r===t.right?e:(0,a.clone)(e,{...t,left:n,right:r})}case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:{let n=s(t.innerType);return n===t.innerType?e:(0,a.clone)(e,{...t,innerType:n})}case`pipe`:{let n=s(t.in),r=s(t.out);return n===t.in&&r===t.out?e:(0,a.clone)(e,{...t,in:n,out:r})}case`function`:{let n=s(t.input),r=s(t.output);return n===t.input&&r===t.output?e:(0,a.clone)(e,{...t,input:n,output:r})}case`lazy`:{let n=t.getter,{_cachedInner:r,...i}=t;return(0,a.clone)(e,{...i,getter:()=>s(n())})}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:return e;default:return e}}return s(e)}(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),cm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.deepPartial=o;let i=sm(),a=r(rm());function o(e){return(0,i.visit)(e,{object:e=>e.partial(),union:e=>{let t=e._zod.def;return t.discriminator===void 0?e:a.union(t.options)}})}(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),lm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.input=u,e.output=d;let i=$(),a=sm(),o=r(rm());function s(e,t){if(!t?.length)return e;let n=e._zod.def;return(0,i.clone)(e,(0,i.mergeDefs)(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function c(e){return s(e.out,e.checks)}function l(e){return e.in._zod.traits.has(`$ZodTransform`)?c(e):e.in}function u(e){return(0,a.visit)(e,{pipe:e=>l(e._zod.def),default:(e,t)=>t?o.optional(e._zod.def.innerType):e,catch:(e,t)=>t?e._zod.def.innerType:e})}function d(e){return(0,a.visit)(e,{pipe:e=>c(e._zod.def),prefault:(e,t)=>t?e._zod.def.innerType:e})}(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),um=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.string=o,e.number=s,e.boolean=c,e.bigint=l,e.date=u;let i=r($p()),a=r(rm());function o(e){return i._coercedString(a.ZodString,e)}function s(e){return i._coercedNumber(a.ZodNumber,e)}function c(e){return i._coercedBoolean(a.ZodBoolean,e)}function l(e){return i._coercedBigint(a.ZodBigInt,e)}function u(e){return i._coercedDate(a.ZodDate,e)}(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),dm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.coerce=e.iso=e.ZodISODuration=e.ZodISOTime=e.ZodISODate=e.ZodISODateTime=e.locales=e.output=e.input=e.deepPartial=e.fromJSONSchema=e.toJSONSchema=e.getDiscriminatedOption=e.ZodCompileUnsupportedError=e.ZodCompileAsyncError=e.withParser=e.compile=e.toZod=e.INVALID=e.NEVER=e.util=e.TimePrecision=e.flattenError=e.formatError=e.prettifyError=e.treeifyError=e.regexes=e.clone=e.$brand=e.$input=e.$output=e.memoizer=e.config=e.registry=e.globalRegistry=e.core=void 0,e.core=r($p()),i(rm(),e),i(em(),e),i(tm(),e),i(nm(),e),i(im(),e);var a=$p();Object.defineProperty(e,"globalRegistry",{enumerable:!0,get:function(){return a.globalRegistry}}),Object.defineProperty(e,"registry",{enumerable:!0,get:function(){return a.registry}}),Object.defineProperty(e,"config",{enumerable:!0,get:function(){return a.config}}),Object.defineProperty(e,"memoizer",{enumerable:!0,get:function(){return a.memoizer}}),Object.defineProperty(e,"$output",{enumerable:!0,get:function(){return a.$output}}),Object.defineProperty(e,"$input",{enumerable:!0,get:function(){return a.$input}}),Object.defineProperty(e,"$brand",{enumerable:!0,get:function(){return a.$brand}}),Object.defineProperty(e,"clone",{enumerable:!0,get:function(){return a.clone}}),Object.defineProperty(e,"regexes",{enumerable:!0,get:function(){return a.regexes}}),Object.defineProperty(e,"treeifyError",{enumerable:!0,get:function(){return a.treeifyError}}),Object.defineProperty(e,"prettifyError",{enumerable:!0,get:function(){return a.prettifyError}}),Object.defineProperty(e,"formatError",{enumerable:!0,get:function(){return a.formatError}}),Object.defineProperty(e,"flattenError",{enumerable:!0,get:function(){return a.flattenError}}),Object.defineProperty(e,"TimePrecision",{enumerable:!0,get:function(){return a.TimePrecision}}),Object.defineProperty(e,"util",{enumerable:!0,get:function(){return a.util}}),Object.defineProperty(e,"NEVER",{enumerable:!0,get:function(){return a.NEVER}}),Object.defineProperty(e,"INVALID",{enumerable:!0,get:function(){return a.INVALID}}),Object.defineProperty(e,"toZod",{enumerable:!0,get:function(){return a.toZod}}),Object.defineProperty(e,"compile",{enumerable:!0,get:function(){return a.compile}}),Object.defineProperty(e,"withParser",{enumerable:!0,get:function(){return a.withParser}}),Object.defineProperty(e,"ZodCompileAsyncError",{enumerable:!0,get:function(){return a.ZodCompileAsyncError}}),Object.defineProperty(e,"ZodCompileUnsupportedError",{enumerable:!0,get:function(){return a.ZodCompileUnsupportedError}}),Object.defineProperty(e,"getDiscriminatedOption",{enumerable:!0,get:function(){return a.getDiscriminatedOption}});var o=Xp();Object.defineProperty(e,"toJSONSchema",{enumerable:!0,get:function(){return o.toJSONSchema}});var s=om();Object.defineProperty(e,"fromJSONSchema",{enumerable:!0,get:function(){return s.fromJSONSchema}});var c=cm();Object.defineProperty(e,"deepPartial",{enumerable:!0,get:function(){return c.deepPartial}});var l=lm();Object.defineProperty(e,"input",{enumerable:!0,get:function(){return l.input}}),Object.defineProperty(e,"output",{enumerable:!0,get:function(){return l.output}}),e.locales=r(Gp());var u=am();Object.defineProperty(e,"ZodISODateTime",{enumerable:!0,get:function(){return u.ZodISODateTime}}),Object.defineProperty(e,"ZodISODate",{enumerable:!0,get:function(){return u.ZodISODate}}),Object.defineProperty(e,"ZodISOTime",{enumerable:!0,get:function(){return u.ZodISOTime}}),Object.defineProperty(e,"ZodISODuration",{enumerable:!0,get:function(){return u.ZodISODuration}}),e.iso=r(am()),e.coerce=r(um()),(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),fm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.z=void 0;let a=r(dm());e.z=a,e.default=a,i(dm(),e),(function(){for(var t=Object.getOwnPropertyNames(e),n=0;n<t.length;n++){var r=Object.getOwnPropertyDescriptor(e,t[n]);if(!(!r||!r.get||!r.configurable)){var i;try{i=r.get()}catch{continue}i!==void 0&&Object.defineProperty(e,t[n],{value:i,writable:!1,enumerable:r.enumerable,configurable:!1})}}Object.freeze(e)})()})),pm=s((e=>{var t=e&&e.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};Object.defineProperty(e,"__esModule",{value:!0}),e.serializeSchema=e.toJsonSchema=e.isZodSchema=void 0;let n=fm();e.isZodSchema=e=>typeof e==`object`&&!!e&&`_zod`in e&&typeof e.parse==`function`,e.toJsonSchema=r=>{if(!(0,e.isZodSchema)(r))return r;let i=(0,n.toJSONSchema)(r,{io:`input`,reused:`inline`}),{$schema:a}=i;return t(i,[`$schema`])},e.serializeSchema=t=>JSON.stringify((0,e.toJsonSchema)(t))})),mm=s((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.convertServerFunctionDefinition=e.convertServerFunction=e.convertConfigurationInit=e.selectConnections=e.convertIntegrationConfiguration=void 0;let n=Jn(),r=hr(),i=an(),a=Ef(),o=pm(),s=_m();e.convertIntegrationConfiguration=(t,i={})=>{let{instance:a,userLevel:s,init:c,serverFunctions:l={}}=t,u=(e,t)=>{if(!e||e.schema===void 0)throw Error(`configuration.${t}.schema is required.`);if(!e.version)throw Error(`configuration.${t}.version is required.`);return Object.assign(Object.assign({schema:(0,o.toJsonSchema)(e.schema),version:e.version},e.ui?{ui:e.ui}:{}),e.versionSchemas?{versionSchemas:Object.fromEntries(Object.entries(e.versionSchemas).filter(([t])=>t!==e.version).map(([e,t])=>[e,(0,o.toJsonSchema)(t)]))}:{})},d=u(a,`instance`),f=s?u(s,`userLevel`):void 0,p=[...Object.entries(a.connections??{}).map(([e,t])=>{if((0,r.isUserScopedConnectionConfigVar)(t))throw Error(`Instance connection "${e}" cannot be user activated.`);return[`instance.${e}`,t]}),...Object.entries(s?.connections??{}).map(([e,t])=>{if((0,r.isOrgOrCustomerActivatedConnection)(t))throw Error(`User-level connection "${e}" must be user activated or integration-defined.`);return[`userLevel.${e}`,t]})],{scopedConfigVars:m,componentConnections:h}=p.reduce((e,[t,i])=>{if((0,r.isConnectionScopedConfigVar)(i))e.scopedConfigVars[t]=i;else if((0,n.isConnectionDefinitionConfigVar)(i)||(0,n.isConnectionReferenceConfigVar)(i))e.componentConnections[t]=i;else throw Error(`Invalid configuration connection: "${t}"`);return e},{scopedConfigVars:Object.create(null),componentConnections:Object.create(null)}),g=p.reduce((e,[t])=>{if(!t.slice(t.indexOf(`.`)+1))throw Error(`Configuration connection name must not be empty: "${t}"`);return e[t]=t,e},Object.create(null)),_=Object.entries(l),v=_.reduce((t,[n,r])=>(t[n]=(0,e.convertServerFunction)(r,g,i),t),Object.create(null));return Object.assign(Object.assign(Object.assign(Object.assign({configuration:Object.assign({instance:d},f?{userLevel:f}:{})},c?{componentConfiguration:{init:Object.assign({perform:(0,e.convertConfigurationInit)(c.perform,(0,e.selectConnections)(c.connections,g))},c.connections?.length?{connections:[...c.connections]}:{})},configurationInit:c.connections?.length?{connections:[...c.connections]}:{}}:{}),{scopedConfigVars:m,componentConnections:h,connectionNames:g,userLevelConnectionNames:p.map(([e])=>e).filter(e=>e.startsWith(`userLevel.`))}),_.length?{serverFunctions:v}:{}),{serverFunctionDefinitions:_.map(([t,n])=>(0,e.convertServerFunctionDefinition)(t,n))})};let c={};e.selectConnections=(e,t)=>Object.fromEntries((e??[]).map(e=>{if(!Object.hasOwn(t,e))throw Error(`Undeclared configuration connection: "${e}"`);return[e,t[e]]}));let l=e=>e?.configurationVersion,u=e=>e?.configVars??{},d=(e,t)=>({logger:t.logger,customer:t.customer,instance:t.instance,user:t.user,configVars:u(e)});e.convertConfigurationInit=(e,n=c)=>r=>t(void 0,void 0,void 0,function*(){let t=l(r)??null,o=u(r),s=(0,a.createConfigurationContext)(r,n);return(0,i.runWithDataSourceContext)(d(r,s),()=>e(Object.assign(s,{configurationVersion:t,configVars:o})))}),e.convertServerFunction=(n,r=c,o={})=>{let l=(0,e.selectConnections)(n.connections,r);return(e,r)=>t(void 0,void 0,void 0,function*(){let t=(0,a.createConfigurationContext)(e,l);return(0,i.runWithDataSourceContext)(d(e,t),()=>n.perform(Object.assign(t,{components:(0,s.createComponentMethods)(e,o)}),r))})},e.convertServerFunctionDefinition=(e,{inputSchema:t,outputSchema:n,connections:r,label:i,description:a})=>Object.assign({key:e,display:{label:i??e,description:a??``},inputSchema:(0,o.serializeSchema)(t),outputSchema:(0,o.serializeSchema)(n)},r?.length?{connections:[...r]}:{})})),hm=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DefinitionVersion=void 0,e.DefinitionVersion=7})),gm=s((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.invokeTriggerComponentInput=e.convertConfigVar=e.convertInputValue=e.convertFlow=e.convertQueueConfig=e.convertConfigPages=e.convertIntegration=e.CONCURRENCY_LIMIT_MIN=e.CONCURRENCY_LIMIT_MAX=void 0;let i=require("node:crypto"),a=require("fs"),o=r(Ru()),s=r(nd()),c=r(Sn()),l=r(id()),u=r(require("path")),d=r(Cf()),f=Sr(),p=an(),m=Tf(),h=Cn(),g=wn(),_=Ef(),v=_m(),y=xm(),b=mm(),x=hm(),S=vm();e.CONCURRENCY_LIMIT_MAX=15,e.CONCURRENCY_LIMIT_MIN=2;let C=e=>{e=(0,h.normalizeBoundTrigger)(e);let t=`trigger`in e?e.trigger:void 0;if(!t)return e;let{onTrigger:r,onDeploy:i}=t,a=e,{trigger:o}=a,s=n(a,[`trigger`]);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),{onTrigger:(0,m.wrapBatchedFire)((0,m.withPollingState)((e,t)=>(0,p.invokeWithContext)(e,r,t)))}),i?{onDeployTrigger:(0,m.wrapBatchedFire)((0,m.withPollingState)((e,t)=>(0,p.invokeWithContext)(e,i,t)))}:{}),{triggerResolver:m.defaultBatchResolver}),i?{onDeployResolver:m.defaultBatchResolver}:{})};e.convertIntegration=e=>{let t=e,n=(0,i.randomUUID)();if(t.configuration&&(t.configPages||t.userLevelConfigPages||t.scopedConfigVars))throw Error("An integration must not define both `configuration` (function-backed) and `configPages` (declared).");for(let{name:e,schedule:n}of t.flows)if(n){if(t.configuration&&`configVar`in n)throw Error(`${e} uses a config variable schedule, but an integration with \`configuration\` has no config variables. Use \`{ value }\` or \`{ fromDeployer: true }\`.`);if(!t.configuration&&n.fromDeployer)throw Error(`${e} has a schedule from the deployer, which only an integration with \`configuration\` supports.`)}let r=t.configuration?(0,b.convertIntegrationConfiguration)(t.configuration,t.componentRegistry):void 0;r&&(t=Object.assign(Object.assign({},t),{scopedConfigVars:Object.assign(Object.assign({},t.scopedConfigVars??{}),r.scopedConfigVars)}));let o=t.scopedConfigVars??{},c=Object.values({configPages:t.configPages??{},userLevelConfigPages:t.userLevelConfigPages??{}}).reduce((e,t)=>Object.assign(Object.assign({},e),Object.values(t).reduce((e,t)=>Object.entries(t.elements).reduce((e,[t,n])=>{if(typeof n==`string`)return e;if(t in e||t in o)throw Error(`Duplicate config var key: "${t}"`);return Object.assign(Object.assign({},e),{[t]:n})},e),{})),Object.assign({},r?.componentConnections??{})),l={},d=new Map;for(let[e,t]of Object.entries(c)){if(!(0,f.isConnectionDefinitionConfigVar)(t))continue;let n=(0,s.default)(e),r=d.get(n);if(!n||r)throw Error(`Generated connection key collision: "${e}" and "${r??``}" normalize to "${n}".`);d.set(n,e)}try{let e=u.default.join(`..`,`.spectral`,`metadata.json`),t=(0,a.readFileSync)(e,{encoding:`utf-8`});l=JSON.parse(t)}catch{}let p=se(t,n,c,r?.connectionNames),m=T(t,n,c,l,r?.configuration,r?.userLevelConnectionNames),h=ce(t);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},p),r?.componentConfiguration?{configuration:r.componentConfiguration}:{}),r?.configurationInit?{configurationInit:r.configurationInit}:{}),r?.serverFunctions?{serverFunctions:r.serverFunctions,serverFunctionDefinitions:r.serverFunctionDefinitions}:{}),{codeNativeIntegrationYAML:m,publishingMetadata:h})};let w=e=>(0,f.isOrgOrCustomerActivatedConnection)(e);e.convertConfigPages=(e,t)=>{if(!e||!Object.keys(e).length)return[];if(!t){let t=Object.entries(e).flatMap(([e,{elements:t}])=>Object.entries(t).filter(([e,t])=>(0,f.isUserScopedConnectionConfigVar)(t)).map(([t])=>`"${t}" on config page "${e}"`));if(t.length)throw Error(`A user-activated connection is activated by each person individually, so it belongs on a user level config page. Move ${t.join(`, `)}.`)}if(t){let t=Object.entries(e).flatMap(([e,{elements:t}])=>Object.entries(t).filter(([e,t])=>w(t)).map(([t])=>`"${t}" on user level config page "${e}"`));if(t.length)throw Error(`A connection activated once by the organization or the customer does not belong on a user level config page, which asks each person for their own. Move ${t.join(`, `)}.`)}return Object.entries(e).map(([e,{tagline:n,elements:r}])=>Object.assign(Object.assign({name:e,tagline:n},t?{userLevelConfigured:t}:{}),{elements:Object.entries(r).filter(([e,t])=>!(0,f.isOrgOrCustomerActivatedConnection)(t)).map(([e,t])=>typeof t==`string`?{type:`htmlElement`,value:t}:t&&typeof t==`object`&&`dataType`in t&&t.dataType===`htmlElement`?{type:`htmlElement`,value:e}:{type:`configVar`,value:e})}))};let T=({name:t,description:n,category:r,documentation:i,version:a,labels:o,endpointType:s,triggerPreprocessFlowConfig:c,flows:l,configPages:u,userLevelConfigPages:p,scopedConfigVars:m,instanceProfile:h,componentRegistry:g={}},_,v,y,b,S=[])=>{let w=l.map(e=>C(e)),T=w.filter(e=>e.preprocessFlowConfig);if(T.length>1)throw Error(`Only one flow may define a Preprocess Flow Config.`);if(T.length&&c)throw Error(`Integration must not define both a Trigger Preprocess Flow Config and a Preprocess Flow.`);let E=T.length>0,D=E?T[0].preprocessFlowConfig:c;if([`instance_specific`,`shared_instance`].includes(s||`flow_specific`)&&!D)throw Error(`Integration with specified EndpointType must define either a Trigger Preprocess Flow Config or a Preprocess Flow.`);let O=Object.entries(m??{}).reduce((e,[t,n])=>typeof n==`string`?e:Object.assign(Object.assign({},e),{[t]:n}),Object.assign({},v??{})),k=[];Object.entries(O).forEach(([t,n])=>{(0,f.isHtmlElementConfigVar)(n)||k.push(Object.assign(Object.assign({},(0,e.convertConfigVar)(t,n,_,g)),S.includes(t)?{userLevelConfigured:!0}:{}))});let A=Object.assign(Object.assign(Object.assign({definitionVersion:x.DefinitionVersion,isCodeNative:!0,name:t,description:n,category:r,documentation:i,version:a,labels:o,requiredConfigVars:k,endpointType:s,preprocessFlowName:E?T[0].name:void 0,externalCustomerIdField:q(E?`onExecution`:`payload`,D?.externalCustomerIdField),externalCustomerUserIdField:q(E?`onExecution`:`payload`,D?.externalCustomerUserIdField),flowNameField:q(E?`onExecution`:`payload`,D?.flowNameField),flows:w.map(t=>(0,e.convertFlow)(t,g,_))},h&&{defaultInstanceProfile:h}),b?{configuration:b}:{configPages:[...(0,e.convertConfigPages)(u,!1),...(0,e.convertConfigPages)(p,!0)]}),{importMetadata:y});return d.default.stringify(A)},E={customer:{orgOnly:!1,visibleToOrgDeployer:!0,visibleToCustomerDeployer:!0},embedded:{orgOnly:!1,visibleToOrgDeployer:!0,visibleToCustomerDeployer:!1},organization:{orgOnly:!0,visibleToOrgDeployer:!0,visibleToCustomerDeployer:!1}},D=({permissionAndVisibilityType:e=`customer`,visibleToOrgDeployer:t=!0})=>Object.assign(Object.assign({},E[e]),t===void 0?{}:{visibleToOrgDeployer:t}),O=({permissionAndVisibilityType:e,visibleToOrgDeployer:t})=>D({permissionAndVisibilityType:e,visibleToOrgDeployer:t}),k=({permissionAndVisibilityType:e,visibleToOrgDeployer:t})=>{let{orgOnly:n,visibleToCustomerDeployer:r,visibleToOrgDeployer:i}=D({permissionAndVisibilityType:e,visibleToOrgDeployer:t});return{orgOnly:n,meta:{visibleToCustomerDeployer:r,visibleToOrgDeployer:i}}},A=e=>typeof e==`object`&&!!e,j=e=>Array.isArray(e)?e.map(e=>{if(!A(e)||!(`key`in e))throw Error(`Key-value list entries must be objects with a "key": ${JSON.stringify(e)}`);return[String(e.key),`value`in e?e.value:void 0]}):Object.entries(e),M=(e,t)=>e===`keyvaluelist`&&A(t)?j(t).map(([e,t])=>({name:{type:`value`,value:e},type:`value`,value:JSON.stringify(t)})):e===`valuelist`&&Array.isArray(t)?t.map(e=>({type:`value`,value:e})):t,N=e=>A(e)&&`configVar`in e?{configVar:String(e.configVar)}:A(e)&&`value`in e?{value:e.value}:{value:e},P=(e,t)=>Object.entries(e).reduce((e,[n,r])=>{let i=r,a=!!i.collection,o=t?.[n]??{value:a?i.default===``?[]:i.default:i.default??``},s=a?`complex`:`value`in o?`value`:`configVar`;if(`value`in o){let t=M(i.collection,o.value),r=s===`complex`||typeof t==`string`?t:JSON.stringify(t),a=O({permissionAndVisibilityType:`permissionAndVisibilityType`in o?o.permissionAndVisibilityType:void 0,visibleToOrgDeployer:`visibleToOrgDeployer`in o?o.visibleToOrgDeployer:void 0});return`writeOnly`in o&&o.writeOnly&&(a.writeOnly=o.writeOnly),Object.assign(Object.assign({},e),{[n]:{type:s,value:r,meta:a}})}return`configVar`in o?Object.assign(Object.assign({},e),{[n]:{type:`configVar`,value:o.configVar}}):`template`in o?Object.assign(Object.assign({},e),{[n]:{type:`template`,value:o.template}}):e},{}),F=e=>Object.fromEntries(Object.entries(e).filter(([,e])=>e.shown!==!1)),I=(e,t,n)=>{let r=(0,g.getPublishedConnection)(e);if(r)return{ref:{component:r.component,key:e.key},inputs:P(F(r.inputs),e.values)};let i=t[e.component];if(!i)throw Error(`Component with key "${e.component}" not found in component registry.`);let a=i[n][e.key];if(!a)throw Error(`Component with key "${e.component}" does not have an entry with key "${e.key}" in the component registry.`);return{ref:{component:{key:i.key,signature:i.signature??``,isPublic:i.public},key:a.key??e.key},inputs:P(a.inputs,e.values)}},L=(e,t)=>{let n=Object.values(e).map(({key:e,public:t,signature:n})=>Object.assign({key:e,isPublic:t},n?{signature:n}:{version:`LATEST`}));return t&&n.push({key:`${t}-triggers`,isPublic:!0,version:`LATEST`}),n},R=(e,t)=>t[e.component]?.triggers[e.key],z=(e,t)=>{let n=t?.dynamicBranchInput,r=n?e[n]:void 0;if(!n||r?.type!==`complex`||!Array.isArray(r.value))return e;let i=r.value.map(e=>typeof e.name==`object`&&e.name.type===`value`?Object.assign(Object.assign({},e),{name:e.name.value}):e);return Object.assign(Object.assign({},e),{[n]:Object.assign(Object.assign({},r),{value:i})})},B=(e,t)=>{let n=R(e,t);return n?.allowsBranching?Object.assign({allowsBranching:!0,staticBranchNames:[...n.staticBranchNames??[]]},n.dynamicBranchInput?{dynamicBranchInput:n.dynamicBranchInput}:{}):{}},V=(e,t,n)=>{if(!e?.allowsBranching)return;let r=e.dynamicBranchInput?t?.[e.dynamicBranchInput]:void 0;if(r?.type===`configVar`)throw Error(`The trigger of flow "${n}" branches on its "${e.dynamicBranchInput}" input, which is bound to a config variable. Publishing requires the branch names in the integration, so give "${e.dynamicBranchInput}" a value in code instead.`);let i=r?.type===`complex`&&Array.isArray(r.value)?r.value.flatMap(e=>typeof e.name==`string`?[e.name]:[]):[];return[...new Set([...e.staticBranchNames??[],...i])].map(e=>({name:e,steps:[]}))},H=e=>{if(!e||!(`dynamicBranchInput`in e.definition)||!e.definition.dynamicBranchInput)return;let t=e.definition.dynamicBranchInput,n=e.definition.inputs[t];if(!n)throw Error(`Dynamic branch input "${t}" is not defined on the trigger.`);let r=e.bindings[t],i=typeof r==`object`&&r?r:void 0;if(i&&`configVar`in i)return{input:(0,y.convertInput)(t,n),value:{type:`configVar`,value:String(i.configVar)}};let a=i&&`value`in i?i.value:r,o=a===void 0?`default`in n?n.default:void 0:a,s=e=>typeof e==`string`?e:JSON.stringify(e),c=n.collection===`keyvaluelist`?(Array.isArray(o)?o:Object.entries(typeof o==`object`&&o?o:{}).map(([e,t])=>({key:e,value:t}))).map(({key:e,value:t})=>({name:e,type:`value`,value:s(t)})):n.collection===`valuelist`?(Array.isArray(o)?o:[]).map(e=>({type:`value`,value:s(e)})):void 0;return{input:(0,y.convertInput)(t,n),value:c?{type:`complex`,value:c}:{type:`value`,value:s(o??``)}}},U=e=>({key:e,version:`LATEST`,isPublic:!1}),W=e=>typeof e.onTrigger==`function`||e.onInstanceDelete||e.onInstanceDeploy||e.webhookLifecycleHandlers,G=e=>{if(e.fromDeployer)return{fromDeployer:!0};let t=`configVar`in e;return{type:t?`configVar`:`value`,value:t?e.configVar:e.value,meta:{scheduleType:`custom`,timeZone:e.timezone??``}}};e.convertQueueConfig=e=>{if(!(`type`in e))return e;switch(e.type){case`parallel`:return{usesFifoQueue:!1};case`throttled`:return{usesFifoQueue:!0,concurrencyLimit:e.concurrencyLimit,dedupeIdField:e.dedupeIdField};case`sequential`:return{usesFifoQueue:!0,dedupeIdField:e.dedupeIdField};default:return e}};let ee=(e,t)=>Object.entries(t).reduce((t,[n,r])=>(t[n]=Object.assign({title:r.title||`${e}-${n}`,type:`object`,$comment:r.$comment,properties:r.properties,$schema:r.$schema||f.DEFAULT_JSON_SCHEMA_VERSION},r.required?.length?{required:r.required}:{}),t),{});e.convertFlow=(t,n,r)=>{let i=C(t),a=Object.assign({},i);a.onTrigger=void 0,a.trigger=void 0,a.onInstanceDeploy=void 0,a.onInstanceDelete=void 0,a.webhookLifecycleHandlers=void 0,a.onExecution=void 0,a.onDeployTrigger=void 0,a.preprocessFlowConfig=void 0,a.errorConfig=void 0,a.testApiKeys=void 0,a.triggerType=void 0;let o,c={name:`On Trigger`,stableKey:`${i.stableKey}-onTrigger`,description:`The function that will be executed by the flow to return an HTTP response.`,isTrigger:!0,errorConfig:`errorConfig`in i?Object.assign({},i.errorConfig):void 0},l=W(i);if((0,f.isComponentReference)(i.onTrigger)&&!l){let{ref:e,inputs:t}=I(i.onTrigger,n,`triggers`),r=R(i.onTrigger,n);c.action=e;let a=z(t,r);c.inputs=a;let o=V(r,a,i.name);o&&(c.branches=o)}else if(l){if(i.onTrigger||(o=i.schedule?`schedule`:`webhook`),(0,f.isComponentReference)(i.onTrigger)){let{inputs:e}=I(i.onTrigger,n,`triggers`),t=R(i.onTrigger,n),r=z(e,t);c.inputs=r;let a=V(t,r,i.name);a&&(c.branches=a)}else{let e=(0,h.getBoundTrigger)(i.onTrigger),t=H(e),n=t?{[t.input.key]:t.value}:void 0;n&&(c.inputs=n);let r=V(e?.definition,n,i.name);r&&(c.branches=r)}c.action={key:te(i.name,`onTrigger`),component:U(r)}}else{let e=`schedule`in i&&typeof i.schedule==`object`?`schedule`:`webhook`;c.action={key:e,component:{key:`${e}-triggers`,version:`LATEST`,isPublic:!0}}}let u=!1;if(`schedule`in i&&typeof i.schedule==`object`&&(c.schedule=G(i.schedule),a.schedule=void 0,u=!0),i.triggerType===`polling`&&!u)throw Error(`${i.name} is marked as a polling trigger but has no schedule. Polling triggers require a schedule.`);if(`queueConfig`in i&&typeof i.queueConfig==`object`){let t=(0,e.convertQueueConfig)(i.queueConfig);if(u&&t.usesFifoQueue)throw Error(`${i.name} has a schedule & usesFifoQueue set to true. FIFO queues cannot be used with scheduled flows.`);if(!u&&t.singletonExecutions)throw Error(`${i.name} is configured for singletonExecutions but has no schedule. Unscheduled flows cannot be configured for singleton executions.`);if(t.usesFifoQueue&&t.singletonExecutions)throw Error(`${i.name} is configured for both FIFO queues and singleton executions, but these options are mutually exclusive. Please choose one.`);if(t.concurrencyLimit!==void 0&&(t.concurrencyLimit<e.CONCURRENCY_LIMIT_MIN||t.concurrencyLimit>e.CONCURRENCY_LIMIT_MAX))throw Error(`${i.name} has an invalid concurrencyLimit of ${t.concurrencyLimit}. concurrencyLimit must be between ${e.CONCURRENCY_LIMIT_MIN} and ${e.CONCURRENCY_LIMIT_MAX}.`);a.queueConfig=Object.assign(Object.assign({usesFifoQueue:!1},t),t.dedupeIdField?{dedupeIdField:{type:`reference`,value:`${(0,s.default)(c.name)}.results.${t.dedupeIdField}`}}:{})}let d=`triggerResolver`in i?i.triggerResolver:void 0,p=`onDeployResolver`in i?i.onDeployResolver:void 0,m=`batchConfig`in i?i.batchConfig:void 0,g=`runInitialSyncOnDeploy`in i&&!!i.runInitialSyncOnDeploy;if(a.triggerResolver=void 0,a.onDeployResolver=void 0,a.batchConfig=void 0,a.runInitialSyncOnDeploy=void 0,d||p){if(!m)throw Error(`${i.name} defines a triggerResolver/onDeployResolver but no batchConfig. Add \`batchConfig: { batchSize }\` to the flow.`);if(p&&(!(`onDeployTrigger`in i)||typeof i.onDeployTrigger!=`function`))throw Error(`${i.name} declares onDeployResolver without onDeployTrigger. Set onDeployTrigger to handle the initial-deploy fire that the resolver fans out.`);let e=(0,y.validateConcurrentBatchLimit)(i.name,`batchConfig`,m.concurrentBatchLimit);a.triggerResolver=Object.assign(Object.assign({batchSize:(0,y.validateBatchSize)(i.name,`batchConfig`,m.batchSize),enabled:!0},e===void 0?{}:{concurrentBatchLimit:e}),typeof i.runInitialSyncOnDeploy==`boolean`?{runInitialSyncOnDeploy:g}:{})}return a.steps=[c,{action:{key:te(i.name,`onExecution`),component:U(r)},name:`On Execution`,stableKey:`${i.stableKey}-onExecution`,description:`The function that will be executed by the flow.`,errorConfig:`errorConfig`in i?Object.assign({},i.errorConfig):void 0}],a.supplementalComponents=L(n,o),a.schemas=i.schemas?ee(i.stableKey,i.schemas):void 0,a},e.convertInputValue=(e,t)=>t!==`keyvaluelist`||Array.isArray(e)?e:Object.entries(e).map(([e,t])=>({key:e,value:typeof t==`string`?t:JSON.stringify(t)}));let K=e=>{if((0,f.isConnectionDefinitionConfigVar)(e)){let t=Object.values(e.inputs).some(e=>`onPremControlled`in e&&e.onPremControlled),{onPremConnectionConfig:n}=e;if(t&&!n)throw Error(`Connection ${e.stableKey} has onPremControlled inputs but no onPremConnectionConfig value set. Please set an onPremConnectionConfig value for the connection.`);if(!t&&n&&n!==`disallowed`)throw Error(`Connection ${e.stableKey} has onPremConnectionConfig set but no onPremControlled inputs. The connection will not be valid without onPremControlled inputs (host, port).`);return t&&n?n:`disallowed`}return`disallowed`};e.convertConfigVar=(t,n,r,i)=>{if((0,f.isConnectionScopedConfigVar)(n)){let{stableKey:e}=(0,l.default)(n,[`stableKey`]);return{key:t,stableKey:e,dataType:`connection`,useScopedConfigVar:e}}let{orgOnly:a,meta:c}=k((0,l.default)(n,[`permissionAndVisibilityType`,`visibleToOrgDeployer`]));if((0,f.isConnectionDefinitionConfigVar)(n)){let{stableKey:e,description:i}=(0,l.default)(n,[`stableKey`,`description`]);return{stableKey:e,description:i,key:t,dataType:`connection`,onPremiseConnectionConfig:K(n),connection:{key:(0,s.default)(t),component:U(r)},inputs:Object.entries(n.inputs).reduce((e,[t,n])=>{if(n.shown===!1||`templateValue`in n)return e;let r=O(n);n.writeOnly&&(r.writeOnly=n.writeOnly);let i=n.collection?(Array.isArray(n.default)?n.default:[]).map(e=>typeof e==`string`?{type:`value`,value:e}:{name:e.key,type:`value`,value:e.value}):n.default||``;return Object.assign(Object.assign({},e),{[t]:{type:n.collection?`complex`:`value`,value:i,meta:r}})},{}),orgOnly:a,meta:Object.assign(Object.assign({},c),`oauth2Config`in n?n.oauth2Config??{}:{})}}if((0,f.isConnectionReferenceConfigVar)(n)){let{ref:e,inputs:r}=I(n.connection,i,`connections`),{stableKey:o=``,description:s,connection:{template:u,onPremiseConnectionConfig:d}}=(0,l.default)(n,[`stableKey`,`description`,`connection`]);return{stableKey:o,description:s,key:t,dataType:`connection`,onPremiseConnectionConfig:d,connection:Object.assign(Object.assign({},e),{template:u}),inputs:r,orgOnly:a,meta:Object.assign(Object.assign({},c),`oauth2Config`in n?n.oauth2Config??{}:{})}}let u=`defaultValue`in n?(0,e.convertInputValue)(n.defaultValue,n.collectionType):void 0,d=u===void 0?void 0:typeof u==`string`?u:JSON.stringify(u),p=(0,o.default)({orgOnly:a,meta:c,key:t,defaultValue:d},(0,l.default)(n,[`stableKey`,`description`,`dataType`,`pickList`,`timeZone`,`codeLanguage`,`collectionType`]));if(((0,f.isScheduleConfigVar)(n)||(0,f.isScheduleDataSourceConfigVar)(n))&&(n.scheduleType?p.scheduleType=n.scheduleType:(0,f.isScheduleDataSourceConfigVar)(n)||typeof d==`string`&&d.length>0?p.scheduleType=`custom`:p.scheduleType=`none`),((0,f.isJsonFormConfigVar)(n)||(0,f.isJsonFormDataSourceConfigVar)(n))&&(p.meta=Object.assign(Object.assign({},p.meta),{validationMode:n?.validationMode??`ValidateAndShow`})),(0,f.isJsonFormDataSourceConfigVar)(n)&&n.dataSourceReset&&(p.meta=Object.assign(Object.assign({},p.meta),{dataSourceReset:n.dataSourceReset.mode}),p.inputs=(n.dataSourceReset.dependencies||[]).reduce((e,t,n)=>Object.assign(Object.assign({},e),{[`input${n}`]:{type:`configVar`,value:t}}),{})),(0,f.isDataSourceDefinitionConfigVar)(n)){p.dataType=n.dataSourceType,p.dataSource={key:(0,s.default)(t),component:U(r)};let e=(0,g.getBundledDataSource)(n);if(e){let t=Object.fromEntries(Object.entries(e.values).map(([e,t])=>[e,N(t)]));p.inputs=Object.assign(Object.assign({},p.inputs),P(e.inputs,t))}}if((0,f.isDataSourceReferenceConfigVar)(n)){let{ref:e,inputs:t}=I(n.dataSource,i,`dataSources`);p.dataType=i[n.dataSource.component].dataSources[e.key].dataSourceType,p.dataSource=e,p.inputs=t,n.validationMode&&(p.meta=Object.assign(Object.assign({},p.meta),{validationMode:n.validationMode})),n.dataSourceReset&&(p.meta=Object.assign(Object.assign({},p.meta),{dataSourceReset:n.dataSourceReset.mode}))}return p};let q=(e,t)=>t?{type:`reference`,value:`${e}.results.${t}`}:void 0,te=(e,t)=>`${e.replace(/[^0-9a-zA-Z]+/g,` `).trim().split(` `).map((e,t)=>t===0?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}_${t}`;e.invokeTriggerComponentInput=(e,t,n)=>{let{component:r}=e;return{component:`signature`in e.component?{key:r.key,signature:`signature`in r&&r.signature!==null&&r.signature!==void 0?r.signature:``,isPublic:r.isPublic}:r,key:t?t.key:e.key,triggerEventFunctionName:n}};let ne=(e,t)=>{if(!(0,f.isComponentReference)(e))return[];let n=t[e.component]?.triggers?.[e.key]?.inputs;return n?Object.entries(n).map(([e,t])=>Object.assign(Object.assign(Object.assign({key:e,label:e,type:t.inputType},t.collection?{collection:t.collection}:{}),t.default===void 0?{}:{default:t.default}),t.required===void 0?{}:{required:t.required})):[]},re=(e,t)=>t!==`polling`;function ie(e){let{componentRef:t,onTrigger:n,componentRegistry:r,triggerType:i}=e;if(t&&typeof n!=`function`)return{componentRef:t,onTrigger:n,triggerType:`component-ref`,componentRegistry:r};if(i===`polling`&&typeof n==`function`)return{componentRef:void 0,onTrigger:n,triggerType:i,componentRegistry:r};if(typeof n==`function`&&re(n,i))return{componentRef:void 0,onTrigger:n,triggerType:`standard`,componentRegistry:r};throw Error(`Invalid trigger configuration detected: ${JSON.stringify(e,null,2)}`)}function ae(e){let{componentRef:t,onTrigger:n,componentRegistry:r,triggerType:i}=ie(e);switch(i){case`polling`:return(0,S.createCNIPollingPerform)({onTrigger:n,componentRegistry:r});case`standard`:return(0,S.createCNIPerform)({componentRegistry:r,onTrigger:n});case`component-ref`:return(0,S.createCNIComponentRefPerform)({componentRegistry:r,componentRef:t,onTrigger:n});default:throw Error(`Invalid trigger configuration detected: ${JSON.stringify(e,null,2)}`)}}let J=(n,r,i,a,o)=>{if(n&&typeof r!=`function`)return(s,l)=>t(void 0,void 0,void 0,function*(){let u=(s._components??{invokeTrigger:()=>{}}).invokeTrigger,d=(0,v.createCNIContext)(s,a);return yield(0,p.invokeWithContext)(d,a=>t(void 0,void 0,void 0,function*(){let t=(yield u((0,e.invokeTriggerComponentInput)(n,r,i),a,null,l))||{},s={};return o&&(s=(yield o(a,l))||{}),(0,c.default)(t,s)}))});if(o)return(e,n)=>t(void 0,void 0,void 0,function*(){let t=(0,v.createCNIContext)(e,a);return yield(0,p.invokeWithContext)(t,o,n)})},oe=(e,n,r)=>(i,a)=>t(void 0,void 0,void 0,function*(){let t=(0,v.createCNIContext)(i,n),o=r?Object.assign(t,{configuration:`configuration`in t?t.configuration??{}:{},userConfiguration:`userConfiguration`in t?t.userConfiguration??{}:{},connections:(0,_.createConfigurationConnections)(r,t.configVars)}):t,s=yield(0,p.invokeWithContext)(o,e,a);return(0,v.logDebugResults)(o),s}),se=({name:e,iconPath:t,description:n,flows:r=[],componentRegistry:i={}},a,o,c)=>{let u=r.map(e=>C(e)),d=u.reduce((e,{name:t,onExecution:n})=>{let r=te(t,`onExecution`);return Object.assign(Object.assign({},e),{[r]:{key:r,display:{label:`${t} - onExecution`,description:`The function that will be executed by the flow.`},perform:oe(n,i,c),inputs:[]}})},{}),m=u.reduce((e,t)=>{let{name:n,onTrigger:r,onInstanceDeploy:a,onInstanceDelete:o,webhookLifecycleHandlers:s,schedule:c,triggerType:u,onDeployTrigger:d}=t,{batchConfig:m,triggerResolver:g,onDeployResolver:_}=t,y=(0,h.getBoundTrigger)(r),b=H(y),x=e=>y?(t,n)=>{let r=(0,v.createCNIContext)(t,i);return(0,p.invokeWithContext)(r,e,n)}:e;if(!W({onTrigger:r,onInstanceDelete:o,onInstanceDeploy:a,webhookLifecycleHandlers:s}))return e;let C=te(n,`onTrigger`),w=c&&typeof c==`object`?`schedule`:`webhook`,T={component:{key:`${w}-triggers`,version:`LATEST`,isPublic:!0},key:w},{ref:E}=(0,f.isComponentReference)(r)?I(r,i,`triggers`):{ref:r?void 0:T},D=ae({componentRef:E,onTrigger:r,componentRegistry:i,triggerType:u}),O=J(E,r,`onInstanceDelete`,i,o),k=J(E,r,`onInstanceDeploy`,i,a),A=J(E,r,`webhookCreate`,i,s?.create),j=J(E,r,`webhookDelete`,i,s?.delete);return Object.assign(Object.assign({},e),{[C]:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({key:C,display:{label:`${n} - onTrigger`,description:`The function that will be executed by the flow to return an HTTP response.`},perform:D,onInstanceDeploy:k,hasOnInstanceDeploy:!!k,onInstanceDelete:O,hasOnInstanceDelete:!!O,webhookCreate:A,hasWebhookCreateFunction:!!A,webhookDelete:j,hasWebhookDeleteFunction:!!j,inputs:b?[b.input]:ne(r,i),scheduleSupport:y&&`scheduleSupport`in y.definition?y.definition.scheduleSupport:u===`polling`?`required`:`valid`,synchronousResponseSupport:y&&`synchronousResponseSupport`in y.definition?y.definition.synchronousResponseSupport:y&&u===`polling`?`invalid`:`valid`},y?(0,l.default)(y.definition,[`allowsBranching`,`staticBranchNames`,`dynamicBranchInput`,`terminateExecution`,`breakLoop`]):(0,f.isComponentReference)(r)?B(r,i):{}),{isPollingTrigger:u===`polling`,triggerResolverSupport:y?.definition.triggerResolverSupport??(g?`valid`:`invalid`)}),g||_||y?.definition.triggerResolverSupport===`valid`||y?.definition.triggerResolverSupport===`required`?Object.assign({triggerResolverDefaultBatchSize:m?.batchSize??1},m?.concurrentBatchLimit===void 0?{}:{triggerResolverDefaultConcurrentBatchLimit:m.concurrentBatchLimit}):{}),g?Object.assign(Object.assign({},g.resolveItems?{resolveTriggerItems:x(g.resolveItems),hasResolveTriggerItems:!0}:{}),g.getNextPaginationState?{getNextPaginationState:x(g.getNextPaginationState),hasGetNextDiscoveryState:!0}:{}):{}),d?{onDeployPerform:(0,S.createCNIPerform)({componentRegistry:i,onTrigger:d}),hasOnDeployPerform:!0}:{}),_?Object.assign(Object.assign({},_.resolveItems?{resolveOnDeployItems:x(_.resolveItems),hasResolveOnDeployItems:!0}:{}),_.getNextPaginationState?{getOnDeployNextPaginationState:x(_.getNextPaginationState),hasGetOnDeployNextDiscoveryState:!0}:{}):{})})},{}),_={},b=(e,t,n=e)=>{let r=(0,g.getBundledDataSource)(t);if(r&&(Object.hasOwn(_,e)||Object.keys(o).some(n=>(0,s.default)(n)===e&&o[n]!==t)))throw Error(`Bundled data source key collision: ${e}`);let i=r?.detail?`${e}__detail`:void 0,a=t.dataSourceType===`jsonForm`?t.dataSourceReset?.dependencies??[]:[];if(r&&(n=e),_[e]=Object.assign({key:e,dataSourceType:t.dataSourceType,display:{label:n,description:n},inputs:r?Object.entries(r.inputs).map(([e,t])=>(0,y.convertInput)(e,t)):a.map((e,t)=>({key:`input${t}`,label:e,type:`string`})),perform:(e,n)=>(0,p.runWithDataSourceContext)(e,()=>t.perform(e,n))},i?{detailDataSource:i}:{}),r?.detail&&i){if(!(0,g.getBundledDataSource)(r.detail))throw Error(`Missing bundled data source definition: ${i}`);b(i,r.detail)}};for(let[e,t]of Object.entries(o))(0,f.isDataSourceDefinitionConfigVar)(t)&&b((0,s.default)(e),t,e);let x=Object.entries(o).reduce((e,[t,n])=>{if(!(0,f.isConnectionDefinitionConfigVar)(n))return e;let r=Object.entries(n.inputs).map(([e,t])=>`templateValue`in t?(0,y.convertTemplateInput)(e,t,n.inputs):(0,y.convertInput)(e,t)),i=(0,l.default)(n,[`oauth2Type`,`oauth2PkceMethod`]),{avatarPath:a,oauth2ConnectionIconPath:o}=n.icons??{};return[...e,Object.assign(Object.assign({},i),{iconPath:o,avatarIconPath:a,inputs:r,key:(0,s.default)(t),label:t})]},[]);return{key:a,display:{label:a,iconPath:t,description:n||e},connections:x,actions:d,triggers:m,dataSources:_}},ce=e=>({flowsWithCustomerRequiredAPIKeys:e.flows.filter(e=>e.endpointSecurityType===`customer_required`).map(({name:e,testApiKeys:t})=>({name:e,testApiKeys:t}))})})),_m=s((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.createInvokeFlow=void 0,e.createComponentMethods=c,e.createCNIContext=l,e.createDebugContext=u,e.logDebugResults=d;let r=require("node:perf_hooks"),i=require("node:process"),a=n(Lu()),o=gm(),s=1024*1024;function c(e,n){let r=(e._components??{invoke:()=>{}}).invoke;return Object.entries(n).reduce((i,[a,{key:s,actions:c,public:l,signature:d}])=>{let f=Object.entries(c).reduce((i,[c,f])=>{let p=n[a].actions[c],m=n=>t(this,void 0,void 0,function*(){let t=Object.entries(p.inputs).reduce((e,[t,r])=>{let i=n[t]??r.default,{collection:a}=r;return Object.assign(Object.assign({},e),{[t]:(0,o.convertInputValue)(i,a)})},{});return r({component:{key:s,signature:d??``,isPublic:l},key:f.key??c},Object.assign(Object.assign({},e),{debug:u(e)}),t)});return Object.assign(Object.assign({},i),{[c]:m})},{});return Object.assign(Object.assign({},i),{[a]:f})},{})}function l(t,n){return Object.assign(Object.assign({},t),{debug:u(t),components:c(t,n),invokeFlow:(0,e.createInvokeFlow)(t,{isCNI:!0})})}function u(e){let t=!!e.globalDebug;return{enabled:t,timeElapsed:{mark:(e,n)=>{t&&(e.debug.results.timeElapsed.marks[n]=r.performance.now())},measure:(e,n,r)=>{t&&(e.debug.results.timeElapsed.measurements[n]={marks:r,duration:e.debug.results.timeElapsed.marks[r.end]-e.debug.results.timeElapsed.marks[r.start]})}},memoryUsage:(e,n,r)=>{if(t){let t=r?f():i.memoryUsage.rss()/s;e.debug.results.memoryUsage.push({mark:n,rss:typeof t==`number`?t:t.rss,detail:typeof t==`number`?void 0:t})}},results:{timeElapsed:{marks:{},measurements:{}},memoryUsage:[],allowedMemory:Number(e.runnerAllocatedMemoryMb)}}}function d(e){e.debug.enabled&&e.logger.metric(e.debug.results)}function f(){let e=(0,i.memoryUsage)();return Object.keys(e).reduce((t,n)=>(t[n]=e[n]/s,t),{rss:-1,heapTotal:-1,heapUsed:-1,external:-1,arrayBuffers:-1})}function p(e,t){let n=e;return t&&(n=Object.assign(Object.assign({},e),{customSource:t})),JSON.stringify(n)}e.createInvokeFlow=(e,n={})=>(r,i,o,s)=>t(void 0,void 0,void 0,function*(){let t=n.isCNI?s:void 0;return yield a.default.post(e.webhookUrls[r],i,Object.assign(Object.assign({},o),{headers:Object.assign(Object.assign(Object.assign({},o?.headers??{}),e.webhookApiKeys[r]?.length>0?{"Api-Key":e.webhookApiKeys[r][0]}:{}),{"prismatic-invoked-by":p(e.executionFrame,t),"prismatic-invoke-type":`Cross Flow`,"prismatic-executionid":e.executionId})}))})})),vm=s((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.createCNIPerform=e.createCNIComponentRefPerform=e.createCNIPollingPerform=e.createPollingPerform=e.createPerform=e.cleanParams=e.createPollingContext=void 0;let i=r(Tl()),a=an(),o=_m(),s=gm(),c=wf();e.createPollingContext=({context:e,invokeAction:t})=>({polling:Object.assign({invokeAction:t},(0,c.createPollingState)(e))}),e.cleanParams=(e,t)=>(0,i.default)([...Object.keys(e),...Object.keys(t)]).reduce((n,r)=>{let i=e[r],a=t[r];return Object.assign(Object.assign({},n),{[r]:a?a(i):i})},{}),e.createPerform=(n,{inputCleaners:r,errorHandler:i})=>(...a)=>t(void 0,void 0,void 0,function*(){try{if(a.length===1){let[t]=a;return yield n((0,e.cleanParams)(t,r))}if(a.length===2){let[t,i]=a,s=Object.assign(Object.assign({},t),{debug:(0,o.createDebugContext)(t),invokeFlow:(0,o.createInvokeFlow)(t)}),c=yield n(s,(0,e.cleanParams)(i,r));return(0,o.logDebugResults)(s),c}let[t,i,s]=a,c=Object.assign(Object.assign({},t),{debug:(0,o.createDebugContext)(t),invokeFlow:(0,o.createInvokeFlow)(t)}),l=yield n(c,i,(0,e.cleanParams)(s,r));return(0,o.logDebugResults)(c),l}catch(e){throw i?yield i(e):e}});let l=(e,n,{errorHandler:r})=>i=>t(void 0,void 0,void 0,function*(){try{if(!n)throw`Error: Attempted to invoke an action for a trigger with no pollAction defined.`;return yield n.perform(Object.assign(Object.assign({},e),{debug:(0,o.createDebugContext)(e)}),i)}catch(e){throw r?yield r(e):e}});e.createPollingPerform=(r,{inputCleaners:i,errorHandler:a})=>(s,c,u)=>t(void 0,void 0,void 0,function*(){try{let{pollAction:t}=r,d=Object.assign(Object.assign({invokeFlow:(0,o.createInvokeFlow)(s)},(0,e.createPollingContext)({context:s,invokeAction:l(s,t,{errorHandler:a})})),{debug:(0,o.createDebugContext)(s)}),f=yield(0,e.createPerform)(r.perform,{inputCleaners:i,errorHandler:a})(Object.assign({},s,d),c,u),{polledNoChanges:p}=f,m=n(f,[`polledNoChanges`]);return Object.assign(Object.assign({},m),{resultType:p?`polled_no_changes`:`completed`})}catch(e){throw a?yield a(e):e}}),e.createCNIPollingPerform=({onTrigger:r,componentRegistry:i})=>(s,c,l)=>t(void 0,void 0,void 0,function*(){let u=(0,o.createCNIContext)(s,i),d=Object.assign(Object.assign({},u),(0,e.createPollingContext)({context:u,invokeAction:()=>t(void 0,void 0,void 0,function*(){throw Error(`invokeAction is not available for code-native polling triggers. Use getState/setState to manage polling state directly in your onTrigger function.`)})})),f=yield(0,a.invokeWithContext)(d,r,c,l);if(f===void 0)return;let{polledNoChanges:p}=f,m=n(f,[`polledNoChanges`]);return Object.assign(Object.assign({},m),{resultType:p?`polled_no_changes`:`completed`})}),e.createCNIComponentRefPerform=({componentRegistry:e,componentRef:n,onTrigger:r})=>(i,a,c)=>t(void 0,void 0,void 0,function*(){let t=(i._components??{invokeTrigger:()=>{}}).invokeTrigger,l=(0,o.createCNIContext)(i,e);return yield t((0,s.invokeTriggerComponentInput)(n,r,`perform`),l,a,c)}),e.createCNIPerform=({componentRegistry:e,onTrigger:n})=>(r,i,s)=>t(void 0,void 0,void 0,function*(){let t=(0,o.createCNIContext)(r,e);return yield(0,a.invokeWithContext)(t,n,i,s)})})),ym=s(((e,t)=>{t.exports=td()(function(e,t,n){return e+(n?`_`:``)+t.toLowerCase()})})),bm=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.fromServerPerformSafety=e.toServerPerformSafety=void 0;let n=t(nd()),r=t(ym());e.toServerPerformSafety=e=>(0,r.default)(e).toUpperCase(),e.fromServerPerformSafety=e=>(0,n.default)(e)})),xm=s((e=>{var t=e&&e.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},n=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.convertComponent=e.convertConnection=e.convertTrigger=e.convertAction=e.convertTemplateInput=e._isValidTemplateValue=e.convertInput=e.validateConcurrentBatchLimit=e.validateBatchSize=e.cleanerFor=void 0;let r=n(In()),i=Sr(),a=mr(),o=n(hl()),s=vm(),c=bm(),l=e=>typeof e==`object`&&!!e&&!Array.isArray(e);e.cleanerFor=t=>{if(t.type===`structuredObject`){let n=Object.entries(t.inputs).reduce((t,[n,r])=>Object.assign(Object.assign({},t),{[n]:(0,e.cleanerFor)(r)}),{}),r=e=>l(e)?(0,s.cleanParams)(e,n):e;return t.collection===`valuelist`?e=>Array.isArray(e)?e.map(r):e:t.collection===`keyvaluelist`?e=>Array.isArray(e)?e.map(e=>l(e)&&`value`in e?Object.assign(Object.assign({},e),{value:r(e.value)}):e):e:r}if(t.type===`dynamicObject`){let n={};for(let[r,i]of Object.entries(t.configurations))n[r]=Object.entries(i.inputs).reduce((t,[n,r])=>Object.assign(Object.assign({},t),{[n]:(0,e.cleanerFor)(r)}),{});return e=>{if(!l(e))return e;let{configuration:t,values:r}=e;if(typeof t!=`string`)return e;let i=n[t];return i?{configuration:t,values:l(r)?(0,s.cleanParams)(r,i):r}:{configuration:t,values:r}}}if(t.type===`number`||t.type===`float`){if(`clean`in t&&t.clean)return t.clean;let e=e=>t.type===`number`?o.default.types.toInt(e):o.default.types.toNumber(e);return t.collection===`valuelist`?t=>Array.isArray(t)?t.map(e):t:t.collection===`keyvaluelist`?t=>Array.isArray(t)?t.map(t=>l(t)&&`value`in t?Object.assign(Object.assign({},t),{value:e(t.value)}):t):t:e}return`clean`in t?t.clean:void 0},e.validateBatchSize=(e,t,n)=>{if(typeof n!=`number`||!Number.isInteger(n)||n<1)throw Error(`${e} has an invalid ${t} batchSize of ${String(n)}. batchSize must be an integer >= 1.`);return n},e.validateConcurrentBatchLimit=(e,t,n)=>{if(n!==void 0){if(typeof n!=`number`||!Number.isInteger(n)||n<1)throw Error(`${e} has an invalid ${t} concurrentBatchLimit of ${String(n)}. concurrentBatchLimit must be an integer >= 1.`);return n}};let u=(t,n,r,i)=>{if(n===`invalid`&&!r)return{};if(!i)throw Error(`Trigger "${t}" supports batching but declares no batchConfig. Add \`batchConfig: { batchSize }\` to set its default batch size.`);let a=(0,e.validateConcurrentBatchLimit)(`Trigger "${t}"`,`batchConfig`,i.concurrentBatchLimit);return Object.assign({triggerResolverDefaultBatchSize:(0,e.validateBatchSize)(`Trigger "${t}"`,`batchConfig`,i.batchSize)},a===void 0?{}:{triggerResolverDefaultConcurrentBatchLimit:a})},d=e=>{if(!e)return{};let{resolveItems:t,getNextPaginationState:n}=e;return Object.assign(Object.assign({},t?{resolveTriggerItems:t,hasResolveTriggerItems:!0}:{}),n?{getNextPaginationState:n,hasGetNextDiscoveryState:!0}:{})},f=e=>{if(!e)return{};let{resolveItems:t,getNextPaginationState:n}=e;return Object.assign(Object.assign({},t?{resolveOnDeployItems:t,hasResolveOnDeployItems:!0}:{}),n?{getOnDeployNextPaginationState:n,hasGetOnDeployNextDiscoveryState:!0}:{})};e.convertInput=(n,a,o)=>{let s=a,{default:c,type:l,label:u,collection:d,inputs:f,configurations:p}=s,m=t(s,[`default`,`type`,`label`,`collection`,`inputs`,`configurations`]),h=d===`keyvaluelist`&&typeof u==`object`?u.key:void 0,g=l===`structuredObject`&&f?Object.entries(f).map(([t,n])=>(0,e.convertInput)(t,n)):l===`dynamicObject`&&p?Object.entries(p).map(([t,n])=>({key:t,type:`structuredObject`,label:typeof n.label==`string`?n.label:n.label.value,comments:n.comments,inputs:Object.entries(n.inputs).map(([t,n])=>(0,e.convertInput)(t,n))})):void 0;return Object.assign(Object.assign(Object.assign({},(0,r.default)(m,[`onPremControlled`,`permissionAndVisibilityType`,`visibleToOrgDeployer`,`writeOnly`])),{key:n,type:l,default:c??(d?[]:i.InputFieldDefaultMap[l]),collection:d,label:typeof u==`string`?u:u.value,keyLabel:h,onPremiseControlled:m.onPremControlled===!0||void 0,inputs:g}),o?{scope:o}:{})};let p=/{{#(\w+)}}/g,m={NO_SLOTS:`No template slots were found. Declare a template slot with this notation: {{#someInputKey}}`,INVALID_KEYS:`Invalid keys were found in the template string. All referenced keys must be non-template inputs declared in the first argument:`};e._isValidTemplateValue=(e,t)=>{let n=[...e.matchAll(p)];if(n.length===0)return{isValid:!1,error:m.NO_SLOTS};let r=[];for(let[e,i]of n)(!t[i]||t[i].type===`template`)&&r.push(i);return r.length>0?{isValid:!1,error:`${m.INVALID_KEYS} ${r}`}:{isValid:!0}},e.convertTemplateInput=(n,i,a)=>{var{templateValue:o,label:s}=i,c=t(i,[`templateValue`,`label`]);let l=(0,e._isValidTemplateValue)(o,a);if(!l.isValid)throw`Template input "${n}": ${l.error}`;return Object.assign(Object.assign({},(0,r.default)(c,[`permissionAndVisibilityType`,`visibleToOrgDeployer`,`writeOnly`])),{key:n,type:`template`,default:o??``,label:typeof s==`string`?s:s.value,shown:!1})};let h=e=>e.type===`actionOutput`?{type:`actionOutput`,schema:JSON.stringify(e.schema)}:{type:`branchingOutput`,branchSchemas:Object.entries(e.branchSchemas).map(([e,t])=>({name:e,schema:JSON.stringify(t)}))};e.convertAction=(n,r,a)=>{var{inputs:o={},perform:l,outputSchema:u,examplePerform:d,performSafety:f}=r,p=t(r,[`inputs`,`perform`,`outputSchema`,`examplePerform`,`performSafety`]);let m=Object.entries(o).map(([t,n])=>(0,e.convertInput)(t,n)),g=Object.entries(o).reduce((t,[n,r])=>Object.assign(Object.assign({},t),{[n]:(0,e.cleanerFor)(r)}),{});return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},p),{key:n,inputs:m,perform:(0,s.createPerform)(l,{inputCleaners:g,errorHandler:a?.error})}),u?{outputSchema:h(u)}:{}),d?{examplePerform:(0,s.createPerform)(d,{inputCleaners:g,errorHandler:a?.error}),examplePerformSafety:(0,c.toServerPerformSafety)(i.PerformSafety.SAFE)}:{}),f?{performSafety:(0,c.toServerPerformSafety)(f)}:{})},e.convertTrigger=(n,i,o)=>{let{onInstanceDeploy:c,onInstanceDelete:l}=i,p=`webhookLifecycleHandlers`in i?i.webhookLifecycleHandlers:void 0,m=i.inputs??{},h=Object.keys(m),g=Object.entries(m).map(([t,n])=>(0,e.convertInput)(t,n)),_=Object.entries(m).reduce((t,[n,r])=>Object.assign(Object.assign({},t),{[n]:(0,e.cleanerFor)(r)}),{}),v=`scheduleSupport`in i?i.scheduleSupport:`invalid`,y=`batchConfig`in i?i.batchConfig:void 0,b=`triggerResolver`in i?i.triggerResolver:void 0,x=`triggerResolverSupport`in i&&i.triggerResolverSupport!==void 0?i.triggerResolverSupport:b?`valid`:`invalid`;if(x===`required`&&!b)throw Error(`Trigger "${i.display.label}" declares triggerResolverSupport "required" but is missing triggerResolver.`);if(x===`invalid`&&b)throw Error(`Trigger "${i.display.label}" declares triggerResolver but triggerResolverSupport is "invalid".`);let S=`onDeployPerform`in i?i.onDeployPerform:void 0,C=`onDeployResolver`in i?i.onDeployResolver:void 0;if(C?.resolveItems&&!S)throw Error(`Trigger "${i.display.label}" declares onDeployResolver.resolveItems but is missing onDeployPerform.`);let w=C?.inputs??{},T=Object.entries(w);for(let[e]of T)if(h.includes(e))throw Error(`Trigger "${i.display.label}" declares an onDeployResolver input with key "${e}", which duplicates a trigger input. On-deploy and trigger inputs share one key namespace; give the on-deploy input a different key.`);let E=T.map(([t,n])=>(0,e.convertInput)(t,n,`ON_DEPLOY`)),D=T.reduce((t,[n,r])=>Object.assign(Object.assign({},t),{[n]:(0,e.cleanerFor)(r)}),{}),O=[],k;if((0,a.isPollingTriggerDefinition)(i)){let{pollAction:t}=i,n={};v=`required`,t&&(O=Object.entries(t.inputs).reduce((n,[r,a])=>{if(h.includes(r))throw Error(`The pollingTrigger "${i.display.label}" was defined with an input with the key: ${r}. This key duplicates an input on the associated "${t.display.label}" action. Please assign the trigger input a different key.`);return n.push((0,e.convertInput)(r,a)),n},[]),n=Object.entries(t.inputs).reduce((t,[n,r])=>Object.assign(Object.assign({},t),{[n]:(0,e.cleanerFor)(r)}),{}));let r=Object.assign({},n,_);k=(0,s.createPollingPerform)(i,{inputCleaners:r,errorHandler:o?.error})}else k=(0,s.createPerform)(i.perform,{inputCleaners:_,errorHandler:o?.error});let A=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},(0,r.default)(i,[`batchConfig`,`triggerResolver`,`onDeployResolver`])),{key:n,inputs:g.concat(O,E),perform:k,scheduleSupport:v,synchronousResponseSupport:`synchronousResponseSupport`in i?i.synchronousResponseSupport:v===`invalid`?`valid`:`invalid`,triggerResolverSupport:x}),u(i.display.label,x,!!C?.resolveItems,y)),d(b)),f(C)),(0,a.isPollingTriggerDefinition)(i)?{isPollingTrigger:!0}:{});c&&(A.onInstanceDeploy=(0,s.createPerform)(c,{inputCleaners:_,errorHandler:o?.error}),A.hasOnInstanceDeploy=!0),S&&(A.onDeployPerform=(0,s.createPerform)(S,{inputCleaners:Object.assign(Object.assign({},_),D),errorHandler:o?.error}),A.hasOnDeployPerform=!0),l&&(A.onInstanceDelete=(0,s.createPerform)(l,{inputCleaners:_,errorHandler:o?.error}),A.hasOnInstanceDelete=!0),p&&(A.webhookCreate=(0,s.createPerform)(p.create,{inputCleaners:_,errorHandler:o?.error}),A.webhookDelete=(0,s.createPerform)(p.delete,{inputCleaners:_,errorHandler:o?.error}),A.hasWebhookCreateFunction=!0,A.hasWebhookDeleteFunction=!0);let{pollAction:j,triggerType:M,webhookLifecycleHandlers:N}=A;return t(A,[`pollAction`,`triggerType`,`webhookLifecycleHandlers`])};let g=(n,r,i)=>{var{inputs:a={},perform:o}=r,c=t(r,[`inputs`,`perform`]);let l=Object.entries(a).map(([t,n])=>(0,e.convertInput)(t,n)),u=Object.entries(a).reduce((t,[n,r])=>Object.assign(Object.assign({},t),{[n]:(0,e.cleanerFor)(r)}),{});return Object.assign(Object.assign({},c),{key:n,inputs:l,perform:(0,s.createPerform)(o,{inputCleaners:u,errorHandler:i?.error})})};e.convertConnection=n=>{var{inputs:r={}}=n,i=t(n,[`inputs`]);let{display:{label:a,icons:o,description:s}}=i,c=t(i,[`display`]),l=Object.entries(r).map(([t,n])=>`templateValue`in n?(0,e.convertTemplateInput)(t,n,r):(0,e.convertInput)(t,n));return Object.assign(Object.assign({},c),{label:a,comments:s,iconPath:o?.oauth2ConnectionIconPath,avatarIconPath:o?.avatarPath,inputs:l})},e.convertComponent=n=>{var{connections:r=[],actions:i={},triggers:a={},dataSources:o={},hooks:s}=n,c=t(n,[`connections`,`actions`,`triggers`,`dataSources`,`hooks`]);let l=Object.entries(i).reduce((t,[n,r])=>Object.assign(Object.assign({},t),{[n]:(0,e.convertAction)(n,r,s)}),{}),u=Object.entries(a).reduce((t,[n,r])=>Object.assign(Object.assign({},t),{[n]:(0,e.convertTrigger)(n,r,s)}),{}),d=Object.entries(o).reduce((e,[t,n])=>Object.assign(Object.assign({},e),{[t]:g(t,n,s)}),{});return Object.assign(Object.assign({},c),{connections:r.map(e.convertConnection),actions:l,triggers:u,dataSources:d})}})),Sm=s((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.callableComponent=e.retainAuthoring=e.authoringSymbol=void 0;let i=r(gt()),a=r(rn()),o=an(),s=Cn(),c=wn(),l=En(),u=xm(),d=vm(),f=wf(),p=Sr();e.authoringSymbol=Symbol.for(`@prismatic-io/spectral/authoring/v1`),e.retainAuthoring=(t,n)=>(Object.defineProperty(t,e.authoringSymbol,{value:n}),t);let m=e=>typeof e==`object`&&!!e&&!Array.isArray(e),h=(e,t)=>{let n=t===void 0?(0,i.default)((`default`in e?e.default:void 0)??(`collection`in e&&e.collection?[]:p.InputFieldDefaultMap[e.type])):t;`collection`in e&&e.collection===`keyvaluelist`&&m(n)&&(n=Object.entries(n).map(([e,t])=>({key:e,value:t})));let r=t=>{if(e.type===`boolean`&&!e.clean)return typeof t==`boolean`?String(t):t;if(e.type===`structuredObject`)return m(t)?g(e.inputs,t):t;if(e.type===`dynamicObject`&&m(t)){let n=typeof t.configuration==`string`?e.configurations[t.configuration]:void 0;if(n&&m(t.values))return Object.assign(Object.assign({},t),{values:g(n.inputs,t.values)})}return t};if(e.type!==`structuredObject`&&!(e.type===`boolean`&&!e.clean))return r(n);if(`collection`in e&&e.collection){if(!Array.isArray(n))return n;if(e.collection===`valuelist`)return n.map(r);if(e.collection===`keyvaluelist`)return n.map(e=>m(e)&&`value`in e?Object.assign(Object.assign({},e),{value:r(e.value)}):e)}return r(e.type===`structuredObject`&&n===void 0?{}:n)},g=(e,t)=>(0,a.default)(e,(e,n)=>h(e,t[n])),_=e=>{let t=(0,a.default)(e,u.cleanerFor);return(n={})=>(0,d.cleanParams)(g(e,n),t)},v=(e,n)=>t(void 0,void 0,void 0,function*(){try{return yield n()}catch(t){throw e?.error?yield e.error(t):t}}),y=(e,n,r,i)=>{let a=e.inputs??{},c=!!e.batchConfig,u=(0,p.isPollingTriggerDefinition)(e)&&`pollAction`in e?e.pollAction:void 0;for(let e of Object.keys(u?.inputs??{}))if(Object.hasOwn(a,e))throw Error(`Polling action input duplicates trigger input: ${e}`);for(let t of Object.keys(e.onDeployResolver?.inputs??{}))if(Object.hasOwn(a,t))throw Error(`On-deploy input duplicates trigger input: ${t}`);let d=_(Object.assign(Object.assign({},u?.inputs),a)),h=_(a),g=_(Object.assign(Object.assign({},a),e.onDeployResolver?.inputs)),y=(r,i)=>(a,...s)=>t(void 0,[a,...s],void 0,function*(a,s={}){let l=(0,o.requireContext)();return v(n,()=>{let n=i(s),d=(0,p.isPollingTriggerDefinition)(e)?Object.assign(Object.assign({},l),{polling:Object.assign(Object.assign({},(0,f.createPollingState)(l)),{invokeAction:e=>t(void 0,void 0,void 0,function*(){if(!u)throw Error(`This polling trigger has no pollAction.`);return u.perform(d,e)})})}):c?Object.assign(Object.assign({},l),{polling:(0,f.createPollingState)(l)}):l;return(0,o.invokeWithContext)(d,r,a,n)})}),b=e=>(...r)=>t(void 0,[...r],void 0,function*(t={}){let r=(0,o.requireContext)();return v(n,()=>e(r,h(t)))}),x=e=>Object.assign(Object.assign(Object.assign({},e),e.resolveItems?{resolveItems:t=>e.resolveItems?.call(e,(0,o.requireContext)(),t)}:{}),e.getNextPaginationState?{getNextPaginationState:t=>e.getNextPaginationState?.call(e,(0,o.requireContext)(),t)}:{}),S=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({perform:y(e.perform,d)},e.onDeployPerform?{onDeployPerform:y(e.onDeployPerform,g)}:{}),e.onInstanceDeploy?{onInstanceDeploy:b(e.onInstanceDeploy)}:{}),e.onInstanceDelete?{onInstanceDelete:b(e.onInstanceDelete)}:{}),`webhookLifecycleHandlers`in e&&e.webhookLifecycleHandlers?{webhookLifecycleHandlers:{create:b(e.webhookLifecycleHandlers.create),delete:b(e.webhookLifecycleHandlers.delete)}}:{}),e.triggerResolver?{triggerResolver:x(e.triggerResolver)}:{}),e.onDeployResolver?{onDeployResolver:x(e.onDeployResolver)}:{});return(0,l.instrumentTriggerCalls)(S,r,i,e.examplePayload),Object.assign((t={})=>{let n=(e,n)=>Object.fromEntries(Object.keys(n).map(n=>{let r=t[n];if(m(r)&&Object.hasOwn(r,`configVar`)){if(typeof r.configVar!=`string`||!Object.hasOwn(e.configVars,r.configVar))throw Error(`Missing config variable for trigger input "${n}": ${String(r.configVar)}`);return[n,e.configVars[r.configVar]]}return[n,m(r)&&Object.hasOwn(r,`value`)?r.value:r]})),r=e=>t=>(0,o.invokeWithContext)(t,t=>e(n(t,a))),i=(e,t)=>(0,o.invokeWithContext)(e,e=>S.perform(t,n(e,Object.assign(Object.assign({},u?.inputs),a)))),c=S.onDeployPerform,l=e=>Object.assign(Object.assign({},e.resolveItems?{resolveItems:(t,n)=>(0,o.invokeWithContext)(t,()=>e.resolveItems?.call(e,n))}:{}),e.getNextPaginationState?{getNextPaginationState:(t,n)=>(0,o.invokeWithContext)(t,()=>e.getNextPaginationState?.call(e,n))}:{}),d=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({definition:e},S.triggerResolver?{triggerResolver:l(S.triggerResolver)}:{}),S.onDeployResolver?{onDeployResolver:l(S.onDeployResolver)}:{}),{bindings:t}),S.onInstanceDeploy?{onInstanceDeploy:r(S.onInstanceDeploy)}:{}),S.onInstanceDelete?{onInstanceDelete:r(S.onInstanceDelete)}:{}),S.webhookLifecycleHandlers?{webhookLifecycleHandlers:{create:r(S.webhookLifecycleHandlers.create),delete:r(S.webhookLifecycleHandlers.delete)}}:{}),c?{onDeployTrigger:(t,r)=>(0,o.invokeWithContext)(t,t=>c(r,n(t,Object.assign(Object.assign({},a),e.onDeployResolver?.inputs))))}:{});return Object.defineProperty(i,s.boundTriggerSymbol,{value:d}),i},e,S)};e.callableComponent=r=>{let i=e.authoringSymbol in r?r[e.authoringSymbol]:r;if([...Object.values(i.actions??{}),...Object.values(i.dataSources??{}),...Object.values(i.triggers??{})].some(e=>Array.isArray(e.inputs)||typeof e.perform!=`function`)||(i.connections??[]).some(e=>Array.isArray(e.inputs))||!(e.authoringSymbol in r)&&`signature`in r)throw Error(`callableComponent requires authoring definitions or a component created with a supporting version of Spectral. Pass the original component; spreading or serializing it loses authoring data.`);let s=(e,n)=>(0,a.default)(e,e=>{let r=_(e.inputs);return(...a)=>t(void 0,[...a],void 0,function*(t={}){let a=n();return v(i.hooks,()=>e.perform(a,r(t)))})}),u=Object.fromEntries((i.connections??[]).map(e=>[e.key,t=>{var{values:r={},template:a,onPremiseConnectionConfig:o}=t,s=n(t,[`values`,`template`,`onPremiseConnectionConfig`]);if(delete s.version,!i.key)throw Error(`Published connections require the component's key.`);let l={component:i.key,key:e.key,values:r,template:a,onPremiseConnectionConfig:o,[c.publishedConnectionSymbol]:{component:{key:i.key,isPublic:i.public??!1,signature:`__PRISMATIC_COMPONENT_SELF__`},inputs:e.inputs}};return Object.assign(Object.assign({},s),{dataType:`connection`,connection:l})}]));if(Object.keys(u).length!==(i.connections??[]).length)throw Error(`Duplicate connection key`);let d=(0,l.instrumentEntityCalls)(s(i.dataSources??{},o.requireDataSourceContext),i,i.dataSources??{},`dataSources`),f=(e,r,a=[])=>{if(a.includes(e))throw Error(`Circular detail data source: ${[...a,e].join(` -> `)}`);let o=i.dataSources?.[e];if(!o)throw Error(`Unknown detail data source: ${e}`);let{values:s}=r,l=n(r,[`values`]),{detailDataSource:u}=o,p=n(o,[`detailDataSource`]);return Object.assign(Object.assign(Object.assign({},p),l),{perform:(n,r)=>t(void 0,void 0,void 0,function*(){let t=Object.fromEntries(Object.entries(s).filter(([e])=>e in o.inputs).map(([e,t])=>{if(m(t)&&`configVar`in t){let r=String(t.configVar);if(!(r in n.configVars))throw Error(`Missing config variable for data source input "${e}": ${r}`);return[e,n.configVars[r]]}return[e,m(t)&&`value`in t?t.value:t]}));return d[e](Object.assign(Object.assign({},t),r))}),[c.bundledDataSourceSymbol]:Object.assign({inputs:o.inputs,values:s},u?{detail:f(u,r,[...a,e])}:{})})},p=(0,a.default)(d,(e,t)=>(0,l.identifyDataSourceAlias)(Object.assign((...n)=>{let[r={}]=n;return typeof r.stableKey==`string`&&m(r.values)?f(t,Object.assign(Object.assign({},r),{stableKey:r.stableKey,values:r.values})):e(...n)},{perform:e}),e));return{actions:(0,l.instrumentEntityCalls)(s(i.actions??{},o.requireContext),i,i.actions??{},`actions`),dataSources:p,triggers:(0,a.default)(i.triggers,(e,t)=>y(e,i.hooks,i,t)),connections:u}}})),Cm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OAuth2Type=void 0;var r;(function(e){e.ClientCredentials=`client_credentials`,e.AuthorizationCode=`authorization_code`})(r||(e.OAuth2Type=r={})),n(an(),e)})),wm=s(((e,t)=>{var n=ht(),r=1,i=4;function a(e,t){return t=typeof t==`function`?t:void 0,n(e,r|i,t)}t.exports=a})),Tm=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.localMock=e.pendingImplementations=e.requireRunner=void 0;let t=require("node:module");e.requireRunner=e=>(0,t.createRequire)(__filename)(e),e.pendingImplementations=new WeakMap;let n=0;e.localMock=t=>{let r=t,i=[],a=`jest.fn()`,o=()=>({calls:[],contexts:[],instances:[],invocationCallOrder:[],results:[],lastCall:void 0}),s=o(),c=function(...e){s.calls.push(e),s.contexts.push(this),s.instances.push(this),s.invocationCallOrder.push(++n),s.lastCall=e;let t={type:`incomplete`,value:void 0};s.results.push(t);try{return t.value=(i.shift()??r)?.apply(this,e),t.type=`return`,t.value}catch(e){throw t.type=`throw`,t.value=e,e}},l=process.versions.bun?(0,e.requireRunner)(`bun:test`).mock(c):c,u=process.versions.bun?l.mockClear.bind(l):()=>{};return Object.defineProperties(l,Object.getOwnPropertyDescriptors({_isMockFunction:!0,getMockName:()=>a,mockName:e=>(a=e||a,l),getMockImplementation:()=>r,mockClear:()=>(u(),s=o(),l),mockReset:()=>(l.mockClear(),r=void 0,i=[],a=`jest.fn()`,l),mockRestore:()=>{l.mockReset()},mockReturnThis:()=>l.mockImplementation(()=>s.contexts[s.contexts.length-1]),withImplementation:(e,t)=>{let n=r,a=i;r=e,i=[];let o=()=>{r=n,i=a};try{let e=t();if(e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0).finally(o);o()}catch(e){throw o(),e}},mockImplementation:e=>(r=e,l),mockImplementationOnce:e=>(i.push(e),l),mockReturnValue:e=>l.mockImplementation(()=>e),mockReturnValueOnce:e=>l.mockImplementationOnce(()=>e),mockResolvedValue:e=>l.mockImplementation(()=>Promise.resolve(e)),mockResolvedValueOnce:e=>l.mockImplementationOnce(()=>Promise.resolve(e)),mockRejectedValue:e=>l.mockImplementation(()=>Promise.reject(e)),mockRejectedValueOnce:e=>l.mockImplementationOnce(()=>Promise.reject(e))})),Object.defineProperty(l,"mock",{enumerable:!0,get:()=>s,set:e=>{s=e}}),e.pendingImplementations.set(l,()=>i),l}})),Em=c({loadRunner:()=>Dm});function Dm(){return Om(this,void 0,void 0,function*(){let e=process.env.VITEST?`vitest`:process.versions.bun?`bun:test`:void 0;if(!e)throw Error(`CNI callable mocks require an active Vitest, Jest, or Bun test runner.`);let t=yield import(e);return e===`vitest`?t.vi.fn:t.mock})}var Om,km=o((()=>{Om=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}})),Am=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!=="default"&&t(i,r,a[o]);return n(i,r),i}})(),i=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.CallableMocks=void 0;let o=a(wm()),s=Tm(),c=Tn(),l=()=>i(void 0,void 0,void 0,function*(){if(process.env.JEST_WORKER_ID!==void 0&&!process.env.VITEST)return(0,s.requireRunner)(`@jest/globals`).jest.fn;let{loadRunner:e}=yield Promise.resolve().then(()=>r((km(),d(Em))));return e()}),u=(e,t)=>{if(t)return{proxy:t(e),initialize:e=>{}};let n=(0,s.localMock)(e),r=!1,i=new Proxy((...e)=>n(...e),{apply:(e,t,r)=>n.apply(t,r),has:(e,t)=>t in n,get:(e,t)=>{let r=n[t];return typeof r!=`function`||typeof t!=`string`||!t.startsWith(`mock`)?r:(...e)=>{let r=n[t](...e);return r===n?i:r}}});return{proxy:i,initialize(e){if(r)return;let t=e(n.getMockImplementation());for(let e of s.pendingImplementations.get(n)?.()??[])t.mockImplementationOnce(e);for(let e of[`calls`,`contexts`,`results`])t.mock[e].push(...n.mock[e]);n=t,r=!0}}};e.CallableMocks=class{constructor(){this.mocks=new Map,this.dispatch=(e,t)=>this.get(e)(...t),process.versions.bun&&!process.env.VITEST&&process.env.JEST_WORKER_ID===void 0&&(this.factory=(0,s.requireRunner)(`bun:test`).mock)}get(e){let t=this.mocks.get(e.owner);t||(t=new Map,this.mocks.set(e.owner,t));let n=t.get(e.method);return n||(n=u(e.examplePayload===void 0?void 0:()=>Promise.resolve((0,o.default)(e.examplePayload,e=>Buffer.isBuffer(e)?Buffer.from(e):void 0)),this.factory),t.set(e.method,n)),n.proxy}mock(e){let t=(0,c.getCallableMockTarget)(e);if(!t)throw Error(`Expected a Spectral callable method. Use a trigger's .perform or a data source's .perform; older component packages may need rebuilding with a newer Spectral.`);return this.get(t)}initialize(){return this.factory?Promise.resolve():(this.initialization??=l().then(e=>{this.factory=e;for(let t of this.mocks.values())for(let n of t.values())n.initialize(e)}),this.initialization)}}})),jm=s((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.FlowTestHarness=e.ComponentTestHarness=e.invokeFlow=e.invokeDataSource=e.invokeTrigger=e.defaultTriggerPayload=e.invoke=e.createMockContextComponents=e.loggerMock=e.connectionValue=e.defaultConnectionValueEnvironmentVariable=e.createConnection=void 0,e.createHarness=g;let r=n(wm()),i=Tm(),a=Am(),o=an(),s=Cn(),c=wf();e.createConnection=({key:e},t,n,r)=>({configVarKey:r??``,key:e,fields:t,token:n}),e.defaultConnectionValueEnvironmentVariable=`PRISMATIC_CONNECTION_VALUE`,e.connectionValue=(t=e.defaultConnectionValueEnvironmentVariable)=>{let n=process.env[t];if(!n)throw Error(`Unable to find connection value.`);return Object.assign(Object.assign({},JSON.parse(n)),{key:``})},e.loggerMock=()=>({metric:(0,i.localMock)(),trace:(0,i.localMock)(),debug:(0,i.localMock)(),info:(0,i.localMock)(),log:(0,i.localMock)(),warn:(0,i.localMock)(),error:(0,i.localMock)(),section:(0,i.localMock)(),sectionEnd:(0,i.localMock)()});function l(e,n,r){return t(this,void 0,void 0,function*(){return Promise.resolve({})})}e.createMockContextComponents=(e,t={actions:{}})=>Object.keys(e).reduce((n,r)=>{let i=Object.keys(e[r].actions).reduce((t,n)=>(t[n]=(()=>{let t=e[r].actions[n].examplePayload??{data:null};return Promise.resolve(t)}),t),{});return n[r]=Object.assign(Object.assign({},i),t.actions[r]??{}),n},{});let u=t=>Object.assign({logger:(0,e.loggerMock)(),instanceState:{},crossFlowState:{},executionState:{},integrationState:{},configVars:{},components:{},stepId:`mockStepId`,executionId:`mockExecutionId`,webhookUrls:{"Flow 1":`https://example.com`},webhookApiKeys:{"Flow 1":[`example-123`,`example-456`]},invokeUrl:`https://example.com`,customer:{id:`customerId`,name:`Customer 1`,externalId:`1234`},instance:{id:`instanceId`,name:`Instance 1`},user:{id:`userId`,email:`user@example.com`,name:`User 1`,externalId:`1234`},integration:{id:`integrationId`,name:`Integration 1`,versionSequenceId:`1234`,externalVersion:`1.0.0`},flow:{id:`flowId`,name:`Flow 1`,stableId:`flowStableId`},startedAt:new Date().toISOString(),invokeFlow:l,executionFrame:{invokedByExecutionJWT:`some-jwt`,invokedByExecutionStartedAt:`00-00-0000`,componentActionKey:`my-component-action-key`,executionId:`abc-123`,executionStartedAt:``,stepName:`some-step`,loopPath:``},debug:{enabled:!1,timeElapsed:{mark:(e,t)=>{},measure:(e,t,n)=>{}},memoryUsage:(e,t,n)=>{},results:{timeElapsed:{marks:{},measurements:{}},memoryUsage:[],allowedMemory:1024}},flowSchemas:{}},t),d=t=>{let n=u(t);return Object.assign(Object.assign({},n),{logger:t?.logger??(0,e.loggerMock)()})},f=t=>Object.assign({logger:(0,e.loggerMock)(),configVars:{},customer:{id:`customerId`,name:`Customer 1`,externalId:`1234`},instance:{id:`instanceId`,name:`Instance 1`},user:{id:`userId`,email:`example@email.com`,externalId:`1234`,name:`Example`}},t);e.invoke=(e,n,r)=>t(void 0,[e,n,r],void 0,function*({perform:e},t,n){let r=u(n);return{result:yield e(r,t),loggerMock:r.logger}}),e.defaultTriggerPayload=()=>{let e={foo:`bar`},t=`application/json`;return{headers:{"content-type":t},queryParameters:{},rawBody:{data:e,contentType:t},body:{data:JSON.stringify(e),contentType:t},pathFragment:``,webhookUrls:{"Flow 1":`https://example.com`},webhookApiKeys:{"Flow 1":[`example-123`,`example-456`]},invokeUrl:`https://example.com`,executionId:`executionId`,customer:{id:`customerId`,name:`Customer 1`,externalId:`1234`},instance:{id:`instanceId`,name:`Instance 1`},user:{id:`userId`,email:`user@example.com`,name:`User 1`,externalId:`1234`},integration:{id:`integrationId`,name:`Integration 1`,versionSequenceId:`1234`,externalVersion:`1.0.0`},flow:{id:`flowId`,name:`Flow 1`,stableId:`flowStableId`},startedAt:new Date().toISOString(),globalDebug:!1}},e.invokeTrigger=(n,r,i,a)=>t(void 0,[n,r,i,a],void 0,function*({perform:t},n,r,i){let a=u(n);return{result:yield t(a,Object.assign(Object.assign({},(0,e.defaultTriggerPayload)()),r),i||{}),loggerMock:a.logger}}),e.invokeDataSource=(e,n,r)=>t(void 0,[e,n,r],void 0,function*({perform:e},t,n){return yield e(f(n),t)});let p=e=>Object.entries(e??{}).reduce((e,[t,n])=>typeof n==`object`&&`fields`in n?Object.assign(Object.assign({},e),{[t]:Object.assign(Object.assign({},n),{configVarKey:``})}):Object.assign(Object.assign({},e),{[t]:n}),{}),m=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Object.fromEntries(Object.entries(t??{}).flatMap(([t,n])=>n?[[t,Object.assign(Object.assign({},n),{configVarKey:`${e}.${t}`})]]:[]))]));e.invokeFlow=(n,...r)=>t(void 0,[n,...r],void 0,function*(t,n={}){let{configVars:r,configuration:i,userConfiguration:a,connections:s,context:c,payload:l}=n,u=p(r),f=d(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},i===void 0?{}:{configuration:i}),a===void 0?{}:{userConfiguration:a}),s?{connections:m(s)}:{}),c),{configVars:u})),h=Object.assign(Object.assign({},(0,e.defaultTriggerPayload)()),l),g={onTrigger:{results:h}};return`onTrigger`in t&&typeof t.onTrigger==`function`&&(g.onTrigger={results:(yield(0,o.invokeWithContext)(f,t.onTrigger.bind(t),h,g))?.payload}),{result:yield(0,o.invokeWithContext)(f,t.onExecution.bind(t),g),loggerMock:f.logger}});var h=class{constructor(e){this.component=e}buildParams(e,t){let n=e.reduce((e,{key:t,default:n})=>Object.assign(Object.assign({},e),{[t]:`${n??``}`}),{});return Object.assign(Object.assign({},n),t)}connectionValue({key:e}){let{PRISMATIC_CONNECTION_VALUE:t}=process.env;if(!t)throw Error(`Unable to find connection value.`);return Object.assign(Object.assign({},JSON.parse(t)),{key:e})}trigger(n,r,i,a){return t(this,void 0,void 0,function*(){let t=this.component.triggers[n];return t.perform(u(a),Object.assign(Object.assign({},(0,e.defaultTriggerPayload)()),r),this.buildParams(t.inputs,i))})}triggerOnInstanceDeploy(e,n,r){return t(this,void 0,void 0,function*(){let t=this.component.triggers[e];if(!t.onInstanceDeploy)throw Error(`Trigger does not support onInstanceDeploy`);return t.onInstanceDeploy(u(r),this.buildParams(t.inputs,n))})}triggerOnInstanceDelete(e,n,r){return t(this,void 0,void 0,function*(){let t=this.component.triggers[e];if(!t.onInstanceDelete)throw Error(`Trigger does not support onInstanceDelete`);return t.onInstanceDelete(u(r),this.buildParams(t.inputs,n))})}action(e,n,r){return t(this,void 0,void 0,function*(){let t=this.component.actions[e];return t.perform(u(r),this.buildParams(t.inputs,n))})}dataSource(e,n,r){return t(this,void 0,void 0,function*(){let t=this.component.dataSources[e];return t.perform(f(r),this.buildParams(t.inputs,n))})}};e.ComponentTestHarness=h;function g(e){return`onExecution`in e&&typeof e.onExecution==`function`?new y(e):new h(e)}let _=e=>{let{configVars:t,configuration:n,userConfiguration:r,connections:i,context:a}=e;return d(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n===void 0?{}:{configuration:n}),r===void 0?{}:{userConfiguration:r}),i?{connections:m(i)}:{}),a),{configVars:p(t)}))},v=e=>(0,r.default)(e,e=>Buffer.isBuffer(e)?Buffer.from(e):void 0);var y=class{constructor(e){this.flow=e,this.mocks=new a.CallableMocks,this.instanceState={}}mock(e){return this.mocks.mock(e)}scoped(e){return t(this,void 0,void 0,function*(){return yield this.mocks.initialize(),yield(0,o.runWithCallableMocks)(this.mocks.dispatch,e)})}run(e={}){return this.execute(e,!1)}initialSync(e={}){return this.execute(e,!0)}execute(n,r){return this.scoped(()=>t(this,void 0,void 0,function*(){let i=(0,s.normalizeBoundTrigger)(this.flow),a=(0,s.getBoundTrigger)(i.onTrigger),l=i.batchConfig,u=(e,t)=>{if(!Number.isSafeInteger(e)||e<1)throw Error(`${t} must be a positive safe integer.`);return e},d=u(n.maxPages??100,`maxPages`),f=u(n.concurrency??1,`concurrency`);l&&(u(l.batchSize,`batchSize`),l.concurrentBatchLimit!==void 0&&(f=Math.min(f,u(l.concurrentBatchLimit,`concurrentBatchLimit`))));let p=Object.assign(Object.assign({},n),{context:Object.assign(Object.assign({instanceState:this.instanceState},n.context),{batch:l?{enabled:!0,batchSize:l.batchSize}:{enabled:!1}})}),m=_(p),h=Object.assign(Object.assign({},m),{polling:(0,c.createPollingState)(m)}),g=Object.assign(Object.assign({},(0,e.defaultTriggerPayload)()),v(n.payload)),y=[],b=0,x=()=>({loggerMock:m.logger,pages:b,results:y}),S=r?`onDeployResolver`:`triggerResolver`,C=a?a[S]:i[S],w=`trigger`in i?i.trigger:void 0,T=r?w?.onDeploy??i.onDeployTrigger:w?.onTrigger??i.onTrigger;if(r&&typeof T!=`function`)throw Error(`This flow has no initial-sync trigger.`);if(T!==void 0&&typeof T!=`function`)throw Error(`The flow harness requires a local trigger, not a platform trigger reference.`);if(l&&typeof T!=`function`)throw Error(`Batch discovery requires a trigger.`);if(l&&a&&!C)throw Error(`Bound callable ${S} is unavailable. Rebuild the component with this SDK; original component callbacks will not be executed.`);let E=e=>t(this,void 0,void 0,function*(){let t=_(Object.assign(Object.assign({},p),{context:Object.assign(Object.assign({},p.context),{logger:m.logger,executionState:{}})}));return yield(0,o.invokeWithContext)(t,i.onExecution.bind(i),{onTrigger:{results:e}})});for(;;){if(b>=d)throw Error(`Batch discovery exceeded maxPages (${d}). Check pagination mocks or increase maxPages.`);b++;let e=typeof T==`function`?yield(0,o.invokeWithContext)(h,T.bind(i),g,{}):{payload:g};if(b===1&&e?.polledNoChanges===!0)return Object.assign(Object.assign({},x()),{status:`skipped`,reason:`polledNoChanges`,result:void 0});if(!l){let t=yield(0,o.invokeWithContext)(m,i.onExecution.bind(i),{onTrigger:{results:e?.payload}});return y.push(t),Object.assign(Object.assign({},x()),{status:`completed`,result:t})}if(!e||!w&&!e.payload)throw Error(`Batch ${r?`onDeployPerform`:`perform`} returned no payload. Configure its callable mock.`);let n=w?e.items:C?.resolveItems?yield(0,o.invokeWithContext)(h,C.resolveItems,e):void 0;if(!Array.isArray(n))throw Error(`Batch ${S}.resolveItems must return an array. Configure its callable mock when using a component trigger.`);let a=w?e.paginationState??null:C?.getNextPaginationState?yield(0,o.invokeWithContext)(h,C.getNextPaginationState,e):null;if(a!==null&&(typeof a!=`object`||Array.isArray(a)))throw Error(`Batch ${S}.getNextPaginationState must return an object or null. Configure its callable mock.`);let s=w?g:e.payload,c=[];for(let e=0;e<n.length;e+=l.batchSize)c.push(v(Object.assign(Object.assign({},s),{body:Object.assign(Object.assign({},s.body),{data:l.batchSize===1?n[e]:n.slice(e,e+l.batchSize)})})));let u=0,p=!1,_=Array(c.length),D=Array.from({length:Math.min(f,c.length)},()=>t(this,void 0,void 0,function*(){for(;!p&&u<c.length;){let e=u++;try{_[e]=yield E(c[e])}catch(e){throw p=!0,e}}})),O=(yield Promise.allSettled(D)).find(e=>e.status===`rejected`);if(O?.status===`rejected`)throw O.reason;if(y.push(..._),a===null)return Object.assign(Object.assign({},x()),{status:`batched`,result:void 0});g=Object.assign(Object.assign({},g),{paginationState:v(a)})}}))}invoke(e,t={}){let n=_(Object.assign(Object.assign({},t),{context:Object.assign({instanceState:this.instanceState},t.context)}));return this.scoped(()=>(0,o.invokeWithContext)(n,e))}configuration(e,t){let n=f(t);return this.scoped(()=>(0,o.runWithDataSourceContext)(n,()=>e(n)))}onInstanceDeploy(e={}){return this.invoke(e=>{var t;return(t=(0,s.normalizeBoundTrigger)(this.flow)).onInstanceDeploy?.call(t,e,{})},e)}onInstanceDelete(e={}){return this.invoke(e=>{var t;return(t=(0,s.normalizeBoundTrigger)(this.flow)).onInstanceDelete?.call(t,e,{})},e)}};e.FlowTestHarness=y,e.default={loggerMock:e.loggerMock,invoke:e.invoke,invokeTrigger:e.invokeTrigger,createHarness:g,invokeDataSource:e.invokeDataSource}})),Mm=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||(function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null)for(var a=e(r),o=0;o<a.length;o++)a[o]!=="default"&&t(i,r,a[o]);return n(i,r),i}})(),i=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)},a=e&&e.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},o=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.util=e.testing=e.requireIntegrationContext=e.requireContext=e.findUserDefinedComponentKey=e.conditionalLogic=e.componentManifests=e.oauth2Connection=e.onPremConnection=e.connection=e.dynamicObjectInput=e.structuredObjectInput=e.input=e.dataSource=e.pollingTrigger=e.batchTrigger=e.trigger=e.outputSchema=e.action=e.component=e.componentManifest=e.userActivatedConnection=e.organizationActivatedConnection=e.customerActivatedConnection=e.connectionConfigVar=e.dataSourceConfigVar=e.configVar=e.userLevelConfigPage=e.serverFunction=e.configuration=e.configPage=e.batchFlowTrigger=e.flow=e.integration=e.callableComponent=void 0;let s=Sm(),c=Cm();var l=Sm();Object.defineProperty(e,"callableComponent",{enumerable:!0,get:function(){return l.callableComponent}});let u=Tf(),d=xm(),f=gm();e.integration=e=>{let t=(0,c.runWithIntegrationContext)(e,()=>(0,f.convertIntegration)(e));return process.env?.DEBUG===`true`&&console.info(t.codeNativeIntegrationYAML),t},e.flow=e=>e,e.batchFlowTrigger=e=>e,e.configPage=e=>e,e.configuration=e=>e,e.serverFunction=e=>e,e.userLevelConfigPage=e=>e,e.configVar=e=>e,e.dataSourceConfigVar=e=>e,e.connectionConfigVar=e=>e,e.customerActivatedConnection=e=>Object.assign(Object.assign({},e),{dataType:`connection`}),e.organizationActivatedConnection=e=>Object.assign(Object.assign({},e),{dataType:`connection`}),e.userActivatedConnection=e=>Object.assign(Object.assign({},e),{dataType:`userScopedConnection`}),e.componentManifest=e=>e,e.component=e=>(0,s.retainAuthoring)((0,d.convertComponent)(e),e),e.action=e=>e,e.outputSchema=e=>e,e.trigger=e=>e,e.batchTrigger=e=>{let{perform:t,onDeploy:n}=e,r=a(e,[`perform`,`onDeploy`]);return Object.assign(Object.assign(Object.assign({},r),{perform:(0,u.withPolledResultType)((0,u.wrapBatchedFire)((0,u.withPollingState)(t))),synchronousResponseSupport:`invalid`,triggerResolverSupport:`required`,triggerResolver:u.defaultBatchResolver}),n?{onDeployPerform:(0,u.withPolledResultType)((0,u.wrapBatchedFire)((0,u.withPollingState)(n.perform))),onDeployResolver:Object.assign(Object.assign({},u.defaultBatchResolver),{inputs:n.inputs})}:{})},e.pollingTrigger=e=>Object.assign(Object.assign({},e),{triggerType:`polling`}),e.dataSource=e=>e,e.input=e=>e,e.structuredObjectInput=e=>Object.assign(Object.assign({},e),{type:`structuredObject`}),e.dynamicObjectInput=e=>Object.assign(Object.assign({},e),{type:`dynamicObject`}),e.connection=e=>e,e.onPremConnection=e=>e,e.oauth2Connection=e=>e,e.componentManifests=e=>e,e.conditionalLogic=r(pl()),i(ml(),e);var p=Cm();Object.defineProperty(e,"findUserDefinedComponentKey",{enumerable:!0,get:function(){return p.findUserDefinedComponentKey}}),Object.defineProperty(e,"requireContext",{enumerable:!0,get:function(){return p.requireContext}}),Object.defineProperty(e,"requireIntegrationContext",{enumerable:!0,get:function(){return p.requireIntegrationContext}});var m=jm();Object.defineProperty(e,"testing",{enumerable:!0,get:function(){return o(m).default}}),i(Sr(),e);var h=hl();Object.defineProperty(e,"util",{enumerable:!0,get:function(){return o(h).default}})})),Nm=u(Al()),Pm=Mm();const Fm=(0,Pm.input)({label:`Connection`,type:`connection`,required:!0,comments:`The SFTP connection to use.`}),Im=(0,Pm.input)({label:`Path`,placeholder:`Enter path`,type:`string`,required:!0,comments:`The path of the directory on the SFTP server to list files from.`,example:`/path/to/directory/`,clean:Pm.util.types.toString}),Lm=(0,Pm.input)({label:`Include Subfolders`,comments:`When true, recursively creates any missing directories in the path.`,type:`boolean`,required:!1,default:`true`,clean:Pm.util.types.toBool}),Rm=(0,Pm.input)({label:`Return Buffer`,type:`boolean`,required:!0,default:`false`,comments:`When true, treats the file as a binary file with content type 'application/octet-stream', even if it is a text file. This is helpful if you are processing non-UTF-8 text files, as the runner assumes text files are UTF-8.`,clean:Pm.util.types.toBool}),zm=(0,Pm.input)({label:`Path`,placeholder:`Enter path`,type:`string`,required:!0,comments:`The path to the file on the SFTP server.`,example:`/we/love/commas.csv`,clean:Pm.util.types.toString}),Bm=(0,Pm.input)({...zm,placeholder:`Enter path`,comments:`The path on the SFTP server where data will be appended.`,example:`/path/to/remote/file.txt`}),Vm=(0,Pm.input)({label:`Data`,placeholder:`Enter data`,type:`text`,required:!0,comments:`The text or data to write into the file.`,clean:e=>Pm.util.types.isData(e)?Pm.util.types.toData(e).data:Buffer.from(typeof e==`string`?e:JSON.stringify(e))}),Hm=(0,Pm.input)({...Vm,placeholder:`Enter data`,comments:`The text or data to append to the file.`}),Um=(0,Pm.input)({label:`Pattern`,default:`*`,placeholder:`Enter pattern`,type:`string`,required:!1,comments:`The glob-style pattern for filtering files (e.g., *.txt).`,example:`*.txt`,clean:Pm.util.types.toString}),Wm=(0,Pm.input)({label:`Include Subdirectories`,default:`false`,type:`boolean`,required:!1,comments:`When true, recursively monitors files in all subdirectories. When false, only monitors files in the specified directory.`,clean:Pm.util.types.toBool}),Gm=(0,Pm.input)({label:`Include Directories`,default:`false`,type:`boolean`,required:!1,comments:`When true, lists directories in addition to files. When false, only lists files.`,clean:Pm.util.types.toBool});var Km=s(((e,t)=>{t.exports={newInvalidAsn1Error:function(e){var t=Error();return t.name=`InvalidAsn1Error`,t.message=e||``,t}}})),qm=s(((e,t)=>{t.exports={EOC:0,Boolean:1,Integer:2,BitString:3,OctetString:4,Null:5,OID:6,ObjectDescriptor:7,External:8,Real:9,Enumeration:10,PDV:11,Utf8String:12,RelativeOID:13,Sequence:16,Set:17,NumericString:18,PrintableString:19,T61String:20,VideotexString:21,IA5String:22,UTCTime:23,GeneralizedTime:24,GraphicString:25,VisibleString:26,GeneralString:28,UniversalString:29,CharacterString:30,BMPString:31,Constructor:32,Context:128}})),Jm=s(((e,t)=>{var n=require("buffer"),r=n.Buffer,i={},a;for(a in n)n.hasOwnProperty(a)&&(a===`SlowBuffer`||a===`Buffer`||(i[a]=n[a]));var o=i.Buffer={};for(a in r)r.hasOwnProperty(a)&&(a===`allocUnsafe`||a===`allocUnsafeSlow`||(o[a]=r[a]));if(i.Buffer.prototype=r.prototype,(!o.from||o.from===Uint8Array.from)&&(o.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type `+typeof e);if(e&&e.length===void 0)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);return r(e,t,n)}),o.alloc||=function(e,t,n){if(typeof e!=`number`)throw TypeError(`The "size" argument must be of type number. Received type `+typeof e);if(e<0||e>=2*(1<<30))throw RangeError(`The value "`+e+`" is invalid for option "size"`);var i=r(e);return!t||t.length===0?i.fill(0):typeof n==`string`?i.fill(t,n):i.fill(t),i},!i.kStringMaxLength)try{i.kStringMaxLength=process.binding(`buffer`).kStringMaxLength}catch{}i.constants||(i.constants={MAX_LENGTH:i.kMaxLength},i.kStringMaxLength&&(i.constants.MAX_STRING_LENGTH=i.kStringMaxLength)),t.exports=i})),Ym=s(((e,t)=>{var n=require("assert"),r=Jm().Buffer,i=qm(),a=Km().newInvalidAsn1Error;function o(e){if(!e||!r.isBuffer(e))throw TypeError(`data must be a node Buffer`);this._buf=e,this._size=e.length,this._len=0,this._offset=0}Object.defineProperty(o.prototype,"length",{enumerable:!0,get:function(){return this._len}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){return this._offset}}),Object.defineProperty(o.prototype,"remain",{get:function(){return this._size-this._offset}}),Object.defineProperty(o.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}}),o.prototype.readByte=function(e){if(this._size-this._offset<1)return null;var t=this._buf[this._offset]&255;return e||(this._offset+=1),t},o.prototype.peek=function(){return this.readByte(!0)},o.prototype.readLength=function(e){if(e===void 0&&(e=this._offset),e>=this._size)return null;var t=this._buf[e++]&255;if(t===null)return null;if((t&128)==128){if(t&=127,t===0)throw a(`Indefinite length not supported`);if(t>4)throw a(`encoding too long`);if(this._size-e<t)return null;this._len=0;for(var n=0;n<t;n++)this._len=(this._len<<8)+(this._buf[e++]&255)}else this._len=t;return e},o.prototype.readSequence=function(e){var t=this.peek();if(t===null)return null;if(e!==void 0&&e!==t)throw a(`Expected 0x`+e.toString(16)+`: got 0x`+t.toString(16));var n=this.readLength(this._offset+1);return n===null?null:(this._offset=n,t)},o.prototype.readInt=function(){return this._readTag(i.Integer)},o.prototype.readBoolean=function(){return this._readTag(i.Boolean)!==0},o.prototype.readEnumeration=function(){return this._readTag(i.Enumeration)},o.prototype.readString=function(e,t){e||=i.OctetString;var n=this.peek();if(n===null)return null;if(n!==e)throw a(`Expected 0x`+e.toString(16)+`: got 0x`+n.toString(16));var o=this.readLength(this._offset+1);if(o===null||this.length>this._size-o)return null;if(this._offset=o,this.length===0)return t?r.alloc(0):``;var s=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?s:s.toString(`utf8`)},o.prototype.readOID=function(e){e||=i.OID;var t=this.readString(e,!0);if(t===null)return null;for(var n=[],r=0,a=0;a<t.length;a++){var o=t[a]&255;r<<=7,r+=o&127,o&128||(n.push(r),r=0)}return r=n.shift(),n.unshift(r%40),n.unshift(r/40>>0),n.join(`.`)},o.prototype._readTag=function(e){n.ok(e!==void 0);var t=this.peek();if(t===null)return null;if(t!==e)throw a(`Expected 0x`+e.toString(16)+`: got 0x`+t.toString(16));var r=this.readLength(this._offset+1);if(r===null)return null;if(this.length>4)throw a(`Integer too long: `+this.length);if(this.length>this._size-r)return null;this._offset=r;for(var i=this._buf[this._offset],o=0,s=0;s<this.length;s++)o<<=8,o|=this._buf[this._offset++]&255;return(i&128)==128&&s!==4&&(o-=1<<s*8),o>>0},t.exports=o})),Xm=s(((e,t)=>{var n=require("assert"),r=Jm().Buffer,i=qm(),a=Km().newInvalidAsn1Error,o={size:1024,growthFactor:8};function s(e,t){return n.ok(e),n.equal(typeof e,`object`),n.ok(t),n.equal(typeof t,`object`),Object.getOwnPropertyNames(e).forEach(function(n){if(!t[n]){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r)}}),t}function c(e){e=s(o,e||{}),this._buf=r.alloc(e.size||1024),this._size=this._buf.length,this._offset=0,this._options=e,this._seq=[]}Object.defineProperty(c.prototype,"buffer",{get:function(){if(this._seq.length)throw a(this._seq.length+` unended sequence(s)`);return this._buf.slice(0,this._offset)}}),c.prototype.writeByte=function(e){if(typeof e!=`number`)throw TypeError(`argument must be a Number`);this._ensure(1),this._buf[this._offset++]=e},c.prototype.writeInt=function(e,t){if(typeof e!=`number`)throw TypeError(`argument must be a Number`);typeof t!=`number`&&(t=i.Integer);for(var n=4;(!(e&4286578688)||(e&4286578688)==-8388608)&&n>1;)n--,e<<=8;if(n>4)throw a(`BER ints cannot be > 0xffffffff`);for(this._ensure(2+n),this._buf[this._offset++]=t,this._buf[this._offset++]=n;n-->0;)this._buf[this._offset++]=(e&4278190080)>>>24,e<<=8},c.prototype.writeNull=function(){this.writeByte(i.Null),this.writeByte(0)},c.prototype.writeEnumeration=function(e,t){if(typeof e!=`number`)throw TypeError(`argument must be a Number`);return typeof t!=`number`&&(t=i.Enumeration),this.writeInt(e,t)},c.prototype.writeBoolean=function(e,t){if(typeof e!=`boolean`)throw TypeError(`argument must be a Boolean`);typeof t!=`number`&&(t=i.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=e?255:0},c.prototype.writeString=function(e,t){if(typeof e!=`string`)throw TypeError(`argument must be a string (was: `+typeof e+`)`);typeof t!=`number`&&(t=i.OctetString);var n=r.byteLength(e);this.writeByte(t),this.writeLength(n),n&&(this._ensure(n),this._buf.write(e,this._offset),this._offset+=n)},c.prototype.writeBuffer=function(e,t){if(typeof t!=`number`)throw TypeError(`tag must be a number`);if(!r.isBuffer(e))throw TypeError(`argument must be a buffer`);this.writeByte(t),this.writeLength(e.length),this._ensure(e.length),e.copy(this._buf,this._offset,0,e.length),this._offset+=e.length},c.prototype.writeStringArray=function(e){if(!e instanceof Array)throw TypeError(`argument must be an Array[String]`);var t=this;e.forEach(function(e){t.writeString(e)})},c.prototype.writeOID=function(e,t){if(typeof e!=`string`)throw TypeError(`argument must be a string`);if(typeof t!=`number`&&(t=i.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(e))throw Error(`argument is not a valid OID string`);function n(e,t){t<128?e.push(t):t<16384?(e.push(t>>>7|128),e.push(t&127)):t<2097152?(e.push(t>>>14|128),e.push((t>>>7|128)&255),e.push(t&127)):t<268435456?(e.push(t>>>21|128),e.push((t>>>14|128)&255),e.push((t>>>7|128)&255),e.push(t&127)):(e.push((t>>>28|128)&255),e.push((t>>>21|128)&255),e.push((t>>>14|128)&255),e.push((t>>>7|128)&255),e.push(t&127))}var r=e.split(`.`),a=[];a.push(parseInt(r[0],10)*40+parseInt(r[1],10)),r.slice(2).forEach(function(e){n(a,parseInt(e,10))});var o=this;this._ensure(2+a.length),this.writeByte(t),this.writeLength(a.length),a.forEach(function(e){o.writeByte(e)})},c.prototype.writeLength=function(e){if(typeof e!=`number`)throw TypeError(`argument must be a Number`);if(this._ensure(4),e<=127)this._buf[this._offset++]=e;else if(e<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=e;else if(e<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=e>>8,this._buf[this._offset++]=e;else if(e<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=e>>16,this._buf[this._offset++]=e>>8,this._buf[this._offset++]=e;else throw a(`Length too long (> 4 bytes)`)},c.prototype.startSequence=function(e){typeof e!=`number`&&(e=i.Sequence|i.Constructor),this.writeByte(e),this._seq.push(this._offset),this._ensure(3),this._offset+=3},c.prototype.endSequence=function(){var e=this._seq.pop(),t=e+3,n=this._offset-t;if(n<=127)this._shift(t,n,-2),this._buf[e]=n;else if(n<=255)this._shift(t,n,-1),this._buf[e]=129,this._buf[e+1]=n;else if(n<=65535)this._buf[e]=130,this._buf[e+1]=n>>8,this._buf[e+2]=n;else if(n<=16777215)this._shift(t,n,1),this._buf[e]=131,this._buf[e+1]=n>>16,this._buf[e+2]=n>>8,this._buf[e+3]=n;else throw a(`Sequence too long`)},c.prototype._shift=function(e,t,r){n.ok(e!==void 0),n.ok(t!==void 0),n.ok(r),this._buf.copy(this._buf,e+r,e,e+t),this._offset+=r},c.prototype._ensure=function(e){if(n.ok(e),this._size-this._offset<e){var t=this._size*this._options.growthFactor;t-this._offset<e&&(t+=e);var i=r.alloc(t);this._buf.copy(i,0,0,this._offset),this._buf=i,this._size=t}},t.exports=c})),Zm=s(((e,t)=>{var n=Km(),r=qm();for(var i in t.exports={Reader:Ym(),Writer:Xm()},r)r.hasOwnProperty(i)&&(t.exports[i]=r[i]);for(var a in n)n.hasOwnProperty(a)&&(t.exports[a]=n[a])})),Qm=s(((e,t)=>{var n=Zm();t.exports={Ber:n,BerReader:n.Reader,BerWriter:n.Writer}})),$m=s(((e,t)=>{(function(e){"use strict";var t=function(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;t++)n[t]=e[t];return n},n=function(){throw Error(`no PRNG`)},r=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var a=t(),o=t([1]),s=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),d=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),f=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(e,t,n,r){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=n&255,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=r&255}function m(e,t,n,r,i){var a,o=0;for(a=0;a<i;a++)o|=e[t+a]^n[r+a];return(1&o-1>>>8)-1}function h(e,t,n,r){return m(e,t,n,r,16)}function g(e,t,n,r){return m(e,t,n,r,32)}function _(e,t,n,r){for(var i=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,a=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,o=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,s=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,c=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,l=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,u=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,d=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,f=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,p=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,m=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,h=n[16]&255|(n[17]&255)<<8|(n[18]&255)<<16|(n[19]&255)<<24,g=n[20]&255|(n[21]&255)<<8|(n[22]&255)<<16|(n[23]&255)<<24,_=n[24]&255|(n[25]&255)<<8|(n[26]&255)<<16|(n[27]&255)<<24,v=n[28]&255|(n[29]&255)<<8|(n[30]&255)<<16|(n[31]&255)<<24,y=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,b=i,x=a,S=o,C=s,w=c,T=l,E=u,D=d,O=f,k=p,A=m,j=h,M=g,N=_,P=v,F=y,I,L=0;L<20;L+=2)I=b+M|0,w^=I<<7|I>>>25,I=w+b|0,O^=I<<9|I>>>23,I=O+w|0,M^=I<<13|I>>>19,I=M+O|0,b^=I<<18|I>>>14,I=T+x|0,k^=I<<7|I>>>25,I=k+T|0,N^=I<<9|I>>>23,I=N+k|0,x^=I<<13|I>>>19,I=x+N|0,T^=I<<18|I>>>14,I=A+E|0,P^=I<<7|I>>>25,I=P+A|0,S^=I<<9|I>>>23,I=S+P|0,E^=I<<13|I>>>19,I=E+S|0,A^=I<<18|I>>>14,I=F+j|0,C^=I<<7|I>>>25,I=C+F|0,D^=I<<9|I>>>23,I=D+C|0,j^=I<<13|I>>>19,I=j+D|0,F^=I<<18|I>>>14,I=b+C|0,x^=I<<7|I>>>25,I=x+b|0,S^=I<<9|I>>>23,I=S+x|0,C^=I<<13|I>>>19,I=C+S|0,b^=I<<18|I>>>14,I=T+w|0,E^=I<<7|I>>>25,I=E+T|0,D^=I<<9|I>>>23,I=D+E|0,w^=I<<13|I>>>19,I=w+D|0,T^=I<<18|I>>>14,I=A+k|0,j^=I<<7|I>>>25,I=j+A|0,O^=I<<9|I>>>23,I=O+j|0,k^=I<<13|I>>>19,I=k+O|0,A^=I<<18|I>>>14,I=F+P|0,M^=I<<7|I>>>25,I=M+F|0,N^=I<<9|I>>>23,I=N+M|0,P^=I<<13|I>>>19,I=P+N|0,F^=I<<18|I>>>14;b=b+i|0,x=x+a|0,S=S+o|0,C=C+s|0,w=w+c|0,T=T+l|0,E=E+u|0,D=D+d|0,O=O+f|0,k=k+p|0,A=A+m|0,j=j+h|0,M=M+g|0,N=N+_|0,P=P+v|0,F=F+y|0,e[0]=b>>>0&255,e[1]=b>>>8&255,e[2]=b>>>16&255,e[3]=b>>>24&255,e[4]=x>>>0&255,e[5]=x>>>8&255,e[6]=x>>>16&255,e[7]=x>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=C>>>0&255,e[13]=C>>>8&255,e[14]=C>>>16&255,e[15]=C>>>24&255,e[16]=w>>>0&255,e[17]=w>>>8&255,e[18]=w>>>16&255,e[19]=w>>>24&255,e[20]=T>>>0&255,e[21]=T>>>8&255,e[22]=T>>>16&255,e[23]=T>>>24&255,e[24]=E>>>0&255,e[25]=E>>>8&255,e[26]=E>>>16&255,e[27]=E>>>24&255,e[28]=D>>>0&255,e[29]=D>>>8&255,e[30]=D>>>16&255,e[31]=D>>>24&255,e[32]=O>>>0&255,e[33]=O>>>8&255,e[34]=O>>>16&255,e[35]=O>>>24&255,e[36]=k>>>0&255,e[37]=k>>>8&255,e[38]=k>>>16&255,e[39]=k>>>24&255,e[40]=A>>>0&255,e[41]=A>>>8&255,e[42]=A>>>16&255,e[43]=A>>>24&255,e[44]=j>>>0&255,e[45]=j>>>8&255,e[46]=j>>>16&255,e[47]=j>>>24&255,e[48]=M>>>0&255,e[49]=M>>>8&255,e[50]=M>>>16&255,e[51]=M>>>24&255,e[52]=N>>>0&255,e[53]=N>>>8&255,e[54]=N>>>16&255,e[55]=N>>>24&255,e[56]=P>>>0&255,e[57]=P>>>8&255,e[58]=P>>>16&255,e[59]=P>>>24&255,e[60]=F>>>0&255,e[61]=F>>>8&255,e[62]=F>>>16&255,e[63]=F>>>24&255}function v(e,t,n,r){for(var i=r[0]&255|(r[1]&255)<<8|(r[2]&255)<<16|(r[3]&255)<<24,a=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,o=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,s=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,c=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,l=r[4]&255|(r[5]&255)<<8|(r[6]&255)<<16|(r[7]&255)<<24,u=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,d=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,f=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,p=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,m=r[8]&255|(r[9]&255)<<8|(r[10]&255)<<16|(r[11]&255)<<24,h=n[16]&255|(n[17]&255)<<8|(n[18]&255)<<16|(n[19]&255)<<24,g=n[20]&255|(n[21]&255)<<8|(n[22]&255)<<16|(n[23]&255)<<24,_=n[24]&255|(n[25]&255)<<8|(n[26]&255)<<16|(n[27]&255)<<24,v=n[28]&255|(n[29]&255)<<8|(n[30]&255)<<16|(n[31]&255)<<24,y=r[12]&255|(r[13]&255)<<8|(r[14]&255)<<16|(r[15]&255)<<24,b=i,x=a,S=o,C=s,w=c,T=l,E=u,D=d,O=f,k=p,A=m,j=h,M=g,N=_,P=v,F=y,I,L=0;L<20;L+=2)I=b+M|0,w^=I<<7|I>>>25,I=w+b|0,O^=I<<9|I>>>23,I=O+w|0,M^=I<<13|I>>>19,I=M+O|0,b^=I<<18|I>>>14,I=T+x|0,k^=I<<7|I>>>25,I=k+T|0,N^=I<<9|I>>>23,I=N+k|0,x^=I<<13|I>>>19,I=x+N|0,T^=I<<18|I>>>14,I=A+E|0,P^=I<<7|I>>>25,I=P+A|0,S^=I<<9|I>>>23,I=S+P|0,E^=I<<13|I>>>19,I=E+S|0,A^=I<<18|I>>>14,I=F+j|0,C^=I<<7|I>>>25,I=C+F|0,D^=I<<9|I>>>23,I=D+C|0,j^=I<<13|I>>>19,I=j+D|0,F^=I<<18|I>>>14,I=b+C|0,x^=I<<7|I>>>25,I=x+b|0,S^=I<<9|I>>>23,I=S+x|0,C^=I<<13|I>>>19,I=C+S|0,b^=I<<18|I>>>14,I=T+w|0,E^=I<<7|I>>>25,I=E+T|0,D^=I<<9|I>>>23,I=D+E|0,w^=I<<13|I>>>19,I=w+D|0,T^=I<<18|I>>>14,I=A+k|0,j^=I<<7|I>>>25,I=j+A|0,O^=I<<9|I>>>23,I=O+j|0,k^=I<<13|I>>>19,I=k+O|0,A^=I<<18|I>>>14,I=F+P|0,M^=I<<7|I>>>25,I=M+F|0,N^=I<<9|I>>>23,I=N+M|0,P^=I<<13|I>>>19,I=P+N|0,F^=I<<18|I>>>14;e[0]=b>>>0&255,e[1]=b>>>8&255,e[2]=b>>>16&255,e[3]=b>>>24&255,e[4]=T>>>0&255,e[5]=T>>>8&255,e[6]=T>>>16&255,e[7]=T>>>24&255,e[8]=A>>>0&255,e[9]=A>>>8&255,e[10]=A>>>16&255,e[11]=A>>>24&255,e[12]=F>>>0&255,e[13]=F>>>8&255,e[14]=F>>>16&255,e[15]=F>>>24&255,e[16]=E>>>0&255,e[17]=E>>>8&255,e[18]=E>>>16&255,e[19]=E>>>24&255,e[20]=D>>>0&255,e[21]=D>>>8&255,e[22]=D>>>16&255,e[23]=D>>>24&255,e[24]=O>>>0&255,e[25]=O>>>8&255,e[26]=O>>>16&255,e[27]=O>>>24&255,e[28]=k>>>0&255,e[29]=k>>>8&255,e[30]=k>>>16&255,e[31]=k>>>24&255}function y(e,t,n,r){_(e,t,n,r)}function b(e,t,n,r){v(e,t,n,r)}var x=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function S(e,t,n,r,i,a,o){var s=new Uint8Array(16),c=new Uint8Array(64),l,u;for(u=0;u<16;u++)s[u]=0;for(u=0;u<8;u++)s[u]=a[u];for(;i>=64;){for(y(c,s,o,x),u=0;u<64;u++)e[t+u]=n[r+u]^c[u];for(l=1,u=8;u<16;u++)l=l+(s[u]&255)|0,s[u]=l&255,l>>>=8;i-=64,t+=64,r+=64}if(i>0)for(y(c,s,o,x),u=0;u<i;u++)e[t+u]=n[r+u]^c[u];return 0}function C(e,t,n,r,i){var a=new Uint8Array(16),o=new Uint8Array(64),s,c;for(c=0;c<16;c++)a[c]=0;for(c=0;c<8;c++)a[c]=r[c];for(;n>=64;){for(y(o,a,i,x),c=0;c<64;c++)e[t+c]=o[c];for(s=1,c=8;c<16;c++)s=s+(a[c]&255)|0,a[c]=s&255,s>>>=8;n-=64,t+=64}if(n>0)for(y(o,a,i,x),c=0;c<n;c++)e[t+c]=o[c];return 0}function w(e,t,n,r,i){var a=new Uint8Array(32);b(a,r,i,x);for(var o=new Uint8Array(8),s=0;s<8;s++)o[s]=r[s+16];return C(e,t,n,o,a)}function T(e,t,n,r,i,a,o){var s=new Uint8Array(32);b(s,a,o,x);for(var c=new Uint8Array(8),l=0;l<8;l++)c[l]=a[l+16];return S(e,t,n,r,i,c,s)}var E=function(e){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var t=e[0]&255|(e[1]&255)<<8,n,r,i,a,o,s,c;this.r[0]=t&8191,n=e[2]&255|(e[3]&255)<<8,this.r[1]=(t>>>13|n<<3)&8191,r=e[4]&255|(e[5]&255)<<8,this.r[2]=(n>>>10|r<<6)&7939,i=e[6]&255|(e[7]&255)<<8,this.r[3]=(r>>>7|i<<9)&8191,a=e[8]&255|(e[9]&255)<<8,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,o=e[10]&255|(e[11]&255)<<8,this.r[6]=(a>>>14|o<<2)&8191,s=e[12]&255|(e[13]&255)<<8,this.r[7]=(o>>>11|s<<5)&8065,c=e[14]&255|(e[15]&255)<<8,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127,this.pad[0]=e[16]&255|(e[17]&255)<<8,this.pad[1]=e[18]&255|(e[19]&255)<<8,this.pad[2]=e[20]&255|(e[21]&255)<<8,this.pad[3]=e[22]&255|(e[23]&255)<<8,this.pad[4]=e[24]&255|(e[25]&255)<<8,this.pad[5]=e[26]&255|(e[27]&255)<<8,this.pad[6]=e[28]&255|(e[29]&255)<<8,this.pad[7]=e[30]&255|(e[31]&255)<<8};E.prototype.blocks=function(e,t,n){for(var r=this.fin?0:2048,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C=this.h[0],w=this.h[1],T=this.h[2],E=this.h[3],D=this.h[4],O=this.h[5],k=this.h[6],A=this.h[7],j=this.h[8],M=this.h[9],N=this.r[0],P=this.r[1],F=this.r[2],I=this.r[3],L=this.r[4],R=this.r[5],z=this.r[6],B=this.r[7],V=this.r[8],H=this.r[9];n>=16;)i=e[t+0]&255|(e[t+1]&255)<<8,C+=i&8191,a=e[t+2]&255|(e[t+3]&255)<<8,w+=(i>>>13|a<<3)&8191,o=e[t+4]&255|(e[t+5]&255)<<8,T+=(a>>>10|o<<6)&8191,s=e[t+6]&255|(e[t+7]&255)<<8,E+=(o>>>7|s<<9)&8191,c=e[t+8]&255|(e[t+9]&255)<<8,D+=(s>>>4|c<<12)&8191,O+=c>>>1&8191,l=e[t+10]&255|(e[t+11]&255)<<8,k+=(c>>>14|l<<2)&8191,u=e[t+12]&255|(e[t+13]&255)<<8,A+=(l>>>11|u<<5)&8191,d=e[t+14]&255|(e[t+15]&255)<<8,j+=(u>>>8|d<<8)&8191,M+=d>>>5|r,f=0,p=f,p+=C*N,p+=5*H*w,p+=5*V*T,p+=5*B*E,p+=5*z*D,f=p>>>13,p&=8191,p+=5*R*O,p+=5*L*k,p+=5*I*A,p+=5*F*j,p+=5*P*M,f+=p>>>13,p&=8191,m=f,m+=C*P,m+=w*N,m+=5*H*T,m+=5*V*E,m+=5*B*D,f=m>>>13,m&=8191,m+=5*z*O,m+=5*R*k,m+=5*L*A,m+=5*I*j,m+=5*F*M,f+=m>>>13,m&=8191,h=f,h+=C*F,h+=w*P,h+=T*N,h+=5*H*E,h+=5*V*D,f=h>>>13,h&=8191,h+=5*B*O,h+=5*z*k,h+=5*R*A,h+=5*L*j,h+=5*I*M,f+=h>>>13,h&=8191,g=f,g+=C*I,g+=w*F,g+=T*P,g+=E*N,g+=5*H*D,f=g>>>13,g&=8191,g+=5*V*O,g+=5*B*k,g+=5*z*A,g+=5*R*j,g+=5*L*M,f+=g>>>13,g&=8191,_=f,_+=C*L,_+=w*I,_+=T*F,_+=E*P,_+=D*N,f=_>>>13,_&=8191,_+=5*H*O,_+=5*V*k,_+=5*B*A,_+=5*z*j,_+=5*R*M,f+=_>>>13,_&=8191,v=f,v+=C*R,v+=w*L,v+=T*I,v+=E*F,v+=D*P,f=v>>>13,v&=8191,v+=O*N,v+=5*H*k,v+=5*V*A,v+=5*B*j,v+=5*z*M,f+=v>>>13,v&=8191,y=f,y+=C*z,y+=w*R,y+=T*L,y+=E*I,y+=D*F,f=y>>>13,y&=8191,y+=O*P,y+=k*N,y+=5*H*A,y+=5*V*j,y+=5*B*M,f+=y>>>13,y&=8191,b=f,b+=C*B,b+=w*z,b+=T*R,b+=E*L,b+=D*I,f=b>>>13,b&=8191,b+=O*F,b+=k*P,b+=A*N,b+=5*H*j,b+=5*V*M,f+=b>>>13,b&=8191,x=f,x+=C*V,x+=w*B,x+=T*z,x+=E*R,x+=D*L,f=x>>>13,x&=8191,x+=O*I,x+=k*F,x+=A*P,x+=j*N,x+=5*H*M,f+=x>>>13,x&=8191,S=f,S+=C*H,S+=w*V,S+=T*B,S+=E*z,S+=D*R,f=S>>>13,S&=8191,S+=O*L,S+=k*I,S+=A*F,S+=j*P,S+=M*N,f+=S>>>13,S&=8191,f=(f<<2)+f|0,f=f+p|0,p=f&8191,f>>>=13,m+=f,C=p,w=m,T=h,E=g,D=_,O=v,k=y,A=b,j=x,M=S,t+=16,n-=16;this.h[0]=C,this.h[1]=w,this.h[2]=T,this.h[3]=E,this.h[4]=D,this.h[5]=O,this.h[6]=k,this.h[7]=A,this.h[8]=j,this.h[9]=M},E.prototype.finish=function(e,t){var n=new Uint16Array(10),r,i,a,o;if(this.leftover){for(o=this.leftover,this.buffer[o++]=1;o<16;o++)this.buffer[o]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,o=2;o<10;o++)this.h[o]+=r,r=this.h[o]>>>13,this.h[o]&=8191;for(this.h[0]+=r*5,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,n[0]=this.h[0]+5,r=n[0]>>>13,n[0]&=8191,o=1;o<10;o++)n[o]=this.h[o]+r,r=n[o]>>>13,n[o]&=8191;for(n[9]-=8192,i=(r^1)-1,o=0;o<10;o++)n[o]&=i;for(i=~i,o=0;o<10;o++)this.h[o]=this.h[o]&i|n[o];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,a=this.h[0]+this.pad[0],this.h[0]=a&65535,o=1;o<8;o++)a=(this.h[o]+this.pad[o]|0)+(a>>>16)|0,this.h[o]=a&65535;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},E.prototype.update=function(e,t,n){var r,i;if(this.leftover){for(i=16-this.leftover,i>n&&(i=n),r=0;r<i;r++)this.buffer[this.leftover+r]=e[t+r];if(n-=i,t+=i,this.leftover+=i,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(i=n-n%16,this.blocks(e,t,i),t+=i,n-=i),n){for(r=0;r<n;r++)this.buffer[this.leftover+r]=e[t+r];this.leftover+=n}};function D(e,t,n,r,i,a){var o=new E(a);return o.update(n,r,i),o.finish(e,t),0}function O(e,t,n,r,i,a){var o=new Uint8Array(16);return D(o,0,n,r,i,a),h(e,t,o,0)}function k(e,t,n,r,i){var a;if(n<32)return-1;for(T(e,0,t,0,n,r,i),D(e,16,e,32,n-32,e),a=0;a<16;a++)e[a]=0;return 0}function A(e,t,n,r,i){var a,o=new Uint8Array(32);if(n<32||(w(o,0,32,r,i),O(t,16,t,32,n-32,o)!==0))return-1;for(T(e,0,t,0,n,r,i),a=0;a<32;a++)e[a]=0;return 0}function j(e,t){var n;for(n=0;n<16;n++)e[n]=t[n]|0}function M(e){var t,n,r=1;for(t=0;t<16;t++)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-r*65536;e[0]+=r-1+37*(r-1)}function N(e,t,n){for(var r,i=~(n-1),a=0;a<16;a++)r=i&(e[a]^t[a]),e[a]^=r,t[a]^=r}function P(e,n){var r,i,a,o=t(),s=t();for(r=0;r<16;r++)s[r]=n[r];for(M(s),M(s),M(s),i=0;i<2;i++){for(o[0]=s[0]-65517,r=1;r<15;r++)o[r]=s[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=s[15]-32767-(o[14]>>16&1),a=o[15]>>16&1,o[14]&=65535,N(s,o,1-a)}for(r=0;r<16;r++)e[2*r]=s[r]&255,e[2*r+1]=s[r]>>8}function F(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return P(n,e),P(r,t),g(n,0,r,0)}function I(e){var t=new Uint8Array(32);return P(t,e),t[0]&1}function L(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function R(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function z(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function B(e,t,n){var r,i,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=0,O=0,k=0,A=0,j=0,M=0,N=0,P=0,F=0,I=n[0],L=n[1],R=n[2],z=n[3],B=n[4],V=n[5],H=n[6],U=n[7],W=n[8],G=n[9],ee=n[10],K=n[11],q=n[12],te=n[13],ne=n[14],re=n[15];r=t[0],a+=r*I,o+=r*L,s+=r*R,c+=r*z,l+=r*B,u+=r*V,d+=r*H,f+=r*U,p+=r*W,m+=r*G,h+=r*ee,g+=r*K,_+=r*q,v+=r*te,y+=r*ne,b+=r*re,r=t[1],o+=r*I,s+=r*L,c+=r*R,l+=r*z,u+=r*B,d+=r*V,f+=r*H,p+=r*U,m+=r*W,h+=r*G,g+=r*ee,_+=r*K,v+=r*q,y+=r*te,b+=r*ne,x+=r*re,r=t[2],s+=r*I,c+=r*L,l+=r*R,u+=r*z,d+=r*B,f+=r*V,p+=r*H,m+=r*U,h+=r*W,g+=r*G,_+=r*ee,v+=r*K,y+=r*q,b+=r*te,x+=r*ne,S+=r*re,r=t[3],c+=r*I,l+=r*L,u+=r*R,d+=r*z,f+=r*B,p+=r*V,m+=r*H,h+=r*U,g+=r*W,_+=r*G,v+=r*ee,y+=r*K,b+=r*q,x+=r*te,S+=r*ne,C+=r*re,r=t[4],l+=r*I,u+=r*L,d+=r*R,f+=r*z,p+=r*B,m+=r*V,h+=r*H,g+=r*U,_+=r*W,v+=r*G,y+=r*ee,b+=r*K,x+=r*q,S+=r*te,C+=r*ne,w+=r*re,r=t[5],u+=r*I,d+=r*L,f+=r*R,p+=r*z,m+=r*B,h+=r*V,g+=r*H,_+=r*U,v+=r*W,y+=r*G,b+=r*ee,x+=r*K,S+=r*q,C+=r*te,w+=r*ne,T+=r*re,r=t[6],d+=r*I,f+=r*L,p+=r*R,m+=r*z,h+=r*B,g+=r*V,_+=r*H,v+=r*U,y+=r*W,b+=r*G,x+=r*ee,S+=r*K,C+=r*q,w+=r*te,T+=r*ne,E+=r*re,r=t[7],f+=r*I,p+=r*L,m+=r*R,h+=r*z,g+=r*B,_+=r*V,v+=r*H,y+=r*U,b+=r*W,x+=r*G,S+=r*ee,C+=r*K,w+=r*q,T+=r*te,E+=r*ne,D+=r*re,r=t[8],p+=r*I,m+=r*L,h+=r*R,g+=r*z,_+=r*B,v+=r*V,y+=r*H,b+=r*U,x+=r*W,S+=r*G,C+=r*ee,w+=r*K,T+=r*q,E+=r*te,D+=r*ne,O+=r*re,r=t[9],m+=r*I,h+=r*L,g+=r*R,_+=r*z,v+=r*B,y+=r*V,b+=r*H,x+=r*U,S+=r*W,C+=r*G,w+=r*ee,T+=r*K,E+=r*q,D+=r*te,O+=r*ne,k+=r*re,r=t[10],h+=r*I,g+=r*L,_+=r*R,v+=r*z,y+=r*B,b+=r*V,x+=r*H,S+=r*U,C+=r*W,w+=r*G,T+=r*ee,E+=r*K,D+=r*q,O+=r*te,k+=r*ne,A+=r*re,r=t[11],g+=r*I,_+=r*L,v+=r*R,y+=r*z,b+=r*B,x+=r*V,S+=r*H,C+=r*U,w+=r*W,T+=r*G,E+=r*ee,D+=r*K,O+=r*q,k+=r*te,A+=r*ne,j+=r*re,r=t[12],_+=r*I,v+=r*L,y+=r*R,b+=r*z,x+=r*B,S+=r*V,C+=r*H,w+=r*U,T+=r*W,E+=r*G,D+=r*ee,O+=r*K,k+=r*q,A+=r*te,j+=r*ne,M+=r*re,r=t[13],v+=r*I,y+=r*L,b+=r*R,x+=r*z,S+=r*B,C+=r*V,w+=r*H,T+=r*U,E+=r*W,D+=r*G,O+=r*ee,k+=r*K,A+=r*q,j+=r*te,M+=r*ne,N+=r*re,r=t[14],y+=r*I,b+=r*L,x+=r*R,S+=r*z,C+=r*B,w+=r*V,T+=r*H,E+=r*U,D+=r*W,O+=r*G,k+=r*ee,A+=r*K,j+=r*q,M+=r*te,N+=r*ne,P+=r*re,r=t[15],b+=r*I,x+=r*L,S+=r*R,C+=r*z,w+=r*B,T+=r*V,E+=r*H,D+=r*U,O+=r*W,k+=r*G,A+=r*ee,j+=r*K,M+=r*q,N+=r*te,P+=r*ne,F+=r*re,a+=38*x,o+=38*S,s+=38*C,c+=38*w,l+=38*T,u+=38*E,d+=38*D,f+=38*O,p+=38*k,m+=38*A,h+=38*j,g+=38*M,_+=38*N,v+=38*P,y+=38*F,i=1,r=a+i+65535,i=Math.floor(r/65536),a=r-i*65536,r=o+i+65535,i=Math.floor(r/65536),o=r-i*65536,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=d+i+65535,i=Math.floor(r/65536),d=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=m+i+65535,i=Math.floor(r/65536),m=r-i*65536,r=h+i+65535,i=Math.floor(r/65536),h=r-i*65536,r=g+i+65535,i=Math.floor(r/65536),g=r-i*65536,r=_+i+65535,i=Math.floor(r/65536),_=r-i*65536,r=v+i+65535,i=Math.floor(r/65536),v=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=b+i+65535,i=Math.floor(r/65536),b=r-i*65536,a+=i-1+37*(i-1),i=1,r=a+i+65535,i=Math.floor(r/65536),a=r-i*65536,r=o+i+65535,i=Math.floor(r/65536),o=r-i*65536,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=d+i+65535,i=Math.floor(r/65536),d=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=m+i+65535,i=Math.floor(r/65536),m=r-i*65536,r=h+i+65535,i=Math.floor(r/65536),h=r-i*65536,r=g+i+65535,i=Math.floor(r/65536),g=r-i*65536,r=_+i+65535,i=Math.floor(r/65536),_=r-i*65536,r=v+i+65535,i=Math.floor(r/65536),v=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=b+i+65535,i=Math.floor(r/65536),b=r-i*65536,a+=i-1+37*(i-1),e[0]=a,e[1]=o,e[2]=s,e[3]=c,e[4]=l,e[5]=u,e[6]=d,e[7]=f,e[8]=p,e[9]=m,e[10]=h,e[11]=g,e[12]=_,e[13]=v,e[14]=y,e[15]=b}function V(e,t){B(e,t,t)}function H(e,n){var r=t(),i;for(i=0;i<16;i++)r[i]=n[i];for(i=253;i>=0;i--)V(r,r),i!==2&&i!==4&&B(r,r,n);for(i=0;i<16;i++)e[i]=r[i]}function U(e,n){var r=t(),i;for(i=0;i<16;i++)r[i]=n[i];for(i=250;i>=0;i--)V(r,r),i!==1&&B(r,r,n);for(i=0;i<16;i++)e[i]=r[i]}function W(e,n,r){var i=new Uint8Array(32),a=new Float64Array(80),o,c,l=t(),u=t(),d=t(),f=t(),p=t(),m=t();for(c=0;c<31;c++)i[c]=n[c];for(i[31]=n[31]&127|64,i[0]&=248,L(a,r),c=0;c<16;c++)u[c]=a[c],f[c]=l[c]=d[c]=0;for(l[0]=f[0]=1,c=254;c>=0;--c)o=i[c>>>3]>>>(c&7)&1,N(l,u,o),N(d,f,o),R(p,l,d),z(l,l,d),R(d,u,f),z(u,u,f),V(f,p),V(m,l),B(l,d,l),B(d,u,p),R(p,l,d),z(l,l,d),V(u,l),z(d,f,m),B(l,d,s),R(l,l,f),B(d,d,l),B(l,f,m),B(f,u,a),V(u,p),N(l,u,o),N(d,f,o);for(c=0;c<16;c++)a[c+16]=l[c],a[c+32]=d[c],a[c+48]=u[c],a[c+64]=f[c];var h=a.subarray(32),g=a.subarray(16);return H(h,h),B(g,g,h),P(e,g),0}function G(e,t){return W(e,t,i)}function ee(e,t){return n(t,32),G(e,t)}function K(e,t,n){var i=new Uint8Array(32);return W(i,n,t),b(e,r,i,x)}var q=k,te=A;function ne(e,t,n,r,i,a){var o=new Uint8Array(32);return K(o,i,a),q(e,t,n,r,o)}function re(e,t,n,r,i,a){var o=new Uint8Array(32);return K(o,i,a),te(e,t,n,r,o)}var ie=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ae(e,t,n,r){for(var i=new Int32Array(16),a=new Int32Array(16),o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M=e[0],N=e[1],P=e[2],F=e[3],I=e[4],L=e[5],R=e[6],z=e[7],B=t[0],V=t[1],H=t[2],U=t[3],W=t[4],G=t[5],ee=t[6],K=t[7],q=0;r>=128;){for(w=0;w<16;w++)T=8*w+q,i[w]=n[T+0]<<24|n[T+1]<<16|n[T+2]<<8|n[T+3],a[w]=n[T+4]<<24|n[T+5]<<16|n[T+6]<<8|n[T+7];for(w=0;w<80;w++)if(o=M,s=N,c=P,l=F,u=I,d=L,f=R,p=z,m=B,h=V,g=H,_=U,v=W,y=G,b=ee,x=K,E=z,D=K,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=(I>>>14|W<<18)^(I>>>18|W<<14)^(W>>>9|I<<23),D=(W>>>14|I<<18)^(W>>>18|I<<14)^(I>>>9|W<<23),O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,E=I&L^~I&R,D=W&G^~W&ee,O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,E=ie[w*2],D=ie[w*2+1],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,E=i[w%16],D=a[w%16],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,S=A&65535|j<<16,C=O&65535|k<<16,E=S,D=C,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=(M>>>28|B<<4)^(B>>>2|M<<30)^(B>>>7|M<<25),D=(B>>>28|M<<4)^(M>>>2|B<<30)^(M>>>7|B<<25),O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,E=M&N^M&P^N&P,D=B&V^B&H^V&H,O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,p=A&65535|j<<16,x=O&65535|k<<16,E=l,D=_,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=S,D=C,O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,l=A&65535|j<<16,_=O&65535|k<<16,N=o,P=s,F=c,I=l,L=u,R=d,z=f,M=p,V=m,H=h,U=g,W=_,G=v,ee=y,K=b,B=x,w%16==15)for(T=0;T<16;T++)E=i[T],D=a[T],O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=i[(T+9)%16],D=a[(T+9)%16],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,S=i[(T+1)%16],C=a[(T+1)%16],E=(S>>>1|C<<31)^(S>>>8|C<<24)^S>>>7,D=(C>>>1|S<<31)^(C>>>8|S<<24)^(C>>>7|S<<25),O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,S=i[(T+14)%16],C=a[(T+14)%16],E=(S>>>19|C<<13)^(C>>>29|S<<3)^S>>>6,D=(C>>>19|S<<13)^(S>>>29|C<<3)^(C>>>6|S<<26),O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,i[T]=A&65535|j<<16,a[T]=O&65535|k<<16;E=M,D=B,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[0],D=t[0],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[0]=M=A&65535|j<<16,t[0]=B=O&65535|k<<16,E=N,D=V,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[1],D=t[1],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[1]=N=A&65535|j<<16,t[1]=V=O&65535|k<<16,E=P,D=H,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[2],D=t[2],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[2]=P=A&65535|j<<16,t[2]=H=O&65535|k<<16,E=F,D=U,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[3],D=t[3],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[3]=F=A&65535|j<<16,t[3]=U=O&65535|k<<16,E=I,D=W,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[4],D=t[4],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[4]=I=A&65535|j<<16,t[4]=W=O&65535|k<<16,E=L,D=G,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[5],D=t[5],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[5]=L=A&65535|j<<16,t[5]=G=O&65535|k<<16,E=R,D=ee,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[6],D=t[6],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[6]=R=A&65535|j<<16,t[6]=ee=O&65535|k<<16,E=z,D=K,O=D&65535,k=D>>>16,A=E&65535,j=E>>>16,E=e[7],D=t[7],O+=D&65535,k+=D>>>16,A+=E&65535,j+=E>>>16,k+=O>>>16,A+=k>>>16,j+=A>>>16,e[7]=z=A&65535|j<<16,t[7]=K=O&65535|k<<16,q+=128,r-=128}return r}function J(e,t,n){var r=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),o,s=n;for(r[0]=1779033703,r[1]=3144134277,r[2]=1013904242,r[3]=2773480762,r[4]=1359893119,r[5]=2600822924,r[6]=528734635,r[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,ae(r,i,t,n),n%=128,o=0;o<n;o++)a[o]=t[s-n+o];for(a[n]=128,n=256-128*(n<112),a[n-9]=0,p(a,n-8,s/536870912|0,s<<3),ae(r,i,a,n),o=0;o<8;o++)p(e,8*o,r[o],i[o]);return 0}function oe(e,n){var r=t(),i=t(),a=t(),o=t(),s=t(),c=t(),u=t(),d=t(),f=t();z(r,e[1],e[0]),z(f,n[1],n[0]),B(r,r,f),R(i,e[0],e[1]),R(f,n[0],n[1]),B(i,i,f),B(a,e[3],n[3]),B(a,a,l),B(o,e[2],n[2]),R(o,o,o),z(s,i,r),z(c,o,a),R(u,o,a),R(d,i,r),B(e[0],s,c),B(e[1],d,u),B(e[2],u,c),B(e[3],s,d)}function se(e,t,n){var r;for(r=0;r<4;r++)N(e[r],t[r],n)}function ce(e,n){var r=t(),i=t(),a=t();H(a,n[2]),B(r,n[0],a),B(i,n[1],a),P(e,i),e[31]^=I(r)<<7}function Y(e,t,n){var r,i;for(j(e[0],a),j(e[1],o),j(e[2],o),j(e[3],a),i=255;i>=0;--i)r=n[i/8|0]>>(i&7)&1,se(e,t,r),oe(t,e),oe(e,e),se(e,t,r)}function le(e,n){var r=[t(),t(),t(),t()];j(r[0],u),j(r[1],d),j(r[2],o),B(r[3],u,d),Y(e,r,n)}function ue(e,r,i){var a=new Uint8Array(64),o=[t(),t(),t(),t()],s;for(i||n(r,32),J(a,r,32),a[0]&=248,a[31]&=127,a[31]|=64,le(o,a),ce(e,o),s=0;s<32;s++)r[s+32]=e[s];return 0}var de=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function fe(e,t){var n,r,i,a;for(r=63;r>=32;--r){for(n=0,i=r-32,a=r-12;i<a;++i)t[i]+=n-16*t[r]*de[i-(r-32)],n=t[i]+128>>8,t[i]-=n*256;t[i]+=n,t[r]=0}for(n=0,i=0;i<32;i++)t[i]+=n-(t[31]>>4)*de[i],n=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=n*de[i];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=t[r]&255}function pe(e){var t=new Float64Array(64),n;for(n=0;n<64;n++)t[n]=e[n];for(n=0;n<64;n++)e[n]=0;fe(e,t)}function me(e,n,r,i){var a=new Uint8Array(64),o=new Uint8Array(64),s=new Uint8Array(64),c,l,u=new Float64Array(64),d=[t(),t(),t(),t()];J(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=r+64;for(c=0;c<r;c++)e[64+c]=n[c];for(c=0;c<32;c++)e[32+c]=a[32+c];for(J(s,e.subarray(32),r+32),pe(s),le(d,s),ce(e,d),c=32;c<64;c++)e[c]=i[c];for(J(o,e,r+64),pe(o),c=0;c<64;c++)u[c]=0;for(c=0;c<32;c++)u[c]=s[c];for(c=0;c<32;c++)for(l=0;l<32;l++)u[c+l]+=o[c]*a[l];return fe(e.subarray(32),u),f}function he(e,n){var r=t(),i=t(),s=t(),l=t(),u=t(),d=t(),p=t();return j(e[2],o),L(e[1],n),V(s,e[1]),B(l,s,c),z(s,s,e[2]),R(l,e[2],l),V(u,l),V(d,u),B(p,d,u),B(r,p,s),B(r,r,l),U(r,r),B(r,r,s),B(r,r,l),B(r,r,l),B(e[0],r,l),V(i,e[0]),B(i,i,l),F(i,s)&&B(e[0],e[0],f),V(i,e[0]),B(i,i,l),F(i,s)?-1:(I(e[0])===n[31]>>7&&z(e[0],a,e[0]),B(e[3],e[0],e[1]),0)}function ge(e,n,r,i){var a,o,s=new Uint8Array(32),c=new Uint8Array(64),l=[t(),t(),t(),t()],u=[t(),t(),t(),t()];if(o=-1,r<64||he(u,i))return-1;for(a=0;a<r;a++)e[a]=n[a];for(a=0;a<32;a++)e[a+32]=i[a];if(J(c,e,r),pe(c),Y(l,u,c),le(u,n.subarray(32)),oe(l,u),ce(s,l),r-=64,g(n,0,s,0)){for(a=0;a<r;a++)e[a]=0;return-1}for(a=0;a<r;a++)e[a]=n[a+64];return o=r,o}var _e=32,ve=24,ye=32,be=16,xe=32,Se=32,Ce=32,we=32,Te=32,Ee=ve,De=ye,Oe=be,ke=64,Ae=32,je=64,Me=32,Ne=64;e.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:T,crypto_stream:w,crypto_stream_salsa20_xor:S,crypto_stream_salsa20:C,crypto_onetimeauth:D,crypto_onetimeauth_verify:O,crypto_verify_16:h,crypto_verify_32:g,crypto_secretbox:k,crypto_secretbox_open:A,crypto_scalarmult:W,crypto_scalarmult_base:G,crypto_box_beforenm:K,crypto_box_afternm:q,crypto_box:ne,crypto_box_open:re,crypto_box_keypair:ee,crypto_hash:J,crypto_sign:me,crypto_sign_keypair:ue,crypto_sign_open:ge,crypto_secretbox_KEYBYTES:_e,crypto_secretbox_NONCEBYTES:ve,crypto_secretbox_ZEROBYTES:ye,crypto_secretbox_BOXZEROBYTES:be,crypto_scalarmult_BYTES:xe,crypto_scalarmult_SCALARBYTES:Se,crypto_box_PUBLICKEYBYTES:Ce,crypto_box_SECRETKEYBYTES:we,crypto_box_BEFORENMBYTES:Te,crypto_box_NONCEBYTES:Ee,crypto_box_ZEROBYTES:De,crypto_box_BOXZEROBYTES:Oe,crypto_sign_BYTES:ke,crypto_sign_PUBLICKEYBYTES:Ae,crypto_sign_SECRETKEYBYTES:je,crypto_sign_SEEDBYTES:Me,crypto_hash_BYTES:Ne};function Pe(e,t){if(e.length!==_e)throw Error(`bad key size`);if(t.length!==ve)throw Error(`bad nonce size`)}function Fe(e,t){if(e.length!==Ce)throw Error(`bad public key size`);if(t.length!==we)throw Error(`bad secret key size`)}function Ie(){var e,t;for(t=0;t<arguments.length;t++)if((e=Object.prototype.toString.call(arguments[t]))!==`[object Uint8Array]`)throw TypeError(`unexpected type `+e+`, use Uint8Array`)}function Le(e){for(var t=0;t<e.length;t++)e[t]=0}e.util||(e.util={},e.util.decodeUTF8=e.util.encodeUTF8=e.util.encodeBase64=e.util.decodeBase64=function(){throw Error(`nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js`)}),e.randomBytes=function(e){var t=new Uint8Array(e);return n(t,e),t},e.secretbox=function(e,t,n){Ie(e,t,n),Pe(n,t);for(var r=new Uint8Array(ye+e.length),i=new Uint8Array(r.length),a=0;a<e.length;a++)r[a+ye]=e[a];return k(i,r,r.length,t,n),i.subarray(be)},e.secretbox.open=function(e,t,n){Ie(e,t,n),Pe(n,t);for(var r=new Uint8Array(be+e.length),i=new Uint8Array(r.length),a=0;a<e.length;a++)r[a+be]=e[a];return r.length<32||A(i,r,r.length,t,n)!==0?!1:i.subarray(ye)},e.secretbox.keyLength=_e,e.secretbox.nonceLength=ve,e.secretbox.overheadLength=be,e.scalarMult=function(e,t){if(Ie(e,t),e.length!==Se)throw Error(`bad n size`);if(t.length!==xe)throw Error(`bad p size`);var n=new Uint8Array(xe);return W(n,e,t),n},e.scalarMult.base=function(e){if(Ie(e),e.length!==Se)throw Error(`bad n size`);var t=new Uint8Array(xe);return G(t,e),t},e.scalarMult.scalarLength=Se,e.scalarMult.groupElementLength=xe,e.box=function(t,n,r,i){var a=e.box.before(r,i);return e.secretbox(t,n,a)},e.box.before=function(e,t){Ie(e,t),Fe(e,t);var n=new Uint8Array(Te);return K(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,i){var a=e.box.before(r,i);return e.secretbox.open(t,n,a)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(Ce),t=new Uint8Array(we);return ee(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(Ie(e),e.length!==we)throw Error(`bad secret key size`);var t=new Uint8Array(Ce);return G(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=Ce,e.box.secretKeyLength=we,e.box.sharedKeyLength=Te,e.box.nonceLength=Ee,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(Ie(e,t),t.length!==je)throw Error(`bad secret key size`);var n=new Uint8Array(ke+e.length);return me(n,e,e.length,t),n},e.sign.open=function(e,t){if(arguments.length!==2)throw Error(`nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?`);if(Ie(e,t),t.length!==Ae)throw Error(`bad public key size`);var n=new Uint8Array(e.length),r=ge(n,e,e.length,t);if(r<0)return null;for(var i=new Uint8Array(r),a=0;a<i.length;a++)i[a]=n[a];return i},e.sign.detached=function(t,n){for(var r=e.sign(t,n),i=new Uint8Array(ke),a=0;a<i.length;a++)i[a]=r[a];return i},e.sign.detached.verify=function(e,t,n){if(Ie(e,t,n),t.length!==ke)throw Error(`bad signature size`);if(n.length!==Ae)throw Error(`bad public key size`);var r=new Uint8Array(ke+e.length),i=new Uint8Array(ke+e.length),a;for(a=0;a<ke;a++)r[a]=t[a];for(a=0;a<e.length;a++)r[a+ke]=e[a];return ge(i,r,r.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(Ae),t=new Uint8Array(je);return ue(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(Ie(e),e.length!==je)throw Error(`bad secret key size`);for(var t=new Uint8Array(Ae),n=0;n<t.length;n++)t[n]=e[32+n];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(Ie(e),e.length!==Me)throw Error(`bad seed size`);for(var t=new Uint8Array(Ae),n=new Uint8Array(je),r=0;r<32;r++)n[r]=e[r];return ue(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=Ae,e.sign.secretKeyLength=je,e.sign.seedLength=Me,e.sign.signatureLength=ke,e.hash=function(e){Ie(e);var t=new Uint8Array(Ne);return J(t,e,e.length),t},e.hash.hashLength=Ne,e.verify=function(e,t){return Ie(e,t),e.length===0||t.length===0||e.length!==t.length?!1:m(e,0,t,0,e.length)===0},e.setPRNG=function(e){n=e},(function(){var t=typeof self<`u`?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){var n=65536;e.setPRNG(function(e,r){var i,a=new Uint8Array(r);for(i=0;i<r;i+=n)t.getRandomValues(a.subarray(i,i+Math.min(r-i,n)));for(i=0;i<r;i++)e[i]=a[i];Le(a)})}else typeof require<`u`&&(t=require("crypto"),t&&t.randomBytes&&e.setPRNG(function(e,n){var r,i=t.randomBytes(n);for(r=0;r<n;r++)e[r]=i[r];Le(i)}))})()})(t!==void 0&&t.exports?t.exports:self.nacl=self.nacl||{})})),eh=s(((e,t)=>{var n=$m().lowlevel.crypto_hash,r=0,i=function(){this.S=[new Uint32Array([3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946]),new Uint32Array([1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055]),new Uint32Array([3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504]),new Uint32Array([976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462])],this.P=new Uint32Array([608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731])};function a(e,t,n){return(e[0][t[n+3]]+e[1][t[n+2]]^e[2][t[n+1]])+e[3][t[n]]}i.prototype.encipher=function(e,t){t===void 0&&(t=new Uint8Array(e.buffer),e.byteOffset!==0&&(t=t.subarray(e.byteOffset))),e[0]^=this.P[0];for(var n=1;n<16;n+=2)e[1]^=a(this.S,t,0)^this.P[n],e[0]^=a(this.S,t,4)^this.P[n+1];var r=e[0];e[0]=e[1]^this.P[17],e[1]=r},i.prototype.decipher=function(e){var t=new Uint8Array(e.buffer);e.byteOffset!==0&&(t=t.subarray(e.byteOffset)),e[0]^=this.P[17];for(var n=16;n>0;n-=2)e[1]^=a(this.S,t,0)^this.P[n],e[0]^=a(this.S,t,4)^this.P[n-1];var r=e[0];e[0]=e[1]^this.P[0],e[1]=r};function o(e,t){var n,i=0;for(n=0;n<4;n++,r++)r>=t&&(r=0),i=i<<8|e[r];return i}i.prototype.expand0state=function(e,t){var n=new Uint32Array(2),i,a,s=new Uint8Array(n.buffer);for(i=0,r=0;i<18;i++)this.P[i]^=o(e,t);for(r=0,i=0;i<18;i+=2)this.encipher(n,s),this.P[i]=n[0],this.P[i+1]=n[1];for(i=0;i<4;i++)for(a=0;a<256;a+=2)this.encipher(n,s),this.S[i][a]=n[0],this.S[i][a+1]=n[1]},i.prototype.expandstate=function(e,t,n,i){var a=new Uint32Array(2),s,c;for(s=0,r=0;s<18;s++)this.P[s]^=o(n,i);for(s=0,r=0;s<18;s+=2)a[0]^=o(e,t),a[1]^=o(e,t),this.encipher(a),this.P[s]=a[0],this.P[s+1]=a[1];for(s=0;s<4;s++)for(c=0;c<256;c+=2)a[0]^=o(e,t),a[1]^=o(e,t),this.encipher(a),this.S[s][c]=a[0],this.S[s][c+1]=a[1];r=0},i.prototype.enc=function(e,t){for(var n=0;n<t;n++)this.encipher(e.subarray(n*2))},i.prototype.dec=function(e,t){for(var n=0;n<t;n++)this.decipher(e.subarray(n*2))};var s=8,c=32;function l(e,t,n){var r=new i,a=new Uint32Array(s),c,l=new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,105,116,101]);for(r.expandstate(t,64,e,64),c=0;c<64;c++)r.expand0state(t,64),r.expand0state(e,64);for(c=0;c<s;c++)a[c]=o(l,l.byteLength);for(c=0;c<64;c++)r.enc(a,a.byteLength/8);for(c=0;c<s;c++)n[4*c+3]=a[c]>>>24,n[4*c+2]=a[c]>>>16,n[4*c+1]=a[c]>>>8,n[4*c+0]=a[c]}function u(e,t,r,i,a,o,s){var u=new Uint8Array(64),d=new Uint8Array(64),f=new Uint8Array(c),p=new Uint8Array(c),m=new Uint8Array(i+4),h,g,_,v,y,b,x=o;if(s<1||t===0||i===0||o===0||o>f.byteLength*f.byteLength||i>1<<20)return-1;for(v=Math.floor((o+f.byteLength-1)/f.byteLength),_=Math.floor((o+v-1)/v),h=0;h<i;h++)m[h]=r[h];for(n(u,e,t),b=1;o>0;b++){for(m[i+0]=b>>>24,m[i+1]=b>>>16,m[i+2]=b>>>8,m[i+3]=b,n(d,m,i+4),l(u,d,p),h=f.byteLength;h--;)f[h]=p[h];for(h=1;h<s;h++)for(n(d,p,p.byteLength),l(u,d,p),g=0;g<f.byteLength;g++)f[g]^=p[g];for(_=Math.min(_,o),h=0;h<_&&(y=h*v+(b-1),!(y>=x));h++)a[y]=f[h];o-=h}return 0}t.exports={BLOCKS:s,HASHSIZE:c,hash:l,pbkdf:u}})),th=s(((e,t)=>{let n=require("crypto"),r;try{r=require("cpu-features")()}catch{}let{bindingAvailable:i,CIPHER_INFO:a,MAC_INFO:o}=ih(),s=(()=>{if(typeof n.sign==`function`&&typeof n.verify==`function`){let e=`-----BEGIN PRIVATE KEY-----\r
|
|
219
219
|
MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
|
|
220
|
-
-----END PRIVATE KEY-----`,t=Buffer.from(`a`),r,i;try{r=n.sign(null,t,e),i=n.verify(null,t,e,r)}catch{}return Buffer.isBuffer(r)&&r.length===64&&i===!0}return!1})(),c=typeof n.diffieHellman==`function`&&typeof n.generateKeyPairSync==`function`&&typeof n.createPublicKey==`function`,l=[`ecdh-sha2-nistp256`,`ecdh-sha2-nistp384`,`ecdh-sha2-nistp521`,`diffie-hellman-group-exchange-sha256`,`diffie-hellman-group14-sha256`,`diffie-hellman-group15-sha512`,`diffie-hellman-group16-sha512`,`diffie-hellman-group17-sha512`,`diffie-hellman-group18-sha512`];c&&(l.unshift(`curve25519-sha256`),l.unshift(`curve25519-sha256@libssh.org`));let u=l.concat([`diffie-hellman-group-exchange-sha1`,`diffie-hellman-group14-sha1`,`diffie-hellman-group1-sha1`]),d=[`ecdsa-sha2-nistp256`,`ecdsa-sha2-nistp384`,`ecdsa-sha2-nistp521`,`rsa-sha2-512`,`rsa-sha2-256`,`ssh-rsa`];s&&d.unshift(`ssh-ed25519`);let f=d.concat([`ssh-dss`]),p=(()=>{let e=n.getCiphers();return t=>e.includes(a[t].sslName)})(),m=[`aes128-gcm@openssh.com`,`aes256-gcm@openssh.com`,`aes128-ctr`,`aes192-ctr`,`aes256-ctr`];r&&r.flags&&!r.flags.aes?i?m.unshift(`chacha20-poly1305@openssh.com`):m.push(`chacha20-poly1305@openssh.com`):i&&r&&r.arch===`x86`?m.splice(4,0,`chacha20-poly1305@openssh.com`):m.push(`chacha20-poly1305@openssh.com`),m=m.filter(p);let h=m.concat([`aes256-cbc`,`aes192-cbc`,`aes128-cbc`,`blowfish-cbc`,`3des-cbc`,`aes128-gcm`,`aes256-gcm`,`arcfour256`,`arcfour128`,`cast128-cbc`,`arcfour`].filter(p)),g=(()=>{let e=n.getHashes();return t=>e.includes(o[t].sslName)})(),_=[`hmac-sha2-256-etm@openssh.com`,`hmac-sha2-512-etm@openssh.com`,`hmac-sha1-etm@openssh.com`,`hmac-sha2-256`,`hmac-sha2-512`,`hmac-sha1`].filter(g),v=_.concat([`hmac-md5`,`hmac-sha2-256-96`,`hmac-sha2-512-96`,`hmac-ripemd160`,`hmac-sha1-96`,`hmac-md5-96`].filter(g)),y=[`none`,`zlib@openssh.com`,`zlib`],b=y.concat([]),x={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};t.exports={MESSAGE:{DISCONNECT:1,IGNORE:2,UNIMPLEMENTED:3,DEBUG:4,SERVICE_REQUEST:5,SERVICE_ACCEPT:6,EXT_INFO:7,KEXINIT:20,NEWKEYS:21,KEXDH_INIT:30,KEXDH_REPLY:31,KEXDH_GEX_GROUP:31,KEXDH_GEX_INIT:32,KEXDH_GEX_REPLY:33,KEXDH_GEX_REQUEST:34,KEXECDH_INIT:30,KEXECDH_REPLY:31,USERAUTH_REQUEST:50,USERAUTH_FAILURE:51,USERAUTH_SUCCESS:52,USERAUTH_BANNER:53,USERAUTH_PASSWD_CHANGEREQ:60,USERAUTH_PK_OK:60,USERAUTH_INFO_REQUEST:60,USERAUTH_INFO_RESPONSE:61,GLOBAL_REQUEST:80,REQUEST_SUCCESS:81,REQUEST_FAILURE:82,CHANNEL_OPEN:90,CHANNEL_OPEN_CONFIRMATION:91,CHANNEL_OPEN_FAILURE:92,CHANNEL_WINDOW_ADJUST:93,CHANNEL_DATA:94,CHANNEL_EXTENDED_DATA:95,CHANNEL_EOF:96,CHANNEL_CLOSE:97,CHANNEL_REQUEST:98,CHANNEL_SUCCESS:99,CHANNEL_FAILURE:100},DISCONNECT_REASON:{HOST_NOT_ALLOWED_TO_CONNECT:1,PROTOCOL_ERROR:2,KEY_EXCHANGE_FAILED:3,RESERVED:4,MAC_ERROR:5,COMPRESSION_ERROR:6,SERVICE_NOT_AVAILABLE:7,PROTOCOL_VERSION_NOT_SUPPORTED:8,HOST_KEY_NOT_VERIFIABLE:9,CONNECTION_LOST:10,BY_APPLICATION:11,TOO_MANY_CONNECTIONS:12,AUTH_CANCELED_BY_USER:13,NO_MORE_AUTH_METHODS_AVAILABLE:14,ILLEGAL_USER_NAME:15},DISCONNECT_REASON_STR:void 0,CHANNEL_OPEN_FAILURE:{ADMINISTRATIVELY_PROHIBITED:1,CONNECT_FAILED:2,UNKNOWN_CHANNEL_TYPE:3,RESOURCE_SHORTAGE:4},TERMINAL_MODE:{TTY_OP_END:0,VINTR:1,VQUIT:2,VERASE:3,VKILL:4,VEOF:5,VEOL:6,VEOL2:7,VSTART:8,VSTOP:9,VSUSP:10,VDSUSP:11,VREPRINT:12,VWERASE:13,VLNEXT:14,VFLUSH:15,VSWTCH:16,VSTATUS:17,VDISCARD:18,IGNPAR:30,PARMRK:31,INPCK:32,ISTRIP:33,INLCR:34,IGNCR:35,ICRNL:36,IUCLC:37,IXON:38,IXANY:39,IXOFF:40,IMAXBEL:41,ISIG:50,ICANON:51,XCASE:52,ECHO:53,ECHOE:54,ECHOK:55,ECHONL:56,NOFLSH:57,TOSTOP:58,IEXTEN:59,ECHOCTL:60,ECHOKE:61,PENDIN:62,OPOST:70,OLCUC:71,ONLCR:72,OCRNL:73,ONOCR:74,ONLRET:75,CS7:90,CS8:91,PARENB:92,PARODD:93,TTY_OP_ISPEED:128,TTY_OP_OSPEED:129},CHANNEL_EXTENDED_DATATYPE:{STDERR:1},SIGNALS:[`ABRT`,`ALRM`,`FPE`,`HUP`,`ILL`,`INT`,`QUIT`,`SEGV`,`TERM`,`USR1`,`USR2`,`KILL`,`PIPE`].reduce((e,t)=>({...e,[t]:1}),{}),COMPAT:x,COMPAT_CHECKS:[[`Cisco-1.25`,x.BAD_DHGEX],[/^Cisco-1[.]/,x.BUG_DHGEX_LARGE],[/^[0-9.]+$/,x.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,x.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,x.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:l,SUPPORTED_KEX:u,DEFAULT_SERVER_HOST_KEY:d,SUPPORTED_SERVER_HOST_KEY:f,DEFAULT_CIPHER:m,SUPPORTED_CIPHER:h,DEFAULT_MAC:_,SUPPORTED_MAC:v,DEFAULT_COMPRESSION:y,SUPPORTED_COMPRESSION:b,curve25519Supported:c,eddsaSupported:s},t.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(t.exports.DISCONNECT_REASON)).reduce((e,[t,n])=>({...e,[n]:t}),{})})),nh=s(((e,t)=>{let n=Qm().Ber,r,i=Buffer[Symbol.species],a=Object.getPrototypeOf(Uint8Array.prototype).fill;function o(e,t){return e[t++]*16777216+e[t++]*65536+e[t++]*256+e[t]}function s(e,t,n,r,i){i||=0,r>e.length&&(r=e.length);let a=r-n,o=t.length-i;return a>o&&(a=o),t.set(new Uint8Array(e.buffer,e.byteOffset+n,a),i),a}function c(e,t,n){return n===void 0&&(n=e.length),new i(e.buffer,e.byteOffset+t,n-t)}function l(){let e=0,t,n={init:(n,r)=>{t=n,e=typeof r==`number`?r:0},pos:()=>e,length:()=>t?t.length:0,avail:()=>t&&e<t.length?t.length-e:0,clear:()=>{t=void 0},readUInt32BE:()=>{if(!(!t||e+3>=t.length))return t[e++]*16777216+t[e++]*65536+t[e++]*256+t[e++]},readUInt64BE:n=>{if(!(!t||e+7>=t.length))switch(n){case`always`:return BigInt(`0x${t.hexSlice(e,e+=8)}`);case`maybe`:if(t[e]>31)return BigInt(`0x${t.hexSlice(e,e+=8)}`);default:return t[e++]*72057594037927940+t[e++]*281474976710656+t[e++]*1099511627776+t[e++]*4294967296+t[e++]*16777216+t[e++]*65536+t[e++]*256+t[e++]}},skip:n=>{t&&n>0&&(e+=n)},skipString:()=>{let r=n.readUInt32BE();if(r!==void 0)return e+=r,e<=t.length?r:void 0},readByte:()=>{if(t&&e<t.length)return t[e++]},readBool:()=>{if(t&&e<t.length)return!!t[e++]},readList:()=>{let e=n.readString(!0);if(e!==void 0)return e?e.split(`,`):[]},readString:(r,i)=>{typeof r==`number`&&(i=r,r=void 0);let a=n.readUInt32BE();if(a!==void 0&&!(t.length-e<a||typeof i==`number`&&a>i))return r?Buffer.isBuffer(r)?s(t,r,e,e+=a):t.utf8Slice(e,e+=a):c(t,e,e+=a)},readRaw:n=>{if(t){if(typeof n!=`number`)return c(t,e,e+=t.length-e);if(t.length-e>=n)return c(t,e,e+=n)}}};return n}function u(e,t,n){let r=Error(e);return typeof t==`boolean`?(n=t,r.level=`protocol`):r.level=t||`protocol`,r.fatal=!!n,r}function d(e,t,n){return e[n++]=t>>>24,e[n++]=t>>>16,e[n++]=t>>>8,e[n++]=t,n}let f=l();t.exports={bufferCopy:s,bufferSlice:c,FastBuffer:i,bufferFill:(e,t,n,r)=>a.call(e,t,n,r),makeError:u,doFatalError:(e,t,n,i)=>{let a;return r===void 0&&({DISCONNECT_REASON:r}=th()),t instanceof Error?(a=t,i=typeof n==`number`?n:r.PROTOCOL_ERROR):a=u(t,n,!0),typeof i!=`number`&&(i=r.PROTOCOL_ERROR),e.disconnect(i),e._destruct(),e._onError(a),1/0},readUInt32BE:o,writeUInt32BE:d,writeUInt32LE:(e,t,n)=>(e[n++]=t,e[n++]=t>>>8,e[n++]=t>>>16,e[n++]=t>>>24,n),makeBufferParser:l,bufferParser:l(),readString:(e,t,n,r)=>{typeof n==`number`&&(r=n,n=void 0),t===void 0&&(t=0);let i=e.length-t;if(t<0||t>=e.length||i<4)return;let a=o(e,t);if(i<4+a||typeof r==`number`&&a>r)return;t+=4;let l=t+a;return e._pos=l,n?Buffer.isBuffer(n)?s(e,n,t,l):e.utf8Slice(t,l):c(e,t,l)},sigSSHToASN1:(e,t)=>{switch(t){case`ssh-dss`:{if(e.length>40)return e;let t=new n.Writer;t.startSequence();let r=e.slice(0,20),i=e.slice(20);if(r[0]&128){let e=Buffer.allocUnsafe(21);e[0]=0,r.copy(e,1),r=e}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(i[0]&128){let e=Buffer.allocUnsafe(21);e[0]=0,i.copy(e,1),i=e}else i[0]===0&&!(i[1]&128)&&(i=i.slice(1));return t.writeBuffer(r,n.Integer),t.writeBuffer(i,n.Integer),t.endSequence(),t.buffer}case`ecdsa-sha2-nistp256`:case`ecdsa-sha2-nistp384`:case`ecdsa-sha2-nistp521`:{f.init(e,0);let t=f.readString(),r=f.readString();if(f.clear(),t===void 0||r===void 0)return;let i=new n.Writer;return i.startSequence(),i.writeBuffer(t,n.Integer),i.writeBuffer(r,n.Integer),i.endSequence(),i.buffer}default:return e}},convertSignature:(e,t)=>{switch(t){case`ssh-dss`:{if(e.length<=40)return e;let t=new n.Reader(e);t.readSequence();let r=t.readString(n.Integer,!0),i=t.readString(n.Integer,!0),a=0,o=0;if(r.length<20){let e=Buffer.allocUnsafe(20);e.set(r,1),r=e,r[0]=0}if(i.length<20){let e=Buffer.allocUnsafe(20);e.set(i,1),i=e,i[0]=0}r.length>20&&r[0]===0&&(a=1),i.length>20&&i[0]===0&&(o=1);let c=Buffer.allocUnsafe(r.length-a+(i.length-o));return s(r,c,a,r.length,0),s(i,c,o,i.length,r.length-a),c}case`ecdsa-sha2-nistp256`:case`ecdsa-sha2-nistp384`:case`ecdsa-sha2-nistp521`:{if(e[0]===0)return e;let t=new n.Reader(e);t.readSequence();let r=t.readString(n.Integer,!0),i=t.readString(n.Integer,!0);if(r===null||i===null)return;let a=Buffer.allocUnsafe(4+r.length+4+i.length);return d(a,r.length,0),a.set(r,4),d(a,i.length,4+r.length),a.set(i,8+r.length),a}}return e},sendPacket:(e,t,n)=>!n&&e._kexinit!==void 0?(e._queue===void 0&&(e._queue=[]),e._queue.push(t),e._debug&&e._debug(`Outbound: ... packet queued`),!1):(e._cipher.encrypt(t),!0)}})),rh=s(((e,t)=>{var n=(function(){var e=typeof document<`u`&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<`u`&&(e||=__filename),(function(t){t||={};var n;n||=t===void 0?{}:t;var r,i;n.ready=new Promise(function(e,t){r=e,i=t});var a={},o;for(o in n)n.hasOwnProperty(o)&&(a[o]=n[o]);var s=typeof window==`object`,c=typeof importScripts==`function`,l=typeof process==`object`&&typeof process.versions==`object`&&typeof process.versions.node==`string`,u=``,d,f,p,m,h;l?(u=c?require("path").dirname(u)+`/`:__dirname+`/`,d=function(e,t){var n=G(e);return n?t?n:n.toString():(m||=require("fs"),h||=require("path"),e=h.normalize(e),m.readFileSync(e,t?null:`utf8`))},p=function(e){return e=d(e,!0),e.buffer||(e=new Uint8Array(e)),b(e.buffer),e},f=function(e,t,n){var r=G(e);r&&t(r),m||=require("fs"),h||=require("path"),e=h.normalize(e),m.readFile(e,function(e,r){e?n(e):t(r.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,`/`),process.argv.slice(2),n.inspect=function(){return`[Emscripten Module object]`}):(s||c)&&(c?u=self.location.href:typeof document<`u`&&document.currentScript&&(u=document.currentScript.src),e&&(u=e),u=u.indexOf(`blob:`)===0?``:u.substr(0,u.lastIndexOf(`/`)+1),d=function(e){try{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.send(null),t.responseText}catch(i){if(e=G(e)){t=[];for(var n=0;n<e.length;n++){var r=e[n];255<r&&(U&&b(!1,`Character code `+r+` (`+String.fromCharCode(r)+`) at offset `+n+` not in 0x00-0xFF.`),r&=255),t.push(String.fromCharCode(r))}return t.join(``)}throw i}},c&&(p=function(e){try{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}catch(t){if(e=G(e))return e;throw t}}),f=function(e,t,n){var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=function(){if(r.status==200||r.status==0&&r.response)t(r.response);else{var i=G(e);i?t(i.buffer):n()}},r.onerror=n,r.send(null)}),n.print||console.log.bind(console);var g=n.printErr||console.warn.bind(console);for(o in a)a.hasOwnProperty(o)&&(n[o]=a[o]);a=null;var _;n.wasmBinary&&(_=n.wasmBinary),n.noExitRuntime,typeof WebAssembly!=`object`&&I(`no native wasm support detected`);var v,y=!1;function b(e,t){e||I(`Assertion failed: `+t)}function x(e){var t=n[`_`+e];return b(t,`Cannot call unknown function `+e+`, make sure it is exported`),t}function S(e,t,n,r){var i={string:function(e){var t=0;if(e!=null&&e!==0){var n=(e.length<<2)+1;t=te(n);var r=t,i=E;if(0<n){n=r+n-1;for(var a=0;a<e.length;++a){var o=e.charCodeAt(a);if(55296<=o&&57343>=o){var s=e.charCodeAt(++a);o=65536+((o&1023)<<10)|s&1023}if(127>=o){if(r>=n)break;i[r++]=o}else{if(2047>=o){if(r+1>=n)break;i[r++]=192|o>>6}else{if(65535>=o){if(r+2>=n)break;i[r++]=224|o>>12}else{if(r+3>=n)break;i[r++]=240|o>>18,i[r++]=128|o>>12&63}i[r++]=128|o>>6&63}i[r++]=128|o&63}}i[r]=0}}return t},array:function(e){var t=te(e.length);return T.set(e,t),t}},a=x(e),o=[];if(e=0,r)for(var s=0;s<r.length;s++){var c=i[n[s]];c?(e===0&&(e=K()),o[s]=c(r[s])):o[s]=r[s]}return n=a.apply(null,o),n=function(e){if(t===`string`)if(e){for(var n=E,r=e+NaN,i=e;n[i]&&!(i>=r);)++i;if(16<i-e&&n.subarray&&C)e=C.decode(n.subarray(e,i));else{for(r=``;e<i;){var a=n[e++];if(a&128){var o=n[e++]&63;if((a&224)==192)r+=String.fromCharCode((a&31)<<6|o);else{var s=n[e++]&63;a=(a&240)==224?(a&15)<<12|o<<6|s:(a&7)<<18|o<<12|s<<6|n[e++]&63,65536>a?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|a&1023))}}else r+=String.fromCharCode(a)}e=r}}else e=``;else e=t===`boolean`?!!e:e;return e}(n),e!==0&&q(e),n}var C=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0,w,T,E;function D(){var e=v.buffer;w=e,n.HEAP8=T=new Int8Array(e),n.HEAP16=new Int16Array(e),n.HEAP32=new Int32Array(e),n.HEAPU8=E=new Uint8Array(e),n.HEAPU16=new Uint16Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=new Float32Array(e),n.HEAPF64=new Float64Array(e)}var O,k=[],A=[],j=[];function M(){var e=n.preRun.shift();k.unshift(e)}var N=0,P=null,F=null;n.preloadedImages={},n.preloadedAudios={};function I(e){throw n.onAbort&&n.onAbort(e),g(e),y=!0,e=new WebAssembly.RuntimeError(`abort(`+e+`). Build with -s ASSERTIONS=1 for more info.`),i(e),e}var L=`data:application/octet-stream;base64,`,R=`data:application/octet-stream;base64,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`;if(!R.startsWith(L)){var z=R;R=n.locateFile?n.locateFile(z,u):u+z}function B(){var e=R;try{if(e==R&&_)return new Uint8Array(_);var t=G(e);if(t)return t;if(p)return p(e);throw`both async and sync fetching of the wasm failed`}catch(e){I(e)}}function V(){if(!_&&(s||c)){if(typeof fetch==`function`&&!R.startsWith(`file://`))return fetch(R,{credentials:`same-origin`}).then(function(e){if(!e.ok)throw`failed to load wasm binary file at '`+R+`'`;return e.arrayBuffer()}).catch(function(){return B()});if(f)return new Promise(function(e,t){f(R,function(t){e(new Uint8Array(t))},t)})}return Promise.resolve().then(function(){return B()})}function H(e){for(;0<e.length;){var t=e.shift();if(typeof t==`function`)t(n);else{var r=t.m;typeof r==`number`?t.l===void 0?O.get(r)():O.get(r)(t.l):r(t.l===void 0?null:t.l)}}}var U=!1,W=typeof atob==`function`?atob:function(e){var t=``,n=0;e=e.replace(/[^A-Za-z0-9\+\/=]/g,``);do{var r=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`.indexOf(e.charAt(n++)),i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`.indexOf(e.charAt(n++)),a=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`.indexOf(e.charAt(n++)),o=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`.indexOf(e.charAt(n++));r=r<<2|i>>4,i=(i&15)<<4|a>>2;var s=(a&3)<<6|o;t+=String.fromCharCode(r),a!==64&&(t+=String.fromCharCode(i)),o!==64&&(t+=String.fromCharCode(s))}while(n<e.length);return t};function G(e){if(e.startsWith(L)){if(e=e.slice(L.length),typeof l==`boolean`&&l){var t=Buffer.from(e,`base64`);t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}else try{var n=W(e),r=new Uint8Array(n.length);for(e=0;e<n.length;++e)r[e]=n.charCodeAt(e);t=r}catch{throw Error(`Converting base64 string to bytes failed.`)}return t}}var ee={a:function(e){var t=E.length;if(e>>>=0,2147483648<e)return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296),r=Math.max(e,r),0<r%65536&&(r+=65536-r%65536);a:{try{v.grow(Math.min(2147483648,r)-w.byteLength+65535>>>16),D();var i=1;break a}catch{}i=void 0}if(i)return!0}return!1}};(function(){function e(e){n.asm=e.exports,v=n.asm.b,D(),O=n.asm.j,A.unshift(n.asm.c),N--,n.monitorRunDependencies&&n.monitorRunDependencies(N),N==0&&(P!==null&&(clearInterval(P),P=null),F&&(e=F,F=null,e()))}function t(t){e(t.instance)}function r(e){return V().then(function(e){return WebAssembly.instantiate(e,a)}).then(e,function(e){g(`failed to asynchronously prepare wasm: `+e),I(e)})}var a={a:ee};if(N++,n.monitorRunDependencies&&n.monitorRunDependencies(N),n.instantiateWasm)try{return n.instantiateWasm(a,e)}catch(e){return g(`Module.instantiateWasm callback failed with error: `+e),!1}return(function(){return _||typeof WebAssembly.instantiateStreaming!=`function`||R.startsWith(L)||R.startsWith(`file://`)||typeof fetch!=`function`?r(t):fetch(R,{credentials:`same-origin`}).then(function(e){return WebAssembly.instantiateStreaming(e,a).then(t,function(e){return g(`wasm streaming compile failed: `+e),g(`falling back to ArrayBuffer instantiation`),r(t)})})})().catch(i),{}})(),n.___wasm_call_ctors=function(){return(n.___wasm_call_ctors=n.asm.c).apply(null,arguments)},n._poly1305_auth=function(){return(n._poly1305_auth=n.asm.d).apply(null,arguments)};var K=n.stackSave=function(){return(K=n.stackSave=n.asm.e).apply(null,arguments)},q=n.stackRestore=function(){return(q=n.stackRestore=n.asm.f).apply(null,arguments)},te=n.stackAlloc=function(){return(te=n.stackAlloc=n.asm.g).apply(null,arguments)};n._malloc=function(){return(n._malloc=n.asm.h).apply(null,arguments)},n._free=function(){return(n._free=n.asm.i).apply(null,arguments)},n.cwrap=function(e,t,n,r){n||=[];var i=n.every(function(e){return e===`number`});return t!==`string`&&i&&!r?x(e):function(){return S(e,t,n,arguments)}};var ne;F=function e(){ne||re(),ne||(F=e)};function re(){function e(){if(!ne&&(ne=!0,n.calledRun=!0,!y)){if(H(A),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),n.postRun)for(typeof n.postRun==`function`&&(n.postRun=[n.postRun]);n.postRun.length;){var e=n.postRun.shift();j.unshift(e)}H(j)}}if(!(0<N)){if(n.preRun)for(typeof n.preRun==`function`&&(n.preRun=[n.preRun]);n.preRun.length;)M();H(k),0<N||(n.setStatus?(n.setStatus(`Running...`),setTimeout(function(){setTimeout(function(){n.setStatus(``)},1),e()},1)):e())}}if(n.run=re,n.preInit)for(typeof n.preInit==`function`&&(n.preInit=[n.preInit]);0<n.preInit.length;)n.preInit.pop()();return re(),t.ready})})();typeof e==`object`&&typeof t==`object`?t.exports=n:typeof define==`function`&&define.amd?define([],function(){return n}):typeof e==`object`&&(e.createPoly1305=n)})),ih=s(((e,t)=>{let{createCipheriv:n,createDecipheriv:r,createHmac:i,randomFillSync:a,timingSafeEqual:o}=require("crypto"),{readUInt32BE:s,writeUInt32BE:c}=nh(),l=Buffer[Symbol.species],u=2**32-1,d=Buffer.alloc(0),f=Buffer.alloc(4),p=new Map,m=35e3,h,g,_,v,y,b,x;try{h=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:g,ChaChaPolyCipher:_,GenericCipher:v,AESGCMDecipher:y,ChaChaPolyDecipher:b,GenericDecipher:x}=h}catch{}let S=(()=>{function e(e,t,n,r,i,a,o){return{sslName:e,blockLen:t,keyLen:n,ivLen:r!==0||o&1?r:t,authLen:i,discardLen:a,stream:!!(o&1)}}return{"chacha20-poly1305@openssh.com":e(`chacha20`,8,64,0,16,0,1),"aes128-gcm":e(`aes-128-gcm`,16,16,12,16,0,1),"aes256-gcm":e(`aes-256-gcm`,16,32,12,16,0,1),"aes128-gcm@openssh.com":e(`aes-128-gcm`,16,16,12,16,0,1),"aes256-gcm@openssh.com":e(`aes-256-gcm`,16,32,12,16,0,1),"aes128-cbc":e(`aes-128-cbc`,16,16,0,0,0,0),"aes192-cbc":e(`aes-192-cbc`,16,24,0,0,0,0),"aes256-cbc":e(`aes-256-cbc`,16,32,0,0,0,0),"rijndael-cbc@lysator.liu.se":e(`aes-256-cbc`,16,32,0,0,0,0),"3des-cbc":e(`des-ede3-cbc`,8,24,0,0,0,0),"blowfish-cbc":e(`bf-cbc`,8,16,0,0,0,0),"idea-cbc":e(`idea-cbc`,8,16,0,0,0,0),"cast128-cbc":e(`cast-cbc`,8,16,0,0,0,0),"aes128-ctr":e(`aes-128-ctr`,16,16,16,0,0,1),"aes192-ctr":e(`aes-192-ctr`,16,24,16,0,0,1),"aes256-ctr":e(`aes-256-ctr`,16,32,16,0,0,1),"3des-ctr":e(`des-ede3`,8,24,8,0,0,1),"blowfish-ctr":e(`bf-ecb`,8,16,8,0,0,1),"cast128-ctr":e(`cast5-ecb`,8,16,8,0,0,1),arcfour:e(`rc4`,8,16,0,0,1536,1),arcfour128:e(`rc4`,8,16,0,0,1536,1),arcfour256:e(`rc4`,8,32,0,0,1536,1),arcfour512:e(`rc4`,8,64,0,0,1536,1)}})(),C=(()=>{function e(e,t,n,r){return{sslName:e,len:t,actualLen:n,isETM:r}}return{"hmac-md5":e(`md5`,16,16,!1),"hmac-md5-96":e(`md5`,16,12,!1),"hmac-ripemd160":e(`ripemd160`,20,20,!1),"hmac-sha1":e(`sha1`,20,20,!1),"hmac-sha1-etm@openssh.com":e(`sha1`,20,20,!0),"hmac-sha1-96":e(`sha1`,20,12,!1),"hmac-sha2-256":e(`sha256`,32,32,!1),"hmac-sha2-256-etm@openssh.com":e(`sha256`,32,32,!0),"hmac-sha2-256-96":e(`sha256`,32,12,!1),"hmac-sha2-512":e(`sha512`,64,64,!1),"hmac-sha2-512-etm@openssh.com":e(`sha512`,64,64,!0),"hmac-sha2-512-96":e(`sha512`,64,12,!1)}})();var w=class{constructor(e,t){this.outSeqno=e,this._onWrite=t,this._dead=!1}free(){this._dead=!0}allocPacket(e){let t=5+e,n=8-(t&7);n<4&&(n+=8),t+=n;let r=Buffer.allocUnsafe(t);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){this._dead||(this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}};let T=Buffer.alloc(32),E=Buffer.alloc(16),D,O,k;var A=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._encKeyMain=t.cipherKey.slice(0,32),this._encKeyPktLen=t.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(e){let t=5+e,n=8-(t-4&7);n<4&&(n+=8),t+=n;let r=Buffer.allocUnsafe(t);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){if(this._dead)return;E[0]=0,c(E,this.outSeqno,12);let t=n(`chacha20`,this._encKeyMain,E).update(T),r=n(`chacha20`,this._encKeyPktLen,E).update(e.slice(0,4));this._onWrite(r),E[0]=1;let i=n(`chacha20`,this._encKeyMain,E).update(e.slice(4));this._onWrite(i),k(O,r,r.length,i,i.length,t);let a=Buffer.allocUnsafe(16);a.set(new Uint8Array(D.HEAPU8.buffer,O,16),0),this._onWrite(a),this.outSeqno=this.outSeqno+1>>>0}},j=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._instance=new _(t.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let t=5+e,n=8-(t-4&7);n<4&&(n+=8),t+=n;let r=Buffer.allocUnsafe(t+16);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){this._dead||(this._instance.encrypt(e,this.outSeqno),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},M=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._encSSLName=t.cipherInfo.sslName,this._encKey=t.cipherKey,this._encIV=t.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(e){let t=5+e,n=16-(t-4&15);n<4&&(n+=16),t+=n;let r=Buffer.allocUnsafe(t);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){if(this._dead)return;let t=n(this._encSSLName,this._encKey,this._encIV);t.setAutoPadding(!1);let r=e.slice(0,4);t.setAAD(r),this._onWrite(r);let i=t.update(e.slice(4));this._onWrite(i);let a=t.final();a.length&&this._onWrite(a);let o=t.getAuthTag();this._onWrite(o),U(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},N=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._instance=new g(t.cipherInfo.sslName,t.cipherKey,t.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let t=5+e,n=16-(t-4&15);n<4&&(n+=16),t+=n;let r=Buffer.allocUnsafe(t+16);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){this._dead||(this._instance.encrypt(e),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},P=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._encBlockLen=t.cipherInfo.blockLen,this._cipherInstance=n(t.cipherInfo.sslName,t.cipherKey,t.cipherIV),this._macSSLName=t.macInfo.sslName,this._macKey=t.macKey,this._macActualLen=t.macInfo.actualLen,this._macETM=t.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let r=t.cipherInfo.discardLen;if(r){let e=p.get(r);e===void 0&&(e=Buffer.alloc(r),p.set(r,e)),this._cipherInstance.update(e)}}free(){this._dead=!0}allocPacket(e){let t=this._encBlockLen,n=5+e,r=t-(n-this._aadLen&t-1);r<4&&(r+=t),n+=r;let i=Buffer.allocUnsafe(n);return c(i,n-4,0),i[4]=r,a(i,5+e,r),i}encrypt(e){if(this._dead)return;let t;if(this._macETM){let n=new Uint8Array(e.buffer,e.byteOffset,4),r=this._cipherInstance.update(new Uint8Array(e.buffer,e.byteOffset+4,e.length-4));this._onWrite(n),this._onWrite(r),t=i(this._macSSLName,this._macKey),c(f,this.outSeqno,0),t.update(f),t.update(n),t.update(r)}else{let n=this._cipherInstance.update(e);this._onWrite(n),t=i(this._macSSLName,this._macKey),c(f,this.outSeqno,0),t.update(f),t.update(e)}let n=t.digest();n.length>this._macActualLen&&(n=n.slice(0,this._macActualLen)),this._onWrite(n),this.outSeqno=this.outSeqno+1>>>0}},F=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._encBlockLen=t.cipherInfo.blockLen,this._macLen=t.macInfo.len,this._macActualLen=t.macInfo.actualLen,this._aadLen=t.macInfo.isETM?4:0,this._instance=new v(t.cipherInfo.sslName,t.cipherKey,t.cipherIV,t.macInfo.sslName,t.macKey,t.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let t=this._encBlockLen,n=5+e,r=t-(n-this._aadLen&t-1);r<4&&(r+=t),n+=r;let i=Buffer.allocUnsafe(n+this._macLen);return c(i,n-4,0),i[4]=r,a(i,5+e,r),i}encrypt(e){this._dead||(this._instance.encrypt(e,this.outSeqno),this._macActualLen<this._macLen&&(e=new l(e.buffer,e.byteOffset,e.length-(this._macLen-this._macActualLen))),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},I=class{constructor(e,t){this.inSeqno=e,this._onPayload=t,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(e,t,n){for(;t<n;){if(this._lenBytes<4){let r=Math.min(4-this._lenBytes,n-t);for(this._lenBytes+=r;r--;)this._len=(this._len<<8)+e[t++];if(this._lenBytes<4)return;if(this._len>m||this._len<8||4+this._len&7)throw Error(`Bad packet length`);if(t>=n)return}if(this._packetPos<this._len){let r=Math.min(this._len-this._packetPos,n-t),i;if(i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._packetPos)),t+=r,this._packetPos+=r,this._packetPos<this._len)return}let r=this._packet?new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):d;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let e=this._onPayload(r);if(e!==void 0)return e===!1?t:e}}}},L=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._decKeyMain=t.decipherKey.slice(0,32),this._decKeyPktLen=t.decipherKey.slice(32),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._calcMac=Buffer.allocUnsafe(16),this._macPos=0}free(){}decrypt(e,t,i){for(;t<i;){if(this._lenPos<4){let n=Math.min(4-this._lenPos,i-t);for(;n--;)this._lenBuf[this._lenPos++]=e[t++];if(this._lenPos<4)return;E[0]=0,c(E,this.inSeqno,12);let a=r(`chacha20`,this._decKeyPktLen,E).update(this._lenBuf);if(this._len=s(a,0),this._len>m||this._len<8||this._len&7)throw Error(`Bad packet length`)}if(this._pktLen<this._len){if(t>=i)return;let n=Math.min(this._len-this._pktLen,i-t),r;if(r=t!==0||n!==i?new Uint8Array(e.buffer,e.byteOffset+t,n):e,n===this._len?this._packet=r:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(r,this._pktLen)),t+=n,this._pktLen+=n,this._pktLen<this._len||t>=i)return}{let n=Math.min(16-this._macPos,i-t);if(t!==0||n!==i?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+t,n),this._macPos):this._mac.set(e,this._macPos),t+=n,this._macPos+=n,this._macPos<16)return}E[0]=0,c(E,this.inSeqno,12);let a=n(`chacha20`,this._decKeyMain,E).update(T);if(k(O,this._lenBuf,4,this._packet,this._packet.length,a),this._calcMac.set(new Uint8Array(D.HEAPU8.buffer,O,16),0),!o(this._calcMac,this._mac))throw Error(`Invalid MAC`);E[0]=1;let u=r(`chacha20`,this._decKeyMain,E).update(this._packet),d=new l(u.buffer,u.byteOffset+1,u.length-u[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let e=this._onPayload(d);if(e!==void 0)return e===!1?t:e}}}},R=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._instance=new b(t.decipherKey),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._macPos=0}free(){this._instance.free()}decrypt(e,t,n){for(;t<n;){if(this._lenPos<4){let r=Math.min(4-this._lenPos,n-t);for(;r--;)this._lenBuf[this._lenPos++]=e[t++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>m||this._len<8||this._len&7)throw Error(`Bad packet length`);if(t>=n)return}if(this._pktLen<this._len){let r=Math.min(this._len-this._pktLen,n-t),i;if(i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._pktLen)),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(16-this._macPos,n-t);if(t!==0||r!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._macPos):this._mac.set(e,this._macPos),t+=r,this._macPos+=r,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let r=new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let e=this._onPayload(r);if(e!==void 0)return e===!1?t:e}}}},z=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._decipherInstance=null,this._decipherSSLName=t.decipherInfo.sslName,this._decipherKey=t.decipherKey,this._decipherIV=t.decipherIV,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(e,t,n){for(;t<n;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,n-t);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+e[t++];if(this._lenBytes<4)return;if(this._len+20>m||this._len<16||this._len&15)throw Error(`Bad packet length`);this._decipherInstance=r(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(W(this._len))}if(this._pktLen<this._len){if(t>=n)return;let r=Math.min(this._len-this._pktLen,n-t),i;if(i=t!==0||r!==n?this._decipherInstance.update(new Uint8Array(e.buffer,e.byteOffset+t,r)):this._decipherInstance.update(e),i.length&&(r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._packetPos)),this._packetPos+=i.length),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(16-this._tagPos,n-t);if(t!==0||r!==n?this._tag.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._tagPos):this._tag.set(e,this._tagPos),t+=r,this._tagPos+=r,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let e=this._decipherInstance.final();e.length&&(this._packet?this._packet.set(e,this._packetPos):this._packet=e)}let i=this._packet?new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):d;this.inSeqno=this.inSeqno+1>>>0,U(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let e=this._onPayload(i);if(e!==void 0)return e===!1?t:e}}}},B=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._instance=new y(t.decipherInfo.sslName,t.decipherKey,t.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(e,t,n){for(;t<n;){if(this._lenBytes<4){let r=Math.min(4-this._lenBytes,n-t);for(this._lenBytes+=r;r--;)this._len=(this._len<<8)+e[t++];if(this._lenBytes<4)return;if(this._len+20>m||this._len<16||this._len&15)throw Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(t>=n)return;let r=Math.min(this._len-this._pktLen,n-t),i;if(i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._pktLen)),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(16-this._tagPos,n-t);if(t!==0||r!==n?this._tag.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._tagPos):this._tag.set(e,this._tagPos),t+=r,this._tagPos+=r,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let r=new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tagPos=0;{let e=this._onPayload(r);if(e!==void 0)return e===!1?t:e}}}},V=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._decipherInstance=r(t.decipherInfo.sslName,t.decipherKey,t.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(t.macInfo.isETM?4:t.decipherInfo.blockLen),this._blockSize=t.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(t.macInfo.actualLen),this._macPos=0,this._macSSLName=t.macInfo.sslName,this._macKey=t.macKey,this._macActualLen=t.macInfo.actualLen,this._macETM=t.macInfo.isETM,this._macInstance=null;let n=t.decipherInfo.discardLen;if(n){let e=p.get(n);e===void 0&&(e=Buffer.alloc(n),p.set(n,e)),this._decipherInstance.update(e)}}free(){}decrypt(e,t,n){for(;t<n;){if(this._blockPos<this._block.length){let r=Math.min(this._block.length-this._blockPos,n-t);if(t!==0||r!==n||r<e.length?this._block.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._blockPos):this._block.set(e,this._blockPos),t+=r,this._blockPos+=r,this._blockPos<this._block.length)return;let a,o;if(this._macETM?this._len=o=s(this._block,0):(a=this._decipherInstance.update(this._block),this._len=s(a,0),o=4+this._len-this._blockSize),this._len>m||this._len<5||o&this._blockSize-1)throw Error(`Bad packet length`);if(this._macInstance=i(this._macSSLName,this._macKey),c(f,this.inSeqno,0),this._macInstance.update(f),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),t>=n)return}if(this._pktLen<this._len){let r=Math.min(this._len-this._pktLen,n-t),i;i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,this._macETM&&this._macInstance.update(i);let a=this._decipherInstance.update(i);if(a.length&&(r===this._len?this._packet=a:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(a,this._packetPos)),this._packetPos+=a.length),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(this._macActualLen-this._macPos,n-t);if(t!==0||r!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._macPos):this._mac.set(e,this._macPos),t+=r,this._macPos+=r,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let r=this._macInstance.digest();if(this._macActualLen<r.length&&(r=new Uint8Array(r.buffer,r.byteOffset,this._macActualLen)),!G(r,this._mac))throw Error(`Invalid MAC`);let a=new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._macPos=0,this._macInstance=null;{let e=this._onPayload(a);if(e!==void 0)return e===!1?t:e}}}},H=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._instance=new x(t.decipherInfo.sslName,t.decipherKey,t.decipherIV,t.macInfo.sslName,t.macKey,t.macInfo.isETM,t.macInfo.actualLen),this._block=Buffer.allocUnsafe(t.macInfo.isETM||t.decipherInfo.stream?4:t.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(t.macInfo.actualLen),this._macPos=0,this._macActualLen=t.macInfo.actualLen,this._macETM=t.macInfo.isETM}free(){this._instance.free()}decrypt(e,t,n){for(;t<n;){if(this._blockPos<this._block.length){let r=Math.min(this._block.length-this._blockPos,n-t);if(t!==0||r!==n||r<e.length?this._block.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._blockPos):this._block.set(e,this._blockPos),t+=r,this._blockPos+=r,this._blockPos<this._block.length)return;let i;if(this._macETM?this._len=i=s(this._block,0):(this._instance.decryptBlock(this._block),this._len=s(this._block,0),i=4+this._len-this._block.length),this._len>m||this._len<5||i&this._block.length-1)throw Error(`Bad packet length`);if(this._macETM||(this._pktLen=this._block.length-4,this._pktLen&&(this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(this._block.buffer,this._block.byteOffset+4,this._pktLen),0))),t>=n)return}if(this._pktLen<this._len){let r=Math.min(this._len-this._pktLen,n-t),i;if(i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._pktLen)),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(this._macActualLen-this._macPos,n-t);if(t!==0||r!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._macPos):this._mac.set(e,this._macPos),t+=r,this._macPos+=r,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let r=new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._macPos=0,this._macInstance=null;{let e=this._onPayload(r);if(e!==void 0)return e===!1?t:e}}}};function U(e){++e[11]>>>8&&++e[10]>>>8&&++e[9]>>>8&&++e[8]>>>8&&++e[7]>>>8&&++e[6]>>>8&&++e[5]>>>8&&++e[4]>>>8}let W=(()=>{let e=Buffer.alloc(4);return t=>(e[0]=t>>>24,e[1]=t>>>16,e[2]=t>>>8,e[3]=t,e)})();function G(e,t){return e.length===t.length?o(e,t):(o(e,e),!1)}function ee(e){if(typeof e!=`object`||!e)throw Error(`Invalid config`);if(typeof e.outbound!=`object`||e.outbound===null)throw Error(`Invalid outbound`);let t=e.outbound;if(typeof t.onWrite!=`function`)throw Error(`Invalid outbound.onWrite`);if(typeof t.cipherInfo!=`object`||t.cipherInfo===null)throw Error(`Invalid outbound.cipherInfo`);if(!Buffer.isBuffer(t.cipherKey)||t.cipherKey.length!==t.cipherInfo.keyLen)throw Error(`Invalid outbound.cipherKey`);if(t.cipherInfo.ivLen&&(!Buffer.isBuffer(t.cipherIV)||t.cipherIV.length!==t.cipherInfo.ivLen))throw Error(`Invalid outbound.cipherIV`);if(typeof t.seqno!=`number`||t.seqno<0||t.seqno>u)throw Error(`Invalid outbound.seqno`);let n=!!t.forceNative;switch(t.cipherInfo.sslName){case`aes-128-gcm`:case`aes-256-gcm`:return g&&!n?new N(e):new M(e);case`chacha20`:return _&&!n?new j(e):new A(e);default:if(typeof t.macInfo!=`object`||t.macInfo===null)throw Error(`Invalid outbound.macInfo`);if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw Error(`Invalid outbound.macKey`);return v&&!n?new F(e):new P(e)}}function K(e){if(typeof e!=`object`||!e)throw Error(`Invalid config`);if(typeof e.inbound!=`object`||e.inbound===null)throw Error(`Invalid inbound`);let t=e.inbound;if(typeof t.onPayload!=`function`)throw Error(`Invalid inbound.onPayload`);if(typeof t.decipherInfo!=`object`||t.decipherInfo===null)throw Error(`Invalid inbound.decipherInfo`);if(!Buffer.isBuffer(t.decipherKey)||t.decipherKey.length!==t.decipherInfo.keyLen)throw Error(`Invalid inbound.decipherKey`);if(t.decipherInfo.ivLen&&(!Buffer.isBuffer(t.decipherIV)||t.decipherIV.length!==t.decipherInfo.ivLen))throw Error(`Invalid inbound.decipherIV`);if(typeof t.seqno!=`number`||t.seqno<0||t.seqno>u)throw Error(`Invalid inbound.seqno`);let n=!!t.forceNative;switch(t.decipherInfo.sslName){case`aes-128-gcm`:case`aes-256-gcm`:return y&&!n?new B(e):new z(e);case`chacha20`:return b&&!n?new R(e):new L(e);default:if(typeof t.macInfo!=`object`||t.macInfo===null)throw Error(`Invalid inbound.macInfo`);if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw Error(`Invalid inbound.macKey`);return x&&!n?new H(e):new V(e)}}t.exports={CIPHER_INFO:S,MAC_INFO:C,bindingAvailable:!!h,init:new Promise(async(e,t)=>{try{D=await rh()(),O=D._malloc(16),k=D.cwrap(`poly1305_auth`,null,[`number`,`array`,`number`,`array`,`number`,`array`])}catch(e){return t(e)}e()}),NullCipher:w,createCipher:ee,NullDecipher:I,createDecipher:K}})),ah=s(((e,t)=>{let{createDecipheriv:n,createECDH:r,createHash:i,createHmac:a,createSign:o,createVerify:s,getCiphers:c,sign:l,verify:u}=require("crypto"),d=c(),{Ber:f}=Qm(),p=eh().pbkdf,{CIPHER_INFO:m}=ih(),{eddsaSupported:h,SUPPORTED_CIPHER:g}=th(),{bufferSlice:_,makeBufferParser:v,readString:y,readUInt32BE:b,writeUInt32BE:x}=nh(),S=Symbol(`Hash Algorithm`),C=Symbol(`Private key PEM`),w=Symbol(`Public key PEM`),T=Symbol(`Public key SSH`),E=Symbol(`Decrypted Key`),D=Object.create(null);{let e=Object.keys(m);for(let t=0;t<e.length;++t){let n=m[e[t]].sslName;!n||D[n]||(D[n]=m[e[t]])}}let O=v();function k(e,t){t=t.base64Slice(0,t.length);let n=t.replace(/.{64}/g,`$&
|
|
220
|
+
-----END PRIVATE KEY-----`,t=Buffer.from(`a`),r,i;try{r=n.sign(null,t,e),i=n.verify(null,t,e,r)}catch{}return Buffer.isBuffer(r)&&r.length===64&&i===!0}return!1})(),c=typeof n.diffieHellman==`function`&&typeof n.generateKeyPairSync==`function`&&typeof n.createPublicKey==`function`,l=[`ecdh-sha2-nistp256`,`ecdh-sha2-nistp384`,`ecdh-sha2-nistp521`,`diffie-hellman-group-exchange-sha256`,`diffie-hellman-group14-sha256`,`diffie-hellman-group15-sha512`,`diffie-hellman-group16-sha512`,`diffie-hellman-group17-sha512`,`diffie-hellman-group18-sha512`];c&&(l.unshift(`curve25519-sha256`),l.unshift(`curve25519-sha256@libssh.org`));let u=l.concat([`diffie-hellman-group-exchange-sha1`,`diffie-hellman-group14-sha1`,`diffie-hellman-group1-sha1`]),d=[`ecdsa-sha2-nistp256`,`ecdsa-sha2-nistp384`,`ecdsa-sha2-nistp521`,`rsa-sha2-512`,`rsa-sha2-256`,`ssh-rsa`];s&&d.unshift(`ssh-ed25519`);let f=d.concat([`ssh-dss`]),p=(()=>{let e=n.getCiphers();return t=>e.includes(a[t].sslName)})(),m=[`aes128-gcm@openssh.com`,`aes256-gcm@openssh.com`,`aes128-ctr`,`aes192-ctr`,`aes256-ctr`];r&&r.flags&&!r.flags.aes?i?m.unshift(`chacha20-poly1305@openssh.com`):m.push(`chacha20-poly1305@openssh.com`):i&&r&&r.arch===`x86`?m.splice(4,0,`chacha20-poly1305@openssh.com`):m.push(`chacha20-poly1305@openssh.com`),m=m.filter(p);let h=m.concat([`aes256-cbc`,`aes192-cbc`,`aes128-cbc`,`blowfish-cbc`,`3des-cbc`,`aes128-gcm`,`aes256-gcm`,`arcfour256`,`arcfour128`,`cast128-cbc`,`arcfour`].filter(p)),g=(()=>{let e=n.getHashes();return t=>e.includes(o[t].sslName)})(),_=[`hmac-sha2-256-etm@openssh.com`,`hmac-sha2-512-etm@openssh.com`,`hmac-sha1-etm@openssh.com`,`hmac-sha2-256`,`hmac-sha2-512`,`hmac-sha1`].filter(g),v=_.concat([`hmac-md5`,`hmac-sha2-256-96`,`hmac-sha2-512-96`,`hmac-ripemd160`,`hmac-sha1-96`,`hmac-md5-96`].filter(g)),y=[`none`,`zlib@openssh.com`,`zlib`],b=y.concat([]),x={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};t.exports={MESSAGE:{DISCONNECT:1,IGNORE:2,UNIMPLEMENTED:3,DEBUG:4,SERVICE_REQUEST:5,SERVICE_ACCEPT:6,EXT_INFO:7,KEXINIT:20,NEWKEYS:21,KEXDH_INIT:30,KEXDH_REPLY:31,KEXDH_GEX_GROUP:31,KEXDH_GEX_INIT:32,KEXDH_GEX_REPLY:33,KEXDH_GEX_REQUEST:34,KEXECDH_INIT:30,KEXECDH_REPLY:31,USERAUTH_REQUEST:50,USERAUTH_FAILURE:51,USERAUTH_SUCCESS:52,USERAUTH_BANNER:53,USERAUTH_PASSWD_CHANGEREQ:60,USERAUTH_PK_OK:60,USERAUTH_INFO_REQUEST:60,USERAUTH_INFO_RESPONSE:61,GLOBAL_REQUEST:80,REQUEST_SUCCESS:81,REQUEST_FAILURE:82,CHANNEL_OPEN:90,CHANNEL_OPEN_CONFIRMATION:91,CHANNEL_OPEN_FAILURE:92,CHANNEL_WINDOW_ADJUST:93,CHANNEL_DATA:94,CHANNEL_EXTENDED_DATA:95,CHANNEL_EOF:96,CHANNEL_CLOSE:97,CHANNEL_REQUEST:98,CHANNEL_SUCCESS:99,CHANNEL_FAILURE:100},DISCONNECT_REASON:{HOST_NOT_ALLOWED_TO_CONNECT:1,PROTOCOL_ERROR:2,KEY_EXCHANGE_FAILED:3,RESERVED:4,MAC_ERROR:5,COMPRESSION_ERROR:6,SERVICE_NOT_AVAILABLE:7,PROTOCOL_VERSION_NOT_SUPPORTED:8,HOST_KEY_NOT_VERIFIABLE:9,CONNECTION_LOST:10,BY_APPLICATION:11,TOO_MANY_CONNECTIONS:12,AUTH_CANCELED_BY_USER:13,NO_MORE_AUTH_METHODS_AVAILABLE:14,ILLEGAL_USER_NAME:15},DISCONNECT_REASON_STR:void 0,CHANNEL_OPEN_FAILURE:{ADMINISTRATIVELY_PROHIBITED:1,CONNECT_FAILED:2,UNKNOWN_CHANNEL_TYPE:3,RESOURCE_SHORTAGE:4},TERMINAL_MODE:{TTY_OP_END:0,VINTR:1,VQUIT:2,VERASE:3,VKILL:4,VEOF:5,VEOL:6,VEOL2:7,VSTART:8,VSTOP:9,VSUSP:10,VDSUSP:11,VREPRINT:12,VWERASE:13,VLNEXT:14,VFLUSH:15,VSWTCH:16,VSTATUS:17,VDISCARD:18,IGNPAR:30,PARMRK:31,INPCK:32,ISTRIP:33,INLCR:34,IGNCR:35,ICRNL:36,IUCLC:37,IXON:38,IXANY:39,IXOFF:40,IMAXBEL:41,ISIG:50,ICANON:51,XCASE:52,ECHO:53,ECHOE:54,ECHOK:55,ECHONL:56,NOFLSH:57,TOSTOP:58,IEXTEN:59,ECHOCTL:60,ECHOKE:61,PENDIN:62,OPOST:70,OLCUC:71,ONLCR:72,OCRNL:73,ONOCR:74,ONLRET:75,CS7:90,CS8:91,PARENB:92,PARODD:93,TTY_OP_ISPEED:128,TTY_OP_OSPEED:129},CHANNEL_EXTENDED_DATATYPE:{STDERR:1},SIGNALS:[`ABRT`,`ALRM`,`FPE`,`HUP`,`ILL`,`INT`,`QUIT`,`SEGV`,`TERM`,`USR1`,`USR2`,`KILL`,`PIPE`].reduce((e,t)=>({...e,[t]:1}),{}),COMPAT:x,COMPAT_CHECKS:[[`Cisco-1.25`,x.BAD_DHGEX],[/^Cisco-1[.]/,x.BUG_DHGEX_LARGE],[/^[0-9.]+$/,x.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,x.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,x.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:l,SUPPORTED_KEX:u,DEFAULT_SERVER_HOST_KEY:d,SUPPORTED_SERVER_HOST_KEY:f,DEFAULT_CIPHER:m,SUPPORTED_CIPHER:h,DEFAULT_MAC:_,SUPPORTED_MAC:v,DEFAULT_COMPRESSION:y,SUPPORTED_COMPRESSION:b,curve25519Supported:c,eddsaSupported:s},t.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(t.exports.DISCONNECT_REASON)).reduce((e,[t,n])=>({...e,[n]:t}),{})})),nh=s(((e,t)=>{let n=Qm().Ber,r,i=Buffer[Symbol.species],a=Object.getPrototypeOf(Uint8Array.prototype).fill;function o(e,t){return e[t++]*16777216+e[t++]*65536+e[t++]*256+e[t]}function s(e,t,n,r,i){i||=0,r>e.length&&(r=e.length);let a=r-n,o=t.length-i;return a>o&&(a=o),t.set(new Uint8Array(e.buffer,e.byteOffset+n,a),i),a}function c(e,t,n){return n===void 0&&(n=e.length),new i(e.buffer,e.byteOffset+t,n-t)}function l(){let e=0,t,n={init:(n,r)=>{t=n,e=typeof r==`number`?r:0},pos:()=>e,length:()=>t?t.length:0,avail:()=>t&&e<t.length?t.length-e:0,clear:()=>{t=void 0},readUInt32BE:()=>{if(!(!t||e+3>=t.length))return t[e++]*16777216+t[e++]*65536+t[e++]*256+t[e++]},readUInt64BE:n=>{if(!(!t||e+7>=t.length))switch(n){case`always`:return BigInt(`0x${t.hexSlice(e,e+=8)}`);case`maybe`:if(t[e]>31)return BigInt(`0x${t.hexSlice(e,e+=8)}`);default:return t[e++]*72057594037927940+t[e++]*281474976710656+t[e++]*1099511627776+t[e++]*4294967296+t[e++]*16777216+t[e++]*65536+t[e++]*256+t[e++]}},skip:n=>{t&&n>0&&(e+=n)},skipString:()=>{let r=n.readUInt32BE();if(r!==void 0)return e+=r,e<=t.length?r:void 0},readByte:()=>{if(t&&e<t.length)return t[e++]},readBool:()=>{if(t&&e<t.length)return!!t[e++]},readList:()=>{let e=n.readString(!0);if(e!==void 0)return e?e.split(`,`):[]},readString:(r,i)=>{typeof r==`number`&&(i=r,r=void 0);let a=n.readUInt32BE();if(a!==void 0&&!(t.length-e<a||typeof i==`number`&&a>i))return r?Buffer.isBuffer(r)?s(t,r,e,e+=a):t.utf8Slice(e,e+=a):c(t,e,e+=a)},readRaw:n=>{if(t){if(typeof n!=`number`)return c(t,e,e+=t.length-e);if(t.length-e>=n)return c(t,e,e+=n)}}};return n}function u(e,t,n){let r=Error(e);return typeof t==`boolean`?(n=t,r.level=`protocol`):r.level=t||`protocol`,r.fatal=!!n,r}function d(e,t,n){return e[n++]=t>>>24,e[n++]=t>>>16,e[n++]=t>>>8,e[n++]=t,n}let f=l();t.exports={bufferCopy:s,bufferSlice:c,FastBuffer:i,bufferFill:(e,t,n,r)=>a.call(e,t,n,r),makeError:u,doFatalError:(e,t,n,i)=>{let a;return r===void 0&&({DISCONNECT_REASON:r}=th()),t instanceof Error?(a=t,i=typeof n==`number`?n:r.PROTOCOL_ERROR):a=u(t,n,!0),typeof i!=`number`&&(i=r.PROTOCOL_ERROR),e.disconnect(i),e._destruct(),e._onError(a),1/0},readUInt32BE:o,writeUInt32BE:d,writeUInt32LE:(e,t,n)=>(e[n++]=t,e[n++]=t>>>8,e[n++]=t>>>16,e[n++]=t>>>24,n),makeBufferParser:l,bufferParser:l(),readString:(e,t,n,r)=>{typeof n==`number`&&(r=n,n=void 0),t===void 0&&(t=0);let i=e.length-t;if(t<0||t>=e.length||i<4)return;let a=o(e,t);if(i<4+a||typeof r==`number`&&a>r)return;t+=4;let l=t+a;return e._pos=l,n?Buffer.isBuffer(n)?s(e,n,t,l):e.utf8Slice(t,l):c(e,t,l)},sigSSHToASN1:(e,t)=>{switch(t){case`ssh-dss`:{if(e.length>40)return e;let t=new n.Writer;t.startSequence();let r=e.slice(0,20),i=e.slice(20);if(r[0]&128){let e=Buffer.allocUnsafe(21);e[0]=0,r.copy(e,1),r=e}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(i[0]&128){let e=Buffer.allocUnsafe(21);e[0]=0,i.copy(e,1),i=e}else i[0]===0&&!(i[1]&128)&&(i=i.slice(1));return t.writeBuffer(r,n.Integer),t.writeBuffer(i,n.Integer),t.endSequence(),t.buffer}case`ecdsa-sha2-nistp256`:case`ecdsa-sha2-nistp384`:case`ecdsa-sha2-nistp521`:{f.init(e,0);let t=f.readString(),r=f.readString();if(f.clear(),t===void 0||r===void 0)return;let i=new n.Writer;return i.startSequence(),i.writeBuffer(t,n.Integer),i.writeBuffer(r,n.Integer),i.endSequence(),i.buffer}default:return e}},convertSignature:(e,t)=>{switch(t){case`ssh-dss`:{if(e.length<=40)return e;let t=new n.Reader(e);t.readSequence();let r=t.readString(n.Integer,!0),i=t.readString(n.Integer,!0),a=0,o=0;if(r.length<20){let e=Buffer.allocUnsafe(20);e.set(r,1),r=e,r[0]=0}if(i.length<20){let e=Buffer.allocUnsafe(20);e.set(i,1),i=e,i[0]=0}r.length>20&&r[0]===0&&(a=1),i.length>20&&i[0]===0&&(o=1);let c=Buffer.allocUnsafe(r.length-a+(i.length-o));return s(r,c,a,r.length,0),s(i,c,o,i.length,r.length-a),c}case`ecdsa-sha2-nistp256`:case`ecdsa-sha2-nistp384`:case`ecdsa-sha2-nistp521`:{if(e[0]===0)return e;let t=new n.Reader(e);t.readSequence();let r=t.readString(n.Integer,!0),i=t.readString(n.Integer,!0);if(r===null||i===null)return;let a=Buffer.allocUnsafe(4+r.length+4+i.length);return d(a,r.length,0),a.set(r,4),d(a,i.length,4+r.length),a.set(i,8+r.length),a}}return e},sendPacket:(e,t,n)=>!n&&e._kexinit!==void 0?(e._queue===void 0&&(e._queue=[]),e._queue.push(t),e._debug&&e._debug(`Outbound: ... packet queued`),!1):(e._cipher.encrypt(t),!0)}})),rh=s(((e,t)=>{var n=(function(){var e=typeof document<`u`&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<`u`&&(e||=__filename),(function(t){t||={};var n;n||=t===void 0?{}:t;var r,i;n.ready=new Promise(function(e,t){r=e,i=t});var a={},o;for(o in n)n.hasOwnProperty(o)&&(a[o]=n[o]);var s=typeof window==`object`,c=typeof importScripts==`function`,l=typeof process==`object`&&typeof process.versions==`object`&&typeof process.versions.node==`string`,u=``,d,f,p,m,h;l?(u=c?require("path").dirname(u)+`/`:__dirname+`/`,d=function(e,t){var n=G(e);return n?t?n:n.toString():(m||=require("fs"),h||=require("path"),e=h.normalize(e),m.readFileSync(e,t?null:`utf8`))},p=function(e){return e=d(e,!0),e.buffer||(e=new Uint8Array(e)),b(e.buffer),e},f=function(e,t,n){var r=G(e);r&&t(r),m||=require("fs"),h||=require("path"),e=h.normalize(e),m.readFile(e,function(e,r){e?n(e):t(r.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,`/`),process.argv.slice(2),n.inspect=function(){return`[Emscripten Module object]`}):(s||c)&&(c?u=self.location.href:typeof document<`u`&&document.currentScript&&(u=document.currentScript.src),e&&(u=e),u=u.indexOf(`blob:`)===0?``:u.substr(0,u.lastIndexOf(`/`)+1),d=function(e){try{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.send(null),t.responseText}catch(i){if(e=G(e)){t=[];for(var n=0;n<e.length;n++){var r=e[n];255<r&&(U&&b(!1,`Character code `+r+` (`+String.fromCharCode(r)+`) at offset `+n+` not in 0x00-0xFF.`),r&=255),t.push(String.fromCharCode(r))}return t.join(``)}throw i}},c&&(p=function(e){try{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}catch(t){if(e=G(e))return e;throw t}}),f=function(e,t,n){var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=function(){if(r.status==200||r.status==0&&r.response)t(r.response);else{var i=G(e);i?t(i.buffer):n()}},r.onerror=n,r.send(null)}),n.print||console.log.bind(console);var g=n.printErr||console.warn.bind(console);for(o in a)a.hasOwnProperty(o)&&(n[o]=a[o]);a=null;var _;n.wasmBinary&&(_=n.wasmBinary),n.noExitRuntime,typeof WebAssembly!=`object`&&I(`no native wasm support detected`);var v,y=!1;function b(e,t){e||I(`Assertion failed: `+t)}function x(e){var t=n[`_`+e];return b(t,`Cannot call unknown function `+e+`, make sure it is exported`),t}function S(e,t,n,r){var i={string:function(e){var t=0;if(e!=null&&e!==0){var n=(e.length<<2)+1;t=te(n);var r=t,i=E;if(0<n){n=r+n-1;for(var a=0;a<e.length;++a){var o=e.charCodeAt(a);if(55296<=o&&57343>=o){var s=e.charCodeAt(++a);o=65536+((o&1023)<<10)|s&1023}if(127>=o){if(r>=n)break;i[r++]=o}else{if(2047>=o){if(r+1>=n)break;i[r++]=192|o>>6}else{if(65535>=o){if(r+2>=n)break;i[r++]=224|o>>12}else{if(r+3>=n)break;i[r++]=240|o>>18,i[r++]=128|o>>12&63}i[r++]=128|o>>6&63}i[r++]=128|o&63}}i[r]=0}}return t},array:function(e){var t=te(e.length);return T.set(e,t),t}},a=x(e),o=[];if(e=0,r)for(var s=0;s<r.length;s++){var c=i[n[s]];c?(e===0&&(e=K()),o[s]=c(r[s])):o[s]=r[s]}return n=a.apply(null,o),n=function(e){if(t===`string`)if(e){for(var n=E,r=e+NaN,i=e;n[i]&&!(i>=r);)++i;if(16<i-e&&n.subarray&&C)e=C.decode(n.subarray(e,i));else{for(r=``;e<i;){var a=n[e++];if(a&128){var o=n[e++]&63;if((a&224)==192)r+=String.fromCharCode((a&31)<<6|o);else{var s=n[e++]&63;a=(a&240)==224?(a&15)<<12|o<<6|s:(a&7)<<18|o<<12|s<<6|n[e++]&63,65536>a?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|a&1023))}}else r+=String.fromCharCode(a)}e=r}}else e=``;else e=t===`boolean`?!!e:e;return e}(n),e!==0&&q(e),n}var C=typeof TextDecoder<`u`?new TextDecoder(`utf8`):void 0,w,T,E;function D(){var e=v.buffer;w=e,n.HEAP8=T=new Int8Array(e),n.HEAP16=new Int16Array(e),n.HEAP32=new Int32Array(e),n.HEAPU8=E=new Uint8Array(e),n.HEAPU16=new Uint16Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=new Float32Array(e),n.HEAPF64=new Float64Array(e)}var O,k=[],A=[],j=[];function M(){var e=n.preRun.shift();k.unshift(e)}var N=0,P=null,F=null;n.preloadedImages={},n.preloadedAudios={};function I(e){throw n.onAbort&&n.onAbort(e),g(e),y=!0,e=new WebAssembly.RuntimeError(`abort(`+e+`). Build with -s ASSERTIONS=1 for more info.`),i(e),e}var L=`data:application/octet-stream;base64,`,R=`data:application/octet-stream;base64,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`;if(!R.startsWith(L)){var z=R;R=n.locateFile?n.locateFile(z,u):u+z}function B(){var e=R;try{if(e==R&&_)return new Uint8Array(_);var t=G(e);if(t)return t;if(p)return p(e);throw`both async and sync fetching of the wasm failed`}catch(e){I(e)}}function V(){if(!_&&(s||c)){if(typeof fetch==`function`&&!R.startsWith(`file://`))return fetch(R,{credentials:`same-origin`}).then(function(e){if(!e.ok)throw`failed to load wasm binary file at '`+R+`'`;return e.arrayBuffer()}).catch(function(){return B()});if(f)return new Promise(function(e,t){f(R,function(t){e(new Uint8Array(t))},t)})}return Promise.resolve().then(function(){return B()})}function H(e){for(;0<e.length;){var t=e.shift();if(typeof t==`function`)t(n);else{var r=t.m;typeof r==`number`?t.l===void 0?O.get(r)():O.get(r)(t.l):r(t.l===void 0?null:t.l)}}}var U=!1,W=typeof atob==`function`?atob:function(e){var t=``,n=0;e=e.replace(/[^A-Za-z0-9\+\/=]/g,``);do{var r=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`.indexOf(e.charAt(n++)),i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`.indexOf(e.charAt(n++)),a=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`.indexOf(e.charAt(n++)),o=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`.indexOf(e.charAt(n++));r=r<<2|i>>4,i=(i&15)<<4|a>>2;var s=(a&3)<<6|o;t+=String.fromCharCode(r),a!==64&&(t+=String.fromCharCode(i)),o!==64&&(t+=String.fromCharCode(s))}while(n<e.length);return t};function G(e){if(e.startsWith(L)){if(e=e.slice(L.length),typeof l==`boolean`&&l){var t=Buffer.from(e,`base64`);t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}else try{var n=W(e),r=new Uint8Array(n.length);for(e=0;e<n.length;++e)r[e]=n.charCodeAt(e);t=r}catch{throw Error(`Converting base64 string to bytes failed.`)}return t}}var ee={a:function(e){var t=E.length;if(e>>>=0,2147483648<e)return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296),r=Math.max(e,r),0<r%65536&&(r+=65536-r%65536);a:{try{v.grow(Math.min(2147483648,r)-w.byteLength+65535>>>16),D();var i=1;break a}catch{}i=void 0}if(i)return!0}return!1}};(function(){function e(e){n.asm=e.exports,v=n.asm.b,D(),O=n.asm.j,A.unshift(n.asm.c),N--,n.monitorRunDependencies&&n.monitorRunDependencies(N),N==0&&(P!==null&&(clearInterval(P),P=null),F&&(e=F,F=null,e()))}function t(t){e(t.instance)}function r(e){return V().then(function(e){return WebAssembly.instantiate(e,a)}).then(e,function(e){g(`failed to asynchronously prepare wasm: `+e),I(e)})}var a={a:ee};if(N++,n.monitorRunDependencies&&n.monitorRunDependencies(N),n.instantiateWasm)try{return n.instantiateWasm(a,e)}catch(e){return g(`Module.instantiateWasm callback failed with error: `+e),!1}return(function(){return _||typeof WebAssembly.instantiateStreaming!=`function`||R.startsWith(L)||R.startsWith(`file://`)||typeof fetch!=`function`?r(t):fetch(R,{credentials:`same-origin`}).then(function(e){return WebAssembly.instantiateStreaming(e,a).then(t,function(e){return g(`wasm streaming compile failed: `+e),g(`falling back to ArrayBuffer instantiation`),r(t)})})})().catch(i),{}})(),n.___wasm_call_ctors=function(){return(n.___wasm_call_ctors=n.asm.c).apply(null,arguments)},n._poly1305_auth=function(){return(n._poly1305_auth=n.asm.d).apply(null,arguments)};var K=n.stackSave=function(){return(K=n.stackSave=n.asm.e).apply(null,arguments)},q=n.stackRestore=function(){return(q=n.stackRestore=n.asm.f).apply(null,arguments)},te=n.stackAlloc=function(){return(te=n.stackAlloc=n.asm.g).apply(null,arguments)};n._malloc=function(){return(n._malloc=n.asm.h).apply(null,arguments)},n._free=function(){return(n._free=n.asm.i).apply(null,arguments)},n.cwrap=function(e,t,n,r){n||=[];var i=n.every(function(e){return e===`number`});return t!==`string`&&i&&!r?x(e):function(){return S(e,t,n,arguments)}};var ne;F=function e(){ne||re(),ne||(F=e)};function re(){function e(){if(!ne&&(ne=!0,n.calledRun=!0,!y)){if(H(A),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),n.postRun)for(typeof n.postRun==`function`&&(n.postRun=[n.postRun]);n.postRun.length;){var e=n.postRun.shift();j.unshift(e)}H(j)}}if(!(0<N)){if(n.preRun)for(typeof n.preRun==`function`&&(n.preRun=[n.preRun]);n.preRun.length;)M();H(k),0<N||(n.setStatus?(n.setStatus(`Running...`),setTimeout(function(){setTimeout(function(){n.setStatus(``)},1),e()},1)):e())}}if(n.run=re,n.preInit)for(typeof n.preInit==`function`&&(n.preInit=[n.preInit]);0<n.preInit.length;)n.preInit.pop()();return re(),t.ready})})();typeof e==`object`&&typeof t==`object`?t.exports=n:typeof define==`function`&&define.amd?define([],function(){return n}):typeof e==`object`&&(e.createPoly1305=n)})),ih=s(((e,t)=>{let{createCipheriv:n,createDecipheriv:r,createHmac:i,randomFillSync:a,timingSafeEqual:o}=require("crypto"),{readUInt32BE:s,writeUInt32BE:c}=nh(),l=Buffer[Symbol.species],u=2**32-1,d=Buffer.alloc(0),f=Buffer.alloc(4),p=new Map,m=35e3,h,g,_,v,y,b,x;try{h=require("../node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node"),{AESGCMCipher:g,ChaChaPolyCipher:_,GenericCipher:v,AESGCMDecipher:y,ChaChaPolyDecipher:b,GenericDecipher:x}=h}catch{}let S=(()=>{function e(e,t,n,r,i,a,o){return{sslName:e,blockLen:t,keyLen:n,ivLen:r!==0||o&1?r:t,authLen:i,discardLen:a,stream:!!(o&1)}}return{"chacha20-poly1305@openssh.com":e(`chacha20`,8,64,0,16,0,1),"aes128-gcm":e(`aes-128-gcm`,16,16,12,16,0,1),"aes256-gcm":e(`aes-256-gcm`,16,32,12,16,0,1),"aes128-gcm@openssh.com":e(`aes-128-gcm`,16,16,12,16,0,1),"aes256-gcm@openssh.com":e(`aes-256-gcm`,16,32,12,16,0,1),"aes128-cbc":e(`aes-128-cbc`,16,16,0,0,0,0),"aes192-cbc":e(`aes-192-cbc`,16,24,0,0,0,0),"aes256-cbc":e(`aes-256-cbc`,16,32,0,0,0,0),"rijndael-cbc@lysator.liu.se":e(`aes-256-cbc`,16,32,0,0,0,0),"3des-cbc":e(`des-ede3-cbc`,8,24,0,0,0,0),"blowfish-cbc":e(`bf-cbc`,8,16,0,0,0,0),"idea-cbc":e(`idea-cbc`,8,16,0,0,0,0),"cast128-cbc":e(`cast-cbc`,8,16,0,0,0,0),"aes128-ctr":e(`aes-128-ctr`,16,16,16,0,0,1),"aes192-ctr":e(`aes-192-ctr`,16,24,16,0,0,1),"aes256-ctr":e(`aes-256-ctr`,16,32,16,0,0,1),"3des-ctr":e(`des-ede3`,8,24,8,0,0,1),"blowfish-ctr":e(`bf-ecb`,8,16,8,0,0,1),"cast128-ctr":e(`cast5-ecb`,8,16,8,0,0,1),arcfour:e(`rc4`,8,16,0,0,1536,1),arcfour128:e(`rc4`,8,16,0,0,1536,1),arcfour256:e(`rc4`,8,32,0,0,1536,1),arcfour512:e(`rc4`,8,64,0,0,1536,1)}})(),C=(()=>{function e(e,t,n,r){return{sslName:e,len:t,actualLen:n,isETM:r}}return{"hmac-md5":e(`md5`,16,16,!1),"hmac-md5-96":e(`md5`,16,12,!1),"hmac-ripemd160":e(`ripemd160`,20,20,!1),"hmac-sha1":e(`sha1`,20,20,!1),"hmac-sha1-etm@openssh.com":e(`sha1`,20,20,!0),"hmac-sha1-96":e(`sha1`,20,12,!1),"hmac-sha2-256":e(`sha256`,32,32,!1),"hmac-sha2-256-etm@openssh.com":e(`sha256`,32,32,!0),"hmac-sha2-256-96":e(`sha256`,32,12,!1),"hmac-sha2-512":e(`sha512`,64,64,!1),"hmac-sha2-512-etm@openssh.com":e(`sha512`,64,64,!0),"hmac-sha2-512-96":e(`sha512`,64,12,!1)}})();var w=class{constructor(e,t){this.outSeqno=e,this._onWrite=t,this._dead=!1}free(){this._dead=!0}allocPacket(e){let t=5+e,n=8-(t&7);n<4&&(n+=8),t+=n;let r=Buffer.allocUnsafe(t);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){this._dead||(this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}};let T=Buffer.alloc(32),E=Buffer.alloc(16),D,O,k;var A=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._encKeyMain=t.cipherKey.slice(0,32),this._encKeyPktLen=t.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(e){let t=5+e,n=8-(t-4&7);n<4&&(n+=8),t+=n;let r=Buffer.allocUnsafe(t);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){if(this._dead)return;E[0]=0,c(E,this.outSeqno,12);let t=n(`chacha20`,this._encKeyMain,E).update(T),r=n(`chacha20`,this._encKeyPktLen,E).update(e.slice(0,4));this._onWrite(r),E[0]=1;let i=n(`chacha20`,this._encKeyMain,E).update(e.slice(4));this._onWrite(i),k(O,r,r.length,i,i.length,t);let a=Buffer.allocUnsafe(16);a.set(new Uint8Array(D.HEAPU8.buffer,O,16),0),this._onWrite(a),this.outSeqno=this.outSeqno+1>>>0}},j=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._instance=new _(t.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let t=5+e,n=8-(t-4&7);n<4&&(n+=8),t+=n;let r=Buffer.allocUnsafe(t+16);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){this._dead||(this._instance.encrypt(e,this.outSeqno),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},M=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._encSSLName=t.cipherInfo.sslName,this._encKey=t.cipherKey,this._encIV=t.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(e){let t=5+e,n=16-(t-4&15);n<4&&(n+=16),t+=n;let r=Buffer.allocUnsafe(t);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){if(this._dead)return;let t=n(this._encSSLName,this._encKey,this._encIV);t.setAutoPadding(!1);let r=e.slice(0,4);t.setAAD(r),this._onWrite(r);let i=t.update(e.slice(4));this._onWrite(i);let a=t.final();a.length&&this._onWrite(a);let o=t.getAuthTag();this._onWrite(o),U(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},N=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._instance=new g(t.cipherInfo.sslName,t.cipherKey,t.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let t=5+e,n=16-(t-4&15);n<4&&(n+=16),t+=n;let r=Buffer.allocUnsafe(t+16);return c(r,t-4,0),r[4]=n,a(r,5+e,n),r}encrypt(e){this._dead||(this._instance.encrypt(e),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},P=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._encBlockLen=t.cipherInfo.blockLen,this._cipherInstance=n(t.cipherInfo.sslName,t.cipherKey,t.cipherIV),this._macSSLName=t.macInfo.sslName,this._macKey=t.macKey,this._macActualLen=t.macInfo.actualLen,this._macETM=t.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let r=t.cipherInfo.discardLen;if(r){let e=p.get(r);e===void 0&&(e=Buffer.alloc(r),p.set(r,e)),this._cipherInstance.update(e)}}free(){this._dead=!0}allocPacket(e){let t=this._encBlockLen,n=5+e,r=t-(n-this._aadLen&t-1);r<4&&(r+=t),n+=r;let i=Buffer.allocUnsafe(n);return c(i,n-4,0),i[4]=r,a(i,5+e,r),i}encrypt(e){if(this._dead)return;let t;if(this._macETM){let n=new Uint8Array(e.buffer,e.byteOffset,4),r=this._cipherInstance.update(new Uint8Array(e.buffer,e.byteOffset+4,e.length-4));this._onWrite(n),this._onWrite(r),t=i(this._macSSLName,this._macKey),c(f,this.outSeqno,0),t.update(f),t.update(n),t.update(r)}else{let n=this._cipherInstance.update(e);this._onWrite(n),t=i(this._macSSLName,this._macKey),c(f,this.outSeqno,0),t.update(f),t.update(e)}let n=t.digest();n.length>this._macActualLen&&(n=n.slice(0,this._macActualLen)),this._onWrite(n),this.outSeqno=this.outSeqno+1>>>0}},F=class{constructor(e){let t=e.outbound;this.outSeqno=t.seqno,this._onWrite=t.onWrite,this._encBlockLen=t.cipherInfo.blockLen,this._macLen=t.macInfo.len,this._macActualLen=t.macInfo.actualLen,this._aadLen=t.macInfo.isETM?4:0,this._instance=new v(t.cipherInfo.sslName,t.cipherKey,t.cipherIV,t.macInfo.sslName,t.macKey,t.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let t=this._encBlockLen,n=5+e,r=t-(n-this._aadLen&t-1);r<4&&(r+=t),n+=r;let i=Buffer.allocUnsafe(n+this._macLen);return c(i,n-4,0),i[4]=r,a(i,5+e,r),i}encrypt(e){this._dead||(this._instance.encrypt(e,this.outSeqno),this._macActualLen<this._macLen&&(e=new l(e.buffer,e.byteOffset,e.length-(this._macLen-this._macActualLen))),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},I=class{constructor(e,t){this.inSeqno=e,this._onPayload=t,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(e,t,n){for(;t<n;){if(this._lenBytes<4){let r=Math.min(4-this._lenBytes,n-t);for(this._lenBytes+=r;r--;)this._len=(this._len<<8)+e[t++];if(this._lenBytes<4)return;if(this._len>m||this._len<8||4+this._len&7)throw Error(`Bad packet length`);if(t>=n)return}if(this._packetPos<this._len){let r=Math.min(this._len-this._packetPos,n-t),i;if(i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._packetPos)),t+=r,this._packetPos+=r,this._packetPos<this._len)return}let r=this._packet?new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):d;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let e=this._onPayload(r);if(e!==void 0)return e===!1?t:e}}}},L=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._decKeyMain=t.decipherKey.slice(0,32),this._decKeyPktLen=t.decipherKey.slice(32),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._calcMac=Buffer.allocUnsafe(16),this._macPos=0}free(){}decrypt(e,t,i){for(;t<i;){if(this._lenPos<4){let n=Math.min(4-this._lenPos,i-t);for(;n--;)this._lenBuf[this._lenPos++]=e[t++];if(this._lenPos<4)return;E[0]=0,c(E,this.inSeqno,12);let a=r(`chacha20`,this._decKeyPktLen,E).update(this._lenBuf);if(this._len=s(a,0),this._len>m||this._len<8||this._len&7)throw Error(`Bad packet length`)}if(this._pktLen<this._len){if(t>=i)return;let n=Math.min(this._len-this._pktLen,i-t),r;if(r=t!==0||n!==i?new Uint8Array(e.buffer,e.byteOffset+t,n):e,n===this._len?this._packet=r:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(r,this._pktLen)),t+=n,this._pktLen+=n,this._pktLen<this._len||t>=i)return}{let n=Math.min(16-this._macPos,i-t);if(t!==0||n!==i?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+t,n),this._macPos):this._mac.set(e,this._macPos),t+=n,this._macPos+=n,this._macPos<16)return}E[0]=0,c(E,this.inSeqno,12);let a=n(`chacha20`,this._decKeyMain,E).update(T);if(k(O,this._lenBuf,4,this._packet,this._packet.length,a),this._calcMac.set(new Uint8Array(D.HEAPU8.buffer,O,16),0),!o(this._calcMac,this._mac))throw Error(`Invalid MAC`);E[0]=1;let u=r(`chacha20`,this._decKeyMain,E).update(this._packet),d=new l(u.buffer,u.byteOffset+1,u.length-u[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let e=this._onPayload(d);if(e!==void 0)return e===!1?t:e}}}},R=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._instance=new b(t.decipherKey),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._macPos=0}free(){this._instance.free()}decrypt(e,t,n){for(;t<n;){if(this._lenPos<4){let r=Math.min(4-this._lenPos,n-t);for(;r--;)this._lenBuf[this._lenPos++]=e[t++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>m||this._len<8||this._len&7)throw Error(`Bad packet length`);if(t>=n)return}if(this._pktLen<this._len){let r=Math.min(this._len-this._pktLen,n-t),i;if(i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._pktLen)),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(16-this._macPos,n-t);if(t!==0||r!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._macPos):this._mac.set(e,this._macPos),t+=r,this._macPos+=r,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let r=new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let e=this._onPayload(r);if(e!==void 0)return e===!1?t:e}}}},z=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._decipherInstance=null,this._decipherSSLName=t.decipherInfo.sslName,this._decipherKey=t.decipherKey,this._decipherIV=t.decipherIV,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(e,t,n){for(;t<n;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,n-t);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+e[t++];if(this._lenBytes<4)return;if(this._len+20>m||this._len<16||this._len&15)throw Error(`Bad packet length`);this._decipherInstance=r(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(W(this._len))}if(this._pktLen<this._len){if(t>=n)return;let r=Math.min(this._len-this._pktLen,n-t),i;if(i=t!==0||r!==n?this._decipherInstance.update(new Uint8Array(e.buffer,e.byteOffset+t,r)):this._decipherInstance.update(e),i.length&&(r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._packetPos)),this._packetPos+=i.length),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(16-this._tagPos,n-t);if(t!==0||r!==n?this._tag.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._tagPos):this._tag.set(e,this._tagPos),t+=r,this._tagPos+=r,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let e=this._decipherInstance.final();e.length&&(this._packet?this._packet.set(e,this._packetPos):this._packet=e)}let i=this._packet?new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):d;this.inSeqno=this.inSeqno+1>>>0,U(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let e=this._onPayload(i);if(e!==void 0)return e===!1?t:e}}}},B=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._instance=new y(t.decipherInfo.sslName,t.decipherKey,t.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(e,t,n){for(;t<n;){if(this._lenBytes<4){let r=Math.min(4-this._lenBytes,n-t);for(this._lenBytes+=r;r--;)this._len=(this._len<<8)+e[t++];if(this._lenBytes<4)return;if(this._len+20>m||this._len<16||this._len&15)throw Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(t>=n)return;let r=Math.min(this._len-this._pktLen,n-t),i;if(i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._pktLen)),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(16-this._tagPos,n-t);if(t!==0||r!==n?this._tag.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._tagPos):this._tag.set(e,this._tagPos),t+=r,this._tagPos+=r,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let r=new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tagPos=0;{let e=this._onPayload(r);if(e!==void 0)return e===!1?t:e}}}},V=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._decipherInstance=r(t.decipherInfo.sslName,t.decipherKey,t.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(t.macInfo.isETM?4:t.decipherInfo.blockLen),this._blockSize=t.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(t.macInfo.actualLen),this._macPos=0,this._macSSLName=t.macInfo.sslName,this._macKey=t.macKey,this._macActualLen=t.macInfo.actualLen,this._macETM=t.macInfo.isETM,this._macInstance=null;let n=t.decipherInfo.discardLen;if(n){let e=p.get(n);e===void 0&&(e=Buffer.alloc(n),p.set(n,e)),this._decipherInstance.update(e)}}free(){}decrypt(e,t,n){for(;t<n;){if(this._blockPos<this._block.length){let r=Math.min(this._block.length-this._blockPos,n-t);if(t!==0||r!==n||r<e.length?this._block.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._blockPos):this._block.set(e,this._blockPos),t+=r,this._blockPos+=r,this._blockPos<this._block.length)return;let a,o;if(this._macETM?this._len=o=s(this._block,0):(a=this._decipherInstance.update(this._block),this._len=s(a,0),o=4+this._len-this._blockSize),this._len>m||this._len<5||o&this._blockSize-1)throw Error(`Bad packet length`);if(this._macInstance=i(this._macSSLName,this._macKey),c(f,this.inSeqno,0),this._macInstance.update(f),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),t>=n)return}if(this._pktLen<this._len){let r=Math.min(this._len-this._pktLen,n-t),i;i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,this._macETM&&this._macInstance.update(i);let a=this._decipherInstance.update(i);if(a.length&&(r===this._len?this._packet=a:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(a,this._packetPos)),this._packetPos+=a.length),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(this._macActualLen-this._macPos,n-t);if(t!==0||r!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._macPos):this._mac.set(e,this._macPos),t+=r,this._macPos+=r,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let r=this._macInstance.digest();if(this._macActualLen<r.length&&(r=new Uint8Array(r.buffer,r.byteOffset,this._macActualLen)),!G(r,this._mac))throw Error(`Invalid MAC`);let a=new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._macPos=0,this._macInstance=null;{let e=this._onPayload(a);if(e!==void 0)return e===!1?t:e}}}},H=class{constructor(e){let t=e.inbound;this.inSeqno=t.seqno,this._onPayload=t.onPayload,this._instance=new x(t.decipherInfo.sslName,t.decipherKey,t.decipherIV,t.macInfo.sslName,t.macKey,t.macInfo.isETM,t.macInfo.actualLen),this._block=Buffer.allocUnsafe(t.macInfo.isETM||t.decipherInfo.stream?4:t.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(t.macInfo.actualLen),this._macPos=0,this._macActualLen=t.macInfo.actualLen,this._macETM=t.macInfo.isETM}free(){this._instance.free()}decrypt(e,t,n){for(;t<n;){if(this._blockPos<this._block.length){let r=Math.min(this._block.length-this._blockPos,n-t);if(t!==0||r!==n||r<e.length?this._block.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._blockPos):this._block.set(e,this._blockPos),t+=r,this._blockPos+=r,this._blockPos<this._block.length)return;let i;if(this._macETM?this._len=i=s(this._block,0):(this._instance.decryptBlock(this._block),this._len=s(this._block,0),i=4+this._len-this._block.length),this._len>m||this._len<5||i&this._block.length-1)throw Error(`Bad packet length`);if(this._macETM||(this._pktLen=this._block.length-4,this._pktLen&&(this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(this._block.buffer,this._block.byteOffset+4,this._pktLen),0))),t>=n)return}if(this._pktLen<this._len){let r=Math.min(this._len-this._pktLen,n-t),i;if(i=t!==0||r!==n?new Uint8Array(e.buffer,e.byteOffset+t,r):e,r===this._len?this._packet=i:(this._packet||=Buffer.allocUnsafe(this._len),this._packet.set(i,this._pktLen)),t+=r,this._pktLen+=r,this._pktLen<this._len||t>=n)return}{let r=Math.min(this._macActualLen-this._macPos,n-t);if(t!==0||r!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+t,r),this._macPos):this._mac.set(e,this._macPos),t+=r,this._macPos+=r,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let r=new l(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._macPos=0,this._macInstance=null;{let e=this._onPayload(r);if(e!==void 0)return e===!1?t:e}}}};function U(e){++e[11]>>>8&&++e[10]>>>8&&++e[9]>>>8&&++e[8]>>>8&&++e[7]>>>8&&++e[6]>>>8&&++e[5]>>>8&&++e[4]>>>8}let W=(()=>{let e=Buffer.alloc(4);return t=>(e[0]=t>>>24,e[1]=t>>>16,e[2]=t>>>8,e[3]=t,e)})();function G(e,t){return e.length===t.length?o(e,t):(o(e,e),!1)}function ee(e){if(typeof e!=`object`||!e)throw Error(`Invalid config`);if(typeof e.outbound!=`object`||e.outbound===null)throw Error(`Invalid outbound`);let t=e.outbound;if(typeof t.onWrite!=`function`)throw Error(`Invalid outbound.onWrite`);if(typeof t.cipherInfo!=`object`||t.cipherInfo===null)throw Error(`Invalid outbound.cipherInfo`);if(!Buffer.isBuffer(t.cipherKey)||t.cipherKey.length!==t.cipherInfo.keyLen)throw Error(`Invalid outbound.cipherKey`);if(t.cipherInfo.ivLen&&(!Buffer.isBuffer(t.cipherIV)||t.cipherIV.length!==t.cipherInfo.ivLen))throw Error(`Invalid outbound.cipherIV`);if(typeof t.seqno!=`number`||t.seqno<0||t.seqno>u)throw Error(`Invalid outbound.seqno`);let n=!!t.forceNative;switch(t.cipherInfo.sslName){case`aes-128-gcm`:case`aes-256-gcm`:return g&&!n?new N(e):new M(e);case`chacha20`:return _&&!n?new j(e):new A(e);default:if(typeof t.macInfo!=`object`||t.macInfo===null)throw Error(`Invalid outbound.macInfo`);if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw Error(`Invalid outbound.macKey`);return v&&!n?new F(e):new P(e)}}function K(e){if(typeof e!=`object`||!e)throw Error(`Invalid config`);if(typeof e.inbound!=`object`||e.inbound===null)throw Error(`Invalid inbound`);let t=e.inbound;if(typeof t.onPayload!=`function`)throw Error(`Invalid inbound.onPayload`);if(typeof t.decipherInfo!=`object`||t.decipherInfo===null)throw Error(`Invalid inbound.decipherInfo`);if(!Buffer.isBuffer(t.decipherKey)||t.decipherKey.length!==t.decipherInfo.keyLen)throw Error(`Invalid inbound.decipherKey`);if(t.decipherInfo.ivLen&&(!Buffer.isBuffer(t.decipherIV)||t.decipherIV.length!==t.decipherInfo.ivLen))throw Error(`Invalid inbound.decipherIV`);if(typeof t.seqno!=`number`||t.seqno<0||t.seqno>u)throw Error(`Invalid inbound.seqno`);let n=!!t.forceNative;switch(t.decipherInfo.sslName){case`aes-128-gcm`:case`aes-256-gcm`:return y&&!n?new B(e):new z(e);case`chacha20`:return b&&!n?new R(e):new L(e);default:if(typeof t.macInfo!=`object`||t.macInfo===null)throw Error(`Invalid inbound.macInfo`);if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw Error(`Invalid inbound.macKey`);return x&&!n?new H(e):new V(e)}}t.exports={CIPHER_INFO:S,MAC_INFO:C,bindingAvailable:!!h,init:new Promise(async(e,t)=>{try{D=await rh()(),O=D._malloc(16),k=D.cwrap(`poly1305_auth`,null,[`number`,`array`,`number`,`array`,`number`,`array`])}catch(e){return t(e)}e()}),NullCipher:w,createCipher:ee,NullDecipher:I,createDecipher:K}})),ah=s(((e,t)=>{let{createDecipheriv:n,createECDH:r,createHash:i,createHmac:a,createSign:o,createVerify:s,getCiphers:c,sign:l,verify:u}=require("crypto"),d=c(),{Ber:f}=Qm(),p=eh().pbkdf,{CIPHER_INFO:m}=ih(),{eddsaSupported:h,SUPPORTED_CIPHER:g}=th(),{bufferSlice:_,makeBufferParser:v,readString:y,readUInt32BE:b,writeUInt32BE:x}=nh(),S=Symbol(`Hash Algorithm`),C=Symbol(`Private key PEM`),w=Symbol(`Public key PEM`),T=Symbol(`Public key SSH`),E=Symbol(`Decrypted Key`),D=Object.create(null);{let e=Object.keys(m);for(let t=0;t<e.length;++t){let n=m[e[t]].sslName;!n||D[n]||(D[n]=m[e[t]])}}let O=v();function k(e,t){t=t.base64Slice(0,t.length);let n=t.replace(/.{64}/g,`$&
|
|
221
221
|
`);return t.length&63&&(n+=`
|
|
222
222
|
`),`-----BEGIN ${e} KEY-----\n${n}-----END ${e} KEY-----`}function A(e,t){let n=Buffer.allocUnsafe(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function j(e,t){let n=e.length,r=e._pos||0;for(let i=0;i<t;++i){let t=n-r;if(r>=n||t<4)return!1;let i=b(e,r);if(t<4+i)return!1;r+=4+i}return e._pos=r,!0}function M(e,t){let n=new f.Writer;return n.startSequence(),n.startSequence(),n.writeOID(`1.2.840.113549.1.1.1`),n.writeNull(),n.endSequence(),n.startSequence(f.BitString),n.writeByte(0),n.startSequence(),n.writeBuffer(e,f.Integer),n.writeBuffer(t,f.Integer),n.endSequence(),n.endSequence(),n.endSequence(),k(`PUBLIC`,n.buffer)}function N(e,t){let n=Buffer.allocUnsafe(15+t.length+4+e.length);x(n,7,0),n.utf8Write(`ssh-rsa`,4,7);let r=11;return x(n,t.length,r),n.set(t,r+=4),x(n,e.length,r+=t.length),n.set(e,r+4),n}let P=(()=>{function e(e,t,n,r,i,a,o,s){let c=new f.Writer;return c.startSequence(),c.writeInt(0,f.Integer),c.writeBuffer(e,f.Integer),c.writeBuffer(t,f.Integer),c.writeBuffer(n,f.Integer),c.writeBuffer(r,f.Integer),c.writeBuffer(i,f.Integer),c.writeBuffer(a,f.Integer),c.writeBuffer(o,f.Integer),c.writeBuffer(s,f.Integer),c.endSequence(),c.buffer}function t(e){return BigInt(`0x${e.hexSlice(0,e.length)}`)}function n(e){let t=e.toString(16);if(t.length&1)t=`0${t}`;else{let e=t.charCodeAt(0);(e===56||e===57||e>=97&&e<=102)&&(t=`00${t}`)}return Buffer.from(t,`hex`)}return function(r,i,a,o,s,c){let l=t(a);return k(`RSA PRIVATE`,e(r,i,a,s,c,n(l%(t(s)-1n)),n(l%(t(c)-1n)),o))}})();function F(e,t,n,r){let i=new f.Writer;return i.startSequence(),i.startSequence(),i.writeOID(`1.2.840.10040.4.1`),i.startSequence(),i.writeBuffer(e,f.Integer),i.writeBuffer(t,f.Integer),i.writeBuffer(n,f.Integer),i.endSequence(),i.endSequence(),i.startSequence(f.BitString),i.writeByte(0),i.writeBuffer(r,f.Integer),i.endSequence(),i.endSequence(),k(`PUBLIC`,i.buffer)}function I(e,t,n,r){let i=Buffer.allocUnsafe(15+e.length+4+t.length+4+n.length+4+r.length);x(i,7,0),i.utf8Write(`ssh-dss`,4,7);let a=11;return x(i,e.length,a),i.set(e,a+=4),x(i,t.length,a+=e.length),i.set(t,a+=4),x(i,n.length,a+=t.length),i.set(n,a+=4),x(i,r.length,a+=n.length),i.set(r,a+4),i}function L(e,t,n,r,i){let a=new f.Writer;return a.startSequence(),a.writeInt(0,f.Integer),a.writeBuffer(e,f.Integer),a.writeBuffer(t,f.Integer),a.writeBuffer(n,f.Integer),a.writeBuffer(r,f.Integer),a.writeBuffer(i,f.Integer),a.endSequence(),k(`DSA PRIVATE`,a.buffer)}function R(e){let t=new f.Writer;return t.startSequence(),t.startSequence(),t.writeOID(`1.3.101.112`),t.endSequence(),t.startSequence(f.BitString),t.writeByte(0),t._ensure(e.length),t._buf.set(e,t._offset),t._offset+=e.length,t.endSequence(),t.endSequence(),k(`PUBLIC`,t.buffer)}function z(e){let t=Buffer.allocUnsafe(19+e.length);return x(t,11,0),t.utf8Write(`ssh-ed25519`,4,11),x(t,e.length,15),t.set(e,19),t}function B(e){let t=new f.Writer;return t.startSequence(),t.writeInt(0,f.Integer),t.startSequence(),t.writeOID(`1.3.101.112`),t.endSequence(),t.startSequence(f.OctetString),t.writeBuffer(e,f.OctetString),t.endSequence(),t.endSequence(),k(`PRIVATE`,t.buffer)}function V(e,t){let n=new f.Writer;return n.startSequence(),n.startSequence(),n.writeOID(`1.2.840.10045.2.1`),n.writeOID(e),n.endSequence(),n.startSequence(f.BitString),n.writeByte(0),n._ensure(t.length),n._buf.set(t,n._offset),n._offset+=t.length,n.endSequence(),n.endSequence(),k(`PUBLIC`,n.buffer)}function H(e,t){let n;switch(e){case`1.2.840.10045.3.1.7`:n=`nistp256`;break;case`1.3.132.0.34`:n=`nistp384`;break;case`1.3.132.0.35`:n=`nistp521`;break;default:return}let r=Buffer.allocUnsafe(39+t.length);return x(r,19,0),r.utf8Write(`ecdsa-sha2-${n}`,4,19),x(r,8,23),r.utf8Write(n,27,8),x(r,t.length,35),r.set(t,39),r}function U(e,t,n){let r=new f.Writer;return r.startSequence(),r.writeInt(1,f.Integer),r.writeBuffer(n,f.OctetString),r.startSequence(160),r.writeOID(e),r.endSequence(),r.startSequence(161),r.startSequence(f.BitString),r.writeByte(0),r._ensure(t.length),r._buf.set(t,r._offset),r._offset+=t.length,r.endSequence(),r.endSequence(),r.endSequence(),k(`EC PRIVATE`,r.buffer)}function W(e,t){let n=r(e);return n.setPrivateKey(t),n.getPublicKey()}let G={sign:typeof l==`function`?function(e,t){let n=this[C];if(n===null)return Error(`No private key available`);(!t||typeof t!=`string`)&&(t=this[S]);try{return l(t,e,n)}catch(e){return e}}:function(e,t){let n=this[C];if(n===null)return Error(`No private key available`);(!t||typeof t!=`string`)&&(t=this[S]);let r=o(t);r.update(e);try{return r.sign(n)}catch(e){return e}},verify:typeof u==`function`?function(e,t,n){let r=this[w];if(r===null)return Error(`No public key available`);(!n||typeof n!=`string`)&&(n=this[S]);try{return u(n,e,r,t)}catch(e){return e}}:function(e,t,n){let r=this[w];if(r===null)return Error(`No public key available`);(!n||typeof n!=`string`)&&(n=this[S]);let i=s(n);i.update(e);try{return i.verify(r,t)}catch(e){return e}},isPrivateKey:function(){return this[C]!==null},getPrivatePEM:function(){return this[C]},getPublicPEM:function(){return this[w]},getPublicSSH:function(){return this[T]},equals:function(e){let t=oe(e);return t instanceof Error?!1:this.type===t.type&&this[C]===t[C]&&this[w]===t[w]&&this[T].equals(t[T])}};function ee(e,t,n,r,i,a,o){this.type=e,this.comment=t,this[C]=n,this[w]=r,this[T]=i,this[S]=a,this[E]=o}ee.prototype=G;{let e=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;ee.parse=(t,r)=>{let i=e.exec(t);if(i===null)return null;let a,o=Buffer.from(i[1],`base64`);if(o.length<31)return Error(`Malformed OpenSSH private key`);let s=o.utf8Slice(0,15);if(s!==`openssh-key-v1\0`)return Error(`Unsupported OpenSSH key magic: ${s}`);let c=y(o,15,!0);if(c===void 0)return Error(`Malformed OpenSSH private key`);if(c!==`none`&&g.indexOf(c)===-1)return Error(`Unsupported cipher for OpenSSH key: ${c}`);let l=y(o,o._pos,!0);if(l===void 0)return Error(`Malformed OpenSSH private key`);if(l!==`none`){if(c===`none`)return Error(`Malformed OpenSSH private key`);if(l!==`bcrypt`)return Error(`Unsupported kdf name for OpenSSH key: ${l}`);if(!r)return Error(`Encrypted private OpenSSH key detected, but no passphrase given`)}else if(c!==`none`)return Error(`Malformed OpenSSH private key`);let u,d,f;c!==`none`&&(u=m[c]);let h=y(o,o._pos);if(h===void 0)return Error(`Malformed OpenSSH private key`);if(h.length)switch(l){case`none`:return Error(`Malformed OpenSSH private key`);case`bcrypt`:{let e=y(h,0);if(e===void 0||h._pos+4>h.length)return Error(`Malformed OpenSSH private key`);let t=b(h,h._pos),n=Buffer.allocUnsafe(u.keyLen+u.ivLen);if(p(r,r.length,e,e.length,n,n.length,t)!==0)return Error(`Failed to generate information to decrypt key`);d=_(n,0,u.keyLen),f=_(n,u.keyLen,n.length);break}}else if(l!==`none`)return Error(`Malformed OpenSSH private key`);if(o._pos+3>=o.length)return Error(`Malformed OpenSSH private key`);let v=b(o,o._pos);if(o._pos+=4,v>0){for(let e=0;e<v;++e){let e=y(o,o._pos);if(e===void 0||y(e,0,!0)===void 0)return Error(`Malformed OpenSSH private key`)}let e=y(o,o._pos);if(e===void 0)return Error(`Malformed OpenSSH private key`);if(d!==void 0){if(e.length<u.blockLen||e.length%u.blockLen!==0)return Error(`Malformed OpenSSH private key`);try{let t={authTagLength:u.authLen},r=n(u.sslName,d,f,t);if(r.setAutoPadding(!1),u.authLen>0){if(o.length-o._pos<u.authLen)return Error(`Malformed OpenSSH private key`);r.setAuthTag(_(o,o._pos,o._pos+=u.authLen))}e=A(r.update(e),r.final())}catch(e){return e}}if(o._pos!==o.length)return Error(`Malformed OpenSSH private key`);a=K(e,v,d!==void 0)}else a=[];return a instanceof Error?a:a[0]};function K(e,t,n){let r=[];if(e.length<8)return Error(`Malformed OpenSSH private key`);if(b(e,0)!==b(e,4))return Error(n?`OpenSSH key integrity check failed -- bad passphrase?`:`OpenSSH key integrity check failed`);e._pos=8;let i,a;for(i=0;i<t;++i){let t,i,o,s,c=y(e,e._pos,!0);if(c===void 0)return Error(`Malformed OpenSSH private key`);switch(c){case`ssh-rsa`:{let n=y(e,e._pos);if(n===void 0)return Error(`Malformed OpenSSH private key`);let r=y(e,e._pos);if(r===void 0)return Error(`Malformed OpenSSH private key`);let a=y(e,e._pos);if(a===void 0)return Error(`Malformed OpenSSH private key`);let c=y(e,e._pos);if(c===void 0)return Error(`Malformed OpenSSH private key`);let l=y(e,e._pos);if(l===void 0)return Error(`Malformed OpenSSH private key`);let u=y(e,e._pos);if(u===void 0)return Error(`Malformed OpenSSH private key`);o=M(n,r),s=N(n,r),i=P(n,r,a,c,l,u),t=`sha1`;break}case`ssh-dss`:{let n=y(e,e._pos);if(n===void 0)return Error(`Malformed OpenSSH private key`);let r=y(e,e._pos);if(r===void 0)return Error(`Malformed OpenSSH private key`);let a=y(e,e._pos);if(a===void 0)return Error(`Malformed OpenSSH private key`);let c=y(e,e._pos);if(c===void 0)return Error(`Malformed OpenSSH private key`);let l=y(e,e._pos);if(l===void 0)return Error(`Malformed OpenSSH private key`);o=F(n,r,a,c),s=I(n,r,a,c),i=L(n,r,a,c,l),t=`sha1`;break}case`ssh-ed25519`:{if(!h)return Error(`Unsupported OpenSSH private key type: ${c}`);let n=y(e,e._pos);if(n===void 0||n.length!==32)return Error(`Malformed OpenSSH private key`);let r=y(e,e._pos);if(r===void 0||r.length!==64)return Error(`Malformed OpenSSH private key`);o=R(n),s=z(n),i=B(_(r,0,32)),t=null;break}case`ecdsa-sha2-nistp256`:t=`sha256`,a=`1.2.840.10045.3.1.7`;case`ecdsa-sha2-nistp384`:t===void 0&&(t=`sha384`,a=`1.3.132.0.34`);case`ecdsa-sha2-nistp521`:{if(t===void 0&&(t=`sha512`,a=`1.3.132.0.35`),!j(e,1))return Error(`Malformed OpenSSH private key`);let n=y(e,e._pos);if(n===void 0)return Error(`Malformed OpenSSH private key`);let r=y(e,e._pos);if(r===void 0)return Error(`Malformed OpenSSH private key`);o=V(a,n),s=H(a,n),i=U(a,n,r);break}default:return Error(`Unsupported OpenSSH private key type: ${c}`)}let l=y(e,e._pos,!0);if(l===void 0)return Error(`Malformed OpenSSH private key`);r.push(new ee(c,l,i,o,s,t,n))}let o=0;for(i=e._pos;i<e.length;++i)if(e[i]!==++o%255)return Error(`Malformed OpenSSH private key`);return r}}function q(e,t,n,r,i,a,o){this.type=e,this.comment=t,this[C]=n,this[w]=r,this[T]=i,this[S]=a,this[E]=o}q.prototype=G;{let e=/^-----BEGIN (RSA|DSA|EC) PRIVATE KEY-----(?:\r\n|\n)((?:[^:]+:\s*[\S].*(?:\r\n|\n))*)([\s\S]+)(?:\r\n|\n)-----END (RSA|DSA|EC) PRIVATE KEY-----$/;q.parse=(t,r)=>{let a=e.exec(t);if(a===null)return null;let o=Buffer.from(a[3],`base64`),s=a[2],c=!1;if(s!==void 0){s=s.split(/\r\n|\n/g);for(let e=0;e<s.length;++e){let t=s[e],a=t.indexOf(`:`);if(t.slice(0,a)===`DEK-Info`){let e=t.slice(a+2);if(a=e.indexOf(`,`),a===-1)continue;let s=e.slice(0,a).toLowerCase();if(d.indexOf(s)===-1)return Error(`Cipher (${s}) not supported for encrypted OpenSSH private key`);let l=D[s];if(!l)return Error(`Cipher (${s}) not supported for encrypted OpenSSH private key`);let u=Buffer.from(e.slice(a+1),`hex`);if(u.length!==l.ivLen)return Error(`Malformed encrypted OpenSSH private key`);if(!r)return Error(`Encrypted OpenSSH private key detected, but no passphrase given`);let f=_(u,0,8),p=i(`md5`).update(r).update(f).digest();for(;p.length<l.keyLen;)p=A(p,i(`md5`).update(p).update(r).update(f).digest());p.length>l.keyLen&&(p=_(p,0,l.keyLen));try{let e=n(s,p,u);e.setAutoPadding(!1),o=A(e.update(o),e.final()),c=!0}catch(e){return e}}}}let l,u,p,m,h,g,v=`Malformed OpenSSH private key`;switch(c&&(v+=`. Bad passphrase?`),a[1]){case`RSA`:l=`ssh-rsa`,u=k(`RSA PRIVATE`,o);try{g=new f.Reader(o),g.readSequence(),g.readInt();let e=g.readString(f.Integer,!0);if(e===null)return Error(v);let t=g.readString(f.Integer,!0);if(t===null)return Error(v);p=M(e,t),m=N(e,t)}catch{return Error(v)}h=`sha1`;break;case`DSA`:l=`ssh-dss`,u=k(`DSA PRIVATE`,o);try{g=new f.Reader(o),g.readSequence(),g.readInt();let e=g.readString(f.Integer,!0);if(e===null)return Error(v);let t=g.readString(f.Integer,!0);if(t===null)return Error(v);let n=g.readString(f.Integer,!0);if(n===null)return Error(v);let r=g.readString(f.Integer,!0);if(r===null)return Error(v);p=F(e,t,n,r),m=I(e,t,n,r)}catch{return Error(v)}h=`sha1`;break;case`EC`:{let e,t,n;try{g=new f.Reader(o),g.readSequence(),g.readInt(),t=g.readString(f.OctetString,!0),g.readByte();let r=g.readLength();if(r!==null){if(g._offset=r,n=g.readOID(),n===null)return Error(v);switch(n){case`1.2.840.10045.3.1.7`:e=`prime256v1`,l=`ecdsa-sha2-nistp256`,h=`sha256`;break;case`1.3.132.0.34`:e=`secp384r1`,l=`ecdsa-sha2-nistp384`,h=`sha384`;break;case`1.3.132.0.35`:e=`secp521r1`,l=`ecdsa-sha2-nistp521`,h=`sha512`;break;default:return Error(`Unsupported private key EC OID: ${n}`)}}else return Error(v)}catch{return Error(v)}u=k(`EC PRIVATE`,o);let r=W(e,t);p=V(n,r),m=H(n,r);break}}return new q(l,``,u,p,m,h,c)}}function te(e,t,n,r,i,a,o){this.type=e,this.comment=t,this[C]=n,this[w]=r,this[T]=i,this[S]=a,this[E]=o}te.prototype=G;{let e=Buffer.alloc(0),t=Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),r=Buffer.from([0,0,0,0]),o=Buffer.from([0,0,0,1]),s=/^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\r?\nEncryption: (aes256-cbc|none)\r?\nComment: ([^\r\n]*)\r?\nPublic-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-MAC: ([^\r\n]+)/;te.parse=(c,l)=>{let u=s.exec(c);if(u===null)return null;let d=u[2],f=d!==`none`;if(f&&!l)return Error(`Encrypted PPK private key detected, but no passphrase given`);let p=Buffer.from(u[5],`base64`);if(f){let e=m[d],a=A(i(`sha1`).update(r).update(l).digest(),i(`sha1`).update(o).update(l).digest());a.length>e.keyLen&&(a=_(a,0,e.keyLen));try{let r=n(e.sslName,a,t);r.setAutoPadding(!1),p=A(r.update(p),r.final())}catch(e){return e}}let h=u[1],g=u[3],v=Buffer.from(u[4],`base64`),b=u[6],S=h.length,C=d.length,w=Buffer.byteLength(g),T=v.length,E=p.length,D=Buffer.allocUnsafe(4+S+4+C+4+w+4+T+4+E),O=0;if(x(D,S,O),D.utf8Write(h,O+=4,S),x(D,C,O+=S),D.utf8Write(d,O+=4,C),x(D,w,O+=C),D.utf8Write(g,O+=4,w),x(D,T,O+=w),D.set(v,O+=4),x(D,E,O+=T),D.set(p,O+4),l||=e,a(`sha1`,i(`sha1`).update(`putty-private-key-file-mac-key`).update(l).digest()).update(D).digest(`hex`)!==b)return Error(f?`PPK private key integrity check failed -- bad passphrase?`:`PPK private key integrity check failed`);let k,R,z;switch(v._pos=0,j(v,1),h){case`ssh-rsa`:{let e=y(v,v._pos);if(e===void 0)return Error(`Malformed PPK public key`);let t=y(v,v._pos);if(t===void 0)return Error(`Malformed PPK public key`);let n=y(p,0);if(n===void 0)return Error(`Malformed PPK private key`);let r=y(p,p._pos);if(r===void 0)return Error(`Malformed PPK private key`);let i=y(p,p._pos);if(i===void 0)return Error(`Malformed PPK private key`);let a=y(p,p._pos);if(a===void 0)return Error(`Malformed PPK private key`);k=M(t,e),R=N(t,e),z=P(t,e,n,a,r,i);break}case`ssh-dss`:{let e=y(v,v._pos);if(e===void 0)return Error(`Malformed PPK public key`);let t=y(v,v._pos);if(t===void 0)return Error(`Malformed PPK public key`);let n=y(v,v._pos);if(n===void 0)return Error(`Malformed PPK public key`);let r=y(v,v._pos);if(r===void 0)return Error(`Malformed PPK public key`);let i=y(p,0);if(i===void 0)return Error(`Malformed PPK private key`);k=F(e,t,n,r),R=I(e,t,n,r),z=L(e,t,n,r,i);break}}return new te(h,g,z,k,R,`sha1`,f)}}function ne(e,t,n,r,i){this.type=e,this.comment=t,this[C]=null,this[w]=n,this[T]=r,this[S]=i,this[E]=!1}ne.prototype=G;{let e;e=h?/^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/:/^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/,ne.parse=t=>{let n=e.exec(t);if(n===null)return null;let r=n[1],i=n[2],a=Buffer.from(n[3],`base64`),o=n[4]||``,s=y(a,a._pos,!0);return s===void 0||s.indexOf(i)!==0?Error(`Malformed OpenSSH public key`):ie(a,i,o,r)}}function re(e,t,n,r,i){this.type=e,this.comment=t,this[C]=null,this[w]=n,this[T]=r,this[S]=i,this[E]=!1}re.prototype=G;{let e=/^---- BEGIN SSH2 PUBLIC KEY ----(?:\r?\n)((?:.{0,72}\r?\n)+)---- END SSH2 PUBLIC KEY ----$/,t=/^[A-Z0-9a-z/+=\r\n]+$/,n=/^([\x21-\x39\x3B-\x7E]{1,64}): ((?:[^\\]*\\\r?\n)*[^\r\n]+)\r?\n/gm,r=/\\\r?\n/g;re.parse=i=>{let a=e.exec(i);if(a===null)return null;let o=a[1],s=0,c=``;for(;a=n.exec(o);){let e=a[1],t=a[2].replace(r,``);if(t.length>1024)return n.lastIndex=0,Error(`Malformed RFC4716 public key`);s=n.lastIndex,e.toLowerCase()===`comment`&&(c=t,c.length>1&&c.charCodeAt(0)===34&&c.charCodeAt(c.length-1)===34&&(c=c.slice(1,-1)))}let l=o.slice(s);if(!t.test(l))return Error(`Malformed RFC4716 public key`);l=Buffer.from(l,`base64`);let u=y(l,0,!0);if(u===void 0)return Error(`Malformed RFC4716 public key`);let d=null,f=null;switch(u){case`ssh-rsa`:{let e=y(l,l._pos);if(e===void 0)return Error(`Malformed RFC4716 public key`);let t=y(l,l._pos);if(t===void 0)return Error(`Malformed RFC4716 public key`);d=M(t,e),f=N(t,e);break}case`ssh-dss`:{let e=y(l,l._pos);if(e===void 0)return Error(`Malformed RFC4716 public key`);let t=y(l,l._pos);if(t===void 0)return Error(`Malformed RFC4716 public key`);let n=y(l,l._pos);if(n===void 0)return Error(`Malformed RFC4716 public key`);let r=y(l,l._pos);if(r===void 0)return Error(`Malformed RFC4716 public key`);d=F(e,t,n,r),f=I(e,t,n,r);break}default:return Error(`Malformed RFC4716 public key`)}return new re(u,c,d,f,`sha1`)}}function ie(e,t,n,r){if(!ae(t))return Error(`Unsupported OpenSSH public key type: ${t}`);let i,a,o=null,s=null;switch(t){case`ssh-rsa`:{let t=y(e,e._pos||0);if(t===void 0)return Error(`Malformed OpenSSH public key`);let n=y(e,e._pos);if(n===void 0)return Error(`Malformed OpenSSH public key`);o=M(n,t),s=N(n,t),i=`sha1`;break}case`ssh-dss`:{let t=y(e,e._pos||0);if(t===void 0)return Error(`Malformed OpenSSH public key`);let n=y(e,e._pos);if(n===void 0)return Error(`Malformed OpenSSH public key`);let r=y(e,e._pos);if(r===void 0)return Error(`Malformed OpenSSH public key`);let a=y(e,e._pos);if(a===void 0)return Error(`Malformed OpenSSH public key`);o=F(t,n,r,a),s=I(t,n,r,a),i=`sha1`;break}case`ssh-ed25519`:{let t=y(e,e._pos||0);if(t===void 0||t.length!==32)return Error(`Malformed OpenSSH public key`);o=R(t),s=z(t),i=null;break}case`ecdsa-sha2-nistp256`:i=`sha256`,a=`1.2.840.10045.3.1.7`;case`ecdsa-sha2-nistp384`:i===void 0&&(i=`sha384`,a=`1.3.132.0.34`);case`ecdsa-sha2-nistp521`:{if(i===void 0&&(i=`sha512`,a=`1.3.132.0.35`),!j(e,1))return Error(`Malformed OpenSSH public key`);let t=y(e,e._pos||0);if(t===void 0)return Error(`Malformed OpenSSH public key`);o=V(a,t),s=H(a,t);break}default:return Error(`Unsupported OpenSSH public key type: ${t}`)}return new ne(r,n,o,s,i)}function ae(e){switch(e){case`ssh-rsa`:case`ssh-dss`:case`ecdsa-sha2-nistp256`:case`ecdsa-sha2-nistp384`:case`ecdsa-sha2-nistp521`:return!0;case`ssh-ed25519`:if(h)return!0;default:return!1}}function J(e){return e?typeof e[E]==`boolean`:!1}function oe(e,t){if(J(e))return e;let n;if(Buffer.isBuffer(e))n=e,e=e.utf8Slice(0,e.length).trim();else if(typeof e==`string`)e=e.trim();else return Error(`Key data must be a Buffer or string`);if(t!=null){if(typeof t==`string`)t=Buffer.from(t);else if(!Buffer.isBuffer(t))return Error(`Passphrase must be a string or Buffer when supplied`)}let r;if((r=ee.parse(e,t))!==null||(r=q.parse(e,t))!==null||(r=te.parse(e,t))!==null||(r=ne.parse(e))!==null||(r=re.parse(e))!==null)return r;if(n){O.init(n,0);let t=O.readString(!0);t!==void 0&&(e=O.readRaw(),e!==void 0&&(r=ie(e,t,``,t),r instanceof Error&&(r=null))),O.clear()}return r||Error(`Unsupported key format`)}t.exports={isParsedKey:J,isSupportedKeyType:ae,parseDERKey:(e,t)=>ie(e,t,``,t),parseKey:oe}})),oh=s(((e,t)=>{let{Socket:n}=require("net"),{Duplex:r}=require("stream"),{resolve:i}=require("path"),{readFile:a}=require("fs"),{execFile:o,spawn:s}=require("child_process"),{isParsedKey:c,parseKey:l}=ah(),{makeBufferParser:u,readUInt32BE:d,writeUInt32BE:f,writeUInt32LE:p}=nh();function m(e){let t=!1;return(...n)=>{t||(t=!0,e(...n))}}function h(e,t){let n=Buffer.allocUnsafe(e.length+t.length);return e.copy(n,0),t.copy(n,e.length),n}function g(){}let _=Buffer.alloc(0),v=u();var y=class{getIdentities(e){e(Error(`Missing getIdentities() implementation`))}sign(e,t,n,r){typeof n==`function`&&(r=n),r(Error(`Missing sign() implementation`))}},b=class extends y{constructor(e){super(),this.socketPath=e}getStream(e){e=m(e);let t=new n;t.on(`connect`,()=>{e(null,t)}),t.on(`close`,r).on(`end`,r).on(`error`,r),t.connect(this.socketPath);function r(){try{t.destroy()}catch{}e(Error(`Failed to connect to agent`))}}getIdentities(e){e=m(e),this.getStream((t,n)=>{function r(t){if(n)try{n.destroy()}catch{}t||=Error(`Failed to retrieve identities from agent`),e(t)}if(t)return r(t);let i=new T(!0);i.on(`error`,r),i.pipe(n).pipe(i),n.on(`close`,r).on(`end`,r).on(`error`,r),i.getIdentities((t,i)=>{if(t)return r(t);try{n.destroy()}catch{}e(null,i)})})}sign(e,t,n,r){typeof n==`function`?(r=n,n=void 0):(typeof n!=`object`||!n)&&(n=void 0),r=m(r),this.getStream((i,a)=>{function o(e){if(a)try{a.destroy()}catch{}e||=Error(`Failed to sign data with agent`),r(e)}if(i)return o(i);let s=new T(!0);s.on(`error`,o),s.pipe(a).pipe(s),a.on(`close`,o).on(`end`,o).on(`error`,o),s.sign(e,t,n,(e,t)=>{if(e)return o(e);try{a.destroy()}catch{}r(null,t)})})}};let x=(()=>{let e=i(__dirname,`..`,`util/pagent.exe`),t={10:Error(`Invalid pagent.exe arguments`),11:Error(`Pageant is not running`),12:Error(`pagent.exe could not create an mmap`),13:Error(`pagent.exe could not set mode for stdin`),14:Error(`pagent.exe could not set mode for stdout`),15:Error(`pagent.exe did not get expected input payload`)};function n(e){e.buffer=null,e.proc&&=(e.proc.kill(),void 0)}class a extends r{constructor(){super(),this.proc=void 0,this.buffer=null}_read(e){}_write(n,r,i){if(this.buffer===null)this.buffer=n;else{let e=Buffer.allocUnsafe(this.buffer.length+n.length);this.buffer.copy(e,0),n.copy(e,this.buffer.length),this.buffer=e}if(this.buffer.length<4)return i();let a=d(this.buffer,0);if(this.buffer.length-4<a)return i();if(n=this.buffer.slice(0,4+a),this.buffer.length>4+a)return i(Error(`Unexpected multiple agent requests`));this.buffer=null;let o,c=this.proc=s(e,[n.length]);c.stdout.on(`data`,e=>{this.push(e)}),c.on(`error`,e=>{o=e,i(o)}),c.on(`close`,e=>{if(this.proc=void 0,!o){if(o=t[e])return i(o);i()}}),c.stdin.end(n)}_final(e){n(this),e()}_destroy(e,t){n(this),t()}}return class extends b{getStream(e){e(null,new a)}}})(),S=(()=>{let e=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends b{getStream(t){t=m(t);let r=this.socketPath,i=!1;a(r,function s(c,l){if(c){if(i)return t(Error(`Invalid cygwin unix socket path`));o(`cygpath`,[`-w`,r],(e,n,o)=>{if(e||n.length===0)return t(Error(`Invalid cygwin unix socket path`));i=!0,r=n.toString().replace(/[\r\n]/g,``),a(r,s)});return}let u=e.exec(l.toString(`ascii`));if(!u)return t(Error(`Malformed cygwin unix socket file`));let f,m=0,h=!1,g=[],_,v=Buffer.alloc(12),y=parseInt(u[1],10),b=u[2].replace(/-/g,``),x=Buffer.allocUnsafe(16);for(let e=0,t=0;t<32;++e,t+=2)x[e]=parseInt(b.substring(t,t+2),16);for(let e=0;e<16;e+=4)p(x,d(x,e),e);T();function S(){m=0,f=`secret`,_.write(x)}function C(e){if(m+=e.length,f===`secret`){m===16&&(m=0,f=`creds`,_.write(v));return}if(f===`creds`&&(h||g.push(e),m===12)){if(_.removeListener(`connect`,S),_.removeListener(`data`,C),_.removeListener(`error`,w),_.removeListener(`end`,w),_.removeListener(`close`,w),h)return t(null,_);h=!0,v=Buffer.concat(g),p(v,process.pid,0),_.on(`error`,()=>{}),_.destroy(),T()}}function w(){t(Error(`Problem negotiating cygwin unix socket security`))}function T(){_=new n,_.on(`connect`,S),_.on(`data`,C),_.on(`error`,w),_.on(`end`,w),_.on(`close`,w),_.connect(y)}})}}})(),C=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function w(e){return process.platform===`win32`&&!C.test(e)?e===`pageant`?new x:new S(e):new b(e)}let T=(()=>{function e(e){let t;for(;e[m].length;){let r=e[m][0][n];if(r===void 0)break;e[m].shift(),t=e.push(r)}return t}let t=Symbol(`Inbound Request Type`),n=Symbol(`Inbound Request Response`),i=Symbol(`Inbound Request Context`);class a{constructor(e,r){this[t]=e,this[n]=void 0,this[i]=r}hasResponded(){return this[n]!==void 0}getType(){return this[t]}getContext(){return this[i]}}function o(t,r,i){return r[n]=i,e(t)}function s(e){if(e[b]=null,e[y]===0){let t=e[m];if(t&&t.length){e[m]=[];for(let e of t)e.cb(Error(`No reply from server`))}}try{e.end()}catch{}setImmediate(()=>{e[C]||e.emit(`end`),e[S]||e.emit(`close`)})}function u(){this[S]=!0}function p(){this[C]=!0}let m=Symbol(`Requests`),y=Symbol(`Agent Protocol Role`),b=Symbol(`Agent Protocol Buffer`),x=Symbol(`Agent Protocol Current Message Length`),S=Symbol(`Agent Protocol Closed`),C=Symbol(`Agent Protocol Ended`);return class extends r{constructor(e){super({autoDestroy:!0,emitClose:!1}),this[y]=+!e,this[m]=[],this[b]=null,this[x]=-1,this.once(`end`,p),this.once(`close`,u)}_read(e){}_write(e,t,n){this[b]===null?this[b]=e:this[b]=h(this[b],e);let r=this[b],i=r.length,o=0;for(;o<i&&!(i<5||(this[x]===-1&&(this[x]=d(r,o)),i<4+this[x]));){let e=r[o+=4];if(++o,this[y]===0){if(this[m].length===0)return n(Error(`Received unexpected message from server`));let t=this[m].shift();switch(e){case 5:t.cb(Error(`Agent responded with failure`));break;case 12:{if(t.type!==11)return n(Error(`Agent responded with wrong message type`));v.init(r,o);let e=v.readUInt32BE();if(e===void 0)return v.clear(),n(Error(`Malformed agent response`));let i=[];for(let t=0;t<e;++t){let e=v.readString();if(e===void 0)return v.clear(),n(Error(`Malformed agent response`));let t=v.readString(!0);if(t===void 0)return v.clear(),n(Error(`Malformed agent response`));e=l(e),!(e instanceof Error)&&(e.comment=e.comment||t,i.push(e))}o=v.pos(),v.clear(),t.cb(null,i);break}case 14:{if(t.type!==13)return n(Error(`Agent responded with wrong message type`));v.init(r,o);let e=v.readString();if(o=v.pos(),v.clear(),e===void 0)return n(Error(`Malformed agent response`));if(v.init(e,0),v.readString(!0),e=v.readString(),v.clear(),e===void 0)return n(Error(`Malformed OpenSSH signature format`));t.cb(null,e);break}default:return n(Error(`Agent responded with unsupported message type`))}}else switch(e){case 11:{let t=new a(e);this[m].push(t),this.emit(`identities`,t);break}case 13:{v.init(r,o);let t=v.readString(),n=v.readString(),i=v.readUInt32BE();if(o=v.pos(),v.clear(),i===void 0){let t=new a(e);return this[m].push(t),this.failureReply(t)}if(t=l(t),t instanceof Error){let t=new a(e);return this[m].push(t),this.failureReply(t)}let s={hash:void 0},c;t.type===`ssh-rsa`&&(i&2?(c=`rsa-sha2-256`,s.hash=`sha256`):i&4&&(c=`rsa-sha2-512`,s.hash=`sha512`)),c===void 0&&(c=t.type);let u=new a(e,c);this[m].push(u),this.emit(`sign`,u,t,n,s);break}default:{let t=new a(e);this[m].push(t),this.failureReply(t)}}if(this[x]=-1,o===i){this[b]=null;break}else this[b]=r=r.slice(o),i=r.length,o=0}n()}_destroy(e,t){s(this),t()}_final(e){s(this),e()}sign(e,t,n,r){if(this[y]!==0)throw Error(`Client-only method called with server role`);typeof n==`function`?(r=n,n=void 0):(typeof n!=`object`||!n)&&(n=void 0);let i=0;if(e=l(e),e instanceof Error)throw Error(`Invalid public key argument`);if(e.type===`ssh-rsa`&&n)switch(n.hash){case`sha256`:i=2;break;case`sha512`:i=4;break}e=e.getPublicSSH();let a=e.length,o=t.length,s=0,c=Buffer.allocUnsafe(9+a+4+o+4);return f(c,c.length-4,s),c[s+=4]=13,f(c,a,++s),e.copy(c,s+=4),f(c,o,s+=a),t.copy(c,s+=4),f(c,i,s+=o),typeof r!=`function`&&(r=g),this[m].push({type:13,cb:r}),this.push(c)}getIdentities(e){if(this[y]!==0)throw Error(`Client-only method called with server role`);let t=0,n=Buffer.allocUnsafe(5);return f(n,n.length-4,t),n[t+=4]=11,typeof e!=`function`&&(e=g),this[m].push({type:11,cb:e}),this.push(n)}failureReply(e){if(this[y]!==1)throw Error(`Server-only method called with client role`);if(!(e instanceof a))throw Error(`Wrong request argument`);if(e.hasResponded())return!0;let t=0,n=Buffer.allocUnsafe(5);return f(n,n.length-4,t),n[t+=4]=5,o(this,e,n)}getIdentitiesReply(e,t){if(this[y]!==1)throw Error(`Server-only method called with client role`);if(!(e instanceof a))throw Error(`Wrong request argument`);if(e.hasResponded())return!0;if(e.getType()!==11)throw Error(`Invalid response to request`);if(!Array.isArray(t))throw Error(`Keys argument must be an array`);let n=4,r=[];for(let e=0;e<t.length;++e){let i=t[e];if(typeof i!=`object`||!i)throw Error(`Invalid key entry: ${i}`);let a,o;if(c(i))a=i;else if(c(i.pubKey))a=i.pubKey;else if(typeof i.pubKey!=`object`||i.pubKey===null||({pubKey:a,comment:o}=i.pubKey,a=l(a),a instanceof Error))continue;o=a.comment||o,a=a.getPublicSSH(),n+=4+a.length,o&&typeof o==`string`?o=Buffer.from(o):Buffer.isBuffer(o)||(o=_),n+=4+o.length,r.push({pubKey:a,comment:o})}let i=0,s=Buffer.allocUnsafe(5+n);f(s,s.length-4,i),s[i+=4]=12,f(s,r.length,++i),i+=4;for(let e=0;e<r.length;++e){let{pubKey:t,comment:n}=r[e];f(s,t.length,i),t.copy(s,i+=4),f(s,n.length,i+=t.length),i+=4,n.length&&(n.copy(s,i),i+=n.length)}return o(this,e,s)}signReply(e,t){if(this[y]!==1)throw Error(`Server-only method called with client role`);if(!(e instanceof a))throw Error(`Wrong request argument`);if(e.hasResponded())return!0;if(e.getType()!==13)throw Error(`Invalid response to request`);if(!Buffer.isBuffer(t))throw Error(`Signature argument must be a Buffer`);if(t.length===0)throw Error(`Signature argument must be non-empty`);let n=0,r=e.getContext(),i=Buffer.byteLength(r),s=Buffer.allocUnsafe(13+i+4+t.length);return f(s,s.length-4,n),s[n+=4]=14,f(s,4+i+4+t.length,++n),f(s,i,n+=4),s.utf8Write(r,n+=4,i),f(s,t.length,n+=i),t.copy(s,n+=4),o(this,e,s)}}})(),E=Symbol(`Agent`),D=Symbol(`Agent Keys`),O=Symbol(`Agent Keys Index`),k=Symbol(`Agent Init Callbacks`);var A=class{constructor(e){if(typeof e==`string`)e=w(e);else if(!j(e))throw Error(`Invalid agent argument`);this[E]=e,this[D]=null,this[O]=-1,this[k]=null}init(e){if(typeof e!=`function`&&(e=g),this[D]===null)if(this[k]===null){this[k]=[e];let t=(...e)=>{process.nextTick(()=>{let t=this[k];this[k]=null;for(let n of t)n(...e)})};this[E].getIdentities(m((e,n)=>{if(e)return t(e);if(!Array.isArray(n))return t(Error(`Agent implementation failed to provide keys`));let r=[];for(let e of n)e=l(e),!(e instanceof Error)&&r.push(e);this[D]=r,this[O]=-1,t()}))}else this[k].push(e);else process.nextTick(e)}nextKey(){return this[D]===null||++this[O]>=this[D].length?!1:this[D][this[O]]}currentKey(){return this[D]===null||this[O]>=this[D].length?null:this[D][this[O]]}pos(){return this[D]===null||this[O]>=this[D].length?-1:this[O]}reset(){this[O]=-1}sign(...e){this[E].sign(...e)}};function j(e){return e instanceof y}t.exports={AgentContext:A,AgentProtocol:T,BaseAgent:y,createAgent:w,CygwinAgent:S,isAgent:j,OpenSSHAgent:b,PageantAgent:x}})),sh=s(((e,t)=>{let{kMaxLength:n}=require("buffer"),{createInflate:r,constants:{DEFLATE:i,INFLATE:a,Z_DEFAULT_CHUNK:o,Z_DEFAULT_COMPRESSION:s,Z_DEFAULT_MEMLEVEL:c,Z_DEFAULT_STRATEGY:l,Z_DEFAULT_WINDOWBITS:u,Z_PARTIAL_FLUSH:d}}=require("zlib"),f=r()._handle.constructor;function p(){throw Error(`Should not get here`)}function m(e,t,n){let r=this._owner,i=Error(e);i.errno=t,i.code=n,r._err=i}function h(e){e._handle&&=(e._handle.close(),null)}var g=class{constructor(e){let t=u,r=s,i=c,a=l;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=o,this._maxOutputLength=n,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new f(e),this._handle._owner=this,this._handle.onerror=m,this._handle.init(t,r,i,a,this._writeState,p,void 0)}writeSync(e,t){let n=this._handle;if(!n)throw Error(`Invalid Zlib instance`);let r=e.length,i=this._chunkSize-this._outOffset,a=0,o,s,c,l=0,u=this._writeState,f=this._outBuffer,p=this._outOffset,m=this._chunkSize;for(;;){if(n.writeSync(d,e,a,r,f,p,i),this._err)throw this._err;o=u[0],s=u[1];let t=r-s,g=i-o;if(g>0){let e=p===0&&g===f.length?f:f.slice(p,p+g);if(p+=g,c?c.push===void 0?c=[c,e]:c.push(e):c=e,l+=e.byteLength,l>this._maxOutputLength)throw h(this),Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(g!==0)throw Error(`have should not go down`);if((o===0||p>=m)&&(i=m,p=0,f=Buffer.allocUnsafe(m)),o===0)a+=t,r=s;else break}if(this._outBuffer=f,this._outOffset=p,l===0&&(c=Buffer.alloc(0)),t)return c.totalLen=l,c;if(c.push===void 0)return c;let g=Buffer.allocUnsafe(l);for(let e=0,t=0;e<c.length;++e){let n=c[e];g.set(n,t),t+=n.length}return g}};t.exports={PacketReader:class{cleanup(){}read(e){return e}},PacketWriter:class{constructor(e){this.allocStart=5,this.allocStartKEX=5,this._protocol=e}cleanup(){}alloc(e,t){return this._protocol._kexinit===void 0||t?this._protocol._cipher.allocPacket(e):Buffer.allocUnsafe(e)}finalize(e,t){return e}},ZlibPacketReader:class{constructor(){this._zlib=new g(a)}cleanup(){this._zlib&&h(this._zlib)}read(e){return this._zlib.writeSync(e,!1)}},ZlibPacketWriter:class{constructor(e){this.allocStart=0,this.allocStartKEX=0,this._protocol=e,this._zlib=new g(i)}cleanup(){this._zlib&&h(this._zlib)}alloc(e,t){return Buffer.allocUnsafe(e)}finalize(e,t){if(this._protocol._kexinit===void 0||t){let t=this._zlib.writeSync(e,!0),n=this._protocol._cipher.allocPacket(t.totalLen);if(t.push===void 0)n.set(t,5);else for(let e=0,r=5;e<t.length;++e){let i=t[e];n.set(i,r),r+=i.length}return n}return e}}}})),ch=s(((e,t)=>{let{bufferSlice:n,bufferParser:r,doFatalError:i,sigSSHToASN1:a,writeUInt32BE:o}=nh(),{CHANNEL_OPEN_FAILURE:s,COMPAT:c,MESSAGE:l,TERMINAL_MODE:u}=th(),{parseKey:d}=ah(),f=Array.from(Object.entries(u)).reduce((e,[t,n])=>({...e,[t]:n}),{});t.exports={[l.DISCONNECT]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE(),a=r.readString(!0),o=r.readString();if(r.clear(),o===void 0)return i(e,`Inbound: Malformed DISCONNECT packet`);e._debug&&e._debug(`Inbound: Received DISCONNECT (${n}, "${a}")`);let s=e._handlers.DISCONNECT;s&&s(e,n,a)},[l.IGNORE]:(e,t)=>{e._debug&&e._debug(`Inbound: Received IGNORE`)},[l.UNIMPLEMENTED]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE();if(r.clear(),n===void 0)return i(e,`Inbound: Malformed UNIMPLEMENTED packet`);e._debug&&e._debug(`Inbound: Received UNIMPLEMENTED (seqno ${n})`)},[l.DEBUG]:(e,t)=>{r.init(t,1);let n=r.readBool(),a=r.readString(!0),o=r.readString();if(r.clear(),o===void 0)return i(e,`Inbound: Malformed DEBUG packet`);e._debug&&e._debug(`Inbound: Received DEBUG`);let s=e._handlers.DEBUG;s&&s(e,n,a)},[l.SERVICE_REQUEST]:(e,t)=>{r.init(t,1);let n=r.readString(!0);if(r.clear(),n===void 0)return i(e,`Inbound: Malformed SERVICE_REQUEST packet`);e._debug&&e._debug(`Inbound: Received SERVICE_REQUEST (${n})`);let a=e._handlers.SERVICE_REQUEST;a&&a(e,n)},[l.SERVICE_ACCEPT]:(e,t)=>{r.init(t,1);let n=r.readString(!0);if(r.clear(),n===void 0)return i(e,`Inbound: Malformed SERVICE_ACCEPT packet`);e._debug&&e._debug(`Inbound: Received SERVICE_ACCEPT (${n})`);let a=e._handlers.SERVICE_ACCEPT;a&&a(e,n)},[l.EXT_INFO]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE(),a;if(n!==void 0){a=[];for(let e=0;e<n;++e){let e=r.readString(!0),t=r.readString();if(t!==void 0)switch(e){case`server-sig-algs`:{let n=t.latin1Slice(0,t.length).split(`,`);a.push({name:e,algs:n});continue}default:continue}a=void 0;break}}if(r.clear(),a===void 0)return i(e,`Inbound: Malformed EXT_INFO packet`);e._debug&&e._debug(`Inbound: Received EXT_INFO`);let o=e._handlers.EXT_INFO;o&&o(e,a)},[l.USERAUTH_REQUEST]:(e,t)=>{r.init(t,1);let s=r.readString(!0),c=r.readString(!0),l=r.readString(!0),u,d;switch(l){case`none`:u=null;break;case`password`:{let e=r.readBool();if(e!==void 0&&(u=r.readString(!0),u!==void 0&&e)){let e=r.readString(!0);u=e===void 0?void 0:{oldPassword:u,newPassword:e}}break}case`publickey`:{let i=r.readBool();if(i!==void 0){let s=r.readString(!0),c=s,l=r.readString(),f;switch(s){case`rsa-sha2-256`:c=`ssh-rsa`,f=`sha256`;break;case`rsa-sha2-512`:c=`ssh-rsa`,f=`sha512`;break}if(i){let i=r.pos(),d=r.readString();if(d!==void 0&&(d.length>4+s.length+4&&d.utf8Slice(4,4+s.length)===s&&(d=n(d,4+s.length+4)),d=a(d,c),d)){let n=e._kex.sessionID,r=Buffer.allocUnsafe(4+n.length+i);o(r,n.length,0),r.set(n,4),r.set(new Uint8Array(t.buffer,t.byteOffset,i),4+n.length),u={keyAlgo:c,key:l,signature:d,blob:r,hashAlgo:f}}}else u={keyAlgo:c,key:l,hashAlgo:f},d=`publickey -- check`}break}case`hostbased`:{let i=r.readString(!0),s=i,c=r.readString(),l=r.readString(!0),d=r.readString(!0),f;switch(i){case`rsa-sha2-256`:s=`ssh-rsa`,f=`sha256`;break;case`rsa-sha2-512`:s=`ssh-rsa`,f=`sha512`;break}let p=r.pos(),m=r.readString();if(m!==void 0&&(m.length>4+i.length+4&&m.utf8Slice(4,4+i.length)===i&&(m=n(m,4+i.length+4)),m=a(m,s),m!==void 0)){let n=e._kex.sessionID,r=Buffer.allocUnsafe(4+n.length+p);o(r,n.length,0),r.set(n,4),r.set(new Uint8Array(t.buffer,t.byteOffset,p),4+n.length),u={keyAlgo:s,key:c,signature:m,blob:r,localHostname:l,localUsername:d,hashAlgo:f}}break}case`keyboard-interactive`:r.skipString(),u=r.readList();break;default:l!==void 0&&(u=r.readRaw())}if(r.clear(),u===void 0)return i(e,`Inbound: Malformed USERAUTH_REQUEST packet`);d===void 0&&(d=l),e._authsQueue.push(l),e._debug&&e._debug(`Inbound: Received USERAUTH_REQUEST (${d})`);let f=e._handlers.USERAUTH_REQUEST;f&&f(e,s,c,l,u)},[l.USERAUTH_FAILURE]:(e,t)=>{r.init(t,1);let n=r.readList(),a=r.readBool();if(r.clear(),a===void 0)return i(e,`Inbound: Malformed USERAUTH_FAILURE packet`);e._debug&&e._debug(`Inbound: Received USERAUTH_FAILURE (${n})`),e._authsQueue.shift();let o=e._handlers.USERAUTH_FAILURE;o&&o(e,n,a)},[l.USERAUTH_SUCCESS]:(e,t)=>{e._debug&&e._debug(`Inbound: Received USERAUTH_SUCCESS`),e._authsQueue.shift();let n=e._handlers.USERAUTH_SUCCESS;n&&n(e)},[l.USERAUTH_BANNER]:(e,t)=>{r.init(t,1);let n=r.readString(!0),a=r.readString();if(r.clear(),a===void 0)return i(e,`Inbound: Malformed USERAUTH_BANNER packet`);e._debug&&e._debug(`Inbound: Received USERAUTH_BANNER`);let o=e._handlers.USERAUTH_BANNER;o&&o(e,n)},60:(e,t)=>{if(!e._authsQueue.length){e._debug&&e._debug(`Inbound: Received payload type 60 without auth`);return}switch(e._authsQueue[0]){case`password`:{r.init(t,1);let n=r.readString(!0),a=r.readString();if(r.clear(),a===void 0)return i(e,`Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet`);e._debug&&e._debug(`Inbound: Received USERAUTH_PASSWD_CHANGEREQ`);let o=e._handlers.USERAUTH_PASSWD_CHANGEREQ;o&&o(e,n);break}case`publickey`:{r.init(t,1);let n=r.readString(!0),a=r.readString();if(r.clear(),a===void 0)return i(e,`Inbound: Malformed USERAUTH_PK_OK packet`);e._debug&&e._debug(`Inbound: Received USERAUTH_PK_OK`),e._authsQueue.shift();let o=e._handlers.USERAUTH_PK_OK;o&&o(e,n,a);break}case`keyboard-interactive`:{r.init(t,1);let n=r.readString(!0),a=r.readString(!0);r.readString();let o=r.readUInt32BE(),s;if(o!==void 0){s=Array(o);let e;for(e=0;e<o;++e){let t=r.readString(!0),n=r.readBool();if(n===void 0)break;s[e]={prompt:t,echo:n}}e!==o&&(s=void 0)}if(r.clear(),s===void 0)return i(e,`Inbound: Malformed USERAUTH_INFO_REQUEST packet`);e._debug&&e._debug(`Inbound: Received USERAUTH_INFO_REQUEST`);let c=e._handlers.USERAUTH_INFO_REQUEST;c&&c(e,n,a,s);break}default:e._debug&&e._debug(`Inbound: Received unexpected payload type 60`)}},61:(e,t)=>{if(!e._authsQueue.length){e._debug&&e._debug(`Inbound: Received payload type 61 without auth`);return}if(e._authsQueue[0]!==`keyboard-interactive`)return i(e,`Inbound: Received unexpected payload type 61`);r.init(t,1);let n=r.readUInt32BE(),a;if(n!==void 0){a=Array(n);let e;for(e=0;e<n;++e){let t=r.readString(!0);if(t===void 0)break;a[e]=t}e!==n&&(a=void 0)}if(r.clear(),a===void 0)return i(e,`Inbound: Malformed USERAUTH_INFO_RESPONSE packet`);e._debug&&e._debug(`Inbound: Received USERAUTH_INFO_RESPONSE`);let o=e._handlers.USERAUTH_INFO_RESPONSE;o&&o(e,a)},[l.GLOBAL_REQUEST]:(e,t)=>{r.init(t,1);let n=r.readString(!0),a=r.readBool(),o;if(a!==void 0)switch(n){case`tcpip-forward`:case`cancel-tcpip-forward`:{let e=r.readString(!0),t=r.readUInt32BE();t!==void 0&&(o={bindAddr:e,bindPort:t});break}case`streamlocal-forward@openssh.com`:case`cancel-streamlocal-forward@openssh.com`:{let e=r.readString(!0);e!==void 0&&(o={socketPath:e});break}case`no-more-sessions@openssh.com`:o=null;break;case`hostkeys-00@openssh.com`:for(o=[];r.avail()>0;){let e=r.readString();if(e===void 0){o=void 0;break}let t=d(e);t instanceof Error||o.push(t)}break;default:o=r.readRaw()}if(r.clear(),o===void 0)return i(e,`Inbound: Malformed GLOBAL_REQUEST packet`);e._debug&&e._debug(`Inbound: GLOBAL_REQUEST (${n})`);let s=e._handlers.GLOBAL_REQUEST;s?s(e,n,a,o):e.requestFailure()},[l.REQUEST_SUCCESS]:(e,t)=>{let r=t.length>1?n(t,1):null;e._debug&&e._debug(`Inbound: REQUEST_SUCCESS`);let i=e._handlers.REQUEST_SUCCESS;i&&i(e,r)},[l.REQUEST_FAILURE]:(e,t)=>{e._debug&&e._debug(`Inbound: Received REQUEST_FAILURE`);let n=e._handlers.REQUEST_FAILURE;n&&n(e)},[l.CHANNEL_OPEN]:(e,t)=>{r.init(t,1);let n=r.readString(!0),a=r.readUInt32BE(),o=r.readUInt32BE(),c=r.readUInt32BE(),l;switch(n){case`forwarded-tcpip`:case`direct-tcpip`:{let e=r.readString(!0),t=r.readUInt32BE(),i=r.readString(!0),s=r.readUInt32BE();s!==void 0&&(l={type:n,sender:a,window:o,packetSize:c,data:{destIP:e,destPort:t,srcIP:i,srcPort:s}});break}case`forwarded-streamlocal@openssh.com`:case`direct-streamlocal@openssh.com`:{let e=r.readString(!0);e!==void 0&&(l={type:n,sender:a,window:o,packetSize:c,data:{socketPath:e}});break}case`x11`:{let e=r.readString(!0),t=r.readUInt32BE();t!==void 0&&(l={type:n,sender:a,window:o,packetSize:c,data:{srcIP:e,srcPort:t}});break}default:l={type:n,sender:a,window:o,packetSize:c,data:{}}}if(r.clear(),l===void 0)return i(e,`Inbound: Malformed CHANNEL_OPEN packet`);e._debug&&e._debug(`Inbound: CHANNEL_OPEN (s:${a}, ${n})`);let u=e._handlers.CHANNEL_OPEN;u?u(e,l):e.channelOpenFail(l.sender,s.ADMINISTRATIVELY_PROHIBITED,``,``)},[l.CHANNEL_OPEN_CONFIRMATION]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE(),a=r.readUInt32BE(),o=r.readUInt32BE(),s=r.readUInt32BE(),c=r.avail()?r.readRaw():void 0;if(r.clear(),s===void 0)return i(e,`Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet`);e._debug&&e._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${n}, s:${a})`);let l=e._handlers.CHANNEL_OPEN_CONFIRMATION;l&&l(e,{recipient:n,sender:a,window:o,packetSize:s,data:c})},[l.CHANNEL_OPEN_FAILURE]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE(),a=r.readUInt32BE(),o=r.readString(!0),s=r.readString();if(r.clear(),s===void 0)return i(e,`Inbound: Malformed CHANNEL_OPEN_FAILURE packet`);e._debug&&e._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${n})`);let c=e._handlers.CHANNEL_OPEN_FAILURE;c&&c(e,n,a,o)},[l.CHANNEL_WINDOW_ADJUST]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE(),a=r.readUInt32BE();if(r.clear(),a===void 0)return i(e,`Inbound: Malformed CHANNEL_WINDOW_ADJUST packet`);e._debug&&e._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${n}, ${a})`);let o=e._handlers.CHANNEL_WINDOW_ADJUST;o&&o(e,n,a)},[l.CHANNEL_DATA]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE(),a=r.readString();if(r.clear(),a===void 0)return i(e,`Inbound: Malformed CHANNEL_DATA packet`);e._debug&&e._debug(`Inbound: CHANNEL_DATA (r:${n}, ${a.length})`);let o=e._handlers.CHANNEL_DATA;o&&o(e,n,a)},[l.CHANNEL_EXTENDED_DATA]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE(),a=r.readUInt32BE(),o=r.readString();if(r.clear(),o===void 0)return i(e,`Inbound: Malformed CHANNEL_EXTENDED_DATA packet`);e._debug&&e._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${n}, ${o.length})`);let s=e._handlers.CHANNEL_EXTENDED_DATA;s&&s(e,n,o,a)},[l.CHANNEL_EOF]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE();if(r.clear(),n===void 0)return i(e,`Inbound: Malformed CHANNEL_EOF packet`);e._debug&&e._debug(`Inbound: CHANNEL_EOF (r:${n})`);let a=e._handlers.CHANNEL_EOF;a&&a(e,n)},[l.CHANNEL_CLOSE]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE();if(r.clear(),n===void 0)return i(e,`Inbound: Malformed CHANNEL_CLOSE packet`);e._debug&&e._debug(`Inbound: CHANNEL_CLOSE (r:${n})`);let a=e._handlers.CHANNEL_CLOSE;a&&a(e,n)},[l.CHANNEL_REQUEST]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE(),a=r.readString(!0),o=r.readBool(),s;if(o!==void 0)switch(a){case`exit-status`:s=r.readUInt32BE(),e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a}: ${s})`);break;case`exit-signal`:{let t,i;if(e._compatFlags&c.OLD_EXIT){let e=r.readUInt32BE();switch(e){case 1:t=`HUP`;break;case 2:t=`INT`;break;case 3:t=`QUIT`;break;case 6:t=`ABRT`;break;case 9:t=`KILL`;break;case 14:t=`ALRM`;break;case 15:t=`TERM`;break;default:e!==void 0&&(t=`UNKNOWN (${e})`)}i=!1}else t=r.readString(!0),i=r.readBool(),i===void 0&&(t=void 0);let o=r.readString(!0);r.skipString()!==void 0&&(s={signal:t,coreDumped:i,errorMessage:o}),e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a}: ${t})`);break}case`pty-req`:{let t=r.readString(!0),i=r.readUInt32BE(),o=r.readUInt32BE(),c=r.readUInt32BE(),l=r.readUInt32BE(),d=r.readString();if(d!==void 0){r.init(d,1);let e={};for(;r.avail();){let t=r.readByte();if(t===u.TTY_OP_END)break;let n=f[t],i=r.readUInt32BE();if(t===void 0||n===void 0||i===void 0){e=void 0;break}e[n]=i}e!==void 0&&(s={term:t,cols:i,rows:o,width:c,height:l,modes:e})}e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a})`);break}case`window-change`:{let t=r.readUInt32BE(),i=r.readUInt32BE(),o=r.readUInt32BE(),c=r.readUInt32BE();c!==void 0&&(s={cols:t,rows:i,width:o,height:c}),e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a})`);break}case`x11-req`:{let t=r.readBool(),i=r.readString(!0),o=r.readString(),c=r.readUInt32BE();c!==void 0&&(s={single:t,protocol:i,cookie:o,screen:c}),e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a})`);break}case`env`:{let t=r.readString(!0),i=r.readString(!0);i!==void 0&&(s={name:t,value:i}),e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a}: ${t}=${i})`);break}case`shell`:s=null,e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a})`);break;case`exec`:s=r.readString(!0),e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a}: ${s})`);break;case`subsystem`:s=r.readString(!0),e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a}: ${s})`);break;case`signal`:s=r.readString(!0),e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a}: ${s})`);break;case`xon-xoff`:s=r.readBool(),e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a}: ${s})`);break;case`auth-agent-req@openssh.com`:s=null,e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a})`);break;default:s=r.avail()?r.readRaw():null,e._debug&&e._debug(`Inbound: CHANNEL_REQUEST (r:${n}, ${a})`)}if(r.clear(),s===void 0)return i(e,`Inbound: Malformed CHANNEL_REQUEST packet`);let l=e._handlers.CHANNEL_REQUEST;l&&l(e,n,a,o,s)},[l.CHANNEL_SUCCESS]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE();if(r.clear(),n===void 0)return i(e,`Inbound: Malformed CHANNEL_SUCCESS packet`);e._debug&&e._debug(`Inbound: CHANNEL_SUCCESS (r:${n})`);let a=e._handlers.CHANNEL_SUCCESS;a&&a(e,n)},[l.CHANNEL_FAILURE]:(e,t)=>{r.init(t,1);let n=r.readUInt32BE();if(r.clear(),n===void 0)return i(e,`Inbound: Malformed CHANNEL_FAILURE packet`);e._debug&&e._debug(`Inbound: CHANNEL_FAILURE (r:${n})`);let a=e._handlers.CHANNEL_FAILURE;a&&a(e,n)}}})),lh=s(((e,t)=>{let n=Array(256);[uh().HANDLERS,ch()].forEach(e=>{for(let[t,r]of Object.entries(e))t=+t,isFinite(t)&&t>=0&&t<n.length&&(n[t]=r)}),t.exports=n})),uh=s(((e,t)=>{let{createDiffieHellman:n,createDiffieHellmanGroup:r,createECDH:i,createHash:a,createPublicKey:o,diffieHellman:s,generateKeyPairSync:c,randomFillSync:l}=require("crypto"),{Ber:u}=Qm(),{COMPAT:d,curve25519Supported:f,DEFAULT_KEX:p,DEFAULT_SERVER_HOST_KEY:m,DEFAULT_CIPHER:h,DEFAULT_MAC:g,DEFAULT_COMPRESSION:_,DISCONNECT_REASON:v,MESSAGE:y}=th(),{CIPHER_INFO:b,createCipher:x,createDecipher:S,MAC_INFO:C}=ih(),{parseDERKey:w}=ah(),{bufferFill:T,bufferParser:E,convertSignature:D,doFatalError:O,FastBuffer:k,sigSSHToASN1:A,writeUInt32BE:j}=nh(),{PacketReader:M,PacketWriter:N,ZlibPacketReader:P,ZlibPacketWriter:F}=sh(),I,L=Buffer.alloc(0);function R(e){let t;if(e._compatFlags&d.BAD_DHGEX){let n=e._offer.lists.kex,r=n.array,i=!1;for(let e=0;e<r.length;++e)r[e].includes(`group-exchange`)&&(i||(i=!0,r=r.slice()),r.splice(e--,1));if(i){let i=17+e._offer.totalSize+1+4,a=Buffer.from(r.join(`,`));i-=n.buffer.length-a.length;let o=e._offer.lists.all,s=new Uint8Array(o.buffer,o.byteOffset+4+n.buffer.length,o.length-(4+n.buffer.length));t=Buffer.allocUnsafe(i),j(t,a.length,17),t.set(a,21),t.set(s,21+a.length)}}t===void 0&&(t=Buffer.allocUnsafe(17+e._offer.totalSize+1+4),e._offer.copyAllTo(t,17)),e._debug&&e._debug(`Outbound: Sending KEXINIT`),t[0]=y.KEXINIT,l(t,1,16),T(t,0,t.length-5),e._kexinit=t,e._packetRW.write.allocStart=0;{let n=e._packetRW.write.allocStartKEX,r=e._packetRW.write.alloc(t.length,!0);r.set(t,n),e._cipher.encrypt(e._packetRW.write.finalize(r,!0))}}function z(e,t){let n={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0}};if(E.init(t,17),(n.kex=E.readList())===void 0||(n.serverHostKey=E.readList())===void 0||(n.cs.cipher=E.readList())===void 0||(n.sc.cipher=E.readList())===void 0||(n.cs.mac=E.readList())===void 0||(n.sc.mac=E.readList())===void 0||(n.cs.compress=E.readList())===void 0||(n.sc.compress=E.readList())===void 0||(n.cs.lang=E.readList())===void 0||(n.sc.lang=E.readList())===void 0)return E.clear(),O(e,`Received malformed KEXINIT`,`handshake`,v.KEY_EXCHANGE_FAILED);let r=E.pos(),i=r<t.length&&t[r]===1;E.clear();let a=e._offer,o=n,s=a.lists.kex.array;if(e._compatFlags&d.BAD_DHGEX){let e=!1;for(let t=0;t<s.length;++t)s[t].indexOf(`group-exchange`)!==-1&&(e||(e=!0,s=s.slice()),s.splice(t--,1))}let c,l,u,f=e._debug;f&&f(`Inbound: Handshake in progress`),f&&f(`Handshake: (local) KEX method: ${s}`),f&&f(`Handshake: (remote) KEX method: ${o.kex}`);let p;if(e._server?(l=s,c=o.kex,p=c.indexOf(`ext-info-c`)!==-1):(l=o.kex,c=s,p=l.indexOf(`ext-info-s`)!==-1),e._strictMode===void 0&&(e._server?e._strictMode=c.indexOf(`kex-strict-c-v00@openssh.com`)!==-1:e._strictMode=l.indexOf(`kex-strict-s-v00@openssh.com`)!==-1,e._strictMode&&(f&&f(`Handshake: strict KEX mode enabled`),e._decipher.inSeqno!==1)))return f&&f(`Handshake: KEXINIT not first packet in strict KEX mode`),O(e,`Handshake failed: KEXINIT not first packet in strict KEX mode`,`handshake`,v.KEY_EXCHANGE_FAILED);for(u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f(`Handshake: no matching key exchange algorithm`),O(e,`Handshake failed: no matching key exchange algorithm`,`handshake`,v.KEY_EXCHANGE_FAILED);n.kex=c[u],f&&f(`Handshake: KEX algorithm: ${c[u]}`),i&&(!o.kex.length||c[u]!==o.kex[0])&&(e._skipNextInboundPacket=!0);let m=a.lists.serverHostKey.array;for(f&&f(`Handshake: (local) Host key format: ${m}`),f&&f(`Handshake: (remote) Host key format: ${o.serverHostKey}`),e._server?(l=m,c=o.serverHostKey):(l=o.serverHostKey,c=m),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f(`Handshake: No matching host key format`),O(e,`Handshake failed: no matching host key format`,`handshake`,v.KEY_EXCHANGE_FAILED);n.serverHostKey=c[u],f&&f(`Handshake: Host key format: ${c[u]}`);let h=a.lists.cs.cipher.array;for(f&&f(`Handshake: (local) C->S cipher: ${h}`),f&&f(`Handshake: (remote) C->S cipher: ${o.cs.cipher}`),e._server?(l=h,c=o.cs.cipher):(l=o.cs.cipher,c=h),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f(`Handshake: No matching C->S cipher`),O(e,`Handshake failed: no matching C->S cipher`,`handshake`,v.KEY_EXCHANGE_FAILED);n.cs.cipher=c[u],f&&f(`Handshake: C->S Cipher: ${c[u]}`);let g=a.lists.sc.cipher.array;for(f&&f(`Handshake: (local) S->C cipher: ${g}`),f&&f(`Handshake: (remote) S->C cipher: ${o.sc.cipher}`),e._server?(l=g,c=o.sc.cipher):(l=o.sc.cipher,c=g),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f(`Handshake: No matching S->C cipher`),O(e,`Handshake failed: no matching S->C cipher`,`handshake`,v.KEY_EXCHANGE_FAILED);n.sc.cipher=c[u],f&&f(`Handshake: S->C cipher: ${c[u]}`);let _=a.lists.cs.mac.array;if(f&&f(`Handshake: (local) C->S MAC: ${_}`),f&&f(`Handshake: (remote) C->S MAC: ${o.cs.mac}`),b[n.cs.cipher].authLen>0)n.cs.mac=``,f&&f(`Handshake: C->S MAC: <implicit>`);else{for(e._server?(l=_,c=o.cs.mac):(l=o.cs.mac,c=_),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f(`Handshake: No matching C->S MAC`),O(e,`Handshake failed: no matching C->S MAC`,`handshake`,v.KEY_EXCHANGE_FAILED);n.cs.mac=c[u],f&&f(`Handshake: C->S MAC: ${c[u]}`)}let y=a.lists.sc.mac.array;if(f&&f(`Handshake: (local) S->C MAC: ${y}`),f&&f(`Handshake: (remote) S->C MAC: ${o.sc.mac}`),b[n.sc.cipher].authLen>0)n.sc.mac=``,f&&f(`Handshake: S->C MAC: <implicit>`);else{for(e._server?(l=y,c=o.sc.mac):(l=o.sc.mac,c=y),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f(`Handshake: No matching S->C MAC`),O(e,`Handshake failed: no matching S->C MAC`,`handshake`,v.KEY_EXCHANGE_FAILED);n.sc.mac=c[u],f&&f(`Handshake: S->C MAC: ${c[u]}`)}let x=a.lists.cs.compress.array;for(f&&f(`Handshake: (local) C->S compression: ${x}`),f&&f(`Handshake: (remote) C->S compression: ${o.cs.compress}`),e._server?(l=x,c=o.cs.compress):(l=o.cs.compress,c=x),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f(`Handshake: No matching C->S compression`),O(e,`Handshake failed: no matching C->S compression`,`handshake`,v.KEY_EXCHANGE_FAILED);n.cs.compress=c[u],f&&f(`Handshake: C->S compression: ${c[u]}`);let S=a.lists.sc.compress.array;for(f&&f(`Handshake: (local) S->C compression: ${S}`),f&&f(`Handshake: (remote) S->C compression: ${o.sc.compress}`),e._server?(l=S,c=o.sc.compress):(l=o.sc.compress,c=S),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f(`Handshake: No matching S->C compression`),O(e,`Handshake failed: no matching S->C compression`,`handshake`,v.KEY_EXCHANGE_FAILED);n.sc.compress=c[u],f&&f(`Handshake: S->C compression: ${c[u]}`),n.cs.lang=``,n.sc.lang=``,e._kex&&(e._kexinit||R(e),e._decipher._onPayload=W.bind(e,{firstPacket:!1})),e._kex=B(n,e,t),e._kex.remoteExtInfoEnabled=p,e._kex.start()}let B=(()=>{function e(e){let t=0,n=e.length;for(;e[t]===0;)++t,--n;let r;return e[t]&128?(r=Buffer.allocUnsafe(1+n),r[0]=0,e.copy(r,1,t),e=r):n!==e.length&&(r=Buffer.allocUnsafe(n),e.copy(r,0,t),e=r),e}class t{constructor(e,t,n){this._protocol=t,this.sessionID=t._kex?t._kex.sessionID:void 0,this.negotiated=e,this.remoteExtInfoEnabled=!1,this._step=1,this._public=null,this._dh=null,this._sentNEWKEYS=!1,this._receivedNEWKEYS=!1,this._finished=!1,this._hostVerified=!1,this._kexinit=t._kexinit,this._remoteKexinit=n,this._identRaw=t._identRaw,this._remoteIdentRaw=t._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(e){if(this._finished)return!1;this._finished=!0;let t=this._protocol._server,n=this.negotiated,r=this.convertPublicKey(this._dhData),i=this.computeSecret(this._dhData);if(i instanceof Error)return i.message=`Error while computing DH secret (${this.type}): ${i.message}`,i.level=`handshake`,O(this._protocol,i,v.KEY_EXCHANGE_FAILED);let o=a(this.hashName);H(o,t?this._remoteIdentRaw:this._identRaw),H(o,t?this._identRaw:this._remoteIdentRaw),H(o,t?this._remoteKexinit:this._kexinit),H(o,t?this._kexinit:this._remoteKexinit);let s=t?this._hostKey.getPublicSSH():this._hostKey;if(H(o,s),this.type===`groupex`){let e=this.getDHParams(),t=Buffer.allocUnsafe(4);j(t,this._minBits,0),o.update(t),j(t,this._prefBits,0),o.update(t),j(t,this._maxBits,0),o.update(t),H(o,e.prime),H(o,e.generator)}H(o,t?r:this.getPublicKey());let c=t?this.getPublicKey():r;H(o,c),H(o,i);let l=o.digest();if(t){let e;switch(this.negotiated.serverHostKey){case`rsa-sha2-256`:e=`sha256`;break;case`rsa-sha2-512`:e=`sha512`;break}this._protocol._debug&&this._protocol._debug(`Generating signature ...`);let t=this._hostKey.sign(l,e);if(t instanceof Error)return O(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${t.message}`,`handshake`,v.KEY_EXCHANGE_FAILED);if(t=D(t,this._hostKey.type),t===!1)return O(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,`handshake`,v.KEY_EXCHANGE_FAILED);let n=this.negotiated.serverHostKey,r=Buffer.byteLength(n),i=4+r+4+t.length,a=this._protocol._packetRW.write.allocStartKEX,o=this._protocol._packetRW.write.alloc(5+s.length+4+c.length+4+i,!0);if(o[a]=y.KEXDH_REPLY,j(o,s.length,++a),o.set(s,a+=4),j(o,c.length,a+=s.length),o.set(c,a+=4),j(o,i,a+=c.length),j(o,r,a+=4),o.utf8Write(n,a+=4,r),j(o,t.length,a+=r),o.set(t,a+=4),this._protocol._debug){let e;switch(this.type){case`group`:e=`KEXDH_REPLY`;break;case`groupex`:e=`KEXDH_GEX_REPLY`;break;default:e=`KEXECDH_REPLY`}this._protocol._debug(`Outbound: Sending ${e}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(o,!0))}else{E.init(this._sig,0);let e=E.readString(!0);if(!e)return O(this._protocol,`Malformed packet while reading signature`,`handshake`,v.KEY_EXCHANGE_FAILED);if(e!==n.serverHostKey)return O(this._protocol,`Wrong signature type: ${e}, expected: ${n.serverHostKey}`,`handshake`,v.KEY_EXCHANGE_FAILED);let t=E.readString();if(E.clear(),t===void 0)return O(this._protocol,`Malformed packet while reading signature`,`handshake`,v.KEY_EXCHANGE_FAILED);if(!(t=A(t,e)))return O(this._protocol,`Malformed signature`,`handshake`,v.KEY_EXCHANGE_FAILED);let r;{E.init(this._hostKey,0);let e=E.readString(!0),t=this._hostKey.slice(E.pos());if(E.clear(),r=w(t,e),r instanceof Error)return r.level=`handshake`,O(this._protocol,r,v.KEY_EXCHANGE_FAILED)}let i;switch(this.negotiated.serverHostKey){case`rsa-sha2-256`:i=`sha256`;break;case`rsa-sha2-512`:i=`sha512`;break}this._protocol._debug&&this._protocol._debug(`Verifying signature ...`);let a=r.verify(l,t,i);if(a!==!0)return a instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${a.stack}`):this._protocol._debug&&this._protocol._debug(`Signature verification failed`),O(this._protocol,`Handshake failed: signature verification failed`,`handshake`,v.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug(`Verified signature`)}(t||!e)&&ee(this);let u,d,f=e=>{if(u)return ee(this),u.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=x(u),this._protocol._packetRW.write=d,u=void 0,d=void 0,this._protocol._onHandshakeComplete(n),!1;this.sessionID||=l;{let e=Buffer.allocUnsafe(4+i.length);j(e,i.length,0),e.set(i,4),i=e}let r=b[n.cs.cipher],a=b[n.sc.cipher],o=U(r.ivLen,this.hashName,i,l,this.sessionID,`A`),s=U(a.ivLen,this.hashName,i,l,this.sessionID,`B`),c=U(r.keyLen,this.hashName,i,l,this.sessionID,`C`),p=U(a.keyLen,this.hashName,i,l,this.sessionID,`D`),m,h;r.authLen||(m=C[n.cs.mac],h=U(m.len,this.hashName,i,l,this.sessionID,`E`));let g,_;a.authLen||(g=C[n.sc.mac],_=U(g.len,this.hashName,i,l,this.sessionID,`F`));let v={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:t?r:a,decipherIV:t?o:s,decipherKey:t?c:p,macInfo:t?m:g,macKey:t?h:_},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:t?a:r,cipherIV:t?s:o,cipherKey:t?p:c,macInfo:t?g:m,macKey:t?_:h}};this._protocol._decipher.free(),u=v,this._protocol._decipher=S(v);let y={read:void 0,write:void 0};switch(n.cs.compress){case`zlib`:t?y.read=new P:y.write=new F(this._protocol);break;case`zlib@openssh.com`:if(this._protocol._authenticated){t?y.read=new P:y.write=new F(this._protocol);break}default:t?y.read=new M:y.write=new N(this._protocol)}switch(n.sc.compress){case`zlib`:t?y.write=new F(this._protocol):y.read=new P;break;case`zlib@openssh.com`:if(this._protocol._authenticated){t?y.write=new F(this._protocol):y.read=new P;break}default:t?y.write=new N(this._protocol):y.read=new M}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=y.read,d=y.write,this._public=null,this._dh=null,this._kexinit=this._protocol._kexinit=void 0,this._remoteKexinit=void 0,this._identRaw=void 0,this._remoteIdentRaw=void 0,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0,!e&&f()};if((t||e)&&(this.finish=f),!t)return f(e)}start(){if(!this._protocol._server){if(this._protocol._debug){let e;switch(this.type){case`group`:e=`KEXDH_INIT`;break;default:e=`KEXECDH_INIT`}this._protocol._debug(`Outbound: Sending ${e}`)}let e=this.getPublicKey(),t=this._protocol._packetRW.write.allocStartKEX,n=this._protocol._packetRW.write.alloc(5+e.length,!0);n[t]=y.KEXDH_INIT,j(n,e.length,++t),n.set(e,t+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(n,!0))}}getPublicKey(){this.generateKeys();let e=this._public;if(e)return this.convertPublicKey(e)}convertPublicKey(e){let t,n=0,r=e.length;for(;e[n]===0;)++n,--r;return e[n]&128?(t=Buffer.allocUnsafe(1+r),t[0]=0,e.copy(t,1,n),t):(r!==e.length&&(t=Buffer.allocUnsafe(r),e.copy(t,0,n),e=t),e)}computeSecret(t){this.generateKeys();try{return e(this._dh.computeSecret(t))}catch(e){return e}}parse(e){let t=e[0];switch(this._step){case 1:if(this._protocol._server){if(t!==y.KEXDH_INIT)return O(this._protocol,`Received packet ${t} instead of ${y.KEXDH_INIT}`,`handshake`,v.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug(`Received DH Init`),E.init(e,1);let n=E.readString();if(E.clear(),n===void 0)return O(this._protocol,`Received malformed KEX*_INIT`,`handshake`,v.KEY_EXCHANGE_FAILED);this._dhData=n;let r=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(r)&&(r=r[0]),this._hostKey=r,this.finish()}else{if(t!==y.KEXDH_REPLY)return O(this._protocol,`Received packet ${t} instead of ${y.KEXDH_REPLY}`,`handshake`,v.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug(`Received DH Reply`),E.init(e,1);let n,r,i;if((n=E.readString())===void 0||(r=E.readString())===void 0||(i=E.readString())===void 0)return E.clear(),O(this._protocol,`Received malformed KEX*_REPLY`,`handshake`,v.KEY_EXCHANGE_FAILED);E.clear(),E.init(n,0);let a=E.readString(!0);if(E.clear(),a===void 0)return O(this._protocol,`Received malformed host public key`,`handshake`,v.KEY_EXCHANGE_FAILED);if(a!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case`rsa-sha2-256`:case`rsa-sha2-512`:if(a===`ssh-rsa`)break;default:return O(this._protocol,`Host key does not match negotiated type`,`handshake`,v.KEY_EXCHANGE_FAILED)}this._hostKey=n,this._dhData=r,this._sig=i;let o=!1,s;if(this._protocol._hostVerifier===void 0?(s=!0,this._protocol._debug&&this._protocol._debug(`Host accepted by default (no verification)`)):s=this._protocol._hostVerifier(n,e=>{if(!o){if(o=!0,e===!1)return this._protocol._debug&&this._protocol._debug(`Host denied (verification failed)`),O(this._protocol,`Host denied (verification failed)`,`handshake`,v.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug(`Host accepted (verified)`),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():ee(this)}}),s===void 0){++this._step;return}if(o=!0,s===!1)return this._protocol._debug&&this._protocol._debug(`Host denied (verification failed)`),O(this._protocol,`Host denied (verification failed)`,`handshake`,v.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug(`Host accepted (verified)`),this._hostVerified=!0,ee(this)}++this._step;break;case 2:return t===y.NEWKEYS?(this._protocol._debug&&this._protocol._debug(`Inbound: NEWKEYS`),this._receivedNEWKEYS=!0,this._protocol._strictMode&&(this._protocol._decipher.inSeqno=0),++this._step,this.finish(!this._protocol._server&&!this._hostVerified)):O(this._protocol,`Received packet ${t} instead of ${y.NEWKEYS}`,`handshake`,v.KEY_EXCHANGE_FAILED);default:return O(this._protocol,`Received unexpected packet ${t} after NEWKEYS`,`handshake`,v.KEY_EXCHANGE_FAILED)}}}class l extends t{constructor(e,...t){super(...t),this.type=`25519`,this.hashName=e,this._keys=null}generateKeys(){this._keys||=c(`x25519`)}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:`spki`,format:`der`}).slice(-32)}convertPublicKey(e){let t,n=0,r=e.length;for(;e[n]===0;)++n,--r;return e.length===32||r!==e.length&&(t=Buffer.allocUnsafe(r),e.copy(t,0,n),e=t),e}computeSecret(t){this.generateKeys();try{let n=new u.Writer;return n.startSequence(),n.startSequence(),n.writeOID(`1.3.101.110`),n.endSequence(),n.startSequence(u.BitString),n.writeByte(0),n._ensure(t.length),t.copy(n._buf,n._offset,0,t.length),n._offset+=t.length,n.endSequence(),n.endSequence(),e(s({privateKey:this._keys.privateKey,publicKey:o({key:n.buffer,type:`spki`,format:`der`})}))}catch(e){return e}}}class p extends t{constructor(e,t,...n){super(...n),this.type=`ecdh`,this.curveName=e,this.hashName=t}generateKeys(){this._dh||(this._dh=i(this.curveName),this._public=this._dh.generateKeys())}}class m extends t{constructor(e,...t){super(...t),this.type=`groupex`,this.hashName=e,this._prime=null,this._generator=null,this._minBits=2048,this._prefBits=G(this.negotiated),this._protocol._compatFlags&d.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=8192}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug(`Outbound: Sending KEXDH_GEX_REQUEST`);let e=this._protocol._packetRW.write.allocStartKEX,t=this._protocol._packetRW.write.alloc(13,!0);t[e]=y.KEXDH_GEX_REQUEST,j(t,this._minBits,++e),j(t,this._prefBits,e+=4),j(t,this._maxBits,e+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(t,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=n(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(e,t){if(!Buffer.isBuffer(e))throw Error(`Invalid prime value`);if(!Buffer.isBuffer(t))throw Error(`Invalid generator value`);this._prime=e,this._generator=t}getDHParams(){if(this._dh)return{prime:e(this._dh.getPrime()),generator:e(this._dh.getGenerator())}}parse(e){let n=e[0];switch(this._step){case 1:{if(this._protocol._server)return n===y.KEXDH_GEX_REQUEST?O(this._protocol,`Group exchange not implemented for server`,`handshake`,v.KEY_EXCHANGE_FAILED):O(this._protocol,`Received packet ${n} instead of `+y.KEXDH_GEX_REQUEST,`handshake`,v.KEY_EXCHANGE_FAILED);if(n!==y.KEXDH_GEX_GROUP)return O(this._protocol,`Received packet ${n} instead of ${y.KEXDH_GEX_GROUP}`,`handshake`,v.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug(`Received DH GEX Group`),E.init(e,1);let t,r;if((t=E.readString())===void 0||(r=E.readString())===void 0)return E.clear(),O(this._protocol,`Received malformed KEXDH_GEX_GROUP`,`handshake`,v.KEY_EXCHANGE_FAILED);E.clear(),this.setDHParams(t,r),this.generateKeys();let i=this.getPublicKey();this._protocol._debug&&this._protocol._debug(`Outbound: Sending KEXDH_GEX_INIT`);let a=this._protocol._packetRW.write.allocStartKEX,o=this._protocol._packetRW.write.alloc(5+i.length,!0);o[a]=y.KEXDH_GEX_INIT,j(o,i.length,++a),o.set(i,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(o,!0)),++this._step;break}case 2:if(this._protocol._server)return n===y.KEXDH_GEX_INIT?(this._protocol._debug&&this._protocol._debug(`Received DH GEX Init`),O(this._protocol,`Group exchange not implemented for server`,`handshake`,v.KEY_EXCHANGE_FAILED)):O(this._protocol,`Received packet ${n} instead of ${y.KEXDH_GEX_INIT}`,`handshake`,v.KEY_EXCHANGE_FAILED);if(n!==y.KEXDH_GEX_REPLY)return O(this._protocol,`Received packet ${n} instead of ${y.KEXDH_GEX_REPLY}`,`handshake`,v.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug(`Received DH GEX Reply`),this._step=1,e[0]=y.KEXDH_REPLY,this.parse=t.prototype.parse,this.parse(e)}}}class h extends t{constructor(e,t,...n){super(...n),this.type=`group`,this.groupName=e,this.hashName=t}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug(`Outbound: Sending KEXDH_INIT`);let e=this.getPublicKey(),t=this._protocol._packetRW.write.allocStartKEX,n=this._protocol._packetRW.write.alloc(5+e.length,!0);n[t]=y.KEXDH_INIT,j(n,e.length,++t),n.set(e,t+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(n,!0))}}generateKeys(){this._dh||(this._dh=r(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:e(this._dh.getPrime()),generator:e(this._dh.getGenerator())}}}return(e,...t)=>{if(typeof e!=`object`||!e)throw Error(`Invalid negotiated argument`);let n=e.kex;if(typeof n==`string`){switch(t=[e,...t],n){case`curve25519-sha256`:case`curve25519-sha256@libssh.org`:if(!f)break;return new l(`sha256`,...t);case`ecdh-sha2-nistp256`:return new p(`prime256v1`,`sha256`,...t);case`ecdh-sha2-nistp384`:return new p(`secp384r1`,`sha384`,...t);case`ecdh-sha2-nistp521`:return new p(`secp521r1`,`sha512`,...t);case`diffie-hellman-group1-sha1`:return new h(`modp2`,`sha1`,...t);case`diffie-hellman-group14-sha1`:return new h(`modp14`,`sha1`,...t);case`diffie-hellman-group14-sha256`:return new h(`modp14`,`sha256`,...t);case`diffie-hellman-group15-sha512`:return new h(`modp15`,`sha512`,...t);case`diffie-hellman-group16-sha512`:return new h(`modp16`,`sha512`,...t);case`diffie-hellman-group17-sha512`:return new h(`modp17`,`sha512`,...t);case`diffie-hellman-group18-sha512`:return new h(`modp18`,`sha512`,...t);case`diffie-hellman-group-exchange-sha1`:return new m(`sha1`,...t);case`diffie-hellman-group-exchange-sha256`:return new m(`sha256`,...t)}throw Error(`Unsupported key exchange algorithm: ${n}`)}throw Error(`Invalid key exchange type: ${n}`)}})(),V=(()=>{let e=[`kex`,`serverHostKey`,[`cs`,`cipher`],[`sc`,`cipher`],[`cs`,`mac`],[`sc`,`mac`],[`cs`,`compress`],[`sc`,`compress`],[`cs`,`lang`],[`sc`,`lang`]];return class{constructor(t){if(typeof t!=`object`||!t)throw TypeError(`Argument must be an object`);let n={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},all:void 0},r=0;for(let i of e){let e,a,o,s;if(typeof i==`string`)e=n,a=t[i],o=s=i;else{let r=i[0];e=n[r],s=i[1],a=t[r][s],o=`${r}.${s}`}let c={array:void 0,buffer:void 0};if(Buffer.isBuffer(a))c.array=(``+a).split(`,`),c.buffer=a,r+=4+a.length;else{if(typeof a==`string`&&(a=a.split(`,`)),Array.isArray(a))c.array=a,c.buffer=Buffer.from(a.join(`,`));else throw TypeError(`Invalid \`${o}\` type: ${typeof a}`);r+=4+c.buffer.length}e[s]=c}let i=Buffer.allocUnsafe(r);n.all=i;let a=0;for(let t of e){let e;e=typeof t==`string`?n[t].buffer:n[t[0]][t[1]].buffer,a=j(i,e.length,a),i.set(e,a),a+=e.length}this.totalSize=r,this.lists=n}copyAllTo(e,t){let n=this.lists.all;if(typeof t!=`number`)throw TypeError(`Invalid offset value: ${typeof t}`);if(e.length-t<n.length)throw Error(`Insufficient space to copy list`);return e.set(n,t),n.length}}})(),H=(()=>{let e=Buffer.allocUnsafe(4);return(t,n)=>{j(e,n.length,0),t.update(e),t.update(n)}})();function U(e,t,n,r,i,o){let s;if(e){let c=a(t).update(n).update(r).update(o).update(i).digest();for(;c.length<e;){let e=a(t).update(n).update(r).update(c).digest(),i=Buffer.allocUnsafe(c.length+e.length);i.set(c,0),i.set(e,c.length),c=i}s=c.length===e?c:new k(c.buffer,c.byteOffset,e)}else s=L;return s}function W(e,t){if(t.length===0){this._debug&&this._debug(`Inbound: Skipping empty packet payload`);return}if(this._skipNextInboundPacket){this._skipNextInboundPacket=!1;return}t=this._packetRW.read.read(t);let n=t[0];if(!this._strictMode)switch(n){case y.IGNORE:case y.UNIMPLEMENTED:case y.DEBUG:return I||=lh(),I[n](this,t)}switch(n){case y.DISCONNECT:return I||=lh(),I[n](this,t);case y.KEXINIT:return e.firstPacket?(e.firstPacket=!1,z(this,t)):O(this,`Received extra KEXINIT during handshake`,`handshake`,v.KEY_EXCHANGE_FAILED);default:if(n<20||n>49)return O(this,`Received unexpected packet type ${n}`,`handshake`,v.KEY_EXCHANGE_FAILED)}return this._kex.parse(t)}function G(e){let t=b[e.cs.cipher],n=b[e.sc.cipher],r=Math.max(0,t.sslName===`des-ede3-cbc`?14:t.keyLen,t.blockLen,t.ivLen,n.sslName===`des-ede3-cbc`?14:n.keyLen,n.blockLen,n.ivLen)*8;return r<=112?2048:r<=128?3072:r<=192?7680:8192}function ee(e){if(!e._sentNEWKEYS){e._protocol._debug&&e._protocol._debug(`Outbound: Sending NEWKEYS`);let t=e._protocol._packetRW.write.allocStartKEX,n=e._protocol._packetRW.write.alloc(1,!0);n[t]=y.NEWKEYS,e._protocol._cipher.encrypt(e._protocol._packetRW.write.finalize(n,!0)),e._sentNEWKEYS=!0,e._protocol._strictMode&&(e._protocol._cipher.outSeqno=0)}}t.exports={KexInit:V,kexinit:R,onKEXPayload:W,DEFAULT_KEXINIT_CLIENT:new V({kex:p.concat([`ext-info-c`,`kex-strict-c-v00@openssh.com`]),serverHostKey:m,cs:{cipher:h,mac:g,compress:_,lang:[]},sc:{cipher:h,mac:g,compress:_,lang:[]}}),DEFAULT_KEXINIT_SERVER:new V({kex:p.concat([`kex-strict-s-v00@openssh.com`]),serverHostKey:m,cs:{cipher:h,mac:g,compress:_,lang:[]},sc:{cipher:h,mac:g,compress:_,lang:[]}}),HANDLERS:{[y.KEXINIT]:z}}})),dh=s(((e,t)=>{t.exports={name:`ssh2`,version:`1.16.0`,author:`Brian White <mscdex@mscdex.net>`,description:`SSH2 client and server modules written in pure JavaScript for node.js`,main:`./lib/index.js`,engines:{node:`>=10.16.0`},dependencies:{asn1:`^0.2.6`,"bcrypt-pbkdf":`^1.0.2`},devDependencies:{"@mscdex/eslint-config":`^1.1.0`,eslint:`^7.32.0`},optionalDependencies:{"cpu-features":`~0.0.10`,nan:`^2.20.0`},scripts:{install:`node install.js`,rebuild:`node install.js`,test:`node test/test.js`,lint:`eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js examples lib test`,"lint:fix":`npm run lint -- --fix`},keywords:[`ssh`,`ssh2`,`sftp`,`secure`,`shell`,`exec`,`remote`,`client`],licenses:[{type:`MIT`,url:`http://github.com/mscdex/ssh2/raw/master/LICENSE`}],repository:{type:`git`,url:`http://github.com/mscdex/ssh2.git`}}})),fh=s(((e,t)=>{let{inspect:n}=require("util"),{bindingAvailable:r,NullCipher:i,NullDecipher:a}=ih(),{COMPAT_CHECKS:o,DISCONNECT_REASON:s,eddsaSupported:c,MESSAGE:l,SIGNALS:u,TERMINAL_MODE:d}=th(),{DEFAULT_KEXINIT_CLIENT:f,DEFAULT_KEXINIT_SERVER:p,KexInit:m,kexinit:h,onKEXPayload:g}=uh(),{parseKey:_}=ah(),v=lh(),{bufferCopy:y,bufferFill:b,bufferSlice:x,convertSignature:S,sendPacket:C,writeUInt32BE:w}=nh(),{PacketReader:T,PacketWriter:E,ZlibPacketReader:D,ZlibPacketWriter:O}=sh(),k=dh().version,A=new Map(Object.values(s).map(e=>[e,1])),j=Buffer.from(`SSH-2.0-ssh2js${k}`),M=Buffer.from(`${j}\r\n`),N=Buffer.from([l.GLOBAL_REQUEST,0,0,0,21,107,101,101,112,97,108,105,118,101,64,111,112,101,110,115,115,104,46,99,111,109,1]),P=Buffer.from([d.TTY_OP_END]);function F(){}var I=class{constructor(e){let t=e.onWrite;if(typeof t!=`function`)throw Error(`Missing onWrite function`);this._onWrite=e=>{t(e)};let a=e.onError;if(typeof a!=`function`)throw Error(`Missing onError function`);this._onError=e=>{a(e)};let o=e.debug;this._debug=typeof o==`function`?e=>{o(e)}:void 0;let s=e.onHeader;this._onHeader=typeof s==`function`?(...e)=>{s(...e)}:F;let c=e.onPacket;this._onPacket=typeof c==`function`?()=>{c()}:F;let l=e.onHandshakeComplete;typeof l!=`function`&&(l=F);let u;this._onHandshakeComplete=(...e)=>{this._debug&&this._debug(`Handshake completed`),u=u===void 0;let t=this._queue;if(t){this._queue=void 0,this._debug&&this._debug(`Draining outbound queue (${t.length}) ...`);for(let e=0;e<t.length;++e){let n=t[e],r=this._packetRW.write.finalize(n);if(r===n){let e=this._cipher.allocPacket(n.length);e.set(n,5),r=e}C(this,r)}this._debug&&this._debug(`... finished draining outbound queue`)}u&&this._server&&this._kex.remoteExtInfoEnabled&&U(this),l(...e)},this._queue=void 0;let d=e.messageHandlers;typeof d==`object`&&d?this._handlers=d:this._handlers={},this._onPayload=B.bind(this),this._server=!!e.server,this._banner=void 0;let h;if(this._server){if(typeof e.hostKeys!=`object`||e.hostKeys===null)throw Error(`Missing server host key(s)`);this._hostKeys=e.hostKeys,typeof e.greeting==`string`&&e.greeting.length&&(h=e.greeting.slice(-2)===`\r
|
|
223
223
|
`?e.greeting:`${e.greeting}\r\n`),typeof e.banner==`string`&&e.banner.length&&(this._banner=e.banner.slice(-2)===`\r
|