@inkly-org/cli 0.6.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capture-listener.js +33 -21
- package/dist/cli.js +378 -233
- package/dist/skills/inkly/SKILL.md +133 -0
- package/package.json +4 -1
- package/skills/inkly/SKILL.md +133 -0
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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
|
-
${
|
|
4
|
-
</style>`,u=/<\/head\s*>/i.test(
|
|
2
|
+
var Wo=Object.defineProperty;var Vo=(e,t)=>{for(var n in t)Wo(e,n,{get:t[n],enumerable:!0})};import qh from"mri";import{existsSync as li,statSync as Zh}from"fs";import{isAbsolute as Gh,join as Io,resolve as Kh}from"path";import{Buffer as Vc}from"buffer";import{mkdir as la,writeFile as Jc,access as qc}from"fs/promises";import{dirname as Zc,join as Gc,resolve as Kc,sep as ca}from"path";var l={};Vo(l,{BRAND:()=>bs,DIRTY:()=>Xe,EMPTY_PATH:()=>Go,INVALID:()=>v,NEVER:()=>tl,OK:()=>Y,ParseStatus:()=>Z,Schema:()=>T,ZodAny:()=>Fe,ZodArray:()=>Ee,ZodBigInt:()=>et,ZodBoolean:()=>tt,ZodBranded:()=>Kt,ZodCatch:()=>pt,ZodDate:()=>nt,ZodDefault:()=>ut,ZodDiscriminatedUnion:()=>bn,ZodEffects:()=>ue,ZodEnum:()=>ct,ZodError:()=>re,ZodFirstPartyTypeKind:()=>S,ZodFunction:()=>xn,ZodIntersection:()=>ot,ZodIssueCode:()=>m,ZodLazy:()=>st,ZodLiteral:()=>lt,ZodMap:()=>It,ZodNaN:()=>Et,ZodNativeEnum:()=>dt,ZodNever:()=>he,ZodNull:()=>it,ZodNullable:()=>ke,ZodNumber:()=>Qe,ZodObject:()=>ie,ZodOptional:()=>ce,ZodParsedType:()=>y,ZodPipeline:()=>Yt,ZodPromise:()=>He,ZodReadonly:()=>ht,ZodRecord:()=>yn,ZodSchema:()=>T,ZodSet:()=>Pt,ZodString:()=>ze,ZodSymbol:()=>Tt,ZodTransformer:()=>ue,ZodTuple:()=>xe,ZodType:()=>T,ZodUndefined:()=>rt,ZodUnion:()=>at,ZodUnknown:()=>Pe,ZodVoid:()=>At,addIssueToContext:()=>g,any:()=>Ts,array:()=>Es,bigint:()=>ws,boolean:()=>wi,coerce:()=>el,custom:()=>yi,date:()=>vs,datetimeRegex:()=>gi,defaultErrorMap:()=>Ae,discriminatedUnion:()=>Ns,effect:()=>Js,enum:()=>Bs,function:()=>zs,getErrorMap:()=>St,getParsedType:()=>ye,instanceof:()=>xs,intersection:()=>Ms,isAborted:()=>fn,isAsync:()=>_t,isDirty:()=>gn,isValid:()=>Ue,late:()=>ys,lazy:()=>Fs,literal:()=>Hs,makeIssue:()=>Gt,map:()=>js,nan:()=>ks,nativeEnum:()=>Ws,never:()=>Is,null:()=>Cs,nullable:()=>Zs,number:()=>ki,object:()=>Rs,objectUtil:()=>er,oboolean:()=>Qs,onumber:()=>Xs,optional:()=>qs,ostring:()=>Ys,pipeline:()=>Ks,preprocess:()=>Gs,promise:()=>Vs,quotelessJson:()=>Jo,record:()=>Os,set:()=>Us,setErrorMap:()=>Zo,strictObject:()=>$s,string:()=>xi,symbol:()=>Ss,transformer:()=>Js,tuple:()=>Ls,undefined:()=>_s,union:()=>Ds,unknown:()=>As,util:()=>I,void:()=>Ps});var I;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{let a={};for(let o of i)a[o]=o;return a},e.getValidEnumValues=i=>{let a=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(let s of a)o[s]=i[s];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},e.find=(i,a)=>{for(let o of i)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=r,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(I||(I={}));var er;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(er||(er={}));var y=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ye=e=>{switch(typeof e){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(e)?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(e)?y.array:e===null?y.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?y.promise:typeof Map<"u"&&e instanceof Map?y.map:typeof Set<"u"&&e instanceof Set?y.set:typeof Date<"u"&&e instanceof Date?y.date:y.object;default:return y.unknown}};var m=I.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"]),Jo=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),re=class e extends Error{get errors(){return this.issues}constructor(t){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=t}format(t){let n=t||function(a){return a.message},r={_errors:[]},i=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let 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 i(this),r}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},r=[];for(let i of this.issues)if(i.path.length>0){let a=i.path[0];n[a]=n[a]||[],n[a].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};re.create=e=>new re(e);var qo=(e,t)=>{let n;switch(e.code){case m.invalid_type:e.received===y.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,I.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${I.joinValues(e.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${I.joinValues(e.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${I.joinValues(e.options)}, received '${e.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 e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:I.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case m.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case m.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.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 ${e.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=t.defaultError,I.assertNever(e)}return{message:n}},Ae=qo;var ui=Ae;function Zo(e){ui=e}function St(){return ui}var Gt=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="",c=r.filter(d=>!!d).slice().reverse();for(let d of c)s=d(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},Go=[];function g(e,t){let n=St(),r=Gt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ae?void 0:Ae].filter(i=>!!i)});e.common.issues.push(r)}var Z=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let r=[];for(let i of n){if(i.status==="aborted")return v;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){let r=[];for(let i of n){let a=await i.key,o=await i.value;r.push({key:a,value:o})}return e.mergeObjectSync(t,r)}static mergeObjectSync(t,n){let r={};for(let i of n){let{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return v;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[a.value]=o.value)}return{status:t.value,value:r}}},v=Object.freeze({status:"aborted"}),Xe=e=>({status:"dirty",value:e}),Y=e=>({status:"valid",value:e}),fn=e=>e.status==="aborted",gn=e=>e.status==="dirty",Ue=e=>e.status==="valid",_t=e=>typeof Promise<"u"&&e instanceof Promise;var k;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(k||(k={}));var de=class{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},pi=(e,t)=>{if(Ue(t))return{success:!0,data:t.value};if(!e.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 re(e.common.issues);return this._error=n,this._error}}};function C(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,s)=>{let{message:c}=e;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:i}}var T=class{get description(){return this._def.description}_getType(t){return ye(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ye(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Z,ctx:{common:t.parent.common,data:t.data,parsedType:ye(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(_t(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ye(t)},i=this._parseSync({data:t,path:r.path,parent:r});return pi(r,i)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ye(t)};if(!this["~standard"].async)try{let r=this._parseSync({data:t,path:[],parent:n});return Ue(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:t,path:[],parent:n}).then(r=>Ue(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(t,n){let r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ye(t)},i=this._parse({data:t,path:r.path,parent:r}),a=await(_t(i)?i:Promise.resolve(i));return pi(r,a)}refine(t,n){let r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,a)=>{let o=t(i),s=()=>a.addIssue({code:m.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new ue({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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 ce.create(this,this._def)}nullable(){return ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ee.create(this)}promise(){return He.create(this,this._def)}or(t){return at.create([this,t],this._def)}and(t){return ot.create(this,t,this._def)}transform(t){return new ue({...C(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new ut({...C(this._def),innerType:this,defaultValue:n,typeName:S.ZodDefault})}brand(){return new Kt({typeName:S.ZodBranded,type:this,...C(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new pt({...C(this._def),innerType:this,catchValue:n,typeName:S.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Yt.create(this,t)}readonly(){return ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ko=/^c[^\s-]{8,}$/i,Yo=/^[0-9a-z]+$/,Xo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Qo=/^[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,es=/^[a-z0-9_-]{21}$/i,ts=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ns=/^[-+]?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)?)??$/,rs=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,is="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tr,as=/^(?:(?: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])$/,os=/^(?:(?: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])$/,ss=/^(([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]))$/,ls=/^(([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])$/,cs=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ds=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mi="((\\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])))",us=new RegExp(`^${mi}$`);function fi(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function ps(e){return new RegExp(`^${fi(e)}$`)}function gi(e){let t=`${mi}T${fi(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function hs(e,t){return!!((t==="v4"||!t)&&as.test(e)||(t==="v6"||!t)&&ss.test(e))}function ms(e,t){if(!ts.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function fs(e,t){return!!((t==="v4"||!t)&&os.test(e)||(t==="v6"||!t)&&ls.test(e))}var ze=class e extends T{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==y.string){let a=this._getOrReturnCtx(t);return g(a,{code:m.invalid_type,expected:y.string,received:a.parsedType}),v}let r=new Z,i;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),g(i,{code:m.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),g(i,{code:m.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){let o=t.data.length>a.value,s=t.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(t,i),o?g(i,{code:m.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&g(i,{code:m.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")rs.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"email",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")tr||(tr=new RegExp(is,"u")),tr.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"emoji",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Qo.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"uuid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")es.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"nanoid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Ko.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"cuid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Yo.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"cuid2",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Xo.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"ulid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),g(i,{validation:"url",code:m.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"regex",code:m.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?gi(a).test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?us.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?ps(a).test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?ns.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"duration",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?hs(t.data,a.version)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"ip",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?ms(t.data,a.alg)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"jwt",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?fs(t.data,a.version)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"cidr",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?cs.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"base64",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?ds.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"base64url",code:m.invalid_string,message:a.message}),r.dirty()):I.assertNever(a);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:m.invalid_string,...k.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...k.errToObj(t)})}url(t){return this._addCheck({kind:"url",...k.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...k.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...k.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...k.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...k.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...k.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...k.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...k.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...k.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...k.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...k.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...k.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...k.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...k.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...k.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...k.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...k.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...k.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...k.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...k.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...k.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...k.errToObj(n)})}nonempty(t){return this.min(1,k.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};ze.create=e=>new ze({checks:[],typeName:S.ZodString,coerce:e?.coerce??!1,...C(e)});function gs(e,t){let n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return a%o/10**i}var Qe=class e extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==y.number){let a=this._getOrReturnCtx(t);return g(a,{code:m.invalid_type,expected:y.number,received:a.parsedType}),v}let r,i=new Z;for(let a of this._def.checks)a.kind==="int"?I.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),g(r,{code:m.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?gs(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),g(r,{code:m.not_finite,message:a.message}),i.dirty()):I.assertNever(a);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,k.toString(n))}gt(t,n){return this.setLimit("min",t,!1,k.toString(n))}lte(t,n){return this.setLimit("max",t,!0,k.toString(n))}lt(t,n){return this.setLimit("max",t,!1,k.toString(n))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:k.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:k.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:k.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:k.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&I.isInteger(t.value))}get isFinite(){let t=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"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}};Qe.create=e=>new Qe({checks:[],typeName:S.ZodNumber,coerce:e?.coerce||!1,...C(e)});var et=class e extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==y.bigint)return this._getInvalidInput(t);let r,i=new Z;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):I.assertNever(a);return{status:i.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return g(n,{code:m.invalid_type,expected:y.bigint,received:n.parsedType}),v}gte(t,n){return this.setLimit("min",t,!0,k.toString(n))}gt(t,n){return this.setLimit("min",t,!1,k.toString(n))}lte(t,n){return this.setLimit("max",t,!0,k.toString(n))}lt(t,n){return this.setLimit("max",t,!1,k.toString(n))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:k.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:k.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};et.create=e=>new et({checks:[],typeName:S.ZodBigInt,coerce:e?.coerce??!1,...C(e)});var tt=class extends T{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==y.boolean){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.boolean,received:r.parsedType}),v}return Y(t.data)}};tt.create=e=>new tt({typeName:S.ZodBoolean,coerce:e?.coerce||!1,...C(e)});var nt=class e extends T{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==y.date){let a=this._getOrReturnCtx(t);return g(a,{code:m.invalid_type,expected:y.date,received:a.parsedType}),v}if(Number.isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return g(a,{code:m.invalid_date}),v}let r=new Z,i;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),g(i,{code:m.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),g(i,{code:m.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):I.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:k.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:k.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};nt.create=e=>new nt({checks:[],coerce:e?.coerce||!1,typeName:S.ZodDate,...C(e)});var Tt=class extends T{_parse(t){if(this._getType(t)!==y.symbol){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.symbol,received:r.parsedType}),v}return Y(t.data)}};Tt.create=e=>new Tt({typeName:S.ZodSymbol,...C(e)});var rt=class extends T{_parse(t){if(this._getType(t)!==y.undefined){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.undefined,received:r.parsedType}),v}return Y(t.data)}};rt.create=e=>new rt({typeName:S.ZodUndefined,...C(e)});var it=class extends T{_parse(t){if(this._getType(t)!==y.null){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.null,received:r.parsedType}),v}return Y(t.data)}};it.create=e=>new it({typeName:S.ZodNull,...C(e)});var Fe=class extends T{constructor(){super(...arguments),this._any=!0}_parse(t){return Y(t.data)}};Fe.create=e=>new Fe({typeName:S.ZodAny,...C(e)});var Pe=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Y(t.data)}};Pe.create=e=>new Pe({typeName:S.ZodUnknown,...C(e)});var he=class extends T{_parse(t){let n=this._getOrReturnCtx(t);return g(n,{code:m.invalid_type,expected:y.never,received:n.parsedType}),v}};he.create=e=>new he({typeName:S.ZodNever,...C(e)});var At=class extends T{_parse(t){if(this._getType(t)!==y.undefined){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.void,received:r.parsedType}),v}return Y(t.data)}};At.create=e=>new At({typeName:S.ZodVoid,...C(e)});var Ee=class e extends T{_parse(t){let{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==y.array)return g(n,{code:m.invalid_type,expected:y.array,received:n.parsedType}),v;if(i.exactLength!==null){let o=n.data.length>i.exactLength.value,s=n.data.length<i.exactLength.value;(o||s)&&(g(n,{code:o?m.too_big:m.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(g(n,{code:m.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(g(n,{code:m.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,s)=>i.type._parseAsync(new de(n,o,n.path,s)))).then(o=>Z.mergeArray(r,o));let a=[...n.data].map((o,s)=>i.type._parseSync(new de(n,o,n.path,s)));return Z.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:k.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:k.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:k.toString(n)}})}nonempty(t){return this.min(1,t)}};Ee.create=(e,t)=>new Ee({type:e,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...C(t)});function Ct(e){if(e instanceof ie){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=ce.create(Ct(r))}return new ie({...e._def,shape:()=>t})}else return e instanceof Ee?new Ee({...e._def,type:Ct(e.element)}):e instanceof ce?ce.create(Ct(e.unwrap())):e instanceof ke?ke.create(Ct(e.unwrap())):e instanceof xe?xe.create(e.items.map(t=>Ct(t))):e}var ie=class e extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=I.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==y.object){let d=this._getOrReturnCtx(t);return g(d,{code:m.invalid_type,expected:y.object,received:d.parsedType}),v}let{status:r,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof he&&this._def.unknownKeys==="strip"))for(let d in i.data)o.includes(d)||s.push(d);let c=[];for(let d of o){let u=a[d],p=i.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new de(i,p,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof he){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(d==="strict")s.length>0&&(g(i,{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=i.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new de(i,p,i.path,u)),alwaysSet:u in i.data})}}return i.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(t){return k.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{let i=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:k.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:S.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let r of I.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let r of I.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new e({...this._def,shape:()=>n})}deepPartial(){return Ct(this)}partial(t){let n={};for(let r of I.objectKeys(this.shape)){let i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let r of I.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof ce;)a=a._def.innerType;n[r]=a}return new e({...this._def,shape:()=>n})}keyof(){return bi(I.objectKeys(this.shape))}};ie.create=(e,t)=>new ie({shape:()=>e,unknownKeys:"strip",catchall:he.create(),typeName:S.ZodObject,...C(t)});ie.strictCreate=(e,t)=>new ie({shape:()=>e,unknownKeys:"strict",catchall:he.create(),typeName:S.ZodObject,...C(t)});ie.lazycreate=(e,t)=>new ie({shape:e,unknownKeys:"strip",catchall:he.create(),typeName:S.ZodObject,...C(t)});var at=class extends T{_parse(t){let{ctx:n}=this._processInputParams(t),r=this._def.options;function i(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new re(s.ctx.common.issues));return g(n,{code:m.invalid_union,unionErrors:o}),v}if(n.common.async)return Promise.all(r.map(async a=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let a,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"&&!a&&(a={result:u,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(c=>new re(c));return g(n,{code:m.invalid_union,unionErrors:s}),v}}get options(){return this._def.options}};at.create=(e,t)=>new at({options:e,typeName:S.ZodUnion,...C(t)});var Ie=e=>e instanceof st?Ie(e.schema):e instanceof ue?Ie(e.innerType()):e instanceof lt?[e.value]:e instanceof ct?e.options:e instanceof dt?I.objectValues(e.enum):e instanceof ut?Ie(e._def.innerType):e instanceof rt?[void 0]:e instanceof it?[null]:e instanceof ce?[void 0,...Ie(e.unwrap())]:e instanceof ke?[null,...Ie(e.unwrap())]:e instanceof Kt||e instanceof ht?Ie(e.unwrap()):e instanceof pt?Ie(e._def.innerType):[],bn=class e extends T{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==y.object)return g(n,{code:m.invalid_type,expected:y.object,received:n.parsedType}),v;let r=this.discriminator,i=n.data[r],a=this.optionsMap.get(i);return a?n.common.async?a._parseAsync({data:n.data,path:n.path,parent:n}):a._parseSync({data:n.data,path:n.path,parent:n}):(g(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(t,n,r){let i=new Map;for(let a of n){let o=Ie(a.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of o){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,a)}}return new e({typeName:S.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...C(r)})}};function nr(e,t){let n=ye(e),r=ye(t);if(e===t)return{valid:!0,data:e};if(n===y.object&&r===y.object){let i=I.objectKeys(t),a=I.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(let s of a){let c=nr(e[s],t[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(e.length!==t.length)return{valid:!1};let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=t[a],c=nr(o,s);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return n===y.date&&r===y.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var ot=class extends T{_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=(a,o)=>{if(fn(a)||fn(o))return v;let s=nr(a.value,o.value);return s.valid?((gn(a)||gn(o))&&n.dirty(),{status:n.value,value:s.data}):(g(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(([a,o])=>i(a,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ot.create=(e,t,n)=>new ot({left:e,right:t,typeName:S.ZodIntersection,...C(n)});var xe=class e extends T{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==y.array)return g(r,{code:m.invalid_type,expected:y.array,received:r.parsedType}),v;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"}),v;!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 a=[...r.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new de(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>Z.mergeArray(n,o)):Z.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};xe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xe({items:e,typeName:S.ZodTuple,rest:null,...C(t)})};var yn=class e extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==y.object)return g(r,{code:m.invalid_type,expected:y.object,received:r.parsedType}),v;let i=[],a=this._def.keyType,o=this._def.valueType;for(let s in r.data)i.push({key:a._parse(new de(r,s,r.path,s)),value:o._parse(new de(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?Z.mergeObjectAsync(n,i):Z.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof T?new e({keyType:t,valueType:n,typeName:S.ZodRecord,...C(r)}):new e({keyType:ze.create(),valueType:t,typeName:S.ZodRecord,...C(n)})}},It=class extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==y.map)return g(r,{code:m.invalid_type,expected:y.map,received:r.parsedType}),v;let i=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([s,c],d)=>({key:i._parse(new de(r,s,r.path,[d,"key"])),value:a._parse(new de(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}}}};It.create=(e,t,n)=>new It({valueType:t,keyType:e,typeName:S.ZodMap,...C(n)});var Pt=class e extends T{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==y.set)return g(r,{code:m.invalid_type,expected:y.set,received:r.parsedType}),v;let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(g(r,{code:m.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(g(r,{code:m.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let a=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)=>a._parse(new de(r,c,r.path,d)));return r.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(t,n){return new e({...this._def,minSize:{value:t,message:k.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:k.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};Pt.create=(e,t)=>new Pt({valueType:e,minSize:null,maxSize:null,typeName:S.ZodSet,...C(t)});var xn=class e extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==y.function)return g(n,{code:m.invalid_type,expected:y.function,received:n.parsedType}),v;function r(s,c){return Gt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,St(),Ae].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:c}})}function i(s,c){return Gt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,St(),Ae].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:c}})}let a={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof He){let s=this;return Y(async function(...c){let d=new re([]),u=await s._def.args.parseAsync(c,a).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,a).catch(f=>{throw d.addIssue(i(p,f)),d})})}else{let s=this;return Y(function(...c){let d=s._def.args.safeParse(c,a);if(!d.success)throw new re([r(c,d.error)]);let u=Reflect.apply(o,this,d.data),p=s._def.returns.safeParse(u,a);if(!p.success)throw new re([i(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:xe.create(t).rest(Pe.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new e({args:t||xe.create([]).rest(Pe.create()),returns:n||Pe.create(),typeName:S.ZodFunction,...C(r)})}},st=class extends T{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};st.create=(e,t)=>new st({getter:e,typeName:S.ZodLazy,...C(t)});var lt=class extends T{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return g(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:t.data}}get value(){return this._def.value}};lt.create=(e,t)=>new lt({value:e,typeName:S.ZodLiteral,...C(t)});function bi(e,t){return new ct({values:e,typeName:S.ZodEnum,...C(t)})}var ct=class e extends T{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),r=this._def.values;return g(n,{expected:I.joinValues(r),received:n.parsedType,code:m.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),r=this._def.values;return g(n,{received:n.data,code:m.invalid_enum_value,options:r}),v}return Y(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}};ct.create=bi;var dt=class extends T{_parse(t){let n=I.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==y.string&&r.parsedType!==y.number){let i=I.objectValues(n);return g(r,{expected:I.joinValues(i),received:r.parsedType,code:m.invalid_type}),v}if(this._cache||(this._cache=new Set(I.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=I.objectValues(n);return g(r,{received:r.data,code:m.invalid_enum_value,options:i}),v}return Y(t.data)}get enum(){return this._def.values}};dt.create=(e,t)=>new dt({values:e,typeName:S.ZodNativeEnum,...C(t)});var He=class extends T{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==y.promise&&n.common.async===!1)return g(n,{code:m.invalid_type,expected:y.promise,received:n.parsedType}),v;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return Y(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}};He.create=(e,t)=>new He({type:e,typeName:S.ZodPromise,...C(t)});var ue=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:o=>{g(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let o=i.transform(r.data,a);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"?Xe(c.value):n.value==="dirty"?Xe(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"?Xe(s.value):n.value==="dirty"?Xe(s.value):s}}if(i.type==="refinement"){let o=s=>{let c=i.refinement(s,a);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(i.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ue(o))return v;let s=i.transform(o.value,a);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=>Ue(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:n.value,value:s})):v);I.assertNever(i)}};ue.create=(e,t,n)=>new ue({schema:e,typeName:S.ZodEffects,effect:t,...C(n)});ue.createWithPreprocess=(e,t,n)=>new ue({schema:t,effect:{type:"preprocess",transform:e},typeName:S.ZodEffects,...C(n)});var ce=class extends T{_parse(t){return this._getType(t)===y.undefined?Y(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};ce.create=(e,t)=>new ce({innerType:e,typeName:S.ZodOptional,...C(t)});var ke=class extends T{_parse(t){return this._getType(t)===y.null?Y(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};ke.create=(e,t)=>new ke({innerType:e,typeName:S.ZodNullable,...C(t)});var ut=class extends T{_parse(t){let{ctx:n}=this._processInputParams(t),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}};ut.create=(e,t)=>new ut({innerType:e,typeName:S.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...C(t)});var pt=class extends T{_parse(t){let{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _t(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};pt.create=(e,t)=>new pt({innerType:e,typeName:S.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...C(t)});var Et=class extends T{_parse(t){if(this._getType(t)!==y.nan){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.nan,received:r.parsedType}),v}return{status:"valid",value:t.data}}};Et.create=e=>new Et({typeName:S.ZodNaN,...C(e)});var bs=Symbol("zod_brand"),Kt=class extends T{_parse(t){let{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Yt=class e extends T{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(n.dirty(),Xe(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new e({in:t,out:n,typeName:S.ZodPipeline})}},ht=class extends T{_parse(t){let n=this._def.innerType._parse(t),r=i=>(Ue(i)&&(i.value=Object.freeze(i.value)),i);return _t(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}};ht.create=(e,t)=>new ht({innerType:e,typeName:S.ZodReadonly,...C(t)});function hi(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function yi(e,t={},n){return e?Fe.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(o=>{if(!o){let s=hi(t,r),c=s.fatal??n??!0;i.addIssue({code:"custom",...s,fatal:c})}});if(!a){let o=hi(t,r),s=o.fatal??n??!0;i.addIssue({code:"custom",...o,fatal:s})}}):Fe.create()}var ys={object:ie.lazycreate},S;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(S||(S={}));var xs=(e,t={message:`Input not instance of ${e.name}`})=>yi(n=>n instanceof e,t),xi=ze.create,ki=Qe.create,ks=Et.create,ws=et.create,wi=tt.create,vs=nt.create,Ss=Tt.create,_s=rt.create,Cs=it.create,Ts=Fe.create,As=Pe.create,Is=he.create,Ps=At.create,Es=Ee.create,Rs=ie.create,$s=ie.strictCreate,Ds=at.create,Ns=bn.create,Ms=ot.create,Ls=xe.create,Os=yn.create,js=It.create,Us=Pt.create,zs=xn.create,Fs=st.create,Hs=lt.create,Bs=ct.create,Ws=dt.create,Vs=He.create,Js=ue.create,qs=ce.create,Zs=ke.create,Gs=ue.createWithPreprocess,Ks=Yt.create,Ys=()=>xi().optional(),Xs=()=>ki().optional(),Qs=()=>wi().optional(),el={string:(e=>ze.create({...e,coerce:!0})),number:(e=>Qe.create({...e,coerce:!0})),boolean:(e=>tt.create({...e,coerce:!0})),bigint:(e=>et.create({...e,coerce:!0})),date:(e=>nt.create({...e,coerce:!0}))};var tl=v;var rr=l.object({id:l.string()}),nl=l.enum(["top","right","bottom","left","auto"]).default("auto"),ir=l.enum(["left","middle","right"]),rl=ir.default("left"),vi=l.object({label:l.string().optional(),hidden:l.boolean().default(!1)}),il={background:l.string().optional(),textColor:l.string().optional(),borderRadius:l.string().optional(),textAlign:rl,anchor:nl,showNavigation:l.boolean().default(!0),prevButton:vi.optional(),nextButton:vi.optional()},al=l.enum(["pointer","callout","area"]),ol=l.discriminatedUnion("type",[l.object({type:l.literal("html-element"),alphaId:l.string().min(1)})]),sl=rr.extend({type:l.literal("message"),variant:al.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:ol.optional(),advancesStep:l.boolean().default(!0),...il}),ll=rr.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)}),cl=rr.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()}),Si=l.discriminatedUnion("type",[sl,ll,cl]),_i=new Set(["message","blur","text"]),Ci=l.object({type:l.string()}).passthrough();function Ti(e){return typeof e=="object"&&e!==null?e.type:void 0}var Ai=l.any().superRefine((e,t)=>{let i=(_i.has(Ti(e))?Si:Ci).safeParse(e);if(!i.success)for(let a of i.error.issues)t.addIssue(a)}).transform(e=>(_i.has(Ti(e))?Si:Ci).parse(e));var Ii=l.object({label:l.string().min(1),href:l.string().refine(e=>/^(https?:|mailto:)/i.test(e),"href must be an http(s) or mailto URL")}),ar=l.object({logo:l.string().min(1).optional(),name:l.string().min(1).optional(),logoHref:l.string().refine(e=>/^(https?:|mailto:)/i.test(e),"logoHref must be an http(s) or mailto URL").optional(),favicon:l.string().min(1).optional(),cta:Ii.optional(),secondaryCta:Ii.optional(),watermark:l.boolean().optional()}),Pi=ar.omit({favicon:!0});var dl=l.object({type:l.literal("next")}),ul=l.object({type:l.literal("prev")}),pl=l.object({type:l.literal("step"),stepId:l.string().min(1)}),hl=l.object({type:l.literal("chapter"),chapterId:l.string().min(1)}),ml=l.object({type:l.literal("url"),href:l.string().min(1),target:l.enum(["_self","_blank"]).default("_blank")}),fl=l.object({type:l.literal("restart")}),gl=l.discriminatedUnion("type",[dl,ul,pl,hl,ml,fl]),bl=l.enum(["shimmer"]),kn=l.object({label:l.string().min(1),action:gl.default({type:"next"}),animation:bl.optional(),background:l.string().optional(),textColor:l.string().optional()});var yl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",or=/^[A-Za-z0-9_-]{12}$/;function xl(e){let t=globalThis.crypto;if(!t||typeof t.getRandomValues!="function")throw new Error("generateDemoId requires globalThis.crypto.getRandomValues (Node 19+, browsers, or edge runtime).");t.getRandomValues(e)}function se(){let e=new Uint8Array(12);xl(e);let t="";for(let n of e)t+=yl.charAt(n&63);return t}function Ei(e){return typeof e=="string"&&or.test(e)}function Ri(e){return String(e+1).padStart(4,"0")}function $i(e){return`snap-${e.toString().padStart(3,"0")}`}function wn(e){let t=((e??"").toLowerCase().split(";")[0]??"").trim();return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("font/")||t.includes("font")||t.includes("woff")?"font":"other"}function sr(e){if(!e)return"";let t=e.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(t.split(/\r?\n/).map(r=>r.trim()).find(Boolean)??t).replace(/\s+/g," ").trim().slice(0,48)}function lr(e){let{stepId:t,assetId:n,posterAssetId:r,kind:i,isLast:a}=e,o=`asset:${n}`,s=i==="video"?{type:"video",src:o,posterSrc:r?`asset:${r}`:void 0,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight,alt:e.title,sourceUrl:e.sourceUrl??"",title:e.title,autoplay:!0,muted:!0,objectFit:"cover"}:{type:"image",src:o,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight,alt:e.title,sourceUrl:e.sourceUrl??"",title:e.title,objectFit:"cover"},c=e.click,d=[];if(c){let h=sr(c.label);d.push({id:`${t}_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:`${t}_callout`,type:"message",variant:"callout",x:.5,y:.5,text:a?"End of walkthrough":"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});let u=!!c&&!(c.x===0&&c.y===0),p=i==="image"&&e.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:t,kind:"content",background:s,...p?{transform:p}:{},annotations:d,advance:{trigger:"click"}}}function Di(e){let{stepId:t,htmlPath:n,click:r}=e,i=[];if(r?.alphaId)i.push({id:`${t}_area`,type:"message",variant:"area",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),w:0,h:0,text:sr(r.label)||"Click here",target:{type:"html-element",alphaId:r.alphaId},anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});else if(r){let a=sr(r.label);i.push({id:`${t}_pointer`,type:"message",variant:"pointer",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),text:a?`Click on "${a}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}return{id:t,kind:"content",background:{type:"html",path:n,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight,zoom:1,scroll:e.scroll,sourceUrl:e.sourceUrl??"",title:e.sourceUrl??""},annotations:i,advance:{trigger:"click"}}}function kl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cr(e,t){let n=e;for(let[r,i]of t){let a=kl(r);n=n.replace(new RegExp(`(?:\\.\\./)*assets/${a}`,"g"),i),n=n.replace(new RegExp(`assets/${a}`,"g"),i)}return n}function wl(e){return`<script data-inkly-replay-scroll>(()=>{const c=${JSON.stringify(e).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 Ni(e,t){let n=wl(t);return/<\/body\s*>/i.test(e)?e.replace(/<\/body\s*>/i,`${n}</body>`):`${e}${n}`}function Mi(e,t){if(!t||/data-inkly-document-css|document\.css/i.test(e))return e;let n='<link rel="stylesheet" href="./document.css?draft=1" data-inkly-document-css>';return/<\/head\s*>/i.test(e)?e.replace(/<\/head\s*>/i,`${n}</head>`):`${n}${e}`}var Li=l.object({id:l.string(),text:l.string(),start:l.number().nonnegative().optional(),end:l.number().nonnegative().optional()});var vl=l.enum(["screenshot","image","video","audio","font","other"]),Sl=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:vl,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()}),Rt=l.object({version:l.literal(1),assets:l.array(Sl),screens:l.array(l.unknown()).optional()});var dr=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.enum(["color","image","glassmorphism"]),Oi=l.object({type:_l,color:dr.optional(),from:dr.optional(),to:dr.optional(),src:l.string().min(1).optional(),alt:l.string().optional(),intensity:l.number().min(-5).max(48).optional()}).superRefine((e,t)=>{if(e.type==="color"){let n=!!e.color,r=!!e.from&&!!e.to;!n&&!r&&t.addIssue({code:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!e.from!=!!e.to&&t.addIssue({code:l.ZodIssueCode.custom,path:e.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}e.type==="image"&&!e.src&&t.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),ji=l.object({src:l.string(),alt:l.string().optional()});var ur=l.object({src:l.string().min(1),duration:l.number().positive().optional()});var Cl=l.enum(["text","dropdown"]),Tl=l.object({value:l.string().min(1),label:l.string().min(1)}),Al=l.object({id:l.string(),label:l.string(),type:Cl.default("text"),placeholder:l.string().optional(),required:l.boolean().default(!1),options:l.array(Tl).optional()}).superRefine((e,t)=>{e.type==="dropdown"&&(!e.options||e.options.length===0)&&t.addIssue({code:l.ZodIssueCode.custom,message:"Dropdown field requires at least one option.",path:["options"]})}),Bi=l.object({src:l.string().min(1),alt:l.string().optional(),height:l.number().int().positive().optional()}),Il=l.enum(["left","right","top"]),Pl=l.enum(["standard","hero"]),Wi=l.object({src:l.string().min(1),alt:l.string().optional(),naturalWidth:l.number().positive().optional(),naturalHeight:l.number().positive().optional(),position:Il.default("right"),layout:Pl.default("hero")}),El=l.object({type:l.literal("headline"),id:l.string(),logo:Bi.optional(),image:Wi.optional(),title:l.string(),titleColor:l.string().optional(),description:l.string().optional(),descriptionColor:l.string().optional(),textAlign:ir.optional(),cta:kn.optional(),secondaryCta:kn.optional()}),Rl=l.object({type:l.literal("form"),id:l.string(),logo:Bi.optional(),image:Wi.optional(),title:l.string().optional(),description:l.string().optional(),fields:l.array(Al).min(1),submit:kn.default({label:"Submit",action:{type:"next"}})}),$l="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",Dl="camera; microphone; fullscreen; payment; clipboard-write",Nl=l.object({type:l.literal("embed"),id:l.string(),src:l.string(),iframeTitle:l.string().optional(),sandbox:l.string().default($l),allow:l.string().default(Dl)}),Ml=l.object({type:l.literal("custom"),id:l.string(),name:l.string().min(1),data:l.record(l.unknown()).optional()}),Ui=l.discriminatedUnion("type",[El,Rl,Nl,Ml]),zi=new Set(["headline","form","embed","custom"]),Fi=l.object({type:l.string()}).passthrough();function Hi(e){return typeof e=="object"&&e!==null?e.type:void 0}var Vi=l.any().superRefine((e,t)=>{let i=(zi.has(Hi(e))?Ui:Fi).safeParse(e);if(!i.success)for(let a of i.error.issues)t.addIssue(a)}).transform(e=>(zi.has(Hi(e))?Ui:Fi).parse(e));var Ji=l.enum(["contain","cover","fill"]),qi=l.enum(["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"]),Ll=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:Ji.optional(),objectPosition:qi.optional()}),Ol=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:Ji.optional(),objectPosition:qi.optional()}),jl=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)}),Ul=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:jl.default({x:0,y:0,maxX:0,maxY:0}),sourceUrl:l.string().optional(),title:l.string().optional()}),zl=l.discriminatedUnion("type",[Ll,Ol,Ul]),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)}),Hl=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:zl,script:l.string().optional(),voiceover:ur.optional(),transform:Fl.optional(),advance:Hl,annotations:l.array(Ai).default([]),captions:l.array(Li).optional()}).passthrough(),Wl=l.object({kind:l.literal("cover"),id:l.string(),label:l.string().optional(),widgets:l.array(Vi).length(1),background:Oi.optional(),backgroundImage:ji.optional(),backgroundDim:l.number().min(0).max(1).optional(),script:l.string().optional(),voiceover:ur.optional(),duration:l.number().positive().optional(),advance:l.object({trigger:l.enum(["auto","click"]).default("click")}).default({trigger:"click"})}).passthrough(),Zi=l.discriminatedUnion("kind",[Bl,Wl]);var Vl=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,Gi=l.string().regex(Vl,"must be a hex color like #5b3df5"),vn=l.object({primary:Gi.optional(),secondary:Gi.optional(),font:l.string().min(1).optional(),radius:l.string().min(1).optional()}).partial();var Sn=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"}),Jl=l.object({id:l.string(),title:l.string(),stepIds:l.array(l.string()).min(1)}),ql=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)}),Zl=l.object({width:l.number().positive(),height:l.number().positive()}),Gl=l.enum(["public","private"]),Kl=l.enum(["none","color","image"]),Yl=l.object({type:Kl,color:Sn.optional(),from:Sn.optional(),to:Sn.optional(),src:l.string().min(1).optional(),alt:l.string().optional()}).superRefine((e,t)=>{if(e.type==="color"){let n=!!e.color,r=!!e.from&&!!e.to;!n&&!r&&t.addIssue({code:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!e.from!=!!e.to&&t.addIssue({code:l.ZodIssueCode.custom,path:e.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}e.type==="image"&&!e.src&&t.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),mt=l.object({id:l.string().regex(or,{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:Gl.default("public"),backgroundColor:Sn.optional(),background:Yl.optional(),theme:l.object({preset:l.string().min(1).optional(),tokens:vn.optional(),brand:Pi.optional()}).optional(),chrome:ql.default({}),aspectRatio:Zl.optional(),chapters:l.array(Jl).default([]),steps:l.array(Zi).min(1)}).passthrough().superRefine((e,t)=>{let n=new Set(e.steps.map(i=>i.id)),r=new Set(e.chapters.map(i=>i.id));e.chapters.forEach((i,a)=>{i.stepIds.forEach(o=>{n.has(o)||t.addIssue({code:l.ZodIssueCode.custom,path:["chapters",a,"stepIds"],message:`Chapter "${i.id}" references unknown step "${o}"`})})}),e.steps.forEach((i,a)=>{i.kind==="cover"&&i.widgets.forEach((o,s)=>{o.type==="headline"&&["cta","secondaryCta"].forEach(c=>{let d=o[c]?.action;d&&(d.type==="step"&&!n.has(d.stepId)&&t.addIssue({code:l.ZodIssueCode.custom,path:["steps",a,"widgets",s,c,"action","stepId"],message:`Widget "${o.id}" CTA targets unknown step "${d.stepId}"`}),d.type==="chapter"&&!r.has(d.chapterId)&&t.addIssue({code:l.ZodIssueCode.custom,path:["steps",a,"widgets",s,c,"action","chapterId"],message:`Widget "${o.id}" CTA targets unknown chapter "${d.chapterId}"`}))})})})});function _n(e){return mt.parse(e)}function $t(e){let t=typeof e=="object"&&e!==null?e:{},n=Ei(t.id),r=n?t:{...t,id:se()};return{config:mt.parse(r),changed:!n}}function Ki(e){let t=new Map;e.forEach((r,i)=>{let a=t.get(r.id);a?a.push({entry:r,index:i}):t.set(r.id,[{entry:r,index:i}])});let n=[];for(let r of t.values()){if(r.length<2)continue;let i=[...r].sort((o,s)=>o.entry.updatedAt!==s.entry.updatedAt?o.entry.updatedAt-s.entry.updatedAt:o.index-s.index),[,...a]=i;for(let{entry:o}of a)n.push({entry:o,newId:se()})}return n}var pr=l.enum(["sidebar","tabs"]),Xl=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))}),we=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:pr.optional(),theme:l.string().min(1).optional(),tokens:vn.optional(),brand:ar.optional(),title:l.string().min(1).optional(),subtitle:l.string().min(1).optional(),collections:l.array(Xl).optional()});function Yi({slug:e,config:t,resolveAssetSrc:n}){let r=t.title??t.id??e;return{slug:e,title:r,description:Ql(t,r),thumbnail:nc(t,r,n),visibility:t.visibility}}function Cn(e,t){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}\u2026`}function Ql(e,t){if(e.subtitle?.trim())return Cn(e.subtitle.trim(),120);for(let n of e.steps){if(n.kind!=="content")continue;let r=n.captions?.[0]?.text;if(r&&r.trim())return Cn(r.trim(),120);break}for(let n of e.steps)if(n.kind==="cover"){for(let r of n.widgets)if(r.type==="headline"&&r.description&&r.description.trim())return Cn(r.description.trim(),120)}return Cn(`Explore the ${t} workflow.`,120)}function ec(e){return e.background?e.background.type==="image":e.backgroundImage?!0:e.widgets.some(t=>t.type==="headline"?!!t.title:t.type==="embed"?!!t.src:t.type==="form")}function hr(e,t){return e?t?t(e):e:null}function tc(e,t){if(!t)return e;let n=e.widgets.map(o=>{if((o.type==="headline"||o.type==="form")&&o.image?.src){let s=t(o.image.src);return s&&s!==o.image.src?{...o,image:{...o.image,src:s}}:o}return o}),r=e.backgroundImage,i=e.background;if(i?.type==="image"&&i.src){let o=t(i.src);o&&o!==i.src&&(i={...i,src:o})}if(r?.src){let o=t(r.src);o&&o!==r.src&&(r={...r,src:o})}return!n.some((o,s)=>o!==e.widgets[s])&&i===e.background&&r===e.backgroundImage?e:{...e,widgets:n,background:i,backgroundImage:r}}function nc(e,t,n){let r=e.steps[0];if(r){if(r.kind==="cover"&&ec(r))return{kind:"cover",cover:tc(r,n),themeTokens:e.theme?.tokens};if(r.kind==="content"){let i=r.background;if(i?.type==="image"){let a=hr(i.src,n);if(a)return{kind:"image",src:a}}else if(i?.type==="video"){let a=hr(i.posterSrc,n);if(a)return{kind:"image",src:a};let o=hr(i.src,n);if(o)return{kind:"video",src:o}}else if(i?.type==="html")return{kind:"html",path:i.path,naturalWidth:i.naturalWidth,naturalHeight:i.naturalHeight,zoom:i.zoom,scroll:i.scroll}}}return{kind:"placeholder",title:t}}function rc(e){return!e||e==="null"?"":e.replace(/\/+$/,"")}function ic(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ac(e){return String(e||"").replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"")}function mr(e){let t=ac(e);return/\/index\.html$/i.test(t)||/^index\.html$/i.test(t)?t.replace(/index\.html$/i,"document.css"):/\.html?$/i.test(t)?t.replace(/\.html?$/i,".css"):null}function oc(e){return e.replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?content-security-policy\b)[^>]*>/gi,"")}var sc=/\s+(?:href|xlink:href|target|rel|download|ping|referrerpolicy|data-inkly-href)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?/gi;function Xt(e){return String(e||"").replace(/<(a|area)\b[^>]*>/gi,t=>t.replace(sc,""))}function ft(e,t={}){let n=rc(t.resourceOrigin),r=String(e||"");return n?r.replace(new RegExp(`(^|["'\\(\\s,=])${ic("/api/hubs/")}`,"g"),`$1${n}/api/hubs/`):r}function lc(e){return oc(e).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 Xi({htmlPath:e,html:t,css:n,cssHref:r,resourceOrigin:i}){let a=lc(Xt(t)),o=mr(e)!=null,s=n?.trim()??"";if(o&&s){let d=`<style data-inkly-document-css>
|
|
3
|
+
${ft(n??"",{resourceOrigin:i}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
4
|
+
</style>`,u=/<\/head\s*>/i.test(a)?a.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${a}`;return ft(u,{resourceOrigin:i})}if(o&&r){let d=`<link rel="stylesheet" href="${ft(r,{resourceOrigin:i})}" data-inkly-document-css>`,u=/<\/head\s*>/i.test(a)?a.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${a}`;return ft(u,{resourceOrigin:i})}return ft(a,{resourceOrigin:i})}var Qt=l.string().regex(/^sha(?:256|384|512)-[A-Za-z0-9+/]+=*$/,{message:"must be an SRI string like sha384-<base64>"}),Tn=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"}),cc=l.object({version:Tn,url:l.string().url(),integrity:Qt}),An=l.object({$schema:l.string().optional(),runtime:cc});var Qi=l.string().regex(/^[0-9a-f]{64}$/,{message:"must be lowercase sha-256 hex (64 chars)"}),Dt=l.object({version:Tn,externals:l.array(l.string().min(1)),jsHash:Qi,cssHash:Qi,jsBytes:l.number().int().nonnegative(),cssBytes:l.number().int().nonnegative(),integrity:Qt,cssIntegrity:Qt,minSchema:Tn,codemodsIntegrity:Qt.optional(),codemodsBytes:l.number().int().nonnegative().optional()});var gt=["__inkly","assets","api","c"],dc={__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"},uc=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;function Re(e){return typeof e!="string"?{ok:!1,reason:"Name is required."}:e.length===0?{ok:!1,reason:"Name cannot be empty."}:/\s/.test(e)?{ok:!1,reason:"Name cannot contain spaces."}:e.includes("/")||e.includes("\\")?{ok:!1,reason:"Name cannot contain slashes."}:e.includes(".")?{ok:!1,reason:"Name cannot contain dots."}:gt.includes(e)?{ok:!1,reason:dc[e]}:e.startsWith("_")?{ok:!1,reason:"Name cannot start with '_' (reserved for internal use)."}:e!==e.toLowerCase()?{ok:!1,reason:'Name must be lowercase (e.g. "getting-started").'}:uc.test(e)?{ok:!0}:{ok:!1,reason:"Name must be kebab-case: lowercase letters, digits, and hyphens, starting and ending with a letter or digit."}}var Be={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 pc=`
|
|
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 @@ ${st(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
|
+
`,ea={id:"editorial",label:"Editorial",theme:Be.editorial,css:pc};var hc=`
|
|
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 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2333
2333
|
border-radius: 10px;
|
|
2334
2334
|
box-shadow: none;
|
|
2335
2335
|
}
|
|
2336
|
-
`,
|
|
2336
|
+
`,ta={id:"mono",label:"Mono",theme:Be.mono,css:hc};var mc=`
|
|
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
|
|
@@ -2354,6 +2354,20 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2354
2354
|
src: url("https://www.cdn.inklyai.dev/fonts/newsreader/newsreader-latin-600-normal.woff2?v=1") format("woff2");
|
|
2355
2355
|
}
|
|
2356
2356
|
|
|
2357
|
+
/* Fraunces 600 \u2014 the cover + hub display headline. Self-hosted on the Inkly
|
|
2358
|
+
CDN (same pattern as Newsreader) so exported self-contained demos render it
|
|
2359
|
+
without a Google Fonts round-trip; Georgia is the swap fallback. The
|
|
2360
|
+
fonts/fraunces path was probed (404) before the woff2 was uploaded, so
|
|
2361
|
+
?v=1 gives a fresh cache key that sidesteps any stale negative cache.
|
|
2362
|
+
Bump on any future re-upload to this path. */
|
|
2363
|
+
@font-face {
|
|
2364
|
+
font-family: "Fraunces";
|
|
2365
|
+
font-style: normal;
|
|
2366
|
+
font-weight: 600;
|
|
2367
|
+
font-display: swap;
|
|
2368
|
+
src: url("https://www.cdn.inklyai.dev/fonts/fraunces/fraunces-latin-600-normal.woff2?v=1") format("woff2");
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2357
2371
|
/* \u2500\u2500 Inkly hub-index \u2014 designs 14 v2 (top nav) + 24 v3 (sidebar
|
|
2358
2372
|
connected shell) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
2359
2373
|
All sans (Geist), no italic, no serif. Dotted canvas backdrop, indigo
|
|
@@ -2412,10 +2426,10 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2412
2426
|
background-color: var(--inkly-hub-canvas);
|
|
2413
2427
|
background-image: radial-gradient(
|
|
2414
2428
|
circle at 1px 1px,
|
|
2415
|
-
var(--inkly-hub-dot)
|
|
2416
|
-
transparent
|
|
2429
|
+
var(--inkly-hub-dot) 0.5px,
|
|
2430
|
+
transparent 1px
|
|
2417
2431
|
);
|
|
2418
|
-
background-size:
|
|
2432
|
+
background-size: 10px 10px;
|
|
2419
2433
|
color: var(--inkly-hub-ink-strong);
|
|
2420
2434
|
}
|
|
2421
2435
|
|
|
@@ -2625,10 +2639,10 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2625
2639
|
background-color: var(--inkly-hub-canvas);
|
|
2626
2640
|
background-image: radial-gradient(
|
|
2627
2641
|
circle at 1px 1px,
|
|
2628
|
-
var(--inkly-hub-dot)
|
|
2629
|
-
transparent
|
|
2642
|
+
var(--inkly-hub-dot) 0.5px,
|
|
2643
|
+
transparent 1px
|
|
2630
2644
|
);
|
|
2631
|
-
background-size:
|
|
2645
|
+
background-size: 10px 10px;
|
|
2632
2646
|
}
|
|
2633
2647
|
.inkly-hub-pa-topbar {
|
|
2634
2648
|
flex: 0 0 auto;
|
|
@@ -2687,12 +2701,19 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2687
2701
|
}
|
|
2688
2702
|
.inkly-hub-pa-title {
|
|
2689
2703
|
margin: 0;
|
|
2704
|
+
/* Shares the cover-title font stack so the hub hero and the player
|
|
2705
|
+
headline read as one type voice \u2014 self-hosted Fraunces, with
|
|
2706
|
+
Newsreader then Georgia as fallbacks. */
|
|
2707
|
+
font-family: "Fraunces", "Newsreader", Georgia, serif;
|
|
2690
2708
|
font-weight: 600;
|
|
2691
2709
|
line-height: 1.08;
|
|
2692
2710
|
letter-spacing: -0.5px;
|
|
2693
2711
|
color: var(--inkly-hub-ink-strong);
|
|
2694
2712
|
max-width: 820px;
|
|
2695
|
-
|
|
2713
|
+
/* Fluid against the hub container so the hero title scales smoothly
|
|
2714
|
+
with the subtitle (also fluid) rather than stepping at breakpoints \u2014
|
|
2715
|
+
this keeps the title:subtitle ratio locked, matching the cover. */
|
|
2716
|
+
font-size: clamp(30px, 3.6cqi, 40px);
|
|
2696
2717
|
}
|
|
2697
2718
|
.inkly-hub-pa-title em {
|
|
2698
2719
|
font-style: normal;
|
|
@@ -2701,7 +2722,9 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2701
2722
|
.inkly-hub-pa-subtitle {
|
|
2702
2723
|
margin: 12px 0 0;
|
|
2703
2724
|
max-width: 600px;
|
|
2704
|
-
|
|
2725
|
+
/* Fluid at the same proportion as the title (\u22482.4x) so the pair scales
|
|
2726
|
+
together. Floors at 14px / caps at 16.5px. */
|
|
2727
|
+
font-size: clamp(14px, 1.5cqi, 16.5px);
|
|
2705
2728
|
color: var(--inkly-hub-ink-2);
|
|
2706
2729
|
line-height: 1.55;
|
|
2707
2730
|
}
|
|
@@ -2781,7 +2804,7 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2781
2804
|
overflow: hidden;
|
|
2782
2805
|
}
|
|
2783
2806
|
.inkly-hub-pa-shell-header {
|
|
2784
|
-
height:
|
|
2807
|
+
height: 52px;
|
|
2785
2808
|
position: sticky;
|
|
2786
2809
|
top: 0;
|
|
2787
2810
|
z-index: 5;
|
|
@@ -2807,18 +2830,6 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2807
2830
|
gap: 10px;
|
|
2808
2831
|
padding: 0 24px 0 22px;
|
|
2809
2832
|
}
|
|
2810
|
-
.inkly-hub-pa-breadcrumb {
|
|
2811
|
-
font-size: 13px;
|
|
2812
|
-
color: var(--inkly-hub-ink-muted);
|
|
2813
|
-
}
|
|
2814
|
-
.inkly-hub-pa-breadcrumb-sep {
|
|
2815
|
-
margin: 0 6px;
|
|
2816
|
-
color: var(--inkly-hub-line-strong);
|
|
2817
|
-
}
|
|
2818
|
-
.inkly-hub-pa-breadcrumb strong {
|
|
2819
|
-
color: var(--inkly-hub-ink-strong);
|
|
2820
|
-
font-weight: 500;
|
|
2821
|
-
}
|
|
2822
2833
|
.inkly-hub-pa-shell-bar-end {
|
|
2823
2834
|
margin-left: auto;
|
|
2824
2835
|
display: flex;
|
|
@@ -2919,10 +2930,10 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2919
2930
|
background-color: var(--inkly-hub-canvas);
|
|
2920
2931
|
background-image: radial-gradient(
|
|
2921
2932
|
circle at 1px 1px,
|
|
2922
|
-
var(--inkly-hub-dot)
|
|
2923
|
-
transparent
|
|
2933
|
+
var(--inkly-hub-dot) 0.5px,
|
|
2934
|
+
transparent 1px
|
|
2924
2935
|
);
|
|
2925
|
-
background-size:
|
|
2936
|
+
background-size: 10px 10px;
|
|
2926
2937
|
border-top-left-radius: 8px;
|
|
2927
2938
|
border-top: 1px solid var(--inkly-hub-line);
|
|
2928
2939
|
border-left: 1px solid var(--inkly-hub-line);
|
|
@@ -2941,13 +2952,9 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2941
2952
|
.inkly-hub-pa-shell-hero {
|
|
2942
2953
|
padding: 32px 32px 14px;
|
|
2943
2954
|
}
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
}
|
|
2948
|
-
.inkly-hub-pa-shell-hero .inkly-hub-pa-subtitle {
|
|
2949
|
-
font-size: 16px;
|
|
2950
|
-
}
|
|
2955
|
+
/* Title + subtitle sizing now lives on the base .inkly-hub-pa-title /
|
|
2956
|
+
.inkly-hub-pa-subtitle rules (fluid clamps), shared by both the sidebar
|
|
2957
|
+
shell-hero and the tabs hero. */
|
|
2951
2958
|
|
|
2952
2959
|
/* \u2500\u2500 Demo grid (both layouts) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
2953
2960
|
|
|
@@ -3084,9 +3091,6 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3084
3091
|
.hub-index[data-theme="inkly"][data-layout="tabs"] .inkly-hub-demos-grid {
|
|
3085
3092
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
3086
3093
|
}
|
|
3087
|
-
.hub-index[data-theme="inkly"][data-layout="tabs"] .inkly-hub-pa-title {
|
|
3088
|
-
font-size: 34px;
|
|
3089
|
-
}
|
|
3090
3094
|
}
|
|
3091
3095
|
|
|
3092
3096
|
@container hub-pa-tabs (max-width: 640px) {
|
|
@@ -3301,16 +3305,10 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3301
3305
|
.hub-index[data-theme="inkly"][data-layout="sidebar"] .inkly-hub-demos-grid {
|
|
3302
3306
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
3303
3307
|
}
|
|
3304
|
-
|
|
3305
|
-
font-size: 34px;
|
|
3306
|
-
}
|
|
3307
|
-
/* Trim the header bar so breadcrumb + search + CTAs don't wrap. */
|
|
3308
|
+
/* Trim the header bar so search + CTAs don't wrap. */
|
|
3308
3309
|
.hub-index[data-theme="inkly"][data-layout="sidebar"] .inkly-hub-pa-shell-bar-end .inkly-hub-pa-cta.is-secondary {
|
|
3309
3310
|
display: none;
|
|
3310
3311
|
}
|
|
3311
|
-
.hub-index[data-theme="inkly"][data-layout="sidebar"] .inkly-hub-pa-breadcrumb {
|
|
3312
|
-
display: none;
|
|
3313
|
-
}
|
|
3314
3312
|
}
|
|
3315
3313
|
|
|
3316
3314
|
@container hub-pa-sidebar (max-width: 640px) {
|
|
@@ -3514,7 +3512,7 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3514
3512
|
/* Dotted backdrop on the content stage. */
|
|
3515
3513
|
[data-demo-theme="inkly"] .demo-player-shell {
|
|
3516
3514
|
background:
|
|
3517
|
-
radial-gradient(circle at 1px 1px, rgba(0,0,0,0.
|
|
3515
|
+
radial-gradient(circle at 1px 1px, rgba(0,0,0,0.08) 0.5px, transparent 1px) 0 0 / 10px 10px,
|
|
3518
3516
|
#f5f5f5;
|
|
3519
3517
|
}
|
|
3520
3518
|
|
|
@@ -3523,17 +3521,30 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3523
3521
|
when authors want a unique cover image. */
|
|
3524
3522
|
[data-demo-theme="inkly"] .demo-intro{
|
|
3525
3523
|
background-color: #f5f5f5;
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3524
|
+
}
|
|
3525
|
+
/* Watercolor backdrop lives on a ::before so it can be mirrored
|
|
3526
|
+
horizontally \u2014 the source image's dark pine sits bottom-LEFT, right where
|
|
3527
|
+
the left-aligned headline/description go. scaleX(-1) flips it to the
|
|
3528
|
+
right (empty) side without touching the text. The image is 16:9 inside a
|
|
3529
|
+
16:9 cover, so background-position can't slide it; mirroring is the only
|
|
3530
|
+
way to move the pine off the copy without zooming or washing it out.
|
|
3531
|
+
z-index:-1 keeps it above the solid #f5f5f5 fill but below the (un-
|
|
3532
|
+
positioned) cover content, so the copy stays on top. A translucent white
|
|
3533
|
+
wash pales the watercolor back a touch for headline contrast. */
|
|
3534
|
+
[data-demo-theme="inkly"] .demo-intro::before{
|
|
3535
|
+
content: "";
|
|
3536
|
+
position: absolute;
|
|
3537
|
+
inset: 0;
|
|
3538
|
+
z-index: -1;
|
|
3539
|
+
border-radius: inherit;
|
|
3529
3540
|
background-image:
|
|
3530
3541
|
linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3)),
|
|
3531
3542
|
url("https://www.cdn.inklyai.dev/backgrounds/watercolor-background.png");
|
|
3532
3543
|
background-size: cover;
|
|
3533
|
-
|
|
3534
|
-
the headline/description that sit on the left of the cover. */
|
|
3535
|
-
background-position: 70% 30%;
|
|
3544
|
+
background-position: center;
|
|
3536
3545
|
background-repeat: no-repeat;
|
|
3546
|
+
transform: scaleX(-1);
|
|
3547
|
+
pointer-events: none;
|
|
3537
3548
|
}
|
|
3538
3549
|
|
|
3539
3550
|
/* Header \u2014 design's macOS chrome: 52px tall, gradient surface, single
|
|
@@ -3721,11 +3732,15 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3721
3732
|
padding: clamp(40px, 6cqi, 72px);
|
|
3722
3733
|
}
|
|
3723
3734
|
[data-demo-theme="inkly"] .demo-intro-title{
|
|
3724
|
-
|
|
3735
|
+
/* Fraunces 600 \u2014 a high-contrast display serif, self-hosted on the Inkly
|
|
3736
|
+
CDN (see @font-face above) so it renders everywhere: preview, hosted
|
|
3737
|
+
hubs, and exported self-contained demos. Newsreader then Georgia are
|
|
3738
|
+
swap fallbacks. */
|
|
3739
|
+
font-family: "Fraunces", "Newsreader", Georgia, serif;
|
|
3725
3740
|
font-weight: 600;
|
|
3726
|
-
font-size: clamp(
|
|
3727
|
-
line-height: 1.
|
|
3728
|
-
letter-spacing: -
|
|
3741
|
+
font-size: clamp(30px, 3.8cqi, 44px);
|
|
3742
|
+
line-height: 1.08;
|
|
3743
|
+
letter-spacing: -1.5px;
|
|
3729
3744
|
color: var(--demo-fg);
|
|
3730
3745
|
text-wrap: balance;
|
|
3731
3746
|
}
|
|
@@ -3735,8 +3750,11 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3735
3750
|
}
|
|
3736
3751
|
[data-demo-theme="inkly"] .demo-intro-description{
|
|
3737
3752
|
color: #5f5f5f;
|
|
3738
|
-
|
|
3739
|
-
|
|
3753
|
+
/* Fluid like the title (3.8cqi) so the title:subtitle ratio stays a
|
|
3754
|
+
steady ~2.2\u20132.6x across player widths instead of drifting from 2x to
|
|
3755
|
+
~2.9x when the title is fixed against a 15px subtitle. */
|
|
3756
|
+
font-size: clamp(14px, 1.5cqi, 17px);
|
|
3757
|
+
line-height: 1.5;
|
|
3740
3758
|
max-width: 46ch;
|
|
3741
3759
|
opacity: 1;
|
|
3742
3760
|
}
|
|
@@ -3888,12 +3906,11 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3888
3906
|
gap: 4px;
|
|
3889
3907
|
padding: 3px 6px 3px 5px;
|
|
3890
3908
|
}
|
|
3891
|
-
/*
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
so the demo stays self-contained. */
|
|
3909
|
+
/* Wordmark shares the cover-title font stack so the watermark and the
|
|
3910
|
+
headline read as one type voice \u2014 self-hosted Fraunces, with Newsreader
|
|
3911
|
+
then Georgia as fallbacks. */
|
|
3895
3912
|
[data-demo-theme="inkly"] .demo-builtwith-badge-text {
|
|
3896
|
-
font-family: "Newsreader", Georgia, "Times New Roman", serif;
|
|
3913
|
+
font-family: "Fraunces", "Newsreader", Georgia, "Times New Roman", serif;
|
|
3897
3914
|
font-size: 12px;
|
|
3898
3915
|
font-weight: 600;
|
|
3899
3916
|
letter-spacing: 0.2px;
|
|
@@ -4029,7 +4046,7 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
4029
4046
|
line-height: 1.45;
|
|
4030
4047
|
}
|
|
4031
4048
|
}
|
|
4032
|
-
`,
|
|
4049
|
+
`,na={id:"inkly",label:"Inkly",theme:Be.inkly,css:mc};var fc=`
|
|
4033
4050
|
.hub-index[data-theme="substack"] {
|
|
4034
4051
|
background: #ffffff;
|
|
4035
4052
|
color: #1a1a1a;
|
|
@@ -4960,143 +4977,158 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
4960
4977
|
--demo-watermark-mark-radius: 3px;
|
|
4961
4978
|
font-family: var(--demo-font);
|
|
4962
4979
|
}
|
|
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
|
|
4965
|
-
`);else if(
|
|
4966
|
-
`):s?process.stdout.write(`inkly lock: wrote ${r} (runtime ${
|
|
4967
|
-
`):process.stdout.write(`inkly lock: ${r} already up to date (runtime ${
|
|
4980
|
+
`,ra={id:"substack",label:"Substack",theme:Be.substack,css:fc};var ia=[na,ea,ta,ra],pe=Object.fromEntries(ia.map(e=>[e.id,e]));import{createHash as Ac}from"crypto";import{mkdir as Ic,readFile as xr,rm as Zf,stat as Gf}from"fs/promises";import{homedir as Pc}from"os";import{join as We}from"path";import{fileURLToPath as Ec}from"url";import{access as gc,readFile as bc,readdir as yc,stat as xc}from"fs/promises";import{dirname as kc,join as Nt,resolve as wc,sep as vc}from"path";async function q(e){return gc(e).then(()=>!0,()=>!1)}async function De(e){let t=wc(e);for(;;){if(await q(Nt(t,"inkly.json")))return t;let n=kc(t);if(n===t)return null;t=n}}async function fr(e){let t=Nt(e,"demos");if(!await q(t))return[];let n=[];async function r(i){let a;try{a=await yc(i,{withFileTypes:!0})}catch{return}if(a.some(o=>o.isFile()&&o.name==="demo.config.json")){let o=i===t?"":i.slice(t.length+1).split(vc).join("/");n.push({slug:o,dir:i,configPath:Nt(i,"demo.config.json")});return}for(let o of a)o.isDirectory()&&await r(Nt(i,o.name))}return await r(t),n.sort((i,a)=>i.slug.localeCompare(a.slug))}async function $e(e){let t=await bc(e,"utf8");return JSON.parse(t)}async function Mt(e){let t=await De(e);if(!t)throw new Error(`No inkly.json found in ${e} or any parent directory.`);let n=Nt(t,"inkly.json"),r=we.safeParse(await $e(n));if(!r.success)throw new Error(`inkly.json failed schema validation: ${r.error.message}`);let i=[];for(let a of await fr(t)){let o;try{o=$t(await $e(a.configPath)).config}catch(d){throw new Error(`demos/${a.slug}/demo.config.json failed schema validation: ${d.message}`)}let s=Nt(a.dir,"assets.json"),c=null;if(await q(s)){let d=Rt.safeParse(await $e(s));if(!d.success)throw new Error(`demos/${a.slug}/assets.json failed schema validation: ${d.error.message}`);c=d.data}i.push({slug:a.slug,dir:a.dir,configPath:a.configPath,config:o,assetsPath:s,assets:c})}return{root:t,inklyPath:n,inkly:r.data,demos:i}}function gr(e){let t=e.split("/")[0]??e,n=Re(t);return n.ok?gt.includes(e)?`Demo folder "${e}" uses a reserved slug.`:null:n.reason}async function In(e){try{let t=await xc(e);return t.isFile()?t.size:null}catch{return null}}import{mkdir as Sc,rename as _c,writeFile as Cc}from"fs/promises";import{dirname as Tc}from"path";async function te(e,t,n){await Sc(Tc(e),{recursive:!0});let r=`${e}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await Cc(r,t,n?.mode!=null?{mode:n.mode}:void 0),await _c(r,e)}var Rc="https://www.runtime.inklyai.dev";function yt(){let e=process.env.BUNDLES_R2_PUBLIC_BASE_URL;return typeof e=="string"&&e.length>0?e.replace(/\/+$/,""):Rc}function kr(e,t,n=yt()){return`${n}/runtime/${e}/${t}`}function $c(e){return We(Pc(),".inkly","cache","runtime",e)}function Dc(e){let t=/^(sha(?:256|384|512))-([A-Za-z0-9+/]+=*)$/.exec(e);return t?{algorithm:t[1],expected:t[2]}:null}function Lt(e,t){let n=Dc(t);return n?Ac(n.algorithm).update(e).digest("base64")===n.expected:!1}var Ot=class extends Error{constructor(n,r,i){super(`integrity mismatch for ${n}: expected ${r}`+(i?` (from ${i})`:"")+". 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=i;this.name="IntegrityMismatchError"}},bt=class extends Error{constructor(t){super(t),this.name="LockReadError"}};async function Nc(e){let t=We(e,"inkly.lock");if(!await q(t))throw new bt(`no inkly.lock found in ${e}. Run \`inkly lock\` to generate one.`);let n;try{n=await $e(t)}catch(i){throw new bt(`failed to read ${t}: ${i.message}`)}let r=An.safeParse(n);if(!r.success)throw new bt(`${t} failed InklyLockSchema validation: ${r.error.message}`);return r.data}function Mc(e,t){let n=e.lastIndexOf("/");return n===-1?e:`${e.slice(0,n+1)}${t}`}async function aa(e){try{return await xr(e)}catch{return null}}async function Lc(e){let t=We(e,"manifest.json");if(!await q(t))return null;try{let n=JSON.parse(await xr(t,"utf8")),r=Dt.safeParse(n);return r.success?r.data:null}catch{return null}}async function br(e,t){await te(e,t)}async function yr(e,t){if(e.startsWith("file://"))try{return await xr(Ec(e))}catch(i){throw new Error(`failed to read ${e}: ${i.message}`)}let n;try{n=await t(e)}catch(i){throw new Error(`failed to fetch ${e}: ${i.message}`)}if(!n.ok)throw new Error(`fetch ${e} returned HTTP ${n.status}`);let r=await n.arrayBuffer();return Buffer.from(r)}async function wr(e){let t=e.fetchImpl??fetch,n=e.lock??await Nc(e.hubRoot),{version:r,url:i,integrity:a}=n.runtime,o=$c(r),s=await aa(We(o,"runtime.js")),c=await aa(We(o,"runtime.css")),d=await Lc(o);if(s&&c&&d){let $=Lt(s,a),R=d.version===r,b=Lt(c,d.cssIntegrity);if($&&R&&b)return{version:r,cacheDir:o,manifest:d,fetched:!1,bytesFetched:0,lock:n}}let u=$=>{let R=e.urlOverrides?.[$];return R||($==="runtime.js"?i:Mc(i,$))};await Ic(o,{recursive:!0});let p=u("manifest.json"),h=await yr(p,t),f;try{let $=JSON.parse(h.toString("utf8")),R=Dt.safeParse($);if(!R.success)throw new Error(`manifest from ${p} failed schema validation: ${R.error.message}`);f=R.data}catch($){throw new Error(`manifest from ${p} is not valid JSON: ${$.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"),x=await yr(w,t);if(!Lt(x,a))throw new Ot("runtime.js",a,w);let _=u("runtime.css"),P=await yr(_,t);if(!Lt(P,f.cssIntegrity))throw new Ot("runtime.css",f.cssIntegrity,_);return await br(We(o,"runtime.js"),x),await br(We(o,"runtime.css"),P),await br(We(o,"manifest.json"),h),{version:r,cacheDir:o,manifest:f,fetched:!0,bytesFetched:x.byteLength+P.byteLength+h.byteLength,lock:n}}import{readFile as sa,writeFile as Oc}from"fs/promises";import{dirname as vr,isAbsolute as jc,join as jt,resolve as Uc}from"path";import{fileURLToPath as zc,pathToFileURL as Fc}from"url";function Ve(e,t,n){e.push({level:t,message:n})}async function Hc(){let e=vr(zc(import.meta.url));for(let t=0;t<10;t+=1){let n=jt(e,"node_modules","@inkly","runtime","dist","manifest.json");if(await q(n))return n;let r=jt(e,"packages","inkly-runtime","dist","manifest.json");if(await q(r))return r;let i=vr(e);if(i===e)break;e=i}return null}async function oa(e){let t=JSON.parse(await sa(e,"utf8")),n=Dt.safeParse(t);if(!n.success)throw new Error(`${e} failed RuntimeManifestSchema validation: ${n.error.message}`);return n.data}async function Bc(e,t){let n=yt(),r=kr(e,"manifest.json",n);try{let i=await t(r);if(!i.ok)return null;let a=JSON.parse(await i.text()),o=Dt.safeParse(a);return o.success?{manifest:o.data,url:r}:null}catch{return null}}async function Wc(e,t){if(t.manifestPath)return{manifest:await oa(t.manifestPath),source:"local",manifestPath:t.manifestPath};if(!t.localOnly){let r=t.fetchImpl??fetch,i=await Bc(e,r);if(i){if(i.manifest.version!==e)throw new Error(`CDN manifest at ${i.url} reports version ${i.manifest.version} but inkly.json pins ${e}. Wait for the publish workflow to upload the matching artifact, or update inkly.json#runtime to match.`);return{manifest:i.manifest,source:"cdn"}}}let n=await Hc();if(!n)throw new Error(`Could not fetch runtime manifest for ${e} from ${yt()} 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 oa(n),source:"local",manifestPath:n}}async function Pn(e,t={}){let n=jt(e,"inkly.json"),r=await $e(n),i=typeof r.runtime=="string"?r.runtime:null;if(!i)throw new Error('inkly.json is missing a string "runtime" pin.');if(!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(i))throw new Error(`inkly.json#runtime must be an exact semver (got "${i}"). Set runtime to an exact version and put your compatibility range in runtimeRange.`);let{manifest:a,source:o,manifestPath:s}=await Wc(i,t);if(a.version!==i)throw new Error(`Runtime manifest reports version ${a.version} but inkly.json pins ${i}. Build the matching Inkly runtime version (or upgrade the pin) and retry.`);return{lock:{$schema:"https://inklyai.dev/inkly.lock",runtime:{version:a.version,url:o==="local"&&s?Fc(jt(vr(s),"runtime.js")).toString():kr(a.version,"runtime.js"),integrity:a.integrity}},manifest:a,source:o}}async function En(e){let t=[],n=await De(e.cwd);if(!n)return Ve(t,"error",`No inkly.json found in ${e.cwd} or any parent directory.`),ve({ok:!1,hubRoot:null,lockPath:null,lock:null,source:null,issues:t,drifted:!1,options:e});let r=jt(n,"inkly.lock"),i=e.manifestPath?jc(e.manifestPath)?e.manifestPath:Uc(e.cwd,e.manifestPath):void 0;if(e.check){if(!await q(r))return Ve(t,"error","inkly.lock is missing. Run `inkly lock` to create it."),ve({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:t,drifted:!0,options:e});let a=await $e(r),o=An.safeParse(a);if(!o.success)return Ve(t,"error",`inkly.lock failed schema validation: ${o.error.message}`),ve({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:t,drifted:!0,options:e});let s=jt(n,"inkly.json"),c=await $e(s),d=typeof c.runtime=="string"?c.runtime:null;if(!d)return Ve(t,"error",'inkly.json is missing a string "runtime" pin.'),ve({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:t,drifted:!0,options:e});if(o.data.runtime.version!==d)return Ve(t,"error",`inkly.lock pins runtime ${o.data.runtime.version}, but inkly.json pins ${d}. Re-run \`inkly lock\` to refresh.`),ve({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:null,issues:t,drifted:!0,options:e});try{let u=await Pn(n,{manifestPath:i,localOnly:!!i||e.localOnly,fetchImpl:e.fetchImpl});return u.lock.runtime.integrity!==o.data.runtime.integrity?(Ve(t,"error",`inkly.lock integrity does not match what ${u.source==="cdn"?yt():"the local build"} serves for runtime ${d}. Re-run \`inkly lock\` to refresh, or someone tampered with the source.`),ve({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:u.source,issues:t,drifted:!0,options:e})):ve({ok:!0,hubRoot:n,lockPath:r,lock:o.data,source:u.source,issues:t,drifted:!1,options:e})}catch(u){return Ve(t,"error",u.message),ve({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:null,issues:t,drifted:!0,options:e})}}try{let{lock:a,source:o}=await Pn(n,{manifestPath:i,localOnly:!!i||e.localOnly,fetchImpl:e.fetchImpl}),s=JSON.stringify(a,null,2)+`
|
|
4981
|
+
`,d=(await q(r)?await sa(r,"utf8"):null)!==s;return d&&await Oc(r,s,"utf8"),ve({ok:!0,hubRoot:n,lockPath:r,lock:a,source:o,issues:t,drifted:d,options:e})}catch(a){return Ve(t,"error",a.message),ve({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:t,drifted:!1,options:e})}}function ve(e){let{ok:t,hubRoot:n,lockPath:r,lock:i,source:a,issues:o,drifted:s,options:c}=e,d={ok:t,hubRoot:n,lockPath:r,lock:i,source:a,issues:o,drifted:s};if(!c.silent)if(c.json)process.stdout.write(JSON.stringify(d,null,2)+`
|
|
4982
|
+
`);else if(t)c.check?process.stdout.write(`inkly lock --check: inkly.lock matches inkly.json (runtime ${i?.runtime.version}, source: ${a??"unknown"}).
|
|
4983
|
+
`):s?process.stdout.write(`inkly lock: wrote ${r} (runtime ${i?.runtime.version}, source: ${a??"unknown"}).
|
|
4984
|
+
`):process.stdout.write(`inkly lock: ${r} already up to date (runtime ${i?.runtime.version}, source: ${a??"unknown"}).
|
|
4968
4985
|
`);else{for(let u of o)process.stdout.write(`${u.level.toUpperCase()} ${u.message}
|
|
4969
4986
|
`);process.stdout.write(`inkly lock failed
|
|
4970
|
-
`)}return d}function
|
|
4971
|
-
`],["{{themeJson}}",JSON.stringify(
|
|
4987
|
+
`)}return d}function Rn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Yc(e=yt()){return`${e}/runtime/latest.json`}function da(e){return ca==="/"?e:e.split("/").join(ca)}function Xc(e){let t=e??globalThis.fetch;if(typeof t!="function")throw new Error("This Node runtime does not provide fetch; Node 20+ is required.");return t}async function ua(e,t){let n=await t(e);if(!n.ok)throw new Error(`failed to fetch ${e}: HTTP ${n.status}${n.statusText?` ${n.statusText}`:""}`);let r=Vc.from(await n.arrayBuffer()),i;try{i=JSON.parse(r.toString("utf8"))}catch(a){throw new Error(`failed to parse JSON from ${e}: ${a.message}`)}return{json:i,bytes:r}}function Qc(e,t){if(!Rn(e))throw new Error(`${t} is not an object`);let n=e.version,r=e.hubSkeleton;if(typeof n!="string"||n.length===0)throw new Error(`${t} is missing version`);if(!Rn(r))throw new Error(`${t} is missing hubSkeleton`);if(typeof r.url!="string"||r.url.length===0)throw new Error(`${t} is missing hubSkeleton.url`);if(typeof r.integrity!="string"||r.integrity.length===0)throw new Error(`${t} is missing hubSkeleton.integrity`);if(typeof r.version!="number")throw new Error(`${t} is missing hubSkeleton.version`);let i=typeof r.bytes=="number"?r.bytes:void 0;return{version:n,hubSkeleton:{version:r.version,url:r.url,integrity:r.integrity,bytes:i}}}function ed(e,t){if(!Rn(e))throw new Error(`${t} is not an object`);if(e.version!==1)throw new Error(`${t} has unsupported skeleton version`);if(typeof e.runtime!="string"||e.runtime.length===0)throw new Error(`${t} is missing runtime`);if(!Array.isArray(e.files))throw new Error(`${t} is missing files`);let n=e.files.map((r,i)=>{if(!Rn(r))throw new Error(`${t} files[${i}] is not an object`);if(typeof r.path!="string"||r.path.length===0)throw new Error(`${t} files[${i}].path is missing`);if(typeof r.contents!="string")throw new Error(`${t} files[${i}].contents is missing`);return{path:r.path,contents:r.contents}});return{version:1,runtime:e.runtime,files:n}}function td(e,t,n){return e.split(t).join(n)}function nd(e){if(e.startsWith("/")||e.startsWith("\\")||/^[A-Za-z]:/.test(e)||e.includes("\\")||e.split("/").some(t=>t===".."||t.length===0))throw new Error(`Unsafe skeleton path from runtime manifest: ${e}`)}function rd(e,t){let n=e.runtime,r=se(),i=[["{{hubName}}",t.hubName],["{{hubNameJson}}",JSON.stringify(t.hubName)],["{{runtimeVersionJson}}",JSON.stringify(n)],["{{layoutEntry}}",t.layout===void 0?"":` "layout": ${JSON.stringify(t.layout)},
|
|
4988
|
+
`],["{{themeJson}}",JSON.stringify(t.theme??"inkly")],["{{starterDemoIdJson}}",JSON.stringify(r)]],a=e.files.map(u=>{nd(u.path);let p=u.contents;for(let[h,f]of i)p=td(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=a.find(u=>u.path==="inkly.json");if(!o)throw new Error("Runtime skeleton is missing inkly.json");let s=we.safeParse(JSON.parse(o.contents));if(!s.success)throw new Error(`Runtime skeleton inkly.json is invalid: ${s.error.message}`);let c=a.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=mt.safeParse(JSON.parse(c.contents));if(!d.success)throw new Error(`Runtime skeleton starter demo is invalid: ${d.error.message}`);return a}async function id(e){let{latestUrl:t,fetchImpl:n}=e,r=await ua(t,n),i=Qc(r.json,t),a=new URL(i.hubSkeleton.url,t).toString(),o=await ua(a,n);if(!Lt(o.bytes,i.hubSkeleton.integrity))throw new Error(`integrity mismatch for hub-skeleton.json from ${a}`);if(typeof i.hubSkeleton.bytes=="number"&&o.bytes.byteLength!==i.hubSkeleton.bytes)throw new Error(`byte length mismatch for hub-skeleton.json from ${a}`);let s=ed(o.json,a);if(s.runtime!==i.version)throw new Error(`runtime/latest.json points at ${i.version}, but hub-skeleton.json declares ${s.runtime}`);return s}async function pa(e){let{name:t,cwd:n,layout:r,theme:i,silent:a}=e,o=Re(t);if(!o.ok)throw new Error(o.reason);let s=r===void 0?void 0:pr.safeParse(r);if(s&&!s.success)throw new Error("Invalid layout. Expected one of: sidebar, tabs.");if(i!==void 0){if(i.length===0)throw new Error("Invalid theme. Expected a theme preset id.");if(!pe[i]){let f=Object.keys(pe).join(", ");throw new Error(`Invalid theme "${i}". Expected one of: ${f}.`)}}let c=Kc(n,t);if(await qc(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 id({latestUrl:e.runtimeManifestUrl??Yc(),fetchImpl:Xc(e.fetchImpl)}),p=rd(u,{hubName:t,layout:s?.data,theme:i});await la(c,{recursive:!0}),await Promise.all(p.map(async f=>{let w=da(f.path),x=Gc(c,w);await la(Zc(x),{recursive:!0}),await Jc(x,f.contents,"utf8")}));let h=!1;try{let f=await En({cwd:c,silent:!0,fetchImpl:e.fetchImpl});h=f.ok&&f.lockPath!==null}catch{}return a||(process.stdout.write(`Scaffolded hub ${t} at ${c}
|
|
4972
4989
|
|
|
4973
4990
|
Next steps:
|
|
4974
|
-
cd ${
|
|
4991
|
+
cd ${t}
|
|
4975
4992
|
inkly dev
|
|
4976
4993
|
open http://localhost:3000
|
|
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=>
|
|
4978
|
-
`)}var
|
|
4979
|
-
${
|
|
4994
|
+
`),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=>da(f.path))}}import{createServer as sd}from"vite";import ld from"chokidar";import{readFile as me,readdir as cd,stat as nn,mkdtemp as dd,mkdir as ud,cp as pd,writeFile as hd,rm as md}from"fs/promises";import{existsSync as xt,createReadStream as fd}from"fs";import{tmpdir as gd}from"os";import{basename as bd,dirname as kt,extname as yd,join as j,relative as xd,resolve as Je,sep as Nn}from"path";import{fileURLToPath as wa}from"url";import{createRequire as kd}from"module";import{createConnection as wd,createServer as vd}from"net";import{readFile as ha,stat as ad}from"fs/promises";import{relative as od}from"path";async function $n(e){let t=await De(e);if(!t)throw new Error(`No inkly.json found in ${e} or any parent directory. Run \`inkly init <name>\` first or cd into your hub.`);let n=[],r=[],i=[],a=[];for(let s of await fr(t)){let c;try{c=await ha(s.configPath,"utf8")}catch(h){i.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){i.push({slug:s.slug,configPath:s.configPath,message:`demo.config.json is not valid JSON (${h.message})`});continue}let u;try{u=$t(d)}catch(h){i.push({slug:s.slug,configPath:s.configPath,message:`demo.config.json failed schema validation: ${h.message}`});continue}u.changed&&(await ma(s.configPath,u.config),n.push({slug:s.slug,configPath:s.configPath,reason:"heal"}));let p=(await ad(s.configPath)).mtimeMs;a.push({slug:s.slug,configPath:s.configPath,id:u.config.id,mtimeMs:p})}let o=Ki(a.map(s=>({...s,updatedAt:s.mtimeMs})));for(let{entry:s,newId:c}of o){let d=await ha(s.configPath,"utf8"),u=JSON.parse(d);u.id=c,await ma(s.configPath,u),r.push({slug:s.slug,configPath:s.configPath,reason:"remint"})}return{hubRoot:t,healed:n,reminted:r,skipped:i}}function en(e,t){return od(e,t).split(/[\\/]/).join("/")}async function ma(e,t){await te(e,JSON.stringify(t,null,2)+`
|
|
4995
|
+
`)}var Sd=wa(import.meta.url),Ut=kt(Sd),_r="127.0.0.1";function fa(e){let t=Je(Ut,"template",e);return xt(t)?t:Je(Ut,"..","..","template",e)}function _d(e){let t=[Je(Ut,"..","vendor",e),Je(Ut,"..","..","vendor",e),Je(Ut,"..","..","..","public","__inkly","vendor",e)];for(let n of t)if(xt(n))return n;return null}function Cd(e){try{let r=kd(j(e,"package.json")).resolve("@inkly/runtime/package.json");return Je(kt(r),"dist")}catch{}let t=Ut;for(let n=0;n<8;n++){let r=j(t,"packages","inkly-runtime","dist");if(xt(r))return r;let i=kt(t);if(i===t)break;t=i}return null}function ga(e,t){if(!t)return e;let{integrity:n}=t.lock.runtime,r=t.manifest.cssIntegrity,i=e;i=i.replace(/<link rel="stylesheet" href="\/__inkly\/runtime\.css" \/>/,`<link rel="stylesheet" href="/__inkly/runtime.css" integrity="${r}" crossorigin="anonymous" />`);let a=`<link rel="modulepreload" href="/__inkly/runtime.js" integrity="${n}" crossorigin="anonymous" />`;return/<link rel="prefetch" href="\/__inkly\/runtime\.js"[^>]*\/>/.test(i)?i=i.replace(/<link rel="prefetch" href="\/__inkly\/runtime\.js"[^>]*\/>/,a):i=i.replace(/<link rel="stylesheet" href="\/__inkly\/runtime\.css"[^>]*\/>/,o=>`${o}
|
|
4996
|
+
${a}`),i}function H(e,t,n,r){e.statusCode=t,e.setHeader("content-type",n),e.setHeader("cache-control","no-store"),e.end(r)}function rn(e,t,n){e.statusCode=200,e.setHeader("content-type",n),e.setHeader("cache-control","no-store");let r=fd(t);r.on("error",i=>{e.statusCode=500,e.end(`Failed to read ${t}: ${i.message}`)}),r.pipe(e)}var ba=`Inkly runtime artifact not found. Run:
|
|
4980
4997
|
npm run build:runtime -w @inkly/runtime
|
|
4981
4998
|
then restart \`inkly dev\`.
|
|
4982
|
-
`;function
|
|
4983
|
-
${
|
|
4984
|
-
</head>`)}function
|
|
4985
|
-
`),{hubRoot:r,slug:n}}async function
|
|
4986
|
-
`)},o=
|
|
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
|
|
4988
|
-
`);for(let
|
|
4989
|
-
`)}let u=await
|
|
4999
|
+
`;function Td(e){let t=Je(e);for(;;){if(xt(j(t,"inkly.json")))return t;let n=kt(t);if(n===t)return null;t=n}}function ya(e){if(!e)return null;let t=e.trim();return t?/^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i.test(t)||t.startsWith("/")?t:t.startsWith("public/")?`/${t.slice(7)}`:`/${t.replace(/^\.\/+/,"")}`:null}function Cr(e){return e.brand?{...e,brand:{...e.brand,...e.brand.logo?{logo:ya(e.brand.logo)??e.brand.logo}:{},...e.brand.favicon?{favicon:ya(e.brand.favicon)??e.brand.favicon}:{}}}:e}function va(e,t){return e.publicUrl&&/^(https?:)?\/\//i.test(e.publicUrl)?e.publicUrl:e.file?`/${t}/${e.file}`:e.publicUrl??null}function Ad(e){let t=new Map(e.assets.map(n=>[n.id,n]));return Yi({slug:e.slug,config:e.config,resolveAssetSrc:n=>{if(!n.startsWith("asset:"))return n;let r=t.get(n.slice(6));return r?va(r,e.slug):null}})}async function Id(e){let t=j(kt(e),"assets.json");try{let n=await me(t,"utf8"),r=JSON.parse(n);return Array.isArray(r.assets)?r.assets.filter(i=>{if(!i||typeof i!="object")return!1;let a=i;return typeof a.id=="string"&&a.id.length>0}):[]}catch{return[]}}async function Pd(e){let t=j(e,"demos");if(!xt(t))return[];let n=[];async function r(i){let a;try{a=await cd(i,{withFileTypes:!0})}catch{return}if(a.some(s=>s.isFile()&&s.name==="demo.config.json")){let s=xd(t,i).split(Nn).join("/");n.push({slug:s,configPath:j(i,"demo.config.json")});return}for(let s of a)s.isDirectory()&&await r(j(i,s.name))}return await r(t),n}async function xa(e,t){let n=j(e,"inkly.json"),r;try{r=await me(n,"utf8")}catch(p){throw new Error(`Failed to read inkly.json at ${n}: ${p.message}`)}let i;try{i=JSON.parse(r)}catch(p){throw new Error(`inkly.json is not valid JSON: ${p.message}`)}let a=we.safeParse(i);if(!a.success)throw new Error(`inkly.json failed schema validation:
|
|
5000
|
+
${a.error.message}`);let o=a.data,s=await Pd(e);for(let p of s){let h=an(p.slug);if(!h.ok)throw new Error(`Demo folder "${p.slug}" has an invalid slug: ${h.reason}`);if(gt.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 me(p.configPath,"utf8")}catch(x){t(`Skipping ${p.slug}: failed to read demo.config.json (${x.message})`);continue}let f;try{f=JSON.parse(h)}catch(x){t(`Skipping ${p.slug}: demo.config.json is not valid JSON (${x.message})`);continue}let w;try{w=$t(f).config}catch(x){t(`Skipping ${p.slug}: demo.config.json failed schema validation: ${x.message}`);continue}c.push({slug:p.slug,configPath:p.configPath,config:w,assets:await Id(p.configPath)})}let d=c.map(p=>Ad(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 Dn(e,t,n){let r=JSON.stringify(n).replace(/<\/(script)/gi,"<\\/$1"),i=`<script id="${t}" type="application/json">${r}</script>`;return e.includes(`id="${t}"`)?e.replace(new RegExp(`<script id="${t}"[^>]*>[\\s\\S]*?</script>`),i):e.replace("</head>",`${i}
|
|
5001
|
+
</head>`)}function Ed(e){let t=e.hub.theme??"inkly",n=pe[t];return{hub:Cr(e.hub),demos:e.index,theme:{id:t,tokens:n?.theme??null,css:n?.css??""}}}var Rd={".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 tn(e){return Rd[yd(e).toLowerCase()]??"application/octet-stream"}function an(e){let t=e.split("/").filter(Boolean);if(t.length===0)return{ok:!1,reason:"Name cannot be empty."};for(let n of t){let r=Re(n);if(!r.ok)return r}return gt.includes(e)?{ok:!1,reason:`Demo folder "${e}" uses a reserved slug.`}:{ok:!0}}function ka(e,t){let n;try{n=decodeURIComponent(e)}catch{return null}let r=n.replace(/^\/+/,"").replace(/\/+$/,"");if(!r)return null;let i=r.split("/").filter(Boolean);for(let a=i.length;a>=1;a-=1){let o=i.slice(0,a).join("/");if(!an(o).ok)continue;let s=t.bySlug.get(o);if(s)return{slug:o,demo:s,rel:i.slice(a).join("/")}}return null}async function $d(e){return new Promise(t=>{let n=vd();n.once("error",()=>t(!1)),n.once("listening",()=>{n.close(()=>t(!0))}),n.listen(e,_r)})}async function Dd(e,t){return new Promise(n=>{let r=!1,i=o=>{r||(r=!0,a.destroy(),n(o))},a=wd({port:e,host:t});a.setTimeout(250),a.once("connect",()=>i(!0)),a.once("timeout",()=>i(!1)),a.once("error",()=>i(!1))})}async function Nd(e){if(!await $d(e))return!1;for(let t of["localhost","127.0.0.1","::1"])if(await Dd(e,t))return!1;return!0}async function Md(e){if(e===0)return 0;if(!Number.isInteger(e)||e<0||e>65535)throw new Error(`invalid port: ${e}`);for(let t=e;t<=65535;t+=1)if(await Nd(t))return t;throw new Error(`No available port found at or above ${e}`)}function Ld(e,t){let n=e.httpServer?.address();return n&&typeof n=="object"?n.port:e.config.server.port??t}async function Od(e){let t=bd(e),n=/^[a-z0-9][a-z0-9-]*$/.test(t)&&!gt.includes(t)?t:"demo",r=await dd(j(gd(),"inkly-dev-"));await ud(j(r,"demos"),{recursive:!0}),await pd(e,j(r,"demos",n),{recursive:!0});let i=n;try{let o=JSON.parse(await me(j(e,"demo.config.json"),"utf8"));typeof o.title=="string"&&o.title.trim()&&(i=o.title.trim())}catch{}let a={$schema:"https://inklyai.dev/inkly.json",name:i,runtime:"0.6.2",theme:"inkly",collections:[{name:"Preview",demos:[n]}]};return await hd(j(r,"inkly.json"),`${JSON.stringify(a,null,2)}
|
|
5002
|
+
`),{hubRoot:r,slug:n}}async function Sa(e){let{cwd:t,port:n=3e3,silent:r,skipRuntimeResolve:i}=e,a=L=>{r||process.stderr.write(`[inkly dev] ${L}
|
|
5003
|
+
`)},o=e.path?Je(t,e.path):t,s=Td(o),c=null;if(!s)if(xt(j(o,"demo.config.json"))){let L=await Od(o);s=L.hubRoot,c=L.hubRoot,r||process.stdout.write(`[inkly dev] serving standalone demo "${L.slug}" via a temporary hub (no inkly.json required)
|
|
5004
|
+
`)}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 $n(s);if(!r){for(let L of d.healed)process.stdout.write(`[inkly dev] healed missing id: ${en(d.hubRoot,L.configPath)}
|
|
5005
|
+
`);for(let L of d.reminted)process.stdout.write(`[inkly dev] re-minted duplicate id: ${en(d.hubRoot,L.configPath)}
|
|
5006
|
+
`)}let u=await xa(s,a),p=j(s,"inkly.lock"),h=xt(p),f=null;if(h&&!i)try{if(f=await wr({hubRoot:s}),!r)if(f.fetched){let L=(f.bytesFetched/1048576).toFixed(2);process.stdout.write(`[inkly dev] fetched runtime ${f.version} from ${f.lock.runtime.url} (${L} MiB)
|
|
4990
5007
|
`)}else process.stdout.write(`[inkly dev] runtime ${f.version} loaded from cache (${f.cacheDir})
|
|
4991
|
-
`)}catch(
|
|
4992
|
-
`)}}catch(
|
|
4993
|
-
`)}let w=f?.cacheDir??
|
|
4994
|
-
`);return}
|
|
4995
|
-
`);return}}
|
|
5008
|
+
`)}catch(L){throw L instanceof bt||L instanceof Ot?L:new Error(`Failed to resolve runtime via inkly.lock: ${L.message}`)}else if(!i)try{let{lock:L,source:K}=await Pn(s);if(f=await wr({hubRoot:s,lock:L}),!r){let ge=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 ${K==="cdn"?"the CDN":"a local build"} (${ge}). Run \`inkly lock\` to pin this version.
|
|
5009
|
+
`)}}catch(L){r||process.stdout.write(`[inkly dev] no inkly.lock and could not resolve a published runtime (${L.message}). Falling back to the in-workspace @inkly/runtime dist. Run \`inkly lock\` once a runtime is published to R2 to pin a version.
|
|
5010
|
+
`)}let w=f?.cacheDir??Cd(s),x=ga(await me(fa("hub-index.html"),"utf8"),f),_=ga(await me(fa("demo.html"),"utf8"),f),P=await Md(n),$=P,R=async()=>{},b=await sd({root:s,server:{port:P,strictPort:!0,host:_r,hmr:{host:_r},fs:{allow:[s,wa(new URL("../",import.meta.url))]}},appType:"custom",clearScreen:!1,logLevel:r?"silent":"info",configFile:!1,plugins:[{name:"inkly-dev-endpoints",configureServer(L){let K=(ge,A,le)=>{let N=(ge.url??"").split("?")[0]??"";if(N==="/"||N==="/index.html"){let E=Dn(x,"__inkly_hub_data",Ed(u));H(A,200,"text/html; charset=utf-8",E);return}if(N.startsWith("/__inkly/cache/")){let E=decodeURIComponent(N.slice(15));if(!E||E.includes("..")||E.includes("/")){H(A,400,"text/plain; charset=utf-8","Invalid cache path");return}let F=j(s,".inkly","cache",E);nn(F).then(M=>{if(!M.isFile()){H(A,404,"text/plain; charset=utf-8",`Capture not found: ${E}`);return}rn(A,F,tn(F))},()=>H(A,404,"text/plain; charset=utf-8",`Capture not found: ${E}`));return}if(N.startsWith("/__inkly/snapshot/")){let E=decodeURIComponent(N.slice(18)),M=E.indexOf("/snapshots/"),J=M>0?E.slice(0,M):"",ee=M>0?E.slice(M+1):"";if(!an(J).ok||!u.bySlug.has(J)||!ee||ee.includes("..")||ee.startsWith("/")){H(A,400,"text/plain; charset=utf-8","Invalid snapshot path");return}if(!ee.startsWith("snapshots/")){H(A,400,"text/plain; charset=utf-8","Invalid snapshot path");return}let Te=j(s,"demos",...J.split("/")),be=j(Te,ee);if(!be.startsWith(Te+Nn)&&be!==Te){H(A,400,"text/plain; charset=utf-8","Invalid snapshot path");return}nn(be).then(async Jt=>{if(!Jt.isFile()){H(A,404,"text/plain; charset=utf-8",`Snapshot not found: ${ee}`);return}if(!/\.html?$/i.test(ee)){let Bo=await me(be,"utf8");H(A,200,tn(be),ft(Bo));return}let oe=mr(ee),qt=oe?j(Te,oe):null,[Qn,Zt]=await Promise.all([me(be,"utf8"),qt?me(qt,"utf8").catch(()=>null):Promise.resolve(null)]),mn=Xi({htmlPath:ee,html:Qn,css:Zt,cssHref:oe?`/__inkly/snapshot/${encodeURIComponent(J)}/${oe.split("/").map(encodeURIComponent).join("/")}`:null});H(A,200,tn(be),mn)},()=>H(A,404,"text/plain; charset=utf-8",`Snapshot not found: ${ee}`));return}if(N==="/__inkly/hub"){H(A,200,"application/json; charset=utf-8",JSON.stringify(Cr(u.hub)));return}if(N==="/__inkly/demos"){H(A,200,"application/json; charset=utf-8",JSON.stringify(u.index));return}if(N.startsWith("/__inkly/demo/")){let E=decodeURIComponent(N.slice(14)),F=an(E);if(!F.ok){H(A,400,"text/plain; charset=utf-8",F.reason);return}let M=u.bySlug.get(E);if(!M){H(A,404,"text/plain; charset=utf-8",`No such demo: ${E}`);return}let J=j(kt(M.configPath),"assets.json");me(J,"utf8").then(ee=>{let Vt=[];try{let Te=JSON.parse(ee);Array.isArray(Te.assets)&&(Vt=Te.assets)}catch{}H(A,200,"application/json; charset=utf-8",JSON.stringify({demo:M.config,assets:Vt}))},()=>{H(A,200,"application/json; charset=utf-8",JSON.stringify({demo:M.config,assets:[]}))});return}if(N==="/__inkly/runtime.js"){Sr(A,w,"runtime.js","text/javascript; charset=utf-8");return}if(N==="/__inkly/runtime.css"){Sr(A,w,"runtime.css","text/css; charset=utf-8");return}if(N==="/__inkly/manifest.json"){Sr(A,w,"manifest.json","application/json; charset=utf-8");return}if(N.startsWith("/__inkly/vendor/")){let E=decodeURIComponent(N.slice(16));if(!/^(react|react-dom|react-dom-client|react-jsx-runtime)\.mjs$/.test(E)){H(A,404,"text/plain; charset=utf-8",`No such vendor module: ${E}`);return}let F=_d(E);if(!F){H(A,503,"text/plain; charset=utf-8",`Runtime vendor module not found: ${E}`);return}rn(A,F,"text/javascript; charset=utf-8");return}if(N.startsWith("/__inkly/theme/")&&N.endsWith(".css")){let E=decodeURIComponent(N.slice(15,-4)),F=pe[E];if(!F){let M=Object.keys(pe).join(", ");H(A,404,"text/plain; charset=utf-8",`No such theme: "${E}". Known themes: ${M}
|
|
5011
|
+
`);return}H(A,200,"text/css; charset=utf-8",F.css??"");return}let O=N.startsWith("/__inkly/")?null:ka(N,u);if(O&&O.rel){let{slug:E,rel:F}=O;if(F.includes("..")||F.startsWith("/")){H(A,400,"text/plain; charset=utf-8","Invalid path");return}let M=j(s,"demos",...E.split("/"),"public"),J=j(M,F);if(!J.startsWith(M+Nn)&&J!==M){H(A,400,"text/plain; charset=utf-8","Invalid path");return}nn(J).then(ee=>{if(!ee.isFile()){le();return}rn(A,J,tn(J))},()=>le());return}if(N.length>1&&!N.startsWith("/__inkly/")&&!N.endsWith("/")){let E=decodeURIComponent(N.slice(1)),F=j(s,"public"),M=j(F,E);if(!E.includes("..")&&(M.startsWith(F+Nn)||M===F)){nn(M).then(J=>{if(J.isFile()){rn(A,M,tn(M));return}vt()},()=>vt());return}}vt();function vt(){if(N.length>1&&!N.startsWith("/__inkly/")){let E=N.replace(/^\/+/,"").replace(/\/+$/,""),F=ka(N,u);if(F&&F.rel===""){let{slug:M,demo:J}=F;if(!an(M).ok){le();return}let Vt={hub:{name:u.hub.name,brand:Cr(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},Te=j(kt(J.configPath),"assets.json"),be=Jt=>{let oe=Dn(_,"__inkly_hub_meta",Vt);oe=Dn(oe,"__inkly_demo_config",J.config),oe=Dn(oe,"__inkly_demo_assets",Jt),H(A,200,"text/html; charset=utf-8",oe)};me(Te,"utf8").then(Jt=>{let oe=[];try{let qt=JSON.parse(Jt);Array.isArray(qt.assets)&&(oe=qt.assets.map(Qn=>{let Zt=Qn,mn=va(Zt,M);return mn?{...Zt,publicUrl:mn}:Zt}))}catch{}be(oe)},()=>{be([])});return}if(E&&!E.includes("/")){if(!Re(E).ok){le();return}H(A,404,"text/plain; charset=utf-8",`No such demo: "${E}". Known demos: ${[...u.bySlug.keys()].join(", ")||"(none)"}
|
|
5012
|
+
`);return}}le()}};L.middlewares.use(K)}}]});await b.listen(),$=Ld(b,P);let U=`http://127.0.0.1:${$}/`,z=`http://localhost:${$}/`,D=ld.watch([j(s,"inkly.json"),j(s,"demos/**/demo.config.json"),j(s,"demos/**/assets.json")],{ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:60,pollInterval:20}}),V=!1,ne=async()=>{if(!V){V=!0;try{u=await xa(s,a);try{b.ws.send({type:"custom",event:"inkly:hub-changed"}),b.ws.send({type:"full-reload"})}catch{}}catch(L){a(`Reload failed: ${L.message}`)}finally{V=!1}}};if(R=ne,D.on("add",ne),D.on("change",ne),D.on("unlink",ne),!r){let L=u.hub.collections?.length??0,K=[...u.bySlug.keys()],ge=10,A=K.length>0?`
|
|
4996
5013
|
demos:
|
|
4997
|
-
`+
|
|
4998
|
-
`)+(
|
|
4999
|
-
\u2026and ${
|
|
5014
|
+
`+K.slice(0,ge).map(le=>` ${z}${le}`).join(`
|
|
5015
|
+
`)+(K.length>ge?`
|
|
5016
|
+
\u2026and ${K.length-ge} more`:""):"";process.stdout.write(`
|
|
5000
5017
|
inkly dev running at ${z}
|
|
5001
5018
|
hub: ${u.hub.name}
|
|
5002
|
-
demos: ${u.demos.length} in ${
|
|
5019
|
+
demos: ${u.demos.length} in ${L} collection(s)${A}
|
|
5003
5020
|
watching ${s}
|
|
5004
5021
|
|
|
5005
|
-
`)}let
|
|
5006
|
-
`),w&&await
|
|
5007
|
-
`),!
|
|
5008
|
-
`;b+=` id: ${
|
|
5022
|
+
`)}let Ce=!1;return{url:U,port:$,server:b,hubRoot:s,close:async()=>{Ce||(Ce=!0,await D.close(),await b.close(),c&&await md(c,{recursive:!0,force:!0}).catch(()=>{}))}}}function Sr(e,t,n,r){if(!t){H(e,503,"text/plain; charset=utf-8",ba);return}let i=j(t,n);nn(i).then(()=>rn(e,i,r),()=>H(e,503,"text/plain; charset=utf-8",`${ba}(missing: ${n})`))}import{mkdir as jd,access as Ca,readFile as Ud}from"fs/promises";import{dirname as zd,join as Mn,resolve as Fd}from"path";function Tr(e){return e.split("-").filter(t=>t.length>0).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function _a(e,t){return{id:se(),version:1,title:t??Tr(e),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 Hd(e){let t=Fd(e);for(;;){let n=Mn(t,"inkly.json");if(await Ca(n).then(()=>!0,()=>!1))return t;let i=zd(t);if(i===t)return null;t=i}}async function Ta(e){let{slug:t,cwd:n,collection:r,silent:i}=e,a=await Hd(n);if(!a)throw new Error("Not inside a hub. Run `inkly init <name>` first.");let o=Re(t);if(!o.ok)throw new Error(o.reason);let s=Mn(a,"inkly.json"),c=await Ud(s,"utf8"),d;try{d=JSON.parse(c)}catch(b){throw new Error(`Failed to parse inkly.json: ${b.message}`)}let u=we.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=Mn(a,"demos",t);if(await Ca(h).then(()=>!0,()=>!1))throw new Error(`Demo already exists: demos/${t}. Choose a different slug or remove it first.`);let w,x=p,_=p.collections??[];if(r){let b={...p,collections:_.map(z=>({...z,demos:[...z.demos]}))},U=b.collections.find(z=>z.name===r);U?U.demos.push(t):b.collections.push({name:r,demos:[t]}),x=b,w=r}if(w){let b=we.safeParse(x);if(!b.success)throw new Error(`Internal error: updated inkly.json failed schema validation. ${b.error.message}`)}let P=se(),$={..._a(t,Tr(t)),id:P},R=mt.safeParse($);if(!R.success)throw new Error(`Internal error: scaffolded demo failed schema validation. ${R.error.message}`);if(await jd(h,{recursive:!0}),await te(Mn(h,"demo.config.json"),JSON.stringify($,null,2)+`
|
|
5023
|
+
`),w&&await te(s,JSON.stringify(x,null,2)+`
|
|
5024
|
+
`),!i){let b=`Added ${h}
|
|
5025
|
+
`;b+=` id: ${P}
|
|
5009
5026
|
`,w&&(b+=`Added to collection "${w}" in inkly.json
|
|
5010
5027
|
`),b+=`Next: inkly dev
|
|
5011
|
-
`,process.stdout.write(b)}return{hubRoot:
|
|
5012
|
-
`);else if(
|
|
5013
|
-
`);else{for(let o of
|
|
5014
|
-
`);process.stdout.write(`inkly validate failed (${r} errors, ${
|
|
5015
|
-
`)}return
|
|
5016
|
-
`)}return
|
|
5017
|
-
`);return}await new Promise((r,
|
|
5018
|
-
`,{mode:384})}async function
|
|
5019
|
-
`);else{for(let d of
|
|
5028
|
+
`,process.stdout.write(b)}return{hubRoot:a,demoDir:h,collectionModified:w,id:P}}import{readdir as Bd}from"fs/promises";import{join as Wd}from"path";function Ne(e,t,n,r){e.push({level:t,file:n,message:r})}function Ar(e,t){if(typeof e=="string"){e.startsWith("asset:")&&t.add(e.slice(6));return}if(!(!e||typeof e!="object")){if(Array.isArray(e)){for(let n of e)Ar(n,t);return}for(let n of Object.values(e))Ar(n,t)}}async function Ln(e){let t=[],n=null;try{let o=await Mt(e.cwd);n=o.root,o.inkly.theme&&!pe[o.inkly.theme]&&Ne(t,"error","inkly.json",`Unknown theme "${o.inkly.theme}". Known themes: ${Object.keys(pe).join(", ")}.`);let s=new Set(o.demos.map(d=>d.slug)),c=new Map;for(let d of o.demos){let u=gr(d.slug);u&&Ne(t,"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&&!pe[d.config.theme.preset]&&Ne(t,"error",`demos/${d.slug}/demo.config.json`,`Unknown demo theme preset "${d.config.theme.preset}".`);let h=new Set;Ar(d.config,h);let f=new Set((d.assets?.assets??[]).map(w=>w.id));for(let w of h)f.has(w)||Ne(t,"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 Vd(o.root,w.sha256)).length===0&&!Jd(w)&&Ne(t,"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)Ne(t,"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=gr(u);if(p){Ne(t,"error","inkly.json",`Collection "${d.name}" references invalid slug "${u}": ${p}`);continue}s.has(u)||Ne(t,"warning","inkly.json",`Collection "${d.name}" references missing demo "${u}".`)}}catch(o){Ne(t,"error","hub",o.message)}let r=t.filter(o=>o.level==="error").length,i=t.filter(o=>o.level==="warning").length,a={ok:r===0&&(!e.strict||i===0),hubRoot:n,errors:r,warnings:i,issues:t};if(!e.silent)if(e.json)process.stdout.write(JSON.stringify(a,null,2)+`
|
|
5029
|
+
`);else if(a.ok)process.stdout.write(`inkly validate passed (${r} errors, ${i} warnings)
|
|
5030
|
+
`);else{for(let o of t)process.stdout.write(`${o.level.toUpperCase()} ${o.file}: ${o.message}
|
|
5031
|
+
`);process.stdout.write(`inkly validate failed (${r} errors, ${i} warnings)
|
|
5032
|
+
`)}return a}async function Vd(e,t){let n=Wd(e,".inkly","cache");if(!await q(n))return[];try{return(await Bd(n)).filter(i=>i.startsWith(`${t}.`))}catch{return[]}}function Jd(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.publicUrl=="string"||typeof t.cdnPath=="string"}import{readFile as qd}from"fs/promises";import{existsSync as Zd}from"fs";import{dirname as Ir,join as Aa}from"path";import{fileURLToPath as Gd}from"url";async function Pr(){let e=Ir(Gd(import.meta.url));for(let t=0;t<5;t+=1){let n=Aa(e,"package.json");try{let i=JSON.parse(await qd(n,"utf8"));if(typeof i.version=="string"){let a=Zd(Aa(Ir(n),"src"));return{version:i.version,packagePath:n,isLocalBuild:a}}}catch{}let r=Ir(e);if(r===e)break;e=r}return{version:"0.0.0-unknown",packagePath:null,isLocalBuild:!1}}async function Er(e={}){let t=await Pr();if(!e.silent){let n=t.isLocalBuild?" (local build)":"";process.stdout.write(`${t.version}${n}
|
|
5033
|
+
`)}return t}import{spawn as Kd}from"child_process";async function Ia(e={}){let t=e.packageName??"@inkly-org/cli@latest",n=process.env.npm_execpath?[process.execPath,process.env.npm_execpath,"install","-g",t]:["npm","install","-g",t];if(e.dryRun){e.silent||process.stdout.write(`${n.join(" ")}
|
|
5034
|
+
`);return}await new Promise((r,i)=>{let a=Kd(n[0],n.slice(1),{stdio:"inherit"});a.on("error",i),a.on("exit",o=>{o===0?r():i(new Error(`Update failed with exit code ${o??"unknown"}`))})})}import{join as Ra}from"path";import{readFile as Yd,rm as Xd}from"fs/promises";import{join as Qd}from"path";import{homedir as eu}from"os";var Rr="https://app.inklyai.dev",Pa="http://localhost:3000",Me=Qd(eu(),".inkly","config.json");async function qe(){try{let e=await Yd(Me,"utf8"),t=JSON.parse(e);return{apiBase:typeof t.apiBase=="string"?t.apiBase:void 0,token:typeof t.token=="string"?t.token:void 0}}catch{return{}}}async function $r(e){await te(Me,JSON.stringify(e,null,2)+`
|
|
5035
|
+
`,{mode:384})}async function Ea(){await Xd(Me,{force:!0})}function Ze(e){return(e||Rr).replace(/\/+$/,"")}async function $a(e){let t=[],n=await Pr();t.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);t.push({name:"node",ok:r>=20,message:process.version});let i=await De(e.cwd);t.push({name:"hub-root",ok:!!i,message:i??"No inkly.json found."});let a=await qe();t.push({name:"login",ok:!!a.token,message:a.token?`Configured for ${a.apiBase??"(default API)"}`:"Not logged in."});let o=[],s=null;if(i){let d=await $n(i);s={healed:d.healed.length,reminted:d.reminted.length,paths:[...d.healed,...d.reminted].map(f=>en(d.hubRoot,f.configPath))},t.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 Ln({cwd:i,silent:!0});o=u.issues,t.push({name:"schema",ok:u.ok,message:`${u.errors} errors, ${u.warnings} warnings`});let p=await q(Ra(i,".inkly","cache"));t.push({name:"local-cache",ok:!0,message:p?".inkly/cache exists":".inkly/cache not present yet"});let h=await In(Ra(i,"node_modules","@inkly","runtime","dist","runtime.js"));h!==null&&t.push({name:"runtime-artifact",ok:!0,message:`${h} bytes`})}let c={ok:t.every(d=>d.ok||d.name==="login"),checks:t,validationIssues:o,demoIds:s};if(!e.silent)if(e.json)process.stdout.write(JSON.stringify(c,null,2)+`
|
|
5036
|
+
`);else{for(let d of t)process.stdout.write(`${d.ok?"OK":"WARN"} ${d.name}: ${d.message}
|
|
5020
5037
|
`);if(s&&s.paths.length>0)for(let d of s.paths)process.stdout.write(` fixed id in ${d}
|
|
5021
5038
|
`);if(o.length>0)for(let d of o)process.stdout.write(`${d.level.toUpperCase()} ${d.file}: ${d.message}
|
|
5022
|
-
`)}return c}import{randomBytes as
|
|
5023
|
-
`,{encoding:"utf8",mode:384})}async function
|
|
5024
|
-
`),{apiBase:
|
|
5025
|
-
`),{apiBase:r.apiBase,configPath:
|
|
5026
|
-
`)}async function
|
|
5027
|
-
`):(process.stdout.write(`Config: ${
|
|
5039
|
+
`)}return c}import{randomBytes as mu}from"crypto";import{createServer as fu}from"http";import{spawn as gu}from"child_process";import{randomUUID as tu}from"crypto";import{mkdir as nu,readFile as ru,writeFile as iu}from"fs/promises";import{dirname as au,join as ou}from"path";import{homedir as su}from"os";import{PostHog as lu}from"posthog-node";var Da=process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN??process.env.POSTHOG_PROJECT_TOKEN??"phc_Dmh4w8YFNosi3YHD4Sv7ShHX7ccS8kmtRcm8XSVmB5jT",cu=process.env.NEXT_PUBLIC_POSTHOG_HOST??process.env.POSTHOG_HOST??"https://us.i.posthog.com",du="@inkly-org/cli@0.5.1",Dr=ou(su(),".inkly","analytics.json"),jn=null,On=null,zt=null;function uu(){return!!Da&&process.env.INKLY_TELEMETRY_DISABLED!=="1"}function Na(){return uu()?(jn??=new lu(Da,{host:cu,flushAt:1,flushInterval:0}),jn):null}async function Nr(){try{let e=await ru(Dr,"utf8");return JSON.parse(e)}catch{return{}}}async function Mr(e){await nu(au(Dr),{recursive:!0}),await iu(Dr,JSON.stringify(e,null,2)+`
|
|
5040
|
+
`,{encoding:"utf8",mode:384})}async function Ma(){return On||(On=(async()=>{let e=await Nr();if(typeof e.platformUserId=="string"&&e.platformUserId&&(zt=e.platformUserId),typeof e.distinctId=="string"&&e.distinctId)return e.distinctId;let t=`cli_${tu()}`;return await Mr({...e,distinctId:t}),t})(),On)}async function pu(){let e=await Ma();return zt??e}async function Lr(e){if(!e||zt===e){e&&(zt=e);return}let t=Na();try{let n=await Ma(),r=await Nr(),i=r.platformUserId!==e;zt=e,i&&(await Mr({...r,platformUserId:e}),t?.alias({distinctId:e,alias:n}))}catch{}}async function La(){zt=null;try{let e=await Nr();if(e.platformUserId){let{platformUserId:t,...n}=e;await Mr(n)}}catch{}}function hu(){return{surface:"cli",release:process.env.POSTHOG_RELEASE??du,node_version:process.versions.node,platform:process.platform,arch:process.arch,ci:!!process.env.CI}}async function B(e,t={}){let n=Na();if(n)try{n.capture({distinctId:await pu(),event:e,properties:{...hu(),...t}})}catch{}}async function Or(){if(jn)try{await jn.shutdown(2e3)}catch{}}async function ja(e){let t=Ze(e.local?Pa:Rr),n=e.token??process.env.INKLY_API_TOKEN;if(n){let a=await Ur(t,n).catch(()=>({valid:!1,userId:null}));return await $r({apiBase:t,token:n}),await Oa("token",a),e.silent||process.stdout.write(`Logged in to ${t}${a.valid?"":" (token saved without online verification)"}
|
|
5041
|
+
`),{apiBase:t,configPath:Me,verified:a.valid,method:"token"}}let r=await bu({apiBase:t,shouldOpen:e.open!==!1,silent:e.silent});await $r({apiBase:r.apiBase,token:r.apiToken});let i=await Ur(r.apiBase,r.apiToken).catch(()=>({valid:!1,userId:null}));return await Oa("browser",i),e.silent||process.stdout.write(`Logged in to ${r.apiBase}
|
|
5042
|
+
`),{apiBase:r.apiBase,configPath:Me,verified:i.valid,method:"browser"}}async function Oa(e,t){t.valid&&t.userId&&await Lr(t.userId),await B("inkly_cli_logged_in",{method:e,verified:t.valid})}async function Ua(e={}){await B("inkly_cli_logged_out",{}),await La(),await Ea(),e.silent||process.stdout.write(`Removed ${Me}
|
|
5043
|
+
`)}async function za(e){let t=await qe(),n=t.apiBase?Ze(t.apiBase):null,r=await De(e.cwd),i="skipped",a;if(n&&t.token)try{let s=await Ur(n,t.token);i=s.valid?"ok":"failed",i==="failed"&&(a="Token was rejected by the platform."),s.valid&&s.userId&&await Lr(s.userId)}catch(s){i="failed",a=s.message}let o={configPath:Me,apiBase:n,loggedIn:!!t.token,hubRoot:r,online:i,message:a};return e.silent||(e.json?process.stdout.write(JSON.stringify(o,null,2)+`
|
|
5044
|
+
`):(process.stdout.write(`Config: ${Me}
|
|
5028
5045
|
`),process.stdout.write(`Hub: ${r??"(not inside a hub)"}
|
|
5029
5046
|
`),process.stdout.write(`API: ${n??"(not configured)"}
|
|
5030
5047
|
`),process.stdout.write(`Login: ${o.loggedIn?"configured":"not configured"}
|
|
5031
|
-
`),process.stdout.write(`Online: ${
|
|
5032
|
-
`))),o}async function
|
|
5033
|
-
${
|
|
5034
|
-
`),
|
|
5035
|
-
`),await
|
|
5036
|
-
`);return}if(
|
|
5037
|
-
`),
|
|
5038
|
-
`),
|
|
5039
|
-
`);for(let
|
|
5040
|
-
`)}}import{readdir as
|
|
5041
|
-
`+
|
|
5042
|
-
`));let o=[];
|
|
5043
|
-
`),o=(await
|
|
5044
|
-
`):
|
|
5048
|
+
`),process.stdout.write(`Online: ${i}${a?` (${a})`:""}
|
|
5049
|
+
`))),o}async function Ur(e,t){let n=await fetch(`${e}/api/captures/verify`,{method:"GET",headers:{authorization:`Bearer ${t}`}});if(!n.ok)return{valid:!1,userId:null};let r=null;try{let i=await n.json();typeof i.userId=="string"&&i.userId&&(r=i.userId)}catch{}return{valid:!0,userId:r}}async function bu(e){let t=mu(16).toString("hex"),n=fu(),r=await yu(n),i=new URL("/cli/login",e.apiBase);i.searchParams.set("callback",r.url),i.searchParams.set("state",t);let a=xu({server:n,state:t,apiBase:e.apiBase,timeoutMs:120*1e3});return e.silent||process.stdout.write(`Opening browser for Inkly login:
|
|
5050
|
+
${i.toString()}
|
|
5051
|
+
`),e.shouldOpen&&wu(i.toString()),a}async function yu(e){await new Promise((n,r)=>{e.once("error",r),e.listen(0,"127.0.0.1",()=>n())});let t=e.address();if(!t||typeof t=="string")throw new Error("Could not start local login callback server.");return{url:`http://127.0.0.1:${t.port}/callback`}}async function xu(e){return new Promise((t,n)=>{let r=setTimeout(()=>{jr(e.server),n(new Error("Timed out waiting for browser login."))},e.timeoutMs);e.server.on("request",(i,a)=>{(async()=>{try{let o=new URL(i.url??"/","http://127.0.0.1");if(o.pathname!=="/callback"){Un(a,404,"Not found.");return}let s=o.searchParams.get("state"),c=o.searchParams.get("pairingToken");if(!c||s!==e.state){Un(a,400,"Invalid Inkly CLI login callback. You can close this tab.");return}let d=await ku(e.apiBase,c);clearTimeout(r),Un(a,200,"Inkly CLI is connected. You can close this tab."),jr(e.server),t(d)}catch(o){clearTimeout(r),Un(a,500,`Inkly CLI login failed: ${o.message}`),jr(e.server),n(o)}})()})})}async function ku(e,t){let n=await fetch(`${e}/api/cli/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pairingToken:t})}),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:Ze(r.apiBase??e)}}function wu(e){let t=process.platform,i=gu(t==="darwin"?"open":t==="win32"?"cmd":"xdg-open",t==="win32"?["/c","start","",e]:[e],{stdio:"ignore",detached:!0});i.on("error",()=>{}),i.unref()}function Un(e,t,n){e.statusCode=t,e.setHeader("content-type","text/html; charset=utf-8"),e.end(`<!doctype html><meta charset="utf-8"><title>Inkly CLI</title><body style="font-family: system-ui, sans-serif; padding: 32px;">${vu(n)}</body>`)}function jr(e){try{e.close()}catch{}}function vu(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}import{readFile as Ba,readdir as Wa,writeFile as Su}from"fs/promises";import{join as on,extname as Va}from"path";async function Fn(e){let t=await qe(),n=await Mt(e.cwd),r=e.demo?n.demos.filter(p=>p.slug===e.demo):n.demos;if(e.demo&&r.length===0)throw new Error(`No such demo: ${e.demo}`);let i=[],a=[];for(let p of r)for(let h of p.assets?.assets??[]){let f=await Tu(n.root,h.sha256),w=Au(h);if(!f&&!w){a.push({demo:p.slug,id:h.id,sha256:h.sha256});continue}if(!f||w)continue;let x=await In(on(n.root,".inkly","cache",f));i.push({demo:p.slug,id:h.id,sha256:h.sha256,cacheFile:f,contentType:h.contentType??zn(f,h.kind),size:h.size??x??0,alreadyRemote:w})}let o={hubRoot:n.root,dryRun:!!e.dryRun,assets:i,unresolved:a,uploaded:0,updatedManifests:[]};if(e.dryRun||i.length===0)return e.silent||Fa(o,e.json),o;if(!t.token)throw new Error("Not logged in. Run `inkly login --token <token>` first.");let s=Ze(t.apiBase??process.env.INKLY_API_BASE),c=await zr({apiBase:s,token:t.token,hubRoot:n.root,assets:i}),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(x=>{let _=u.get(x.sha256);return _?(h=!0,{...x,contentType:x.contentType??zn(`${x.sha256}${_.ext}`,x.kind),publicUrl:_.publicUrl,cdnPath:_.cdnPath}):x});if(!h)continue;let w={...p.assets,assets:f};await te(p.assetsPath,JSON.stringify(w,null,2)+`
|
|
5052
|
+
`),await Iu(p.dir,d),o.updatedManifests.push(`demos/${p.slug}/assets.json`)}return o.uploaded=c.uploaded,e.silent||Fa(o,e.json),o}async function zr(e){let t=await Cu(e.apiBase,e.token,e.assets),n=new Map(t.uploads.map(a=>[a.sha256,a])),r=0;for(let a of e.assets){let o=n.get(a.sha256);if(!o)throw new Error(`Platform did not return upload metadata for ${a.sha256}.`);if(o.uploadUrl){let s=await Ba(on(e.hubRoot,".inkly","cache",a.cacheFile)),c=await fetch(o.uploadUrl,{method:"PUT",headers:o.uploadHeaders??{"content-type":a.contentType},body:s});if(!c.ok)throw new Error(`Asset upload failed for ${a.id}: HTTP ${c.status}`);r+=1}}return{uploads:(await _u(e.apiBase,e.token,e.assets,t.uploads)).uploads,uploaded:r}}async function _u(e,t,n,r){let i=new Map(r.map(s=>[s.sha256,s])),a=await fetch(`${e}/api/cli/sync-assets/complete`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t}`},body:JSON.stringify({assets:n.map(s=>{let c=i.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 a.json().catch(()=>null);if(!a.ok||!o||!Array.isArray(o.uploads))throw new Error(o?.error??`Sync completion failed: HTTP ${a.status}`);return{uploads:o.uploads}}async function Cu(e,t,n){let r=await fetch(`${e}/api/cli/sync-assets`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t}`},body:JSON.stringify({assets:n.map(a=>({sha256:a.sha256,ext:Va(a.cacheFile)||Fr(a.contentType),contentType:a.contentType,size:a.size}))})}),i=await r.json().catch(()=>null);if(!r.ok||!i||!Array.isArray(i.uploads))throw new Error(i?.error??`Sync endpoint failed: HTTP ${r.status}`);return{uploads:i.uploads}}async function Tu(e,t){let n=on(e,".inkly","cache");return await q(n)?(await Wa(n)).find(i=>i.startsWith(`${t}.`))??null:null}function Au(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.publicUrl=="string"&&typeof t.cdnPath=="string"}function zn(e,t){let n=Va(e).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":t==="font"?"font/woff2":"application/octet-stream"}function Fr(e){let t=e.toLowerCase().split(";")[0]?.trim();return t==="image/png"?".png":t==="image/jpeg"?".jpg":t==="image/webp"?".webp":t==="image/gif"?".gif":t==="image/svg+xml"?".svg":t==="video/webm"?".webm":t==="video/mp4"?".mp4":t==="audio/mpeg"?".mp3":t==="audio/wav"?".wav":t==="font/woff2"?".woff2":".bin"}async function Iu(e,t){let n=on(e,"snapshots");if(!await q(n))return;let r=t.map(i=>({local:`/__inkly/cache/${`${i.sha256}${i.ext}`}`,remote:i.publicUrl}));await Ja(n,r)}async function Ja(e,t){for(let n of await Wa(e,{withFileTypes:!0})){let r=on(e,n.name);if(n.isDirectory())await Ja(r,t);else if(n.isFile()&&/\.(html|css)$/i.test(n.name)){let i=await Ba(r,"utf8"),a=i;for(let o of t)i=i.split(o.local).join(o.remote);i!==a&&await Su(r,i,"utf8")}}}function Fa(e,t){if(t){process.stdout.write(JSON.stringify(e,null,2)+`
|
|
5053
|
+
`);return}if(e.dryRun){process.stdout.write(`inkly sync dry run: ${e.assets.length} asset(s) need upload
|
|
5054
|
+
`),Ha(e);return}process.stdout.write(`inkly sync complete: ${e.uploaded} uploaded, ${e.updatedManifests.length} manifest(s) updated
|
|
5055
|
+
`),Ha(e)}function Ha(e){if(e.unresolved.length!==0){process.stderr.write(`inkly sync warning: ${e.unresolved.length} asset(s) have no local cache file and are not on the CDN:
|
|
5056
|
+
`);for(let t of e.unresolved)process.stderr.write(` - demos/${t.demo} "${t.id}" (${t.sha256})
|
|
5057
|
+
`)}}import{readdir as Pu,readFile as Eu}from"fs/promises";import{extname as Br,join as qa,resolve as Za}from"path";function Hr(e,t){e||process.stdout.write(t)}function Ru(e,t){if(t.demo){let n=e.demos.find(r=>r.slug===t.demo);if(!n)throw new Error(`No such demo: ${t.demo}`);return n}if(t.path){let n=Za(t.cwd,t.path),r=e.demos.find(a=>Za(a.dir)===n);if(r)return r;let i=e.demos.find(a=>a.slug===t.path||a.slug===t.path?.replace(/^demos\//,""));if(i)return i;throw new Error(`No demo found at "${t.path}". Available demos: ${e.demos.map(a=>a.slug).join(", ")||"(none)"}`)}if(e.demos.length===1)return e.demos[0];throw new Error(`This hub has ${e.demos.length} demos \u2014 pass a demo path or --demo <slug>. Available: ${e.demos.map(n=>n.slug).join(", ")}`)}async function $u(e,t=[]){let n=qa(e,"snapshots");if(!await q(n))return{};let r={};async function i(a){for(let o of await Pu(a,{withFileTypes:!0})){let s=qa(a,o.name);if(o.isDirectory())await i(s);else if(o.isFile()&&/\.(html|css)$/i.test(o.name)){let c=s.slice(e.length+1).split(/[\\/]/).join("/");r[c]=Du(await Eu(s,"utf8"),t)}}}return await i(n),r}function Du(e,t){let n=e;for(let r of t)n=n.split(r.local).join(r.remote);return n}function Ga(e){if(!e)return null;try{let t=new URL(e);return Br(t.pathname)||null}catch{return Br(e)||null}}function Nu(e,t,n){let r=new Map,i=(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 t)i(o.sha256,Br(o.cacheFile));for(let o of n)i(o.sha256,o.ext);for(let o of e.assets)i(o.sha256,Ga(o.cdnPath)),i(o.sha256,Ga(o.publicUrl)),o.contentType&&i(o.sha256,Fr(o.contentType));let a=[];for(let o of e.assets)if(o.publicUrl)for(let s of r.get(o.sha256)??[])a.push({local:`/__inkly/cache/${o.sha256}${s}`,remote:o.publicUrl});return a}function Mu(e,t,n){let r=e??{version:1,assets:[]},i=new Map(n.map(o=>[o.sha256,o])),a=new Map(t.map(o=>[o.sha256,o]));return{...r,assets:r.assets.map(o=>{let s=i.get(o.sha256);if(!s)return o;let c=a.get(o.sha256);return{...o,contentType:o.contentType??c?.contentType??zn(`${o.sha256}${s.ext}`,o.kind),publicUrl:s.publicUrl,cdnPath:s.cdnPath}})}}async function Ka(e){let t=await qe();if(!t.token)throw new Error("Not logged in. Run `inkly login` first.");let n=Ze(t.apiBase??process.env.INKLY_API_BASE),r=await Mt(e.cwd),i=Ru(r,e),a=await Fn({cwd:r.root,demo:i.slug,dryRun:!0,silent:!0});if(a.unresolved.length>0)throw new Error(`${a.unresolved.length} asset(s) have no local bytes and are not on the CDN, so a hosted preview cannot be published:
|
|
5058
|
+
`+a.unresolved.map(f=>` - ${f.id} (${f.sha256})`).join(`
|
|
5059
|
+
`));let o=[];a.assets.length>0&&(Hr(e.silent,`Uploading ${a.assets.length} asset(s) to the CDN for this snapshot...
|
|
5060
|
+
`),o=(await zr({apiBase:n,token:t.token,hubRoot:r.root,assets:a.assets})).uploads);let s=Mu(i.assets,a.assets,o),c=await $u(i.dir,Nu(s,a.assets,o)),d=await fetch(`${n}/api/previews`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t.token}`},body:JSON.stringify({demoSlug:i.slug,title:i.config.title??null,config:i.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:i.slug,id:u.id,url:p};return e.json?Hr(e.silent,JSON.stringify(h,null,2)+`
|
|
5061
|
+
`):Hr(e.silent,`Snapshot published:
|
|
5045
5062
|
${p}
|
|
5046
|
-
`),h}import*as
|
|
5047
|
-
|
|
5048
|
-
`)}function
|
|
5049
|
-
`,o=!0};for(let d of
|
|
5050
|
-
`,n+=1,o=!0;continue}if(d==="}"){n=Math.max(0,n-1),c(),s(),
|
|
5051
|
-
`}function
|
|
5052
|
-
${r}${
|
|
5053
|
-
${" ".repeat(
|
|
5054
|
-
`)}function
|
|
5063
|
+
`),h}import*as wt from"@sentry/node";var Lu="https://b3450c6a8fdcd02b8aee3b9f2c8425eb@o4511498910433280.ingest.us.sentry.io/4511498940252160",Ou="@inkly-org/cli@0.5.1";function Ya(){wt.init({dsn:Lu,release:process.env.SENTRY_RELEASE??Ou,environment:process.env.SENTRY_ENVIRONMENT??"production",enabled:process.env.INKLY_SENTRY_DISABLED!=="1",sendDefaultPii:!1,tracesSampleRate:0,beforeSend(e){return e.server_name=void 0,e}})}async function ae(e,t){wt.captureException(t,{tags:{command:e,surface:"cli"}}),await wt.flush(2e3)}async function Xa(){await wt.flush(2e3)}import{spawn as po,execFile as Rp}from"child_process";import{createHash as $p,randomUUID as Dp}from"crypto";import{mkdir as Ht,mkdtemp as Np,open as ho,readFile as _e,readdir as mo,rm as fe,writeFile as fo}from"fs/promises";import{existsSync as je}from"fs";import{dirname as Zn,isAbsolute as go,join as W,resolve as Vn,sep as Mp}from"path";import{tmpdir as Lp,homedir as ni}from"os";import{fileURLToPath as bo}from"url";import{unzipSync as Op,zipSync as jp}from"fflate";import Up from"ws";import zp from"sharp";import Fp from"subset-font";var ju=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Uu=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 zu(e){let t="";for(let n=0;n<e.length;n+=1)t+=(e[n]??0).toString(16).padStart(2,"0");return t}async function Hn(e,t=16){let n=new Uint8Array(e.byteLength);n.set(e);let r=await crypto.subtle.digest("SHA-256",n);return zu(new Uint8Array(r)).slice(0,t)}function Zr(e){switch((e.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 Wr(e,t){let n=e.trim();if(!n||n.startsWith("data:")||n.startsWith("blob:")||n.startsWith("assets/")||n.startsWith("#"))return null;try{let r=new URL(n,t);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.href}catch{return null}}function ro(e,t,n){if(t){let i=atob(n.replace(/\s+/g,"")),a=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)a[o]=i.charCodeAt(o);return a}let r=decodeURIComponent(n.replace(/\+/g,"%20"));return new TextEncoder().encode(r)}function Fu(e){return/\s/.test(e)||e===")"||e==='"'||e==="<"||e===">"}function io(e){return e.replace(/\\(?:\r\n|[\n\r\f])/g,"").replace(/\\([0-9a-fA-F]{1,6}\s?|[\s\S])/g,(t,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 Hu(e){let t=[],n=0;for(;n<e.length;){let r=e.toLowerCase().indexOf("data:",n);if(r<0)break;let i=r>0?e[r-1]:"",a=i==='"'||i==="'"?i:null,o=e.indexOf(",",r);if(o<0)break;let s=e.slice(r+5,o);if(!s||/[\s"'()<>]/.test(s)){n=r+5;continue}let c=o+1,d=!1;for(;c<e.length;){let x=e[c]??"";if(d){d=!1,c+=1;continue}if(x==="\\"){d=!0,c+=1;continue}if(a?x===a:Fu(x))break;c+=1}let u=e.slice(r,c),p=io(e.slice(o+1,c)),h=s.split(";"),f=h.shift()||"text/plain",w=h.some(x=>x.toLowerCase()==="base64");t.push({match:u,mime:f,isBase64:w,payload:p,index:r}),n=c}return t}function Bu(e){let t=e.trim();if(!t.toLowerCase().startsWith("data:"))return null;let n=t.indexOf(",");if(n<0)return null;let r=t.slice(5,n);if(!r||/[\s"'()<>]/.test(r))return null;let i=r.split(";"),a=i.shift()||"text/plain",o=i.some(s=>s.toLowerCase()==="base64");return{mime:a,isBase64:o,payload:io(t.slice(n+1))}}async function Qa(e,t){let n=Bu(e);if(!n)return null;let r;try{r=ro(n.mime,n.isBase64,n.payload)}catch{return null}let i=`${await Hn(r)}${Zr(n.mime)}`;return t.has(i)||t.set(i,{filename:i,bytes:r,contentType:n.mime||"application/octet-stream"}),`assets/${i}`}async function Vr(e,t,n){let r=n.get(e);if(r)return r;try{let i=await fetch(e,{cache:"force-cache",referrerPolicy:"strict-origin-when-cross-origin"});if(!i.ok)return null;let a=i.headers.get("content-type")?.split(";")[0]?.trim()||"application/octet-stream",o=new Uint8Array(await i.arrayBuffer());if(o.byteLength===0)return null;let s=`${await Hn(o)}${Zr(a)}`;t.has(s)||t.set(s,{filename:s,bytes:o,contentType:a});let c=`assets/${s}`;return n.set(e,c),c}catch{return null}}function Wu(e){let t=[],n=0,r=!1;for(let i=0;i<e.length;i+=1){if(e[i]!==",")continue;if(e.slice(n,i).trimStart().toLowerCase().startsWith("data:")&&!r){r=!0;continue}t.push(e.slice(n,i).trim()),n=i+1,r=!1}return t.push(e.slice(n).trim()),t.filter(Boolean).map(i=>{let a=i.match(/\s+(\d+(?:\.\d+)?[wx])$/);return a?.index?{url:i.slice(0,a.index).trim(),descriptor:a[1]??""}:{url:i,descriptor:""}}).filter(i=>i.url.length>0)}async function Vu(e,t,n,r){let i=Array.from(e.querySelectorAll("img[src],source[src],video[poster]"));for(let o of i){let s=o.hasAttribute("poster")?"poster":"src",c=o.getAttribute(s);if(!c)continue;let d=await Qa(c,n);if(d){o.setAttribute(s,d);continue}let u=Wr(c,t);if(!u)continue;let p=await Vr(u,n,r);p&&o.setAttribute(s,p)}let a=Array.from(e.querySelectorAll("img[srcset],source[srcset]"));for(let o of a){let s=o.getAttribute("srcset");if(!s)continue;let c=[];for(let d of Wu(s)){let u=await Qa(d.url,n);if(u){c.push(`${u}${d.descriptor?` ${d.descriptor}`:""}`);continue}let p=Wr(d.url,t),h=p?await Vr(p,n,r):null;c.push(`${h??d.url}${d.descriptor?` ${d.descriptor}`:""}`)}o.setAttribute("srcset",c.join(", "))}}async function Ju(e,t,n,r){let i=[],a=/url\(\s*(["']?)([^"')]+)\1\s*\)/gi,o;for(;o=a.exec(e);){let c=o[2]??"",d=Wr(c,t);d&&i.push({raw:c,url:d})}let s=e;for(let c of i){let d=await Vr(c.url,n,r);d&&(s=s.split(c.raw).join(d))}return s}async function qu(e){let t=new Map,n=Hu(e),r=[];for(let o of n){let s;try{s=ro(o.mime,o.isBase64,o.payload)}catch{continue}let c=`${await Hn(s)}${Zr(o.mime)}`;t.has(c)||t.set(c,{filename:c,bytes:s,contentType:o.mime||"application/octet-stream"}),r.push({match:o.match,replacement:`assets/${c}`})}let i=e,a=new Map;for(let o of r)a.set(o.match,o.replacement);for(let[o,s]of a)i=i.split(o).join(s);return{html:i,assets:t}}function Zu(e){return e.replace(/<script\b[\s\S]*?<\/script>/gi,"")}function Gu(e){return e.replace(/<script\b(?=[^>]*\bid=["']alpha-capture-index["'])[\s\S]*?<\/script>/i,"")}function Ku(e){return e.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 Yu(e){let t=1,n=e.createTreeWalker(e.documentElement,NodeFilter.SHOW_ELEMENT,null),r=e.documentElement;do{if(r&&r.nodeType===1){let i=r.tagName.toLowerCase();Uu.has(i)&&(r.setAttribute("data-inkly-id",String(t)),t+=1)}r=n.nextNode()}while(r)}function Xu(e){e.removeAttribute("href"),e.removeAttribute("xlink:href"),e.removeAttributeNS("http://www.w3.org/1999/xlink","href"),e.removeAttribute("target"),e.removeAttribute("rel"),e.removeAttribute("download"),e.removeAttribute("ping"),e.removeAttribute("referrerpolicy")}function Qu(e){for(let t of Array.from(e.querySelectorAll("*")))for(let n of Array.from(t.attributes))/^on/i.test(n.name)&&t.removeAttribute(n.name),/^formaction$/i.test(n.name)&&t.removeAttribute(n.name);for(let t of Array.from(e.querySelectorAll("base")))t.remove();for(let t of Array.from(e.querySelectorAll("link[href]")))(t.getAttribute("rel")??"").toLowerCase().split(/\s+/).filter(Boolean).includes("stylesheet")||t.remove();for(let t of Array.from(e.querySelectorAll("meta[http-equiv]")))(t.getAttribute("http-equiv")??"").toLowerCase()==="refresh"&&t.remove();for(let t of Array.from(e.querySelectorAll("a,area")))Xu(t),t.removeAttribute("data-inkly-href");for(let t of Array.from(e.querySelectorAll("form")))t.removeAttribute("action"),t.removeAttribute("method"),t.removeAttribute("target"),t.removeAttribute("data-inkly-action")}function ep(e){let t=Array.from(e.querySelectorAll("style"));if(t.length===0)return"";let n=[],r=!0;for(let i of t){let a=i.textContent?.trim()??"",o=i.getAttribute("media")?.trim();if(o&&o.toLowerCase()!=="all"?n.push(`@media ${o} {${a}}`):n.push(a),r){let s=e.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href","assets/document.css"),i.replaceWith(s),r=!1}else i.remove()}return n.join(`
|
|
5064
|
+
|
|
5065
|
+
`)}function tp(e){let t="",n=0,r="",i=!1,a=0,o=!0,s=()=>{o&&(t+=" ".repeat(n),o=!1)},c=()=>{t=t.replace(/[ \t]+$/,""),t+=`
|
|
5066
|
+
`,o=!0};for(let d of e){if(r){s(),t+=d,i?i=!1:d==="\\"?i=!0:d===r&&(r="");continue}if(i){s(),t+=d,i=!1;continue}if(d==="\\"){s(),t+=d,i=!0;continue}if(d==='"'||d==="'"){s(),r=d,t+=d;continue}if(d==="("&&(a+=1),d===")"&&(a=Math.max(0,a-1)),d==="{"){s(),t=t.replace(/[ \t]+$/,""),t+=` {
|
|
5067
|
+
`,n+=1,o=!0;continue}if(d==="}"){n=Math.max(0,n-1),c(),s(),t+="}",c();continue}if(d===";"&&a===0){s(),t+=";",c();continue}if(d===","&&a===0){s(),t+=",",c();continue}s(),t+=d}return`${t.trim()}
|
|
5068
|
+
`}function eo(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Jr(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function to(e){return e==="id"?0:e==="data-inkly-id"?1:e==="class"?2:e==="href"?3:e==="src"?4:e==="srcset"?5:e==="alt"?6:e==="aria-label"?7:e==="role"?8:e==="type"?9:e==="style"?10:20}function np(e){return Array.from(e.attributes).sort((n,r)=>to(n.name)-to(r.name)||n.name.localeCompare(r.name))}function rp(e,t){let n=e.trim().split(/\s+/).filter(Boolean);if(n.length<=5&&e.length<=100)return`"${Jr(e)}"`;let r=" ".repeat(t+2);return`"${n.map(i=>`
|
|
5069
|
+
${r}${Jr(i)}`).join("")}
|
|
5070
|
+
${" ".repeat(t)}"`}function no(e,t){return e.name==="class"?`${e.name}=${rp(e.value,t+e.name.length+2)}`:`${e.name}="${Jr(e.value)}"`}function ip(e,t){let n=np(e),r=e.tagName.toLowerCase();if(n.length===0)return`<${r}>`;let i=`<${r} ${n.map(o=>no(o,t)).join(" ")}>`;if(i.length<=110&&!n.some(o=>o.name==="class"&&o.value.length>100))return i;let a=[`<${r}`];for(let o of n)a.push(`${" ".repeat(t+2)}${no(o,t+2)}`);return a.push(`${" ".repeat(t)}>`),a.join(`
|
|
5071
|
+
`)}function ap(e){let t=e.tagName.toLowerCase();if(t==="pre"||t==="code"||t==="textarea"||t==="style")return!0;let n=e.getAttribute("class")??"";if(/(^|\s)whitespace-(?:pre|pre-wrap|pre-line|break-spaces)(\s|$)/.test(n))return!0;let r=e.getAttribute("style")??"";return/(?:^|;)\s*white-space\s*:\s*(?:pre|pre-wrap|pre-line|break-spaces)\b/i.test(r)}function qr(e,t){let n=" ".repeat(t*2);if(e.nodeType===Node.TEXT_NODE){let d=(e.nodeValue??"").replace(/\s+/g," ").trim();return d?`${n}${eo(d)}`:""}if(e.nodeType===Node.COMMENT_NODE||e.nodeType!==Node.ELEMENT_NODE)return"";let r=e,i=r.tagName.toLowerCase(),a=`${n}${ip(r,n.length)}`;if(ju.has(i))return a;if(i==="template"&&"content"in r){let d=r,u=[];for(let p of Array.from(d.content.childNodes)){let h=qr(p,t+1);h&&u.push(h)}return u.length===0?`${a}</${i}>`:`${a}
|
|
5055
5072
|
${u.join(`
|
|
5056
5073
|
`)}
|
|
5057
|
-
${n}</${
|
|
5058
|
-
`)&&
|
|
5074
|
+
${n}</${i}>`}if(ap(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?`${a}${eo(d)}</${i}>`:`${a}</${i}>`}let s=[];for(let d of Array.from(r.childNodes)){let u=qr(d,t+1);u&&s.push(u)}if(s.length===0)return`${a}</${i}>`;let c=s[0];return s.length===1&&c&&c.trim()&&!c.includes(`
|
|
5075
|
+
`)&&a.length+c.trim().length<120?`${a}${c.trim()}</${i}>`:`${a}
|
|
5059
5076
|
${s.join(`
|
|
5060
5077
|
`)}
|
|
5061
|
-
${n}</${
|
|
5062
|
-
${
|
|
5063
|
-
`}var
|
|
5078
|
+
${n}</${i}>`}function op(e){let t=e.documentElement;return`<!doctype html>
|
|
5079
|
+
${qr(t,0)}
|
|
5080
|
+
`}var sp=.8,lp=1024;function cp(e){let t=(e.toLowerCase().split(";")[0]??"").trim();return t==="image/png"||t==="image/jpeg"||t==="image/jpg"}async function dp(e,t){if(typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{let n=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),r=await createImageBitmap(new Blob([n],{type:t}));try{let i=new OffscreenCanvas(r.width,r.height),a=i.getContext("2d");if(!a)return null;a.drawImage(r,0,0);let o=await i.convertToBlob({type:"image/webp",quality:sp});return o.type!=="image/webp"?null:new Uint8Array(await o.arrayBuffer())}finally{r.close()}}catch{return null}}async function up(e,t,n){let r=new Map,i=new Map;for(let s of e.values()){if(!cp(s.contentType)||s.bytes.byteLength<lp){i.set(s.filename,s);continue}let c=await dp(s.bytes,s.contentType);if(!c||c.byteLength>=s.bytes.byteLength){i.set(s.filename,s);continue}let d=`${await Hn(c)}.webp`;r.set(s.filename,d),i.has(d)||i.set(d,{filename:d,bytes:c,contentType:"image/webp"})}if(r.size===0)return{assets:[...e.values()],html:t,css:n};let a=t,o=n;for(let[s,c]of r)a=a.split(`assets/${s}`).join(`assets/${c}`),o=o.split(s).join(c);return{assets:[...i.values()],html:a,css:o}}async function ao(e,t,n={}){let r=Zu(e);r=Gu(r),r=Ku(r);let i=await qu(r);r=i.html;let a=pp(r);Yu(a),Qu(a);let o=new Map;await Vu(a,t,i.assets,o);let s=(await Ju(ep(a),t,i.assets,o)).replace(/url\((["']?)assets\//g,"url($1"),c=Xt(op(a)),d=tp(s);if(n.compressImages){let u=await up(i.assets,c,d);return{html:u.html,css:u.css,assets:u.assets}}return{html:c,css:d,assets:[...i.assets.values()]}}function pp(e){let t=globalThis.DOMParser;if(!t)throw new Error("DOMParser is not available in this context. Run compactSnapshot in an offscreen document.");return new t().parseFromString(e,"text/html")}import{zipSync as hp}from"fflate";var mp=/^(?:https?:)?\/\//i,fp=/^(?:#|data:|blob:|javascript:|mailto:|tel:|about:|chrome:|chrome-extension:)/i;function gp(e){return e.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,60).replace(/-+$/,"")||"demo"}function bp(e){let t="abcdefghijklmnopqrstuvwxyz0123456789",n=new Uint8Array(e);crypto.getRandomValues(n);let r="";for(let i=0;i<e;i+=1)r+=t[(n[i]??0)%t.length];return r}function yp(e){return`${gp(e)}-${bp(6)}`}function xp(e,t){return`# ${t}
|
|
5081
|
+
|
|
5082
|
+
This is a self-contained Inkly HTML capture. Everything it needs is in
|
|
5083
|
+
this folder \u2014 no hub and no upload required to preview it.
|
|
5084
|
+
|
|
5085
|
+
## Preview it
|
|
5064
5086
|
|
|
5065
|
-
|
|
5066
|
-
\`inkly
|
|
5087
|
+
Install the CLI once, then point \`inkly dev\` at this folder \u2014 no
|
|
5088
|
+
\`inkly init\` needed:
|
|
5067
5089
|
|
|
5068
|
-
|
|
5090
|
+
\`\`\`bash
|
|
5091
|
+
npm install -g @inkly-org/cli
|
|
5092
|
+
inkly dev ${e}
|
|
5093
|
+
\`\`\`
|
|
5069
5094
|
|
|
5070
|
-
|
|
5095
|
+
It serves at http://localhost:3000.
|
|
5071
5096
|
|
|
5072
|
-
|
|
5073
|
-
npm install -g @inkly-org/cli
|
|
5074
|
-
inkly init my-hub
|
|
5075
|
-
cd my-hub
|
|
5076
|
-
\`\`\`
|
|
5097
|
+
## Host it in a hub
|
|
5077
5098
|
|
|
5078
|
-
|
|
5079
|
-
|
|
5099
|
+
To keep all your demos together as a collection and sync them with the
|
|
5100
|
+
Inkly platform, scaffold a hub and drop this demo into it:
|
|
5080
5101
|
|
|
5081
|
-
|
|
5102
|
+
\`\`\`bash
|
|
5103
|
+
inkly init my-hub
|
|
5104
|
+
cp -r ${e} my-hub/demos/
|
|
5105
|
+
cd my-hub
|
|
5106
|
+
inkly login # connect your Inkly account
|
|
5107
|
+
inkly sync # upload assets to the CDN
|
|
5108
|
+
\`\`\`
|
|
5082
5109
|
|
|
5083
|
-
|
|
5084
|
-
inkly dev
|
|
5085
|
-
\`\`\`
|
|
5110
|
+
## Publish a shareable link
|
|
5086
5111
|
|
|
5087
|
-
|
|
5112
|
+
From inside the hub (and once logged in), freeze this demo to a
|
|
5113
|
+
standalone, hosted \`/p/<id>\` URL you can share with anyone:
|
|
5114
|
+
|
|
5115
|
+
\`\`\`bash
|
|
5116
|
+
inkly snapshot --demo ${e}
|
|
5117
|
+
\`\`\`
|
|
5088
5118
|
|
|
5089
5119
|
## What's inside
|
|
5090
5120
|
|
|
5091
|
-
- \`${
|
|
5092
|
-
- \`${
|
|
5093
|
-
- \`${
|
|
5094
|
-
- \`${
|
|
5095
|
-
- \`${
|
|
5096
|
-
`}function
|
|
5121
|
+
- \`${e}/demo.config.json\` - the demo definition.
|
|
5122
|
+
- \`${e}/assets.json\` - maps pooled asset ids to files in \`public/\`.
|
|
5123
|
+
- \`${e}/capture-metadata.json\` - HTML export diagnostics.
|
|
5124
|
+
- \`${e}/public/<file>\` - captured HTML asset bytes.
|
|
5125
|
+
- \`${e}/snapshots/snap-NNN/index.html\` and \`document.css\` - replayable snapshots.
|
|
5126
|
+
`}function kp(e){return e.trim().replace(/^['"]|['"]$/g,"")}function Bn(e,t){let n=kp(t.url);!n||fp.test(n)||!mp.test(n)||e.set(`${t.stepId}\0${t.file}\0${t.kind}\0${n}`,{...t,url:n})}function wp(e){return e.split(",").map(t=>t.trim().split(/\s+/)[0]??"").filter(Boolean)}function vp(e,t){return e?.alphaId?t.includes(`data-inkly-id="${e.alphaId}"`)||t.includes(`data-inkly-id='${e.alphaId}'`)?e:{...e,alphaId:void 0}:e}function Sp(e){let t=new Map,n=/\b(?:src|poster|data|action|formaction)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))/gi,r;for(;(r=n.exec(e.html))!==null;)Bn(t,{stepId:e.stepId,file:e.htmlPath,kind:"html-attribute",url:r[1]??r[2]??r[3]??""});let i=/<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,a;for(;(a=i.exec(e.html))!==null;)Bn(t,{stepId:e.stepId,file:e.htmlPath,kind:"html-attribute",url:a[1]??a[2]??a[3]??""});let o=/\b(?:srcset|imagesrcset)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))/gi,s;for(;(s=o.exec(e.html))!==null;){let u=s[1]??s[2]??s[3]??"";for(let p of wp(u))Bn(t,{stepId:e.stepId,file:e.htmlPath,kind:"html-srcset",url:p})}let c=/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)"'\s]+))\s*\)/gi,d;for(;(d=c.exec(e.css))!==null;)Bn(t,{stepId:e.stepId,file:e.htmlPath.replace(/\/index\.html$/,"/document.css"),kind:"css-url",url:d[1]??d[2]??d[3]??""});return[...t.values()]}async function oo(e){let{name:t,steps:n,assets:r}=e;if(n.length===0)throw new Error("No HTML steps captured.");let i=yp(t),a=new Map;for(let _ of r)a.set(_.filename,`/${i}/${_.filename}`);let o={},s=[],c=[],d=new TextEncoder;for(let _=0;_<n.length;_+=1){let P=n[_];if(!P)continue;let $=`s${_+1}`,R=$i(_+1),b=`snapshots/${R}/index.html`,U=cr(P.cssText??"",a),z=Ni(Mi(Xt(cr(P.htmlText,a)),U.length>0),P.scroll);o[R]={"index.html":d.encode(z),"document.css":d.encode(U)},c.push(...Sp({stepId:$,htmlPath:b,html:z,css:U})),s.push(Di({stepId:$,htmlPath:b,naturalWidth:P.viewport.width,naturalHeight:P.viewport.height,scroll:P.scroll,sourceUrl:P.url||void 0,click:vp(P.click,z)}))}let u=r.map(_=>({id:_.filename,sha256:_.sha256,kind:wn(_.contentType),contentType:_.contentType,size:_.bytes.byteLength,publicUrl:`/${i}/${_.filename}`})),p=_n({id:se(),version:1,title:t,steps:s}),h=Rt.parse({version:1,assets:u,screens:[]}),f={version:1,kind:"html-capture",generatedAt:e.generatedAt??new Date().toISOString(),stepCount:n.length,assetCount:r.length,unresolvedExternalReferences:c},w={};for(let _ of r)w[_.filename]=_.bytes;let x={"README.md":d.encode(xp(i,t)),[i]:{"demo.config.json":d.encode(`${JSON.stringify(p,null,2)}
|
|
5097
5127
|
`),"assets.json":d.encode(`${JSON.stringify(h,null,2)}
|
|
5098
5128
|
`),"capture-metadata.json":d.encode(`${JSON.stringify(f,null,2)}
|
|
5099
|
-
`),snapshots:o,public:w}};return{bytes:
|
|
5129
|
+
`),snapshots:o,public:w}};return{bytes:hp(x,{level:6}),filename:`${i}.zip`,slug:i}}import{JSDOM as Hp}from"jsdom";import{Stagehand as ay}from"@browserbasehq/stagehand";import{NodeHtmlMarkdown as sy}from"node-html-markdown";var _p=["button","link","textbox","searchbox","checkbox","radio","combobox","listbox","option","switch","slider","spinbutton","tab","menuitem","menuitemcheckbox","menuitemradio","treeitem"],Cp=["navigation","main","banner","contentinfo","complementary","search","form","dialog","alertdialog","menu","menubar","tablist","region"],sn="^\\s*(?:\\[[\\w-]+]\\s*)?",Gb=new RegExp(`${sn}(?:${_p.join("|")})\\b`,"i"),Kb=new RegExp(`${sn}(?:${Cp.join("|")})\\b`,"i"),Yb=new RegExp(`${sn}heading\\b`,"i"),Xb=new RegExp(`${sn}StaticText\\b`,"i");var Qb=new RegExp(`${sn}[\\w-]+(?:,[^:]*)?:\\s`,"i");import Tp from"net";import hy from"readline";import{rm as fy}from"fs/promises";import{join as Gr}from"path";import{homedir as Ap}from"os";function Ip(){return Gr(process.env.INKLY_CAPTURE_AGENT_HOME||Gr(Ap(),".inkly"),"capture-agent","sessions")}function Kr(e){if(!/^[a-zA-Z0-9._:-]+$/.test(e))throw new Error(`invalid session id: ${e}`);return Gr(Ip(),`${e}.nav.sock`)}async function G(e,t,n,r={}){let i=r.connectTimeoutMs??8e3,a=r.requestTimeoutMs??6e4,s={id:`${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`,type:"command",command:t,params:n},c=await Pp(e,i);return new Promise((d,u)=>{let p="",h=!1,f=x=>{h||(h=!0,clearTimeout(w),x())},w=setTimeout(()=>{f(()=>{c.destroy(),u(new Error(`nav request "${t}" timed out`))})},a);c.on("data",x=>{p+=x.toString();let _=p.indexOf(`
|
|
5130
|
+
`);if(_===-1)return;let P;try{P=JSON.parse(p.slice(0,_))}catch($){f(()=>{c.destroy(),u($ instanceof Error?$:new Error(String($)))});return}if(P.type==="error"){f(()=>{c.end(),u(new Error(P.error))});return}f(()=>{c.end(),d(P.data)})}),c.on("error",x=>{f(()=>u(x))}),c.on("close",()=>{f(()=>u(new Error("nav listener closed without a response")))}),c.write(`${JSON.stringify(s)}
|
|
5131
|
+
`)})}async function Pp(e,t){let n=Date.now(),r=null;for(;Date.now()-n<t;)try{return await Ep(e)}catch(i){r=i instanceof Error?i:new Error(String(i)),await new Promise(a=>setTimeout(a,150))}throw new Error(`could not reach the capture listener nav socket at ${e}`+(r?` (${r.message})`:"")+". Is the session started and is its listener ready?")}function Ep(e){return new Promise((t,n)=>{let r=Tp.createConnection(e),i=a=>{r.destroy(),n(a)};r.once("error",i),r.once("connect",()=>{r.off("error",i),t(r)})})}var so=!1;function Bp(){if(so)return;let{window:e}=new Hp("<!doctype html><html></html>"),t=globalThis;t.DOMParser??=e.DOMParser,t.Node??=e.Node,t.NodeFilter??=e.NodeFilter,t.Element??=e.Element,t.HTMLImageElement??=e.HTMLImageElement,so=!0}var yo=`Options:
|
|
5100
5132
|
--url <url> URL to open and arm for recording.
|
|
5101
5133
|
--name <name> Demo name written into the exported ZIP.
|
|
5102
5134
|
--session <id> Session id printed by start.
|
|
@@ -5116,7 +5148,7 @@ This folder is a self-contained Inkly HTML capture. It works locally with
|
|
|
5116
5148
|
done once in this profile survives, so later captures of the same site need
|
|
5117
5149
|
no re-login. Implies --keep-profile. Run --headed the first time so the user
|
|
5118
5150
|
can sign in; reuse can run headless.
|
|
5119
|
-
--no-unpack On stop, write only the ZIP.`,
|
|
5151
|
+
--no-unpack On stop, write only the ZIP.`,dn=`inkly capture - capture an image/video walkthrough for an external browser agent
|
|
5120
5152
|
|
|
5121
5153
|
Usage:
|
|
5122
5154
|
inkly capture start --url <url> --name <name>
|
|
@@ -5124,9 +5156,10 @@ Usage:
|
|
|
5124
5156
|
inkly capture cancel --session <id>
|
|
5125
5157
|
inkly capture status --session <id>
|
|
5126
5158
|
inkly capture undo --session <id>
|
|
5159
|
+
inkly capture nav <verb> --session <id> (snapshot|click|fill|type|press|select|upload|get|is|wait|back|forward|reload|refs|mouse)
|
|
5127
5160
|
inkly capture profiles
|
|
5128
5161
|
|
|
5129
|
-
${
|
|
5162
|
+
${yo}
|
|
5130
5163
|
--video, --record-video Record motion segments. Enabled by default; use --no-video to disable.
|
|
5131
5164
|
--zoom Apply click zoom/pan to screenshot steps. Enabled by default; use --no-zoom to disable.
|
|
5132
5165
|
--compress-images Re-encode captured PNG/JPEG screenshots to WebP (smaller, near-lossless).
|
|
@@ -5135,7 +5168,7 @@ ${oo}
|
|
|
5135
5168
|
Output:
|
|
5136
5169
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
5137
5170
|
For self-contained HTML snapshot capture, use \`inkly capture-html\`.
|
|
5138
|
-
`,
|
|
5171
|
+
`,un=`inkly capture-html - capture a self-contained HTML walkthrough for an external browser agent
|
|
5139
5172
|
|
|
5140
5173
|
Usage:
|
|
5141
5174
|
inkly capture-html start --url <url> --name <name>
|
|
@@ -5143,46 +5176,72 @@ Usage:
|
|
|
5143
5176
|
inkly capture-html cancel --session <id>
|
|
5144
5177
|
inkly capture-html status --session <id>
|
|
5145
5178
|
inkly capture-html undo --session <id>
|
|
5179
|
+
inkly capture-html nav <verb> --session <id> (snapshot|click|fill|type|press|select|upload|get|is|wait|back|forward|reload|refs|mouse)
|
|
5146
5180
|
inkly capture-html profiles
|
|
5147
5181
|
|
|
5148
|
-
${
|
|
5182
|
+
${yo}
|
|
5149
5183
|
--block-videos Replace <video> with its poster frame instead of inlining the video.
|
|
5150
5184
|
|
|
5151
5185
|
Output:
|
|
5152
5186
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
5153
|
-
`,
|
|
5154
|
-
`)}function
|
|
5187
|
+
`,Wp=Zn(bo(import.meta.url)),Vp=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/opt/google/chrome/chrome"],Jp=1440,qp=900,Zp=12e4;var Gp=720,Kp=60,Fy=Math.round(Gp/Kp);function Bt(e){return new Promise(t=>setTimeout(t,e))}function Q(e){process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
5188
|
+
`)}function Se(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t];return typeof n=="string"?n:""}function Yr(e,t,n){let r=e[t];return typeof r=="number"?r:typeof r=="string"&&r.trim()?Number(r):n}function Ft(e,t,n){for(let r of t)if(Object.prototype.hasOwnProperty.call(e,r))return e[r]!==!1;return n}function Yp(e){if(!e)return null;let t=/^\s*(\d+)\s*[x,]\s*(\d+)\s*$/i.exec(e);if(!t)throw new Error("--window-size must look like 1440x900");return{width:Number(t[1]),height:Number(t[2])}}function Ge(e,t,n){let r=Se(e,t);if(!r)throw new Error(`missing --${t} <value>
|
|
5155
5189
|
|
|
5156
|
-
${n}`);return r}function
|
|
5190
|
+
${n}`);return r}function Xp(e){return Se(e,"connect-to-browser")??process.env.INKLY_CAPTURE_BROWSER_URL}function Qp(e){if(Object.prototype.hasOwnProperty.call(e,"prompt"))throw new Error("inkly capture does not accept --prompt. The external agent owns planning.")}function Gn(e,t){return go(t)?t:Vn(e,t)}function xo(){return W(ni(),".inkly","capture-agent","profiles")}function eh(e,t){if(t.includes("/")||go(t))return Gn(e,t);let n=t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);return W(xo(),n||"default")}function lo(e,t){let n=Vn(e);for(;;){let r=W(n,t);if(je(r))return r;let i=Zn(n);if(i===n)return null;n=i}}async function co(e){let t=[e];for(;t.length>0;){let n=t.pop();if(!n)continue;let r=await mo(n,{withFileTypes:!0}).catch(()=>[]);for(let i of r){let a=W(n,i.name);if(i.isDirectory()){t.push(a);continue}if(i.name==="Google Chrome for Testing"&&a.includes("Google Chrome for Testing.app/Contents/MacOS"))return a}}return null}async function th(e,t){if(t){let s=Gn(e,t);if(je(s))return s;throw new Error(`Chrome binary does not exist: ${s}`)}let n=process.env.CHROME_PATH;if(n&&je(n))return n;let r=Vp.find(s=>je(s));if(r)return r;let i=lo(e,"chrome");if(i){let s=await co(i);if(s)return s}let a=lo(Wp,"chrome");if(a&&a!==i){let s=await co(a);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(je(s))return s;throw new Error("No Chrome binary found. Pass --browser /path/to/chrome.")}var Jn=class{constructor(t){this.nextId=1;this.pending=new Map;this.listeners=new Map;this.ws=new Up(t,{perMessageDeflate:!1,maxPayload:512*1024*1024}),this.ready=new Promise((n,r)=>{this.ws.once("open",()=>n()),this.ws.once("error",i=>r(i))}),this.ws.on("message",n=>{let r=JSON.parse(n.toString());if(typeof r.id=="number"&&this.pending.has(r.id)){let a=this.pending.get(r.id);if(this.pending.delete(r.id),!a)return;r.error?a.reject(new Error(`${r.error.message??"CDP error"}: ${JSON.stringify(r.error.data??"")}`)):a.resolve(r.result??{});return}if(!r.method)return;let i=this.listeners.get(r.method);if(i)for(let a of i)a(r.params,r.sessionId)})}async send(t,n={},r){await this.ready;let i=this.nextId;this.nextId+=1;let a={id:i,method:t,params:n};return r&&(a.sessionId=r),new Promise((o,s)=>{this.pending.set(i,{resolve:o,reject:s}),this.ws.send(JSON.stringify(a),c=>{c&&(this.pending.delete(i),s(c))})})}on(t,n){let r=this.listeners.get(t)??new Set;return r.add(n),this.listeners.set(t,r),()=>r.delete(n)}close(){try{this.ws.close()}catch{}}};async function ko(e,t,n,r=3e4){let i=await e.send("Runtime.evaluate",{expression:n,awaitPromise:!0,returnByValue:!0,timeout:r,userGesture:!0},t);if(i.exceptionDetails)throw new Error(`Runtime.evaluate failed: ${JSON.stringify(i.exceptionDetails)}`);return i.result?.value}async function nh(e,t){let r=(await e.send("Target.attachToTarget",{targetId:t,flatten:!0})).sessionId;if(typeof r!="string")throw new Error("Target.attachToTarget returned no sessionId");return r}async function rh(e){let t=e.userDataDir?(await Ht(e.userDataDir,{recursive:!0}),e.userDataDir):await Np(W(Lp(),"inkly-capture-agent-")),n=W(t,"chrome.log"),r=await ho(n,"a"),i=["--remote-debugging-port=0",`--user-data-dir=${t}`,`--window-size=${e.width},${e.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"];e.headless&&i.unshift("--headless=new");for(let p of["DevToolsActivePort","SingletonLock","SingletonCookie","SingletonSocket"])await fe(W(t,p),{force:!0}).catch(()=>{});let a=po(e.browser,i,{detached:!0,stdio:["ignore",r.fd,r.fd]});a.unref(),await r.close();let o=W(t,"DevToolsActivePort"),s=Date.now(),c;a.once("exit",p=>{c=p});let d=!e.userDataDir,u=async p=>{let h=await _e(n,"utf8").then(f=>f.split(`
|
|
5191
|
+
`).filter(Boolean).slice(-10).join(`
|
|
5192
|
+
`)).catch(()=>"");throw a.pid&&await Qr(a.pid).catch(()=>{}),await vo(t).catch(()=>{}),d&&await fe(t,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),new Error(`${p} Chrome log (${n}):
|
|
5193
|
+
${h||"(empty \u2014 Chrome wrote nothing)"}`)};for(;Date.now()-s<2e4;){if(c!==void 0)return u("Chrome exited before DevTools was ready.");let p=await _e(o,"utf8").catch(()=>null);if(p){let h=p.trim().split(/\r?\n/),f=h[0],w=h[1];if(f&&w)return{pid:a.pid??null,profileDir:t,wsUrl:`ws://127.0.0.1:${f}${w}`,debuggingUrl:`http://127.0.0.1:${f}`,logPath:n}}await Bt(100)}return u("Timed out waiting for Chrome DevTools.")}async function ih(e){if(e.startsWith("ws://")||e.startsWith("wss://")){let i=new URL(e);return{wsUrl:e,debuggingUrl:`${i.protocol==="wss:"?"https":"http"}://${i.host}`}}let t=new URL(e),n=await fetch(new URL("/json/version",t));if(!n.ok)throw new Error(`could not read Chrome DevTools metadata from ${t.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:`${t.protocol}//${t.host}`}}async function ah(e,t,n,r,i){let o=(await e.send("Target.createTarget",{url:"about:blank"})).targetId;if(typeof o!="string")throw new Error("Target.createTarget returned no targetId");let s=await nh(e,o);await e.send("Page.enable",{},s),await e.send("Runtime.enable",{},s),await sh(e,s,o,n,r);let c=!1,d=e.on("Page.loadEventFired",(p,h)=>{h===s&&(c=!0)});await e.send("Page.navigate",{url:t},s);let u=Date.now();for(;!c&&Date.now()-u<i;)await Bt(100);return d(),await Bt(1e3),{targetId:o,sessionId:s}}async function oh(e,t){let n=await ko(e,t,`JSON.stringify({
|
|
5157
5194
|
innerWidth: window.innerWidth,
|
|
5158
5195
|
innerHeight: window.innerHeight,
|
|
5159
5196
|
outerWidth: window.outerWidth,
|
|
5160
5197
|
outerHeight: window.outerHeight
|
|
5161
|
-
})`,5e3),r=JSON.parse(String(n)),
|
|
5198
|
+
})`,5e3),r=JSON.parse(String(n)),i={innerWidth:Number(r.innerWidth),innerHeight:Number(r.innerHeight),outerWidth:Number(r.outerWidth),outerHeight:Number(r.outerHeight)};if(!Number.isFinite(i.innerWidth)||!Number.isFinite(i.innerHeight)||!Number.isFinite(i.outerWidth)||!Number.isFinite(i.outerHeight))throw new Error(`could not measure Chrome viewport: ${JSON.stringify(r)}`);return i}async function sh(e,t,n,r,i){try{let o=(await e.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 oh(e,t),d=Math.max(0,c.outerWidth-c.innerWidth),u=Math.max(0,c.outerHeight-c.innerHeight),p=r+d,h=i+u;if(Math.abs(c.innerWidth-r)<=1&&Math.abs(c.innerHeight-i)<=1)return;await e.send("Browser.setWindowBounds",{windowId:o,bounds:{windowState:"normal",width:p,height:h}}),await Bt(250)}}catch{}await e.send("Emulation.setDeviceMetricsOverride",{width:r,height:i,deviceScaleFactor:1,mobile:!1},t).catch(()=>{}),await Bt(100)}function lh(e){return e.toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"captured-demo"}function ch(e){return`${lh(e)}-${Math.random().toString(36).slice(2,8)}`}function ri(e){return $p("sha256").update(e).digest("hex")}function dh(e,t){return`# ${t}
|
|
5199
|
+
|
|
5200
|
+
This is a self-contained Inkly demo. Everything it needs is in this
|
|
5201
|
+
folder \u2014 no hub and no upload required to preview it.
|
|
5162
5202
|
|
|
5163
|
-
|
|
5164
|
-
agent runtime. It works locally with \`inkly-cli\` \u2014 no upload needed.
|
|
5203
|
+
## Preview it
|
|
5165
5204
|
|
|
5166
|
-
|
|
5205
|
+
Install the CLI once, then point \`inkly dev\` at this folder \u2014 no
|
|
5206
|
+
\`inkly init\` needed:
|
|
5167
5207
|
|
|
5168
|
-
|
|
5169
|
-
|
|
5208
|
+
\`\`\`bash
|
|
5209
|
+
npm install -g @inkly-org/cli
|
|
5210
|
+
inkly dev ${e}
|
|
5211
|
+
\`\`\`
|
|
5170
5212
|
|
|
5171
|
-
|
|
5213
|
+
It serves at http://localhost:3000.
|
|
5172
5214
|
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5215
|
+
## Host it in a hub
|
|
5216
|
+
|
|
5217
|
+
To keep all your demos together as a collection and sync them with the
|
|
5218
|
+
Inkly platform, scaffold a hub and drop this demo into it:
|
|
5219
|
+
|
|
5220
|
+
\`\`\`bash
|
|
5221
|
+
inkly init my-hub
|
|
5222
|
+
cp -r ${e} my-hub/demos/
|
|
5223
|
+
cd my-hub
|
|
5224
|
+
inkly login # connect your Inkly account
|
|
5225
|
+
inkly sync # upload assets to the CDN
|
|
5226
|
+
\`\`\`
|
|
5227
|
+
|
|
5228
|
+
## Publish a shareable link
|
|
5229
|
+
|
|
5230
|
+
From inside the hub (and once logged in), freeze this demo to a
|
|
5231
|
+
standalone, hosted \`/p/<id>\` URL you can share with anyone:
|
|
5232
|
+
|
|
5233
|
+
\`\`\`bash
|
|
5234
|
+
inkly snapshot --demo ${e}
|
|
5235
|
+
\`\`\`
|
|
5176
5236
|
|
|
5177
5237
|
## What's inside
|
|
5178
5238
|
|
|
5179
|
-
- \`${
|
|
5180
|
-
- \`${
|
|
5181
|
-
- \`${
|
|
5182
|
-
|
|
5183
|
-
`
|
|
5184
|
-
`),"assets.
|
|
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=`(() => {
|
|
5239
|
+
- \`${e}/demo.config.json\` \u2014 the demo definition.
|
|
5240
|
+
- \`${e}/assets.json\` \u2014 maps each \`asset:<id>\` to a file in \`public/\`.
|
|
5241
|
+
- \`${e}/public/<file>\` \u2014 captured image/video bytes.
|
|
5242
|
+
`}function uh(e){switch(e.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 ph(e,t,n,r,i){let a=new TextDecoder,o=new TextEncoder,s=new Map,c=0,d=0,u=0,p=" ";if(i.subsetFonts){let h=new Set;for(let f of Object.values(r)){let w=f["index.html"];if(!w)continue;let x=a.decode(w).replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ");for(let _ of x)h.add(_)}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 t){let f=h.publicUrl;if(!f)continue;let w=f.split("/").pop();if(!w)continue;let x=n[w];if(!x)continue;let _=null,P="",$="",R=(h.contentType??"").toLowerCase();try{if(i.compressImages&&h.kind==="image"&&/^image\/(png|jpe?g)$/.test(R)){let V=await zp(Buffer.from(x)).webp({quality:80}).toBuffer();V.length<x.byteLength&&(_=V,P="webp",$="image/webp")}else if(i.subsetFonts&&h.kind==="font"){let V=await Fp(Buffer.from(x),p,{targetFormat:"woff2"});V.length<x.byteLength&&(_=V,P="woff2",$="font/woff2")}}catch{_=null}if(!_)continue;let b=new Uint8Array(_),U=ri(b),z=`${U.slice(0,16)}.${P}`,D=`/${e}/${z}`;u+=x.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=U,h.size=b.byteLength,h.contentType=$,h.publicUrl=D}if(s.size)for(let h of Object.values(r)){let f=h;for(let w of Object.keys(f)){let x=a.decode(f[w]);for(let[_,P]of s)x=x.split(_).join(P);f[w]=o.encode(x)}}return{images:c,fonts:d,savedBytes:u}}async function hh(e){let{name:t,screens:n,autoApplyZoom:r=!0,compressImages:i=!1,subsetFonts:a=!1}=e;if(n.length===0)throw new Error("No screens captured.");let o=ch(t),s=[],c=[],d={},u={},p=[],h=[],f=new TextEncoder,w=0;async function x(R,b,U,z,D){let V=ri(R),ne=D??`${V}.${uh(b)}`;d[ne]=R,w+=1;let Ce=U==="other"?ne:`cap-${String(w).padStart(3,"0")}`;return s.push({id:Ce,sha256:V,kind:U==="other"?wn(b):U,contentType:b,size:R.byteLength,viewport:z?{w:z.width,h:z.height}:void 0,file:ne}),Ce}for(let[R,b]of n.entries()){let U=`s${R+1}`,z=null;if(b.kind!=="html"){if(b.kind==="video"&&b.videoPath){let D=new Uint8Array(await _e(b.videoPath));z=await x(D,"video/webm","video",b.viewport);let V;if(b.posterPngPath){let ne=new Uint8Array(await _e(b.posterPngPath));V=await x(ne,"image/png","image",b.viewport)}p.push(lr({stepId:U,kind:"video",assetId:z,posterAssetId:V,naturalWidth:b.naturalSize.width,naturalHeight:b.naturalSize.height,sourceUrl:b.sourceUrl||void 0,title:b.title||void 0,click:b.click,autoApplyZoom:r,isLast:R===n.length-1})),h.push(b.click?.label||b.title||`Step ${R+1}`)}else{if(!b.pngPath)continue;let D=new Uint8Array(await _e(b.pngPath));z=await x(D,"image/png","image",b.viewport),p.push(lr({stepId:U,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:R===n.length-1})),h.push(b.click?.label||b.title||`Step ${R+1}`)}c.push({index:R,id:Ri(R),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.");(i||a)&&await ph(o,s,d,u,{compressImages:i,subsetFonts:a});let _=_n({id:se(),version:1,title:t,steps:p}),P=Rt.parse({version:1,assets:s,screens:c}),$={"README.md":f.encode(dh(o,t)),[o]:{"demo.config.json":f.encode(`${JSON.stringify(_,null,2)}
|
|
5243
|
+
`),"assets.json":f.encode(`${JSON.stringify(P,null,2)}
|
|
5244
|
+
`),public:d,snapshots:u}};return{bytes:jp($,{level:6}),filename:`${o}.zip`,slug:o,stepCount:n.length,labels:h}}function mh(e){return e?{x:e.x,y:e.y,alphaId:e.alphaId??void 0,label:e.label}:null}async function fh(e){let{name:t,screens:n}=e,r=n.filter(c=>c.kind==="html"&&c.htmlPath);if(r.length===0)throw new Error("No HTML screens captured.");let i=r.map((c,d)=>c.click?.label||c.title||`Step ${d+1}`);Bp();let a=[],o=new Map;for(let c of r){let d=await _e(c.htmlPath,"utf8"),u=await ao(d,c.sourceUrl||"");for(let p of u.assets)o.has(p.filename)||o.set(p.filename,{filename:p.filename,sha256:ri(p.bytes),contentType:p.contentType,bytes:p.bytes});a.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:mh(c.click)})}return{...await oo({name:t,steps:a,assets:[...o.values()]}),stepCount:r.length,labels:i}}var uo=`(() => {
|
|
5186
5245
|
if (window.__inklyCliRecorderInstalled) return;
|
|
5187
5246
|
window.__inklyCliRecorderInstalled = true;
|
|
5188
5247
|
window.__inklyCliLastClick = null;
|
|
@@ -5366,7 +5425,7 @@ function selectorFor(el) {
|
|
|
5366
5425
|
window.addEventListener("scroll", onMotionScroll, true);
|
|
5367
5426
|
window.addEventListener("wheel", onMotionScroll, true);
|
|
5368
5427
|
window.addEventListener("touchmove", onMotionScroll, true);
|
|
5369
|
-
})();`;async function
|
|
5428
|
+
})();`;async function gh(e,t,n=!1){n&&(await e.send("Runtime.addBinding",{name:"__inklyCliCaptureEvent"},t).catch(()=>{}),await e.send("Runtime.addBinding",{name:"__inklyCliCaptureClick"},t).catch(()=>{})),await e.send("Page.addScriptToEvaluateOnNewDocument",{source:uo},t),await ko(e,t,uo,5e3).catch(()=>{})}var bh="__inklySingleFileFetch",Hy=`(() => {
|
|
5370
5429
|
if (globalThis.__inklyFetchInstalled) return;
|
|
5371
5430
|
globalThis.__inklyFetchInstalled = true;
|
|
5372
5431
|
const pending = new Map();
|
|
@@ -5386,7 +5445,7 @@ function selectorFor(el) {
|
|
|
5386
5445
|
const id = nextId++;
|
|
5387
5446
|
pending.set(id, { resolve, reject });
|
|
5388
5447
|
try {
|
|
5389
|
-
globalThis.${
|
|
5448
|
+
globalThis.${bh}(JSON.stringify({
|
|
5390
5449
|
id,
|
|
5391
5450
|
url: String(url),
|
|
5392
5451
|
options: {
|
|
@@ -5409,14 +5468,97 @@ function selectorFor(el) {
|
|
|
5409
5468
|
return viaNode(url, options);
|
|
5410
5469
|
}
|
|
5411
5470
|
};
|
|
5412
|
-
})();`;var
|
|
5413
|
-
`)}async function
|
|
5414
|
-
`)}async function
|
|
5415
|
-
`).map(o=>Number(o.trim())).filter(o=>Number.isInteger(o)&&o>0&&o!==process.pid);n(
|
|
5471
|
+
})();`;var By=Math.max(6e4,Number(process.env.INKLY_CAPTURE_TIMEOUT_MS)||24e4);function ii(){return W(process.env.INKLY_CAPTURE_AGENT_HOME||W(ni(),".inkly"),"capture-agent","sessions")}function yh(e){return W(process.env.INKLY_CAPTURE_AGENT_HOME||W(ni(),".inkly"),"capture-agent","captures",e)}async function xh(e,t){await Ht(t,{recursive:!0});let n=W(t,"listener.log"),r=await ho(n,"a"),i=bo(import.meta.url),a=W(Zn(i),"capture-listener.js"),o=po(process.execPath,[a,"--session",e],{detached:!0,stdio:["ignore",r.fd,r.fd]});return o.unref(),await r.close(),{pid:o.pid??null,logPath:n}}async function kh(e,t){let n=Date.now();for(;Date.now()-n<t;){let r=await Ke(e).catch(()=>null);if(r?.cliListenerReadyAt)return r;await Bt(100)}return Ke(e)}function Kn(e){if(!/^[a-zA-Z0-9._:-]+$/.test(e))throw new Error(`invalid session id: ${e}`);return W(ii(),`${e}.json`)}function ai(e){return W(ii(),`${e}.listener.json`)}async function wh(e,t){await te(ai(e),`${JSON.stringify(t,null,2)}
|
|
5472
|
+
`)}async function vh(e){try{let t=await _e(ai(e),"utf8");return JSON.parse(t)}catch{return null}}async function Sh(e){await te(Kn(e.id),`${JSON.stringify(e,null,2)}
|
|
5473
|
+
`)}async function Ke(e){let t=await _e(Kn(e),"utf8");return JSON.parse(t)}async function Xr(e){await fe(Kn(e),{force:!0}),await fe(ai(e),{force:!0}),await fe(Kr(e),{force:!0}).catch(()=>{}),await fe(Yn(e),{force:!0}).catch(()=>{})}function wo(e){try{return process.kill(e,0),!0}catch{return!1}}async function Qr(e){let t=(n,r)=>{try{process.kill(n,r)}catch{}};t(-e,"SIGTERM"),t(e,"SIGTERM");for(let n=0;n<8&&wo(e);n+=1)await new Promise(r=>setTimeout(r,100));t(-e,"SIGKILL"),t(e,"SIGKILL")}async function vo(e){if(!e||!e.includes("inkly"))return;let t=await new Promise(n=>{Rp("pgrep",["-f","--",e],{timeout:4e3},(r,i)=>{let a=String(i||"").split(`
|
|
5474
|
+
`).map(o=>Number(o.trim())).filter(o=>Number.isInteger(o)&&o>0&&o!==process.pid);n(a)})});for(let n of t)try{process.kill(n,"SIGKILL")}catch{}}async function _h(e){if(!e)return;let t=null;try{t=new Jn(e),await Promise.race([t.send("Browser.close"),new Promise((n,r)=>setTimeout(()=>r(new Error("Browser.close timed out")),2e3))])}catch{}finally{t?.close()}}async function cn(e){let t=e.cliListenerPid??null;!t&&e.id&&(t=(await vh(e.id))?.cliListenerPid??null),t&&await Qr(t),!e.attached&&(await _h(e.browserWsUrl),e.chromePid&&await Qr(e.chromePid),await vo(e.profileDir),e.keepProfile||e.profileDir&&await fe(e.profileDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}))}async function Ch(e,t,n,r){let i=Ge(t,"url",r),a=Ge(t,"name",r);new URL(i);let o=Yp(Se(t,"window-size")),s=o?.width??Yr(t,"width",Jp),c=o?.height??Yr(t,"height",qp),d=Yr(t,"timeout",Zp),u=Xp(t),p=Se(t,"runtime");if(p&&p!=="cli")throw new Error("--runtime must be cli");let h=n,f=Ft(t,["zoom","auto-apply-zoom"],!0),x=Ft(t,["record-video","video"],!0)&&h!=="html",_=Ft(t,["block-videos","block-video"],!1),P=Ft(t,["compress-images","compress-image"],!1),$=Ft(t,["subset-fonts","subset-font"],!1),R=Ft(t,["headless"],!0)&&t.headed!==!0,b=Se(t,"profile"),U=!u&&b?eh(e,b):null,z=U!=null&&je(W(U,"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 ih(u),logPath:null}:await(async()=>{let K=await th(e,Se(t,"browser"));return rh({browser:K,width:s,height:c,headless:R,timeoutMs:d,userDataDir:U})})(),V=new Jn(D.wsUrl),ne=null,Ce=!1,Wt=()=>{cn({id:"",runtime:"cli",createdAt:"",url:i,name:a,chromePid:D.pid,profileDir:D.profileDir,keepProfile:U!=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:ne,cliListenerLogPath:null,cliListenerReadyAt:null}).finally(()=>{process.exit(130)})};process.on("SIGINT",Wt),process.on("SIGTERM",Wt),Ce=!0;let L=()=>{Ce&&(process.removeListener("SIGINT",Wt),process.removeListener("SIGTERM",Wt),Ce=!1)};try{await V.send("Target.setDiscoverTargets",{discover:!0}).catch(()=>{});let K=await ah(V,i,s,c,d);await V.send("Target.activateTarget",{targetId:K.targetId}).catch(()=>{});let ge=Dp();await gh(V,K.sessionId);let A=yh(ge),le={id:ge,runtime:"cli",createdAt:new Date().toISOString(),url:i,name:a,chromePid:D.pid,profileDir:D.profileDir,keepProfile:u?!0:U!=null||t["keep-profile"]===!0,browserWsUrl:D.wsUrl,browserDebuggingUrl:D.debuggingUrl,chromeLogPath:D.logPath,attached:!!u,tabId:0,tabUrl:i,targetId:K.targetId,width:s,height:c,cliScreens:[],cliCaptureKind:h,cliRecordVideo:x,cliHeadless:u?!1:R,cliBlockVideos:h==="html"?_:!1,cliCompressImages:h==="image"?P:!1,cliSubsetFonts:h==="image"?$:!1,autoApplyZoom:f,captureDir:A,cliListenerPid:null,cliListenerLogPath:null,cliListenerReadyAt:null};await Ht(A,{recursive:!0}),await Sh(le);let Ye=await xh(le.id,A);ne=Ye.pid,await wh(le.id,{cliListenerPid:Ye.pid,cliListenerLogPath:Ye.logPath});let N=15e3,O=await kh(le.id,N);if(!O.cliListenerReadyAt){let vt=async M=>M?_e(M,"utf8").then(J=>J.split(`
|
|
5416
5475
|
`).filter(Boolean).slice(-12).join(`
|
|
5417
|
-
`)
|
|
5418
|
-
|
|
5419
|
-
|
|
5476
|
+
`)).catch(()=>""):"",E=await vt(Ye.logPath),F=await vt(O.chromeLogPath??D.logPath);throw new Error(`capture recorder failed to arm within ${N/1e3}s (listenerReadyAt is null). Every click would be silently dropped, so this session is unusable.
|
|
5477
|
+
Listener log (${Ye.logPath}):
|
|
5478
|
+
${E||"(empty)"}
|
|
5479
|
+
Chrome log (${O.chromeLogPath??D.logPath}):
|
|
5480
|
+
${F||"(empty)"}`)}return await B("inkly_cli_capture_session_started",{runtime:"cli",capture_kind:O.cliCaptureKind??h,record_video:O.cliRecordVideo===!0,auto_apply_zoom:O.autoApplyZoom!==!1,window_width:O.width,window_height:O.height,headless:u?null:R,attached:O.attached,persistent_profile:U!=null,profile_reused:z,connect_to_browser:!!u}),L(),Q({ok:!0,mode:"cli",session:{id:O.id,stateFile:Kn(O.id),createdAt:O.createdAt},browser:{pid:O.chromePid,debuggingUrl:O.browserDebuggingUrl,webSocketDebuggerUrl:O.browserWsUrl,headless:u?null:R,attached:O.attached,profile:U?{dir:U,persistent:!0,reused:z}:null},tab:{targetId:O.targetId,url:O.tabUrl},capture:{kind:O.cliCaptureKind??"image",video:O.cliRecordVideo===!0,recordVideo:O.cliRecordVideo===!0,autoApplyZoom:O.autoApplyZoom!==!1,window:{width:O.width,height:O.height},stepCount:0,automatic:!0,listenerPid:O.cliListenerPid??Ye.pid,listenerReadyAt:O.cliListenerReadyAt}}),0}catch(K){throw await cn({id:"",runtime:"cli",createdAt:"",url:i,name:a,chromePid:D.pid,profileDir:D.profileDir,keepProfile:U!=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:ne,cliListenerLogPath:null,cliListenerReadyAt:null}),K}finally{L(),V.close()}}async function Th(e,t){let n=Op(new Uint8Array(e)),r=Vn(t);await Ht(r,{recursive:!0});for(let[i,a]of Object.entries(n)){let o=i.replace(/\\/g,"/");if(!o||o.endsWith("/"))continue;let s=Vn(r,o);if(s!==r&&!s.startsWith(r+Mp))throw new Error(`Unsafe zip entry: ${i}`);await Ht(Zn(s),{recursive:!0}),await fo(s,Buffer.from(a))}}async function Ah(e,t,n){let r=Ge(t,"session",n),i=Ge(t,"out",n),a=Gn(e,i),o=await Ke(r),s=await oi(r),c=qn(o.cliScreens??[],s);if(c.length===0)return await cn(o),o.captureDir&&await fe(o.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Xr(o.id),await ei(o.id),await B("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}),Q({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 fh({name:o.name,screens:c}):await hh({name:o.name,screens:c,autoApplyZoom:o.autoApplyZoom!==!1,compressImages:o.cliCompressImages===!0,subsetFonts:o.cliSubsetFonts===!0});await Ht(a,{recursive:!0});let p=Buffer.from(u.bytes),h=W(a,u.filename);await fo(h,p);let f=null;return t["no-unpack"]!==!0&&(await Th(p,a),f=W(a,u.slug)),await cn(o),o.captureDir&&await fe(o.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Xr(o.id),await ei(o.id),await B("inkly_cli_capture_session_stopped",{runtime:"cli",capture_kind:o.cliCaptureKind??"image",step_count:u.stepCount,output_bytes:p.byteLength,unpacked:t["no-unpack"]!==!0,record_video:o.cliRecordVideo===!0,auto_apply_zoom:o.autoApplyZoom!==!1}),Q({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(e,t){let n=Ge(e,"session",t),r=await Ke(n);return await cn(r),r.captureDir&&await fe(r.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Xr(r.id),await ei(r.id),await B("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}),Q({ok:!0,mode:"cli",session:{id:r.id}}),0}function So(e){return e.pngPath||e.videoPath||e.htmlPath||e.posterPngPath||`t:${e.capturedAt??""}`}function Yn(e){return W(ii(),`${e}.undo.json`)}async function oi(e){try{let t=JSON.parse(await _e(Yn(e),"utf8"));return Array.isArray(t.droppedKeys)?t.droppedKeys.filter(n=>typeof n=="string"):[]}catch{return[]}}function qn(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(r=>!n.has(So(r)))}async function ei(e){await fe(Yn(e),{force:!0}).catch(()=>{})}function ti(e,t){return e.click?.label||e.title||`Step ${t+1}`}async function Ph(e,t){let n=Ge(e,"session",t),r=await Ke(n),i=await oi(n),a=qn(r.cliScreens??[],i);if(a.length===0)return Q({ok:!1,mode:"cli",session:{id:r.id},error:"No recorded step to undo.",capture:{stepCount:0}}),1;let o=a[a.length-1],s=ti(o,a.length-1);i.push(So(o)),await te(Yn(n),`${JSON.stringify({droppedKeys:i},null,2)}
|
|
5481
|
+
`);let c=qn(r.cliScreens??[],i);return Q({ok:!0,mode:"cli",session:{id:r.id},capture:{undone:s,stepCount:c.length,stepLabels:c.map((d,u)=>ti(d,u))}}),0}async function Eh(e,t){let n=Ge(e,"session",t),r=await Ke(n),i=await oi(n),a=qn(r.cliScreens??[],i),o=a.map((c,d)=>ti(c,d)),s=a.map((c,d)=>({index:d+1,label:o[d],url:c.sourceUrl||null,kind:c.kind??"image"}));return Q({ok:!0,mode:"cli",session:{id:r.id},capture:{kind:r.cliCaptureKind??"image",ready:!!r.cliListenerReadyAt,browserAlive:r.attached?null:!!(r.chromePid&&wo(r.chromePid)),listenerReadyAt:r.cliListenerReadyAt??null,stepCount:a.length,stepLabels:o,lastLabel:o[o.length-1]??null,steps:s}}),0}async function Xn(e){let{cwd:t,subcommand:n,args:r,kind:i,usage:a}=e;switch(Qp(r),await B("inkly_cli_capture_command_invoked",{capture_kind:i,subcommand:n??"(none)"}),n){case"start":return Ch(t,r,i,a);case"stop":return Ah(t,r,a);case"cancel":return Ih(r,a);case"status":return Eh(r,a);case"undo":return Ph(r,a);case"profiles":return Mh();case"nav":return Dh(r);default:return process.stdout.write(a),1}}var X=`inkly capture nav - drive the captured browser (Stagehand)
|
|
5482
|
+
|
|
5483
|
+
Usage:
|
|
5484
|
+
inkly capture nav snapshot --session <id> [--full] [--filter <t|/re/>] [--max-depth <n>] [--json]
|
|
5485
|
+
inkly capture nav refs --session <id>
|
|
5486
|
+
inkly capture nav click <selector> --session <id> [--no-snapshot] [--json]
|
|
5487
|
+
inkly capture nav fill <selector> <value> --session <id> [--enter] [--no-snapshot]
|
|
5488
|
+
inkly capture nav type <text> --session <id> [--delay <ms>] [--no-snapshot]
|
|
5489
|
+
inkly capture nav press <key> --session <id> (alias: key)
|
|
5490
|
+
inkly capture nav select <selector> <value...> --session <id>
|
|
5491
|
+
inkly capture nav scroll <down|up> [pixels] --session <id> (scenic scroll / video over on-screen content; a click auto-scrolls to its own target)
|
|
5492
|
+
inkly capture nav upload <selector> <file...> --session <id>
|
|
5493
|
+
inkly capture nav get <url|title|text|html|value|visible|checked|markdown|box> [<selector>] --session <id>
|
|
5494
|
+
inkly capture nav is <visible|checked> <selector> --session <id>
|
|
5495
|
+
inkly capture nav wait <load|selector|timeout> [<arg>] --session <id> [--state <s>] [--timeout <ms>]
|
|
5496
|
+
inkly capture nav back --session <id> [--wait <state>] [--timeout <ms>]
|
|
5497
|
+
inkly capture nav forward --session <id> [--wait <state>] [--timeout <ms>]
|
|
5498
|
+
inkly capture nav reload --session <id> [--wait <state>] [--timeout <ms>]
|
|
5499
|
+
inkly capture nav mouse click <x> <y> --session <id> [--button <left|right|middle>]
|
|
5500
|
+
inkly capture nav mouse hover <x> <y> --session <id>
|
|
5501
|
+
inkly capture nav mouse scroll <x> <y> <deltaX> <deltaY> --session <id> (prefer \`nav scroll\`)
|
|
5502
|
+
|
|
5503
|
+
<selector> accepts a ref from the last snapshot (@0-12, [0-12], ref=0-12, 0-12)
|
|
5504
|
+
or an XPath/CSS selector. Run \`nav snapshot\` first to populate refs.
|
|
5505
|
+
--wait / wait <load> arg accepts load | domcontentloaded | networkidle.
|
|
5506
|
+
|
|
5507
|
+
Output:
|
|
5508
|
+
\`snapshot\` prints a plain indented accessibility tree (roles + names + @refs)
|
|
5509
|
+
straight to stdout \u2014 no JSON, no maps; read refs directly from it. Action verbs
|
|
5510
|
+
(click/fill/type/select/scroll/back/...) print a one-line status header
|
|
5511
|
+
(\`ok | url=\u2026 | steps=N | <label>\`) then the FRESH trimmed tree, so you rarely
|
|
5512
|
+
need a standalone snapshot. Read the WHOLE returned tree \u2014 do NOT pipe through
|
|
5513
|
+
\`head\`/\`sed\` (truncating it cuts the refs and forces a wasteful re-snapshot);
|
|
5514
|
+
bound a long tree with \`--filter\`/\`--max-depth\` instead. Add \`--full\` to
|
|
5515
|
+
snapshot for the untrimmed tree, \`--no-snapshot\` to suppress the post-action
|
|
5516
|
+
tree, and \`--json\` for the structured object (with urlMap/xpathMap on snapshot).
|
|
5517
|
+
A driving verb fires real browser input, which the recorder captures as a step \u2014
|
|
5518
|
+
nav never writes steps.
|
|
5519
|
+
`;async function Rh(e){let n=(await Ke(e).catch(()=>null))?.cliScreens??[],r=n[n.length-1];return{steps:n.length,lastLabel:r&&(r.click?.label||r.title)||null,lastKind:r?.kind??null}}function si(e){return e.json===!0}function Le(e){return e["no-snapshot"]===!0||e.snapshot===!1}function $h(e,t){if(si(t)){Q({ok:!0,...e});return}let n=typeof e.tree=="string"?e.tree:"";process.stdout.write(`${n}
|
|
5520
|
+
`)}async function Oe(e,t,n){if(si(t)){Q({ok:!0,...e});return}let r=e,i=r.steps!==void 0?{steps:r.steps,lastLabel:r.lastLabel??null}:await Rh(n),a=r.snapshot?.url??"",o=["ok"];a&&o.push(`url=${a}`),i.steps!==null&&o.push(`steps=${i.steps}`),i.lastLabel&&o.push(i.lastLabel),process.stdout.write(`${o.join(" | ")}
|
|
5521
|
+
`);let s=r.snapshot?.tree;typeof s=="string"&&s.length>0&&process.stdout.write(`${s}
|
|
5522
|
+
`)}async function Dh(e){let t=typeof e._[2]=="string"?e._[2]:void 0;if(!t)return process.stdout.write(X),1;let n=Ge(e,"session",X),r=await Ke(n).catch(()=>null);if(!r)throw new Error(`no capture session "${n}" \u2014 run \`inkly capture start\` first`);if(r.runtime!=="cli")throw new Error("nav is only available for cli runtime sessions");let i=Kr(n);switch(t){case"snapshot":{let a=await G(i,"snapshot",{full:e.full===!0,json:si(e),filter:Se(e,"filter"),maxDepth:Wn(e,"max-depth")});return $h(a,e),0}case"refs":{let a=await G(i,"refs",{});return Q({ok:!0,...a}),0}case"click":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(!a)throw new Error(`nav click requires a <selector>
|
|
5523
|
+
|
|
5524
|
+
`+X);let o=await G(i,"click",{selector:a,noSnapshot:Le(e)});return await Oe(o,e,n),0}case"fill":{let a=typeof e._[3]=="string"?e._[3]:void 0,o=typeof e._[4]=="string"?e._[4]:void 0;if(!a||o===void 0)throw new Error(`nav fill requires <selector> <value>
|
|
5525
|
+
|
|
5526
|
+
`+X);let s=await G(i,"fill",{selector:a,value:o,pressEnter:e.enter===!0,noSnapshot:Le(e)});return await Oe(s,e,n),0}case"type":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(a===void 0)throw new Error(`nav type requires <text>
|
|
5527
|
+
|
|
5528
|
+
`+X);let o=await G(i,"type",{text:a,delay:Wn(e,"delay"),noSnapshot:Le(e)});return await Oe(o,e,n),0}case"press":case"key":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(!a)throw new Error(`nav press requires a <key>
|
|
5529
|
+
|
|
5530
|
+
`+X);let o=await G(i,"key",{key:a,noSnapshot:Le(e)});return await Oe(o,e,n),0}case"scroll":{let o=(typeof e._[3]=="string"?e._[3]:void 0)==="up"?"up":"down",s=ln(e._[4]),c=await G(i,"scroll",{direction:o,amount:s!==void 0&&s>0?s:void 0,noSnapshot:Le(e)});return await Oe(c,e,n),0}case"select":{let a=typeof e._[3]=="string"?e._[3]:void 0,o=e._.slice(4).filter(c=>typeof c=="string");if(!a||o.length===0)throw new Error(`nav select requires <selector> <value...>
|
|
5531
|
+
|
|
5532
|
+
`+X);let s=await G(i,"select",{selector:a,values:o,noSnapshot:Le(e)});return await Oe(s,e,n),0}case"upload":{let a=typeof e._[3]=="string"?e._[3]:void 0,o=e._.slice(4).filter(c=>typeof c=="string").map(c=>Gn(process.cwd(),c));if(!a||o.length===0)throw new Error(`nav upload requires <selector> <file...>
|
|
5533
|
+
|
|
5534
|
+
`+X);let s=await G(i,"upload",{selector:a,files:o});return Q({ok:!0,...s}),0}case"get":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(!a)throw new Error(`nav get requires a target
|
|
5535
|
+
|
|
5536
|
+
`+X);let o=typeof e._[4]=="string"?e._[4]:void 0,s=await G(i,"get",{what:a,selector:o});return Q({ok:!0,...s}),0}case"is":{let a=typeof e._[3]=="string"?e._[3]:void 0,o=typeof e._[4]=="string"?e._[4]:void 0;if(!a||!o)throw new Error(`nav is requires <visible|checked> <selector>
|
|
5537
|
+
|
|
5538
|
+
`+X);let s=await G(i,"is",{check:a,selector:o});return Q({ok:!0,...s}),0}case"wait":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(!a)throw new Error(`nav wait requires <load|selector|timeout>
|
|
5539
|
+
|
|
5540
|
+
`+X);let o=/^\d+$/.test(a),s=o?"timeout":a,c=o?a:typeof e._[4]=="string"?e._[4]:void 0,d=await G(i,"wait",{type:s,arg:c,state:Se(e,"state"),timeoutMs:Wn(e,"timeout")});return Q({ok:!0,...d}),0}case"back":case"forward":case"reload":{let a=await G(i,t,{waitUntil:Se(e,"wait"),timeoutMs:Wn(e,"timeout"),noSnapshot:Le(e)});return await Oe(a,e,n),0}case"mouse":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(a==="click"){let o=ln(e._[4]),s=ln(e._[5]);if(o===void 0||s===void 0)throw new Error(`nav mouse click requires <x> <y>
|
|
5541
|
+
|
|
5542
|
+
`+X);let c=await G(i,"mouse.click",{x:o,y:s,button:Se(e,"button"),noSnapshot:Le(e)});return await Oe(c,e,n),0}if(a==="hover"){let o=ln(e._[4]),s=ln(e._[5]);if(o===void 0||s===void 0)throw new Error(`nav mouse hover requires <x> <y>
|
|
5543
|
+
|
|
5544
|
+
`+X);let c=await G(i,"mouse.hover",{x:o,y:s});return Q({ok:!0,...c}),0}if(a==="scroll"){let o=Nh(),s=o[0],c=o[1],d=o[2],u=o[3];if(s===void 0||c===void 0||d===void 0||u===void 0)throw new Error(`nav mouse scroll requires <x> <y> <deltaX> <deltaY>
|
|
5545
|
+
|
|
5546
|
+
`+X);let p=await G(i,"mouse.scroll",{x:s,y:c,deltaX:d,deltaY:u,noSnapshot:Le(e)});return await Oe(p,e,n),0}throw new Error(`nav mouse requires <click|hover|scroll>
|
|
5547
|
+
|
|
5548
|
+
`+X)}default:return process.stdout.write(X),1}}function ln(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}}function Nh(){let e=process.argv.slice(2),t=e.findIndex(r=>r==="scroll"),n=[];if(t!==-1)for(let r=t+1;r<e.length&&n.length<4;r+=1){let i=e[r];if(i.startsWith("--"))break;/^-?\d+(\.\d+)?$/.test(i)&&n.push(Number(i))}return[n[0],n[1],n[2],n[3]]}function Wn(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t],r=typeof n=="number"?n:Number(n);return Number.isFinite(r)?r:void 0}async function Mh(){let e=xo(),t=await mo(e,{withFileTypes:!0}).catch(()=>[]),n=[];for(let r of t){if(!r.isDirectory())continue;let i=W(e,r.name),a=je(W(i,"Default")),o=je(W(i,"Default","Network","Cookies"))||je(W(i,"Default","Cookies"));n.push({name:r.name,dir:i,initialized:a,hasCookies:o})}return await B("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}),Q({ok:!0,profilesDir:e,profiles:n}),0}async function _o(e){let{cwd:t,subcommand:n,args:r}=e;if(r.html===!0)throw new Error("inkly capture is image/video only. For HTML snapshot capture use `inkly capture-html`.");for(let i of["block-videos","block-video","compress-images","compress-image","subset-fonts","subset-font"])if(Object.prototype.hasOwnProperty.call(r,i))throw new Error(`--${i} only applies to HTML capture. Use \`inkly capture-html --${i}\`.`);return Xn({cwd:t,subcommand:n,args:r,kind:"image",usage:dn})}async function Co(e){let{cwd:t,subcommand:n,args:r}=e;return Xn({cwd:t,subcommand:n,args:r,kind:"html",usage:un})}import{spawn as Lh}from"child_process";import{access as Oh,constants as jh}from"fs/promises";import{delimiter as Uh,dirname as zh,join as To}from"path";import{fileURLToPath as Fh}from"url";var pn=`inkly skills \u2014 install the bundled Inkly CLI skill
|
|
5549
|
+
|
|
5550
|
+
Usage:
|
|
5551
|
+
inkly skills install
|
|
5552
|
+
|
|
5553
|
+
Installs the Inkly CLI agent skill into every AI coding agent detected on this
|
|
5554
|
+
machine (Claude Code, Cursor, Codex, and others) via the open \`skills\`
|
|
5555
|
+
ecosystem. Re-run any time to refresh the skill after a CLI upgrade.
|
|
5556
|
+
|
|
5557
|
+
Commands:
|
|
5558
|
+
install Install or refresh the bundled Inkly CLI skill.
|
|
5559
|
+
`;function Hh(){return To(zh(Fh(import.meta.url)),"skills","inkly")}async function Bh(e){let t=process.env.PATH;if(!t)return null;let n=process.platform==="win32"?(process.env.PATHEXT||".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean):[""];for(let r of t.split(Uh))for(let i of n){let a=To(r,`${e}${i.toLowerCase()}`);try{return await Oh(a,jh.X_OK),a}catch{}}return null}function Wh(e){return process.platform==="win32"&&/\.(?:bat|cmd)$/i.test(e)}async function Vh(e,t){return await new Promise((n,r)=>{let i=Lh(e,t,{stdio:"inherit",shell:Wh(e)});i.on("error",r),i.on("close",(a,o)=>{if(o){n(1);return}n(a??0)})})}async function Jh(){let e=await Bh("npx");return e?await Vh(e,["--yes","skills","add",Hh(),"--yes","--global","--agent","*"]):(process.stderr.write("`npx` is not installed. Install Node.js from https://nodejs.org, then rerun `inkly skills install`.\n"),1)}async function Ao(e){return e.help||!e.subcommand?(process.stdout.write(pn),e.help?0:1):e.subcommand==="install"?await Jh():(process.stderr.write(`inkly skills: unknown command "${e.subcommand}"
|
|
5560
|
+
|
|
5561
|
+
${pn}`),1)}var Po=`inkly \u2014 Inkly CLI
|
|
5420
5562
|
|
|
5421
5563
|
Usage:
|
|
5422
5564
|
inkly init <name> [--layout <layout>] Scaffold a new demo hub.
|
|
@@ -5435,10 +5577,11 @@ Usage:
|
|
|
5435
5577
|
inkly snapshot <demo> Publish a standalone snapshot of one demo.
|
|
5436
5578
|
inkly capture <command> Capture an image/video walkthrough for an agent.
|
|
5437
5579
|
inkly capture-html <command> Capture a self-contained HTML walkthrough.
|
|
5580
|
+
inkly skills install Install the Inkly CLI agent skill.
|
|
5438
5581
|
inkly help [command] Show CLI help.
|
|
5439
5582
|
|
|
5440
5583
|
Run \`inkly <command> --help\` for more.
|
|
5441
|
-
`,
|
|
5584
|
+
`,ci=`inkly init \u2014 scaffold a new demo hub
|
|
5442
5585
|
|
|
5443
5586
|
Usage:
|
|
5444
5587
|
inkly init <name> [--layout <layout>]
|
|
@@ -5449,7 +5592,7 @@ Arguments:
|
|
|
5449
5592
|
Options:
|
|
5450
5593
|
--layout <layout> Hub index layout to write to inkly.json.
|
|
5451
5594
|
One of: sidebar, tabs.
|
|
5452
|
-
`,
|
|
5595
|
+
`,Eo=`inkly add \u2014 scaffold a new demo in the current hub
|
|
5453
5596
|
|
|
5454
5597
|
Usage:
|
|
5455
5598
|
inkly add <name> [--collection <name>]
|
|
@@ -5463,7 +5606,7 @@ Options:
|
|
|
5463
5606
|
--collection <name> Add the demo to this collection in inkly.json.
|
|
5464
5607
|
Creates the collection if it doesn't exist. When
|
|
5465
5608
|
omitted, the demo is not added to any collection.
|
|
5466
|
-
`,
|
|
5609
|
+
`,Ro=`inkly demo \u2014 alias of \`inkly add\`
|
|
5467
5610
|
|
|
5468
5611
|
Usage:
|
|
5469
5612
|
inkly demo <slug> [--collection <name>]
|
|
@@ -5475,7 +5618,7 @@ Options:
|
|
|
5475
5618
|
--collection <name> Add the demo to this collection in inkly.json.
|
|
5476
5619
|
Creates the collection if it doesn't exist. When
|
|
5477
5620
|
omitted, the demo is not added to any collection.
|
|
5478
|
-
|
|
5621
|
+
`,$o=`inkly validate \u2014 validate a demo hub
|
|
5479
5622
|
|
|
5480
5623
|
Usage:
|
|
5481
5624
|
inkly validate [--json] [--strict]
|
|
@@ -5483,7 +5626,7 @@ Usage:
|
|
|
5483
5626
|
Options:
|
|
5484
5627
|
--json Print machine-readable JSON.
|
|
5485
5628
|
--strict Treat warnings as failures.
|
|
5486
|
-
`,
|
|
5629
|
+
`,Do=`inkly lock \u2014 pin the runtime via inkly.lock
|
|
5487
5630
|
|
|
5488
5631
|
Usage:
|
|
5489
5632
|
inkly lock [--json] [--local <path>]
|
|
@@ -5504,7 +5647,7 @@ Environment:
|
|
|
5504
5647
|
BUNDLES_R2_PUBLIC_BASE_URL
|
|
5505
5648
|
Override the bundles bucket's public base URL
|
|
5506
5649
|
(default https://www.runtime.inklyai.dev). Useful for staging.
|
|
5507
|
-
`,
|
|
5650
|
+
`,No=`inkly login \u2014 connect to the hosted app
|
|
5508
5651
|
|
|
5509
5652
|
Usage:
|
|
5510
5653
|
inkly login [--no-open]
|
|
@@ -5516,11 +5659,11 @@ overridden on the command line.
|
|
|
5516
5659
|
Options:
|
|
5517
5660
|
--no-open Print the grant URL without opening a browser.
|
|
5518
5661
|
--token <token> Automation fallback: save an existing API token.
|
|
5519
|
-
`,
|
|
5662
|
+
`,Mo=`inkly logout \u2014 remove saved platform API credentials
|
|
5520
5663
|
|
|
5521
5664
|
Usage:
|
|
5522
5665
|
inkly logout
|
|
5523
|
-
`,
|
|
5666
|
+
`,Lo=`inkly sync \u2014 upload local capture blobs to CDN
|
|
5524
5667
|
|
|
5525
5668
|
Usage:
|
|
5526
5669
|
inkly sync [--demo <slug>] [--dry-run] [--json]
|
|
@@ -5529,7 +5672,7 @@ Options:
|
|
|
5529
5672
|
--demo <slug> Sync one demo instead of every demo.
|
|
5530
5673
|
--dry-run Report pending uploads without changing files.
|
|
5531
5674
|
--json Print machine-readable JSON.
|
|
5532
|
-
`,
|
|
5675
|
+
`,Oo=`inkly snapshot \u2014 publish a standalone snapshot of one demo
|
|
5533
5676
|
|
|
5534
5677
|
Usage:
|
|
5535
5678
|
inkly snapshot <demo-path> [--json]
|
|
@@ -5546,7 +5689,7 @@ Arguments:
|
|
|
5546
5689
|
Options:
|
|
5547
5690
|
--demo <slug> Select the demo by slug instead of by path.
|
|
5548
5691
|
--json Print machine-readable JSON.
|
|
5549
|
-
`,
|
|
5692
|
+
`,jo=`inkly dev \u2014 start the local preview server
|
|
5550
5693
|
|
|
5551
5694
|
Usage:
|
|
5552
5695
|
inkly dev [<path>] [--port <n>]
|
|
@@ -5562,33 +5705,33 @@ Arguments:
|
|
|
5562
5705
|
Options:
|
|
5563
5706
|
--port <n> Preferred port. Defaults to 3000; if taken, the CLI
|
|
5564
5707
|
tries the next available port. Must be 1-65535.
|
|
5565
|
-
`,
|
|
5708
|
+
`,Uo=`inkly update \u2014 update the globally installed CLI
|
|
5566
5709
|
|
|
5567
5710
|
Usage:
|
|
5568
5711
|
inkly update [--dry-run]
|
|
5569
5712
|
|
|
5570
5713
|
Options:
|
|
5571
5714
|
--dry-run Print the update command without running it.
|
|
5572
|
-
`,
|
|
5715
|
+
`,zo=`inkly doctor \u2014 run local diagnostics
|
|
5573
5716
|
|
|
5574
5717
|
Usage:
|
|
5575
5718
|
inkly doctor [--json]
|
|
5576
5719
|
|
|
5577
5720
|
Options:
|
|
5578
5721
|
--json Print machine-readable JSON.
|
|
5579
|
-
`,
|
|
5722
|
+
`,Fo=`inkly status \u2014 show local CLI status
|
|
5580
5723
|
|
|
5581
5724
|
Usage:
|
|
5582
5725
|
inkly status [--json]
|
|
5583
5726
|
|
|
5584
5727
|
Options:
|
|
5585
5728
|
--json Print machine-readable JSON.
|
|
5586
|
-
`,
|
|
5729
|
+
`,Ho=`inkly version \u2014 print the CLI version
|
|
5587
5730
|
|
|
5588
5731
|
Usage:
|
|
5589
5732
|
inkly version
|
|
5590
5733
|
inkly --version
|
|
5591
|
-
`,
|
|
5734
|
+
`,di=`inkly help \u2014 show command help
|
|
5592
5735
|
|
|
5593
5736
|
Usage:
|
|
5594
5737
|
inkly help [command]
|
|
@@ -5612,25 +5755,27 @@ Commands:
|
|
|
5612
5755
|
capture Capture an image/video walkthrough for an agent.
|
|
5613
5756
|
capture-html
|
|
5614
5757
|
Capture a self-contained HTML walkthrough for an agent.
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
`),await
|
|
5625
|
-
`),await
|
|
5626
|
-
`),await
|
|
5627
|
-
`),await
|
|
5628
|
-
`),await
|
|
5629
|
-
`),await
|
|
5630
|
-
`),await
|
|
5631
|
-
`),
|
|
5632
|
-
`),
|
|
5633
|
-
`),await
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5758
|
+
skills Install the Inkly CLI agent skill.
|
|
5759
|
+
`,Yh={add:Eo,demo:Ro,dev:jo,doctor:zo,capture:dn,"capture-html":un,help:di,init:ci,lock:Do,login:No,logout:Mo,skills:pn,snapshot:Oo,status:Fo,sync:Lo,update:Uo,validate:$o,version:Ho};function Xh(e,t){let n=Gh(e)?e:Kh(t,e);if(li(n))try{if(Zh(n).isFile())return n;let i=Io(n,"manifest.json");if(li(i))return i;let a=Io(n,"dist","manifest.json");if(li(a))return a}catch{}return n}function hn(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t];return typeof n=="string"?n:""}function Qh(e){let t=new Set(["_","api-base","token","url","name","out","session"]);return Object.keys(e).filter(n=>!t.has(n)).filter(n=>e[n]!==!1&&e[n]!==void 0).sort()}async function em(e){let t=qh(e,{alias:{h:"help",p:"port",v:"version"},boolean:["auto-apply-zoom","block-videos","check","compress-images","dry-run","enter","full","headed","headless","html","help","json","keep-profile","no-open","no-snapshot","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]=t._,i=n??(t.version?"version":t.help?"help":"(none)");if(await B("inkly_cli_invoked",{command:i,subcommand:typeof r[0]=="string"?r[0]:void 0,option_keys:Qh(t),json:!!t.json,help:!!t.help}),t.version&&!n)return await Er(),0;if(!n||t.help&&!n)return process.stdout.write(Po),t.help?0:1;switch(n){case"help":{let a=r[0];if(!a)return process.stdout.write(di),0;let o=Yh[a];return o?(process.stdout.write(o),0):(process.stderr.write(`inkly help: unknown command "${a}"
|
|
5760
|
+
|
|
5761
|
+
${di}`),1)}case"init":{if(t.help)return process.stdout.write(ci),0;let a=r[0];if(!a)return process.stderr.write(`inkly init: missing <name> argument
|
|
5762
|
+
|
|
5763
|
+
`+ci),1;let o=hn(t,"layout");try{return await pa({name:a,cwd:process.cwd(),layout:o}),0}catch(s){return process.stderr.write(`inkly init failed: ${s.message}
|
|
5764
|
+
`),await B("inkly_cli_failed",{command:"init"}),await ae("init",s),1}}case"add":case"demo":{let a=n==="add"?Eo:Ro;if(t.help)return process.stdout.write(a),0;let o=r[0];if(!o)return process.stderr.write(`inkly ${n}: missing <name> argument
|
|
5765
|
+
|
|
5766
|
+
`+a),1;let s=typeof t.collection=="string"&&t.collection.length>0?t.collection:void 0;try{return await Ta({slug:o,cwd:process.cwd(),collection:s}),0}catch(c){return process.stderr.write(`inkly ${n} failed: ${c.message}
|
|
5767
|
+
`),await B("inkly_cli_failed",{command:n}),await ae(n,c),1}}case"validate":return t.help?(process.stdout.write($o),0):(await Ln({cwd:process.cwd(),json:!!t.json,strict:!!t.strict})).ok?0:1;case"lock":{if(t.help)return process.stdout.write(Do),0;try{let a=hn(t,"local");return(await En({cwd:process.cwd(),check:!!t.check,json:!!t.json,manifestPath:a?Xh(a,process.cwd()):void 0})).ok?0:1}catch(a){return process.stderr.write(`inkly lock failed: ${a.message}
|
|
5768
|
+
`),await B("inkly_cli_failed",{command:"lock"}),await ae("lock",a),1}}case"version":return t.help?(process.stdout.write(Ho),0):(await Er(),0);case"update":{if(t.help)return process.stdout.write(Uo),0;try{return await Ia({dryRun:!!t["dry-run"]}),0}catch(a){return process.stderr.write(`inkly update failed: ${a.message}
|
|
5769
|
+
`),await B("inkly_cli_failed",{command:"update"}),await ae("update",a),1}}case"doctor":return t.help?(process.stdout.write(zo),0):(await $a({cwd:process.cwd(),json:!!t.json})).ok?0:1;case"login":{if(t.help)return process.stdout.write(No),0;try{return await ja({cwd:process.cwd(),local:process.env.INKLY_LOCAL==="1",token:hn(t,"token"),open:!t["no-open"]}),0}catch(a){return process.stderr.write(`inkly login failed: ${a.message}
|
|
5770
|
+
`),await B("inkly_cli_failed",{command:"login"}),await ae("login",a),1}}case"logout":return t.help?(process.stdout.write(Mo),0):(await Ua(),0);case"status":return t.help?(process.stdout.write(Fo),0):(await za({cwd:process.cwd(),json:!!t.json})).loggedIn?0:1;case"sync":{if(t.help)return process.stdout.write(Lo),0;try{return await Fn({cwd:process.cwd(),demo:hn(t,"demo"),dryRun:!!t["dry-run"],json:!!t.json}),0}catch(a){return process.stderr.write(`inkly sync failed: ${a.message}
|
|
5771
|
+
`),await B("inkly_cli_failed",{command:"sync"}),await ae("sync",a),1}}case"snapshot":{if(t.help)return process.stdout.write(Oo),0;try{return await Ka({cwd:process.cwd(),path:r[0],demo:hn(t,"demo"),json:!!t.json}),0}catch(a){return process.stderr.write(`inkly snapshot failed: ${a.message}
|
|
5772
|
+
`),await B("inkly_cli_failed",{command:"snapshot"}),await ae("snapshot",a),1}}case"capture":{if(t.help)return process.stdout.write(dn),0;try{return await _o({cwd:process.cwd(),subcommand:r[0],args:t})}catch(a){return process.stderr.write(`inkly capture failed: ${a.message}
|
|
5773
|
+
`),await B("inkly_cli_failed",{command:"capture",subcommand:r[0]}),await ae("capture",a),1}}case"capture-html":{if(t.help)return process.stdout.write(un),0;try{return await Co({cwd:process.cwd(),subcommand:r[0],args:t})}catch(a){return process.stderr.write(`inkly capture-html failed: ${a.message}
|
|
5774
|
+
`),await B("inkly_cli_failed",{command:"capture-html",subcommand:r[0]}),await ae("capture-html",a),1}}case"skills":{if(t.help&&!r[0])return process.stdout.write(pn),0;try{return await Ao({subcommand:r[0],help:!!t.help})}catch(a){return process.stderr.write(`inkly skills failed: ${a.message}
|
|
5775
|
+
`),await B("inkly_cli_failed",{command:"skills",subcommand:r[0]}),await ae("skills",a),1}}case"dev":{if(t.help)return process.stdout.write(jo),0;let a=t.port,o=typeof a=="number"?a:typeof a=="string"?Number(a):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
|
|
5776
|
+
`),1;try{let s=await Sa({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}
|
|
5777
|
+
`),B("inkly_cli_failed",{command:"dev.shutdown"}),ae("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}
|
|
5778
|
+
`),await B("inkly_cli_failed",{command:"dev"}),await ae("dev",s),1}}default:return process.stderr.write(`inkly: unknown command "${n}"
|
|
5779
|
+
|
|
5780
|
+
${Po}`),1}}Ya();em(process.argv.slice(2)).then(async e=>{await B("inkly_cli_exited",{command:process.argv[2]??"(none)",exit_code:e}),await Or(),await Xa(),process.exit(e)},async e=>{process.stderr.write(`inkly: ${e.message}
|
|
5781
|
+
`),await B("inkly_cli_failed",{command:"main"}),await ae("main",e),await Or(),process.exit(1)});
|