@okhay-p/mivra 0.1.2 → 0.1.3

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.
@@ -410,4 +410,4 @@ function _b(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...q(n)})}//
410
410
  function vb(e,t){let n=/* @__PURE__ */ yb(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Oh(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Oh(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
411
411
  function yb(e,t){let n=new $g({check:`custom`,...q(t)});return n._zod.check=e,n}function bb(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Bm(e,t,n[t]);return e}function xb(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??gy,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Sb(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Cb(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Cb(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&bb(o.schema,c),t.io===`input`&&Nb(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function wb(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Tb(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${wb(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+wb(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
412
412
 
413
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Eb(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Eb(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let Db=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Ob=[`oneOf`,`anyOf`];function kb(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ab(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Db.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??kb(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Bm(n,r,e.length===1?e[0]:Ab(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=kb(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function jb(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Db)if(t in e)return;let n=t.filter(e=>Ob.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ab(t);else{let e=n[0],i=Ob.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ab([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,bb(e,r))}function Mb(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):bb(i,s),bb(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Eb(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])jb(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}bb(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Bm(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Fb(t,`input`,e.processors),output:Fb(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Nb(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Nb(r.element,n);if(r.type===`set`)return Nb(r.valueType,n);if(r.type===`lazy`)return Nb(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Nb(r.innerType,n);if(r.type===`intersection`)return Nb(r.left,n)||Nb(r.right,n);if(r.type===`record`||r.type===`map`)return Nb(r.keyType,n)||Nb(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Nb(r.in,n)||Nb(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Nb(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Nb(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Nb(e,n))return!0;return!!(r.rest&&Nb(r.rest,n))}return!1}let Pb=(e,t={})=>n=>{let r=xb({...n,processors:t});return Cb(e,r),Tb(r,e),Mb(r,e)},Fb=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=xb({...i??{},target:a,io:t,processors:n});return Cb(e,o),Tb(o,e),Mb(o,e)},Ib=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Lb=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rb=(e,t)=>{Ib(e,`minimum`,t),Lb(e,`maximum`,t)},zb=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Bb=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Vb=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Hb=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ub=(e,t)=>Ib(e,`minimum`,t.minimum),Wb=(e,t)=>Lb(e,`maximum`,t.maximum),Gb=e=>(t,n)=>{Hb(t,n.format);let[r,i]=e[n.format];Ib(t,`minimum`,r),Lb(t,`maximum`,i)},Kb={greater_than:(e,t)=>Ib(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Lb(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>zb(e,t.value),number_format:Gb(oh),bigint_format:Gb(sh),min_length:Ub,max_length:Wb,length_equals:(e,t)=>Rb(e,t.length),min_size:Ub,max_size:Wb,size_equals:(e,t)=>Rb(e,t.size),string_format:(e,t)=>{Hb(e,t.format),t.pattern&&Bb(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Vb(e,t.mime)};function qb(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Kb[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ib(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ib(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Lb(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Lb(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&zb(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Vb(t,i.mime);for(let e of i.patterns??[])Bb(t,e);return t}let Jb={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yb=/* @__PURE__ */ new Map([[tv,Rg],[rv,zg]]),Xb=e=>Yb.get(e)??e,Zb=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=qb(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jb[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Xb);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Qb=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=qb(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Sb(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},$b=(e,t,n,r)=>{n.type=`boolean`},ex=(e,t,n,r)=>{n.not={}},tx=(e,t,n,r)=>{let i=e._zod.def,a=Mm(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},nx=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Sb(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Sb(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},rx=(e,t,n,r)=>{Sb(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ix=(e,t,n,r)=>{Sb(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},ax=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=qb(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Cb(a.element,t,{...r,path:[...r.path,`items`]})};function ox(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ox(t.out):t.type===`catch`?ox(t.innerType):e._zod.optin}let sx=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Sb(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Bm(i.properties,e,Cb(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ox(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Cb(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},cx=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Cb(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},lx=(e,t,n,r)=>{let i=e._zod.def,a=Cb(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Cb(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},ux=(e,t,n,r)=>{let i=e._zod.def,a=Cb(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},dx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},fx=Symbol();function px(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Sb(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),fx):JSON.parse(o)}let mx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=px(i.defaultValue,e,t,n,r);o!==fx&&(n.default=o)},hx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=px(i.defaultValue,e,t,n,r);o!==fx&&(n._prefault=o)},gx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Sb(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},_x=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Cb(o,t,r);let s=t.seen.get(e);s.ref=o},vx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},yx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},bx=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function xx(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let Sx=/*@__PURE__*/ Y(`ZodError`,(e,t)=>{$h.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);bx.has(n)||(bx.add(n),xx(n,`format`,e=>t=>ng(e,t)),xx(n,`flatten`,e=>t=>tg(e,t)),xx(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Pm,2)}),xx(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Pm,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Cx=/* @__PURE__ */ ig(Sx),wx=/* @__PURE__ */ ag(Sx),Tx=/* @__PURE__ */ og(Sx),Ex=/* @__PURE__ */ cg(Sx),Dx=/* @__PURE__ */ mg(Sx),Ox=/* @__PURE__ */ hg(Sx),kx=/* @__PURE__ */ gg(Sx),Ax=/* @__PURE__ */ _g(Sx),jx=/* @__PURE__ */ vg(Sx),Mx=/* @__PURE__ */ yg(Sx),Nx=/* @__PURE__ */ bg(Sx),Px=/* @__PURE__ */ xg(Sx);function Fx(){Kh.localeError||qh(fy())}function Ix(){Kh.memoizer||qh({memoizer:ly()})}let Lx=/*@__PURE__*/ Y(`ZodType`,(e,t)=>(Fx(),y_.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(qm(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return rh(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(QS(e,t))},superRefine(e,t){return this.check($S(e,t))},overwrite(e){return this.check(/* @__PURE__ */ ub(e))},optional(){return PS(this)},exactOptional(){return IS(this)},nullable(){return RS(this)},nullish(){return PS(RS(this))},nonoptional(e){return WS(this,e)},array(){return Z(this)},or(e){return CS([this,e])},and(e){return DS(this,e)},transform(e){return JS(this,MS(e))},default(e){return BS(this,e)},prefault(e){return HS(this,e)},catch(e){return KS(this,e)},pipe(e){return JS(this,e)},readonly(){return XS(this)},describe(e){let t=this.clone();return gy.add(t,{description:e}),t},meta(...e){if(e.length===0)return gy.get(this);let t=this.clone();return gy.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return jh(this,`~standard`,{...S_(this),jsonSchema:{input:Fb(this,`input`),output:Fb(this,`output`)}})},set"~standard"(e){Ah(this,`~standard`,e)},parse:function e(t,n){return Cx(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await wx(this,t,n,{callee:e})},safeParse(e,t){return Tx(this,e,t)},async safeParseAsync(e,t){return Ex(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ah(this,`spa`,e)},validate(e,t){return dg(this,e,t)},validateAsync(e,t){return pg(this,e,t)},encode:function e(t,n){return Dx(this,t,n,{callee:e})},decode:function e(t,n){return Ox(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await kx(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ax(this,t,n,{callee:e})},safeEncode(e,t){return jx(this,e,t)},safeDecode(e,t){return Mx(this,e,t)},async safeEncodeAsync(e,t){return Nx(this,e,t)},async safeDecodeAsync(e,t){return Px(this,e,t)},toJSONSchema(e){return Pb(this,{})(e)},get description(){return gy.get(this)?.description},get _def(){return this._zod.def}}),Rx=/*@__PURE__*/ Y(`_ZodString`,(e,t)=>{C_.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zb(e,t,n,r)},/*@__PURE__*/ Mh({format:e=>qb(e).format??null,minLength:e=>qb(e).minimum??null,maxLength:e=>qb(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ ib(...e))},includes(...e){return this.check(/* @__PURE__ */ sb(...e))},startsWith(...e){return this.check(/* @__PURE__ */ cb(...e))},endsWith(...e){return this.check(/* @__PURE__ */ lb(...e))},min(...e){return this.check(/* @__PURE__ */ nb(...e))},max(...e){return this.check(/* @__PURE__ */ tb(...e))},length(...e){return this.check(/* @__PURE__ */ rb(...e))},nonempty(...e){return this.check(/* @__PURE__ */ nb(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ ab(e))},uppercase(e){return this.check(/* @__PURE__ */ ob(e))},trim(){return this.check(/* @__PURE__ */ fb())},normalize(...e){return this.check(/* @__PURE__ */ db(...e))},toLowerCase(){return this.check(/* @__PURE__ */ pb())},toUpperCase(){return this.check(/* @__PURE__ */ mb())},slugify(){return this.check(/* @__PURE__ */ hb())}})),zx=/*@__PURE__*/ Y(`ZodString`,(e,t)=>{C_.init(e,t),Rx.init(e,t)},{email(e){return this.check(/* @__PURE__ */ yy(Gx,e))},url(e){return this.check(/* @__PURE__ */ Ty(Jx,e))},jwt(e){return this.check(/* @__PURE__ */ By(lS,e))},emoji(e){return this.check(/* @__PURE__ */ Ey(Yx,e))},guid(e){return this.check(/* @__PURE__ */ by(Kx,e))},uuid(e){return this.check(/* @__PURE__ */ xy(qx,e))},uuidv4(e){return this.check(/* @__PURE__ */ Sy(qx,e))},uuidv6(e){return this.check(/* @__PURE__ */ Cy(qx,e))},uuidv7(e){return this.check(/* @__PURE__ */ wy(qx,e))},nanoid(e){return this.check(/* @__PURE__ */ Dy(Xx,e))},cuid(e){return this.check(/* @__PURE__ */ Oy(Zx,e))},cuid2(e){return this.check(/* @__PURE__ */ ky(Qx,e))},ulid(e){return this.check(/* @__PURE__ */ Ay($x,e))},base64(e){return this.check(/* @__PURE__ */ Ly(oS,e))},base64url(e){return this.check(/* @__PURE__ */ Ry(sS,e))},xid(e){return this.check(/* @__PURE__ */ jy(eS,e))},ksuid(e){return this.check(/* @__PURE__ */ My(tS,e))},ipv4(e){return this.check(/* @__PURE__ */ Ny(nS,e))},ipv6(e){return this.check(/* @__PURE__ */ Py(rS,e))},cidrv4(e){return this.check(/* @__PURE__ */ Fy(iS,e))},cidrv6(e){return this.check(/* @__PURE__ */ Iy(aS,e))},e164(e){return this.check(/* @__PURE__ */ zy(cS,e))},datetime(e){return this.check(/* @__PURE__ */ Vy(Vx,e))},date(e){return this.check(/* @__PURE__ */ Hy(Hx,e))},time(e){return this.check(/* @__PURE__ */ Uy(Ux,e))},duration(e){return this.check(/* @__PURE__ */ Wy(Wx,e))}});function X(e){return/* @__PURE__ */ vy(zx,e)}let Bx=/*@__PURE__*/ Y(`ZodStringFormat`,(e,t)=>{w_.init(e,t),Rx.init(e,t)}),Vx=/*@__PURE__*/ Y(`ZodISODateTime`,(e,t)=>{U_.init(e,t),Bx.init(e,t)}),Hx=/*@__PURE__*/ Y(`ZodISODate`,(e,t)=>{W_.init(e,t),Bx.init(e,t)}),Ux=/*@__PURE__*/ Y(`ZodISOTime`,(e,t)=>{G_.init(e,t),Bx.init(e,t)}),Wx=/*@__PURE__*/ Y(`ZodISODuration`,(e,t)=>{K_.init(e,t),Bx.init(e,t)}),Gx=/*@__PURE__*/ Y(`ZodEmail`,(e,t)=>{D_.init(e,t),Bx.init(e,t)}),Kx=/*@__PURE__*/ Y(`ZodGUID`,(e,t)=>{T_.init(e,t),Bx.init(e,t)}),qx=/*@__PURE__*/ Y(`ZodUUID`,(e,t)=>{E_.init(e,t),Bx.init(e,t)}),Jx=/*@__PURE__*/ Y(`ZodURL`,(e,t)=>{F_.init(e,t),Bx.init(e,t)}),Yx=/*@__PURE__*/ Y(`ZodEmoji`,(e,t)=>{I_.init(e,t),Bx.init(e,t)}),Xx=/*@__PURE__*/ Y(`ZodNanoID`,(e,t)=>{L_.init(e,t),Bx.init(e,t)}),Zx=/*@__PURE__*/ Y(`ZodCUID`,(e,t)=>{R_.init(e,t),Bx.init(e,t)}),Qx=/*@__PURE__*/ Y(`ZodCUID2`,(e,t)=>{z_.init(e,t),Bx.init(e,t)}),$x=/*@__PURE__*/ Y(`ZodULID`,(e,t)=>{B_.init(e,t),Bx.init(e,t)}),eS=/*@__PURE__*/ Y(`ZodXID`,(e,t)=>{V_.init(e,t),Bx.init(e,t)}),tS=/*@__PURE__*/ Y(`ZodKSUID`,(e,t)=>{H_.init(e,t),Bx.init(e,t)}),nS=/*@__PURE__*/ Y(`ZodIPv4`,(e,t)=>{q_.init(e,t),Bx.init(e,t)}),rS=/*@__PURE__*/ Y(`ZodIPv6`,(e,t)=>{X_.init(e,t),Bx.init(e,t)}),iS=/*@__PURE__*/ Y(`ZodCIDRv4`,(e,t)=>{Z_.init(e,t),Bx.init(e,t)}),aS=/*@__PURE__*/ Y(`ZodCIDRv6`,(e,t)=>{$_.init(e,t),Bx.init(e,t)}),oS=/*@__PURE__*/ Y(`ZodBase64`,(e,t)=>{nv.init(e,t),Bx.init(e,t)}),sS=/*@__PURE__*/ Y(`ZodBase64URL`,(e,t)=>{av.init(e,t),Bx.init(e,t)}),cS=/*@__PURE__*/ Y(`ZodE164`,(e,t)=>{ov.init(e,t),Bx.init(e,t)}),lS=/*@__PURE__*/ Y(`ZodJWT`,(e,t)=>{cv.init(e,t),Bx.init(e,t)}),uS=/*@__PURE__*/ Y(`ZodNumber`,(e,t)=>{lv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qb(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Mh({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=qb(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=qb(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=qb(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>qb(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ Qy(e,t))},gte(e,t){return this.check(/* @__PURE__ */ $y(e,t))},min(e,t){return this.check(/* @__PURE__ */ $y(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Xy(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Zy(e,t))},max(e,t){return this.check(/* @__PURE__ */ Zy(e,t))},int(e){return this.check(pS(e))},safe(e){return this.check(pS(e))},positive(e){return this.check(/* @__PURE__ */ Qy(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ $y(0,e))},negative(e){return this.check(/* @__PURE__ */ Xy(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Zy(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ eb(e,t))},step(e,t){return this.check(/* @__PURE__ */ eb(e,t))},finite(){return this}}));function dS(e){return/* @__PURE__ */ Gy(uS,e)}let fS=/*@__PURE__*/ Y(`ZodNumberFormat`,(e,t)=>{uv.init(e,t),uS.init(e,t)});function pS(e){return/* @__PURE__ */ Ky(fS,e)}let mS=/*@__PURE__*/ Y(`ZodBoolean`,(e,t)=>{dv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$b(e,t,n,r)});function hS(e){return/* @__PURE__ */ qy(mS,e)}let gS=/*@__PURE__*/ Y(`ZodUnknown`,(e,t)=>{fv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function _S(){return/* @__PURE__ */ Jy(gS)}let vS=/*@__PURE__*/ Y(`ZodNever`,(e,t)=>{pv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ex(e,t,n,r)});function yS(e){return/* @__PURE__ */ Yy(vS,e)}let bS=/*@__PURE__*/ Y(`ZodArray`,(e,t)=>{Ix(),_v.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ax(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ nb(e,t))},nonempty(e){return this.check(/* @__PURE__ */ nb(1,e))},max(e,t){return this.check(/* @__PURE__ */ tb(e,t))},length(e,t){return this.check(/* @__PURE__ */ rb(e,t))},unwrap(){return this.element}});function Z(e,t){return/* @__PURE__ */ gb(bS,e,t)}let xS=/*@__PURE__*/ Y(`ZodObject`,(e,t)=>{Ix(),Cv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sx(e,t,n,r),Rh(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return kS(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(qm(this._zod.def,{catchall:e}))},passthrough(){return this.clone(qm(this._zod.def,{catchall:_S()}))},loose(){return this.clone(qm(this._zod.def,{catchall:_S()}))},strict(){return this.clone(qm(this._zod.def,{catchall:yS()}))},strip(){return this.clone(qm(this._zod.def,{catchall:void 0}))},extend(e){return dh(this,e)},safeExtend(e){return ph(this,e)},merge(e){return mh(this,e)},pick(e){return ch(this,e)},omit(e){return uh(this,e)},partial(...e){return hh(NS,this,e[0])},exactPartial(...e){return hh(FS,this,e[0],`exactPartial`)},required(...e){return gh(US,this,e[0])}});function Q(e,t){let n={type:`object`,shape:e??{},...q(t)};return new xS(n)}let SS=/*@__PURE__*/ Y(`ZodUnion`,(e,t)=>{Tv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cx(e,t,n,r),e.options=t.options});function CS(e,t){return new SS({type:`union`,options:e,...q(t)})}let wS=/*@__PURE__*/ Y(`ZodDiscriminatedUnion`,(e,t)=>{SS.init(e,t),Dv.init(e,t)});function TS(e,t,n){return new wS({type:`union`,options:t,discriminator:e,...q(n)})}let ES=/*@__PURE__*/ Y(`ZodIntersection`,(e,t)=>{Ov.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lx(e,t,n,r)});function DS(e,t){return new ES({type:`intersection`,left:e,right:t})}let OS=/*@__PURE__*/ Y(`ZodEnum`,(e,t)=>{jv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tx(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new OS({...t,checks:[],...q(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new OS({...t,checks:[],...q(r),entries:i})}});function kS(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new OS({type:`enum`,entries:n,...q(t)})}let AS=/*@__PURE__*/ Y(`ZodLiteral`,(e,t)=>{Mv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nx(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(e,t){return new AS({type:`literal`,values:Array.isArray(e)?e:[e],...q(t)})}let jS=/*@__PURE__*/ Y(`ZodTransform`,(e,t)=>{Ix(),Nv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ix(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Gh(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Oh(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Oh(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function MS(e){return new jS({type:`transform`,transform:e})}let NS=/*@__PURE__*/ Y(`ZodOptional`,(e,t)=>{Fv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function PS(e){return new NS({type:`optional`,innerType:e})}let FS=/*@__PURE__*/ Y(`ZodExactOptional`,(e,t)=>{Iv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function IS(e){return new FS({type:`optional`,innerType:e})}let LS=/*@__PURE__*/ Y(`ZodNullable`,(e,t)=>{Lv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ux(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function RS(e){return new LS({type:`nullable`,innerType:e})}let zS=/*@__PURE__*/ Y(`ZodDefault`,(e,t)=>{Rv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function BS(e,t){return new zS({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():eh(t)}})}let VS=/*@__PURE__*/ Y(`ZodPrefault`,(e,t)=>{Bv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function HS(e,t){return new VS({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():eh(t)}})}let US=/*@__PURE__*/ Y(`ZodNonOptional`,(e,t)=>{Vv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function WS(e,t){return new US({type:`nonoptional`,innerType:e,...q(t)})}let GS=/*@__PURE__*/ Y(`ZodCatch`,(e,t)=>{Wv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function KS(e,t){return new GS({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:zh(t)})}let qS=/*@__PURE__*/ Y(`ZodPipe`,(e,t)=>{Gv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_x(e,t,n,r),e.in=t.in,e.out=t.out});function JS(e,t){return new qS({type:`pipe`,in:e,out:t})}let YS=/*@__PURE__*/ Y(`ZodReadonly`,(e,t)=>{qv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function XS(e){return new YS({type:`readonly`,innerType:e})}let ZS=/*@__PURE__*/ Y(`ZodCustom`,(e,t)=>{Yv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rx(e,t,n,r)});function QS(e,t={}){return/* @__PURE__ */ _b(ZS,e,t)}function $S(e,t){return/* @__PURE__ */ vb(e,t)}let eC=e=>e!==void 0&&/\s/.test(e),tC=e=>e!==void 0&&e>=`0`&&e<=`9`;function nC(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`\\`&&e[r+1]===`$`)n+=`$`,r+=2;else if(i!==`$`)n+=i,r+=1;else if(e[r+1]===`$`)for(;e[r]===`$`;)n+=`$`,r+=1;else{let i=rC(e,r);i===void 0?(n+=`$`,r+=1):(n&&t.push({text:n}),n=``,t.push({formula:e.slice(r+1,i)}),r=i+1)}}return n&&t.push({text:n}),t}function rC(e,t){let n=t+1;for(;n<e.length&&e[n]!==`$`;)n+=e[n]===`\\`&&(e[n+1]===`$`||e[n+1]===`\\`)?2:1;if(!(n>=e.length||n===t+1||e[n+1]===`$`)&&!(eC(e[t+1])||eC(e[n-1])||tC(e[n+1])))return/`|\n\s*\n/.test(e.slice(t,n))?void 0:n}let iC=String.raw`Wrap LaTeX commands in single-dollar math delimiters, with no spaces inside: $\displaystyle\sum_{i=1}^{n} i$. Put \displaystyle inside the dollars. For literal backslashes followed by two or more letters (such as C:\Users), use forward slashes, Unicode symbols such as ∖, or describe them in words; backticks do not escape artifact math. Correct the affected field and retry this tool call.`;function aC(e,t,n){typeof e==`string`&&nC(e).some(e=>`text`in e&&/\\[a-zA-Z]{2,}/.test(e.text))&&n.addIssue({code:`custom`,path:t,message:iC})}function oC(e,t,n){return e.superRefine((e,r)=>{let i=(e,t,n)=>{if(t.length===0)return aC(e,n,r);let[a,...o]=t;a===`*`&&Array.isArray(e)?e.forEach((e,t)=>i(e,o,[...n,t])):e&&typeof e==`object`&&a!==void 0&&i(e[a],o,[...n,a])};for(let n of t)i(e,n.split(`.`),[]);n?.(e,r)})}let sC=X().trim().min(1).max(40),cC=CS([dS(),X().max(24)]),lC=dS().int().nonnegative(),uC=Q({name:sC.describe(`Pointer label shown under the cell, e.g. "left", "right", "mid", "i".`),index:lC.describe(`0-based index into the sequence as it is at this step.`)}).strict(),dC=Q({start:lC.describe(`0-based start index, inclusive, within the sequence as it is at this step.`),end:lC.describe(`0-based end index, inclusive. Must be >= start and within the sequence.`),label:sC.optional().describe(`Optional label, e.g. "window".`),tone:kS([`active`,`done`,`muted`]).optional().describe(`active = current focus, done = finished/sorted, muted = ruled out. Defaults to active.`)}).strict(),fC=Q({name:sC,value:CS([dS(),X().max(80),hS()])}).strict(),pC=Q({explanation:X().trim().min(1).max(500).describe(`What happens in this step, in one or two sentences.`),values:Z(cC).min(1).max(64).optional().describe(`The whole sequence after this step. Omit unless the values changed (e.g. a swap); omitted means unchanged.`),pointers:Z(uC).max(8).optional().describe(`All pointers to show at this step. Not carried over from earlier steps: repeat any that still apply.`),ranges:Z(dC).max(8).optional().describe(`All highlighted ranges at this step. Not carried over from earlier steps.`),variables:Z(fC).max(12).optional().describe(`All running state at this step, e.g. current sum, best so far. Not carried over from earlier steps.`)}).strict(),mC=Q({title:X().trim().min(1).max(120),values:Z(cC).min(1).max(64).describe(`The input sequence before the first step.`),steps:Z(pC).min(1).max(200)}).strict().superRefine((e,t)=>{let n=e.values.length;e.steps.forEach((e,r)=>{e.values&&(n=e.values.length),e.pointers?.forEach((e,i)=>{e.index>=n&&t.addIssue({code:`custom`,path:[`steps`,r,`pointers`,i,`index`],message:`index ${e.index} is outside the sequence (length ${n})`})}),e.ranges?.forEach((e,i)=>{(e.end>=n||e.start>e.end)&&t.addIssue({code:`custom`,path:[`steps`,r,`ranges`,i],message:`range ${e.start}..${e.end} is invalid for a sequence of length ${n}`})})})});Q({goal:X().trim().min(1).max(300)}).strict();let hC=X().trim().min(1).max(80),gC=Q({concept:hC.describe(`The single concept this question probes, e.g. "chain rule". Reuse the exact name from the learner's record when it is there.`),question:X().trim().min(1).max(1e3),options:Z(Q({text:X().trim().min(1).max(300)}).strict()).min(2).max(5).describe(`2-5 options with distinct text. For true/false or yes/no use two options, e.g. "True" and "False". Never add a "Not sure" option: the UI always offers one.`),correctOptionIndex:dS().int().nonnegative().describe(`0-based index of the single correct option.`),explanation:X().trim().min(1).max(600).describe(`One or two sentences shown after answering: why the correct option is correct.`)}).strict().superRefine((e,t)=>{e.correctOptionIndex>=e.options.length&&t.addIssue({code:`custom`,path:[`correctOptionIndex`],message:`correctOptionIndex must point at one of the options`});let n=/* @__PURE__ */ new Map;e.options.forEach((e,r)=>{let i=e.text.normalize(`NFC`),a=n.get(i);a===void 0?n.set(i,r):t.addIssue({code:`custom`,path:[`options`,r,`text`],message:`duplicates option ${a}`}),/^\s*(not sure|i don'?t know|unsure|skip)\W*$/i.test(e.text)&&t.addIssue({code:`custom`,path:[`options`,r,`text`],message:`Leave out Not sure / Skip: the UI always offers them`})})}),_C=Q({concept:X(),question:X(),options:Z(Q({text:X()}).strict())}).strict(),vC=CS([Q({optionIndex:dS().int().nonnegative()}).strict(),Q({unsure:$(!0)}).strict(),Q({skipped:$(!0)}).strict()]),yC=Q({result:kS([`correct`,`incorrect`,`unsure`,`skipped`]),correctOptionIndex:dS().int().nonnegative(),explanation:X()}).strict(),bC=kS([`memory`,`test`,`guess`]),xC=Q({title:X().trim().min(1).max(120),summary:X().trim().min(1).max(400).describe(`What the lesson on this topic will cover, in one or two sentences.`),reason:X().trim().min(1).max(300).describe(`Why this topic is here for this learner, e.g. "You missed the question on local minima".`),requestedByLearner:hS().describe(`True if the learner explicitly asked for this topic. Such topics are never removed automatically.`),concepts:Z(hC).min(1).max(8).describe(`Concept names this topic teaches; reuse names from the learner's record and the placement questions.`)}).strict(),SC=Q({topics:Z(xC).min(1).max(20).describe(`The ordered topics, first to learn first. Each topic gets one lesson.`),known:Z(Q({concept:hC,source:bC.describe(`memory = from their record or memories; test = from this placement interview; guess = your inference`),note:X().trim().min(1).max(200)}).strict()).max(20).describe(`What the learner already knows or doesn't, each labelled with where that comes from. Shown to the learner.`)}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;e.topics.forEach((e,r)=>{let i=e.title.trim().toLowerCase();n.has(i)&&t.addIssue({code:`custom`,path:[`topics`,r,`title`],message:`Topic titles must be distinct`}),n.add(i)})}),CC=xC.extend({id:X()}).strict(),wC=Q({version:dS().int().positive(),source:kS([`interview`,`tutor`,`adaptive`,`undo`]),reason:X().nullable(),changedTopicIds:Z(X()),canUndo:hS(),topics:Z(CC),known:SC.shape.known,createdAt:X().datetime()}).strict(),TC=kS([`interviewing`,`active`,`complete`]);Q({id:X(),sessionId:X(),goal:X(),status:TC,syllabus:wC.nullable(),interviewMessageId:X().nullable(),createdAt:X().datetime()}).strict();let EC=X().trim().min(1).max(24),DC=X().trim().min(1).max(24),OC=kS([`active`,`done`,`muted`]).optional().describe(`active = current focus, done = finished/visited, muted = ruled out. Defaults to active.`),kC=Q({id:EC.describe(`Unique id, used by edges and steps. Shown on the node if it has no label.`),label:DC.optional().describe(`Short text on the node. Only $...$ is a formula, e.g. $v_1$.`)}).strict(),AC=Q({from:EC.describe(`Id of a node. In a tree, the parent.`),to:EC.describe("Id of a node, the same as `from` for a self-loop. In a tree, the child; children appear left to right in edge order unless they have a `side`."),side:kS([`left`,`right`]).optional().describe("Only when kind is tree: which child this is of `from`, its parent. Set it on every edge of a binary search tree or binary tree traversal, because a lone left child and a lone right child are different trees. A node has at most one child per side, and either all of its children have a side or none do."),weight:dS().optional().describe(`Numeric weight shown on the edge. Give a weight or a label, not both.`),label:DC.optional().describe(`Text shown on the edge. Only $...$ is a formula.`)}).strict(),jC=Q({id:EC.describe(`Id of a node.`),tone:OC}).strict(),MC=Q({from:EC,to:EC,nth:dS().int().nonnegative().optional().describe("Only for parallel edges, and then required: which of the edges joining these nodes, 0-based in the order of `edges`."),tone:OC}).strict().describe(`An edge of the graph. In an undirected graph, from and to may be in either order.`),NC=Q({explanation:X().trim().min(1).max(500).describe(`What happens in this step, in one or two sentences.`),nodeStates:Z(jC).max(60).optional().describe(`The state of every node that has one at this step, at most one each. Not carried over from earlier steps: repeat any that still apply.`),edgeStates:Z(MC).max(200).optional().describe(`The state of every edge that has one at this step, at most one each. Not carried over from earlier steps: repeat any that still apply.`),variables:Z(fC).max(12).optional().describe(`All running state at this step, e.g. the queue or current distances. Not carried over from earlier steps.`)}).strict(),PC=(e,t,n)=>JSON.stringify(n||e<=t?[e,t]:[t,e]);function FC(e){let t=/* @__PURE__ */ new Map;return e.edges.forEach((n,r)=>{let i=PC(n.from,n.to,e.directed),a=t.get(i);a?a.push(r):t.set(i,[r])}),n=>{let r=`${n.from} ${e.directed?`->`:`--`} ${n.to}`,i=t.get(PC(n.from,n.to,e.directed));if(!i)return{error:`there is no edge ${r}`};if(n.nth===void 0&&i.length>1)return{error:`${i.length} edges match ${r}: set nth to pick one`};let a=i[n.nth??0];return a===void 0?{error:`nth ${n.nth} is out of range: ${i.length} edges match ${r}`}:{index:a}}}function IC(e){if(e.edges.length!==e.nodes.length-1)return;let t=e.nodes.map(e=>e.id),n=new Map(t.map(e=>[e,[]]));for(let{from:t,to:r}of e.edges)n.get(t).push(r),!e.directed&&t!==r&&n.get(r).push(t);let r=e.directed?t.filter(t=>!e.edges.some(e=>e.to===t)):t.slice(0,1),i=r[0];if(r.length!==1||i===void 0)return;let a=/* @__PURE__ */ new Map,o=[i];for(;o.length;){let e=o.pop(),t=n.get(e).filter(e=>!a.has(e));a.set(e,t),o.push(...t)}return a.size===t.length?{root:i,children:a}:void 0}function LC(e,t){let n=e.edges.flatMap((e,t)=>e.side?[{edge:e,side:e.side,path:[`edges`,t,`side`]}]:[]),r=n[0];if(!r)return;if(e.kind!==`tree`){for(let{path:e}of n)t.addIssue({code:`custom`,path:e,message:`side only applies when kind is "tree": remove it, or set kind`});return}let i=IC(e);if(!i){t.addIssue({code:`custom`,path:r.path,message:`side needs a real tree: connected with no cycles, and when directed, edges going parent to child from one root`});return}let a=/* @__PURE__ */ new Map;for(let{edge:e,side:r,path:o}of n)i.children.get(e.from).includes(e.to)?a.set(e.to,r):t.addIssue({code:`custom`,path:o,message:`side needs from to be the parent, but ${e.to} is the parent of ${e.from} here: swap them`});for(let[e,n]of i.children){let r=n.flatMap(e=>a.get(e)??[]);r.length>0&&r.length<n.length&&t.addIssue({code:`custom`,path:[`edges`],message:`node ${e} mixes children with and without a side: give all of them one, or none`});for(let n of[`left`,`right`])r.filter(e=>e===n).length>1&&t.addIssue({code:`custom`,path:[`edges`],message:`node ${e} has two ${n} children`})}}let RC=Q({title:X().trim().min(1).max(120),directed:hS().describe("True draws arrowheads from `from` to `to`."),kind:kS([`tree`,`graph`]).optional().describe("Layout hint. tree draws a rooted tree top-down, and needs a real tree: connected with no cycles, and when directed, edges going parent to child from one root. When undirected, the first node is the root. Anything else falls back to the general layout, unless an edge has a `side`, which is then an error. Defaults to graph."),nodes:Z(kC).min(1).max(60),edges:Z(AC).max(200).describe(`Self-loops and parallel edges are allowed.`),steps:Z(NC).min(1).max(200).optional().describe(`Omit to show the graph without stepping through it.`)}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;e.nodes.forEach((e,r)=>{n.has(e.id)&&t.addIssue({code:`custom`,path:[`nodes`,r,`id`],message:`duplicate node id ${e.id}`}),n.add(e.id)}),e.edges.forEach((e,r)=>{for(let i of[`from`,`to`])n.has(e[i])||t.addIssue({code:`custom`,path:[`edges`,r,i],message:`no node has id ${e[i]}`});e.weight!==void 0&&e.label!==void 0&&t.addIssue({code:`custom`,path:[`edges`,r],message:`give a weight or a label, not both`})}),e.edges.every(e=>n.has(e.from)&&n.has(e.to))&&LC(e,t);let r=FC(e);e.steps?.forEach((e,i)=>{let a=/* @__PURE__ */ new Set;e.nodeStates?.forEach((e,r)=>{let o=[`steps`,i,`nodeStates`,r];n.has(e.id)||t.addIssue({code:`custom`,path:o,message:`no node has id ${e.id}`}),a.has(e.id)&&t.addIssue({code:`custom`,path:o,message:`node ${e.id} has two states in one step`}),a.add(e.id)});let o=/* @__PURE__ */ new Set;e.edgeStates?.forEach((e,n)=>{let a=[`steps`,i,`edgeStates`,n],s=r(e);if(`error`in s)return t.addIssue({code:`custom`,path:a,message:s.error});o.has(s.index)&&t.addIssue({code:`custom`,path:a,message:`edge ${s.index} has two states in one step`}),o.add(s.index)})})}),zC=Q({text:X().trim().min(1).max(300),feedback:X().trim().min(1).max(500).optional().describe(`Shown if the learner picks this option: why it is right or what misconception it reflects.`)}).strict(),BC=Q({concept:X().trim().min(1).max(80).describe(`Short label for the concept being checked, e.g. "sliding window invariant". Used to track progress.`),question:X().trim().min(1).max(1e3),options:Z(zC).min(2).max(6).describe(`2-6 options with distinct text.`),correctOptionIndex:dS().int().nonnegative().describe(`0-based index of the single correct option; must be less than the number of options.`),explanation:X().trim().min(1).max(1e3).describe(`Shown after answering: why the correct option is correct.`)}).strict().superRefine((e,t)=>{e.correctOptionIndex>=e.options.length&&t.addIssue({code:`custom`,path:[`correctOptionIndex`],message:`correctOptionIndex must point at one of the options`});let n=/* @__PURE__ */ new Map;e.options.forEach((e,r)=>{let i=e.text.normalize(`NFC`),a=n.get(i);a===void 0?n.set(i,r):t.addIssue({code:`custom`,path:[`options`,r,`text`],message:`duplicates option ${a}`})})}),VC=Q({concept:X(),question:X(),options:Z(Q({text:X()}).strict())}).strict(),HC=Q({optionIndex:dS().int().nonnegative()}).strict(),UC=Q({correct:hS(),correctOptionIndex:dS().int().nonnegative(),explanation:X(),feedback:X().optional()}).strict(),WC=X().trim().min(1).max(24),GC=/^[^\n\r\v\f\u0085\u2028\u2029]*$/,KC=e=>X().trim().min(1).max(e).regex(GC,`must not contain line breaks`),qC=CS([dS(),KC(24)]);function JC(e){return JSON.stringify([...e].sort())}let YC=Z(WC).max(3),XC=Q({id:WC.describe(`Short id used to refer to this set, e.g. "a". Unique within the diagram.`),label:KC(32).describe(`Shown next to the circle, e.g. "$A$" or "Multiples of 3", on one line. Only $...$ is a formula.`)}).strict(),ZC=Q({in:YC.describe('Ids of the sets this region is inside. It is outside all the others: with sets a, b, c, ["a","b"] means in a and b, not c. [] means outside every set and needs `universe`. No id twice.'),elements:Z(qC).max(30).describe(`What the region contains, each short and on one line. No element may appear twice, in this list or across regions, and 1 and "1" count as the same element. Empty if you only know the count, or the region is empty.`),count:dS().int().nonnegative().max(1e6).optional().describe(`How many elements the region has, when that's more than you list, e.g. for inclusion-exclusion. At least the number of elements listed.`)}).strict(),QC=Q({in:YC.describe("The region to highlight, named like a region's `in`, with no id twice. Any region of the diagram can be highlighted, listed or not."),tone:kS([`active`,`done`,`muted`]).optional().describe(`active = current focus, done = finished, muted = ruled out. Defaults to active.`)}).strict(),$C=Q({explanation:X().trim().min(1).max(500).describe(`What this step shows, in one or two sentences.`),highlights:Z(QC).max(8).optional().describe(`All regions highlighted at this step, each at most once. They apply to this step only, not carried over: repeat any that still apply.`),variables:Z(fC).max(12).optional().describe(`All running state at this step, e.g. |A ∪ B| so far. Not carried over from earlier steps.`)}).strict(),ew=Q({title:X().trim().min(1).max(120),sets:Z(XC).min(1).max(3).describe(`The circles, 1 to 3.`),universe:KC(24).optional().describe(`Label of the rectangle around the sets, e.g. "$U$", on one line. Needed to show or highlight the region outside every set, such as a complement.`),regions:Z(ZC).max(8).describe(`What each region contains, each region at most once.`),steps:Z($C).min(1).max(40).optional().describe(`Optional walk through the diagram. Omit for a static diagram.`)}).strict().superRefine((e,t)=>{let n=e.sets.map(e=>e.id);e.sets.forEach((e,r)=>{n.indexOf(e.id)!==r&&t.addIssue({code:`custom`,path:[`sets`,r,`id`],message:`duplicate set id "${e.id}"`})});let r=(r,i)=>{let a=/* @__PURE__ */ new Set;r.forEach((r,o)=>{let s=[...i,o,`in`];r.in.forEach((e,i)=>{n.includes(e)||t.addIssue({code:`custom`,path:[...s,i],message:`unknown set "${e}"`}),r.in.indexOf(e)!==i&&t.addIssue({code:`custom`,path:[...s,i],message:`set "${e}" is named twice`})}),r.in.length===0&&e.universe===void 0&&t.addIssue({code:`custom`,path:s,message:"the region outside every set needs `universe`"});let c=JC(r.in);a.has(c)&&t.addIssue({code:`custom`,path:s,message:`region ${c} appears more than once`}),a.add(c)})};r(e.regions,[`regions`]),e.steps?.forEach((e,t)=>r(e.highlights??[],[`steps`,t,`highlights`]));let i=/* @__PURE__ */ new Set;e.regions.forEach((e,n)=>{e.elements.forEach((e,r)=>{i.has(String(e))&&t.addIssue({code:`custom`,path:[`regions`,n,`elements`,r],message:`element "${e}" appears more than once; regions don't overlap`}),i.add(String(e))}),e.count!==void 0&&e.count<e.elements.length&&t.addIssue({code:`custom`,path:[`regions`,n,`count`],message:`count ${e.count} is less than the ${e.elements.length} elements listed`})})}),tw=X().trim().min(1).max(80),nw=CS([dS(),hS(),X().max(120)]),rw=dS().int().nonnegative(),iw=Q({row:rw.optional().describe(`0-based data row, below the number of rows. With no column, highlights the whole row. A highlight must give a row, a column or both.`),column:rw.optional().describe(`0-based data column, below the number of columns. With no row, highlights the whole column. With both, highlights one cell.`),tone:kS([`active`,`done`,`muted`]).optional().describe(`active = current focus, done = finished, muted = ruled out. Defaults to active. Where highlights overlap, the later one wins.`)}).strict(),aw=Q({row:rw.describe(`0-based data row, below the number of rows.`),column:rw.describe(`0-based data column, below the number of columns.`),value:nw.describe(`The cell's value from this step on.`)}).strict(),ow=Q({explanation:X().trim().min(1).max(500).describe(`What happens in this step, in one or two sentences.`),highlight:Z(iw).max(32).optional().describe(`All cells, rows and columns to highlight at this step. Not carried over from earlier steps.`),cells:Z(aw).max(64).optional().describe(`Cells this step fills in or changes. They keep the new value on later steps. To reveal working, start a cell as "" and set it here.`)}).strict(),sw=Q({title:X().trim().min(1).max(120),columns:Z(tw).min(1).max(16).describe(`Column headers, one per data column. Don't include a header for rowHeaders.`),rows:Z(Z(nw).min(1).max(16)).min(1).max(64).describe(`Data rows, each with exactly one cell per column. A boolean shows as T or F; "" is a blank cell.`),rowHeaders:Z(tw).max(64).optional().describe(`Optional label for each row, e.g. a relation matrix's elements. Exactly one per row.`),steps:Z(ow).min(1).max(100).optional().describe(`Omit for a static table. With steps, the learner steps through them.`)}).strict().superRefine((e,t)=>{let n=e.rows.length,r=e.columns.length;e.rows.forEach((e,n)=>{e.length!==r&&t.addIssue({code:`custom`,path:[`rows`,n],message:`row has ${e.length} cells but there are ${r} columns`})}),e.rowHeaders&&e.rowHeaders.length!==n&&t.addIssue({code:`custom`,path:[`rowHeaders`],message:`${e.rowHeaders.length} row headers for ${n} rows`});let i=(e,r)=>{e>=n&&t.addIssue({code:`custom`,path:r,message:`row ${e} is outside the table (${n} rows)`})},a=(e,n)=>{e>=r&&t.addIssue({code:`custom`,path:n,message:`column ${e} is outside the table (${r} columns)`})};e.steps?.forEach((e,n)=>{e.highlight?.forEach((e,r)=>{let o=[`steps`,n,`highlight`,r];e.row===void 0&&e.column===void 0&&t.addIssue({code:`custom`,path:o,message:`a highlight needs a row, a column or both`}),e.row!==void 0&&i(e.row,[...o,`row`]),e.column!==void 0&&a(e.column,[...o,`column`])}),e.cells?.forEach((e,t)=>{i(e.row,[`steps`,n,`cells`,t,`row`]),a(e.column,[`steps`,n,`cells`,t,`column`])})})}),cw=Q({label:X().trim().min(1).max(40).optional().describe(`Optional heading for this part of the working, e.g. "Base case", "Inductive step".`),statement:X().trim().min(1).max(1e3).describe(`What this step establishes, mostly as a formula in $...$. For large sums and fractions, put \\displaystyle INSIDE the dollars, e.g. $\\displaystyle\\sum_{i=1}^{n} i$; $$ is not available.`),justification:X().trim().min(1).max(500).describe(`Why it follows, e.g. "by the inductive hypothesis".`)}).strict(),lw=Q({title:X().trim().min(1).max(120),goal:X().trim().min(1).max(500).optional().describe(`Optional statement of what is being shown, e.g. the claim to prove.`),steps:Z(cw).min(1).max(50)}).strict(),uw=kS([`prose`,`algorithm_trace`,`graph`,`multiple_choice`,`set_diagram`,`table`,`worked_steps`]);Q({title:X().trim().min(1).max(120),sections:Z(Q({title:X().trim().min(1).max(120),kind:uw.describe(`prose = write_lesson_text; multiple_choice = ask_multiple_choice (a check); the others = the matching show_* tool.`),purpose:X().trim().min(1).max(300).describe(`What this section does for the learner, in one sentence.`)}).strict()).min(2).max(10).describe(`2-10 sections in reading order. Include at least one multiple_choice check, usually after the idea it checks.`)}).strict().superRefine((e,t)=>{e.sections.some(e=>e.kind===`multiple_choice`)||t.addIssue({code:`custom`,path:[`sections`],message:`Include at least one multiple_choice check`})}),Q({markdown:X().trim().min(1).max(6e3).describe(`The section's prose, as markdown with $...$ and $$...$$ maths. Don't repeat the section title as a heading.`),revisits:Z(X().min(1)).max(5).optional().describe(`sectionIds from <previous_lesson> this section revisits. The page links back to them, so don't write links yourself.`)}).strict();let dw=kS([`generating`,`ready`,`failed`,`finished`]),fw=Q({title:X(),sections:Z(Q({title:X(),kind:uw}).strict())}).strict();Q({id:X(),courseId:X(),topicId:X(),topicTitle:X(),position:dS().int().nonnegative(),status:dw,version:dS().int().positive().nullable(),outline:fw.nullable(),sections:Z(TS(`kind`,[Q({id:X(),title:X(),kind:$(`prose`),markdown:X(),revisits:Z(Q({lessonId:X(),sectionId:X(),title:X(),lessonTitle:X()}).strict())}).strict(),Q({id:X(),title:X(),kind:$(`artifact`),artifact:_S()}).strict()])),checks:Q({total:dS().int().nonnegative(),answered:dS().int().nonnegative()}).strict(),syllabusVersion:dS().int().positive().nullable(),changedSectionIds:Z(X()),changeReason:X().nullable(),canFinish:hS(),error:X().nullable(),createdAt:X().datetime(),finishedAt:X().datetime().nullable()}).strict(),Q({topics:Z(Q({topicId:X(),title:X(),lesson:Q({id:X(),status:dw}).strict().nullable()}).strict()),currentLessonId:X().nullable(),nextTopicId:X().nullable()}).strict();let pw=X().trim().min(1).max(120),mw=X().trim().min(1).max(6e3),hw=X().trim().min(1).max(300);Q({reason:hw.describe(`What the learner asked for, in a few words, e.g. "Simpler intro with an example".`),operations:Z(TS(`op`,[Q({op:$(`rewrite`),sectionId:X().min(1),markdown:mw,title:pw.optional()}).strict().describe(`Replace a prose section's text (and optionally its title).`),Q({op:$(`insert`),afterSectionId:X().min(1).nullable(),title:pw,markdown:mw}).strict().describe(`Add a prose section after the given section, or first if null.`),Q({op:$(`insert_artifact`),afterSectionId:X().min(1).nullable(),title:pw,artifactId:X().min(1)}).strict().describe(`Add a card you created earlier in this reply (its artifactId) as a section.`),Q({op:$(`remove`),sectionId:X().min(1)}).strict(),Q({op:$(`move`),sectionId:X().min(1),afterSectionId:X().min(1).nullable()}).strict()])).min(1).max(10)}).strict(),Q({reason:hw.describe(`What the learner asked for, e.g. "Add a topic on vectors before gradients".`),operations:Z(TS(`op`,[Q({op:$(`insert`),afterTopicId:X().min(1).nullable().describe(`Insert after this topic; null to insert before the first future topic.`),title:pw,summary:X().trim().min(1).max(400),reason:hw,concepts:Z(X().trim().min(1).max(80)).min(1).max(8)}).strict(),Q({op:$(`edit`),topicId:X().min(1),title:pw.optional(),summary:X().trim().min(1).max(400).optional()}).strict(),Q({op:$(`remove`),topicId:X().min(1)}).strict(),Q({op:$(`move`),topicId:X().min(1),afterTopicId:X().min(1).nullable()}).strict()])).min(1).max(10)}).strict(),Q({messageId:X().min(1).max(128),afterSectionId:X().min(1).max(128).nullable(),title:pw}).strict();let gw=Q({title:pw,summary:X().trim().min(1).max(400),concepts:Z(X().trim().min(1).max(80)).min(1).max(8)}).strict();Q({reason:hw.describe(`Shown to the learner, with the evidence, e.g. "Added a chain rule refresher: you missed 3 of 4 checks on derivatives".`),operation:TS(`op`,[gw.extend({op:$(`insert`),afterTopicId:X().min(1).nullable().describe(`null = straight after this lesson's topic`)}).strict(),Q({op:$(`split`),topicId:X().min(1),into:Z(gw).min(2).max(3)}).strict(),Q({op:$(`move`),topicId:X().min(1),afterTopicId:X().min(1).nullable()}).strict()])}).strict();let _w=kS([`goal`,`preference`,`misconception`]),vw=X().trim().min(1).max(300);Q({kind:_w.describe(`goal = what they want to learn or do; preference = how they like to learn; misconception = something they believe that is wrong.`),text:vw.describe(`One short sentence about the learner. Never include the answer to a check they haven't answered.`),concept:X().trim().min(1).max(80).optional().describe(`Required for a misconception: the concept it is about. Use the exact name from the check or from their record, so it can be linked to their answers.`),replaces:X().min(1).optional().describe(`The id of a known memory this one corrects or updates.`)}).strict().superRefine((e,t)=>{e.kind===`misconception`&&!e.concept&&t.addIssue({code:`custom`,path:[`concept`],message:`A misconception needs a concept`})});let yw=kS([`wrong_answer`,`chat`]);Q({id:X(),kind:_w,held:hS(),text:X().nullable(),concept:X().nullable(),basis:yw.nullable(),createdAt:X().datetime(),editedAt:X().datetime().nullable()}).strict(),Q({text:vw}).strict(),Q({id:X(),sessionId:X(),messageId:X().nullable(),filename:X(),kind:kS([`pdf`,`pptx`]),byteSize:dS().int(),pageCount:dS().int(),pagesWithText:dS().int(),status:$(`ready`),createdAt:X().datetime()});let bw={algorithm_trace:{version:1,toolName:`show_algorithm_trace`,description:`Show the learner an interactive step-by-step trace of an algorithm running over a sequence (e.g. sliding window, two pointers, binary search, a simple sort). The learner steps through it with play/pause/step controls. Use it when watching state change step by step will make the idea click. Keep traces short (roughly 5-20 steps) and make each step's explanation say what changed and why.`,spec:mC,input:oC(mC,[`title`,`steps.*.explanation`])},graph:{version:1,toolName:`show_graph`,description:`Show the learner a graph or tree, drawn for you, optionally with steps they can walk through. Use it for graphs, trees, BFS, DFS, shortest paths, spanning trees and tree traversals, whenever seeing the structure or watching an algorithm move over it will help. Never give coordinates: the layout is automatic. For a binary search tree or binary tree traversal, set kind to tree and give every edge a side, so a lone left child and a lone right child are drawn differently. The automatic layout may draw crossing edges that mean nothing, even when the graph is planar, so don't use this to show whether a graph is planar. Keep it small enough to read (roughly 4-15 nodes, 5-20 steps) and make each step's explanation say what changed and why.`,spec:RC,input:oC(RC,[`title`,`nodes.*.label`,`edges.*.label`,`steps.*.explanation`],(e,t)=>{e.nodes.forEach((e,n)=>{e.label===void 0&&aC(e.id,[`nodes`,n,`id`],t)})})},multiple_choice:{version:1,toolName:`ask_multiple_choice`,description:`Ask the learner one multiple-choice question to check understanding of a concept you just taught. Exactly one option is correct. Write plausible wrong options that reflect real misconceptions, and give per-option feedback where useful. The learner answers in the UI; the result is reported back to you on the next turn, so do not reveal the answer in your reply.`,spec:BC,input:oC(BC,[`question`,`options.*.text`,`options.*.feedback`,`explanation`])},placement_question:{version:1,toolName:`ask_placement_question`,description:`Course placement interview only: ask the learner one quick question to find out what they already know about one concept, before the syllabus is written. Use multiple choice, true/false or yes/no. The UI always adds "Not sure" and "Skip", so never include those as options. The learner answers in the UI and the result is reported back to you, so don't reveal the answer.`,spec:gC,input:oC(gC,[`question`,`options.*.text`,`explanation`])},set_diagram:{version:1,toolName:`show_set_diagram`,description:"Show the learner a Venn diagram of 1 to 3 sets, with what each region contains. Use it for set operations (union, intersection, complement, difference) and inclusion-exclusion, not for more than 3 sets. Keep elements short, because they are drawn in their region. Add steps to walk through it: each step highlights exact regions (any of them, including outside every set, which needs `universe`) and says what changed and why.",spec:ew,input:oC(ew,[`title`,`universe`,`sets.*.label`,`regions.*.elements.*`,`steps.*.explanation`,`steps.*.variables.*.name`,`steps.*.variables.*.value`])},table:{version:1,toolName:`show_table`,description:`Show the learner a table: a truth table, a relation matrix or other tabular working. Use it whenever the content is really rows and columns. Add steps when filling it in or highlighting it one part at a time will help, such as working out a truth table column by column; leave them out for a table to read at a glance. Keep steps short and make each explanation say what changed and why.`,spec:sw,input:oC(sw,[`title`,`columns.*`,`rowHeaders.*`,`rows.*.*`,`steps.*.explanation`,`steps.*.cells.*.value`])},worked_steps:{version:1,toolName:`show_worked_steps`,description:`Show the learner a proof, an induction or combinatorics working as a sequence of steps they reveal one at a time, each a statement with its justification. Use it when the reasoning is the point and each line follows from the ones before. Use show_algorithm_trace instead for an algorithm's state changing over a sequence.`,spec:lw,input:oC(lw,[`title`,`goal`,`steps.*.label`,`steps.*.statement`,`steps.*.justification`])}};kS(Object.keys(bw));let xw={id:X(),createdAt:X().datetime()},Sw=Q({answer:HC,grade:UC,createdAt:X().datetime()}).strict(),Cw=Q({answer:vC,grade:yC,createdAt:X().datetime()}).strict();TS(`kind`,[Q({...xw,kind:$(`algorithm_trace`),version:$(1),spec:mC}).strict(),Q({...xw,kind:$(`graph`),version:$(1),spec:RC}).strict(),Q({...xw,kind:$(`multiple_choice`),version:$(1),spec:VC,latestAttempt:Sw.optional()}).strict(),Q({...xw,kind:$(`placement_question`),version:$(1),spec:_C,latestAttempt:Cw.optional()}).strict(),Q({...xw,kind:$(`set_diagram`),version:$(1),spec:ew}).strict(),Q({...xw,kind:$(`table`),version:$(1),spec:sw}).strict(),Q({...xw,kind:$(`worked_steps`),version:$(1),spec:lw}).strict()]);let ww=e=>e!==null&&e<-2,Tw=e=>e===null||e<0||e===32,Ew=e=>e!==null&&e>=48&&e<=57;function Dw(e,t,n){let r=0,i=0,a,o=null,s=t=>t===36?(e.consume(t),r+=1,s):r>2||r===1&&Tw(t)?n(t):(e.exit(`mathTextSequence`),c(t)),c=t=>{if(t===null||t===96)return n(t);if(t===36)return a=e.enter(`mathTextSequence`),i=0,d(t);if(t===32||ww(t)){let n=t===32?`space`:`lineEnding`;return e.enter(n),e.consume(t),e.exit(n),o=t,c}return e.enter(`mathTextData`),l(t)},l=t=>t===null||t===96||t===32||t===36||ww(t)?(e.exit(`mathTextData`),c(t)):(e.consume(t),o=t,t===92?u:l),u=t=>t!==36&&t!==92?l(t):(e.consume(t),o=t,l),d=s=>s===36?(e.consume(s),i+=1,d):i===r?Ew(s)||r===1&&Tw(o)?n(s):(e.exit(`mathTextSequence`),e.exit(`mathText`),t(s)):r===1?n(s):(a.type=`mathTextData`,l(s));return t=>(e.enter(`mathText`),e.enter(`mathTextSequence`),s(t))}function Ow(){for(let e of this.data().micromarkExtensions??[]){let t=e.text?.[36];t&&(e.text[36]={...t,tokenize:Dw})}}let kw=[`http:`,`https:`,`mailto:`];function Aw(e){try{let t=new URL(e);return kw.includes(t.protocol)?t.href:``}catch{return``}}function jw(){return(e,t)=>{let n=String(t.value),r=e=>{for(let t of e.children??[]){let e=t.position?.start.offset;t.type===`inlineMath`&&e!==void 0&&n.startsWith(`$$`,e)&&(t.data={...t.data,hProperties:{...t.data?.hProperties,className:[`language-math`,`math-display`]}}),r(t)}};r(e)}}let Mw=[zd,Zd,Ow,jw],Nw=Sm().use(Vf).use(Mw).use(qp,{allowDangerousHtml:!0}),Pw=/* @__PURE__ */ new Map;function Fw(e,t){let n=`${t?`D`:`I`}${e}`,r=Pw.get(n);if(r!==void 0)return Pw.delete(n),Pw.set(n,r),r;let i;try{i=Ka.renderToString(e,{displayMode:t,trust:!1,strict:`ignore`,throwOnError:!1,errorColor:`var(--destructive)`})}catch{return}return Pw.set(n,i),Pw.size>1e3&&Pw.delete(Pw.keys().next().value),i}let Iw=e=>{let t=e.properties.className;return Array.isArray(t)?t.map(String):[]},Lw=e=>e?.type===`element`&&e.tagName===`code`&&Iw(e).includes(`language-math`),Rw=e=>e.children.map(e=>e.type===`text`?e.value:``).join(``);function zw(e){let t=Nw.runSync(Nw.parse(e),e),n=[],r=(e,t)=>{let r=Fw(e,t);return r===void 0?{type:`element`,tagName:`span`,properties:{className:[`katex-error`]},children:[{type:`text`,value:e}]}:(n.push(r),{type:`element`,tagName:`span`,properties:{className:[`math-text-formula`],dataFormula:n.length-1},children:[]})};return qs(t,(e,t,n)=>{if(delete e.position,n&&t!==void 0){if(e.type===`raw`)n.children[t]={type:`text`,value:e.value};else if(e.type===`element`){if(e.tagName===`pre`&&e.children.length===1&&Lw(e.children[0]))return n.children[t]=r(Rw(e.children[0]).replace(/\n$/,``),!0),`skip`;if(Lw(e))return n.children[t]=r(Rw(e),Iw(e).includes(`math-display`)),`skip`;for(let[t,n]of Object.entries(u))Object.hasOwn(e.properties,t)&&(n===null||n.includes(e.tagName))&&(e.properties[t]=Aw(String(e.properties[t]??``)))}}}),{tree:t,formulas:n}}let Bw=self;Bw.onmessage=e=>{let{id:t,text:n}=e.data,r;try{r={id:t,block:zw(n)}}catch{r={id:t}}Bw.postMessage(r)}})();
413
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Eb(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Eb(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let Db=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Ob=[`oneOf`,`anyOf`];function kb(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ab(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Db.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??kb(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Bm(n,r,e.length===1?e[0]:Ab(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=kb(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function jb(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Db)if(t in e)return;let n=t.filter(e=>Ob.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ab(t);else{let e=n[0],i=Ob.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ab([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,bb(e,r))}function Mb(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):bb(i,s),bb(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Eb(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])jb(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}bb(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Bm(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Fb(t,`input`,e.processors),output:Fb(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Nb(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Nb(r.element,n);if(r.type===`set`)return Nb(r.valueType,n);if(r.type===`lazy`)return Nb(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Nb(r.innerType,n);if(r.type===`intersection`)return Nb(r.left,n)||Nb(r.right,n);if(r.type===`record`||r.type===`map`)return Nb(r.keyType,n)||Nb(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Nb(r.in,n)||Nb(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Nb(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Nb(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Nb(e,n))return!0;return!!(r.rest&&Nb(r.rest,n))}return!1}let Pb=(e,t={})=>n=>{let r=xb({...n,processors:t});return Cb(e,r),Tb(r,e),Mb(r,e)},Fb=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=xb({...i??{},target:a,io:t,processors:n});return Cb(e,o),Tb(o,e),Mb(o,e)},Ib=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Lb=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Rb=(e,t)=>{Ib(e,`minimum`,t),Lb(e,`maximum`,t)},zb=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Bb=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Vb=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Hb=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ub=(e,t)=>Ib(e,`minimum`,t.minimum),Wb=(e,t)=>Lb(e,`maximum`,t.maximum),Gb=e=>(t,n)=>{Hb(t,n.format);let[r,i]=e[n.format];Ib(t,`minimum`,r),Lb(t,`maximum`,i)},Kb={greater_than:(e,t)=>Ib(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Lb(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>zb(e,t.value),number_format:Gb(oh),bigint_format:Gb(sh),min_length:Ub,max_length:Wb,length_equals:(e,t)=>Rb(e,t.length),min_size:Ub,max_size:Wb,size_equals:(e,t)=>Rb(e,t.size),string_format:(e,t)=>{Hb(e,t.format),t.pattern&&Bb(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Vb(e,t.mime)};function qb(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Kb[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ib(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ib(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Lb(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Lb(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&zb(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Vb(t,i.mime);for(let e of i.patterns??[])Bb(t,e);return t}let Jb={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yb=/* @__PURE__ */ new Map([[tv,Rg],[rv,zg]]),Xb=e=>Yb.get(e)??e,Zb=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=qb(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jb[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Xb);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Qb=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=qb(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Sb(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},$b=(e,t,n,r)=>{n.type=`boolean`},ex=(e,t,n,r)=>{n.not={}},tx=(e,t,n,r)=>{let i=e._zod.def,a=Mm(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},nx=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Sb(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Sb(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},rx=(e,t,n,r)=>{Sb(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ix=(e,t,n,r)=>{Sb(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},ax=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=qb(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Cb(a.element,t,{...r,path:[...r.path,`items`]})};function ox(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ox(t.out):t.type===`catch`?ox(t.innerType):e._zod.optin}let sx=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Sb(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Bm(i.properties,e,Cb(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ox(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Cb(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},cx=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Cb(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},lx=(e,t,n,r)=>{let i=e._zod.def,a=Cb(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Cb(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},ux=(e,t,n,r)=>{let i=e._zod.def,a=Cb(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},dx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},fx=Symbol();function px(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Sb(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),fx):JSON.parse(o)}let mx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=px(i.defaultValue,e,t,n,r);o!==fx&&(n.default=o)},hx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=px(i.defaultValue,e,t,n,r);o!==fx&&(n._prefault=o)},gx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Sb(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},_x=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Cb(o,t,r);let s=t.seen.get(e);s.ref=o},vx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},yx=(e,t,n,r)=>{let i=e._zod.def;Cb(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},bx=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function xx(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let Sx=/*@__PURE__*/ Y(`ZodError`,(e,t)=>{$h.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);bx.has(n)||(bx.add(n),xx(n,`format`,e=>t=>ng(e,t)),xx(n,`flatten`,e=>t=>tg(e,t)),xx(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Pm,2)}),xx(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Pm,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Cx=/* @__PURE__ */ ig(Sx),wx=/* @__PURE__ */ ag(Sx),Tx=/* @__PURE__ */ og(Sx),Ex=/* @__PURE__ */ cg(Sx),Dx=/* @__PURE__ */ mg(Sx),Ox=/* @__PURE__ */ hg(Sx),kx=/* @__PURE__ */ gg(Sx),Ax=/* @__PURE__ */ _g(Sx),jx=/* @__PURE__ */ vg(Sx),Mx=/* @__PURE__ */ yg(Sx),Nx=/* @__PURE__ */ bg(Sx),Px=/* @__PURE__ */ xg(Sx);function Fx(){Kh.localeError||qh(fy())}function Ix(){Kh.memoizer||qh({memoizer:ly()})}let Lx=/*@__PURE__*/ Y(`ZodType`,(e,t)=>(Fx(),y_.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(qm(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return rh(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(QS(e,t))},superRefine(e,t){return this.check($S(e,t))},overwrite(e){return this.check(/* @__PURE__ */ ub(e))},optional(){return PS(this)},exactOptional(){return IS(this)},nullable(){return RS(this)},nullish(){return PS(RS(this))},nonoptional(e){return WS(this,e)},array(){return Z(this)},or(e){return CS([this,e])},and(e){return DS(this,e)},transform(e){return JS(this,MS(e))},default(e){return BS(this,e)},prefault(e){return HS(this,e)},catch(e){return KS(this,e)},pipe(e){return JS(this,e)},readonly(){return XS(this)},describe(e){let t=this.clone();return gy.add(t,{description:e}),t},meta(...e){if(e.length===0)return gy.get(this);let t=this.clone();return gy.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return jh(this,`~standard`,{...S_(this),jsonSchema:{input:Fb(this,`input`),output:Fb(this,`output`)}})},set"~standard"(e){Ah(this,`~standard`,e)},parse:function e(t,n){return Cx(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await wx(this,t,n,{callee:e})},safeParse(e,t){return Tx(this,e,t)},async safeParseAsync(e,t){return Ex(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ah(this,`spa`,e)},validate(e,t){return dg(this,e,t)},validateAsync(e,t){return pg(this,e,t)},encode:function e(t,n){return Dx(this,t,n,{callee:e})},decode:function e(t,n){return Ox(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await kx(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ax(this,t,n,{callee:e})},safeEncode(e,t){return jx(this,e,t)},safeDecode(e,t){return Mx(this,e,t)},async safeEncodeAsync(e,t){return Nx(this,e,t)},async safeDecodeAsync(e,t){return Px(this,e,t)},toJSONSchema(e){return Pb(this,{})(e)},get description(){return gy.get(this)?.description},get _def(){return this._zod.def}}),Rx=/*@__PURE__*/ Y(`_ZodString`,(e,t)=>{C_.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zb(e,t,n,r)},/*@__PURE__*/ Mh({format:e=>qb(e).format??null,minLength:e=>qb(e).minimum??null,maxLength:e=>qb(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ ib(...e))},includes(...e){return this.check(/* @__PURE__ */ sb(...e))},startsWith(...e){return this.check(/* @__PURE__ */ cb(...e))},endsWith(...e){return this.check(/* @__PURE__ */ lb(...e))},min(...e){return this.check(/* @__PURE__ */ nb(...e))},max(...e){return this.check(/* @__PURE__ */ tb(...e))},length(...e){return this.check(/* @__PURE__ */ rb(...e))},nonempty(...e){return this.check(/* @__PURE__ */ nb(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ ab(e))},uppercase(e){return this.check(/* @__PURE__ */ ob(e))},trim(){return this.check(/* @__PURE__ */ fb())},normalize(...e){return this.check(/* @__PURE__ */ db(...e))},toLowerCase(){return this.check(/* @__PURE__ */ pb())},toUpperCase(){return this.check(/* @__PURE__ */ mb())},slugify(){return this.check(/* @__PURE__ */ hb())}})),zx=/*@__PURE__*/ Y(`ZodString`,(e,t)=>{C_.init(e,t),Rx.init(e,t)},{email(e){return this.check(/* @__PURE__ */ yy(Gx,e))},url(e){return this.check(/* @__PURE__ */ Ty(Jx,e))},jwt(e){return this.check(/* @__PURE__ */ By(lS,e))},emoji(e){return this.check(/* @__PURE__ */ Ey(Yx,e))},guid(e){return this.check(/* @__PURE__ */ by(Kx,e))},uuid(e){return this.check(/* @__PURE__ */ xy(qx,e))},uuidv4(e){return this.check(/* @__PURE__ */ Sy(qx,e))},uuidv6(e){return this.check(/* @__PURE__ */ Cy(qx,e))},uuidv7(e){return this.check(/* @__PURE__ */ wy(qx,e))},nanoid(e){return this.check(/* @__PURE__ */ Dy(Xx,e))},cuid(e){return this.check(/* @__PURE__ */ Oy(Zx,e))},cuid2(e){return this.check(/* @__PURE__ */ ky(Qx,e))},ulid(e){return this.check(/* @__PURE__ */ Ay($x,e))},base64(e){return this.check(/* @__PURE__ */ Ly(oS,e))},base64url(e){return this.check(/* @__PURE__ */ Ry(sS,e))},xid(e){return this.check(/* @__PURE__ */ jy(eS,e))},ksuid(e){return this.check(/* @__PURE__ */ My(tS,e))},ipv4(e){return this.check(/* @__PURE__ */ Ny(nS,e))},ipv6(e){return this.check(/* @__PURE__ */ Py(rS,e))},cidrv4(e){return this.check(/* @__PURE__ */ Fy(iS,e))},cidrv6(e){return this.check(/* @__PURE__ */ Iy(aS,e))},e164(e){return this.check(/* @__PURE__ */ zy(cS,e))},datetime(e){return this.check(/* @__PURE__ */ Vy(Vx,e))},date(e){return this.check(/* @__PURE__ */ Hy(Hx,e))},time(e){return this.check(/* @__PURE__ */ Uy(Ux,e))},duration(e){return this.check(/* @__PURE__ */ Wy(Wx,e))}});function X(e){return/* @__PURE__ */ vy(zx,e)}let Bx=/*@__PURE__*/ Y(`ZodStringFormat`,(e,t)=>{w_.init(e,t),Rx.init(e,t)}),Vx=/*@__PURE__*/ Y(`ZodISODateTime`,(e,t)=>{U_.init(e,t),Bx.init(e,t)}),Hx=/*@__PURE__*/ Y(`ZodISODate`,(e,t)=>{W_.init(e,t),Bx.init(e,t)}),Ux=/*@__PURE__*/ Y(`ZodISOTime`,(e,t)=>{G_.init(e,t),Bx.init(e,t)}),Wx=/*@__PURE__*/ Y(`ZodISODuration`,(e,t)=>{K_.init(e,t),Bx.init(e,t)}),Gx=/*@__PURE__*/ Y(`ZodEmail`,(e,t)=>{D_.init(e,t),Bx.init(e,t)}),Kx=/*@__PURE__*/ Y(`ZodGUID`,(e,t)=>{T_.init(e,t),Bx.init(e,t)}),qx=/*@__PURE__*/ Y(`ZodUUID`,(e,t)=>{E_.init(e,t),Bx.init(e,t)}),Jx=/*@__PURE__*/ Y(`ZodURL`,(e,t)=>{F_.init(e,t),Bx.init(e,t)}),Yx=/*@__PURE__*/ Y(`ZodEmoji`,(e,t)=>{I_.init(e,t),Bx.init(e,t)}),Xx=/*@__PURE__*/ Y(`ZodNanoID`,(e,t)=>{L_.init(e,t),Bx.init(e,t)}),Zx=/*@__PURE__*/ Y(`ZodCUID`,(e,t)=>{R_.init(e,t),Bx.init(e,t)}),Qx=/*@__PURE__*/ Y(`ZodCUID2`,(e,t)=>{z_.init(e,t),Bx.init(e,t)}),$x=/*@__PURE__*/ Y(`ZodULID`,(e,t)=>{B_.init(e,t),Bx.init(e,t)}),eS=/*@__PURE__*/ Y(`ZodXID`,(e,t)=>{V_.init(e,t),Bx.init(e,t)}),tS=/*@__PURE__*/ Y(`ZodKSUID`,(e,t)=>{H_.init(e,t),Bx.init(e,t)}),nS=/*@__PURE__*/ Y(`ZodIPv4`,(e,t)=>{q_.init(e,t),Bx.init(e,t)}),rS=/*@__PURE__*/ Y(`ZodIPv6`,(e,t)=>{X_.init(e,t),Bx.init(e,t)}),iS=/*@__PURE__*/ Y(`ZodCIDRv4`,(e,t)=>{Z_.init(e,t),Bx.init(e,t)}),aS=/*@__PURE__*/ Y(`ZodCIDRv6`,(e,t)=>{$_.init(e,t),Bx.init(e,t)}),oS=/*@__PURE__*/ Y(`ZodBase64`,(e,t)=>{nv.init(e,t),Bx.init(e,t)}),sS=/*@__PURE__*/ Y(`ZodBase64URL`,(e,t)=>{av.init(e,t),Bx.init(e,t)}),cS=/*@__PURE__*/ Y(`ZodE164`,(e,t)=>{ov.init(e,t),Bx.init(e,t)}),lS=/*@__PURE__*/ Y(`ZodJWT`,(e,t)=>{cv.init(e,t),Bx.init(e,t)}),uS=/*@__PURE__*/ Y(`ZodNumber`,(e,t)=>{lv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qb(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Mh({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=qb(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=qb(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=qb(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>qb(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ Qy(e,t))},gte(e,t){return this.check(/* @__PURE__ */ $y(e,t))},min(e,t){return this.check(/* @__PURE__ */ $y(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Xy(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Zy(e,t))},max(e,t){return this.check(/* @__PURE__ */ Zy(e,t))},int(e){return this.check(pS(e))},safe(e){return this.check(pS(e))},positive(e){return this.check(/* @__PURE__ */ Qy(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ $y(0,e))},negative(e){return this.check(/* @__PURE__ */ Xy(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Zy(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ eb(e,t))},step(e,t){return this.check(/* @__PURE__ */ eb(e,t))},finite(){return this}}));function dS(e){return/* @__PURE__ */ Gy(uS,e)}let fS=/*@__PURE__*/ Y(`ZodNumberFormat`,(e,t)=>{uv.init(e,t),uS.init(e,t)});function pS(e){return/* @__PURE__ */ Ky(fS,e)}let mS=/*@__PURE__*/ Y(`ZodBoolean`,(e,t)=>{dv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$b(e,t,n,r)});function hS(e){return/* @__PURE__ */ qy(mS,e)}let gS=/*@__PURE__*/ Y(`ZodUnknown`,(e,t)=>{fv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function _S(){return/* @__PURE__ */ Jy(gS)}let vS=/*@__PURE__*/ Y(`ZodNever`,(e,t)=>{pv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ex(e,t,n,r)});function yS(e){return/* @__PURE__ */ Yy(vS,e)}let bS=/*@__PURE__*/ Y(`ZodArray`,(e,t)=>{Ix(),_v.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ax(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ nb(e,t))},nonempty(e){return this.check(/* @__PURE__ */ nb(1,e))},max(e,t){return this.check(/* @__PURE__ */ tb(e,t))},length(e,t){return this.check(/* @__PURE__ */ rb(e,t))},unwrap(){return this.element}});function Z(e,t){return/* @__PURE__ */ gb(bS,e,t)}let xS=/*@__PURE__*/ Y(`ZodObject`,(e,t)=>{Ix(),Cv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sx(e,t,n,r),Rh(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return kS(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(qm(this._zod.def,{catchall:e}))},passthrough(){return this.clone(qm(this._zod.def,{catchall:_S()}))},loose(){return this.clone(qm(this._zod.def,{catchall:_S()}))},strict(){return this.clone(qm(this._zod.def,{catchall:yS()}))},strip(){return this.clone(qm(this._zod.def,{catchall:void 0}))},extend(e){return dh(this,e)},safeExtend(e){return ph(this,e)},merge(e){return mh(this,e)},pick(e){return ch(this,e)},omit(e){return uh(this,e)},partial(...e){return hh(NS,this,e[0])},exactPartial(...e){return hh(FS,this,e[0],`exactPartial`)},required(...e){return gh(US,this,e[0])}});function Q(e,t){let n={type:`object`,shape:e??{},...q(t)};return new xS(n)}let SS=/*@__PURE__*/ Y(`ZodUnion`,(e,t)=>{Tv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cx(e,t,n,r),e.options=t.options});function CS(e,t){return new SS({type:`union`,options:e,...q(t)})}let wS=/*@__PURE__*/ Y(`ZodDiscriminatedUnion`,(e,t)=>{SS.init(e,t),Dv.init(e,t)});function TS(e,t,n){return new wS({type:`union`,options:t,discriminator:e,...q(n)})}let ES=/*@__PURE__*/ Y(`ZodIntersection`,(e,t)=>{Ov.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lx(e,t,n,r)});function DS(e,t){return new ES({type:`intersection`,left:e,right:t})}let OS=/*@__PURE__*/ Y(`ZodEnum`,(e,t)=>{jv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tx(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new OS({...t,checks:[],...q(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new OS({...t,checks:[],...q(r),entries:i})}});function kS(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new OS({type:`enum`,entries:n,...q(t)})}let AS=/*@__PURE__*/ Y(`ZodLiteral`,(e,t)=>{Mv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nx(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(e,t){return new AS({type:`literal`,values:Array.isArray(e)?e:[e],...q(t)})}let jS=/*@__PURE__*/ Y(`ZodTransform`,(e,t)=>{Ix(),Nv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ix(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Gh(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Oh(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Oh(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function MS(e){return new jS({type:`transform`,transform:e})}let NS=/*@__PURE__*/ Y(`ZodOptional`,(e,t)=>{Fv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function PS(e){return new NS({type:`optional`,innerType:e})}let FS=/*@__PURE__*/ Y(`ZodExactOptional`,(e,t)=>{Iv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function IS(e){return new FS({type:`optional`,innerType:e})}let LS=/*@__PURE__*/ Y(`ZodNullable`,(e,t)=>{Lv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ux(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function RS(e){return new LS({type:`nullable`,innerType:e})}let zS=/*@__PURE__*/ Y(`ZodDefault`,(e,t)=>{Rv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function BS(e,t){return new zS({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():eh(t)}})}let VS=/*@__PURE__*/ Y(`ZodPrefault`,(e,t)=>{Bv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function HS(e,t){return new VS({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():eh(t)}})}let US=/*@__PURE__*/ Y(`ZodNonOptional`,(e,t)=>{Vv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function WS(e,t){return new US({type:`nonoptional`,innerType:e,...q(t)})}let GS=/*@__PURE__*/ Y(`ZodCatch`,(e,t)=>{Wv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function KS(e,t){return new GS({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:zh(t)})}let qS=/*@__PURE__*/ Y(`ZodPipe`,(e,t)=>{Gv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_x(e,t,n,r),e.in=t.in,e.out=t.out});function JS(e,t){return new qS({type:`pipe`,in:e,out:t})}let YS=/*@__PURE__*/ Y(`ZodReadonly`,(e,t)=>{qv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vx(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function XS(e){return new YS({type:`readonly`,innerType:e})}let ZS=/*@__PURE__*/ Y(`ZodCustom`,(e,t)=>{Yv.init(e,t),Lx.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rx(e,t,n,r)});function QS(e,t={}){return/* @__PURE__ */ _b(ZS,e,t)}function $S(e,t){return/* @__PURE__ */ vb(e,t)}let eC=e=>e!==void 0&&/\s/.test(e),tC=e=>e!==void 0&&e>=`0`&&e<=`9`;function nC(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`\\`&&e[r+1]===`$`)n+=`$`,r+=2;else if(i!==`$`)n+=i,r+=1;else if(e[r+1]===`$`)for(;e[r]===`$`;)n+=`$`,r+=1;else{let i=rC(e,r);i===void 0?(n+=`$`,r+=1):(n&&t.push({text:n}),n=``,t.push({formula:e.slice(r+1,i)}),r=i+1)}}return n&&t.push({text:n}),t}function rC(e,t){let n=t+1;for(;n<e.length&&e[n]!==`$`;)n+=e[n]===`\\`&&(e[n+1]===`$`||e[n+1]===`\\`)?2:1;if(!(n>=e.length||n===t+1||e[n+1]===`$`)&&!(eC(e[t+1])||eC(e[n-1])||tC(e[n+1])))return/`|\n\s*\n/.test(e.slice(t,n))?void 0:n}let iC=String.raw`Wrap LaTeX commands in single-dollar math delimiters, with no spaces inside: $\displaystyle\sum_{i=1}^{n} i$. Put \displaystyle inside the dollars. For literal backslashes followed by two or more letters (such as C:\Users), use forward slashes, Unicode symbols such as ∖, or describe them in words; backticks do not escape artifact math. Correct the affected field and retry this tool call.`;function aC(e,t,n){typeof e==`string`&&nC(e).some(e=>`text`in e&&/\\[a-zA-Z]{2,}/.test(e.text))&&n.addIssue({code:`custom`,path:t,message:iC})}function oC(e,t,n){return e.superRefine((e,r)=>{let i=(e,t,n)=>{if(t.length===0)return aC(e,n,r);let[a,...o]=t;a===`*`&&Array.isArray(e)?e.forEach((e,t)=>i(e,o,[...n,t])):e&&typeof e==`object`&&a!==void 0&&i(e[a],o,[...n,a])};for(let n of t)i(e,n.split(`.`),[]);n?.(e,r)})}let sC=X().trim().min(1).max(40),cC=CS([dS(),X().max(24)]),lC=dS().int().nonnegative(),uC=Q({name:sC.describe(`Pointer label shown under the cell, e.g. "left", "right", "mid", "i".`),index:lC.describe(`0-based index into the sequence as it is at this step.`)}).strict(),dC=Q({start:lC.describe(`0-based start index, inclusive, within the sequence as it is at this step.`),end:lC.describe(`0-based end index, inclusive. Must be >= start and within the sequence.`),label:sC.optional().describe(`Optional label, e.g. "window".`),tone:kS([`active`,`done`,`muted`]).optional().describe(`active = current focus, done = finished/sorted, muted = ruled out. Defaults to active.`)}).strict(),fC=Q({name:sC,value:CS([dS(),X().max(80),hS()])}).strict(),pC=Q({explanation:X().trim().min(1).max(500).describe(`What happens in this step, in one or two sentences.`),values:Z(cC).min(1).max(64).optional().describe(`The whole sequence after this step. Omit unless the values changed (e.g. a swap); omitted means unchanged.`),pointers:Z(uC).max(8).optional().describe(`All pointers to show at this step. Not carried over from earlier steps: repeat any that still apply.`),ranges:Z(dC).max(8).optional().describe(`All highlighted ranges at this step. Not carried over from earlier steps.`),variables:Z(fC).max(12).optional().describe(`All running state at this step, e.g. current sum, best so far. Not carried over from earlier steps.`)}).strict(),mC=Q({title:X().trim().min(1).max(120),values:Z(cC).min(1).max(64).describe(`The input sequence before the first step.`),steps:Z(pC).min(1).max(200)}).strict().superRefine((e,t)=>{let n=e.values.length;e.steps.forEach((e,r)=>{e.values&&(n=e.values.length),e.pointers?.forEach((e,i)=>{e.index>=n&&t.addIssue({code:`custom`,path:[`steps`,r,`pointers`,i,`index`],message:`index ${e.index} is outside the sequence (length ${n})`})}),e.ranges?.forEach((e,i)=>{(e.end>=n||e.start>e.end)&&t.addIssue({code:`custom`,path:[`steps`,r,`ranges`,i],message:`range ${e.start}..${e.end} is invalid for a sequence of length ${n}`})})})});Q({goal:X().trim().min(1).max(300)}).strict();let hC=X().trim().min(1).max(80),gC=Q({concept:hC.describe(`The single concept this question probes, e.g. "chain rule". Reuse the exact name from the learner's record when it is there.`),question:X().trim().min(1).max(1e3),options:Z(Q({text:X().trim().min(1).max(300)}).strict()).min(2).max(5).describe(`2-5 options with distinct text. For true/false or yes/no use two options, e.g. "True" and "False". Never add a "Not sure" option: the UI always offers one.`),correctOptionIndex:dS().int().nonnegative().describe(`0-based index of the single correct option.`),explanation:X().trim().min(1).max(600).describe(`One or two sentences shown after answering: why the correct option is correct.`)}).strict().superRefine((e,t)=>{e.correctOptionIndex>=e.options.length&&t.addIssue({code:`custom`,path:[`correctOptionIndex`],message:`correctOptionIndex must point at one of the options`});let n=/* @__PURE__ */ new Map;e.options.forEach((e,r)=>{let i=e.text.normalize(`NFC`),a=n.get(i);a===void 0?n.set(i,r):t.addIssue({code:`custom`,path:[`options`,r,`text`],message:`duplicates option ${a}`}),/^\s*(not sure|i don'?t know|unsure|skip)\W*$/i.test(e.text)&&t.addIssue({code:`custom`,path:[`options`,r,`text`],message:`Leave out Not sure / Skip: the UI always offers them`})})}),_C=Q({concept:X(),question:X(),options:Z(Q({text:X()}).strict())}).strict(),vC=CS([Q({optionIndex:dS().int().nonnegative()}).strict(),Q({unsure:$(!0)}).strict(),Q({skipped:$(!0)}).strict()]),yC=Q({result:kS([`correct`,`incorrect`,`unsure`,`skipped`]),correctOptionIndex:dS().int().nonnegative(),explanation:X()}).strict(),bC=kS([`memory`,`test`,`guess`]),xC=Q({title:X().trim().min(1).max(120),summary:X().trim().min(1).max(400).describe(`What the lesson on this topic will cover, in one or two sentences.`),reason:X().trim().min(1).max(300).describe(`Why this topic is here for this learner, e.g. "You missed the question on local minima".`),requestedByLearner:hS().describe(`True if the learner explicitly asked for this topic. Such topics are never removed automatically.`),concepts:Z(hC).min(1).max(8).describe(`Concept names this topic teaches; reuse names from the learner's record and the placement questions.`)}).strict(),SC=Q({topics:Z(xC).min(1).max(20).describe(`The ordered topics, first to learn first. Each topic gets one lesson.`),known:Z(Q({concept:hC,source:bC.describe(`memory = from their record or memories; test = from this placement interview; guess = your inference`),note:X().trim().min(1).max(200)}).strict()).max(20).describe(`What the learner already knows or doesn't, each labelled with where that comes from. Shown to the learner.`)}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;e.topics.forEach((e,r)=>{let i=e.title.trim().toLowerCase();n.has(i)&&t.addIssue({code:`custom`,path:[`topics`,r,`title`],message:`Topic titles must be distinct`}),n.add(i)})}),CC=xC.extend({id:X()}).strict(),wC=Q({version:dS().int().positive(),source:kS([`interview`,`tutor`,`adaptive`,`undo`]),reason:X().nullable(),changedTopicIds:Z(X()),canUndo:hS(),topics:Z(CC),known:SC.shape.known,createdAt:X().datetime()}).strict(),TC=kS([`interviewing`,`active`,`complete`]);Q({id:X(),sessionId:X(),goal:X(),status:TC,syllabus:wC.nullable(),interviewMessageId:X().nullable(),createdAt:X().datetime()}).strict();let EC=X().trim().min(1).max(24),DC=X().trim().min(1).max(24),OC=kS([`active`,`done`,`muted`]).optional().describe(`active = current focus, done = finished/visited, muted = ruled out. Defaults to active.`),kC=Q({id:EC.describe(`Unique id, used by edges and steps. Shown on the node if it has no label.`),label:DC.optional().describe(`Short text on the node. Only $...$ is a formula, e.g. $v_1$.`)}).strict(),AC=Q({from:EC.describe(`Id of a node. In a tree, the parent.`),to:EC.describe("Id of a node, the same as `from` for a self-loop. In a tree, the child; children appear left to right in edge order unless they have a `side`."),side:kS([`left`,`right`]).optional().describe("Only when kind is tree: which child this is of `from`, its parent. Set it on every edge of a binary search tree or binary tree traversal, because a lone left child and a lone right child are different trees. A node has at most one child per side, and either all of its children have a side or none do."),weight:dS().optional().describe(`Numeric weight shown on the edge. Give a weight or a label, not both.`),label:DC.optional().describe(`Text shown on the edge. Only $...$ is a formula.`)}).strict(),jC=Q({id:EC.describe(`Id of a node.`),tone:OC}).strict(),MC=Q({from:EC,to:EC,nth:dS().int().nonnegative().optional().describe("Only for parallel edges, and then required: which of the edges joining these nodes, 0-based in the order of `edges`."),tone:OC}).strict().describe(`An edge of the graph. In an undirected graph, from and to may be in either order.`),NC=Q({explanation:X().trim().min(1).max(500).describe(`What happens in this step, in one or two sentences.`),nodeStates:Z(jC).max(60).optional().describe(`The state of every node that has one at this step, at most one each. Not carried over from earlier steps: repeat any that still apply.`),edgeStates:Z(MC).max(200).optional().describe(`The state of every edge that has one at this step, at most one each. Not carried over from earlier steps: repeat any that still apply.`),variables:Z(fC).max(12).optional().describe(`All running state at this step, e.g. the queue or current distances. Not carried over from earlier steps.`)}).strict(),PC=(e,t,n)=>JSON.stringify(n||e<=t?[e,t]:[t,e]);function FC(e){let t=/* @__PURE__ */ new Map;return e.edges.forEach((n,r)=>{let i=PC(n.from,n.to,e.directed),a=t.get(i);a?a.push(r):t.set(i,[r])}),n=>{let r=`${n.from} ${e.directed?`->`:`--`} ${n.to}`,i=t.get(PC(n.from,n.to,e.directed));if(!i)return{error:`there is no edge ${r}`};if(n.nth===void 0&&i.length>1)return{error:`${i.length} edges match ${r}: set nth to pick one`};let a=i[n.nth??0];return a===void 0?{error:`nth ${n.nth} is out of range: ${i.length} edges match ${r}`}:{index:a}}}function IC(e){if(e.edges.length!==e.nodes.length-1)return;let t=e.nodes.map(e=>e.id),n=new Map(t.map(e=>[e,[]]));for(let{from:t,to:r}of e.edges)n.get(t).push(r),!e.directed&&t!==r&&n.get(r).push(t);let r=e.directed?t.filter(t=>!e.edges.some(e=>e.to===t)):t.slice(0,1),i=r[0];if(r.length!==1||i===void 0)return;let a=/* @__PURE__ */ new Map,o=[i];for(;o.length;){let e=o.pop(),t=n.get(e).filter(e=>!a.has(e));a.set(e,t),o.push(...t)}return a.size===t.length?{root:i,children:a}:void 0}function LC(e,t){let n=e.edges.flatMap((e,t)=>e.side?[{edge:e,side:e.side,path:[`edges`,t,`side`]}]:[]),r=n[0];if(!r)return;if(e.kind!==`tree`){for(let{path:e}of n)t.addIssue({code:`custom`,path:e,message:`side only applies when kind is "tree": remove it, or set kind`});return}let i=IC(e);if(!i){t.addIssue({code:`custom`,path:r.path,message:`side needs a real tree: connected with no cycles, and when directed, edges going parent to child from one root`});return}let a=/* @__PURE__ */ new Map;for(let{edge:e,side:r,path:o}of n)i.children.get(e.from).includes(e.to)?a.set(e.to,r):t.addIssue({code:`custom`,path:o,message:`side needs from to be the parent, but ${e.to} is the parent of ${e.from} here: swap them`});for(let[e,n]of i.children){let r=n.flatMap(e=>a.get(e)??[]);r.length>0&&r.length<n.length&&t.addIssue({code:`custom`,path:[`edges`],message:`node ${e} mixes children with and without a side: give all of them one, or none`});for(let n of[`left`,`right`])r.filter(e=>e===n).length>1&&t.addIssue({code:`custom`,path:[`edges`],message:`node ${e} has two ${n} children`})}}let RC=Q({title:X().trim().min(1).max(120),directed:hS().describe("True draws arrowheads from `from` to `to`."),kind:kS([`tree`,`graph`]).optional().describe("Layout hint. tree draws a rooted tree top-down, and needs a real tree: connected with no cycles, and when directed, edges going parent to child from one root. When undirected, the first node is the root. Anything else falls back to the general layout, unless an edge has a `side`, which is then an error. Defaults to graph."),nodes:Z(kC).min(1).max(60),edges:Z(AC).max(200).describe(`Self-loops and parallel edges are allowed.`),steps:Z(NC).min(1).max(200).optional().describe(`Omit to show the graph without stepping through it.`)}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;e.nodes.forEach((e,r)=>{n.has(e.id)&&t.addIssue({code:`custom`,path:[`nodes`,r,`id`],message:`duplicate node id ${e.id}`}),n.add(e.id)}),e.edges.forEach((e,r)=>{for(let i of[`from`,`to`])n.has(e[i])||t.addIssue({code:`custom`,path:[`edges`,r,i],message:`no node has id ${e[i]}`});e.weight!==void 0&&e.label!==void 0&&t.addIssue({code:`custom`,path:[`edges`,r],message:`give a weight or a label, not both`})}),e.edges.every(e=>n.has(e.from)&&n.has(e.to))&&LC(e,t);let r=FC(e);e.steps?.forEach((e,i)=>{let a=/* @__PURE__ */ new Set;e.nodeStates?.forEach((e,r)=>{let o=[`steps`,i,`nodeStates`,r];n.has(e.id)||t.addIssue({code:`custom`,path:o,message:`no node has id ${e.id}`}),a.has(e.id)&&t.addIssue({code:`custom`,path:o,message:`node ${e.id} has two states in one step`}),a.add(e.id)});let o=/* @__PURE__ */ new Set;e.edgeStates?.forEach((e,n)=>{let a=[`steps`,i,`edgeStates`,n],s=r(e);if(`error`in s)return t.addIssue({code:`custom`,path:a,message:s.error});o.has(s.index)&&t.addIssue({code:`custom`,path:a,message:`edge ${s.index} has two states in one step`}),o.add(s.index)})})}),zC=Q({text:X().trim().min(1).max(300),feedback:X().trim().min(1).max(500).optional().describe(`Shown if the learner picks this option: why it is right or what misconception it reflects.`)}).strict(),BC=Q({concept:X().trim().min(1).max(80).describe(`Short label for the concept being checked, e.g. "sliding window invariant". Used to track progress.`),question:X().trim().min(1).max(1e3),options:Z(zC).min(2).max(6).describe(`2-6 options with distinct text.`),correctOptionIndex:dS().int().nonnegative().describe(`0-based index of the single correct option; must be less than the number of options.`),explanation:X().trim().min(1).max(1e3).describe(`Shown after answering: why the correct option is correct.`)}).strict().superRefine((e,t)=>{e.correctOptionIndex>=e.options.length&&t.addIssue({code:`custom`,path:[`correctOptionIndex`],message:`correctOptionIndex must point at one of the options`});let n=/* @__PURE__ */ new Map;e.options.forEach((e,r)=>{let i=e.text.normalize(`NFC`),a=n.get(i);a===void 0?n.set(i,r):t.addIssue({code:`custom`,path:[`options`,r,`text`],message:`duplicates option ${a}`})})}),VC=Q({concept:X(),question:X(),options:Z(Q({text:X()}).strict())}).strict(),HC=Q({optionIndex:dS().int().nonnegative()}).strict(),UC=Q({correct:hS(),correctOptionIndex:dS().int().nonnegative(),explanation:X(),feedback:X().optional()}).strict(),WC=X().trim().min(1).max(24),GC=/^[^\n\r\v\f\u0085\u2028\u2029]*$/,KC=e=>X().trim().min(1).max(e).regex(GC,`must not contain line breaks`),qC=CS([dS(),KC(24)]);function JC(e){return JSON.stringify([...e].sort())}let YC=Z(WC).max(3),XC=Q({id:WC.describe(`Short id used to refer to this set, e.g. "a". Unique within the diagram.`),label:KC(32).describe(`Shown next to the circle, e.g. "$A$" or "Multiples of 3", on one line. Only $...$ is a formula.`)}).strict(),ZC=Q({in:YC.describe('Ids of the sets this region is inside. It is outside all the others: with sets a, b, c, ["a","b"] means in a and b, not c. [] means outside every set and needs `universe`. No id twice.'),elements:Z(qC).max(30).describe(`What the region contains, each short and on one line. No element may appear twice, in this list or across regions, and 1 and "1" count as the same element. Empty if you only know the count, or the region is empty.`),count:dS().int().nonnegative().max(1e6).optional().describe(`How many elements the region has, when that's more than you list, e.g. for inclusion-exclusion. At least the number of elements listed.`)}).strict(),QC=Q({in:YC.describe("The region to highlight, named like a region's `in`, with no id twice. Any region of the diagram can be highlighted, listed or not."),tone:kS([`active`,`done`,`muted`]).optional().describe(`active = current focus, done = finished, muted = ruled out. Defaults to active.`)}).strict(),$C=Q({explanation:X().trim().min(1).max(500).describe(`What this step shows, in one or two sentences.`),highlights:Z(QC).max(8).optional().describe(`All regions highlighted at this step, each at most once. They apply to this step only, not carried over: repeat any that still apply.`),variables:Z(fC).max(12).optional().describe(`All running state at this step, e.g. |A ∪ B| so far. Not carried over from earlier steps.`)}).strict(),ew=Q({title:X().trim().min(1).max(120),sets:Z(XC).min(1).max(3).describe(`The circles, 1 to 3.`),universe:KC(24).optional().describe(`Label of the rectangle around the sets, e.g. "$U$", on one line. Needed to show or highlight the region outside every set, such as a complement.`),regions:Z(ZC).max(8).describe(`What each region contains, each region at most once.`),steps:Z($C).min(1).max(40).optional().describe(`Optional walk through the diagram. Omit for a static diagram.`)}).strict().superRefine((e,t)=>{let n=e.sets.map(e=>e.id);e.sets.forEach((e,r)=>{n.indexOf(e.id)!==r&&t.addIssue({code:`custom`,path:[`sets`,r,`id`],message:`duplicate set id "${e.id}"`})});let r=(r,i)=>{let a=/* @__PURE__ */ new Set;r.forEach((r,o)=>{let s=[...i,o,`in`];r.in.forEach((e,i)=>{n.includes(e)||t.addIssue({code:`custom`,path:[...s,i],message:`unknown set "${e}"`}),r.in.indexOf(e)!==i&&t.addIssue({code:`custom`,path:[...s,i],message:`set "${e}" is named twice`})}),r.in.length===0&&e.universe===void 0&&t.addIssue({code:`custom`,path:s,message:"the region outside every set needs `universe`"});let c=JC(r.in);a.has(c)&&t.addIssue({code:`custom`,path:s,message:`region ${c} appears more than once`}),a.add(c)})};r(e.regions,[`regions`]),e.steps?.forEach((e,t)=>r(e.highlights??[],[`steps`,t,`highlights`]));let i=/* @__PURE__ */ new Set;e.regions.forEach((e,n)=>{e.elements.forEach((e,r)=>{i.has(String(e))&&t.addIssue({code:`custom`,path:[`regions`,n,`elements`,r],message:`element "${e}" appears more than once; regions don't overlap`}),i.add(String(e))}),e.count!==void 0&&e.count<e.elements.length&&t.addIssue({code:`custom`,path:[`regions`,n,`count`],message:`count ${e.count} is less than the ${e.elements.length} elements listed`})})}),tw=X().trim().min(1).max(80),nw=CS([dS(),hS(),X().max(120)]),rw=dS().int().nonnegative(),iw=Q({row:rw.optional().describe(`0-based data row, below the number of rows. With no column, highlights the whole row. A highlight must give a row, a column or both.`),column:rw.optional().describe(`0-based data column, below the number of columns. With no row, highlights the whole column. With both, highlights one cell.`),tone:kS([`active`,`done`,`muted`]).optional().describe(`active = current focus, done = finished, muted = ruled out. Defaults to active. Where highlights overlap, the later one wins.`)}).strict(),aw=Q({row:rw.describe(`0-based data row, below the number of rows.`),column:rw.describe(`0-based data column, below the number of columns.`),value:nw.describe(`The cell's value from this step on.`)}).strict(),ow=Q({explanation:X().trim().min(1).max(500).describe(`What happens in this step, in one or two sentences.`),highlight:Z(iw).max(32).optional().describe(`All cells, rows and columns to highlight at this step. Not carried over from earlier steps.`),cells:Z(aw).max(64).optional().describe(`Cells this step fills in or changes. They keep the new value on later steps. To reveal working, start a cell as "" and set it here.`)}).strict(),sw=Q({title:X().trim().min(1).max(120),columns:Z(tw).min(1).max(16).describe(`Column headers, one per data column. Don't include a header for rowHeaders.`),rows:Z(Z(nw).min(1).max(16)).min(1).max(64).describe(`Data rows, each with exactly one cell per column. A boolean shows as T or F; "" is a blank cell.`),rowHeaders:Z(tw).max(64).optional().describe(`Optional label for each row, e.g. a relation matrix's elements. Exactly one per row.`),steps:Z(ow).min(1).max(100).optional().describe(`Omit for a static table. With steps, the learner steps through them.`)}).strict().superRefine((e,t)=>{let n=e.rows.length,r=e.columns.length;e.rows.forEach((e,n)=>{e.length!==r&&t.addIssue({code:`custom`,path:[`rows`,n],message:`row has ${e.length} cells but there are ${r} columns`})}),e.rowHeaders&&e.rowHeaders.length!==n&&t.addIssue({code:`custom`,path:[`rowHeaders`],message:`${e.rowHeaders.length} row headers for ${n} rows`});let i=(e,r)=>{e>=n&&t.addIssue({code:`custom`,path:r,message:`row ${e} is outside the table (${n} rows)`})},a=(e,n)=>{e>=r&&t.addIssue({code:`custom`,path:n,message:`column ${e} is outside the table (${r} columns)`})};e.steps?.forEach((e,n)=>{e.highlight?.forEach((e,r)=>{let o=[`steps`,n,`highlight`,r];e.row===void 0&&e.column===void 0&&t.addIssue({code:`custom`,path:o,message:`a highlight needs a row, a column or both`}),e.row!==void 0&&i(e.row,[...o,`row`]),e.column!==void 0&&a(e.column,[...o,`column`])}),e.cells?.forEach((e,t)=>{i(e.row,[`steps`,n,`cells`,t,`row`]),a(e.column,[`steps`,n,`cells`,t,`column`])})})}),cw=Q({label:X().trim().min(1).max(40).optional().describe(`Optional heading for this part of the working, e.g. "Base case", "Inductive step".`),statement:X().trim().min(1).max(1e3).describe(`What this step establishes, mostly as a formula in $...$. For large sums and fractions, put \\displaystyle INSIDE the dollars, e.g. $\\displaystyle\\sum_{i=1}^{n} i$; $$ is not available.`),justification:X().trim().min(1).max(500).describe(`Why it follows, e.g. "by the inductive hypothesis".`)}).strict(),lw=Q({title:X().trim().min(1).max(120),goal:X().trim().min(1).max(500).optional().describe(`Optional statement of what is being shown, e.g. the claim to prove.`),steps:Z(cw).min(1).max(50)}).strict(),uw=kS([`prose`,`algorithm_trace`,`graph`,`multiple_choice`,`set_diagram`,`table`,`worked_steps`]);Q({title:X().trim().min(1).max(120),sections:Z(Q({title:X().trim().min(1).max(120),kind:uw.describe(`prose = write_lesson_text; multiple_choice = ask_multiple_choice (a check); the others = the matching show_* tool.`),purpose:X().trim().min(1).max(300).describe(`What this section does for the learner, in one sentence.`)}).strict()).min(2).max(10).describe(`2-10 sections in reading order. Include at least one multiple_choice check, usually after the idea it checks.`)}).strict().superRefine((e,t)=>{e.sections.some(e=>e.kind===`multiple_choice`)||t.addIssue({code:`custom`,path:[`sections`],message:`Include at least one multiple_choice check`})}),Q({markdown:X().trim().min(1).max(6e3).describe(`The section's prose, as markdown with $...$ and $$...$$ maths. Don't repeat the section title as a heading.`),revisits:Z(X().min(1)).max(5).optional().describe(`sectionIds from <previous_lesson> this section revisits. The page links back to them, so don't write links yourself.`)}).strict();let dw=kS([`generating`,`ready`,`failed`,`finished`]),fw=Q({title:X(),sections:Z(Q({title:X(),kind:uw}).strict())}).strict();Q({id:X(),courseId:X(),topicId:X(),topicTitle:X(),position:dS().int().nonnegative(),status:dw,version:dS().int().positive().nullable(),outline:fw.nullable(),sections:Z(TS(`kind`,[Q({id:X(),title:X(),kind:$(`prose`),markdown:X(),revisits:Z(Q({lessonId:X(),sectionId:X(),title:X(),lessonTitle:X()}).strict())}).strict(),Q({id:X(),title:X(),kind:$(`artifact`),artifact:_S()}).strict()])),checks:Q({total:dS().int().nonnegative(),answered:dS().int().nonnegative()}).strict(),syllabusVersion:dS().int().positive().nullable(),changedSectionIds:Z(X()),changeReason:X().nullable(),canFinish:hS(),error:X().nullable(),createdAt:X().datetime(),finishedAt:X().datetime().nullable()}).strict(),Q({topics:Z(Q({topicId:X(),title:X(),lesson:Q({id:X(),status:dw}).strict().nullable()}).strict()),currentLessonId:X().nullable(),nextTopicId:X().nullable()}).strict();let pw=X().trim().min(1).max(120),mw=X().trim().min(1).max(6e3),hw=X().trim().min(1).max(300);Q({reason:hw.describe(`What the learner asked for, in a few words, e.g. "Simpler intro with an example".`),operations:Z(TS(`op`,[Q({op:$(`rewrite`),sectionId:X().min(1),markdown:mw,title:pw.optional()}).strict().describe(`Replace a prose section's text (and optionally its title).`),Q({op:$(`insert`),afterSectionId:X().min(1).nullable(),title:pw,markdown:mw}).strict().describe(`Add a prose section after the given section, or first if null.`),Q({op:$(`insert_artifact`),afterSectionId:X().min(1).nullable(),title:pw,artifactId:X().min(1)}).strict().describe(`Add a card you created earlier in this reply (its artifactId) as a section.`),Q({op:$(`remove`),sectionId:X().min(1)}).strict(),Q({op:$(`move`),sectionId:X().min(1),afterSectionId:X().min(1).nullable()}).strict()])).min(1).max(10)}).strict(),Q({reason:hw.describe(`What the learner asked for, e.g. "Add a topic on vectors before gradients".`),operations:Z(TS(`op`,[Q({op:$(`insert`),afterTopicId:X().min(1).nullable().describe(`Insert after this topic; null to insert before the first future topic.`),title:pw,summary:X().trim().min(1).max(400),reason:hw,concepts:Z(X().trim().min(1).max(80)).min(1).max(8)}).strict(),Q({op:$(`edit`),topicId:X().min(1),title:pw.optional(),summary:X().trim().min(1).max(400).optional()}).strict(),Q({op:$(`remove`),topicId:X().min(1)}).strict(),Q({op:$(`move`),topicId:X().min(1),afterTopicId:X().min(1).nullable()}).strict()])).min(1).max(10)}).strict(),Q({messageId:X().min(1).max(128),afterSectionId:X().min(1).max(128).nullable(),title:pw}).strict();let gw=Q({title:pw,summary:X().trim().min(1).max(400),concepts:Z(X().trim().min(1).max(80)).min(1).max(8)}).strict();Q({reason:hw.describe(`Shown to the learner, with the evidence, e.g. "Added a chain rule refresher: you missed 3 of 4 checks on derivatives".`),operation:TS(`op`,[gw.extend({op:$(`insert`),afterTopicId:X().min(1).nullable().describe(`null = straight after this lesson's topic`)}).strict(),Q({op:$(`split`),topicId:X().min(1),into:Z(gw).min(2).max(3)}).strict(),Q({op:$(`move`),topicId:X().min(1),afterTopicId:X().min(1).nullable()}).strict()])}).strict();let _w=kS([`goal`,`preference`,`misconception`]),vw=X().trim().min(1).max(300);Q({kind:_w.describe(`goal = what they want to learn or do; preference = how they like to learn; misconception = something they believe that is wrong.`),text:vw.describe(`One short sentence about the learner. Never include the answer to a check they haven't answered.`),concept:X().trim().min(1).max(80).optional().describe(`Required for a misconception: the concept it is about. Use the exact name from the check or from their record, so it can be linked to their answers.`),replaces:X().min(1).optional().describe(`The id of a known memory this one corrects or updates.`)}).strict().superRefine((e,t)=>{e.kind===`misconception`&&!e.concept&&t.addIssue({code:`custom`,path:[`concept`],message:`A misconception needs a concept`})});let yw=kS([`wrong_answer`,`chat`]);Q({id:X(),kind:_w,held:hS(),text:X().nullable(),concept:X().nullable(),basis:yw.nullable(),createdAt:X().datetime(),editedAt:X().datetime().nullable()}).strict(),Q({text:vw}).strict(),Q({id:X(),sessionId:X(),messageId:X().nullable(),filename:X(),kind:kS([`pdf`,`pptx`]),byteSize:dS().int(),pageCount:dS().int(),pagesWithText:dS().int(),status:$(`ready`),createdAt:X().datetime()});let bw=Z(Q({path:X().min(1).max(512),text:X().max(1e6)}).strict()).max(1e4);Q({name:X().trim().min(1).max(120),files:bw}).strict(),Q({files:bw}).strict();let xw=Q({id:X(),name:X(),source:$(`obsidian`),noteCount:dS().int(),createdAt:X().datetime(),updatedAt:X().datetime()}).strict(),Sw=kS([`not_markdown`,`hidden`,`bad_path`,`duplicate`,`too_long`,`symlink`]);Q({import:xw,added:dS().int(),updated:dS().int(),removed:dS().int(),unchanged:dS().int(),skippedCount:dS().int(),skipped:Z(Q({path:X(),reason:Sw}).strict()),truncated:hS()}).strict(),Q({id:X(),importId:X(),path:X(),title:X(),aliases:Z(X()),tags:Z(X()),body:X(),updatedAt:X().datetime()}).strict(),Q({notes:Z(Q({id:X(),path:X(),title:X(),tags:Z(X())}).strict()),links:Z(Q({from:X(),to:X().nullable(),target:X(),kind:kS([`link`,`embed`])}).strict())}).strict();let Cw={algorithm_trace:{version:1,toolName:`show_algorithm_trace`,description:`Show the learner an interactive step-by-step trace of an algorithm running over a sequence (e.g. sliding window, two pointers, binary search, a simple sort). The learner steps through it with play/pause/step controls. Use it when watching state change step by step will make the idea click. Keep traces short (roughly 5-20 steps) and make each step's explanation say what changed and why.`,spec:mC,input:oC(mC,[`title`,`steps.*.explanation`])},graph:{version:1,toolName:`show_graph`,description:`Show the learner a graph or tree, drawn for you, optionally with steps they can walk through. Use it for graphs, trees, BFS, DFS, shortest paths, spanning trees and tree traversals, whenever seeing the structure or watching an algorithm move over it will help. Never give coordinates: the layout is automatic. For a binary search tree or binary tree traversal, set kind to tree and give every edge a side, so a lone left child and a lone right child are drawn differently. The automatic layout may draw crossing edges that mean nothing, even when the graph is planar, so don't use this to show whether a graph is planar. Keep it small enough to read (roughly 4-15 nodes, 5-20 steps) and make each step's explanation say what changed and why.`,spec:RC,input:oC(RC,[`title`,`nodes.*.label`,`edges.*.label`,`steps.*.explanation`],(e,t)=>{e.nodes.forEach((e,n)=>{e.label===void 0&&aC(e.id,[`nodes`,n,`id`],t)})})},multiple_choice:{version:1,toolName:`ask_multiple_choice`,description:`Ask the learner one multiple-choice question to check understanding of a concept you just taught. Exactly one option is correct. Write plausible wrong options that reflect real misconceptions, and give per-option feedback where useful. The learner answers in the UI; the result is reported back to you on the next turn, so do not reveal the answer in your reply.`,spec:BC,input:oC(BC,[`question`,`options.*.text`,`options.*.feedback`,`explanation`])},placement_question:{version:1,toolName:`ask_placement_question`,description:`Course placement interview only: ask the learner one quick question to find out what they already know about one concept, before the syllabus is written. Use multiple choice, true/false or yes/no. The UI always adds "Not sure" and "Skip", so never include those as options. The learner answers in the UI and the result is reported back to you, so don't reveal the answer.`,spec:gC,input:oC(gC,[`question`,`options.*.text`,`explanation`])},set_diagram:{version:1,toolName:`show_set_diagram`,description:"Show the learner a Venn diagram of 1 to 3 sets, with what each region contains. Use it for set operations (union, intersection, complement, difference) and inclusion-exclusion, not for more than 3 sets. Keep elements short, because they are drawn in their region. Add steps to walk through it: each step highlights exact regions (any of them, including outside every set, which needs `universe`) and says what changed and why.",spec:ew,input:oC(ew,[`title`,`universe`,`sets.*.label`,`regions.*.elements.*`,`steps.*.explanation`,`steps.*.variables.*.name`,`steps.*.variables.*.value`])},table:{version:1,toolName:`show_table`,description:`Show the learner a table: a truth table, a relation matrix or other tabular working. Use it whenever the content is really rows and columns. Add steps when filling it in or highlighting it one part at a time will help, such as working out a truth table column by column; leave them out for a table to read at a glance. Keep steps short and make each explanation say what changed and why.`,spec:sw,input:oC(sw,[`title`,`columns.*`,`rowHeaders.*`,`rows.*.*`,`steps.*.explanation`,`steps.*.cells.*.value`])},worked_steps:{version:1,toolName:`show_worked_steps`,description:`Show the learner a proof, an induction or combinatorics working as a sequence of steps they reveal one at a time, each a statement with its justification. Use it when the reasoning is the point and each line follows from the ones before. Use show_algorithm_trace instead for an algorithm's state changing over a sequence.`,spec:lw,input:oC(lw,[`title`,`goal`,`steps.*.label`,`steps.*.statement`,`steps.*.justification`])}};kS(Object.keys(Cw));let ww={id:X(),createdAt:X().datetime()},Tw=Q({answer:HC,grade:UC,createdAt:X().datetime()}).strict(),Ew=Q({answer:vC,grade:yC,createdAt:X().datetime()}).strict();TS(`kind`,[Q({...ww,kind:$(`algorithm_trace`),version:$(1),spec:mC}).strict(),Q({...ww,kind:$(`graph`),version:$(1),spec:RC}).strict(),Q({...ww,kind:$(`multiple_choice`),version:$(1),spec:VC,latestAttempt:Tw.optional()}).strict(),Q({...ww,kind:$(`placement_question`),version:$(1),spec:_C,latestAttempt:Ew.optional()}).strict(),Q({...ww,kind:$(`set_diagram`),version:$(1),spec:ew}).strict(),Q({...ww,kind:$(`table`),version:$(1),spec:sw}).strict(),Q({...ww,kind:$(`worked_steps`),version:$(1),spec:lw}).strict()]);let Dw=e=>e!==null&&e<-2,Ow=e=>e===null||e<0||e===32,kw=e=>e!==null&&e>=48&&e<=57;function Aw(e,t,n){let r=0,i=0,a,o=null,s=t=>t===36?(e.consume(t),r+=1,s):r>2||r===1&&Ow(t)?n(t):(e.exit(`mathTextSequence`),c(t)),c=t=>{if(t===null||t===96)return n(t);if(t===36)return a=e.enter(`mathTextSequence`),i=0,d(t);if(t===32||Dw(t)){let n=t===32?`space`:`lineEnding`;return e.enter(n),e.consume(t),e.exit(n),o=t,c}return e.enter(`mathTextData`),l(t)},l=t=>t===null||t===96||t===32||t===36||Dw(t)?(e.exit(`mathTextData`),c(t)):(e.consume(t),o=t,t===92?u:l),u=t=>t!==36&&t!==92?l(t):(e.consume(t),o=t,l),d=s=>s===36?(e.consume(s),i+=1,d):i===r?kw(s)||r===1&&Ow(o)?n(s):(e.exit(`mathTextSequence`),e.exit(`mathText`),t(s)):r===1?n(s):(a.type=`mathTextData`,l(s));return t=>(e.enter(`mathText`),e.enter(`mathTextSequence`),s(t))}function jw(){for(let e of this.data().micromarkExtensions??[]){let t=e.text?.[36];t&&(e.text[36]={...t,tokenize:Aw})}}let Mw=[`http:`,`https:`,`mailto:`];function Nw(e){try{let t=new URL(e);return Mw.includes(t.protocol)?t.href:``}catch{return``}}function Pw(){return(e,t)=>{let n=String(t.value),r=e=>{for(let t of e.children??[]){let e=t.position?.start.offset;t.type===`inlineMath`&&e!==void 0&&n.startsWith(`$$`,e)&&(t.data={...t.data,hProperties:{...t.data?.hProperties,className:[`language-math`,`math-display`]}}),r(t)}};r(e)}}let Fw=[zd,Zd,jw,Pw],Iw=Sm().use(Vf).use(Fw).use(qp,{allowDangerousHtml:!0}),Lw=/* @__PURE__ */ new Map;function Rw(e,t){let n=`${t?`D`:`I`}${e}`,r=Lw.get(n);if(r!==void 0)return Lw.delete(n),Lw.set(n,r),r;let i;try{i=Ka.renderToString(e,{displayMode:t,trust:!1,strict:`ignore`,throwOnError:!1,errorColor:`var(--destructive)`})}catch{return}return Lw.set(n,i),Lw.size>1e3&&Lw.delete(Lw.keys().next().value),i}let zw=e=>{let t=e.properties.className;return Array.isArray(t)?t.map(String):[]},Bw=e=>e?.type===`element`&&e.tagName===`code`&&zw(e).includes(`language-math`),Vw=e=>e.children.map(e=>e.type===`text`?e.value:``).join(``);function Hw(e){let t=Iw.runSync(Iw.parse(e),e),n=[],r=(e,t)=>{let r=Rw(e,t);return r===void 0?{type:`element`,tagName:`span`,properties:{className:[`katex-error`]},children:[{type:`text`,value:e}]}:(n.push(r),{type:`element`,tagName:`span`,properties:{className:[`math-text-formula`],dataFormula:n.length-1},children:[]})};return qs(t,(e,t,n)=>{if(delete e.position,n&&t!==void 0){if(e.type===`raw`)n.children[t]={type:`text`,value:e.value};else if(e.type===`element`){if(e.tagName===`pre`&&e.children.length===1&&Bw(e.children[0]))return n.children[t]=r(Vw(e.children[0]).replace(/\n$/,``),!0),`skip`;if(Bw(e))return n.children[t]=r(Vw(e),zw(e).includes(`math-display`)),`skip`;for(let[t,n]of Object.entries(u))Object.hasOwn(e.properties,t)&&(n===null||n.includes(e.tagName))&&(e.properties[t]=Nw(String(e.properties[t]??``)))}}}),{tree:t,formulas:n}}let Uw=self;Uw.onmessage=e=>{let{id:t,text:n}=e.data,r;try{r={id:t,block:Hw(n)}}catch{r={id:t}}Uw.postMessage(r)}})();
package/web/index.html CHANGED
@@ -15,8 +15,8 @@
15
15
  document.documentElement.classList.toggle("dark", dark);
16
16
  })();
17
17
  </script>
18
- <script type="module" crossorigin src="/assets/index-BfT-sp3_.js"></script>
19
- <link rel="stylesheet" crossorigin href="/assets/index-FIC4B_yh.css">
18
+ <script type="module" crossorigin src="/assets/index-BUYWW1Mc.js"></script>
19
+ <link rel="stylesheet" crossorigin href="/assets/index-Cmq-m9fI.css">
20
20
  </head>
21
21
  <body>
22
22
  <div id="root"></div>