velloo 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +1 -1
  2. package/canvas/assets/index-DZFrkC4P.js +29 -0
  3. package/canvas/assets/index-gB0StCrx.css +2 -0
  4. package/canvas/assets/lucide-all-Bu8-9UDF.js +1 -0
  5. package/canvas/assets/{radix-C3HaOB-d.js → radix-gmpYzWRH.js} +1 -1
  6. package/canvas/index.html +3 -3
  7. package/chunk-0s6drs3n.js +2 -0
  8. package/chunk-0zen7bzb.js +3 -0
  9. package/{chunk-er1fxb7d.js → chunk-1xb88e07.js} +1 -1
  10. package/{chunk-jv0xggh0.js → chunk-2e3nd4tz.js} +1 -1
  11. package/{chunk-08sv3k41.js → chunk-2fgfex9b.js} +1 -1
  12. package/{chunk-a84n72m2.js → chunk-2p37rp3j.js} +1 -1
  13. package/{chunk-ydhwv29b.js → chunk-2zbn6641.js} +2 -2
  14. package/{chunk-6w6ch4ce.js → chunk-3px2d1j1.js} +1 -1
  15. package/{chunk-2c7jbx46.js → chunk-4e9jh482.js} +1 -1
  16. package/{chunk-dgwjpbp9.js → chunk-4g250157.js} +1 -1
  17. package/{chunk-sjgqnykd.js → chunk-4ma2wnqw.js} +1 -1
  18. package/{chunk-x4f4k9pp.js → chunk-59zas5y2.js} +7 -7
  19. package/{chunk-0fe83yzt.js → chunk-5wv5a52y.js} +1 -1
  20. package/{chunk-bwnvcncx.js → chunk-6zz9kfbd.js} +1 -1
  21. package/{chunk-mh2pr7cq.js → chunk-7cvhnp9h.js} +1 -1
  22. package/{chunk-1h55s5he.js → chunk-7s8frnag.js} +1 -1
  23. package/chunk-7t13w87m.js +2 -0
  24. package/{chunk-zb6hc1y0.js → chunk-7yaafw73.js} +1 -1
  25. package/chunk-88eqqdk1.js +688 -0
  26. package/{chunk-ampmdzz4.js → chunk-8z3ykvcs.js} +1 -1
  27. package/{chunk-r22epxz2.js → chunk-98vvrj0c.js} +1 -1
  28. package/{chunk-vdkrbzh1.js → chunk-9cdwhrkh.js} +1 -1
  29. package/{chunk-xt5ayg7g.js → chunk-9p1dk5cb.js} +1 -1
  30. package/{chunk-dg6z4vdd.js → chunk-9psr8atb.js} +1 -1
  31. package/{chunk-4fj5tahv.js → chunk-9ydc34wc.js} +1 -1
  32. package/{chunk-pp86v6m6.js → chunk-as08hzp3.js} +1 -1
  33. package/chunk-asbajsmd.js +5 -0
  34. package/{chunk-vgmr98cv.js → chunk-avkfsc3p.js} +1 -1
  35. package/{chunk-ngnymg2q.js → chunk-bhx8k09w.js} +1 -1
  36. package/{chunk-3e8vez4d.js → chunk-c4fym47a.js} +63 -19
  37. package/{chunk-jb21jkp1.js → chunk-c6hywdvq.js} +1 -1
  38. package/{chunk-rpwpeph5.js → chunk-f0vsjfpc.js} +1 -1
  39. package/{chunk-ek71z2fv.js → chunk-g71v35gd.js} +1 -1
  40. package/{chunk-80r93t2e.js → chunk-hfzg98c8.js} +1 -1
  41. package/{chunk-jfx9xjmr.js → chunk-js6mz7h1.js} +1 -1
  42. package/{chunk-4dn75m6t.js → chunk-mfbxfb9b.js} +1 -1
  43. package/{chunk-mnapdp1y.js → chunk-mt8ds8zj.js} +1 -1
  44. package/chunk-n9t36h0q.js +2 -0
  45. package/{chunk-fsbsksga.js → chunk-nev5mv85.js} +1 -1
  46. package/{chunk-40xgcth8.js → chunk-nte0t7v3.js} +2 -2
  47. package/{chunk-hcb68zt7.js → chunk-p62fygqz.js} +1 -1
  48. package/{chunk-ayrb3qnm.js → chunk-p6e1eg76.js} +1 -1
  49. package/{chunk-7eq7nx37.js → chunk-ph2jfg1x.js} +1 -1
  50. package/{chunk-n9gs6yx9.js → chunk-pve2mmnr.js} +1 -1
  51. package/{chunk-avns4dbf.js → chunk-sn9vg42q.js} +1 -1
  52. package/{chunk-dy41n60j.js → chunk-t2w8a591.js} +5 -5
  53. package/{chunk-735ezz23.js → chunk-t5m5mznb.js} +2 -2
  54. package/{chunk-6nqghjda.js → chunk-t947mxr1.js} +1 -1
  55. package/chunk-tt7fys2w.js +2 -0
  56. package/chunk-wafb2xm9.js +6 -0
  57. package/{chunk-sn3x2m0m.js → chunk-whw3epmr.js} +1 -1
  58. package/{chunk-j11fyeqh.js → chunk-wndntr7s.js} +1 -1
  59. package/{chunk-7eyb8yrf.js → chunk-wnwgqvtd.js} +1 -1
  60. package/{chunk-v40fn08f.js → chunk-wp123630.js} +2 -2
  61. package/{chunk-ccszg02q.js → chunk-wvs939t5.js} +1 -1
  62. package/{chunk-jr0ss0mm.js → chunk-z21hg6j3.js} +2 -2
  63. package/cli.js +1 -1
  64. package/package.json +1 -1
  65. package/pkgs/helpers/src/descriptors.ts +7 -1
  66. package/pkgs/provider-antd/src/index.ts +1 -0
  67. package/pkgs/provider-chakra/src/index.ts +1 -0
  68. package/pkgs/provider-mui/src/index.ts +1 -0
  69. package/pkgs/provider-none/src/index.ts +42 -1
  70. package/pkgs/provider-none/src/intro.ts +2 -2
  71. package/pkgs/schema/src/config.ts +19 -0
  72. package/pkgs/schema/src/extension.ts +26 -0
  73. package/pkgs/schema/src/index.ts +10 -0
  74. package/pkgs/schema/src/node.ts +99 -0
  75. package/pkgs/schema/src/screen.ts +7 -0
  76. package/pkgs/shadcn-snapshot/dist/manifest.json +9 -1
  77. package/skills/velloo-setup/SKILL.md +70 -48
  78. package/canvas/assets/index-BCvDZiBo.css +0 -2
  79. package/canvas/assets/index-ClaBqcaS.js +0 -28
  80. package/canvas/assets/lucide-all-iIF-pmzN.js +0 -1
  81. package/chunk-308ynsxd.js +0 -2
  82. package/chunk-9vg3yafz.js +0 -3
  83. package/chunk-eyr8hrzf.js +0 -2
  84. package/chunk-k17gfwq3.js +0 -2
  85. package/chunk-rgasy862.js +0 -5
  86. package/chunk-t448rrfr.js +0 -2
  87. package/chunk-tdsk5wxa.js +0 -451
  88. package/chunk-vsv8z729.js +0 -6
