@inkly-org/cli 0.5.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/README.md +94 -0
- package/dist/capture-listener.js +320 -0
- package/dist/cli.js +5501 -0
- package/dist/template/demo.html +567 -0
- package/dist/template/hub-index.html +406 -0
- package/package.json +53 -0
- package/template/demo.html +567 -0
- package/template/hub-index.html +406 -0
- package/vendor/react-dom-client.mjs +48 -0
- package/vendor/react-dom.mjs +17 -0
- package/vendor/react-jsx-runtime.mjs +16 -0
- package/vendor/react.mjs +16 -0
- package/vendor/vendor-manifest.json +27 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var An=Object.defineProperty;var Pn=(t,e)=>{for(var n in e)An(t,n,{get:e[n],enumerable:!0})};import Ds from"mri";import{spawn as rs}from"child_process";import{createHash as Yo,randomUUID as Xo}from"crypto";import{mkdir as Ye,mkdtemp as ec,open as tc,readFile as Xe,readdir as nc,rm as is,writeFile as Ue}from"fs/promises";import{existsSync as ss}from"fs";import{dirname as fn,isAbsolute as sc,join as N,resolve as as,sep as ac}from"path";import{tmpdir as cc,homedir as os}from"os";import{fileURLToPath as cs}from"url";import{unzipSync as dc,zipSync as pc}from"fflate";import ls from"ws";import hc from"sharp";import yc from"subset-font";var a={};Pn(a,{BRAND:()=>tr,DIRTY:()=>te,EMPTY_PATH:()=>On,INVALID:()=>g,NEVER:()=>jr,OK:()=>P,ParseStatus:()=>A,Schema:()=>b,ZodAny:()=>Q,ZodArray:()=>K,ZodBigInt:()=>re,ZodBoolean:()=>ie,ZodBranded:()=>Oe,ZodCatch:()=>he,ZodDate:()=>se,ZodDefault:()=>fe,ZodDiscriminatedUnion:()=>ze,ZodEffects:()=>$,ZodEnum:()=>pe,ZodError:()=>D,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>Be,ZodIntersection:()=>le,ZodIssueCode:()=>u,ZodLazy:()=>ue,ZodLiteral:()=>de,ZodMap:()=>ke,ZodNaN:()=>Ce,ZodNativeEnum:()=>me,ZodNever:()=>F,ZodNull:()=>oe,ZodNullable:()=>B,ZodNumber:()=>ne,ZodObject:()=>O,ZodOptional:()=>M,ZodParsedType:()=>m,ZodPipeline:()=>Ne,ZodPromise:()=>ee,ZodReadonly:()=>ge,ZodRecord:()=>He,ZodSchema:()=>b,ZodSet:()=>Se,ZodString:()=>X,ZodSymbol:()=>xe,ZodTransformer:()=>$,ZodTuple:()=>H,ZodType:()=>b,ZodUndefined:()=>ae,ZodUnion:()=>ce,ZodUnknown:()=>Z,ZodVoid:()=>_e,addIssueToContext:()=>p,any:()=>ur,array:()=>fr,bigint:()=>sr,boolean:()=>Ot,coerce:()=>$r,custom:()=>Et,date:()=>ar,datetimeRegex:()=>At,defaultErrorMap:()=>W,discriminatedUnion:()=>wr,effect:()=>Er,enum:()=>Tr,function:()=>Sr,getErrorMap:()=>we,getParsedType:()=>z,instanceof:()=>rr,intersection:()=>br,isAborted:()=>je,isAsync:()=>be,isDirty:()=>Fe,isValid:()=>Y,late:()=>nr,lazy:()=>Cr,literal:()=>Ir,makeIssue:()=>De,map:()=>_r,nan:()=>ir,nativeEnum:()=>Ar,never:()=>pr,null:()=>lr,nullable:()=>Dr,number:()=>Dt,object:()=>hr,objectUtil:()=>it,oboolean:()=>Ur,onumber:()=>Mr,optional:()=>Rr,ostring:()=>Lr,pipeline:()=>Nr,preprocess:()=>Or,promise:()=>Pr,quotelessJson:()=>En,record:()=>xr,set:()=>kr,setErrorMap:()=>Dn,strictObject:()=>gr,string:()=>Rt,symbol:()=>or,transformer:()=>Er,tuple:()=>vr,undefined:()=>cr,union:()=>yr,unknown:()=>dr,util:()=>v,void:()=>mr});var v;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{let s={};for(let o of i)s[o]=o;return s},t.getValidEnumValues=i=>{let s=t.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(let c of s)o[c]=i[c];return t.objectValues(o)},t.objectValues=i=>t.objectKeys(i).map(function(s){return i[s]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},t.find=(i,s)=>{for(let o of i)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(v||(v={}));var it;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(it||(it={}));var m=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map<"u"&&t instanceof Map?m.map:typeof Set<"u"&&t instanceof Set?m.set:typeof Date<"u"&&t instanceof Date?m.date:m.object;default:return m.unknown}};var u=v.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),En=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),D=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(s){return s.message},r={_errors:[]},i=s=>{for(let o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let c=r,l=0;for(;l<o.path.length;){let d=o.path[l];l===o.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(n(o))):c[d]=c[d]||{_errors:[]},c=c[d],l++}}};return i(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,v.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];n[s]=n[s]||[],n[s].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};D.create=t=>new D(t);var Rn=(t,e)=>{let n;switch(t.code){case u.invalid_type:t.received===m.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,v.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:n=`Unrecognized key(s) in object: ${v.joinValues(t.keys,", ")}`;break;case u.invalid_union:n="Invalid input";break;case u.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${v.joinValues(t.options)}`;break;case u.invalid_enum_value:n=`Invalid enum value. Expected ${v.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:n="Invalid function arguments";break;case u.invalid_return_type:n="Invalid function return type";break;case u.invalid_date:n="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:v.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case u.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case u.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case u.custom:n="Invalid input";break;case u.invalid_intersection_types:n="Intersection results could not be merged";break;case u.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:n="Number must be finite";break;default:n=e.defaultError,v.assertNever(t)}return{message:n}},W=Rn;var kt=W;function Dn(t){kt=t}function we(){return kt}var De=t=>{let{data:e,path:n,errorMaps:r,issueData:i}=t,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="",l=r.filter(d=>!!d).slice().reverse();for(let d of l)c=d(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},On=[];function p(t,e){let n=we(),r=De({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===W?void 0:W].filter(i=>!!i)});t.common.issues.push(r)}var A=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let i of n){if(i.status==="aborted")return g;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n){let s=await i.key,o=await i.value;r.push({key:s,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return g;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}},g=Object.freeze({status:"aborted"}),te=t=>({status:"dirty",value:t}),P=t=>({status:"valid",value:t}),je=t=>t.status==="aborted",Fe=t=>t.status==="dirty",Y=t=>t.status==="valid",be=t=>typeof Promise<"u"&&t instanceof Promise;var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));var U=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},St=(t,e)=>{if(Y(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new D(t.common.issues);return this._error=n,this._error}}};function w(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??r??c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:l??n??c.defaultError}},description:i}}var b=class{get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new A,ctx:{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(be(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},i=this._parseSync({data:e,path:r.path,parent:r});return St(r,i)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Y(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Y(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(be(i)?i:Promise.resolve(i));return St(r,s)}refine(e,n){let r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{let o=e(i),c=()=>s.addIssue({code:u.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new $({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return M.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return K.create(this)}promise(){return ee.create(this,this._def)}or(e){return ce.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new $({...w(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new fe({...w(this._def),innerType:this,defaultValue:n,typeName:y.ZodDefault})}brand(){return new Oe({typeName:y.ZodBranded,type:this,...w(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new he({...w(this._def),innerType:this,catchValue:n,typeName:y.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ne.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Nn=/^c[^\s-]{8,}$/i,Ln=/^[0-9a-z]+$/,Mn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Un=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,$n=/^[a-z0-9_-]{21}$/i,jn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Fn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,zn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",st,Bn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Wn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Vn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Zn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Kn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Gn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,It="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Jn=new RegExp(`^${It}$`);function Tt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function qn(t){return new RegExp(`^${Tt(t)}$`)}function At(t){let e=`${It}T${Tt(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Yn(t,e){return!!((e==="v4"||!e)&&Bn.test(t)||(e==="v6"||!e)&&Vn.test(t))}function Xn(t,e){if(!jn.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function Qn(t,e){return!!((e==="v4"||!e)&&Wn.test(t)||(e==="v6"||!e)&&Zn.test(t))}var X=class t extends b{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){let s=this._getOrReturnCtx(e);return p(s,{code:u.invalid_type,expected:m.string,received:s.parsedType}),g}let r=new A,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),p(i,{code:u.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),p(i,{code:u.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?p(i,{code:u.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&p(i,{code:u.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")zn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"email",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")st||(st=new RegExp(Hn,"u")),st.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"emoji",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Un.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"uuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")$n.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"nanoid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")Nn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"cuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Ln.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"cuid2",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Mn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"ulid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),p(i,{validation:"url",code:u.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"regex",code:u.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?At(s).test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Jn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?qn(s).test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Fn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"duration",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Yn(e.data,s.version)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"ip",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?Xn(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"jwt",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?Qn(e.data,s.version)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"cidr",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Kn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"base64",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?Gn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"base64url",code:u.invalid_string,message:s.message}),r.dirty()):v.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:u.invalid_string,...h.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...h.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...h.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...h.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...h.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...h.errToObj(n)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};X.create=t=>new X({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,...w(t)});function er(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(t.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return s%o/10**i}var ne=class t extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){let s=this._getOrReturnCtx(e);return p(s,{code:u.invalid_type,expected:m.number,received:s.parsedType}),g}let r,i=new A;for(let s of this._def.checks)s.kind==="int"?v.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:u.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?er(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:u.not_finite,message:s.message}),i.dirty()):v.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,h.toString(n))}gt(e,n){return this.setLimit("min",e,!1,h.toString(n))}lte(e,n){return this.setLimit("max",e,!0,h.toString(n))}lt(e,n){return this.setLimit("max",e,!1,h.toString(n))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:h.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&v.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};ne.create=t=>new ne({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,...w(t)});var re=class t extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==m.bigint)return this._getInvalidInput(e);let r,i=new A;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):v.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:m.bigint,received:n.parsedType}),g}gte(e,n){return this.setLimit("min",e,!0,h.toString(n))}gt(e,n){return this.setLimit("min",e,!1,h.toString(n))}lte(e,n){return this.setLimit("max",e,!0,h.toString(n))}lt(e,n){return this.setLimit("max",e,!1,h.toString(n))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:h.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};re.create=t=>new re({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,...w(t)});var ie=class extends b{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.boolean,received:r.parsedType}),g}return P(e.data)}};ie.create=t=>new ie({typeName:y.ZodBoolean,coerce:t?.coerce||!1,...w(t)});var se=class t extends b{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){let s=this._getOrReturnCtx(e);return p(s,{code:u.invalid_type,expected:m.date,received:s.parsedType}),g}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return p(s,{code:u.invalid_date}),g}let r=new A,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),p(i,{code:u.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),p(i,{code:u.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):v.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};se.create=t=>new se({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,...w(t)});var xe=class extends b{_parse(e){if(this._getType(e)!==m.symbol){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.symbol,received:r.parsedType}),g}return P(e.data)}};xe.create=t=>new xe({typeName:y.ZodSymbol,...w(t)});var ae=class extends b{_parse(e){if(this._getType(e)!==m.undefined){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.undefined,received:r.parsedType}),g}return P(e.data)}};ae.create=t=>new ae({typeName:y.ZodUndefined,...w(t)});var oe=class extends b{_parse(e){if(this._getType(e)!==m.null){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.null,received:r.parsedType}),g}return P(e.data)}};oe.create=t=>new oe({typeName:y.ZodNull,...w(t)});var Q=class extends b{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}};Q.create=t=>new Q({typeName:y.ZodAny,...w(t)});var Z=class extends b{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}};Z.create=t=>new Z({typeName:y.ZodUnknown,...w(t)});var F=class extends b{_parse(e){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:m.never,received:n.parsedType}),g}};F.create=t=>new F({typeName:y.ZodNever,...w(t)});var _e=class extends b{_parse(e){if(this._getType(e)!==m.undefined){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.void,received:r.parsedType}),g}return P(e.data)}};_e.create=t=>new _e({typeName:y.ZodVoid,...w(t)});var K=class t extends b{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==m.array)return p(n,{code:u.invalid_type,expected:m.array,received:n.parsedType}),g;if(i.exactLength!==null){let o=n.data.length>i.exactLength.value,c=n.data.length<i.exactLength.value;(o||c)&&(p(n,{code:o?u.too_big:u.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(p(n,{code:u.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(p(n,{code:u.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,c)=>i.type._parseAsync(new U(n,o,n.path,c)))).then(o=>A.mergeArray(r,o));let s=[...n.data].map((o,c)=>i.type._parseSync(new U(n,o,n.path,c)));return A.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:h.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:h.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:h.toString(n)}})}nonempty(e){return this.min(1,e)}};K.create=(t,e)=>new K({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...w(e)});function ve(t){if(t instanceof O){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=M.create(ve(r))}return new O({...t._def,shape:()=>e})}else return t instanceof K?new K({...t._def,type:ve(t.element)}):t instanceof M?M.create(ve(t.unwrap())):t instanceof B?B.create(ve(t.unwrap())):t instanceof H?H.create(t.items.map(e=>ve(e))):t}var O=class t extends b{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=v.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==m.object){let d=this._getOrReturnCtx(e);return p(d,{code:u.invalid_type,expected:m.object,received:d.parsedType}),g}let{status:r,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(let d in i.data)o.includes(d)||c.push(d);let l=[];for(let d of o){let f=s[d],x=i.data[d];l.push({key:{status:"valid",value:d},value:f._parse(new U(i,x,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof F){let d=this._def.unknownKeys;if(d==="passthrough")for(let f of c)l.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(d==="strict")c.length>0&&(p(i,{code:u.unrecognized_keys,keys:c}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let f of c){let x=i.data[f];l.push({key:{status:"valid",value:f},value:d._parse(new U(i,x,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let d=[];for(let f of l){let x=await f.key,I=await f.value;d.push({key:x,value:I,alwaysSet:f.alwaysSet})}return d}).then(d=>A.mergeObjectSync(r,d)):A.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let i=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:h.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of v.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of v.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return ve(this)}partial(e){let n={};for(let r of v.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of v.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof M;)s=s._def.innerType;n[r]=s}return new t({...this._def,shape:()=>n})}keyof(){return Pt(v.objectKeys(this.shape))}};O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,...w(e)});O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:y.ZodObject,...w(e)});O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,...w(e)});var ce=class extends b{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function i(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return n.common.issues.push(...c.ctx.common.issues),c.result;let o=s.map(c=>new D(c.ctx.common.issues));return p(n,{code:u.invalid_union,unionErrors:o}),g}if(n.common.async)return Promise.all(r.map(async s=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s,o=[];for(let l of r){let d={...n,common:{...n.common,issues:[]},parent:null},f=l._parseSync({data:n.data,path:n.path,parent:d});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let c=o.map(l=>new D(l));return p(n,{code:u.invalid_union,unionErrors:c}),g}}get options(){return this._def.options}};ce.create=(t,e)=>new ce({options:t,typeName:y.ZodUnion,...w(e)});var V=t=>t instanceof ue?V(t.schema):t instanceof $?V(t.innerType()):t instanceof de?[t.value]:t instanceof pe?t.options:t instanceof me?v.objectValues(t.enum):t instanceof fe?V(t._def.innerType):t instanceof ae?[void 0]:t instanceof oe?[null]:t instanceof M?[void 0,...V(t.unwrap())]:t instanceof B?[null,...V(t.unwrap())]:t instanceof Oe||t instanceof ge?V(t.unwrap()):t instanceof he?V(t._def.innerType):[],ze=class t extends b{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==m.object)return p(n,{code:u.invalid_type,expected:m.object,received:n.parsedType}),g;let r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(p(n,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let i=new Map;for(let s of n){let o=V(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:i,...w(r)})}};function at(t,e){let n=z(t),r=z(e);if(t===e)return{valid:!0,data:t};if(n===m.object&&r===m.object){let i=v.objectKeys(e),s=v.objectKeys(t).filter(c=>i.indexOf(c)!==-1),o={...t,...e};for(let c of s){let l=at(t[c],e[c]);if(!l.valid)return{valid:!1};o[c]=l.data}return{valid:!0,data:o}}else if(n===m.array&&r===m.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<t.length;s++){let o=t[s],c=e[s],l=at(o,c);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===m.date&&r===m.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var le=class extends b{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=(s,o)=>{if(je(s)||je(o))return g;let c=at(s.value,o.value);return c.valid?((Fe(s)||Fe(o))&&n.dirty(),{status:n.value,value:c.data}):(p(r,{code:u.invalid_intersection_types}),g)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};le.create=(t,e,n)=>new le({left:t,right:e,typeName:y.ZodIntersection,...w(n)});var H=class t extends b{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.array)return p(r,{code:u.invalid_type,expected:m.array,received:r.parsedType}),g;if(r.data.length<this._def.items.length)return p(r,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&r.data.length>this._def.items.length&&(p(r,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((o,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new U(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>A.mergeArray(n,o)):A.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};H.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new H({items:t,typeName:y.ZodTuple,rest:null,...w(e)})};var He=class t extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.object)return p(r,{code:u.invalid_type,expected:m.object,received:r.parsedType}),g;let i=[],s=this._def.keyType,o=this._def.valueType;for(let c in r.data)i.push({key:s._parse(new U(r,c,r.path,c)),value:o._parse(new U(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?A.mergeObjectAsync(n,i):A.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof b?new t({keyType:e,valueType:n,typeName:y.ZodRecord,...w(r)}):new t({keyType:X.create(),valueType:e,typeName:y.ZodRecord,...w(n)})}},ke=class extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.map)return p(r,{code:u.invalid_type,expected:m.map,received:r.parsedType}),g;let i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([c,l],d)=>({key:i._parse(new U(r,c,r.path,[d,"key"])),value:s._parse(new U(r,l,r.path,[d,"value"]))}));if(r.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of o){let d=await l.key,f=await l.value;if(d.status==="aborted"||f.status==="aborted")return g;(d.status==="dirty"||f.status==="dirty")&&n.dirty(),c.set(d.value,f.value)}return{status:n.value,value:c}})}else{let c=new Map;for(let l of o){let d=l.key,f=l.value;if(d.status==="aborted"||f.status==="aborted")return g;(d.status==="dirty"||f.status==="dirty")&&n.dirty(),c.set(d.value,f.value)}return{status:n.value,value:c}}}};ke.create=(t,e,n)=>new ke({valueType:e,keyType:t,typeName:y.ZodMap,...w(n)});var Se=class t extends b{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.set)return p(r,{code:u.invalid_type,expected:m.set,received:r.parsedType}),g;let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(p(r,{code:u.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(p(r,{code:u.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function o(l){let d=new Set;for(let f of l){if(f.status==="aborted")return g;f.status==="dirty"&&n.dirty(),d.add(f.value)}return{status:n.value,value:d}}let c=[...r.data.values()].map((l,d)=>s._parse(new U(r,l,r.path,d)));return r.common.async?Promise.all(c).then(l=>o(l)):o(c)}min(e,n){return new t({...this._def,minSize:{value:e,message:h.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:h.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Se.create=(t,e)=>new Se({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,...w(e)});var Be=class t extends b{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==m.function)return p(n,{code:u.invalid_type,expected:m.function,received:n.parsedType}),g;function r(c,l){return De({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,we(),W].filter(d=>!!d),issueData:{code:u.invalid_arguments,argumentsError:l}})}function i(c,l){return De({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,we(),W].filter(d=>!!d),issueData:{code:u.invalid_return_type,returnTypeError:l}})}let s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof ee){let c=this;return P(async function(...l){let d=new D([]),f=await c._def.args.parseAsync(l,s).catch(T=>{throw d.addIssue(r(l,T)),d}),x=await Reflect.apply(o,this,f);return await c._def.returns._def.type.parseAsync(x,s).catch(T=>{throw d.addIssue(i(x,T)),d})})}else{let c=this;return P(function(...l){let d=c._def.args.safeParse(l,s);if(!d.success)throw new D([r(l,d.error)]);let f=Reflect.apply(o,this,d.data),x=c._def.returns.safeParse(f,s);if(!x.success)throw new D([i(f,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:H.create(e).rest(Z.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||H.create([]).rest(Z.create()),returns:n||Z.create(),typeName:y.ZodFunction,...w(r)})}},ue=class extends b{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};ue.create=(t,e)=>new ue({getter:t,typeName:y.ZodLazy,...w(e)});var de=class extends b{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return p(n,{received:n.data,code:u.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};de.create=(t,e)=>new de({value:t,typeName:y.ZodLiteral,...w(e)});function Pt(t,e){return new pe({values:t,typeName:y.ZodEnum,...w(e)})}var pe=class t extends b{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return p(n,{expected:v.joinValues(r),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return p(n,{received:n.data,code:u.invalid_enum_value,options:r}),g}return P(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};pe.create=Pt;var me=class extends b{_parse(e){let n=v.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==m.string&&r.parsedType!==m.number){let i=v.objectValues(n);return p(r,{expected:v.joinValues(i),received:r.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(v.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=v.objectValues(n);return p(r,{received:r.data,code:u.invalid_enum_value,options:i}),g}return P(e.data)}get enum(){return this._def.values}};me.create=(t,e)=>new me({values:t,typeName:y.ZodNativeEnum,...w(e)});var ee=class extends b{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==m.promise&&n.common.async===!1)return p(n,{code:u.invalid_type,expected:m.promise,received:n.parsedType}),g;let r=n.parsedType===m.promise?n.data:Promise.resolve(n.data);return P(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}};ee.create=(t,e)=>new ee({type:t,typeName:y.ZodPromise,...w(e)});var $=class extends b{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{p(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async c=>{if(n.value==="aborted")return g;let l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?g:l.status==="dirty"?te(l.value):n.value==="dirty"?te(l.value):l});{if(n.value==="aborted")return g;let c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?g:c.status==="dirty"?te(c.value):n.value==="dirty"?te(c.value):c}}if(i.type==="refinement"){let o=c=>{let l=i.refinement(c,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){let c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?g:(c.status==="dirty"&&n.dirty(),o(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?g:(c.status==="dirty"&&n.dirty(),o(c.value).then(()=>({status:n.value,value:c.value}))))}if(i.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Y(o))return g;let c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Y(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:n.value,value:c})):g);v.assertNever(i)}};$.create=(t,e,n)=>new $({schema:t,typeName:y.ZodEffects,effect:e,...w(n)});$.createWithPreprocess=(t,e,n)=>new $({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,...w(n)});var M=class extends b{_parse(e){return this._getType(e)===m.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};M.create=(t,e)=>new M({innerType:t,typeName:y.ZodOptional,...w(e)});var B=class extends b{_parse(e){return this._getType(e)===m.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(t,e)=>new B({innerType:t,typeName:y.ZodNullable,...w(e)});var fe=class extends b{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===m.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};fe.create=(t,e)=>new fe({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...w(e)});var he=class extends b{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return be(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};he.create=(t,e)=>new he({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...w(e)});var Ce=class extends b{_parse(e){if(this._getType(e)!==m.nan){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.nan,received:r.parsedType}),g}return{status:"valid",value:e.data}}};Ce.create=t=>new Ce({typeName:y.ZodNaN,...w(t)});var tr=Symbol("zod_brand"),Oe=class extends b{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Ne=class t extends b{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?g:s.status==="dirty"?(n.dirty(),te(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?g:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:y.ZodPipeline})}},ge=class extends b{_parse(e){let n=this._def.innerType._parse(e),r=i=>(Y(i)&&(i.value=Object.freeze(i.value)),i);return be(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:y.ZodReadonly,...w(e)});function Ct(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Et(t,e={},n){return t?Q.create().superRefine((r,i)=>{let s=t(r);if(s instanceof Promise)return s.then(o=>{if(!o){let c=Ct(e,r),l=c.fatal??n??!0;i.addIssue({code:"custom",...c,fatal:l})}});if(!s){let o=Ct(e,r),c=o.fatal??n??!0;i.addIssue({code:"custom",...o,fatal:c})}}):Q.create()}var nr={object:O.lazycreate},y;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(y||(y={}));var rr=(t,e={message:`Input not instance of ${t.name}`})=>Et(n=>n instanceof t,e),Rt=X.create,Dt=ne.create,ir=Ce.create,sr=re.create,Ot=ie.create,ar=se.create,or=xe.create,cr=ae.create,lr=oe.create,ur=Q.create,dr=Z.create,pr=F.create,mr=_e.create,fr=K.create,hr=O.create,gr=O.strictCreate,yr=ce.create,wr=ze.create,br=le.create,vr=H.create,xr=He.create,_r=ke.create,kr=Se.create,Sr=Be.create,Cr=ue.create,Ir=de.create,Tr=pe.create,Ar=me.create,Pr=ee.create,Er=$.create,Rr=M.create,Dr=B.create,Or=$.createWithPreprocess,Nr=Ne.create,Lr=()=>Rt().optional(),Mr=()=>Dt().optional(),Ur=()=>Ot().optional(),$r={string:(t=>X.create({...t,coerce:!0})),number:(t=>ne.create({...t,coerce:!0})),boolean:(t=>ie.create({...t,coerce:!0})),bigint:(t=>re.create({...t,coerce:!0})),date:(t=>se.create({...t,coerce:!0}))};var jr=g;var ot=a.object({id:a.string()}),Fr=a.enum(["top","right","bottom","left","auto"]).default("auto"),ct=a.enum(["left","middle","right"]),zr=ct.default("left"),Nt=a.object({label:a.string().optional(),hidden:a.boolean().default(!1)}),Hr={background:a.string().optional(),textColor:a.string().optional(),borderRadius:a.string().optional(),textAlign:zr,anchor:Fr,showNavigation:a.boolean().default(!0),prevButton:Nt.optional(),nextButton:Nt.optional()},Br=a.enum(["pointer","callout","area"]),Wr=a.discriminatedUnion("type",[a.object({type:a.literal("html-element"),alphaId:a.string().min(1)})]),Vr=ot.extend({type:a.literal("message"),variant:Br.default("callout"),x:a.number().min(0).max(1),y:a.number().min(0).max(1),w:a.number().min(0).max(1).optional(),h:a.number().min(0).max(1).optional(),text:a.string().optional(),target:Wr.optional(),advancesStep:a.boolean().default(!0),...Hr}),Zr=ot.extend({type:a.literal("blur"),x:a.number().min(0).max(1),y:a.number().min(0).max(1),w:a.number().min(0).max(1),h:a.number().min(0).max(1),intensity:a.number().min(0).max(20).default(8)}),Kr=ot.extend({type:a.literal("text"),x:a.number().min(0).max(1),y:a.number().min(0).max(1),text:a.string(),fontSize:a.number().positive().default(16),color:a.string().optional()}),Lt=a.discriminatedUnion("type",[Vr,Zr,Kr]),Mt=new Set(["message","blur","text"]),Ut=a.object({type:a.string()}).passthrough();function $t(t){return typeof t=="object"&&t!==null?t.type:void 0}var jt=a.any().superRefine((t,e)=>{let i=(Mt.has($t(t))?Lt:Ut).safeParse(t);if(!i.success)for(let s of i.error.issues)e.addIssue(s)}).transform(t=>(Mt.has($t(t))?Lt:Ut).parse(t));var lt=a.object({label:a.string().min(1),href:a.string().refine(t=>/^(https?:|mailto:)/i.test(t),"href must be an http(s) or mailto URL")}),ut=a.object({logo:a.string().min(1).optional(),name:a.string().min(1).optional(),logoHref:a.string().refine(t=>/^(https?:|mailto:)/i.test(t),"logoHref must be an http(s) or mailto URL").optional(),favicon:a.string().min(1).optional(),cta:lt.optional(),secondaryCta:lt.optional()}),Ft=ut.omit({favicon:!0});var Gr=a.object({type:a.literal("next")}),Jr=a.object({type:a.literal("prev")}),qr=a.object({type:a.literal("step"),stepId:a.string().min(1)}),Yr=a.object({type:a.literal("chapter"),chapterId:a.string().min(1)}),Xr=a.object({type:a.literal("url"),href:a.string().min(1),target:a.enum(["_self","_blank"]).default("_blank")}),Qr=a.object({type:a.literal("restart")}),ei=a.discriminatedUnion("type",[Gr,Jr,qr,Yr,Xr,Qr]),ti=a.enum(["shimmer"]),We=a.object({label:a.string().min(1),action:ei.default({type:"next"}),animation:ti.optional(),background:a.string().optional(),textColor:a.string().optional()});var zt=/^[A-Za-z0-9_-]{12}$/;var Bt=a.object({id:a.string(),text:a.string(),start:a.number().nonnegative().optional(),end:a.number().nonnegative().optional()});var ni=a.enum(["screenshot","image","video","audio","font","other"]),ri=a.object({id:a.string().min(1),path:a.string().min(1).optional(),uri:a.string().min(1).optional(),sha256:a.string().regex(/^[0-9a-f]{64}$/),kind:ni,contentType:a.string().min(1).optional(),publicUrl:a.string().min(1).optional(),cdnPath:a.string().min(1).optional(),size:a.number().int().nonnegative().optional(),createdAt:a.string().min(1).optional(),updatedAt:a.string().min(1).optional(),viewport:a.object({w:a.number().int().positive(),h:a.number().int().positive()}).optional()}),ii=a.object({version:a.literal(1),assets:a.array(ri),screens:a.array(a.unknown()).optional()});var dt=a.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,{message:"must be a hex color like #5b3df5"}),si=a.enum(["color","image","glassmorphism"]),Wt=a.object({type:si,color:dt.optional(),from:dt.optional(),to:dt.optional(),src:a.string().min(1).optional(),alt:a.string().optional(),intensity:a.number().min(-5).max(48).optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,r=!!t.from&&!!t.to;!n&&!r&&e.addIssue({code:a.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:a.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:a.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),Vt=a.object({src:a.string(),alt:a.string().optional()});var pt=a.object({src:a.string().min(1),duration:a.number().positive().optional()});var ai=a.enum(["text","dropdown"]),oi=a.object({value:a.string().min(1),label:a.string().min(1)}),ci=a.object({id:a.string(),label:a.string(),type:ai.default("text"),placeholder:a.string().optional(),required:a.boolean().default(!1),options:a.array(oi).optional()}).superRefine((t,e)=>{t.type==="dropdown"&&(!t.options||t.options.length===0)&&e.addIssue({code:a.ZodIssueCode.custom,message:"Dropdown field requires at least one option.",path:["options"]})}),qt=a.object({src:a.string().min(1),alt:a.string().optional(),height:a.number().int().positive().optional()}),li=a.enum(["left","right","top"]),ui=a.enum(["standard","hero"]),Yt=a.object({src:a.string().min(1),alt:a.string().optional(),naturalWidth:a.number().positive().optional(),naturalHeight:a.number().positive().optional(),position:li.default("right"),layout:ui.default("hero")}),di=a.object({type:a.literal("headline"),id:a.string(),logo:qt.optional(),image:Yt.optional(),title:a.string(),titleColor:a.string().optional(),description:a.string().optional(),descriptionColor:a.string().optional(),textAlign:ct.optional(),cta:We.optional(),secondaryCta:We.optional()}),pi=a.object({type:a.literal("form"),id:a.string(),logo:qt.optional(),image:Yt.optional(),title:a.string().optional(),description:a.string().optional(),fields:a.array(ci).min(1),submit:We.default({label:"Submit",action:{type:"next"}})}),mi="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",fi="camera; microphone; fullscreen; payment; clipboard-write",hi=a.object({type:a.literal("embed"),id:a.string(),src:a.string(),iframeTitle:a.string().optional(),sandbox:a.string().default(mi),allow:a.string().default(fi)}),gi=a.object({type:a.literal("custom"),id:a.string(),name:a.string().min(1),data:a.record(a.unknown()).optional()}),Zt=a.discriminatedUnion("type",[di,pi,hi,gi]),Kt=new Set(["headline","form","embed","custom"]),Gt=a.object({type:a.string()}).passthrough();function Jt(t){return typeof t=="object"&&t!==null?t.type:void 0}var Xt=a.any().superRefine((t,e)=>{let i=(Kt.has(Jt(t))?Zt:Gt).safeParse(t);if(!i.success)for(let s of i.error.issues)e.addIssue(s)}).transform(t=>(Kt.has(Jt(t))?Zt:Gt).parse(t));var Qt=a.enum(["contain","cover","fill"]),en=a.enum(["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"]),yi=a.object({type:a.literal("image"),src:a.string().min(1),naturalWidth:a.number().positive(),naturalHeight:a.number().positive(),alt:a.string().optional(),sourceUrl:a.string().optional(),title:a.string().optional(),objectFit:Qt.optional(),objectPosition:en.optional()}),wi=a.object({type:a.literal("video"),src:a.string().min(1),posterSrc:a.string().min(1).optional(),naturalWidth:a.number().positive(),naturalHeight:a.number().positive(),alt:a.string().optional(),sourceUrl:a.string().optional(),title:a.string().optional(),autoplay:a.boolean().default(!0),muted:a.boolean().default(!0),objectFit:Qt.optional(),objectPosition:en.optional()}),bi=a.object({x:a.number().nonnegative().default(0),y:a.number().nonnegative().default(0),maxX:a.number().nonnegative().default(0),maxY:a.number().nonnegative().default(0)}),vi=a.object({type:a.literal("html"),path:a.string().min(1),naturalWidth:a.number().positive(),naturalHeight:a.number().positive(),zoom:a.number().positive().default(1),scroll:bi.default({x:0,y:0,maxX:0,maxY:0}),sourceUrl:a.string().optional(),title:a.string().optional()}),xi=a.discriminatedUnion("type",[yi,wi,vi]),_i=a.object({zoom:a.number().min(1).default(1),x:a.number().min(0).max(1).default(.5),y:a.number().min(0).max(1).default(.5)}),ki=a.object({trigger:a.enum(["auto","click"]).default("auto")}).default({trigger:"auto"}),Si=a.object({kind:a.literal("content").default("content"),id:a.string(),label:a.string().optional(),duration:a.number().positive().optional(),background:xi,script:a.string().optional(),voiceover:pt.optional(),transform:_i.optional(),advance:ki,annotations:a.array(jt).default([]),captions:a.array(Bt).optional()}).passthrough(),Ci=a.object({kind:a.literal("cover"),id:a.string(),label:a.string().optional(),widgets:a.array(Xt).length(1),background:Wt.optional(),backgroundImage:Vt.optional(),backgroundDim:a.number().min(0).max(1).optional(),script:a.string().optional(),voiceover:pt.optional(),duration:a.number().positive().optional(),advance:a.object({trigger:a.enum(["auto","click"]).default("click")}).default({trigger:"click"})}).passthrough(),tn=a.discriminatedUnion("kind",[Si,Ci]);var Ii=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,nn=a.string().regex(Ii,"must be a hex color like #5b3df5"),Ve=a.object({primary:nn.optional(),secondary:nn.optional(),font:a.string().min(1).optional(),radius:a.string().min(1).optional()}).partial();var Ze=a.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,{message:"must be a hex color like #5b3df5"}),Ti=a.object({id:a.string(),title:a.string(),stepIds:a.array(a.string()).min(1)}),Ai=a.object({hideHeader:a.boolean().default(!1),hideControls:a.boolean().default(!1),controls:a.enum(["full","minimal","hidden"]).optional(),showHubBreadcrumb:a.boolean().default(!1),mobileFooterMessage:a.boolean().default(!0),autoplay:a.boolean().default(!1)}),Pi=a.object({width:a.number().positive(),height:a.number().positive()}),Ei=a.enum(["public","private"]),Ri=a.enum(["none","color","image"]),Di=a.object({type:Ri,color:Ze.optional(),from:Ze.optional(),to:Ze.optional(),src:a.string().min(1).optional(),alt:a.string().optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,r=!!t.from&&!!t.to;!n&&!r&&e.addIssue({code:a.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:a.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:a.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),Ba=a.object({id:a.string().regex(zt,{message:"must be a 12-character URL-safe demo id (see generateDemoId)"}),version:a.number().int().min(1),title:a.string().optional(),subtitle:a.string().optional(),runtime:a.string().min(1).optional(),visibility:Ei.default("public"),backgroundColor:Ze.optional(),background:Di.optional(),theme:a.object({preset:a.string().min(1).optional(),tokens:Ve.optional(),brand:Ft.optional()}).optional(),chrome:Ai.default({}),aspectRatio:Pi.optional(),chapters:a.array(Ti).default([]),steps:a.array(tn).min(1)}).passthrough().superRefine((t,e)=>{let n=new Set(t.steps.map(i=>i.id)),r=new Set(t.chapters.map(i=>i.id));t.chapters.forEach((i,s)=>{i.stepIds.forEach(o=>{n.has(o)||e.addIssue({code:a.ZodIssueCode.custom,path:["chapters",s,"stepIds"],message:`Chapter "${i.id}" references unknown step "${o}"`})})}),t.steps.forEach((i,s)=>{i.kind==="cover"&&i.widgets.forEach((o,c)=>{o.type==="headline"&&["cta","secondaryCta"].forEach(l=>{let d=o[l]?.action;d&&(d.type==="step"&&!n.has(d.stepId)&&e.addIssue({code:a.ZodIssueCode.custom,path:["steps",s,"widgets",c,l,"action","stepId"],message:`Widget "${o.id}" CTA targets unknown step "${d.stepId}"`}),d.type==="chapter"&&!r.has(d.chapterId)&&e.addIssue({code:a.ZodIssueCode.custom,path:["steps",s,"widgets",c,l,"action","chapterId"],message:`Widget "${o.id}" CTA targets unknown chapter "${d.chapterId}"`}))})})})});var Oi=a.enum(["sidebar","tabs"]),Ni=a.object({name:a.string().min(1),description:a.string().min(1).optional(),icon:a.string().min(1).optional(),demos:a.array(a.string().min(1))}),Ga=a.object({$schema:a.string().optional(),name:a.string().min(1),runtime:a.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,"runtime must be an exact semver version"),runtimeRange:a.string().min(1).optional(),layout:Oi.optional(),theme:a.string().min(1).optional(),tokens:Ve.optional(),brand:ut.optional(),title:a.string().min(1).optional(),subtitle:a.string().min(1).optional(),collections:a.array(Ni).optional()});var Le=a.string().regex(/^sha(?:256|384|512)-[A-Za-z0-9+/]+=*$/,{message:"must be an SRI string like sha384-<base64>"}),Ke=a.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,{message:"must be an exact semver like 0.1.0"}),Li=a.object({version:Ke,url:a.string().url(),integrity:Le}),eo=a.object({$schema:a.string().optional(),runtime:Li});var rn=a.string().regex(/^[0-9a-f]{64}$/,{message:"must be lowercase sha-256 hex (64 chars)"}),io=a.object({version:Ke,externals:a.array(a.string().min(1)),jsHash:rn,cssHash:rn,jsBytes:a.number().int().nonnegative(),cssBytes:a.number().int().nonnegative(),integrity:Le,cssIntegrity:Le,minSchema:Ke,codemodsIntegrity:Le.optional(),codemodsBytes:a.number().int().nonnegative().optional()});var Me={demoSlug:a.string().min(1),timestamp:a.number().int().nonnegative()},co=a.discriminatedUnion("type",[a.object({type:a.literal("inkly:ready"),...Me,runtimeVersion:a.string().min(1),schemaVersion:a.string().min(1),stepIds:a.array(a.string().min(1))}),a.object({type:a.literal("inkly:step"),...Me,stepId:a.string().min(1),stepIndex:a.number().int().nonnegative()}),a.object({type:a.literal("inkly:heartbeat"),...Me,stepId:a.string().min(1)}),a.object({type:a.literal("inkly:action"),...Me,stepId:a.string().min(1),widgetId:a.string().min(1),kind:a.string().min(1),payload:a.unknown().optional()}),a.object({type:a.literal("inkly:complete"),...Me})]);import{randomUUID as Mi}from"crypto";import{mkdir as Ui,readFile as $i,writeFile as ji}from"fs/promises";import{dirname as Fi,join as zi}from"path";import{homedir as Hi}from"os";import{PostHog as Bi}from"posthog-node";var an=process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN??process.env.POSTHOG_PROJECT_TOKEN??"phc_Dmh4w8YFNosi3YHD4Sv7ShHX7ccS8kmtRcm8XSVmB5jT",Wi=process.env.NEXT_PUBLIC_POSTHOG_HOST??process.env.POSTHOG_HOST??"https://us.i.posthog.com",Vi="@inkly-org/cli@0.5.1",mt=zi(Hi(),".inkly","analytics.json"),sn=null,Ge=null,on=null;function Zi(){return!!an&&process.env.INKLY_TELEMETRY_DISABLED!=="1"}function Ki(){return Zi()?(sn??=new Bi(an,{host:Wi,flushAt:1,flushInterval:0}),sn):null}async function Gi(){try{let t=await $i(mt,"utf8");return JSON.parse(t)}catch{return{}}}async function Ji(t){await Ui(Fi(mt),{recursive:!0}),await ji(mt,JSON.stringify(t,null,2)+`
|
|
3
|
+
`,{encoding:"utf8",mode:384})}async function qi(){return Ge||(Ge=(async()=>{let t=await Gi();if(typeof t.platformUserId=="string"&&t.platformUserId&&(on=t.platformUserId),typeof t.distinctId=="string"&&t.distinctId)return t.distinctId;let e=`cli_${Mi()}`;return await Ji({...t,distinctId:e}),e})(),Ge)}async function Yi(){let t=await qi();return on??t}function Xi(){return{surface:"cli",release:process.env.POSTHOG_RELEASE??Vi,node_version:process.versions.node,platform:process.platform,arch:process.arch,ci:!!process.env.CI}}async function cn(t,e={}){let n=Ki();if(n)try{n.capture({distinctId:await Yi(),event:t,properties:{...Xi(),...e}})}catch{}}import{mkdir as Qi,rename as es,writeFile as ts}from"fs/promises";import{dirname as ns}from"path";async function ln(t,e,n){await Qi(ns(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await ts(r,e,n?.mode!=null?{mode:n.mode}:void 0),await es(r,t)}var hn=`Options:
|
|
4
|
+
--url <url> URL to open and arm for recording.
|
|
5
|
+
--name <name> Demo name written into the exported ZIP.
|
|
6
|
+
--session <id> Session id printed by start.
|
|
7
|
+
--out <dir> Directory for stop output. Writes the ZIP and unpacks the demo.
|
|
8
|
+
--browser <path> Chrome/Chromium binary. Defaults to local Chrome candidates.
|
|
9
|
+
--connect-to-browser <url>
|
|
10
|
+
Attach to an already-running Chrome DevTools endpoint.
|
|
11
|
+
--width <n> Browser viewport width. Defaults to 1440.
|
|
12
|
+
--height <n> Browser viewport height. Defaults to 900.
|
|
13
|
+
--window-size <w>x<h> Shortcut for --width <w> --height <h>.
|
|
14
|
+
--timeout <ms> CDP/page wait timeout. Defaults to 120000.
|
|
15
|
+
--headless Use headless Chrome. This is the default (faster, no visible window). Real Chrome passes most bot protection (Cloudflare) even headless.
|
|
16
|
+
--headed Use a visible Chrome window. Use for an interactive login you need to watch, or to retry a site that challenged headless.
|
|
17
|
+
--keep-profile Leave the temporary Chrome profile after stop/cancel.
|
|
18
|
+
--profile <name> Reuse a PERSISTENT Chrome profile across captures (a bare name maps to
|
|
19
|
+
~/.inkly/capture-agent/profiles/<name>, or pass a directory path). A login
|
|
20
|
+
done once in this profile survives, so later captures of the same site need
|
|
21
|
+
no re-login. Implies --keep-profile. Run --headed the first time so the user
|
|
22
|
+
can sign in; reuse can run headless.
|
|
23
|
+
--no-unpack On stop, write only the ZIP.`,us=`inkly capture - capture an image/video walkthrough for an external browser agent
|
|
24
|
+
|
|
25
|
+
Usage:
|
|
26
|
+
inkly capture start --url <url> --name <name>
|
|
27
|
+
inkly capture stop --session <id> --out <dir>
|
|
28
|
+
inkly capture cancel --session <id>
|
|
29
|
+
inkly capture profiles
|
|
30
|
+
|
|
31
|
+
${hn}
|
|
32
|
+
--video, --record-video Record motion segments. Enabled by default; use --no-video to disable.
|
|
33
|
+
--zoom Apply click zoom/pan to screenshot steps. Enabled by default; use --no-zoom to disable.
|
|
34
|
+
|
|
35
|
+
Output:
|
|
36
|
+
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
37
|
+
For self-contained HTML snapshot capture, use \`inkly capture-html\`.
|
|
38
|
+
`,xc=`inkly capture-html - capture a self-contained HTML walkthrough for an external browser agent
|
|
39
|
+
|
|
40
|
+
Usage:
|
|
41
|
+
inkly capture-html start --url <url> --name <name>
|
|
42
|
+
inkly capture-html stop --session <id> --out <dir>
|
|
43
|
+
inkly capture-html cancel --session <id>
|
|
44
|
+
inkly capture-html profiles
|
|
45
|
+
|
|
46
|
+
${hn}
|
|
47
|
+
--block-videos Replace <video> with its poster frame instead of inlining the video.
|
|
48
|
+
--compress-images Re-encode captured PNG/JPEG images to WebP (smaller, near-lossless).
|
|
49
|
+
--subset-fonts Subset fonts to the glyphs used and convert to WOFF2.
|
|
50
|
+
|
|
51
|
+
Output:
|
|
52
|
+
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
53
|
+
`,ds=fn(cs(import.meta.url));var gn=1440,yn=900;var wn=4e3,Je=30,un=480,ps=7e3,ms=20,fs=1200,hs=1500;function Ie(t){return new Promise(e=>setTimeout(e,t))}function gs(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))return;let n=t[e];return typeof n=="string"?n:""}function ys(t){return{click_tag:t?.tag??null,has_click_label:!!t?.label,has_click_selector:!!t?.selector,has_click_alpha_id:!!t?.alphaId}}async function qe(t){await cn("inkly_cli_capture_step_captured",{runtime:t.session.runtime??"cli",capture_kind:t.session.cliCaptureKind??t.stepKind,step_kind:t.stepKind,action:t.action,step_count:t.session.cliScreens?.length??null,window_width:t.session.width,window_height:t.session.height,record_video:t.session.cliRecordVideo===!0,auto_apply_zoom:t.session.autoApplyZoom!==!1,...ys(t.click)})}function dn(t){let e=t.cliScreens??[],n=e[e.length-1]?.kind;return n==="video"||n==="html"?n:"image"}function ws(t,e,n){let r=gs(t,e);if(!r)throw new Error(`missing --${e} <value>
|
|
54
|
+
|
|
55
|
+
${n}`);return r}function pn(t,e){let n=as(t);for(;;){let r=N(n,e);if(ss(r))return r;let i=fn(n);if(i===n)return null;n=i}}var Te=class{constructor(e){this.nextId=1;this.pending=new Map;this.listeners=new Map;this.ws=new ls(e,{perMessageDeflate:!1,maxPayload:512*1024*1024}),this.ready=new Promise((n,r)=>{this.ws.once("open",()=>n()),this.ws.once("error",i=>r(i))}),this.ws.on("message",n=>{let r=JSON.parse(n.toString());if(typeof r.id=="number"&&this.pending.has(r.id)){let s=this.pending.get(r.id);if(this.pending.delete(r.id),!s)return;r.error?s.reject(new Error(`${r.error.message??"CDP error"}: ${JSON.stringify(r.error.data??"")}`)):s.resolve(r.result??{});return}if(!r.method)return;let i=this.listeners.get(r.method);if(i)for(let s of i)s(r.params,r.sessionId)})}async send(e,n={},r){await this.ready;let i=this.nextId;this.nextId+=1;let s={id:i,method:e,params:n};return r&&(s.sessionId=r),new Promise((o,c)=>{this.pending.set(i,{resolve:o,reject:c}),this.ws.send(JSON.stringify(s),l=>{l&&(this.pending.delete(i),c(l))})})}on(e,n){let r=this.listeners.get(e)??new Set;return r.add(n),this.listeners.set(e,r),()=>r.delete(n)}close(){try{this.ws.close()}catch{}}};async function G(t,e,n,r=3e4){let i=await t.send("Runtime.evaluate",{expression:n,awaitPromise:!0,returnByValue:!0,timeout:r,userGesture:!0},e);if(i.exceptionDetails)throw new Error(`Runtime.evaluate failed: ${JSON.stringify(i.exceptionDetails)}`);return i.result?.value}async function Qe(t,e){let r=(await t.send("Target.attachToTarget",{targetId:e,flatten:!0})).sessionId;if(typeof r!="string")throw new Error("Target.attachToTarget returned no sessionId");return r}async function mn(t){return((await t.send("Target.getTargets",{filter:[{type:"page"}]})).targetInfos??[]).filter(r=>r.type==="page")}async function bs(t,e){let n=await G(t,e,`JSON.stringify({
|
|
56
|
+
innerWidth: window.innerWidth,
|
|
57
|
+
innerHeight: window.innerHeight,
|
|
58
|
+
outerWidth: window.outerWidth,
|
|
59
|
+
outerHeight: window.outerHeight
|
|
60
|
+
})`,5e3),r=JSON.parse(String(n)),i={innerWidth:Number(r.innerWidth),innerHeight:Number(r.innerHeight),outerWidth:Number(r.outerWidth),outerHeight:Number(r.outerHeight)};if(!Number.isFinite(i.innerWidth)||!Number.isFinite(i.innerHeight)||!Number.isFinite(i.outerWidth)||!Number.isFinite(i.outerHeight))throw new Error(`could not measure Chrome viewport: ${JSON.stringify(r)}`);return i}async function et(t,e,n,r,i){try{let o=(await t.send("Browser.getWindowForTarget",{targetId:n})).windowId;if(typeof o!="number")throw new Error("Browser.getWindowForTarget returned no windowId");for(let c=0;c<4;c+=1){let l=await bs(t,e),d=Math.max(0,l.outerWidth-l.innerWidth),f=Math.max(0,l.outerHeight-l.innerHeight),x=r+d,I=i+f;if(Math.abs(l.innerWidth-r)<=1&&Math.abs(l.innerHeight-i)<=1)return;await t.send("Browser.setWindowBounds",{windowId:o,bounds:{windowState:"normal",width:x,height:I}}),await Ie(250)}}catch{}await t.send("Emulation.setDeviceMetricsOverride",{width:r,height:i,deviceScaleFactor:1,mobile:!1},e).catch(()=>{}),await Ie(100)}function yt(t){if(t.length<24)return null;let e=[137,80,78,71,13,10,26,10];for(let o=0;o<e.length;o+=1)if(t[o]!==e[o])return null;if(String.fromCharCode(t[12],t[13],t[14],t[15])!=="IHDR")return null;let r=new DataView(t.buffer,t.byteOffset,t.byteLength),i=r.getUint32(16,!1),s=r.getUint32(20,!1);return i>0&&s>0?{width:i,height:s}:null}var ht=`(() => {
|
|
61
|
+
if (window.__inklyCliRecorderInstalled) return;
|
|
62
|
+
window.__inklyCliRecorderInstalled = true;
|
|
63
|
+
window.__inklyCliLastClick = null;
|
|
64
|
+
window.__inklyCliLastEvent = null;
|
|
65
|
+
let lastMotionEmitAt = 0;
|
|
66
|
+
function firstLine(value) {
|
|
67
|
+
const lines = String(value || "")
|
|
68
|
+
.split(/\\r?\\n/)
|
|
69
|
+
.map((line) => line.trim())
|
|
70
|
+
.filter(Boolean);
|
|
71
|
+
return lines.length ? lines[0] : "";
|
|
72
|
+
}
|
|
73
|
+
function compactLabel(value) {
|
|
74
|
+
return firstLine(value)
|
|
75
|
+
.replace(/\\s+/g, " ")
|
|
76
|
+
.trim()
|
|
77
|
+
.slice(0, 48);
|
|
78
|
+
}
|
|
79
|
+
function ownText(el) {
|
|
80
|
+
if (!el || !el.childNodes) return "";
|
|
81
|
+
let out = "";
|
|
82
|
+
el.childNodes.forEach((node) => {
|
|
83
|
+
if (node.nodeType === 3) out += node.textContent;
|
|
84
|
+
});
|
|
85
|
+
return out.replace(/\\s+/g, " ").trim();
|
|
86
|
+
}
|
|
87
|
+
function firstUsefulText(el) {
|
|
88
|
+
if (!el || !el.querySelector) return "";
|
|
89
|
+
const candidate = el.querySelector("[aria-label],h1,h2,h3,h4,button,[role=button],a,label,input[placeholder],textarea[placeholder]");
|
|
90
|
+
if (!candidate || candidate === el) return "";
|
|
91
|
+
return textFor(candidate);
|
|
92
|
+
}
|
|
93
|
+
function textFor(el) {
|
|
94
|
+
if (!el) return "";
|
|
95
|
+
// Prefer the clicked element's OWN accessible name before descending into
|
|
96
|
+
// children, so composite cards (heading + description) and collapsible
|
|
97
|
+
// sidebars do not produce run-on or sibling labels.
|
|
98
|
+
const aria = el.getAttribute && (el.getAttribute("aria-label") || el.getAttribute("title") || el.getAttribute("alt"));
|
|
99
|
+
if (aria && aria.trim()) return compactLabel(aria);
|
|
100
|
+
const own = ownText(el);
|
|
101
|
+
if (own) return compactLabel(own);
|
|
102
|
+
const value = el.getAttribute && (el.getAttribute("value") || el.getAttribute("placeholder") || el.getAttribute("name"));
|
|
103
|
+
if (value && value.trim()) return compactLabel(value);
|
|
104
|
+
// Only the FIRST line of innerText: for a card whose innerText is
|
|
105
|
+
// "Title\\nDescription" this yields just "Title".
|
|
106
|
+
const inner = compactLabel(el.innerText || el.textContent || "");
|
|
107
|
+
if (inner) return inner;
|
|
108
|
+
const usefulText = firstUsefulText(el);
|
|
109
|
+
if (usefulText) return usefulText;
|
|
110
|
+
const closest = el.closest && el.closest("a,button,[role=button],label,[aria-label],[title]");
|
|
111
|
+
if (closest && closest !== el) return textFor(closest);
|
|
112
|
+
return "";
|
|
113
|
+
}
|
|
114
|
+
function selectorFor(el) {
|
|
115
|
+
if (!el || !el.tagName) return "";
|
|
116
|
+
if (el.id) return "#" + CSS.escape(el.id);
|
|
117
|
+
const parts = [];
|
|
118
|
+
let node = el;
|
|
119
|
+
while (node && node.nodeType === 1 && parts.length < 4) {
|
|
120
|
+
let part = node.tagName.toLowerCase();
|
|
121
|
+
if (node.classList && node.classList.length) {
|
|
122
|
+
part += "." + Array.from(node.classList).slice(0, 2).map((c) => CSS.escape(c)).join(".");
|
|
123
|
+
}
|
|
124
|
+
parts.unshift(part);
|
|
125
|
+
node = node.parentElement;
|
|
126
|
+
}
|
|
127
|
+
return parts.join(" > ");
|
|
128
|
+
}
|
|
129
|
+
function pointFor(el, fallbackX, fallbackY) {
|
|
130
|
+
if (el && el.getBoundingClientRect) {
|
|
131
|
+
const rect = el.getBoundingClientRect();
|
|
132
|
+
if (rect.width > 0 || rect.height > 0) {
|
|
133
|
+
return {
|
|
134
|
+
x: Math.max(0, Math.min(1, (rect.left + rect.width / 2) / Math.max(1, window.innerWidth))),
|
|
135
|
+
y: Math.max(0, Math.min(1, (rect.top + rect.height / 2) / Math.max(1, window.innerHeight))),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
x: Math.max(0, Math.min(1, fallbackX)),
|
|
141
|
+
y: Math.max(0, Math.min(1, fallbackY)),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function navigationUrlFor(el) {
|
|
145
|
+
const link = el && el.closest ? el.closest("a[href],area[href]") : null;
|
|
146
|
+
if (!link) return null;
|
|
147
|
+
const href = link.href || (link.getAttribute && link.getAttribute("href")) || "";
|
|
148
|
+
if (!href || /^\\s*(?:#|javascript:|mailto:|tel:)/i.test(href)) return null;
|
|
149
|
+
return href;
|
|
150
|
+
}
|
|
151
|
+
function payloadFor(type, el, point, label, navigationUrl = null) {
|
|
152
|
+
let alphaId = null;
|
|
153
|
+
if (el && el.nodeType === 1 && el.setAttribute) {
|
|
154
|
+
alphaId = el.getAttribute("data-inkly-id");
|
|
155
|
+
if (!alphaId) {
|
|
156
|
+
alphaId = "inkly-" + Math.random().toString(36).slice(2, 10);
|
|
157
|
+
el.setAttribute("data-inkly-id", alphaId);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
type,
|
|
162
|
+
click: point ? {
|
|
163
|
+
x: point.x,
|
|
164
|
+
y: point.y,
|
|
165
|
+
label: label || textFor(el) || null,
|
|
166
|
+
tag: el && el.tagName ? el.tagName.toLowerCase() : null,
|
|
167
|
+
selector: selectorFor(el) || null,
|
|
168
|
+
alphaId,
|
|
169
|
+
outerHTML: el && el.outerHTML ? String(el.outerHTML).slice(0, 2000) : null,
|
|
170
|
+
} : null,
|
|
171
|
+
// Page context captured IN-PAGE at event time, before any navigation the
|
|
172
|
+
// click triggers \u2014 so the exported step's sourceUrl/title match the page
|
|
173
|
+
// the click happened on, not the racy post-navigation destination.
|
|
174
|
+
page: {
|
|
175
|
+
url: location.href,
|
|
176
|
+
title: document.title || "Captured screen",
|
|
177
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
178
|
+
scroll: {
|
|
179
|
+
x: window.scrollX || document.documentElement.scrollLeft || 0,
|
|
180
|
+
y: window.scrollY || document.documentElement.scrollTop || 0,
|
|
181
|
+
maxX: Math.max(0, document.documentElement.scrollWidth - window.innerWidth),
|
|
182
|
+
maxY: Math.max(0, document.documentElement.scrollHeight - window.innerHeight),
|
|
183
|
+
},
|
|
184
|
+
navigationUrl,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function emit(payload) {
|
|
189
|
+
window.__inklyCliLastEvent = payload;
|
|
190
|
+
if (payload.type === "click") window.__inklyCliLastClick = payload.click;
|
|
191
|
+
try {
|
|
192
|
+
if (typeof window.__inklyCliCaptureEvent === "function") {
|
|
193
|
+
window.__inklyCliCaptureEvent(JSON.stringify(payload));
|
|
194
|
+
} else if (typeof window.__inklyCliCaptureClick === "function" && payload.type === "click") {
|
|
195
|
+
window.__inklyCliCaptureClick(JSON.stringify(payload.click));
|
|
196
|
+
}
|
|
197
|
+
} catch {
|
|
198
|
+
// The CLI listener is best effort; manual capture remains available.
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function emitMotion(type, el, point, label, minInterval = 250) {
|
|
202
|
+
const now = Date.now();
|
|
203
|
+
if (now - lastMotionEmitAt < minInterval) return;
|
|
204
|
+
lastMotionEmitAt = now;
|
|
205
|
+
emit(payloadFor(type, el, point, label));
|
|
206
|
+
}
|
|
207
|
+
document.addEventListener("click", (event) => {
|
|
208
|
+
const el = event.target && event.target.closest ? event.target.closest("a,button,[role=button],input,select,textarea,label,[aria-label],[title]") || event.target : event.target;
|
|
209
|
+
const navigationUrl = navigationUrlFor(el);
|
|
210
|
+
if (navigationUrl) event.preventDefault();
|
|
211
|
+
// A synthetic (.click()) or untrusted click, or one whose coordinates are
|
|
212
|
+
// 0/0 (off-viewport / programmatic), has no real cursor position. Fall
|
|
213
|
+
// back to the clicked element's bounding-rect center like the other
|
|
214
|
+
// handlers do, so the pointer never lands in the top-left corner.
|
|
215
|
+
const hasRealPoint = event.isTrusted && (event.clientX > 0 || event.clientY > 0);
|
|
216
|
+
const point = hasRealPoint
|
|
217
|
+
? {
|
|
218
|
+
x: Math.max(0, Math.min(1, event.clientX / Math.max(1, window.innerWidth))),
|
|
219
|
+
y: Math.max(0, Math.min(1, event.clientY / Math.max(1, window.innerHeight))),
|
|
220
|
+
}
|
|
221
|
+
: pointFor(el, 0.5, 0.5);
|
|
222
|
+
emit(payloadFor("click", el, point, null, navigationUrl));
|
|
223
|
+
}, true);
|
|
224
|
+
document.addEventListener("keydown", (event) => {
|
|
225
|
+
if (event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta") return;
|
|
226
|
+
const el = event.target;
|
|
227
|
+
const label = textFor(el) || (el && el.getAttribute && (el.getAttribute("placeholder") || el.getAttribute("name"))) || "Typed text";
|
|
228
|
+
emitMotion("input", el, pointFor(el, 0.5, 0.5), label);
|
|
229
|
+
}, true);
|
|
230
|
+
document.addEventListener("input", (event) => {
|
|
231
|
+
const el = event.target;
|
|
232
|
+
const label = textFor(el) || (el && el.getAttribute && (el.getAttribute("placeholder") || el.getAttribute("name"))) || "Typed text";
|
|
233
|
+
emitMotion("input", el, pointFor(el, 0.5, 0.5), label);
|
|
234
|
+
}, true);
|
|
235
|
+
function onMotionScroll() {
|
|
236
|
+
emitMotion("scroll", document.scrollingElement || document.documentElement, {
|
|
237
|
+
x: 0.9,
|
|
238
|
+
y: Math.max(0.1, Math.min(0.9, window.scrollY / Math.max(1, document.documentElement.scrollHeight - window.innerHeight))),
|
|
239
|
+
}, "Scrolled page");
|
|
240
|
+
}
|
|
241
|
+
window.addEventListener("scroll", onMotionScroll, true);
|
|
242
|
+
window.addEventListener("wheel", onMotionScroll, true);
|
|
243
|
+
window.addEventListener("touchmove", onMotionScroll, true);
|
|
244
|
+
})();`;async function tt(t,e,n=!1){n&&(await t.send("Runtime.addBinding",{name:"__inklyCliCaptureEvent"},e).catch(()=>{}),await t.send("Runtime.addBinding",{name:"__inklyCliCaptureClick"},e).catch(()=>{})),await t.send("Page.addScriptToEvaluateOnNewDocument",{source:ht},e),await G(t,e,ht,5e3).catch(()=>{})}async function nt(t,e){await G(t,e,ht,5e3).catch(()=>{});let n=await G(t,e,`JSON.stringify({
|
|
245
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
246
|
+
sourceUrl: location.href,
|
|
247
|
+
title: document.title || "Captured screen",
|
|
248
|
+
click: window.__inklyCliLastClick || null,
|
|
249
|
+
scroll: {
|
|
250
|
+
x: window.scrollX || document.documentElement.scrollLeft || 0,
|
|
251
|
+
y: window.scrollY || document.documentElement.scrollTop || 0,
|
|
252
|
+
maxX: Math.max(0, document.documentElement.scrollWidth - window.innerWidth),
|
|
253
|
+
maxY: Math.max(0, document.documentElement.scrollHeight - window.innerHeight)
|
|
254
|
+
}
|
|
255
|
+
})`,5e3),r=JSON.parse(String(n));return{viewport:{width:Number(r.viewport?.width)||gn,height:Number(r.viewport?.height)||yn},sourceUrl:typeof r.sourceUrl=="string"?r.sourceUrl:"",title:typeof r.title=="string"?r.title:"Captured screen",click:r.click??null,scroll:{x:Number(r.scroll?.x)||0,y:Number(r.scroll?.y)||0,maxX:Number(r.scroll?.maxX)||0,maxY:Number(r.scroll?.maxY)||0}}}function vs(){let t=pn(process.cwd(),"packages/capture-extension/dist/singlefile-injected.js"),e=pn(ds,"packages/capture-extension/dist/singlefile-injected.js"),n=t??e;if(!n)throw new Error("SingleFile bundle not found. Run `npm run extension:build` before --html capture.");return n}var xs={removeFrames:!0,removeImports:!0,blockScripts:!0,compressHTML:!1,compressCSS:!1,saveRawPage:!1,loadDeferredImages:!1,loadDeferredImagesMaxIdleTime:1500,loadDeferredImagesKeepZoomLevel:!1,loadDeferredImagesBlockCookies:!1,loadDeferredImagesBlockStorage:!1,blockMixedContent:!1,insertMetaCSP:!0,insertMetaNoIndex:!1,insertSingleFileComment:!1,removeAlternativeFonts:!0,removeAlternativeImages:!0,removeAlternativeMedias:!0,removeUnusedFonts:!0,backgroundSave:!1,removeUnusedStyles:!0,removeHiddenElements:!0,compressContent:!1},gt="__inklySingleFileFetch",_s=`(() => {
|
|
256
|
+
if (globalThis.__inklyFetchInstalled) return;
|
|
257
|
+
globalThis.__inklyFetchInstalled = true;
|
|
258
|
+
const pending = new Map();
|
|
259
|
+
let nextId = 1;
|
|
260
|
+
const b64ToBytes = (s) => Uint8Array.from(atob(s || ''), (c) => c.charCodeAt(0));
|
|
261
|
+
globalThis.__inklyResolveFetch = (id, r) => {
|
|
262
|
+
const p = pending.get(id); if (!p) return; pending.delete(id);
|
|
263
|
+
try {
|
|
264
|
+
p.resolve(new Response(b64ToBytes(r.data), { status: r.status || 200, headers: r.headers || {} }));
|
|
265
|
+
} catch (e) { p.reject(e); }
|
|
266
|
+
};
|
|
267
|
+
globalThis.__inklyRejectFetch = (id, e) => {
|
|
268
|
+
const p = pending.get(id); if (!p) return; pending.delete(id);
|
|
269
|
+
p.reject(new Error((e && e.error) || 'fetch failed'));
|
|
270
|
+
};
|
|
271
|
+
const viaNode = (url, options) => new Promise((resolve, reject) => {
|
|
272
|
+
const id = nextId++;
|
|
273
|
+
pending.set(id, { resolve, reject });
|
|
274
|
+
try {
|
|
275
|
+
globalThis.${gt}(JSON.stringify({
|
|
276
|
+
id,
|
|
277
|
+
url: String(url),
|
|
278
|
+
options: {
|
|
279
|
+
headers: (options && options.headers) || undefined,
|
|
280
|
+
referrer: (options && options.referrer) || undefined,
|
|
281
|
+
},
|
|
282
|
+
}));
|
|
283
|
+
} catch (err) { pending.delete(id); reject(err); }
|
|
284
|
+
});
|
|
285
|
+
// In-page fetch first (fast; carries the page's cookies for same-origin and
|
|
286
|
+
// for cross-origin resources that send permissive CORS). Fall back to the
|
|
287
|
+
// privileged Node fetch only when the browser blocks it (CORS / no ACAO),
|
|
288
|
+
// which is the case the extension covers via host permissions.
|
|
289
|
+
globalThis.__inklyPrivilegedFetch = async (url, options) => {
|
|
290
|
+
try {
|
|
291
|
+
const r = await fetch(url, { cache: 'force-cache', headers: options && options.headers });
|
|
292
|
+
if (r.type === 'opaque' || r.type === 'opaqueredirect') throw new Error('opaque');
|
|
293
|
+
return r;
|
|
294
|
+
} catch (err) {
|
|
295
|
+
return viaNode(url, options);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
})();`;function ks(t,e){let n,r,i;try{let s=new URL(t);n=s.hostname,r=s.pathname||"/",i=s.protocol==="https:"}catch{return""}return e.filter(s=>{let o=s.domain.replace(/^\./,""),c=n===o||n.endsWith(`.${o}`),l=r.startsWith(s.path||"/"),d=!s.secure||i;return c&&l&&d}).map(s=>`${s.name}=${s.value}`).join("; ")}async function Ss(t,e,n,r){let i;try{let s=JSON.parse(n);i=s.id;let o={...s.options?.headers??{}},c=ks(s.url,r);c&&(o.cookie=c),s.options?.referrer&&(o.referer=s.options.referrer);let l=await fetch(s.url,{headers:o,redirect:"follow"}),d=Buffer.from(await l.arrayBuffer()),f={};l.headers.forEach((I,T)=>{f[T]=I});let x={status:l.status,headers:f,data:d.toString("base64")};await G(t,e,`globalThis.__inklyResolveFetch(${i}, ${JSON.stringify(x)})`,2e4)}catch(s){if(i===void 0)return;await G(t,e,`globalThis.__inklyRejectFetch(${i}, ${JSON.stringify({error:String(s)})})`,2e4).catch(()=>{})}}var ft=Math.max(6e4,Number(process.env.INKLY_CAPTURE_TIMEOUT_MS)||24e4);async function Cs(t,e,n=!1){let r=await Xe(vs(),"utf8");await t.send("Network.enable",{},e).catch(()=>{}),await t.send("Runtime.addBinding",{name:gt},e).catch(()=>{});let i=[];try{i=(await t.send("Network.getAllCookies",{},e)).cookies??[]}catch{}let s=t.on("Runtime.bindingCalled",(o,c)=>{if(c!==e)return;let l=o;l.name!==gt||typeof l.payload!="string"||Ss(t,e,l.payload,i)});try{await G(t,e,r,3e4),await G(t,e,_s,1e4);let o=await G(t,e,`(async () => {
|
|
299
|
+
const sf = globalThis.__inklySingleFile;
|
|
300
|
+
if (!sf || typeof sf.getPageData !== "function") throw new Error("SingleFile not loaded");
|
|
301
|
+
// initOptions (2nd arg) is forwarded to single-file-core/core/util.js
|
|
302
|
+
// getInstance(), which wires options.fetch / frameFetch as the resource
|
|
303
|
+
// downloader. This routes CORS-blocked fetches through the CDP binding.
|
|
304
|
+
const initOptions = {
|
|
305
|
+
fetch: globalThis.__inklyPrivilegedFetch,
|
|
306
|
+
frameFetch: globalThis.__inklyPrivilegedFetch,
|
|
307
|
+
};
|
|
308
|
+
const data = await Promise.race([
|
|
309
|
+
sf.getPageData(${JSON.stringify({...xs,blockVideos:n})}, initOptions),
|
|
310
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("SingleFile getPageData exceeded ${ft}ms")), ${ft}))
|
|
311
|
+
]);
|
|
312
|
+
if (typeof data.content === "string") return data.content;
|
|
313
|
+
return new TextDecoder().decode(new Uint8Array(data.content));
|
|
314
|
+
})()`,ft+15e3);return String(o)}finally{s()}}async function Is(t,e){if(t.runtime!=="cli")throw new Error("HTML capture is only available for --runtime cli sessions");if(!t.captureDir)throw new Error("CLI capture session has no captureDir");let n=new Te(t.browserWsUrl);try{let r=await Qe(n,t.targetId);await n.send("Page.enable",{},r).catch(()=>{}),await n.send("Runtime.enable",{},r).catch(()=>{}),await tt(n,r),await et(n,r,t.targetId,t.width,t.height);let i=await nt(n,r),s=await Cs(n,r,t.cliBlockVideos===!0),o=(t.cliScreens?.length??0)+1,c=N(t.captureDir,`html-${String(o).padStart(3,"0")}`),l=N(c,"index.html");await Ye(c,{recursive:!0}),await Ue(l,s,"utf8");let d={...t,cliScreens:[...t.cliScreens??[],{kind:"html",pngPath:null,htmlPath:l,viewport:i.viewport,naturalSize:i.viewport,sourceUrl:i.sourceUrl,title:i.title,click:e??i.click,scroll:i.scroll,capturedAt:new Date().toISOString()}],tabUrl:i.sourceUrl};return await n.send("Target.detachFromTarget",{sessionId:r}).catch(()=>{}),await Ae(d),d}finally{n.close()}}async function Ts(t){await new Promise((e,n)=>{let r=rs("ffmpeg",t,{stdio:["ignore","ignore","pipe"]}),i=[];r.stderr.on("data",s=>i.push(s)),r.on("error",n),r.on("close",s=>{if(s===0){e();return}n(new Error(`ffmpeg exited ${s}: ${Buffer.concat(i).toString("utf8").slice(-2e3)}`))})})}async function As(t){let e=[...t.frames].sort((E,L)=>E.receivedAt-L.receivedAt),n=[],r=e[0]?.receivedAt;if(r!==void 0){let E=1e3/Je,L=r;for(let J of e)J.receivedAt<L&&J!==e[e.length-1]||(n.push(J),L=J.receivedAt+E)}let i=n.slice(-Math.ceil(wn/1e3*Je)-2),s=i[0]?.receivedAt,o=i[i.length-1]?.receivedAt,c=s!==void 0&&o!==void 0?o-s:0;if(i.length<ms||c<fs||new Set(i.map(E=>E.data)).size<=1)return null;let l=Math.ceil(hs/1e3*Je),d=i.length>=l?i:i.concat(Array.from({length:l-i.length},()=>i[i.length-1])),f=N(t.captureDir,`video-${String(t.index).padStart(3,"0")}`);await is(f,{recursive:!0,force:!0}).catch(()=>{}),await Ye(f,{recursive:!0});for(let[E,L]of d.entries())await Ue(N(f,`frame-${String(E+1).padStart(5,"0")}.png`),Buffer.from(L.data,"base64"));let x=N(f,"poster.png");await Ue(x,Buffer.from(i[0].data,"base64"));let I=N(t.captureDir,`video-${String(t.index).padStart(3,"0")}.webm`);await Ts(["-y","-framerate",String(Je),"-i",N(f,"frame-%05d.png"),"-c:v","libvpx-vp9","-pix_fmt","yuv420p","-deadline","realtime","-cpu-used","6",I]);let T=new Uint8Array(await Xe(x));return{videoPath:I,posterPngPath:x,naturalSize:yt(T)??{width:gn,height:yn}}}async function bn(t,e,n,r){if(!t.captureDir)throw new Error("CLI capture session has no captureDir");let i=Buffer.from(e,"base64"),s=(t.cliScreens?.length??0)+1,o=N(t.captureDir,`screen-${String(s).padStart(3,"0")}.png`);await Ye(t.captureDir,{recursive:!0}),await Ue(o,i);let c=yt(i)??n.viewport,l={...t,cliScreens:[...t.cliScreens??[],{kind:"image",pngPath:o,viewport:n.viewport,naturalSize:c,sourceUrl:n.sourceUrl,title:n.title,click:r,scroll:n.scroll,capturedAt:new Date().toISOString()}],tabUrl:n.sourceUrl};return await Ae(l),l}async function Ps(t,e,n,r,i){if(t.runtime!=="cli")throw new Error("video capture is only available for --runtime cli sessions");if(!t.captureDir)throw new Error("CLI capture session has no captureDir");let s=r??null,o=null;try{if(!s){o=new Te(t.browserWsUrl);let f=await Qe(o,t.targetId);await o.send("Page.enable",{},f).catch(()=>{}),await o.send("Runtime.enable",{},f).catch(()=>{}),await tt(o,f),await et(o,f,t.targetId,t.width,t.height),s=await nt(o,f),await o.send("Target.detachFromTarget",{sessionId:f}).catch(()=>{})}let c=(t.cliScreens?.length??0)+1,l=await As({frames:e,captureDir:t.captureDir,index:c});if(!l)return i&&r?bn(t,i,r,n??null):vn(t,void 0,n,"click");let d={...t,cliScreens:[...t.cliScreens??[],{kind:"video",pngPath:l.posterPngPath,videoPath:l.videoPath,posterPngPath:l.posterPngPath,viewport:s.viewport,naturalSize:l.naturalSize,sourceUrl:s.sourceUrl,title:s.title,click:n??s.click,scroll:s.scroll,capturedAt:new Date().toISOString()}],tabUrl:s.sourceUrl};return await Ae(d),d}finally{o?.close()}}async function vn(t,e,n,r="click"){if(t.runtime!=="cli")throw new Error("capture is only available for --runtime cli sessions");if(!t.captureDir)throw new Error("CLI capture session has no captureDir");let i=new Te(t.browserWsUrl);try{let s=await Qe(i,t.targetId);await i.send("Page.enable",{},s).catch(()=>{}),await i.send("Runtime.enable",{},s).catch(()=>{}),await tt(i,s),await et(i,s,t.targetId,t.width,t.height);let o=await nt(i,s),l=(await i.send("Page.captureScreenshot",{format:"png",fromSurface:!0,captureBeyondViewport:!1},s)).data;if(typeof l!="string")throw new Error("Page.captureScreenshot returned no data");let d=Buffer.from(l,"base64"),f=(t.cliScreens?.length??0)+1,x=N(t.captureDir,`screen-${String(f).padStart(3,"0")}.png`);await Ye(t.captureDir,{recursive:!0}),await Ue(x,d);let I=yt(d)??o.viewport,T=r==="click"?n??o.click:null,E=e&&r==="click"?{...T??{x:.5,y:.5},label:e}:T,L={...t,cliScreens:[...t.cliScreens??[],{kind:"image",pngPath:x,viewport:o.viewport,naturalSize:I,sourceUrl:o.sourceUrl,title:o.title,click:E,scroll:o.scroll,capturedAt:new Date().toISOString()}],tabUrl:o.sourceUrl};return await i.send("Target.detachFromTarget",{sessionId:s}).catch(()=>{}),await Ae(L),L}finally{i.close()}}function xn(){return N(process.env.INKLY_CAPTURE_AGENT_HOME||N(os(),".inkly"),"capture-agent","sessions")}function _n(t){if(!/^[a-zA-Z0-9._:-]+$/.test(t))throw new Error(`invalid session id: ${t}`);return N(xn(),`${t}.json`)}function Es(t){return N(xn(),`${t}.listener.json`)}async function Rs(t){try{let e=await Xe(Es(t),"utf8");return JSON.parse(e)}catch{return null}}async function Ae(t){await ln(_n(t.id),`${JSON.stringify(t,null,2)}
|
|
315
|
+
`)}async function ye(t){let e=await Xe(_n(t),"utf8");return JSON.parse(e)}async function kn(t){let e=ws(t,"session",us),n=await ye(e);if(n.runtime!=="cli")throw new Error("listen subcommand is only available for cli runtime sessions");let r=await Rs(e),i=new Te(n.browserWsUrl),s=null,o=n.targetId,c=Promise.resolve(),l=Promise.resolve(),d=0,f=new Set,x=[],I=!1,T=null,E=null,L=!1;async function J(S){s&&(await i.send("Page.stopScreencast",{},s).catch(()=>{}),await i.send("Target.detachFromTarget",{sessionId:s}).catch(()=>{})),x=[],I=!1,T=null,E=null,o=S,s=await Qe(i,S),await i.send("Page.enable",{},s).catch(()=>{}),await i.send("Runtime.enable",{},s).catch(()=>{});let R=await ye(e).catch(()=>n);await et(i,s,S,R.width,R.height),await tt(i,s,!0),x=[],I=!1,T=null,E=null;let k=await ye(e).catch(()=>R);k.cliRecordVideo&&k.cliCaptureKind!=="html"&&await i.send("Page.startScreencast",{format:"png",quality:90,maxWidth:k.width,maxHeight:k.height,everyNthFrame:1},s).catch(C=>{process.stderr.write(`capture video start failed: ${C.message}
|
|
316
|
+
`)});let _=await ye(e).catch(()=>n);await Ae({..._,targetId:S,cliListenerPid:_.cliListenerPid??r?.cliListenerPid??null,cliListenerLogPath:_.cliListenerLogPath??r?.cliListenerLogPath??null,cliListenerReadyAt:_.cliListenerReadyAt??new Date().toISOString()})}async function $e(S){L||(L=!0,s&&(await i.send("Page.stopScreencast",{},s).catch(()=>{}),await i.send("Target.detachFromTarget",{sessionId:s}).catch(()=>{})),i.close(),process.exit(S))}process.once("SIGTERM",()=>{$e(0)}),process.once("SIGINT",()=>{$e(0)}),await i.send("Target.setDiscoverTargets",{discover:!0}).catch(()=>{});for(let S of await mn(i).catch(()=>[]))f.add(S.targetId);await J(n.targetId);{let S=await ye(e).catch(()=>n);await Ae({...S,targetId:o,cliListenerPid:S.cliListenerPid??r?.cliListenerPid??null,cliListenerLogPath:S.cliListenerLogPath??r?.cliListenerLogPath??null,cliListenerReadyAt:S.cliListenerReadyAt??new Date().toISOString()})}i.on("Target.targetCreated",S=>{let k=S.targetInfo;!k||k.type!=="page"||!(k.openerId===o||Date.now()<d)||(l=l.then(async()=>{await Ie(250),await J(k.targetId),f.add(k.targetId)}).catch(C=>{process.stderr.write(`capture target follow failed: ${C.message}
|
|
317
|
+
`)}))}),i.on("Page.screencastFrame",(S,R)=>{if(R!==s)return;let k=S;typeof k.sessionId=="number"&&i.send("Page.screencastFrameAck",{sessionId:k.sessionId},R).catch(()=>{}),typeof k.data=="string"&&(x.push({data:k.data,receivedAt:Date.now()}),x.length>un&&(x=x.slice(-un)))});async function wt(){let S=await mn(i).catch(()=>[]),R=S.find(k=>k.openerId===o)??S.find(k=>k.targetId!==o&&!f.has(k.targetId));for(let k of S)f.add(k.targetId);!R||R.targetId===o||await J(R.targetId)}async function bt(S){!S||!s||await i.send("Page.navigate",{url:S},s).catch(R=>{process.stderr.write(`capture post-click navigation failed: ${R.message}
|
|
318
|
+
`)})}i.on("Runtime.bindingCalled",(S,R)=>{if(R!==s)return;let k=S;if(k.name!=="__inklyCliCaptureEvent"&&k.name!=="__inklyCliCaptureClick"||typeof k.payload!="string")return;let _=null;try{let C=JSON.parse(k.payload);k.name==="__inklyCliCaptureClick"?_={type:"click",click:C,page:null}:_={type:C.type==="input"||C.type==="scroll"?C.type:"click",click:typeof C.click=="object"&&C.click?C.click:null,page:typeof C.page=="object"&&C.page?C.page:null}}catch{_=null}if(_){if(_.type==="click")d=Date.now()+3e3;else{let C=Date.now();T=T??C,E=C,I=!0}c=c.then(async()=>{if(_.type!=="click")return;let C=Date.now(),Pe=T,vt=E,Cn=I&&Pe!==null&&vt!==null&&C-vt<=ps;I=!1,T=null,E=null;let In=Math.max(Pe?Pe-250:0,C-wn),Tn=Pe?x.filter(j=>j.receivedAt>=In):[...x],rt=_.page?.navigationUrl??null,Ee=x.length?x[x.length-1].data:null,Re=_.page?{viewport:_.page.viewport,sourceUrl:_.page.url,title:_.page.title,click:_.click,scroll:_.page.scroll}:null;if(s&&(Re||(Re=await nt(i,s).catch(()=>null)),!Ee)){let j=await i.send("Page.captureScreenshot",{format:"png",fromSurface:!0,captureBeyondViewport:!1},s).catch(()=>null),_t=j&&j.data;Ee=typeof _t=="string"?_t:null}x=[];let q=await ye(e).catch(()=>null);if(!q||q.runtime!=="cli"){await $e(0);return}if(q.cliCaptureKind==="html"){await Ie(rt?500:2e3);let j=await Is(q,_.click);await qe({session:j,stepKind:"html",action:_.type,click:_.click}),await bt(rt),await Ie(2e3),await l,await wt();return}if(await bt(rt),await Ie(2e3),await l,await wt(),q.cliRecordVideo&&Cn){let j=await Ps(q,Tn,_.click,Re??void 0,Ee);await qe({session:j,stepKind:dn(j),action:_.type,click:_.click});return}if(Ee&&Re){let j=await bn(q,Ee,Re,_.click??null);await qe({session:j,stepKind:"image",action:_.type,click:_.click});return}let xt=await vn(q,void 0,_.click,"click");await qe({session:xt,stepKind:dn(xt),action:_.type,click:_.click})}).catch(C=>{process.stderr.write(`capture listener failed: ${C.message}
|
|
319
|
+
`)})}});let Sn=setInterval(()=>{ye(e).catch(()=>{clearInterval(Sn),$e(0)})},1e3);return await new Promise(()=>{}),0}async function Os(){let t=Ds(process.argv.slice(2));process.exit(await kn(t))}Os().catch(t=>{process.stderr.write(`capture listener failed: ${t.message}
|
|
320
|
+
`),process.exit(1)});
|