@inkly-org/cli 0.5.4 → 0.6.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 +5 -7
- package/dist/capture-listener.js +15 -11
- package/dist/cli.js +159 -131
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var yo=Object.defineProperty;var xo=(t,e)=>{for(var n in e)yo(t,n,{get:e[n],enumerable:!0})};import Mp from"mri";import{existsSync as Nr,statSync as Up}from"fs";import{isAbsolute as Fp,join as Qi,resolve as Hp}from"path";import{Buffer as ud}from"buffer";import{mkdir as Oa,writeFile as pd,access as hd}from"fs/promises";import{dirname as md,join as fd,resolve as gd,sep as Na}from"path";var l={};xo(l,{BRAND:()=>Vo,DIRTY:()=>ze,EMPTY_PATH:()=>So,INVALID:()=>v,NEVER:()=>Ps,OK:()=>q,ParseStatus:()=>G,Schema:()=>A,ZodAny:()=>Ee,ZodArray:()=>xe,ZodBigInt:()=>Ue,ZodBoolean:()=>Fe,ZodBranded:()=>zt,ZodCatch:()=>Xe,ZodDate:()=>He,ZodDefault:()=>Ye,ZodDiscriminatedUnion:()=>an,ZodEffects:()=>ie,ZodEnum:()=>qe,ZodError:()=>Y,ZodFirstPartyTypeKind:()=>S,ZodFunction:()=>sn,ZodIntersection:()=>Ze,ZodIssueCode:()=>m,ZodLazy:()=>Je,ZodLiteral:()=>Ge,ZodMap:()=>ft,ZodNaN:()=>bt,ZodNativeEnum:()=>Ke,ZodNever:()=>se,ZodNull:()=>We,ZodNullable:()=>ue,ZodNumber:()=>Me,ZodObject:()=>X,ZodOptional:()=>re,ZodParsedType:()=>g,ZodPipeline:()=>Mt,ZodPromise:()=>Re,ZodReadonly:()=>Qe,ZodRecord:()=>on,ZodSchema:()=>A,ZodSet:()=>gt,ZodString:()=>Pe,ZodSymbol:()=>ht,ZodTransformer:()=>ie,ZodTuple:()=>ce,ZodType:()=>A,ZodUndefined:()=>Be,ZodUnion:()=>Ve,ZodUnknown:()=>ye,ZodVoid:()=>mt,addIssueToContext:()=>f,any:()=>es,array:()=>as,bigint:()=>qo,boolean:()=>qr,coerce:()=>Is,custom:()=>Zr,date:()=>Ko,datetimeRegex:()=>Wr,defaultErrorMap:()=>ge,discriminatedUnion:()=>ls,effect:()=>ks,enum:()=>bs,function:()=>ms,getErrorMap:()=>ct,getParsedType:()=>de,instanceof:()=>Jo,intersection:()=>ds,isAborted:()=>nn,isAsync:()=>ut,isDirty:()=>rn,isValid:()=>Ie,late:()=>Zo,lazy:()=>fs,literal:()=>gs,makeIssue:()=>Lt,map:()=>ps,nan:()=>Go,nativeEnum:()=>ys,never:()=>ns,null:()=>Qo,nullable:()=>vs,number:()=>Gr,object:()=>is,objectUtil:()=>On,oboolean:()=>As,onumber:()=>Ts,optional:()=>ws,ostring:()=>Cs,pipeline:()=>_s,preprocess:()=>Ss,promise:()=>xs,quotelessJson:()=>ko,record:()=>us,set:()=>hs,setErrorMap:()=>vo,strictObject:()=>os,string:()=>Jr,symbol:()=>Yo,transformer:()=>ks,tuple:()=>cs,undefined:()=>Xo,union:()=>ss,unknown:()=>ts,util:()=>E,void:()=>rs});var E;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{let i={};for(let o of a)i[o]=o;return i},t.getValidEnumValues=a=>{let i=t.objectKeys(a).filter(s=>typeof a[a[s]]!="number"),o={};for(let s of i)o[s]=a[s];return t.objectValues(o)},t.objectValues=a=>t.objectKeys(a).map(function(i){return a[i]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let i=[];for(let o in a)Object.prototype.hasOwnProperty.call(a,o)&&i.push(o);return i},t.find=(a,i)=>{for(let o of a)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(E||(E={}));var On;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(On||(On={}));var g=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),de=t=>{switch(typeof t){case"undefined":return g.undefined;case"string":return g.string;case"number":return Number.isNaN(t)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}};var m=E.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"]),ko=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Y=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(i){return i.message},r={_errors:[]},a=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let s=r,c=0;for(;c<o.path.length;){let d=o.path[c];c===o.path.length-1?(s[d]=s[d]||{_errors:[]},s[d]._errors.push(n(o))):s[d]=s[d]||{_errors:[]},s=s[d],c++}}};return a(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,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let a of this.issues)if(a.path.length>0){let i=a.path[0];n[i]=n[i]||[],n[i].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Y.create=t=>new Y(t);var wo=(t,e)=>{let n;switch(t.code){case m.invalid_type:t.received===g.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,E.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${E.joinValues(t.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${E.joinValues(t.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;break;case m.invalid_arguments:n="Invalid function arguments";break;case m.invalid_return_type:n="Invalid function return type";break;case m.invalid_date:n="Invalid date";break;case m.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}"`:E.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case m.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 m.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 m.custom:n="Invalid input";break;case m.invalid_intersection_types:n="Intersection results could not be merged";break;case m.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=e.defaultError,E.assertNever(t)}return{message:n}},ge=wo;var Mr=ge;function vo(t){Mr=t}function ct(){return Mr}var Lt=t=>{let{data:e,path:n,errorMaps:r,issueData:a}=t,i=[...n,...a.path||[]],o={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let s="",c=r.filter(d=>!!d).slice().reverse();for(let d of c)s=d(o,{data:e,defaultError:s}).message;return{...a,path:i,message:s}},So=[];function f(t,e){let n=ct(),r=Lt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ge?void 0:ge].filter(a=>!!a)});t.common.issues.push(r)}var G=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 a of n){if(a.status==="aborted")return v;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let a of n){let i=await a.key,o=await a.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let a of n){let{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},v=Object.freeze({status:"aborted"}),ze=t=>({status:"dirty",value:t}),q=t=>({status:"valid",value:t}),nn=t=>t.status==="aborted",rn=t=>t.status==="dirty",Ie=t=>t.status==="valid",ut=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}));var ae=class{constructor(e,n,r,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=a}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}},Ur=(t,e)=>{if(Ie(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 Y(t.common.issues);return this._error=n,this._error}}};function C(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:a}=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:a}:{errorMap:(o,s)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??r??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:c??n??s.defaultError}},description:a}}var A=class{get description(){return this._def.description}_getType(e){return de(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:de(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new G,ctx:{common:e.parent.common,data:e.data,parsedType:de(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(ut(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:de(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Ur(r,a)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:de(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Ie(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=>Ie(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:de(e)},a=this._parse({data:e,path:r.path,parent:r}),i=await(ut(a)?a:Promise.resolve(a));return Ur(r,i)}refine(e,n){let r=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,i)=>{let o=e(a),s=()=>i.addIssue({code:m.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(e,n){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof n=="function"?n(r,a):n),!1))}_refinement(e){return new ie({schema:this,typeName:S.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 re.create(this,this._def)}nullable(){return ue.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xe.create(this)}promise(){return Re.create(this,this._def)}or(e){return Ve.create([this,e],this._def)}and(e){return Ze.create(this,e,this._def)}transform(e){return new ie({...C(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ye({...C(this._def),innerType:this,defaultValue:n,typeName:S.ZodDefault})}brand(){return new zt({typeName:S.ZodBranded,type:this,...C(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Xe({...C(this._def),innerType:this,catchValue:n,typeName:S.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Mt.create(this,e)}readonly(){return Qe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},_o=/^c[^\s-]{8,}$/i,Co=/^[0-9a-z]+$/,To=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ao=/^[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,Io=/^[a-z0-9_-]{21}$/i,Po=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Eo=/^[-+]?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)?)??$/,Ro=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$o="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Nn,Do=/^(?:(?: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])$/,jo=/^(?:(?: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])$/,Oo=/^(([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]))$/,No=/^(([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])$/,Lo=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,zo=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Hr="((\\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])))",Mo=new RegExp(`^${Hr}$`);function Br(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 Uo(t){return new RegExp(`^${Br(t)}$`)}function Wr(t){let e=`${Hr}T${Br(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 Fo(t,e){return!!((e==="v4"||!e)&&Do.test(t)||(e==="v6"||!e)&&Oo.test(t))}function Ho(t,e){if(!Po.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,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function Bo(t,e){return!!((e==="v4"||!e)&&jo.test(t)||(e==="v6"||!e)&&No.test(t))}var Pe=class t extends A{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:g.string,received:i.parsedType}),v}let r=new G,a;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,s=e.data.length<i.value;(o||s)&&(a=this._getOrReturnCtx(e,a),o?f(a,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&f(a,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Ro.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Nn||(Nn=new RegExp($o,"u")),Nn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Ao.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Io.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")_o.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Co.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")To.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:m.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"regex",code:m.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Wr(i).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Mo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Uo(i).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Eo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Fo(e.data,i.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Ho(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"jwt",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Bo(e.data,i.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cidr",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Lo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?zo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64url",code:m.invalid_string,message:i.message}),r.dirty()):E.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(a=>e.test(a),{validation:n,code:m.invalid_string,...b.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.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,...b.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,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...b.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.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}};Pe.create=t=>new Pe({checks:[],typeName:S.ZodString,coerce:t?.coerce??!1,...C(t)});function Wo(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=n>r?n:r,i=Number.parseInt(t.toFixed(a).replace(".","")),o=Number.parseInt(e.toFixed(a).replace(".",""));return i%o/10**a}var Me=class t extends A{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)!==g.number){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:g.number,received:i.parsedType}),v}let r,a=new G;for(let i of this._def.checks)i.kind==="int"?E.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?Wo(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_finite,message:i.message}),a.dirty()):E.assertNever(i);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(a)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.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"&&E.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)}};Me.create=t=>new Me({checks:[],typeName:S.ZodNumber,coerce:t?.coerce||!1,...C(t)});var Ue=class t extends A{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)!==g.bigint)return this._getInvalidInput(e);let r,a=new G;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):E.assertNever(i);return{status:a.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:g.bigint,received:n.parsedType}),v}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(a)}]})}_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:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.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}};Ue.create=t=>new Ue({checks:[],typeName:S.ZodBigInt,coerce:t?.coerce??!1,...C(t)});var Fe=class extends A{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.boolean,received:r.parsedType}),v}return q(e.data)}};Fe.create=t=>new Fe({typeName:S.ZodBoolean,coerce:t?.coerce||!1,...C(t)});var He=class t extends A{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:g.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_date}),v}let r=new G,a;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):E.assertNever(i);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:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.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}};He.create=t=>new He({checks:[],coerce:t?.coerce||!1,typeName:S.ZodDate,...C(t)});var ht=class extends A{_parse(e){if(this._getType(e)!==g.symbol){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.symbol,received:r.parsedType}),v}return q(e.data)}};ht.create=t=>new ht({typeName:S.ZodSymbol,...C(t)});var Be=class extends A{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.undefined,received:r.parsedType}),v}return q(e.data)}};Be.create=t=>new Be({typeName:S.ZodUndefined,...C(t)});var We=class extends A{_parse(e){if(this._getType(e)!==g.null){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.null,received:r.parsedType}),v}return q(e.data)}};We.create=t=>new We({typeName:S.ZodNull,...C(t)});var Ee=class extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return q(e.data)}};Ee.create=t=>new Ee({typeName:S.ZodAny,...C(t)});var ye=class extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return q(e.data)}};ye.create=t=>new ye({typeName:S.ZodUnknown,...C(t)});var se=class extends A{_parse(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:g.never,received:n.parsedType}),v}};se.create=t=>new se({typeName:S.ZodNever,...C(t)});var mt=class extends A{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.void,received:r.parsedType}),v}return q(e.data)}};mt.create=t=>new mt({typeName:S.ZodVoid,...C(t)});var xe=class t extends A{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),a=this._def;if(n.parsedType!==g.array)return f(n,{code:m.invalid_type,expected:g.array,received:n.parsedType}),v;if(a.exactLength!==null){let o=n.data.length>a.exactLength.value,s=n.data.length<a.exactLength.value;(o||s)&&(f(n,{code:o?m.too_big:m.too_small,minimum:s?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(f(n,{code:m.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(f(n,{code:m.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,s)=>a.type._parseAsync(new ae(n,o,n.path,s)))).then(o=>G.mergeArray(r,o));let i=[...n.data].map((o,s)=>a.type._parseSync(new ae(n,o,n.path,s)));return G.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};xe.create=(t,e)=>new xe({type:t,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...C(e)});function pt(t){if(t instanceof X){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=re.create(pt(r))}return new X({...t._def,shape:()=>e})}else return t instanceof xe?new xe({...t._def,type:pt(t.element)}):t instanceof re?re.create(pt(t.unwrap())):t instanceof ue?ue.create(pt(t.unwrap())):t instanceof ce?ce.create(t.items.map(e=>pt(e))):t}var X=class t extends A{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=E.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==g.object){let d=this._getOrReturnCtx(e);return f(d,{code:m.invalid_type,expected:g.object,received:d.parsedType}),v}let{status:r,ctx:a}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof se&&this._def.unknownKeys==="strip"))for(let d in a.data)o.includes(d)||s.push(d);let c=[];for(let d of o){let u=i[d],p=a.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new ae(a,p,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof se){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(d==="strict")s.length>0&&(f(a,{code:m.unrecognized_keys,keys:s}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let u of s){let p=a.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new ae(a,p,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let d=[];for(let u of c){let p=await u.key,h=await u.value;d.push({key:p,value:h,alwaysSet:u.alwaysSet})}return d}).then(d=>G.mergeObjectSync(r,d)):G.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let a=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:b.errToObj(e).message??a}:{message:a}}}:{}})}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:S.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 E.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 E.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return pt(this)}partial(e){let n={};for(let r of E.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?n[r]=a:n[r]=a.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of E.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof re;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Vr(E.objectKeys(this.shape))}};X.create=(t,e)=>new X({shape:()=>t,unknownKeys:"strip",catchall:se.create(),typeName:S.ZodObject,...C(e)});X.strictCreate=(t,e)=>new X({shape:()=>t,unknownKeys:"strict",catchall:se.create(),typeName:S.ZodObject,...C(e)});X.lazycreate=(t,e)=>new X({shape:t,unknownKeys:"strip",catchall:se.create(),typeName:S.ZodObject,...C(e)});var Ve=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function a(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;let o=i.map(s=>new Y(s.ctx.common.issues));return f(n,{code:m.invalid_union,unionErrors:o}),v}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(a);{let i,o=[];for(let c of r){let d={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map(c=>new Y(c));return f(n,{code:m.invalid_union,unionErrors:s}),v}}get options(){return this._def.options}};Ve.create=(t,e)=>new Ve({options:t,typeName:S.ZodUnion,...C(e)});var be=t=>t instanceof Je?be(t.schema):t instanceof ie?be(t.innerType()):t instanceof Ge?[t.value]:t instanceof qe?t.options:t instanceof Ke?E.objectValues(t.enum):t instanceof Ye?be(t._def.innerType):t instanceof Be?[void 0]:t instanceof We?[null]:t instanceof re?[void 0,...be(t.unwrap())]:t instanceof ue?[null,...be(t.unwrap())]:t instanceof zt||t instanceof Qe?be(t.unwrap()):t instanceof Xe?be(t._def.innerType):[],an=class t extends A{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return f(n,{code:m.invalid_type,expected:g.object,received:n.parsedType}),v;let r=this.discriminator,a=n.data[r],i=this.optionsMap.get(a);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let a=new Map;for(let i of n){let o=be(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of o){if(a.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);a.set(s,i)}}return new t({typeName:S.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,...C(r)})}};function Ln(t,e){let n=de(t),r=de(e);if(t===e)return{valid:!0,data:t};if(n===g.object&&r===g.object){let a=E.objectKeys(e),i=E.objectKeys(t).filter(s=>a.indexOf(s)!==-1),o={...t,...e};for(let s of i){let c=Ln(t[s],e[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(n===g.array&&r===g.array){if(t.length!==e.length)return{valid:!1};let a=[];for(let i=0;i<t.length;i++){let o=t[i],s=e[i],c=Ln(o,s);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===g.date&&r===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Ze=class extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),a=(i,o)=>{if(nn(i)||nn(o))return v;let s=Ln(i.value,o.value);return s.valid?((rn(i)||rn(o))&&n.dirty(),{status:n.value,value:s.data}):(f(r,{code:m.invalid_intersection_types}),v)};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(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Ze.create=(t,e,n)=>new Ze({left:t,right:e,typeName:S.ZodIntersection,...C(n)});var ce=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return f(r,{code:m.invalid_type,expected:g.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return f(r,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new ae(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>G.mergeArray(n,o)):G.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};ce.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ce({items:t,typeName:S.ZodTuple,rest:null,...C(e)})};var on=class t extends A{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!==g.object)return f(r,{code:m.invalid_type,expected:g.object,received:r.parsedType}),v;let a=[],i=this._def.keyType,o=this._def.valueType;for(let s in r.data)a.push({key:i._parse(new ae(r,s,r.path,s)),value:o._parse(new ae(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?G.mergeObjectAsync(n,a):G.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof A?new t({keyType:e,valueType:n,typeName:S.ZodRecord,...C(r)}):new t({keyType:Pe.create(),valueType:e,typeName:S.ZodRecord,...C(n)})}},ft=class extends A{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!==g.map)return f(r,{code:m.invalid_type,expected:g.map,received:r.parsedType}),v;let a=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([s,c],d)=>({key:a._parse(new ae(r,s,r.path,[d,"key"])),value:i._parse(new ae(r,c,r.path,[d,"value"]))}));if(r.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of o){let d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return v;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}})}else{let s=new Map;for(let c of o){let d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return v;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}}}};ft.create=(t,e,n)=>new ft({valueType:e,keyType:t,typeName:S.ZodMap,...C(n)});var gt=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return f(r,{code:m.invalid_type,expected:g.set,received:r.parsedType}),v;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(f(r,{code:m.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(f(r,{code:m.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let d=new Set;for(let u of c){if(u.status==="aborted")return v;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}let s=[...r.data.values()].map((c,d)=>i._parse(new ae(r,c,r.path,d)));return r.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(e,n){return new t({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};gt.create=(t,e)=>new gt({valueType:t,minSize:null,maxSize:null,typeName:S.ZodSet,...C(e)});var sn=class t extends A{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.function)return f(n,{code:m.invalid_type,expected:g.function,received:n.parsedType}),v;function r(s,c){return Lt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ct(),ge].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:c}})}function a(s,c){return Lt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ct(),ge].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Re){let s=this;return q(async function(...c){let d=new Y([]),u=await s._def.args.parseAsync(c,i).catch(y=>{throw d.addIssue(r(c,y)),d}),p=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(p,i).catch(y=>{throw d.addIssue(a(p,y)),d})})}else{let s=this;return q(function(...c){let d=s._def.args.safeParse(c,i);if(!d.success)throw new Y([r(c,d.error)]);let u=Reflect.apply(o,this,d.data),p=s._def.returns.safeParse(u,i);if(!p.success)throw new Y([a(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:ce.create(e).rest(ye.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||ce.create([]).rest(ye.create()),returns:n||ye.create(),typeName:S.ZodFunction,...C(r)})}},Je=class extends A{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})}};Je.create=(t,e)=>new Je({getter:t,typeName:S.ZodLazy,...C(e)});var Ge=class extends A{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ge.create=(t,e)=>new Ge({value:t,typeName:S.ZodLiteral,...C(e)});function Vr(t,e){return new qe({values:t,typeName:S.ZodEnum,...C(e)})}var qe=class t extends A{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:E.joinValues(r),received:n.parsedType,code:m.invalid_type}),v}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 f(n,{received:n.data,code:m.invalid_enum_value,options:r}),v}return q(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})}};qe.create=Vr;var Ke=class extends A{_parse(e){let n=E.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){let a=E.objectValues(n);return f(r,{expected:E.joinValues(a),received:r.parsedType,code:m.invalid_type}),v}if(this._cache||(this._cache=new Set(E.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let a=E.objectValues(n);return f(r,{received:r.data,code:m.invalid_enum_value,options:a}),v}return q(e.data)}get enum(){return this._def.values}};Ke.create=(t,e)=>new Ke({values:t,typeName:S.ZodNativeEnum,...C(e)});var Re=class extends A{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.promise&&n.common.async===!1)return f(n,{code:m.invalid_type,expected:g.promise,received:n.parsedType}),v;let r=n.parsedType===g.promise?n.data:Promise.resolve(n.data);return q(r.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Re.create=(t,e)=>new Re({type:t,typeName:S.ZodPromise,...C(e)});var ie=class extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:o=>{f(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){let o=a.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async s=>{if(n.value==="aborted")return v;let c=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"?ze(c.value):n.value==="dirty"?ze(c.value):c});{if(n.value==="aborted")return v;let s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?ze(s.value):n.value==="dirty"?ze(s.value):s}}if(a.type==="refinement"){let o=s=>{let c=a.refinement(s,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:(s.status==="dirty"&&n.dirty(),o(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?v:(s.status==="dirty"&&n.dirty(),o(s.value).then(()=>({status:n.value,value:s.value}))))}if(a.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ie(o))return v;let s=a.transform(o.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ie(o)?Promise.resolve(a.transform(o.value,i)).then(s=>({status:n.value,value:s})):v);E.assertNever(a)}};ie.create=(t,e,n)=>new ie({schema:t,typeName:S.ZodEffects,effect:e,...C(n)});ie.createWithPreprocess=(t,e,n)=>new ie({schema:e,effect:{type:"preprocess",transform:t},typeName:S.ZodEffects,...C(n)});var re=class extends A{_parse(e){return this._getType(e)===g.undefined?q(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};re.create=(t,e)=>new re({innerType:t,typeName:S.ZodOptional,...C(e)});var ue=class extends A{_parse(e){return this._getType(e)===g.null?q(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ue.create=(t,e)=>new ue({innerType:t,typeName:S.ZodNullable,...C(e)});var Ye=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ye.create=(t,e)=>new Ye({innerType:t,typeName:S.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...C(e)});var Xe=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ut(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Y(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Y(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Xe.create=(t,e)=>new Xe({innerType:t,typeName:S.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...C(e)});var bt=class extends A{_parse(e){if(this._getType(e)!==g.nan){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}};bt.create=t=>new bt({typeName:S.ZodNaN,...C(t)});var Vo=Symbol("zod_brand"),zt=class extends A{_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}},Mt=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(n.dirty(),ze(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:S.ZodPipeline})}},Qe=class extends A{_parse(e){let n=this._def.innerType._parse(e),r=a=>(Ie(a)&&(a.value=Object.freeze(a.value)),a);return ut(n)?n.then(a=>r(a)):r(n)}unwrap(){return this._def.innerType}};Qe.create=(t,e)=>new Qe({innerType:t,typeName:S.ZodReadonly,...C(e)});function Fr(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Zr(t,e={},n){return t?Ee.create().superRefine((r,a)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let s=Fr(e,r),c=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:c})}});if(!i){let o=Fr(e,r),s=o.fatal??n??!0;a.addIssue({code:"custom",...o,fatal:s})}}):Ee.create()}var Zo={object:X.lazycreate},S;(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"})(S||(S={}));var Jo=(t,e={message:`Input not instance of ${t.name}`})=>Zr(n=>n instanceof t,e),Jr=Pe.create,Gr=Me.create,Go=bt.create,qo=Ue.create,qr=Fe.create,Ko=He.create,Yo=ht.create,Xo=Be.create,Qo=We.create,es=Ee.create,ts=ye.create,ns=se.create,rs=mt.create,as=xe.create,is=X.create,os=X.strictCreate,ss=Ve.create,ls=an.create,ds=Ze.create,cs=ce.create,us=on.create,ps=ft.create,hs=gt.create,ms=sn.create,fs=Je.create,gs=Ge.create,bs=qe.create,ys=Ke.create,xs=Re.create,ks=ie.create,ws=re.create,vs=ue.create,Ss=ie.createWithPreprocess,_s=Mt.create,Cs=()=>Jr().optional(),Ts=()=>Gr().optional(),As=()=>qr().optional(),Is={string:(t=>Pe.create({...t,coerce:!0})),number:(t=>Me.create({...t,coerce:!0})),boolean:(t=>Fe.create({...t,coerce:!0})),bigint:(t=>Ue.create({...t,coerce:!0})),date:(t=>He.create({...t,coerce:!0}))};var Ps=v;var zn=l.object({id:l.string()}),Es=l.enum(["top","right","bottom","left","auto"]).default("auto"),Mn=l.enum(["left","middle","right"]),Rs=Mn.default("left"),Kr=l.object({label:l.string().optional(),hidden:l.boolean().default(!1)}),$s={background:l.string().optional(),textColor:l.string().optional(),borderRadius:l.string().optional(),textAlign:Rs,anchor:Es,showNavigation:l.boolean().default(!0),prevButton:Kr.optional(),nextButton:Kr.optional()},Ds=l.enum(["pointer","callout","area"]),js=l.discriminatedUnion("type",[l.object({type:l.literal("html-element"),alphaId:l.string().min(1)})]),Os=zn.extend({type:l.literal("message"),variant:Ds.default("callout"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1).optional(),h:l.number().min(0).max(1).optional(),text:l.string().optional(),target:js.optional(),advancesStep:l.boolean().default(!0),...$s}),Ns=zn.extend({type:l.literal("blur"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1),h:l.number().min(0).max(1),intensity:l.number().min(0).max(20).default(8)}),Ls=zn.extend({type:l.literal("text"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),text:l.string(),fontSize:l.number().positive().default(16),color:l.string().optional()}),Yr=l.discriminatedUnion("type",[Os,Ns,Ls]),Xr=new Set(["message","blur","text"]),Qr=l.object({type:l.string()}).passthrough();function ea(t){return typeof t=="object"&&t!==null?t.type:void 0}var ta=l.any().superRefine((t,e)=>{let a=(Xr.has(ea(t))?Yr:Qr).safeParse(t);if(!a.success)for(let i of a.error.issues)e.addIssue(i)}).transform(t=>(Xr.has(ea(t))?Yr:Qr).parse(t));var na=l.object({label:l.string().min(1),href:l.string().refine(t=>/^(https?:|mailto:)/i.test(t),"href must be an http(s) or mailto URL")}),Un=l.object({logo:l.string().min(1).optional(),name:l.string().min(1).optional(),logoHref:l.string().refine(t=>/^(https?:|mailto:)/i.test(t),"logoHref must be an http(s) or mailto URL").optional(),favicon:l.string().min(1).optional(),cta:na.optional(),secondaryCta:na.optional(),watermark:l.boolean().optional()}),ra=Un.omit({favicon:!0});var zs=l.object({type:l.literal("next")}),Ms=l.object({type:l.literal("prev")}),Us=l.object({type:l.literal("step"),stepId:l.string().min(1)}),Fs=l.object({type:l.literal("chapter"),chapterId:l.string().min(1)}),Hs=l.object({type:l.literal("url"),href:l.string().min(1),target:l.enum(["_self","_blank"]).default("_blank")}),Bs=l.object({type:l.literal("restart")}),Ws=l.discriminatedUnion("type",[zs,Ms,Us,Fs,Hs,Bs]),Vs=l.enum(["shimmer"]),ln=l.object({label:l.string().min(1),action:Ws.default({type:"next"}),animation:Vs.optional(),background:l.string().optional(),textColor:l.string().optional()});var Zs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Fn=/^[A-Za-z0-9_-]{12}$/;function Js(t){let e=globalThis.crypto;if(!e||typeof e.getRandomValues!="function")throw new Error("generateDemoId requires globalThis.crypto.getRandomValues (Node 19+, browsers, or edge runtime).");e.getRandomValues(t)}function te(){let t=new Uint8Array(12);Js(t);let e="";for(let n of t)e+=Zs.charAt(n&63);return e}function aa(t){return typeof t=="string"&&Fn.test(t)}function ia(t){return String(t+1).padStart(4,"0")}function oa(t){return`snap-${t.toString().padStart(3,"0")}`}function dn(t){let e=((t??"").toLowerCase().split(";")[0]??"").trim();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("font/")||e.includes("font")||e.includes("woff")?"font":"other"}function Hn(t){if(!t)return"";let e=t.replace(/^(?:tree\s*item|menu\s*item|menuitem|list\s*item|tab(?:\s*panel)?|button|link|option|region|combobox|radio|checkbox|switch|dialog|row|cell|columnheader|rowheader|navigation|article|banner|main|complementary|contentinfo)\s*:?\s+/i,"").trim();return(e.split(/\r?\n/).map(r=>r.trim()).find(Boolean)??e).replace(/\s+/g," ").trim().slice(0,48)}function Bn(t){let{stepId:e,assetId:n,posterAssetId:r,kind:a,isLast:i}=t,o=`asset:${n}`,s=a==="video"?{type:"video",src:o,posterSrc:r?`asset:${r}`:void 0,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,alt:t.title,sourceUrl:t.sourceUrl??"",title:t.title,autoplay:!0,muted:!0,objectFit:"cover"}:{type:"image",src:o,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,alt:t.title,sourceUrl:t.sourceUrl??"",title:t.title,objectFit:"cover"},c=t.click,d=[];if(c){let h=Hn(c.label);d.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:c.x,y:c.y,text:h?`Click on "${h}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}else d.push({id:`${e}_callout`,type:"message",variant:"callout",x:.5,y:.5,text:i?"End of walkthrough":"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});let u=!!c&&!(c.x===0&&c.y===0),p=a==="image"&&t.autoApplyZoom===!0&&u?{zoom:1.35,x:Number(Math.max(0,Math.min(1,c.x)).toFixed(4)),y:Number(Math.max(0,Math.min(1,c.y)).toFixed(4))}:void 0;return{id:e,kind:"content",background:s,...p?{transform:p}:{},annotations:d,advance:{trigger:"click"}}}function sa(t){let{stepId:e,htmlPath:n,click:r}=t,a=[];if(r?.alphaId)a.push({id:`${e}_area`,type:"message",variant:"area",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),w:0,h:0,text:Hn(r.label)||"Click here",target:{type:"html-element",alphaId:r.alphaId},anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});else if(r){let i=Hn(r.label);a.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),text:i?`Click on "${i}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}return{id:e,kind:"content",background:{type:"html",path:n,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,zoom:1,scroll:t.scroll,sourceUrl:t.sourceUrl??"",title:t.sourceUrl??""},annotations:a,advance:{trigger:"click"}}}function Gs(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wn(t,e){let n=t;for(let[r,a]of e){let i=Gs(r);n=n.replace(new RegExp(`(?:\\.\\./)*assets/${i}`,"g"),a),n=n.replace(new RegExp(`assets/${i}`,"g"),a)}return n}function qs(t){return`<script data-inkly-replay-scroll>(()=>{const c=${JSON.stringify(t).replace(/<\/(script)/gi,"<\\/$1")};function r(){const d=document.documentElement,b=document.body;const vw=innerWidth||d.clientWidth||0;const vh=innerHeight||d.clientHeight||0;const mx=Math.max(0,Math.max(d.scrollWidth,b?b.scrollWidth:0)-vw);const my=Math.max(0,Math.max(d.scrollHeight,b?b.scrollHeight:0)-vh);const x=c.maxX>0&&mx>0?c.x/c.maxX*mx:c.x;const y=c.maxY>0&&my>0?c.y/c.maxY*my:c.y;scrollTo(Math.max(0,x),Math.max(0,y));}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",r,{once:true});r();requestAnimationFrame(r);setTimeout(r,120);setTimeout(r,500);})();</script>`}function la(t,e){let n=qs(e);return/<\/body\s*>/i.test(t)?t.replace(/<\/body\s*>/i,`${n}</body>`):`${t}${n}`}function da(t,e){if(!e||/data-inkly-document-css|document\.css/i.test(t))return t;let n='<link rel="stylesheet" href="./document.css?draft=1" data-inkly-document-css>';return/<\/head\s*>/i.test(t)?t.replace(/<\/head\s*>/i,`${n}</head>`):`${n}${t}`}var ca=l.object({id:l.string(),text:l.string(),start:l.number().nonnegative().optional(),end:l.number().nonnegative().optional()});var Ks=l.enum(["screenshot","image","video","audio","font","other"]),Ys=l.object({id:l.string().min(1),path:l.string().min(1).optional(),uri:l.string().min(1).optional(),sha256:l.string().regex(/^[0-9a-f]{64}$/),kind:Ks,contentType:l.string().min(1).optional(),publicUrl:l.string().min(1).optional(),cdnPath:l.string().min(1).optional(),size:l.number().int().nonnegative().optional(),createdAt:l.string().min(1).optional(),updatedAt:l.string().min(1).optional(),viewport:l.object({w:l.number().int().positive(),h:l.number().int().positive()}).optional()}),yt=l.object({version:l.literal(1),assets:l.array(Ys),screens:l.array(l.unknown()).optional()});var Vn=l.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"}),Xs=l.enum(["color","image","glassmorphism"]),ua=l.object({type:Xs,color:Vn.optional(),from:Vn.optional(),to:Vn.optional(),src:l.string().min(1).optional(),alt:l.string().optional(),intensity:l.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:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:l.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),pa=l.object({src:l.string(),alt:l.string().optional()});var Zn=l.object({src:l.string().min(1),duration:l.number().positive().optional()});var Qs=l.enum(["text","dropdown"]),el=l.object({value:l.string().min(1),label:l.string().min(1)}),tl=l.object({id:l.string(),label:l.string(),type:Qs.default("text"),placeholder:l.string().optional(),required:l.boolean().default(!1),options:l.array(el).optional()}).superRefine((t,e)=>{t.type==="dropdown"&&(!t.options||t.options.length===0)&&e.addIssue({code:l.ZodIssueCode.custom,message:"Dropdown field requires at least one option.",path:["options"]})}),ba=l.object({src:l.string().min(1),alt:l.string().optional(),height:l.number().int().positive().optional()}),nl=l.enum(["left","right","top"]),rl=l.enum(["standard","hero"]),ya=l.object({src:l.string().min(1),alt:l.string().optional(),naturalWidth:l.number().positive().optional(),naturalHeight:l.number().positive().optional(),position:nl.default("right"),layout:rl.default("hero")}),al=l.object({type:l.literal("headline"),id:l.string(),logo:ba.optional(),image:ya.optional(),title:l.string(),titleColor:l.string().optional(),description:l.string().optional(),descriptionColor:l.string().optional(),textAlign:Mn.optional(),cta:ln.optional(),secondaryCta:ln.optional()}),il=l.object({type:l.literal("form"),id:l.string(),logo:ba.optional(),image:ya.optional(),title:l.string().optional(),description:l.string().optional(),fields:l.array(tl).min(1),submit:ln.default({label:"Submit",action:{type:"next"}})}),ol="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",sl="camera; microphone; fullscreen; payment; clipboard-write",ll=l.object({type:l.literal("embed"),id:l.string(),src:l.string(),iframeTitle:l.string().optional(),sandbox:l.string().default(ol),allow:l.string().default(sl)}),dl=l.object({type:l.literal("custom"),id:l.string(),name:l.string().min(1),data:l.record(l.unknown()).optional()}),ha=l.discriminatedUnion("type",[al,il,ll,dl]),ma=new Set(["headline","form","embed","custom"]),fa=l.object({type:l.string()}).passthrough();function ga(t){return typeof t=="object"&&t!==null?t.type:void 0}var xa=l.any().superRefine((t,e)=>{let a=(ma.has(ga(t))?ha:fa).safeParse(t);if(!a.success)for(let i of a.error.issues)e.addIssue(i)}).transform(t=>(ma.has(ga(t))?ha:fa).parse(t));var ka=l.enum(["contain","cover","fill"]),wa=l.enum(["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"]),cl=l.object({type:l.literal("image"),src:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),objectFit:ka.optional(),objectPosition:wa.optional()}),ul=l.object({type:l.literal("video"),src:l.string().min(1),posterSrc:l.string().min(1).optional(),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),autoplay:l.boolean().default(!0),muted:l.boolean().default(!0),objectFit:ka.optional(),objectPosition:wa.optional()}),pl=l.object({x:l.number().nonnegative().default(0),y:l.number().nonnegative().default(0),maxX:l.number().nonnegative().default(0),maxY:l.number().nonnegative().default(0)}),hl=l.object({type:l.literal("html"),path:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),zoom:l.number().positive().default(1),scroll:pl.default({x:0,y:0,maxX:0,maxY:0}),sourceUrl:l.string().optional(),title:l.string().optional()}),ml=l.discriminatedUnion("type",[cl,ul,hl]),fl=l.object({zoom:l.number().min(1).default(1),x:l.number().min(0).max(1).default(.5),y:l.number().min(0).max(1).default(.5)}),gl=l.object({trigger:l.enum(["auto","click"]).default("auto")}).default({trigger:"auto"}),bl=l.object({kind:l.literal("content").default("content"),id:l.string(),label:l.string().optional(),duration:l.number().positive().optional(),background:ml,script:l.string().optional(),voiceover:Zn.optional(),transform:fl.optional(),advance:gl,annotations:l.array(ta).default([]),captions:l.array(ca).optional()}).passthrough(),yl=l.object({kind:l.literal("cover"),id:l.string(),label:l.string().optional(),widgets:l.array(xa).length(1),background:ua.optional(),backgroundImage:pa.optional(),backgroundDim:l.number().min(0).max(1).optional(),script:l.string().optional(),voiceover:Zn.optional(),duration:l.number().positive().optional(),advance:l.object({trigger:l.enum(["auto","click"]).default("click")}).default({trigger:"click"})}).passthrough(),va=l.discriminatedUnion("kind",[bl,yl]);var xl=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,Sa=l.string().regex(xl,"must be a hex color like #5b3df5"),cn=l.object({primary:Sa.optional(),secondary:Sa.optional(),font:l.string().min(1).optional(),radius:l.string().min(1).optional()}).partial();var un=l.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"}),kl=l.object({id:l.string(),title:l.string(),stepIds:l.array(l.string()).min(1)}),wl=l.object({hideHeader:l.boolean().default(!1),hideControls:l.boolean().default(!1),controls:l.enum(["full","minimal","hidden"]).optional(),showHubBreadcrumb:l.boolean().default(!1),mobileFooterMessage:l.boolean().default(!0),autoplay:l.boolean().default(!1)}),vl=l.object({width:l.number().positive(),height:l.number().positive()}),Sl=l.enum(["public","private"]),_l=l.enum(["none","color","image"]),Cl=l.object({type:_l,color:un.optional(),from:un.optional(),to:un.optional(),src:l.string().min(1).optional(),alt:l.string().optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,r=!!t.from&&!!t.to;!n&&!r&&e.addIssue({code:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:l.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),et=l.object({id:l.string().regex(Fn,{message:"must be a 12-character URL-safe demo id (see generateDemoId)"}),version:l.number().int().min(1),title:l.string().optional(),subtitle:l.string().optional(),runtime:l.string().min(1).optional(),visibility:Sl.default("public"),backgroundColor:un.optional(),background:Cl.optional(),theme:l.object({preset:l.string().min(1).optional(),tokens:cn.optional(),brand:ra.optional()}).optional(),chrome:wl.default({}),aspectRatio:vl.optional(),chapters:l.array(kl).default([]),steps:l.array(va).min(1)}).passthrough().superRefine((t,e)=>{let n=new Set(t.steps.map(a=>a.id)),r=new Set(t.chapters.map(a=>a.id));t.chapters.forEach((a,i)=>{a.stepIds.forEach(o=>{n.has(o)||e.addIssue({code:l.ZodIssueCode.custom,path:["chapters",i,"stepIds"],message:`Chapter "${a.id}" references unknown step "${o}"`})})}),t.steps.forEach((a,i)=>{a.kind==="cover"&&a.widgets.forEach((o,s)=>{o.type==="headline"&&["cta","secondaryCta"].forEach(c=>{let d=o[c]?.action;d&&(d.type==="step"&&!n.has(d.stepId)&&e.addIssue({code:l.ZodIssueCode.custom,path:["steps",i,"widgets",s,c,"action","stepId"],message:`Widget "${o.id}" CTA targets unknown step "${d.stepId}"`}),d.type==="chapter"&&!r.has(d.chapterId)&&e.addIssue({code:l.ZodIssueCode.custom,path:["steps",i,"widgets",s,c,"action","chapterId"],message:`Widget "${o.id}" CTA targets unknown chapter "${d.chapterId}"`}))})})})});function pn(t){return et.parse(t)}function xt(t){let e=typeof t=="object"&&t!==null?t:{},n=aa(e.id),r=n?e:{...e,id:te()};return{config:et.parse(r),changed:!n}}function _a(t){let e=new Map;t.forEach((r,a)=>{let i=e.get(r.id);i?i.push({entry:r,index:a}):e.set(r.id,[{entry:r,index:a}])});let n=[];for(let r of e.values()){if(r.length<2)continue;let a=[...r].sort((o,s)=>o.entry.updatedAt!==s.entry.updatedAt?o.entry.updatedAt-s.entry.updatedAt:o.index-s.index),[,...i]=a;for(let{entry:o}of i)n.push({entry:o,newId:te()})}return n}var Jn=l.enum(["sidebar","tabs"]),Tl=l.object({name:l.string().min(1),description:l.string().min(1).optional(),icon:l.string().min(1).optional(),demos:l.array(l.string().min(1))}),pe=l.object({$schema:l.string().optional(),name:l.string().min(1),runtime:l.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:l.string().min(1).optional(),layout:Jn.optional(),theme:l.string().min(1).optional(),tokens:cn.optional(),brand:Un.optional(),title:l.string().min(1).optional(),subtitle:l.string().min(1).optional(),collections:l.array(Tl).optional()});function Ca({slug:t,config:e,resolveAssetSrc:n}){let r=e.title??e.id??t;return{slug:t,title:r,description:Al(e,r),thumbnail:El(e,r,n),visibility:e.visibility}}function hn(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function Al(t,e){if(t.subtitle?.trim())return hn(t.subtitle.trim(),120);for(let n of t.steps){if(n.kind!=="content")continue;let r=n.captions?.[0]?.text;if(r&&r.trim())return hn(r.trim(),120);break}for(let n of t.steps)if(n.kind==="cover"){for(let r of n.widgets)if(r.type==="headline"&&r.description&&r.description.trim())return hn(r.description.trim(),120)}return hn(`Explore the ${e} workflow.`,120)}function Il(t){return t.background?t.background.type==="image":t.backgroundImage?!0:t.widgets.some(e=>e.type==="headline"?!!e.title:e.type==="embed"?!!e.src:e.type==="form")}function Gn(t,e){return t?e?e(t):t:null}function Pl(t,e){if(!e)return t;let n=t.widgets.map(o=>{if((o.type==="headline"||o.type==="form")&&o.image?.src){let s=e(o.image.src);return s&&s!==o.image.src?{...o,image:{...o.image,src:s}}:o}return o}),r=t.backgroundImage,a=t.background;if(a?.type==="image"&&a.src){let o=e(a.src);o&&o!==a.src&&(a={...a,src:o})}if(r?.src){let o=e(r.src);o&&o!==r.src&&(r={...r,src:o})}return!n.some((o,s)=>o!==t.widgets[s])&&a===t.background&&r===t.backgroundImage?t:{...t,widgets:n,background:a,backgroundImage:r}}function El(t,e,n){let r=t.steps[0];if(r){if(r.kind==="cover"&&Il(r))return{kind:"cover",cover:Pl(r,n),themeTokens:t.theme?.tokens};if(r.kind==="content"){let a=r.background;if(a?.type==="image"){let i=Gn(a.src,n);if(i)return{kind:"image",src:i}}else if(a?.type==="video"){let i=Gn(a.posterSrc,n);if(i)return{kind:"image",src:i};let o=Gn(a.src,n);if(o)return{kind:"video",src:o}}else if(a?.type==="html")return{kind:"html",path:a.path,naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight,zoom:a.zoom,scroll:a.scroll}}}return{kind:"placeholder",title:e}}function Rl(t){return!t||t==="null"?"":t.replace(/\/+$/,"")}function $l(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dl(t){return String(t||"").replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"")}function qn(t){let e=Dl(t);return/\/index\.html$/i.test(e)||/^index\.html$/i.test(e)?e.replace(/index\.html$/i,"document.css"):/\.html?$/i.test(e)?e.replace(/\.html?$/i,".css"):null}function jl(t){return t.replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?content-security-policy\b)[^>]*>/gi,"")}var Ol=/\s+(?:href|xlink:href|target|rel|download|ping|referrerpolicy|data-inkly-href)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?/gi;function Ut(t){return String(t||"").replace(/<(a|area)\b[^>]*>/gi,e=>e.replace(Ol,""))}function tt(t,e={}){let n=Rl(e.resourceOrigin),r=String(t||"");return n?r.replace(new RegExp(`(^|["'\\(\\s,=])${$l("/api/hubs/")}`,"g"),`$1${n}/api/hubs/`):r}function Nl(t){return jl(t).replace(/<style\b(?=[^>]*\bdata-inkly-document-css\b)[\s\S]*?<\/style>/gi,"").replace(/<link\b(?=[^>]*\bdata-inkly-document-css\b)[^>]*>/gi,"").replace(/<link\b(?=[^>]*\brel\s*=\s*["']?stylesheet\b)(?=[^>]*\bhref\s*=\s*["']?[^"'\s>]*document\.css(?:\?draft=1)?)[^>]*>/gi,"")}function Ta({htmlPath:t,html:e,css:n,cssHref:r,resourceOrigin:a}){let i=Nl(Ut(e)),o=qn(t)!=null,s=n?.trim()??"";if(o&&s){let d=`<style data-inkly-document-css>
|
|
3
|
-
${
|
|
4
|
-
</style>`,u=/<\/head\s*>/i.test(i)?i.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${i}`;return
|
|
2
|
+
var Eo=Object.defineProperty;var Ro=(t,e)=>{for(var n in e)Eo(t,n,{get:e[n],enumerable:!0})};import dh from"mri";import{existsSync as Kr,statSync as ch}from"fs";import{isAbsolute as uh,join as mo,resolve as ph}from"path";import{Buffer as Rd}from"buffer";import{mkdir as Ka,writeFile as $d,access as Dd}from"fs/promises";import{dirname as jd,join as Od,resolve as Nd,sep as Ya}from"path";var l={};Ro(l,{BRAND:()=>rs,DIRTY:()=>We,EMPTY_PATH:()=>Oo,INVALID:()=>S,NEVER:()=>Fs,OK:()=>q,ParseStatus:()=>Z,Schema:()=>A,ZodAny:()=>De,ZodArray:()=>Se,ZodBigInt:()=>Je,ZodBoolean:()=>Ze,ZodBranded:()=>Vt,ZodCatch:()=>at,ZodDate:()=>Ge,ZodDefault:()=>rt,ZodDiscriminatedUnion:()=>cn,ZodEffects:()=>se,ZodEnum:()=>tt,ZodError:()=>Q,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>pn,ZodIntersection:()=>Xe,ZodIssueCode:()=>m,ZodLazy:()=>Qe,ZodLiteral:()=>et,ZodMap:()=>wt,ZodNaN:()=>St,ZodNativeEnum:()=>nt,ZodNever:()=>de,ZodNull:()=>Ke,ZodNullable:()=>fe,ZodNumber:()=>Ve,ZodObject:()=>ee,ZodOptional:()=>ie,ZodParsedType:()=>y,ZodPipeline:()=>Jt,ZodPromise:()=>je,ZodReadonly:()=>it,ZodRecord:()=>un,ZodSchema:()=>A,ZodSet:()=>vt,ZodString:()=>$e,ZodSymbol:()=>xt,ZodTransformer:()=>se,ZodTuple:()=>me,ZodType:()=>A,ZodUndefined:()=>qe,ZodUnion:()=>Ye,ZodUnknown:()=>ve,ZodVoid:()=>kt,addIssueToContext:()=>g,any:()=>ps,array:()=>gs,bigint:()=>ss,boolean:()=>da,coerce:()=>Us,custom:()=>oa,date:()=>ls,datetimeRegex:()=>aa,defaultErrorMap:()=>ke,discriminatedUnion:()=>ks,effect:()=>$s,enum:()=>Ps,function:()=>Ts,getErrorMap:()=>gt,getParsedType:()=>he,instanceof:()=>is,intersection:()=>ws,isAborted:()=>ln,isAsync:()=>bt,isDirty:()=>dn,isValid:()=>Re,late:()=>as,lazy:()=>As,literal:()=>Is,makeIssue:()=>Wt,map:()=>_s,nan:()=>os,nativeEnum:()=>Es,never:()=>ms,null:()=>us,nullable:()=>js,number:()=>la,object:()=>bs,objectUtil:()=>Bn,oboolean:()=>Ms,onumber:()=>zs,optional:()=>Ds,ostring:()=>Ls,pipeline:()=>Ns,preprocess:()=>Os,promise:()=>Rs,quotelessJson:()=>$o,record:()=>Ss,set:()=>Cs,setErrorMap:()=>jo,strictObject:()=>ys,string:()=>sa,symbol:()=>ds,transformer:()=>$s,tuple:()=>vs,undefined:()=>cs,union:()=>xs,unknown:()=>hs,util:()=>P,void:()=>fs});var P;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{let i={};for(let o of a)i[o]=o;return i},t.getValidEnumValues=a=>{let i=t.objectKeys(a).filter(s=>typeof a[a[s]]!="number"),o={};for(let s of i)o[s]=a[s];return t.objectValues(o)},t.objectValues=a=>t.objectKeys(a).map(function(i){return a[i]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let i=[];for(let o in a)Object.prototype.hasOwnProperty.call(a,o)&&i.push(o);return i},t.find=(a,i)=>{for(let o of a)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(P||(P={}));var Bn;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Bn||(Bn={}));var y=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),he=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}};var m=P.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"]),$o=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Q=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(i){return i.message},r={_errors:[]},a=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let s=r,c=0;for(;c<o.path.length;){let d=o.path[c];c===o.path.length-1?(s[d]=s[d]||{_errors:[]},s[d]._errors.push(n(o))):s[d]=s[d]||{_errors:[]},s=s[d],c++}}};return a(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,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let a of this.issues)if(a.path.length>0){let i=a.path[0];n[i]=n[i]||[],n[i].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Q.create=t=>new Q(t);var Do=(t,e)=>{let n;switch(t.code){case m.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,P.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${P.joinValues(t.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${P.joinValues(t.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${P.joinValues(t.options)}, received '${t.received}'`;break;case m.invalid_arguments:n="Invalid function arguments";break;case m.invalid_return_type:n="Invalid function return type";break;case m.invalid_date:n="Invalid date";break;case m.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}"`:P.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case m.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 m.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 m.custom:n="Invalid input";break;case m.invalid_intersection_types:n="Intersection results could not be merged";break;case m.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=e.defaultError,P.assertNever(t)}return{message:n}},ke=Do;var Qr=ke;function jo(t){Qr=t}function gt(){return Qr}var Wt=t=>{let{data:e,path:n,errorMaps:r,issueData:a}=t,i=[...n,...a.path||[]],o={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let s="",c=r.filter(d=>!!d).slice().reverse();for(let d of c)s=d(o,{data:e,defaultError:s}).message;return{...a,path:i,message:s}},Oo=[];function g(t,e){let n=gt(),r=Wt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ke?void 0:ke].filter(a=>!!a)});t.common.issues.push(r)}var Z=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 a of n){if(a.status==="aborted")return S;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let a of n){let i=await a.key,o=await a.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let a of n){let{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return S;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},S=Object.freeze({status:"aborted"}),We=t=>({status:"dirty",value:t}),q=t=>({status:"valid",value:t}),ln=t=>t.status==="aborted",dn=t=>t.status==="dirty",Re=t=>t.status==="valid",bt=t=>typeof Promise<"u"&&t instanceof Promise;var x;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(x||(x={}));var oe=class{constructor(e,n,r,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=a}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}},ea=(t,e)=>{if(Re(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 Q(t.common.issues);return this._error=n,this._error}}};function T(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:a}=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:a}:{errorMap:(o,s)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??r??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:c??n??s.defaultError}},description:a}}var A=class{get description(){return this._def.description}_getType(e){return he(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:he(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Z,ctx:{common:e.parent.common,data:e.data,parsedType:he(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(bt(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:he(e)},a=this._parseSync({data:e,path:r.path,parent:r});return ea(r,a)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:he(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Re(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=>Re(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:he(e)},a=this._parse({data:e,path:r.path,parent:r}),i=await(bt(a)?a:Promise.resolve(a));return ea(r,i)}refine(e,n){let r=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,i)=>{let o=e(a),s=()=>i.addIssue({code:m.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(e,n){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof n=="function"?n(r,a):n),!1))}_refinement(e){return new se({schema:this,typeName:_.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 ie.create(this,this._def)}nullable(){return fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Se.create(this)}promise(){return je.create(this,this._def)}or(e){return Ye.create([this,e],this._def)}and(e){return Xe.create(this,e,this._def)}transform(e){return new se({...T(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new rt({...T(this._def),innerType:this,defaultValue:n,typeName:_.ZodDefault})}brand(){return new Vt({typeName:_.ZodBranded,type:this,...T(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new at({...T(this._def),innerType:this,catchValue:n,typeName:_.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Jt.create(this,e)}readonly(){return it.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},No=/^c[^\s-]{8,}$/i,Lo=/^[0-9a-z]+$/,zo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Mo=/^[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,Uo=/^[a-z0-9_-]{21}$/i,Fo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ho=/^[-+]?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)?)??$/,Bo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Wo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Wn,Vo=/^(?:(?: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])$/,Jo=/^(?:(?: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])$/,Zo=/^(([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]))$/,Go=/^(([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])$/,qo=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ko=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,na="((\\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])))",Yo=new RegExp(`^${na}$`);function ra(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 Xo(t){return new RegExp(`^${ra(t)}$`)}function aa(t){let e=`${na}T${ra(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 Qo(t,e){return!!((e==="v4"||!e)&&Vo.test(t)||(e==="v6"||!e)&&Zo.test(t))}function es(t,e){if(!Fo.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,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function ts(t,e){return!!((e==="v4"||!e)&&Jo.test(t)||(e==="v6"||!e)&&Go.test(t))}var $e=class t extends A{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let i=this._getOrReturnCtx(e);return g(i,{code:m.invalid_type,expected:y.string,received:i.parsedType}),S}let r=new Z,a;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),g(a,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),g(a,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,s=e.data.length<i.value;(o||s)&&(a=this._getOrReturnCtx(e,a),o?g(a,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&g(a,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Bo.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"email",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Wn||(Wn=new RegExp(Wo,"u")),Wn.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"emoji",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Mo.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"uuid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Uo.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"nanoid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")No.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"cuid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Lo.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"cuid2",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")zo.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"ulid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),g(a,{validation:"url",code:m.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"regex",code:m.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),g(a,{code:m.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),g(a,{code:m.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),g(a,{code:m.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?aa(i).test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{code:m.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Yo.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{code:m.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Xo(i).test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{code:m.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ho.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"duration",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Qo(e.data,i.version)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"ip",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?es(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"jwt",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?ts(e.data,i.version)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"cidr",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?qo.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"base64",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Ko.test(e.data)||(a=this._getOrReturnCtx(e,a),g(a,{validation:"base64url",code:m.invalid_string,message:i.message}),r.dirty()):P.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(a=>e.test(a),{validation:n,code:m.invalid_string,...x.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...x.errToObj(e)})}url(e){return this._addCheck({kind:"url",...x.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...x.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...x.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...x.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...x.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...x.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...x.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...x.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...x.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...x.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...x.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...x.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,...x.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,...x.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...x.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...x.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...x.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...x.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...x.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...x.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...x.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...x.errToObj(n)})}nonempty(e){return this.min(1,x.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}};$e.create=t=>new $e({checks:[],typeName:_.ZodString,coerce:t?.coerce??!1,...T(t)});function ns(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=n>r?n:r,i=Number.parseInt(t.toFixed(a).replace(".","")),o=Number.parseInt(e.toFixed(a).replace(".",""));return i%o/10**a}var Ve=class t extends A{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)!==y.number){let i=this._getOrReturnCtx(e);return g(i,{code:m.invalid_type,expected:y.number,received:i.parsedType}),S}let r,a=new Z;for(let i of this._def.checks)i.kind==="int"?P.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:m.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:m.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:m.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?ns(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),g(r,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:m.not_finite,message:i.message}),a.dirty()):P.assertNever(i);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,x.toString(n))}gt(e,n){return this.setLimit("min",e,!1,x.toString(n))}lte(e,n){return this.setLimit("max",e,!0,x.toString(n))}lt(e,n){return this.setLimit("max",e,!1,x.toString(n))}setLimit(e,n,r,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:x.toString(a)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:x.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:x.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.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"&&P.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)}};Ve.create=t=>new Ve({checks:[],typeName:_.ZodNumber,coerce:t?.coerce||!1,...T(t)});var Je=class t extends A{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)!==y.bigint)return this._getInvalidInput(e);let r,a=new Z;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:m.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:m.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),g(r,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):P.assertNever(i);return{status:a.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return g(n,{code:m.invalid_type,expected:y.bigint,received:n.parsedType}),S}gte(e,n){return this.setLimit("min",e,!0,x.toString(n))}gt(e,n){return this.setLimit("min",e,!1,x.toString(n))}lte(e,n){return this.setLimit("max",e,!0,x.toString(n))}lt(e,n){return this.setLimit("max",e,!1,x.toString(n))}setLimit(e,n,r,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:x.toString(a)}]})}_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:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:x.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}};Je.create=t=>new Je({checks:[],typeName:_.ZodBigInt,coerce:t?.coerce??!1,...T(t)});var Ze=class extends A{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return g(r,{code:m.invalid_type,expected:y.boolean,received:r.parsedType}),S}return q(e.data)}};Ze.create=t=>new Ze({typeName:_.ZodBoolean,coerce:t?.coerce||!1,...T(t)});var Ge=class t extends A{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let i=this._getOrReturnCtx(e);return g(i,{code:m.invalid_type,expected:y.date,received:i.parsedType}),S}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return g(i,{code:m.invalid_date}),S}let r=new Z,a;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),g(a,{code:m.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),g(a,{code:m.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):P.assertNever(i);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:x.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:x.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}};Ge.create=t=>new Ge({checks:[],coerce:t?.coerce||!1,typeName:_.ZodDate,...T(t)});var xt=class extends A{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return g(r,{code:m.invalid_type,expected:y.symbol,received:r.parsedType}),S}return q(e.data)}};xt.create=t=>new xt({typeName:_.ZodSymbol,...T(t)});var qe=class extends A{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:m.invalid_type,expected:y.undefined,received:r.parsedType}),S}return q(e.data)}};qe.create=t=>new qe({typeName:_.ZodUndefined,...T(t)});var Ke=class extends A{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return g(r,{code:m.invalid_type,expected:y.null,received:r.parsedType}),S}return q(e.data)}};Ke.create=t=>new Ke({typeName:_.ZodNull,...T(t)});var De=class extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return q(e.data)}};De.create=t=>new De({typeName:_.ZodAny,...T(t)});var ve=class extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return q(e.data)}};ve.create=t=>new ve({typeName:_.ZodUnknown,...T(t)});var de=class extends A{_parse(e){let n=this._getOrReturnCtx(e);return g(n,{code:m.invalid_type,expected:y.never,received:n.parsedType}),S}};de.create=t=>new de({typeName:_.ZodNever,...T(t)});var kt=class extends A{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:m.invalid_type,expected:y.void,received:r.parsedType}),S}return q(e.data)}};kt.create=t=>new kt({typeName:_.ZodVoid,...T(t)});var Se=class t extends A{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),a=this._def;if(n.parsedType!==y.array)return g(n,{code:m.invalid_type,expected:y.array,received:n.parsedType}),S;if(a.exactLength!==null){let o=n.data.length>a.exactLength.value,s=n.data.length<a.exactLength.value;(o||s)&&(g(n,{code:o?m.too_big:m.too_small,minimum:s?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(g(n,{code:m.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(g(n,{code:m.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,s)=>a.type._parseAsync(new oe(n,o,n.path,s)))).then(o=>Z.mergeArray(r,o));let i=[...n.data].map((o,s)=>a.type._parseSync(new oe(n,o,n.path,s)));return Z.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:x.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:x.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:x.toString(n)}})}nonempty(e){return this.min(1,e)}};Se.create=(t,e)=>new Se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...T(e)});function yt(t){if(t instanceof ee){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=ie.create(yt(r))}return new ee({...t._def,shape:()=>e})}else return t instanceof Se?new Se({...t._def,type:yt(t.element)}):t instanceof ie?ie.create(yt(t.unwrap())):t instanceof fe?fe.create(yt(t.unwrap())):t instanceof me?me.create(t.items.map(e=>yt(e))):t}var ee=class t extends A{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=P.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let d=this._getOrReturnCtx(e);return g(d,{code:m.invalid_type,expected:y.object,received:d.parsedType}),S}let{status:r,ctx:a}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof de&&this._def.unknownKeys==="strip"))for(let d in a.data)o.includes(d)||s.push(d);let c=[];for(let d of o){let u=i[d],p=a.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new oe(a,p,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof de){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(d==="strict")s.length>0&&(g(a,{code:m.unrecognized_keys,keys:s}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let u of s){let p=a.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new oe(a,p,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let d=[];for(let u of c){let p=await u.key,h=await u.value;d.push({key:p,value:h,alwaysSet:u.alwaysSet})}return d}).then(d=>Z.mergeObjectSync(r,d)):Z.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return x.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let a=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:x.errToObj(e).message??a}:{message:a}}}:{}})}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:_.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 P.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 P.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return yt(this)}partial(e){let n={};for(let r of P.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?n[r]=a:n[r]=a.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of P.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ie;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return ia(P.objectKeys(this.shape))}};ee.create=(t,e)=>new ee({shape:()=>t,unknownKeys:"strip",catchall:de.create(),typeName:_.ZodObject,...T(e)});ee.strictCreate=(t,e)=>new ee({shape:()=>t,unknownKeys:"strict",catchall:de.create(),typeName:_.ZodObject,...T(e)});ee.lazycreate=(t,e)=>new ee({shape:t,unknownKeys:"strip",catchall:de.create(),typeName:_.ZodObject,...T(e)});var Ye=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function a(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;let o=i.map(s=>new Q(s.ctx.common.issues));return g(n,{code:m.invalid_union,unionErrors:o}),S}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(a);{let i,o=[];for(let c of r){let d={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map(c=>new Q(c));return g(n,{code:m.invalid_union,unionErrors:s}),S}}get options(){return this._def.options}};Ye.create=(t,e)=>new Ye({options:t,typeName:_.ZodUnion,...T(e)});var we=t=>t instanceof Qe?we(t.schema):t instanceof se?we(t.innerType()):t instanceof et?[t.value]:t instanceof tt?t.options:t instanceof nt?P.objectValues(t.enum):t instanceof rt?we(t._def.innerType):t instanceof qe?[void 0]:t instanceof Ke?[null]:t instanceof ie?[void 0,...we(t.unwrap())]:t instanceof fe?[null,...we(t.unwrap())]:t instanceof Vt||t instanceof it?we(t.unwrap()):t instanceof at?we(t._def.innerType):[],cn=class t extends A{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return g(n,{code:m.invalid_type,expected:y.object,received:n.parsedType}),S;let r=this.discriminator,a=n.data[r],i=this.optionsMap.get(a);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(g(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let a=new Map;for(let i of n){let o=we(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of o){if(a.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);a.set(s,i)}}return new t({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,...T(r)})}};function Vn(t,e){let n=he(t),r=he(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let a=P.objectKeys(e),i=P.objectKeys(t).filter(s=>a.indexOf(s)!==-1),o={...t,...e};for(let s of i){let c=Vn(t[s],e[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let a=[];for(let i=0;i<t.length;i++){let o=t[i],s=e[i],c=Vn(o,s);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Xe=class extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),a=(i,o)=>{if(ln(i)||ln(o))return S;let s=Vn(i.value,o.value);return s.valid?((dn(i)||dn(o))&&n.dirty(),{status:n.value,value:s.data}):(g(r,{code:m.invalid_intersection_types}),S)};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(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Xe.create=(t,e,n)=>new Xe({left:t,right:e,typeName:_.ZodIntersection,...T(n)});var me=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return g(r,{code:m.invalid_type,expected:y.array,received:r.parsedType}),S;if(r.data.length<this._def.items.length)return g(r,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new oe(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Z.mergeArray(n,o)):Z.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};me.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new me({items:t,typeName:_.ZodTuple,rest:null,...T(e)})};var un=class t extends A{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!==y.object)return g(r,{code:m.invalid_type,expected:y.object,received:r.parsedType}),S;let a=[],i=this._def.keyType,o=this._def.valueType;for(let s in r.data)a.push({key:i._parse(new oe(r,s,r.path,s)),value:o._parse(new oe(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?Z.mergeObjectAsync(n,a):Z.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof A?new t({keyType:e,valueType:n,typeName:_.ZodRecord,...T(r)}):new t({keyType:$e.create(),valueType:e,typeName:_.ZodRecord,...T(n)})}},wt=class extends A{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!==y.map)return g(r,{code:m.invalid_type,expected:y.map,received:r.parsedType}),S;let a=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([s,c],d)=>({key:a._parse(new oe(r,s,r.path,[d,"key"])),value:i._parse(new oe(r,c,r.path,[d,"value"]))}));if(r.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of o){let d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return S;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}})}else{let s=new Map;for(let c of o){let d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return S;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}}}};wt.create=(t,e,n)=>new wt({valueType:e,keyType:t,typeName:_.ZodMap,...T(n)});var vt=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return g(r,{code:m.invalid_type,expected:y.set,received:r.parsedType}),S;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(g(r,{code:m.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(g(r,{code:m.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let d=new Set;for(let u of c){if(u.status==="aborted")return S;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}let s=[...r.data.values()].map((c,d)=>i._parse(new oe(r,c,r.path,d)));return r.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(e,n){return new t({...this._def,minSize:{value:e,message:x.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:x.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};vt.create=(t,e)=>new vt({valueType:t,minSize:null,maxSize:null,typeName:_.ZodSet,...T(e)});var pn=class t extends A{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return g(n,{code:m.invalid_type,expected:y.function,received:n.parsedType}),S;function r(s,c){return Wt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,gt(),ke].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:c}})}function a(s,c){return Wt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,gt(),ke].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof je){let s=this;return q(async function(...c){let d=new Q([]),u=await s._def.args.parseAsync(c,i).catch(f=>{throw d.addIssue(r(c,f)),d}),p=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(p,i).catch(f=>{throw d.addIssue(a(p,f)),d})})}else{let s=this;return q(function(...c){let d=s._def.args.safeParse(c,i);if(!d.success)throw new Q([r(c,d.error)]);let u=Reflect.apply(o,this,d.data),p=s._def.returns.safeParse(u,i);if(!p.success)throw new Q([a(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:me.create(e).rest(ve.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||me.create([]).rest(ve.create()),returns:n||ve.create(),typeName:_.ZodFunction,...T(r)})}},Qe=class extends A{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})}};Qe.create=(t,e)=>new Qe({getter:t,typeName:_.ZodLazy,...T(e)});var et=class extends A{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return g(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}};et.create=(t,e)=>new et({value:t,typeName:_.ZodLiteral,...T(e)});function ia(t,e){return new tt({values:t,typeName:_.ZodEnum,...T(e)})}var tt=class t extends A{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{expected:P.joinValues(r),received:n.parsedType,code:m.invalid_type}),S}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 g(n,{received:n.data,code:m.invalid_enum_value,options:r}),S}return q(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})}};tt.create=ia;var nt=class extends A{_parse(e){let n=P.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let a=P.objectValues(n);return g(r,{expected:P.joinValues(a),received:r.parsedType,code:m.invalid_type}),S}if(this._cache||(this._cache=new Set(P.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let a=P.objectValues(n);return g(r,{received:r.data,code:m.invalid_enum_value,options:a}),S}return q(e.data)}get enum(){return this._def.values}};nt.create=(t,e)=>new nt({values:t,typeName:_.ZodNativeEnum,...T(e)});var je=class extends A{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return g(n,{code:m.invalid_type,expected:y.promise,received:n.parsedType}),S;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return q(r.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};je.create=(t,e)=>new je({type:t,typeName:_.ZodPromise,...T(e)});var se=class extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:o=>{g(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){let o=a.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async s=>{if(n.value==="aborted")return S;let c=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return c.status==="aborted"?S:c.status==="dirty"?We(c.value):n.value==="dirty"?We(c.value):c});{if(n.value==="aborted")return S;let s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?S:s.status==="dirty"?We(s.value):n.value==="dirty"?We(s.value):s}}if(a.type==="refinement"){let o=s=>{let c=a.refinement(s,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?S:(s.status==="dirty"&&n.dirty(),o(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?S:(s.status==="dirty"&&n.dirty(),o(s.value).then(()=>({status:n.value,value:s.value}))))}if(a.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Re(o))return S;let s=a.transform(o.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Re(o)?Promise.resolve(a.transform(o.value,i)).then(s=>({status:n.value,value:s})):S);P.assertNever(a)}};se.create=(t,e,n)=>new se({schema:t,typeName:_.ZodEffects,effect:e,...T(n)});se.createWithPreprocess=(t,e,n)=>new se({schema:e,effect:{type:"preprocess",transform:t},typeName:_.ZodEffects,...T(n)});var ie=class extends A{_parse(e){return this._getType(e)===y.undefined?q(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ie.create=(t,e)=>new ie({innerType:t,typeName:_.ZodOptional,...T(e)});var fe=class extends A{_parse(e){return this._getType(e)===y.null?q(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};fe.create=(t,e)=>new fe({innerType:t,typeName:_.ZodNullable,...T(e)});var rt=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};rt.create=(t,e)=>new rt({innerType:t,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...T(e)});var at=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return bt(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Q(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Q(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};at.create=(t,e)=>new at({innerType:t,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...T(e)});var St=class extends A{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return g(r,{code:m.invalid_type,expected:y.nan,received:r.parsedType}),S}return{status:"valid",value:e.data}}};St.create=t=>new St({typeName:_.ZodNaN,...T(t)});var rs=Symbol("zod_brand"),Vt=class extends A{_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}},Jt=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?S:i.status==="dirty"?(n.dirty(),We(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?S:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:_.ZodPipeline})}},it=class extends A{_parse(e){let n=this._def.innerType._parse(e),r=a=>(Re(a)&&(a.value=Object.freeze(a.value)),a);return bt(n)?n.then(a=>r(a)):r(n)}unwrap(){return this._def.innerType}};it.create=(t,e)=>new it({innerType:t,typeName:_.ZodReadonly,...T(e)});function ta(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function oa(t,e={},n){return t?De.create().superRefine((r,a)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let s=ta(e,r),c=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:c})}});if(!i){let o=ta(e,r),s=o.fatal??n??!0;a.addIssue({code:"custom",...o,fatal:s})}}):De.create()}var as={object:ee.lazycreate},_;(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"})(_||(_={}));var is=(t,e={message:`Input not instance of ${t.name}`})=>oa(n=>n instanceof t,e),sa=$e.create,la=Ve.create,os=St.create,ss=Je.create,da=Ze.create,ls=Ge.create,ds=xt.create,cs=qe.create,us=Ke.create,ps=De.create,hs=ve.create,ms=de.create,fs=kt.create,gs=Se.create,bs=ee.create,ys=ee.strictCreate,xs=Ye.create,ks=cn.create,ws=Xe.create,vs=me.create,Ss=un.create,_s=wt.create,Cs=vt.create,Ts=pn.create,As=Qe.create,Is=et.create,Ps=tt.create,Es=nt.create,Rs=je.create,$s=se.create,Ds=ie.create,js=fe.create,Os=se.createWithPreprocess,Ns=Jt.create,Ls=()=>sa().optional(),zs=()=>la().optional(),Ms=()=>da().optional(),Us={string:(t=>$e.create({...t,coerce:!0})),number:(t=>Ve.create({...t,coerce:!0})),boolean:(t=>Ze.create({...t,coerce:!0})),bigint:(t=>Je.create({...t,coerce:!0})),date:(t=>Ge.create({...t,coerce:!0}))};var Fs=S;var Jn=l.object({id:l.string()}),Hs=l.enum(["top","right","bottom","left","auto"]).default("auto"),Zn=l.enum(["left","middle","right"]),Bs=Zn.default("left"),ca=l.object({label:l.string().optional(),hidden:l.boolean().default(!1)}),Ws={background:l.string().optional(),textColor:l.string().optional(),borderRadius:l.string().optional(),textAlign:Bs,anchor:Hs,showNavigation:l.boolean().default(!0),prevButton:ca.optional(),nextButton:ca.optional()},Vs=l.enum(["pointer","callout","area"]),Js=l.discriminatedUnion("type",[l.object({type:l.literal("html-element"),alphaId:l.string().min(1)})]),Zs=Jn.extend({type:l.literal("message"),variant:Vs.default("callout"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1).optional(),h:l.number().min(0).max(1).optional(),text:l.string().optional(),target:Js.optional(),advancesStep:l.boolean().default(!0),...Ws}),Gs=Jn.extend({type:l.literal("blur"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1),h:l.number().min(0).max(1),intensity:l.number().min(0).max(20).default(8)}),qs=Jn.extend({type:l.literal("text"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),text:l.string(),fontSize:l.number().positive().default(16),color:l.string().optional()}),ua=l.discriminatedUnion("type",[Zs,Gs,qs]),pa=new Set(["message","blur","text"]),ha=l.object({type:l.string()}).passthrough();function ma(t){return typeof t=="object"&&t!==null?t.type:void 0}var fa=l.any().superRefine((t,e)=>{let a=(pa.has(ma(t))?ua:ha).safeParse(t);if(!a.success)for(let i of a.error.issues)e.addIssue(i)}).transform(t=>(pa.has(ma(t))?ua:ha).parse(t));var ga=l.object({label:l.string().min(1),href:l.string().refine(t=>/^(https?:|mailto:)/i.test(t),"href must be an http(s) or mailto URL")}),Gn=l.object({logo:l.string().min(1).optional(),name:l.string().min(1).optional(),logoHref:l.string().refine(t=>/^(https?:|mailto:)/i.test(t),"logoHref must be an http(s) or mailto URL").optional(),favicon:l.string().min(1).optional(),cta:ga.optional(),secondaryCta:ga.optional(),watermark:l.boolean().optional()}),ba=Gn.omit({favicon:!0});var Ks=l.object({type:l.literal("next")}),Ys=l.object({type:l.literal("prev")}),Xs=l.object({type:l.literal("step"),stepId:l.string().min(1)}),Qs=l.object({type:l.literal("chapter"),chapterId:l.string().min(1)}),el=l.object({type:l.literal("url"),href:l.string().min(1),target:l.enum(["_self","_blank"]).default("_blank")}),tl=l.object({type:l.literal("restart")}),nl=l.discriminatedUnion("type",[Ks,Ys,Xs,Qs,el,tl]),rl=l.enum(["shimmer"]),hn=l.object({label:l.string().min(1),action:nl.default({type:"next"}),animation:rl.optional(),background:l.string().optional(),textColor:l.string().optional()});var al="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",qn=/^[A-Za-z0-9_-]{12}$/;function il(t){let e=globalThis.crypto;if(!e||typeof e.getRandomValues!="function")throw new Error("generateDemoId requires globalThis.crypto.getRandomValues (Node 19+, browsers, or edge runtime).");e.getRandomValues(t)}function ne(){let t=new Uint8Array(12);il(t);let e="";for(let n of t)e+=al.charAt(n&63);return e}function ya(t){return typeof t=="string"&&qn.test(t)}function xa(t){return String(t+1).padStart(4,"0")}function ka(t){return`snap-${t.toString().padStart(3,"0")}`}function mn(t){let e=((t??"").toLowerCase().split(";")[0]??"").trim();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("font/")||e.includes("font")||e.includes("woff")?"font":"other"}function Kn(t){if(!t)return"";let e=t.replace(/^(?:tree\s*item|menu\s*item|menuitem|list\s*item|tab(?:\s*panel)?|button|link|option|region|combobox|radio|checkbox|switch|dialog|row|cell|columnheader|rowheader|navigation|article|banner|main|complementary|contentinfo)\s*:?\s+/i,"").trim();return(e.split(/\r?\n/).map(r=>r.trim()).find(Boolean)??e).replace(/\s+/g," ").trim().slice(0,48)}function Yn(t){let{stepId:e,assetId:n,posterAssetId:r,kind:a,isLast:i}=t,o=`asset:${n}`,s=a==="video"?{type:"video",src:o,posterSrc:r?`asset:${r}`:void 0,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,alt:t.title,sourceUrl:t.sourceUrl??"",title:t.title,autoplay:!0,muted:!0,objectFit:"cover"}:{type:"image",src:o,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,alt:t.title,sourceUrl:t.sourceUrl??"",title:t.title,objectFit:"cover"},c=t.click,d=[];if(c){let h=Kn(c.label);d.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:c.x,y:c.y,text:h?`Click on "${h}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}else d.push({id:`${e}_callout`,type:"message",variant:"callout",x:.5,y:.5,text:i?"End of walkthrough":"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});let u=!!c&&!(c.x===0&&c.y===0),p=a==="image"&&t.autoApplyZoom===!0&&u?{zoom:1.35,x:Number(Math.max(0,Math.min(1,c.x)).toFixed(4)),y:Number(Math.max(0,Math.min(1,c.y)).toFixed(4))}:void 0;return{id:e,kind:"content",background:s,...p?{transform:p}:{},annotations:d,advance:{trigger:"click"}}}function wa(t){let{stepId:e,htmlPath:n,click:r}=t,a=[];if(r?.alphaId)a.push({id:`${e}_area`,type:"message",variant:"area",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),w:0,h:0,text:Kn(r.label)||"Click here",target:{type:"html-element",alphaId:r.alphaId},anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});else if(r){let i=Kn(r.label);a.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),text:i?`Click on "${i}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}return{id:e,kind:"content",background:{type:"html",path:n,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,zoom:1,scroll:t.scroll,sourceUrl:t.sourceUrl??"",title:t.sourceUrl??""},annotations:a,advance:{trigger:"click"}}}function ol(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xn(t,e){let n=t;for(let[r,a]of e){let i=ol(r);n=n.replace(new RegExp(`(?:\\.\\./)*assets/${i}`,"g"),a),n=n.replace(new RegExp(`assets/${i}`,"g"),a)}return n}function sl(t){return`<script data-inkly-replay-scroll>(()=>{const c=${JSON.stringify(t).replace(/<\/(script)/gi,"<\\/$1")};function r(){const d=document.documentElement,b=document.body;const vw=innerWidth||d.clientWidth||0;const vh=innerHeight||d.clientHeight||0;const mx=Math.max(0,Math.max(d.scrollWidth,b?b.scrollWidth:0)-vw);const my=Math.max(0,Math.max(d.scrollHeight,b?b.scrollHeight:0)-vh);const x=c.maxX>0&&mx>0?c.x/c.maxX*mx:c.x;const y=c.maxY>0&&my>0?c.y/c.maxY*my:c.y;scrollTo(Math.max(0,x),Math.max(0,y));}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",r,{once:true});r();requestAnimationFrame(r);setTimeout(r,120);setTimeout(r,500);})();</script>`}function va(t,e){let n=sl(e);return/<\/body\s*>/i.test(t)?t.replace(/<\/body\s*>/i,`${n}</body>`):`${t}${n}`}function Sa(t,e){if(!e||/data-inkly-document-css|document\.css/i.test(t))return t;let n='<link rel="stylesheet" href="./document.css?draft=1" data-inkly-document-css>';return/<\/head\s*>/i.test(t)?t.replace(/<\/head\s*>/i,`${n}</head>`):`${n}${t}`}var _a=l.object({id:l.string(),text:l.string(),start:l.number().nonnegative().optional(),end:l.number().nonnegative().optional()});var ll=l.enum(["screenshot","image","video","audio","font","other"]),dl=l.object({id:l.string().min(1),path:l.string().min(1).optional(),uri:l.string().min(1).optional(),sha256:l.string().regex(/^[0-9a-f]{64}$/),kind:ll,contentType:l.string().min(1).optional(),publicUrl:l.string().min(1).optional(),cdnPath:l.string().min(1).optional(),file:l.string().min(1).optional(),size:l.number().int().nonnegative().optional(),createdAt:l.string().min(1).optional(),updatedAt:l.string().min(1).optional(),viewport:l.object({w:l.number().int().positive(),h:l.number().int().positive()}).optional()}),_t=l.object({version:l.literal(1),assets:l.array(dl),screens:l.array(l.unknown()).optional()});var Qn=l.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"}),cl=l.enum(["color","image","glassmorphism"]),Ca=l.object({type:cl,color:Qn.optional(),from:Qn.optional(),to:Qn.optional(),src:l.string().min(1).optional(),alt:l.string().optional(),intensity:l.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:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:l.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),Ta=l.object({src:l.string(),alt:l.string().optional()});var er=l.object({src:l.string().min(1),duration:l.number().positive().optional()});var ul=l.enum(["text","dropdown"]),pl=l.object({value:l.string().min(1),label:l.string().min(1)}),hl=l.object({id:l.string(),label:l.string(),type:ul.default("text"),placeholder:l.string().optional(),required:l.boolean().default(!1),options:l.array(pl).optional()}).superRefine((t,e)=>{t.type==="dropdown"&&(!t.options||t.options.length===0)&&e.addIssue({code:l.ZodIssueCode.custom,message:"Dropdown field requires at least one option.",path:["options"]})}),Ra=l.object({src:l.string().min(1),alt:l.string().optional(),height:l.number().int().positive().optional()}),ml=l.enum(["left","right","top"]),fl=l.enum(["standard","hero"]),$a=l.object({src:l.string().min(1),alt:l.string().optional(),naturalWidth:l.number().positive().optional(),naturalHeight:l.number().positive().optional(),position:ml.default("right"),layout:fl.default("hero")}),gl=l.object({type:l.literal("headline"),id:l.string(),logo:Ra.optional(),image:$a.optional(),title:l.string(),titleColor:l.string().optional(),description:l.string().optional(),descriptionColor:l.string().optional(),textAlign:Zn.optional(),cta:hn.optional(),secondaryCta:hn.optional()}),bl=l.object({type:l.literal("form"),id:l.string(),logo:Ra.optional(),image:$a.optional(),title:l.string().optional(),description:l.string().optional(),fields:l.array(hl).min(1),submit:hn.default({label:"Submit",action:{type:"next"}})}),yl="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",xl="camera; microphone; fullscreen; payment; clipboard-write",kl=l.object({type:l.literal("embed"),id:l.string(),src:l.string(),iframeTitle:l.string().optional(),sandbox:l.string().default(yl),allow:l.string().default(xl)}),wl=l.object({type:l.literal("custom"),id:l.string(),name:l.string().min(1),data:l.record(l.unknown()).optional()}),Aa=l.discriminatedUnion("type",[gl,bl,kl,wl]),Ia=new Set(["headline","form","embed","custom"]),Pa=l.object({type:l.string()}).passthrough();function Ea(t){return typeof t=="object"&&t!==null?t.type:void 0}var Da=l.any().superRefine((t,e)=>{let a=(Ia.has(Ea(t))?Aa:Pa).safeParse(t);if(!a.success)for(let i of a.error.issues)e.addIssue(i)}).transform(t=>(Ia.has(Ea(t))?Aa:Pa).parse(t));var ja=l.enum(["contain","cover","fill"]),Oa=l.enum(["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"]),vl=l.object({type:l.literal("image"),src:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),objectFit:ja.optional(),objectPosition:Oa.optional()}),Sl=l.object({type:l.literal("video"),src:l.string().min(1),posterSrc:l.string().min(1).optional(),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),autoplay:l.boolean().default(!0),muted:l.boolean().default(!0),objectFit:ja.optional(),objectPosition:Oa.optional()}),_l=l.object({x:l.number().nonnegative().default(0),y:l.number().nonnegative().default(0),maxX:l.number().nonnegative().default(0),maxY:l.number().nonnegative().default(0)}),Cl=l.object({type:l.literal("html"),path:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),zoom:l.number().positive().default(1),scroll:_l.default({x:0,y:0,maxX:0,maxY:0}),sourceUrl:l.string().optional(),title:l.string().optional()}),Tl=l.discriminatedUnion("type",[vl,Sl,Cl]),Al=l.object({zoom:l.number().min(1).default(1),x:l.number().min(0).max(1).default(.5),y:l.number().min(0).max(1).default(.5)}),Il=l.object({trigger:l.enum(["auto","click"]).default("auto")}).default({trigger:"auto"}),Pl=l.object({kind:l.literal("content").default("content"),id:l.string(),label:l.string().optional(),duration:l.number().positive().optional(),background:Tl,script:l.string().optional(),voiceover:er.optional(),transform:Al.optional(),advance:Il,annotations:l.array(fa).default([]),captions:l.array(_a).optional()}).passthrough(),El=l.object({kind:l.literal("cover"),id:l.string(),label:l.string().optional(),widgets:l.array(Da).length(1),background:Ca.optional(),backgroundImage:Ta.optional(),backgroundDim:l.number().min(0).max(1).optional(),script:l.string().optional(),voiceover:er.optional(),duration:l.number().positive().optional(),advance:l.object({trigger:l.enum(["auto","click"]).default("click")}).default({trigger:"click"})}).passthrough(),Na=l.discriminatedUnion("kind",[Pl,El]);var Rl=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,La=l.string().regex(Rl,"must be a hex color like #5b3df5"),fn=l.object({primary:La.optional(),secondary:La.optional(),font:l.string().min(1).optional(),radius:l.string().min(1).optional()}).partial();var gn=l.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"}),$l=l.object({id:l.string(),title:l.string(),stepIds:l.array(l.string()).min(1)}),Dl=l.object({hideHeader:l.boolean().default(!1),hideControls:l.boolean().default(!1),controls:l.enum(["full","minimal","hidden"]).optional(),showHubBreadcrumb:l.boolean().default(!1),mobileFooterMessage:l.boolean().default(!0),autoplay:l.boolean().default(!1)}),jl=l.object({width:l.number().positive(),height:l.number().positive()}),Ol=l.enum(["public","private"]),Nl=l.enum(["none","color","image"]),Ll=l.object({type:Nl,color:gn.optional(),from:gn.optional(),to:gn.optional(),src:l.string().min(1).optional(),alt:l.string().optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,r=!!t.from&&!!t.to;!n&&!r&&e.addIssue({code:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:l.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),ot=l.object({id:l.string().regex(qn,{message:"must be a 12-character URL-safe demo id (see generateDemoId)"}),version:l.number().int().min(1),title:l.string().optional(),subtitle:l.string().optional(),runtime:l.string().min(1).optional(),visibility:Ol.default("public"),backgroundColor:gn.optional(),background:Ll.optional(),theme:l.object({preset:l.string().min(1).optional(),tokens:fn.optional(),brand:ba.optional()}).optional(),chrome:Dl.default({}),aspectRatio:jl.optional(),chapters:l.array($l).default([]),steps:l.array(Na).min(1)}).passthrough().superRefine((t,e)=>{let n=new Set(t.steps.map(a=>a.id)),r=new Set(t.chapters.map(a=>a.id));t.chapters.forEach((a,i)=>{a.stepIds.forEach(o=>{n.has(o)||e.addIssue({code:l.ZodIssueCode.custom,path:["chapters",i,"stepIds"],message:`Chapter "${a.id}" references unknown step "${o}"`})})}),t.steps.forEach((a,i)=>{a.kind==="cover"&&a.widgets.forEach((o,s)=>{o.type==="headline"&&["cta","secondaryCta"].forEach(c=>{let d=o[c]?.action;d&&(d.type==="step"&&!n.has(d.stepId)&&e.addIssue({code:l.ZodIssueCode.custom,path:["steps",i,"widgets",s,c,"action","stepId"],message:`Widget "${o.id}" CTA targets unknown step "${d.stepId}"`}),d.type==="chapter"&&!r.has(d.chapterId)&&e.addIssue({code:l.ZodIssueCode.custom,path:["steps",i,"widgets",s,c,"action","chapterId"],message:`Widget "${o.id}" CTA targets unknown chapter "${d.chapterId}"`}))})})})});function bn(t){return ot.parse(t)}function Ct(t){let e=typeof t=="object"&&t!==null?t:{},n=ya(e.id),r=n?e:{...e,id:ne()};return{config:ot.parse(r),changed:!n}}function za(t){let e=new Map;t.forEach((r,a)=>{let i=e.get(r.id);i?i.push({entry:r,index:a}):e.set(r.id,[{entry:r,index:a}])});let n=[];for(let r of e.values()){if(r.length<2)continue;let a=[...r].sort((o,s)=>o.entry.updatedAt!==s.entry.updatedAt?o.entry.updatedAt-s.entry.updatedAt:o.index-s.index),[,...i]=a;for(let{entry:o}of i)n.push({entry:o,newId:ne()})}return n}var tr=l.enum(["sidebar","tabs"]),zl=l.object({name:l.string().min(1),description:l.string().min(1).optional(),icon:l.string().min(1).optional(),demos:l.array(l.string().min(1))}),ge=l.object({$schema:l.string().optional(),name:l.string().min(1),runtime:l.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:l.string().min(1).optional(),layout:tr.optional(),theme:l.string().min(1).optional(),tokens:fn.optional(),brand:Gn.optional(),title:l.string().min(1).optional(),subtitle:l.string().min(1).optional(),collections:l.array(zl).optional()});function Ma({slug:t,config:e,resolveAssetSrc:n}){let r=e.title??e.id??t;return{slug:t,title:r,description:Ml(e,r),thumbnail:Hl(e,r,n),visibility:e.visibility}}function yn(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function Ml(t,e){if(t.subtitle?.trim())return yn(t.subtitle.trim(),120);for(let n of t.steps){if(n.kind!=="content")continue;let r=n.captions?.[0]?.text;if(r&&r.trim())return yn(r.trim(),120);break}for(let n of t.steps)if(n.kind==="cover"){for(let r of n.widgets)if(r.type==="headline"&&r.description&&r.description.trim())return yn(r.description.trim(),120)}return yn(`Explore the ${e} workflow.`,120)}function Ul(t){return t.background?t.background.type==="image":t.backgroundImage?!0:t.widgets.some(e=>e.type==="headline"?!!e.title:e.type==="embed"?!!e.src:e.type==="form")}function nr(t,e){return t?e?e(t):t:null}function Fl(t,e){if(!e)return t;let n=t.widgets.map(o=>{if((o.type==="headline"||o.type==="form")&&o.image?.src){let s=e(o.image.src);return s&&s!==o.image.src?{...o,image:{...o.image,src:s}}:o}return o}),r=t.backgroundImage,a=t.background;if(a?.type==="image"&&a.src){let o=e(a.src);o&&o!==a.src&&(a={...a,src:o})}if(r?.src){let o=e(r.src);o&&o!==r.src&&(r={...r,src:o})}return!n.some((o,s)=>o!==t.widgets[s])&&a===t.background&&r===t.backgroundImage?t:{...t,widgets:n,background:a,backgroundImage:r}}function Hl(t,e,n){let r=t.steps[0];if(r){if(r.kind==="cover"&&Ul(r))return{kind:"cover",cover:Fl(r,n),themeTokens:t.theme?.tokens};if(r.kind==="content"){let a=r.background;if(a?.type==="image"){let i=nr(a.src,n);if(i)return{kind:"image",src:i}}else if(a?.type==="video"){let i=nr(a.posterSrc,n);if(i)return{kind:"image",src:i};let o=nr(a.src,n);if(o)return{kind:"video",src:o}}else if(a?.type==="html")return{kind:"html",path:a.path,naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight,zoom:a.zoom,scroll:a.scroll}}}return{kind:"placeholder",title:e}}function Bl(t){return!t||t==="null"?"":t.replace(/\/+$/,"")}function Wl(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vl(t){return String(t||"").replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"")}function rr(t){let e=Vl(t);return/\/index\.html$/i.test(e)||/^index\.html$/i.test(e)?e.replace(/index\.html$/i,"document.css"):/\.html?$/i.test(e)?e.replace(/\.html?$/i,".css"):null}function Jl(t){return t.replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?content-security-policy\b)[^>]*>/gi,"")}var Zl=/\s+(?:href|xlink:href|target|rel|download|ping|referrerpolicy|data-inkly-href)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?/gi;function Zt(t){return String(t||"").replace(/<(a|area)\b[^>]*>/gi,e=>e.replace(Zl,""))}function st(t,e={}){let n=Bl(e.resourceOrigin),r=String(t||"");return n?r.replace(new RegExp(`(^|["'\\(\\s,=])${Wl("/api/hubs/")}`,"g"),`$1${n}/api/hubs/`):r}function Gl(t){return Jl(t).replace(/<style\b(?=[^>]*\bdata-inkly-document-css\b)[\s\S]*?<\/style>/gi,"").replace(/<link\b(?=[^>]*\bdata-inkly-document-css\b)[^>]*>/gi,"").replace(/<link\b(?=[^>]*\brel\s*=\s*["']?stylesheet\b)(?=[^>]*\bhref\s*=\s*["']?[^"'\s>]*document\.css(?:\?draft=1)?)[^>]*>/gi,"")}function Ua({htmlPath:t,html:e,css:n,cssHref:r,resourceOrigin:a}){let i=Gl(Zt(e)),o=rr(t)!=null,s=n?.trim()??"";if(o&&s){let d=`<style data-inkly-document-css>
|
|
3
|
+
${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
4
|
+
</style>`,u=/<\/head\s*>/i.test(i)?i.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${i}`;return st(u,{resourceOrigin:a})}if(o&&r){let d=`<link rel="stylesheet" href="${st(r,{resourceOrigin:a})}" data-inkly-document-css>`,u=/<\/head\s*>/i.test(i)?i.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${i}`;return st(u,{resourceOrigin:a})}return st(i,{resourceOrigin:a})}var Gt=l.string().regex(/^sha(?:256|384|512)-[A-Za-z0-9+/]+=*$/,{message:"must be an SRI string like sha384-<base64>"}),xn=l.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"}),ql=l.object({version:xn,url:l.string().url(),integrity:Gt}),kn=l.object({$schema:l.string().optional(),runtime:ql});var Fa=l.string().regex(/^[0-9a-f]{64}$/,{message:"must be lowercase sha-256 hex (64 chars)"}),Tt=l.object({version:xn,externals:l.array(l.string().min(1)),jsHash:Fa,cssHash:Fa,jsBytes:l.number().int().nonnegative(),cssBytes:l.number().int().nonnegative(),integrity:Gt,cssIntegrity:Gt,minSchema:xn,codemodsIntegrity:Gt.optional(),codemodsBytes:l.number().int().nonnegative().optional()});var lt=["__inkly","assets","api","c"],Kl={__inkly:"'__inkly' is reserved for CLI internal endpoints",assets:"'assets' is reserved for hub static files",api:"'api' is reserved for future use",c:"'c' is reserved for future use"},Yl=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;function _e(t){return typeof t!="string"?{ok:!1,reason:"Name is required."}:t.length===0?{ok:!1,reason:"Name cannot be empty."}:/\s/.test(t)?{ok:!1,reason:"Name cannot contain spaces."}:t.includes("/")||t.includes("\\")?{ok:!1,reason:"Name cannot contain slashes."}:t.includes(".")?{ok:!1,reason:"Name cannot contain dots."}:lt.includes(t)?{ok:!1,reason:Kl[t]}:t.startsWith("_")?{ok:!1,reason:"Name cannot start with '_' (reserved for internal use)."}:t!==t.toLowerCase()?{ok:!1,reason:'Name must be lowercase (e.g. "getting-started").'}:Yl.test(t)?{ok:!0}:{ok:!1,reason:"Name must be kebab-case: lowercase letters, digits, and hyphens, starting and ending with a letter or digit."}}var Oe={inkly:{primary:"#5b6cff",secondary:"#ebebeb",radius:"10px",font:"Geist, ui-sans-serif, system-ui, sans-serif"},editorial:{primary:"#d97757",secondary:"#f4f0e7",radius:"12px",font:"Inter, ui-sans-serif, system-ui, sans-serif"},mono:{primary:"#5b6cff",secondary:"#f5f5f5",radius:"10px",font:"Inter, ui-sans-serif, system-ui, sans-serif"},substack:{primary:"#ff6719",secondary:"#fdf1eb",radius:"4px",font:"Inter, ui-sans-serif, system-ui, sans-serif"}};var Xl=`
|
|
5
5
|
/* \u2500\u2500 Editorial hub-index \u2014 designs 07 (sidebar) + 15 (top nav) \u2500\u2500\u2500\u2500\u2500\u2500
|
|
6
6
|
Design 07 (ClaudeHub) is the source of truth for tokens: cream
|
|
7
7
|
#FAF9F5 page, ink #1F1E1B, accent #D97757, sidebar #F4F0E7, hairline
|
|
@@ -1191,7 +1191,7 @@ ${tt(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
1191
1191
|
0 1px 2px rgba(91,55,21,0.07),
|
|
1192
1192
|
0 20px 40px -22px rgba(91,55,21,0.30);
|
|
1193
1193
|
}
|
|
1194
|
-
`,
|
|
1194
|
+
`,Ha={id:"editorial",label:"Editorial",theme:Oe.editorial,css:Xl};var Ql=`
|
|
1195
1195
|
/* \u2500\u2500 Mono hub-index \u2014 designs 08 (sidebar) + 16 (top-nav filled pills) \u2500\u2500
|
|
1196
1196
|
White paper #FFFFFF, ink #0D0D0D, muted #5D5D5D, dim #8E8E8E,
|
|
1197
1197
|
hairline #ECECEC, sidebar bg #F9F9F9. CTAs use the primary token;
|
|
@@ -2333,7 +2333,7 @@ ${tt(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2333
2333
|
border-radius: 10px;
|
|
2334
2334
|
box-shadow: none;
|
|
2335
2335
|
}
|
|
2336
|
-
`,
|
|
2336
|
+
`,Ba={id:"mono",label:"Mono",theme:Oe.mono,css:Ql};var ed=`
|
|
2337
2337
|
/* Newsreader 600 \u2014 the true semi-bold cut for the "Built with Inkly"
|
|
2338
2338
|
wordmark. Self-hosted on the Inkly bundle CDN so the self-contained demo
|
|
2339
2339
|
document loads it without a Google Fonts round-trip; Georgia is the
|
|
@@ -4029,7 +4029,7 @@ ${tt(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
4029
4029
|
line-height: 1.45;
|
|
4030
4030
|
}
|
|
4031
4031
|
}
|
|
4032
|
-
`,
|
|
4032
|
+
`,Wa={id:"inkly",label:"Inkly",theme:Oe.inkly,css:ed};var td=`
|
|
4033
4033
|
.hub-index[data-theme="substack"] {
|
|
4034
4034
|
background: #ffffff;
|
|
4035
4035
|
color: #1a1a1a;
|
|
@@ -4960,99 +4960,107 @@ ${tt(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
4960
4960
|
--demo-watermark-mark-radius: 3px;
|
|
4961
4961
|
font-family: var(--demo-font);
|
|
4962
4962
|
}
|
|
4963
|
-
`,Ra={id:"substack",label:"Substack",theme:$e.substack,css:Bl};var $a=[Ea,Ia,Pa,Ra],oe=Object.fromEntries($a.map(t=>[t.id,t]));import{createHash as td}from"crypto";import{mkdir as nd,readFile as er,rm as Mm,stat as Um}from"fs/promises";import{homedir as rd}from"os";import{join as De}from"path";import{fileURLToPath as ad}from"url";import{access as Wl,readFile as Vl,readdir as Zl,stat as Jl}from"fs/promises";import{dirname as Gl,join as vt,resolve as ql,sep as Kl}from"path";async function Z(t){return Wl(t).then(()=>!0,()=>!1)}async function ve(t){let e=ql(t);for(;;){if(await Z(vt(e,"inkly.json")))return e;let n=Gl(e);if(n===e)return null;e=n}}async function Kn(t){let e=vt(t,"demos");if(!await Z(e))return[];let n=[];async function r(a){let i;try{i=await Zl(a,{withFileTypes:!0})}catch{return}if(i.some(o=>o.isFile()&&o.name==="demo.config.json")){let o=a===e?"":a.slice(e.length+1).split(Kl).join("/");n.push({slug:o,dir:a,configPath:vt(a,"demo.config.json")});return}for(let o of i)o.isDirectory()&&await r(vt(a,o.name))}return await r(e),n.sort((a,i)=>a.slug.localeCompare(i.slug))}async function we(t){let e=await Vl(t,"utf8");return JSON.parse(e)}async function St(t){let e=await ve(t);if(!e)throw new Error(`No inkly.json found in ${t} or any parent directory.`);let n=vt(e,"inkly.json"),r=pe.safeParse(await we(n));if(!r.success)throw new Error(`inkly.json failed schema validation: ${r.error.message}`);let a=[];for(let i of await Kn(e)){let o;try{o=xt(await we(i.configPath)).config}catch(d){throw new Error(`demos/${i.slug}/demo.config.json failed schema validation: ${d.message}`)}let s=vt(i.dir,"assets.json"),c=null;if(await Z(s)){let d=yt.safeParse(await we(s));if(!d.success)throw new Error(`demos/${i.slug}/assets.json failed schema validation: ${d.error.message}`);c=d.data}a.push({slug:i.slug,dir:i.dir,configPath:i.configPath,config:o,assetsPath:s,assets:c})}return{root:e,inklyPath:n,inkly:r.data,demos:a}}function Yn(t){let e=t.split("/")[0]??t,n=ke(e);return n.ok?wt.includes(t)?`Demo folder "${t}" uses a reserved slug.`:null:n.reason}async function gn(t){try{let e=await Jl(t);return e.isFile()?e.size:null}catch{return null}}import{mkdir as Yl,rename as Xl,writeFile as Ql}from"fs/promises";import{dirname as ed}from"path";async function Q(t,e,n){await Yl(ed(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await Ql(r,e,n?.mode!=null?{mode:n.mode}:void 0),await Xl(r,t)}var id="https://www.runtime.inklyai.dev";function rt(){let t=process.env.BUNDLES_R2_PUBLIC_BASE_URL;return typeof t=="string"&&t.length>0?t.replace(/\/+$/,""):id}function tr(t,e,n=rt()){return`${n}/runtime/${t}/${e}`}function od(t){return De(rd(),".inkly","cache","runtime",t)}function sd(t){let e=/^(sha(?:256|384|512))-([A-Za-z0-9+/]+=*)$/.exec(t);return e?{algorithm:e[1],expected:e[2]}:null}function _t(t,e){let n=sd(e);return n?td(n.algorithm).update(t).digest("base64")===n.expected:!1}var Ct=class extends Error{constructor(n,r,a){super(`integrity mismatch for ${n}: expected ${r}`+(a?` (from ${a})`:"")+". The bundle does not match inkly.lock. Re-run `inkly lock` to refresh, or the CDN may have been tampered with.");this.file=n;this.expected=r;this.url=a;this.name="IntegrityMismatchError"}},nt=class extends Error{constructor(e){super(e),this.name="LockReadError"}};async function ld(t){let e=De(t,"inkly.lock");if(!await Z(e))throw new nt(`no inkly.lock found in ${t}. Run \`inkly lock\` to generate one.`);let n;try{n=await we(e)}catch(a){throw new nt(`failed to read ${e}: ${a.message}`)}let r=fn.safeParse(n);if(!r.success)throw new nt(`${e} failed InklyLockSchema validation: ${r.error.message}`);return r.data}function dd(t,e){let n=t.lastIndexOf("/");return n===-1?t:`${t.slice(0,n+1)}${e}`}async function Da(t){try{return await er(t)}catch{return null}}async function cd(t){let e=De(t,"manifest.json");if(!await Z(e))return null;try{let n=JSON.parse(await er(e,"utf8")),r=kt.safeParse(n);return r.success?r.data:null}catch{return null}}async function Xn(t,e){await Q(t,e)}async function Qn(t,e){if(t.startsWith("file://"))try{return await er(ad(t))}catch(a){throw new Error(`failed to read ${t}: ${a.message}`)}let n;try{n=await e(t)}catch(a){throw new Error(`failed to fetch ${t}: ${a.message}`)}if(!n.ok)throw new Error(`fetch ${t} returned HTTP ${n.status}`);let r=await n.arrayBuffer();return Buffer.from(r)}async function ja(t){let e=t.fetchImpl??fetch,n=await ld(t.hubRoot),{version:r,url:a,integrity:i}=n.runtime,o=od(r),s=await Da(De(o,"runtime.js")),c=await Da(De(o,"runtime.css")),d=await cd(o);if(s&&c&&d){let I=_t(s,i),k=d.version===r,P=_t(c,d.cssIntegrity);if(I&&k&&P)return{version:r,cacheDir:o,manifest:d,fetched:!1,bytesFetched:0,lock:n}}let u=I=>{let k=t.urlOverrides?.[I];return k||(I==="runtime.js"?a:dd(a,I))};await nd(o,{recursive:!0});let p=u("manifest.json"),h=await Qn(p,e),y;try{let I=JSON.parse(h.toString("utf8")),k=kt.safeParse(I);if(!k.success)throw new Error(`manifest from ${p} failed schema validation: ${k.error.message}`);y=k.data}catch(I){throw new Error(`manifest from ${p} is not valid JSON: ${I.message}`)}if(y.version!==r)throw new Error(`CDN manifest for ${p} reports version ${y.version} but inkly.lock pins ${r}. Re-run \`inkly lock\` to refresh.`);let x=u("runtime.js"),w=await Qn(x,e);if(!_t(w,i))throw new Ct("runtime.js",i,x);let _=u("runtime.css"),O=await Qn(_,e);if(!_t(O,y.cssIntegrity))throw new Ct("runtime.css",y.cssIntegrity,_);return await Xn(De(o,"runtime.js"),w),await Xn(De(o,"runtime.css"),O),await Xn(De(o,"manifest.json"),h),{version:r,cacheDir:o,manifest:y,fetched:!0,bytesFetched:w.byteLength+O.byteLength+h.byteLength,lock:n}}function bn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function bd(t=rt()){return`${t}/runtime/latest.json`}function La(t){return Na==="/"?t:t.split("/").join(Na)}function yd(t){let e=t??globalThis.fetch;if(typeof e!="function")throw new Error("This Node runtime does not provide fetch; Node 20+ is required.");return e}async function za(t,e){let n=await e(t);if(!n.ok)throw new Error(`failed to fetch ${t}: HTTP ${n.status}${n.statusText?` ${n.statusText}`:""}`);let r=ud.from(await n.arrayBuffer()),a;try{a=JSON.parse(r.toString("utf8"))}catch(i){throw new Error(`failed to parse JSON from ${t}: ${i.message}`)}return{json:a,bytes:r}}function xd(t,e){if(!bn(t))throw new Error(`${e} is not an object`);let n=t.version,r=t.hubSkeleton;if(typeof n!="string"||n.length===0)throw new Error(`${e} is missing version`);if(!bn(r))throw new Error(`${e} is missing hubSkeleton`);if(typeof r.url!="string"||r.url.length===0)throw new Error(`${e} is missing hubSkeleton.url`);if(typeof r.integrity!="string"||r.integrity.length===0)throw new Error(`${e} is missing hubSkeleton.integrity`);if(typeof r.version!="number")throw new Error(`${e} is missing hubSkeleton.version`);let a=typeof r.bytes=="number"?r.bytes:void 0;return{version:n,hubSkeleton:{version:r.version,url:r.url,integrity:r.integrity,bytes:a}}}function kd(t,e){if(!bn(t))throw new Error(`${e} is not an object`);if(t.version!==1)throw new Error(`${e} has unsupported skeleton version`);if(typeof t.runtime!="string"||t.runtime.length===0)throw new Error(`${e} is missing runtime`);if(!Array.isArray(t.files))throw new Error(`${e} is missing files`);let n=t.files.map((r,a)=>{if(!bn(r))throw new Error(`${e} files[${a}] is not an object`);if(typeof r.path!="string"||r.path.length===0)throw new Error(`${e} files[${a}].path is missing`);if(typeof r.contents!="string")throw new Error(`${e} files[${a}].contents is missing`);return{path:r.path,contents:r.contents}});return{version:1,runtime:t.runtime,files:n}}function wd(t,e,n){return t.split(e).join(n)}function vd(t){if(t.startsWith("/")||t.startsWith("\\")||/^[A-Za-z]:/.test(t)||t.includes("\\")||t.split("/").some(e=>e===".."||e.length===0))throw new Error(`Unsafe skeleton path from runtime manifest: ${t}`)}function Sd(t,e){let n=t.runtime,r=te(),a=[["{{hubName}}",e.hubName],["{{hubNameJson}}",JSON.stringify(e.hubName)],["{{runtimeVersionJson}}",JSON.stringify(n)],["{{layoutEntry}}",e.layout===void 0?"":` "layout": ${JSON.stringify(e.layout)},
|
|
4964
|
-
|
|
4963
|
+
`,Va={id:"substack",label:"Substack",theme:Oe.substack,css:td};var Ja=[Wa,Ha,Ba,Va],le=Object.fromEntries(Ja.map(t=>[t.id,t]));import{createHash as hd}from"crypto";import{mkdir as md,readFile as lr,rm as cf,stat as uf}from"fs/promises";import{homedir as fd}from"os";import{join as Ne}from"path";import{fileURLToPath as gd}from"url";import{access as nd,readFile as rd,readdir as ad,stat as id}from"fs/promises";import{dirname as od,join as At,resolve as sd,sep as ld}from"path";async function V(t){return nd(t).then(()=>!0,()=>!1)}async function Te(t){let e=sd(t);for(;;){if(await V(At(e,"inkly.json")))return e;let n=od(e);if(n===e)return null;e=n}}async function ar(t){let e=At(t,"demos");if(!await V(e))return[];let n=[];async function r(a){let i;try{i=await ad(a,{withFileTypes:!0})}catch{return}if(i.some(o=>o.isFile()&&o.name==="demo.config.json")){let o=a===e?"":a.slice(e.length+1).split(ld).join("/");n.push({slug:o,dir:a,configPath:At(a,"demo.config.json")});return}for(let o of i)o.isDirectory()&&await r(At(a,o.name))}return await r(e),n.sort((a,i)=>a.slug.localeCompare(i.slug))}async function Ce(t){let e=await rd(t,"utf8");return JSON.parse(e)}async function It(t){let e=await Te(t);if(!e)throw new Error(`No inkly.json found in ${t} or any parent directory.`);let n=At(e,"inkly.json"),r=ge.safeParse(await Ce(n));if(!r.success)throw new Error(`inkly.json failed schema validation: ${r.error.message}`);let a=[];for(let i of await ar(e)){let o;try{o=Ct(await Ce(i.configPath)).config}catch(d){throw new Error(`demos/${i.slug}/demo.config.json failed schema validation: ${d.message}`)}let s=At(i.dir,"assets.json"),c=null;if(await V(s)){let d=_t.safeParse(await Ce(s));if(!d.success)throw new Error(`demos/${i.slug}/assets.json failed schema validation: ${d.error.message}`);c=d.data}a.push({slug:i.slug,dir:i.dir,configPath:i.configPath,config:o,assetsPath:s,assets:c})}return{root:e,inklyPath:n,inkly:r.data,demos:a}}function ir(t){let e=t.split("/")[0]??t,n=_e(e);return n.ok?lt.includes(t)?`Demo folder "${t}" uses a reserved slug.`:null:n.reason}async function wn(t){try{let e=await id(t);return e.isFile()?e.size:null}catch{return null}}import{mkdir as dd,rename as cd,writeFile as ud}from"fs/promises";import{dirname as pd}from"path";async function Y(t,e,n){await dd(pd(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await ud(r,e,n?.mode!=null?{mode:n.mode}:void 0),await cd(r,t)}var bd="https://www.runtime.inklyai.dev";function ct(){let t=process.env.BUNDLES_R2_PUBLIC_BASE_URL;return typeof t=="string"&&t.length>0?t.replace(/\/+$/,""):bd}function dr(t,e,n=ct()){return`${n}/runtime/${t}/${e}`}function yd(t){return Ne(fd(),".inkly","cache","runtime",t)}function xd(t){let e=/^(sha(?:256|384|512))-([A-Za-z0-9+/]+=*)$/.exec(t);return e?{algorithm:e[1],expected:e[2]}:null}function Pt(t,e){let n=xd(e);return n?hd(n.algorithm).update(t).digest("base64")===n.expected:!1}var Et=class extends Error{constructor(n,r,a){super(`integrity mismatch for ${n}: expected ${r}`+(a?` (from ${a})`:"")+". The bundle does not match inkly.lock. Re-run `inkly lock` to refresh, or the CDN may have been tampered with.");this.file=n;this.expected=r;this.url=a;this.name="IntegrityMismatchError"}},dt=class extends Error{constructor(e){super(e),this.name="LockReadError"}};async function kd(t){let e=Ne(t,"inkly.lock");if(!await V(e))throw new dt(`no inkly.lock found in ${t}. Run \`inkly lock\` to generate one.`);let n;try{n=await Ce(e)}catch(a){throw new dt(`failed to read ${e}: ${a.message}`)}let r=kn.safeParse(n);if(!r.success)throw new dt(`${e} failed InklyLockSchema validation: ${r.error.message}`);return r.data}function wd(t,e){let n=t.lastIndexOf("/");return n===-1?t:`${t.slice(0,n+1)}${e}`}async function Za(t){try{return await lr(t)}catch{return null}}async function vd(t){let e=Ne(t,"manifest.json");if(!await V(e))return null;try{let n=JSON.parse(await lr(e,"utf8")),r=Tt.safeParse(n);return r.success?r.data:null}catch{return null}}async function or(t,e){await Y(t,e)}async function sr(t,e){if(t.startsWith("file://"))try{return await lr(gd(t))}catch(a){throw new Error(`failed to read ${t}: ${a.message}`)}let n;try{n=await e(t)}catch(a){throw new Error(`failed to fetch ${t}: ${a.message}`)}if(!n.ok)throw new Error(`fetch ${t} returned HTTP ${n.status}`);let r=await n.arrayBuffer();return Buffer.from(r)}async function cr(t){let e=t.fetchImpl??fetch,n=t.lock??await kd(t.hubRoot),{version:r,url:a,integrity:i}=n.runtime,o=yd(r),s=await Za(Ne(o,"runtime.js")),c=await Za(Ne(o,"runtime.css")),d=await vd(o);if(s&&c&&d){let N=Pt(s,i),E=d.version===r,b=Pt(c,d.cssIntegrity);if(N&&E&&b)return{version:r,cacheDir:o,manifest:d,fetched:!1,bytesFetched:0,lock:n}}let u=N=>{let E=t.urlOverrides?.[N];return E||(N==="runtime.js"?a:wd(a,N))};await md(o,{recursive:!0});let p=u("manifest.json"),h=await sr(p,e),f;try{let N=JSON.parse(h.toString("utf8")),E=Tt.safeParse(N);if(!E.success)throw new Error(`manifest from ${p} failed schema validation: ${E.error.message}`);f=E.data}catch(N){throw new Error(`manifest from ${p} is not valid JSON: ${N.message}`)}if(f.version!==r)throw new Error(`CDN manifest for ${p} reports version ${f.version} but inkly.lock pins ${r}. Re-run \`inkly lock\` to refresh.`);let w=u("runtime.js"),k=await sr(w,e);if(!Pt(k,i))throw new Et("runtime.js",i,w);let C=u("runtime.css"),$=await sr(C,e);if(!Pt($,f.cssIntegrity))throw new Et("runtime.css",f.cssIntegrity,C);return await or(Ne(o,"runtime.js"),k),await or(Ne(o,"runtime.css"),$),await or(Ne(o,"manifest.json"),h),{version:r,cacheDir:o,manifest:f,fetched:!0,bytesFetched:k.byteLength+$.byteLength+h.byteLength,lock:n}}import{readFile as qa,writeFile as Sd}from"fs/promises";import{dirname as ur,isAbsolute as _d,join as Rt,resolve as Cd}from"path";import{fileURLToPath as Td,pathToFileURL as Ad}from"url";function Le(t,e,n){t.push({level:e,message:n})}async function Id(){let t=ur(Td(import.meta.url));for(let e=0;e<10;e+=1){let n=Rt(t,"node_modules","@inkly","runtime","dist","manifest.json");if(await V(n))return n;let r=Rt(t,"packages","inkly-runtime","dist","manifest.json");if(await V(r))return r;let a=ur(t);if(a===t)break;t=a}return null}async function Ga(t){let e=JSON.parse(await qa(t,"utf8")),n=Tt.safeParse(e);if(!n.success)throw new Error(`${t} failed RuntimeManifestSchema validation: ${n.error.message}`);return n.data}async function Pd(t,e){let n=ct(),r=dr(t,"manifest.json",n);try{let a=await e(r);if(!a.ok)return null;let i=JSON.parse(await a.text()),o=Tt.safeParse(i);return o.success?{manifest:o.data,url:r}:null}catch{return null}}async function Ed(t,e){if(e.manifestPath)return{manifest:await Ga(e.manifestPath),source:"local",manifestPath:e.manifestPath};if(!e.localOnly){let r=e.fetchImpl??fetch,a=await Pd(t,r);if(a){if(a.manifest.version!==t)throw new Error(`CDN manifest at ${a.url} reports version ${a.manifest.version} but inkly.json pins ${t}. Wait for the publish workflow to upload the matching artifact, or update inkly.json#runtime to match.`);return{manifest:a.manifest,source:"cdn"}}}let n=await Id();if(!n)throw new Error(`Could not fetch runtime manifest for ${t} from ${ct()} and no local @inkly/runtime/dist/manifest.json was found. Either publish the runtime to R2, run \`npm run build:runtime\` in @inkly/runtime, or pass \`inkly lock --local <path-to-inkly-runtime>\`.`);return{manifest:await Ga(n),source:"local",manifestPath:n}}async function vn(t,e={}){let n=Rt(t,"inkly.json"),r=await Ce(n),a=typeof r.runtime=="string"?r.runtime:null;if(!a)throw new Error('inkly.json is missing a string "runtime" pin.');if(!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(a))throw new Error(`inkly.json#runtime must be an exact semver (got "${a}"). Set runtime to an exact version and put your compatibility range in runtimeRange.`);let{manifest:i,source:o,manifestPath:s}=await Ed(a,e);if(i.version!==a)throw new Error(`Runtime manifest reports version ${i.version} but inkly.json pins ${a}. Build the matching Inkly runtime version (or upgrade the pin) and retry.`);return{lock:{$schema:"https://inklyai.dev/inkly.lock",runtime:{version:i.version,url:o==="local"&&s?Ad(Rt(ur(s),"runtime.js")).toString():dr(i.version,"runtime.js"),integrity:i.integrity}},manifest:i,source:o}}async function Sn(t){let e=[],n=await Te(t.cwd);if(!n)return Le(e,"error",`No inkly.json found in ${t.cwd} or any parent directory.`),be({ok:!1,hubRoot:null,lockPath:null,lock:null,source:null,issues:e,drifted:!1,options:t});let r=Rt(n,"inkly.lock"),a=t.manifestPath?_d(t.manifestPath)?t.manifestPath:Cd(t.cwd,t.manifestPath):void 0;if(t.check){if(!await V(r))return Le(e,"error","inkly.lock is missing. Run `inkly lock` to create it."),be({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:e,drifted:!0,options:t});let i=await Ce(r),o=kn.safeParse(i);if(!o.success)return Le(e,"error",`inkly.lock failed schema validation: ${o.error.message}`),be({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:e,drifted:!0,options:t});let s=Rt(n,"inkly.json"),c=await Ce(s),d=typeof c.runtime=="string"?c.runtime:null;if(!d)return Le(e,"error",'inkly.json is missing a string "runtime" pin.'),be({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:e,drifted:!0,options:t});if(o.data.runtime.version!==d)return Le(e,"error",`inkly.lock pins runtime ${o.data.runtime.version}, but inkly.json pins ${d}. Re-run \`inkly lock\` to refresh.`),be({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:null,issues:e,drifted:!0,options:t});try{let u=await vn(n,{manifestPath:a,localOnly:!!a||t.localOnly,fetchImpl:t.fetchImpl});return u.lock.runtime.integrity!==o.data.runtime.integrity?(Le(e,"error",`inkly.lock integrity does not match what ${u.source==="cdn"?ct():"the local build"} serves for runtime ${d}. Re-run \`inkly lock\` to refresh, or someone tampered with the source.`),be({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:u.source,issues:e,drifted:!0,options:t})):be({ok:!0,hubRoot:n,lockPath:r,lock:o.data,source:u.source,issues:e,drifted:!1,options:t})}catch(u){return Le(e,"error",u.message),be({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:null,issues:e,drifted:!0,options:t})}}try{let{lock:i,source:o}=await vn(n,{manifestPath:a,localOnly:!!a||t.localOnly,fetchImpl:t.fetchImpl}),s=JSON.stringify(i,null,2)+`
|
|
4964
|
+
`,d=(await V(r)?await qa(r,"utf8"):null)!==s;return d&&await Sd(r,s,"utf8"),be({ok:!0,hubRoot:n,lockPath:r,lock:i,source:o,issues:e,drifted:d,options:t})}catch(i){return Le(e,"error",i.message),be({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:e,drifted:!1,options:t})}}function be(t){let{ok:e,hubRoot:n,lockPath:r,lock:a,source:i,issues:o,drifted:s,options:c}=t,d={ok:e,hubRoot:n,lockPath:r,lock:a,source:i,issues:o,drifted:s};if(!c.silent)if(c.json)process.stdout.write(JSON.stringify(d,null,2)+`
|
|
4965
|
+
`);else if(e)c.check?process.stdout.write(`inkly lock --check: inkly.lock matches inkly.json (runtime ${a?.runtime.version}, source: ${i??"unknown"}).
|
|
4966
|
+
`):s?process.stdout.write(`inkly lock: wrote ${r} (runtime ${a?.runtime.version}, source: ${i??"unknown"}).
|
|
4967
|
+
`):process.stdout.write(`inkly lock: ${r} already up to date (runtime ${a?.runtime.version}, source: ${i??"unknown"}).
|
|
4968
|
+
`);else{for(let u of o)process.stdout.write(`${u.level.toUpperCase()} ${u.message}
|
|
4969
|
+
`);process.stdout.write(`inkly lock failed
|
|
4970
|
+
`)}return d}function _n(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ld(t=ct()){return`${t}/runtime/latest.json`}function Xa(t){return Ya==="/"?t:t.split("/").join(Ya)}function zd(t){let e=t??globalThis.fetch;if(typeof e!="function")throw new Error("This Node runtime does not provide fetch; Node 20+ is required.");return e}async function Qa(t,e){let n=await e(t);if(!n.ok)throw new Error(`failed to fetch ${t}: HTTP ${n.status}${n.statusText?` ${n.statusText}`:""}`);let r=Rd.from(await n.arrayBuffer()),a;try{a=JSON.parse(r.toString("utf8"))}catch(i){throw new Error(`failed to parse JSON from ${t}: ${i.message}`)}return{json:a,bytes:r}}function Md(t,e){if(!_n(t))throw new Error(`${e} is not an object`);let n=t.version,r=t.hubSkeleton;if(typeof n!="string"||n.length===0)throw new Error(`${e} is missing version`);if(!_n(r))throw new Error(`${e} is missing hubSkeleton`);if(typeof r.url!="string"||r.url.length===0)throw new Error(`${e} is missing hubSkeleton.url`);if(typeof r.integrity!="string"||r.integrity.length===0)throw new Error(`${e} is missing hubSkeleton.integrity`);if(typeof r.version!="number")throw new Error(`${e} is missing hubSkeleton.version`);let a=typeof r.bytes=="number"?r.bytes:void 0;return{version:n,hubSkeleton:{version:r.version,url:r.url,integrity:r.integrity,bytes:a}}}function Ud(t,e){if(!_n(t))throw new Error(`${e} is not an object`);if(t.version!==1)throw new Error(`${e} has unsupported skeleton version`);if(typeof t.runtime!="string"||t.runtime.length===0)throw new Error(`${e} is missing runtime`);if(!Array.isArray(t.files))throw new Error(`${e} is missing files`);let n=t.files.map((r,a)=>{if(!_n(r))throw new Error(`${e} files[${a}] is not an object`);if(typeof r.path!="string"||r.path.length===0)throw new Error(`${e} files[${a}].path is missing`);if(typeof r.contents!="string")throw new Error(`${e} files[${a}].contents is missing`);return{path:r.path,contents:r.contents}});return{version:1,runtime:t.runtime,files:n}}function Fd(t,e,n){return t.split(e).join(n)}function Hd(t){if(t.startsWith("/")||t.startsWith("\\")||/^[A-Za-z]:/.test(t)||t.includes("\\")||t.split("/").some(e=>e===".."||e.length===0))throw new Error(`Unsafe skeleton path from runtime manifest: ${t}`)}function Bd(t,e){let n=t.runtime,r=ne(),a=[["{{hubName}}",e.hubName],["{{hubNameJson}}",JSON.stringify(e.hubName)],["{{runtimeVersionJson}}",JSON.stringify(n)],["{{layoutEntry}}",e.layout===void 0?"":` "layout": ${JSON.stringify(e.layout)},
|
|
4971
|
+
`],["{{themeJson}}",JSON.stringify(e.theme??"inkly")],["{{starterDemoIdJson}}",JSON.stringify(r)]],i=t.files.map(u=>{Hd(u.path);let p=u.contents;for(let[h,f]of a)p=Fd(p,h,f);if(/\{\{[A-Za-z][A-Za-z0-9]*\}\}/.test(p))throw new Error(`Unresolved placeholder in runtime skeleton file: ${u.path}`);return{path:u.path,contents:p}}),o=i.find(u=>u.path==="inkly.json");if(!o)throw new Error("Runtime skeleton is missing inkly.json");let s=ge.safeParse(JSON.parse(o.contents));if(!s.success)throw new Error(`Runtime skeleton inkly.json is invalid: ${s.error.message}`);let c=i.find(u=>u.path==="demos/getting-started/demo.config.json");if(!c)throw new Error("Runtime skeleton is missing demos/getting-started/demo.config.json");let d=ot.safeParse(JSON.parse(c.contents));if(!d.success)throw new Error(`Runtime skeleton starter demo is invalid: ${d.error.message}`);return i}async function Wd(t){let{latestUrl:e,fetchImpl:n}=t,r=await Qa(e,n),a=Md(r.json,e),i=new URL(a.hubSkeleton.url,e).toString(),o=await Qa(i,n);if(!Pt(o.bytes,a.hubSkeleton.integrity))throw new Error(`integrity mismatch for hub-skeleton.json from ${i}`);if(typeof a.hubSkeleton.bytes=="number"&&o.bytes.byteLength!==a.hubSkeleton.bytes)throw new Error(`byte length mismatch for hub-skeleton.json from ${i}`);let s=Ud(o.json,i);if(s.runtime!==a.version)throw new Error(`runtime/latest.json points at ${a.version}, but hub-skeleton.json declares ${s.runtime}`);return s}async function ei(t){let{name:e,cwd:n,layout:r,theme:a,silent:i}=t,o=_e(e);if(!o.ok)throw new Error(o.reason);let s=r===void 0?void 0:tr.safeParse(r);if(s&&!s.success)throw new Error("Invalid layout. Expected one of: sidebar, tabs.");if(a!==void 0){if(a.length===0)throw new Error("Invalid theme. Expected a theme preset id.");if(!le[a]){let f=Object.keys(le).join(", ");throw new Error(`Invalid theme "${a}". Expected one of: ${f}.`)}}let c=Nd(n,e);if(await Dd(c).then(()=>!0,()=>!1))throw new Error(`Directory already exists: ${c}. Refusing to overwrite \u2014 choose a different name or remove it first.`);let u=await Wd({latestUrl:t.runtimeManifestUrl??Ld(),fetchImpl:zd(t.fetchImpl)}),p=Bd(u,{hubName:e,layout:s?.data,theme:a});await Ka(c,{recursive:!0}),await Promise.all(p.map(async f=>{let w=Xa(f.path),k=Od(c,w);await Ka(jd(k),{recursive:!0}),await $d(k,f.contents,"utf8")}));let h=!1;try{let f=await Sn({cwd:c,silent:!0,fetchImpl:t.fetchImpl});h=f.ok&&f.lockPath!==null}catch{}return i||(process.stdout.write(`Scaffolded hub ${e} at ${c}
|
|
4965
4972
|
|
|
4966
4973
|
Next steps:
|
|
4967
4974
|
cd ${e}
|
|
4968
4975
|
inkly dev
|
|
4969
4976
|
open http://localhost:3000
|
|
4970
|
-
`),{dir:c,files:p.map(
|
|
4971
|
-
`)}var
|
|
4972
|
-
${i}`),a}function
|
|
4977
|
+
`),h||process.stdout.write("\nNote: could not pin the runtime yet (inkly.lock not written). `inkly dev` will resolve it on first run; run `inkly lock` to pin it.\n")),{dir:c,files:p.map(f=>Xa(f.path))}}import{createServer as Zd}from"vite";import Gd from"chokidar";import{readFile as ce,readdir as qd,stat as Yt,mkdtemp as Kd,mkdir as Yd,cp as Xd,writeFile as Qd,rm as ec}from"fs/promises";import{existsSync as ut,createReadStream as tc}from"fs";import{tmpdir as nc}from"os";import{basename as rc,dirname as pt,extname as ac,join as O,relative as ic,resolve as ze,sep as An}from"path";import{fileURLToPath as di}from"url";import{createRequire as oc}from"module";import{createConnection as sc,createServer as lc}from"net";import{readFile as ti,stat as Vd}from"fs/promises";import{relative as Jd}from"path";async function Cn(t){let e=await Te(t);if(!e)throw new Error(`No inkly.json found in ${t} or any parent directory. Run \`inkly init <name>\` first or cd into your hub.`);let n=[],r=[],a=[],i=[];for(let s of await ar(e)){let c;try{c=await ti(s.configPath,"utf8")}catch(h){a.push({slug:s.slug,configPath:s.configPath,message:`failed to read demo.config.json (${h.message})`});continue}let d;try{d=JSON.parse(c)}catch(h){a.push({slug:s.slug,configPath:s.configPath,message:`demo.config.json is not valid JSON (${h.message})`});continue}let u;try{u=Ct(d)}catch(h){a.push({slug:s.slug,configPath:s.configPath,message:`demo.config.json failed schema validation: ${h.message}`});continue}u.changed&&(await ni(s.configPath,u.config),n.push({slug:s.slug,configPath:s.configPath,reason:"heal"}));let p=(await Vd(s.configPath)).mtimeMs;i.push({slug:s.slug,configPath:s.configPath,id:u.config.id,mtimeMs:p})}let o=za(i.map(s=>({...s,updatedAt:s.mtimeMs})));for(let{entry:s,newId:c}of o){let d=await ti(s.configPath,"utf8"),u=JSON.parse(d);u.id=c,await ni(s.configPath,u),r.push({slug:s.slug,configPath:s.configPath,reason:"remint"})}return{hubRoot:e,healed:n,reminted:r,skipped:a}}function qt(t,e){return Jd(t,e).split(/[\\/]/).join("/")}async function ni(t,e){await Y(t,JSON.stringify(e,null,2)+`
|
|
4978
|
+
`)}var dc=di(import.meta.url),$t=pt(dc),hr="127.0.0.1";function ri(t){let e=ze($t,"template",t);return ut(e)?e:ze($t,"..","..","template",t)}function cc(t){let e=[ze($t,"..","vendor",t),ze($t,"..","..","vendor",t),ze($t,"..","..","..","public","__inkly","vendor",t)];for(let n of e)if(ut(n))return n;return null}function uc(t){try{let r=oc(O(t,"package.json")).resolve("@inkly/runtime/package.json");return ze(pt(r),"dist")}catch{}let e=$t;for(let n=0;n<8;n++){let r=O(e,"packages","inkly-runtime","dist");if(ut(r))return r;let a=pt(e);if(a===e)break;e=a}return null}function ai(t,e){if(!e)return t;let{integrity:n}=e.lock.runtime,r=e.manifest.cssIntegrity,a=t;a=a.replace(/<link rel="stylesheet" href="\/__inkly\/runtime\.css" \/>/,`<link rel="stylesheet" href="/__inkly/runtime.css" integrity="${r}" crossorigin="anonymous" />`);let i=`<link rel="modulepreload" href="/__inkly/runtime.js" integrity="${n}" crossorigin="anonymous" />`;return/<link rel="prefetch" href="\/__inkly\/runtime\.js"[^>]*\/>/.test(a)?a=a.replace(/<link rel="prefetch" href="\/__inkly\/runtime\.js"[^>]*\/>/,i):a=a.replace(/<link rel="stylesheet" href="\/__inkly\/runtime\.css"[^>]*\/>/,o=>`${o}
|
|
4979
|
+
${i}`),a}function U(t,e,n,r){t.statusCode=e,t.setHeader("content-type",n),t.setHeader("cache-control","no-store"),t.end(r)}function Xt(t,e,n){t.statusCode=200,t.setHeader("content-type",n),t.setHeader("cache-control","no-store");let r=tc(e);r.on("error",a=>{t.statusCode=500,t.end(`Failed to read ${e}: ${a.message}`)}),r.pipe(t)}var ii=`Inkly runtime artifact not found. Run:
|
|
4973
4980
|
npm run build:runtime -w @inkly/runtime
|
|
4974
4981
|
then restart \`inkly dev\`.
|
|
4975
|
-
`;function
|
|
4976
|
-
${i.error.message}`);let o=i.data,s=await
|
|
4977
|
-
</head>`)}function
|
|
4978
|
-
`)}
|
|
4979
|
-
`);
|
|
4980
|
-
`)}
|
|
4981
|
-
`)
|
|
4982
|
-
`)}
|
|
4983
|
-
`)
|
|
4984
|
-
`)
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
`)
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4982
|
+
`;function pc(t){let e=ze(t);for(;;){if(ut(O(e,"inkly.json")))return e;let n=pt(e);if(n===e)return null;e=n}}function oi(t){if(!t)return null;let e=t.trim();return e?/^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i.test(e)||e.startsWith("/")?e:e.startsWith("public/")?`/${e.slice(7)}`:`/${e.replace(/^\.\/+/,"")}`:null}function mr(t){return t.brand?{...t,brand:{...t.brand,...t.brand.logo?{logo:oi(t.brand.logo)??t.brand.logo}:{},...t.brand.favicon?{favicon:oi(t.brand.favicon)??t.brand.favicon}:{}}}:t}function ci(t,e){return t.publicUrl&&/^(https?:)?\/\//i.test(t.publicUrl)?t.publicUrl:t.file?`/${e}/${t.file}`:t.publicUrl??null}function hc(t){let e=new Map(t.assets.map(n=>[n.id,n]));return Ma({slug:t.slug,config:t.config,resolveAssetSrc:n=>{if(!n.startsWith("asset:"))return n;let r=e.get(n.slice(6));return r?ci(r,t.slug):null}})}async function mc(t){let e=O(pt(t),"assets.json");try{let n=await ce(e,"utf8"),r=JSON.parse(n);return Array.isArray(r.assets)?r.assets.filter(a=>{if(!a||typeof a!="object")return!1;let i=a;return typeof i.id=="string"&&i.id.length>0}):[]}catch{return[]}}async function fc(t){let e=O(t,"demos");if(!ut(e))return[];let n=[];async function r(a){let i;try{i=await qd(a,{withFileTypes:!0})}catch{return}if(i.some(s=>s.isFile()&&s.name==="demo.config.json")){let s=ic(e,a).split(An).join("/");n.push({slug:s,configPath:O(a,"demo.config.json")});return}for(let s of i)s.isDirectory()&&await r(O(a,s.name))}return await r(e),n}async function si(t,e){let n=O(t,"inkly.json"),r;try{r=await ce(n,"utf8")}catch(p){throw new Error(`Failed to read inkly.json at ${n}: ${p.message}`)}let a;try{a=JSON.parse(r)}catch(p){throw new Error(`inkly.json is not valid JSON: ${p.message}`)}let i=ge.safeParse(a);if(!i.success)throw new Error(`inkly.json failed schema validation:
|
|
4983
|
+
${i.error.message}`);let o=i.data,s=await fc(t);for(let p of s){let h=Qt(p.slug);if(!h.ok)throw new Error(`Demo folder "${p.slug}" has an invalid slug: ${h.reason}`);if(lt.includes(p.slug))throw new Error(`Demo folder "${p.slug}" uses a reserved slug.`)}let c=[];for(let p of s){let h;try{h=await ce(p.configPath,"utf8")}catch(k){e(`Skipping ${p.slug}: failed to read demo.config.json (${k.message})`);continue}let f;try{f=JSON.parse(h)}catch(k){e(`Skipping ${p.slug}: demo.config.json is not valid JSON (${k.message})`);continue}let w;try{w=Ct(f).config}catch(k){e(`Skipping ${p.slug}: demo.config.json failed schema validation: ${k.message}`);continue}c.push({slug:p.slug,configPath:p.configPath,config:w,assets:await mc(p.configPath)})}let d=c.map(p=>hc(p)),u=new Map;for(let p of c)u.set(p.slug,p);return{hub:o,hubPath:n,demos:c,index:d,bySlug:u}}function Tn(t,e,n){let r=JSON.stringify(n).replace(/<\/(script)/gi,"<\\/$1"),a=`<script id="${e}" type="application/json">${r}</script>`;return t.includes(`id="${e}"`)?t.replace(new RegExp(`<script id="${e}"[^>]*>[\\s\\S]*?</script>`),a):t.replace("</head>",`${a}
|
|
4984
|
+
</head>`)}function gc(t){let e=t.hub.theme??"inkly",n=le[e];return{hub:mr(t.hub),demos:t.index,theme:{id:e,tokens:n?.theme??null,css:n?.css??""}}}var bc={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".txt":"text/plain; charset=utf-8",".md":"text/markdown; charset=utf-8"};function Kt(t){return bc[ac(t).toLowerCase()]??"application/octet-stream"}function Qt(t){let e=t.split("/").filter(Boolean);if(e.length===0)return{ok:!1,reason:"Name cannot be empty."};for(let n of e){let r=_e(n);if(!r.ok)return r}return lt.includes(t)?{ok:!1,reason:`Demo folder "${t}" uses a reserved slug.`}:{ok:!0}}function li(t,e){let n;try{n=decodeURIComponent(t)}catch{return null}let r=n.replace(/^\/+/,"").replace(/\/+$/,"");if(!r)return null;let a=r.split("/").filter(Boolean);for(let i=a.length;i>=1;i-=1){let o=a.slice(0,i).join("/");if(!Qt(o).ok)continue;let s=e.bySlug.get(o);if(s)return{slug:o,demo:s,rel:a.slice(i).join("/")}}return null}async function yc(t){return new Promise(e=>{let n=lc();n.once("error",()=>e(!1)),n.once("listening",()=>{n.close(()=>e(!0))}),n.listen(t,hr)})}async function xc(t,e){return new Promise(n=>{let r=!1,a=o=>{r||(r=!0,i.destroy(),n(o))},i=sc({port:t,host:e});i.setTimeout(250),i.once("connect",()=>a(!0)),i.once("timeout",()=>a(!1)),i.once("error",()=>a(!1))})}async function kc(t){if(!await yc(t))return!1;for(let e of["localhost","127.0.0.1","::1"])if(await xc(t,e))return!1;return!0}async function wc(t){if(t===0)return 0;if(!Number.isInteger(t)||t<0||t>65535)throw new Error(`invalid port: ${t}`);for(let e=t;e<=65535;e+=1)if(await kc(e))return e;throw new Error(`No available port found at or above ${t}`)}function vc(t,e){let n=t.httpServer?.address();return n&&typeof n=="object"?n.port:t.config.server.port??e}async function Sc(t){let e=rc(t),n=/^[a-z0-9][a-z0-9-]*$/.test(e)&&!lt.includes(e)?e:"demo",r=await Kd(O(nc(),"inkly-dev-"));await Yd(O(r,"demos"),{recursive:!0}),await Xd(t,O(r,"demos",n),{recursive:!0});let a=n;try{let o=JSON.parse(await ce(O(t,"demo.config.json"),"utf8"));typeof o.title=="string"&&o.title.trim()&&(a=o.title.trim())}catch{}let i={$schema:"https://inklyai.dev/inkly.json",name:a,runtime:"0.6.0",theme:"inkly",collections:[{name:"Preview",demos:[n]}]};return await Qd(O(r,"inkly.json"),`${JSON.stringify(i,null,2)}
|
|
4985
|
+
`),{hubRoot:r,slug:n}}async function ui(t){let{cwd:e,port:n=3e3,silent:r,skipRuntimeResolve:a}=t,i=j=>{r||process.stderr.write(`[inkly dev] ${j}
|
|
4986
|
+
`)},o=t.path?ze(e,t.path):e,s=pc(o),c=null;if(!s)if(ut(O(o,"demo.config.json"))){let j=await Sc(o);s=j.hubRoot,c=j.hubRoot,r||process.stdout.write(`[inkly dev] serving standalone demo "${j.slug}" via a temporary hub (no inkly.json required)
|
|
4987
|
+
`)}else throw new Error(`No inkly.json found in ${o} or any parent directory. Run \`inkly init <name>\` first, cd into your hub, or point \`inkly dev\` at an exported demo folder (a directory containing demo.config.json).`);let d=await Cn(s);if(!r){for(let j of d.healed)process.stdout.write(`[inkly dev] healed missing id: ${qt(d.hubRoot,j.configPath)}
|
|
4988
|
+
`);for(let j of d.reminted)process.stdout.write(`[inkly dev] re-minted duplicate id: ${qt(d.hubRoot,j.configPath)}
|
|
4989
|
+
`)}let u=await si(s,i),p=O(s,"inkly.lock"),h=ut(p),f=null;if(h&&!a)try{if(f=await cr({hubRoot:s}),!r)if(f.fetched){let j=(f.bytesFetched/1048576).toFixed(2);process.stdout.write(`[inkly dev] fetched runtime ${f.version} from ${f.lock.runtime.url} (${j} MiB)
|
|
4990
|
+
`)}else process.stdout.write(`[inkly dev] runtime ${f.version} loaded from cache (${f.cacheDir})
|
|
4991
|
+
`)}catch(j){throw j instanceof dt||j instanceof Et?j:new Error(`Failed to resolve runtime via inkly.lock: ${j.message}`)}else if(!a)try{let{lock:j,source:G}=await vn(s);if(f=await cr({hubRoot:s,lock:j}),!r){let ue=f.fetched?`fetched ${(f.bytesFetched/1048576).toFixed(2)} MiB`:"from cache";process.stdout.write(`[inkly dev] no inkly.lock \u2014 resolved runtime ${f.version} from ${G==="cdn"?"the CDN":"a local build"} (${ue}). Run \`inkly lock\` to pin this version.
|
|
4992
|
+
`)}}catch(j){r||process.stdout.write(`[inkly dev] no inkly.lock and could not resolve a published runtime (${j.message}). Falling back to the in-workspace @inkly/runtime dist. Run \`inkly lock\` once a runtime is published to R2 to pin a version.
|
|
4993
|
+
`)}let w=f?.cacheDir??uc(s),k=ai(await ce(ri("hub-index.html"),"utf8"),f),C=ai(await ce(ri("demo.html"),"utf8"),f),$=await wc(n),N=$,E=async()=>{},b=await Zd({root:s,server:{port:$,strictPort:!0,host:hr,hmr:{host:hr},fs:{allow:[s,di(new URL("../",import.meta.url))]}},appType:"custom",clearScreen:!1,logLevel:r?"silent":"info",configFile:!1,plugins:[{name:"inkly-dev-endpoints",configureServer(j){let G=(ue,I,ae)=>{let v=(ue.url??"").split("?")[0]??"";if(v==="/"||v==="/index.html"){let R=Tn(k,"__inkly_hub_data",gc(u));U(I,200,"text/html; charset=utf-8",R);return}if(v.startsWith("/__inkly/cache/")){let R=decodeURIComponent(v.slice(15));if(!R||R.includes("..")||R.includes("/")){U(I,400,"text/plain; charset=utf-8","Invalid cache path");return}let F=O(s,".inkly","cache",R);Yt(F).then(M=>{if(!M.isFile()){U(I,404,"text/plain; charset=utf-8",`Capture not found: ${R}`);return}Xt(I,F,Kt(F))},()=>U(I,404,"text/plain; charset=utf-8",`Capture not found: ${R}`));return}if(v.startsWith("/__inkly/snapshot/")){let R=decodeURIComponent(v.slice(18)),M=R.indexOf("/snapshots/"),J=M>0?R.slice(0,M):"",K=M>0?R.slice(M+1):"";if(!Qt(J).ok||!u.bySlug.has(J)||!K||K.includes("..")||K.startsWith("/")){U(I,400,"text/plain; charset=utf-8","Invalid snapshot path");return}if(!K.startsWith("snapshots/")){U(I,400,"text/plain; charset=utf-8","Invalid snapshot path");return}let xe=O(s,"demos",...J.split("/")),pe=O(xe,K);if(!pe.startsWith(xe+An)&&pe!==xe){U(I,400,"text/plain; charset=utf-8","Invalid snapshot path");return}Yt(pe).then(async Ft=>{if(!Ft.isFile()){U(I,404,"text/plain; charset=utf-8",`Snapshot not found: ${K}`);return}if(!/\.html?$/i.test(K)){let Po=await ce(pe,"utf8");U(I,200,Kt(pe),st(Po));return}let te=rr(K),Ht=te?O(xe,te):null,[Hn,Bt]=await Promise.all([ce(pe,"utf8"),Ht?ce(Ht,"utf8").catch(()=>null):Promise.resolve(null)]),sn=Ua({htmlPath:K,html:Hn,css:Bt,cssHref:te?`/__inkly/snapshot/${encodeURIComponent(J)}/${te.split("/").map(encodeURIComponent).join("/")}`:null});U(I,200,Kt(pe),sn)},()=>U(I,404,"text/plain; charset=utf-8",`Snapshot not found: ${K}`));return}if(v==="/__inkly/hub"){U(I,200,"application/json; charset=utf-8",JSON.stringify(mr(u.hub)));return}if(v==="/__inkly/demos"){U(I,200,"application/json; charset=utf-8",JSON.stringify(u.index));return}if(v.startsWith("/__inkly/demo/")){let R=decodeURIComponent(v.slice(14)),F=Qt(R);if(!F.ok){U(I,400,"text/plain; charset=utf-8",F.reason);return}let M=u.bySlug.get(R);if(!M){U(I,404,"text/plain; charset=utf-8",`No such demo: ${R}`);return}let J=O(pt(M.configPath),"assets.json");ce(J,"utf8").then(K=>{let Ut=[];try{let xe=JSON.parse(K);Array.isArray(xe.assets)&&(Ut=xe.assets)}catch{}U(I,200,"application/json; charset=utf-8",JSON.stringify({demo:M.config,assets:Ut}))},()=>{U(I,200,"application/json; charset=utf-8",JSON.stringify({demo:M.config,assets:[]}))});return}if(v==="/__inkly/runtime.js"){pr(I,w,"runtime.js","text/javascript; charset=utf-8");return}if(v==="/__inkly/runtime.css"){pr(I,w,"runtime.css","text/css; charset=utf-8");return}if(v==="/__inkly/manifest.json"){pr(I,w,"manifest.json","application/json; charset=utf-8");return}if(v.startsWith("/__inkly/vendor/")){let R=decodeURIComponent(v.slice(16));if(!/^(react|react-dom|react-dom-client|react-jsx-runtime)\.mjs$/.test(R)){U(I,404,"text/plain; charset=utf-8",`No such vendor module: ${R}`);return}let F=cc(R);if(!F){U(I,503,"text/plain; charset=utf-8",`Runtime vendor module not found: ${R}`);return}Xt(I,F,"text/javascript; charset=utf-8");return}if(v.startsWith("/__inkly/theme/")&&v.endsWith(".css")){let R=decodeURIComponent(v.slice(15,-4)),F=le[R];if(!F){let M=Object.keys(le).join(", ");U(I,404,"text/plain; charset=utf-8",`No such theme: "${R}". Known themes: ${M}
|
|
4994
|
+
`);return}U(I,200,"text/css; charset=utf-8",F.css??"");return}let ft=v.startsWith("/__inkly/")?null:li(v,u);if(ft&&ft.rel){let{slug:R,rel:F}=ft;if(F.includes("..")||F.startsWith("/")){U(I,400,"text/plain; charset=utf-8","Invalid path");return}let M=O(s,"demos",...R.split("/"),"public"),J=O(M,F);if(!J.startsWith(M+An)&&J!==M){U(I,400,"text/plain; charset=utf-8","Invalid path");return}Yt(J).then(K=>{if(!K.isFile()){ae();return}Xt(I,J,Kt(J))},()=>ae());return}if(v.length>1&&!v.startsWith("/__inkly/")&&!v.endsWith("/")){let R=decodeURIComponent(v.slice(1)),F=O(s,"public"),M=O(F,R);if(!R.includes("..")&&(M.startsWith(F+An)||M===F)){Yt(M).then(J=>{if(J.isFile()){Xt(I,M,Kt(M));return}on()},()=>on());return}}on();function on(){if(v.length>1&&!v.startsWith("/__inkly/")){let R=v.replace(/^\/+/,"").replace(/\/+$/,""),F=li(v,u);if(F&&F.rel===""){let{slug:M,demo:J}=F;if(!Qt(M).ok){ae();return}let Ut={hub:{name:u.hub.name,brand:mr(u.hub).brand??null,tokens:u.hub.tokens??null,theme:u.hub.theme??null,layout:u.hub.layout??null},demoSlug:M,demoTitle:J.config.title??J.config.id},xe=O(pt(J.configPath),"assets.json"),pe=Ft=>{let te=Tn(C,"__inkly_hub_meta",Ut);te=Tn(te,"__inkly_demo_config",J.config),te=Tn(te,"__inkly_demo_assets",Ft),U(I,200,"text/html; charset=utf-8",te)};ce(xe,"utf8").then(Ft=>{let te=[];try{let Ht=JSON.parse(Ft);Array.isArray(Ht.assets)&&(te=Ht.assets.map(Hn=>{let Bt=Hn,sn=ci(Bt,M);return sn?{...Bt,publicUrl:sn}:Bt}))}catch{}pe(te)},()=>{pe([])});return}if(R&&!R.includes("/")){if(!_e(R).ok){ae();return}U(I,404,"text/plain; charset=utf-8",`No such demo: "${R}". Known demos: ${[...u.bySlug.keys()].join(", ")||"(none)"}
|
|
4995
|
+
`);return}}ae()}};j.middlewares.use(G)}}]});await b.listen(),N=vc(b,$);let L=`http://127.0.0.1:${N}/`,z=`http://localhost:${N}/`,D=Gd.watch([O(s,"inkly.json"),O(s,"demos/**/demo.config.json"),O(s,"demos/**/assets.json")],{ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:60,pollInterval:20}}),W=!1,X=async()=>{if(!W){W=!0;try{u=await si(s,i);try{b.ws.send({type:"custom",event:"inkly:hub-changed"}),b.ws.send({type:"full-reload"})}catch{}}catch(j){i(`Reload failed: ${j.message}`)}finally{W=!1}}};if(E=X,D.on("add",X),D.on("change",X),D.on("unlink",X),!r){let j=u.hub.collections?.length??0,G=[...u.bySlug.keys()],ue=10,I=G.length>0?`
|
|
4996
|
+
demos:
|
|
4997
|
+
`+G.slice(0,ue).map(ae=>` ${z}${ae}`).join(`
|
|
4998
|
+
`)+(G.length>ue?`
|
|
4999
|
+
\u2026and ${G.length-ue} more`:""):"";process.stdout.write(`
|
|
5000
|
+
inkly dev running at ${z}
|
|
5001
|
+
hub: ${u.hub.name}
|
|
5002
|
+
demos: ${u.demos.length} in ${j} collection(s)${I}
|
|
5003
|
+
watching ${s}
|
|
5004
|
+
|
|
5005
|
+
`)}let ye=!1;return{url:L,port:N,server:b,hubRoot:s,close:async()=>{ye||(ye=!0,await D.close(),await b.close(),c&&await ec(c,{recursive:!0,force:!0}).catch(()=>{}))}}}function pr(t,e,n,r){if(!e){U(t,503,"text/plain; charset=utf-8",ii);return}let a=O(e,n);Yt(a).then(()=>Xt(t,a,r),()=>U(t,503,"text/plain; charset=utf-8",`${ii}(missing: ${n})`))}import{mkdir as _c,access as hi,readFile as Cc}from"fs/promises";import{dirname as Tc,join as In,resolve as Ac}from"path";function fr(t){return t.split("-").filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function pi(t,e){return{id:ne(),version:1,title:e??fr(t),theme:{background:"#ffffff",foreground:"#0a0a0a",primary:"#5b6cff",primaryForeground:"#ffffff",secondary:"#f4f4f5",secondaryForeground:"#18181b",radius:"12px",font:"Inter, system-ui, sans-serif",fontSize:"14px"},chrome:{showHubBreadcrumb:!0},chapters:[{id:"create",title:"Create",stepIds:["s1"]},{id:"preview",title:"Preview",stepIds:["s2"]},{id:"ship",title:"Ship",stepIds:["s3"]}],steps:[{id:"intro",kind:"cover",widgets:[{type:"headline",id:"intro-headline",title:"Your demo in *60 seconds*.",description:"See how to spin up a sharable demo from a single prompt.",image:{src:"https://placehold.co/2800x1600/f8fafc/111827/png?text=Workspace&font=inter",alt:"Workspace preview",naturalWidth:2800,naturalHeight:1600,position:"right",layout:"hero"},cta:{label:"Get started",animation:"shimmer",action:{type:"next"}}}]},{id:"s1",kind:"content",background:{type:"image",src:"https://placehold.co/2800x1600/f8fafc/111827/png?text=Workspace&font=inter",naturalWidth:2800,naturalHeight:1600,alt:"Workspace overview"},annotations:[{id:"s1_pointer",type:"message",variant:"pointer",x:.28,y:.34,text:"Just **describe** the flow you want \u2014 the demo scaffolds the walkthrough in seconds.",anchor:"right",advancesStep:!0}]},{id:"s2",kind:"content",background:{type:"image",src:"https://placehold.co/2800x1600/ecfeff/111827/png?text=Live+Preview&font=inter",naturalWidth:2800,naturalHeight:1600,alt:"Live preview with editable files"},transform:{zoom:1.25,x:.62,y:.42},captions:[{id:"s2_caption",text:"See your changes come to life with our live preview."}],annotations:[{id:"s2_callout",type:"message",variant:"callout",x:.5,y:.5,text:"**Live preview that follows you.** Every edit lands in the preview *instantly* \u2014 tweak copy, swap assets, reorder steps, and watch the demo update **without a rebuild**.",advancesStep:!0}]},{id:"s3",kind:"content",background:{type:"image",src:"https://placehold.co/2800x1600/f0fdf4/111827/png?text=Export+and+Share&font=inter",naturalWidth:2800,naturalHeight:1600,alt:"Export and share demo"},captions:[{id:"s3_caption",text:"When you are ready, export your demo and share it with anyone."}],annotations:[{id:"s3_area",type:"message",variant:"area",x:.55,y:.45,w:.32,h:.22,text:"**Ready to share.** Export your demo as a **single sharable link** that runs anywhere \u2014 drop it in an email, embed it on your landing page, or paste it in Slack. Works in *any* browser, no install needed.",anchor:"top",advancesStep:!0}]}]}}async function Ic(t){let e=Ac(t);for(;;){let n=In(e,"inkly.json");if(await hi(n).then(()=>!0,()=>!1))return e;let a=Tc(e);if(a===e)return null;e=a}}async function mi(t){let{slug:e,cwd:n,collection:r,silent:a}=t,i=await Ic(n);if(!i)throw new Error("Not inside a hub. Run `inkly init <name>` first.");let o=_e(e);if(!o.ok)throw new Error(o.reason);let s=In(i,"inkly.json"),c=await Cc(s,"utf8"),d;try{d=JSON.parse(c)}catch(b){throw new Error(`Failed to parse inkly.json: ${b.message}`)}let u=ge.safeParse(d);if(!u.success)throw new Error(`Invalid inkly.json: ${u.error.issues.map(b=>`${b.path.join(".")||"<root>"}: ${b.message}`).join("; ")}`);let p=u.data,h=In(i,"demos",e);if(await hi(h).then(()=>!0,()=>!1))throw new Error(`Demo already exists: demos/${e}. Choose a different slug or remove it first.`);let w,k=p,C=p.collections??[];if(r){let b={...p,collections:C.map(z=>({...z,demos:[...z.demos]}))},L=b.collections.find(z=>z.name===r);L?L.demos.push(e):b.collections.push({name:r,demos:[e]}),k=b,w=r}if(w){let b=ge.safeParse(k);if(!b.success)throw new Error(`Internal error: updated inkly.json failed schema validation. ${b.error.message}`)}let $=ne(),N={...pi(e,fr(e)),id:$},E=ot.safeParse(N);if(!E.success)throw new Error(`Internal error: scaffolded demo failed schema validation. ${E.error.message}`);if(await _c(h,{recursive:!0}),await Y(In(h,"demo.config.json"),JSON.stringify(N,null,2)+`
|
|
5006
|
+
`),w&&await Y(s,JSON.stringify(k,null,2)+`
|
|
5007
|
+
`),!a){let b=`Added ${h}
|
|
5008
|
+
`;b+=` id: ${$}
|
|
5009
|
+
`,w&&(b+=`Added to collection "${w}" in inkly.json
|
|
5010
|
+
`),b+=`Next: inkly dev
|
|
5011
|
+
`,process.stdout.write(b)}return{hubRoot:i,demoDir:h,collectionModified:w,id:$}}import{readdir as Pc}from"fs/promises";import{join as Ec}from"path";function Ae(t,e,n,r){t.push({level:e,file:n,message:r})}function gr(t,e){if(typeof t=="string"){t.startsWith("asset:")&&e.add(t.slice(6));return}if(!(!t||typeof t!="object")){if(Array.isArray(t)){for(let n of t)gr(n,e);return}for(let n of Object.values(t))gr(n,e)}}async function Pn(t){let e=[],n=null;try{let o=await It(t.cwd);n=o.root,o.inkly.theme&&!le[o.inkly.theme]&&Ae(e,"error","inkly.json",`Unknown theme "${o.inkly.theme}". Known themes: ${Object.keys(le).join(", ")}.`);let s=new Set(o.demos.map(d=>d.slug)),c=new Map;for(let d of o.demos){let u=ir(d.slug);u&&Ae(e,"error",`demos/${d.slug}`,u);let p=c.get(d.config.id);p?p.push(d.slug):c.set(d.config.id,[d.slug]),d.config.theme?.preset&&!le[d.config.theme.preset]&&Ae(e,"error",`demos/${d.slug}/demo.config.json`,`Unknown demo theme preset "${d.config.theme.preset}".`);let h=new Set;gr(d.config,h);let f=new Set((d.assets?.assets??[]).map(w=>w.id));for(let w of h)f.has(w)||Ae(e,"error",`demos/${d.slug}/demo.config.json`,`References asset:${w}, but demos/${d.slug}/assets.json has no matching asset id.`);for(let w of d.assets?.assets??[])(await Rc(o.root,w.sha256)).length===0&&!$c(w)&&Ae(e,"warning",`demos/${d.slug}/assets.json`,`Asset "${w.id}" has no local cache file and no CDN URL.`)}for(let[d,u]of c)if(!(u.length<2))for(let p of u)Ae(e,"warning",`demos/${p}/demo.config.json`,`Duplicate demo id "${d}" shared with ${u.filter(h=>h!==p).map(h=>`demos/${h}`).join(", ")}. Run \`inkly doctor\` to re-mint.`);for(let d of o.inkly.collections??[])for(let u of d.demos){let p=ir(u);if(p){Ae(e,"error","inkly.json",`Collection "${d.name}" references invalid slug "${u}": ${p}`);continue}s.has(u)||Ae(e,"warning","inkly.json",`Collection "${d.name}" references missing demo "${u}".`)}}catch(o){Ae(e,"error","hub",o.message)}let r=e.filter(o=>o.level==="error").length,a=e.filter(o=>o.level==="warning").length,i={ok:r===0&&(!t.strict||a===0),hubRoot:n,errors:r,warnings:a,issues:e};if(!t.silent)if(t.json)process.stdout.write(JSON.stringify(i,null,2)+`
|
|
4997
5012
|
`);else if(i.ok)process.stdout.write(`inkly validate passed (${r} errors, ${a} warnings)
|
|
4998
5013
|
`);else{for(let o of e)process.stdout.write(`${o.level.toUpperCase()} ${o.file}: ${o.message}
|
|
4999
5014
|
`);process.stdout.write(`inkly validate failed (${r} errors, ${a} warnings)
|
|
5000
|
-
`)}return i}async function
|
|
5001
|
-
`)}return e}import{spawn as
|
|
5002
|
-
`);return}await new Promise((r,a)=>{let i=
|
|
5003
|
-
`,{mode:384})}async function
|
|
5015
|
+
`)}return i}async function Rc(t,e){let n=Ec(t,".inkly","cache");if(!await V(n))return[];try{return(await Pc(n)).filter(a=>a.startsWith(`${e}.`))}catch{return[]}}function $c(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.publicUrl=="string"||typeof e.cdnPath=="string"}import{readFile as Dc}from"fs/promises";import{existsSync as jc}from"fs";import{dirname as br,join as fi}from"path";import{fileURLToPath as Oc}from"url";async function yr(){let t=br(Oc(import.meta.url));for(let e=0;e<5;e+=1){let n=fi(t,"package.json");try{let a=JSON.parse(await Dc(n,"utf8"));if(typeof a.version=="string"){let i=jc(fi(br(n),"src"));return{version:a.version,packagePath:n,isLocalBuild:i}}}catch{}let r=br(t);if(r===t)break;t=r}return{version:"0.0.0-unknown",packagePath:null,isLocalBuild:!1}}async function xr(t={}){let e=await yr();if(!t.silent){let n=e.isLocalBuild?" (local build)":"";process.stdout.write(`${e.version}${n}
|
|
5016
|
+
`)}return e}import{spawn as Nc}from"child_process";async function gi(t={}){let e=t.packageName??"@inkly-org/cli@latest",n=process.env.npm_execpath?[process.execPath,process.env.npm_execpath,"install","-g",e]:["npm","install","-g",e];if(t.dryRun){t.silent||process.stdout.write(`${n.join(" ")}
|
|
5017
|
+
`);return}await new Promise((r,a)=>{let i=Nc(n[0],n.slice(1),{stdio:"inherit"});i.on("error",a),i.on("exit",o=>{o===0?r():a(new Error(`Update failed with exit code ${o??"unknown"}`))})})}import{join as xi}from"path";import{readFile as Lc,rm as zc}from"fs/promises";import{join as Mc}from"path";import{homedir as Uc}from"os";var kr="https://app.inklyai.dev",bi="http://localhost:3000",Ie=Mc(Uc(),".inkly","config.json");async function Me(){try{let t=await Lc(Ie,"utf8"),e=JSON.parse(t);return{apiBase:typeof e.apiBase=="string"?e.apiBase:void 0,token:typeof e.token=="string"?e.token:void 0}}catch{return{}}}async function wr(t){await Y(Ie,JSON.stringify(t,null,2)+`
|
|
5018
|
+
`,{mode:384})}async function yi(){await zc(Ie,{force:!0})}function Ue(t){return(t||kr).replace(/\/+$/,"")}async function ki(t){let e=[],n=await yr();e.push({name:"cli-version",ok:n.version!=="0.0.0-unknown",message:n.version});let r=Number.parseInt(process.versions.node.split(".")[0]??"0",10);e.push({name:"node",ok:r>=20,message:process.version});let a=await Te(t.cwd);e.push({name:"hub-root",ok:!!a,message:a??"No inkly.json found."});let i=await Me();e.push({name:"login",ok:!!i.token,message:i.token?`Configured for ${i.apiBase??"(default API)"}`:"Not logged in."});let o=[],s=null;if(a){let d=await Cn(a);s={healed:d.healed.length,reminted:d.reminted.length,paths:[...d.healed,...d.reminted].map(f=>qt(d.hubRoot,f.configPath))},e.push({name:"demo-ids",ok:!0,message:s.healed===0&&s.reminted===0?"all demos have a valid unique id":`healed ${s.healed}, re-minted ${s.reminted}`});let u=await Pn({cwd:a,silent:!0});o=u.issues,e.push({name:"schema",ok:u.ok,message:`${u.errors} errors, ${u.warnings} warnings`});let p=await V(xi(a,".inkly","cache"));e.push({name:"local-cache",ok:!0,message:p?".inkly/cache exists":".inkly/cache not present yet"});let h=await wn(xi(a,"node_modules","@inkly","runtime","dist","runtime.js"));h!==null&&e.push({name:"runtime-artifact",ok:!0,message:`${h} bytes`})}let c={ok:e.every(d=>d.ok||d.name==="login"),checks:e,validationIssues:o,demoIds:s};if(!t.silent)if(t.json)process.stdout.write(JSON.stringify(c,null,2)+`
|
|
5004
5019
|
`);else{for(let d of e)process.stdout.write(`${d.ok?"OK":"WARN"} ${d.name}: ${d.message}
|
|
5005
5020
|
`);if(s&&s.paths.length>0)for(let d of s.paths)process.stdout.write(` fixed id in ${d}
|
|
5006
5021
|
`);if(o.length>0)for(let d of o)process.stdout.write(`${d.level.toUpperCase()} ${d.file}: ${d.message}
|
|
5007
|
-
`)}return c}import{randomBytes as
|
|
5008
|
-
`,{encoding:"utf8",mode:384})}async function
|
|
5009
|
-
`),{apiBase:e,configPath:
|
|
5010
|
-
`),{apiBase:r.apiBase,configPath:
|
|
5011
|
-
`)}async function
|
|
5012
|
-
`):(process.stdout.write(`Config: ${
|
|
5022
|
+
`)}return c}import{randomBytes as eu}from"crypto";import{createServer as tu}from"http";import{spawn as nu}from"child_process";import{randomUUID as Fc}from"crypto";import{mkdir as Hc,readFile as Bc,writeFile as Wc}from"fs/promises";import{dirname as Vc,join as Jc}from"path";import{homedir as Zc}from"os";import{PostHog as Gc}from"posthog-node";var wi=process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN??process.env.POSTHOG_PROJECT_TOKEN??"phc_Dmh4w8YFNosi3YHD4Sv7ShHX7ccS8kmtRcm8XSVmB5jT",qc=process.env.NEXT_PUBLIC_POSTHOG_HOST??process.env.POSTHOG_HOST??"https://us.i.posthog.com",Kc="@inkly-org/cli@0.5.1",vr=Jc(Zc(),".inkly","analytics.json"),Rn=null,En=null,Dt=null;function Yc(){return!!wi&&process.env.INKLY_TELEMETRY_DISABLED!=="1"}function vi(){return Yc()?(Rn??=new Gc(wi,{host:qc,flushAt:1,flushInterval:0}),Rn):null}async function Sr(){try{let t=await Bc(vr,"utf8");return JSON.parse(t)}catch{return{}}}async function _r(t){await Hc(Vc(vr),{recursive:!0}),await Wc(vr,JSON.stringify(t,null,2)+`
|
|
5023
|
+
`,{encoding:"utf8",mode:384})}async function Si(){return En||(En=(async()=>{let t=await Sr();if(typeof t.platformUserId=="string"&&t.platformUserId&&(Dt=t.platformUserId),typeof t.distinctId=="string"&&t.distinctId)return t.distinctId;let e=`cli_${Fc()}`;return await _r({...t,distinctId:e}),e})(),En)}async function Xc(){let t=await Si();return Dt??t}async function Cr(t){if(!t||Dt===t){t&&(Dt=t);return}let e=vi();try{let n=await Si(),r=await Sr(),a=r.platformUserId!==t;Dt=t,a&&(await _r({...r,platformUserId:t}),e?.alias({distinctId:t,alias:n}))}catch{}}async function _i(){Dt=null;try{let t=await Sr();if(t.platformUserId){let{platformUserId:e,...n}=t;await _r(n)}}catch{}}function Qc(){return{surface:"cli",release:process.env.POSTHOG_RELEASE??Kc,node_version:process.versions.node,platform:process.platform,arch:process.arch,ci:!!process.env.CI}}async function H(t,e={}){let n=vi();if(n)try{n.capture({distinctId:await Xc(),event:t,properties:{...Qc(),...e}})}catch{}}async function Tr(){if(Rn)try{await Rn.shutdown(2e3)}catch{}}async function Ti(t){let e=Ue(t.local?bi:kr),n=t.token??process.env.INKLY_API_TOKEN;if(n){let i=await Ir(e,n).catch(()=>({valid:!1,userId:null}));return await wr({apiBase:e,token:n}),await Ci("token",i),t.silent||process.stdout.write(`Logged in to ${e}${i.valid?"":" (token saved without online verification)"}
|
|
5024
|
+
`),{apiBase:e,configPath:Ie,verified:i.valid,method:"token"}}let r=await ru({apiBase:e,shouldOpen:t.open!==!1,silent:t.silent});await wr({apiBase:r.apiBase,token:r.apiToken});let a=await Ir(r.apiBase,r.apiToken).catch(()=>({valid:!1,userId:null}));return await Ci("browser",a),t.silent||process.stdout.write(`Logged in to ${r.apiBase}
|
|
5025
|
+
`),{apiBase:r.apiBase,configPath:Ie,verified:a.valid,method:"browser"}}async function Ci(t,e){e.valid&&e.userId&&await Cr(e.userId),await H("inkly_cli_logged_in",{method:t,verified:e.valid})}async function Ai(t={}){await H("inkly_cli_logged_out",{}),await _i(),await yi(),t.silent||process.stdout.write(`Removed ${Ie}
|
|
5026
|
+
`)}async function Ii(t){let e=await Me(),n=e.apiBase?Ue(e.apiBase):null,r=await Te(t.cwd),a="skipped",i;if(n&&e.token)try{let s=await Ir(n,e.token);a=s.valid?"ok":"failed",a==="failed"&&(i="Token was rejected by the platform."),s.valid&&s.userId&&await Cr(s.userId)}catch(s){a="failed",i=s.message}let o={configPath:Ie,apiBase:n,loggedIn:!!e.token,hubRoot:r,online:a,message:i};return t.silent||(t.json?process.stdout.write(JSON.stringify(o,null,2)+`
|
|
5027
|
+
`):(process.stdout.write(`Config: ${Ie}
|
|
5013
5028
|
`),process.stdout.write(`Hub: ${r??"(not inside a hub)"}
|
|
5014
5029
|
`),process.stdout.write(`API: ${n??"(not configured)"}
|
|
5015
5030
|
`),process.stdout.write(`Login: ${o.loggedIn?"configured":"not configured"}
|
|
5016
5031
|
`),process.stdout.write(`Online: ${a}${i?` (${i})`:""}
|
|
5017
|
-
`))),o}async function
|
|
5032
|
+
`))),o}async function Ir(t,e){let n=await fetch(`${t}/api/captures/verify`,{method:"GET",headers:{authorization:`Bearer ${e}`}});if(!n.ok)return{valid:!1,userId:null};let r=null;try{let a=await n.json();typeof a.userId=="string"&&a.userId&&(r=a.userId)}catch{}return{valid:!0,userId:r}}async function ru(t){let e=eu(16).toString("hex"),n=tu(),r=await au(n),a=new URL("/cli/login",t.apiBase);a.searchParams.set("callback",r.url),a.searchParams.set("state",e);let i=iu({server:n,state:e,apiBase:t.apiBase,timeoutMs:120*1e3});return t.silent||process.stdout.write(`Opening browser for Inkly login:
|
|
5018
5033
|
${a.toString()}
|
|
5019
|
-
`),t.shouldOpen&&
|
|
5020
|
-
`),await
|
|
5034
|
+
`),t.shouldOpen&&su(a.toString()),i}async function au(t){await new Promise((n,r)=>{t.once("error",r),t.listen(0,"127.0.0.1",()=>n())});let e=t.address();if(!e||typeof e=="string")throw new Error("Could not start local login callback server.");return{url:`http://127.0.0.1:${e.port}/callback`}}async function iu(t){return new Promise((e,n)=>{let r=setTimeout(()=>{Ar(t.server),n(new Error("Timed out waiting for browser login."))},t.timeoutMs);t.server.on("request",(a,i)=>{(async()=>{try{let o=new URL(a.url??"/","http://127.0.0.1");if(o.pathname!=="/callback"){$n(i,404,"Not found.");return}let s=o.searchParams.get("state"),c=o.searchParams.get("pairingToken");if(!c||s!==t.state){$n(i,400,"Invalid Inkly CLI login callback. You can close this tab.");return}let d=await ou(t.apiBase,c);clearTimeout(r),$n(i,200,"Inkly CLI is connected. You can close this tab."),Ar(t.server),e(d)}catch(o){clearTimeout(r),$n(i,500,`Inkly CLI login failed: ${o.message}`),Ar(t.server),n(o)}})()})})}async function ou(t,e){let n=await fetch(`${t}/api/cli/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pairingToken:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r?.apiToken)throw new Error(r?.error??`Login exchange failed: HTTP ${n.status}`);return{apiToken:r.apiToken,apiBase:Ue(r.apiBase??t)}}function su(t){let e=process.platform,a=nu(e==="darwin"?"open":e==="win32"?"cmd":"xdg-open",e==="win32"?["/c","start","",t]:[t],{stdio:"ignore",detached:!0});a.on("error",()=>{}),a.unref()}function $n(t,e,n){t.statusCode=e,t.setHeader("content-type","text/html; charset=utf-8"),t.end(`<!doctype html><meta charset="utf-8"><title>Inkly CLI</title><body style="font-family: system-ui, sans-serif; padding: 32px;">${lu(n)}</body>`)}function Ar(t){try{t.close()}catch{}}function lu(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}import{readFile as Ri,readdir as $i,writeFile as du}from"fs/promises";import{join as en,extname as Di}from"path";async function jn(t){let e=await Me(),n=await It(t.cwd),r=t.demo?n.demos.filter(p=>p.slug===t.demo):n.demos;if(t.demo&&r.length===0)throw new Error(`No such demo: ${t.demo}`);let a=[],i=[];for(let p of r)for(let h of p.assets?.assets??[]){let f=await pu(n.root,h.sha256),w=hu(h);if(!f&&!w){i.push({demo:p.slug,id:h.id,sha256:h.sha256});continue}if(!f||w)continue;let k=await wn(en(n.root,".inkly","cache",f));a.push({demo:p.slug,id:h.id,sha256:h.sha256,cacheFile:f,contentType:h.contentType??Dn(f,h.kind),size:h.size??k??0,alreadyRemote:w})}let o={hubRoot:n.root,dryRun:!!t.dryRun,assets:a,unresolved:i,uploaded:0,updatedManifests:[]};if(t.dryRun||a.length===0)return t.silent||Pi(o,t.json),o;if(!e.token)throw new Error("Not logged in. Run `inkly login --token <token>` first.");let s=Ue(e.apiBase??process.env.INKLY_API_BASE),c=await Pr({apiBase:s,token:e.token,hubRoot:n.root,assets:a}),d=c.uploads,u=new Map(d.map(p=>[p.sha256,p]));for(let p of r){if(!p.assets)continue;let h=!1,f=p.assets.assets.map(k=>{let C=u.get(k.sha256);return C?(h=!0,{...k,contentType:k.contentType??Dn(`${k.sha256}${C.ext}`,k.kind),publicUrl:C.publicUrl,cdnPath:C.cdnPath}):k});if(!h)continue;let w={...p.assets,assets:f};await Y(p.assetsPath,JSON.stringify(w,null,2)+`
|
|
5035
|
+
`),await mu(p.dir,d),o.updatedManifests.push(`demos/${p.slug}/assets.json`)}return o.uploaded=c.uploaded,t.silent||Pi(o,t.json),o}async function Pr(t){let e=await uu(t.apiBase,t.token,t.assets),n=new Map(e.uploads.map(i=>[i.sha256,i])),r=0;for(let i of t.assets){let o=n.get(i.sha256);if(!o)throw new Error(`Platform did not return upload metadata for ${i.sha256}.`);if(o.uploadUrl){let s=await Ri(en(t.hubRoot,".inkly","cache",i.cacheFile)),c=await fetch(o.uploadUrl,{method:"PUT",headers:o.uploadHeaders??{"content-type":i.contentType},body:s});if(!c.ok)throw new Error(`Asset upload failed for ${i.id}: HTTP ${c.status}`);r+=1}}return{uploads:(await cu(t.apiBase,t.token,t.assets,e.uploads)).uploads,uploaded:r}}async function cu(t,e,n,r){let a=new Map(r.map(s=>[s.sha256,s])),i=await fetch(`${t}/api/cli/sync-assets/complete`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({assets:n.map(s=>{let c=a.get(s.sha256);if(!c)throw new Error(`Platform did not return upload metadata for ${s.sha256}.`);return{sha256:s.sha256,ext:c.ext,contentType:s.contentType,size:s.size,cdnPath:c.cdnPath}})})}),o=await i.json().catch(()=>null);if(!i.ok||!o||!Array.isArray(o.uploads))throw new Error(o?.error??`Sync completion failed: HTTP ${i.status}`);return{uploads:o.uploads}}async function uu(t,e,n){let r=await fetch(`${t}/api/cli/sync-assets`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({assets:n.map(i=>({sha256:i.sha256,ext:Di(i.cacheFile)||Er(i.contentType),contentType:i.contentType,size:i.size}))})}),a=await r.json().catch(()=>null);if(!r.ok||!a||!Array.isArray(a.uploads))throw new Error(a?.error??`Sync endpoint failed: HTTP ${r.status}`);return{uploads:a.uploads}}async function pu(t,e){let n=en(t,".inkly","cache");return await V(n)?(await $i(n)).find(a=>a.startsWith(`${e}.`))??null:null}function hu(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.publicUrl=="string"&&typeof e.cdnPath=="string"}function Dn(t,e){let n=Di(t).toLowerCase();return n===".png"?"image/png":n===".jpg"||n===".jpeg"?"image/jpeg":n===".webp"?"image/webp":n===".gif"?"image/gif":n===".svg"?"image/svg+xml":n===".webm"?"video/webm":n===".mp4"?"video/mp4":n===".mp3"?"audio/mpeg":n===".wav"?"audio/wav":e==="font"?"font/woff2":"application/octet-stream"}function Er(t){let e=t.toLowerCase().split(";")[0]?.trim();return e==="image/png"?".png":e==="image/jpeg"?".jpg":e==="image/webp"?".webp":e==="image/gif"?".gif":e==="image/svg+xml"?".svg":e==="video/webm"?".webm":e==="video/mp4"?".mp4":e==="audio/mpeg"?".mp3":e==="audio/wav"?".wav":e==="font/woff2"?".woff2":".bin"}async function mu(t,e){let n=en(t,"snapshots");if(!await V(n))return;let r=e.map(a=>({local:`/__inkly/cache/${`${a.sha256}${a.ext}`}`,remote:a.publicUrl}));await ji(n,r)}async function ji(t,e){for(let n of await $i(t,{withFileTypes:!0})){let r=en(t,n.name);if(n.isDirectory())await ji(r,e);else if(n.isFile()&&/\.(html|css)$/i.test(n.name)){let a=await Ri(r,"utf8"),i=a;for(let o of e)a=a.split(o.local).join(o.remote);a!==i&&await du(r,a,"utf8")}}}function Pi(t,e){if(e){process.stdout.write(JSON.stringify(t,null,2)+`
|
|
5021
5036
|
`);return}if(t.dryRun){process.stdout.write(`inkly sync dry run: ${t.assets.length} asset(s) need upload
|
|
5022
|
-
`),
|
|
5023
|
-
`),
|
|
5037
|
+
`),Ei(t);return}process.stdout.write(`inkly sync complete: ${t.uploaded} uploaded, ${t.updatedManifests.length} manifest(s) updated
|
|
5038
|
+
`),Ei(t)}function Ei(t){if(t.unresolved.length!==0){process.stderr.write(`inkly sync warning: ${t.unresolved.length} asset(s) have no local cache file and are not on the CDN:
|
|
5024
5039
|
`);for(let e of t.unresolved)process.stderr.write(` - demos/${e.demo} "${e.id}" (${e.sha256})
|
|
5025
|
-
`)}}import{readdir as
|
|
5026
|
-
`+i.unresolved.map(
|
|
5027
|
-
`));let o=[];i.assets.length>0&&(
|
|
5028
|
-
`),o=(await
|
|
5029
|
-
`):
|
|
5040
|
+
`)}}import{readdir as fu,readFile as gu}from"fs/promises";import{extname as $r,join as Oi,resolve as Ni}from"path";function Rr(t,e){t||process.stdout.write(e)}function bu(t,e){if(e.demo){let n=t.demos.find(r=>r.slug===e.demo);if(!n)throw new Error(`No such demo: ${e.demo}`);return n}if(e.path){let n=Ni(e.cwd,e.path),r=t.demos.find(i=>Ni(i.dir)===n);if(r)return r;let a=t.demos.find(i=>i.slug===e.path||i.slug===e.path?.replace(/^demos\//,""));if(a)return a;throw new Error(`No demo found at "${e.path}". Available demos: ${t.demos.map(i=>i.slug).join(", ")||"(none)"}`)}if(t.demos.length===1)return t.demos[0];throw new Error(`This hub has ${t.demos.length} demos \u2014 pass a demo path or --demo <slug>. Available: ${t.demos.map(n=>n.slug).join(", ")}`)}async function yu(t,e=[]){let n=Oi(t,"snapshots");if(!await V(n))return{};let r={};async function a(i){for(let o of await fu(i,{withFileTypes:!0})){let s=Oi(i,o.name);if(o.isDirectory())await a(s);else if(o.isFile()&&/\.(html|css)$/i.test(o.name)){let c=s.slice(t.length+1).split(/[\\/]/).join("/");r[c]=xu(await gu(s,"utf8"),e)}}}return await a(n),r}function xu(t,e){let n=t;for(let r of e)n=n.split(r.local).join(r.remote);return n}function Li(t){if(!t)return null;try{let e=new URL(t);return $r(e.pathname)||null}catch{return $r(t)||null}}function ku(t,e,n){let r=new Map,a=(o,s)=>{if(!s)return;let c=s.startsWith(".")?s:`.${s}`;r.has(o)||r.set(o,new Set),r.get(o).add(c)};for(let o of e)a(o.sha256,$r(o.cacheFile));for(let o of n)a(o.sha256,o.ext);for(let o of t.assets)a(o.sha256,Li(o.cdnPath)),a(o.sha256,Li(o.publicUrl)),o.contentType&&a(o.sha256,Er(o.contentType));let i=[];for(let o of t.assets)if(o.publicUrl)for(let s of r.get(o.sha256)??[])i.push({local:`/__inkly/cache/${o.sha256}${s}`,remote:o.publicUrl});return i}function wu(t,e,n){let r=t??{version:1,assets:[]},a=new Map(n.map(o=>[o.sha256,o])),i=new Map(e.map(o=>[o.sha256,o]));return{...r,assets:r.assets.map(o=>{let s=a.get(o.sha256);if(!s)return o;let c=i.get(o.sha256);return{...o,contentType:o.contentType??c?.contentType??Dn(`${o.sha256}${s.ext}`,o.kind),publicUrl:s.publicUrl,cdnPath:s.cdnPath}})}}async function zi(t){let e=await Me();if(!e.token)throw new Error("Not logged in. Run `inkly login` first.");let n=Ue(e.apiBase??process.env.INKLY_API_BASE),r=await It(t.cwd),a=bu(r,t),i=await jn({cwd:r.root,demo:a.slug,dryRun:!0,silent:!0});if(i.unresolved.length>0)throw new Error(`${i.unresolved.length} asset(s) have no local bytes and are not on the CDN, so a hosted preview cannot be published:
|
|
5041
|
+
`+i.unresolved.map(f=>` - ${f.id} (${f.sha256})`).join(`
|
|
5042
|
+
`));let o=[];i.assets.length>0&&(Rr(t.silent,`Uploading ${i.assets.length} asset(s) to the CDN for this snapshot...
|
|
5043
|
+
`),o=(await Pr({apiBase:n,token:e.token,hubRoot:r.root,assets:i.assets})).uploads);let s=wu(a.assets,i.assets,o),c=await yu(a.dir,ku(s,i.assets,o)),d=await fetch(`${n}/api/previews`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.token}`},body:JSON.stringify({demoSlug:a.slug,title:a.config.title??null,config:a.config,assets:s,hub:r.inkly,snapshots:c})}),u=await d.json().catch(()=>null);if(!d.ok||!u?.id)throw new Error(u?.error??`Snapshot publish failed: HTTP ${d.status}`);let p=u.url??`${n}${u.path??`/p/${u.id}`}`,h={hubRoot:r.root,slug:a.slug,id:u.id,url:p};return t.json?Rr(t.silent,JSON.stringify(h,null,2)+`
|
|
5044
|
+
`):Rr(t.silent,`Snapshot published:
|
|
5030
5045
|
${p}
|
|
5031
|
-
`),h}import{readFile as
|
|
5032
|
-
`,d=(await Z(r)?await Ci(r,"utf8"):null)!==s;return d&&await Gc(r,s,"utf8"),me({ok:!0,hubRoot:n,lockPath:r,lock:i,source:o,issues:e,drifted:d,options:t})}catch(i){return Ne(e,"error",i.message),me({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:e,drifted:!1,options:t})}}function me(t){let{ok:e,hubRoot:n,lockPath:r,lock:a,source:i,issues:o,drifted:s,options:c}=t,d={ok:e,hubRoot:n,lockPath:r,lock:a,source:i,issues:o,drifted:s};if(!c.silent)if(c.json)process.stdout.write(JSON.stringify(d,null,2)+`
|
|
5033
|
-
`);else if(e)c.check?process.stdout.write(`inkly lock --check: inkly.lock matches inkly.json (runtime ${a?.runtime.version}, source: ${i??"unknown"}).
|
|
5034
|
-
`):s?process.stdout.write(`inkly lock: wrote ${r} (runtime ${a?.runtime.version}, source: ${i??"unknown"}).
|
|
5035
|
-
`):process.stdout.write(`inkly lock: ${r} already up to date (runtime ${a?.runtime.version}, source: ${i??"unknown"}).
|
|
5036
|
-
`);else{for(let u of o)process.stdout.write(`${u.level.toUpperCase()} ${u.message}
|
|
5037
|
-
`);process.stdout.write(`inkly lock failed
|
|
5038
|
-
`)}return d}import*as ot from"@sentry/node";var nu="https://b3450c6a8fdcd02b8aee3b9f2c8425eb@o4511498910433280.ingest.us.sentry.io/4511498940252160",ru="@inkly-org/cli@0.5.1";function Ai(){ot.init({dsn:nu,release:process.env.SENTRY_RELEASE??ru,environment:process.env.SENTRY_ENVIRONMENT??"production",enabled:process.env.INKLY_SENTRY_DISABLED!=="1",sendDefaultPii:!1,tracesSampleRate:0,beforeSend(t){return t.server_name=void 0,t}})}async function ne(t,e){ot.captureException(e,{tags:{command:t,surface:"cli"}}),await ot.flush(2e3)}async function Ii(){await ot.flush(2e3)}import{spawn as Fi}from"child_process";import{createHash as Wu,randomUUID as Vu}from"crypto";import{mkdir as $t,mkdtemp as Zu,open as Hi,readFile as st,readdir as Bi,rm as lt,writeFile as Wi}from"fs/promises";import{existsSync as Ce}from"fs";import{dirname as $n,isAbsolute as Vi,join as W,resolve as En,sep as Ju}from"path";import{tmpdir as Gu,homedir as $r}from"os";import{fileURLToPath as Zi}from"url";import{unzipSync as qu,zipSync as Ku}from"fflate";import Yu from"ws";import Xu from"sharp";import Qu from"subset-font";var au=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),iu=new Set(["a","button","input","select","textarea","label","p","h1","h2","h3","h4","h5","h6","img","li","nav","main","header","footer","section","article","aside","form","table","tr","td","th","ul","ol"]);function ou(t){let e="";for(let n=0;n<t.length;n+=1)e+=(t[n]??0).toString(16).padStart(2,"0");return e}async function In(t,e=16){let n=new Uint8Array(t.byteLength);n.set(t);let r=await crypto.subtle.digest("SHA-256",n);return ou(new Uint8Array(r)).slice(0,e)}function Ir(t){switch((t.toLowerCase().split(";")[0]??"").trim()){case"image/png":return".png";case"image/jpeg":case"image/jpg":return".jpg";case"image/webp":return".webp";case"image/gif":return".gif";case"image/svg+xml":return".svg";case"image/avif":return".avif";case"image/x-icon":case"image/vnd.microsoft.icon":return".ico";case"font/woff2":return".woff2";case"font/woff":return".woff";case"text/css":return".css";case"text/javascript":case"application/javascript":return".js";default:return".bin"}}function _r(t,e){let n=t.trim();if(!n||n.startsWith("data:")||n.startsWith("blob:")||n.startsWith("assets/")||n.startsWith("#"))return null;try{let r=new URL(n,e);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.href}catch{return null}}function Di(t,e,n){if(e){let a=atob(n.replace(/\s+/g,"")),i=new Uint8Array(a.length);for(let o=0;o<a.length;o+=1)i[o]=a.charCodeAt(o);return i}let r=decodeURIComponent(n.replace(/\+/g,"%20"));return new TextEncoder().encode(r)}function su(t){return/\s/.test(t)||t===")"||t==='"'||t==="<"||t===">"}function ji(t){return t.replace(/\\(?:\r\n|[\n\r\f])/g,"").replace(/\\([0-9a-fA-F]{1,6}\s?|[\s\S])/g,(e,n)=>{let r=n.match(/^([0-9a-fA-F]{1,6})\s?$/);if(r?.[1])try{return String.fromCodePoint(Number.parseInt(r[1],16))}catch{return""}return n})}function lu(t){let e=[],n=0;for(;n<t.length;){let r=t.toLowerCase().indexOf("data:",n);if(r<0)break;let a=r>0?t[r-1]:"",i=a==='"'||a==="'"?a:null,o=t.indexOf(",",r);if(o<0)break;let s=t.slice(r+5,o);if(!s||/[\s"'()<>]/.test(s)){n=r+5;continue}let c=o+1,d=!1;for(;c<t.length;){let w=t[c]??"";if(d){d=!1,c+=1;continue}if(w==="\\"){d=!0,c+=1;continue}if(i?w===i:su(w))break;c+=1}let u=t.slice(r,c),p=ji(t.slice(o+1,c)),h=s.split(";"),y=h.shift()||"text/plain",x=h.some(w=>w.toLowerCase()==="base64");e.push({match:u,mime:y,isBase64:x,payload:p,index:r}),n=c}return e}function du(t){let e=t.trim();if(!e.toLowerCase().startsWith("data:"))return null;let n=e.indexOf(",");if(n<0)return null;let r=e.slice(5,n);if(!r||/[\s"'()<>]/.test(r))return null;let a=r.split(";"),i=a.shift()||"text/plain",o=a.some(s=>s.toLowerCase()==="base64");return{mime:i,isBase64:o,payload:ji(e.slice(n+1))}}async function Pi(t,e){let n=du(t);if(!n)return null;let r;try{r=Di(n.mime,n.isBase64,n.payload)}catch{return null}let a=`${await In(r)}${Ir(n.mime)}`;return e.has(a)||e.set(a,{filename:a,bytes:r,contentType:n.mime||"application/octet-stream"}),`assets/${a}`}async function Cr(t,e,n){let r=n.get(t);if(r)return r;try{let a=await fetch(t,{cache:"force-cache",referrerPolicy:"strict-origin-when-cross-origin"});if(!a.ok)return null;let i=a.headers.get("content-type")?.split(";")[0]?.trim()||"application/octet-stream",o=new Uint8Array(await a.arrayBuffer());if(o.byteLength===0)return null;let s=`${await In(o)}${Ir(i)}`;e.has(s)||e.set(s,{filename:s,bytes:o,contentType:i});let c=`assets/${s}`;return n.set(t,c),c}catch{return null}}function cu(t){let e=[],n=0,r=!1;for(let a=0;a<t.length;a+=1){if(t[a]!==",")continue;if(t.slice(n,a).trimStart().toLowerCase().startsWith("data:")&&!r){r=!0;continue}e.push(t.slice(n,a).trim()),n=a+1,r=!1}return e.push(t.slice(n).trim()),e.filter(Boolean).map(a=>{let i=a.match(/\s+(\d+(?:\.\d+)?[wx])$/);return i?.index?{url:a.slice(0,i.index).trim(),descriptor:i[1]??""}:{url:a,descriptor:""}}).filter(a=>a.url.length>0)}async function uu(t,e,n,r){let a=Array.from(t.querySelectorAll("img[src],source[src],video[poster]"));for(let o of a){let s=o.hasAttribute("poster")?"poster":"src",c=o.getAttribute(s);if(!c)continue;let d=await Pi(c,n);if(d){o.setAttribute(s,d);continue}let u=_r(c,e);if(!u)continue;let p=await Cr(u,n,r);p&&o.setAttribute(s,p)}let i=Array.from(t.querySelectorAll("img[srcset],source[srcset]"));for(let o of i){let s=o.getAttribute("srcset");if(!s)continue;let c=[];for(let d of cu(s)){let u=await Pi(d.url,n);if(u){c.push(`${u}${d.descriptor?` ${d.descriptor}`:""}`);continue}let p=_r(d.url,e),h=p?await Cr(p,n,r):null;c.push(`${h??d.url}${d.descriptor?` ${d.descriptor}`:""}`)}o.setAttribute("srcset",c.join(", "))}}async function pu(t,e,n,r){let a=[],i=/url\(\s*(["']?)([^"')]+)\1\s*\)/gi,o;for(;o=i.exec(t);){let c=o[2]??"",d=_r(c,e);d&&a.push({raw:c,url:d})}let s=t;for(let c of a){let d=await Cr(c.url,n,r);d&&(s=s.split(c.raw).join(d))}return s}async function hu(t){let e=new Map,n=lu(t),r=[];for(let o of n){let s;try{s=Di(o.mime,o.isBase64,o.payload)}catch{continue}let c=`${await In(s)}${Ir(o.mime)}`;e.has(c)||e.set(c,{filename:c,bytes:s,contentType:o.mime||"application/octet-stream"}),r.push({match:o.match,replacement:`assets/${c}`})}let a=t,i=new Map;for(let o of r)i.set(o.match,o.replacement);for(let[o,s]of i)a=a.split(o).join(s);return{html:a,assets:e}}function mu(t){return t.replace(/<script\b[\s\S]*?<\/script>/gi,"")}function fu(t){return t.replace(/<script\b(?=[^>]*\bid=["']alpha-capture-index["'])[\s\S]*?<\/script>/i,"")}function gu(t){return t.replace(/<link\b(?=[^>]*\brel=["'](?:preload|prefetch|preconnect|dns-prefetch|modulepreload|canonical|alternate)["'])[^>]*>/gi,"").replace(/<meta\b(?=[^>]*\b(?:property|name)=["'](?:og:[^"']+|twitter:[^"']+|description|keywords|robots|theme-color|generator)["'])[^>]*>/gi,"")}function bu(t){let e=1,n=t.createTreeWalker(t.documentElement,NodeFilter.SHOW_ELEMENT,null),r=t.documentElement;do{if(r&&r.nodeType===1){let a=r.tagName.toLowerCase();iu.has(a)&&(r.setAttribute("data-inkly-id",String(e)),e+=1)}r=n.nextNode()}while(r)}function yu(t){t.removeAttribute("href"),t.removeAttribute("xlink:href"),t.removeAttributeNS("http://www.w3.org/1999/xlink","href"),t.removeAttribute("target"),t.removeAttribute("rel"),t.removeAttribute("download"),t.removeAttribute("ping"),t.removeAttribute("referrerpolicy")}function xu(t){for(let e of Array.from(t.querySelectorAll("*")))for(let n of Array.from(e.attributes))/^on/i.test(n.name)&&e.removeAttribute(n.name),/^formaction$/i.test(n.name)&&e.removeAttribute(n.name);for(let e of Array.from(t.querySelectorAll("base")))e.remove();for(let e of Array.from(t.querySelectorAll("link[href]")))(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).filter(Boolean).includes("stylesheet")||e.remove();for(let e of Array.from(t.querySelectorAll("meta[http-equiv]")))(e.getAttribute("http-equiv")??"").toLowerCase()==="refresh"&&e.remove();for(let e of Array.from(t.querySelectorAll("a,area")))yu(e),e.removeAttribute("data-inkly-href");for(let e of Array.from(t.querySelectorAll("form")))e.removeAttribute("action"),e.removeAttribute("method"),e.removeAttribute("target"),e.removeAttribute("data-inkly-action")}function ku(t){let e=Array.from(t.querySelectorAll("style"));if(e.length===0)return"";let n=[],r=!0;for(let a of e){let i=a.textContent?.trim()??"",o=a.getAttribute("media")?.trim();if(o&&o.toLowerCase()!=="all"?n.push(`@media ${o} {${i}}`):n.push(i),r){let s=t.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href","assets/document.css"),a.replaceWith(s),r=!1}else a.remove()}return n.join(`
|
|
5046
|
+
`),h}import*as ht from"@sentry/node";var vu="https://b3450c6a8fdcd02b8aee3b9f2c8425eb@o4511498910433280.ingest.us.sentry.io/4511498940252160",Su="@inkly-org/cli@0.5.1";function Mi(){ht.init({dsn:vu,release:process.env.SENTRY_RELEASE??Su,environment:process.env.SENTRY_ENVIRONMENT??"production",enabled:process.env.INKLY_SENTRY_DISABLED!=="1",sendDefaultPii:!1,tracesSampleRate:0,beforeSend(t){return t.server_name=void 0,t}})}async function re(t,e){ht.captureException(e,{tags:{command:t,surface:"cli"}}),await ht.flush(2e3)}async function Ui(){await ht.flush(2e3)}import{spawn as eo,execFile as cp}from"child_process";import{createHash as up,randomUUID as pp}from"crypto";import{mkdir as Nt,mkdtemp as hp,open as to,readFile as Ee,readdir as no,rm as Fe,writeFile as ro}from"fs/promises";import{existsSync as Pe}from"fs";import{dirname as Mn,isAbsolute as ao,join as B,resolve as Ln,sep as mp}from"path";import{tmpdir as fp,homedir as Br}from"os";import{fileURLToPath as io}from"url";import{unzipSync as gp,zipSync as bp}from"fflate";import yp from"ws";import xp from"sharp";import kp from"subset-font";var _u=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Cu=new Set(["a","button","input","select","textarea","label","p","h1","h2","h3","h4","h5","h6","img","li","nav","main","header","footer","section","article","aside","form","table","tr","td","th","ul","ol"]);function Tu(t){let e="";for(let n=0;n<t.length;n+=1)e+=(t[n]??0).toString(16).padStart(2,"0");return e}async function On(t,e=16){let n=new Uint8Array(t.byteLength);n.set(t);let r=await crypto.subtle.digest("SHA-256",n);return Tu(new Uint8Array(r)).slice(0,e)}function Lr(t){switch((t.toLowerCase().split(";")[0]??"").trim()){case"image/png":return".png";case"image/jpeg":case"image/jpg":return".jpg";case"image/webp":return".webp";case"image/gif":return".gif";case"image/svg+xml":return".svg";case"image/avif":return".avif";case"image/x-icon":case"image/vnd.microsoft.icon":return".ico";case"font/woff2":return".woff2";case"font/woff":return".woff";case"text/css":return".css";case"text/javascript":case"application/javascript":return".js";default:return".bin"}}function Dr(t,e){let n=t.trim();if(!n||n.startsWith("data:")||n.startsWith("blob:")||n.startsWith("assets/")||n.startsWith("#"))return null;try{let r=new URL(n,e);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.href}catch{return null}}function Vi(t,e,n){if(e){let a=atob(n.replace(/\s+/g,"")),i=new Uint8Array(a.length);for(let o=0;o<a.length;o+=1)i[o]=a.charCodeAt(o);return i}let r=decodeURIComponent(n.replace(/\+/g,"%20"));return new TextEncoder().encode(r)}function Au(t){return/\s/.test(t)||t===")"||t==='"'||t==="<"||t===">"}function Ji(t){return t.replace(/\\(?:\r\n|[\n\r\f])/g,"").replace(/\\([0-9a-fA-F]{1,6}\s?|[\s\S])/g,(e,n)=>{let r=n.match(/^([0-9a-fA-F]{1,6})\s?$/);if(r?.[1])try{return String.fromCodePoint(Number.parseInt(r[1],16))}catch{return""}return n})}function Iu(t){let e=[],n=0;for(;n<t.length;){let r=t.toLowerCase().indexOf("data:",n);if(r<0)break;let a=r>0?t[r-1]:"",i=a==='"'||a==="'"?a:null,o=t.indexOf(",",r);if(o<0)break;let s=t.slice(r+5,o);if(!s||/[\s"'()<>]/.test(s)){n=r+5;continue}let c=o+1,d=!1;for(;c<t.length;){let k=t[c]??"";if(d){d=!1,c+=1;continue}if(k==="\\"){d=!0,c+=1;continue}if(i?k===i:Au(k))break;c+=1}let u=t.slice(r,c),p=Ji(t.slice(o+1,c)),h=s.split(";"),f=h.shift()||"text/plain",w=h.some(k=>k.toLowerCase()==="base64");e.push({match:u,mime:f,isBase64:w,payload:p,index:r}),n=c}return e}function Pu(t){let e=t.trim();if(!e.toLowerCase().startsWith("data:"))return null;let n=e.indexOf(",");if(n<0)return null;let r=e.slice(5,n);if(!r||/[\s"'()<>]/.test(r))return null;let a=r.split(";"),i=a.shift()||"text/plain",o=a.some(s=>s.toLowerCase()==="base64");return{mime:i,isBase64:o,payload:Ji(e.slice(n+1))}}async function Fi(t,e){let n=Pu(t);if(!n)return null;let r;try{r=Vi(n.mime,n.isBase64,n.payload)}catch{return null}let a=`${await On(r)}${Lr(n.mime)}`;return e.has(a)||e.set(a,{filename:a,bytes:r,contentType:n.mime||"application/octet-stream"}),`assets/${a}`}async function jr(t,e,n){let r=n.get(t);if(r)return r;try{let a=await fetch(t,{cache:"force-cache",referrerPolicy:"strict-origin-when-cross-origin"});if(!a.ok)return null;let i=a.headers.get("content-type")?.split(";")[0]?.trim()||"application/octet-stream",o=new Uint8Array(await a.arrayBuffer());if(o.byteLength===0)return null;let s=`${await On(o)}${Lr(i)}`;e.has(s)||e.set(s,{filename:s,bytes:o,contentType:i});let c=`assets/${s}`;return n.set(t,c),c}catch{return null}}function Eu(t){let e=[],n=0,r=!1;for(let a=0;a<t.length;a+=1){if(t[a]!==",")continue;if(t.slice(n,a).trimStart().toLowerCase().startsWith("data:")&&!r){r=!0;continue}e.push(t.slice(n,a).trim()),n=a+1,r=!1}return e.push(t.slice(n).trim()),e.filter(Boolean).map(a=>{let i=a.match(/\s+(\d+(?:\.\d+)?[wx])$/);return i?.index?{url:a.slice(0,i.index).trim(),descriptor:i[1]??""}:{url:a,descriptor:""}}).filter(a=>a.url.length>0)}async function Ru(t,e,n,r){let a=Array.from(t.querySelectorAll("img[src],source[src],video[poster]"));for(let o of a){let s=o.hasAttribute("poster")?"poster":"src",c=o.getAttribute(s);if(!c)continue;let d=await Fi(c,n);if(d){o.setAttribute(s,d);continue}let u=Dr(c,e);if(!u)continue;let p=await jr(u,n,r);p&&o.setAttribute(s,p)}let i=Array.from(t.querySelectorAll("img[srcset],source[srcset]"));for(let o of i){let s=o.getAttribute("srcset");if(!s)continue;let c=[];for(let d of Eu(s)){let u=await Fi(d.url,n);if(u){c.push(`${u}${d.descriptor?` ${d.descriptor}`:""}`);continue}let p=Dr(d.url,e),h=p?await jr(p,n,r):null;c.push(`${h??d.url}${d.descriptor?` ${d.descriptor}`:""}`)}o.setAttribute("srcset",c.join(", "))}}async function $u(t,e,n,r){let a=[],i=/url\(\s*(["']?)([^"')]+)\1\s*\)/gi,o;for(;o=i.exec(t);){let c=o[2]??"",d=Dr(c,e);d&&a.push({raw:c,url:d})}let s=t;for(let c of a){let d=await jr(c.url,n,r);d&&(s=s.split(c.raw).join(d))}return s}async function Du(t){let e=new Map,n=Iu(t),r=[];for(let o of n){let s;try{s=Vi(o.mime,o.isBase64,o.payload)}catch{continue}let c=`${await On(s)}${Lr(o.mime)}`;e.has(c)||e.set(c,{filename:c,bytes:s,contentType:o.mime||"application/octet-stream"}),r.push({match:o.match,replacement:`assets/${c}`})}let a=t,i=new Map;for(let o of r)i.set(o.match,o.replacement);for(let[o,s]of i)a=a.split(o).join(s);return{html:a,assets:e}}function ju(t){return t.replace(/<script\b[\s\S]*?<\/script>/gi,"")}function Ou(t){return t.replace(/<script\b(?=[^>]*\bid=["']alpha-capture-index["'])[\s\S]*?<\/script>/i,"")}function Nu(t){return t.replace(/<link\b(?=[^>]*\brel=["'](?:preload|prefetch|preconnect|dns-prefetch|modulepreload|canonical|alternate)["'])[^>]*>/gi,"").replace(/<meta\b(?=[^>]*\b(?:property|name)=["'](?:og:[^"']+|twitter:[^"']+|description|keywords|robots|theme-color|generator)["'])[^>]*>/gi,"")}function Lu(t){let e=1,n=t.createTreeWalker(t.documentElement,NodeFilter.SHOW_ELEMENT,null),r=t.documentElement;do{if(r&&r.nodeType===1){let a=r.tagName.toLowerCase();Cu.has(a)&&(r.setAttribute("data-inkly-id",String(e)),e+=1)}r=n.nextNode()}while(r)}function zu(t){t.removeAttribute("href"),t.removeAttribute("xlink:href"),t.removeAttributeNS("http://www.w3.org/1999/xlink","href"),t.removeAttribute("target"),t.removeAttribute("rel"),t.removeAttribute("download"),t.removeAttribute("ping"),t.removeAttribute("referrerpolicy")}function Mu(t){for(let e of Array.from(t.querySelectorAll("*")))for(let n of Array.from(e.attributes))/^on/i.test(n.name)&&e.removeAttribute(n.name),/^formaction$/i.test(n.name)&&e.removeAttribute(n.name);for(let e of Array.from(t.querySelectorAll("base")))e.remove();for(let e of Array.from(t.querySelectorAll("link[href]")))(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).filter(Boolean).includes("stylesheet")||e.remove();for(let e of Array.from(t.querySelectorAll("meta[http-equiv]")))(e.getAttribute("http-equiv")??"").toLowerCase()==="refresh"&&e.remove();for(let e of Array.from(t.querySelectorAll("a,area")))zu(e),e.removeAttribute("data-inkly-href");for(let e of Array.from(t.querySelectorAll("form")))e.removeAttribute("action"),e.removeAttribute("method"),e.removeAttribute("target"),e.removeAttribute("data-inkly-action")}function Uu(t){let e=Array.from(t.querySelectorAll("style"));if(e.length===0)return"";let n=[],r=!0;for(let a of e){let i=a.textContent?.trim()??"",o=a.getAttribute("media")?.trim();if(o&&o.toLowerCase()!=="all"?n.push(`@media ${o} {${i}}`):n.push(i),r){let s=t.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href","assets/document.css"),a.replaceWith(s),r=!1}else a.remove()}return n.join(`
|
|
5039
5047
|
|
|
5040
|
-
`)}function
|
|
5048
|
+
`)}function Fu(t){let e="",n=0,r="",a=!1,i=0,o=!0,s=()=>{o&&(e+=" ".repeat(n),o=!1)},c=()=>{e=e.replace(/[ \t]+$/,""),e+=`
|
|
5041
5049
|
`,o=!0};for(let d of t){if(r){s(),e+=d,a?a=!1:d==="\\"?a=!0:d===r&&(r="");continue}if(a){s(),e+=d,a=!1;continue}if(d==="\\"){s(),e+=d,a=!0;continue}if(d==='"'||d==="'"){s(),r=d,e+=d;continue}if(d==="("&&(i+=1),d===")"&&(i=Math.max(0,i-1)),d==="{"){s(),e=e.replace(/[ \t]+$/,""),e+=` {
|
|
5042
5050
|
`,n+=1,o=!0;continue}if(d==="}"){n=Math.max(0,n-1),c(),s(),e+="}",c();continue}if(d===";"&&i===0){s(),e+=";",c();continue}if(d===","&&i===0){s(),e+=",",c();continue}s(),e+=d}return`${e.trim()}
|
|
5043
|
-
`}function
|
|
5044
|
-
${r}${
|
|
5045
|
-
${" ".repeat(e)}"`}function
|
|
5046
|
-
`)}function
|
|
5051
|
+
`}function Hi(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Or(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Bi(t){return t==="id"?0:t==="data-inkly-id"?1:t==="class"?2:t==="href"?3:t==="src"?4:t==="srcset"?5:t==="alt"?6:t==="aria-label"?7:t==="role"?8:t==="type"?9:t==="style"?10:20}function Hu(t){return Array.from(t.attributes).sort((n,r)=>Bi(n.name)-Bi(r.name)||n.name.localeCompare(r.name))}function Bu(t,e){let n=t.trim().split(/\s+/).filter(Boolean);if(n.length<=5&&t.length<=100)return`"${Or(t)}"`;let r=" ".repeat(e+2);return`"${n.map(a=>`
|
|
5052
|
+
${r}${Or(a)}`).join("")}
|
|
5053
|
+
${" ".repeat(e)}"`}function Wi(t,e){return t.name==="class"?`${t.name}=${Bu(t.value,e+t.name.length+2)}`:`${t.name}="${Or(t.value)}"`}function Wu(t,e){let n=Hu(t),r=t.tagName.toLowerCase();if(n.length===0)return`<${r}>`;let a=`<${r} ${n.map(o=>Wi(o,e)).join(" ")}>`;if(a.length<=110&&!n.some(o=>o.name==="class"&&o.value.length>100))return a;let i=[`<${r}`];for(let o of n)i.push(`${" ".repeat(e+2)}${Wi(o,e+2)}`);return i.push(`${" ".repeat(e)}>`),i.join(`
|
|
5054
|
+
`)}function Vu(t){let e=t.tagName.toLowerCase();if(e==="pre"||e==="code"||e==="textarea"||e==="style")return!0;let n=t.getAttribute("class")??"";if(/(^|\s)whitespace-(?:pre|pre-wrap|pre-line|break-spaces)(\s|$)/.test(n))return!0;let r=t.getAttribute("style")??"";return/(?:^|;)\s*white-space\s*:\s*(?:pre|pre-wrap|pre-line|break-spaces)\b/i.test(r)}function Nr(t,e){let n=" ".repeat(e*2);if(t.nodeType===Node.TEXT_NODE){let d=(t.nodeValue??"").replace(/\s+/g," ").trim();return d?`${n}${Hi(d)}`:""}if(t.nodeType===Node.COMMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return"";let r=t,a=r.tagName.toLowerCase(),i=`${n}${Wu(r,n.length)}`;if(_u.has(a))return i;if(a==="template"&&"content"in r){let d=r,u=[];for(let p of Array.from(d.content.childNodes)){let h=Nr(p,e+1);h&&u.push(h)}return u.length===0?`${i}</${a}>`:`${i}
|
|
5047
5055
|
${u.join(`
|
|
5048
5056
|
`)}
|
|
5049
|
-
${n}</${a}>`}if(
|
|
5057
|
+
${n}</${a}>`}if(Vu(r))return`${n}${r.outerHTML}`;let o=Array.from(r.childNodes).filter(d=>d.nodeType!==Node.COMMENT_NODE&&!(d.nodeType===Node.TEXT_NODE&&(d.nodeValue??"").trim().length===0));if(o.length>0&&o.every(d=>d.nodeType===Node.TEXT_NODE)){let d=o.map(u=>u.nodeValue??"").join("").replace(/\s+/g," ").trim();return d?`${i}${Hi(d)}</${a}>`:`${i}</${a}>`}let s=[];for(let d of Array.from(r.childNodes)){let u=Nr(d,e+1);u&&s.push(u)}if(s.length===0)return`${i}</${a}>`;let c=s[0];return s.length===1&&c&&c.trim()&&!c.includes(`
|
|
5050
5058
|
`)&&i.length+c.trim().length<120?`${i}${c.trim()}</${a}>`:`${i}
|
|
5051
5059
|
${s.join(`
|
|
5052
5060
|
`)}
|
|
5053
|
-
${n}</${a}>`}function
|
|
5054
|
-
${
|
|
5055
|
-
`}var
|
|
5061
|
+
${n}</${a}>`}function Ju(t){let e=t.documentElement;return`<!doctype html>
|
|
5062
|
+
${Nr(e,0)}
|
|
5063
|
+
`}var Zu=.8,Gu=1024;function qu(t){let e=(t.toLowerCase().split(";")[0]??"").trim();return e==="image/png"||e==="image/jpeg"||e==="image/jpg"}async function Ku(t,e){if(typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{let n=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),r=await createImageBitmap(new Blob([n],{type:e}));try{let a=new OffscreenCanvas(r.width,r.height),i=a.getContext("2d");if(!i)return null;i.drawImage(r,0,0);let o=await a.convertToBlob({type:"image/webp",quality:Zu});return o.type!=="image/webp"?null:new Uint8Array(await o.arrayBuffer())}finally{r.close()}}catch{return null}}async function Yu(t,e,n){let r=new Map,a=new Map;for(let s of t.values()){if(!qu(s.contentType)||s.bytes.byteLength<Gu){a.set(s.filename,s);continue}let c=await Ku(s.bytes,s.contentType);if(!c||c.byteLength>=s.bytes.byteLength){a.set(s.filename,s);continue}let d=`${await On(c)}.webp`;r.set(s.filename,d),a.has(d)||a.set(d,{filename:d,bytes:c,contentType:"image/webp"})}if(r.size===0)return{assets:[...t.values()],html:e,css:n};let i=e,o=n;for(let[s,c]of r)i=i.split(`assets/${s}`).join(`assets/${c}`),o=o.split(s).join(c);return{assets:[...a.values()],html:i,css:o}}async function Zi(t,e,n={}){let r=ju(t);r=Ou(r),r=Nu(r);let a=await Du(r);r=a.html;let i=Xu(r);Lu(i),Mu(i);let o=new Map;await Ru(i,e,a.assets,o);let s=(await $u(Uu(i),e,a.assets,o)).replace(/url\((["']?)assets\//g,"url($1"),c=Zt(Ju(i)),d=Fu(s);if(n.compressImages){let u=await Yu(a.assets,c,d);return{html:u.html,css:u.css,assets:u.assets}}return{html:c,css:d,assets:[...a.assets.values()]}}function Xu(t){let e=globalThis.DOMParser;if(!e)throw new Error("DOMParser is not available in this context. Run compactSnapshot in an offscreen document.");return new e().parseFromString(t,"text/html")}import{zipSync as Qu}from"fflate";var ep=/^(?:https?:)?\/\//i,tp=/^(?:#|data:|blob:|javascript:|mailto:|tel:|about:|chrome:|chrome-extension:)/i;function np(t){return t.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,60).replace(/-+$/,"")||"demo"}function rp(t){let e="abcdefghijklmnopqrstuvwxyz0123456789",n=new Uint8Array(t);crypto.getRandomValues(n);let r="";for(let a=0;a<t;a+=1)r+=e[(n[a]??0)%e.length];return r}function ap(t){return`${np(t)}-${rp(6)}`}function ip(t,e){return`# ${e}
|
|
5056
5064
|
|
|
5057
5065
|
This folder is a self-contained Inkly HTML capture. It works locally with
|
|
5058
5066
|
\`inkly-cli\` with no upload needed.
|
|
@@ -5062,7 +5070,8 @@ This folder is a self-contained Inkly HTML capture. It works locally with
|
|
|
5062
5070
|
1. If you don't have a hub yet, create one:
|
|
5063
5071
|
|
|
5064
5072
|
\`\`\`bash
|
|
5065
|
-
|
|
5073
|
+
npm install -g @inkly-org/cli
|
|
5074
|
+
inkly init my-hub
|
|
5066
5075
|
cd my-hub
|
|
5067
5076
|
\`\`\`
|
|
5068
5077
|
|
|
@@ -5084,10 +5093,10 @@ This folder is a self-contained Inkly HTML capture. It works locally with
|
|
|
5084
5093
|
- \`${t}/capture-metadata.json\` - HTML export diagnostics.
|
|
5085
5094
|
- \`${t}/public/<file>\` - captured HTML asset bytes.
|
|
5086
5095
|
- \`${t}/snapshots/snap-NNN/index.html\` and \`document.css\` - replayable snapshots.
|
|
5087
|
-
`}function
|
|
5096
|
+
`}function op(t){return t.trim().replace(/^['"]|['"]$/g,"")}function Nn(t,e){let n=op(e.url);!n||tp.test(n)||!ep.test(n)||t.set(`${e.stepId}\0${e.file}\0${e.kind}\0${n}`,{...e,url:n})}function sp(t){return t.split(",").map(e=>e.trim().split(/\s+/)[0]??"").filter(Boolean)}function lp(t,e){return t?.alphaId?e.includes(`data-inkly-id="${t.alphaId}"`)||e.includes(`data-inkly-id='${t.alphaId}'`)?t:{...t,alphaId:void 0}:t}function dp(t){let e=new Map,n=/\b(?:src|poster|data|action|formaction)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))/gi,r;for(;(r=n.exec(t.html))!==null;)Nn(e,{stepId:t.stepId,file:t.htmlPath,kind:"html-attribute",url:r[1]??r[2]??r[3]??""});let a=/<link\b(?=[^>]*\b(?:rel|as)\s*=\s*(?:"(?:stylesheet|preload|modulepreload|icon|apple-touch-icon|image_src)"|'(?:stylesheet|preload|modulepreload|icon|apple-touch-icon|image_src)'|[^\s"'<>`]*(?:stylesheet|preload|modulepreload|icon|apple-touch-icon|image_src)[^\s"'<>`]*))[^>]*\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))[^>]*>/gi,i;for(;(i=a.exec(t.html))!==null;)Nn(e,{stepId:t.stepId,file:t.htmlPath,kind:"html-attribute",url:i[1]??i[2]??i[3]??""});let o=/\b(?:srcset|imagesrcset)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))/gi,s;for(;(s=o.exec(t.html))!==null;){let u=s[1]??s[2]??s[3]??"";for(let p of sp(u))Nn(e,{stepId:t.stepId,file:t.htmlPath,kind:"html-srcset",url:p})}let c=/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)"'\s]+))\s*\)/gi,d;for(;(d=c.exec(t.css))!==null;)Nn(e,{stepId:t.stepId,file:t.htmlPath.replace(/\/index\.html$/,"/document.css"),kind:"css-url",url:d[1]??d[2]??d[3]??""});return[...e.values()]}async function Gi(t){let{name:e,steps:n,assets:r}=t;if(n.length===0)throw new Error("No HTML steps captured.");let a=ap(e),i=new Map;for(let C of r)i.set(C.filename,`/${a}/${C.filename}`);let o={},s=[],c=[],d=new TextEncoder;for(let C=0;C<n.length;C+=1){let $=n[C];if(!$)continue;let N=`s${C+1}`,E=ka(C+1),b=`snapshots/${E}/index.html`,L=Xn($.cssText??"",i),z=va(Sa(Zt(Xn($.htmlText,i)),L.length>0),$.scroll);o[E]={"index.html":d.encode(z),"document.css":d.encode(L)},c.push(...dp({stepId:N,htmlPath:b,html:z,css:L})),s.push(wa({stepId:N,htmlPath:b,naturalWidth:$.viewport.width,naturalHeight:$.viewport.height,scroll:$.scroll,sourceUrl:$.url||void 0,click:lp($.click,z)}))}let u=r.map(C=>({id:C.filename,sha256:C.sha256,kind:mn(C.contentType),contentType:C.contentType,size:C.bytes.byteLength,publicUrl:`/${a}/${C.filename}`})),p=bn({id:ne(),version:1,title:e,steps:s}),h=_t.parse({version:1,assets:u,screens:[]}),f={version:1,kind:"html-capture",generatedAt:t.generatedAt??new Date().toISOString(),stepCount:n.length,assetCount:r.length,unresolvedExternalReferences:c},w={};for(let C of r)w[C.filename]=C.bytes;let k={"README.md":d.encode(ip(a,e)),[a]:{"demo.config.json":d.encode(`${JSON.stringify(p,null,2)}
|
|
5088
5097
|
`),"assets.json":d.encode(`${JSON.stringify(h,null,2)}
|
|
5089
|
-
`),"capture-metadata.json":d.encode(`${JSON.stringify(
|
|
5090
|
-
`),snapshots:o,public:
|
|
5098
|
+
`),"capture-metadata.json":d.encode(`${JSON.stringify(f,null,2)}
|
|
5099
|
+
`),snapshots:o,public:w}};return{bytes:Qu(k,{level:6}),filename:`${a}.zip`,slug:a}}import{JSDOM as wp}from"jsdom";var qi=!1;function vp(){if(qi)return;let{window:t}=new wp("<!doctype html><html></html>"),e=globalThis;e.DOMParser??=t.DOMParser,e.Node??=t.Node,e.NodeFilter??=t.NodeFilter,e.Element??=t.Element,e.HTMLImageElement??=t.HTMLImageElement,qi=!0}var oo=`Options:
|
|
5091
5100
|
--url <url> URL to open and arm for recording.
|
|
5092
5101
|
--name <name> Demo name written into the exported ZIP.
|
|
5093
5102
|
--session <id> Session id printed by start.
|
|
@@ -5107,15 +5116,17 @@ This folder is a self-contained Inkly HTML capture. It works locally with
|
|
|
5107
5116
|
done once in this profile survives, so later captures of the same site need
|
|
5108
5117
|
no re-login. Implies --keep-profile. Run --headed the first time so the user
|
|
5109
5118
|
can sign in; reuse can run headless.
|
|
5110
|
-
--no-unpack On stop, write only the ZIP.`,
|
|
5119
|
+
--no-unpack On stop, write only the ZIP.`,nn=`inkly capture - capture an image/video walkthrough for an external browser agent
|
|
5111
5120
|
|
|
5112
5121
|
Usage:
|
|
5113
5122
|
inkly capture start --url <url> --name <name>
|
|
5114
5123
|
inkly capture stop --session <id> --out <dir>
|
|
5115
5124
|
inkly capture cancel --session <id>
|
|
5125
|
+
inkly capture status --session <id>
|
|
5126
|
+
inkly capture undo --session <id>
|
|
5116
5127
|
inkly capture profiles
|
|
5117
5128
|
|
|
5118
|
-
${
|
|
5129
|
+
${oo}
|
|
5119
5130
|
--video, --record-video Record motion segments. Enabled by default; use --no-video to disable.
|
|
5120
5131
|
--zoom Apply click zoom/pan to screenshot steps. Enabled by default; use --no-zoom to disable.
|
|
5121
5132
|
--compress-images Re-encode captured PNG/JPEG screenshots to WebP (smaller, near-lossless).
|
|
@@ -5124,28 +5135,30 @@ ${Ji}
|
|
|
5124
5135
|
Output:
|
|
5125
5136
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
5126
5137
|
For self-contained HTML snapshot capture, use \`inkly capture-html\`.
|
|
5127
|
-
`,
|
|
5138
|
+
`,rn=`inkly capture-html - capture a self-contained HTML walkthrough for an external browser agent
|
|
5128
5139
|
|
|
5129
5140
|
Usage:
|
|
5130
5141
|
inkly capture-html start --url <url> --name <name>
|
|
5131
5142
|
inkly capture-html stop --session <id> --out <dir>
|
|
5132
5143
|
inkly capture-html cancel --session <id>
|
|
5144
|
+
inkly capture-html status --session <id>
|
|
5145
|
+
inkly capture-html undo --session <id>
|
|
5133
5146
|
inkly capture-html profiles
|
|
5134
5147
|
|
|
5135
|
-
${
|
|
5148
|
+
${oo}
|
|
5136
5149
|
--block-videos Replace <video> with its poster frame instead of inlining the video.
|
|
5137
5150
|
|
|
5138
5151
|
Output:
|
|
5139
5152
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
5140
|
-
`,
|
|
5141
|
-
`)}function
|
|
5153
|
+
`,Sp=Mn(io(import.meta.url)),_p=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/opt/google/chrome/chrome"],Cp=1440,Tp=900,Ap=12e4;function Lt(t){return new Promise(e=>setTimeout(e,t))}function He(t){process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
5154
|
+
`)}function Ot(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))return;let n=t[e];return typeof n=="string"?n:""}function zr(t,e,n){let r=t[e];return typeof r=="number"?r:typeof r=="string"&&r.trim()?Number(r):n}function jt(t,e,n){for(let r of e)if(Object.prototype.hasOwnProperty.call(t,r))return t[r]!==!1;return n}function Ip(t){if(!t)return null;let e=/^\s*(\d+)\s*[x,]\s*(\d+)\s*$/i.exec(t);if(!e)throw new Error("--window-size must look like 1440x900");return{width:Number(e[1]),height:Number(e[2])}}function mt(t,e,n){let r=Ot(t,e);if(!r)throw new Error(`missing --${e} <value>
|
|
5142
5155
|
|
|
5143
|
-
${n}`);return r}function
|
|
5156
|
+
${n}`);return r}function Pp(t){return Ot(t,"connect-to-browser")??process.env.INKLY_CAPTURE_BROWSER_URL}function Ep(t){if(Object.prototype.hasOwnProperty.call(t,"prompt"))throw new Error("inkly capture does not accept --prompt. The external agent owns planning.")}function Wr(t,e){return ao(e)?e:Ln(t,e)}function so(){return B(Br(),".inkly","capture-agent","profiles")}function Rp(t,e){if(e.includes("/")||ao(e))return Wr(t,e);let n=e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);return B(so(),n||"default")}function Ki(t,e){let n=Ln(t);for(;;){let r=B(n,e);if(Pe(r))return r;let a=Mn(n);if(a===n)return null;n=a}}async function Yi(t){let e=[t];for(;e.length>0;){let n=e.pop();if(!n)continue;let r=await no(n,{withFileTypes:!0}).catch(()=>[]);for(let a of r){let i=B(n,a.name);if(a.isDirectory()){e.push(i);continue}if(a.name==="Google Chrome for Testing"&&i.includes("Google Chrome for Testing.app/Contents/MacOS"))return i}}return null}async function $p(t,e){if(e){let s=Wr(t,e);if(Pe(s))return s;throw new Error(`Chrome binary does not exist: ${s}`)}let n=process.env.CHROME_PATH;if(n&&Pe(n))return n;let r=_p.find(s=>Pe(s));if(r)return r;let a=Ki(t,"chrome");if(a){let s=await Yi(a);if(s)return s}let i=Ki(Sp,"chrome");if(i&&i!==a){let s=await Yi(i);if(s)return s}let o=["/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing","/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary","/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"];for(let s of o)if(Pe(s))return s;throw new Error("No Chrome binary found. Pass --browser /path/to/chrome.")}var Mr=class{constructor(e){this.nextId=1;this.pending=new Map;this.listeners=new Map;this.ws=new yp(e,{perMessageDeflate:!1,maxPayload:512*1024*1024}),this.ready=new Promise((n,r)=>{this.ws.once("open",()=>n()),this.ws.once("error",a=>r(a))}),this.ws.on("message",n=>{let r=JSON.parse(n.toString());if(typeof r.id=="number"&&this.pending.has(r.id)){let i=this.pending.get(r.id);if(this.pending.delete(r.id),!i)return;r.error?i.reject(new Error(`${r.error.message??"CDP error"}: ${JSON.stringify(r.error.data??"")}`)):i.resolve(r.result??{});return}if(!r.method)return;let a=this.listeners.get(r.method);if(a)for(let i of a)i(r.params,r.sessionId)})}async send(e,n={},r){await this.ready;let a=this.nextId;this.nextId+=1;let i={id:a,method:e,params:n};return r&&(i.sessionId=r),new Promise((o,s)=>{this.pending.set(a,{resolve:o,reject:s}),this.ws.send(JSON.stringify(i),c=>{c&&(this.pending.delete(a),s(c))})})}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 lo(t,e,n,r=3e4){let a=await t.send("Runtime.evaluate",{expression:n,awaitPromise:!0,returnByValue:!0,timeout:r,userGesture:!0},e);if(a.exceptionDetails)throw new Error(`Runtime.evaluate failed: ${JSON.stringify(a.exceptionDetails)}`);return a.result?.value}async function Dp(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 jp(t){let e=t.userDataDir?(await Nt(t.userDataDir,{recursive:!0}),t.userDataDir):await hp(B(fp(),"inkly-capture-agent-")),n=B(e,"chrome.log"),r=await to(n,"a"),a=["--remote-debugging-port=0",`--user-data-dir=${e}`,`--window-size=${t.width},${t.height}`,"--no-first-run","--no-default-browser-check","--disable-default-apps","--disable-background-networking","--disable-features=Translate,AutofillServerCommunication","--use-mock-keychain","--hide-scrollbars","--hide-crash-restore-bubble"];t.headless&&a.unshift("--headless=new");for(let d of["DevToolsActivePort","SingletonLock","SingletonCookie","SingletonSocket"])await Fe(B(e,d),{force:!0}).catch(()=>{});let i=eo(t.browser,a,{detached:!0,stdio:["ignore",r.fd,r.fd]});i.unref(),await r.close();let o=B(e,"DevToolsActivePort"),s=Date.now(),c;for(i.once("exit",d=>{c=d});Date.now()-s<2e4;){if(c!==void 0)throw new Error(`Chrome exited before DevTools was ready. See ${n}`);let d=await Ee(o,"utf8").catch(()=>null);if(d){let u=d.trim().split(/\r?\n/),p=u[0],h=u[1];if(p&&h)return{pid:i.pid??null,profileDir:e,wsUrl:`ws://127.0.0.1:${p}${h}`,debuggingUrl:`http://127.0.0.1:${p}`,logPath:n}}await Lt(100)}throw new Error(`Timed out waiting for Chrome DevTools. See ${n}`)}async function Op(t){if(t.startsWith("ws://")||t.startsWith("wss://")){let a=new URL(t);return{wsUrl:t,debuggingUrl:`${a.protocol==="wss:"?"https":"http"}://${a.host}`}}let e=new URL(t),n=await fetch(new URL("/json/version",e));if(!n.ok)throw new Error(`could not read Chrome DevTools metadata from ${e.toString()}: ${n.status}`);let r=await n.json();if(typeof r.webSocketDebuggerUrl!="string")throw new Error("Chrome DevTools metadata did not include webSocketDebuggerUrl");return{wsUrl:r.webSocketDebuggerUrl,debuggingUrl:`${e.protocol}//${e.host}`}}async function Np(t,e,n,r,a){let o=(await t.send("Target.createTarget",{url:"about:blank"})).targetId;if(typeof o!="string")throw new Error("Target.createTarget returned no targetId");let s=await Dp(t,o);await t.send("Page.enable",{},s),await t.send("Runtime.enable",{},s),await zp(t,s,o,n,r);let c=!1,d=t.on("Page.loadEventFired",(p,h)=>{h===s&&(c=!0)});await t.send("Page.navigate",{url:e},s);let u=Date.now();for(;!c&&Date.now()-u<a;)await Lt(100);return d(),await Lt(1e3),{targetId:o,sessionId:s}}async function Lp(t,e){let n=await lo(t,e,`JSON.stringify({
|
|
5144
5157
|
innerWidth: window.innerWidth,
|
|
5145
5158
|
innerHeight: window.innerHeight,
|
|
5146
5159
|
outerWidth: window.outerWidth,
|
|
5147
5160
|
outerHeight: window.outerHeight
|
|
5148
|
-
})`,5e3),r=JSON.parse(String(n)),a={innerWidth:Number(r.innerWidth),innerHeight:Number(r.innerHeight),outerWidth:Number(r.outerWidth),outerHeight:Number(r.outerHeight)};if(!Number.isFinite(a.innerWidth)||!Number.isFinite(a.innerHeight)||!Number.isFinite(a.outerWidth)||!Number.isFinite(a.outerHeight))throw new Error(`could not measure Chrome viewport: ${JSON.stringify(r)}`);return a}async function
|
|
5161
|
+
})`,5e3),r=JSON.parse(String(n)),a={innerWidth:Number(r.innerWidth),innerHeight:Number(r.innerHeight),outerWidth:Number(r.outerWidth),outerHeight:Number(r.outerHeight)};if(!Number.isFinite(a.innerWidth)||!Number.isFinite(a.innerHeight)||!Number.isFinite(a.outerWidth)||!Number.isFinite(a.outerHeight))throw new Error(`could not measure Chrome viewport: ${JSON.stringify(r)}`);return a}async function zp(t,e,n,r,a){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 s=0;s<4;s+=1){let c=await Lp(t,e),d=Math.max(0,c.outerWidth-c.innerWidth),u=Math.max(0,c.outerHeight-c.innerHeight),p=r+d,h=a+u;if(Math.abs(c.innerWidth-r)<=1&&Math.abs(c.innerHeight-a)<=1)return;await t.send("Browser.setWindowBounds",{windowId:o,bounds:{windowState:"normal",width:p,height:h}}),await Lt(250)}}catch{}await t.send("Emulation.setDeviceMetricsOverride",{width:r,height:a,deviceScaleFactor:1,mobile:!1},e).catch(()=>{}),await Lt(100)}function Mp(t){return t.toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"captured-demo"}function Up(t){return`${Mp(t)}-${Math.random().toString(36).slice(2,8)}`}function Vr(t){return up("sha256").update(t).digest("hex")}function Fp(t,e){return`# ${e}
|
|
5149
5162
|
|
|
5150
5163
|
This folder is a self-contained Inkly demo captured with the Inkly CLI
|
|
5151
5164
|
agent runtime. It works locally with \`inkly-cli\` \u2014 no upload needed.
|
|
@@ -5167,9 +5180,9 @@ agent runtime. It works locally with \`inkly-cli\` \u2014 no upload needed.
|
|
|
5167
5180
|
- \`${t}/assets.json\` \u2014 maps each \`asset:<id>\` to a file in \`public/\`.
|
|
5168
5181
|
- \`${t}/public/<file>\` \u2014 captured image/video bytes.
|
|
5169
5182
|
- \`${t}/snapshots/snap-NNN/index.html\` \u2014 captured HTML snapshots, when present.
|
|
5170
|
-
`}function
|
|
5171
|
-
`),"assets.json":
|
|
5172
|
-
`),public:d,snapshots:u}};return{bytes:
|
|
5183
|
+
`}function Hp(t){switch(t.toLowerCase().split(";")[0]?.trim()){case"image/png":return"png";case"image/jpeg":case"image/jpg":return"jpg";case"image/webp":return"webp";case"image/gif":return"gif";case"image/svg+xml":return"svg";case"image/avif":return"avif";case"image/x-icon":case"image/vnd.microsoft.icon":return"ico";case"font/woff":return"woff";case"font/woff2":return"woff2";case"font/ttf":case"application/x-font-ttf":return"ttf";case"video/webm":return"webm";case"video/mp4":return"mp4";case"audio/mpeg":return"mp3";case"text/html":return"html";case"text/css":return"css";case"text/javascript":case"application/javascript":case"application/x-javascript":return"js";default:return"bin"}}async function Bp(t,e,n,r,a){let i=new TextDecoder,o=new TextEncoder,s=new Map,c=0,d=0,u=0,p=" ";if(a.subsetFonts){let h=new Set;for(let f of Object.values(r)){let w=f["index.html"];if(!w)continue;let k=i.decode(w).replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ");for(let C of k)h.add(C)}for(let f of" 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,:;!?@#$%&*()-_=+[]{}/\\|<>'\"`~\u2019\u201C\u201D\u2014\u2013\u2026\u2022\u2192")h.add(f);p=Array.from(h).join("")}for(let h of e){let f=h.publicUrl;if(!f)continue;let w=f.split("/").pop();if(!w)continue;let k=n[w];if(!k)continue;let C=null,$="",N="",E=(h.contentType??"").toLowerCase();try{if(a.compressImages&&h.kind==="image"&&/^image\/(png|jpe?g)$/.test(E)){let W=await xp(Buffer.from(k)).webp({quality:80}).toBuffer();W.length<k.byteLength&&(C=W,$="webp",N="image/webp")}else if(a.subsetFonts&&h.kind==="font"){let W=await kp(Buffer.from(k),p,{targetFormat:"woff2"});W.length<k.byteLength&&(C=W,$="woff2",N="font/woff2")}}catch{C=null}if(!C)continue;let b=new Uint8Array(C),L=Vr(b),z=`${L.slice(0,16)}.${$}`,D=`/${t}/${z}`;u+=k.byteLength-b.byteLength,h.kind==="image"?c+=1:d+=1,delete n[w],n[z]=b,h.id===w&&(h.id=z),s.set(f,D),h.sha256=L,h.size=b.byteLength,h.contentType=N,h.publicUrl=D}if(s.size)for(let h of Object.values(r)){let f=h;for(let w of Object.keys(f)){let k=i.decode(f[w]);for(let[C,$]of s)k=k.split(C).join($);f[w]=o.encode(k)}}return{images:c,fonts:d,savedBytes:u}}async function Wp(t){let{name:e,screens:n,autoApplyZoom:r=!0,compressImages:a=!1,subsetFonts:i=!1}=t;if(n.length===0)throw new Error("No screens captured.");let o=Up(e),s=[],c=[],d={},u={},p=[],h=[],f=new TextEncoder,w=0;async function k(E,b,L,z,D){let W=Vr(E),X=D??`${W}.${Hp(b)}`;d[X]=E,w+=1;let ye=L==="other"?X:`cap-${String(w).padStart(3,"0")}`;return s.push({id:ye,sha256:W,kind:L==="other"?mn(b):L,contentType:b,size:E.byteLength,viewport:z?{w:z.width,h:z.height}:void 0,file:X}),ye}for(let[E,b]of n.entries()){let L=`s${E+1}`,z=null;if(b.kind!=="html"){if(b.kind==="video"&&b.videoPath){let D=new Uint8Array(await Ee(b.videoPath));z=await k(D,"video/webm","video",b.viewport);let W;if(b.posterPngPath){let X=new Uint8Array(await Ee(b.posterPngPath));W=await k(X,"image/png","image",b.viewport)}p.push(Yn({stepId:L,kind:"video",assetId:z,posterAssetId:W,naturalWidth:b.naturalSize.width,naturalHeight:b.naturalSize.height,sourceUrl:b.sourceUrl||void 0,title:b.title||void 0,click:b.click,autoApplyZoom:r,isLast:E===n.length-1})),h.push(b.click?.label||b.title||`Step ${E+1}`)}else{if(!b.pngPath)continue;let D=new Uint8Array(await Ee(b.pngPath));z=await k(D,"image/png","image",b.viewport),p.push(Yn({stepId:L,kind:"image",assetId:z,naturalWidth:b.naturalSize.width,naturalHeight:b.naturalSize.height,sourceUrl:b.sourceUrl||void 0,title:b.title||void 0,click:b.click,autoApplyZoom:r,isLast:E===n.length-1})),h.push(b.click?.label||b.title||`Step ${E+1}`)}c.push({index:E,id:xa(E),assetId:z,sourceUrl:b.sourceUrl,capturedAt:b.capturedAt,naturalWidth:b.naturalSize.width,naturalHeight:b.naturalSize.height,precedingClick:b.click})}}if(p.length===0)throw new Error("No usable screens captured.");(a||i)&&await Bp(o,s,d,u,{compressImages:a,subsetFonts:i});let C=bn({id:ne(),version:1,title:e,steps:p}),$=_t.parse({version:1,assets:s,screens:c}),N={"README.md":f.encode(Fp(o,e)),[o]:{"demo.config.json":f.encode(`${JSON.stringify(C,null,2)}
|
|
5184
|
+
`),"assets.json":f.encode(`${JSON.stringify($,null,2)}
|
|
5185
|
+
`),public:d,snapshots:u}};return{bytes:bp(N,{level:6}),filename:`${o}.zip`,slug:o,stepCount:n.length,labels:h}}function Vp(t){return t?{x:t.x,y:t.y,alphaId:t.alphaId??void 0,label:t.label}:null}async function Jp(t){let{name:e,screens:n}=t,r=n.filter(c=>c.kind==="html"&&c.htmlPath);if(r.length===0)throw new Error("No HTML screens captured.");let a=r.map((c,d)=>c.click?.label||c.title||`Step ${d+1}`);vp();let i=[],o=new Map;for(let c of r){let d=await Ee(c.htmlPath,"utf8"),u=await Zi(d,c.sourceUrl||"");for(let p of u.assets)o.has(p.filename)||o.set(p.filename,{filename:p.filename,sha256:Vr(p.bytes),contentType:p.contentType,bytes:p.bytes});i.push({htmlText:u.html,cssText:u.css,viewport:{width:c.naturalSize.width,height:c.naturalSize.height},scroll:c.scroll??{x:0,y:0,maxX:0,maxY:0},url:c.sourceUrl||"",click:Vp(c.click)})}return{...await Gi({name:e,steps:i,assets:[...o.values()]}),stepCount:r.length,labels:a}}var Xi=`(() => {
|
|
5173
5186
|
if (window.__inklyCliRecorderInstalled) return;
|
|
5174
5187
|
window.__inklyCliRecorderInstalled = true;
|
|
5175
5188
|
window.__inklyCliLastClick = null;
|
|
@@ -5353,7 +5366,7 @@ function selectorFor(el) {
|
|
|
5353
5366
|
window.addEventListener("scroll", onMotionScroll, true);
|
|
5354
5367
|
window.addEventListener("wheel", onMotionScroll, true);
|
|
5355
5368
|
window.addEventListener("touchmove", onMotionScroll, true);
|
|
5356
|
-
})();`;async function
|
|
5369
|
+
})();`;async function Zp(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:Xi},e),await lo(t,e,Xi,5e3).catch(()=>{})}var Gp="__inklySingleFileFetch",Ab=`(() => {
|
|
5357
5370
|
if (globalThis.__inklyFetchInstalled) return;
|
|
5358
5371
|
globalThis.__inklyFetchInstalled = true;
|
|
5359
5372
|
const pending = new Map();
|
|
@@ -5373,7 +5386,7 @@ function selectorFor(el) {
|
|
|
5373
5386
|
const id = nextId++;
|
|
5374
5387
|
pending.set(id, { resolve, reject });
|
|
5375
5388
|
try {
|
|
5376
|
-
globalThis.${
|
|
5389
|
+
globalThis.${Gp}(JSON.stringify({
|
|
5377
5390
|
id,
|
|
5378
5391
|
url: String(url),
|
|
5379
5392
|
options: {
|
|
@@ -5396,9 +5409,14 @@ function selectorFor(el) {
|
|
|
5396
5409
|
return viaNode(url, options);
|
|
5397
5410
|
}
|
|
5398
5411
|
};
|
|
5399
|
-
})();`;var
|
|
5400
|
-
`)}async function
|
|
5401
|
-
`)}async function
|
|
5412
|
+
})();`;var Ib=Math.max(6e4,Number(process.env.INKLY_CAPTURE_TIMEOUT_MS)||24e4);function Jr(){return B(process.env.INKLY_CAPTURE_AGENT_HOME||B(Br(),".inkly"),"capture-agent","sessions")}function qp(t){return B(process.env.INKLY_CAPTURE_AGENT_HOME||B(Br(),".inkly"),"capture-agent","captures",t)}async function Kp(t,e){await Nt(e,{recursive:!0});let n=B(e,"listener.log"),r=await to(n,"a"),a=io(import.meta.url),i=B(Mn(a),"capture-listener.js"),o=eo(process.execPath,[i,"--session",t],{detached:!0,stdio:["ignore",r.fd,r.fd]});return o.unref(),await r.close(),{pid:o.pid??null,logPath:n}}async function Yp(t,e){let n=Date.now();for(;Date.now()-n<e;){let r=await zt(t).catch(()=>null);if(r?.cliListenerReadyAt)return r;await Lt(100)}return zt(t)}function Un(t){if(!/^[a-zA-Z0-9._:-]+$/.test(t))throw new Error(`invalid session id: ${t}`);return B(Jr(),`${t}.json`)}function Zr(t){return B(Jr(),`${t}.listener.json`)}async function Xp(t,e){await Y(Zr(t),`${JSON.stringify(e,null,2)}
|
|
5413
|
+
`)}async function Qp(t){try{let e=await Ee(Zr(t),"utf8");return JSON.parse(e)}catch{return null}}async function eh(t){await Y(Un(t.id),`${JSON.stringify(t,null,2)}
|
|
5414
|
+
`)}async function zt(t){let e=await Ee(Un(t),"utf8");return JSON.parse(e)}async function Ur(t){await Fe(Un(t),{force:!0}),await Fe(Zr(t),{force:!0})}function co(t){try{return process.kill(t,0),!0}catch{return!1}}async function Qi(t){let e=(n,r)=>{try{process.kill(n,r)}catch{}};e(-t,"SIGTERM"),e(t,"SIGTERM");for(let n=0;n<8&&co(t);n+=1)await new Promise(r=>setTimeout(r,100));e(-t,"SIGKILL"),e(t,"SIGKILL")}async function th(t){if(!t||!t.includes("inkly"))return;let e=await new Promise(n=>{cp("pgrep",["-f","--",t],{timeout:4e3},(r,a)=>{let i=String(a||"").split(`
|
|
5415
|
+
`).map(o=>Number(o.trim())).filter(o=>Number.isInteger(o)&&o>0&&o!==process.pid);n(i)})});for(let n of e)try{process.kill(n,"SIGKILL")}catch{}}async function tn(t){let e=t.cliListenerPid??null;!e&&t.id&&(e=(await Qp(t.id))?.cliListenerPid??null),e&&await Qi(e),!t.attached&&(t.chromePid&&await Qi(t.chromePid),await th(t.profileDir),t.keepProfile||t.profileDir&&await Fe(t.profileDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}))}async function nh(t,e,n,r){let a=mt(e,"url",r),i=mt(e,"name",r);new URL(a);let o=Ip(Ot(e,"window-size")),s=o?.width??zr(e,"width",Cp),c=o?.height??zr(e,"height",Tp),d=zr(e,"timeout",Ap),u=Pp(e),p=Ot(e,"runtime");if(p&&p!=="cli")throw new Error("--runtime must be cli");let h=n,f=jt(e,["zoom","auto-apply-zoom"],!0),k=jt(e,["record-video","video"],!0)&&h!=="html",C=jt(e,["block-videos","block-video"],!1),$=jt(e,["compress-images","compress-image"],!1),N=jt(e,["subset-fonts","subset-font"],!1),E=jt(e,["headless"],!0)&&e.headed!==!0,b=Ot(e,"profile"),L=!u&&b?Rp(t,b):null,z=L!=null&&Pe(B(L,"Default"));if(!Number.isInteger(s)||s<320)throw new Error("--width must be an integer >= 320");if(!Number.isInteger(c)||c<240)throw new Error("--height must be an integer >= 240");if(!Number.isInteger(d)||d<1e3)throw new Error("--timeout must be an integer >= 1000");let D=u?{pid:null,profileDir:null,...await Op(u),logPath:null}:await(async()=>{let G=await $p(t,Ot(e,"browser"));return jp({browser:G,width:s,height:c,headless:E,timeoutMs:d,userDataDir:L})})(),W=new Mr(D.wsUrl),X=null,ye=!1,Mt=()=>{tn({id:"",runtime:"cli",createdAt:"",url:a,name:i,chromePid:D.pid,profileDir:D.profileDir,keepProfile:L!=null||!!u,browserWsUrl:D.wsUrl,browserDebuggingUrl:D.debuggingUrl,chromeLogPath:D.logPath,attached:!!u,tabId:0,tabUrl:"",targetId:"",width:s,height:c,cliScreens:[],captureDir:null,cliListenerPid:X,cliListenerLogPath:null,cliListenerReadyAt:null}).finally(()=>{process.exit(130)})};process.on("SIGINT",Mt),process.on("SIGTERM",Mt),ye=!0;let j=()=>{ye&&(process.removeListener("SIGINT",Mt),process.removeListener("SIGTERM",Mt),ye=!1)};try{await W.send("Target.setDiscoverTargets",{discover:!0}).catch(()=>{});let G=await Np(W,a,s,c,d);await W.send("Target.activateTarget",{targetId:G.targetId}).catch(()=>{});let ue=pp();await Zp(W,G.sessionId);let I=qp(ue),ae={id:ue,runtime:"cli",createdAt:new Date().toISOString(),url:a,name:i,chromePid:D.pid,profileDir:D.profileDir,keepProfile:u?!0:L!=null||e["keep-profile"]===!0,browserWsUrl:D.wsUrl,browserDebuggingUrl:D.debuggingUrl,chromeLogPath:D.logPath,attached:!!u,tabId:0,tabUrl:a,targetId:G.targetId,width:s,height:c,cliScreens:[],cliCaptureKind:h,cliRecordVideo:k,cliBlockVideos:h==="html"?C:!1,cliCompressImages:h==="image"?$:!1,cliSubsetFonts:h==="image"?N:!1,autoApplyZoom:f,captureDir:I,cliListenerPid:null,cliListenerLogPath:null,cliListenerReadyAt:null};await Nt(I,{recursive:!0}),await eh(ae);let Be=await Kp(ae.id,I);X=Be.pid,await Xp(ae.id,{cliListenerPid:Be.pid,cliListenerLogPath:Be.logPath});let v=await Yp(ae.id,5e3);if(!v.cliListenerReadyAt){let ft="";try{ft=(await Ee(Be.logPath,"utf8")).split(`
|
|
5416
|
+
`).filter(Boolean).slice(-12).join(`
|
|
5417
|
+
`)}catch{}throw new Error(`capture recorder failed to arm within 5s (listenerReadyAt is null). Every click would be silently dropped, so this session is unusable. Listener log (${Be.logPath}):
|
|
5418
|
+
${ft||"(empty)"}`)}return await H("inkly_cli_capture_session_started",{runtime:"cli",capture_kind:v.cliCaptureKind??h,record_video:v.cliRecordVideo===!0,auto_apply_zoom:v.autoApplyZoom!==!1,window_width:v.width,window_height:v.height,headless:u?null:E,attached:v.attached,persistent_profile:L!=null,profile_reused:z,connect_to_browser:!!u}),j(),He({ok:!0,mode:"cli",session:{id:v.id,stateFile:Un(v.id),createdAt:v.createdAt},browser:{pid:v.chromePid,debuggingUrl:v.browserDebuggingUrl,webSocketDebuggerUrl:v.browserWsUrl,headless:u?null:E,attached:v.attached,profile:L?{dir:L,persistent:!0,reused:z}:null},tab:{targetId:v.targetId,url:v.tabUrl},capture:{kind:v.cliCaptureKind??"image",video:v.cliRecordVideo===!0,recordVideo:v.cliRecordVideo===!0,autoApplyZoom:v.autoApplyZoom!==!1,window:{width:v.width,height:v.height},stepCount:0,automatic:!0,listenerPid:v.cliListenerPid??Be.pid,listenerReadyAt:v.cliListenerReadyAt}}),0}catch(G){throw await tn({id:"",runtime:"cli",createdAt:"",url:a,name:i,chromePid:D.pid,profileDir:D.profileDir,keepProfile:L!=null||!!u,browserWsUrl:D.wsUrl,browserDebuggingUrl:D.debuggingUrl,chromeLogPath:D.logPath,attached:!!u,tabId:0,tabUrl:"",targetId:"",width:s,height:c,cliScreens:[],captureDir:null,cliListenerPid:X,cliListenerLogPath:null,cliListenerReadyAt:null}),G}finally{j(),W.close()}}async function rh(t,e){let n=gp(new Uint8Array(t)),r=Ln(e);await Nt(r,{recursive:!0});for(let[a,i]of Object.entries(n)){let o=a.replace(/\\/g,"/");if(!o||o.endsWith("/"))continue;let s=Ln(r,o);if(s!==r&&!s.startsWith(r+mp))throw new Error(`Unsafe zip entry: ${a}`);await Nt(Mn(s),{recursive:!0}),await ro(s,Buffer.from(i))}}async function ah(t,e,n){let r=mt(e,"session",n),a=mt(e,"out",n),i=Wr(t,a),o=await zt(r),s=await qr(r),c=zn(o.cliScreens??[],s);if(c.length===0)return await tn(o),o.captureDir&&await Fe(o.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Ur(o.id),await Fr(o.id),await H("inkly_cli_capture_session_stopped",{runtime:"cli",capture_kind:o.cliCaptureKind??"image",step_count:0,output_bytes:0,unpacked:!1,record_video:o.cliRecordVideo===!0,auto_apply_zoom:o.autoApplyZoom!==!1}),He({ok:!1,mode:"cli",session:{id:o.id},error:"No steps captured \u2014 nothing to export. Each step comes from a click driven over CDP; the initial page load is not a step. The session has been cleaned up, so no `cancel` is needed.",output:{zipPath:null,demoDir:null,bytes:0,stepCount:0}}),1;let u=o.cliCaptureKind==="html"?await Jp({name:o.name,screens:c}):await Wp({name:o.name,screens:c,autoApplyZoom:o.autoApplyZoom!==!1,compressImages:o.cliCompressImages===!0,subsetFonts:o.cliSubsetFonts===!0});await Nt(i,{recursive:!0});let p=Buffer.from(u.bytes),h=B(i,u.filename);await ro(h,p);let f=null;return e["no-unpack"]!==!0&&(await rh(p,i),f=B(i,u.slug)),await tn(o),o.captureDir&&await Fe(o.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Ur(o.id),await Fr(o.id),await H("inkly_cli_capture_session_stopped",{runtime:"cli",capture_kind:o.cliCaptureKind??"image",step_count:u.stepCount,output_bytes:p.byteLength,unpacked:e["no-unpack"]!==!0,record_video:o.cliRecordVideo===!0,auto_apply_zoom:o.autoApplyZoom!==!1}),He({ok:!0,mode:"cli",session:{id:o.id},output:{zipPath:h,demoDir:f,bytes:p.byteLength,stepCount:u.stepCount,stepLabels:u.labels}}),0}async function ih(t,e){let n=mt(t,"session",e),r=await zt(n);return await tn(r),r.captureDir&&await Fe(r.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Ur(r.id),await Fr(r.id),await H("inkly_cli_capture_session_cancelled",{runtime:"cli",capture_kind:r.cliCaptureKind??"image",step_count:r.cliScreens?.length??0,record_video:r.cliRecordVideo===!0,auto_apply_zoom:r.autoApplyZoom!==!1}),He({ok:!0,mode:"cli",session:{id:r.id}}),0}function uo(t){return t.pngPath||t.videoPath||t.htmlPath||t.posterPngPath||`t:${t.capturedAt??""}`}function Gr(t){return B(Jr(),`${t}.undo.json`)}async function qr(t){try{let e=JSON.parse(await Ee(Gr(t),"utf8"));return Array.isArray(e.droppedKeys)?e.droppedKeys.filter(n=>typeof n=="string"):[]}catch{return[]}}function zn(t,e){if(e.length===0)return t;let n=new Set(e);return t.filter(r=>!n.has(uo(r)))}async function Fr(t){await Fe(Gr(t),{force:!0}).catch(()=>{})}function Hr(t,e){return t.click?.label||t.title||`Step ${e+1}`}async function oh(t,e){let n=mt(t,"session",e),r=await zt(n),a=await qr(n),i=zn(r.cliScreens??[],a);if(i.length===0)return He({ok:!1,mode:"cli",session:{id:r.id},error:"No recorded step to undo.",capture:{stepCount:0}}),1;let o=i[i.length-1],s=Hr(o,i.length-1);a.push(uo(o)),await Y(Gr(n),`${JSON.stringify({droppedKeys:a},null,2)}
|
|
5419
|
+
`);let c=zn(r.cliScreens??[],a);return He({ok:!0,mode:"cli",session:{id:r.id},capture:{undone:s,stepCount:c.length,stepLabels:c.map((d,u)=>Hr(d,u))}}),0}async function sh(t,e){let n=mt(t,"session",e),r=await zt(n),a=await qr(n),i=zn(r.cliScreens??[],a),o=i.map((c,d)=>Hr(c,d)),s=i.map((c,d)=>({index:d+1,label:o[d],url:c.sourceUrl||null,kind:c.kind??"image"}));return He({ok:!0,mode:"cli",session:{id:r.id},capture:{kind:r.cliCaptureKind??"image",ready:!!r.cliListenerReadyAt,browserAlive:r.attached?null:!!(r.chromePid&&co(r.chromePid)),listenerReadyAt:r.cliListenerReadyAt??null,stepCount:i.length,stepLabels:o,lastLabel:o[o.length-1]??null,steps:s}}),0}async function Fn(t){let{cwd:e,subcommand:n,args:r,kind:a,usage:i}=t;switch(Ep(r),await H("inkly_cli_capture_command_invoked",{capture_kind:a,subcommand:n??"(none)"}),n){case"start":return nh(e,r,a,i);case"stop":return ah(e,r,i);case"cancel":return ih(r,i);case"status":return sh(r,i);case"undo":return oh(r,i);case"profiles":return lh();default:return process.stdout.write(i),1}}async function lh(){let t=so(),e=await no(t,{withFileTypes:!0}).catch(()=>[]),n=[];for(let r of e){if(!r.isDirectory())continue;let a=B(t,r.name),i=Pe(B(a,"Default")),o=Pe(B(a,"Default","Network","Cookies"))||Pe(B(a,"Default","Cookies"));n.push({name:r.name,dir:a,initialized:i,hasCookies:o})}return await H("inkly_cli_capture_profiles_listed",{profile_count:n.length,initialized_count:n.filter(r=>r.initialized).length,cookie_count:n.filter(r=>r.hasCookies).length}),He({ok:!0,profilesDir:t,profiles:n}),0}async function po(t){let{cwd:e,subcommand:n,args:r}=t;if(r.html===!0)throw new Error("inkly capture is image/video only. For HTML snapshot capture use `inkly capture-html`.");for(let a of["block-videos","block-video","compress-images","compress-image","subset-fonts","subset-font"])if(Object.prototype.hasOwnProperty.call(r,a))throw new Error(`--${a} only applies to HTML capture. Use \`inkly capture-html --${a}\`.`);return Fn({cwd:e,subcommand:n,args:r,kind:"image",usage:nn})}async function ho(t){let{cwd:e,subcommand:n,args:r}=t;return Fn({cwd:e,subcommand:n,args:r,kind:"html",usage:rn})}var fo=`inkly \u2014 Inkly CLI
|
|
5402
5420
|
|
|
5403
5421
|
Usage:
|
|
5404
5422
|
inkly init <name> [--layout <layout>] Scaffold a new demo hub.
|
|
@@ -5414,13 +5432,13 @@ Usage:
|
|
|
5414
5432
|
inkly login Connect to the hosted app.
|
|
5415
5433
|
inkly status [--json] Show auth and hub status.
|
|
5416
5434
|
inkly sync [--demo <slug>] [--dry-run] Upload local capture blobs to CDN.
|
|
5417
|
-
inkly
|
|
5435
|
+
inkly snapshot <demo> Publish a standalone snapshot of one demo.
|
|
5418
5436
|
inkly capture <command> Capture an image/video walkthrough for an agent.
|
|
5419
5437
|
inkly capture-html <command> Capture a self-contained HTML walkthrough.
|
|
5420
5438
|
inkly help [command] Show CLI help.
|
|
5421
5439
|
|
|
5422
5440
|
Run \`inkly <command> --help\` for more.
|
|
5423
|
-
`,
|
|
5441
|
+
`,Yr=`inkly init \u2014 scaffold a new demo hub
|
|
5424
5442
|
|
|
5425
5443
|
Usage:
|
|
5426
5444
|
inkly init <name> [--layout <layout>]
|
|
@@ -5431,7 +5449,7 @@ Arguments:
|
|
|
5431
5449
|
Options:
|
|
5432
5450
|
--layout <layout> Hub index layout to write to inkly.json.
|
|
5433
5451
|
One of: sidebar, tabs.
|
|
5434
|
-
`,
|
|
5452
|
+
`,go=`inkly add \u2014 scaffold a new demo in the current hub
|
|
5435
5453
|
|
|
5436
5454
|
Usage:
|
|
5437
5455
|
inkly add <name> [--collection <name>]
|
|
@@ -5445,7 +5463,7 @@ Options:
|
|
|
5445
5463
|
--collection <name> Add the demo to this collection in inkly.json.
|
|
5446
5464
|
Creates the collection if it doesn't exist. When
|
|
5447
5465
|
omitted, the demo is not added to any collection.
|
|
5448
|
-
`,
|
|
5466
|
+
`,bo=`inkly demo \u2014 alias of \`inkly add\`
|
|
5449
5467
|
|
|
5450
5468
|
Usage:
|
|
5451
5469
|
inkly demo <slug> [--collection <name>]
|
|
@@ -5457,7 +5475,7 @@ Options:
|
|
|
5457
5475
|
--collection <name> Add the demo to this collection in inkly.json.
|
|
5458
5476
|
Creates the collection if it doesn't exist. When
|
|
5459
5477
|
omitted, the demo is not added to any collection.
|
|
5460
|
-
`,
|
|
5478
|
+
`,yo=`inkly validate \u2014 validate a demo hub
|
|
5461
5479
|
|
|
5462
5480
|
Usage:
|
|
5463
5481
|
inkly validate [--json] [--strict]
|
|
@@ -5465,7 +5483,7 @@ Usage:
|
|
|
5465
5483
|
Options:
|
|
5466
5484
|
--json Print machine-readable JSON.
|
|
5467
5485
|
--strict Treat warnings as failures.
|
|
5468
|
-
`,
|
|
5486
|
+
`,xo=`inkly lock \u2014 pin the runtime via inkly.lock
|
|
5469
5487
|
|
|
5470
5488
|
Usage:
|
|
5471
5489
|
inkly lock [--json] [--local <path>]
|
|
@@ -5486,7 +5504,7 @@ Environment:
|
|
|
5486
5504
|
BUNDLES_R2_PUBLIC_BASE_URL
|
|
5487
5505
|
Override the bundles bucket's public base URL
|
|
5488
5506
|
(default https://www.runtime.inklyai.dev). Useful for staging.
|
|
5489
|
-
`,
|
|
5507
|
+
`,ko=`inkly login \u2014 connect to the hosted app
|
|
5490
5508
|
|
|
5491
5509
|
Usage:
|
|
5492
5510
|
inkly login [--no-open]
|
|
@@ -5498,11 +5516,11 @@ overridden on the command line.
|
|
|
5498
5516
|
Options:
|
|
5499
5517
|
--no-open Print the grant URL without opening a browser.
|
|
5500
5518
|
--token <token> Automation fallback: save an existing API token.
|
|
5501
|
-
`,
|
|
5519
|
+
`,wo=`inkly logout \u2014 remove saved platform API credentials
|
|
5502
5520
|
|
|
5503
5521
|
Usage:
|
|
5504
5522
|
inkly logout
|
|
5505
|
-
`,
|
|
5523
|
+
`,vo=`inkly sync \u2014 upload local capture blobs to CDN
|
|
5506
5524
|
|
|
5507
5525
|
Usage:
|
|
5508
5526
|
inkly sync [--demo <slug>] [--dry-run] [--json]
|
|
@@ -5511,14 +5529,15 @@ Options:
|
|
|
5511
5529
|
--demo <slug> Sync one demo instead of every demo.
|
|
5512
5530
|
--dry-run Report pending uploads without changing files.
|
|
5513
5531
|
--json Print machine-readable JSON.
|
|
5514
|
-
`,
|
|
5532
|
+
`,So=`inkly snapshot \u2014 publish a standalone snapshot of one demo
|
|
5515
5533
|
|
|
5516
5534
|
Usage:
|
|
5517
|
-
inkly
|
|
5535
|
+
inkly snapshot <demo-path> [--json]
|
|
5518
5536
|
|
|
5519
5537
|
Freezes one local demo and hosts it at a standalone /p/<id> URL, separate
|
|
5520
5538
|
from the demo hub. Missing binary assets are uploaded to the CDN for the
|
|
5521
|
-
|
|
5539
|
+
snapshot without changing local files. (For a LOCAL preview without
|
|
5540
|
+
publishing, use \`inkly dev\` instead.)
|
|
5522
5541
|
|
|
5523
5542
|
Arguments:
|
|
5524
5543
|
<demo-path> Path to the demo folder (e.g. demos/intro). Omit when the
|
|
@@ -5527,41 +5546,49 @@ Arguments:
|
|
|
5527
5546
|
Options:
|
|
5528
5547
|
--demo <slug> Select the demo by slug instead of by path.
|
|
5529
5548
|
--json Print machine-readable JSON.
|
|
5530
|
-
`,
|
|
5549
|
+
`,_o=`inkly dev \u2014 start the local preview server
|
|
5531
5550
|
|
|
5532
5551
|
Usage:
|
|
5533
|
-
inkly dev [--port <n>]
|
|
5552
|
+
inkly dev [<path>] [--port <n>]
|
|
5553
|
+
|
|
5554
|
+
Arguments:
|
|
5555
|
+
<path> A hub root (a directory containing inkly.json) or a bare
|
|
5556
|
+
exported demo folder (a directory containing demo.config.json).
|
|
5557
|
+
Defaults to the current directory. When given a demo folder,
|
|
5558
|
+
dev wraps it in a throwaway hub so a fresh \`capture stop\`
|
|
5559
|
+
export previews with no manual hub assembly. dev needs a hub;
|
|
5560
|
+
each demo is served at /<slug>.
|
|
5534
5561
|
|
|
5535
5562
|
Options:
|
|
5536
5563
|
--port <n> Preferred port. Defaults to 3000; if taken, the CLI
|
|
5537
5564
|
tries the next available port. Must be 1-65535.
|
|
5538
|
-
`,
|
|
5565
|
+
`,Co=`inkly update \u2014 update the globally installed CLI
|
|
5539
5566
|
|
|
5540
5567
|
Usage:
|
|
5541
5568
|
inkly update [--dry-run]
|
|
5542
5569
|
|
|
5543
5570
|
Options:
|
|
5544
5571
|
--dry-run Print the update command without running it.
|
|
5545
|
-
`,
|
|
5572
|
+
`,To=`inkly doctor \u2014 run local diagnostics
|
|
5546
5573
|
|
|
5547
5574
|
Usage:
|
|
5548
5575
|
inkly doctor [--json]
|
|
5549
5576
|
|
|
5550
5577
|
Options:
|
|
5551
5578
|
--json Print machine-readable JSON.
|
|
5552
|
-
`,
|
|
5579
|
+
`,Ao=`inkly status \u2014 show local CLI status
|
|
5553
5580
|
|
|
5554
5581
|
Usage:
|
|
5555
5582
|
inkly status [--json]
|
|
5556
5583
|
|
|
5557
5584
|
Options:
|
|
5558
5585
|
--json Print machine-readable JSON.
|
|
5559
|
-
`,
|
|
5586
|
+
`,Io=`inkly version \u2014 print the CLI version
|
|
5560
5587
|
|
|
5561
5588
|
Usage:
|
|
5562
5589
|
inkly version
|
|
5563
5590
|
inkly --version
|
|
5564
|
-
`,
|
|
5591
|
+
`,Xr=`inkly help \u2014 show command help
|
|
5565
5592
|
|
|
5566
5593
|
Usage:
|
|
5567
5594
|
inkly help [command]
|
|
@@ -5581,28 +5608,29 @@ Commands:
|
|
|
5581
5608
|
logout Remove saved platform API credentials.
|
|
5582
5609
|
status Show auth and hub status.
|
|
5583
5610
|
sync Upload local capture blobs to CDN.
|
|
5611
|
+
snapshot Publish a standalone snapshot of one demo.
|
|
5584
5612
|
capture Capture an image/video walkthrough for an agent.
|
|
5585
5613
|
capture-html
|
|
5586
5614
|
Capture a self-contained HTML walkthrough for an agent.
|
|
5587
|
-
`,
|
|
5588
|
-
|
|
5589
|
-
${
|
|
5590
|
-
|
|
5591
|
-
`+
|
|
5592
|
-
`),await
|
|
5593
|
-
|
|
5594
|
-
`+i),1;let s=typeof e.collection=="string"&&e.collection.length>0?e.collection:void 0;try{return await
|
|
5595
|
-
`),await
|
|
5596
|
-
`),await
|
|
5597
|
-
`),await
|
|
5598
|
-
`),await
|
|
5599
|
-
`),await
|
|
5600
|
-
`),await
|
|
5601
|
-
`),await
|
|
5602
|
-
`),await
|
|
5603
|
-
`),1;try{let s=await
|
|
5604
|
-
`),
|
|
5605
|
-
`),await
|
|
5606
|
-
|
|
5607
|
-
${
|
|
5608
|
-
`),await
|
|
5615
|
+
`,hh={add:go,demo:bo,dev:_o,doctor:To,capture:nn,"capture-html":rn,help:Xr,init:Yr,lock:xo,login:ko,logout:wo,snapshot:So,status:Ao,sync:vo,update:Co,validate:yo,version:Io};function mh(t,e){let n=uh(t)?t:ph(e,t);if(Kr(n))try{if(ch(n).isFile())return n;let a=mo(n,"manifest.json");if(Kr(a))return a;let i=mo(n,"dist","manifest.json");if(Kr(i))return i}catch{}return n}function an(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))return;let n=t[e];return typeof n=="string"?n:""}function fh(t){let e=new Set(["_","api-base","token","url","name","out","session"]);return Object.keys(t).filter(n=>!e.has(n)).filter(n=>t[n]!==!1&&t[n]!==void 0).sort()}async function gh(t){let e=dh(t,{alias:{h:"help",p:"port",v:"version"},boolean:["auto-apply-zoom","block-videos","check","compress-images","dry-run","headed","headless","html","help","json","keep-profile","no-open","no-unpack","record-video","strict","subset-fonts","version","video","zoom"],string:["browser","collection","connect-to-browser","demo","height","layout","local","name","out","port","profile","runtime","session","timeout","token","url","width","window-size"]}),[n,...r]=e._,a=n??(e.version?"version":e.help?"help":"(none)");if(await H("inkly_cli_invoked",{command:a,subcommand:typeof r[0]=="string"?r[0]:void 0,option_keys:fh(e),json:!!e.json,help:!!e.help}),e.version&&!n)return await xr(),0;if(!n||e.help&&!n)return process.stdout.write(fo),e.help?0:1;switch(n){case"help":{let i=r[0];if(!i)return process.stdout.write(Xr),0;let o=hh[i];return o?(process.stdout.write(o),0):(process.stderr.write(`inkly help: unknown command "${i}"
|
|
5616
|
+
|
|
5617
|
+
${Xr}`),1)}case"init":{if(e.help)return process.stdout.write(Yr),0;let i=r[0];if(!i)return process.stderr.write(`inkly init: missing <name> argument
|
|
5618
|
+
|
|
5619
|
+
`+Yr),1;let o=an(e,"layout");try{return await ei({name:i,cwd:process.cwd(),layout:o}),0}catch(s){return process.stderr.write(`inkly init failed: ${s.message}
|
|
5620
|
+
`),await H("inkly_cli_failed",{command:"init"}),await re("init",s),1}}case"add":case"demo":{let i=n==="add"?go:bo;if(e.help)return process.stdout.write(i),0;let o=r[0];if(!o)return process.stderr.write(`inkly ${n}: missing <name> argument
|
|
5621
|
+
|
|
5622
|
+
`+i),1;let s=typeof e.collection=="string"&&e.collection.length>0?e.collection:void 0;try{return await mi({slug:o,cwd:process.cwd(),collection:s}),0}catch(c){return process.stderr.write(`inkly ${n} failed: ${c.message}
|
|
5623
|
+
`),await H("inkly_cli_failed",{command:n}),await re(n,c),1}}case"validate":return e.help?(process.stdout.write(yo),0):(await Pn({cwd:process.cwd(),json:!!e.json,strict:!!e.strict})).ok?0:1;case"lock":{if(e.help)return process.stdout.write(xo),0;try{let i=an(e,"local");return(await Sn({cwd:process.cwd(),check:!!e.check,json:!!e.json,manifestPath:i?mh(i,process.cwd()):void 0})).ok?0:1}catch(i){return process.stderr.write(`inkly lock failed: ${i.message}
|
|
5624
|
+
`),await H("inkly_cli_failed",{command:"lock"}),await re("lock",i),1}}case"version":return e.help?(process.stdout.write(Io),0):(await xr(),0);case"update":{if(e.help)return process.stdout.write(Co),0;try{return await gi({dryRun:!!e["dry-run"]}),0}catch(i){return process.stderr.write(`inkly update failed: ${i.message}
|
|
5625
|
+
`),await H("inkly_cli_failed",{command:"update"}),await re("update",i),1}}case"doctor":return e.help?(process.stdout.write(To),0):(await ki({cwd:process.cwd(),json:!!e.json})).ok?0:1;case"login":{if(e.help)return process.stdout.write(ko),0;try{return await Ti({cwd:process.cwd(),local:process.env.INKLY_LOCAL==="1",token:an(e,"token"),open:!e["no-open"]}),0}catch(i){return process.stderr.write(`inkly login failed: ${i.message}
|
|
5626
|
+
`),await H("inkly_cli_failed",{command:"login"}),await re("login",i),1}}case"logout":return e.help?(process.stdout.write(wo),0):(await Ai(),0);case"status":return e.help?(process.stdout.write(Ao),0):(await Ii({cwd:process.cwd(),json:!!e.json})).loggedIn?0:1;case"sync":{if(e.help)return process.stdout.write(vo),0;try{return await jn({cwd:process.cwd(),demo:an(e,"demo"),dryRun:!!e["dry-run"],json:!!e.json}),0}catch(i){return process.stderr.write(`inkly sync failed: ${i.message}
|
|
5627
|
+
`),await H("inkly_cli_failed",{command:"sync"}),await re("sync",i),1}}case"snapshot":{if(e.help)return process.stdout.write(So),0;try{return await zi({cwd:process.cwd(),path:r[0],demo:an(e,"demo"),json:!!e.json}),0}catch(i){return process.stderr.write(`inkly snapshot failed: ${i.message}
|
|
5628
|
+
`),await H("inkly_cli_failed",{command:"snapshot"}),await re("snapshot",i),1}}case"capture":{if(e.help)return process.stdout.write(nn),0;try{return await po({cwd:process.cwd(),subcommand:r[0],args:e})}catch(i){return process.stderr.write(`inkly capture failed: ${i.message}
|
|
5629
|
+
`),await H("inkly_cli_failed",{command:"capture",subcommand:r[0]}),await re("capture",i),1}}case"capture-html":{if(e.help)return process.stdout.write(rn),0;try{return await ho({cwd:process.cwd(),subcommand:r[0],args:e})}catch(i){return process.stderr.write(`inkly capture-html failed: ${i.message}
|
|
5630
|
+
`),await H("inkly_cli_failed",{command:"capture-html",subcommand:r[0]}),await re("capture-html",i),1}}case"dev":{if(e.help)return process.stdout.write(_o),0;let i=e.port,o=typeof i=="number"?i:typeof i=="string"?Number(i):3e3;if(!Number.isInteger(o)||o<1||o>65535)return process.stderr.write(`inkly dev: invalid --port value; expected an integer from 1 to 65535
|
|
5631
|
+
`),1;try{let s=await ui({cwd:process.cwd(),port:o,path:r[0]});return await new Promise(c=>{let d=()=>{s.close().catch(u=>{process.stderr.write(`inkly dev: error during shutdown: ${u.message}
|
|
5632
|
+
`),H("inkly_cli_failed",{command:"dev.shutdown"}),re("dev.shutdown",u)}).finally(()=>c())};process.once("SIGINT",d),process.once("SIGTERM",d)}),0}catch(s){return process.stderr.write(`inkly dev failed: ${s.message}
|
|
5633
|
+
`),await H("inkly_cli_failed",{command:"dev"}),await re("dev",s),1}}default:return process.stderr.write(`inkly: unknown command "${n}"
|
|
5634
|
+
|
|
5635
|
+
${fo}`),1}}Mi();gh(process.argv.slice(2)).then(async t=>{await H("inkly_cli_exited",{command:process.argv[2]??"(none)",exit_code:t}),await Tr(),await Ui(),process.exit(t)},async t=>{process.stderr.write(`inkly: ${t.message}
|
|
5636
|
+
`),await H("inkly_cli_failed",{command:"main"}),await re("main",t),await Tr(),process.exit(1)});
|