@@ -51,7 +51,7 @@ ${content.join(`
51
51
 
52
52
  `)}return doc.write("payload.value = newResult;"),doc.write("return payload;"),doc.compile()},fastpass,isObject2=isObject,jit=!globalConfig.jitless,fastEnabled=jit&&allowsEval.value,catchall=def.catchall,value;inst._zod.parse=(payload,ctx)=>{value??(value=_normalized.value);let input=payload.value;if(!isObject2(input))return payload.issues.push({expected:"object",code:"invalid_type",input,inst}),payload;if(jit&&fastEnabled&&ctx?.async===!1&&ctx.jitless!==!0){if(!fastpass)fastpass=generateFastpass(def.shape);if(payload=fastpass(payload,ctx),!catchall)return payload;return handleCatchall([],input,payload,ctx,value,inst)}return superParse(payload,ctx)}});function handleUnionResults(results,final,inst,ctx){for(let result of results)if(result.issues.length===0)return final.value=result.value,final;let nonaborted=results.filter((r)=>!aborted(r));if(nonaborted.length===1)return final.value=nonaborted[0].value,nonaborted[0];return final.issues.push({code:"invalid_union",input:final.value,inst,errors:results.map((result)=>result.issues.map((iss)=>finalizeIssue(iss,ctx,config())))}),final}var $ZodUnion=$constructor("$ZodUnion",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"optin",(zod)=>zod.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":zod.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),defineLazyInternal(inst,"optout",(zod)=>zod.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),defineLazyInternal(inst,"values",(zod)=>{if(zod.def.options.every((o)=>o._zod.values))return new Set(zod.def.options.flatMap((option)=>Array.from(option._zod.values)));return}),defineLazyInternal(inst,"pattern",(zod)=>{if(zod.def.options.every((o)=>o._zod.pattern)){let patterns=zod.def.options.map((o)=>o._zod.pattern);return new RegExp(`^(${patterns.map((p)=>cleanRegex(p.source)).join("|")})$`)}return});let first=def.options.length===1?def.options[0]._zod.run:null;inst._zod.parse=(payload,ctx)=>{if(first)return first(payload,ctx);let async=!1,results=[];for(let option of def.options){let result=option._zod.run({value:payload.value,issues:[]},ctx);if(result instanceof Promise)results.push(result),async=!0;else{if(result.issues.length===0)return result;results.push(result)}}if(!async)return handleUnionResults(results,payload,inst,ctx);return Promise.all(results).then((results)=>handleUnionResults(results,payload,inst,ctx))}});var $ZodDiscriminatedUnion=$constructor("$ZodDiscriminatedUnion",(inst,def)=>{def.inclusive=!1,$ZodUnion.init(inst,def);let _super=inst._zod.parse;defineLazyInternal(inst,"propValues",(zod)=>{let propValues={};for(let option of zod.def.options){let pv=option._zod.propValues;if(!pv||Object.keys(pv).length===0)throw Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);for(let[k,v]of Object.entries(pv)){if(!Object.prototype.hasOwnProperty.call(propValues,k))assignProp(propValues,k,new Set);for(let val of v)propValues[k].add(val)}}return propValues}),def.options.forEach((option,i)=>{let propShape=propShapes.get(option._zod.def);if(propShape&&!Object.prototype.hasOwnProperty.call(propShape,def.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let disc=cached(()=>{let opts=def.options,map=new Map;for(let o of opts){let values=o._zod.propValues?.[def.discriminator];if(!values||values.size===0)throw Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);for(let v of values){if(map.has(v))throw Error(`Duplicate discriminator value "${String(v)}"`);map.set(v,o)}}return map});inst._zod.parse=(payload,ctx)=>{let input=payload.value;if(!isObject(input))return payload.issues.push({code:"invalid_type",expected:"object",input,inst}),payload;let opt=disc.value.get(input?.[def.discriminator]);if(opt)return opt._zod.run(payload,ctx);if(def.unionFallback||ctx.direction==="backward")return _super(payload,ctx);return payload.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:def.discriminator,options:Array.from(disc.value.keys()),input,path:[def.discriminator],inst}),payload}}),$ZodIntersection=$constructor("$ZodIntersection",(inst,def)=>{$ZodType.init(inst,def),inst._zod.parse=(payload,ctx)=>{let input=payload.value,left=def.left._zod.run({value:input,issues:[]},ctx),right=def.right._zod.run({value:input,issues:[]},ctx);if(left instanceof Promise||right instanceof Promise)return Promise.all([left,right]).then(([left,right])=>handleIntersectionResults(payload,left,right));return handleIntersectionResults(payload,left,right)}});function mergeValues(a,b){if(a===b)return{valid:!0,data:a};if(a instanceof Date&&b instanceof Date&&+a===+b)return{valid:!0,data:a};if(isPlainObject(a)&&isPlainObject(b)){let bKeys=Object.keys(b),sharedKeys=Object.keys(a).filter((key)=>bKeys.indexOf(key)!==-1),newObj={...a,...b};if(Object.prototype.hasOwnProperty.call(newObj,"__proto__"))delete newObj.__proto__;for(let key of sharedKeys){if(key==="__proto__")continue;let sharedValue=mergeValues(a[key],b[key]);if(!sharedValue.valid)return{valid:!1,mergeErrorPath:[key,...sharedValue.mergeErrorPath]};newObj[key]=sharedValue.data}return{valid:!0,data:newObj}}if(Array.isArray(a)&&Array.isArray(b)){if(a.length!==b.length)return{valid:!1,mergeErrorPath:[]};let newArray=[];for(let index=0;index<a.length;index++){let itemA=a[index],itemB=b[index],sharedValue=mergeValues(itemA,itemB);if(!sharedValue.valid)return{valid:!1,mergeErrorPath:[index,...sharedValue.mergeErrorPath]};newArray.push(sharedValue.data)}return{valid:!0,data:newArray}}return{valid:!1,mergeErrorPath:[]}}function handleIntersectionResults(result,left,right){let unrecKeys=new Map,unrecIssue,keyIssues=new Map,collect=(iss,side)=>{let keys;if(iss.code==="unrecognized_keys"&&!iss.path?.length)unrecIssue??(unrecIssue=iss),keys=iss.keys;else if(iss.code==="invalid_key"&&iss.origin==="record"&&iss.path?.length===1){let k=String(iss.path[0]);if(!keyIssues.has(k))keyIssues.set(k,iss);keys=[k]}else return!1;for(let k of keys){if(!unrecKeys.has(k))unrecKeys.set(k,{});unrecKeys.get(k)[side]=!0}return!0};for(let iss of left.issues)if(!collect(iss,"l"))result.issues.push(iss);for(let iss of right.issues)if(!collect(iss,"r"))result.issues.push(iss);let bothKeys=[...unrecKeys].filter(([,f])=>f.l&&f.r).map(([k])=>k);if(bothKeys.length){let aggregated=unrecIssue?bothKeys.filter((k)=>unrecIssue.keys.includes(k)):[];if(aggregated.length)result.issues.push({...unrecIssue,keys:aggregated});for(let k of bothKeys)if(!aggregated.includes(k)&&keyIssues.has(k))result.issues.push(keyIssues.get(k))}let merged=mergeValues(left.value,right.value);if(!merged.valid){if(aborted(result))return result;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`)}return result.value=merged.data,result}var $ZodRecord=$constructor("$ZodRecord",(inst,def)=>{$ZodType.init(inst,def);let memo=globalConfig.memoizer;memo?.attach(inst),inst._zod.parse=(payload,ctx)=>{let input=payload.value;if(!isPlainObject(input))return payload.issues.push({expected:"record",code:"invalid_type",input,inst}),payload;let proms=[],values=def.keyType._zod.values;if(values&&!def.partial){payload.value=memo?memo.alloc(inst,payload,{},ctx):{};let recordKeys=new Set;for(let key of values)if(typeof key==="string"||typeof key==="number"||typeof key==="symbol"){if(recordKeys.add(typeof key==="number"?key.toString():key),key==="__proto__")continue;let keyResult=def.keyType._zod.run({value:key,issues:[]},ctx);if(keyResult instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(keyResult.issues.length){payload.issues.push({code:"invalid_key",origin:"record",issues:keyResult.issues.map((iss)=>finalizeIssue(iss,ctx,config())),input:key,path:[key],inst});continue}let outKey=keyResult.value;if(outKey==="__proto__")continue;let result=def.valueType._zod.run({value:input[key],issues:[]},ctx);if(result instanceof Promise)proms.push(result.then((result)=>{if(result.issues.length)payload.issues.push(...prefixIssues(key,result.issues));payload.value[outKey]=result.value}));else{if(result.issues.length)payload.issues.push(...prefixIssues(key,result.issues));payload.value[outKey]=result.value}}let unrecognized;for(let key in input)if(!recordKeys.has(key))if(def.mode==="loose"){if(key==="__proto__")continue;payload.value[key]=input[key]}else unrecognized=unrecognized??[],unrecognized.push(key);if(unrecognized&&unrecognized.length>0)payload.issues.push({code:"unrecognized_keys",input,inst,keys:unrecognized,continue:!0})}else{payload.value=memo?memo.alloc(inst,payload,{},ctx):{};let unrecognized;for(let key of Reflect.ownKeys(input)){if(key==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(input,key))continue;let keyResult=def.keyType._zod.run({value:key,issues:[]},ctx);if(keyResult instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof key==="string"&&number2.test(key)&&keyResult.issues.length){let retryResult=def.keyType._zod.run({value:Number(key),issues:[]},ctx);if(retryResult instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(retryResult.issues.length===0)keyResult=retryResult}if(keyResult.issues.length){if(def.mode==="loose")payload.value[key]=input[key];else if(values)unrecognized=unrecognized??[],unrecognized.push(key);else payload.issues.push({code:"invalid_key",origin:"record",issues:keyResult.issues.map((iss)=>finalizeIssue(iss,ctx,config())),input:key,path:[key],inst});continue}let outKey=keyResult.value;if(outKey==="__proto__")continue;let result=def.valueType._zod.run({value:input[key],issues:[]},ctx);if(result instanceof Promise)proms.push(result.then((result)=>{if(result.issues.length)payload.issues.push(...prefixIssues(key,result.issues));payload.value[outKey]=result.value}));else{if(result.issues.length)payload.issues.push(...prefixIssues(key,result.issues));payload.value[outKey]=result.value}}if(unrecognized&&unrecognized.length>0)payload.issues.push({code:"unrecognized_keys",input,inst,keys:unrecognized,continue:!0})}if(proms.length)return Promise.all(proms).then(()=>payload);return payload}});var $ZodEnum=$constructor("$ZodEnum",(inst,def)=>{$ZodType.init(inst,def);let values=getEnumValues(def.entries),valuesSet=new Set(values);inst._zod.values=valuesSet;let patternValues=values.filter((k)=>propertyKeyTypes.has(typeof k));inst._zod.pattern=new RegExp(patternValues.length?`^(${patternValues.map((o)=>escapeRegex(o.toString())).join("|")})$`:"^[^\\s\\S]$"),inst._zod.parse=(payload,_ctx)=>{let input=payload.value;if(valuesSet.has(input))return payload;return payload.issues.push({code:"invalid_value",values,input,inst}),payload}}),$ZodLiteral=$constructor("$ZodLiteral",(inst,def)=>{$ZodType.init(inst,def);let values=new Set(def.values);inst._zod.values=values,inst._zod.pattern=new RegExp(def.values.length?`^(${def.values.map((o)=>typeof o==="string"?escapeRegex(o):o?escapeRegex(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$"),inst._zod.parse=(payload,_ctx)=>{let input=payload.value;if(values.has(input))return payload;return payload.issues.push({code:"invalid_value",values:def.values,input,inst}),payload}});var $ZodTransform=$constructor("$ZodTransform",(inst,def)=>{$ZodType.init(inst,def),inst._zod.optin="optional",globalConfig.memoizer?.guard(inst),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")throw new $ZodEncodeError(inst.constructor.name);let _out=def.transform(payload.value,payload);if(ctx.async)return(_out instanceof Promise?_out:Promise.resolve(_out)).then((output)=>(payload.value=output,payload));if(_out instanceof Promise)throw new $ZodAsyncError;return payload.value=_out,payload}});function handleOptionalResult(payload,result){return payload.value=result.issues.length?void 0:result.value,payload}var $ZodOptional=$constructor("$ZodOptional",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"optin",(zod)=>zod.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),inst._zod.optout="optional",defineLazyInternal(inst,"values",(zod)=>{let values=zod.def.innerType._zod.values;return values?new Set([...values,void 0]):void 0}),defineLazyInternal(inst,"pattern",(zod)=>{let pattern=zod.def.innerType._zod.pattern;return pattern?new RegExp(`^(${cleanRegex(pattern.source)})?$`):void 0}),inst._zod.parse=(payload,ctx)=>{if(payload.value===void 0){if(def.innerType._zod.optin!=="defaulted")return payload;let result=def.innerType._zod.run({value:payload.value,issues:[]},ctx);if(result instanceof Promise)return result.then((result)=>handleOptionalResult(payload,result));return handleOptionalResult(payload,result)}return def.innerType._zod.run(payload,ctx)}}),$ZodExactOptional=$constructor("$ZodExactOptional",(inst,def)=>{$ZodOptional.init(inst,def),defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),defineLazyInternal(inst,"pattern",(zod)=>zod.def.innerType._zod.pattern),inst._zod.parse=(payload,ctx)=>def.innerType._zod.run(payload,ctx)}),$ZodNullable=$constructor("$ZodNullable",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"optin",(zod)=>zod.def.innerType._zod.optin),defineLazyInternal(inst,"optout",(zod)=>zod.def.innerType._zod.optout),defineLazyInternal(inst,"pattern",(zod)=>{let pattern=zod.def.innerType._zod.pattern;return pattern?new RegExp(`^(${cleanRegex(pattern.source)}|null)$`):void 0}),defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values?new Set([...zod.def.innerType._zod.values,null]):void 0),inst._zod.parse=(payload,ctx)=>{if(payload.value===null)return payload;return def.innerType._zod.run(payload,ctx)}}),$ZodDefault=$constructor("$ZodDefault",(inst,def)=>{$ZodType.init(inst,def),inst._zod.optin="defaulted",defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")return def.innerType._zod.run(payload,ctx);if(payload.value===void 0)return payload.value=def.defaultValue,payload;let result=def.innerType._zod.run(payload,ctx);if(result instanceof Promise)return result.then((result)=>handleDefaultResult(result,def));return handleDefaultResult(result,def)}});function handleDefaultResult(payload,def){if(payload.value===void 0)payload.value=def.defaultValue;return payload}var $ZodPrefault=$constructor("$ZodPrefault",(inst,def)=>{$ZodType.init(inst,def),inst._zod.optin="defaulted",defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")return def.innerType._zod.run(payload,ctx);if(payload.value===void 0)payload.value=def.defaultValue;return def.innerType._zod.run(payload,ctx)}}),$ZodNonOptional=$constructor("$ZodNonOptional",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"values",(zod)=>{let v=zod.def.innerType._zod.values;return v?new Set([...v].filter((x)=>x!==void 0)):void 0}),inst._zod.parse=(payload,ctx)=>{let result=def.innerType._zod.run(payload,ctx);if(result instanceof Promise)return result.then((result)=>handleNonOptionalResult(result,inst));return handleNonOptionalResult(result,inst)}});function handleNonOptionalResult(payload,inst){if(!payload.issues.length&&payload.value===void 0)payload.issues.push({code:"invalid_type",expected:"nonoptional",input:payload.value,inst});return payload}function handleCatchResult(payload,result,def,ctx){if(!result.issues.length){if(payload.value=result.value,result.memo)payload.memo=!0;return payload}return payload.value=def.catchValue({...result,value:payload.value,error:{issues:result.issues.map((iss)=>finalizeIssue(iss,ctx,config()))},input:payload.value}),payload}var $ZodCatch=$constructor("$ZodCatch",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"optin",(zod)=>zod.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),defineLazyInternal(inst,"optout",(zod)=>zod.def.innerType._zod.optout),defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")return def.innerType._zod.run(payload,ctx);let result=def.innerType._zod.run({value:payload.value,issues:[]},ctx);if(result instanceof Promise)return result.then((result)=>handleCatchResult(payload,result,def,ctx));return handleCatchResult(payload,result,def,ctx)}});var $ZodPipe=$constructor("$ZodPipe",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"values",(zod)=>zod.def.in._zod.values),defineLazyInternal(inst,"optin",(zod)=>zod.def.in._zod.optin),defineLazyInternal(inst,"optout",(zod)=>zod.def.out._zod.optout),defineLazyInternal(inst,"propValues",(zod)=>zod.def.in._zod.propValues),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward"){let right=def.out._zod.run(payload,ctx);if(right instanceof Promise)return right.then((right)=>handlePipeResult(right,def.in,ctx));return handlePipeResult(right,def.in,ctx)}let left=def.in._zod.run(payload,ctx);if(left instanceof Promise)return left.then((left)=>handlePipeResult(left,def.out,ctx));return handlePipeResult(left,def.out,ctx)}});function handlePipeResult(left,next,ctx){if(left.issues.some((iss)=>iss.code!=="unrecognized_keys"))return left.aborted=!0,left;return next._zod.run({value:left.value,issues:left.issues},ctx)}var $ZodPreprocess=$constructor("$ZodPreprocess",(inst,def)=>{$ZodPipe.init(inst,def)}),$ZodReadonly=$constructor("$ZodReadonly",(inst,def)=>{$ZodType.init(inst,def),defineLazyInternal(inst,"propValues",(zod)=>zod.def.innerType._zod.propValues),defineLazyInternal(inst,"values",(zod)=>zod.def.innerType._zod.values),defineLazyInternal(inst,"optin",(zod)=>zod.def.innerType?._zod?.optin),defineLazyInternal(inst,"optout",(zod)=>zod.def.innerType?._zod?.optout),inst._zod.parse=(payload,ctx)=>{if(ctx.direction==="backward")return def.innerType._zod.run(payload,ctx);let result=def.innerType._zod.run(payload,ctx);if(result instanceof Promise)return result.then(handleReadonlyResult);return handleReadonlyResult(result)}});function handleReadonlyResult(payload){if(!payload.memo)payload.value=Object.freeze(payload.value);return payload}var $ZodLazy=$constructor("$ZodLazy",(inst,def)=>{$ZodType.init(inst,def),defineLazy(inst._zod,"innerType",()=>{let d=def;if(!d._cachedInner)d._cachedInner=def.getter();return d._cachedInner}),defineLazyInternal(inst,"pattern",(zod)=>zod.innerType?._zod?.pattern),defineLazyInternal(inst,"propValues",(zod)=>zod.innerType?._zod?.propValues),defineLazyInternal(inst,"optin",(zod)=>zod.innerType?._zod?.optin??void 0),defineLazyInternal(inst,"optout",(zod)=>zod.innerType?._zod?.optout??void 0),inst._zod.parse=(payload,ctx)=>inst._zod.innerType._zod.run(payload,ctx)}),$ZodCustom=$constructor("$ZodCustom",(inst,def)=>{$ZodCheck.init(inst,def),$ZodType.init(inst,def),inst._zod.parse=(payload,_)=>payload,inst._zod.check=(payload)=>{let input=payload.value,r=def.fn(input);if(r instanceof Promise)return r.then((r)=>handleRefineResult(r,payload,input,inst));handleRefineResult(r,payload,input,inst);return}});function handleRefineResult(result,payload,input,inst){if(!result){let _iss={code:"custom",input,inst,path:[...inst._zod.def.path??[]],continue:!inst._zod.def.abort};if(inst._zod.def.params)_iss.params=inst._zod.def.params;payload.issues.push(issue(_iss))}}class $ZodCyclicError extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var STATE="~memo",NO_ISSUES=[];function cloneIssues(issues){return issues.map((iss)=>iss.path?{...iss,path:iss.path.slice()}:{...iss})}var recursive=new WeakMap;function isRecursive(inst,stack){let cached=recursive.get(inst);if(cached!==void 0)return cached;if(stack.has(inst))return!0;stack.add(inst);let result=!1,check=(child)=>{if(!result&&child?._zod&&isRecursive(child,stack))result=!0},def=inst._zod.def,kind=def.type;switch(kind){case"object":{for(let key of Reflect.ownKeys(def.shape))check(def.shape[key]);check(def.catchall);break}case"array":check(def.element);break;case"tuple":for(let el of def.items)check(el);check(def.rest);break;case"record":case"map":check(def.keyType),check(def.valueType);break;case"set":check(def.valueType);break;case"union":for(let el of def.options)check(el);break;case"intersection":check(def.left),check(def.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":check(def.innerType);break;case"pipe":check(def.in),check(def.out);break;case"function":check(def.input),check(def.output);break;case"lazy":check(inst._zod.innerType);break;case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let key in def){let desc=Object.getOwnPropertyDescriptor(def,key);if(!desc||desc.get)continue;let value=desc.value;if(!value||typeof value!=="object")continue;if(value._zod)check(value);else if(Array.isArray(value))for(let el of value)check(el)}}return stack.delete(inst),recursive.set(inst,result),result}function bucketFor(state,inst){let bucket=state.buckets.get(inst);if(!bucket)bucket=new Map,state.buckets.set(inst,bucket);return bucket}var handoff,open=[],memo={alloc(_inst,payload,empty){let bucket=handoff;if(!bucket)return empty;handoff=void 0;let entry={value:empty,issues:null};return bucket.set(payload.value,entry),open.push(entry),empty},guard(inst){var _a;(_a=inst._zod).deferred??(_a.deferred=[]),inst._zod.deferred.push(()=>{let base=inst._zod.parse,wrapped=(payload,ctx)=>{if(ctx.direction!=="backward"&&isBackEdge(ctx,payload.value))throw new $ZodCyclicError;return base(payload,ctx)};if(inst._zod.parse=wrapped,inst._zod.run===base)inst._zod.run=wrapped})},attach(inst){var _a;let isRecursiveInst,lastCtx,lastBucket;(_a=inst._zod).deferred??(_a.deferred=[]),inst._zod.deferred.push(()=>{let base=inst._zod.parse,wrapped=(payload,ctx)=>{if(isRecursiveInst===void 0){if(isRecursiveInst=isRecursive(inst,new Set),!isRecursiveInst){if(inst._zod.parse=base,inst._zod.run===wrapped)inst._zod.run=base;return base(payload,ctx)}}let input=payload.value;if(input===null||typeof input!=="object")return base(payload,ctx);let state=ctx[STATE];if(!state)state={buckets:new Map,backEdges:void 0},ctx[STATE]=state;let bucket;if(lastCtx===ctx)bucket=lastBucket;else bucket=bucketFor(state,inst),lastCtx=ctx,lastBucket=bucket;let hit=bucket.get(input);if(hit){if(payload.value=hit.value,hit.issues){if(hit.issues.length)payload.issues.push(...cloneIssues(hit.issues))}else payload.memo=!0,state.backEdges??(state.backEdges=new Set),state.backEdges.add(hit.value);return payload}handoff=bucket;let depth=open.length,result=base(payload,ctx);handoff=void 0;let entry=open.length>depth?open.pop():void 0;if(result instanceof Promise)return result.then((r)=>{if(entry)entry.issues=r.issues.length?cloneIssues(r.issues):NO_ISSUES;return r});if(entry)entry.issues=result.issues.length?cloneIssues(result.issues):NO_ISSUES;return result};if(inst._zod.parse=wrapped,inst._zod.run===base)inst._zod.run=wrapped})}};function memoizer(){return memo}function isBackEdge(ctx,value){let backEdges=ctx[STATE]?.backEdges;return backEdges!==void 0&&value!==null&&typeof value==="object"&&backEdges.has(value)}var error=()=>{let Sizable={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function getSizing(origin){return Sizable[origin]??null}let FormatDictionary={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"credit card number",jwt:"JWT",template_literal:"input"},TypeDictionary={nan:"NaN"};function getTypeName(type,input){if(type==="number"&&typeof input==="number"&&!Number.isFinite(input))return String(input);return TypeDictionary[type]??type}return(issue)=>{switch(issue.code){case"invalid_type":{let expected=getTypeName(issue.expected),receivedType=parsedType(issue.input),received=getTypeName(receivedType,issue.input);return`Invalid input: expected ${expected}, received ${received}`}case"invalid_value":if(issue.values.length===1)return`Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;return`Invalid option: expected one of ${joinValues(issue.values,"|")}`;case"too_big":{let adj=issue.exact?"exactly ":issue.inclusive?"<=":"<",sizing=getSizing(issue.origin);if(sizing)return`Too big: expected ${issue.origin??"value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit??"elements"}`;return`Too big: expected ${issue.origin??"value"} to be ${adj}${issue.maximum.toString()}`}case"too_small":{let adj=issue.exact?"exactly ":issue.inclusive?">=":">",sizing=getSizing(issue.origin);if(sizing)return`Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;return`Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`}case"invalid_format":{let _issue=issue;if(_issue.format==="starts_with")return`Invalid string: must start with "${_issue.prefix}"`;if(_issue.format==="ends_with")return`Invalid string: must end with "${_issue.suffix}"`;if(_issue.format==="includes")return`Invalid string: must include "${_issue.includes}"`;if(_issue.format==="regex")return`Invalid string: must match pattern ${_issue.pattern}`;return`Invalid ${FormatDictionary[_issue.format]??issue.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${issue.divisor}`;case"unrecognized_keys":return`Unrecognized key${issue.keys.length>1?"s":""}: ${joinValues(issue.keys,", ")}`;case"invalid_key":return`Invalid key in ${issue.origin}`;case"invalid_union":if(issue.options&&Array.isArray(issue.options)&&issue.options.length>0)return`Invalid discriminator value. Expected ${issue.options.map((o)=>`'${o}'`).join(" | ")}`;if(issue.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${issue.origin}`;default:return"Invalid input"}}};function en_default(){return{localeError:error()}}var _a2;class $ZodRegistry{constructor(){this._map=new WeakMap,this._idmap=new Map}add(schema,..._meta){let meta=_meta[0];if(this._map.set(schema,meta),meta&&typeof meta==="object"&&"id"in meta)this._idmap.set(meta.id,schema);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(schema){let meta=this._map.get(schema);if(meta&&typeof meta==="object"&&"id"in meta)this._idmap.delete(meta.id);return this._map.delete(schema),this}get(schema){let p=schema._zod.parent;if(p){let pm={...this.get(p)??{}};delete pm.id;let f={...pm,...this._map.get(schema)};return Object.keys(f).length?f:void 0}return this._map.get(schema)}has(schema){return this._map.has(schema)}}function registry(){return new $ZodRegistry}(_a2=globalThis).__zod_globalRegistry??(_a2.__zod_globalRegistry=registry());var globalRegistry=globalThis.__zod_globalRegistry;function _string(Class,params){return new Class({type:"string",...normalizeParams(params)})}function _email(Class,params){return new Class({type:"string",format:"email",check:"string_format",abort:!1,...normalizeParams(params)})}function _guid(Class,params){return new Class({type:"string",format:"guid",check:"string_format",abort:!1,...normalizeParams(params)})}function _uuid(Class,params){return new Class({type:"string",format:"uuid",check:"string_format",abort:!1,...normalizeParams(params)})}function _uuidv4(Class,params){return new Class({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...normalizeParams(params)})}function _uuidv6(Class,params){return new Class({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...normalizeParams(params)})}function _uuidv7(Class,params){return new Class({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...normalizeParams(params)})}function _url(Class,params){return new Class({type:"string",format:"url",check:"string_format",abort:!1,...normalizeParams(params)})}function _emoji2(Class,params){return new Class({type:"string",format:"emoji",check:"string_format",abort:!1,...normalizeParams(params)})}function _nanoid(Class,params){return new Class({type:"string",format:"nanoid",check:"string_format",abort:!1,...normalizeParams(params)})}function _cuid(Class,params){return new Class({type:"string",format:"cuid",check:"string_format",abort:!1,...normalizeParams(params)})}function _cuid2(Class,params){return new Class({type:"string",format:"cuid2",check:"string_format",abort:!1,...normalizeParams(params)})}function _ulid(Class,params){return new Class({type:"string",format:"ulid",check:"string_format",abort:!1,...normalizeParams(params)})}function _xid(Class,params){return new Class({type:"string",format:"xid",check:"string_format",abort:!1,...normalizeParams(params)})}function _ksuid(Class,params){return new Class({type:"string",format:"ksuid",check:"string_format",abort:!1,...normalizeParams(params)})}function _ipv4(Class,params){return new Class({type:"string",format:"ipv4",check:"string_format",abort:!1,...normalizeParams(params)})}function _ipv6(Class,params){return new Class({type:"string",format:"ipv6",check:"string_format",abort:!1,...normalizeParams(params)})}function _cidrv4(Class,params){return new Class({type:"string",format:"cidrv4",check:"string_format",abort:!1,...normalizeParams(params)})}function _cidrv6(Class,params){return new Class({type:"string",format:"cidrv6",check:"string_format",abort:!1,...normalizeParams(params)})}function _base64(Class,params){return new Class({type:"string",format:"base64",check:"string_format",abort:!1,...normalizeParams(params)})}function _base64url(Class,params){return new Class({type:"string",format:"base64url",check:"string_format",abort:!1,...normalizeParams(params)})}function _e164(Class,params){return new Class({type:"string",format:"e164",check:"string_format",abort:!1,...normalizeParams(params)})}function _jwt(Class,params){return new Class({type:"string",format:"jwt",check:"string_format",abort:!1,...normalizeParams(params)})}function _isoDateTime(Class,params){return new Class({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...normalizeParams(params)})}function _isoDate(Class,params){return new Class({type:"string",format:"date",check:"string_format",...normalizeParams(params)})}function _isoTime(Class,params){return new Class({type:"string",format:"time",check:"string_format",precision:null,...normalizeParams(params)})}function _isoDuration(Class,params){return new Class({type:"string",format:"duration",check:"string_format",...normalizeParams(params)})}function _number(Class,params){return new Class({type:"number",checks:[],...normalizeParams(params)})}function _coercedNumber(Class,params){return new Class({type:"number",coerce:!0,checks:[],...normalizeParams(params)})}function _int(Class,params){return new Class({type:"number",check:"number_format",abort:!1,format:"safeint",...normalizeParams(params)})}function _boolean(Class,params){return new Class({type:"boolean",...normalizeParams(params)})}function _null3(Class,params){return new Class({type:"null",...normalizeParams(params)})}function _any(Class){return new Class({type:"any"})}function _unknown(Class){return new Class({type:"unknown"})}function _never(Class,params){return new Class({type:"never",...normalizeParams(params)})}function _lt(value,params){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(params),value,inclusive:!1})}function _lte(value,params){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(params),value,inclusive:!0})}function _gt(value,params){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(params),value,inclusive:!1})}function _gte(value,params){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(params),value,inclusive:!0})}function _multipleOf(value,params){return new $ZodCheckMultipleOf({check:"multiple_of",...normalizeParams(params),value})}function _maxLength(maximum,params){return new $ZodCheckMaxLength({check:"max_length",...normalizeParams(params),maximum})}function _minLength(minimum,params){return new $ZodCheckMinLength({check:"min_length",...normalizeParams(params),minimum})}function _length(length,params){return new $ZodCheckLengthEquals({check:"length_equals",...normalizeParams(params),length})}function _regex(pattern,params){return new $ZodCheckRegex({check:"string_format",format:"regex",...normalizeParams(params),pattern})}function _lowercase(params){return new $ZodCheckLowerCase({check:"string_format",format:"lowercase",...normalizeParams(params)})}function _uppercase(params){return new $ZodCheckUpperCase({check:"string_format",format:"uppercase",...normalizeParams(params)})}function _includes(includes,params){return new $ZodCheckIncludes({check:"string_format",format:"includes",...normalizeParams(params),includes})}function _startsWith(prefix,params){return new $ZodCheckStartsWith({check:"string_format",format:"starts_with",...normalizeParams(params),prefix})}function _endsWith(suffix,params){return new $ZodCheckEndsWith({check:"string_format",format:"ends_with",...normalizeParams(params),suffix})}function _overwrite(tx){return new $ZodCheckOverwrite({check:"overwrite",tx})}function _normalize(form){return _overwrite((input)=>input.normalize(form))}function _trim(){return _overwrite((input)=>input.trim())}function _toLowerCase(){return _overwrite((input)=>input.toLowerCase())}function _toUpperCase(){return _overwrite((input)=>input.toUpperCase())}function _slugify(){return _overwrite((input)=>slugify(input))}function _array(Class,element,params){return new Class({type:"array",element,...normalizeParams(params)})}function _custom(Class,fn,_params){let norm=normalizeParams(_params);return norm.abort??(norm.abort=!0),new Class({type:"custom",check:"custom",fn,...norm})}function _refine(Class,fn,_params){return new Class({type:"custom",check:"custom",fn,...normalizeParams(_params)})}function _superRefine(fn,params){let ch=_check((payload)=>(payload.addIssue=(issue2)=>{if(typeof issue2==="string")payload.issues.push(issue(issue2,payload.value,ch._zod.def));else{let _issue=issue2;if(_issue.fatal)_issue.continue=!1;if(_issue.code??(_issue.code="custom"),!("input"in _issue))_issue.input=payload.value;_issue.inst??(_issue.inst=ch),_issue.continue??(_issue.continue=!ch._zod.def.abort),payload.issues.push(issue(_issue))}},fn(payload.value,payload)),params);return ch}function _check(fn,params){let ch=new $ZodCheck({check:"custom",...normalizeParams(params)});return ch._zod.check=fn,ch}function assignProps(target,...sources){for(let source of sources)for(let key of Reflect.ownKeys(source))if(Object.prototype.propertyIsEnumerable.call(source,key))assignProp(target,key,source[key]);return target}function initializeContext(params){let target=params?.target??"draft-2020-12";if(target==="draft-4")target="draft-04";if(target==="draft-7")target="draft-07";return{processors:params.processors??{},metadataRegistry:params?.metadata??globalRegistry,target,unrepresentable:params?.unrepresentable??"throw",override:params?.override??(()=>{}),io:params?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:params?.cycles??"ref",reused:params?.reused??"inline",intersections:[],deferred:[],external:params?.external??void 0}}function handleUnrepresentable(schema,ctx,json,params,message){let result=typeof ctx.unrepresentable==="function"?ctx.unrepresentable({zodSchema:schema,path:params.path,message}):ctx.unrepresentable;if(result==="any")return!1;if(result===void 0||result==="throw")throw Error(message);return Object.assign(json,result),!0}function process(schema,ctx,_params={path:[],schemaPath:[]}){var _a;let def=schema._zod.def,seen=ctx.seen.get(schema);if(seen){if(seen.count++,_params.schemaPath.includes(schema))seen.cycle=_params.path;return seen.schema}let result={schema:{},count:1,cycle:void 0,path:_params.path};ctx.seen.set(schema,result),ctx.sharedDefsExtractedFor=void 0,ctx.sharedEmitDoneFor=void 0;let overrideSchema=schema._zod.toJSONSchema?.();if(overrideSchema)result.schema=overrideSchema;else{let params={..._params,schemaPath:[..._params.schemaPath,schema],path:_params.path};if(schema._zod.processJSONSchema)schema._zod.processJSONSchema(ctx,result.schema,params);else{let _json=result.schema,processor=ctx.processors[def.type];if(!processor)throw Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);processor(schema,ctx,_json,params)}let parent=schema._zod.parent;if(parent){if(!result.ref)result.ref=parent;process(parent,ctx,params),ctx.seen.get(parent).isParent=!0}}let meta=ctx.metadataRegistry.get(schema);if(meta)assignProps(result.schema,meta);if(ctx.io==="input"&&isTransforming(schema))delete result.schema.examples,delete result.schema.default;if(ctx.io==="input"&&"_prefault"in result.schema)(_a=result.schema).default??(_a.default=result.schema._prefault);return delete result.schema._prefault,ctx.seen.get(schema).schema}function encodeJSONPointerSegment(segment){return segment.replace(/~/g,"~0").replace(/\//g,"~1")}function extractDefs(ctx,schema){let root=ctx.seen.get(schema);if(!root)throw Error("Unprocessed schema. This is a bug in Zod.");if(ctx.external&&ctx.sharedDefsExtractedFor===ctx.external)return;let idToSchema=new Map;for(let entry of ctx.seen.entries()){let id=ctx.metadataRegistry.get(entry[0])?.id;if(id){let existing=idToSchema.get(id);if(existing&&existing!==entry[0])throw Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);idToSchema.set(id,entry[0])}}let makeURI=(entry)=>{let defsSegment=ctx.target==="draft-2020-12"?"$defs":"definitions";if(ctx.external){let externalId=ctx.external.registry.get(entry[0])?.id,uriGenerator=ctx.external.uri??((id)=>id);if(externalId)return{ref:uriGenerator(externalId)};let id=entry[1].defId??entry[1].schema.id??`schema${ctx.counter++}`;return entry[1].defId=id,{defId:id,ref:`${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`}}let uriPrefix="#",defUriPrefix=`${uriPrefix}/${defsSegment}/`;if(entry[1]===root&&!entry[1].schema.id)return{ref:uriPrefix};let defId=entry[1].schema.id??`__schema${ctx.counter++}`;return{defId,ref:defUriPrefix+encodeJSONPointerSegment(defId)}},extractToDef=(entry)=>{if(entry[1].schema.$ref)return;let seen=entry[1],{ref,defId}=makeURI(entry);if(seen.def={...seen.schema},defId)seen.defId=defId;let schema=seen.schema;for(let key in schema)delete schema[key];schema.$ref=ref};if(ctx.cycles==="throw")for(let entry of ctx.seen.entries()){let seen=entry[1];if(seen.cycle)throw Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
53
53
 
54
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let entry of ctx.seen.entries()){let seen=entry[1];if(schema===entry[0]){extractToDef(entry);continue}if(ctx.external){let ext=ctx.external.registry.get(entry[0])?.id;if(schema!==entry[0]&&ext){extractToDef(entry);continue}}if(ctx.metadataRegistry.get(entry[0])?.id){extractToDef(entry);continue}if(seen.cycle){extractToDef(entry);continue}if(seen.count>1){if(ctx.reused==="ref"){extractToDef(entry);continue}}}if(ctx.external)ctx.sharedDefsExtractedFor=ctx.external}function compactTypeUnion(schema){let options=schema.anyOf;if(!Array.isArray(options)||options.length===0||schema.type!==void 0)return;let types=[];for(let option of options){if(!option||typeof option!=="object")return;compactTypeUnion(option);let keys=Object.keys(option);if(keys.length!==1||keys[0]!=="type")return;let type=option.type;for(let member of Array.isArray(type)?type:[type]){if(typeof member!=="string")return;if(!types.includes(member))types.push(member)}}delete schema.anyOf,schema.type=types.length===1?types[0]:types}var FOLDABLE_KEYS=new Set(["type","properties","required","additionalProperties"]),UNION_KEYS=["oneOf","anyOf"];function undeclaredConstraint(member){let extra=member.additionalProperties;if(extra===void 0||extra===!1||typeof extra!=="object"||extra===null)return null;return Object.keys(extra).length?extra:null}function foldObjects(members){let objects=[];for(let member of members){if(typeof member!=="object"||member.type!=="object")return null;for(let key in member)if(!FOLDABLE_KEYS.has(key))return null;objects.push(member)}let properties={},required=new Set;for(let object of objects){for(let key in object.properties){if(Object.prototype.hasOwnProperty.call(properties,key))continue;let parts=[];for(let other of objects){let part=other.properties?.[key]??undeclaredConstraint(other);if(part===null||part===void 0)continue;if(!parts.some((seen)=>JSON.stringify(seen)===JSON.stringify(part)))parts.push(part)}let merged=parts.length===1?parts[0]:foldObjects(parts)??{allOf:parts};assignProp(properties,key,merged)}for(let key of object.required??[])required.add(key)}let folded={type:"object",properties};if(required.size)folded.required=[...required];if(objects.every((object)=>object.additionalProperties===!1))folded.additionalProperties=!1;else{let constraints=[];for(let object of objects){let constraint=undeclaredConstraint(object);if(constraint&&!constraints.some((seen)=>JSON.stringify(seen)===JSON.stringify(constraint)))constraints.push(constraint)}if(constraints.length===1)folded.additionalProperties=constraints[0];else if(constraints.length>1)folded.additionalProperties={allOf:constraints}}return folded}function foldIntersection(json){let allOf=json.allOf;if(!Array.isArray(allOf)||allOf.length<2)return;for(let key of FOLDABLE_KEYS)if(key in json)return;let unions=allOf.filter((m)=>UNION_KEYS.some((k)=>Array.isArray(m[k]))),folded=null;if(!unions.length)folded=foldObjects(allOf);else{let union=unions[0],keyword=UNION_KEYS.find((k)=>Array.isArray(union[k]));if(Object.keys(union).length!==1)return;let rest=allOf.filter((m)=>m!==union),branches=union[keyword].map((branch)=>foldObjects([...rest,branch]));if(branches.some((b)=>!b))return;folded={[keyword]:branches}}if(!folded)return;delete json.allOf,assignProps(json,folded)}function finalize(ctx,schema){let root=ctx.seen.get(schema);if(!root)throw Error("Unprocessed schema. This is a bug in Zod.");let flattenRef=(zodSchema)=>{let seen=ctx.seen.get(zodSchema);if(seen.ref===null)return;let schema=seen.def??seen.schema,_cached={...schema},ref=seen.ref;if(seen.ref=null,ref){flattenRef(ref);let refSeen=ctx.seen.get(ref),refSchema=refSeen.schema;if(refSchema.$ref&&(ctx.target==="draft-07"||ctx.target==="draft-04"||ctx.target==="openapi-3.0"))schema.allOf=schema.allOf??[],schema.allOf.push(refSchema);else assignProps(schema,refSchema);if(assignProps(schema,_cached),zodSchema._zod.parent===ref)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(!(key in _cached))delete schema[key]}if(refSchema.$ref&&refSeen.def)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(key in refSeen.def&&JSON.stringify(schema[key])===JSON.stringify(refSeen.def[key]))delete schema[key]}}let parent=zodSchema._zod.parent;if(parent&&parent!==ref){flattenRef(parent);let parentSeen=ctx.seen.get(parent);if(parentSeen?.schema.$ref){if(schema.$ref=parentSeen.schema.$ref,parentSeen.def)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(key in parentSeen.def&&JSON.stringify(schema[key])===JSON.stringify(parentSeen.def[key]))delete schema[key]}}}ctx.override({zodSchema,jsonSchema:schema,path:seen.path??[]})};if(!ctx.external||ctx.sharedEmitDoneFor!==ctx.external){for(let entry of[...ctx.seen.entries()].reverse())flattenRef(entry[0]);if(ctx.target!=="openapi-3.0")for(let entry of ctx.seen.entries())compactTypeUnion(entry[1].def??entry[1].schema);for(let rewrite of ctx.deferred)rewrite();if(ctx.intersections.length){let carriers=new Map;for(let seen of ctx.seen.values())for(let json of[seen.schema,seen.def]){let allOf=json?.allOf;if(!Array.isArray(allOf))continue;let existing=carriers.get(allOf);if(existing)existing.push(json);else carriers.set(allOf,[json])}for(let allOf of ctx.intersections)for(let json of carriers.get(allOf)??[])foldIntersection(json)}}let result={};if(ctx.target==="draft-2020-12")result.$schema="https://json-schema.org/draft/2020-12/schema";else if(ctx.target==="draft-07")result.$schema="http://json-schema.org/draft-07/schema#";else if(ctx.target==="draft-04")result.$schema="http://json-schema.org/draft-04/schema#";else if(ctx.target==="openapi-3.0");if(ctx.external?.uri){let id=ctx.external.registry.get(schema)?.id;if(!id)throw Error("Schema is missing an `id` property");result.$id=ctx.external.uri(id)}assignProps(result,root.defId?root.schema:root.def??root.schema);let rootMetaId=ctx.metadataRegistry.get(schema)?.id;if(rootMetaId!==void 0&&result.id===rootMetaId)delete result.id;let defs=ctx.external?.defs??{};if(!ctx.external||ctx.sharedEmitDoneFor!==ctx.external)for(let entry of ctx.seen.entries()){let seen=entry[1];if(seen.def&&seen.defId){if(seen.def.id===seen.defId)delete seen.def.id;assignProp(defs,seen.defId,seen.def)}}if(ctx.external)ctx.sharedEmitDoneFor=ctx.external;if(ctx.external);else if(Object.keys(defs).length>0)if(ctx.target==="draft-2020-12")result.$defs=defs;else result.definitions=defs;try{let finalized=JSON.parse(JSON.stringify(result));return Object.defineProperty(finalized,"~standard",{value:{...schema["~standard"],jsonSchema:{input:createStandardJSONSchemaMethod(schema,"input",ctx.processors),output:createStandardJSONSchemaMethod(schema,"output",ctx.processors)}},enumerable:!1,writable:!1}),finalized}catch(_err){throw Error("Error converting schema to JSON.")}}function isTransforming(_schema,_ctx){let ctx=_ctx??{seen:new Set};if(ctx.seen.has(_schema))return!1;ctx.seen.add(_schema);let def=_schema._zod.def;if(def.type==="transform")return!0;if(def.type==="array")return isTransforming(def.element,ctx);if(def.type==="set")return isTransforming(def.valueType,ctx);if(def.type==="lazy")return isTransforming(def.getter(),ctx);if(def.type==="promise"||def.type==="optional"||def.type==="nonoptional"||def.type==="nullable"||def.type==="readonly"||def.type==="default"||def.type==="prefault"||def.type==="catch")return isTransforming(def.innerType,ctx);if(def.type==="intersection")return isTransforming(def.left,ctx)||isTransforming(def.right,ctx);if(def.type==="record"||def.type==="map")return isTransforming(def.keyType,ctx)||isTransforming(def.valueType,ctx);if(def.type==="pipe"){if(_schema._zod.traits.has("$ZodCodec"))return!0;return isTransforming(def.in,ctx)||isTransforming(def.out,ctx)}if(def.type==="object"){for(let key in def.shape)if(isTransforming(def.shape[key],ctx))return!0;return!1}if(def.type==="union"){for(let option of def.options)if(isTransforming(option,ctx))return!0;return!1}if(def.type==="tuple"){for(let item of def.items)if(isTransforming(item,ctx))return!0;if(def.rest&&isTransforming(def.rest,ctx))return!0;return!1}return!1}var createToJSONSchemaMethod=(schema,processors={})=>(params)=>{let ctx=initializeContext({...params,processors});return process(schema,ctx),extractDefs(ctx,schema),finalize(ctx,schema)},createStandardJSONSchemaMethod=(schema,io,processors={})=>(params)=>{let{libraryOptions,target}=params??{},ctx=initializeContext({...libraryOptions??{},target,io,processors});return process(schema,ctx),extractDefs(ctx,schema),finalize(ctx,schema)};var formatMap={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},stringProcessor=(schema,ctx,_json,_params)=>{let json=_json;json.type="string";let{minimum,maximum,format,patterns,contentEncoding,laxFormat}=schema._zod.bag;if(typeof minimum==="number")json.minLength=minimum;if(typeof maximum==="number")json.maxLength=maximum;if(format){if(json.format=formatMap[format]??format,json.format==="")delete json.format;if(format==="time"||laxFormat)delete json.format}if(contentEncoding)json.contentEncoding=contentEncoding;if(patterns&&patterns.size>0){let patternList=[...patterns];if(patternList.length===1)json.pattern=patternList[0].source;else if(patternList.length>1)json.allOf=[...patternList.map((regex)=>({...ctx.target==="draft-07"||ctx.target==="draft-04"||ctx.target==="openapi-3.0"?{type:"string"}:{},pattern:regex.source}))]}},numberProcessor=(schema,ctx,_json,params)=>{let json=_json,{minimum,maximum,format,multipleOf,exclusiveMaximum,exclusiveMinimum}=schema._zod.bag;if(typeof format==="string"&&format.includes("int"))json.type="integer";else json.type="number";let exMin=typeof exclusiveMinimum==="number"&&exclusiveMinimum>=(minimum??Number.NEGATIVE_INFINITY),exMax=typeof exclusiveMaximum==="number"&&exclusiveMaximum<=(maximum??Number.POSITIVE_INFINITY),legacy=ctx.target==="draft-04"||ctx.target==="openapi-3.0";if(exMin)if(legacy)json.minimum=exclusiveMinimum,json.exclusiveMinimum=!0;else json.exclusiveMinimum=exclusiveMinimum;else if(typeof minimum==="number")json.minimum=minimum;if(exMax)if(legacy)json.maximum=exclusiveMaximum,json.exclusiveMaximum=!0;else json.exclusiveMaximum=exclusiveMaximum;else if(typeof maximum==="number")json.maximum=maximum;if(typeof multipleOf==="number")if(Number.isFinite(multipleOf)&&multipleOf!==0)json.multipleOf=Math.abs(multipleOf);else handleUnrepresentable(schema,ctx,json,params,`A multipleOf divisor of ${multipleOf} cannot be represented in JSON Schema`)},booleanProcessor=(_schema,_ctx,json,_params)=>{json.type="boolean"},bigintProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"BigInt cannot be represented in JSON Schema")},symbolProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Symbols cannot be represented in JSON Schema")},nullProcessor=(_schema,ctx,json,_params)=>{if(ctx.target==="openapi-3.0")json.type="string",json.nullable=!0,json.enum=[null];else json.type="null"},undefinedProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Undefined cannot be represented in JSON Schema")},voidProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Void cannot be represented in JSON Schema")},neverProcessor=(_schema,_ctx,json,_params)=>{json.not={}},anyProcessor=(_schema,_ctx,_json,_params)=>{},unknownProcessor=(_schema,_ctx,_json,_params)=>{},dateProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Date cannot be represented in JSON Schema")},enumProcessor=(schema,_ctx,json,_params)=>{let def=schema._zod.def,values=getEnumValues(def.entries);if(values.length===0){json.not={};return}if(values.every((v)=>typeof v==="number"))json.type="number";if(values.every((v)=>typeof v==="string"))json.type="string";json.enum=values},literalProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;if(def.values.length===0){json.not={};return}let vals=[];for(let val of def.values)if(val===void 0){if(handleUnrepresentable(schema,ctx,json,params,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof val==="bigint"){if(handleUnrepresentable(schema,ctx,json,params,"BigInt literals cannot be represented in JSON Schema"))return;vals.push(Number(val))}else vals.push(val);if(vals.length===0);else if(vals.length===1){let val=vals[0];if(json.type=val===null?"null":typeof val,ctx.target==="draft-04"||ctx.target==="openapi-3.0")json.enum=[val];else json.const=val}else{if(vals.every((v)=>typeof v==="number"))json.type="number";if(vals.every((v)=>typeof v==="string"))json.type="string";if(vals.every((v)=>typeof v==="boolean"))json.type="boolean";if(vals.every((v)=>v===null))json.type="null";json.enum=vals}},nanProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"NaN cannot be represented in JSON Schema")},templateLiteralProcessor=(schema,_ctx,json,_params)=>{let _json=json,pattern=schema._zod.pattern;if(!pattern)throw Error("Pattern not found in template literal");_json.type="string",_json.pattern=pattern.source},fileProcessor=(schema,_ctx,json,_params)=>{let _json=json,file={type:"string",format:"binary",contentEncoding:"binary"},{minimum,maximum,mime}=schema._zod.bag;if(minimum!==void 0)file.minLength=minimum;if(maximum!==void 0)file.maxLength=maximum;if(mime)if(mime.length===1)file.contentMediaType=mime[0],Object.assign(_json,file);else Object.assign(_json,file),_json.anyOf=mime.map((m)=>({contentMediaType:m}));else Object.assign(_json,file)},successProcessor=(_schema,_ctx,json,_params)=>{json.type="boolean"},customProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Custom types cannot be represented in JSON Schema")},functionProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Function types cannot be represented in JSON Schema")},transformProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Transforms cannot be represented in JSON Schema")},mapProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Map cannot be represented in JSON Schema")},setProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Set cannot be represented in JSON Schema")},arrayProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def,{minimum,maximum}=schema._zod.bag;if(typeof minimum==="number")json.minItems=minimum;if(typeof maximum==="number")json.maxItems=maximum;json.type="array",json.items=process(def.element,ctx,{...params,path:[...params.path,"items"]})};function inputOptin(schema){let def=schema._zod.def;if(def.type==="pipe"&&def.in._zod.traits.has("$ZodTransform"))return inputOptin(def.out);if(def.type==="catch")return inputOptin(def.innerType);return schema._zod.optin}var objectProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def,shape=def.shape;if(Object.getOwnPropertySymbols(shape).length&&handleUnrepresentable(schema,ctx,json,params,"Symbol keys cannot be represented in JSON Schema"))return;json.type="object",json.properties={};for(let key in shape)assignProp(json.properties,key,process(shape[key],ctx,{...params,path:[...params.path,"properties",key]}));let allKeys=new Set(Object.keys(shape)),requiredKeys=new Set([...allKeys].filter((key)=>{let field=def.shape[key];if(ctx.io==="input")return inputOptin(field)===void 0;else return field._zod.optout===void 0}));if(requiredKeys.size>0)json.required=Array.from(requiredKeys);if(def.catchall?._zod.def.type==="never")json.additionalProperties=!1;else if(!def.catchall){if(ctx.io==="output")json.additionalProperties=!1}else if(def.catchall)json.additionalProperties=process(def.catchall,ctx,{...params,path:[...params.path,"additionalProperties"]})},unionProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,isExclusive=def.inclusive===!1,options=def.options.map((x,i)=>process(x,ctx,{...params,path:[...params.path,isExclusive?"oneOf":"anyOf",i]}));if(isExclusive)json.oneOf=options;else json.anyOf=options},intersectionProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,a=process(def.left,ctx,{...params,path:[...params.path,"allOf",0]}),b=process(def.right,ctx,{...params,path:[...params.path,"allOf",1]}),isSimpleIntersection=(val)=>("allOf"in val)&&Object.keys(val).length===1,allOf=[...isSimpleIntersection(a)?a.allOf:[a],...isSimpleIntersection(b)?b.allOf:[b]];json.allOf=allOf,ctx.intersections.push(allOf)},tupleProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def;json.type="array";let prefixPath=ctx.target==="draft-2020-12"?"prefixItems":"items",restPath=ctx.target==="draft-2020-12"?"items":ctx.target==="openapi-3.0"?"items":"additionalItems",prefixItems=def.items.map((x,i)=>process(x,ctx,{...params,path:[...params.path,prefixPath,i]})),rest=def.rest?process(def.rest,ctx,{...params,path:[...params.path,restPath,...ctx.target==="openapi-3.0"?[def.items.length]:[]]}):null,minItems=def.items.length;while(minItems>0){let item=def.items[minItems-1];if(!(ctx.io==="input"?inputOptin(item)!==void 0:item._zod.optout==="optional"))break;minItems--}let maxItems=def.items.length,isClosed=!def.rest;if(ctx.target==="draft-2020-12"){if(json.prefixItems=prefixItems,isClosed)json.items=!1;else if(rest)json.items=rest;if(minItems>0)json.minItems=minItems;if(isClosed)json.maxItems=maxItems}else if(ctx.target==="openapi-3.0"){if(json.items={anyOf:prefixItems},rest)json.items.anyOf.push(rest);if(minItems>0)json.minItems=minItems;if(isClosed)json.maxItems=maxItems}else{if(json.items=prefixItems,isClosed)json.additionalItems=!1;else if(rest)json.additionalItems=rest;if(minItems>0)json.minItems=minItems;if(isClosed)json.maxItems=maxItems}let{minimum,maximum}=schema._zod.bag;if(typeof minimum==="number")json.minItems=minimum;if(typeof maximum==="number")json.maxItems=maximum};function stringifyKeyNames(bySchema,json,visited){if(json.$ref){if(visited.has(json))return json;visited.add(json);let def=bySchema.get(json)?.def;if(!def)return json;let inlined=stringifyKeyNames(bySchema,def,visited);return inlined===def?json:inlined}for(let keyword of["anyOf","oneOf"]){let branches=json[keyword];if(!Array.isArray(branches))continue;let mapped=branches.map((branch)=>stringifyKeyNames(bySchema,branch,visited));if(mapped.some((branch,i)=>branch!==branches[i]))json={...json,[keyword]:mapped}}let types=Array.isArray(json.type)?json.type:[json.type],numericType=!types.includes("string")&&types.some((t)=>t==="number"||t==="integer"),values=json.enum??(json.const!==void 0?[json.const]:void 0);if(!numericType&&!values?.some((v)=>typeof v==="number"))return json;let{minimum,maximum,exclusiveMinimum,exclusiveMaximum,multipleOf,format,id,...rest}=json;if(rest.enum)rest.enum=rest.enum.map((v)=>typeof v==="number"?String(v):v);else if(typeof rest.const==="number")rest.const=String(rest.const);if(!numericType)return rest;if(rest.type="string",!values)rest.pattern=(types.includes("number")?number2:integer).source;return rest}var pendingRecords=new WeakMap;function rewriteKeyNames(ctx){let bySchema=new Map;for(let entry of ctx.seen.values())if(entry.def&&!bySchema.has(entry.schema))bySchema.set(entry.schema,entry);let rewrites=new Map;for(let record of pendingRecords.get(ctx)??[]){let seen=ctx.seen.get(record),names=(seen?.def??seen?.schema)?.propertyNames;if(!names||names===!0||rewrites.has(names))continue;let rewritten=stringifyKeyNames(bySchema,names,new Set);if(rewritten!==names)rewrites.set(names,rewritten)}if(!rewrites.size)return;for(let entry of ctx.seen.values())for(let carrier of[entry.schema,entry.def]){let rewritten=carrier&&rewrites.get(carrier.propertyNames);if(rewritten)carrier.propertyNames=rewritten}}var recordProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def;json.type="object";let keyType=def.keyType,patterns=keyType._zod.bag?.patterns;if(def.mode==="loose"&&patterns&&patterns.size>0){let valueSchema=process(def.valueType,ctx,{...params,path:[...params.path,"patternProperties","*"]});json.patternProperties={};for(let pattern of patterns)assignProp(json.patternProperties,pattern.source,valueSchema)}else{if(ctx.target==="draft-07"||ctx.target==="draft-2020-12"){json.propertyNames=process(def.keyType,ctx,{...params,path:[...params.path,"propertyNames"]});let pending=pendingRecords.get(ctx);if(!pending)pending=[],pendingRecords.set(ctx,pending),ctx.deferred.push(()=>rewriteKeyNames(ctx));pending.push(schema)}json.additionalProperties=process(def.valueType,ctx,{...params,path:[...params.path,"additionalProperties"]})}let keyValues=keyType._zod.values,omittableOnInput=ctx.io==="input"&&inputOptin(def.valueType)!==void 0;if(keyValues&&!def.partial&&!omittableOnInput){let validKeyValues=[...keyValues].filter((v)=>typeof v==="string"||typeof v==="number");if(validKeyValues.length>0)json.required=validKeyValues.map(String)}},nullableProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,inner=process(def.innerType,ctx,params),seen=ctx.seen.get(schema);if(ctx.target==="openapi-3.0")seen.ref=def.innerType,json.nullable=!0;else json.anyOf=[inner,{type:"null"}]},nonoptionalProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType},UNREPRESENTABLE_DEFAULT=Symbol();function serializeDefaultValue(value,schema,ctx,json,params){let unrepresentable=!1,serialized=JSON.stringify(value,(_,val)=>{if(typeof val!=="bigint")return val;return unrepresentable=!0,null});if(!unrepresentable)return JSON.parse(serialized);return handleUnrepresentable(schema,ctx,json,params,"BigInt defaults cannot be represented in JSON Schema"),UNREPRESENTABLE_DEFAULT}var defaultProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType;let value=serializeDefaultValue(def.defaultValue,schema,ctx,json,params);if(value!==UNREPRESENTABLE_DEFAULT)json.default=value},prefaultProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);if(seen.ref=def.innerType,ctx.io!=="input")return;let value=serializeDefaultValue(def.defaultValue,schema,ctx,json,params);if(value!==UNREPRESENTABLE_DEFAULT)json._prefault=value},catchProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType;let catchValue;try{catchValue=def.catchValue(void 0)}catch{handleUnrepresentable(schema,ctx,json,params,"Dynamic catch values are not supported in JSON Schema");return}json.default=catchValue},pipeProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def,inIsTransform=def.in._zod.traits.has("$ZodTransform"),innerType=ctx.io==="input"?inIsTransform?def.out:def.in:def.out;process(innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=innerType},readonlyProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType,json.readOnly=!0},promiseProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType},optionalProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType},lazyProcessor=(schema,ctx,_json,params)=>{let innerType=schema._zod.innerType;process(innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=innerType},allProcessors={string:stringProcessor,number:numberProcessor,boolean:booleanProcessor,bigint:bigintProcessor,symbol:symbolProcessor,null:nullProcessor,undefined:undefinedProcessor,void:voidProcessor,never:neverProcessor,any:anyProcessor,unknown:unknownProcessor,date:dateProcessor,enum:enumProcessor,literal:literalProcessor,nan:nanProcessor,template_literal:templateLiteralProcessor,file:fileProcessor,success:successProcessor,custom:customProcessor,function:functionProcessor,transform:transformProcessor,map:mapProcessor,set:setProcessor,array:arrayProcessor,object:objectProcessor,union:unionProcessor,intersection:intersectionProcessor,tuple:tupleProcessor,record:recordProcessor,nullable:nullableProcessor,nonoptional:nonoptionalProcessor,default:defaultProcessor,prefault:prefaultProcessor,catch:catchProcessor,pipe:pipeProcessor,readonly:readonlyProcessor,promise:promiseProcessor,optional:optionalProcessor,lazy:lazyProcessor};function toJSONSchema(input,params){if("_idmap"in input){let registry=input,ctx=initializeContext({...params,processors:allProcessors}),defs={};for(let entry of registry._idmap.entries()){let[_,schema]=entry;process(schema,ctx)}let schemas={},external={registry,uri:params?.uri,defs};ctx.external=external;for(let entry of registry._idmap.entries()){let[key,schema]=entry;extractDefs(ctx,schema),assignProp(schemas,key,finalize(ctx,schema))}if(Object.keys(defs).length>0){let defsSegment=ctx.target==="draft-2020-12"?"$defs":"definitions";schemas.__shared={[defsSegment]:defs}}return{schemas}}let ctx=initializeContext({...params,processors:allProcessors});return process(input,ctx),extractDefs(ctx,input),finalize(ctx,input)}var _installedErrorProtos=new WeakSet([Object.prototype,Error.prototype]);function _lazyMethod(proto,key,make){Object.defineProperty(proto,key,{configurable:!0,enumerable:!1,get(){let value=make(this);return Object.defineProperty(this,key,{value,configurable:!0,writable:!0}),value},set(value){Object.defineProperty(this,key,{value,configurable:!0,writable:!0})}})}var initializer2=(inst,issues)=>{$ZodError.init(inst,issues),inst.name="ZodError";let proto=Object.getPrototypeOf(inst);if(_installedErrorProtos.has(proto))return;_installedErrorProtos.add(proto),_lazyMethod(proto,"format",(self)=>(mapper)=>formatError(self,mapper)),_lazyMethod(proto,"flatten",(self)=>(mapper)=>flattenError(self,mapper)),_lazyMethod(proto,"addIssue",(self)=>(issue)=>{self.issues.push(issue),self.message=JSON.stringify(self.issues,jsonStringifyReplacer,2)}),_lazyMethod(proto,"addIssues",(self)=>(issues)=>{self.issues.push(...issues),self.message=JSON.stringify(self.issues,jsonStringifyReplacer,2)}),Object.defineProperty(proto,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})},ZodError=$constructor("ZodError",initializer2),ZodRealError=$constructor("ZodError",initializer2,void 0,{Parent:Error});var parse3=_parse(ZodRealError),parseAsync2=_parseAsync(ZodRealError),safeParse2=_safeParse(ZodRealError),safeParseAsync2=_safeParseAsync(ZodRealError),encode=_encode(ZodRealError),decode=_decode(ZodRealError),encodeAsync=_encodeAsync(ZodRealError),decodeAsync=_decodeAsync(ZodRealError),safeEncode=_safeEncode(ZodRealError),safeDecode=_safeDecode(ZodRealError),safeEncodeAsync=_safeEncodeAsync(ZodRealError),safeDecodeAsync=_safeDecodeAsync(ZodRealError);function _ensureDefaultLocale(){if(!globalConfig.localeError)config(en_default())}function _ensureDefaultMemoizer(){if(!globalConfig.memoizer)config({memoizer:memoizer()})}var ZodType=$constructor("ZodType",(inst,def)=>(_ensureDefaultLocale(),$ZodType.init(inst,def),inst.def=def,inst.type=def.type,inst),{check(...chks){let def=this.def;return this.clone(mergeDefs(def,{checks:[...def.checks??[],...chks.map((ch)=>typeof ch==="function"?{_zod:{check:ch,def:{check:"custom"},onattach:[]}}:ch)]}),{parent:!0})},with(...chks){return this.check(...chks)},clone(def,params){return clone(this,def,params)},brand(){return this},register(reg,meta){return reg.add(this,meta),this},refine(check,params){return this.check(refine(check,params))},superRefine(refinement,params){return this.check(superRefine(refinement,params))},overwrite(fn){return this.check(_overwrite(fn))},optional(){return optional(this)},exactOptional(){return exactOptional(this)},nullable(){return nullable(this)},nullish(){return optional(nullable(this))},nonoptional(params){return nonoptional(this,params)},array(){return array(this)},or(arg){return union([this,arg])},and(arg){return intersection(this,arg)},transform(tx){return pipe(this,transform(tx))},default(d){return _default(this,d)},prefault(d){return prefault(this,d)},catch(params){return _catch(this,params)},pipe(target){return pipe(this,target)},readonly(){return readonly(this)},describe(description){let cl=this.clone();return globalRegistry.add(cl,{description}),cl},meta(...args){if(args.length===0)return globalRegistry.get(this);let cl=this.clone();return globalRegistry.add(cl,args[0]),cl},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(fn,...args){return args.length===0?fn(this):fn(this,...args)},get "~standard"(){return hide(this,"~standard",{...standardProps(this),jsonSchema:{input:createStandardJSONSchemaMethod(this,"input"),output:createStandardJSONSchemaMethod(this,"output")}})},set "~standard"(value){own(this,"~standard",value)},parse:function _parse(data,params){return parse3(this,data,params,{callee:_parse})},parseAsync:async function _parseAsync(data,params){return await parseAsync2(this,data,params,{callee:_parseAsync})},safeParse(data,params){return safeParse2(this,data,params)},async safeParseAsync(data,params){return safeParseAsync2(this,data,params)},get spa(){return this?.safeParseAsync},set spa(value){own(this,"spa",value)},encode:function _encode(data,params){return encode(this,data,params,{callee:_encode})},decode:function _decode(data,params){return decode(this,data,params,{callee:_decode})},encodeAsync:async function _encodeAsync(data,params){return await encodeAsync(this,data,params,{callee:_encodeAsync})},decodeAsync:async function _decodeAsync(data,params){return await decodeAsync(this,data,params,{callee:_decodeAsync})},safeEncode(data,params){return safeEncode(this,data,params)},safeDecode(data,params){return safeDecode(this,data,params)},async safeEncodeAsync(data,params){return safeEncodeAsync(this,data,params)},async safeDecodeAsync(data,params){return safeDecodeAsync(this,data,params)},toJSONSchema(params){return createToJSONSchemaMethod(this,{})(params)},get description(){return globalRegistry.get(this)?.description},get _def(){return this._zod.def}}),_ZodString=$constructor("_ZodString",(inst,def)=>{$ZodString.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>stringProcessor(inst,ctx,json,params);let bag=inst._zod.bag;inst.format=bag.format??null,inst.minLength=bag.minimum??null,inst.maxLength=bag.maximum??null},{regex(...args){return this.check(_regex(...args))},includes(...args){return this.check(_includes(...args))},startsWith(...args){return this.check(_startsWith(...args))},endsWith(...args){return this.check(_endsWith(...args))},min(...args){return this.check(_minLength(...args))},max(...args){return this.check(_maxLength(...args))},length(...args){return this.check(_length(...args))},nonempty(...args){return this.check(_minLength(1,...args))},lowercase(params){return this.check(_lowercase(params))},uppercase(params){return this.check(_uppercase(params))},trim(){return this.check(_trim())},normalize(...args){return this.check(_normalize(...args))},toLowerCase(){return this.check(_toLowerCase())},toUpperCase(){return this.check(_toUpperCase())},slugify(){return this.check(_slugify())}}),ZodString=$constructor("ZodString",(inst,def)=>{$ZodString.init(inst,def),_ZodString.init(inst,def)},{email(params){return this.check(_email(ZodEmail,params))},url(params){return this.check(_url(ZodURL,params))},jwt(params){return this.check(_jwt(ZodJWT,params))},emoji(params){return this.check(_emoji2(ZodEmoji,params))},guid(params){return this.check(_guid(ZodGUID,params))},uuid(params){return this.check(_uuid(ZodUUID,params))},uuidv4(params){return this.check(_uuidv4(ZodUUID,params))},uuidv6(params){return this.check(_uuidv6(ZodUUID,params))},uuidv7(params){return this.check(_uuidv7(ZodUUID,params))},nanoid(params){return this.check(_nanoid(ZodNanoID,params))},cuid(params){return this.check(_cuid(ZodCUID,params))},cuid2(params){return this.check(_cuid2(ZodCUID2,params))},ulid(params){return this.check(_ulid(ZodULID,params))},base64(params){return this.check(_base64(ZodBase64,params))},base64url(params){return this.check(_base64url(ZodBase64URL,params))},xid(params){return this.check(_xid(ZodXID,params))},ksuid(params){return this.check(_ksuid(ZodKSUID,params))},ipv4(params){return this.check(_ipv4(ZodIPv4,params))},ipv6(params){return this.check(_ipv6(ZodIPv6,params))},cidrv4(params){return this.check(_cidrv4(ZodCIDRv4,params))},cidrv6(params){return this.check(_cidrv6(ZodCIDRv6,params))},e164(params){return this.check(_e164(ZodE164,params))},datetime(params){return this.check(_isoDateTime(ZodISODateTime,params))},date(params){return this.check(_isoDate(ZodISODate,params))},time(params){return this.check(_isoTime(ZodISOTime,params))},duration(params){return this.check(_isoDuration(ZodISODuration,params))}});function string(params){return _string(ZodString,params)}var ZodStringFormat=$constructor("ZodStringFormat",(inst,def)=>{$ZodStringFormat.init(inst,def),_ZodString.init(inst,def)}),ZodISODateTime=$constructor("ZodISODateTime",(inst,def)=>{$ZodISODateTime.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISODate=$constructor("ZodISODate",(inst,def)=>{$ZodISODate.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISOTime=$constructor("ZodISOTime",(inst,def)=>{$ZodISOTime.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISODuration=$constructor("ZodISODuration",(inst,def)=>{$ZodISODuration.init(inst,def),ZodStringFormat.init(inst,def)}),ZodEmail=$constructor("ZodEmail",(inst,def)=>{$ZodEmail.init(inst,def),ZodStringFormat.init(inst,def)});var ZodGUID=$constructor("ZodGUID",(inst,def)=>{$ZodGUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodUUID=$constructor("ZodUUID",(inst,def)=>{$ZodUUID.init(inst,def),ZodStringFormat.init(inst,def)});function uuid2(params){return _uuid(ZodUUID,params)}var ZodURL=$constructor("ZodURL",(inst,def)=>{$ZodURL.init(inst,def),ZodStringFormat.init(inst,def)});function url(params){return _url(ZodURL,params)}var ZodEmoji=$constructor("ZodEmoji",(inst,def)=>{$ZodEmoji.init(inst,def),ZodStringFormat.init(inst,def)});var ZodNanoID=$constructor("ZodNanoID",(inst,def)=>{$ZodNanoID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCUID=$constructor("ZodCUID",(inst,def)=>{$ZodCUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCUID2=$constructor("ZodCUID2",(inst,def)=>{$ZodCUID2.init(inst,def),ZodStringFormat.init(inst,def)});var ZodULID=$constructor("ZodULID",(inst,def)=>{$ZodULID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodXID=$constructor("ZodXID",(inst,def)=>{$ZodXID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodKSUID=$constructor("ZodKSUID",(inst,def)=>{$ZodKSUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodIPv4=$constructor("ZodIPv4",(inst,def)=>{$ZodIPv4.init(inst,def),ZodStringFormat.init(inst,def)});var ZodIPv6=$constructor("ZodIPv6",(inst,def)=>{$ZodIPv6.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCIDRv4=$constructor("ZodCIDRv4",(inst,def)=>{$ZodCIDRv4.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCIDRv6=$constructor("ZodCIDRv6",(inst,def)=>{$ZodCIDRv6.init(inst,def),ZodStringFormat.init(inst,def)});var ZodBase64=$constructor("ZodBase64",(inst,def)=>{$ZodBase64.init(inst,def),ZodStringFormat.init(inst,def)});var ZodBase64URL=$constructor("ZodBase64URL",(inst,def)=>{$ZodBase64URL.init(inst,def),ZodStringFormat.init(inst,def)});var ZodE164=$constructor("ZodE164",(inst,def)=>{$ZodE164.init(inst,def),ZodStringFormat.init(inst,def)});var ZodJWT=$constructor("ZodJWT",(inst,def)=>{$ZodJWT.init(inst,def),ZodStringFormat.init(inst,def)});var ZodNumber=$constructor("ZodNumber",(inst,def)=>{$ZodNumber.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>numberProcessor(inst,ctx,json,params);let bag=inst._zod.bag;inst.minValue=Math.max(bag.minimum??Number.NEGATIVE_INFINITY,bag.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,inst.maxValue=Math.min(bag.maximum??Number.POSITIVE_INFINITY,bag.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,inst.isInt=(bag.format??"").includes("int")||Number.isSafeInteger(bag.multipleOf??0.5),inst.isFinite=!0,inst.format=bag.format??null},{gt(value,params){return this.check(_gt(value,params))},gte(value,params){return this.check(_gte(value,params))},min(value,params){return this.check(_gte(value,params))},lt(value,params){return this.check(_lt(value,params))},lte(value,params){return this.check(_lte(value,params))},max(value,params){return this.check(_lte(value,params))},int(params){return this.check(int(params))},safe(params){return this.check(int(params))},positive(params){return this.check(_gt(0,params))},nonnegative(params){return this.check(_gte(0,params))},negative(params){return this.check(_lt(0,params))},nonpositive(params){return this.check(_lte(0,params))},multipleOf(value,params){return this.check(_multipleOf(value,params))},step(value,params){return this.check(_multipleOf(value,params))},finite(){return this}});function number(params){return _number(ZodNumber,params)}var ZodNumberFormat=$constructor("ZodNumberFormat",(inst,def)=>{$ZodNumberFormat.init(inst,def),ZodNumber.init(inst,def)});function int(params){return _int(ZodNumberFormat,params)}var ZodBoolean=$constructor("ZodBoolean",(inst,def)=>{$ZodBoolean.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>booleanProcessor(inst,ctx,json,params)});function boolean(params){return _boolean(ZodBoolean,params)}var ZodNull=$constructor("ZodNull",(inst,def)=>{$ZodNull.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nullProcessor(inst,ctx,json,params)});function _null(params){return _null3(ZodNull,params)}var ZodAny=$constructor("ZodAny",(inst,def)=>{$ZodAny.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>anyProcessor(inst,ctx,json,params)});function any(){return _any(ZodAny)}var ZodUnknown=$constructor("ZodUnknown",(inst,def)=>{$ZodUnknown.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>unknownProcessor(inst,ctx,json,params)});function unknown(){return _unknown(ZodUnknown)}var ZodNever=$constructor("ZodNever",(inst,def)=>{$ZodNever.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>neverProcessor(inst,ctx,json,params)});function never(params){return _never(ZodNever,params)}var ZodArray=$constructor("ZodArray",(inst,def)=>{_ensureDefaultMemoizer(),$ZodArray.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>arrayProcessor(inst,ctx,json,params),inst.element=def.element},{min(n,params){return this.check(_minLength(n,params))},nonempty(params){return this.check(_minLength(1,params))},max(n,params){return this.check(_maxLength(n,params))},length(n,params){return this.check(_length(n,params))},unwrap(){return this.element}});function array(element,params){return _array(ZodArray,element,params)}var ZodObject=$constructor("ZodObject",(inst,def)=>{_ensureDefaultMemoizer(),$ZodObjectJIT.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>objectProcessor(inst,ctx,json,params),installLazyProp(inst,"shape",(self)=>self._zod.def.shape,!1)},{keyof(){return _enum(Object.keys(this._zod.def.shape))},catchall(catchall){return this.clone({...this._zod.def,catchall})},passthrough(){return this.clone({...this._zod.def,catchall:unknown()})},loose(){return this.clone({...this._zod.def,catchall:unknown()})},strict(){return this.clone({...this._zod.def,catchall:never()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(incoming){return extend(this,incoming)},safeExtend(incoming){return safeExtend(this,incoming)},merge(other){return merge(this,other)},pick(mask){return pick(this,mask)},omit(mask){return omit(this,mask)},partial(...args){return partial(ZodOptional,this,args[0])},exactPartial(...args){return partial(ZodExactOptional,this,args[0],"exactPartial")},required(...args){return required(ZodNonOptional,this,args[0])}});function object(shape,params){let def={type:"object",shape:shape??{},...normalizeParams(params)};return new ZodObject(def)}function strictObject(shape,params){return new ZodObject({type:"object",shape,catchall:never(),...normalizeParams(params)})}function looseObject(shape,params){return new ZodObject({type:"object",shape,catchall:unknown(),...normalizeParams(params)})}var ZodUnion=$constructor("ZodUnion",(inst,def)=>{$ZodUnion.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>unionProcessor(inst,ctx,json,params),inst.options=def.options});function union(options,params){return new ZodUnion({type:"union",options,...normalizeParams(params)})}var ZodDiscriminatedUnion=$constructor("ZodDiscriminatedUnion",(inst,def)=>{ZodUnion.init(inst,def),$ZodDiscriminatedUnion.init(inst,def)});function discriminatedUnion(discriminator,options,params){return new ZodDiscriminatedUnion({type:"union",options,discriminator,...normalizeParams(params)})}var ZodIntersection=$constructor("ZodIntersection",(inst,def)=>{$ZodIntersection.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>intersectionProcessor(inst,ctx,json,params)});function intersection(left,right){return new ZodIntersection({type:"intersection",left,right})}var ZodRecord=$constructor("ZodRecord",(inst,def)=>{_ensureDefaultMemoizer(),$ZodRecord.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>recordProcessor(inst,ctx,json,params),inst.keyType=def.keyType,inst.valueType=def.valueType});function record(keyType,valueType,params){if(!valueType||!valueType._zod)return new ZodRecord({type:"record",keyType:string(),valueType:keyType,...normalizeParams(valueType)});return new ZodRecord({type:"record",keyType,valueType,...normalizeParams(params)})}var ZodEnum=$constructor("ZodEnum",(inst,def)=>{$ZodEnum.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>enumProcessor(inst,ctx,json,params),inst.enum=def.entries,inst.options=Object.values(def.entries);let keys=new Set(Object.keys(def.entries));inst.extract=(values,params)=>{let newEntries={};for(let value of values)if(keys.has(value))newEntries[value]=def.entries[value];else throw Error(`Key ${value} not found in enum`);return new ZodEnum({...def,checks:[],...normalizeParams(params),entries:newEntries})},inst.exclude=(values,params)=>{let newEntries={...def.entries};for(let value of values)if(keys.has(value))delete newEntries[value];else throw Error(`Key ${value} not found in enum`);return new ZodEnum({...def,checks:[],...normalizeParams(params),entries:newEntries})}});function _enum(values,params){let entries=Array.isArray(values)?Object.fromEntries(values.map((v)=>[v,v])):values;return new ZodEnum({type:"enum",entries,...normalizeParams(params)})}var ZodLiteral=$constructor("ZodLiteral",(inst,def)=>{$ZodLiteral.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>literalProcessor(inst,ctx,json,params),inst.values=new Set(def.values),Object.defineProperty(inst,"value",{get(){if(def.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return def.values[0]}})});function literal(value,params){return new ZodLiteral({type:"literal",values:Array.isArray(value)?value:[value],...normalizeParams(params)})}var ZodTransform=$constructor("ZodTransform",(inst,def)=>{_ensureDefaultMemoizer(),$ZodTransform.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>transformProcessor(inst,ctx,json,params),inst._zod.parse=(payload,_ctx)=>{if(_ctx.direction==="backward")throw new $ZodEncodeError(inst.constructor.name);payload.addIssue=(issue2)=>{if(typeof issue2==="string")payload.issues.push(issue(issue2,payload.value,def));else{let _issue=issue2;if(_issue.fatal)_issue.continue=!1;if(_issue.code??(_issue.code="custom"),!("input"in _issue))_issue.input=payload.value;_issue.inst??(_issue.inst=inst),payload.issues.push(issue(_issue))}};let output=def.transform(payload.value,payload);if(output instanceof Promise)return output.then((output)=>(payload.value=output,payload));return payload.value=output,payload}});function transform(fn){return new ZodTransform({type:"transform",transform:fn})}var ZodOptional=$constructor("ZodOptional",(inst,def)=>{$ZodOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>optionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function optional(innerType){return new ZodOptional({type:"optional",innerType})}var ZodExactOptional=$constructor("ZodExactOptional",(inst,def)=>{$ZodExactOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>optionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function exactOptional(innerType){return new ZodExactOptional({type:"optional",innerType})}var ZodNullable=$constructor("ZodNullable",(inst,def)=>{$ZodNullable.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nullableProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function nullable(innerType){return new ZodNullable({type:"nullable",innerType})}var ZodDefault=$constructor("ZodDefault",(inst,def)=>{$ZodDefault.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>defaultProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType,inst.removeDefault=inst.unwrap});function _default(innerType,defaultValue){return new ZodDefault({type:"default",innerType,get defaultValue(){return typeof defaultValue==="function"?defaultValue():shallowClone(defaultValue)}})}var ZodPrefault=$constructor("ZodPrefault",(inst,def)=>{$ZodPrefault.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>prefaultProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function prefault(innerType,defaultValue){return new ZodPrefault({type:"prefault",innerType,get defaultValue(){return typeof defaultValue==="function"?defaultValue():shallowClone(defaultValue)}})}var ZodNonOptional=$constructor("ZodNonOptional",(inst,def)=>{$ZodNonOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nonoptionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function nonoptional(innerType,params){return new ZodNonOptional({type:"nonoptional",innerType,...normalizeParams(params)})}var ZodCatch=$constructor("ZodCatch",(inst,def)=>{$ZodCatch.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>catchProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType,inst.removeCatch=inst.unwrap});function _catch(innerType,catchValue){return new ZodCatch({type:"catch",innerType,catchValue:typeof catchValue==="function"?catchValue:constantCatch(catchValue)})}var ZodPipe=$constructor("ZodPipe",(inst,def)=>{$ZodPipe.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>pipeProcessor(inst,ctx,json,params),inst.in=def.in,inst.out=def.out});function pipe(in_,out){return new ZodPipe({type:"pipe",in:in_,out})}var ZodPreprocess=$constructor("ZodPreprocess",(inst,def)=>{ZodPipe.init(inst,def),$ZodPreprocess.init(inst,def)}),ZodReadonly=$constructor("ZodReadonly",(inst,def)=>{$ZodReadonly.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>readonlyProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function readonly(innerType){return new ZodReadonly({type:"readonly",innerType})}var ZodLazy=$constructor("ZodLazy",(inst,def)=>{$ZodLazy.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>lazyProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.getter()});function lazy(getter){return new ZodLazy({type:"lazy",getter})}var ZodCustom=$constructor("ZodCustom",(inst,def)=>{$ZodCustom.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>customProcessor(inst,ctx,json,params)});function custom(fn,_params){return _custom(ZodCustom,fn??(()=>!0),_params)}function refine(fn,_params={}){return _refine(ZodCustom,fn,_params)}function superRefine(fn,params){return _superRefine(fn,params)}function preprocess(fn,schema){return new ZodPreprocess({type:"pipe",in:transform(fn),out:schema})}var exports_iso={};__export(exports_iso,{ZodISODate:()=>ZodISODate,ZodISODateTime:()=>ZodISODateTime,ZodISODuration:()=>ZodISODuration,ZodISOTime:()=>ZodISOTime,date:()=>date2,datetime:()=>datetime,duration:()=>duration2,time:()=>time2});function datetime(params){return _isoDateTime(ZodISODateTime,params)}function date2(params){return _isoDate(ZodISODate,params)}function time2(params){return _isoTime(ZodISOTime,params)}function duration2(params){return _isoDuration(ZodISODuration,params)}var FeedbackPrefsSchema=object({enabled:boolean(),contactOk:boolean().optional()}),MAX_DESIGN_NAME=80;function designNameIssue(name){if(name.trim()==="")return"a design name can't be empty";if(name!==name.trim())return"a design name can't start or end with spaces";if(name==="."||name==="..")return`"${name}" can't be a design name`;if(/[/\\]/.test(name))return"a design name can't contain / or \\";if(/\p{Cc}/u.test(name))return"a design name can't contain control characters";if([...name].length>MAX_DESIGN_NAME)return`a design name can't be longer than ${MAX_DESIGN_NAME} characters`;return null}function isDesignName(name){return designNameIssue(name)===null}var DesignNameSchema=string().superRefine((name,ctx)=>{let issue=designNameIssue(name);if(issue)ctx.addIssue({code:"custom",message:issue})});function toDesignName(text){let cleaned=[...text.replace(/[/\\\p{Cc}]+/gu," ").trim()].slice(0,MAX_DESIGN_NAME).join("").trim();return cleaned&&isDesignName(cleaned)?cleaned:null}var RepoManifestSchema=object({$schema:string().optional(),designs:array(string().min(1)),defaultDesign:DesignNameSchema.optional(),feedback:FeedbackPrefsSchema.optional()}).refine((m)=>new Set(m.designs).size===m.designs.length,{message:"designs lists the same path twice"}),REPO_MANIFEST_FILE="velloo.json";function normalizeRepoManifest(raw){if(typeof raw!=="object"||raw===null||Array.isArray(raw))return{manifest:raw,legacyNames:{},legacy:!1};let{projects,defaultProject,...rest}=raw;if(projects===void 0||"designs"in rest)return{manifest:raw,legacyNames:{},legacy:!1};let legacyNames={},designs=[];if(typeof projects==="object"&&projects!==null&&!Array.isArray(projects)){for(let[name,path]of Object.entries(projects))if(designs.push(path),typeof path==="string")legacyNames[path]=name}return{manifest:{...rest,designs,...defaultProject!==void 0?{defaultDesign:defaultProject}:{}},legacyNames,legacy:!0}}var CURRENT_SCHEMA_VERSION=4;function schemaVersionOf(rawConfig){if(typeof rawConfig!=="object"||rawConfig===null)return 1;let v=rawConfig.schemaVersion;return typeof v==="number"&&Number.isInteger(v)&&v>=1?v:1}var APP_PATH_PREFIX="app:",LEGACY_APP_PREFIX="project:",LEGACY_LIBRARY_KEY="default";function migrateLibraryEntry(raw){if(typeof raw!=="object"||raw===null)return raw;let lib={...raw};if(lib.source==="embedded:shadcn"||lib.source==="registry:shadcn")lib.source="binary",lib.componentsPath="binary";if(lib.id==="shadcn-react")lib.id="shadcn-upstream";return lib}var RETIRED_TYPOGRAPHY_KEYS=["fontSize","fontWeight","lineHeight","letterSpacing"],FACE_ROLE_CANDIDATES={fontBody:["sans","body","base"],fontHeading:["display","heading","serif"],fontMono:["mono","code"]},IMPLIED_BASE_PX=16;function asObject(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)?value:void 0}function positiveNumber(value){return typeof value==="number"&&Number.isFinite(value)&&value>0?value:void 0}function deriveTypeset(typography){let derived={},base=positiveNumber(asObject(typography.fontSize)?.base);if(base!==void 0&&base!==IMPLIED_BASE_PX)derived.size=base;let leading=positiveNumber(asObject(typography.lineHeight)?.normal);if(leading!==void 0)derived.leading=leading;let families=asObject(typography.fontFamily);if(families)for(let[face,candidates]of Object.entries(FACE_ROLE_CANDIDATES)){let role=candidates.find((name)=>typeof families[name]==="string");if(role)derived[face]=role}return derived}var FOLDER_MIGRATIONS=[{from:1,summary:"multi-library config shape, source enum, shadcn-react \u2192 shadcn-upstream, required annotation author",config(raw){let out={...raw};if(out.library!==void 0&&out.libraries===void 0)out.libraries={[LEGACY_LIBRARY_KEY]:out.library},out.defaultLibrary=LEGACY_LIBRARY_KEY;if(delete out.library,typeof out.libraries==="object"&&out.libraries!==null)out.libraries=Object.fromEntries(Object.entries(out.libraries).map(([id,lib])=>[id,migrateLibraryEntry(lib)]));return out.schemaVersion=2,out},annotation(raw){if(raw.author===void 0)return{...raw,author:"user"};return raw}},{from:2,summary:"typography scales \u2192 typesets (font roles bound, dead size/weight/tracking records dropped)",config(raw){return{...raw,schemaVersion:3}},theme(raw){let typography=asObject(raw.typography);if(!typography)return raw;let next={...typography},typesets=asObject(next.typesets);if(typesets?.default===void 0){let derived=deriveTypeset(next);if(Object.keys(derived).length>0)next.typesets={...typesets,default:derived}}for(let key of RETIRED_TYPOGRAPHY_KEYS)delete next[key];return{...raw,typography:next}}},{from:3,summary:"the design's name moves into its config; `project:` paths become `app:`",config(raw,context){let out={...raw,schemaVersion:4};if(typeof out.name!=="string"||!isDesignName(out.name))out.name=(context.name&&toDesignName(context.name))??"design";let toApp=(path)=>typeof path==="string"&&path.startsWith(LEGACY_APP_PREFIX)?`${APP_PATH_PREFIX}${path.slice(LEGACY_APP_PREFIX.length)}`:path,hostApp=asObject(out.hostApp);if(hostApp)out.hostApp={...hostApp,root:toApp(hostApp.root)};let hostApps=asObject(out.hostApps);if(hostApps)out.hostApps=Object.fromEntries(Object.entries(hostApps).map(([key,app])=>{let entry=asObject(app);return[key,entry?{...entry,root:toApp(entry.root)}:app]}));let libraries=asObject(out.libraries);if(libraries)out.libraries=Object.fromEntries(Object.entries(libraries).map(([key,lib])=>{let entry=asObject(lib);return[key,entry?{...entry,componentsPath:toApp(entry.componentsPath)}:lib]}));return out}}];function planMigration(rawConfig,context={}){let from=schemaVersionOf(rawConfig);if(from>CURRENT_SCHEMA_VERSION)throw Error(`Design folder uses schema version ${from}, newer than this velloo (v${CURRENT_SCHEMA_VERSION}). Upgrade velloo.`);let steps=[];for(let v=from;v<CURRENT_SCHEMA_VERSION;v++){let step=FOLDER_MIGRATIONS.find((m)=>m.from===v);if(!step)throw Error(`velloo: no migration step from schema version ${v} \u2014 bug.`);steps.push(step)}let config={...rawConfig??{}};for(let step of steps)if(step.config)config=step.config(config,context);return config.schemaVersion=CURRENT_SCHEMA_VERSION,{config,applied:steps.map((s)=>s.summary),annotation:(raw)=>steps.reduce((acc,step)=>step.annotation?.(acc)??acc,raw),theme:(raw)=>steps.reduce((acc,step)=>step.theme?.(acc)??acc,raw)}}var ResourceIdSchema=string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,"ids are [A-Za-z0-9][A-Za-z0-9_-]{0,63}");function isComponentNode(n){return typeof n.$ref==="string"}function isSnippetInstance(n){return typeof n.$snippet==="string"}function isParamRef(n){return typeof n.$param==="string"}var NodeIdSchema=string().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/,{message:"node id must match /^[a-zA-Z][a-zA-Z0-9_-]*$/"});function wrapScalarChild(item){if(typeof item==="string"||typeof item==="number")return{$ref:"Box",props:{as:"span",children:item}};return item}var EmitAsSchema=object({name:string().min(1),importPath:string().min(1)}),ComponentNodeSchema=lazy(()=>object({$ref:string().min(1),$id:NodeIdSchema.optional(),props:record(string(),unknown()).optional(),children:array(union([string(),number(),NodeSchema])).transform((items)=>items.map(wrapScalarChild)).optional(),$emitAs:EmitAsSchema.optional()})),SnippetInstanceSchema=object({$snippet:string().min(1),$id:NodeIdSchema.optional(),$extraClassName:string().optional(),args:record(string(),unknown()).optional(),$overrides:record(string().regex(/^$|^\d+(\.\d+)*$|^@[a-zA-Z][a-zA-Z0-9_-]*$/,{message:'override key must be a dotted index path like "0.2", an "@id" reference with a literal leading @ (e.g. "@row-active" to target the body node whose $id is "row-active"), or "" for the body root'}),object({props:record(string(),unknown())})).optional()}),ParamRefSchema=object({$param:string().min(1)}),NodeSchema=unknown().transform((val,ctx)=>{if(val===null||typeof val!=="object"||Array.isArray(val))return ctx.addIssue({code:"custom",message:'node must be an object with one of "$ref" (component), "$snippet" (instance), or "$param" (param ref)'}),NEVER;let v=val,branch=typeof v.$ref==="string"?ComponentNodeSchema:typeof v.$snippet==="string"?SnippetInstanceSchema:typeof v.$param==="string"?ParamRefSchema:null;if(!branch)return ctx.addIssue({code:"custom",message:'node needs exactly one of "$ref" (component), "$snippet" (snippet instance), or "$param" (param ref, snippet bodies only)'}),NEVER;let parsed=branch.safeParse(val);if(!parsed.success){for(let issue of parsed.error.issues)ctx.addIssue({...issue});return NEVER}return parsed.data}).describe('{"$ref":"Button","$id?":"cta","props?":{...},"children?":[Node]}, or {"$snippet":"<id>","args?":{...}}. Guide: velloo://guide/components').meta({type:"object",additionalProperties:!0});function nodeId(n){if(isParamRef(n))return;return n.$id}var ScreenSchema=object({id:ResourceIdSchema,name:string().min(1),library:string().min(1).optional(),tree:NodeSchema});var NumOrCssLen=union([number(),string().min(1)]),LooseTokenGroupSchema=lazy(()=>record(string(),union([string(),number(),LooseTokenGroupSchema]))),ColorPairSchema=union([string().min(1),object({DEFAULT:string().min(1),foreground:string().min(1).optional()})]),ColorsSchema=object({background:string().min(1),foreground:string().min(1),primary:ColorPairSchema,secondary:ColorPairSchema.optional(),muted:ColorPairSchema.optional(),accent:ColorPairSchema.optional(),destructive:ColorPairSchema.optional(),card:ColorPairSchema.optional(),popover:ColorPairSchema.optional(),border:string().min(1).optional(),input:string().min(1).optional(),ring:string().min(1).optional()});function resolveColors(theme,dark=!1){if(!dark||!theme.colorsDark)return theme.colors;let merged={...theme.colors};for(let[key,value]of Object.entries(theme.colorsDark))if(value!==void 0)merged[key]=value;return merged}var PaletteSchema=record(string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/),string().min(1)),TypesetSchema=object({size:NumOrCssLen.optional(),leading:number().positive().optional(),flow:NumOrCssLen.optional(),fontBody:string().min(1).optional(),fontHeading:string().min(1).optional(),fontMono:string().min(1).optional()}),TypographySchema=object({fontFamily:record(string(),string().min(1)).optional(),googleFonts:array(string().min(1)).optional(),typesets:record(string().regex(/^[A-Za-z0-9_-]+$/),TypesetSchema).optional()}).strict(),RadiusSchema=object({none:NumOrCssLen.optional(),sm:NumOrCssLen.optional(),md:NumOrCssLen.optional(),lg:NumOrCssLen.optional(),xl:NumOrCssLen.optional(),"2xl":NumOrCssLen.optional(),"3xl":NumOrCssLen.optional(),full:NumOrCssLen.optional()}).partial(),ContainerSchema=object({center:boolean().optional(),padding:string().min(1).optional(),maxWidth:string().min(1).optional()}),ThemeSchema=object({name:string().min(1),colors:ColorsSchema,colorsDark:ColorsSchema.partial().optional(),palette:PaletteSchema.optional(),paletteDark:PaletteSchema.optional(),typography:TypographySchema,spacing:LooseTokenGroupSchema,radius:RadiusSchema,shadows:LooseTokenGroupSchema.optional(),container:ContainerSchema.optional(),keyframes:record(string(),record(string(),record(string(),string()))).optional(),animation:record(string(),string()).optional()});var AnnotationLocatorSchema=union([array(number().int().nonnegative()),string().regex(/^@[a-zA-Z][a-zA-Z0-9_-]*$/)]),AnnotationTargetSchema=object({locator:AnnotationLocatorSchema}),PositionSchema=union([object({x:number(),y:number()}),literal("auto")]),AnnotationSchema=object({id:ResourceIdSchema,target:AnnotationTargetSchema,position:PositionSchema.default("auto"),body:string(),collapsed:boolean().optional(),author:_enum(["user","agent"]),cloud:object({commentId:string().min(1),slug:string().min(1),author:string().optional()}).optional()}),CanvasNoteAttachmentSchema=object({frameId:ResourceIdSchema,screenId:ResourceIdSchema,locator:AnnotationLocatorSchema}),CanvasNoteSchema=object({id:ResourceIdSchema,x:number().optional(),y:number().optional(),width:number().positive(),body:string(),attachment:CanvasNoteAttachmentSchema.optional()}).refine((note)=>note.attachment!==void 0||note.x!==void 0&&note.y!==void 0,{message:"A note without an attachment needs x and y",path:["x"]});var GeneratedAssetSchema=object({prompt:string(),intent:string(),aspect:string().optional(),width:number().int().positive().optional(),height:number().int().positive().optional(),generatedAt:string(),reference:array(string()).optional(),replaces:string().optional()}),AssetsFileSchema=object({version:literal(1),generated:record(string(),GeneratedAssetSchema)}),EMPTY_ASSETS_FILE={version:1,generated:{}};var FrameSchemeSchema=_enum(["light","dark"]),FrameSchema=object({id:ResourceIdSchema,screen:string().min(1),x:number(),y:number(),w:number().int().positive(),h:number().int().positive(),label:string().optional(),group:string().optional(),scheme:FrameSchemeSchema.optional()});var BoardGroupSchema=object({id:ResourceIdSchema,name:string().min(1),color:string().optional()}),MAX_BOARD_NAME_LENGTH=80,BoardSchema=object({id:ResourceIdSchema,name:string().min(1),theme:string().min(1).optional(),archivedAt:string().datetime().optional(),group:string().min(1).optional(),frames:array(FrameSchema).default([]),groups:array(BoardGroupSchema).default([])});function isArchived(board){return board.archivedAt!==void 0}var CommentLocatorSchema=union([array(number().int().nonnegative()),string().regex(/^@[a-zA-Z][a-zA-Z0-9_-]*$/)]),CommentBoundsSchema=object({x:number(),y:number(),w:number().nonnegative(),h:number().nonnegative()}),CommentNodeFingerprintSchema=object({ref:string().min(1).optional(),text:string().max(500).optional(),ancestorIds:array(string().min(1)).max(16).optional()}),CommentAnchorSchema=discriminatedUnion("kind",[object({kind:literal("node"),boardId:ResourceIdSchema,frameId:ResourceIdSchema,screenId:ResourceIdSchema,locator:CommentLocatorSchema,bounds:CommentBoundsSchema,fingerprint:CommentNodeFingerprintSchema.optional()}),object({kind:literal("board"),boardId:ResourceIdSchema,x:number(),y:number()})]),CommentAuthorSchema=object({kind:_enum(["user","agent","reviewer"]),displayName:string().min(1).max(200).optional(),accountId:string().min(1).max(200).optional()}),CommentMessageSchema=object({id:uuid2(),author:CommentAuthorSchema,body:string().trim().max(4000),createdAt:exports_iso.datetime(),deletedAt:exports_iso.datetime().optional()}).refine((message)=>message.deletedAt!==void 0||message.body.length>0,{message:"A comment needs something to say",path:["body"]}),CommentOriginSchema=discriminatedUnion("kind",[object({kind:literal("local")}),object({kind:literal("published"),slug:string().min(1),versionId:string().min(1)})]),CommentThreadSchema=object({id:uuid2(),scope:_enum(["local","shared"]),folderId:string().min(1),boardId:ResourceIdSchema,anchor:CommentAnchorSchema.optional(),origin:CommentOriginSchema,status:_enum(["open","resolved"]),messages:array(CommentMessageSchema).min(1),createdAt:exports_iso.datetime(),updatedAt:exports_iso.datetime(),resolvedAt:exports_iso.datetime().optional()});var PropControlSchema=_enum(["boolean","number","string","color","enum","icon"]),ExtensionPropDescriptorSchema=object({name:string().min(1),type:string().min(1),optional:boolean(),defaultValue:string().optional(),control:PropControlSchema,enumValues:array(union([string(),number()])).optional()}).superRefine((prop,ctx)=>{if(prop.control==="enum"&&(!prop.enumValues||prop.enumValues.length===0))ctx.addIssue({code:"custom",path:["enumValues"],message:`prop "${prop.name}": control "enum" requires a non-empty \`enumValues\` array`})}),ExtensionSchema=object({importPath:string().min(1),category:_enum(["ui","typography"]).optional(),description:string().optional(),props:array(ExtensionPropDescriptorSchema),origin:_enum(["agent","manual"]).optional(),render:_enum(["static","live"]).optional(),app:string().min(1).optional(),fit:_enum(["aspect-video","content"]).optional()});var ViewportPresetSchema=object({name:string().min(1),w:number().int().positive(),h:number().int().positive()}),LibrarySchema=object({id:_enum(["shadcn-upstream","none","mui","antd","chakra"]),version:string().min(1),source:_enum(["binary","cache","in-repo"]),componentsPath:string().min(1)}),CodegenConfigSchema=object({componentsAlias:string().min(1).optional(),componentsDir:string().min(1).optional()}),HostAppSchema=object({root:string().min(1),aliases:record(string().min(1),string().min(1)).optional()}),ConfigSchema=object({schemaVersion:literal(CURRENT_SCHEMA_VERSION),toolVersion:string().min(1),name:DesignNameSchema,folderId:string().regex(/^[A-Za-z0-9_-]{8,64}$/).optional(),libraries:record(string().min(1),LibrarySchema),defaultLibrary:string().min(1),extensions:record(string().min(1),ExtensionSchema).optional(),viewportPresets:array(ViewportPresetSchema).min(1),defaultScreen:string().min(1).optional(),defaultBoard:string().min(1).optional(),boardOrder:array(string().min(1)).optional(),boardGroups:array(BoardGroupSchema).optional(),codegen:CodegenConfigSchema.optional(),styling:object({framework:_enum(["tailwind","none"])}).optional(),hostApp:HostAppSchema.optional(),hostApps:record(string().min(1),HostAppSchema).optional(),feedback:FeedbackPrefsSchema.optional()}).refine((c)=>(c.defaultLibrary in c.libraries),{message:"`defaultLibrary` must name an entry in `libraries`."});var CSS_IDENT_RE=/^[A-Za-z0-9_-]+$/;function isCssIdent(name){return CSS_IDENT_RE.test(name)}function sanitizeCssTokenValue(value){return value.replace(/\*\//g,"").replace(/[<>{};\\]/g,"").replace(/[\r\n]+/g," ").trim()}function neutralizeCssText(css){return css.replace(/<\//g,"<\\/")}function sanitizeGoogleFontSpec(spec){return spec.replace(/[^A-Za-z0-9 +:,.;@_-]/g,"").replace(/ /g,"+")}function pascalizeIconName(name){let trimmed=name.trim();if(trimmed==="")return trimmed;if(!/[-_\s]/.test(trimmed))return trimmed.charAt(0).toUpperCase()+trimmed.slice(1);return trimmed.split(/[-_\s]+/).filter((part)=>part!=="").map((part)=>part.charAt(0).toUpperCase()+part.slice(1)).join("")}var SnippetParamSchema=object({name:string().min(1),type:_enum(["string","number","boolean","node","icon","color","enum"]),default:unknown().optional(),optional:boolean().optional(),enum:array(string()).optional(),min:number().optional(),max:number().optional(),step:number().optional(),description:string().optional()}).superRefine((param,ctx)=>{if(param.type==="enum"){if(!param.enum||param.enum.length===0){ctx.addIssue({code:"custom",path:["enum"],message:`param "${param.name}": type "enum" requires a non-empty \`enum\` array`});return}if(param.default!==void 0&&!param.enum.includes(param.default))ctx.addIssue({code:"custom",path:["default"],message:`param "${param.name}": default ${JSON.stringify(param.default)} is not one of the declared enum values`});return}if(param.default===void 0||param.type==="node")return;let expected=param.type==="number"?"number":param.type==="boolean"?"boolean":"string";if(typeof param.default!==expected)ctx.addIssue({code:"custom",path:["default"],message:`param "${param.name}": default ${JSON.stringify(param.default)} does not match declared type "${param.type}"`})}),SnippetSchema=object({id:ResourceIdSchema,name:string().min(1),params:array(SnippetParamSchema),library:string().min(1).optional(),tree:NodeSchema});var OMITTED=Symbol("velloo.omitted-optional-param"),DROP=Symbol("velloo.drop");function resolveSnippetArgs(snippet,passed){let args={},missing=[];for(let param of snippet.params)if(param.name in passed)args[param.name]=passed[param.name];else if(param.default!==void 0)args[param.name]=param.default;else if(param.optional)args[param.name]=OMITTED;else missing.push(param.name);return{args,missing}}function isTruthy(v){if(v===void 0||v===null||v===OMITTED)return!1;if(typeof v==="boolean")return v;if(typeof v==="number")return v!==0&&!Number.isNaN(v);if(typeof v==="string")return v!=="";return!0}function substituteSnippetParams(value,args){let missing=[],invalid=[];function walk(v,inNodePosition){if(v===null||typeof v!=="object")return v;if(Array.isArray(v))return v.map((item)=>walk(item,inNodePosition)).filter((item)=>item!==DROP);if(typeof v.$param==="string"){let name=v.$param;if(!(name in args)){missing.push(name);return}let resolved=args[name];if(resolved===OMITTED)return DROP;if(inNodePosition&&(resolved===null||typeof resolved!=="object")){invalid.push({param:name,valueType:resolved===null?"null":typeof resolved});return}return resolved}if(typeof v.$if==="string"){let cond=v;if(!(cond.$if in args)){missing.push(cond.$if);return}let matched="eq"in cond?args[cond.$if]===cond.eq:isTruthy(args[cond.$if]);return walk(matched?cond.then:cond.else,inNodePosition)}let isComponentNodeObj=typeof v.$ref==="string",out={};for(let[k,val]of Object.entries(v)){let w=walk(val,isComponentNodeObj&&k==="children");if(w!==DROP)out[k]=w}return out}return{value:walk(value,!1),missing,invalid}}function findNodeById(root,id){if(!isComponentNode(root))return;if(root.$id===id)return root;for(let child of root.children??[]){let hit=findNodeById(child,id);if(hit)return hit}return}function applySnippetOverrides(body,overrides){let clone=structuredClone(body);for(let[key,patch]of Object.entries(overrides)){let target;if(key.startsWith("@"))target=findNodeById(clone,key.slice(1));else{let segments=key===""?[]:key.split(".").map(Number);target=clone;for(let i of segments){if(!target||!isComponentNode(target)||!target.children){target=void 0;break}target=target.children[i]}}if(!target||!isComponentNode(target))continue;let props={...target.props??{}};for(let[k,v]of Object.entries(patch.props))if(v===null)delete props[k];else props[k]=v;target.props=props}return clone}function applySnippetExtraClassName(node,extra){if(isParamRef(node))return node;if(isSnippetInstance(node)){let existing=node.$extraClassName?`${node.$extraClassName} ${extra}`:extra;return{...node,$extraClassName:existing}}if(!isComponentNode(node))return node;let existingClass=typeof node.props?.className==="string"?node.props.className:"",merged=existingClass?`${existingClass} ${extra}`:extra;return{...node,props:{...node.props??{},className:merged}}}var ALLOWED_ELEMENTS=new Map(["a","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","style","svg","switch","symbol","text","textPath","title","tspan","use","view"].map((name)=>[name.toLowerCase(),name])),ACTIVE_ELEMENTS=new Set(["animate","animatecolor","animatemotion","animatetransform","applet","audio","base","embed","foreignobject","form","frame","frameset","iframe","img","input","link","meta","noscript","object","script","set","template","video"]),RAW_TEXT_ELEMENTS=new Set(["iframe","noembed","noframes","noscript","plaintext","script","style","textarea","xmp"]),VOID_ELEMENTS=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),NAMED_ENTITIES={amp:"&",apos:"'",bull:"\u2022",colon:":",copy:"\xA9",deg:"\xB0",divide:"\xF7",gt:">",hellip:"\u2026",laquo:"\xAB",ldquo:"\u201C",lsquo:"\u2018",lt:"<",mdash:"\u2014",middot:"\xB7",nbsp:"\xA0",ndash:"\u2013",NewLine:`
54
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let entry of ctx.seen.entries()){let seen=entry[1];if(schema===entry[0]){extractToDef(entry);continue}if(ctx.external){let ext=ctx.external.registry.get(entry[0])?.id;if(schema!==entry[0]&&ext){extractToDef(entry);continue}}if(ctx.metadataRegistry.get(entry[0])?.id){extractToDef(entry);continue}if(seen.cycle){extractToDef(entry);continue}if(seen.count>1){if(ctx.reused==="ref"){extractToDef(entry);continue}}}if(ctx.external)ctx.sharedDefsExtractedFor=ctx.external}function compactTypeUnion(schema){let options=schema.anyOf;if(!Array.isArray(options)||options.length===0||schema.type!==void 0)return;let types=[];for(let option of options){if(!option||typeof option!=="object")return;compactTypeUnion(option);let keys=Object.keys(option);if(keys.length!==1||keys[0]!=="type")return;let type=option.type;for(let member of Array.isArray(type)?type:[type]){if(typeof member!=="string")return;if(!types.includes(member))types.push(member)}}delete schema.anyOf,schema.type=types.length===1?types[0]:types}var FOLDABLE_KEYS=new Set(["type","properties","required","additionalProperties"]),UNION_KEYS=["oneOf","anyOf"];function undeclaredConstraint(member){let extra=member.additionalProperties;if(extra===void 0||extra===!1||typeof extra!=="object"||extra===null)return null;return Object.keys(extra).length?extra:null}function foldObjects(members){let objects=[];for(let member of members){if(typeof member!=="object"||member.type!=="object")return null;for(let key in member)if(!FOLDABLE_KEYS.has(key))return null;objects.push(member)}let properties={},required=new Set;for(let object of objects){for(let key in object.properties){if(Object.prototype.hasOwnProperty.call(properties,key))continue;let parts=[];for(let other of objects){let part=other.properties?.[key]??undeclaredConstraint(other);if(part===null||part===void 0)continue;if(!parts.some((seen)=>JSON.stringify(seen)===JSON.stringify(part)))parts.push(part)}let merged=parts.length===1?parts[0]:foldObjects(parts)??{allOf:parts};assignProp(properties,key,merged)}for(let key of object.required??[])required.add(key)}let folded={type:"object",properties};if(required.size)folded.required=[...required];if(objects.every((object)=>object.additionalProperties===!1))folded.additionalProperties=!1;else{let constraints=[];for(let object of objects){let constraint=undeclaredConstraint(object);if(constraint&&!constraints.some((seen)=>JSON.stringify(seen)===JSON.stringify(constraint)))constraints.push(constraint)}if(constraints.length===1)folded.additionalProperties=constraints[0];else if(constraints.length>1)folded.additionalProperties={allOf:constraints}}return folded}function foldIntersection(json){let allOf=json.allOf;if(!Array.isArray(allOf)||allOf.length<2)return;for(let key of FOLDABLE_KEYS)if(key in json)return;let unions=allOf.filter((m)=>UNION_KEYS.some((k)=>Array.isArray(m[k]))),folded=null;if(!unions.length)folded=foldObjects(allOf);else{let union=unions[0],keyword=UNION_KEYS.find((k)=>Array.isArray(union[k]));if(Object.keys(union).length!==1)return;let rest=allOf.filter((m)=>m!==union),branches=union[keyword].map((branch)=>foldObjects([...rest,branch]));if(branches.some((b)=>!b))return;folded={[keyword]:branches}}if(!folded)return;delete json.allOf,assignProps(json,folded)}function finalize(ctx,schema){let root=ctx.seen.get(schema);if(!root)throw Error("Unprocessed schema. This is a bug in Zod.");let flattenRef=(zodSchema)=>{let seen=ctx.seen.get(zodSchema);if(seen.ref===null)return;let schema=seen.def??seen.schema,_cached={...schema},ref=seen.ref;if(seen.ref=null,ref){flattenRef(ref);let refSeen=ctx.seen.get(ref),refSchema=refSeen.schema;if(refSchema.$ref&&(ctx.target==="draft-07"||ctx.target==="draft-04"||ctx.target==="openapi-3.0"))schema.allOf=schema.allOf??[],schema.allOf.push(refSchema);else assignProps(schema,refSchema);if(assignProps(schema,_cached),zodSchema._zod.parent===ref)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(!(key in _cached))delete schema[key]}if(refSchema.$ref&&refSeen.def)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(key in refSeen.def&&JSON.stringify(schema[key])===JSON.stringify(refSeen.def[key]))delete schema[key]}}let parent=zodSchema._zod.parent;if(parent&&parent!==ref){flattenRef(parent);let parentSeen=ctx.seen.get(parent);if(parentSeen?.schema.$ref){if(schema.$ref=parentSeen.schema.$ref,parentSeen.def)for(let key in schema){if(key==="$ref"||key==="allOf")continue;if(key in parentSeen.def&&JSON.stringify(schema[key])===JSON.stringify(parentSeen.def[key]))delete schema[key]}}}ctx.override({zodSchema,jsonSchema:schema,path:seen.path??[]})};if(!ctx.external||ctx.sharedEmitDoneFor!==ctx.external){for(let entry of[...ctx.seen.entries()].reverse())flattenRef(entry[0]);if(ctx.target!=="openapi-3.0")for(let entry of ctx.seen.entries())compactTypeUnion(entry[1].def??entry[1].schema);for(let rewrite of ctx.deferred)rewrite();if(ctx.intersections.length){let carriers=new Map;for(let seen of ctx.seen.values())for(let json of[seen.schema,seen.def]){let allOf=json?.allOf;if(!Array.isArray(allOf))continue;let existing=carriers.get(allOf);if(existing)existing.push(json);else carriers.set(allOf,[json])}for(let allOf of ctx.intersections)for(let json of carriers.get(allOf)??[])foldIntersection(json)}}let result={};if(ctx.target==="draft-2020-12")result.$schema="https://json-schema.org/draft/2020-12/schema";else if(ctx.target==="draft-07")result.$schema="http://json-schema.org/draft-07/schema#";else if(ctx.target==="draft-04")result.$schema="http://json-schema.org/draft-04/schema#";else if(ctx.target==="openapi-3.0");if(ctx.external?.uri){let id=ctx.external.registry.get(schema)?.id;if(!id)throw Error("Schema is missing an `id` property");result.$id=ctx.external.uri(id)}assignProps(result,root.defId?root.schema:root.def??root.schema);let rootMetaId=ctx.metadataRegistry.get(schema)?.id;if(rootMetaId!==void 0&&result.id===rootMetaId)delete result.id;let defs=ctx.external?.defs??{};if(!ctx.external||ctx.sharedEmitDoneFor!==ctx.external)for(let entry of ctx.seen.entries()){let seen=entry[1];if(seen.def&&seen.defId){if(seen.def.id===seen.defId)delete seen.def.id;assignProp(defs,seen.defId,seen.def)}}if(ctx.external)ctx.sharedEmitDoneFor=ctx.external;if(ctx.external);else if(Object.keys(defs).length>0)if(ctx.target==="draft-2020-12")result.$defs=defs;else result.definitions=defs;try{let finalized=JSON.parse(JSON.stringify(result));return Object.defineProperty(finalized,"~standard",{value:{...schema["~standard"],jsonSchema:{input:createStandardJSONSchemaMethod(schema,"input",ctx.processors),output:createStandardJSONSchemaMethod(schema,"output",ctx.processors)}},enumerable:!1,writable:!1}),finalized}catch(_err){throw Error("Error converting schema to JSON.")}}function isTransforming(_schema,_ctx){let ctx=_ctx??{seen:new Set};if(ctx.seen.has(_schema))return!1;ctx.seen.add(_schema);let def=_schema._zod.def;if(def.type==="transform")return!0;if(def.type==="array")return isTransforming(def.element,ctx);if(def.type==="set")return isTransforming(def.valueType,ctx);if(def.type==="lazy")return isTransforming(def.getter(),ctx);if(def.type==="promise"||def.type==="optional"||def.type==="nonoptional"||def.type==="nullable"||def.type==="readonly"||def.type==="default"||def.type==="prefault"||def.type==="catch")return isTransforming(def.innerType,ctx);if(def.type==="intersection")return isTransforming(def.left,ctx)||isTransforming(def.right,ctx);if(def.type==="record"||def.type==="map")return isTransforming(def.keyType,ctx)||isTransforming(def.valueType,ctx);if(def.type==="pipe"){if(_schema._zod.traits.has("$ZodCodec"))return!0;return isTransforming(def.in,ctx)||isTransforming(def.out,ctx)}if(def.type==="object"){for(let key in def.shape)if(isTransforming(def.shape[key],ctx))return!0;return!1}if(def.type==="union"){for(let option of def.options)if(isTransforming(option,ctx))return!0;return!1}if(def.type==="tuple"){for(let item of def.items)if(isTransforming(item,ctx))return!0;if(def.rest&&isTransforming(def.rest,ctx))return!0;return!1}return!1}var createToJSONSchemaMethod=(schema,processors={})=>(params)=>{let ctx=initializeContext({...params,processors});return process(schema,ctx),extractDefs(ctx,schema),finalize(ctx,schema)},createStandardJSONSchemaMethod=(schema,io,processors={})=>(params)=>{let{libraryOptions,target}=params??{},ctx=initializeContext({...libraryOptions??{},target,io,processors});return process(schema,ctx),extractDefs(ctx,schema),finalize(ctx,schema)};var formatMap={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},stringProcessor=(schema,ctx,_json,_params)=>{let json=_json;json.type="string";let{minimum,maximum,format,patterns,contentEncoding,laxFormat}=schema._zod.bag;if(typeof minimum==="number")json.minLength=minimum;if(typeof maximum==="number")json.maxLength=maximum;if(format){if(json.format=formatMap[format]??format,json.format==="")delete json.format;if(format==="time"||laxFormat)delete json.format}if(contentEncoding)json.contentEncoding=contentEncoding;if(patterns&&patterns.size>0){let patternList=[...patterns];if(patternList.length===1)json.pattern=patternList[0].source;else if(patternList.length>1)json.allOf=[...patternList.map((regex)=>({...ctx.target==="draft-07"||ctx.target==="draft-04"||ctx.target==="openapi-3.0"?{type:"string"}:{},pattern:regex.source}))]}},numberProcessor=(schema,ctx,_json,params)=>{let json=_json,{minimum,maximum,format,multipleOf,exclusiveMaximum,exclusiveMinimum}=schema._zod.bag;if(typeof format==="string"&&format.includes("int"))json.type="integer";else json.type="number";let exMin=typeof exclusiveMinimum==="number"&&exclusiveMinimum>=(minimum??Number.NEGATIVE_INFINITY),exMax=typeof exclusiveMaximum==="number"&&exclusiveMaximum<=(maximum??Number.POSITIVE_INFINITY),legacy=ctx.target==="draft-04"||ctx.target==="openapi-3.0";if(exMin)if(legacy)json.minimum=exclusiveMinimum,json.exclusiveMinimum=!0;else json.exclusiveMinimum=exclusiveMinimum;else if(typeof minimum==="number")json.minimum=minimum;if(exMax)if(legacy)json.maximum=exclusiveMaximum,json.exclusiveMaximum=!0;else json.exclusiveMaximum=exclusiveMaximum;else if(typeof maximum==="number")json.maximum=maximum;if(typeof multipleOf==="number")if(Number.isFinite(multipleOf)&&multipleOf!==0)json.multipleOf=Math.abs(multipleOf);else handleUnrepresentable(schema,ctx,json,params,`A multipleOf divisor of ${multipleOf} cannot be represented in JSON Schema`)},booleanProcessor=(_schema,_ctx,json,_params)=>{json.type="boolean"},bigintProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"BigInt cannot be represented in JSON Schema")},symbolProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Symbols cannot be represented in JSON Schema")},nullProcessor=(_schema,ctx,json,_params)=>{if(ctx.target==="openapi-3.0")json.type="string",json.nullable=!0,json.enum=[null];else json.type="null"},undefinedProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Undefined cannot be represented in JSON Schema")},voidProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Void cannot be represented in JSON Schema")},neverProcessor=(_schema,_ctx,json,_params)=>{json.not={}},anyProcessor=(_schema,_ctx,_json,_params)=>{},unknownProcessor=(_schema,_ctx,_json,_params)=>{},dateProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Date cannot be represented in JSON Schema")},enumProcessor=(schema,_ctx,json,_params)=>{let def=schema._zod.def,values=getEnumValues(def.entries);if(values.length===0){json.not={};return}if(values.every((v)=>typeof v==="number"))json.type="number";if(values.every((v)=>typeof v==="string"))json.type="string";json.enum=values},literalProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;if(def.values.length===0){json.not={};return}let vals=[];for(let val of def.values)if(val===void 0){if(handleUnrepresentable(schema,ctx,json,params,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof val==="bigint"){if(handleUnrepresentable(schema,ctx,json,params,"BigInt literals cannot be represented in JSON Schema"))return;vals.push(Number(val))}else vals.push(val);if(vals.length===0);else if(vals.length===1){let val=vals[0];if(json.type=val===null?"null":typeof val,ctx.target==="draft-04"||ctx.target==="openapi-3.0")json.enum=[val];else json.const=val}else{if(vals.every((v)=>typeof v==="number"))json.type="number";if(vals.every((v)=>typeof v==="string"))json.type="string";if(vals.every((v)=>typeof v==="boolean"))json.type="boolean";if(vals.every((v)=>v===null))json.type="null";json.enum=vals}},nanProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"NaN cannot be represented in JSON Schema")},templateLiteralProcessor=(schema,_ctx,json,_params)=>{let _json=json,pattern=schema._zod.pattern;if(!pattern)throw Error("Pattern not found in template literal");_json.type="string",_json.pattern=pattern.source},fileProcessor=(schema,_ctx,json,_params)=>{let _json=json,file={type:"string",format:"binary",contentEncoding:"binary"},{minimum,maximum,mime}=schema._zod.bag;if(minimum!==void 0)file.minLength=minimum;if(maximum!==void 0)file.maxLength=maximum;if(mime)if(mime.length===1)file.contentMediaType=mime[0],Object.assign(_json,file);else Object.assign(_json,file),_json.anyOf=mime.map((m)=>({contentMediaType:m}));else Object.assign(_json,file)},successProcessor=(_schema,_ctx,json,_params)=>{json.type="boolean"},customProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Custom types cannot be represented in JSON Schema")},functionProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Function types cannot be represented in JSON Schema")},transformProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Transforms cannot be represented in JSON Schema")},mapProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Map cannot be represented in JSON Schema")},setProcessor=(schema,ctx,json,params)=>{handleUnrepresentable(schema,ctx,json,params,"Set cannot be represented in JSON Schema")},arrayProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def,{minimum,maximum}=schema._zod.bag;if(typeof minimum==="number")json.minItems=minimum;if(typeof maximum==="number")json.maxItems=maximum;json.type="array",json.items=process(def.element,ctx,{...params,path:[...params.path,"items"]})};function inputOptin(schema){let def=schema._zod.def;if(def.type==="pipe"&&def.in._zod.traits.has("$ZodTransform"))return inputOptin(def.out);if(def.type==="catch")return inputOptin(def.innerType);return schema._zod.optin}var objectProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def,shape=def.shape;if(Object.getOwnPropertySymbols(shape).length&&handleUnrepresentable(schema,ctx,json,params,"Symbol keys cannot be represented in JSON Schema"))return;json.type="object",json.properties={};for(let key in shape)assignProp(json.properties,key,process(shape[key],ctx,{...params,path:[...params.path,"properties",key]}));let allKeys=new Set(Object.keys(shape)),requiredKeys=new Set([...allKeys].filter((key)=>{let field=def.shape[key];if(ctx.io==="input")return inputOptin(field)===void 0;else return field._zod.optout===void 0}));if(requiredKeys.size>0)json.required=Array.from(requiredKeys);if(def.catchall?._zod.def.type==="never")json.additionalProperties=!1;else if(!def.catchall){if(ctx.io==="output")json.additionalProperties=!1}else if(def.catchall)json.additionalProperties=process(def.catchall,ctx,{...params,path:[...params.path,"additionalProperties"]})},unionProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,isExclusive=def.inclusive===!1,options=def.options.map((x,i)=>process(x,ctx,{...params,path:[...params.path,isExclusive?"oneOf":"anyOf",i]}));if(isExclusive)json.oneOf=options;else json.anyOf=options},intersectionProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,a=process(def.left,ctx,{...params,path:[...params.path,"allOf",0]}),b=process(def.right,ctx,{...params,path:[...params.path,"allOf",1]}),isSimpleIntersection=(val)=>("allOf"in val)&&Object.keys(val).length===1,allOf=[...isSimpleIntersection(a)?a.allOf:[a],...isSimpleIntersection(b)?b.allOf:[b]];json.allOf=allOf,ctx.intersections.push(allOf)},tupleProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def;json.type="array";let prefixPath=ctx.target==="draft-2020-12"?"prefixItems":"items",restPath=ctx.target==="draft-2020-12"?"items":ctx.target==="openapi-3.0"?"items":"additionalItems",prefixItems=def.items.map((x,i)=>process(x,ctx,{...params,path:[...params.path,prefixPath,i]})),rest=def.rest?process(def.rest,ctx,{...params,path:[...params.path,restPath,...ctx.target==="openapi-3.0"?[def.items.length]:[]]}):null,minItems=def.items.length;while(minItems>0){let item=def.items[minItems-1];if(!(ctx.io==="input"?inputOptin(item)!==void 0:item._zod.optout==="optional"))break;minItems--}let maxItems=def.items.length,isClosed=!def.rest;if(ctx.target==="draft-2020-12"){if(json.prefixItems=prefixItems,isClosed)json.items=!1;else if(rest)json.items=rest;if(minItems>0)json.minItems=minItems;if(isClosed)json.maxItems=maxItems}else if(ctx.target==="openapi-3.0"){if(json.items={anyOf:prefixItems},rest)json.items.anyOf.push(rest);if(minItems>0)json.minItems=minItems;if(isClosed)json.maxItems=maxItems}else{if(json.items=prefixItems,isClosed)json.additionalItems=!1;else if(rest)json.additionalItems=rest;if(minItems>0)json.minItems=minItems;if(isClosed)json.maxItems=maxItems}let{minimum,maximum}=schema._zod.bag;if(typeof minimum==="number")json.minItems=minimum;if(typeof maximum==="number")json.maxItems=maximum};function stringifyKeyNames(bySchema,json,visited){if(json.$ref){if(visited.has(json))return json;visited.add(json);let def=bySchema.get(json)?.def;if(!def)return json;let inlined=stringifyKeyNames(bySchema,def,visited);return inlined===def?json:inlined}for(let keyword of["anyOf","oneOf"]){let branches=json[keyword];if(!Array.isArray(branches))continue;let mapped=branches.map((branch)=>stringifyKeyNames(bySchema,branch,visited));if(mapped.some((branch,i)=>branch!==branches[i]))json={...json,[keyword]:mapped}}let types=Array.isArray(json.type)?json.type:[json.type],numericType=!types.includes("string")&&types.some((t)=>t==="number"||t==="integer"),values=json.enum??(json.const!==void 0?[json.const]:void 0);if(!numericType&&!values?.some((v)=>typeof v==="number"))return json;let{minimum,maximum,exclusiveMinimum,exclusiveMaximum,multipleOf,format,id,...rest}=json;if(rest.enum)rest.enum=rest.enum.map((v)=>typeof v==="number"?String(v):v);else if(typeof rest.const==="number")rest.const=String(rest.const);if(!numericType)return rest;if(rest.type="string",!values)rest.pattern=(types.includes("number")?number2:integer).source;return rest}var pendingRecords=new WeakMap;function rewriteKeyNames(ctx){let bySchema=new Map;for(let entry of ctx.seen.values())if(entry.def&&!bySchema.has(entry.schema))bySchema.set(entry.schema,entry);let rewrites=new Map;for(let record of pendingRecords.get(ctx)??[]){let seen=ctx.seen.get(record),names=(seen?.def??seen?.schema)?.propertyNames;if(!names||names===!0||rewrites.has(names))continue;let rewritten=stringifyKeyNames(bySchema,names,new Set);if(rewritten!==names)rewrites.set(names,rewritten)}if(!rewrites.size)return;for(let entry of ctx.seen.values())for(let carrier of[entry.schema,entry.def]){let rewritten=carrier&&rewrites.get(carrier.propertyNames);if(rewritten)carrier.propertyNames=rewritten}}var recordProcessor=(schema,ctx,_json,params)=>{let json=_json,def=schema._zod.def;json.type="object";let keyType=def.keyType,patterns=keyType._zod.bag?.patterns;if(def.mode==="loose"&&patterns&&patterns.size>0){let valueSchema=process(def.valueType,ctx,{...params,path:[...params.path,"patternProperties","*"]});json.patternProperties={};for(let pattern of patterns)assignProp(json.patternProperties,pattern.source,valueSchema)}else{if(ctx.target==="draft-07"||ctx.target==="draft-2020-12"){json.propertyNames=process(def.keyType,ctx,{...params,path:[...params.path,"propertyNames"]});let pending=pendingRecords.get(ctx);if(!pending)pending=[],pendingRecords.set(ctx,pending),ctx.deferred.push(()=>rewriteKeyNames(ctx));pending.push(schema)}json.additionalProperties=process(def.valueType,ctx,{...params,path:[...params.path,"additionalProperties"]})}let keyValues=keyType._zod.values,omittableOnInput=ctx.io==="input"&&inputOptin(def.valueType)!==void 0;if(keyValues&&!def.partial&&!omittableOnInput){let validKeyValues=[...keyValues].filter((v)=>typeof v==="string"||typeof v==="number");if(validKeyValues.length>0)json.required=validKeyValues.map(String)}},nullableProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def,inner=process(def.innerType,ctx,params),seen=ctx.seen.get(schema);if(ctx.target==="openapi-3.0")seen.ref=def.innerType,json.nullable=!0;else json.anyOf=[inner,{type:"null"}]},nonoptionalProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType},UNREPRESENTABLE_DEFAULT=Symbol();function serializeDefaultValue(value,schema,ctx,json,params){let unrepresentable=!1,serialized=JSON.stringify(value,(_,val)=>{if(typeof val!=="bigint")return val;return unrepresentable=!0,null});if(!unrepresentable)return JSON.parse(serialized);return handleUnrepresentable(schema,ctx,json,params,"BigInt defaults cannot be represented in JSON Schema"),UNREPRESENTABLE_DEFAULT}var defaultProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType;let value=serializeDefaultValue(def.defaultValue,schema,ctx,json,params);if(value!==UNREPRESENTABLE_DEFAULT)json.default=value},prefaultProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);if(seen.ref=def.innerType,ctx.io!=="input")return;let value=serializeDefaultValue(def.defaultValue,schema,ctx,json,params);if(value!==UNREPRESENTABLE_DEFAULT)json._prefault=value},catchProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType;let catchValue;try{catchValue=def.catchValue(void 0)}catch{handleUnrepresentable(schema,ctx,json,params,"Dynamic catch values are not supported in JSON Schema");return}json.default=catchValue},pipeProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def,inIsTransform=def.in._zod.traits.has("$ZodTransform"),innerType=ctx.io==="input"?inIsTransform?def.out:def.in:def.out;process(innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=innerType},readonlyProcessor=(schema,ctx,json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType,json.readOnly=!0},promiseProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType},optionalProcessor=(schema,ctx,_json,params)=>{let def=schema._zod.def;process(def.innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=def.innerType},lazyProcessor=(schema,ctx,_json,params)=>{let innerType=schema._zod.innerType;process(innerType,ctx,params);let seen=ctx.seen.get(schema);seen.ref=innerType},allProcessors={string:stringProcessor,number:numberProcessor,boolean:booleanProcessor,bigint:bigintProcessor,symbol:symbolProcessor,null:nullProcessor,undefined:undefinedProcessor,void:voidProcessor,never:neverProcessor,any:anyProcessor,unknown:unknownProcessor,date:dateProcessor,enum:enumProcessor,literal:literalProcessor,nan:nanProcessor,template_literal:templateLiteralProcessor,file:fileProcessor,success:successProcessor,custom:customProcessor,function:functionProcessor,transform:transformProcessor,map:mapProcessor,set:setProcessor,array:arrayProcessor,object:objectProcessor,union:unionProcessor,intersection:intersectionProcessor,tuple:tupleProcessor,record:recordProcessor,nullable:nullableProcessor,nonoptional:nonoptionalProcessor,default:defaultProcessor,prefault:prefaultProcessor,catch:catchProcessor,pipe:pipeProcessor,readonly:readonlyProcessor,promise:promiseProcessor,optional:optionalProcessor,lazy:lazyProcessor};function toJSONSchema(input,params){if("_idmap"in input){let registry=input,ctx=initializeContext({...params,processors:allProcessors}),defs={};for(let entry of registry._idmap.entries()){let[_,schema]=entry;process(schema,ctx)}let schemas={},external={registry,uri:params?.uri,defs};ctx.external=external;for(let entry of registry._idmap.entries()){let[key,schema]=entry;extractDefs(ctx,schema),assignProp(schemas,key,finalize(ctx,schema))}if(Object.keys(defs).length>0){let defsSegment=ctx.target==="draft-2020-12"?"$defs":"definitions";schemas.__shared={[defsSegment]:defs}}return{schemas}}let ctx=initializeContext({...params,processors:allProcessors});return process(input,ctx),extractDefs(ctx,input),finalize(ctx,input)}var _installedErrorProtos=new WeakSet([Object.prototype,Error.prototype]);function _lazyMethod(proto,key,make){Object.defineProperty(proto,key,{configurable:!0,enumerable:!1,get(){let value=make(this);return Object.defineProperty(this,key,{value,configurable:!0,writable:!0}),value},set(value){Object.defineProperty(this,key,{value,configurable:!0,writable:!0})}})}var initializer2=(inst,issues)=>{$ZodError.init(inst,issues),inst.name="ZodError";let proto=Object.getPrototypeOf(inst);if(_installedErrorProtos.has(proto))return;_installedErrorProtos.add(proto),_lazyMethod(proto,"format",(self)=>(mapper)=>formatError(self,mapper)),_lazyMethod(proto,"flatten",(self)=>(mapper)=>flattenError(self,mapper)),_lazyMethod(proto,"addIssue",(self)=>(issue)=>{self.issues.push(issue),self.message=JSON.stringify(self.issues,jsonStringifyReplacer,2)}),_lazyMethod(proto,"addIssues",(self)=>(issues)=>{self.issues.push(...issues),self.message=JSON.stringify(self.issues,jsonStringifyReplacer,2)}),Object.defineProperty(proto,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})},ZodError=$constructor("ZodError",initializer2),ZodRealError=$constructor("ZodError",initializer2,void 0,{Parent:Error});var parse3=_parse(ZodRealError),parseAsync2=_parseAsync(ZodRealError),safeParse2=_safeParse(ZodRealError),safeParseAsync2=_safeParseAsync(ZodRealError),encode=_encode(ZodRealError),decode=_decode(ZodRealError),encodeAsync=_encodeAsync(ZodRealError),decodeAsync=_decodeAsync(ZodRealError),safeEncode=_safeEncode(ZodRealError),safeDecode=_safeDecode(ZodRealError),safeEncodeAsync=_safeEncodeAsync(ZodRealError),safeDecodeAsync=_safeDecodeAsync(ZodRealError);function _ensureDefaultLocale(){if(!globalConfig.localeError)config(en_default())}function _ensureDefaultMemoizer(){if(!globalConfig.memoizer)config({memoizer:memoizer()})}var ZodType=$constructor("ZodType",(inst,def)=>(_ensureDefaultLocale(),$ZodType.init(inst,def),inst.def=def,inst.type=def.type,inst),{check(...chks){let def=this.def;return this.clone(mergeDefs(def,{checks:[...def.checks??[],...chks.map((ch)=>typeof ch==="function"?{_zod:{check:ch,def:{check:"custom"},onattach:[]}}:ch)]}),{parent:!0})},with(...chks){return this.check(...chks)},clone(def,params){return clone(this,def,params)},brand(){return this},register(reg,meta){return reg.add(this,meta),this},refine(check,params){return this.check(refine(check,params))},superRefine(refinement,params){return this.check(superRefine(refinement,params))},overwrite(fn){return this.check(_overwrite(fn))},optional(){return optional(this)},exactOptional(){return exactOptional(this)},nullable(){return nullable(this)},nullish(){return optional(nullable(this))},nonoptional(params){return nonoptional(this,params)},array(){return array(this)},or(arg){return union([this,arg])},and(arg){return intersection(this,arg)},transform(tx){return pipe(this,transform(tx))},default(d){return _default(this,d)},prefault(d){return prefault(this,d)},catch(params){return _catch(this,params)},pipe(target){return pipe(this,target)},readonly(){return readonly(this)},describe(description){let cl=this.clone();return globalRegistry.add(cl,{description}),cl},meta(...args){if(args.length===0)return globalRegistry.get(this);let cl=this.clone();return globalRegistry.add(cl,args[0]),cl},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(fn,...args){return args.length===0?fn(this):fn(this,...args)},get "~standard"(){return hide(this,"~standard",{...standardProps(this),jsonSchema:{input:createStandardJSONSchemaMethod(this,"input"),output:createStandardJSONSchemaMethod(this,"output")}})},set "~standard"(value){own(this,"~standard",value)},parse:function _parse(data,params){return parse3(this,data,params,{callee:_parse})},parseAsync:async function _parseAsync(data,params){return await parseAsync2(this,data,params,{callee:_parseAsync})},safeParse(data,params){return safeParse2(this,data,params)},async safeParseAsync(data,params){return safeParseAsync2(this,data,params)},get spa(){return this?.safeParseAsync},set spa(value){own(this,"spa",value)},encode:function _encode(data,params){return encode(this,data,params,{callee:_encode})},decode:function _decode(data,params){return decode(this,data,params,{callee:_decode})},encodeAsync:async function _encodeAsync(data,params){return await encodeAsync(this,data,params,{callee:_encodeAsync})},decodeAsync:async function _decodeAsync(data,params){return await decodeAsync(this,data,params,{callee:_decodeAsync})},safeEncode(data,params){return safeEncode(this,data,params)},safeDecode(data,params){return safeDecode(this,data,params)},async safeEncodeAsync(data,params){return safeEncodeAsync(this,data,params)},async safeDecodeAsync(data,params){return safeDecodeAsync(this,data,params)},toJSONSchema(params){return createToJSONSchemaMethod(this,{})(params)},get description(){return globalRegistry.get(this)?.description},get _def(){return this._zod.def}}),_ZodString=$constructor("_ZodString",(inst,def)=>{$ZodString.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>stringProcessor(inst,ctx,json,params);let bag=inst._zod.bag;inst.format=bag.format??null,inst.minLength=bag.minimum??null,inst.maxLength=bag.maximum??null},{regex(...args){return this.check(_regex(...args))},includes(...args){return this.check(_includes(...args))},startsWith(...args){return this.check(_startsWith(...args))},endsWith(...args){return this.check(_endsWith(...args))},min(...args){return this.check(_minLength(...args))},max(...args){return this.check(_maxLength(...args))},length(...args){return this.check(_length(...args))},nonempty(...args){return this.check(_minLength(1,...args))},lowercase(params){return this.check(_lowercase(params))},uppercase(params){return this.check(_uppercase(params))},trim(){return this.check(_trim())},normalize(...args){return this.check(_normalize(...args))},toLowerCase(){return this.check(_toLowerCase())},toUpperCase(){return this.check(_toUpperCase())},slugify(){return this.check(_slugify())}}),ZodString=$constructor("ZodString",(inst,def)=>{$ZodString.init(inst,def),_ZodString.init(inst,def)},{email(params){return this.check(_email(ZodEmail,params))},url(params){return this.check(_url(ZodURL,params))},jwt(params){return this.check(_jwt(ZodJWT,params))},emoji(params){return this.check(_emoji2(ZodEmoji,params))},guid(params){return this.check(_guid(ZodGUID,params))},uuid(params){return this.check(_uuid(ZodUUID,params))},uuidv4(params){return this.check(_uuidv4(ZodUUID,params))},uuidv6(params){return this.check(_uuidv6(ZodUUID,params))},uuidv7(params){return this.check(_uuidv7(ZodUUID,params))},nanoid(params){return this.check(_nanoid(ZodNanoID,params))},cuid(params){return this.check(_cuid(ZodCUID,params))},cuid2(params){return this.check(_cuid2(ZodCUID2,params))},ulid(params){return this.check(_ulid(ZodULID,params))},base64(params){return this.check(_base64(ZodBase64,params))},base64url(params){return this.check(_base64url(ZodBase64URL,params))},xid(params){return this.check(_xid(ZodXID,params))},ksuid(params){return this.check(_ksuid(ZodKSUID,params))},ipv4(params){return this.check(_ipv4(ZodIPv4,params))},ipv6(params){return this.check(_ipv6(ZodIPv6,params))},cidrv4(params){return this.check(_cidrv4(ZodCIDRv4,params))},cidrv6(params){return this.check(_cidrv6(ZodCIDRv6,params))},e164(params){return this.check(_e164(ZodE164,params))},datetime(params){return this.check(_isoDateTime(ZodISODateTime,params))},date(params){return this.check(_isoDate(ZodISODate,params))},time(params){return this.check(_isoTime(ZodISOTime,params))},duration(params){return this.check(_isoDuration(ZodISODuration,params))}});function string(params){return _string(ZodString,params)}var ZodStringFormat=$constructor("ZodStringFormat",(inst,def)=>{$ZodStringFormat.init(inst,def),_ZodString.init(inst,def)}),ZodISODateTime=$constructor("ZodISODateTime",(inst,def)=>{$ZodISODateTime.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISODate=$constructor("ZodISODate",(inst,def)=>{$ZodISODate.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISOTime=$constructor("ZodISOTime",(inst,def)=>{$ZodISOTime.init(inst,def),ZodStringFormat.init(inst,def)}),ZodISODuration=$constructor("ZodISODuration",(inst,def)=>{$ZodISODuration.init(inst,def),ZodStringFormat.init(inst,def)}),ZodEmail=$constructor("ZodEmail",(inst,def)=>{$ZodEmail.init(inst,def),ZodStringFormat.init(inst,def)});var ZodGUID=$constructor("ZodGUID",(inst,def)=>{$ZodGUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodUUID=$constructor("ZodUUID",(inst,def)=>{$ZodUUID.init(inst,def),ZodStringFormat.init(inst,def)});function uuid2(params){return _uuid(ZodUUID,params)}var ZodURL=$constructor("ZodURL",(inst,def)=>{$ZodURL.init(inst,def),ZodStringFormat.init(inst,def)});function url(params){return _url(ZodURL,params)}var ZodEmoji=$constructor("ZodEmoji",(inst,def)=>{$ZodEmoji.init(inst,def),ZodStringFormat.init(inst,def)});var ZodNanoID=$constructor("ZodNanoID",(inst,def)=>{$ZodNanoID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCUID=$constructor("ZodCUID",(inst,def)=>{$ZodCUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCUID2=$constructor("ZodCUID2",(inst,def)=>{$ZodCUID2.init(inst,def),ZodStringFormat.init(inst,def)});var ZodULID=$constructor("ZodULID",(inst,def)=>{$ZodULID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodXID=$constructor("ZodXID",(inst,def)=>{$ZodXID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodKSUID=$constructor("ZodKSUID",(inst,def)=>{$ZodKSUID.init(inst,def),ZodStringFormat.init(inst,def)});var ZodIPv4=$constructor("ZodIPv4",(inst,def)=>{$ZodIPv4.init(inst,def),ZodStringFormat.init(inst,def)});var ZodIPv6=$constructor("ZodIPv6",(inst,def)=>{$ZodIPv6.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCIDRv4=$constructor("ZodCIDRv4",(inst,def)=>{$ZodCIDRv4.init(inst,def),ZodStringFormat.init(inst,def)});var ZodCIDRv6=$constructor("ZodCIDRv6",(inst,def)=>{$ZodCIDRv6.init(inst,def),ZodStringFormat.init(inst,def)});var ZodBase64=$constructor("ZodBase64",(inst,def)=>{$ZodBase64.init(inst,def),ZodStringFormat.init(inst,def)});var ZodBase64URL=$constructor("ZodBase64URL",(inst,def)=>{$ZodBase64URL.init(inst,def),ZodStringFormat.init(inst,def)});var ZodE164=$constructor("ZodE164",(inst,def)=>{$ZodE164.init(inst,def),ZodStringFormat.init(inst,def)});var ZodJWT=$constructor("ZodJWT",(inst,def)=>{$ZodJWT.init(inst,def),ZodStringFormat.init(inst,def)});var ZodNumber=$constructor("ZodNumber",(inst,def)=>{$ZodNumber.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>numberProcessor(inst,ctx,json,params);let bag=inst._zod.bag;inst.minValue=Math.max(bag.minimum??Number.NEGATIVE_INFINITY,bag.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,inst.maxValue=Math.min(bag.maximum??Number.POSITIVE_INFINITY,bag.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,inst.isInt=(bag.format??"").includes("int")||Number.isSafeInteger(bag.multipleOf??0.5),inst.isFinite=!0,inst.format=bag.format??null},{gt(value,params){return this.check(_gt(value,params))},gte(value,params){return this.check(_gte(value,params))},min(value,params){return this.check(_gte(value,params))},lt(value,params){return this.check(_lt(value,params))},lte(value,params){return this.check(_lte(value,params))},max(value,params){return this.check(_lte(value,params))},int(params){return this.check(int(params))},safe(params){return this.check(int(params))},positive(params){return this.check(_gt(0,params))},nonnegative(params){return this.check(_gte(0,params))},negative(params){return this.check(_lt(0,params))},nonpositive(params){return this.check(_lte(0,params))},multipleOf(value,params){return this.check(_multipleOf(value,params))},step(value,params){return this.check(_multipleOf(value,params))},finite(){return this}});function number(params){return _number(ZodNumber,params)}var ZodNumberFormat=$constructor("ZodNumberFormat",(inst,def)=>{$ZodNumberFormat.init(inst,def),ZodNumber.init(inst,def)});function int(params){return _int(ZodNumberFormat,params)}var ZodBoolean=$constructor("ZodBoolean",(inst,def)=>{$ZodBoolean.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>booleanProcessor(inst,ctx,json,params)});function boolean(params){return _boolean(ZodBoolean,params)}var ZodNull=$constructor("ZodNull",(inst,def)=>{$ZodNull.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nullProcessor(inst,ctx,json,params)});function _null(params){return _null3(ZodNull,params)}var ZodAny=$constructor("ZodAny",(inst,def)=>{$ZodAny.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>anyProcessor(inst,ctx,json,params)});function any(){return _any(ZodAny)}var ZodUnknown=$constructor("ZodUnknown",(inst,def)=>{$ZodUnknown.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>unknownProcessor(inst,ctx,json,params)});function unknown(){return _unknown(ZodUnknown)}var ZodNever=$constructor("ZodNever",(inst,def)=>{$ZodNever.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>neverProcessor(inst,ctx,json,params)});function never(params){return _never(ZodNever,params)}var ZodArray=$constructor("ZodArray",(inst,def)=>{_ensureDefaultMemoizer(),$ZodArray.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>arrayProcessor(inst,ctx,json,params),inst.element=def.element},{min(n,params){return this.check(_minLength(n,params))},nonempty(params){return this.check(_minLength(1,params))},max(n,params){return this.check(_maxLength(n,params))},length(n,params){return this.check(_length(n,params))},unwrap(){return this.element}});function array(element,params){return _array(ZodArray,element,params)}var ZodObject=$constructor("ZodObject",(inst,def)=>{_ensureDefaultMemoizer(),$ZodObjectJIT.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>objectProcessor(inst,ctx,json,params),installLazyProp(inst,"shape",(self)=>self._zod.def.shape,!1)},{keyof(){return _enum(Object.keys(this._zod.def.shape))},catchall(catchall){return this.clone({...this._zod.def,catchall})},passthrough(){return this.clone({...this._zod.def,catchall:unknown()})},loose(){return this.clone({...this._zod.def,catchall:unknown()})},strict(){return this.clone({...this._zod.def,catchall:never()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(incoming){return extend(this,incoming)},safeExtend(incoming){return safeExtend(this,incoming)},merge(other){return merge(this,other)},pick(mask){return pick(this,mask)},omit(mask){return omit(this,mask)},partial(...args){return partial(ZodOptional,this,args[0])},exactPartial(...args){return partial(ZodExactOptional,this,args[0],"exactPartial")},required(...args){return required(ZodNonOptional,this,args[0])}});function object(shape,params){let def={type:"object",shape:shape??{},...normalizeParams(params)};return new ZodObject(def)}function strictObject(shape,params){return new ZodObject({type:"object",shape,catchall:never(),...normalizeParams(params)})}function looseObject(shape,params){return new ZodObject({type:"object",shape,catchall:unknown(),...normalizeParams(params)})}var ZodUnion=$constructor("ZodUnion",(inst,def)=>{$ZodUnion.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>unionProcessor(inst,ctx,json,params),inst.options=def.options});function union(options,params){return new ZodUnion({type:"union",options,...normalizeParams(params)})}var ZodDiscriminatedUnion=$constructor("ZodDiscriminatedUnion",(inst,def)=>{ZodUnion.init(inst,def),$ZodDiscriminatedUnion.init(inst,def)});function discriminatedUnion(discriminator,options,params){return new ZodDiscriminatedUnion({type:"union",options,discriminator,...normalizeParams(params)})}var ZodIntersection=$constructor("ZodIntersection",(inst,def)=>{$ZodIntersection.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>intersectionProcessor(inst,ctx,json,params)});function intersection(left,right){return new ZodIntersection({type:"intersection",left,right})}var ZodRecord=$constructor("ZodRecord",(inst,def)=>{_ensureDefaultMemoizer(),$ZodRecord.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>recordProcessor(inst,ctx,json,params),inst.keyType=def.keyType,inst.valueType=def.valueType});function record(keyType,valueType,params){if(!valueType||!valueType._zod)return new ZodRecord({type:"record",keyType:string(),valueType:keyType,...normalizeParams(valueType)});return new ZodRecord({type:"record",keyType,valueType,...normalizeParams(params)})}var ZodEnum=$constructor("ZodEnum",(inst,def)=>{$ZodEnum.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>enumProcessor(inst,ctx,json,params),inst.enum=def.entries,inst.options=Object.values(def.entries);let keys=new Set(Object.keys(def.entries));inst.extract=(values,params)=>{let newEntries={};for(let value of values)if(keys.has(value))newEntries[value]=def.entries[value];else throw Error(`Key ${value} not found in enum`);return new ZodEnum({...def,checks:[],...normalizeParams(params),entries:newEntries})},inst.exclude=(values,params)=>{let newEntries={...def.entries};for(let value of values)if(keys.has(value))delete newEntries[value];else throw Error(`Key ${value} not found in enum`);return new ZodEnum({...def,checks:[],...normalizeParams(params),entries:newEntries})}});function _enum(values,params){let entries=Array.isArray(values)?Object.fromEntries(values.map((v)=>[v,v])):values;return new ZodEnum({type:"enum",entries,...normalizeParams(params)})}var ZodLiteral=$constructor("ZodLiteral",(inst,def)=>{$ZodLiteral.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>literalProcessor(inst,ctx,json,params),inst.values=new Set(def.values),Object.defineProperty(inst,"value",{get(){if(def.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return def.values[0]}})});function literal(value,params){return new ZodLiteral({type:"literal",values:Array.isArray(value)?value:[value],...normalizeParams(params)})}var ZodTransform=$constructor("ZodTransform",(inst,def)=>{_ensureDefaultMemoizer(),$ZodTransform.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>transformProcessor(inst,ctx,json,params),inst._zod.parse=(payload,_ctx)=>{if(_ctx.direction==="backward")throw new $ZodEncodeError(inst.constructor.name);payload.addIssue=(issue2)=>{if(typeof issue2==="string")payload.issues.push(issue(issue2,payload.value,def));else{let _issue=issue2;if(_issue.fatal)_issue.continue=!1;if(_issue.code??(_issue.code="custom"),!("input"in _issue))_issue.input=payload.value;_issue.inst??(_issue.inst=inst),payload.issues.push(issue(_issue))}};let output=def.transform(payload.value,payload);if(output instanceof Promise)return output.then((output)=>(payload.value=output,payload));return payload.value=output,payload}});function transform(fn){return new ZodTransform({type:"transform",transform:fn})}var ZodOptional=$constructor("ZodOptional",(inst,def)=>{$ZodOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>optionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function optional(innerType){return new ZodOptional({type:"optional",innerType})}var ZodExactOptional=$constructor("ZodExactOptional",(inst,def)=>{$ZodExactOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>optionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function exactOptional(innerType){return new ZodExactOptional({type:"optional",innerType})}var ZodNullable=$constructor("ZodNullable",(inst,def)=>{$ZodNullable.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nullableProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function nullable(innerType){return new ZodNullable({type:"nullable",innerType})}var ZodDefault=$constructor("ZodDefault",(inst,def)=>{$ZodDefault.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>defaultProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType,inst.removeDefault=inst.unwrap});function _default(innerType,defaultValue){return new ZodDefault({type:"default",innerType,get defaultValue(){return typeof defaultValue==="function"?defaultValue():shallowClone(defaultValue)}})}var ZodPrefault=$constructor("ZodPrefault",(inst,def)=>{$ZodPrefault.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>prefaultProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function prefault(innerType,defaultValue){return new ZodPrefault({type:"prefault",innerType,get defaultValue(){return typeof defaultValue==="function"?defaultValue():shallowClone(defaultValue)}})}var ZodNonOptional=$constructor("ZodNonOptional",(inst,def)=>{$ZodNonOptional.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>nonoptionalProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function nonoptional(innerType,params){return new ZodNonOptional({type:"nonoptional",innerType,...normalizeParams(params)})}var ZodCatch=$constructor("ZodCatch",(inst,def)=>{$ZodCatch.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>catchProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType,inst.removeCatch=inst.unwrap});function _catch(innerType,catchValue){return new ZodCatch({type:"catch",innerType,catchValue:typeof catchValue==="function"?catchValue:constantCatch(catchValue)})}var ZodPipe=$constructor("ZodPipe",(inst,def)=>{$ZodPipe.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>pipeProcessor(inst,ctx,json,params),inst.in=def.in,inst.out=def.out});function pipe(in_,out){return new ZodPipe({type:"pipe",in:in_,out})}var ZodPreprocess=$constructor("ZodPreprocess",(inst,def)=>{ZodPipe.init(inst,def),$ZodPreprocess.init(inst,def)}),ZodReadonly=$constructor("ZodReadonly",(inst,def)=>{$ZodReadonly.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>readonlyProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.innerType});function readonly(innerType){return new ZodReadonly({type:"readonly",innerType})}var ZodLazy=$constructor("ZodLazy",(inst,def)=>{$ZodLazy.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>lazyProcessor(inst,ctx,json,params),inst.unwrap=()=>inst._zod.def.getter()});function lazy(getter){return new ZodLazy({type:"lazy",getter})}var ZodCustom=$constructor("ZodCustom",(inst,def)=>{$ZodCustom.init(inst,def),ZodType.init(inst,def),inst._zod.processJSONSchema=(ctx,json,params)=>customProcessor(inst,ctx,json,params)});function custom(fn,_params){return _custom(ZodCustom,fn??(()=>!0),_params)}function refine(fn,_params={}){return _refine(ZodCustom,fn,_params)}function superRefine(fn,params){return _superRefine(fn,params)}function preprocess(fn,schema){return new ZodPreprocess({type:"pipe",in:transform(fn),out:schema})}var exports_iso={};__export(exports_iso,{ZodISODate:()=>ZodISODate,ZodISODateTime:()=>ZodISODateTime,ZodISODuration:()=>ZodISODuration,ZodISOTime:()=>ZodISOTime,date:()=>date2,datetime:()=>datetime,duration:()=>duration2,time:()=>time2});function datetime(params){return _isoDateTime(ZodISODateTime,params)}function date2(params){return _isoDate(ZodISODate,params)}function time2(params){return _isoTime(ZodISOTime,params)}function duration2(params){return _isoDuration(ZodISODuration,params)}var FeedbackPrefsSchema=object({enabled:boolean(),contactOk:boolean().optional()}),MAX_DESIGN_NAME=80;function designNameIssue(name){if(name.trim()==="")return"a design name can't be empty";if(name!==name.trim())return"a design name can't start or end with spaces";if(name==="."||name==="..")return`"${name}" can't be a design name`;if(/[/\\]/.test(name))return"a design name can't contain / or \\";if(/\p{Cc}/u.test(name))return"a design name can't contain control characters";if([...name].length>MAX_DESIGN_NAME)return`a design name can't be longer than ${MAX_DESIGN_NAME} characters`;return null}function isDesignName(name){return designNameIssue(name)===null}var DesignNameSchema=string().superRefine((name,ctx)=>{let issue=designNameIssue(name);if(issue)ctx.addIssue({code:"custom",message:issue})});function toDesignName(text){let cleaned=[...text.replace(/[/\\\p{Cc}]+/gu," ").trim()].slice(0,MAX_DESIGN_NAME).join("").trim();return cleaned&&isDesignName(cleaned)?cleaned:null}var RepoManifestSchema=object({$schema:string().optional(),designs:array(string().min(1)),defaultDesign:DesignNameSchema.optional(),feedback:FeedbackPrefsSchema.optional()}).refine((m)=>new Set(m.designs).size===m.designs.length,{message:"designs lists the same path twice"}),REPO_MANIFEST_FILE="velloo.json";function normalizeRepoManifest(raw){if(typeof raw!=="object"||raw===null||Array.isArray(raw))return{manifest:raw,legacyNames:{},legacy:!1};let{projects,defaultProject,...rest}=raw;if(projects===void 0||"designs"in rest)return{manifest:raw,legacyNames:{},legacy:!1};let legacyNames={},designs=[];if(typeof projects==="object"&&projects!==null&&!Array.isArray(projects)){for(let[name,path]of Object.entries(projects))if(designs.push(path),typeof path==="string")legacyNames[path]=name}return{manifest:{...rest,designs,...defaultProject!==void 0?{defaultDesign:defaultProject}:{}},legacyNames,legacy:!0}}var CURRENT_SCHEMA_VERSION=4;function schemaVersionOf(rawConfig){if(typeof rawConfig!=="object"||rawConfig===null)return 1;let v=rawConfig.schemaVersion;return typeof v==="number"&&Number.isInteger(v)&&v>=1?v:1}var APP_PATH_PREFIX="app:",LEGACY_APP_PREFIX="project:",LEGACY_LIBRARY_KEY="default";function migrateLibraryEntry(raw){if(typeof raw!=="object"||raw===null)return raw;let lib={...raw};if(lib.source==="embedded:shadcn"||lib.source==="registry:shadcn")lib.source="binary",lib.componentsPath="binary";if(lib.id==="shadcn-react")lib.id="shadcn-upstream";return lib}var RETIRED_TYPOGRAPHY_KEYS=["fontSize","fontWeight","lineHeight","letterSpacing"],FACE_ROLE_CANDIDATES={fontBody:["sans","body","base"],fontHeading:["display","heading","serif"],fontMono:["mono","code"]},IMPLIED_BASE_PX=16;function asObject(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)?value:void 0}function positiveNumber(value){return typeof value==="number"&&Number.isFinite(value)&&value>0?value:void 0}function deriveTypeset(typography){let derived={},base=positiveNumber(asObject(typography.fontSize)?.base);if(base!==void 0&&base!==IMPLIED_BASE_PX)derived.size=base;let leading=positiveNumber(asObject(typography.lineHeight)?.normal);if(leading!==void 0)derived.leading=leading;let families=asObject(typography.fontFamily);if(families)for(let[face,candidates]of Object.entries(FACE_ROLE_CANDIDATES)){let role=candidates.find((name)=>typeof families[name]==="string");if(role)derived[face]=role}return derived}var FOLDER_MIGRATIONS=[{from:1,summary:"multi-library config shape, source enum, shadcn-react \u2192 shadcn-upstream, required annotation author",config(raw){let out={...raw};if(out.library!==void 0&&out.libraries===void 0)out.libraries={[LEGACY_LIBRARY_KEY]:out.library},out.defaultLibrary=LEGACY_LIBRARY_KEY;if(delete out.library,typeof out.libraries==="object"&&out.libraries!==null)out.libraries=Object.fromEntries(Object.entries(out.libraries).map(([id,lib])=>[id,migrateLibraryEntry(lib)]));return out.schemaVersion=2,out},annotation(raw){if(raw.author===void 0)return{...raw,author:"user"};return raw}},{from:2,summary:"typography scales \u2192 typesets (font roles bound, dead size/weight/tracking records dropped)",config(raw){return{...raw,schemaVersion:3}},theme(raw){let typography=asObject(raw.typography);if(!typography)return raw;let next={...typography},typesets=asObject(next.typesets);if(typesets?.default===void 0){let derived=deriveTypeset(next);if(Object.keys(derived).length>0)next.typesets={...typesets,default:derived}}for(let key of RETIRED_TYPOGRAPHY_KEYS)delete next[key];return{...raw,typography:next}}},{from:3,summary:"the design's name moves into its config; `project:` paths become `app:`",config(raw,context){let out={...raw,schemaVersion:4};if(typeof out.name!=="string"||!isDesignName(out.name))out.name=(context.name&&toDesignName(context.name))??"design";let toApp=(path)=>typeof path==="string"&&path.startsWith(LEGACY_APP_PREFIX)?`${APP_PATH_PREFIX}${path.slice(LEGACY_APP_PREFIX.length)}`:path,hostApp=asObject(out.hostApp);if(hostApp)out.hostApp={...hostApp,root:toApp(hostApp.root)};let hostApps=asObject(out.hostApps);if(hostApps)out.hostApps=Object.fromEntries(Object.entries(hostApps).map(([key,app])=>{let entry=asObject(app);return[key,entry?{...entry,root:toApp(entry.root)}:app]}));let libraries=asObject(out.libraries);if(libraries)out.libraries=Object.fromEntries(Object.entries(libraries).map(([key,lib])=>{let entry=asObject(lib);return[key,entry?{...entry,componentsPath:toApp(entry.componentsPath)}:lib]}));return out}}];function planMigration(rawConfig,context={}){let from=schemaVersionOf(rawConfig);if(from>CURRENT_SCHEMA_VERSION)throw Error(`Design folder uses schema version ${from}, newer than this velloo (v${CURRENT_SCHEMA_VERSION}). Upgrade velloo.`);let steps=[];for(let v=from;v<CURRENT_SCHEMA_VERSION;v++){let step=FOLDER_MIGRATIONS.find((m)=>m.from===v);if(!step)throw Error(`velloo: no migration step from schema version ${v} \u2014 bug.`);steps.push(step)}let config={...rawConfig??{}};for(let step of steps)if(step.config)config=step.config(config,context);return config.schemaVersion=CURRENT_SCHEMA_VERSION,{config,applied:steps.map((s)=>s.summary),annotation:(raw)=>steps.reduce((acc,step)=>step.annotation?.(acc)??acc,raw),theme:(raw)=>steps.reduce((acc,step)=>step.theme?.(acc)??acc,raw)}}var ResourceIdSchema=string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,"ids are [A-Za-z0-9][A-Za-z0-9_-]{0,63}");function isComponentNode(n){return typeof n.$ref==="string"}function isSnippetInstance(n){return typeof n.$snippet==="string"}function isParamRef(n){return typeof n.$param==="string"}var NodeIdSchema=string().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/,{message:"node id must match /^[a-zA-Z][a-zA-Z0-9_-]*$/"});function wrapScalarChild(item){if(typeof item==="string"||typeof item==="number")return{$ref:"Box",props:{as:"span",children:item}};return item}var EmitAsSchema=object({name:string().min(1),importPath:string().min(1)});function repoImportIssue(importPath){if(!/^[\w@./~-]+$/.test(importPath))return"has characters an import specifier can't carry";if(importPath.startsWith("/"))return"must not be an absolute path";if(importPath.split("/").includes(".."))return"must not climb out of the host app with ..";return null}var IDENTIFIER=/^[A-Za-z_$][\w$]*$/,RepoComponentRefSchema=object({importPath:string().min(1).superRefine((value,ctx)=>{let issue=repoImportIssue(value);if(issue)ctx.addIssue({code:"custom",message:`importPath ${issue}`})}),exportName:string().regex(IDENTIFIER,{message:'exportName must be an identifier or "default"'}),member:string().regex(/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/,{message:'member must be a dotted identifier path like "List"'}).optional(),app:string().min(1).optional(),proxy:string().min(1).optional()}),ComponentNodeSchema=lazy(()=>object({$ref:string().min(1),$id:NodeIdSchema.optional(),props:record(string(),unknown()).optional(),children:array(union([string(),number(),NodeSchema])).transform((items)=>items.map(wrapScalarChild)).optional(),$emitAs:EmitAsSchema.optional(),$repo:RepoComponentRefSchema.optional()}));function isRepoNode(n){return isComponentNode(n)&&n.$repo!==void 0}function repoKey(ref){let member=ref.member?`.${ref.member}`:"";return`repo:${encodeURIComponent(ref.app??"")}:${ref.importPath}#${ref.exportName}${member}`}function parseRepoKey(key){let match=/^repo:([^:]*):([^#]+)#([A-Za-z_$][\w$]*)(?:\.(.+))?$/.exec(key);if(!match)return null;let parsed=RepoComponentRefSchema.safeParse({importPath:match[2],exportName:match[3],...match[4]?{member:match[4]}:{},...match[1]?{app:decodeURIComponent(match[1])}:{}});return parsed.success?parsed.data:null}var SnippetInstanceSchema=object({$snippet:string().min(1),$id:NodeIdSchema.optional(),$extraClassName:string().optional(),args:record(string(),unknown()).optional(),$overrides:record(string().regex(/^$|^\d+(\.\d+)*$|^@[a-zA-Z][a-zA-Z0-9_-]*$/,{message:'override key must be a dotted index path like "0.2", an "@id" reference with a literal leading @ (e.g. "@row-active" to target the body node whose $id is "row-active"), or "" for the body root'}),object({props:record(string(),unknown())})).optional()}),ParamRefSchema=object({$param:string().min(1)}),NodeSchema=unknown().transform((val,ctx)=>{if(val===null||typeof val!=="object"||Array.isArray(val))return ctx.addIssue({code:"custom",message:'node must be an object with one of "$ref" (component), "$snippet" (instance), or "$param" (param ref)'}),NEVER;let v=val,branch=typeof v.$ref==="string"?ComponentNodeSchema:typeof v.$snippet==="string"?SnippetInstanceSchema:typeof v.$param==="string"?ParamRefSchema:null;if(!branch)return ctx.addIssue({code:"custom",message:'node needs exactly one of "$ref" (component), "$snippet" (snippet instance), or "$param" (param ref, snippet bodies only)'}),NEVER;let parsed=branch.safeParse(val);if(!parsed.success){for(let issue of parsed.error.issues)ctx.addIssue({...issue});return NEVER}return parsed.data}).describe('{"$ref":"Button","$id?":"cta","props?":{...},"children?":[Node]}, or {"$snippet":"<id>","args?":{...}}. Guide: velloo://guide/components').meta({type:"object",additionalProperties:!0});function nodeId(n){if(isParamRef(n))return;return n.$id}var ScreenSchema=object({id:ResourceIdSchema,name:string().min(1),library:string().min(1).optional(),route:string().min(1).optional(),tree:NodeSchema});var NumOrCssLen=union([number(),string().min(1)]),LooseTokenGroupSchema=lazy(()=>record(string(),union([string(),number(),LooseTokenGroupSchema]))),ColorPairSchema=union([string().min(1),object({DEFAULT:string().min(1),foreground:string().min(1).optional()})]),ColorsSchema=object({background:string().min(1),foreground:string().min(1),primary:ColorPairSchema,secondary:ColorPairSchema.optional(),muted:ColorPairSchema.optional(),accent:ColorPairSchema.optional(),destructive:ColorPairSchema.optional(),card:ColorPairSchema.optional(),popover:ColorPairSchema.optional(),border:string().min(1).optional(),input:string().min(1).optional(),ring:string().min(1).optional()});function resolveColors(theme,dark=!1){if(!dark||!theme.colorsDark)return theme.colors;let merged={...theme.colors};for(let[key,value]of Object.entries(theme.colorsDark))if(value!==void 0)merged[key]=value;return merged}var PaletteSchema=record(string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/),string().min(1)),TypesetSchema=object({size:NumOrCssLen.optional(),leading:number().positive().optional(),flow:NumOrCssLen.optional(),fontBody:string().min(1).optional(),fontHeading:string().min(1).optional(),fontMono:string().min(1).optional()}),TypographySchema=object({fontFamily:record(string(),string().min(1)).optional(),googleFonts:array(string().min(1)).optional(),typesets:record(string().regex(/^[A-Za-z0-9_-]+$/),TypesetSchema).optional()}).strict(),RadiusSchema=object({none:NumOrCssLen.optional(),sm:NumOrCssLen.optional(),md:NumOrCssLen.optional(),lg:NumOrCssLen.optional(),xl:NumOrCssLen.optional(),"2xl":NumOrCssLen.optional(),"3xl":NumOrCssLen.optional(),full:NumOrCssLen.optional()}).partial(),ContainerSchema=object({center:boolean().optional(),padding:string().min(1).optional(),maxWidth:string().min(1).optional()}),ThemeSchema=object({name:string().min(1),colors:ColorsSchema,colorsDark:ColorsSchema.partial().optional(),palette:PaletteSchema.optional(),paletteDark:PaletteSchema.optional(),typography:TypographySchema,spacing:LooseTokenGroupSchema,radius:RadiusSchema,shadows:LooseTokenGroupSchema.optional(),container:ContainerSchema.optional(),keyframes:record(string(),record(string(),record(string(),string()))).optional(),animation:record(string(),string()).optional()});var AnnotationLocatorSchema=union([array(number().int().nonnegative()),string().regex(/^@[a-zA-Z][a-zA-Z0-9_-]*$/)]),AnnotationTargetSchema=object({locator:AnnotationLocatorSchema}),PositionSchema=union([object({x:number(),y:number()}),literal("auto")]),AnnotationSchema=object({id:ResourceIdSchema,target:AnnotationTargetSchema,position:PositionSchema.default("auto"),body:string(),collapsed:boolean().optional(),author:_enum(["user","agent"]),cloud:object({commentId:string().min(1),slug:string().min(1),author:string().optional()}).optional()}),CanvasNoteAttachmentSchema=object({frameId:ResourceIdSchema,screenId:ResourceIdSchema,locator:AnnotationLocatorSchema}),CanvasNoteSchema=object({id:ResourceIdSchema,x:number().optional(),y:number().optional(),width:number().positive(),body:string(),attachment:CanvasNoteAttachmentSchema.optional()}).refine((note)=>note.attachment!==void 0||note.x!==void 0&&note.y!==void 0,{message:"A note without an attachment needs x and y",path:["x"]});var GeneratedAssetSchema=object({prompt:string(),intent:string(),aspect:string().optional(),width:number().int().positive().optional(),height:number().int().positive().optional(),generatedAt:string(),reference:array(string()).optional(),replaces:string().optional()}),AssetsFileSchema=object({version:literal(1),generated:record(string(),GeneratedAssetSchema)}),EMPTY_ASSETS_FILE={version:1,generated:{}};var FrameSchemeSchema=_enum(["light","dark"]),FrameSchema=object({id:ResourceIdSchema,screen:string().min(1),x:number(),y:number(),w:number().int().positive(),h:number().int().positive(),label:string().optional(),group:string().optional(),scheme:FrameSchemeSchema.optional()});var BoardGroupSchema=object({id:ResourceIdSchema,name:string().min(1),color:string().optional()}),MAX_BOARD_NAME_LENGTH=80,BoardSchema=object({id:ResourceIdSchema,name:string().min(1),theme:string().min(1).optional(),archivedAt:string().datetime().optional(),group:string().min(1).optional(),frames:array(FrameSchema).default([]),groups:array(BoardGroupSchema).default([])});function isArchived(board){return board.archivedAt!==void 0}var CommentLocatorSchema=union([array(number().int().nonnegative()),string().regex(/^@[a-zA-Z][a-zA-Z0-9_-]*$/)]),CommentBoundsSchema=object({x:number(),y:number(),w:number().nonnegative(),h:number().nonnegative()}),CommentNodeFingerprintSchema=object({ref:string().min(1).optional(),text:string().max(500).optional(),ancestorIds:array(string().min(1)).max(16).optional()}),CommentAnchorSchema=discriminatedUnion("kind",[object({kind:literal("node"),boardId:ResourceIdSchema,frameId:ResourceIdSchema,screenId:ResourceIdSchema,locator:CommentLocatorSchema,bounds:CommentBoundsSchema,fingerprint:CommentNodeFingerprintSchema.optional()}),object({kind:literal("board"),boardId:ResourceIdSchema,x:number(),y:number()})]),CommentAuthorSchema=object({kind:_enum(["user","agent","reviewer"]),displayName:string().min(1).max(200).optional(),accountId:string().min(1).max(200).optional()}),CommentMessageSchema=object({id:uuid2(),author:CommentAuthorSchema,body:string().trim().max(4000),createdAt:exports_iso.datetime(),deletedAt:exports_iso.datetime().optional()}).refine((message)=>message.deletedAt!==void 0||message.body.length>0,{message:"A comment needs something to say",path:["body"]}),CommentOriginSchema=discriminatedUnion("kind",[object({kind:literal("local")}),object({kind:literal("published"),slug:string().min(1),versionId:string().min(1)})]),CommentThreadSchema=object({id:uuid2(),scope:_enum(["local","shared"]),folderId:string().min(1),boardId:ResourceIdSchema,anchor:CommentAnchorSchema.optional(),origin:CommentOriginSchema,status:_enum(["open","resolved"]),messages:array(CommentMessageSchema).min(1),createdAt:exports_iso.datetime(),updatedAt:exports_iso.datetime(),resolvedAt:exports_iso.datetime().optional()});var PropControlSchema=_enum(["boolean","number","string","color","enum","icon"]),ExtensionPropDescriptorSchema=object({name:string().min(1),type:string().min(1),optional:boolean(),defaultValue:string().optional(),control:PropControlSchema,enumValues:array(union([string(),number()])).optional()}).superRefine((prop,ctx)=>{if(prop.control==="enum"&&(!prop.enumValues||prop.enumValues.length===0))ctx.addIssue({code:"custom",path:["enumValues"],message:`prop "${prop.name}": control "enum" requires a non-empty \`enumValues\` array`})}),ExtensionSchema=object({importPath:string().min(1),category:_enum(["ui","typography"]).optional(),description:string().optional(),props:array(ExtensionPropDescriptorSchema),origin:_enum(["agent","manual"]).optional(),render:_enum(["static","live"]).optional(),app:string().min(1).optional(),fit:_enum(["aspect-video","content"]).optional()}),RepoComponentOverrideSchema=object({description:string().optional(),exclude:boolean().optional(),proxy:string().min(1).optional(),props:array(ExtensionPropDescriptorSchema).optional(),states:record(string().min(1),record(string(),unknown())).optional()}),RepoComponentsManifestSchema=object({components:record(string().min(1),RepoComponentOverrideSchema)});var ViewportPresetSchema=object({name:string().min(1),w:number().int().positive(),h:number().int().positive()}),LibrarySchema=object({id:_enum(["shadcn-upstream","none","mui","antd","chakra"]),version:string().min(1),source:_enum(["binary","cache","in-repo"]),componentsPath:string().min(1)}),CodegenConfigSchema=object({componentsAlias:string().min(1).optional(),componentsDir:string().min(1).optional()}),HostAppSchema=object({root:string().min(1),aliases:record(string().min(1),string().min(1)).optional(),preview:string().min(1).optional(),components:object({include:array(string().min(1)).optional(),exclude:array(string().min(1)).optional()}).optional()}),ConfigSchema=object({schemaVersion:literal(CURRENT_SCHEMA_VERSION),toolVersion:string().min(1),name:DesignNameSchema,folderId:string().regex(/^[A-Za-z0-9_-]{8,64}$/).optional(),libraries:record(string().min(1),LibrarySchema),defaultLibrary:string().min(1),extensions:record(string().min(1),ExtensionSchema).optional(),viewportPresets:array(ViewportPresetSchema).min(1),defaultScreen:string().min(1).optional(),defaultBoard:string().min(1).optional(),boardOrder:array(string().min(1)).optional(),boardGroups:array(BoardGroupSchema).optional(),codegen:CodegenConfigSchema.optional(),styling:object({framework:_enum(["tailwind","none"])}).optional(),hostApp:HostAppSchema.optional(),hostApps:record(string().min(1),HostAppSchema).optional(),feedback:FeedbackPrefsSchema.optional()}).refine((c)=>(c.defaultLibrary in c.libraries),{message:"`defaultLibrary` must name an entry in `libraries`."});var CSS_IDENT_RE=/^[A-Za-z0-9_-]+$/;function isCssIdent(name){return CSS_IDENT_RE.test(name)}function sanitizeCssTokenValue(value){return value.replace(/\*\//g,"").replace(/[<>{};\\]/g,"").replace(/[\r\n]+/g," ").trim()}function neutralizeCssText(css){return css.replace(/<\//g,"<\\/")}function sanitizeGoogleFontSpec(spec){return spec.replace(/[^A-Za-z0-9 +:,.;@_-]/g,"").replace(/ /g,"+")}function pascalizeIconName(name){let trimmed=name.trim();if(trimmed==="")return trimmed;if(!/[-_\s]/.test(trimmed))return trimmed.charAt(0).toUpperCase()+trimmed.slice(1);return trimmed.split(/[-_\s]+/).filter((part)=>part!=="").map((part)=>part.charAt(0).toUpperCase()+part.slice(1)).join("")}var SnippetParamSchema=object({name:string().min(1),type:_enum(["string","number","boolean","node","icon","color","enum"]),default:unknown().optional(),optional:boolean().optional(),enum:array(string()).optional(),min:number().optional(),max:number().optional(),step:number().optional(),description:string().optional()}).superRefine((param,ctx)=>{if(param.type==="enum"){if(!param.enum||param.enum.length===0){ctx.addIssue({code:"custom",path:["enum"],message:`param "${param.name}": type "enum" requires a non-empty \`enum\` array`});return}if(param.default!==void 0&&!param.enum.includes(param.default))ctx.addIssue({code:"custom",path:["default"],message:`param "${param.name}": default ${JSON.stringify(param.default)} is not one of the declared enum values`});return}if(param.default===void 0||param.type==="node")return;let expected=param.type==="number"?"number":param.type==="boolean"?"boolean":"string";if(typeof param.default!==expected)ctx.addIssue({code:"custom",path:["default"],message:`param "${param.name}": default ${JSON.stringify(param.default)} does not match declared type "${param.type}"`})}),SnippetSchema=object({id:ResourceIdSchema,name:string().min(1),params:array(SnippetParamSchema),library:string().min(1).optional(),tree:NodeSchema});var OMITTED=Symbol("velloo.omitted-optional-param"),DROP=Symbol("velloo.drop");function resolveSnippetArgs(snippet,passed){let args={},missing=[];for(let param of snippet.params)if(param.name in passed)args[param.name]=passed[param.name];else if(param.default!==void 0)args[param.name]=param.default;else if(param.optional)args[param.name]=OMITTED;else missing.push(param.name);return{args,missing}}function isTruthy(v){if(v===void 0||v===null||v===OMITTED)return!1;if(typeof v==="boolean")return v;if(typeof v==="number")return v!==0&&!Number.isNaN(v);if(typeof v==="string")return v!=="";return!0}function substituteSnippetParams(value,args){let missing=[],invalid=[];function walk(v,inNodePosition){if(v===null||typeof v!=="object")return v;if(Array.isArray(v))return v.map((item)=>walk(item,inNodePosition)).filter((item)=>item!==DROP);if(typeof v.$param==="string"){let name=v.$param;if(!(name in args)){missing.push(name);return}let resolved=args[name];if(resolved===OMITTED)return DROP;if(inNodePosition&&(resolved===null||typeof resolved!=="object")){invalid.push({param:name,valueType:resolved===null?"null":typeof resolved});return}return resolved}if(typeof v.$if==="string"){let cond=v;if(!(cond.$if in args)){missing.push(cond.$if);return}let matched="eq"in cond?args[cond.$if]===cond.eq:isTruthy(args[cond.$if]);return walk(matched?cond.then:cond.else,inNodePosition)}let isComponentNodeObj=typeof v.$ref==="string",out={};for(let[k,val]of Object.entries(v)){let w=walk(val,isComponentNodeObj&&k==="children");if(w!==DROP)out[k]=w}return out}return{value:walk(value,!1),missing,invalid}}function findNodeById(root,id){if(!isComponentNode(root))return;if(root.$id===id)return root;for(let child of root.children??[]){let hit=findNodeById(child,id);if(hit)return hit}return}function applySnippetOverrides(body,overrides){let clone=structuredClone(body);for(let[key,patch]of Object.entries(overrides)){let target;if(key.startsWith("@"))target=findNodeById(clone,key.slice(1));else{let segments=key===""?[]:key.split(".").map(Number);target=clone;for(let i of segments){if(!target||!isComponentNode(target)||!target.children){target=void 0;break}target=target.children[i]}}if(!target||!isComponentNode(target))continue;let props={...target.props??{}};for(let[k,v]of Object.entries(patch.props))if(v===null)delete props[k];else props[k]=v;target.props=props}return clone}function applySnippetExtraClassName(node,extra){if(isParamRef(node))return node;if(isSnippetInstance(node)){let existing=node.$extraClassName?`${node.$extraClassName} ${extra}`:extra;return{...node,$extraClassName:existing}}if(!isComponentNode(node))return node;let existingClass=typeof node.props?.className==="string"?node.props.className:"",merged=existingClass?`${existingClass} ${extra}`:extra;return{...node,props:{...node.props??{},className:merged}}}var ALLOWED_ELEMENTS=new Map(["a","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","style","svg","switch","symbol","text","textPath","title","tspan","use","view"].map((name)=>[name.toLowerCase(),name])),ACTIVE_ELEMENTS=new Set(["animate","animatecolor","animatemotion","animatetransform","applet","audio","base","embed","foreignobject","form","frame","frameset","iframe","img","input","link","meta","noscript","object","script","set","template","video"]),RAW_TEXT_ELEMENTS=new Set(["iframe","noembed","noframes","noscript","plaintext","script","style","textarea","xmp"]),VOID_ELEMENTS=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),NAMED_ENTITIES={amp:"&",apos:"'",bull:"\u2022",colon:":",copy:"\xA9",deg:"\xB0",divide:"\xF7",gt:">",hellip:"\u2026",laquo:"\xAB",ldquo:"\u201C",lsquo:"\u2018",lt:"<",mdash:"\u2014",middot:"\xB7",nbsp:"\xA0",ndash:"\u2013",NewLine:`
55
55
  `,quot:'"',raquo:"\xBB",rdquo:"\u201D",reg:"\xAE",rsquo:"\u2019",sol:"/",Tab:"\t",times:"\xD7",trade:"\u2122"},ATTRIBUTE_NAME=/^[A-Za-z_][-A-Za-z0-9_.:]*$/,SAFE_DATA_IMAGE=/^data:image\/(?:png|jpe?g|gif|webp|avif)[;,]/i,SCHEME=/^([A-Za-z][A-Za-z0-9+.-]*):/;function svgLooksActive(markup){return sanitize(markup).removedActive}function sanitizeSvgMarkup(markup){return sanitize(markup).markup}function sanitize(input){let lower=input.toLowerCase(),out=[],stack=[],removedActive=!1,dropped=0,i=0,emitText=(text)=>{if(dropped===0&&text!=="")out.push(escapeText(decodeEntities(text)))};while(i<input.length){let lt=input.indexOf("<",i);if(lt===-1){emitText(input.slice(i));break}if(emitText(input.slice(i,lt)),i=lt,input.startsWith("<!--",i)){let end=input.indexOf("-->",i+4);i=end===-1?input.length:end+3;continue}if(input.startsWith("<![CDATA[",i)){let end=input.indexOf("]]>",i+9),stop=end===-1?input.length:end;if(dropped===0)out.push(escapeText(input.slice(i+9,stop)));i=end===-1?input.length:end+3;continue}let next=input[i+1]??"";if(next==="!"||next==="?"){let gt=input.indexOf(">",i+2),bracket=lower.startsWith("<!doctype",i)?input.indexOf("[",i):-1,subsetEnd=bracket!==-1&&(gt===-1||bracket<gt)?input.indexOf("]",bracket):-1,end=input.indexOf(">",subsetEnd===-1?i+2:subsetEnd);i=end===-1?input.length:end+1;continue}if(next==="/"&&isNameStart(input[i+2]??"")){let end=input.indexOf(">",i+2),raw=input.slice(i+2,end===-1?input.length:end);i=end===-1?input.length:end+1,closeElement(tagName(raw).toLowerCase());continue}if(!isNameStart(next)){emitText("<"),i+=1;continue}let tag=readStartTag(input,i+1);i=tag.end;let tagLower=tag.name.toLowerCase(),localName=tagLower.slice(tagLower.lastIndexOf(":")+1),canonical=tagLower.includes(":")?void 0:ALLOWED_ELEMENTS.get(tagLower),report=(active)=>{if(active)removedActive=!0};if(RAW_TEXT_ELEMENTS.has(tagLower)&&!tag.selfClosing){let close=lower.indexOf(`</${tagLower}`,i),content=input.slice(i,close===-1?input.length:close),gt=close===-1?-1:input.indexOf(">",close);if(i=gt===-1?input.length:gt+1,dropped>0)continue;if(canonical==="style"){let css=filterCss(content.replace(/<!\[CDATA\[|\]\]>/g,""));report(css.removed),out.push(`<style${serializeAttributes(tag.attributes,report)}>`),out.push(escapeText(css.value),"</style>")}else report(ACTIVE_ELEMENTS.has(localName));continue}if(dropped>0||!canonical){if(dropped===0)report(ACTIVE_ELEMENTS.has(localName));if(!tag.selfClosing&&!VOID_ELEMENTS.has(tagLower))stack.push({name:null,lower:tagLower}),dropped+=1;continue}let attributes=serializeAttributes(tag.attributes,report);if(tag.selfClosing)out.push(`<${canonical}${attributes}/>`);else out.push(`<${canonical}${attributes}>`),stack.push({name:canonical,lower:tagLower})}while(stack.length>0)popElement();return{markup:out.join(""),removedActive};function closeElement(name){let index=stack.length-1;while(index>=0&&stack[index]?.lower!==name)index-=1;if(index===-1)return;while(stack.length>index)popElement()}function popElement(){let top=stack.pop();if(!top)return;if(top.name===null)dropped-=1;else out.push(`</${top.name}>`)}}function readStartTag(input,from){let i=from;while(i<input.length&&!/[\s/>]/.test(input[i]))i+=1;let name=input.slice(from,i),attributes=[],selfClosing=!1;while(i<input.length){let ch=input[i];if(/\s/.test(ch)){i+=1;continue}if(ch===">")return{name,attributes,selfClosing,end:i+1};if(ch==="/"){selfClosing=input[i+1]===">",i+=1;continue}selfClosing=!1;let nameStart=i;i+=1;while(i<input.length&&!/[\s/>=]/.test(input[i]))i+=1;let attrName=input.slice(nameStart,i);while(i<input.length&&/\s/.test(input[i]))i+=1;let value="";if(input[i]==="="){i+=1;while(i<input.length&&/\s/.test(input[i]))i+=1;let quote=input[i];if(quote==='"'||quote==="'"){let close=input.indexOf(quote,i+1),stop=close===-1?input.length:close;value=input.slice(i+1,stop),i=close===-1?input.length:close+1}else{let valueStart=i;while(i<input.length&&!/[\s>]/.test(input[i]))i+=1;value=input.slice(valueStart,i)}}attributes.push({name:attrName,value:decodeEntities(value)})}return{name,attributes,selfClosing,end:input.length}}function serializeAttributes(attributes,report){let seen=new Set,result="";for(let{name,value}of attributes){let lower=name.toLowerCase();if(seen.has(lower))continue;if(seen.add(lower),!ATTRIBUTE_NAME.test(name))continue;if(lower.startsWith("on")){report(!0);continue}let colon=lower.indexOf(":"),prefix=colon===-1?"":lower.slice(0,colon),isLink=lower.slice(colon+1)==="href"||lower==="src";if(!isLink&&prefix!==""&&prefix!=="xlink"&&prefix!=="xml"&&prefix!=="xmlns")continue;let kept=value;if(isLink){if(!isSafeUrl(value)){report(!0);continue}}else if(lower==="style"||/url\s*\(|@import/i.test(value)){let css=filterCss(value);if(css.removed)report(!0);kept=css.value}result+=` ${name}="${escapeAttribute(kept)}"`}return result}function isSafeUrl(value){let url=value.replace(/[\u0000- \u007F-\u009F]/g,""),scheme=SCHEME.exec(url)?.[1]?.toLowerCase();if(scheme===void 0)return!0;if(scheme==="http"||scheme==="https"||scheme==="mailto")return!0;return scheme==="data"&&SAFE_DATA_IMAGE.test(url)}function filterCss(css){let removed=!1;return{value:css.replace(/\\/g,()=>(removed=!0,"")).replace(/@import[^;]*;?/gi,()=>(removed=!0,"")).replace(/url\s*\(([^)]*)\)?/gi,(match,target)=>{if(target.trim().replace(/^["']|["']$/g,"").startsWith("#"))return match;return removed=!0,"none"}),removed}}function decodeEntities(text){if(!text.includes("&"))return text;return text.replace(/&(?:#[xX]([0-9a-fA-F]{1,8})|#([0-9]{1,9})|([A-Za-z][A-Za-z0-9]{0,31}));?/g,(match,hex,dec,named)=>{if(named!==void 0)return NAMED_ENTITIES[named]??match;let code=hex!==void 0?Number.parseInt(hex,16):Number(dec);return code>0&&code<=1114111&&!(code>=55296&&code<=57343)?String.fromCodePoint(code):"\uFFFD"})}function escapeText(text){return text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function escapeAttribute(value){return escapeText(value).replace(/"/g,"&quot;")}function isNameStart(ch){return/[A-Za-z]/.test(ch)}function tagName(raw){return/^[^\s/>]+/.exec(raw)?.[0]??""}var TYPESET_DEFAULT={size:"1em",leading:1.75,flow:"1.25em"},DEFAULT_TYPESET_NAME="default";function isTypesetName(name){return isCssIdent(name)}var TYPESET_RATIOS={h1:{size:2.5,leading:0.63,tracking:"-0.025em",weight:700,face:"heading"},h2:{size:2,leading:0.66,tracking:"-0.025em",weight:700,face:"heading"},h3:{size:1.5,leading:0.71,tracking:"-0.02em",weight:600,face:"heading"},h4:{size:1.25,leading:0.74,tracking:"-0.02em",weight:600,face:"heading"},h5:{size:1.125,leading:0.8,tracking:"-0.015em",weight:600,face:"heading"},h6:{size:1,leading:0.8,tracking:"-0.01em",weight:600,face:"heading"},body:{size:1,leading:1,tracking:"0em",weight:400,face:"body"},lead:{size:1.25,leading:0.91,tracking:"0em",weight:400,face:"body"},small:{size:0.875,leading:0.57,tracking:"0em",weight:500,face:"body"},caption:{size:0.875,leading:0.86,tracking:"0em",weight:400,face:"body"}},TYPESET_SCALE_NAMES=Object.keys(TYPESET_RATIOS),HEADING_ROLE_BY_LEVEL={1:"h1",2:"h2",3:"h3",4:"h4",5:"h5",6:"h6"},TEXT_ROLE_BY_VARIANT={default:"body",muted:"caption",small:"small",lead:"lead"},TEXT_TONE_BY_VARIANT={default:"foreground",muted:"muted-foreground",lead:"muted-foreground"},WEIGHT_CLASS={400:"font-normal",500:"font-medium",600:"font-semibold",700:"font-bold"},TYPESET_CLASSES=Object.fromEntries(TYPESET_SCALE_NAMES.map((role)=>{let ratio=TYPESET_RATIOS[role];return[role,`text-${role} leading-${role} tracking-${role} ${WEIGHT_CLASS[ratio.weight]}`]})),TYPESET_INLINE_STYLE=Object.fromEntries(TYPESET_SCALE_NAMES.map((role)=>[role,{fontSize:`var(--text-${role})`,lineHeight:`var(--leading-${role})`,letterSpacing:`var(--tracking-${role})`,fontWeight:TYPESET_RATIOS[role].weight}]));function resolveHeadingLevel(level){let n=Number(level??1);return Number.isFinite(n)&&n>=1&&n<=6?Math.trunc(n):1}function textVariant(variant){let v=String(variant??"default");return v in TEXT_ROLE_BY_VARIANT?v:"default"}function headingClasses(level){let role=HEADING_ROLE_BY_LEVEL[resolveHeadingLevel(level)];return TYPESET_CLASSES[role]}function textClasses(variant){let v=textVariant(variant),tone=TEXT_TONE_BY_VARIANT[v];return tone?`${TYPESET_CLASSES[TEXT_ROLE_BY_VARIANT[v]]} text-${tone}`:TYPESET_CLASSES[TEXT_ROLE_BY_VARIANT[v]]}function headingInlineStyle(level){let role=HEADING_ROLE_BY_LEVEL[resolveHeadingLevel(level)];return{...TYPESET_INLINE_STYLE[role]}}function textInlineStyle(variant){let v=textVariant(variant),tone=TEXT_TONE_BY_VARIANT[v];return{...TYPESET_INLINE_STYLE[TEXT_ROLE_BY_VARIANT[v]],...tone?{color:`var(--color-${tone})`}:{}}}function typesetSafelist(){let roles=TYPESET_SCALE_NAMES.join(","),weights=Object.values(WEIGHT_CLASS).map((c)=>c.replace(/^font-/,"")).join(","),tones=[...new Set(Object.values(TEXT_TONE_BY_VARIANT))].join(",");return[`{text,leading,tracking}-{${roles}}`,`font-{${weights}}`,`text-{${tones}}`]}function typesetUtilityClasses(){let seen=new Set;for(let classes of Object.values(TYPESET_CLASSES))for(let cls of classes.split(" "))seen.add(cls);for(let tone of Object.values(TEXT_TONE_BY_VARIANT))seen.add(`text-${tone}`);return[...seen]}function typesetV3FontSize(){return Object.fromEntries(TYPESET_SCALE_NAMES.map((role)=>[role,[`var(--text-${role})`,{lineHeight:`var(--leading-${role})`,letterSpacing:`var(--tracking-${role})`}]]))}function typesetThemeTokens(){let lines=[];for(let role of TYPESET_SCALE_NAMES){let ratio=TYPESET_RATIOS[role];lines.push(` --text-${role}: ${ratio.size}rem;`),lines.push(` --leading-${role}: ${round(ratio.leading*TYPESET_DEFAULT.leading)};`),lines.push(` --tracking-${role}: ${ratio.tracking};`)}return lines}function round(n){return Math.round(n*1000)/1000}function len(value){return typeof value==="number"?`${value}px`:sanitizeCssTokenValue(value)}function faceVar(role,fallback){if(!role||!isCssIdent(role))return fallback;return`var(--font-${role})`}function resolveTypeset(typeset){return{...typeset,size:typeset?.size??TYPESET_DEFAULT.size,leading:typeset?.leading??TYPESET_DEFAULT.leading,flow:typeset?.flow??TYPESET_DEFAULT.flow}}function typesetBaseVars(typeset,indent=" ",partial=!1){let t=partial?typeset??{}:resolveTypeset(typeset),lines=[],push=(name,value)=>lines.push(`${indent}--typeset-${name}: ${value};`);if(t.size!==void 0)push("size",len(t.size));if(t.leading!==void 0)push("leading",String(round(t.leading)));if(t.flow!==void 0)push("flow",len(t.flow));if(!partial||t.fontBody!==void 0)push("font-body",faceVar(t.fontBody,"inherit"));if(!partial||t.fontHeading!==void 0)push("font-heading",faceVar(t.fontHeading,"var(--typeset-font-body)"));if(!partial||t.fontMono!==void 0)push("font-mono",faceVar(t.fontMono,"var(--font-mono, ui-monospace, monospace)"));return lines}function typesetVars(indent=" "){let lines=[`${indent}--typeset-rhythm: var(--typeset-size);`];for(let role of TYPESET_SCALE_NAMES){let ratio=TYPESET_RATIOS[role],size=ratio.size===1?"var(--typeset-rhythm)":`calc(var(--typeset-rhythm) * ${ratio.size})`,leading=ratio.leading===1?"var(--typeset-leading)":`calc(var(--typeset-leading) * ${ratio.leading})`;lines.push(`${indent}--text-${role}: ${size};`),lines.push(`${indent}--leading-${role}: ${leading};`),lines.push(`${indent}--tracking-${role}: ${ratio.tracking};`)}return lines}var NARROW_BREAKPOINT="48rem",NARROW_BUMP=1.125;function rhythmBump(selector){return[`@media (width < ${NARROW_BREAKPOINT}) {`,` ${selector} {`,` --typeset-rhythm: calc(var(--typeset-size) * ${NARROW_BUMP});`," }","}"]}function typesetElementRules(){let rules=[":where(.typeset) {"," font-family: var(--typeset-font-body);"," font-size: var(--typeset-rhythm);"," line-height: var(--typeset-leading);","}"];for(let level of[1,2,3,4,5,6]){let role=HEADING_ROLE_BY_LEVEL[level],space=round(1.9-(level-1)*0.15);rules.push(`:where(.typeset h${level}) {`," font-family: var(--typeset-font-heading);",` font-size: var(--text-${role});`,` line-height: var(--leading-${role});`,` letter-spacing: var(--tracking-${role});`,` font-weight: ${TYPESET_RATIOS[role].weight};`,` margin-block-start: calc(var(--typeset-flow) * ${space});`," margin-block-end: 0;"," text-wrap: balance;","}")}return rules.push(":where("," .typeset p,"," .typeset ul,"," .typeset ol,"," .typeset blockquote,"," .typeset pre,"," .typeset table,"," .typeset figure",") {"," margin-block-start: var(--typeset-flow);"," margin-block-end: 0;","}",":where(.typeset > :first-child) {"," margin-block-start: 0;","}",":where(.typeset ul, .typeset ol) {"," padding-inline-start: calc(var(--typeset-flow) * 1.25);","}",":where(.typeset ul) { list-style: disc; }",":where(.typeset ol) { list-style: decimal; }",":where(.typeset li) {"," margin-block-start: calc(var(--typeset-flow) * 0.4);","}",":where(.typeset li)::marker {"," color: var(--color-muted-foreground, currentColor);","}",":where(.typeset blockquote) {"," padding-inline-start: var(--typeset-flow);"," border-inline-start: 2px solid var(--color-border, currentColor);"," color: var(--color-muted-foreground, inherit);"," font-style: italic;","}",":where(.typeset code) {"," font-family: var(--typeset-font-mono);"," font-size: 0.875em;"," border-radius: calc(var(--radius, 0.5rem) * 0.5);"," background: var(--color-muted, transparent);"," padding: 0.15em 0.35em;","}",":where(.typeset pre) {"," font-family: var(--typeset-font-mono);"," padding: var(--typeset-flow);"," border-radius: var(--radius, 0.5rem);"," background: var(--color-muted, transparent);"," overflow-x: auto;","}",":where(.typeset pre code) {"," background: none;"," padding: 0;"," font-size: 0.875em;","}",":where(.typeset a) {"," color: inherit;"," text-decoration: underline;"," text-underline-offset: 0.2em;","}",":where(.typeset strong) { font-weight: 600; }",":where(.typeset small) {"," font-size: var(--text-small);"," line-height: var(--leading-small);","}",":where(.typeset hr) {"," margin-block-start: calc(var(--typeset-flow) * 1.6);"," margin-block-end: 0;"," border: 0;"," border-block-start: 1px solid var(--color-border, currentColor);","}",":where(.typeset table) {"," width: 100%;"," border-collapse: collapse;"," font-size: var(--text-caption);"," line-height: var(--leading-caption);","}",":where(.typeset th, .typeset td) {"," padding: calc(var(--typeset-flow) * 0.4) calc(var(--typeset-flow) * 0.6);"," border-block-end: 1px solid var(--color-border, currentColor);"," text-align: start;","}",":where(.typeset th) { font-weight: 600; }",":where(.typeset img, .typeset video) {"," max-width: 100%;"," height: auto;"," border-radius: var(--radius, 0.5rem);","}"),rules}function typesetCss(typesets,options={}){let all=typesets??{},base=all[DEFAULT_TYPESET_NAME],blocks=[];if(options.root!==!1)blocks.push([":root {",...typesetBaseVars(base),...typesetVars(),"}"].join(`
56
56
  `)),blocks.push(rhythmBump(":root").join(`
57
57
  `));blocks.push([".typeset {",...typesetBaseVars(base),...typesetVars(),"}"].join(`
@@ -60,4 +60,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
60
60
  `))}return blocks.push(typesetElementRules().join(`
61
61
  `)),blocks.join(`
62
62
 
63
- `)}var DEFAULT_ROOT_PX=16;function typesetSizePx(size,rootPx=DEFAULT_ROOT_PX){if(typeof size==="number")return size;let match=/^(-?[\d.]+)\s*(px|rem|em|%)?$/.exec(size.trim());if(!match)return rootPx;let n=Number.parseFloat(match[1]);if(!Number.isFinite(n))return rootPx;switch(match[2]){case"px":case void 0:return n;case"%":return n/100*rootPx;default:return n*rootPx}}function typesetScale(typeset,options={}){let t=resolveTypeset(typeset),rootPx=options.rootPx??DEFAULT_ROOT_PX,basePx=typesetSizePx(t.size,rootPx),families=options.fontFamily??{},headingStack=t.fontHeading?families[t.fontHeading]:void 0,bodyStack=t.fontBody?families[t.fontBody]:void 0,out={};for(let role of TYPESET_SCALE_NAMES){let ratio=TYPESET_RATIOS[role],stack=ratio.face==="heading"?headingStack??bodyStack:bodyStack;out[role]={fontSize:round(basePx*ratio.size),lineHeight:round(t.leading*ratio.leading),letterSpacing:ratio.tracking,fontWeight:ratio.weight,...stack?{fontFamily:stack}:{}}}return out}function collectIds(root){let out=new Map;function walk(node,path){let id=nodeId(node);if(id!==void 0){let existing=out.get(id);if(existing)existing.push([...path]);else out.set(id,[[...path]])}if(isSnippetInstance(node))return;if(!isComponentNode(node))return;if(!node.children)return;for(let i=0;i<node.children.length;i++){let child=node.children[i];if(child)walk(child,[...path,i])}}return walk(root,[]),out}function findDuplicateIds(root){let all=collectIds(root),dupes=[];for(let[id,paths]of all)if(paths.length>1)dupes.push({id,paths});return dupes}var ViewportSchema=object({w:number().int().positive(),h:number().int().positive()});export{clone,normalizeParams,own,installLazyProp,NEVER,$constructor,prettifyError,parse,parseAsync,safeParse,safeParseAsync,$ZodType,$ZodObject,_coercedNumber,toJSONSchema,ZodError,string,url,ZodNumber,number,boolean,_null,any,unknown,array,object,strictObject,looseObject,union,discriminatedUnion,intersection,record,_enum,literal,ZodOptional,optional,custom,preprocess,datetime,exports_iso,AnnotationSchema,CanvasNoteSchema,AssetsFileSchema,EMPTY_ASSETS_FILE,FrameSchemeSchema,MAX_BOARD_NAME_LENGTH,BoardSchema,isArchived,CommentAnchorSchema,CommentAuthorSchema,CommentThreadSchema,ExtensionPropDescriptorSchema,ExtensionSchema,designNameIssue,isDesignName,toDesignName,RepoManifestSchema,REPO_MANIFEST_FILE,normalizeRepoManifest,CURRENT_SCHEMA_VERSION,schemaVersionOf,APP_PATH_PREFIX,planMigration,ViewportPresetSchema,LibrarySchema,ConfigSchema,isCssIdent,sanitizeCssTokenValue,neutralizeCssText,sanitizeGoogleFontSpec,pascalizeIconName,isComponentNode,isSnippetInstance,isParamRef,NodeIdSchema,NodeSchema,nodeId,ScreenSchema,SnippetParamSchema,SnippetSchema,resolveSnippetArgs,substituteSnippetParams,applySnippetOverrides,applySnippetExtraClassName,svgLooksActive,sanitizeSvgMarkup,ColorsSchema,resolveColors,ThemeSchema,DEFAULT_TYPESET_NAME,isTypesetName,TYPESET_SCALE_NAMES,resolveHeadingLevel,headingClasses,textClasses,headingInlineStyle,textInlineStyle,typesetSafelist,typesetUtilityClasses,typesetV3FontSize,typesetThemeTokens,resolveTypeset,typesetCss,typesetScale,findDuplicateIds,ViewportSchema};
63
+ `)}var DEFAULT_ROOT_PX=16;function typesetSizePx(size,rootPx=DEFAULT_ROOT_PX){if(typeof size==="number")return size;let match=/^(-?[\d.]+)\s*(px|rem|em|%)?$/.exec(size.trim());if(!match)return rootPx;let n=Number.parseFloat(match[1]);if(!Number.isFinite(n))return rootPx;switch(match[2]){case"px":case void 0:return n;case"%":return n/100*rootPx;default:return n*rootPx}}function typesetScale(typeset,options={}){let t=resolveTypeset(typeset),rootPx=options.rootPx??DEFAULT_ROOT_PX,basePx=typesetSizePx(t.size,rootPx),families=options.fontFamily??{},headingStack=t.fontHeading?families[t.fontHeading]:void 0,bodyStack=t.fontBody?families[t.fontBody]:void 0,out={};for(let role of TYPESET_SCALE_NAMES){let ratio=TYPESET_RATIOS[role],stack=ratio.face==="heading"?headingStack??bodyStack:bodyStack;out[role]={fontSize:round(basePx*ratio.size),lineHeight:round(t.leading*ratio.leading),letterSpacing:ratio.tracking,fontWeight:ratio.weight,...stack?{fontFamily:stack}:{}}}return out}function collectIds(root){let out=new Map;function walk(node,path){let id=nodeId(node);if(id!==void 0){let existing=out.get(id);if(existing)existing.push([...path]);else out.set(id,[[...path]])}if(isSnippetInstance(node))return;if(!isComponentNode(node))return;if(!node.children)return;for(let i=0;i<node.children.length;i++){let child=node.children[i];if(child)walk(child,[...path,i])}}return walk(root,[]),out}function findDuplicateIds(root){let all=collectIds(root),dupes=[];for(let[id,paths]of all)if(paths.length>1)dupes.push({id,paths});return dupes}var ViewportSchema=object({w:number().int().positive(),h:number().int().positive()});export{clone,normalizeParams,own,installLazyProp,NEVER,$constructor,prettifyError,parse,parseAsync,safeParse,safeParseAsync,$ZodType,$ZodObject,_coercedNumber,toJSONSchema,ZodError,string,url,ZodNumber,number,boolean,_null,any,unknown,array,object,strictObject,looseObject,union,discriminatedUnion,intersection,record,_enum,literal,ZodOptional,optional,custom,preprocess,datetime,exports_iso,AnnotationSchema,CanvasNoteSchema,AssetsFileSchema,EMPTY_ASSETS_FILE,FrameSchemeSchema,MAX_BOARD_NAME_LENGTH,BoardSchema,isArchived,CommentAnchorSchema,CommentAuthorSchema,CommentThreadSchema,ExtensionPropDescriptorSchema,ExtensionSchema,RepoComponentsManifestSchema,designNameIssue,isDesignName,toDesignName,RepoManifestSchema,REPO_MANIFEST_FILE,normalizeRepoManifest,CURRENT_SCHEMA_VERSION,schemaVersionOf,APP_PATH_PREFIX,planMigration,ViewportPresetSchema,LibrarySchema,ConfigSchema,isCssIdent,sanitizeCssTokenValue,neutralizeCssText,sanitizeGoogleFontSpec,pascalizeIconName,isComponentNode,isSnippetInstance,isParamRef,NodeIdSchema,repoImportIssue,RepoComponentRefSchema,isRepoNode,repoKey,parseRepoKey,NodeSchema,nodeId,ScreenSchema,SnippetParamSchema,SnippetSchema,resolveSnippetArgs,substituteSnippetParams,applySnippetOverrides,applySnippetExtraClassName,svgLooksActive,sanitizeSvgMarkup,ColorsSchema,resolveColors,ThemeSchema,DEFAULT_TYPESET_NAME,isTypesetName,TYPESET_SCALE_NAMES,resolveHeadingLevel,headingClasses,textClasses,headingInlineStyle,textInlineStyle,typesetSafelist,typesetUtilityClasses,typesetV3FontSize,typesetThemeTokens,resolveTypeset,typesetCss,typesetScale,findDuplicateIds,ViewportSchema};