@inkly-org/cli 0.5.1 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/capture-listener.js +23 -23
- package/dist/cli.js +331 -224
- package/dist/singlefile-injected.js +15136 -0
- package/dist/template/demo.html +1 -1
- package/package.json +5 -5
- package/template/demo.html +1 -1
- package/vendor/react-dom-client.mjs +0 -1
- package/vendor/react-dom.mjs +0 -1
- package/vendor/react-jsx-runtime.mjs +0 -1
- package/vendor/react.mjs +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var qi=Object.defineProperty;var Ki=(t,e)=>{for(var n in e)qi(t,n,{get:e[n],enumerable:!0})};import _u from"mri";import{existsSync as Sa,statSync as Cu}from"fs";import{isAbsolute as Iu,join as $i,resolve as Tu}from"path";import{mkdir as kr,writeFile as Il,access as Tl}from"fs/promises";import{dirname as Pl,join as Al,resolve as Rl,sep as wr}from"path";var s={};Ki(s,{BRAND:()=>So,DIRTY:()=>Ue,EMPTY_PATH:()=>eo,INVALID:()=>w,NEVER:()=>ss,OK:()=>q,ParseStatus:()=>G,Schema:()=>P,ZodAny:()=>$e,ZodArray:()=>ke,ZodBigInt:()=>Fe,ZodBoolean:()=>Be,ZodBranded:()=>Ot,ZodCatch:()=>Qe,ZodDate:()=>He,ZodDefault:()=>Xe,ZodDiscriminatedUnion:()=>tn,ZodEffects:()=>oe,ZodEnum:()=>Ke,ZodError:()=>Y,ZodFirstPartyTypeKind:()=>S,ZodFunction:()=>an,ZodIntersection:()=>Je,ZodIssueCode:()=>m,ZodLazy:()=>Ge,ZodLiteral:()=>qe,ZodMap:()=>mt,ZodNaN:()=>bt,ZodNativeEnum:()=>Ye,ZodNever:()=>le,ZodNull:()=>Ve,ZodNullable:()=>pe,ZodNumber:()=>Me,ZodObject:()=>X,ZodOptional:()=>re,ZodParsedType:()=>b,ZodPipeline:()=>zt,ZodPromise:()=>je,ZodReadonly:()=>et,ZodRecord:()=>nn,ZodSchema:()=>P,ZodSet:()=>ft,ZodString:()=>De,ZodSymbol:()=>pt,ZodTransformer:()=>oe,ZodTuple:()=>ue,ZodType:()=>P,ZodUndefined:()=>We,ZodUnion:()=>Ze,ZodUnknown:()=>xe,ZodVoid:()=>ht,addIssueToContext:()=>f,any:()=>Do,array:()=>zo,bigint:()=>To,boolean:()=>za,coerce:()=>os,custom:()=>$a,date:()=>Po,datetimeRegex:()=>Ea,defaultErrorMap:()=>ge,discriminatedUnion:()=>Mo,effect:()=>Xo,enum:()=>qo,function:()=>Zo,getErrorMap:()=>dt,getParsedType:()=>ce,instanceof:()=>Co,intersection:()=>Fo,isAborted:()=>Qt,isAsync:()=>ct,isDirty:()=>en,isValid:()=>Ee,late:()=>_o,lazy:()=>Jo,literal:()=>Go,makeIssue:()=>jt,map:()=>Wo,nan:()=>Io,nativeEnum:()=>Ko,never:()=>jo,null:()=>Eo,nullable:()=>es,number:()=>Oa,object:()=>No,objectUtil:()=>jn,oboolean:()=>is,onumber:()=>rs,optional:()=>Qo,ostring:()=>as,pipeline:()=>ns,preprocess:()=>ts,promise:()=>Yo,quotelessJson:()=>Yi,record:()=>Ho,set:()=>Vo,setErrorMap:()=>Qi,strictObject:()=>Lo,string:()=>ja,symbol:()=>Ao,transformer:()=>Xo,tuple:()=>Bo,undefined:()=>Ro,union:()=>Uo,unknown:()=>$o,util:()=>A,void:()=>Oo});var A;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function n(r){throw new Error}t.assertNever=n,t.arrayToEnum=r=>{let i={};for(let o of r)i[o]=o;return i},t.getValidEnumValues=r=>{let i=t.objectKeys(r).filter(l=>typeof r[r[l]]!="number"),o={};for(let l of i)o[l]=r[l];return t.objectValues(o)},t.objectValues=r=>t.objectKeys(r).map(function(i){return r[i]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{let i=[];for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&i.push(o);return i},t.find=(r,i)=>{for(let o of r)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function a(r,i=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=a,t.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i})(A||(A={}));var jn;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(jn||(jn={}));var b=A.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ce=t=>{switch(typeof t){case"undefined":return b.undefined;case"string":return b.string;case"number":return Number.isNaN(t)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(t)?b.array:t===null?b.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?b.promise:typeof Map<"u"&&t instanceof Map?b.map:typeof Set<"u"&&t instanceof Set?b.set:typeof Date<"u"&&t instanceof Date?b.date:b.object;default:return b.unknown}};var m=A.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"]),Yi=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Y=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};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},a={_errors:[]},r=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)a._errors.push(n(o));else{let l=a,c=0;for(;c<o.path.length;){let d=o.path[c];c===o.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(n(o))):l[d]=l[d]||{_errors:[]},l=l[d],c++}}};return r(this),a}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,A.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},a=[];for(let r of this.issues)if(r.path.length>0){let i=r.path[0];n[i]=n[i]||[],n[i].push(e(r))}else a.push(e(r));return{formErrors:a,fieldErrors:n}}get formErrors(){return this.flatten()}};Y.create=t=>new Y(t);var Xi=(t,e)=>{let n;switch(t.code){case m.invalid_type:t.received===b.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,A.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${A.joinValues(t.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${A.joinValues(t.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${A.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}"`:A.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,A.assertNever(t)}return{message:n}},ge=Xi;var Ia=ge;function Qi(t){Ia=t}function dt(){return Ia}var jt=t=>{let{data:e,path:n,errorMaps:a,issueData:r}=t,i=[...n,...r.path||[]],o={...r,path:i};if(r.message!==void 0)return{...r,path:i,message:r.message};let l="",c=a.filter(d=>!!d).slice().reverse();for(let d of c)l=d(o,{data:e,defaultError:l}).message;return{...r,path:i,message:l}},eo=[];function f(t,e){let n=dt(),a=jt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ge?void 0:ge].filter(r=>!!r)});t.common.issues.push(a)}var G=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let a=[];for(let r of n){if(r.status==="aborted")return w;r.status==="dirty"&&e.dirty(),a.push(r.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,n){let a=[];for(let r of n){let i=await r.key,o=await r.value;a.push({key:i,value:o})}return t.mergeObjectSync(e,a)}static mergeObjectSync(e,n){let a={};for(let r of n){let{key:i,value:o}=r;if(i.status==="aborted"||o.status==="aborted")return w;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(a[i.value]=o.value)}return{status:e.value,value:a}}},w=Object.freeze({status:"aborted"}),Ue=t=>({status:"dirty",value:t}),q=t=>({status:"valid",value:t}),Qt=t=>t.status==="aborted",en=t=>t.status==="dirty",Ee=t=>t.status==="valid",ct=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 ie=class{constructor(e,n,a,r){this._cachedPath=[],this.parent=e,this.data=n,this._path=a,this._key=r}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}},Ta=(t,e)=>{if(Ee(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new Y(t.common.issues);return this._error=n,this._error}}};function I(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:a,description:r}=t;if(e&&(n||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(o,l)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??a??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??n??l.defaultError}},description:r}}var P=class{get description(){return this._def.description}_getType(e){return ce(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new G,ctx:{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(ct(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 a=this.safeParse(e,n);if(a.success)return a.data;throw a.error}safeParse(e,n){let a={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)},r=this._parseSync({data:e,path:a.path,parent:a});return Ta(a,r)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)};if(!this["~standard"].async)try{let a=this._parseSync({data:e,path:[],parent:n});return Ee(a)?{value:a.value}:{issues:n.common.issues}}catch(a){a?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(a=>Ee(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(e,n){let a=await this.safeParseAsync(e,n);if(a.success)return a.data;throw a.error}async safeParseAsync(e,n){let a={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)},r=this._parse({data:e,path:a.path,parent:a}),i=await(ct(r)?r:Promise.resolve(r));return Ta(a,i)}refine(e,n){let a=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,i)=>{let o=e(r),l=()=>i.addIssue({code:m.custom,...a(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,n){return this._refinement((a,r)=>e(a)?!0:(r.addIssue(typeof n=="function"?n(a,r):n),!1))}_refinement(e){return new oe({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return re.create(this,this._def)}nullable(){return pe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ke.create(this)}promise(){return je.create(this,this._def)}or(e){return Ze.create([this,e],this._def)}and(e){return Je.create(this,e,this._def)}transform(e){return new oe({...I(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Xe({...I(this._def),innerType:this,defaultValue:n,typeName:S.ZodDefault})}brand(){return new Ot({typeName:S.ZodBranded,type:this,...I(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Qe({...I(this._def),innerType:this,catchValue:n,typeName:S.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return zt.create(this,e)}readonly(){return et.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},to=/^c[^\s-]{8,}$/i,no=/^[0-9a-z]+$/,ao=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ro=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,io=/^[a-z0-9_-]{21}$/i,oo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,so=/^[-+]?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)?)??$/,lo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,co="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",On,uo=/^(?:(?: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])$/,po=/^(?:(?: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])$/,ho=/^(([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]))$/,mo=/^(([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])$/,fo=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,bo=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Aa="((\\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])))",go=new RegExp(`^${Aa}$`);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 yo(t){return new RegExp(`^${Ra(t)}$`)}function Ea(t){let e=`${Aa}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 xo(t,e){return!!((e==="v4"||!e)&&uo.test(t)||(e==="v6"||!e)&&ho.test(t))}function ko(t,e){if(!oo.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let a=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(a));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function wo(t,e){return!!((e==="v4"||!e)&&po.test(t)||(e==="v6"||!e)&&mo.test(t))}var De=class t extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:b.string,received:i.parsedType}),w}let a=new G,r;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")e.data.length>i.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(r=this._getOrReturnCtx(e,r),o?f(r,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&f(r,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")lo.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"email",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")On||(On=new RegExp(co,"u")),On.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"emoji",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")ro.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"uuid",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")io.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"nanoid",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")to.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")no.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid2",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")ao.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ulid",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),f(r,{validation:"url",code:m.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"regex",code:m.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.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)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?Ea(i).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?go.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?yo(i).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?so.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"duration",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?xo(e.data,i.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ip",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?ko(e.data,i.alg)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"jwt",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?wo(e.data,i.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cidr",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?fo.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"base64",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?bo.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"base64url",code:m.invalid_string,message:i.message}),a.dirty()):A.assertNever(i);return{status:a.value,value:e.data}}_regex(e,n,a){return this.refinement(r=>e.test(r),{validation:n,code:m.invalid_string,...x.errToObj(a)})}_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}};De.create=t=>new De({checks:[],typeName:S.ZodString,coerce:t?.coerce??!1,...I(t)});function vo(t,e){let n=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,r=n>a?n:a,i=Number.parseInt(t.toFixed(r).replace(".","")),o=Number.parseInt(e.toFixed(r).replace(".",""));return i%o/10**r}var Me=class t extends P{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)!==b.number){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:b.number,received:i.parsedType}),w}let a,r=new G;for(let i of this._def.checks)i.kind==="int"?A.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_type,expected:"integer",received:"float",message:i.message}),r.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind==="multipleOf"?vo(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.not_finite,message:i.message}),r.dirty()):A.assertNever(i);return{status:r.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,a,r){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:a,message:x.toString(r)}]})}_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"&&A.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(n===null||a.value>n)&&(n=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(n)&&Number.isFinite(e)}};Me.create=t=>new Me({checks:[],typeName:S.ZodNumber,coerce:t?.coerce||!1,...I(t)});var Fe=class t extends P{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)!==b.bigint)return this._getInvalidInput(e);let a,r=new G;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):A.assertNever(i);return{status:r.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:b.bigint,received:n.parsedType}),w}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,a,r){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:a,message:x.toString(r)}]})}_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}};Fe.create=t=>new Fe({checks:[],typeName:S.ZodBigInt,coerce:t?.coerce??!1,...I(t)});var Be=class extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){let a=this._getOrReturnCtx(e);return f(a,{code:m.invalid_type,expected:b.boolean,received:a.parsedType}),w}return q(e.data)}};Be.create=t=>new Be({typeName:S.ZodBoolean,coerce:t?.coerce||!1,...I(t)});var He=class t extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:b.date,received:i.parsedType}),w}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_date}),w}let a=new G,r;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):A.assertNever(i);return{status:a.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}};He.create=t=>new He({checks:[],coerce:t?.coerce||!1,typeName:S.ZodDate,...I(t)});var pt=class extends P{_parse(e){if(this._getType(e)!==b.symbol){let a=this._getOrReturnCtx(e);return f(a,{code:m.invalid_type,expected:b.symbol,received:a.parsedType}),w}return q(e.data)}};pt.create=t=>new pt({typeName:S.ZodSymbol,...I(t)});var We=class extends P{_parse(e){if(this._getType(e)!==b.undefined){let a=this._getOrReturnCtx(e);return f(a,{code:m.invalid_type,expected:b.undefined,received:a.parsedType}),w}return q(e.data)}};We.create=t=>new We({typeName:S.ZodUndefined,...I(t)});var Ve=class extends P{_parse(e){if(this._getType(e)!==b.null){let a=this._getOrReturnCtx(e);return f(a,{code:m.invalid_type,expected:b.null,received:a.parsedType}),w}return q(e.data)}};Ve.create=t=>new Ve({typeName:S.ZodNull,...I(t)});var $e=class extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return q(e.data)}};$e.create=t=>new $e({typeName:S.ZodAny,...I(t)});var xe=class extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return q(e.data)}};xe.create=t=>new xe({typeName:S.ZodUnknown,...I(t)});var le=class extends P{_parse(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:b.never,received:n.parsedType}),w}};le.create=t=>new le({typeName:S.ZodNever,...I(t)});var ht=class extends P{_parse(e){if(this._getType(e)!==b.undefined){let a=this._getOrReturnCtx(e);return f(a,{code:m.invalid_type,expected:b.void,received:a.parsedType}),w}return q(e.data)}};ht.create=t=>new ht({typeName:S.ZodVoid,...I(t)});var ke=class t extends P{_parse(e){let{ctx:n,status:a}=this._processInputParams(e),r=this._def;if(n.parsedType!==b.array)return f(n,{code:m.invalid_type,expected:b.array,received:n.parsedType}),w;if(r.exactLength!==null){let o=n.data.length>r.exactLength.value,l=n.data.length<r.exactLength.value;(o||l)&&(f(n,{code:o?m.too_big:m.too_small,minimum:l?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(f(n,{code:m.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(f(n,{code:m.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),n.common.async)return Promise.all([...n.data].map((o,l)=>r.type._parseAsync(new ie(n,o,n.path,l)))).then(o=>G.mergeArray(a,o));let i=[...n.data].map((o,l)=>r.type._parseSync(new ie(n,o,n.path,l)));return G.mergeArray(a,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)}};ke.create=(t,e)=>new ke({type:t,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...I(e)});function ut(t){if(t instanceof X){let e={};for(let n in t.shape){let a=t.shape[n];e[n]=re.create(ut(a))}return new X({...t._def,shape:()=>e})}else return t instanceof ke?new ke({...t._def,type:ut(t.element)}):t instanceof re?re.create(ut(t.unwrap())):t instanceof pe?pe.create(ut(t.unwrap())):t instanceof ue?ue.create(t.items.map(e=>ut(e))):t}var X=class t extends P{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=A.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==b.object){let d=this._getOrReturnCtx(e);return f(d,{code:m.invalid_type,expected:b.object,received:d.parsedType}),w}let{status:a,ctx:r}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof le&&this._def.unknownKeys==="strip"))for(let d in r.data)o.includes(d)||l.push(d);let c=[];for(let d of o){let u=i[d],h=r.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new ie(r,h,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof le){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of l)c.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")l.length>0&&(f(r,{code:m.unrecognized_keys,keys:l}),a.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let u of l){let h=r.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new ie(r,h,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let d=[];for(let u of c){let h=await u.key,p=await u.value;d.push({key:h,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>G.mergeObjectSync(a,d)):G.mergeObjectSync(a,c)}get shape(){return this._def.shape()}strict(e){return x.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,a)=>{let r=this._def.errorMap?.(n,a).message??a.defaultError;return n.code==="unrecognized_keys"?{message:x.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:S.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let a of A.objectKeys(e))e[a]&&this.shape[a]&&(n[a]=this.shape[a]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let a of A.objectKeys(this.shape))e[a]||(n[a]=this.shape[a]);return new t({...this._def,shape:()=>n})}deepPartial(){return ut(this)}partial(e){let n={};for(let a of A.objectKeys(this.shape)){let r=this.shape[a];e&&!e[a]?n[a]=r:n[a]=r.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let a of A.objectKeys(this.shape))if(e&&!e[a])n[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof re;)i=i._def.innerType;n[a]=i}return new t({...this._def,shape:()=>n})}keyof(){return Da(A.objectKeys(this.shape))}};X.create=(t,e)=>new X({shape:()=>t,unknownKeys:"strip",catchall:le.create(),typeName:S.ZodObject,...I(e)});X.strictCreate=(t,e)=>new X({shape:()=>t,unknownKeys:"strict",catchall:le.create(),typeName:S.ZodObject,...I(e)});X.lazycreate=(t,e)=>new X({shape:t,unknownKeys:"strip",catchall:le.create(),typeName:S.ZodObject,...I(e)});var Ze=class extends P{_parse(e){let{ctx:n}=this._processInputParams(e),a=this._def.options;function r(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new Y(l.ctx.common.issues));return f(n,{code:m.invalid_union,unionErrors:o}),w}if(n.common.async)return Promise.all(a.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(r);{let i,o=[];for(let c of a){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 l=o.map(c=>new Y(c));return f(n,{code:m.invalid_union,unionErrors:l}),w}}get options(){return this._def.options}};Ze.create=(t,e)=>new Ze({options:t,typeName:S.ZodUnion,...I(e)});var ye=t=>t instanceof Ge?ye(t.schema):t instanceof oe?ye(t.innerType()):t instanceof qe?[t.value]:t instanceof Ke?t.options:t instanceof Ye?A.objectValues(t.enum):t instanceof Xe?ye(t._def.innerType):t instanceof We?[void 0]:t instanceof Ve?[null]:t instanceof re?[void 0,...ye(t.unwrap())]:t instanceof pe?[null,...ye(t.unwrap())]:t instanceof Ot||t instanceof et?ye(t.unwrap()):t instanceof Qe?ye(t._def.innerType):[],tn=class t extends P{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==b.object)return f(n,{code:m.invalid_type,expected:b.object,received:n.parsedType}),w;let a=this.discriminator,r=n.data[a],i=this.optionsMap.get(r);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),w)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,a){let r=new Map;for(let i of n){let o=ye(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 l of o){if(r.has(l))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(l)}`);r.set(l,i)}}return new t({typeName:S.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:r,...I(a)})}};function zn(t,e){let n=ce(t),a=ce(e);if(t===e)return{valid:!0,data:t};if(n===b.object&&a===b.object){let r=A.objectKeys(e),i=A.objectKeys(t).filter(l=>r.indexOf(l)!==-1),o={...t,...e};for(let l of i){let c=zn(t[l],e[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(n===b.array&&a===b.array){if(t.length!==e.length)return{valid:!1};let r=[];for(let i=0;i<t.length;i++){let o=t[i],l=e[i],c=zn(o,l);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===b.date&&a===b.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Je=class extends P{_parse(e){let{status:n,ctx:a}=this._processInputParams(e),r=(i,o)=>{if(Qt(i)||Qt(o))return w;let l=zn(i.value,o.value);return l.valid?((en(i)||en(o))&&n.dirty(),{status:n.value,value:l.data}):(f(a,{code:m.invalid_intersection_types}),w)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,o])=>r(i,o)):r(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};Je.create=(t,e,n)=>new Je({left:t,right:e,typeName:S.ZodIntersection,...I(n)});var ue=class t extends P{_parse(e){let{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==b.array)return f(a,{code:m.invalid_type,expected:b.array,received:a.parsedType}),w;if(a.data.length<this._def.items.length)return f(a,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;!this._def.rest&&a.data.length>this._def.items.length&&(f(a,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...a.data].map((o,l)=>{let c=this._def.items[l]||this._def.rest;return c?c._parse(new ie(a,o,a.path,l)):null}).filter(o=>!!o);return a.common.async?Promise.all(i).then(o=>G.mergeArray(n,o)):G.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};ue.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ue({items:t,typeName:S.ZodTuple,rest:null,...I(e)})};var nn=class t extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==b.object)return f(a,{code:m.invalid_type,expected:b.object,received:a.parsedType}),w;let r=[],i=this._def.keyType,o=this._def.valueType;for(let l in a.data)r.push({key:i._parse(new ie(a,l,a.path,l)),value:o._parse(new ie(a,a.data[l],a.path,l)),alwaysSet:l in a.data});return a.common.async?G.mergeObjectAsync(n,r):G.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(e,n,a){return n instanceof P?new t({keyType:e,valueType:n,typeName:S.ZodRecord,...I(a)}):new t({keyType:De.create(),valueType:e,typeName:S.ZodRecord,...I(n)})}},mt=class extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==b.map)return f(a,{code:m.invalid_type,expected:b.map,received:a.parsedType}),w;let r=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map(([l,c],d)=>({key:r._parse(new ie(a,l,a.path,[d,"key"])),value:i._parse(new ie(a,c,a.path,[d,"value"]))}));if(a.common.async){let l=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 w;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),l.set(d.value,u.value)}return{status:n.value,value:l}})}else{let l=new Map;for(let c of o){let d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return w;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),l.set(d.value,u.value)}return{status:n.value,value:l}}}};mt.create=(t,e,n)=>new mt({valueType:e,keyType:t,typeName:S.ZodMap,...I(n)});var ft=class t extends P{_parse(e){let{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==b.set)return f(a,{code:m.invalid_type,expected:b.set,received:a.parsedType}),w;let r=this._def;r.minSize!==null&&a.data.size<r.minSize.value&&(f(a,{code:m.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&a.data.size>r.maxSize.value&&(f(a,{code:m.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.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 w;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}let l=[...a.data.values()].map((c,d)=>i._parse(new ie(a,c,a.path,d)));return a.common.async?Promise.all(l).then(c=>o(c)):o(l)}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)}};ft.create=(t,e)=>new ft({valueType:t,minSize:null,maxSize:null,typeName:S.ZodSet,...I(e)});var an=class t extends P{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==b.function)return f(n,{code:m.invalid_type,expected:b.function,received:n.parsedType}),w;function a(l,c){return jt({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dt(),ge].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:c}})}function r(l,c){return jt({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,dt(),ge].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof je){let l=this;return q(async function(...c){let d=new Y([]),u=await l._def.args.parseAsync(c,i).catch(g=>{throw d.addIssue(a(c,g)),d}),h=await Reflect.apply(o,this,u);return await l._def.returns._def.type.parseAsync(h,i).catch(g=>{throw d.addIssue(r(h,g)),d})})}else{let l=this;return q(function(...c){let d=l._def.args.safeParse(c,i);if(!d.success)throw new Y([a(c,d.error)]);let u=Reflect.apply(o,this,d.data),h=l._def.returns.safeParse(u,i);if(!h.success)throw new Y([r(u,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:ue.create(e).rest(xe.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,a){return new t({args:e||ue.create([]).rest(xe.create()),returns:n||xe.create(),typeName:S.ZodFunction,...I(a)})}},Ge=class extends P{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})}};Ge.create=(t,e)=>new Ge({getter:t,typeName:S.ZodLazy,...I(e)});var qe=class extends P{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:e.data}}get value(){return this._def.value}};qe.create=(t,e)=>new qe({value:t,typeName:S.ZodLiteral,...I(e)});function Da(t,e){return new Ke({values:t,typeName:S.ZodEnum,...I(e)})}var Ke=class t extends P{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),a=this._def.values;return f(n,{expected:A.joinValues(a),received:n.parsedType,code:m.invalid_type}),w}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),a=this._def.values;return f(n,{received:n.data,code:m.invalid_enum_value,options:a}),w}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(a=>!e.includes(a)),{...this._def,...n})}};Ke.create=Da;var Ye=class extends P{_parse(e){let n=A.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==b.string&&a.parsedType!==b.number){let r=A.objectValues(n);return f(a,{expected:A.joinValues(r),received:a.parsedType,code:m.invalid_type}),w}if(this._cache||(this._cache=new Set(A.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let r=A.objectValues(n);return f(a,{received:a.data,code:m.invalid_enum_value,options:r}),w}return q(e.data)}get enum(){return this._def.values}};Ye.create=(t,e)=>new Ye({values:t,typeName:S.ZodNativeEnum,...I(e)});var je=class extends P{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==b.promise&&n.common.async===!1)return f(n,{code:m.invalid_type,expected:b.promise,received:n.parsedType}),w;let a=n.parsedType===b.promise?n.data:Promise.resolve(n.data);return q(a.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}};je.create=(t,e)=>new je({type:t,typeName:S.ZodPromise,...I(e)});var oe=class extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:a}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:o=>{f(a,o),o.fatal?n.abort():n.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),r.type==="preprocess"){let o=r.transform(a.data,i);if(a.common.async)return Promise.resolve(o).then(async l=>{if(n.value==="aborted")return w;let c=await this._def.schema._parseAsync({data:l,path:a.path,parent:a});return c.status==="aborted"?w:c.status==="dirty"?Ue(c.value):n.value==="dirty"?Ue(c.value):c});{if(n.value==="aborted")return w;let l=this._def.schema._parseSync({data:o,path:a.path,parent:a});return l.status==="aborted"?w:l.status==="dirty"?Ue(l.value):n.value==="dirty"?Ue(l.value):l}}if(r.type==="refinement"){let o=l=>{let c=r.refinement(l,i);if(a.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(a.common.async===!1){let l=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return l.status==="aborted"?w:(l.status==="dirty"&&n.dirty(),o(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(l=>l.status==="aborted"?w:(l.status==="dirty"&&n.dirty(),o(l.value).then(()=>({status:n.value,value:l.value}))))}if(r.type==="transform")if(a.common.async===!1){let o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Ee(o))return w;let l=r.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>Ee(o)?Promise.resolve(r.transform(o.value,i)).then(l=>({status:n.value,value:l})):w);A.assertNever(r)}};oe.create=(t,e,n)=>new oe({schema:t,typeName:S.ZodEffects,effect:e,...I(n)});oe.createWithPreprocess=(t,e,n)=>new oe({schema:e,effect:{type:"preprocess",transform:t},typeName:S.ZodEffects,...I(n)});var re=class extends P{_parse(e){return this._getType(e)===b.undefined?q(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};re.create=(t,e)=>new re({innerType:t,typeName:S.ZodOptional,...I(e)});var pe=class extends P{_parse(e){return this._getType(e)===b.null?q(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};pe.create=(t,e)=>new pe({innerType:t,typeName:S.ZodNullable,...I(e)});var Xe=class extends P{_parse(e){let{ctx:n}=this._processInputParams(e),a=n.data;return n.parsedType===b.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Xe.create=(t,e)=>new Xe({innerType:t,typeName:S.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...I(e)});var Qe=class extends P{_parse(e){let{ctx:n}=this._processInputParams(e),a={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return ct(r)?r.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Y(a.common.issues)},input:a.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Y(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};Qe.create=(t,e)=>new Qe({innerType:t,typeName:S.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...I(e)});var bt=class extends P{_parse(e){if(this._getType(e)!==b.nan){let a=this._getOrReturnCtx(e);return f(a,{code:m.invalid_type,expected:b.nan,received:a.parsedType}),w}return{status:"valid",value:e.data}}};bt.create=t=>new bt({typeName:S.ZodNaN,...I(t)});var So=Symbol("zod_brand"),Ot=class extends P{_parse(e){let{ctx:n}=this._processInputParams(e),a=n.data;return this._def.type._parse({data:a,path:n.path,parent:n})}unwrap(){return this._def.type}},zt=class t extends P{_parse(e){let{status:n,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?w:i.status==="dirty"?(n.dirty(),Ue(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{let r=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return r.status==="aborted"?w:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:a.path,parent:a})}}static create(e,n){return new t({in:e,out:n,typeName:S.ZodPipeline})}},et=class extends P{_parse(e){let n=this._def.innerType._parse(e),a=r=>(Ee(r)&&(r.value=Object.freeze(r.value)),r);return ct(n)?n.then(r=>a(r)):a(n)}unwrap(){return this._def.innerType}};et.create=(t,e)=>new et({innerType:t,typeName:S.ZodReadonly,...I(e)});function Pa(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function $a(t,e={},n){return t?$e.create().superRefine((a,r)=>{let i=t(a);if(i instanceof Promise)return i.then(o=>{if(!o){let l=Pa(e,a),c=l.fatal??n??!0;r.addIssue({code:"custom",...l,fatal:c})}});if(!i){let o=Pa(e,a),l=o.fatal??n??!0;r.addIssue({code:"custom",...o,fatal:l})}}):$e.create()}var _o={object:X.lazycreate},S;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(S||(S={}));var Co=(t,e={message:`Input not instance of ${t.name}`})=>$a(n=>n instanceof t,e),ja=De.create,Oa=Me.create,Io=bt.create,To=Fe.create,za=Be.create,Po=He.create,Ao=pt.create,Ro=We.create,Eo=Ve.create,Do=$e.create,$o=xe.create,jo=le.create,Oo=ht.create,zo=ke.create,No=X.create,Lo=X.strictCreate,Uo=Ze.create,Mo=tn.create,Fo=Je.create,Bo=ue.create,Ho=nn.create,Wo=mt.create,Vo=ft.create,Zo=an.create,Jo=Ge.create,Go=qe.create,qo=Ke.create,Ko=Ye.create,Yo=je.create,Xo=oe.create,Qo=re.create,es=pe.create,ts=oe.createWithPreprocess,ns=zt.create,as=()=>ja().optional(),rs=()=>Oa().optional(),is=()=>za().optional(),os={string:(t=>De.create({...t,coerce:!0})),number:(t=>Me.create({...t,coerce:!0})),boolean:(t=>Be.create({...t,coerce:!0})),bigint:(t=>Fe.create({...t,coerce:!0})),date:(t=>He.create({...t,coerce:!0}))};var ss=w;var Nn=s.object({id:s.string()}),ls=s.enum(["top","right","bottom","left","auto"]).default("auto"),Ln=s.enum(["left","middle","right"]),ds=Ln.default("left"),Na=s.object({label:s.string().optional(),hidden:s.boolean().default(!1)}),cs={background:s.string().optional(),textColor:s.string().optional(),borderRadius:s.string().optional(),textAlign:ds,anchor:ls,showNavigation:s.boolean().default(!0),prevButton:Na.optional(),nextButton:Na.optional()},us=s.enum(["pointer","callout","area"]),ps=s.discriminatedUnion("type",[s.object({type:s.literal("html-element"),alphaId:s.string().min(1)})]),hs=Nn.extend({type:s.literal("message"),variant:us.default("callout"),x:s.number().min(0).max(1),y:s.number().min(0).max(1),w:s.number().min(0).max(1).optional(),h:s.number().min(0).max(1).optional(),text:s.string().optional(),target:ps.optional(),advancesStep:s.boolean().default(!0),...cs}),ms=Nn.extend({type:s.literal("blur"),x:s.number().min(0).max(1),y:s.number().min(0).max(1),w:s.number().min(0).max(1),h:s.number().min(0).max(1),intensity:s.number().min(0).max(20).default(8)}),fs=Nn.extend({type:s.literal("text"),x:s.number().min(0).max(1),y:s.number().min(0).max(1),text:s.string(),fontSize:s.number().positive().default(16),color:s.string().optional()}),La=s.discriminatedUnion("type",[hs,ms,fs]),Ua=new Set(["message","blur","text"]),Ma=s.object({type:s.string()}).passthrough();function Fa(t){return typeof t=="object"&&t!==null?t.type:void 0}var Ba=s.any().superRefine((t,e)=>{let r=(Ua.has(Fa(t))?La:Ma).safeParse(t);if(!r.success)for(let i of r.error.issues)e.addIssue(i)}).transform(t=>(Ua.has(Fa(t))?La:Ma).parse(t));var Un=s.object({label:s.string().min(1),href:s.string().refine(t=>/^(https?:|mailto:)/i.test(t),"href must be an http(s) or mailto URL")}),Mn=s.object({logo:s.string().min(1).optional(),name:s.string().min(1).optional(),logoHref:s.string().refine(t=>/^(https?:|mailto:)/i.test(t),"logoHref must be an http(s) or mailto URL").optional(),favicon:s.string().min(1).optional(),cta:Un.optional(),secondaryCta:Un.optional()}),Ha=Mn.omit({favicon:!0});var bs=s.object({type:s.literal("next")}),gs=s.object({type:s.literal("prev")}),ys=s.object({type:s.literal("step"),stepId:s.string().min(1)}),xs=s.object({type:s.literal("chapter"),chapterId:s.string().min(1)}),ks=s.object({type:s.literal("url"),href:s.string().min(1),target:s.enum(["_self","_blank"]).default("_blank")}),ws=s.object({type:s.literal("restart")}),vs=s.discriminatedUnion("type",[bs,gs,ys,xs,ks,ws]),Ss=s.enum(["shimmer"]),rn=s.object({label:s.string().min(1),action:vs.default({type:"next"}),animation:Ss.optional(),background:s.string().optional(),textColor:s.string().optional()});var _s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Fn=/^[A-Za-z0-9_-]{12}$/;function Cs(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 he(){let t=new Uint8Array(12);Cs(t);let e="";for(let n of t)e+=_s.charAt(n&63);return e}function Wa(t){return typeof t=="string"&&Fn.test(t)}function Va(t){return String(t+1).padStart(4,"0")}function Za(t){return`snap-${t.toString().padStart(3,"0")}`}function Hn(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 Bn(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(a=>a.trim()).find(Boolean)??e).replace(/\s+/g," ").trim().slice(0,48)}function Wn(t){let{stepId:e,assetId:n,posterAssetId:a,kind:r,isLast:i}=t,o=`asset:${n}`,l=r==="video"?{type:"video",src:o,posterSrc:a?`asset:${a}`: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 p=Bn(c.label);d.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:c.x,y:c.y,text:p?`Click on "${p}"`:"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),h=r==="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:l,...h?{transform:h}:{},annotations:d,advance:{trigger:"click"}}}function Ja(t){let{stepId:e,htmlPath:n,click:a}=t,r=[];if(a?.alphaId)r.push({id:`${e}_area`,type:"message",variant:"area",x:Number((a.x??.5).toFixed(4)),y:Number((a.y??.5).toFixed(4)),w:0,h:0,text:Bn(a.label)||"Click here",target:{type:"html-element",alphaId:a.alphaId},anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});else if(a){let i=Bn(a.label);r.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:Number((a.x??.5).toFixed(4)),y:Number((a.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:r,advance:{trigger:"click"}}}function Is(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 Ga(t,e){let n=Is(e);return/<\/body\s*>/i.test(t)?t.replace(/<\/body\s*>/i,`${n}</body>`):`${t}${n}`}var qa=s.object({id:s.string(),text:s.string(),start:s.number().nonnegative().optional(),end:s.number().nonnegative().optional()});var Ts=s.enum(["screenshot","image","video","audio","font","other"]),Ps=s.object({id:s.string().min(1),path:s.string().min(1).optional(),uri:s.string().min(1).optional(),sha256:s.string().regex(/^[0-9a-f]{64}$/),kind:Ts,contentType:s.string().min(1).optional(),publicUrl:s.string().min(1).optional(),cdnPath:s.string().min(1).optional(),size:s.number().int().nonnegative().optional(),createdAt:s.string().min(1).optional(),updatedAt:s.string().min(1).optional(),viewport:s.object({w:s.number().int().positive(),h:s.number().int().positive()}).optional()}),on=s.object({version:s.literal(1),assets:s.array(Ps),screens:s.array(s.unknown()).optional()});var Vn=s.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"}),As=s.enum(["color","image","glassmorphism"]),Ka=s.object({type:As,color:Vn.optional(),from:Vn.optional(),to:Vn.optional(),src:s.string().min(1).optional(),alt:s.string().optional(),intensity:s.number().min(-5).max(48).optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,a=!!t.from&&!!t.to;!n&&!a&&e.addIssue({code:s.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:s.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:s.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),Ya=s.object({src:s.string(),alt:s.string().optional()});var Zn=s.object({src:s.string().min(1),duration:s.number().positive().optional()});var Rs=s.enum(["text","dropdown"]),Es=s.object({value:s.string().min(1),label:s.string().min(1)}),Ds=s.object({id:s.string(),label:s.string(),type:Rs.default("text"),placeholder:s.string().optional(),required:s.boolean().default(!1),options:s.array(Es).optional()}).superRefine((t,e)=>{t.type==="dropdown"&&(!t.options||t.options.length===0)&&e.addIssue({code:s.ZodIssueCode.custom,message:"Dropdown field requires at least one option.",path:["options"]})}),nr=s.object({src:s.string().min(1),alt:s.string().optional(),height:s.number().int().positive().optional()}),$s=s.enum(["left","right","top"]),js=s.enum(["standard","hero"]),ar=s.object({src:s.string().min(1),alt:s.string().optional(),naturalWidth:s.number().positive().optional(),naturalHeight:s.number().positive().optional(),position:$s.default("right"),layout:js.default("hero")}),Os=s.object({type:s.literal("headline"),id:s.string(),logo:nr.optional(),image:ar.optional(),title:s.string(),titleColor:s.string().optional(),description:s.string().optional(),descriptionColor:s.string().optional(),textAlign:Ln.optional(),cta:rn.optional(),secondaryCta:rn.optional()}),zs=s.object({type:s.literal("form"),id:s.string(),logo:nr.optional(),image:ar.optional(),title:s.string().optional(),description:s.string().optional(),fields:s.array(Ds).min(1),submit:rn.default({label:"Submit",action:{type:"next"}})}),Ns="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",Ls="camera; microphone; fullscreen; payment; clipboard-write",Us=s.object({type:s.literal("embed"),id:s.string(),src:s.string(),iframeTitle:s.string().optional(),sandbox:s.string().default(Ns),allow:s.string().default(Ls)}),Ms=s.object({type:s.literal("custom"),id:s.string(),name:s.string().min(1),data:s.record(s.unknown()).optional()}),Xa=s.discriminatedUnion("type",[Os,zs,Us,Ms]),Qa=new Set(["headline","form","embed","custom"]),er=s.object({type:s.string()}).passthrough();function tr(t){return typeof t=="object"&&t!==null?t.type:void 0}var rr=s.any().superRefine((t,e)=>{let r=(Qa.has(tr(t))?Xa:er).safeParse(t);if(!r.success)for(let i of r.error.issues)e.addIssue(i)}).transform(t=>(Qa.has(tr(t))?Xa:er).parse(t));var ir=s.enum(["contain","cover","fill"]),or=s.enum(["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"]),Fs=s.object({type:s.literal("image"),src:s.string().min(1),naturalWidth:s.number().positive(),naturalHeight:s.number().positive(),alt:s.string().optional(),sourceUrl:s.string().optional(),title:s.string().optional(),objectFit:ir.optional(),objectPosition:or.optional()}),Bs=s.object({type:s.literal("video"),src:s.string().min(1),posterSrc:s.string().min(1).optional(),naturalWidth:s.number().positive(),naturalHeight:s.number().positive(),alt:s.string().optional(),sourceUrl:s.string().optional(),title:s.string().optional(),autoplay:s.boolean().default(!0),muted:s.boolean().default(!0),objectFit:ir.optional(),objectPosition:or.optional()}),Hs=s.object({x:s.number().nonnegative().default(0),y:s.number().nonnegative().default(0),maxX:s.number().nonnegative().default(0),maxY:s.number().nonnegative().default(0)}),Ws=s.object({type:s.literal("html"),path:s.string().min(1),naturalWidth:s.number().positive(),naturalHeight:s.number().positive(),zoom:s.number().positive().default(1),scroll:Hs.default({x:0,y:0,maxX:0,maxY:0}),sourceUrl:s.string().optional(),title:s.string().optional()}),Vs=s.discriminatedUnion("type",[Fs,Bs,Ws]),Zs=s.object({zoom:s.number().min(1).default(1),x:s.number().min(0).max(1).default(.5),y:s.number().min(0).max(1).default(.5)}),Js=s.object({trigger:s.enum(["auto","click"]).default("auto")}).default({trigger:"auto"}),Gs=s.object({kind:s.literal("content").default("content"),id:s.string(),label:s.string().optional(),duration:s.number().positive().optional(),background:Vs,script:s.string().optional(),voiceover:Zn.optional(),transform:Zs.optional(),advance:Js,annotations:s.array(Ba).default([]),captions:s.array(qa).optional()}).passthrough(),qs=s.object({kind:s.literal("cover"),id:s.string(),label:s.string().optional(),widgets:s.array(rr).length(1),background:Ka.optional(),backgroundImage:Ya.optional(),backgroundDim:s.number().min(0).max(1).optional(),script:s.string().optional(),voiceover:Zn.optional(),duration:s.number().positive().optional(),advance:s.object({trigger:s.enum(["auto","click"]).default("click")}).default({trigger:"click"})}).passthrough(),sr=s.discriminatedUnion("kind",[Gs,qs]);var Ks=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,lr=s.string().regex(Ks,"must be a hex color like #5b3df5"),sn=s.object({primary:lr.optional(),secondary:lr.optional(),font:s.string().min(1).optional(),radius:s.string().min(1).optional()}).partial();var ln=s.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"}),Ys=s.object({id:s.string(),title:s.string(),stepIds:s.array(s.string()).min(1)}),Xs=s.object({hideHeader:s.boolean().default(!1),hideControls:s.boolean().default(!1),controls:s.enum(["full","minimal","hidden"]).optional(),showHubBreadcrumb:s.boolean().default(!1),mobileFooterMessage:s.boolean().default(!0),autoplay:s.boolean().default(!1)}),Qs=s.object({width:s.number().positive(),height:s.number().positive()}),el=s.enum(["public","private"]),tl=s.enum(["none","color","image"]),nl=s.object({type:tl,color:ln.optional(),from:ln.optional(),to:ln.optional(),src:s.string().min(1).optional(),alt:s.string().optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,a=!!t.from&&!!t.to;!n&&!a&&e.addIssue({code:s.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:s.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:s.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),gt=s.object({id:s.string().regex(Fn,{message:"must be a 12-character URL-safe demo id (see generateDemoId)"}),version:s.number().int().min(1),title:s.string().optional(),subtitle:s.string().optional(),runtime:s.string().min(1).optional(),visibility:el.default("public"),backgroundColor:ln.optional(),background:nl.optional(),theme:s.object({preset:s.string().min(1).optional(),tokens:sn.optional(),brand:Ha.optional()}).optional(),chrome:Xs.default({}),aspectRatio:Qs.optional(),chapters:s.array(Ys).default([]),steps:s.array(sr).min(1)}).passthrough().superRefine((t,e)=>{let n=new Set(t.steps.map(r=>r.id)),a=new Set(t.chapters.map(r=>r.id));t.chapters.forEach((r,i)=>{r.stepIds.forEach(o=>{n.has(o)||e.addIssue({code:s.ZodIssueCode.custom,path:["chapters",i,"stepIds"],message:`Chapter "${r.id}" references unknown step "${o}"`})})}),t.steps.forEach((r,i)=>{r.kind==="cover"&&r.widgets.forEach((o,l)=>{o.type==="headline"&&["cta","secondaryCta"].forEach(c=>{let d=o[c]?.action;d&&(d.type==="step"&&!n.has(d.stepId)&&e.addIssue({code:s.ZodIssueCode.custom,path:["steps",i,"widgets",l,c,"action","stepId"],message:`Widget "${o.id}" CTA targets unknown step "${d.stepId}"`}),d.type==="chapter"&&!a.has(d.chapterId)&&e.addIssue({code:s.ZodIssueCode.custom,path:["steps",i,"widgets",l,c,"action","chapterId"],message:`Widget "${o.id}" CTA targets unknown chapter "${d.chapterId}"`}))})})})});function dr(t){return gt.parse(t)}function yt(t){let e=typeof t=="object"&&t!==null?t:{},n=Wa(e.id),a=n?e:{...e,id:he()};return{config:gt.parse(a),changed:!n}}function cr(t){let e=new Map;t.forEach((a,r)=>{let i=e.get(a.id);i?i.push({entry:a,index:r}):e.set(a.id,[{entry:a,index:r}])});let n=[];for(let a of e.values()){if(a.length<2)continue;let r=[...a].sort((o,l)=>o.entry.updatedAt!==l.entry.updatedAt?o.entry.updatedAt-l.entry.updatedAt:o.index-l.index),[,...i]=r;for(let{entry:o}of i)n.push({entry:o,newId:he()})}return n}var Jn=s.enum(["sidebar","tabs"]),al=s.object({name:s.string().min(1),description:s.string().min(1).optional(),icon:s.string().min(1).optional(),demos:s.array(s.string().min(1))}),we=s.object({$schema:s.string().optional(),name:s.string().min(1),runtime:s.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:s.string().min(1).optional(),layout:Jn.optional(),theme:s.string().min(1).optional(),tokens:sn.optional(),brand:Mn.optional(),title:s.string().min(1).optional(),subtitle:s.string().min(1).optional(),collections:s.array(al).optional()});function ur({slug:t,config:e,resolveAssetSrc:n}){let a=e.title??e.id??t;return{slug:t,title:a,description:rl(e,a),thumbnail:sl(e,a,n),visibility:e.visibility}}function dn(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function rl(t,e){if(t.subtitle?.trim())return dn(t.subtitle.trim(),120);for(let n of t.steps){if(n.kind!=="content")continue;let a=n.captions?.[0]?.text;if(a&&a.trim())return dn(a.trim(),120);break}for(let n of t.steps)if(n.kind==="cover"){for(let a of n.widgets)if(a.type==="headline"&&a.description&&a.description.trim())return dn(a.description.trim(),120)}return dn(`Explore the ${e} workflow.`,120)}function il(t){return t.background?t.background.type==="image":t.backgroundImage?!0:t.widgets.some(e=>e.type==="headline"?!!e.title:e.type==="embed"?!!e.src:e.type==="form")}function Gn(t,e){return t?e?e(t):t:null}function ol(t,e){if(!e)return t;let n=t.widgets.map(o=>{if((o.type==="headline"||o.type==="form")&&o.image?.src){let l=e(o.image.src);return l&&l!==o.image.src?{...o,image:{...o.image,src:l}}:o}return o}),a=t.backgroundImage,r=t.background;if(r?.type==="image"&&r.src){let o=e(r.src);o&&o!==r.src&&(r={...r,src:o})}if(a?.src){let o=e(a.src);o&&o!==a.src&&(a={...a,src:o})}return!n.some((o,l)=>o!==t.widgets[l])&&r===t.background&&a===t.backgroundImage?t:{...t,widgets:n,background:r,backgroundImage:a}}function sl(t,e,n){let a=t.steps[0];if(a){if(a.kind==="cover"&&il(a))return{kind:"cover",cover:ol(a,n),themeTokens:t.theme?.tokens};if(a.kind==="content"){let r=a.background;if(r?.type==="image"){let i=Gn(r.src,n);if(i)return{kind:"image",src:i}}else if(r?.type==="video"){let i=Gn(r.posterSrc,n);if(i)return{kind:"image",src:i};let o=Gn(r.src,n);if(o)return{kind:"video",src:o}}else if(r?.type==="html")return{kind:"html",path:r.path,naturalWidth:r.naturalWidth,naturalHeight:r.naturalHeight,zoom:r.zoom,scroll:r.scroll}}}return{kind:"placeholder",title:e}}function ll(t){return!t||t==="null"?"":t.replace(/\/+$/,"")}function dl(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cl(t){return String(t||"").replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"")}function qn(t){let e=cl(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 ul(t){return t.replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?content-security-policy\b)[^>]*>/gi,"")}var pl=/\s+(?:href|xlink:href|target|rel|download|ping|referrerpolicy|data-inkly-href)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?/gi;function Kn(t){return String(t||"").replace(/<(a|area)\b[^>]*>/gi,e=>e.replace(pl,""))}function tt(t,e={}){let n=ll(e.resourceOrigin),a=String(t||"");return n?a.replace(new RegExp(`(^|["'\\(\\s,=])${dl("/api/hubs/")}`,"g"),`$1${n}/api/hubs/`):a}function hl(t){return ul(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 pr({htmlPath:t,html:e,css:n,cssHref:a,resourceOrigin:r}){let i=hl(Kn(e)),o=qn(t)!=null,l=n?.trim()??"";if(o&&l){let d=`<style data-inkly-document-css>
|
|
3
|
-
${tt(n??"",{resourceOrigin:
|
|
4
|
-
</style>`,u=/<\/head\s*>/i.test(i)?i.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${i}`;return tt(u,{resourceOrigin:
|
|
2
|
+
var yo=Object.defineProperty;var xo=(t,e)=>{for(var n in e)yo(t,n,{get:e[n],enumerable:!0})};import Mp from"mri";import{existsSync as Nr,statSync as Up}from"fs";import{isAbsolute as Fp,join as Qi,resolve as Hp}from"path";import{Buffer as ud}from"buffer";import{mkdir as Oa,writeFile as pd,access as hd}from"fs/promises";import{dirname as md,join as fd,resolve as gd,sep as Na}from"path";var l={};xo(l,{BRAND:()=>Vo,DIRTY:()=>ze,EMPTY_PATH:()=>So,INVALID:()=>v,NEVER:()=>Ps,OK:()=>q,ParseStatus:()=>G,Schema:()=>A,ZodAny:()=>Ee,ZodArray:()=>xe,ZodBigInt:()=>Ue,ZodBoolean:()=>Fe,ZodBranded:()=>zt,ZodCatch:()=>Xe,ZodDate:()=>He,ZodDefault:()=>Ye,ZodDiscriminatedUnion:()=>an,ZodEffects:()=>ie,ZodEnum:()=>qe,ZodError:()=>Y,ZodFirstPartyTypeKind:()=>S,ZodFunction:()=>sn,ZodIntersection:()=>Ze,ZodIssueCode:()=>m,ZodLazy:()=>Je,ZodLiteral:()=>Ge,ZodMap:()=>ft,ZodNaN:()=>bt,ZodNativeEnum:()=>Ke,ZodNever:()=>se,ZodNull:()=>We,ZodNullable:()=>ue,ZodNumber:()=>Me,ZodObject:()=>X,ZodOptional:()=>re,ZodParsedType:()=>g,ZodPipeline:()=>Mt,ZodPromise:()=>Re,ZodReadonly:()=>Qe,ZodRecord:()=>on,ZodSchema:()=>A,ZodSet:()=>gt,ZodString:()=>Pe,ZodSymbol:()=>ht,ZodTransformer:()=>ie,ZodTuple:()=>ce,ZodType:()=>A,ZodUndefined:()=>Be,ZodUnion:()=>Ve,ZodUnknown:()=>ye,ZodVoid:()=>mt,addIssueToContext:()=>f,any:()=>es,array:()=>as,bigint:()=>qo,boolean:()=>qr,coerce:()=>Is,custom:()=>Zr,date:()=>Ko,datetimeRegex:()=>Wr,defaultErrorMap:()=>ge,discriminatedUnion:()=>ls,effect:()=>ks,enum:()=>bs,function:()=>ms,getErrorMap:()=>ct,getParsedType:()=>de,instanceof:()=>Jo,intersection:()=>ds,isAborted:()=>nn,isAsync:()=>ut,isDirty:()=>rn,isValid:()=>Ie,late:()=>Zo,lazy:()=>fs,literal:()=>gs,makeIssue:()=>Lt,map:()=>ps,nan:()=>Go,nativeEnum:()=>ys,never:()=>ns,null:()=>Qo,nullable:()=>vs,number:()=>Gr,object:()=>is,objectUtil:()=>On,oboolean:()=>As,onumber:()=>Ts,optional:()=>ws,ostring:()=>Cs,pipeline:()=>_s,preprocess:()=>Ss,promise:()=>xs,quotelessJson:()=>ko,record:()=>us,set:()=>hs,setErrorMap:()=>vo,strictObject:()=>os,string:()=>Jr,symbol:()=>Yo,transformer:()=>ks,tuple:()=>cs,undefined:()=>Xo,union:()=>ss,unknown:()=>ts,util:()=>E,void:()=>rs});var E;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{let i={};for(let o of a)i[o]=o;return i},t.getValidEnumValues=a=>{let i=t.objectKeys(a).filter(s=>typeof a[a[s]]!="number"),o={};for(let s of i)o[s]=a[s];return t.objectValues(o)},t.objectValues=a=>t.objectKeys(a).map(function(i){return a[i]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let i=[];for(let o in a)Object.prototype.hasOwnProperty.call(a,o)&&i.push(o);return i},t.find=(a,i)=>{for(let o of a)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(E||(E={}));var On;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(On||(On={}));var g=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),de=t=>{switch(typeof t){case"undefined":return g.undefined;case"string":return g.string;case"number":return Number.isNaN(t)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}};var m=E.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ko=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Y=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},a=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let s=r,c=0;for(;c<o.path.length;){let d=o.path[c];c===o.path.length-1?(s[d]=s[d]||{_errors:[]},s[d]._errors.push(n(o))):s[d]=s[d]||{_errors:[]},s=s[d],c++}}};return a(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let a of this.issues)if(a.path.length>0){let i=a.path[0];n[i]=n[i]||[],n[i].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Y.create=t=>new Y(t);var wo=(t,e)=>{let n;switch(t.code){case m.invalid_type:t.received===g.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,E.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${E.joinValues(t.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${E.joinValues(t.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;break;case m.invalid_arguments:n="Invalid function arguments";break;case m.invalid_return_type:n="Invalid function return type";break;case m.invalid_date:n="Invalid date";break;case m.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:E.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case m.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case m.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case m.custom:n="Invalid input";break;case m.invalid_intersection_types:n="Intersection results could not be merged";break;case m.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=e.defaultError,E.assertNever(t)}return{message:n}},ge=wo;var Mr=ge;function vo(t){Mr=t}function ct(){return Mr}var Lt=t=>{let{data:e,path:n,errorMaps:r,issueData:a}=t,i=[...n,...a.path||[]],o={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let s="",c=r.filter(d=>!!d).slice().reverse();for(let d of c)s=d(o,{data:e,defaultError:s}).message;return{...a,path:i,message:s}},So=[];function f(t,e){let n=ct(),r=Lt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ge?void 0:ge].filter(a=>!!a)});t.common.issues.push(r)}var G=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let a of n){if(a.status==="aborted")return v;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let a of n){let i=await a.key,o=await a.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let a of n){let{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},v=Object.freeze({status:"aborted"}),ze=t=>({status:"dirty",value:t}),q=t=>({status:"valid",value:t}),nn=t=>t.status==="aborted",rn=t=>t.status==="dirty",Ie=t=>t.status==="valid",ut=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}));var ae=class{constructor(e,n,r,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ur=(t,e)=>{if(Ie(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new Y(t.common.issues);return this._error=n,this._error}}};function C(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(o,s)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??r??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:c??n??s.defaultError}},description:a}}var A=class{get description(){return this._def.description}_getType(e){return de(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:de(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new G,ctx:{common:e.parent.common,data:e.data,parsedType:de(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(ut(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:de(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Ur(r,a)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:de(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Ie(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Ie(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:de(e)},a=this._parse({data:e,path:r.path,parent:r}),i=await(ut(a)?a:Promise.resolve(a));return Ur(r,i)}refine(e,n){let r=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,i)=>{let o=e(a),s=()=>i.addIssue({code:m.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(e,n){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof n=="function"?n(r,a):n),!1))}_refinement(e){return new ie({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return re.create(this,this._def)}nullable(){return ue.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xe.create(this)}promise(){return Re.create(this,this._def)}or(e){return Ve.create([this,e],this._def)}and(e){return Ze.create(this,e,this._def)}transform(e){return new ie({...C(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ye({...C(this._def),innerType:this,defaultValue:n,typeName:S.ZodDefault})}brand(){return new zt({typeName:S.ZodBranded,type:this,...C(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Xe({...C(this._def),innerType:this,catchValue:n,typeName:S.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Mt.create(this,e)}readonly(){return Qe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},_o=/^c[^\s-]{8,}$/i,Co=/^[0-9a-z]+$/,To=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ao=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Io=/^[a-z0-9_-]{21}$/i,Po=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Eo=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ro=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$o="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Nn,Do=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,jo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Oo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,No=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Lo=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,zo=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Hr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Mo=new RegExp(`^${Hr}$`);function Br(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Uo(t){return new RegExp(`^${Br(t)}$`)}function Wr(t){let e=`${Hr}T${Br(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Fo(t,e){return!!((e==="v4"||!e)&&Do.test(t)||(e==="v6"||!e)&&Oo.test(t))}function Ho(t,e){if(!Po.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function Bo(t,e){return!!((e==="v4"||!e)&&jo.test(t)||(e==="v6"||!e)&&No.test(t))}var Pe=class t extends A{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:g.string,received:i.parsedType}),v}let r=new G,a;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,s=e.data.length<i.value;(o||s)&&(a=this._getOrReturnCtx(e,a),o?f(a,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&f(a,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Ro.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Nn||(Nn=new RegExp($o,"u")),Nn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Ao.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Io.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")_o.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Co.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")To.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:m.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"regex",code:m.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Wr(i).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Mo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Uo(i).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Eo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Fo(e.data,i.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Ho(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"jwt",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Bo(e.data,i.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cidr",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Lo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?zo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64url",code:m.invalid_string,message:i.message}),r.dirty()):E.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(a=>e.test(a),{validation:n,code:m.invalid_string,...b.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...b.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...b.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Pe.create=t=>new Pe({checks:[],typeName:S.ZodString,coerce:t?.coerce??!1,...C(t)});function Wo(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=n>r?n:r,i=Number.parseInt(t.toFixed(a).replace(".","")),o=Number.parseInt(e.toFixed(a).replace(".",""));return i%o/10**a}var Me=class t extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:g.number,received:i.parsedType}),v}let r,a=new G;for(let i of this._def.checks)i.kind==="int"?E.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?Wo(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_finite,message:i.message}),a.dirty()):E.assertNever(i);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(a)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&E.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};Me.create=t=>new Me({checks:[],typeName:S.ZodNumber,coerce:t?.coerce||!1,...C(t)});var Ue=class t extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==g.bigint)return this._getInvalidInput(e);let r,a=new G;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):E.assertNever(i);return{status:a.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:g.bigint,received:n.parsedType}),v}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(a)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Ue.create=t=>new Ue({checks:[],typeName:S.ZodBigInt,coerce:t?.coerce??!1,...C(t)});var Fe=class extends A{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.boolean,received:r.parsedType}),v}return q(e.data)}};Fe.create=t=>new Fe({typeName:S.ZodBoolean,coerce:t?.coerce||!1,...C(t)});var He=class t extends A{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:g.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_date}),v}let r=new G,a;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):E.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};He.create=t=>new He({checks:[],coerce:t?.coerce||!1,typeName:S.ZodDate,...C(t)});var ht=class extends A{_parse(e){if(this._getType(e)!==g.symbol){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.symbol,received:r.parsedType}),v}return q(e.data)}};ht.create=t=>new ht({typeName:S.ZodSymbol,...C(t)});var Be=class extends A{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.undefined,received:r.parsedType}),v}return q(e.data)}};Be.create=t=>new Be({typeName:S.ZodUndefined,...C(t)});var We=class extends A{_parse(e){if(this._getType(e)!==g.null){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.null,received:r.parsedType}),v}return q(e.data)}};We.create=t=>new We({typeName:S.ZodNull,...C(t)});var Ee=class extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return q(e.data)}};Ee.create=t=>new Ee({typeName:S.ZodAny,...C(t)});var ye=class extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return q(e.data)}};ye.create=t=>new ye({typeName:S.ZodUnknown,...C(t)});var se=class extends A{_parse(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:g.never,received:n.parsedType}),v}};se.create=t=>new se({typeName:S.ZodNever,...C(t)});var mt=class extends A{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.void,received:r.parsedType}),v}return q(e.data)}};mt.create=t=>new mt({typeName:S.ZodVoid,...C(t)});var xe=class t extends A{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),a=this._def;if(n.parsedType!==g.array)return f(n,{code:m.invalid_type,expected:g.array,received:n.parsedType}),v;if(a.exactLength!==null){let o=n.data.length>a.exactLength.value,s=n.data.length<a.exactLength.value;(o||s)&&(f(n,{code:o?m.too_big:m.too_small,minimum:s?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(f(n,{code:m.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(f(n,{code:m.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,s)=>a.type._parseAsync(new ae(n,o,n.path,s)))).then(o=>G.mergeArray(r,o));let i=[...n.data].map((o,s)=>a.type._parseSync(new ae(n,o,n.path,s)));return G.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};xe.create=(t,e)=>new xe({type:t,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...C(e)});function pt(t){if(t instanceof X){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=re.create(pt(r))}return new X({...t._def,shape:()=>e})}else return t instanceof xe?new xe({...t._def,type:pt(t.element)}):t instanceof re?re.create(pt(t.unwrap())):t instanceof ue?ue.create(pt(t.unwrap())):t instanceof ce?ce.create(t.items.map(e=>pt(e))):t}var X=class t extends A{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=E.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==g.object){let d=this._getOrReturnCtx(e);return f(d,{code:m.invalid_type,expected:g.object,received:d.parsedType}),v}let{status:r,ctx:a}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof se&&this._def.unknownKeys==="strip"))for(let d in a.data)o.includes(d)||s.push(d);let c=[];for(let d of o){let u=i[d],p=a.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new ae(a,p,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof se){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(d==="strict")s.length>0&&(f(a,{code:m.unrecognized_keys,keys:s}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let u of s){let p=a.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new ae(a,p,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let d=[];for(let u of c){let p=await u.key,h=await u.value;d.push({key:p,value:h,alwaysSet:u.alwaysSet})}return d}).then(d=>G.mergeObjectSync(r,d)):G.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let a=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:b.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:S.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of E.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of E.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return pt(this)}partial(e){let n={};for(let r of E.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?n[r]=a:n[r]=a.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of E.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof re;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Vr(E.objectKeys(this.shape))}};X.create=(t,e)=>new X({shape:()=>t,unknownKeys:"strip",catchall:se.create(),typeName:S.ZodObject,...C(e)});X.strictCreate=(t,e)=>new X({shape:()=>t,unknownKeys:"strict",catchall:se.create(),typeName:S.ZodObject,...C(e)});X.lazycreate=(t,e)=>new X({shape:t,unknownKeys:"strip",catchall:se.create(),typeName:S.ZodObject,...C(e)});var Ve=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function a(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;let o=i.map(s=>new Y(s.ctx.common.issues));return f(n,{code:m.invalid_union,unionErrors:o}),v}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(a);{let i,o=[];for(let c of r){let d={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map(c=>new Y(c));return f(n,{code:m.invalid_union,unionErrors:s}),v}}get options(){return this._def.options}};Ve.create=(t,e)=>new Ve({options:t,typeName:S.ZodUnion,...C(e)});var be=t=>t instanceof Je?be(t.schema):t instanceof ie?be(t.innerType()):t instanceof Ge?[t.value]:t instanceof qe?t.options:t instanceof Ke?E.objectValues(t.enum):t instanceof Ye?be(t._def.innerType):t instanceof Be?[void 0]:t instanceof We?[null]:t instanceof re?[void 0,...be(t.unwrap())]:t instanceof ue?[null,...be(t.unwrap())]:t instanceof zt||t instanceof Qe?be(t.unwrap()):t instanceof Xe?be(t._def.innerType):[],an=class t extends A{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return f(n,{code:m.invalid_type,expected:g.object,received:n.parsedType}),v;let r=this.discriminator,a=n.data[r],i=this.optionsMap.get(a);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let a=new Map;for(let i of n){let o=be(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of o){if(a.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);a.set(s,i)}}return new t({typeName:S.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,...C(r)})}};function Ln(t,e){let n=de(t),r=de(e);if(t===e)return{valid:!0,data:t};if(n===g.object&&r===g.object){let a=E.objectKeys(e),i=E.objectKeys(t).filter(s=>a.indexOf(s)!==-1),o={...t,...e};for(let s of i){let c=Ln(t[s],e[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(n===g.array&&r===g.array){if(t.length!==e.length)return{valid:!1};let a=[];for(let i=0;i<t.length;i++){let o=t[i],s=e[i],c=Ln(o,s);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===g.date&&r===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Ze=class extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),a=(i,o)=>{if(nn(i)||nn(o))return v;let s=Ln(i.value,o.value);return s.valid?((rn(i)||rn(o))&&n.dirty(),{status:n.value,value:s.data}):(f(r,{code:m.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Ze.create=(t,e,n)=>new Ze({left:t,right:e,typeName:S.ZodIntersection,...C(n)});var ce=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return f(r,{code:m.invalid_type,expected:g.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return f(r,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new ae(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>G.mergeArray(n,o)):G.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};ce.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ce({items:t,typeName:S.ZodTuple,rest:null,...C(e)})};var on=class t extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return f(r,{code:m.invalid_type,expected:g.object,received:r.parsedType}),v;let a=[],i=this._def.keyType,o=this._def.valueType;for(let s in r.data)a.push({key:i._parse(new ae(r,s,r.path,s)),value:o._parse(new ae(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?G.mergeObjectAsync(n,a):G.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof A?new t({keyType:e,valueType:n,typeName:S.ZodRecord,...C(r)}):new t({keyType:Pe.create(),valueType:e,typeName:S.ZodRecord,...C(n)})}},ft=class extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.map)return f(r,{code:m.invalid_type,expected:g.map,received:r.parsedType}),v;let a=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([s,c],d)=>({key:a._parse(new ae(r,s,r.path,[d,"key"])),value:i._parse(new ae(r,c,r.path,[d,"value"]))}));if(r.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of o){let d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return v;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}})}else{let s=new Map;for(let c of o){let d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return v;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}}}};ft.create=(t,e,n)=>new ft({valueType:e,keyType:t,typeName:S.ZodMap,...C(n)});var gt=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return f(r,{code:m.invalid_type,expected:g.set,received:r.parsedType}),v;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(f(r,{code:m.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(f(r,{code:m.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let d=new Set;for(let u of c){if(u.status==="aborted")return v;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}let s=[...r.data.values()].map((c,d)=>i._parse(new ae(r,c,r.path,d)));return r.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(e,n){return new t({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};gt.create=(t,e)=>new gt({valueType:t,minSize:null,maxSize:null,typeName:S.ZodSet,...C(e)});var sn=class t extends A{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.function)return f(n,{code:m.invalid_type,expected:g.function,received:n.parsedType}),v;function r(s,c){return Lt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ct(),ge].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:c}})}function a(s,c){return Lt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ct(),ge].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Re){let s=this;return q(async function(...c){let d=new Y([]),u=await s._def.args.parseAsync(c,i).catch(y=>{throw d.addIssue(r(c,y)),d}),p=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(p,i).catch(y=>{throw d.addIssue(a(p,y)),d})})}else{let s=this;return q(function(...c){let d=s._def.args.safeParse(c,i);if(!d.success)throw new Y([r(c,d.error)]);let u=Reflect.apply(o,this,d.data),p=s._def.returns.safeParse(u,i);if(!p.success)throw new Y([a(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:ce.create(e).rest(ye.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||ce.create([]).rest(ye.create()),returns:n||ye.create(),typeName:S.ZodFunction,...C(r)})}},Je=class extends A{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Je.create=(t,e)=>new Je({getter:t,typeName:S.ZodLazy,...C(e)});var Ge=class extends A{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ge.create=(t,e)=>new Ge({value:t,typeName:S.ZodLiteral,...C(e)});function Vr(t,e){return new qe({values:t,typeName:S.ZodEnum,...C(e)})}var qe=class t extends A{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:E.joinValues(r),received:n.parsedType,code:m.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{received:n.data,code:m.invalid_enum_value,options:r}),v}return q(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};qe.create=Vr;var Ke=class extends A{_parse(e){let n=E.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){let a=E.objectValues(n);return f(r,{expected:E.joinValues(a),received:r.parsedType,code:m.invalid_type}),v}if(this._cache||(this._cache=new Set(E.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let a=E.objectValues(n);return f(r,{received:r.data,code:m.invalid_enum_value,options:a}),v}return q(e.data)}get enum(){return this._def.values}};Ke.create=(t,e)=>new Ke({values:t,typeName:S.ZodNativeEnum,...C(e)});var Re=class extends A{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.promise&&n.common.async===!1)return f(n,{code:m.invalid_type,expected:g.promise,received:n.parsedType}),v;let r=n.parsedType===g.promise?n.data:Promise.resolve(n.data);return q(r.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Re.create=(t,e)=>new Re({type:t,typeName:S.ZodPromise,...C(e)});var ie=class extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:o=>{f(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){let o=a.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async s=>{if(n.value==="aborted")return v;let c=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"?ze(c.value):n.value==="dirty"?ze(c.value):c});{if(n.value==="aborted")return v;let s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?ze(s.value):n.value==="dirty"?ze(s.value):s}}if(a.type==="refinement"){let o=s=>{let c=a.refinement(s,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:(s.status==="dirty"&&n.dirty(),o(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?v:(s.status==="dirty"&&n.dirty(),o(s.value).then(()=>({status:n.value,value:s.value}))))}if(a.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ie(o))return v;let s=a.transform(o.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ie(o)?Promise.resolve(a.transform(o.value,i)).then(s=>({status:n.value,value:s})):v);E.assertNever(a)}};ie.create=(t,e,n)=>new ie({schema:t,typeName:S.ZodEffects,effect:e,...C(n)});ie.createWithPreprocess=(t,e,n)=>new ie({schema:e,effect:{type:"preprocess",transform:t},typeName:S.ZodEffects,...C(n)});var re=class extends A{_parse(e){return this._getType(e)===g.undefined?q(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};re.create=(t,e)=>new re({innerType:t,typeName:S.ZodOptional,...C(e)});var ue=class extends A{_parse(e){return this._getType(e)===g.null?q(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ue.create=(t,e)=>new ue({innerType:t,typeName:S.ZodNullable,...C(e)});var Ye=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ye.create=(t,e)=>new Ye({innerType:t,typeName:S.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...C(e)});var Xe=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ut(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Y(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Y(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Xe.create=(t,e)=>new Xe({innerType:t,typeName:S.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...C(e)});var bt=class extends A{_parse(e){if(this._getType(e)!==g.nan){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:g.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}};bt.create=t=>new bt({typeName:S.ZodNaN,...C(t)});var Vo=Symbol("zod_brand"),zt=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Mt=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(n.dirty(),ze(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:S.ZodPipeline})}},Qe=class extends A{_parse(e){let n=this._def.innerType._parse(e),r=a=>(Ie(a)&&(a.value=Object.freeze(a.value)),a);return ut(n)?n.then(a=>r(a)):r(n)}unwrap(){return this._def.innerType}};Qe.create=(t,e)=>new Qe({innerType:t,typeName:S.ZodReadonly,...C(e)});function Fr(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Zr(t,e={},n){return t?Ee.create().superRefine((r,a)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let s=Fr(e,r),c=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:c})}});if(!i){let o=Fr(e,r),s=o.fatal??n??!0;a.addIssue({code:"custom",...o,fatal:s})}}):Ee.create()}var Zo={object:X.lazycreate},S;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(S||(S={}));var Jo=(t,e={message:`Input not instance of ${t.name}`})=>Zr(n=>n instanceof t,e),Jr=Pe.create,Gr=Me.create,Go=bt.create,qo=Ue.create,qr=Fe.create,Ko=He.create,Yo=ht.create,Xo=Be.create,Qo=We.create,es=Ee.create,ts=ye.create,ns=se.create,rs=mt.create,as=xe.create,is=X.create,os=X.strictCreate,ss=Ve.create,ls=an.create,ds=Ze.create,cs=ce.create,us=on.create,ps=ft.create,hs=gt.create,ms=sn.create,fs=Je.create,gs=Ge.create,bs=qe.create,ys=Ke.create,xs=Re.create,ks=ie.create,ws=re.create,vs=ue.create,Ss=ie.createWithPreprocess,_s=Mt.create,Cs=()=>Jr().optional(),Ts=()=>Gr().optional(),As=()=>qr().optional(),Is={string:(t=>Pe.create({...t,coerce:!0})),number:(t=>Me.create({...t,coerce:!0})),boolean:(t=>Fe.create({...t,coerce:!0})),bigint:(t=>Ue.create({...t,coerce:!0})),date:(t=>He.create({...t,coerce:!0}))};var Ps=v;var zn=l.object({id:l.string()}),Es=l.enum(["top","right","bottom","left","auto"]).default("auto"),Mn=l.enum(["left","middle","right"]),Rs=Mn.default("left"),Kr=l.object({label:l.string().optional(),hidden:l.boolean().default(!1)}),$s={background:l.string().optional(),textColor:l.string().optional(),borderRadius:l.string().optional(),textAlign:Rs,anchor:Es,showNavigation:l.boolean().default(!0),prevButton:Kr.optional(),nextButton:Kr.optional()},Ds=l.enum(["pointer","callout","area"]),js=l.discriminatedUnion("type",[l.object({type:l.literal("html-element"),alphaId:l.string().min(1)})]),Os=zn.extend({type:l.literal("message"),variant:Ds.default("callout"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1).optional(),h:l.number().min(0).max(1).optional(),text:l.string().optional(),target:js.optional(),advancesStep:l.boolean().default(!0),...$s}),Ns=zn.extend({type:l.literal("blur"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1),h:l.number().min(0).max(1),intensity:l.number().min(0).max(20).default(8)}),Ls=zn.extend({type:l.literal("text"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),text:l.string(),fontSize:l.number().positive().default(16),color:l.string().optional()}),Yr=l.discriminatedUnion("type",[Os,Ns,Ls]),Xr=new Set(["message","blur","text"]),Qr=l.object({type:l.string()}).passthrough();function ea(t){return typeof t=="object"&&t!==null?t.type:void 0}var ta=l.any().superRefine((t,e)=>{let a=(Xr.has(ea(t))?Yr:Qr).safeParse(t);if(!a.success)for(let i of a.error.issues)e.addIssue(i)}).transform(t=>(Xr.has(ea(t))?Yr:Qr).parse(t));var na=l.object({label:l.string().min(1),href:l.string().refine(t=>/^(https?:|mailto:)/i.test(t),"href must be an http(s) or mailto URL")}),Un=l.object({logo:l.string().min(1).optional(),name:l.string().min(1).optional(),logoHref:l.string().refine(t=>/^(https?:|mailto:)/i.test(t),"logoHref must be an http(s) or mailto URL").optional(),favicon:l.string().min(1).optional(),cta:na.optional(),secondaryCta:na.optional(),watermark:l.boolean().optional()}),ra=Un.omit({favicon:!0});var zs=l.object({type:l.literal("next")}),Ms=l.object({type:l.literal("prev")}),Us=l.object({type:l.literal("step"),stepId:l.string().min(1)}),Fs=l.object({type:l.literal("chapter"),chapterId:l.string().min(1)}),Hs=l.object({type:l.literal("url"),href:l.string().min(1),target:l.enum(["_self","_blank"]).default("_blank")}),Bs=l.object({type:l.literal("restart")}),Ws=l.discriminatedUnion("type",[zs,Ms,Us,Fs,Hs,Bs]),Vs=l.enum(["shimmer"]),ln=l.object({label:l.string().min(1),action:Ws.default({type:"next"}),animation:Vs.optional(),background:l.string().optional(),textColor:l.string().optional()});var Zs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Fn=/^[A-Za-z0-9_-]{12}$/;function Js(t){let e=globalThis.crypto;if(!e||typeof e.getRandomValues!="function")throw new Error("generateDemoId requires globalThis.crypto.getRandomValues (Node 19+, browsers, or edge runtime).");e.getRandomValues(t)}function te(){let t=new Uint8Array(12);Js(t);let e="";for(let n of t)e+=Zs.charAt(n&63);return e}function aa(t){return typeof t=="string"&&Fn.test(t)}function ia(t){return String(t+1).padStart(4,"0")}function oa(t){return`snap-${t.toString().padStart(3,"0")}`}function dn(t){let e=((t??"").toLowerCase().split(";")[0]??"").trim();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("font/")||e.includes("font")||e.includes("woff")?"font":"other"}function Hn(t){if(!t)return"";let e=t.replace(/^(?:tree\s*item|menu\s*item|menuitem|list\s*item|tab(?:\s*panel)?|button|link|option|region|combobox|radio|checkbox|switch|dialog|row|cell|columnheader|rowheader|navigation|article|banner|main|complementary|contentinfo)\s*:?\s+/i,"").trim();return(e.split(/\r?\n/).map(r=>r.trim()).find(Boolean)??e).replace(/\s+/g," ").trim().slice(0,48)}function Bn(t){let{stepId:e,assetId:n,posterAssetId:r,kind:a,isLast:i}=t,o=`asset:${n}`,s=a==="video"?{type:"video",src:o,posterSrc:r?`asset:${r}`:void 0,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,alt:t.title,sourceUrl:t.sourceUrl??"",title:t.title,autoplay:!0,muted:!0,objectFit:"cover"}:{type:"image",src:o,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,alt:t.title,sourceUrl:t.sourceUrl??"",title:t.title,objectFit:"cover"},c=t.click,d=[];if(c){let h=Hn(c.label);d.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:c.x,y:c.y,text:h?`Click on "${h}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}else d.push({id:`${e}_callout`,type:"message",variant:"callout",x:.5,y:.5,text:i?"End of walkthrough":"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});let u=!!c&&!(c.x===0&&c.y===0),p=a==="image"&&t.autoApplyZoom===!0&&u?{zoom:1.35,x:Number(Math.max(0,Math.min(1,c.x)).toFixed(4)),y:Number(Math.max(0,Math.min(1,c.y)).toFixed(4))}:void 0;return{id:e,kind:"content",background:s,...p?{transform:p}:{},annotations:d,advance:{trigger:"click"}}}function sa(t){let{stepId:e,htmlPath:n,click:r}=t,a=[];if(r?.alphaId)a.push({id:`${e}_area`,type:"message",variant:"area",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),w:0,h:0,text:Hn(r.label)||"Click here",target:{type:"html-element",alphaId:r.alphaId},anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});else if(r){let i=Hn(r.label);a.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),text:i?`Click on "${i}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}return{id:e,kind:"content",background:{type:"html",path:n,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,zoom:1,scroll:t.scroll,sourceUrl:t.sourceUrl??"",title:t.sourceUrl??""},annotations:a,advance:{trigger:"click"}}}function Gs(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wn(t,e){let n=t;for(let[r,a]of e){let i=Gs(r);n=n.replace(new RegExp(`(?:\\.\\./)*assets/${i}`,"g"),a),n=n.replace(new RegExp(`assets/${i}`,"g"),a)}return n}function qs(t){return`<script data-inkly-replay-scroll>(()=>{const c=${JSON.stringify(t).replace(/<\/(script)/gi,"<\\/$1")};function r(){const d=document.documentElement,b=document.body;const vw=innerWidth||d.clientWidth||0;const vh=innerHeight||d.clientHeight||0;const mx=Math.max(0,Math.max(d.scrollWidth,b?b.scrollWidth:0)-vw);const my=Math.max(0,Math.max(d.scrollHeight,b?b.scrollHeight:0)-vh);const x=c.maxX>0&&mx>0?c.x/c.maxX*mx:c.x;const y=c.maxY>0&&my>0?c.y/c.maxY*my:c.y;scrollTo(Math.max(0,x),Math.max(0,y));}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",r,{once:true});r();requestAnimationFrame(r);setTimeout(r,120);setTimeout(r,500);})();</script>`}function la(t,e){let n=qs(e);return/<\/body\s*>/i.test(t)?t.replace(/<\/body\s*>/i,`${n}</body>`):`${t}${n}`}function da(t,e){if(!e||/data-inkly-document-css|document\.css/i.test(t))return t;let n='<link rel="stylesheet" href="./document.css?draft=1" data-inkly-document-css>';return/<\/head\s*>/i.test(t)?t.replace(/<\/head\s*>/i,`${n}</head>`):`${n}${t}`}var ca=l.object({id:l.string(),text:l.string(),start:l.number().nonnegative().optional(),end:l.number().nonnegative().optional()});var Ks=l.enum(["screenshot","image","video","audio","font","other"]),Ys=l.object({id:l.string().min(1),path:l.string().min(1).optional(),uri:l.string().min(1).optional(),sha256:l.string().regex(/^[0-9a-f]{64}$/),kind:Ks,contentType:l.string().min(1).optional(),publicUrl:l.string().min(1).optional(),cdnPath:l.string().min(1).optional(),size:l.number().int().nonnegative().optional(),createdAt:l.string().min(1).optional(),updatedAt:l.string().min(1).optional(),viewport:l.object({w:l.number().int().positive(),h:l.number().int().positive()}).optional()}),yt=l.object({version:l.literal(1),assets:l.array(Ys),screens:l.array(l.unknown()).optional()});var Vn=l.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,{message:"must be a hex color like #5b3df5"}),Xs=l.enum(["color","image","glassmorphism"]),ua=l.object({type:Xs,color:Vn.optional(),from:Vn.optional(),to:Vn.optional(),src:l.string().min(1).optional(),alt:l.string().optional(),intensity:l.number().min(-5).max(48).optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,r=!!t.from&&!!t.to;!n&&!r&&e.addIssue({code:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:l.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),pa=l.object({src:l.string(),alt:l.string().optional()});var Zn=l.object({src:l.string().min(1),duration:l.number().positive().optional()});var Qs=l.enum(["text","dropdown"]),el=l.object({value:l.string().min(1),label:l.string().min(1)}),tl=l.object({id:l.string(),label:l.string(),type:Qs.default("text"),placeholder:l.string().optional(),required:l.boolean().default(!1),options:l.array(el).optional()}).superRefine((t,e)=>{t.type==="dropdown"&&(!t.options||t.options.length===0)&&e.addIssue({code:l.ZodIssueCode.custom,message:"Dropdown field requires at least one option.",path:["options"]})}),ba=l.object({src:l.string().min(1),alt:l.string().optional(),height:l.number().int().positive().optional()}),nl=l.enum(["left","right","top"]),rl=l.enum(["standard","hero"]),ya=l.object({src:l.string().min(1),alt:l.string().optional(),naturalWidth:l.number().positive().optional(),naturalHeight:l.number().positive().optional(),position:nl.default("right"),layout:rl.default("hero")}),al=l.object({type:l.literal("headline"),id:l.string(),logo:ba.optional(),image:ya.optional(),title:l.string(),titleColor:l.string().optional(),description:l.string().optional(),descriptionColor:l.string().optional(),textAlign:Mn.optional(),cta:ln.optional(),secondaryCta:ln.optional()}),il=l.object({type:l.literal("form"),id:l.string(),logo:ba.optional(),image:ya.optional(),title:l.string().optional(),description:l.string().optional(),fields:l.array(tl).min(1),submit:ln.default({label:"Submit",action:{type:"next"}})}),ol="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",sl="camera; microphone; fullscreen; payment; clipboard-write",ll=l.object({type:l.literal("embed"),id:l.string(),src:l.string(),iframeTitle:l.string().optional(),sandbox:l.string().default(ol),allow:l.string().default(sl)}),dl=l.object({type:l.literal("custom"),id:l.string(),name:l.string().min(1),data:l.record(l.unknown()).optional()}),ha=l.discriminatedUnion("type",[al,il,ll,dl]),ma=new Set(["headline","form","embed","custom"]),fa=l.object({type:l.string()}).passthrough();function ga(t){return typeof t=="object"&&t!==null?t.type:void 0}var xa=l.any().superRefine((t,e)=>{let a=(ma.has(ga(t))?ha:fa).safeParse(t);if(!a.success)for(let i of a.error.issues)e.addIssue(i)}).transform(t=>(ma.has(ga(t))?ha:fa).parse(t));var ka=l.enum(["contain","cover","fill"]),wa=l.enum(["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"]),cl=l.object({type:l.literal("image"),src:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),objectFit:ka.optional(),objectPosition:wa.optional()}),ul=l.object({type:l.literal("video"),src:l.string().min(1),posterSrc:l.string().min(1).optional(),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),autoplay:l.boolean().default(!0),muted:l.boolean().default(!0),objectFit:ka.optional(),objectPosition:wa.optional()}),pl=l.object({x:l.number().nonnegative().default(0),y:l.number().nonnegative().default(0),maxX:l.number().nonnegative().default(0),maxY:l.number().nonnegative().default(0)}),hl=l.object({type:l.literal("html"),path:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),zoom:l.number().positive().default(1),scroll:pl.default({x:0,y:0,maxX:0,maxY:0}),sourceUrl:l.string().optional(),title:l.string().optional()}),ml=l.discriminatedUnion("type",[cl,ul,hl]),fl=l.object({zoom:l.number().min(1).default(1),x:l.number().min(0).max(1).default(.5),y:l.number().min(0).max(1).default(.5)}),gl=l.object({trigger:l.enum(["auto","click"]).default("auto")}).default({trigger:"auto"}),bl=l.object({kind:l.literal("content").default("content"),id:l.string(),label:l.string().optional(),duration:l.number().positive().optional(),background:ml,script:l.string().optional(),voiceover:Zn.optional(),transform:fl.optional(),advance:gl,annotations:l.array(ta).default([]),captions:l.array(ca).optional()}).passthrough(),yl=l.object({kind:l.literal("cover"),id:l.string(),label:l.string().optional(),widgets:l.array(xa).length(1),background:ua.optional(),backgroundImage:pa.optional(),backgroundDim:l.number().min(0).max(1).optional(),script:l.string().optional(),voiceover:Zn.optional(),duration:l.number().positive().optional(),advance:l.object({trigger:l.enum(["auto","click"]).default("click")}).default({trigger:"click"})}).passthrough(),va=l.discriminatedUnion("kind",[bl,yl]);var xl=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,Sa=l.string().regex(xl,"must be a hex color like #5b3df5"),cn=l.object({primary:Sa.optional(),secondary:Sa.optional(),font:l.string().min(1).optional(),radius:l.string().min(1).optional()}).partial();var un=l.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,{message:"must be a hex color like #5b3df5"}),kl=l.object({id:l.string(),title:l.string(),stepIds:l.array(l.string()).min(1)}),wl=l.object({hideHeader:l.boolean().default(!1),hideControls:l.boolean().default(!1),controls:l.enum(["full","minimal","hidden"]).optional(),showHubBreadcrumb:l.boolean().default(!1),mobileFooterMessage:l.boolean().default(!0),autoplay:l.boolean().default(!1)}),vl=l.object({width:l.number().positive(),height:l.number().positive()}),Sl=l.enum(["public","private"]),_l=l.enum(["none","color","image"]),Cl=l.object({type:_l,color:un.optional(),from:un.optional(),to:un.optional(),src:l.string().min(1).optional(),alt:l.string().optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,r=!!t.from&&!!t.to;!n&&!r&&e.addIssue({code:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:l.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),et=l.object({id:l.string().regex(Fn,{message:"must be a 12-character URL-safe demo id (see generateDemoId)"}),version:l.number().int().min(1),title:l.string().optional(),subtitle:l.string().optional(),runtime:l.string().min(1).optional(),visibility:Sl.default("public"),backgroundColor:un.optional(),background:Cl.optional(),theme:l.object({preset:l.string().min(1).optional(),tokens:cn.optional(),brand:ra.optional()}).optional(),chrome:wl.default({}),aspectRatio:vl.optional(),chapters:l.array(kl).default([]),steps:l.array(va).min(1)}).passthrough().superRefine((t,e)=>{let n=new Set(t.steps.map(a=>a.id)),r=new Set(t.chapters.map(a=>a.id));t.chapters.forEach((a,i)=>{a.stepIds.forEach(o=>{n.has(o)||e.addIssue({code:l.ZodIssueCode.custom,path:["chapters",i,"stepIds"],message:`Chapter "${a.id}" references unknown step "${o}"`})})}),t.steps.forEach((a,i)=>{a.kind==="cover"&&a.widgets.forEach((o,s)=>{o.type==="headline"&&["cta","secondaryCta"].forEach(c=>{let d=o[c]?.action;d&&(d.type==="step"&&!n.has(d.stepId)&&e.addIssue({code:l.ZodIssueCode.custom,path:["steps",i,"widgets",s,c,"action","stepId"],message:`Widget "${o.id}" CTA targets unknown step "${d.stepId}"`}),d.type==="chapter"&&!r.has(d.chapterId)&&e.addIssue({code:l.ZodIssueCode.custom,path:["steps",i,"widgets",s,c,"action","chapterId"],message:`Widget "${o.id}" CTA targets unknown chapter "${d.chapterId}"`}))})})})});function pn(t){return et.parse(t)}function xt(t){let e=typeof t=="object"&&t!==null?t:{},n=aa(e.id),r=n?e:{...e,id:te()};return{config:et.parse(r),changed:!n}}function _a(t){let e=new Map;t.forEach((r,a)=>{let i=e.get(r.id);i?i.push({entry:r,index:a}):e.set(r.id,[{entry:r,index:a}])});let n=[];for(let r of e.values()){if(r.length<2)continue;let a=[...r].sort((o,s)=>o.entry.updatedAt!==s.entry.updatedAt?o.entry.updatedAt-s.entry.updatedAt:o.index-s.index),[,...i]=a;for(let{entry:o}of i)n.push({entry:o,newId:te()})}return n}var Jn=l.enum(["sidebar","tabs"]),Tl=l.object({name:l.string().min(1),description:l.string().min(1).optional(),icon:l.string().min(1).optional(),demos:l.array(l.string().min(1))}),pe=l.object({$schema:l.string().optional(),name:l.string().min(1),runtime:l.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,"runtime must be an exact semver version"),runtimeRange:l.string().min(1).optional(),layout:Jn.optional(),theme:l.string().min(1).optional(),tokens:cn.optional(),brand:Un.optional(),title:l.string().min(1).optional(),subtitle:l.string().min(1).optional(),collections:l.array(Tl).optional()});function Ca({slug:t,config:e,resolveAssetSrc:n}){let r=e.title??e.id??t;return{slug:t,title:r,description:Al(e,r),thumbnail:El(e,r,n),visibility:e.visibility}}function hn(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function Al(t,e){if(t.subtitle?.trim())return hn(t.subtitle.trim(),120);for(let n of t.steps){if(n.kind!=="content")continue;let r=n.captions?.[0]?.text;if(r&&r.trim())return hn(r.trim(),120);break}for(let n of t.steps)if(n.kind==="cover"){for(let r of n.widgets)if(r.type==="headline"&&r.description&&r.description.trim())return hn(r.description.trim(),120)}return hn(`Explore the ${e} workflow.`,120)}function Il(t){return t.background?t.background.type==="image":t.backgroundImage?!0:t.widgets.some(e=>e.type==="headline"?!!e.title:e.type==="embed"?!!e.src:e.type==="form")}function Gn(t,e){return t?e?e(t):t:null}function Pl(t,e){if(!e)return t;let n=t.widgets.map(o=>{if((o.type==="headline"||o.type==="form")&&o.image?.src){let s=e(o.image.src);return s&&s!==o.image.src?{...o,image:{...o.image,src:s}}:o}return o}),r=t.backgroundImage,a=t.background;if(a?.type==="image"&&a.src){let o=e(a.src);o&&o!==a.src&&(a={...a,src:o})}if(r?.src){let o=e(r.src);o&&o!==r.src&&(r={...r,src:o})}return!n.some((o,s)=>o!==t.widgets[s])&&a===t.background&&r===t.backgroundImage?t:{...t,widgets:n,background:a,backgroundImage:r}}function El(t,e,n){let r=t.steps[0];if(r){if(r.kind==="cover"&&Il(r))return{kind:"cover",cover:Pl(r,n),themeTokens:t.theme?.tokens};if(r.kind==="content"){let a=r.background;if(a?.type==="image"){let i=Gn(a.src,n);if(i)return{kind:"image",src:i}}else if(a?.type==="video"){let i=Gn(a.posterSrc,n);if(i)return{kind:"image",src:i};let o=Gn(a.src,n);if(o)return{kind:"video",src:o}}else if(a?.type==="html")return{kind:"html",path:a.path,naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight,zoom:a.zoom,scroll:a.scroll}}}return{kind:"placeholder",title:e}}function Rl(t){return!t||t==="null"?"":t.replace(/\/+$/,"")}function $l(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dl(t){return String(t||"").replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"")}function qn(t){let e=Dl(t);return/\/index\.html$/i.test(e)||/^index\.html$/i.test(e)?e.replace(/index\.html$/i,"document.css"):/\.html?$/i.test(e)?e.replace(/\.html?$/i,".css"):null}function jl(t){return t.replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?content-security-policy\b)[^>]*>/gi,"")}var Ol=/\s+(?:href|xlink:href|target|rel|download|ping|referrerpolicy|data-inkly-href)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?/gi;function Ut(t){return String(t||"").replace(/<(a|area)\b[^>]*>/gi,e=>e.replace(Ol,""))}function tt(t,e={}){let n=Rl(e.resourceOrigin),r=String(t||"");return n?r.replace(new RegExp(`(^|["'\\(\\s,=])${$l("/api/hubs/")}`,"g"),`$1${n}/api/hubs/`):r}function Nl(t){return jl(t).replace(/<style\b(?=[^>]*\bdata-inkly-document-css\b)[\s\S]*?<\/style>/gi,"").replace(/<link\b(?=[^>]*\bdata-inkly-document-css\b)[^>]*>/gi,"").replace(/<link\b(?=[^>]*\brel\s*=\s*["']?stylesheet\b)(?=[^>]*\bhref\s*=\s*["']?[^"'\s>]*document\.css(?:\?draft=1)?)[^>]*>/gi,"")}function Ta({htmlPath:t,html:e,css:n,cssHref:r,resourceOrigin:a}){let i=Nl(Ut(e)),o=qn(t)!=null,s=n?.trim()??"";if(o&&s){let d=`<style data-inkly-document-css>
|
|
3
|
+
${tt(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
4
|
+
</style>`,u=/<\/head\s*>/i.test(i)?i.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${i}`;return tt(u,{resourceOrigin:a})}if(o&&r){let d=`<link rel="stylesheet" href="${tt(r,{resourceOrigin:a})}" data-inkly-document-css>`,u=/<\/head\s*>/i.test(i)?i.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${i}`;return tt(u,{resourceOrigin:a})}return tt(i,{resourceOrigin:a})}var Ft=l.string().regex(/^sha(?:256|384|512)-[A-Za-z0-9+/]+=*$/,{message:"must be an SRI string like sha384-<base64>"}),mn=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"}),Ll=l.object({version:mn,url:l.string().url(),integrity:Ft}),fn=l.object({$schema:l.string().optional(),runtime:Ll});var Aa=l.string().regex(/^[0-9a-f]{64}$/,{message:"must be lowercase sha-256 hex (64 chars)"}),kt=l.object({version:mn,externals:l.array(l.string().min(1)),jsHash:Aa,cssHash:Aa,jsBytes:l.number().int().nonnegative(),cssBytes:l.number().int().nonnegative(),integrity:Ft,cssIntegrity:Ft,minSchema:mn,codemodsIntegrity:Ft.optional(),codemodsBytes:l.number().int().nonnegative().optional()});var wt=["__inkly","assets","api","c"],zl={__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"},Ml=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;function ke(t){return typeof t!="string"?{ok:!1,reason:"Name is required."}:t.length===0?{ok:!1,reason:"Name cannot be empty."}:/\s/.test(t)?{ok:!1,reason:"Name cannot contain spaces."}:t.includes("/")||t.includes("\\")?{ok:!1,reason:"Name cannot contain slashes."}:t.includes(".")?{ok:!1,reason:"Name cannot contain dots."}:wt.includes(t)?{ok:!1,reason:zl[t]}:t.startsWith("_")?{ok:!1,reason:"Name cannot start with '_' (reserved for internal use)."}:t!==t.toLowerCase()?{ok:!1,reason:'Name must be lowercase (e.g. "getting-started").'}:Ml.test(t)?{ok:!0}:{ok:!1,reason:"Name must be kebab-case: lowercase letters, digits, and hyphens, starting and ending with a letter or digit."}}var $e={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 Ul=`
|
|
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
|
|
@@ -940,7 +940,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
940
940
|
wins when authors want a unique cover image. */
|
|
941
941
|
[data-demo-theme="editorial"] .demo-intro{
|
|
942
942
|
background-color: #f5efe2;
|
|
943
|
-
background-image: url("https://
|
|
943
|
+
background-image: url("https://www.cdn.inklyai.dev/backgrounds/player-background-claude.png");
|
|
944
944
|
background-size: cover;
|
|
945
945
|
background-position: center;
|
|
946
946
|
background-repeat: no-repeat;
|
|
@@ -1191,7 +1191,7 @@ ${tt(n??"",{resourceOrigin:r}).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
|
+
`,Ia={id:"editorial",label:"Editorial",theme:$e.editorial,css:Ul};var Fl=`
|
|
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,27 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2333
2333
|
border-radius: 10px;
|
|
2334
2334
|
box-shadow: none;
|
|
2335
2335
|
}
|
|
2336
|
-
`,
|
|
2336
|
+
`,Pa={id:"mono",label:"Mono",theme:$e.mono,css:Fl};var Hl=`
|
|
2337
|
+
/* Newsreader 600 \u2014 the true semi-bold cut for the "Built with Inkly"
|
|
2338
|
+
wordmark. Self-hosted on the Inkly bundle CDN so the self-contained demo
|
|
2339
|
+
document loads it without a Google Fonts round-trip; Georgia is the
|
|
2340
|
+
fallback while it loads (font-display: swap). Only the inkly theme uses
|
|
2341
|
+
"Newsreader" and this preset CSS is injected only for inkly demos, so the
|
|
2342
|
+
face is never declared \u2014 or fetched \u2014 for the other themes.
|
|
2343
|
+
NOTE: the CDN must serve this file with "Access-Control-Allow-Origin: *"
|
|
2344
|
+
\u2014 cross-origin webfonts are CORS-gated (unlike the watercolor <img>). */
|
|
2345
|
+
@font-face {
|
|
2346
|
+
font-family: "Newsreader";
|
|
2347
|
+
font-style: normal;
|
|
2348
|
+
font-weight: 600;
|
|
2349
|
+
font-display: swap;
|
|
2350
|
+
/* ?v=1 is a cache-buster, not a real query param: requesting the font
|
|
2351
|
+
before it was uploaded cached a 404 (Cloudflare's 4h default) in
|
|
2352
|
+
browsers + edge; a fresh URL sidesteps that stale negative. Bump on
|
|
2353
|
+
any future re-upload to this path. */
|
|
2354
|
+
src: url("https://www.cdn.inklyai.dev/fonts/newsreader/newsreader-latin-600-normal.woff2?v=1") format("woff2");
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2337
2357
|
/* \u2500\u2500 Inkly hub-index \u2014 designs 14 v2 (top nav) + 24 v3 (sidebar
|
|
2338
2358
|
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
|
|
2339
2359
|
All sans (Geist), no italic, no serif. Dotted canvas backdrop, indigo
|
|
@@ -2353,7 +2373,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2353
2373
|
--inkly-hub-line-strong: #aaaaaa;
|
|
2354
2374
|
--inkly-hub-ink-strong: #1f1f1f;
|
|
2355
2375
|
--inkly-hub-ink-2: #3a3a3a;
|
|
2356
|
-
--inkly-hub-ink-muted: #
|
|
2376
|
+
--inkly-hub-ink-muted: #6b6b6b;
|
|
2357
2377
|
--inkly-hub-accent: #5b6cff;
|
|
2358
2378
|
/* Darker companion to --inkly-hub-accent, used for the primary
|
|
2359
2379
|
button's border + the glow/aura under it. Derived from the
|
|
@@ -2501,6 +2521,12 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2501
2521
|
min-width: 220px;
|
|
2502
2522
|
box-sizing: border-box;
|
|
2503
2523
|
}
|
|
2524
|
+
.inkly-hub-pa-search:focus-within {
|
|
2525
|
+
border-color: color-mix(in oklab, var(--inkly-hub-accent) 58%, var(--inkly-hub-line));
|
|
2526
|
+
box-shadow:
|
|
2527
|
+
0 0 0 3px color-mix(in oklab, var(--inkly-hub-accent) 18%, transparent),
|
|
2528
|
+
var(--inkly-hub-shadow-press);
|
|
2529
|
+
}
|
|
2504
2530
|
.inkly-hub-pa-search-icon {
|
|
2505
2531
|
position: absolute;
|
|
2506
2532
|
left: 12px;
|
|
@@ -2513,6 +2539,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2513
2539
|
margin: 0;
|
|
2514
2540
|
font: inherit;
|
|
2515
2541
|
cursor: pointer;
|
|
2542
|
+
border-radius: 7px;
|
|
2516
2543
|
}
|
|
2517
2544
|
.inkly-hub-pa-search-icon svg {
|
|
2518
2545
|
width: 13px;
|
|
@@ -2546,6 +2573,16 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2546
2573
|
box-sizing: border-box;
|
|
2547
2574
|
transition: box-shadow 120ms ease, transform 80ms ease, filter 120ms ease;
|
|
2548
2575
|
}
|
|
2576
|
+
.inkly-hub-pa-cta:focus-visible,
|
|
2577
|
+
.inkly-hub-pa-pill:focus-visible,
|
|
2578
|
+
.inkly-hub-demo-card:focus-visible,
|
|
2579
|
+
.inkly-hub-pa-shell-nav-item:focus-visible,
|
|
2580
|
+
.inkly-hub-pa-mobilebar-toggle:focus-visible,
|
|
2581
|
+
.inkly-hub-pa-shell-nav-close:focus-visible,
|
|
2582
|
+
.inkly-hub-pa-search-icon:focus-visible {
|
|
2583
|
+
outline: 2px solid var(--inkly-hub-accent);
|
|
2584
|
+
outline-offset: 2px;
|
|
2585
|
+
}
|
|
2549
2586
|
.inkly-hub-pa-cta.is-primary {
|
|
2550
2587
|
background-image: linear-gradient(
|
|
2551
2588
|
180deg,
|
|
@@ -2604,7 +2641,10 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2604
2641
|
.inkly-hub-pa-topbar-inner {
|
|
2605
2642
|
position: relative;
|
|
2606
2643
|
display: grid;
|
|
2607
|
-
|
|
2644
|
+
/* Symmetric side columns (1fr each) so the centered search track sits
|
|
2645
|
+
on the true viewport centerline regardless of how wide the brand
|
|
2646
|
+
cluster or the CTA group are. */
|
|
2647
|
+
grid-template-columns: 1fr auto 1fr;
|
|
2608
2648
|
align-items: center;
|
|
2609
2649
|
gap: 12px;
|
|
2610
2650
|
/* Match the 56px demo viewer header height. */
|
|
@@ -2614,10 +2654,20 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2614
2654
|
max-width: 1200px;
|
|
2615
2655
|
margin: 0 auto;
|
|
2616
2656
|
}
|
|
2657
|
+
.inkly-hub-pa-topbar-brand {
|
|
2658
|
+
display: flex;
|
|
2659
|
+
align-items: center;
|
|
2660
|
+
gap: 10px;
|
|
2661
|
+
min-width: 0;
|
|
2662
|
+
}
|
|
2617
2663
|
.inkly-hub-pa-topbar-search-center {
|
|
2618
2664
|
min-width: 0;
|
|
2619
|
-
width
|
|
2620
|
-
|
|
2665
|
+
/* Definite width (no percentage). The centered track is 'auto', and a
|
|
2666
|
+
'min(100%, \u2026)' resolves its 100% against that still-being-sized track
|
|
2667
|
+
and collapses to content width \u2014 which narrowed the search. A plain
|
|
2668
|
+
clamp (cqw is definite) lets the auto track adopt the real width. The
|
|
2669
|
+
1fr side gutters + the ellipsizing brand name prevent overflow. */
|
|
2670
|
+
width: clamp(280px, 46cqw, 560px);
|
|
2621
2671
|
justify-self: center;
|
|
2622
2672
|
}
|
|
2623
2673
|
.inkly-hub-pa-topbar-search-center .inkly-hub-pa-search {
|
|
@@ -2639,7 +2689,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2639
2689
|
margin: 0;
|
|
2640
2690
|
font-weight: 600;
|
|
2641
2691
|
line-height: 1.08;
|
|
2642
|
-
letter-spacing: -
|
|
2692
|
+
letter-spacing: -0.5px;
|
|
2643
2693
|
color: var(--inkly-hub-ink-strong);
|
|
2644
2694
|
max-width: 820px;
|
|
2645
2695
|
font-size: 40px;
|
|
@@ -2713,11 +2763,11 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2713
2763
|
}
|
|
2714
2764
|
.inkly-hub-pa-pill-count {
|
|
2715
2765
|
font-size: 11px;
|
|
2716
|
-
color: var(--inkly-hub-
|
|
2766
|
+
color: var(--inkly-hub-ink-muted);
|
|
2717
2767
|
font-variant-numeric: tabular-nums;
|
|
2718
2768
|
}
|
|
2719
2769
|
.inkly-hub-pa-pill[aria-current="page"] .inkly-hub-pa-pill-count {
|
|
2720
|
-
color: var(--inkly-hub-ink-
|
|
2770
|
+
color: var(--inkly-hub-ink-2);
|
|
2721
2771
|
}
|
|
2722
2772
|
|
|
2723
2773
|
/* \u2500\u2500 Sidebar (connected L-shell) layout \u2014 design 24 v3 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
@@ -2749,7 +2799,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2749
2799
|
}
|
|
2750
2800
|
.inkly-hub-pa-shell-logo-cluster .inkly-hub-pa-brand-name {
|
|
2751
2801
|
flex: 1;
|
|
2752
|
-
font-size:
|
|
2802
|
+
font-size: 15px;
|
|
2753
2803
|
}
|
|
2754
2804
|
.inkly-hub-pa-shell-bar {
|
|
2755
2805
|
display: flex;
|
|
@@ -2893,7 +2943,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2893
2943
|
}
|
|
2894
2944
|
.inkly-hub-pa-shell-hero .inkly-hub-pa-title {
|
|
2895
2945
|
font-size: 40px;
|
|
2896
|
-
letter-spacing: -
|
|
2946
|
+
letter-spacing: -0.5px;
|
|
2897
2947
|
}
|
|
2898
2948
|
.inkly-hub-pa-shell-hero .inkly-hub-pa-subtitle {
|
|
2899
2949
|
font-size: 16px;
|
|
@@ -2919,7 +2969,12 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2919
2969
|
border-radius: 14px;
|
|
2920
2970
|
overflow: hidden;
|
|
2921
2971
|
transition: box-shadow 120ms ease;
|
|
2922
|
-
|
|
2972
|
+
/* Subtle resting lift so the card surface (#f8f8f8) separates from the
|
|
2973
|
+
near-identical dotted canvas (#f5f5f5) instead of relying on the 1px
|
|
2974
|
+
hairline alone. Deepens to the full lift shadow on hover. */
|
|
2975
|
+
box-shadow:
|
|
2976
|
+
0 1px 1px rgba(0, 0, 0, 0.03),
|
|
2977
|
+
0 1px 2px rgba(0, 0, 0, 0.04);
|
|
2923
2978
|
}
|
|
2924
2979
|
.hub-index[data-theme="inkly"] .inkly-hub-demo-card:hover {
|
|
2925
2980
|
transform: none;
|
|
@@ -3001,8 +3056,8 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3001
3056
|
|
|
3002
3057
|
@container hub-pa-tabs (max-width: 1080px) {
|
|
3003
3058
|
.hub-index[data-theme="inkly"][data-layout="tabs"] .inkly-hub-pa-topbar-inner {
|
|
3004
|
-
padding:
|
|
3005
|
-
grid-template-columns: auto
|
|
3059
|
+
padding: 0 20px;
|
|
3060
|
+
grid-template-columns: 1fr auto 1fr;
|
|
3006
3061
|
}
|
|
3007
3062
|
.hub-index[data-theme="inkly"][data-layout="tabs"] .inkly-hub-pa-topbar-inner .inkly-hub-pa-brand-name {
|
|
3008
3063
|
min-width: 0;
|
|
@@ -3012,7 +3067,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3012
3067
|
white-space: nowrap;
|
|
3013
3068
|
}
|
|
3014
3069
|
.hub-index[data-theme="inkly"][data-layout="tabs"] .inkly-hub-pa-topbar-search-center {
|
|
3015
|
-
width:
|
|
3070
|
+
width: clamp(240px, 44cqw, 520px);
|
|
3016
3071
|
}
|
|
3017
3072
|
.hub-index[data-theme="inkly"][data-layout="tabs"] .inkly-hub-pa-hero {
|
|
3018
3073
|
padding: 32px 20px 0;
|
|
@@ -3056,7 +3111,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3056
3111
|
display: block;
|
|
3057
3112
|
margin-left: auto;
|
|
3058
3113
|
flex: 0 0 auto;
|
|
3059
|
-
width:
|
|
3114
|
+
width: 40px;
|
|
3060
3115
|
max-width: none;
|
|
3061
3116
|
min-width: 0;
|
|
3062
3117
|
transition: width 220ms cubic-bezier(0.22, 0.61, 0.36, 1);
|
|
@@ -3066,7 +3121,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3066
3121
|
}
|
|
3067
3122
|
.hub-index[data-theme="inkly"][data-layout="tabs"] .inkly-hub-pa-topbar-search-center .inkly-hub-pa-search {
|
|
3068
3123
|
width: 100%;
|
|
3069
|
-
height:
|
|
3124
|
+
height: 40px;
|
|
3070
3125
|
min-width: 0;
|
|
3071
3126
|
padding: 0;
|
|
3072
3127
|
border-color: transparent;
|
|
@@ -3080,8 +3135,8 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3080
3135
|
.hub-index[data-theme="inkly"][data-layout="tabs"] .inkly-hub-pa-topbar-search-center .inkly-hub-pa-search-icon {
|
|
3081
3136
|
position: absolute;
|
|
3082
3137
|
inset: 0 auto 0 0;
|
|
3083
|
-
width:
|
|
3084
|
-
height:
|
|
3138
|
+
width: 40px;
|
|
3139
|
+
height: 40px;
|
|
3085
3140
|
display: grid;
|
|
3086
3141
|
place-items: center;
|
|
3087
3142
|
pointer-events: auto;
|
|
@@ -3423,7 +3478,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3423
3478
|
|
|
3424
3479
|
/* \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
3425
3480
|
Demo-player chrome. Activated via [data-demo-theme="inkly"]
|
|
3426
|
-
set by Demo.Root in @inkly/
|
|
3481
|
+
set by Demo.Root in @inkly/runtime (and mirrored by the
|
|
3427
3482
|
editor stage). These rules paint the macOS-style frame, dotted
|
|
3428
3483
|
backdrop, gradient header, hotspot bubbles, controls, and intro
|
|
3429
3484
|
cover that surround every demo when the inkly theme is
|
|
@@ -3468,9 +3523,16 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3468
3523
|
when authors want a unique cover image. */
|
|
3469
3524
|
[data-demo-theme="inkly"] .demo-intro{
|
|
3470
3525
|
background-color: #f5f5f5;
|
|
3471
|
-
|
|
3526
|
+
/* A translucent white wash layered over the watercolor pales it back a
|
|
3527
|
+
touch so the near-black headline + muted description read with more
|
|
3528
|
+
contrast against the sky. Gradient layer paints above the image. */
|
|
3529
|
+
background-image:
|
|
3530
|
+
linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3)),
|
|
3531
|
+
url("https://www.cdn.inklyai.dev/backgrounds/watercolor-background.png");
|
|
3472
3532
|
background-size: cover;
|
|
3473
|
-
|
|
3533
|
+
/* Nudge the image left + down so the bottom-left watercolor tree clears
|
|
3534
|
+
the headline/description that sit on the left of the cover. */
|
|
3535
|
+
background-position: 70% 30%;
|
|
3474
3536
|
background-repeat: no-repeat;
|
|
3475
3537
|
}
|
|
3476
3538
|
|
|
@@ -3505,6 +3567,14 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3505
3567
|
color: #3a3a3a;
|
|
3506
3568
|
border-color: #dddddd;
|
|
3507
3569
|
}
|
|
3570
|
+
/* The header carries a bottom-only border + inset highlight, so the
|
|
3571
|
+
visual content area is ~1px shorter at the bottom than the grid's
|
|
3572
|
+
centering math assumes. Geometrically-centered lights therefore read
|
|
3573
|
+
as sitting slightly high; nudge the group down 1px for optical center. */
|
|
3574
|
+
[data-demo-theme="inkly"] .demo-header-lights {
|
|
3575
|
+
position: relative;
|
|
3576
|
+
top: 1px;
|
|
3577
|
+
}
|
|
3508
3578
|
[data-demo-theme="inkly"] .demo-header-light {
|
|
3509
3579
|
border: 1px solid rgba(0,0,0,0.18);
|
|
3510
3580
|
box-shadow: inset 0 1px 0 rgba(255,255,255,0.4),
|
|
@@ -3660,11 +3730,11 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3660
3730
|
text-wrap: balance;
|
|
3661
3731
|
}
|
|
3662
3732
|
[data-demo-theme="inkly"] .demo-intro-title em{
|
|
3663
|
-
font-style:
|
|
3733
|
+
font-style: normal;
|
|
3664
3734
|
color: #2a3aaa;
|
|
3665
3735
|
}
|
|
3666
3736
|
[data-demo-theme="inkly"] .demo-intro-description{
|
|
3667
|
-
color: #
|
|
3737
|
+
color: #5f5f5f;
|
|
3668
3738
|
font-size: 15px;
|
|
3669
3739
|
line-height: 1.55;
|
|
3670
3740
|
max-width: 46ch;
|
|
@@ -3810,6 +3880,62 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3810
3880
|
0 1px 2px rgba(0,0,0,0.06),
|
|
3811
3881
|
0 8px 18px -12px rgba(0,0,0,0.22);
|
|
3812
3882
|
--demo-watermark-mark-radius: 7px;
|
|
3883
|
+
/* Tighten the pill against the base badge's roomier defaults: trim the
|
|
3884
|
+
icon-side (leading) inset, the icon\u2194text gap, and the text-side
|
|
3885
|
+
(trailing) inset so the serif wordmark sits snug. Leading is a hair
|
|
3886
|
+
tighter than trailing since the round mark carries its own
|
|
3887
|
+
whitespace. Top/bottom stay 3px (symmetric). */
|
|
3888
|
+
gap: 4px;
|
|
3889
|
+
padding: 3px 6px 3px 5px;
|
|
3890
|
+
}
|
|
3891
|
+
/* Editorial serif wordmark \u2014 a newsreader-class serif gives the watermark
|
|
3892
|
+
a more crafted, magazine feel than the all-sans chrome. Newsreader is
|
|
3893
|
+
used when a host loads it; Georgia is the dependable on-screen fallback
|
|
3894
|
+
so the demo stays self-contained. */
|
|
3895
|
+
[data-demo-theme="inkly"] .demo-builtwith-badge-text {
|
|
3896
|
+
font-family: "Newsreader", Georgia, "Times New Roman", serif;
|
|
3897
|
+
font-size: 12px;
|
|
3898
|
+
font-weight: 600;
|
|
3899
|
+
letter-spacing: 0.2px;
|
|
3900
|
+
/* Newsreader's ascent \u226B descent, so centering the full em box leaves
|
|
3901
|
+
the cap-block sitting high against the icon (measures ~1px high on
|
|
3902
|
+
the cap). Trim the line box to cap-height \u2192 baseline so align-items
|
|
3903
|
+
centers the actual letterforms, not the metric box with its empty
|
|
3904
|
+
descender padding. Browsers without text-box-trim (Firefox, older
|
|
3905
|
+
Chrome/Safari) fall back to the near-centered em-box behavior. */
|
|
3906
|
+
text-box-trim: trim-both;
|
|
3907
|
+
text-box-edge: cap alphabetic;
|
|
3908
|
+
}
|
|
3909
|
+
|
|
3910
|
+
/* Mobile \u2014 keep the watermark in its bottom-right spot instead of dropping
|
|
3911
|
+
it (overrides the base @container rule that sets display:none), but
|
|
3912
|
+
collapse the wordmark to just the brand word so the pill stays compact.
|
|
3913
|
+
"Built with Inkly" \u2192 "Inkly": the real text is zeroed and the brand word
|
|
3914
|
+
painted via ::after. The anchor's aria-label still carries the full
|
|
3915
|
+
"Built with Inkly" name, so the accessible label is unchanged. */
|
|
3916
|
+
@container demo-player (max-width: 640px) {
|
|
3917
|
+
[data-demo-theme="inkly"] .demo-builtwith-badge {
|
|
3918
|
+
display: inline-flex;
|
|
3919
|
+
}
|
|
3920
|
+
[data-demo-theme="inkly"] .demo-builtwith-badge-text {
|
|
3921
|
+
font-size: 0;
|
|
3922
|
+
letter-spacing: 0;
|
|
3923
|
+
/* The desktop cap-trim is computed from this span's font metrics,
|
|
3924
|
+
which collapse at font-size:0 \u2014 leaving the visible ::after word
|
|
3925
|
+
em-box centered (sits ~1px high). Reset here and re-apply the trim
|
|
3926
|
+
to the ::after that actually paints so it cap-centers like desktop. */
|
|
3927
|
+
text-box-trim: none;
|
|
3928
|
+
}
|
|
3929
|
+
[data-demo-theme="inkly"] .demo-builtwith-badge-text::after {
|
|
3930
|
+
content: "Inkly";
|
|
3931
|
+
font-size: 12px;
|
|
3932
|
+
letter-spacing: 0.2px;
|
|
3933
|
+
/* text-box-trim doesn't apply to ::after generated content, so the
|
|
3934
|
+
word stays em-box centered and sits ~1px high. Nudge it down to
|
|
3935
|
+
optically center against the logo. */
|
|
3936
|
+
position: relative;
|
|
3937
|
+
top: 1px;
|
|
3938
|
+
}
|
|
3813
3939
|
}
|
|
3814
3940
|
|
|
3815
3941
|
/* Embedded widget image \u2014 flat gradient card with lift. Replaces the
|
|
@@ -3848,11 +3974,11 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3848
3974
|
text-wrap: balance;
|
|
3849
3975
|
}
|
|
3850
3976
|
[data-demo-theme="inkly"] .demo-widget-title em {
|
|
3851
|
-
font-style:
|
|
3977
|
+
font-style: normal;
|
|
3852
3978
|
color: #2a3aaa;
|
|
3853
3979
|
}
|
|
3854
3980
|
[data-demo-theme="inkly"] .demo-widget-description {
|
|
3855
|
-
color: #
|
|
3981
|
+
color: #5f5f5f;
|
|
3856
3982
|
font-size: 15px;
|
|
3857
3983
|
line-height: 1.55;
|
|
3858
3984
|
max-width: 46ch;
|
|
@@ -3903,7 +4029,7 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
3903
4029
|
line-height: 1.45;
|
|
3904
4030
|
}
|
|
3905
4031
|
}
|
|
3906
|
-
`,
|
|
4032
|
+
`,Ea={id:"inkly",label:"Inkly",theme:$e.inkly,css:Hl};var Bl=`
|
|
3907
4033
|
.hub-index[data-theme="substack"] {
|
|
3908
4034
|
background: #ffffff;
|
|
3909
4035
|
color: #1a1a1a;
|
|
@@ -4834,154 +4960,134 @@ ${tt(n??"",{resourceOrigin:r}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
4834
4960
|
--demo-watermark-mark-radius: 3px;
|
|
4835
4961
|
font-family: var(--demo-font);
|
|
4836
4962
|
}
|
|
4837
|
-
`,
|
|
4838
|
-
.inkly/
|
|
4839
|
-
dist/
|
|
4840
|
-
demos/*/.inkly/
|
|
4841
|
-
`;function _l(t){return`# ${t}
|
|
4842
|
-
|
|
4843
|
-
An Inkly demo hub.
|
|
4844
|
-
|
|
4845
|
-
Each folder under \`demos/\` is one interactive demo. The hub itself
|
|
4846
|
-
is configured by \`inkly.json\` at the repo root \u2014 collections,
|
|
4847
|
-
branding, and the runtime pin all live there.
|
|
4848
|
-
|
|
4849
|
-
## Viewing your hub
|
|
4850
|
-
|
|
4851
|
-
The platform serves this repo at your hub URL \u2014 open the Inkly
|
|
4852
|
-
app to see the live version. Edits to demo files trigger a
|
|
4853
|
-
re-render automatically.
|
|
4854
|
-
|
|
4855
|
-
## Editing locally
|
|
4856
|
-
|
|
4857
|
-
\`\`\`bash
|
|
4858
|
-
npm i -g @inkly-org/cli
|
|
4859
|
-
inkly dev
|
|
4860
|
-
\`\`\`
|
|
4861
|
-
|
|
4862
|
-
\`inkly dev\` boots a local preview that reads straight from the
|
|
4863
|
-
files in this repo. See \`CLAUDE.md\` for the full schema +
|
|
4864
|
-
branching contract.
|
|
4865
|
-
|
|
4866
|
-
## What's in the box
|
|
4867
|
-
|
|
4868
|
-
- \`inkly.json\` \u2014 hub config (collections, optional branding, runtime pin).
|
|
4869
|
-
- Optional \`brand.logo\` / \`brand.favicon\` entries can point at
|
|
4870
|
-
repo-local \`public/...\` files or external \`https://\` URLs.
|
|
4871
|
-
- \`demos/getting-started/demo.config.json\` \u2014 the starter demo.
|
|
4872
|
-
- \`CLAUDE.md\` \u2014 AI-agent context, schema invariants, branching
|
|
4873
|
-
convention. Read this before letting agents commit.
|
|
4874
|
-
`}function Cl(t){return`# ${t} \u2014 Inkly demo hub
|
|
4875
|
-
|
|
4876
|
-
This directory is an Inkly demo **hub**. A hub contains many demos.
|
|
4877
|
-
Source of truth:
|
|
4878
|
-
|
|
4879
|
-
- \`inkly.json\` \u2014 hub config (collections, optional branding, runtime pin).
|
|
4880
|
-
- Branding is opt-in. Add \`brand.logo\` and/or \`brand.favicon\` only
|
|
4881
|
-
when the hub has real brand assets.
|
|
4882
|
-
- \`demos/<slug>/demo.config.json\` \u2014 one file per demo.
|
|
4883
|
-
|
|
4884
|
-
## Schema contracts
|
|
4885
|
-
|
|
4886
|
-
- \`inkly.json\` is validated by \`InklyJsonSchema\` from
|
|
4887
|
-
\`@inkly/demo-schema\`.
|
|
4888
|
-
- Each \`demo.config.json\` is validated by \`DemoSchema\`.
|
|
4889
|
-
- Every edit must keep **both** schemas green. The dev server and CI
|
|
4890
|
-
surface validation errors verbatim.
|
|
4891
|
-
|
|
4892
|
-
## Working with demos
|
|
4893
|
-
|
|
4894
|
-
- \`inkly demo <slug>\` \u2014 add a new demo under \`demos/<slug>/\`.
|
|
4895
|
-
- \`inkly dev\` \u2014 preview the entire hub locally.
|
|
4896
|
-
- Reserved slugs (cannot be demo folder names):
|
|
4897
|
-
\`__inkly\`, \`assets\`, \`api\`, \`c\`. Also: nothing starting with
|
|
4898
|
-
\`_\` or \`.\`.
|
|
4899
|
-
|
|
4900
|
-
## Branching convention
|
|
4901
|
-
|
|
4902
|
-
Agents commit to feature branches, never \`main\`. One logical task per
|
|
4903
|
-
branch. CI validates both schemas and blocks merge on failure.
|
|
4904
|
-
|
|
4905
|
-
## Useful commands
|
|
4906
|
-
|
|
4907
|
-
- \`inkly dev\` \u2014 local preview for the whole hub.
|
|
4908
|
-
- \`inkly demo <slug>\` \u2014 scaffold an additional demo.
|
|
4909
|
-
`}function xr(t){let{hubName:e,layout:n,theme:a}=t,r=vl(e,{layout:n,theme:a}),i=we.safeParse(r);if(!i.success)throw new Error(`hub-skeleton: starter inkly.json failed schema validation. ${i.error.message}`);let o=hn(Yn,wl),l=gt.safeParse(o);if(!l.success)throw new Error(`hub-skeleton: starter demo failed schema validation. ${l.error.message}`);return[{path:"README.md",contents:_l(e)},{path:"CLAUDE.md",contents:Cl(e)},{path:".gitignore",contents:Sl},{path:"inkly.json",contents:JSON.stringify(r,null,2)+`
|
|
4910
|
-
`},{path:`demos/${Yn}/demo.config.json`,contents:JSON.stringify(o,null,2)+`
|
|
4911
|
-
`}]}function vr(t){return wr==="/"?t:t.split("/").join(wr)}async function Sr(t){let{name:e,cwd:n,layout:a,theme:r,silent:i}=t,o=ve(e);if(!o.ok)throw new Error(o.reason);let l=a===void 0?void 0:Jn.safeParse(a);if(l&&!l.success)throw new Error("Invalid layout. Expected one of: sidebar, tabs.");if(r!==void 0){if(r.length===0)throw new Error("Invalid theme. Expected a theme preset id.");if(!se[r]){let h=Object.keys(se).join(", ");throw new Error(`Invalid theme "${r}". Expected one of: ${h}.`)}}let c=Rl(n,e);if(await Tl(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=xr({hubName:e,layout:l?.data,theme:r});return await kr(c,{recursive:!0}),await Promise.all(u.map(async h=>{let p=vr(h.path),g=Al(c,p);await kr(Pl(g),{recursive:!0}),await Il(g,h.contents,"utf8")})),i||process.stdout.write(`Scaffolded hub ${e} at ${c}
|
|
4963
|
+
`,Ra={id:"substack",label:"Substack",theme:$e.substack,css:Bl};var $a=[Ea,Ia,Pa,Ra],oe=Object.fromEntries($a.map(t=>[t.id,t]));import{createHash as td}from"crypto";import{mkdir as nd,readFile as er,rm as Mm,stat as Um}from"fs/promises";import{homedir as rd}from"os";import{join as De}from"path";import{fileURLToPath as ad}from"url";import{access as Wl,readFile as Vl,readdir as Zl,stat as Jl}from"fs/promises";import{dirname as Gl,join as vt,resolve as ql,sep as Kl}from"path";async function Z(t){return Wl(t).then(()=>!0,()=>!1)}async function ve(t){let e=ql(t);for(;;){if(await Z(vt(e,"inkly.json")))return e;let n=Gl(e);if(n===e)return null;e=n}}async function Kn(t){let e=vt(t,"demos");if(!await Z(e))return[];let n=[];async function r(a){let i;try{i=await Zl(a,{withFileTypes:!0})}catch{return}if(i.some(o=>o.isFile()&&o.name==="demo.config.json")){let o=a===e?"":a.slice(e.length+1).split(Kl).join("/");n.push({slug:o,dir:a,configPath:vt(a,"demo.config.json")});return}for(let o of i)o.isDirectory()&&await r(vt(a,o.name))}return await r(e),n.sort((a,i)=>a.slug.localeCompare(i.slug))}async function we(t){let e=await Vl(t,"utf8");return JSON.parse(e)}async function St(t){let e=await ve(t);if(!e)throw new Error(`No inkly.json found in ${t} or any parent directory.`);let n=vt(e,"inkly.json"),r=pe.safeParse(await we(n));if(!r.success)throw new Error(`inkly.json failed schema validation: ${r.error.message}`);let a=[];for(let i of await Kn(e)){let o;try{o=xt(await we(i.configPath)).config}catch(d){throw new Error(`demos/${i.slug}/demo.config.json failed schema validation: ${d.message}`)}let s=vt(i.dir,"assets.json"),c=null;if(await Z(s)){let d=yt.safeParse(await we(s));if(!d.success)throw new Error(`demos/${i.slug}/assets.json failed schema validation: ${d.error.message}`);c=d.data}a.push({slug:i.slug,dir:i.dir,configPath:i.configPath,config:o,assetsPath:s,assets:c})}return{root:e,inklyPath:n,inkly:r.data,demos:a}}function Yn(t){let e=t.split("/")[0]??t,n=ke(e);return n.ok?wt.includes(t)?`Demo folder "${t}" uses a reserved slug.`:null:n.reason}async function gn(t){try{let e=await Jl(t);return e.isFile()?e.size:null}catch{return null}}import{mkdir as Yl,rename as Xl,writeFile as Ql}from"fs/promises";import{dirname as ed}from"path";async function Q(t,e,n){await Yl(ed(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await Ql(r,e,n?.mode!=null?{mode:n.mode}:void 0),await Xl(r,t)}var id="https://www.runtime.inklyai.dev";function rt(){let t=process.env.BUNDLES_R2_PUBLIC_BASE_URL;return typeof t=="string"&&t.length>0?t.replace(/\/+$/,""):id}function tr(t,e,n=rt()){return`${n}/runtime/${t}/${e}`}function od(t){return De(rd(),".inkly","cache","runtime",t)}function sd(t){let e=/^(sha(?:256|384|512))-([A-Za-z0-9+/]+=*)$/.exec(t);return e?{algorithm:e[1],expected:e[2]}:null}function _t(t,e){let n=sd(e);return n?td(n.algorithm).update(t).digest("base64")===n.expected:!1}var Ct=class extends Error{constructor(n,r,a){super(`integrity mismatch for ${n}: expected ${r}`+(a?` (from ${a})`:"")+". The bundle does not match inkly.lock. Re-run `inkly lock` to refresh, or the CDN may have been tampered with.");this.file=n;this.expected=r;this.url=a;this.name="IntegrityMismatchError"}},nt=class extends Error{constructor(e){super(e),this.name="LockReadError"}};async function ld(t){let e=De(t,"inkly.lock");if(!await Z(e))throw new nt(`no inkly.lock found in ${t}. Run \`inkly lock\` to generate one.`);let n;try{n=await we(e)}catch(a){throw new nt(`failed to read ${e}: ${a.message}`)}let r=fn.safeParse(n);if(!r.success)throw new nt(`${e} failed InklyLockSchema validation: ${r.error.message}`);return r.data}function dd(t,e){let n=t.lastIndexOf("/");return n===-1?t:`${t.slice(0,n+1)}${e}`}async function Da(t){try{return await er(t)}catch{return null}}async function cd(t){let e=De(t,"manifest.json");if(!await Z(e))return null;try{let n=JSON.parse(await er(e,"utf8")),r=kt.safeParse(n);return r.success?r.data:null}catch{return null}}async function Xn(t,e){await Q(t,e)}async function Qn(t,e){if(t.startsWith("file://"))try{return await er(ad(t))}catch(a){throw new Error(`failed to read ${t}: ${a.message}`)}let n;try{n=await e(t)}catch(a){throw new Error(`failed to fetch ${t}: ${a.message}`)}if(!n.ok)throw new Error(`fetch ${t} returned HTTP ${n.status}`);let r=await n.arrayBuffer();return Buffer.from(r)}async function ja(t){let e=t.fetchImpl??fetch,n=await ld(t.hubRoot),{version:r,url:a,integrity:i}=n.runtime,o=od(r),s=await Da(De(o,"runtime.js")),c=await Da(De(o,"runtime.css")),d=await cd(o);if(s&&c&&d){let I=_t(s,i),k=d.version===r,P=_t(c,d.cssIntegrity);if(I&&k&&P)return{version:r,cacheDir:o,manifest:d,fetched:!1,bytesFetched:0,lock:n}}let u=I=>{let k=t.urlOverrides?.[I];return k||(I==="runtime.js"?a:dd(a,I))};await nd(o,{recursive:!0});let p=u("manifest.json"),h=await Qn(p,e),y;try{let I=JSON.parse(h.toString("utf8")),k=kt.safeParse(I);if(!k.success)throw new Error(`manifest from ${p} failed schema validation: ${k.error.message}`);y=k.data}catch(I){throw new Error(`manifest from ${p} is not valid JSON: ${I.message}`)}if(y.version!==r)throw new Error(`CDN manifest for ${p} reports version ${y.version} but inkly.lock pins ${r}. Re-run \`inkly lock\` to refresh.`);let x=u("runtime.js"),w=await Qn(x,e);if(!_t(w,i))throw new Ct("runtime.js",i,x);let _=u("runtime.css"),O=await Qn(_,e);if(!_t(O,y.cssIntegrity))throw new Ct("runtime.css",y.cssIntegrity,_);return await Xn(De(o,"runtime.js"),w),await Xn(De(o,"runtime.css"),O),await Xn(De(o,"manifest.json"),h),{version:r,cacheDir:o,manifest:y,fetched:!0,bytesFetched:w.byteLength+O.byteLength+h.byteLength,lock:n}}function bn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function bd(t=rt()){return`${t}/runtime/latest.json`}function La(t){return Na==="/"?t:t.split("/").join(Na)}function yd(t){let e=t??globalThis.fetch;if(typeof e!="function")throw new Error("This Node runtime does not provide fetch; Node 20+ is required.");return e}async function za(t,e){let n=await e(t);if(!n.ok)throw new Error(`failed to fetch ${t}: HTTP ${n.status}${n.statusText?` ${n.statusText}`:""}`);let r=ud.from(await n.arrayBuffer()),a;try{a=JSON.parse(r.toString("utf8"))}catch(i){throw new Error(`failed to parse JSON from ${t}: ${i.message}`)}return{json:a,bytes:r}}function xd(t,e){if(!bn(t))throw new Error(`${e} is not an object`);let n=t.version,r=t.hubSkeleton;if(typeof n!="string"||n.length===0)throw new Error(`${e} is missing version`);if(!bn(r))throw new Error(`${e} is missing hubSkeleton`);if(typeof r.url!="string"||r.url.length===0)throw new Error(`${e} is missing hubSkeleton.url`);if(typeof r.integrity!="string"||r.integrity.length===0)throw new Error(`${e} is missing hubSkeleton.integrity`);if(typeof r.version!="number")throw new Error(`${e} is missing hubSkeleton.version`);let a=typeof r.bytes=="number"?r.bytes:void 0;return{version:n,hubSkeleton:{version:r.version,url:r.url,integrity:r.integrity,bytes:a}}}function kd(t,e){if(!bn(t))throw new Error(`${e} is not an object`);if(t.version!==1)throw new Error(`${e} has unsupported skeleton version`);if(typeof t.runtime!="string"||t.runtime.length===0)throw new Error(`${e} is missing runtime`);if(!Array.isArray(t.files))throw new Error(`${e} is missing files`);let n=t.files.map((r,a)=>{if(!bn(r))throw new Error(`${e} files[${a}] is not an object`);if(typeof r.path!="string"||r.path.length===0)throw new Error(`${e} files[${a}].path is missing`);if(typeof r.contents!="string")throw new Error(`${e} files[${a}].contents is missing`);return{path:r.path,contents:r.contents}});return{version:1,runtime:t.runtime,files:n}}function wd(t,e,n){return t.split(e).join(n)}function vd(t){if(t.startsWith("/")||t.startsWith("\\")||/^[A-Za-z]:/.test(t)||t.includes("\\")||t.split("/").some(e=>e===".."||e.length===0))throw new Error(`Unsafe skeleton path from runtime manifest: ${t}`)}function Sd(t,e){let n=t.runtime,r=te(),a=[["{{hubName}}",e.hubName],["{{hubNameJson}}",JSON.stringify(e.hubName)],["{{runtimeVersionJson}}",JSON.stringify(n)],["{{layoutEntry}}",e.layout===void 0?"":` "layout": ${JSON.stringify(e.layout)},
|
|
4964
|
+
`],["{{themeJson}}",JSON.stringify(e.theme??"inkly")],["{{starterDemoIdJson}}",JSON.stringify(r)]],i=t.files.map(u=>{vd(u.path);let p=u.contents;for(let[h,y]of a)p=wd(p,h,y);if(/\{\{[A-Za-z][A-Za-z0-9]*\}\}/.test(p))throw new Error(`Unresolved placeholder in runtime skeleton file: ${u.path}`);return{path:u.path,contents:p}}),o=i.find(u=>u.path==="inkly.json");if(!o)throw new Error("Runtime skeleton is missing inkly.json");let s=pe.safeParse(JSON.parse(o.contents));if(!s.success)throw new Error(`Runtime skeleton inkly.json is invalid: ${s.error.message}`);let c=i.find(u=>u.path==="demos/getting-started/demo.config.json");if(!c)throw new Error("Runtime skeleton is missing demos/getting-started/demo.config.json");let d=et.safeParse(JSON.parse(c.contents));if(!d.success)throw new Error(`Runtime skeleton starter demo is invalid: ${d.error.message}`);return i}async function _d(t){let{latestUrl:e,fetchImpl:n}=t,r=await za(e,n),a=xd(r.json,e),i=new URL(a.hubSkeleton.url,e).toString(),o=await za(i,n);if(!_t(o.bytes,a.hubSkeleton.integrity))throw new Error(`integrity mismatch for hub-skeleton.json from ${i}`);if(typeof a.hubSkeleton.bytes=="number"&&o.bytes.byteLength!==a.hubSkeleton.bytes)throw new Error(`byte length mismatch for hub-skeleton.json from ${i}`);let s=kd(o.json,i);if(s.runtime!==a.version)throw new Error(`runtime/latest.json points at ${a.version}, but hub-skeleton.json declares ${s.runtime}`);return s}async function Ma(t){let{name:e,cwd:n,layout:r,theme:a,silent:i}=t,o=ke(e);if(!o.ok)throw new Error(o.reason);let s=r===void 0?void 0:Jn.safeParse(r);if(s&&!s.success)throw new Error("Invalid layout. Expected one of: sidebar, tabs.");if(a!==void 0){if(a.length===0)throw new Error("Invalid theme. Expected a theme preset id.");if(!oe[a]){let h=Object.keys(oe).join(", ");throw new Error(`Invalid theme "${a}". Expected one of: ${h}.`)}}let c=gd(n,e);if(await hd(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 _d({latestUrl:t.runtimeManifestUrl??bd(),fetchImpl:yd(t.fetchImpl)}),p=Sd(u,{hubName:e,layout:s?.data,theme:a});return await Oa(c,{recursive:!0}),await Promise.all(p.map(async h=>{let y=La(h.path),x=fd(c,y);await Oa(md(x),{recursive:!0}),await pd(x,h.contents,"utf8")})),i||process.stdout.write(`Scaffolded hub ${e} at ${c}
|
|
4912
4965
|
|
|
4913
4966
|
Next steps:
|
|
4914
4967
|
cd ${e}
|
|
4915
4968
|
inkly dev
|
|
4916
4969
|
open http://localhost:3000
|
|
4917
|
-
`),{dir:c,files:
|
|
4918
|
-
`)}
|
|
4919
|
-
${i}`),
|
|
4920
|
-
npm run build:runtime -w @inkly/
|
|
4970
|
+
`),{dir:c,files:p.map(h=>La(h.path))}}import{createServer as Ad}from"vite";import Id from"chokidar";import{readFile as he,readdir as Pd,stat as Wt}from"fs/promises";import{existsSync as At,createReadStream as Ed}from"fs";import{dirname as it,extname as Rd,join as B,relative as $d,resolve as at,sep as kn}from"path";import{fileURLToPath as Ga}from"url";import{createRequire as Dd}from"module";import{createConnection as jd,createServer as Od}from"net";import{readFile as Ua,stat as Cd}from"fs/promises";import{relative as Td}from"path";async function yn(t){let e=await ve(t);if(!e)throw new Error(`No inkly.json found in ${t} or any parent directory. Run \`inkly init <name>\` first or cd into your hub.`);let n=[],r=[],a=[],i=[];for(let s of await Kn(e)){let c;try{c=await Ua(s.configPath,"utf8")}catch(h){a.push({slug:s.slug,configPath:s.configPath,message:`failed to read demo.config.json (${h.message})`});continue}let d;try{d=JSON.parse(c)}catch(h){a.push({slug:s.slug,configPath:s.configPath,message:`demo.config.json is not valid JSON (${h.message})`});continue}let u;try{u=xt(d)}catch(h){a.push({slug:s.slug,configPath:s.configPath,message:`demo.config.json failed schema validation: ${h.message}`});continue}u.changed&&(await Fa(s.configPath,u.config),n.push({slug:s.slug,configPath:s.configPath,reason:"heal"}));let p=(await Cd(s.configPath)).mtimeMs;i.push({slug:s.slug,configPath:s.configPath,id:u.config.id,mtimeMs:p})}let o=_a(i.map(s=>({...s,updatedAt:s.mtimeMs})));for(let{entry:s,newId:c}of o){let d=await Ua(s.configPath,"utf8"),u=JSON.parse(d);u.id=c,await Fa(s.configPath,u),r.push({slug:s.slug,configPath:s.configPath,reason:"remint"})}return{hubRoot:e,healed:n,reminted:r,skipped:a}}function Ht(t,e){return Td(t,e).split(/[\\/]/).join("/")}async function Fa(t,e){await Q(t,JSON.stringify(e,null,2)+`
|
|
4971
|
+
`)}var Nd=Ga(import.meta.url),Tt=it(Nd),rr="127.0.0.1";function Ha(t){let e=at(Tt,"template",t);return At(e)?e:at(Tt,"..","..","template",t)}function Ld(t){let e=[at(Tt,"..","vendor",t),at(Tt,"..","..","vendor",t),at(Tt,"..","..","..","public","__inkly","vendor",t)];for(let n of e)if(At(n))return n;return null}function zd(t){try{let r=Dd(B(t,"package.json")).resolve("@inkly/runtime/package.json");return at(it(r),"dist")}catch{}let e=Tt;for(let n=0;n<8;n++){let r=B(e,"packages","inkly-runtime","dist");if(At(r))return r;let a=it(e);if(a===e)break;e=a}return null}function Ba(t,e){if(!e)return t;let{integrity:n}=e.lock.runtime,r=e.manifest.cssIntegrity,a=t;a=a.replace(/<link rel="stylesheet" href="\/__inkly\/runtime\.css" \/>/,`<link rel="stylesheet" href="/__inkly/runtime.css" integrity="${r}" crossorigin="anonymous" />`);let i=`<link rel="modulepreload" href="/__inkly/runtime.js" integrity="${n}" crossorigin="anonymous" />`;return/<link rel="prefetch" href="\/__inkly\/runtime\.js"[^>]*\/>/.test(a)?a=a.replace(/<link rel="prefetch" href="\/__inkly\/runtime\.js"[^>]*\/>/,i):a=a.replace(/<link rel="stylesheet" href="\/__inkly\/runtime\.css"[^>]*\/>/,o=>`${o}
|
|
4972
|
+
${i}`),a}function z(t,e,n,r){t.statusCode=e,t.setHeader("content-type",n),t.setHeader("cache-control","no-store"),t.end(r)}function Vt(t,e,n){t.statusCode=200,t.setHeader("content-type",n),t.setHeader("cache-control","no-store");let r=Ed(e);r.on("error",a=>{t.statusCode=500,t.end(`Failed to read ${e}: ${a.message}`)}),r.pipe(t)}var Wa=`Inkly runtime artifact not found. Run:
|
|
4973
|
+
npm run build:runtime -w @inkly/runtime
|
|
4921
4974
|
then restart \`inkly dev\`.
|
|
4922
|
-
`;function
|
|
4923
|
-
${i.error.message}`);let o=i.data,
|
|
4924
|
-
</head>`)}function
|
|
4925
|
-
`)},
|
|
4926
|
-
`);for(let
|
|
4927
|
-
`)}let c=await
|
|
4928
|
-
`)}else process.stdout.write(`[inkly dev] runtime ${
|
|
4929
|
-
`)}catch(
|
|
4930
|
-
`);return}
|
|
4931
|
-
`);return}}
|
|
4932
|
-
inkly dev running at ${
|
|
4975
|
+
`;function Md(t){let e=at(t);for(;;){if(At(B(e,"inkly.json")))return e;let n=it(e);if(n===e)return null;e=n}}function Va(t){if(!t)return null;let e=t.trim();return e?/^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i.test(e)||e.startsWith("/")?e:e.startsWith("public/")?`/${e.slice(7)}`:`/${e.replace(/^\.\/+/,"")}`:null}function ar(t){return t.brand?{...t,brand:{...t.brand,...t.brand.logo?{logo:Va(t.brand.logo)??t.brand.logo}:{},...t.brand.favicon?{favicon:Va(t.brand.favicon)??t.brand.favicon}:{}}}:t}function Ud(t){let e=new Map(t.assets.map(n=>[n.id,n]));return Ca({slug:t.slug,config:t.config,resolveAssetSrc:n=>n.startsWith("asset:")?e.get(n.slice(6))?.publicUrl??null:n})}async function Fd(t){let e=B(it(t),"assets.json");try{let n=await he(e,"utf8"),r=JSON.parse(n);return Array.isArray(r.assets)?r.assets.filter(a=>{if(!a||typeof a!="object")return!1;let i=a;return typeof i.id=="string"&&i.id.length>0}):[]}catch{return[]}}async function Hd(t){let e=B(t,"demos");if(!At(e))return[];let n=[];async function r(a){let i;try{i=await Pd(a,{withFileTypes:!0})}catch{return}if(i.some(s=>s.isFile()&&s.name==="demo.config.json")){let s=$d(e,a).split(kn).join("/");n.push({slug:s,configPath:B(a,"demo.config.json")});return}for(let s of i)s.isDirectory()&&await r(B(a,s.name))}return await r(e),n}async function Za(t,e){let n=B(t,"inkly.json"),r;try{r=await he(n,"utf8")}catch(p){throw new Error(`Failed to read inkly.json at ${n}: ${p.message}`)}let a;try{a=JSON.parse(r)}catch(p){throw new Error(`inkly.json is not valid JSON: ${p.message}`)}let i=pe.safeParse(a);if(!i.success)throw new Error(`inkly.json failed schema validation:
|
|
4976
|
+
${i.error.message}`);let o=i.data,s=await Hd(t);for(let p of s){let h=Zt(p.slug);if(!h.ok)throw new Error(`Demo folder "${p.slug}" has an invalid slug: ${h.reason}`);if(wt.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 he(p.configPath,"utf8")}catch(w){e(`Skipping ${p.slug}: failed to read demo.config.json (${w.message})`);continue}let y;try{y=JSON.parse(h)}catch(w){e(`Skipping ${p.slug}: demo.config.json is not valid JSON (${w.message})`);continue}let x;try{x=xt(y).config}catch(w){e(`Skipping ${p.slug}: demo.config.json failed schema validation: ${w.message}`);continue}c.push({slug:p.slug,configPath:p.configPath,config:x,assets:await Fd(p.configPath)})}let d=c.map(p=>Ud(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 xn(t,e,n){let r=JSON.stringify(n).replace(/<\/(script)/gi,"<\\/$1"),a=`<script id="${e}" type="application/json">${r}</script>`;return t.includes(`id="${e}"`)?t.replace(new RegExp(`<script id="${e}"[^>]*>[\\s\\S]*?</script>`),a):t.replace("</head>",`${a}
|
|
4977
|
+
</head>`)}function Bd(t){let e=t.hub.theme??"inkly",n=oe[e];return{hub:ar(t.hub),demos:t.index,theme:{id:e,tokens:n?.theme??null,css:n?.css??""}}}var Wd={".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 Bt(t){return Wd[Rd(t).toLowerCase()]??"application/octet-stream"}function Zt(t){let e=t.split("/").filter(Boolean);if(e.length===0)return{ok:!1,reason:"Name cannot be empty."};for(let n of e){let r=ke(n);if(!r.ok)return r}return wt.includes(t)?{ok:!1,reason:`Demo folder "${t}" uses a reserved slug.`}:{ok:!0}}function Ja(t,e){let n;try{n=decodeURIComponent(t)}catch{return null}let r=n.replace(/^\/+/,"").replace(/\/+$/,"");if(!r)return null;let a=r.split("/").filter(Boolean);for(let i=a.length;i>=1;i-=1){let o=a.slice(0,i).join("/");if(!Zt(o).ok)continue;let s=e.bySlug.get(o);if(s)return{slug:o,demo:s,rel:a.slice(i).join("/")}}return null}async function Vd(t){return new Promise(e=>{let n=Od();n.once("error",()=>e(!1)),n.once("listening",()=>{n.close(()=>e(!0))}),n.listen(t,rr)})}async function Zd(t,e){return new Promise(n=>{let r=!1,a=o=>{r||(r=!0,i.destroy(),n(o))},i=jd({port:t,host:e});i.setTimeout(250),i.once("connect",()=>a(!0)),i.once("timeout",()=>a(!1)),i.once("error",()=>a(!1))})}async function Jd(t){if(!await Vd(t))return!1;for(let e of["localhost","127.0.0.1","::1"])if(await Zd(t,e))return!1;return!0}async function Gd(t){if(t===0)return 0;if(!Number.isInteger(t)||t<0||t>65535)throw new Error(`invalid port: ${t}`);for(let e=t;e<=65535;e+=1)if(await Jd(e))return e;throw new Error(`No available port found at or above ${t}`)}function qd(t,e){let n=t.httpServer?.address();return n&&typeof n=="object"?n.port:t.config.server.port??e}async function qa(t){let{cwd:e,port:n=3e3,silent:r,skipRuntimeResolve:a}=t,i=Md(e);if(!i)throw new Error(`No inkly.json found in ${e} or any parent directory. Run \`inkly init <name>\` first or cd into your hub.`);let o=H=>{r||process.stderr.write(`[inkly dev] ${H}
|
|
4978
|
+
`)},s=await yn(i);if(!r){for(let H of s.healed)process.stdout.write(`[inkly dev] healed missing id: ${Ht(s.hubRoot,H.configPath)}
|
|
4979
|
+
`);for(let H of s.reminted)process.stdout.write(`[inkly dev] re-minted duplicate id: ${Ht(s.hubRoot,H.configPath)}
|
|
4980
|
+
`)}let c=await Za(i,o),d=B(i,"inkly.lock"),u=At(d),p=null;if(u&&!a)try{if(p=await ja({hubRoot:i}),!r)if(p.fetched){let H=(p.bytesFetched/1048576).toFixed(2);process.stdout.write(`[inkly dev] fetched runtime ${p.version} from ${p.lock.runtime.url} (${H} MiB)
|
|
4981
|
+
`)}else process.stdout.write(`[inkly dev] runtime ${p.version} loaded from cache (${p.cacheDir})
|
|
4982
|
+
`)}catch(H){throw H instanceof nt||H instanceof Ct?H:new Error(`Failed to resolve runtime via inkly.lock: ${H.message}`)}else a||r||process.stdout.write("[inkly dev] no inkly.lock \u2014 serving runtime from the in-workspace @inkly/runtime dist. Run `inkly lock` once a runtime is published to R2 to pin a version.\n");let h=p?.cacheDir??zd(i),y=Ba(await he(Ha("hub-index.html"),"utf8"),p),x=Ba(await he(Ha("demo.html"),"utf8"),p),w=await Gd(n),_=w,O=async()=>{},I=await Ad({root:i,server:{port:w,strictPort:!0,host:rr,hmr:{host:rr},fs:{allow:[i,Ga(new URL("../",import.meta.url))]}},appType:"custom",clearScreen:!1,logLevel:r?"silent":"info",configFile:!1,plugins:[{name:"inkly-dev-endpoints",configureServer(H){let dt=(en,T,Te)=>{let D=(en.url??"").split("?")[0]??"";if(D==="/"||D==="/index.html"){let $=xn(y,"__inkly_hub_data",Bd(c));z(T,200,"text/html; charset=utf-8",$);return}if(D.startsWith("/__inkly/cache/")){let $=decodeURIComponent(D.slice(15));if(!$||$.includes("..")||$.includes("/")){z(T,400,"text/plain; charset=utf-8","Invalid cache path");return}let U=B(i,".inkly","cache",$);Wt(U).then(L=>{if(!L.isFile()){z(T,404,"text/plain; charset=utf-8",`Capture not found: ${$}`);return}Vt(T,U,Bt(U))},()=>z(T,404,"text/plain; charset=utf-8",`Capture not found: ${$}`));return}if(D.startsWith("/__inkly/snapshot/")){let $=decodeURIComponent(D.slice(18)),L=$.indexOf("/snapshots/"),J=L>0?$.slice(0,L):"",K=L>0?$.slice(L+1):"";if(!Zt(J).ok||!c.bySlug.has(J)||!K||K.includes("..")||K.startsWith("/")){z(T,400,"text/plain; charset=utf-8","Invalid snapshot path");return}if(!K.startsWith("snapshots/")){z(T,400,"text/plain; charset=utf-8","Invalid snapshot path");return}let fe=B(i,"demos",...J.split("/")),le=B(fe,K);if(!le.startsWith(fe+kn)&&le!==fe){z(T,400,"text/plain; charset=utf-8","Invalid snapshot path");return}Wt(le).then(async Ot=>{if(!Ot.isFile()){z(T,404,"text/plain; charset=utf-8",`Snapshot not found: ${K}`);return}if(!/\.html?$/i.test(K)){let bo=await he(le,"utf8");z(T,200,Bt(le),tt(bo));return}let ee=qn(K),Nt=ee?B(fe,ee):null,[mo,fo]=await Promise.all([he(le,"utf8"),Nt?he(Nt,"utf8").catch(()=>null):Promise.resolve(null)]),go=Ta({htmlPath:K,html:mo,css:fo,cssHref:ee?`/__inkly/snapshot/${encodeURIComponent(J)}/${ee.split("/").map(encodeURIComponent).join("/")}`:null});z(T,200,Bt(le),go)},()=>z(T,404,"text/plain; charset=utf-8",`Snapshot not found: ${K}`));return}if(D==="/__inkly/hub"){z(T,200,"application/json; charset=utf-8",JSON.stringify(ar(c.hub)));return}if(D==="/__inkly/demos"){z(T,200,"application/json; charset=utf-8",JSON.stringify(c.index));return}if(D.startsWith("/__inkly/demo/")){let $=decodeURIComponent(D.slice(14)),U=Zt($);if(!U.ok){z(T,400,"text/plain; charset=utf-8",U.reason);return}let L=c.bySlug.get($);if(!L){z(T,404,"text/plain; charset=utf-8",`No such demo: ${$}`);return}let J=B(it(L.configPath),"assets.json");he(J,"utf8").then(K=>{let jt=[];try{let fe=JSON.parse(K);Array.isArray(fe.assets)&&(jt=fe.assets)}catch{}z(T,200,"application/json; charset=utf-8",JSON.stringify({demo:L.config,assets:jt}))},()=>{z(T,200,"application/json; charset=utf-8",JSON.stringify({demo:L.config,assets:[]}))});return}if(D==="/__inkly/runtime.js"){nr(T,h,"runtime.js","text/javascript; charset=utf-8");return}if(D==="/__inkly/runtime.css"){nr(T,h,"runtime.css","text/css; charset=utf-8");return}if(D==="/__inkly/manifest.json"){nr(T,h,"manifest.json","application/json; charset=utf-8");return}if(D.startsWith("/__inkly/vendor/")){let $=decodeURIComponent(D.slice(16));if(!/^(react|react-dom|react-dom-client|react-jsx-runtime)\.mjs$/.test($)){z(T,404,"text/plain; charset=utf-8",`No such vendor module: ${$}`);return}let U=Ld($);if(!U){z(T,503,"text/plain; charset=utf-8",`Runtime vendor module not found: ${$}`);return}Vt(T,U,"text/javascript; charset=utf-8");return}if(D.startsWith("/__inkly/theme/")&&D.endsWith(".css")){let $=decodeURIComponent(D.slice(15,-4)),U=oe[$];if(!U){let L=Object.keys(oe).join(", ");z(T,404,"text/plain; charset=utf-8",`No such theme: "${$}". Known themes: ${L}
|
|
4983
|
+
`);return}z(T,200,"text/css; charset=utf-8",U.css??"");return}let Ae=D.startsWith("/__inkly/")?null:Ja(D,c);if(Ae&&Ae.rel){let{slug:$,rel:U}=Ae;if(U.includes("..")||U.startsWith("/")){z(T,400,"text/plain; charset=utf-8","Invalid path");return}let L=B(i,"demos",...$.split("/"),"public"),J=B(L,U);if(!J.startsWith(L+kn)&&J!==L){z(T,400,"text/plain; charset=utf-8","Invalid path");return}Wt(J).then(K=>{if(!K.isFile()){Te();return}Vt(T,J,Bt(J))},()=>Te());return}if(D.length>1&&!D.startsWith("/__inkly/")&&!D.endsWith("/")){let $=decodeURIComponent(D.slice(1)),U=B(i,"public"),L=B(U,$);if(!$.includes("..")&&(L.startsWith(U+kn)||L===U)){Wt(L).then(J=>{if(J.isFile()){Vt(T,L,Bt(L));return}N()},()=>N());return}}N();function N(){if(D.length>1&&!D.startsWith("/__inkly/")){let $=D.replace(/^\/+/,"").replace(/\/+$/,""),U=Ja(D,c);if(U&&U.rel===""){let{slug:L,demo:J}=U;if(!Zt(L).ok){Te();return}let jt={hub:{name:c.hub.name,brand:ar(c.hub).brand??null,tokens:c.hub.tokens??null,theme:c.hub.theme??null,layout:c.hub.layout??null},demoSlug:L,demoTitle:J.config.title??J.config.id},fe=B(it(J.configPath),"assets.json"),le=Ot=>{let ee=xn(x,"__inkly_hub_meta",jt);ee=xn(ee,"__inkly_demo_config",J.config),ee=xn(ee,"__inkly_demo_assets",Ot),z(T,200,"text/html; charset=utf-8",ee)};he(fe,"utf8").then(Ot=>{let ee=[];try{let Nt=JSON.parse(Ot);Array.isArray(Nt.assets)&&(ee=Nt.assets)}catch{}le(ee)},()=>{le([])});return}if($&&!$.includes("/")){if(!ke($).ok){Te();return}z(T,404,"text/plain; charset=utf-8",`No such demo: "${$}". Known demos: ${[...c.bySlug.keys()].join(", ")||"(none)"}
|
|
4984
|
+
`);return}}Te()}};H.middlewares.use(dt)}}]});await I.listen(),_=qd(I,w);let k=`http://127.0.0.1:${_}/`,P=`http://localhost:${_}/`,R=Id.watch([B(i,"inkly.json"),B(i,"demos/**/demo.config.json"),B(i,"demos/**/assets.json")],{ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:60,pollInterval:20}}),M=!1,j=async()=>{if(!M){M=!0;try{c=await Za(i,o);try{I.ws.send({type:"custom",event:"inkly:hub-changed"}),I.ws.send({type:"full-reload"})}catch{}}catch(H){o(`Reload failed: ${H.message}`)}finally{M=!1}}};if(O=j,R.on("add",j),R.on("change",j),R.on("unlink",j),!r){let H=c.hub.collections?.length??0;process.stdout.write(`
|
|
4985
|
+
inkly dev running at ${P}
|
|
4933
4986
|
hub: ${c.hub.name}
|
|
4934
|
-
demos: ${c.demos.length} in ${
|
|
4987
|
+
demos: ${c.demos.length} in ${H} collection(s)
|
|
4935
4988
|
watching ${i}
|
|
4936
4989
|
|
|
4937
|
-
`)}let
|
|
4938
|
-
`),
|
|
4939
|
-
`),!
|
|
4940
|
-
`;
|
|
4941
|
-
`,
|
|
4942
|
-
`),
|
|
4943
|
-
`,process.stdout.write(
|
|
4944
|
-
`);else if(i.ok)process.stdout.write(`inkly validate passed (${
|
|
4990
|
+
`)}let V=!1;return{url:k,port:_,server:I,hubRoot:i,close:async()=>{V||(V=!0,await R.close(),await I.close())}}}function nr(t,e,n,r){if(!e){z(t,503,"text/plain; charset=utf-8",Wa);return}let a=B(e,n);Wt(a).then(()=>Vt(t,a,r),()=>z(t,503,"text/plain; charset=utf-8",`${Wa}(missing: ${n})`))}import{mkdir as Kd,access as Ya,readFile as Yd}from"fs/promises";import{dirname as Xd,join as wn,resolve as Qd}from"path";function ir(t){return t.split("-").filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Ka(t,e){return{id:te(),version:1,title:e??ir(t),theme:{background:"#ffffff",foreground:"#0a0a0a",primary:"#5b6cff",primaryForeground:"#ffffff",secondary:"#f4f4f5",secondaryForeground:"#18181b",radius:"12px",font:"Inter, system-ui, sans-serif",fontSize:"14px"},chrome:{showHubBreadcrumb:!0},chapters:[{id:"create",title:"Create",stepIds:["s1"]},{id:"preview",title:"Preview",stepIds:["s2"]},{id:"ship",title:"Ship",stepIds:["s3"]}],steps:[{id:"intro",kind:"cover",widgets:[{type:"headline",id:"intro-headline",title:"Your demo in *60 seconds*.",description:"See how to spin up a sharable demo from a single prompt.",image:{src:"https://placehold.co/2800x1600/f8fafc/111827/png?text=Workspace&font=inter",alt:"Workspace preview",naturalWidth:2800,naturalHeight:1600,position:"right",layout:"hero"},cta:{label:"Get started",animation:"shimmer",action:{type:"next"}}}]},{id:"s1",kind:"content",background:{type:"image",src:"https://placehold.co/2800x1600/f8fafc/111827/png?text=Workspace&font=inter",naturalWidth:2800,naturalHeight:1600,alt:"Workspace overview"},annotations:[{id:"s1_pointer",type:"message",variant:"pointer",x:.28,y:.34,text:"Just **describe** the flow you want \u2014 the demo scaffolds the walkthrough in seconds.",anchor:"right",advancesStep:!0}]},{id:"s2",kind:"content",background:{type:"image",src:"https://placehold.co/2800x1600/ecfeff/111827/png?text=Live+Preview&font=inter",naturalWidth:2800,naturalHeight:1600,alt:"Live preview with editable files"},transform:{zoom:1.25,x:.62,y:.42},captions:[{id:"s2_caption",text:"See your changes come to life with our live preview."}],annotations:[{id:"s2_callout",type:"message",variant:"callout",x:.5,y:.5,text:"**Live preview that follows you.** Every edit lands in the preview *instantly* \u2014 tweak copy, swap assets, reorder steps, and watch the demo update **without a rebuild**.",advancesStep:!0}]},{id:"s3",kind:"content",background:{type:"image",src:"https://placehold.co/2800x1600/f0fdf4/111827/png?text=Export+and+Share&font=inter",naturalWidth:2800,naturalHeight:1600,alt:"Export and share demo"},captions:[{id:"s3_caption",text:"When you are ready, export your demo and share it with anyone."}],annotations:[{id:"s3_area",type:"message",variant:"area",x:.55,y:.45,w:.32,h:.22,text:"**Ready to share.** Export your demo as a **single sharable link** that runs anywhere \u2014 drop it in an email, embed it on your landing page, or paste it in Slack. Works in *any* browser, no install needed.",anchor:"top",advancesStep:!0}]}]}}async function ec(t){let e=Qd(t);for(;;){let n=wn(e,"inkly.json");if(await Ya(n).then(()=>!0,()=>!1))return e;let a=Xd(e);if(a===e)return null;e=a}}async function Xa(t){let{slug:e,cwd:n,collection:r,silent:a}=t,i=await ec(n);if(!i)throw new Error("Not inside a hub. Run `inkly init <name>` first.");let o=ke(e);if(!o.ok)throw new Error(o.reason);let s=wn(i,"inkly.json"),c=await Yd(s,"utf8"),d;try{d=JSON.parse(c)}catch(P){throw new Error(`Failed to parse inkly.json: ${P.message}`)}let u=pe.safeParse(d);if(!u.success)throw new Error(`Invalid inkly.json: ${u.error.issues.map(P=>`${P.path.join(".")||"<root>"}: ${P.message}`).join("; ")}`);let p=u.data,h=wn(i,"demos",e);if(await Ya(h).then(()=>!0,()=>!1))throw new Error(`Demo already exists: demos/${e}. Choose a different slug or remove it first.`);let x,w=p,_=p.collections??[];if(r){let P={...p,collections:_.map(M=>({...M,demos:[...M.demos]}))},R=P.collections.find(M=>M.name===r);R?R.demos.push(e):P.collections.push({name:r,demos:[e]}),w=P,x=r}if(x){let P=pe.safeParse(w);if(!P.success)throw new Error(`Internal error: updated inkly.json failed schema validation. ${P.error.message}`)}let O=te(),I={...Ka(e,ir(e)),id:O},k=et.safeParse(I);if(!k.success)throw new Error(`Internal error: scaffolded demo failed schema validation. ${k.error.message}`);if(await Kd(h,{recursive:!0}),await Q(wn(h,"demo.config.json"),JSON.stringify(I,null,2)+`
|
|
4991
|
+
`),x&&await Q(s,JSON.stringify(w,null,2)+`
|
|
4992
|
+
`),!a){let P=`Added ${h}
|
|
4993
|
+
`;P+=` id: ${O}
|
|
4994
|
+
`,x&&(P+=`Added to collection "${x}" in inkly.json
|
|
4995
|
+
`),P+=`Next: inkly dev
|
|
4996
|
+
`,process.stdout.write(P)}return{hubRoot:i,demoDir:h,collectionModified:x,id:O}}import{readdir as tc}from"fs/promises";import{join as nc}from"path";function Se(t,e,n,r){t.push({level:e,file:n,message:r})}function or(t,e){if(typeof t=="string"){t.startsWith("asset:")&&e.add(t.slice(6));return}if(!(!t||typeof t!="object")){if(Array.isArray(t)){for(let n of t)or(n,e);return}for(let n of Object.values(t))or(n,e)}}async function vn(t){let e=[],n=null;try{let o=await St(t.cwd);n=o.root,o.inkly.theme&&!oe[o.inkly.theme]&&Se(e,"error","inkly.json",`Unknown theme "${o.inkly.theme}". Known themes: ${Object.keys(oe).join(", ")}.`);let s=new Set(o.demos.map(d=>d.slug)),c=new Map;for(let d of o.demos){let u=Yn(d.slug);u&&Se(e,"error",`demos/${d.slug}`,u);let p=c.get(d.config.id);p?p.push(d.slug):c.set(d.config.id,[d.slug]),d.config.theme?.preset&&!oe[d.config.theme.preset]&&Se(e,"error",`demos/${d.slug}/demo.config.json`,`Unknown demo theme preset "${d.config.theme.preset}".`);let h=new Set;or(d.config,h);let y=new Set((d.assets?.assets??[]).map(x=>x.id));for(let x of h)y.has(x)||Se(e,"error",`demos/${d.slug}/demo.config.json`,`References asset:${x}, but demos/${d.slug}/assets.json has no matching asset id.`);for(let x of d.assets?.assets??[])(await rc(o.root,x.sha256)).length===0&&!ac(x)&&Se(e,"warning",`demos/${d.slug}/assets.json`,`Asset "${x.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)Se(e,"warning",`demos/${p}/demo.config.json`,`Duplicate demo id "${d}" shared with ${u.filter(h=>h!==p).map(h=>`demos/${h}`).join(", ")}. Run \`inkly doctor\` to re-mint.`);for(let d of o.inkly.collections??[])for(let u of d.demos){let p=Yn(u);if(p){Se(e,"error","inkly.json",`Collection "${d.name}" references invalid slug "${u}": ${p}`);continue}s.has(u)||Se(e,"warning","inkly.json",`Collection "${d.name}" references missing demo "${u}".`)}}catch(o){Se(e,"error","hub",o.message)}let r=e.filter(o=>o.level==="error").length,a=e.filter(o=>o.level==="warning").length,i={ok:r===0&&(!t.strict||a===0),hubRoot:n,errors:r,warnings:a,issues:e};if(!t.silent)if(t.json)process.stdout.write(JSON.stringify(i,null,2)+`
|
|
4997
|
+
`);else if(i.ok)process.stdout.write(`inkly validate passed (${r} errors, ${a} warnings)
|
|
4945
4998
|
`);else{for(let o of e)process.stdout.write(`${o.level.toUpperCase()} ${o.file}: ${o.message}
|
|
4946
|
-
`);process.stdout.write(`inkly validate failed (${
|
|
4947
|
-
`)}return i}async function
|
|
4948
|
-
`)
|
|
4949
|
-
`);return}await new Promise((a
|
|
4950
|
-
`,{mode:384})}async function
|
|
4999
|
+
`);process.stdout.write(`inkly validate failed (${r} errors, ${a} warnings)
|
|
5000
|
+
`)}return i}async function rc(t,e){let n=nc(t,".inkly","cache");if(!await Z(n))return[];try{return(await tc(n)).filter(a=>a.startsWith(`${e}.`))}catch{return[]}}function ac(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.publicUrl=="string"||typeof e.cdnPath=="string"}import{readFile as ic}from"fs/promises";import{existsSync as oc}from"fs";import{dirname as sr,join as Qa}from"path";import{fileURLToPath as sc}from"url";async function lr(){let t=sr(sc(import.meta.url));for(let e=0;e<5;e+=1){let n=Qa(t,"package.json");try{let a=JSON.parse(await ic(n,"utf8"));if(typeof a.version=="string"){let i=oc(Qa(sr(n),"src"));return{version:a.version,packagePath:n,isLocalBuild:i}}}catch{}let r=sr(t);if(r===t)break;t=r}return{version:"0.0.0-unknown",packagePath:null,isLocalBuild:!1}}async function dr(t={}){let e=await lr();if(!t.silent){let n=e.isLocalBuild?" (local build)":"";process.stdout.write(`${e.version}${n}
|
|
5001
|
+
`)}return e}import{spawn as lc}from"child_process";async function ei(t={}){let e=t.packageName??"@inkly-org/cli@latest",n=process.env.npm_execpath?[process.execPath,process.env.npm_execpath,"install","-g",e]:["npm","install","-g",e];if(t.dryRun){t.silent||process.stdout.write(`${n.join(" ")}
|
|
5002
|
+
`);return}await new Promise((r,a)=>{let i=lc(n[0],n.slice(1),{stdio:"inherit"});i.on("error",a),i.on("exit",o=>{o===0?r():a(new Error(`Update failed with exit code ${o??"unknown"}`))})})}import{join as ri}from"path";import{readFile as dc,rm as cc}from"fs/promises";import{join as uc}from"path";import{homedir as pc}from"os";var cr="https://app.inklyai.dev",ti="http://localhost:3000",_e=uc(pc(),".inkly","config.json");async function je(){try{let t=await dc(_e,"utf8"),e=JSON.parse(t);return{apiBase:typeof e.apiBase=="string"?e.apiBase:void 0,token:typeof e.token=="string"?e.token:void 0}}catch{return{}}}async function ur(t){await Q(_e,JSON.stringify(t,null,2)+`
|
|
5003
|
+
`,{mode:384})}async function ni(){await cc(_e,{force:!0})}function Oe(t){return(t||cr).replace(/\/+$/,"")}async function ai(t){let e=[],n=await lr();e.push({name:"cli-version",ok:n.version!=="0.0.0-unknown",message:n.version});let r=Number.parseInt(process.versions.node.split(".")[0]??"0",10);e.push({name:"node",ok:r>=20,message:process.version});let a=await ve(t.cwd);e.push({name:"hub-root",ok:!!a,message:a??"No inkly.json found."});let i=await je();e.push({name:"login",ok:!!i.token,message:i.token?`Configured for ${i.apiBase??"(default API)"}`:"Not logged in."});let o=[],s=null;if(a){let d=await yn(a);s={healed:d.healed.length,reminted:d.reminted.length,paths:[...d.healed,...d.reminted].map(y=>Ht(d.hubRoot,y.configPath))},e.push({name:"demo-ids",ok:!0,message:s.healed===0&&s.reminted===0?"all demos have a valid unique id":`healed ${s.healed}, re-minted ${s.reminted}`});let u=await vn({cwd:a,silent:!0});o=u.issues,e.push({name:"schema",ok:u.ok,message:`${u.errors} errors, ${u.warnings} warnings`});let p=await Z(ri(a,".inkly","cache"));e.push({name:"local-cache",ok:!0,message:p?".inkly/cache exists":".inkly/cache not present yet"});let h=await gn(ri(a,"node_modules","@inkly","runtime","dist","runtime.js"));h!==null&&e.push({name:"runtime-artifact",ok:!0,message:`${h} bytes`})}let c={ok:e.every(d=>d.ok||d.name==="login"),checks:e,validationIssues:o,demoIds:s};if(!t.silent)if(t.json)process.stdout.write(JSON.stringify(c,null,2)+`
|
|
4951
5004
|
`);else{for(let d of e)process.stdout.write(`${d.ok?"OK":"WARN"} ${d.name}: ${d.message}
|
|
4952
|
-
`);if(
|
|
5005
|
+
`);if(s&&s.paths.length>0)for(let d of s.paths)process.stdout.write(` fixed id in ${d}
|
|
4953
5006
|
`);if(o.length>0)for(let d of o)process.stdout.write(`${d.level.toUpperCase()} ${d.file}: ${d.message}
|
|
4954
|
-
`)}return c}import{randomBytes as
|
|
4955
|
-
`,{encoding:"utf8",mode:384})}async function
|
|
4956
|
-
`),{apiBase:e,configPath:
|
|
4957
|
-
`),{apiBase:
|
|
4958
|
-
`)}async function
|
|
4959
|
-
`):(process.stdout.write(`Config: ${
|
|
4960
|
-
`),process.stdout.write(`Hub: ${
|
|
5007
|
+
`)}return c}import{randomBytes as Tc}from"crypto";import{createServer as Ac}from"http";import{spawn as Ic}from"child_process";import{randomUUID as hc}from"crypto";import{mkdir as mc,readFile as fc,writeFile as gc}from"fs/promises";import{dirname as bc,join as yc}from"path";import{homedir as xc}from"os";import{PostHog as kc}from"posthog-node";var ii=process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN??process.env.POSTHOG_PROJECT_TOKEN??"phc_Dmh4w8YFNosi3YHD4Sv7ShHX7ccS8kmtRcm8XSVmB5jT",wc=process.env.NEXT_PUBLIC_POSTHOG_HOST??process.env.POSTHOG_HOST??"https://us.i.posthog.com",vc="@inkly-org/cli@0.5.1",pr=yc(xc(),".inkly","analytics.json"),_n=null,Sn=null,It=null;function Sc(){return!!ii&&process.env.INKLY_TELEMETRY_DISABLED!=="1"}function oi(){return Sc()?(_n??=new kc(ii,{host:wc,flushAt:1,flushInterval:0}),_n):null}async function hr(){try{let t=await fc(pr,"utf8");return JSON.parse(t)}catch{return{}}}async function mr(t){await mc(bc(pr),{recursive:!0}),await gc(pr,JSON.stringify(t,null,2)+`
|
|
5008
|
+
`,{encoding:"utf8",mode:384})}async function si(){return Sn||(Sn=(async()=>{let t=await hr();if(typeof t.platformUserId=="string"&&t.platformUserId&&(It=t.platformUserId),typeof t.distinctId=="string"&&t.distinctId)return t.distinctId;let e=`cli_${hc()}`;return await mr({...t,distinctId:e}),e})(),Sn)}async function _c(){let t=await si();return It??t}async function fr(t){if(!t||It===t){t&&(It=t);return}let e=oi();try{let n=await si(),r=await hr(),a=r.platformUserId!==t;It=t,a&&(await mr({...r,platformUserId:t}),e?.alias({distinctId:t,alias:n}))}catch{}}async function li(){It=null;try{let t=await hr();if(t.platformUserId){let{platformUserId:e,...n}=t;await mr(n)}}catch{}}function Cc(){return{surface:"cli",release:process.env.POSTHOG_RELEASE??vc,node_version:process.versions.node,platform:process.platform,arch:process.arch,ci:!!process.env.CI}}async function F(t,e={}){let n=oi();if(n)try{n.capture({distinctId:await _c(),event:t,properties:{...Cc(),...e}})}catch{}}async function gr(){if(_n)try{await _n.shutdown(2e3)}catch{}}async function ci(t){let e=Oe(t.local?ti:cr),n=t.token??process.env.INKLY_API_TOKEN;if(n){let i=await yr(e,n).catch(()=>({valid:!1,userId:null}));return await ur({apiBase:e,token:n}),await di("token",i),t.silent||process.stdout.write(`Logged in to ${e}${i.valid?"":" (token saved without online verification)"}
|
|
5009
|
+
`),{apiBase:e,configPath:_e,verified:i.valid,method:"token"}}let r=await Pc({apiBase:e,shouldOpen:t.open!==!1,silent:t.silent});await ur({apiBase:r.apiBase,token:r.apiToken});let a=await yr(r.apiBase,r.apiToken).catch(()=>({valid:!1,userId:null}));return await di("browser",a),t.silent||process.stdout.write(`Logged in to ${r.apiBase}
|
|
5010
|
+
`),{apiBase:r.apiBase,configPath:_e,verified:a.valid,method:"browser"}}async function di(t,e){e.valid&&e.userId&&await fr(e.userId),await F("inkly_cli_logged_in",{method:t,verified:e.valid})}async function ui(t={}){await F("inkly_cli_logged_out",{}),await li(),await ni(),t.silent||process.stdout.write(`Removed ${_e}
|
|
5011
|
+
`)}async function pi(t){let e=await je(),n=e.apiBase?Oe(e.apiBase):null,r=await ve(t.cwd),a="skipped",i;if(n&&e.token)try{let s=await yr(n,e.token);a=s.valid?"ok":"failed",a==="failed"&&(i="Token was rejected by the platform."),s.valid&&s.userId&&await fr(s.userId)}catch(s){a="failed",i=s.message}let o={configPath:_e,apiBase:n,loggedIn:!!e.token,hubRoot:r,online:a,message:i};return t.silent||(t.json?process.stdout.write(JSON.stringify(o,null,2)+`
|
|
5012
|
+
`):(process.stdout.write(`Config: ${_e}
|
|
5013
|
+
`),process.stdout.write(`Hub: ${r??"(not inside a hub)"}
|
|
4961
5014
|
`),process.stdout.write(`API: ${n??"(not configured)"}
|
|
4962
5015
|
`),process.stdout.write(`Login: ${o.loggedIn?"configured":"not configured"}
|
|
4963
|
-
`),process.stdout.write(`Online: ${
|
|
4964
|
-
`))),o}async function
|
|
4965
|
-
${
|
|
4966
|
-
`),t.shouldOpen&&
|
|
4967
|
-
`),await
|
|
5016
|
+
`),process.stdout.write(`Online: ${a}${i?` (${i})`:""}
|
|
5017
|
+
`))),o}async function yr(t,e){let n=await fetch(`${t}/api/captures/verify`,{method:"GET",headers:{authorization:`Bearer ${e}`}});if(!n.ok)return{valid:!1,userId:null};let r=null;try{let a=await n.json();typeof a.userId=="string"&&a.userId&&(r=a.userId)}catch{}return{valid:!0,userId:r}}async function Pc(t){let e=Tc(16).toString("hex"),n=Ac(),r=await Ec(n),a=new URL("/cli/login",t.apiBase);a.searchParams.set("callback",r.url),a.searchParams.set("state",e);let i=Rc({server:n,state:e,apiBase:t.apiBase,timeoutMs:120*1e3});return t.silent||process.stdout.write(`Opening browser for Inkly login:
|
|
5018
|
+
${a.toString()}
|
|
5019
|
+
`),t.shouldOpen&&Dc(a.toString()),i}async function Ec(t){await new Promise((n,r)=>{t.once("error",r),t.listen(0,"127.0.0.1",()=>n())});let e=t.address();if(!e||typeof e=="string")throw new Error("Could not start local login callback server.");return{url:`http://127.0.0.1:${e.port}/callback`}}async function Rc(t){return new Promise((e,n)=>{let r=setTimeout(()=>{br(t.server),n(new Error("Timed out waiting for browser login."))},t.timeoutMs);t.server.on("request",(a,i)=>{(async()=>{try{let o=new URL(a.url??"/","http://127.0.0.1");if(o.pathname!=="/callback"){Cn(i,404,"Not found.");return}let s=o.searchParams.get("state"),c=o.searchParams.get("pairingToken");if(!c||s!==t.state){Cn(i,400,"Invalid Inkly CLI login callback. You can close this tab.");return}let d=await $c(t.apiBase,c);clearTimeout(r),Cn(i,200,"Inkly CLI is connected. You can close this tab."),br(t.server),e(d)}catch(o){clearTimeout(r),Cn(i,500,`Inkly CLI login failed: ${o.message}`),br(t.server),n(o)}})()})})}async function $c(t,e){let n=await fetch(`${t}/api/cli/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pairingToken:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r?.apiToken)throw new Error(r?.error??`Login exchange failed: HTTP ${n.status}`);return{apiToken:r.apiToken,apiBase:Oe(r.apiBase??t)}}function Dc(t){let e=process.platform,a=Ic(e==="darwin"?"open":e==="win32"?"cmd":"xdg-open",e==="win32"?["/c","start","",t]:[t],{stdio:"ignore",detached:!0});a.on("error",()=>{}),a.unref()}function Cn(t,e,n){t.statusCode=e,t.setHeader("content-type","text/html; charset=utf-8"),t.end(`<!doctype html><meta charset="utf-8"><title>Inkly CLI</title><body style="font-family: system-ui, sans-serif; padding: 32px;">${jc(n)}</body>`)}function br(t){try{t.close()}catch{}}function jc(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}import{readFile as fi,readdir as gi,writeFile as Oc}from"fs/promises";import{join as Jt,extname as bi}from"path";async function An(t){let e=await je(),n=await St(t.cwd),r=t.demo?n.demos.filter(p=>p.slug===t.demo):n.demos;if(t.demo&&r.length===0)throw new Error(`No such demo: ${t.demo}`);let a=[],i=[];for(let p of r)for(let h of p.assets?.assets??[]){let y=await zc(n.root,h.sha256),x=Mc(h);if(!y&&!x){i.push({demo:p.slug,id:h.id,sha256:h.sha256});continue}if(!y||x)continue;let w=await gn(Jt(n.root,".inkly","cache",y));a.push({demo:p.slug,id:h.id,sha256:h.sha256,cacheFile:y,contentType:h.contentType??Tn(y,h.kind),size:h.size??w??0,alreadyRemote:x})}let o={hubRoot:n.root,dryRun:!!t.dryRun,assets:a,unresolved:i,uploaded:0,updatedManifests:[]};if(t.dryRun||a.length===0)return t.silent||hi(o,t.json),o;if(!e.token)throw new Error("Not logged in. Run `inkly login --token <token>` first.");let s=Oe(e.apiBase??process.env.INKLY_API_BASE),c=await xr({apiBase:s,token:e.token,hubRoot:n.root,assets:a}),d=c.uploads,u=new Map(d.map(p=>[p.sha256,p]));for(let p of r){if(!p.assets)continue;let h=!1,y=p.assets.assets.map(w=>{let _=u.get(w.sha256);return _?(h=!0,{...w,contentType:w.contentType??Tn(`${w.sha256}${_.ext}`,w.kind),publicUrl:_.publicUrl,cdnPath:_.cdnPath}):w});if(!h)continue;let x={...p.assets,assets:y};await Q(p.assetsPath,JSON.stringify(x,null,2)+`
|
|
5020
|
+
`),await Uc(p.dir,d),o.updatedManifests.push(`demos/${p.slug}/assets.json`)}return o.uploaded=c.uploaded,t.silent||hi(o,t.json),o}async function xr(t){let e=await Lc(t.apiBase,t.token,t.assets),n=new Map(e.uploads.map(i=>[i.sha256,i])),r=0;for(let i of t.assets){let o=n.get(i.sha256);if(!o)throw new Error(`Platform did not return upload metadata for ${i.sha256}.`);if(o.uploadUrl){let s=await fi(Jt(t.hubRoot,".inkly","cache",i.cacheFile)),c=await fetch(o.uploadUrl,{method:"PUT",headers:o.uploadHeaders??{"content-type":i.contentType},body:s});if(!c.ok)throw new Error(`Asset upload failed for ${i.id}: HTTP ${c.status}`);r+=1}}return{uploads:(await Nc(t.apiBase,t.token,t.assets,e.uploads)).uploads,uploaded:r}}async function Nc(t,e,n,r){let a=new Map(r.map(s=>[s.sha256,s])),i=await fetch(`${t}/api/cli/sync-assets/complete`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({assets:n.map(s=>{let c=a.get(s.sha256);if(!c)throw new Error(`Platform did not return upload metadata for ${s.sha256}.`);return{sha256:s.sha256,ext:c.ext,contentType:s.contentType,size:s.size,cdnPath:c.cdnPath}})})}),o=await i.json().catch(()=>null);if(!i.ok||!o||!Array.isArray(o.uploads))throw new Error(o?.error??`Sync completion failed: HTTP ${i.status}`);return{uploads:o.uploads}}async function Lc(t,e,n){let r=await fetch(`${t}/api/cli/sync-assets`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({assets:n.map(i=>({sha256:i.sha256,ext:bi(i.cacheFile)||kr(i.contentType),contentType:i.contentType,size:i.size}))})}),a=await r.json().catch(()=>null);if(!r.ok||!a||!Array.isArray(a.uploads))throw new Error(a?.error??`Sync endpoint failed: HTTP ${r.status}`);return{uploads:a.uploads}}async function zc(t,e){let n=Jt(t,".inkly","cache");return await Z(n)?(await gi(n)).find(a=>a.startsWith(`${e}.`))??null:null}function Mc(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.publicUrl=="string"&&typeof e.cdnPath=="string"}function Tn(t,e){let n=bi(t).toLowerCase();return n===".png"?"image/png":n===".jpg"||n===".jpeg"?"image/jpeg":n===".webp"?"image/webp":n===".gif"?"image/gif":n===".svg"?"image/svg+xml":n===".webm"?"video/webm":n===".mp4"?"video/mp4":n===".mp3"?"audio/mpeg":n===".wav"?"audio/wav":e==="font"?"font/woff2":"application/octet-stream"}function kr(t){let e=t.toLowerCase().split(";")[0]?.trim();return e==="image/png"?".png":e==="image/jpeg"?".jpg":e==="image/webp"?".webp":e==="image/gif"?".gif":e==="image/svg+xml"?".svg":e==="video/webm"?".webm":e==="video/mp4"?".mp4":e==="audio/mpeg"?".mp3":e==="audio/wav"?".wav":e==="font/woff2"?".woff2":".bin"}async function Uc(t,e){let n=Jt(t,"snapshots");if(!await Z(n))return;let r=e.map(a=>({local:`/__inkly/cache/${`${a.sha256}${a.ext}`}`,remote:a.publicUrl}));await yi(n,r)}async function yi(t,e){for(let n of await gi(t,{withFileTypes:!0})){let r=Jt(t,n.name);if(n.isDirectory())await yi(r,e);else if(n.isFile()&&/\.(html|css)$/i.test(n.name)){let a=await fi(r,"utf8"),i=a;for(let o of e)a=a.split(o.local).join(o.remote);a!==i&&await Oc(r,a,"utf8")}}}function hi(t,e){if(e){process.stdout.write(JSON.stringify(t,null,2)+`
|
|
4968
5021
|
`);return}if(t.dryRun){process.stdout.write(`inkly sync dry run: ${t.assets.length} asset(s) need upload
|
|
4969
|
-
`),
|
|
4970
|
-
`),
|
|
5022
|
+
`),mi(t);return}process.stdout.write(`inkly sync complete: ${t.uploaded} uploaded, ${t.updatedManifests.length} manifest(s) updated
|
|
5023
|
+
`),mi(t)}function mi(t){if(t.unresolved.length!==0){process.stderr.write(`inkly sync warning: ${t.unresolved.length} asset(s) have no local cache file and are not on the CDN:
|
|
4971
5024
|
`);for(let e of t.unresolved)process.stderr.write(` - demos/${e.demo} "${e.id}" (${e.sha256})
|
|
4972
|
-
`)}}import{
|
|
4973
|
-
`+i.unresolved.map(
|
|
4974
|
-
`)
|
|
4975
|
-
`):
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
`)
|
|
4981
|
-
`):process.stdout.write(`inkly lock: ${
|
|
5025
|
+
`)}}import{readdir as Fc,readFile as Hc}from"fs/promises";import{extname as vr,join as xi,resolve as ki}from"path";function wr(t,e){t||process.stdout.write(e)}function Bc(t,e){if(e.demo){let n=t.demos.find(r=>r.slug===e.demo);if(!n)throw new Error(`No such demo: ${e.demo}`);return n}if(e.path){let n=ki(e.cwd,e.path),r=t.demos.find(i=>ki(i.dir)===n);if(r)return r;let a=t.demos.find(i=>i.slug===e.path||i.slug===e.path?.replace(/^demos\//,""));if(a)return a;throw new Error(`No demo found at "${e.path}". Available demos: ${t.demos.map(i=>i.slug).join(", ")||"(none)"}`)}if(t.demos.length===1)return t.demos[0];throw new Error(`This hub has ${t.demos.length} demos \u2014 pass a demo path or --demo <slug>. Available: ${t.demos.map(n=>n.slug).join(", ")}`)}async function Wc(t,e=[]){let n=xi(t,"snapshots");if(!await Z(n))return{};let r={};async function a(i){for(let o of await Fc(i,{withFileTypes:!0})){let s=xi(i,o.name);if(o.isDirectory())await a(s);else if(o.isFile()&&/\.(html|css)$/i.test(o.name)){let c=s.slice(t.length+1).split(/[\\/]/).join("/");r[c]=Vc(await Hc(s,"utf8"),e)}}}return await a(n),r}function Vc(t,e){let n=t;for(let r of e)n=n.split(r.local).join(r.remote);return n}function wi(t){if(!t)return null;try{let e=new URL(t);return vr(e.pathname)||null}catch{return vr(t)||null}}function Zc(t,e,n){let r=new Map,a=(o,s)=>{if(!s)return;let c=s.startsWith(".")?s:`.${s}`;r.has(o)||r.set(o,new Set),r.get(o).add(c)};for(let o of e)a(o.sha256,vr(o.cacheFile));for(let o of n)a(o.sha256,o.ext);for(let o of t.assets)a(o.sha256,wi(o.cdnPath)),a(o.sha256,wi(o.publicUrl)),o.contentType&&a(o.sha256,kr(o.contentType));let i=[];for(let o of t.assets)if(o.publicUrl)for(let s of r.get(o.sha256)??[])i.push({local:`/__inkly/cache/${o.sha256}${s}`,remote:o.publicUrl});return i}function Jc(t,e,n){let r=t??{version:1,assets:[]},a=new Map(n.map(o=>[o.sha256,o])),i=new Map(e.map(o=>[o.sha256,o]));return{...r,assets:r.assets.map(o=>{let s=a.get(o.sha256);if(!s)return o;let c=i.get(o.sha256);return{...o,contentType:o.contentType??c?.contentType??Tn(`${o.sha256}${s.ext}`,o.kind),publicUrl:s.publicUrl,cdnPath:s.cdnPath}})}}async function vi(t){let e=await je();if(!e.token)throw new Error("Not logged in. Run `inkly login` first.");let n=Oe(e.apiBase??process.env.INKLY_API_BASE),r=await St(t.cwd),a=Bc(r,t),i=await An({cwd:r.root,demo:a.slug,dryRun:!0,silent:!0});if(i.unresolved.length>0)throw new Error(`${i.unresolved.length} asset(s) have no local bytes and are not on the CDN, so a hosted preview cannot be published:
|
|
5026
|
+
`+i.unresolved.map(y=>` - ${y.id} (${y.sha256})`).join(`
|
|
5027
|
+
`));let o=[];i.assets.length>0&&(wr(t.silent,`Uploading ${i.assets.length} asset(s) to the CDN for this preview...
|
|
5028
|
+
`),o=(await xr({apiBase:n,token:e.token,hubRoot:r.root,assets:i.assets})).uploads);let s=Jc(a.assets,i.assets,o),c=await Wc(a.dir,Zc(s,i.assets,o)),d=await fetch(`${n}/api/previews`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.token}`},body:JSON.stringify({demoSlug:a.slug,title:a.config.title??null,config:a.config,assets:s,hub:r.inkly,snapshots:c})}),u=await d.json().catch(()=>null);if(!d.ok||!u?.id)throw new Error(u?.error??`Preview publish failed: HTTP ${d.status}`);let p=u.url??`${n}${u.path??`/p/${u.id}`}`,h={hubRoot:r.root,slug:a.slug,id:u.id,url:p};return t.json?wr(t.silent,JSON.stringify(h,null,2)+`
|
|
5029
|
+
`):wr(t.silent,`Preview published:
|
|
5030
|
+
${p}
|
|
5031
|
+
`),h}import{readFile as Ci,writeFile as Gc}from"fs/promises";import{dirname as Sr,isAbsolute as qc,join as Pt,resolve as Kc}from"path";import{fileURLToPath as Yc,pathToFileURL as Xc}from"url";function Ne(t,e,n){t.push({level:e,message:n})}async function Qc(){let t=Sr(Yc(import.meta.url));for(let e=0;e<10;e+=1){let n=Pt(t,"node_modules","@inkly","runtime","dist","manifest.json");if(await Z(n))return n;let r=Pt(t,"packages","inkly-runtime","dist","manifest.json");if(await Z(r))return r;let a=Sr(t);if(a===t)break;t=a}return null}async function Si(t){let e=JSON.parse(await Ci(t,"utf8")),n=kt.safeParse(e);if(!n.success)throw new Error(`${t} failed RuntimeManifestSchema validation: ${n.error.message}`);return n.data}async function eu(t,e){let n=rt(),r=tr(t,"manifest.json",n);try{let a=await e(r);if(!a.ok)return null;let i=JSON.parse(await a.text()),o=kt.safeParse(i);return o.success?{manifest:o.data,url:r}:null}catch{return null}}async function tu(t,e){if(e.manifestPath)return{manifest:await Si(e.manifestPath),source:"local",manifestPath:e.manifestPath};if(!e.localOnly){let r=e.fetchImpl??fetch,a=await eu(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 Qc();if(!n)throw new Error(`Could not fetch runtime manifest for ${t} from ${rt()} 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 Si(n),source:"local",manifestPath:n}}async function _i(t,e={}){let n=Pt(t,"inkly.json"),r=await we(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 tu(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?Xc(Pt(Sr(s),"runtime.js")).toString():tr(i.version,"runtime.js"),integrity:i.integrity}},manifest:i,source:o}}async function Ti(t){let e=[],n=await ve(t.cwd);if(!n)return Ne(e,"error",`No inkly.json found in ${t.cwd} or any parent directory.`),me({ok:!1,hubRoot:null,lockPath:null,lock:null,source:null,issues:e,drifted:!1,options:t});let r=Pt(n,"inkly.lock"),a=t.manifestPath?qc(t.manifestPath)?t.manifestPath:Kc(t.cwd,t.manifestPath):void 0;if(t.check){if(!await Z(r))return Ne(e,"error","inkly.lock is missing. Run `inkly lock` to create it."),me({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:e,drifted:!0,options:t});let i=await we(r),o=fn.safeParse(i);if(!o.success)return Ne(e,"error",`inkly.lock failed schema validation: ${o.error.message}`),me({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:e,drifted:!0,options:t});let s=Pt(n,"inkly.json"),c=await we(s),d=typeof c.runtime=="string"?c.runtime:null;if(!d)return Ne(e,"error",'inkly.json is missing a string "runtime" pin.'),me({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:e,drifted:!0,options:t});if(o.data.runtime.version!==d)return Ne(e,"error",`inkly.lock pins runtime ${o.data.runtime.version}, but inkly.json pins ${d}. Re-run \`inkly lock\` to refresh.`),me({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:null,issues:e,drifted:!0,options:t});try{let u=await _i(n,{manifestPath:a,localOnly:!!a||t.localOnly,fetchImpl:t.fetchImpl});return u.lock.runtime.integrity!==o.data.runtime.integrity?(Ne(e,"error",`inkly.lock integrity does not match what ${u.source==="cdn"?rt():"the local build"} serves for runtime ${d}. Re-run \`inkly lock\` to refresh, or someone tampered with the source.`),me({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:u.source,issues:e,drifted:!0,options:t})):me({ok:!0,hubRoot:n,lockPath:r,lock:o.data,source:u.source,issues:e,drifted:!1,options:t})}catch(u){return Ne(e,"error",u.message),me({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:null,issues:e,drifted:!0,options:t})}}try{let{lock:i,source:o}=await _i(n,{manifestPath:a,localOnly:!!a||t.localOnly,fetchImpl:t.fetchImpl}),s=JSON.stringify(i,null,2)+`
|
|
5032
|
+
`,d=(await Z(r)?await Ci(r,"utf8"):null)!==s;return d&&await Gc(r,s,"utf8"),me({ok:!0,hubRoot:n,lockPath:r,lock:i,source:o,issues:e,drifted:d,options:t})}catch(i){return Ne(e,"error",i.message),me({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:e,drifted:!1,options:t})}}function me(t){let{ok:e,hubRoot:n,lockPath:r,lock:a,source:i,issues:o,drifted:s,options:c}=t,d={ok:e,hubRoot:n,lockPath:r,lock:a,source:i,issues:o,drifted:s};if(!c.silent)if(c.json)process.stdout.write(JSON.stringify(d,null,2)+`
|
|
5033
|
+
`);else if(e)c.check?process.stdout.write(`inkly lock --check: inkly.lock matches inkly.json (runtime ${a?.runtime.version}, source: ${i??"unknown"}).
|
|
5034
|
+
`):s?process.stdout.write(`inkly lock: wrote ${r} (runtime ${a?.runtime.version}, source: ${i??"unknown"}).
|
|
5035
|
+
`):process.stdout.write(`inkly lock: ${r} already up to date (runtime ${a?.runtime.version}, source: ${i??"unknown"}).
|
|
4982
5036
|
`);else{for(let u of o)process.stdout.write(`${u.level.toUpperCase()} ${u.message}
|
|
4983
5037
|
`);process.stdout.write(`inkly lock failed
|
|
4984
|
-
`)}return d}import*as ot from"@sentry/node";var
|
|
5038
|
+
`)}return d}import*as ot from"@sentry/node";var nu="https://b3450c6a8fdcd02b8aee3b9f2c8425eb@o4511498910433280.ingest.us.sentry.io/4511498940252160",ru="@inkly-org/cli@0.5.1";function Ai(){ot.init({dsn:nu,release:process.env.SENTRY_RELEASE??ru,environment:process.env.SENTRY_ENVIRONMENT??"production",enabled:process.env.INKLY_SENTRY_DISABLED!=="1",sendDefaultPii:!1,tracesSampleRate:0,beforeSend(t){return t.server_name=void 0,t}})}async function ne(t,e){ot.captureException(e,{tags:{command:t,surface:"cli"}}),await ot.flush(2e3)}async function Ii(){await ot.flush(2e3)}import{spawn as Fi}from"child_process";import{createHash as Wu,randomUUID as Vu}from"crypto";import{mkdir as $t,mkdtemp as Zu,open as Hi,readFile as st,readdir as Bi,rm as lt,writeFile as Wi}from"fs/promises";import{existsSync as Ce}from"fs";import{dirname as $n,isAbsolute as Vi,join as W,resolve as En,sep as Ju}from"path";import{tmpdir as Gu,homedir as $r}from"os";import{fileURLToPath as Zi}from"url";import{unzipSync as qu,zipSync as Ku}from"fflate";import Yu from"ws";import Xu from"sharp";import Qu from"subset-font";var au=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),iu=new Set(["a","button","input","select","textarea","label","p","h1","h2","h3","h4","h5","h6","img","li","nav","main","header","footer","section","article","aside","form","table","tr","td","th","ul","ol"]);function ou(t){let e="";for(let n=0;n<t.length;n+=1)e+=(t[n]??0).toString(16).padStart(2,"0");return e}async function In(t,e=16){let n=new Uint8Array(t.byteLength);n.set(t);let r=await crypto.subtle.digest("SHA-256",n);return ou(new Uint8Array(r)).slice(0,e)}function Ir(t){switch((t.toLowerCase().split(";")[0]??"").trim()){case"image/png":return".png";case"image/jpeg":case"image/jpg":return".jpg";case"image/webp":return".webp";case"image/gif":return".gif";case"image/svg+xml":return".svg";case"image/avif":return".avif";case"image/x-icon":case"image/vnd.microsoft.icon":return".ico";case"font/woff2":return".woff2";case"font/woff":return".woff";case"text/css":return".css";case"text/javascript":case"application/javascript":return".js";default:return".bin"}}function _r(t,e){let n=t.trim();if(!n||n.startsWith("data:")||n.startsWith("blob:")||n.startsWith("assets/")||n.startsWith("#"))return null;try{let r=new URL(n,e);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.href}catch{return null}}function Di(t,e,n){if(e){let a=atob(n.replace(/\s+/g,"")),i=new Uint8Array(a.length);for(let o=0;o<a.length;o+=1)i[o]=a.charCodeAt(o);return i}let r=decodeURIComponent(n.replace(/\+/g,"%20"));return new TextEncoder().encode(r)}function su(t){return/\s/.test(t)||t===")"||t==='"'||t==="<"||t===">"}function ji(t){return t.replace(/\\(?:\r\n|[\n\r\f])/g,"").replace(/\\([0-9a-fA-F]{1,6}\s?|[\s\S])/g,(e,n)=>{let r=n.match(/^([0-9a-fA-F]{1,6})\s?$/);if(r?.[1])try{return String.fromCodePoint(Number.parseInt(r[1],16))}catch{return""}return n})}function lu(t){let e=[],n=0;for(;n<t.length;){let r=t.toLowerCase().indexOf("data:",n);if(r<0)break;let a=r>0?t[r-1]:"",i=a==='"'||a==="'"?a:null,o=t.indexOf(",",r);if(o<0)break;let s=t.slice(r+5,o);if(!s||/[\s"'()<>]/.test(s)){n=r+5;continue}let c=o+1,d=!1;for(;c<t.length;){let w=t[c]??"";if(d){d=!1,c+=1;continue}if(w==="\\"){d=!0,c+=1;continue}if(i?w===i:su(w))break;c+=1}let u=t.slice(r,c),p=ji(t.slice(o+1,c)),h=s.split(";"),y=h.shift()||"text/plain",x=h.some(w=>w.toLowerCase()==="base64");e.push({match:u,mime:y,isBase64:x,payload:p,index:r}),n=c}return e}function du(t){let e=t.trim();if(!e.toLowerCase().startsWith("data:"))return null;let n=e.indexOf(",");if(n<0)return null;let r=e.slice(5,n);if(!r||/[\s"'()<>]/.test(r))return null;let a=r.split(";"),i=a.shift()||"text/plain",o=a.some(s=>s.toLowerCase()==="base64");return{mime:i,isBase64:o,payload:ji(e.slice(n+1))}}async function Pi(t,e){let n=du(t);if(!n)return null;let r;try{r=Di(n.mime,n.isBase64,n.payload)}catch{return null}let a=`${await In(r)}${Ir(n.mime)}`;return e.has(a)||e.set(a,{filename:a,bytes:r,contentType:n.mime||"application/octet-stream"}),`assets/${a}`}async function Cr(t,e,n){let r=n.get(t);if(r)return r;try{let a=await fetch(t,{cache:"force-cache",referrerPolicy:"strict-origin-when-cross-origin"});if(!a.ok)return null;let i=a.headers.get("content-type")?.split(";")[0]?.trim()||"application/octet-stream",o=new Uint8Array(await a.arrayBuffer());if(o.byteLength===0)return null;let s=`${await In(o)}${Ir(i)}`;e.has(s)||e.set(s,{filename:s,bytes:o,contentType:i});let c=`assets/${s}`;return n.set(t,c),c}catch{return null}}function cu(t){let e=[],n=0,r=!1;for(let a=0;a<t.length;a+=1){if(t[a]!==",")continue;if(t.slice(n,a).trimStart().toLowerCase().startsWith("data:")&&!r){r=!0;continue}e.push(t.slice(n,a).trim()),n=a+1,r=!1}return e.push(t.slice(n).trim()),e.filter(Boolean).map(a=>{let i=a.match(/\s+(\d+(?:\.\d+)?[wx])$/);return i?.index?{url:a.slice(0,i.index).trim(),descriptor:i[1]??""}:{url:a,descriptor:""}}).filter(a=>a.url.length>0)}async function uu(t,e,n,r){let a=Array.from(t.querySelectorAll("img[src],source[src],video[poster]"));for(let o of a){let s=o.hasAttribute("poster")?"poster":"src",c=o.getAttribute(s);if(!c)continue;let d=await Pi(c,n);if(d){o.setAttribute(s,d);continue}let u=_r(c,e);if(!u)continue;let p=await Cr(u,n,r);p&&o.setAttribute(s,p)}let i=Array.from(t.querySelectorAll("img[srcset],source[srcset]"));for(let o of i){let s=o.getAttribute("srcset");if(!s)continue;let c=[];for(let d of cu(s)){let u=await Pi(d.url,n);if(u){c.push(`${u}${d.descriptor?` ${d.descriptor}`:""}`);continue}let p=_r(d.url,e),h=p?await Cr(p,n,r):null;c.push(`${h??d.url}${d.descriptor?` ${d.descriptor}`:""}`)}o.setAttribute("srcset",c.join(", "))}}async function pu(t,e,n,r){let a=[],i=/url\(\s*(["']?)([^"')]+)\1\s*\)/gi,o;for(;o=i.exec(t);){let c=o[2]??"",d=_r(c,e);d&&a.push({raw:c,url:d})}let s=t;for(let c of a){let d=await Cr(c.url,n,r);d&&(s=s.split(c.raw).join(d))}return s}async function hu(t){let e=new Map,n=lu(t),r=[];for(let o of n){let s;try{s=Di(o.mime,o.isBase64,o.payload)}catch{continue}let c=`${await In(s)}${Ir(o.mime)}`;e.has(c)||e.set(c,{filename:c,bytes:s,contentType:o.mime||"application/octet-stream"}),r.push({match:o.match,replacement:`assets/${c}`})}let a=t,i=new Map;for(let o of r)i.set(o.match,o.replacement);for(let[o,s]of i)a=a.split(o).join(s);return{html:a,assets:e}}function mu(t){return t.replace(/<script\b[\s\S]*?<\/script>/gi,"")}function fu(t){return t.replace(/<script\b(?=[^>]*\bid=["']alpha-capture-index["'])[\s\S]*?<\/script>/i,"")}function gu(t){return t.replace(/<link\b(?=[^>]*\brel=["'](?:preload|prefetch|preconnect|dns-prefetch|modulepreload|canonical|alternate)["'])[^>]*>/gi,"").replace(/<meta\b(?=[^>]*\b(?:property|name)=["'](?:og:[^"']+|twitter:[^"']+|description|keywords|robots|theme-color|generator)["'])[^>]*>/gi,"")}function bu(t){let e=1,n=t.createTreeWalker(t.documentElement,NodeFilter.SHOW_ELEMENT,null),r=t.documentElement;do{if(r&&r.nodeType===1){let a=r.tagName.toLowerCase();iu.has(a)&&(r.setAttribute("data-inkly-id",String(e)),e+=1)}r=n.nextNode()}while(r)}function yu(t){t.removeAttribute("href"),t.removeAttribute("xlink:href"),t.removeAttributeNS("http://www.w3.org/1999/xlink","href"),t.removeAttribute("target"),t.removeAttribute("rel"),t.removeAttribute("download"),t.removeAttribute("ping"),t.removeAttribute("referrerpolicy")}function xu(t){for(let e of Array.from(t.querySelectorAll("*")))for(let n of Array.from(e.attributes))/^on/i.test(n.name)&&e.removeAttribute(n.name),/^formaction$/i.test(n.name)&&e.removeAttribute(n.name);for(let e of Array.from(t.querySelectorAll("base")))e.remove();for(let e of Array.from(t.querySelectorAll("link[href]")))(e.getAttribute("rel")??"").toLowerCase().split(/\s+/).filter(Boolean).includes("stylesheet")||e.remove();for(let e of Array.from(t.querySelectorAll("meta[http-equiv]")))(e.getAttribute("http-equiv")??"").toLowerCase()==="refresh"&&e.remove();for(let e of Array.from(t.querySelectorAll("a,area")))yu(e),e.removeAttribute("data-inkly-href");for(let e of Array.from(t.querySelectorAll("form")))e.removeAttribute("action"),e.removeAttribute("method"),e.removeAttribute("target"),e.removeAttribute("data-inkly-action")}function ku(t){let e=Array.from(t.querySelectorAll("style"));if(e.length===0)return"";let n=[],r=!0;for(let a of e){let i=a.textContent?.trim()??"",o=a.getAttribute("media")?.trim();if(o&&o.toLowerCase()!=="all"?n.push(`@media ${o} {${i}}`):n.push(i),r){let s=t.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href","assets/document.css"),a.replaceWith(s),r=!1}else a.remove()}return n.join(`
|
|
5039
|
+
|
|
5040
|
+
`)}function wu(t){let e="",n=0,r="",a=!1,i=0,o=!0,s=()=>{o&&(e+=" ".repeat(n),o=!1)},c=()=>{e=e.replace(/[ \t]+$/,""),e+=`
|
|
5041
|
+
`,o=!0};for(let d of t){if(r){s(),e+=d,a?a=!1:d==="\\"?a=!0:d===r&&(r="");continue}if(a){s(),e+=d,a=!1;continue}if(d==="\\"){s(),e+=d,a=!0;continue}if(d==='"'||d==="'"){s(),r=d,e+=d;continue}if(d==="("&&(i+=1),d===")"&&(i=Math.max(0,i-1)),d==="{"){s(),e=e.replace(/[ \t]+$/,""),e+=` {
|
|
5042
|
+
`,n+=1,o=!0;continue}if(d==="}"){n=Math.max(0,n-1),c(),s(),e+="}",c();continue}if(d===";"&&i===0){s(),e+=";",c();continue}if(d===","&&i===0){s(),e+=",",c();continue}s(),e+=d}return`${e.trim()}
|
|
5043
|
+
`}function Ei(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Tr(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ri(t){return t==="id"?0:t==="data-inkly-id"?1:t==="class"?2:t==="href"?3:t==="src"?4:t==="srcset"?5:t==="alt"?6:t==="aria-label"?7:t==="role"?8:t==="type"?9:t==="style"?10:20}function vu(t){return Array.from(t.attributes).sort((n,r)=>Ri(n.name)-Ri(r.name)||n.name.localeCompare(r.name))}function Su(t,e){let n=t.trim().split(/\s+/).filter(Boolean);if(n.length<=5&&t.length<=100)return`"${Tr(t)}"`;let r=" ".repeat(e+2);return`"${n.map(a=>`
|
|
5044
|
+
${r}${Tr(a)}`).join("")}
|
|
5045
|
+
${" ".repeat(e)}"`}function $i(t,e){return t.name==="class"?`${t.name}=${Su(t.value,e+t.name.length+2)}`:`${t.name}="${Tr(t.value)}"`}function _u(t,e){let n=vu(t),r=t.tagName.toLowerCase();if(n.length===0)return`<${r}>`;let a=`<${r} ${n.map(o=>$i(o,e)).join(" ")}>`;if(a.length<=110&&!n.some(o=>o.name==="class"&&o.value.length>100))return a;let i=[`<${r}`];for(let o of n)i.push(`${" ".repeat(e+2)}${$i(o,e+2)}`);return i.push(`${" ".repeat(e)}>`),i.join(`
|
|
5046
|
+
`)}function Cu(t){let e=t.tagName.toLowerCase();if(e==="pre"||e==="code"||e==="textarea"||e==="style")return!0;let n=t.getAttribute("class")??"";if(/(^|\s)whitespace-(?:pre|pre-wrap|pre-line|break-spaces)(\s|$)/.test(n))return!0;let r=t.getAttribute("style")??"";return/(?:^|;)\s*white-space\s*:\s*(?:pre|pre-wrap|pre-line|break-spaces)\b/i.test(r)}function Ar(t,e){let n=" ".repeat(e*2);if(t.nodeType===Node.TEXT_NODE){let d=(t.nodeValue??"").replace(/\s+/g," ").trim();return d?`${n}${Ei(d)}`:""}if(t.nodeType===Node.COMMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return"";let r=t,a=r.tagName.toLowerCase(),i=`${n}${_u(r,n.length)}`;if(au.has(a))return i;if(a==="template"&&"content"in r){let d=r,u=[];for(let p of Array.from(d.content.childNodes)){let h=Ar(p,e+1);h&&u.push(h)}return u.length===0?`${i}</${a}>`:`${i}
|
|
5047
|
+
${u.join(`
|
|
5048
|
+
`)}
|
|
5049
|
+
${n}</${a}>`}if(Cu(r))return`${n}${r.outerHTML}`;let o=Array.from(r.childNodes).filter(d=>d.nodeType!==Node.COMMENT_NODE&&!(d.nodeType===Node.TEXT_NODE&&(d.nodeValue??"").trim().length===0));if(o.length>0&&o.every(d=>d.nodeType===Node.TEXT_NODE)){let d=o.map(u=>u.nodeValue??"").join("").replace(/\s+/g," ").trim();return d?`${i}${Ei(d)}</${a}>`:`${i}</${a}>`}let s=[];for(let d of Array.from(r.childNodes)){let u=Ar(d,e+1);u&&s.push(u)}if(s.length===0)return`${i}</${a}>`;let c=s[0];return s.length===1&&c&&c.trim()&&!c.includes(`
|
|
5050
|
+
`)&&i.length+c.trim().length<120?`${i}${c.trim()}</${a}>`:`${i}
|
|
5051
|
+
${s.join(`
|
|
5052
|
+
`)}
|
|
5053
|
+
${n}</${a}>`}function Tu(t){let e=t.documentElement;return`<!doctype html>
|
|
5054
|
+
${Ar(e,0)}
|
|
5055
|
+
`}var Au=.8,Iu=1024;function Pu(t){let e=(t.toLowerCase().split(";")[0]??"").trim();return e==="image/png"||e==="image/jpeg"||e==="image/jpg"}async function Eu(t,e){if(typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{let n=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),r=await createImageBitmap(new Blob([n],{type:e}));try{let a=new OffscreenCanvas(r.width,r.height),i=a.getContext("2d");if(!i)return null;i.drawImage(r,0,0);let o=await a.convertToBlob({type:"image/webp",quality:Au});return o.type!=="image/webp"?null:new Uint8Array(await o.arrayBuffer())}finally{r.close()}}catch{return null}}async function Ru(t,e,n){let r=new Map,a=new Map;for(let s of t.values()){if(!Pu(s.contentType)||s.bytes.byteLength<Iu){a.set(s.filename,s);continue}let c=await Eu(s.bytes,s.contentType);if(!c||c.byteLength>=s.bytes.byteLength){a.set(s.filename,s);continue}let d=`${await In(c)}.webp`;r.set(s.filename,d),a.has(d)||a.set(d,{filename:d,bytes:c,contentType:"image/webp"})}if(r.size===0)return{assets:[...t.values()],html:e,css:n};let i=e,o=n;for(let[s,c]of r)i=i.split(`assets/${s}`).join(`assets/${c}`),o=o.split(s).join(c);return{assets:[...a.values()],html:i,css:o}}async function Oi(t,e,n={}){let r=mu(t);r=fu(r),r=gu(r);let a=await hu(r);r=a.html;let i=$u(r);bu(i),xu(i);let o=new Map;await uu(i,e,a.assets,o);let s=(await pu(ku(i),e,a.assets,o)).replace(/url\((["']?)assets\//g,"url($1"),c=Ut(Tu(i)),d=wu(s);if(n.compressImages){let u=await Ru(a.assets,c,d);return{html:u.html,css:u.css,assets:u.assets}}return{html:c,css:d,assets:[...a.assets.values()]}}function $u(t){let e=globalThis.DOMParser;if(!e)throw new Error("DOMParser is not available in this context. Run compactSnapshot in an offscreen document.");return new e().parseFromString(t,"text/html")}import{zipSync as Du}from"fflate";var ju=/^(?:https?:)?\/\//i,Ou=/^(?:#|data:|blob:|javascript:|mailto:|tel:|about:|chrome:|chrome-extension:)/i;function Nu(t){return t.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,60).replace(/-+$/,"")||"demo"}function Lu(t){let e="abcdefghijklmnopqrstuvwxyz0123456789",n=new Uint8Array(t);crypto.getRandomValues(n);let r="";for(let a=0;a<t;a+=1)r+=e[(n[a]??0)%e.length];return r}function zu(t){return`${Nu(t)}-${Lu(6)}`}function Mu(t,e){return`# ${e}
|
|
5056
|
+
|
|
5057
|
+
This folder is a self-contained Inkly HTML capture. It works locally with
|
|
5058
|
+
\`inkly-cli\` with no upload needed.
|
|
5059
|
+
|
|
5060
|
+
## Use it
|
|
5061
|
+
|
|
5062
|
+
1. If you don't have a hub yet, create one:
|
|
5063
|
+
|
|
5064
|
+
\`\`\`bash
|
|
5065
|
+
npx @inkly-org/cli init my-hub
|
|
5066
|
+
cd my-hub
|
|
5067
|
+
\`\`\`
|
|
5068
|
+
|
|
5069
|
+
2. Copy the \`${t}/\` folder from this zip into your hub's \`demos/\`
|
|
5070
|
+
directory (so it lands at \`demos/${t}/\`).
|
|
5071
|
+
|
|
5072
|
+
3. Preview it:
|
|
5073
|
+
|
|
5074
|
+
\`\`\`bash
|
|
5075
|
+
inkly dev
|
|
5076
|
+
\`\`\`
|
|
5077
|
+
|
|
5078
|
+
The demo appears under the slug \`${t}\`.
|
|
5079
|
+
|
|
5080
|
+
## What's inside
|
|
5081
|
+
|
|
5082
|
+
- \`${t}/demo.config.json\` - the demo definition.
|
|
5083
|
+
- \`${t}/assets.json\` - maps pooled asset ids to files in \`public/\`.
|
|
5084
|
+
- \`${t}/capture-metadata.json\` - HTML export diagnostics.
|
|
5085
|
+
- \`${t}/public/<file>\` - captured HTML asset bytes.
|
|
5086
|
+
- \`${t}/snapshots/snap-NNN/index.html\` and \`document.css\` - replayable snapshots.
|
|
5087
|
+
`}function Uu(t){return t.trim().replace(/^['"]|['"]$/g,"")}function Pn(t,e){let n=Uu(e.url);!n||Ou.test(n)||!ju.test(n)||t.set(`${e.stepId}\0${e.file}\0${e.kind}\0${n}`,{...e,url:n})}function Fu(t){return t.split(",").map(e=>e.trim().split(/\s+/)[0]??"").filter(Boolean)}function Hu(t,e){return t?.alphaId?e.includes(`data-inkly-id="${t.alphaId}"`)||e.includes(`data-inkly-id='${t.alphaId}'`)?t:{...t,alphaId:void 0}:t}function Bu(t){let e=new Map,n=/\b(?:src|poster|data|action|formaction)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))/gi,r;for(;(r=n.exec(t.html))!==null;)Pn(e,{stepId:t.stepId,file:t.htmlPath,kind:"html-attribute",url:r[1]??r[2]??r[3]??""});let a=/<link\b(?=[^>]*\b(?:rel|as)\s*=\s*(?:"(?:stylesheet|preload|modulepreload|icon|apple-touch-icon|image_src)"|'(?:stylesheet|preload|modulepreload|icon|apple-touch-icon|image_src)'|[^\s"'<>`]*(?:stylesheet|preload|modulepreload|icon|apple-touch-icon|image_src)[^\s"'<>`]*))[^>]*\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))[^>]*>/gi,i;for(;(i=a.exec(t.html))!==null;)Pn(e,{stepId:t.stepId,file:t.htmlPath,kind:"html-attribute",url:i[1]??i[2]??i[3]??""});let o=/\b(?:srcset|imagesrcset)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))/gi,s;for(;(s=o.exec(t.html))!==null;){let u=s[1]??s[2]??s[3]??"";for(let p of Fu(u))Pn(e,{stepId:t.stepId,file:t.htmlPath,kind:"html-srcset",url:p})}let c=/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)"'\s]+))\s*\)/gi,d;for(;(d=c.exec(t.css))!==null;)Pn(e,{stepId:t.stepId,file:t.htmlPath.replace(/\/index\.html$/,"/document.css"),kind:"css-url",url:d[1]??d[2]??d[3]??""});return[...e.values()]}async function Ni(t){let{name:e,steps:n,assets:r}=t;if(n.length===0)throw new Error("No HTML steps captured.");let a=zu(e),i=new Map;for(let _ of r)i.set(_.filename,`/${a}/${_.filename}`);let o={},s=[],c=[],d=new TextEncoder;for(let _=0;_<n.length;_+=1){let O=n[_];if(!O)continue;let I=`s${_+1}`,k=oa(_+1),P=`snapshots/${k}/index.html`,R=Wn(O.cssText??"",i),M=la(da(Ut(Wn(O.htmlText,i)),R.length>0),O.scroll);o[k]={"index.html":d.encode(M),"document.css":d.encode(R)},c.push(...Bu({stepId:I,htmlPath:P,html:M,css:R})),s.push(sa({stepId:I,htmlPath:P,naturalWidth:O.viewport.width,naturalHeight:O.viewport.height,scroll:O.scroll,sourceUrl:O.url||void 0,click:Hu(O.click,M)}))}let u=r.map(_=>({id:_.filename,sha256:_.sha256,kind:dn(_.contentType),contentType:_.contentType,size:_.bytes.byteLength,publicUrl:`/${a}/${_.filename}`})),p=pn({id:te(),version:1,title:e,steps:s}),h=yt.parse({version:1,assets:u,screens:[]}),y={version:1,kind:"html-capture",generatedAt:t.generatedAt??new Date().toISOString(),stepCount:n.length,assetCount:r.length,unresolvedExternalReferences:c},x={};for(let _ of r)x[_.filename]=_.bytes;let w={"README.md":d.encode(Mu(a,e)),[a]:{"demo.config.json":d.encode(`${JSON.stringify(p,null,2)}
|
|
5088
|
+
`),"assets.json":d.encode(`${JSON.stringify(h,null,2)}
|
|
5089
|
+
`),"capture-metadata.json":d.encode(`${JSON.stringify(y,null,2)}
|
|
5090
|
+
`),snapshots:o,public:x}};return{bytes:Du(w,{level:6}),filename:`${a}.zip`,slug:a}}import{JSDOM as ep}from"jsdom";var Li=!1;function tp(){if(Li)return;let{window:t}=new ep("<!doctype html><html></html>"),e=globalThis;e.DOMParser??=t.DOMParser,e.Node??=t.Node,e.NodeFilter??=t.NodeFilter,e.Element??=t.Element,e.HTMLImageElement??=t.HTMLImageElement,Li=!0}var Ji=`Options:
|
|
4985
5091
|
--url <url> URL to open and arm for recording.
|
|
4986
5092
|
--name <name> Demo name written into the exported ZIP.
|
|
4987
5093
|
--session <id> Session id printed by start.
|
|
@@ -5001,7 +5107,7 @@ ${r.toString()}
|
|
|
5001
5107
|
done once in this profile survives, so later captures of the same site need
|
|
5002
5108
|
no re-login. Implies --keep-profile. Run --headed the first time so the user
|
|
5003
5109
|
can sign in; reuse can run headless.
|
|
5004
|
-
--no-unpack On stop, write only the ZIP.`,
|
|
5110
|
+
--no-unpack On stop, write only the ZIP.`,Yt=`inkly capture - capture an image/video walkthrough for an external browser agent
|
|
5005
5111
|
|
|
5006
5112
|
Usage:
|
|
5007
5113
|
inkly capture start --url <url> --name <name>
|
|
@@ -5009,14 +5115,16 @@ Usage:
|
|
|
5009
5115
|
inkly capture cancel --session <id>
|
|
5010
5116
|
inkly capture profiles
|
|
5011
5117
|
|
|
5012
|
-
${
|
|
5118
|
+
${Ji}
|
|
5013
5119
|
--video, --record-video Record motion segments. Enabled by default; use --no-video to disable.
|
|
5014
5120
|
--zoom Apply click zoom/pan to screenshot steps. Enabled by default; use --no-zoom to disable.
|
|
5121
|
+
--compress-images Re-encode captured PNG/JPEG screenshots to WebP (smaller, near-lossless).
|
|
5122
|
+
--subset-fonts Subset any captured font assets to the glyphs used and convert to WOFF2.
|
|
5015
5123
|
|
|
5016
5124
|
Output:
|
|
5017
5125
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
5018
5126
|
For self-contained HTML snapshot capture, use \`inkly capture-html\`.
|
|
5019
|
-
`,
|
|
5127
|
+
`,Xt=`inkly capture-html - capture a self-contained HTML walkthrough for an external browser agent
|
|
5020
5128
|
|
|
5021
5129
|
Usage:
|
|
5022
5130
|
inkly capture-html start --url <url> --name <name>
|
|
@@ -5024,22 +5132,20 @@ Usage:
|
|
|
5024
5132
|
inkly capture-html cancel --session <id>
|
|
5025
5133
|
inkly capture-html profiles
|
|
5026
5134
|
|
|
5027
|
-
${
|
|
5135
|
+
${Ji}
|
|
5028
5136
|
--block-videos Replace <video> with its poster frame instead of inlining the video.
|
|
5029
|
-
--compress-images Re-encode captured PNG/JPEG images to WebP (smaller, near-lossless).
|
|
5030
|
-
--subset-fonts Subset fonts to the glyphs used and convert to WOFF2.
|
|
5031
5137
|
|
|
5032
5138
|
Output:
|
|
5033
5139
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
5034
|
-
`,
|
|
5035
|
-
`)}function
|
|
5140
|
+
`,np=$n(Zi(import.meta.url)),rp=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/opt/google/chrome/chrome"],ap=1440,ip=900,op=12e4;function Dt(t){return new Promise(e=>setTimeout(e,t))}function Gt(t){process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
5141
|
+
`)}function Rt(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))return;let n=t[e];return typeof n=="string"?n:""}function Pr(t,e,n){let r=t[e];return typeof r=="number"?r:typeof r=="string"&&r.trim()?Number(r):n}function Et(t,e,n){for(let r of e)if(Object.prototype.hasOwnProperty.call(t,r))return t[r]!==!1;return n}function sp(t){if(!t)return null;let e=/^\s*(\d+)\s*[x,]\s*(\d+)\s*$/i.exec(t);if(!e)throw new Error("--window-size must look like 1440x900");return{width:Number(e[1]),height:Number(e[2])}}function qt(t,e,n){let r=Rt(t,e);if(!r)throw new Error(`missing --${e} <value>
|
|
5036
5142
|
|
|
5037
|
-
${n}`);return
|
|
5143
|
+
${n}`);return r}function lp(t){return Rt(t,"connect-to-browser")??process.env.INKLY_CAPTURE_BROWSER_URL}function dp(t){if(Object.prototype.hasOwnProperty.call(t,"prompt"))throw new Error("inkly capture does not accept --prompt. The external agent owns planning.")}function Dr(t,e){return Vi(e)?e:En(t,e)}function Gi(){return W($r(),".inkly","capture-agent","profiles")}function cp(t,e){if(e.includes("/")||Vi(e))return Dr(t,e);let n=e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);return W(Gi(),n||"default")}function zi(t,e){let n=En(t);for(;;){let r=W(n,e);if(Ce(r))return r;let a=$n(n);if(a===n)return null;n=a}}async function Mi(t){let e=[t];for(;e.length>0;){let n=e.pop();if(!n)continue;let r=await Bi(n,{withFileTypes:!0}).catch(()=>[]);for(let a of r){let i=W(n,a.name);if(a.isDirectory()){e.push(i);continue}if(a.name==="Google Chrome for Testing"&&i.includes("Google Chrome for Testing.app/Contents/MacOS"))return i}}return null}async function up(t,e){if(e){let s=Dr(t,e);if(Ce(s))return s;throw new Error(`Chrome binary does not exist: ${s}`)}let n=process.env.CHROME_PATH;if(n&&Ce(n))return n;let r=rp.find(s=>Ce(s));if(r)return r;let a=zi(t,"chrome");if(a){let s=await Mi(a);if(s)return s}let i=zi(np,"chrome");if(i&&i!==a){let s=await Mi(i);if(s)return s}let o=["/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing","/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary","/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"];for(let s of o)if(Ce(s))return s;throw new Error("No Chrome binary found. Pass --browser /path/to/chrome.")}var Er=class{constructor(e){this.nextId=1;this.pending=new Map;this.listeners=new Map;this.ws=new Yu(e,{perMessageDeflate:!1,maxPayload:512*1024*1024}),this.ready=new Promise((n,r)=>{this.ws.once("open",()=>n()),this.ws.once("error",a=>r(a))}),this.ws.on("message",n=>{let r=JSON.parse(n.toString());if(typeof r.id=="number"&&this.pending.has(r.id)){let i=this.pending.get(r.id);if(this.pending.delete(r.id),!i)return;r.error?i.reject(new Error(`${r.error.message??"CDP error"}: ${JSON.stringify(r.error.data??"")}`)):i.resolve(r.result??{});return}if(!r.method)return;let a=this.listeners.get(r.method);if(a)for(let i of a)i(r.params,r.sessionId)})}async send(e,n={},r){await this.ready;let a=this.nextId;this.nextId+=1;let i={id:a,method:e,params:n};return r&&(i.sessionId=r),new Promise((o,s)=>{this.pending.set(a,{resolve:o,reject:s}),this.ws.send(JSON.stringify(i),c=>{c&&(this.pending.delete(a),s(c))})})}on(e,n){let r=this.listeners.get(e)??new Set;return r.add(n),this.listeners.set(e,r),()=>r.delete(n)}close(){try{this.ws.close()}catch{}}};async function qi(t,e,n,r=3e4){let a=await t.send("Runtime.evaluate",{expression:n,awaitPromise:!0,returnByValue:!0,timeout:r,userGesture:!0},e);if(a.exceptionDetails)throw new Error(`Runtime.evaluate failed: ${JSON.stringify(a.exceptionDetails)}`);return a.result?.value}async function pp(t,e){let r=(await t.send("Target.attachToTarget",{targetId:e,flatten:!0})).sessionId;if(typeof r!="string")throw new Error("Target.attachToTarget returned no sessionId");return r}async function hp(t){let e=t.userDataDir?(await $t(t.userDataDir,{recursive:!0}),t.userDataDir):await Zu(W(Gu(),"inkly-capture-agent-")),n=W(e,"chrome.log"),r=await Hi(n,"a"),a=["--remote-debugging-port=0",`--user-data-dir=${e}`,`--window-size=${t.width},${t.height}`,"--no-first-run","--no-default-browser-check","--disable-default-apps","--disable-background-networking","--disable-features=Translate,AutofillServerCommunication","--use-mock-keychain","--hide-scrollbars","--hide-crash-restore-bubble"];t.headless&&a.unshift("--headless=new");for(let d of["DevToolsActivePort","SingletonLock","SingletonCookie","SingletonSocket"])await lt(W(e,d),{force:!0}).catch(()=>{});let i=Fi(t.browser,a,{detached:!0,stdio:["ignore",r.fd,r.fd]});i.unref(),await r.close();let o=W(e,"DevToolsActivePort"),s=Date.now(),c;for(i.once("exit",d=>{c=d});Date.now()-s<2e4;){if(c!==void 0)throw new Error(`Chrome exited before DevTools was ready. See ${n}`);let d=await st(o,"utf8").catch(()=>null);if(d){let u=d.trim().split(/\r?\n/),p=u[0],h=u[1];if(p&&h)return{pid:i.pid??null,profileDir:e,wsUrl:`ws://127.0.0.1:${p}${h}`,debuggingUrl:`http://127.0.0.1:${p}`,logPath:n}}await Dt(100)}throw new Error(`Timed out waiting for Chrome DevTools. See ${n}`)}async function mp(t){if(t.startsWith("ws://")||t.startsWith("wss://")){let a=new URL(t);return{wsUrl:t,debuggingUrl:`${a.protocol==="wss:"?"https":"http"}://${a.host}`}}let e=new URL(t),n=await fetch(new URL("/json/version",e));if(!n.ok)throw new Error(`could not read Chrome DevTools metadata from ${e.toString()}: ${n.status}`);let r=await n.json();if(typeof r.webSocketDebuggerUrl!="string")throw new Error("Chrome DevTools metadata did not include webSocketDebuggerUrl");return{wsUrl:r.webSocketDebuggerUrl,debuggingUrl:`${e.protocol}//${e.host}`}}async function fp(t,e,n,r,a){let o=(await t.send("Target.createTarget",{url:"about:blank"})).targetId;if(typeof o!="string")throw new Error("Target.createTarget returned no targetId");let s=await pp(t,o);await t.send("Page.enable",{},s),await t.send("Runtime.enable",{},s),await bp(t,s,o,n,r);let c=!1,d=t.on("Page.loadEventFired",(p,h)=>{h===s&&(c=!0)});await t.send("Page.navigate",{url:e},s);let u=Date.now();for(;!c&&Date.now()-u<a;)await Dt(100);return d(),await Dt(1e3),{targetId:o,sessionId:s}}async function gp(t,e){let n=await qi(t,e,`JSON.stringify({
|
|
5038
5144
|
innerWidth: window.innerWidth,
|
|
5039
5145
|
innerHeight: window.innerHeight,
|
|
5040
5146
|
outerWidth: window.outerWidth,
|
|
5041
5147
|
outerHeight: window.outerHeight
|
|
5042
|
-
})`,5e3),
|
|
5148
|
+
})`,5e3),r=JSON.parse(String(n)),a={innerWidth:Number(r.innerWidth),innerHeight:Number(r.innerHeight),outerWidth:Number(r.outerWidth),outerHeight:Number(r.outerHeight)};if(!Number.isFinite(a.innerWidth)||!Number.isFinite(a.innerHeight)||!Number.isFinite(a.outerWidth)||!Number.isFinite(a.outerHeight))throw new Error(`could not measure Chrome viewport: ${JSON.stringify(r)}`);return a}async function bp(t,e,n,r,a){try{let o=(await t.send("Browser.getWindowForTarget",{targetId:n})).windowId;if(typeof o!="number")throw new Error("Browser.getWindowForTarget returned no windowId");for(let s=0;s<4;s+=1){let c=await gp(t,e),d=Math.max(0,c.outerWidth-c.innerWidth),u=Math.max(0,c.outerHeight-c.innerHeight),p=r+d,h=a+u;if(Math.abs(c.innerWidth-r)<=1&&Math.abs(c.innerHeight-a)<=1)return;await t.send("Browser.setWindowBounds",{windowId:o,bounds:{windowState:"normal",width:p,height:h}}),await Dt(250)}}catch{}await t.send("Emulation.setDeviceMetricsOverride",{width:r,height:a,deviceScaleFactor:1,mobile:!1},e).catch(()=>{}),await Dt(100)}function yp(t){return t.toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"captured-demo"}function xp(t){return`${yp(t)}-${Math.random().toString(36).slice(2,8)}`}function jr(t){return Wu("sha256").update(t).digest("hex")}function kp(t,e){return`# ${e}
|
|
5043
5149
|
|
|
5044
5150
|
This folder is a self-contained Inkly demo captured with the Inkly CLI
|
|
5045
5151
|
agent runtime. It works locally with \`inkly-cli\` \u2014 no upload needed.
|
|
@@ -5061,9 +5167,9 @@ agent runtime. It works locally with \`inkly-cli\` \u2014 no upload needed.
|
|
|
5061
5167
|
- \`${t}/assets.json\` \u2014 maps each \`asset:<id>\` to a file in \`public/\`.
|
|
5062
5168
|
- \`${t}/public/<file>\` \u2014 captured image/video bytes.
|
|
5063
5169
|
- \`${t}/snapshots/snap-NNN/index.html\` \u2014 captured HTML snapshots, when present.
|
|
5064
|
-
`}function
|
|
5065
|
-
`),"assets.json":
|
|
5066
|
-
`),public:d,snapshots:u}};return{bytes:
|
|
5170
|
+
`}function wp(t){switch(t.toLowerCase().split(";")[0]?.trim()){case"image/png":return"png";case"image/jpeg":case"image/jpg":return"jpg";case"image/webp":return"webp";case"image/gif":return"gif";case"image/svg+xml":return"svg";case"image/avif":return"avif";case"image/x-icon":case"image/vnd.microsoft.icon":return"ico";case"font/woff":return"woff";case"font/woff2":return"woff2";case"font/ttf":case"application/x-font-ttf":return"ttf";case"video/webm":return"webm";case"video/mp4":return"mp4";case"audio/mpeg":return"mp3";case"text/html":return"html";case"text/css":return"css";case"text/javascript":case"application/javascript":case"application/x-javascript":return"js";default:return"bin"}}async function vp(t,e,n,r,a){let i=new TextDecoder,o=new TextEncoder,s=new Map,c=0,d=0,u=0,p=" ";if(a.subsetFonts){let h=new Set;for(let y of Object.values(r)){let x=y["index.html"];if(!x)continue;let w=i.decode(x).replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ");for(let _ of w)h.add(_)}for(let y of" 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,:;!?@#$%&*()-_=+[]{}/\\|<>'\"`~\u2019\u201C\u201D\u2014\u2013\u2026\u2022\u2192")h.add(y);p=Array.from(h).join("")}for(let h of e){let y=h.publicUrl;if(!y)continue;let x=y.split("/").pop();if(!x)continue;let w=n[x];if(!w)continue;let _=null,O="",I="",k=(h.contentType??"").toLowerCase();try{if(a.compressImages&&h.kind==="image"&&/^image\/(png|jpe?g)$/.test(k)){let V=await Xu(Buffer.from(w)).webp({quality:80}).toBuffer();V.length<w.byteLength&&(_=V,O="webp",I="image/webp")}else if(a.subsetFonts&&h.kind==="font"){let V=await Qu(Buffer.from(w),p,{targetFormat:"woff2"});V.length<w.byteLength&&(_=V,O="woff2",I="font/woff2")}}catch{_=null}if(!_)continue;let P=new Uint8Array(_),R=jr(P),M=`${R.slice(0,16)}.${O}`,j=`/${t}/${M}`;u+=w.byteLength-P.byteLength,h.kind==="image"?c+=1:d+=1,delete n[x],n[M]=P,h.id===x&&(h.id=M),s.set(y,j),h.sha256=R,h.size=P.byteLength,h.contentType=I,h.publicUrl=j}if(s.size)for(let h of Object.values(r)){let y=h;for(let x of Object.keys(y)){let w=i.decode(y[x]);for(let[_,O]of s)w=w.split(_).join(O);y[x]=o.encode(w)}}return{images:c,fonts:d,savedBytes:u}}async function Sp(t){let{name:e,screens:n,autoApplyZoom:r=!0,compressImages:a=!1,subsetFonts:i=!1}=t;if(n.length===0)throw new Error("No screens captured.");let o=xp(e),s=[],c=[],d={},u={},p=[],h=new TextEncoder,y=0;async function x(I,k,P,R,M){let j=jr(I),V=M??`${j}.${wp(k)}`;d[V]=I,y+=1;let Le=P==="other"?V:`cap-${String(y).padStart(3,"0")}`;return s.push({id:Le,sha256:j,kind:P==="other"?dn(k):P,contentType:k,size:I.byteLength,viewport:R?{w:R.width,h:R.height}:void 0,publicUrl:`/${o}/${V}`}),Le}for(let[I,k]of n.entries()){let P=`s${I+1}`,R=null;if(k.kind!=="html"){if(k.kind==="video"&&k.videoPath){let M=new Uint8Array(await st(k.videoPath));R=await x(M,"video/webm","video",k.viewport);let j;if(k.posterPngPath){let V=new Uint8Array(await st(k.posterPngPath));j=await x(V,"image/png","image",k.viewport)}p.push(Bn({stepId:P,kind:"video",assetId:R,posterAssetId:j,naturalWidth:k.naturalSize.width,naturalHeight:k.naturalSize.height,sourceUrl:k.sourceUrl||void 0,title:k.title||void 0,click:k.click,autoApplyZoom:r,isLast:I===n.length-1}))}else{if(!k.pngPath)continue;let M=new Uint8Array(await st(k.pngPath));R=await x(M,"image/png","image",k.viewport),p.push(Bn({stepId:P,kind:"image",assetId:R,naturalWidth:k.naturalSize.width,naturalHeight:k.naturalSize.height,sourceUrl:k.sourceUrl||void 0,title:k.title||void 0,click:k.click,autoApplyZoom:r,isLast:I===n.length-1}))}c.push({index:I,id:ia(I),assetId:R,sourceUrl:k.sourceUrl,capturedAt:k.capturedAt,naturalWidth:k.naturalSize.width,naturalHeight:k.naturalSize.height,precedingClick:k.click})}}if(p.length===0)throw new Error("No usable screens captured.");(a||i)&&await vp(o,s,d,u,{compressImages:a,subsetFonts:i});let w=pn({id:te(),version:1,title:e,steps:p}),_=yt.parse({version:1,assets:s,screens:c}),O={"README.md":h.encode(kp(o,e)),[o]:{"demo.config.json":h.encode(`${JSON.stringify(w,null,2)}
|
|
5171
|
+
`),"assets.json":h.encode(`${JSON.stringify(_,null,2)}
|
|
5172
|
+
`),public:d,snapshots:u}};return{bytes:Ku(O,{level:6}),filename:`${o}.zip`,slug:o,stepCount:n.length}}function _p(t){return t?{x:t.x,y:t.y,alphaId:t.alphaId??void 0,label:t.label}:null}async function Cp(t){let{name:e,screens:n}=t,r=n.filter(s=>s.kind==="html"&&s.htmlPath);if(r.length===0)throw new Error("No HTML screens captured.");tp();let a=[],i=new Map;for(let s of r){let c=await st(s.htmlPath,"utf8"),d=await Oi(c,s.sourceUrl||"");for(let u of d.assets)i.has(u.filename)||i.set(u.filename,{filename:u.filename,sha256:jr(u.bytes),contentType:u.contentType,bytes:u.bytes});a.push({htmlText:d.html,cssText:d.css,viewport:{width:s.naturalSize.width,height:s.naturalSize.height},scroll:s.scroll??{x:0,y:0,maxX:0,maxY:0},url:s.sourceUrl||"",click:_p(s.click)})}return{...await Ni({name:e,steps:a,assets:[...i.values()]}),stepCount:r.length}}var Ui=`(() => {
|
|
5067
5173
|
if (window.__inklyCliRecorderInstalled) return;
|
|
5068
5174
|
window.__inklyCliRecorderInstalled = true;
|
|
5069
5175
|
window.__inklyCliLastClick = null;
|
|
@@ -5247,7 +5353,7 @@ function selectorFor(el) {
|
|
|
5247
5353
|
window.addEventListener("scroll", onMotionScroll, true);
|
|
5248
5354
|
window.addEventListener("wheel", onMotionScroll, true);
|
|
5249
5355
|
window.addEventListener("touchmove", onMotionScroll, true);
|
|
5250
|
-
})();`;async function
|
|
5356
|
+
})();`;async function Tp(t,e,n=!1){n&&(await t.send("Runtime.addBinding",{name:"__inklyCliCaptureEvent"},e).catch(()=>{}),await t.send("Runtime.addBinding",{name:"__inklyCliCaptureClick"},e).catch(()=>{})),await t.send("Page.addScriptToEvaluateOnNewDocument",{source:Ui},e),await qi(t,e,Ui,5e3).catch(()=>{})}var Ap="__inklySingleFileFetch",eb=`(() => {
|
|
5251
5357
|
if (globalThis.__inklyFetchInstalled) return;
|
|
5252
5358
|
globalThis.__inklyFetchInstalled = true;
|
|
5253
5359
|
const pending = new Map();
|
|
@@ -5267,7 +5373,7 @@ function selectorFor(el) {
|
|
|
5267
5373
|
const id = nextId++;
|
|
5268
5374
|
pending.set(id, { resolve, reject });
|
|
5269
5375
|
try {
|
|
5270
|
-
globalThis.${
|
|
5376
|
+
globalThis.${Ap}(JSON.stringify({
|
|
5271
5377
|
id,
|
|
5272
5378
|
url: String(url),
|
|
5273
5379
|
options: {
|
|
@@ -5290,9 +5396,9 @@ function selectorFor(el) {
|
|
|
5290
5396
|
return viaNode(url, options);
|
|
5291
5397
|
}
|
|
5292
5398
|
};
|
|
5293
|
-
})();`;var
|
|
5294
|
-
`)}async function
|
|
5295
|
-
`)}async function
|
|
5399
|
+
})();`;var tb=Math.max(6e4,Number(process.env.INKLY_CAPTURE_TIMEOUT_MS)||24e4);function Ki(){return W(process.env.INKLY_CAPTURE_AGENT_HOME||W($r(),".inkly"),"capture-agent","sessions")}function Ip(t){return W(process.env.INKLY_CAPTURE_AGENT_HOME||W($r(),".inkly"),"capture-agent","captures",t)}async function Pp(t,e){await $t(e,{recursive:!0});let n=W(e,"listener.log"),r=await Hi(n,"a"),a=process.argv[1]||Zi(import.meta.url),i=W($n(a),"capture-listener.js"),o=Fi(process.execPath,[i,"--session",t],{detached:!0,stdio:["ignore",r.fd,r.fd]});return o.unref(),await r.close(),{pid:o.pid??null,logPath:n}}async function Ep(t,e){let n=Date.now();for(;Date.now()-n<e;){let r=await Rn(t).catch(()=>null);if(r?.cliListenerReadyAt)return r;await Dt(100)}return Rn(t)}function Dn(t){if(!/^[a-zA-Z0-9._:-]+$/.test(t))throw new Error(`invalid session id: ${t}`);return W(Ki(),`${t}.json`)}function Or(t){return W(Ki(),`${t}.listener.json`)}async function Rp(t,e){await Q(Or(t),`${JSON.stringify(e,null,2)}
|
|
5400
|
+
`)}async function $p(t){try{let e=await st(Or(t),"utf8");return JSON.parse(e)}catch{return null}}async function Dp(t){await Q(Dn(t.id),`${JSON.stringify(t,null,2)}
|
|
5401
|
+
`)}async function Rn(t){let e=await st(Dn(t),"utf8");return JSON.parse(e)}async function Rr(t){await lt(Dn(t),{force:!0}),await lt(Or(t),{force:!0})}async function Kt(t){let e=t.cliListenerPid??null;if(!e&&t.id&&(e=(await $p(t.id))?.cliListenerPid??null),e)try{process.kill(e,"SIGTERM")}catch{}if(!t.attached){if(t.chromePid)try{process.kill(t.chromePid,"SIGTERM")}catch{}t.keepProfile||t.profileDir&&await lt(t.profileDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{})}}async function jp(t,e,n,r){let a=qt(e,"url",r),i=qt(e,"name",r);new URL(a);let o=sp(Rt(e,"window-size")),s=o?.width??Pr(e,"width",ap),c=o?.height??Pr(e,"height",ip),d=Pr(e,"timeout",op),u=lp(e),p=Rt(e,"runtime");if(p&&p!=="cli")throw new Error("--runtime must be cli");let h=n,y=Et(e,["zoom","auto-apply-zoom"],!0),w=Et(e,["record-video","video"],!0)&&h!=="html",_=Et(e,["block-videos","block-video"],!1),O=Et(e,["compress-images","compress-image"],!1),I=Et(e,["subset-fonts","subset-font"],!1),k=Et(e,["headless"],!0)&&e.headed!==!0,P=Rt(e,"profile"),R=!u&&P?cp(t,P):null,M=R!=null&&Ce(W(R,"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 j=u?{pid:null,profileDir:null,...await mp(u),logPath:null}:await(async()=>{let T=await up(t,Rt(e,"browser"));return hp({browser:T,width:s,height:c,headless:k,timeoutMs:d,userDataDir:R})})(),V=new Er(j.wsUrl),Le=null,H=!1,dt=()=>{Kt({id:"",runtime:"cli",createdAt:"",url:a,name:i,chromePid:j.pid,profileDir:j.profileDir,keepProfile:R!=null||!!u,browserWsUrl:j.wsUrl,browserDebuggingUrl:j.debuggingUrl,chromeLogPath:j.logPath,attached:!!u,tabId:0,tabUrl:"",targetId:"",width:s,height:c,cliScreens:[],captureDir:null,cliListenerPid:Le,cliListenerLogPath:null,cliListenerReadyAt:null}).finally(()=>{process.exit(130)})};process.on("SIGINT",dt),process.on("SIGTERM",dt),H=!0;let en=()=>{H&&(process.removeListener("SIGINT",dt),process.removeListener("SIGTERM",dt),H=!1)};try{await V.send("Target.setDiscoverTargets",{discover:!0}).catch(()=>{});let T=await fp(V,a,s,c,d);await V.send("Target.activateTarget",{targetId:T.targetId}).catch(()=>{});let Te=Vu();await Tp(V,T.sessionId);let tn=Ip(Te),D={id:Te,runtime:"cli",createdAt:new Date().toISOString(),url:a,name:i,chromePid:j.pid,profileDir:j.profileDir,keepProfile:u?!0:R!=null||e["keep-profile"]===!0,browserWsUrl:j.wsUrl,browserDebuggingUrl:j.debuggingUrl,chromeLogPath:j.logPath,attached:!!u,tabId:0,tabUrl:a,targetId:T.targetId,width:s,height:c,cliScreens:[],cliCaptureKind:h,cliRecordVideo:w,cliBlockVideos:h==="html"?_:!1,cliCompressImages:h==="image"?O:!1,cliSubsetFonts:h==="image"?I:!1,autoApplyZoom:y,captureDir:tn,cliListenerPid:null,cliListenerLogPath:null,cliListenerReadyAt:null};await $t(tn,{recursive:!0}),await Dp(D);let Ae=await Pp(D.id,tn);Le=Ae.pid,await Rp(D.id,{cliListenerPid:Ae.pid,cliListenerLogPath:Ae.logPath});let N=await Ep(D.id,5e3);return await F("inkly_cli_capture_session_started",{runtime:"cli",capture_kind:N.cliCaptureKind??h,record_video:N.cliRecordVideo===!0,auto_apply_zoom:N.autoApplyZoom!==!1,window_width:N.width,window_height:N.height,headless:u?null:k,attached:N.attached,persistent_profile:R!=null,profile_reused:M,connect_to_browser:!!u}),en(),Gt({ok:!0,mode:"cli",session:{id:N.id,stateFile:Dn(N.id),createdAt:N.createdAt},browser:{pid:N.chromePid,debuggingUrl:N.browserDebuggingUrl,webSocketDebuggerUrl:N.browserWsUrl,headless:u?null:k,attached:N.attached,profile:R?{dir:R,persistent:!0,reused:M}:null},tab:{targetId:N.targetId,url:N.tabUrl},capture:{kind:N.cliCaptureKind??"image",video:N.cliRecordVideo===!0,recordVideo:N.cliRecordVideo===!0,autoApplyZoom:N.autoApplyZoom!==!1,window:{width:N.width,height:N.height},stepCount:0,automatic:!0,listenerPid:N.cliListenerPid??Ae.pid,listenerReadyAt:N.cliListenerReadyAt}}),0}catch(T){throw await Kt({id:"",runtime:"cli",createdAt:"",url:a,name:i,chromePid:j.pid,profileDir:j.profileDir,keepProfile:R!=null||!!u,browserWsUrl:j.wsUrl,browserDebuggingUrl:j.debuggingUrl,chromeLogPath:j.logPath,attached:!!u,tabId:0,tabUrl:"",targetId:"",width:s,height:c,cliScreens:[],captureDir:null,cliListenerPid:Le,cliListenerLogPath:null,cliListenerReadyAt:null}),T}finally{en(),V.close()}}async function Op(t,e){let n=qu(new Uint8Array(t)),r=En(e);await $t(r,{recursive:!0});for(let[a,i]of Object.entries(n)){let o=a.replace(/\\/g,"/");if(!o||o.endsWith("/"))continue;let s=En(r,o);if(s!==r&&!s.startsWith(r+Ju))throw new Error(`Unsafe zip entry: ${a}`);await $t($n(s),{recursive:!0}),await Wi(s,Buffer.from(i))}}async function Np(t,e,n){let r=qt(e,"session",n),a=qt(e,"out",n),i=Dr(t,a),o=await Rn(r);if((o.cliScreens?.length??0)===0)return await Kt(o),o.captureDir&&await lt(o.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Rr(o.id),await F("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}),Gt({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 c=o.cliCaptureKind==="html"?await Cp({name:o.name,screens:o.cliScreens??[]}):await Sp({name:o.name,screens:o.cliScreens??[],autoApplyZoom:o.autoApplyZoom!==!1,compressImages:o.cliCompressImages===!0,subsetFonts:o.cliSubsetFonts===!0});await $t(i,{recursive:!0});let d=Buffer.from(c.bytes),u=W(i,c.filename);await Wi(u,d);let p=null;return e["no-unpack"]!==!0&&(await Op(d,i),p=W(i,c.slug)),await Kt(o),o.captureDir&&await lt(o.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Rr(o.id),await F("inkly_cli_capture_session_stopped",{runtime:"cli",capture_kind:o.cliCaptureKind??"image",step_count:c.stepCount,output_bytes:d.byteLength,unpacked:e["no-unpack"]!==!0,record_video:o.cliRecordVideo===!0,auto_apply_zoom:o.autoApplyZoom!==!1}),Gt({ok:!0,mode:"cli",session:{id:o.id},output:{zipPath:u,demoDir:p,bytes:d.byteLength,stepCount:c.stepCount}}),0}async function Lp(t,e){let n=qt(t,"session",e),r=await Rn(n);return await Kt(r),r.captureDir&&await lt(r.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Rr(r.id),await F("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}),Gt({ok:!0,mode:"cli",session:{id:r.id}}),0}async function jn(t){let{cwd:e,subcommand:n,args:r,kind:a,usage:i}=t;switch(dp(r),await F("inkly_cli_capture_command_invoked",{capture_kind:a,subcommand:n??"(none)"}),n){case"start":return jp(e,r,a,i);case"stop":return Np(e,r,i);case"cancel":return Lp(r,i);case"profiles":return zp();default:return process.stdout.write(i),1}}async function zp(){let t=Gi(),e=await Bi(t,{withFileTypes:!0}).catch(()=>[]),n=[];for(let r of e){if(!r.isDirectory())continue;let a=W(t,r.name),i=Ce(W(a,"Default")),o=Ce(W(a,"Default","Network","Cookies"))||Ce(W(a,"Default","Cookies"));n.push({name:r.name,dir:a,initialized:i,hasCookies:o})}return await F("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}),Gt({ok:!0,profilesDir:t,profiles:n}),0}async function Yi(t){let{cwd:e,subcommand:n,args:r}=t;if(r.html===!0)throw new Error("inkly capture is image/video only. For HTML snapshot capture use `inkly capture-html`.");for(let a of["block-videos","block-video","compress-images","compress-image","subset-fonts","subset-font"])if(Object.prototype.hasOwnProperty.call(r,a))throw new Error(`--${a} only applies to HTML capture. Use \`inkly capture-html --${a}\`.`);return jn({cwd:e,subcommand:n,args:r,kind:"image",usage:Yt})}async function Xi(t){let{cwd:e,subcommand:n,args:r}=t;return jn({cwd:e,subcommand:n,args:r,kind:"html",usage:Xt})}var eo=`inkly \u2014 Inkly CLI
|
|
5296
5402
|
|
|
5297
5403
|
Usage:
|
|
5298
5404
|
inkly init <name> [--layout <layout>] Scaffold a new demo hub.
|
|
@@ -5308,13 +5414,13 @@ Usage:
|
|
|
5308
5414
|
inkly login Connect to the hosted app.
|
|
5309
5415
|
inkly status [--json] Show auth and hub status.
|
|
5310
5416
|
inkly sync [--demo <slug>] [--dry-run] Upload local capture blobs to CDN.
|
|
5311
|
-
inkly preview <demo>
|
|
5417
|
+
inkly preview <demo> Publish a standalone preview snapshot.
|
|
5312
5418
|
inkly capture <command> Capture an image/video walkthrough for an agent.
|
|
5313
5419
|
inkly capture-html <command> Capture a self-contained HTML walkthrough.
|
|
5314
5420
|
inkly help [command] Show CLI help.
|
|
5315
5421
|
|
|
5316
5422
|
Run \`inkly <command> --help\` for more.
|
|
5317
|
-
`,
|
|
5423
|
+
`,Lr=`inkly init \u2014 scaffold a new demo hub
|
|
5318
5424
|
|
|
5319
5425
|
Usage:
|
|
5320
5426
|
inkly init <name> [--layout <layout>]
|
|
@@ -5325,7 +5431,7 @@ Arguments:
|
|
|
5325
5431
|
Options:
|
|
5326
5432
|
--layout <layout> Hub index layout to write to inkly.json.
|
|
5327
5433
|
One of: sidebar, tabs.
|
|
5328
|
-
`,
|
|
5434
|
+
`,to=`inkly add \u2014 scaffold a new demo in the current hub
|
|
5329
5435
|
|
|
5330
5436
|
Usage:
|
|
5331
5437
|
inkly add <name> [--collection <name>]
|
|
@@ -5339,7 +5445,7 @@ Options:
|
|
|
5339
5445
|
--collection <name> Add the demo to this collection in inkly.json.
|
|
5340
5446
|
Creates the collection if it doesn't exist. When
|
|
5341
5447
|
omitted, the demo is not added to any collection.
|
|
5342
|
-
`,
|
|
5448
|
+
`,no=`inkly demo \u2014 alias of \`inkly add\`
|
|
5343
5449
|
|
|
5344
5450
|
Usage:
|
|
5345
5451
|
inkly demo <slug> [--collection <name>]
|
|
@@ -5351,7 +5457,7 @@ Options:
|
|
|
5351
5457
|
--collection <name> Add the demo to this collection in inkly.json.
|
|
5352
5458
|
Creates the collection if it doesn't exist. When
|
|
5353
5459
|
omitted, the demo is not added to any collection.
|
|
5354
|
-
`,
|
|
5460
|
+
`,ro=`inkly validate \u2014 validate a demo hub
|
|
5355
5461
|
|
|
5356
5462
|
Usage:
|
|
5357
5463
|
inkly validate [--json] [--strict]
|
|
@@ -5359,7 +5465,7 @@ Usage:
|
|
|
5359
5465
|
Options:
|
|
5360
5466
|
--json Print machine-readable JSON.
|
|
5361
5467
|
--strict Treat warnings as failures.
|
|
5362
|
-
`,
|
|
5468
|
+
`,ao=`inkly lock \u2014 pin the runtime via inkly.lock
|
|
5363
5469
|
|
|
5364
5470
|
Usage:
|
|
5365
5471
|
inkly lock [--json] [--local <path>]
|
|
@@ -5370,9 +5476,9 @@ Options:
|
|
|
5370
5476
|
serves for inkly.json#runtime. Exits non-zero on
|
|
5371
5477
|
drift. Safe to run in CI.
|
|
5372
5478
|
--local <path> Source the runtime manifest from a local
|
|
5373
|
-
|
|
5479
|
+
Inkly runtime build instead of the CDN. Accepts a path
|
|
5374
5480
|
to a manifest.json, a dist/ directory, or a
|
|
5375
|
-
|
|
5481
|
+
runtime package root. Useful for unpublished
|
|
5376
5482
|
versions during local development.
|
|
5377
5483
|
--json Print machine-readable JSON.
|
|
5378
5484
|
|
|
@@ -5380,12 +5486,11 @@ Environment:
|
|
|
5380
5486
|
BUNDLES_R2_PUBLIC_BASE_URL
|
|
5381
5487
|
Override the bundles bucket's public base URL
|
|
5382
5488
|
(default https://www.runtime.inklyai.dev). Useful for staging.
|
|
5383
|
-
|
|
5489
|
+
`,io=`inkly login \u2014 connect to the hosted app
|
|
5384
5490
|
|
|
5385
5491
|
Usage:
|
|
5386
5492
|
inkly login [--no-open]
|
|
5387
5493
|
inkly login --token <token>
|
|
5388
|
-
inkly logout
|
|
5389
5494
|
|
|
5390
5495
|
Connects to the Inkly app. The platform origin is fixed and cannot be
|
|
5391
5496
|
overridden on the command line.
|
|
@@ -5393,7 +5498,11 @@ overridden on the command line.
|
|
|
5393
5498
|
Options:
|
|
5394
5499
|
--no-open Print the grant URL without opening a browser.
|
|
5395
5500
|
--token <token> Automation fallback: save an existing API token.
|
|
5396
|
-
`,
|
|
5501
|
+
`,oo=`inkly logout \u2014 remove saved platform API credentials
|
|
5502
|
+
|
|
5503
|
+
Usage:
|
|
5504
|
+
inkly logout
|
|
5505
|
+
`,so=`inkly sync \u2014 upload local capture blobs to CDN
|
|
5397
5506
|
|
|
5398
5507
|
Usage:
|
|
5399
5508
|
inkly sync [--demo <slug>] [--dry-run] [--json]
|
|
@@ -5402,14 +5511,14 @@ Options:
|
|
|
5402
5511
|
--demo <slug> Sync one demo instead of every demo.
|
|
5403
5512
|
--dry-run Report pending uploads without changing files.
|
|
5404
5513
|
--json Print machine-readable JSON.
|
|
5405
|
-
`,
|
|
5514
|
+
`,Bp=`inkly preview \u2014 publish a standalone preview snapshot
|
|
5406
5515
|
|
|
5407
5516
|
Usage:
|
|
5408
|
-
inkly preview <demo-path> [--
|
|
5517
|
+
inkly preview <demo-path> [--json]
|
|
5409
5518
|
|
|
5410
5519
|
Freezes one local demo and hosts it at a standalone /p/<id> URL, separate
|
|
5411
|
-
from the demo hub.
|
|
5412
|
-
|
|
5520
|
+
from the demo hub. Missing binary assets are uploaded to the CDN for the
|
|
5521
|
+
preview snapshot without changing local files.
|
|
5413
5522
|
|
|
5414
5523
|
Arguments:
|
|
5415
5524
|
<demo-path> Path to the demo folder (e.g. demos/intro). Omit when the
|
|
@@ -5417,10 +5526,8 @@ Arguments:
|
|
|
5417
5526
|
|
|
5418
5527
|
Options:
|
|
5419
5528
|
--demo <slug> Select the demo by slug instead of by path.
|
|
5420
|
-
--yes, -y Upload any unsynced assets without prompting.
|
|
5421
|
-
--skip-sync Fail instead of uploading when assets are missing.
|
|
5422
5529
|
--json Print machine-readable JSON.
|
|
5423
|
-
`,
|
|
5530
|
+
`,lo=`inkly dev \u2014 start the local preview server
|
|
5424
5531
|
|
|
5425
5532
|
Usage:
|
|
5426
5533
|
inkly dev [--port <n>]
|
|
@@ -5428,33 +5535,33 @@ Usage:
|
|
|
5428
5535
|
Options:
|
|
5429
5536
|
--port <n> Preferred port. Defaults to 3000; if taken, the CLI
|
|
5430
5537
|
tries the next available port. Must be 1-65535.
|
|
5431
|
-
`,
|
|
5538
|
+
`,co=`inkly update \u2014 update the globally installed CLI
|
|
5432
5539
|
|
|
5433
5540
|
Usage:
|
|
5434
5541
|
inkly update [--dry-run]
|
|
5435
5542
|
|
|
5436
5543
|
Options:
|
|
5437
5544
|
--dry-run Print the update command without running it.
|
|
5438
|
-
`,
|
|
5545
|
+
`,uo=`inkly doctor \u2014 run local diagnostics
|
|
5439
5546
|
|
|
5440
5547
|
Usage:
|
|
5441
5548
|
inkly doctor [--json]
|
|
5442
5549
|
|
|
5443
5550
|
Options:
|
|
5444
5551
|
--json Print machine-readable JSON.
|
|
5445
|
-
`,
|
|
5552
|
+
`,po=`inkly status \u2014 show local CLI status
|
|
5446
5553
|
|
|
5447
5554
|
Usage:
|
|
5448
5555
|
inkly status [--json]
|
|
5449
5556
|
|
|
5450
5557
|
Options:
|
|
5451
5558
|
--json Print machine-readable JSON.
|
|
5452
|
-
`,
|
|
5559
|
+
`,ho=`inkly version \u2014 print the CLI version
|
|
5453
5560
|
|
|
5454
5561
|
Usage:
|
|
5455
5562
|
inkly version
|
|
5456
5563
|
inkly --version
|
|
5457
|
-
`,
|
|
5564
|
+
`,zr=`inkly help \u2014 show command help
|
|
5458
5565
|
|
|
5459
5566
|
Usage:
|
|
5460
5567
|
inkly help [command]
|
|
@@ -5477,25 +5584,25 @@ Commands:
|
|
|
5477
5584
|
capture Capture an image/video walkthrough for an agent.
|
|
5478
5585
|
capture-html
|
|
5479
5586
|
Capture a self-contained HTML walkthrough for an agent.
|
|
5480
|
-
`,
|
|
5481
|
-
|
|
5482
|
-
${
|
|
5483
|
-
|
|
5484
|
-
`+
|
|
5485
|
-
`),await F("inkly_cli_failed",{command:"init"}),await
|
|
5486
|
-
|
|
5487
|
-
`+i),1;let
|
|
5488
|
-
`),await F("inkly_cli_failed",{command:n}),await
|
|
5489
|
-
`),await F("inkly_cli_failed",{command:"lock"}),await
|
|
5490
|
-
`),await F("inkly_cli_failed",{command:"update"}),await
|
|
5491
|
-
`),await F("inkly_cli_failed",{command:"login"}),await
|
|
5492
|
-
`),await F("inkly_cli_failed",{command:"sync"}),await
|
|
5493
|
-
`),await F("inkly_cli_failed",{command:"preview"}),await
|
|
5494
|
-
`),await F("inkly_cli_failed",{command:"capture",subcommand:
|
|
5495
|
-
`),await F("inkly_cli_failed",{command:"capture-html",subcommand:
|
|
5496
|
-
`),1;try{let
|
|
5497
|
-
`),F("inkly_cli_failed",{command:"dev.shutdown"}),
|
|
5498
|
-
`),await F("inkly_cli_failed",{command:"dev"}),await
|
|
5499
|
-
|
|
5500
|
-
${
|
|
5501
|
-
`),await F("inkly_cli_failed",{command:"main"}),await
|
|
5587
|
+
`,Wp={add:to,demo:no,dev:lo,doctor:uo,capture:Yt,"capture-html":Xt,help:zr,init:Lr,lock:ao,login:io,logout:oo,status:po,sync:so,update:co,validate:ro,version:ho};function Vp(t,e){let n=Fp(t)?t:Hp(e,t);if(Nr(n))try{if(Up(n).isFile())return n;let a=Qi(n,"manifest.json");if(Nr(a))return a;let i=Qi(n,"dist","manifest.json");if(Nr(i))return i}catch{}return n}function Qt(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))return;let n=t[e];return typeof n=="string"?n:""}function Zp(t){let e=new Set(["_","api-base","token","url","name","out","session"]);return Object.keys(t).filter(n=>!e.has(n)).filter(n=>t[n]!==!1&&t[n]!==void 0).sort()}async function Jp(t){let e=Mp(t,{alias:{h:"help",p:"port",v:"version"},boolean:["auto-apply-zoom","block-videos","check","compress-images","dry-run","headed","headless","html","help","json","keep-profile","no-open","no-unpack","record-video","strict","subset-fonts","version","video","zoom"],string:["browser","collection","connect-to-browser","demo","height","layout","local","name","out","port","profile","runtime","session","timeout","token","url","width","window-size"]}),[n,...r]=e._,a=n??(e.version?"version":e.help?"help":"(none)");if(await F("inkly_cli_invoked",{command:a,subcommand:typeof r[0]=="string"?r[0]:void 0,option_keys:Zp(e),json:!!e.json,help:!!e.help}),e.version&&!n)return await dr(),0;if(!n||e.help&&!n)return process.stdout.write(eo),e.help?0:1;switch(n){case"help":{let i=r[0];if(!i)return process.stdout.write(zr),0;let o=Wp[i];return o?(process.stdout.write(o),0):(process.stderr.write(`inkly help: unknown command "${i}"
|
|
5588
|
+
|
|
5589
|
+
${zr}`),1)}case"init":{if(e.help)return process.stdout.write(Lr),0;let i=r[0];if(!i)return process.stderr.write(`inkly init: missing <name> argument
|
|
5590
|
+
|
|
5591
|
+
`+Lr),1;let o=Qt(e,"layout");try{return await Ma({name:i,cwd:process.cwd(),layout:o}),0}catch(s){return process.stderr.write(`inkly init failed: ${s.message}
|
|
5592
|
+
`),await F("inkly_cli_failed",{command:"init"}),await ne("init",s),1}}case"add":case"demo":{let i=n==="add"?to:no;if(e.help)return process.stdout.write(i),0;let o=r[0];if(!o)return process.stderr.write(`inkly ${n}: missing <name> argument
|
|
5593
|
+
|
|
5594
|
+
`+i),1;let s=typeof e.collection=="string"&&e.collection.length>0?e.collection:void 0;try{return await Xa({slug:o,cwd:process.cwd(),collection:s}),0}catch(c){return process.stderr.write(`inkly ${n} failed: ${c.message}
|
|
5595
|
+
`),await F("inkly_cli_failed",{command:n}),await ne(n,c),1}}case"validate":return e.help?(process.stdout.write(ro),0):(await vn({cwd:process.cwd(),json:!!e.json,strict:!!e.strict})).ok?0:1;case"lock":{if(e.help)return process.stdout.write(ao),0;try{let i=Qt(e,"local");return(await Ti({cwd:process.cwd(),check:!!e.check,json:!!e.json,manifestPath:i?Vp(i,process.cwd()):void 0})).ok?0:1}catch(i){return process.stderr.write(`inkly lock failed: ${i.message}
|
|
5596
|
+
`),await F("inkly_cli_failed",{command:"lock"}),await ne("lock",i),1}}case"version":return e.help?(process.stdout.write(ho),0):(await dr(),0);case"update":{if(e.help)return process.stdout.write(co),0;try{return await ei({dryRun:!!e["dry-run"]}),0}catch(i){return process.stderr.write(`inkly update failed: ${i.message}
|
|
5597
|
+
`),await F("inkly_cli_failed",{command:"update"}),await ne("update",i),1}}case"doctor":return e.help?(process.stdout.write(uo),0):(await ai({cwd:process.cwd(),json:!!e.json})).ok?0:1;case"login":{if(e.help)return process.stdout.write(io),0;try{return await ci({cwd:process.cwd(),local:process.env.INKLY_LOCAL==="1",token:Qt(e,"token"),open:!e["no-open"]}),0}catch(i){return process.stderr.write(`inkly login failed: ${i.message}
|
|
5598
|
+
`),await F("inkly_cli_failed",{command:"login"}),await ne("login",i),1}}case"logout":return e.help?(process.stdout.write(oo),0):(await ui(),0);case"status":return e.help?(process.stdout.write(po),0):(await pi({cwd:process.cwd(),json:!!e.json})).loggedIn?0:1;case"sync":{if(e.help)return process.stdout.write(so),0;try{return await An({cwd:process.cwd(),demo:Qt(e,"demo"),dryRun:!!e["dry-run"],json:!!e.json}),0}catch(i){return process.stderr.write(`inkly sync failed: ${i.message}
|
|
5599
|
+
`),await F("inkly_cli_failed",{command:"sync"}),await ne("sync",i),1}}case"preview":{if(e.help)return process.stdout.write(Bp),0;try{return await vi({cwd:process.cwd(),path:r[0],demo:Qt(e,"demo"),json:!!e.json}),0}catch(i){return process.stderr.write(`inkly preview failed: ${i.message}
|
|
5600
|
+
`),await F("inkly_cli_failed",{command:"preview"}),await ne("preview",i),1}}case"capture":{if(e.help)return process.stdout.write(Yt),0;try{return await Yi({cwd:process.cwd(),subcommand:r[0],args:e})}catch(i){return process.stderr.write(`inkly capture failed: ${i.message}
|
|
5601
|
+
`),await F("inkly_cli_failed",{command:"capture",subcommand:r[0]}),await ne("capture",i),1}}case"capture-html":{if(e.help)return process.stdout.write(Xt),0;try{return await Xi({cwd:process.cwd(),subcommand:r[0],args:e})}catch(i){return process.stderr.write(`inkly capture-html failed: ${i.message}
|
|
5602
|
+
`),await F("inkly_cli_failed",{command:"capture-html",subcommand:r[0]}),await ne("capture-html",i),1}}case"dev":{if(e.help)return process.stdout.write(lo),0;let i=e.port,o=typeof i=="number"?i:typeof i=="string"?Number(i):3e3;if(!Number.isInteger(o)||o<1||o>65535)return process.stderr.write(`inkly dev: invalid --port value; expected an integer from 1 to 65535
|
|
5603
|
+
`),1;try{let s=await qa({cwd:process.cwd(),port:o});return await new Promise(c=>{let d=()=>{s.close().catch(u=>{process.stderr.write(`inkly dev: error during shutdown: ${u.message}
|
|
5604
|
+
`),F("inkly_cli_failed",{command:"dev.shutdown"}),ne("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}
|
|
5605
|
+
`),await F("inkly_cli_failed",{command:"dev"}),await ne("dev",s),1}}default:return process.stderr.write(`inkly: unknown command "${n}"
|
|
5606
|
+
|
|
5607
|
+
${eo}`),1}}Ai();Jp(process.argv.slice(2)).then(async t=>{await F("inkly_cli_exited",{command:process.argv[2]??"(none)",exit_code:t}),await gr(),await Ii(),process.exit(t)},async t=>{process.stderr.write(`inkly: ${t.message}
|
|
5608
|
+
`),await F("inkly_cli_failed",{command:"main"}),await ne("main",t),await gr(),process.exit(1)});
|