finch-markdown-editor 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bmmd/bin/bmmd.mjs +3 -3
- package/dist/bmmd/bin/dist-BoUxJM-2.mjs +71 -0
- package/dist/bmmd/bin/{html-BUXlQGSS.mjs → html-CGVTbdd7.mjs} +143 -143
- package/dist/codemirror.js +25 -25
- package/dist/index.js +142 -19
- package/dist/panel.css +4 -4
- package/dist/panel.js +19 -19
- package/package.json +7 -2
- package/dist/bmmd/bin/dist-B0xJMeoM.mjs +0 -134
package/dist/bmmd/bin/bmmd.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{i as e,o as t,r as n,s as r,t as i}from"./dist-BoUxJM-2.mjs";import a from"node:process";import{readFile as o,writeFile as s}from"node:fs/promises";function c(e){return e==null?[]:Array.isArray(e)?e:[e]}function l(e,t,n,r){var i,a=e[t],o=~r.string.indexOf(t)?n==null||n===!0?``:String(n):typeof n==`boolean`?n:~r.boolean.indexOf(t)?n===`false`?!1:n===`true`||(e._.push((i=+n,i*0==0?i:n)),!!n):(i=+n,i*0==0?i:n);e[t]=a==null?o:Array.isArray(a)?a.concat(o):[a,o]}function u(e,t){e||=[],t||={};var n,r,i,a,o,s={_:[]},u=0,d=0,f=0,p=e.length;let m=t.alias!==void 0,h=t.unknown!==void 0,ee=t.default!==void 0;if(t.alias=t.alias||{},t.string=c(t.string),t.boolean=c(t.boolean),m)for(n in t.alias)for(r=t.alias[n]=c(t.alias[n]),u=0;u<r.length;u++)(t.alias[r[u]]=r.concat(n)).splice(u,1);for(u=t.boolean.length;u-->0;)for(r=t.alias[t.boolean[u]]||[],d=r.length;d-->0;)t.boolean.push(r[d]);for(u=t.string.length;u-->0;)for(r=t.alias[t.string[u]]||[],d=r.length;d-->0;)t.string.push(r[d]);if(ee){for(n in t.default)if(a=typeof t.default[n],r=t.alias[n]=t.alias[n]||[],t[a]!==void 0)for(t[a].push(n),u=0;u<r.length;u++)t[a].push(r[u])}let te=h?Object.keys(t.alias):[];for(u=0;u<p;u++){if(i=e[u],i===`--`){s._=s._.concat(e.slice(++u));break}for(d=0;d<i.length&&i.charCodeAt(d)===45;d++);if(d===0)s._.push(i);else if(i.substring(d,d+3)===`no-`){if(a=i.substring(d+3),h&&!~te.indexOf(a))return t.unknown(i);s[a]=!1}else{for(f=d+1;f<i.length&&i.charCodeAt(f)!==61;f++);for(a=i.substring(d,f),o=i.substring(++f)||u+1===p||(``+e[u+1]).charCodeAt(0)===45||e[++u],r=d===2?[a]:a,f=0;f<r.length;f++){if(a=r[f],h&&!~te.indexOf(a))return t.unknown(`-`.repeat(d)+a);l(s,a,f+1<r.length||o,t)}}}if(ee)for(n in t.default)s[n]===void 0&&(s[n]=t.default[n]);if(m)for(n in s)for(r=t.alias[n]||[];r.length>0;)s[r.shift()]=s[n];return s}function d(e){return e.replace(/[<[].+/,``).trim()}function f(e){let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,r=[],i=e=>{let t=!1,n=e[1];return n.startsWith(`...`)&&(n=n.slice(3),t=!0),{required:e[0].startsWith(`<`),value:n,variadic:t}},a;for(;a=t.exec(e);)r.push(i(a));let o;for(;o=n.exec(e);)r.push(i(o));return r}function p(e){let t={alias:{},boolean:[]};for(let[n,r]of e.entries())r.names.length>1&&(t.alias[r.names[0]]=r.names.slice(1)),r.isBoolean&&(r.negated&&e.some((e,t)=>t!==n&&e.names.some(e=>r.names.includes(e))&&typeof e.required==`boolean`)||t.boolean.push(r.names[0]));return t}function m(e){return e.sort((e,t)=>e.length>t.length?-1:1)[0]}function h(e,t){return e.length>=t?e:`${e}${` `.repeat(t-e.length)}`}function ee(e){return e.replaceAll(/([a-z])-([a-z])/g,(e,t,n)=>t+n.toUpperCase())}function te(e,t,n){let r=e;for(let e=0;e<t.length;e++){let i=t[e];if(e===t.length-1){r[i]=n;return}if(r[i]==null){let n=+t[e+1]>-1;r[i]=n?[]:{}}r=r[i]}}function ne(e,t){for(let n of Object.keys(t)){let r=t[n];r.shouldTransform&&(e[n]=[e[n]].flat(),typeof r.transformFunction==`function`&&(e[n]=e[n].map(r.transformFunction)))}}function re(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:``}function ie(e){return e.split(`.`).map((e,t)=>t===0?ee(e):e).join(`.`)}var ae=class extends Error{constructor(e){super(e),this.name=`CACError`,typeof Error.captureStackTrace!=`function`&&(this.stack=Error(e).stack)}},oe=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,n){this.rawName=e,this.description=t,this.config=Object.assign({},n),e=e.replaceAll(`.*`,``),this.negated=!1,this.names=d(e).split(`,`).map(e=>{let t=e.trim().replace(/^-{1,2}/,``);return t.startsWith(`no-`)&&(this.negated=!0,t=t.replace(/^no-/,``)),ie(t)}).sort((e,t)=>e.length>t.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null&&(this.config.default=!0),e.includes(`<`)?this.required=!0:e.includes(`[`)?this.required=!1:this.isBoolean=!0}};let se,ce;if(typeof process<`u`){let e;e=typeof Deno<`u`&&typeof Deno.version?.deno==`string`?`deno`:typeof Bun<`u`&&typeof Bun.version==`string`?`bun`:`node`,ce=`${process.platform}-${process.arch} ${e}-${process.version}`,se=process.argv}else ce=typeof navigator>`u`?`unknown`:`${navigator.platform} ${navigator.userAgent}`;var le=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(e,t,n={},r){this.rawName=e,this.description=t,this.config=n,this.cli=r,this.options=[],this.aliasNames=[],this.name=d(e),this.args=f(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t=`-v, --version`){return this.versionNumber=e,this.option(t,`Display version number`),this}example(e){return this.examples.push(e),this}option(e,t,n){let r=new oe(e,t,n);return this.options.push(r),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===``||this.aliasNames.includes(`!`)}get isGlobalCommand(){return this instanceof ue}hasOption(e){return e=e.split(`.`)[0],this.options.find(t=>t.names.includes(e))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:n,options:r,helpCallback:i}=this.cli.globalCommand,a=[{body:`${e}${n?`/${n}`:``}`}];if(a.push({title:`Usage`,body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let n=m(t.map(e=>e.rawName));a.push({title:`Commands`,body:t.map(e=>` ${h(e.rawName,n.length)} ${e.description}`).join(`
|
|
3
3
|
`)},{title:"For more info, run any command with the `--help` flag",body:t.map(t=>` $ ${e}${t.name===``?``:` ${t.name}`} --help`).join(`
|
|
4
4
|
`)})}let o=this.isGlobalCommand?r:[...this.options,...r||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand&&(o=o.filter(e=>e.name!==`version`)),o.length>0){let e=m(o.map(e=>e.rawName));a.push({title:`Options`,body:o.map(t=>` ${h(t.rawName,e.length)} ${t.description} ${t.config.default===void 0?``:`(default: ${t.config.default})`}`).join(`
|
|
5
5
|
`)})}this.examples.length>0&&a.push({title:`Examples`,body:this.examples.map(t=>typeof t==`function`?t(e):t).join(`
|
|
6
6
|
`)}),i&&(a=i(a)||a),console.info(a.map(e=>e.title?`${e.title}:\n${e.body}`:e.body).join(`
|
|
7
7
|
|
|
8
|
-
`))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;t&&console.info(`${e}/${t} ${ce}`)}checkRequiredArgs(){let e=this.args.filter(e=>e.required).length;if(this.cli.args.length<e)throw new ae(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!==`--`&&!this.hasOption(n)&&!t.hasOption(n))throw new ae(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let t of n){let r=e[t.name.split(`.`)[0]];if(t.required){let e=n.some(e=>e.negated&&e.names.includes(t.name));if(r===!0||r===!1&&!e)throw new ae(`option \`${t.rawName}\` value is missing`)}}}checkUnusedArgs(){let e=this.args.some(e=>e.variadic)?1/0:this.args.length;if(e<this.cli.args.length)throw new ae(`Unused args: ${this.cli.args.slice(e).map(e=>`\`${e}\``).join(`, `)}`)}},ue=class extends le{constructor(e){super(`@@global@@`,``,{},e)}},de=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(e=``){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new ue(this),this.globalCommand.usage(`<command> [options]`)}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let r=new le(e,t||``,n,this);return r.globalCommand=this.globalCommand,this.commands.push(r),r}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option(`-h, --help`,`Display this message`),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t=`-v, --version`){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,r){return this.args=e,this.options=t,n&&(this.matchedCommand=n),r&&(this.matchedCommandName=r),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e,{run:t=!0}={}){if(!e){if(!se)throw Error(`No argv provided and runtime process argv is not available.`);e=se}this.rawArgs=e,this.name||=e[1]?re(e[1]):`cli`;let n=!0;for(let t of this.commands){let r=this.mri(e.slice(2),t),i=r.args[0];if(t.isMatched(i)){n=!1;let e={...r,args:r.args.slice(1)};this.setParsedInfo(e,t,i),this.dispatchEvent(new CustomEvent(`command:${i}`,{detail:t}))}}if(n){for(let t of this.commands)if(t.isDefaultCommand){n=!1;let r=this.mri(e.slice(2),t);this.setParsedInfo(r,t),this.dispatchEvent(new CustomEvent(`command:!`,{detail:t}))}}if(n){let t=this.mri(e.slice(2));this.setParsedInfo(t)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),t=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),t=!1,this.unsetMatchedCommand());let r={args:this.args,options:this.options};return t&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.dispatchEvent(new CustomEvent(`command:*`,{detail:this.args[0]})),r}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],r=p(n),i=[],a=e.indexOf(`--`);a!==-1&&(i=e.slice(a+1),e=e.slice(0,a));let o=u(e,r);o=Object.keys(o).reduce((e,t)=>({...e,[ie(t)]:o[t]}),{_:[]});let s=o._,c={"--":i},l=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,d=Object.create(null);for(let e of n){if(!l&&e.config.default!==void 0)for(let t of e.names)c[t]=e.config.default;Array.isArray(e.config.type)&&d[e.name]===void 0&&(d[e.name]=Object.create(null),d[e.name].shouldTransform=!0,d[e.name].transformFunction=e.config.type[0])}for(let e of Object.keys(o))e!==`_`&&(te(c,e.split(`.`),o[e]),ne(c,d));return{args:s,options:c}}runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs(),n.checkUnusedArgs();let r=[];return n.args.forEach((t,n)=>{t.variadic?r.push(e.slice(n)):r.push(e[n])}),r.push(t),n.commandAction.apply(this,r)}};const fe=(e=``)=>new de(e);var pe=`0.3.1`,me=`Markdown 排版 CLI,支持微信公众号与 HTML 输出。`,he;function g(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var _=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ge=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(he=globalThis).__zod_globalConfig??(he.__zod_globalConfig={});const v=globalThis.__zod_globalConfig;function y(e){return e&&Object.assign(v,e),v}function _e(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ve(e,t){return typeof t==`bigint`?t.toString():t}function ye(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function be(e){return e==null}function xe(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}const Se=Symbol(`evaluating`);function b(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Se)return r===void 0&&(r=Se,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function x(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function S(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ce(e){return JSON.stringify(e)}function we(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Te=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Ee=ye(()=>{if(v.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function w(e){if(C(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(C(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function De(e){return w(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Oe=new Set([`string`,`number`,`symbol`]);function T(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function E(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function D(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ke(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}-Number.MAX_VALUE,Number.MAX_VALUE;function Ae(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return E(e,S(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return x(this,`shape`,e),e},checks:[]}))}function je(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return E(e,S(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return x(this,`shape`,r),r},checks:[]}))}function Me(e,t){if(!w(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return E(e,S(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return x(this,`shape`,n),n}}))}function Ne(e,t){if(!w(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return E(e,S(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return x(this,`shape`,n),n}}))}function Pe(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return E(e,S(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return x(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Fe(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return E(t,S(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return x(this,`shape`,i),i},checks:[]}))}function Ie(e,t,n){return E(t,S(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return x(this,`shape`,i),i}}))}function O(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Le(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Re(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function k(e){return typeof e==`string`?e:e?.message}function A(e,t,n){let r=e.message?e.message:k(e.inst?._zod.def?.error?.(e))??k(t?.error?.(e))??k(n.customError?.(e))??k(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function ze(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function j(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Be=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ve=g(`$ZodError`,Be),He=g(`$ZodError`,Be,{Parent:Error});function Ue(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function We(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}const Ge=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new _;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>A(e,a,y())));throw Te(t,i?.callee),t}return o.value},Ke=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>A(e,a,y())));throw Te(t,i?.callee),t}return o.value},M=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new _;return a.issues.length?{success:!1,error:new(e??Ve)(a.issues.map(e=>A(e,i,y())))}:{success:!0,data:a.value}},qe=M(He),N=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>A(e,i,y())))}:{success:!0,data:a.value}},Je=N(He),Ye=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ge(e)(t,n,i)},Xe=e=>(t,n,r)=>Ge(e)(t,n,r),Ze=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ke(e)(t,n,i)},Qe=e=>async(t,n,r)=>Ke(e)(t,n,r),$e=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return M(e)(t,n,i)},et=e=>(t,n,r)=>M(e)(t,n,r),tt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return N(e)(t,n,i)},nt=e=>async(t,n,r)=>N(e)(t,n,r),rt=/^[cC][0-9a-z]{6,}$/,it=/^[0-9a-z]+$/,at=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ot=/^[0-9a-vA-V]{20}$/,st=/^[A-Za-z0-9]{27}$/,ct=/^[a-zA-Z0-9_-]{21}$/,lt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ut=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,dt=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ft=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function pt(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const mt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ht=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,gt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,_t=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,vt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yt=/^[A-Za-z0-9_-]*$/,bt=/^https?$/,xt=/^\+[1-9]\d{6,14}$/,St=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Ct=RegExp(`^${St}$`);function wt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Tt(e){return RegExp(`^${wt(e)}$`)}function Et(e){let t=wt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${St}T(?:${r})$`)}const Dt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ot=/^(?:true|false)$/i,kt=/^[^A-Z]*$/,At=/^[^a-z]*$/,P=g(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jt=g(`$ZodCheckMaxLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!be(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=ze(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Mt=g(`$ZodCheckMinLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!be(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=ze(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Nt=g(`$ZodCheckLengthEquals`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!be(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=ze(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),F=g(`$ZodCheckStringFormat`,(e,t)=>{var n,r;P.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Pt=g(`$ZodCheckRegex`,(e,t)=>{F.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ft=g(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=kt,F.init(e,t)}),It=g(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=At,F.init(e,t)}),Lt=g(`$ZodCheckIncludes`,(e,t)=>{P.init(e,t);let n=T(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Rt=g(`$ZodCheckStartsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`^${T(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),zt=g(`$ZodCheckEndsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`.*${T(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Bt=g(`$ZodCheckOverwrite`,(e,t)=>{P.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Vt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
8
|
+
`))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;t&&console.info(`${e}/${t} ${ce}`)}checkRequiredArgs(){let e=this.args.filter(e=>e.required).length;if(this.cli.args.length<e)throw new ae(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!==`--`&&!this.hasOption(n)&&!t.hasOption(n))throw new ae(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let t of n){let r=e[t.name.split(`.`)[0]];if(t.required){let e=n.some(e=>e.negated&&e.names.includes(t.name));if(r===!0||r===!1&&!e)throw new ae(`option \`${t.rawName}\` value is missing`)}}}checkUnusedArgs(){let e=this.args.some(e=>e.variadic)?1/0:this.args.length;if(e<this.cli.args.length)throw new ae(`Unused args: ${this.cli.args.slice(e).map(e=>`\`${e}\``).join(`, `)}`)}},ue=class extends le{constructor(e){super(`@@global@@`,``,{},e)}},de=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(e=``){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new ue(this),this.globalCommand.usage(`<command> [options]`)}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let r=new le(e,t||``,n,this);return r.globalCommand=this.globalCommand,this.commands.push(r),r}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option(`-h, --help`,`Display this message`),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t=`-v, --version`){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,r){return this.args=e,this.options=t,n&&(this.matchedCommand=n),r&&(this.matchedCommandName=r),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e,{run:t=!0}={}){if(!e){if(!se)throw Error(`No argv provided and runtime process argv is not available.`);e=se}this.rawArgs=e,this.name||=e[1]?re(e[1]):`cli`;let n=!0;for(let t of this.commands){let r=this.mri(e.slice(2),t),i=r.args[0];if(t.isMatched(i)){n=!1;let e={...r,args:r.args.slice(1)};this.setParsedInfo(e,t,i),this.dispatchEvent(new CustomEvent(`command:${i}`,{detail:t}))}}if(n){for(let t of this.commands)if(t.isDefaultCommand){n=!1;let r=this.mri(e.slice(2),t);this.setParsedInfo(r,t),this.dispatchEvent(new CustomEvent(`command:!`,{detail:t}))}}if(n){let t=this.mri(e.slice(2));this.setParsedInfo(t)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),t=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),t=!1,this.unsetMatchedCommand());let r={args:this.args,options:this.options};return t&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.dispatchEvent(new CustomEvent(`command:*`,{detail:this.args[0]})),r}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],r=p(n),i=[],a=e.indexOf(`--`);a!==-1&&(i=e.slice(a+1),e=e.slice(0,a));let o=u(e,r);o=Object.keys(o).reduce((e,t)=>({...e,[ie(t)]:o[t]}),{_:[]});let s=o._,c={"--":i},l=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,d=Object.create(null);for(let e of n){if(!l&&e.config.default!==void 0)for(let t of e.names)c[t]=e.config.default;Array.isArray(e.config.type)&&d[e.name]===void 0&&(d[e.name]=Object.create(null),d[e.name].shouldTransform=!0,d[e.name].transformFunction=e.config.type[0])}for(let e of Object.keys(o))e!==`_`&&(te(c,e.split(`.`),o[e]),ne(c,d));return{args:s,options:c}}runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs(),n.checkUnusedArgs();let r=[];return n.args.forEach((t,n)=>{t.variadic?r.push(e.slice(n)):r.push(e[n])}),r.push(t),n.commandAction.apply(this,r)}};const fe=(e=``)=>new de(e);var pe=`0.3.2`,me=`Markdown 排版 CLI,支持微信公众号与 HTML 输出。`,he;function g(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var _=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ge=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(he=globalThis).__zod_globalConfig??(he.__zod_globalConfig={});const v=globalThis.__zod_globalConfig;function y(e){return e&&Object.assign(v,e),v}function _e(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ve(e,t){return typeof t==`bigint`?t.toString():t}function ye(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function be(e){return e==null}function xe(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}const Se=Symbol(`evaluating`);function b(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Se)return r===void 0&&(r=Se,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function x(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function S(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ce(e){return JSON.stringify(e)}function we(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Te=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Ee=ye(()=>{if(v.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function w(e){if(C(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(C(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function De(e){return w(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Oe=new Set([`string`,`number`,`symbol`]);function T(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function E(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function D(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ke(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}-Number.MAX_VALUE,Number.MAX_VALUE;function Ae(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return E(e,S(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return x(this,`shape`,e),e},checks:[]}))}function je(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return E(e,S(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return x(this,`shape`,r),r},checks:[]}))}function Me(e,t){if(!w(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return E(e,S(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return x(this,`shape`,n),n}}))}function Ne(e,t){if(!w(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return E(e,S(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return x(this,`shape`,n),n}}))}function Pe(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return E(e,S(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return x(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Fe(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return E(t,S(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return x(this,`shape`,i),i},checks:[]}))}function Ie(e,t,n){return E(t,S(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return x(this,`shape`,i),i}}))}function O(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Le(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Re(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function k(e){return typeof e==`string`?e:e?.message}function A(e,t,n){let r=e.message?e.message:k(e.inst?._zod.def?.error?.(e))??k(t?.error?.(e))??k(n.customError?.(e))??k(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function ze(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function j(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Be=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ve=g(`$ZodError`,Be),He=g(`$ZodError`,Be,{Parent:Error});function Ue(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function We(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}const Ge=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new _;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>A(e,a,y())));throw Te(t,i?.callee),t}return o.value},Ke=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>A(e,a,y())));throw Te(t,i?.callee),t}return o.value},M=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new _;return a.issues.length?{success:!1,error:new(e??Ve)(a.issues.map(e=>A(e,i,y())))}:{success:!0,data:a.value}},qe=M(He),N=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>A(e,i,y())))}:{success:!0,data:a.value}},Je=N(He),Ye=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ge(e)(t,n,i)},Xe=e=>(t,n,r)=>Ge(e)(t,n,r),Ze=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ke(e)(t,n,i)},Qe=e=>async(t,n,r)=>Ke(e)(t,n,r),$e=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return M(e)(t,n,i)},et=e=>(t,n,r)=>M(e)(t,n,r),tt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return N(e)(t,n,i)},nt=e=>async(t,n,r)=>N(e)(t,n,r),rt=/^[cC][0-9a-z]{6,}$/,it=/^[0-9a-z]+$/,at=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ot=/^[0-9a-vA-V]{20}$/,st=/^[A-Za-z0-9]{27}$/,ct=/^[a-zA-Z0-9_-]{21}$/,lt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ut=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,dt=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ft=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function pt(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const mt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ht=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,gt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,_t=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,vt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yt=/^[A-Za-z0-9_-]*$/,bt=/^https?$/,xt=/^\+[1-9]\d{6,14}$/,St=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Ct=RegExp(`^${St}$`);function wt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Tt(e){return RegExp(`^${wt(e)}$`)}function Et(e){let t=wt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${St}T(?:${r})$`)}const Dt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ot=/^(?:true|false)$/i,kt=/^[^A-Z]*$/,At=/^[^a-z]*$/,P=g(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jt=g(`$ZodCheckMaxLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!be(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=ze(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Mt=g(`$ZodCheckMinLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!be(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=ze(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Nt=g(`$ZodCheckLengthEquals`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!be(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=ze(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),F=g(`$ZodCheckStringFormat`,(e,t)=>{var n,r;P.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Pt=g(`$ZodCheckRegex`,(e,t)=>{F.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ft=g(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=kt,F.init(e,t)}),It=g(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=At,F.init(e,t)}),Lt=g(`$ZodCheckIncludes`,(e,t)=>{P.init(e,t);let n=T(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Rt=g(`$ZodCheckStartsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`^${T(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),zt=g(`$ZodCheckEndsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`.*${T(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Bt=g(`$ZodCheckOverwrite`,(e,t)=>{P.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Vt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
9
9
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
10
10
|
`))}};const Ht={major:4,minor:4,patch:3},I=g(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ht;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=O(e),i;for(let a of t){if(a._zod.def.when){if(Le(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new _;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=O(e,t))});else{if(e.issues.length===t)continue;r||=O(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(O(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new _;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new _;return o.then(e=>t(e,r,a))}return t(o,r,a)}}b(e,`~standard`,()=>({validate:t=>{try{let n=qe(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Je(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Ut=g(`$ZodString`,(e,t)=>{I.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Dt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),L=g(`$ZodStringFormat`,(e,t)=>{F.init(e,t),Ut.init(e,t)}),Wt=g(`$ZodGUID`,(e,t)=>{t.pattern??=ut,L.init(e,t)}),Gt=g(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=dt(e)}else t.pattern??=dt();L.init(e,t)}),Kt=g(`$ZodEmail`,(e,t)=>{t.pattern??=ft,L.init(e,t)}),qt=g(`$ZodURL`,(e,t)=>{L.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===bt.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Jt=g(`$ZodEmoji`,(e,t)=>{t.pattern??=pt(),L.init(e,t)}),Yt=g(`$ZodNanoID`,(e,t)=>{t.pattern??=ct,L.init(e,t)}),Xt=g(`$ZodCUID`,(e,t)=>{t.pattern??=rt,L.init(e,t)}),Zt=g(`$ZodCUID2`,(e,t)=>{t.pattern??=it,L.init(e,t)}),Qt=g(`$ZodULID`,(e,t)=>{t.pattern??=at,L.init(e,t)}),$t=g(`$ZodXID`,(e,t)=>{t.pattern??=ot,L.init(e,t)}),en=g(`$ZodKSUID`,(e,t)=>{t.pattern??=st,L.init(e,t)}),tn=g(`$ZodISODateTime`,(e,t)=>{t.pattern??=Et(t),L.init(e,t)}),nn=g(`$ZodISODate`,(e,t)=>{t.pattern??=Ct,L.init(e,t)}),rn=g(`$ZodISOTime`,(e,t)=>{t.pattern??=Tt(t),L.init(e,t)}),an=g(`$ZodISODuration`,(e,t)=>{t.pattern??=lt,L.init(e,t)}),on=g(`$ZodIPv4`,(e,t)=>{t.pattern??=mt,L.init(e,t),e._zod.bag.format=`ipv4`}),sn=g(`$ZodIPv6`,(e,t)=>{t.pattern??=ht,L.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),cn=g(`$ZodCIDRv4`,(e,t)=>{t.pattern??=gt,L.init(e,t)}),ln=g(`$ZodCIDRv6`,(e,t)=>{t.pattern??=_t,L.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function un(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const dn=g(`$ZodBase64`,(e,t)=>{t.pattern??=vt,L.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{un(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function fn(e){if(!yt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return un(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const pn=g(`$ZodBase64URL`,(e,t)=>{t.pattern??=yt,L.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{fn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),mn=g(`$ZodE164`,(e,t)=>{t.pattern??=xt,L.init(e,t)});function hn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const gn=g(`$ZodJWT`,(e,t)=>{L.init(e,t),e._zod.check=n=>{hn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),_n=g(`$ZodBoolean`,(e,t)=>{I.init(e,t),e._zod.pattern=Ot,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),vn=g(`$ZodUnknown`,(e,t)=>{I.init(e,t),e._zod.parse=e=>e}),yn=g(`$ZodNever`,(e,t)=>{I.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function bn(e,t,n){e.issues.length&&t.issues.push(...Re(n,e.issues)),t.value[n]=e.value}const xn=g(`$ZodArray`,(e,t)=>{I.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>bn(t,n,e))):bn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function R(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Re(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Sn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=ke(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Cn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>R(e,n,i,t,u,d))):R(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const wn=g(`$ZodObject`,(e,t)=>{if(I.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=ye(()=>Sn(t));b(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=C,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>R(n,t,e,s,r,i))):R(a,t,e,s,r,i)}return i?Cn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Tn=g(`$ZodObjectJIT`,(e,t)=>{wn.init(e,t);let n=e._zod.parse,r=ye(()=>Sn(t)),i=e=>{let t=new Vt([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Ce(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Ce(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
11
11
|
if (${n}.issues.length) {
|
|
@@ -68,6 +68,6 @@ import{c as e,d as t,f as n,l as r,t as i}from"./dist-B0xJMeoM.mjs";import a fro
|
|
|
68
68
|
|
|
69
69
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=C,s=!v.jitless,c=s&&Ee.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Cn([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function En(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!O(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>A(e,r,y())))}),t)}const Dn=g(`$ZodUnion`,(e,t)=>{I.init(e,t),b(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),b(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),b(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),b(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>xe(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>En(t,r,e,i)):En(o,r,e,i)}}),On=g(`$ZodIntersection`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>An(e,t,n)):An(e,i,a)}});function kn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(w(e)&&w(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=kn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=kn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function An(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),O(e))return e;let o=kn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const jn=g(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=_e(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Oe.has(typeof e)).map(e=>typeof e==`string`?T(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Mn=g(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ge(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new _;return n.value=i,n.fallback=!0,n}});function Nn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Pn=g(`$ZodOptional`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,b(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),b(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${xe(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Nn(e,r)):Nn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Fn=g(`$ZodExactOptional`,(e,t)=>{Pn.init(e,t),b(e._zod,`values`,()=>t.innerType._zod.values),b(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),In=g(`$ZodNullable`,(e,t)=>{I.init(e,t),b(e._zod,`optin`,()=>t.innerType._zod.optin),b(e._zod,`optout`,()=>t.innerType._zod.optout),b(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${xe(e.source)}|null)$`):void 0}),b(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ln=g(`$ZodDefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,b(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Rn(e,t)):Rn(r,t)}});function Rn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const zn=g(`$ZodPrefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,b(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Bn=g(`$ZodNonOptional`,(e,t)=>{I.init(e,t),b(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Vn(t,e)):Vn(i,e)}});function Vn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Hn=g(`$ZodCatch`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,b(e._zod,`optout`,()=>t.innerType._zod.optout),b(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>A(e,n,y()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>A(e,n,y()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Un=g(`$ZodPipe`,(e,t)=>{I.init(e,t),b(e._zod,`values`,()=>t.in._zod.values),b(e._zod,`optin`,()=>t.in._zod.optin),b(e._zod,`optout`,()=>t.out._zod.optout),b(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>z(e,t.in,n)):z(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>z(e,t.out,n)):z(r,t.out,n)}});function z(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const Wn=g(`$ZodReadonly`,(e,t)=>{I.init(e,t),b(e._zod,`propValues`,()=>t.innerType._zod.propValues),b(e._zod,`values`,()=>t.innerType._zod.values),b(e._zod,`optin`,()=>t.innerType?._zod?.optin),b(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Gn):Gn(r)}});function Gn(e){return e.value=Object.freeze(e.value),e}const Kn=g(`$ZodCustom`,(e,t)=>{P.init(e,t),I.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>qn(t,n,r,e));qn(i,n,r,e)}});function qn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(j(e))}}var Jn,Yn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Xn(){return new Yn}(Jn=globalThis).__zod_globalRegistry??(Jn.__zod_globalRegistry=Xn());const B=globalThis.__zod_globalRegistry;function Zn(e,t){return new e({type:`string`,...D(t)})}function Qn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...D(t)})}function $n(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...D(t)})}function er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...D(t)})}function tr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...D(t)})}function nr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...D(t)})}function rr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...D(t)})}function ir(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...D(t)})}function ar(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...D(t)})}function or(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...D(t)})}function sr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...D(t)})}function cr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...D(t)})}function lr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...D(t)})}function ur(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...D(t)})}function dr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...D(t)})}function fr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...D(t)})}function pr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...D(t)})}function mr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...D(t)})}function hr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...D(t)})}function gr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...D(t)})}function _r(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...D(t)})}function vr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...D(t)})}function yr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...D(t)})}function br(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...D(t)})}function xr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...D(t)})}function Sr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...D(t)})}function Cr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...D(t)})}function wr(e,t){return new e({type:`boolean`,...D(t)})}function Tr(e){return new e({type:`unknown`})}function Er(e,t){return new e({type:`never`,...D(t)})}function Dr(e,t){return new jt({check:`max_length`,...D(t),maximum:e})}function V(e,t){return new Mt({check:`min_length`,...D(t),minimum:e})}function Or(e,t){return new Nt({check:`length_equals`,...D(t),length:e})}function kr(e,t){return new Pt({check:`string_format`,format:`regex`,...D(t),pattern:e})}function Ar(e){return new Ft({check:`string_format`,format:`lowercase`,...D(e)})}function jr(e){return new It({check:`string_format`,format:`uppercase`,...D(e)})}function Mr(e,t){return new Lt({check:`string_format`,format:`includes`,...D(t),includes:e})}function Nr(e,t){return new Rt({check:`string_format`,format:`starts_with`,...D(t),prefix:e})}function Pr(e,t){return new zt({check:`string_format`,format:`ends_with`,...D(t),suffix:e})}function H(e){return new Bt({check:`overwrite`,tx:e})}function Fr(e){return H(t=>t.normalize(e))}function Ir(){return H(e=>e.trim())}function Lr(){return H(e=>e.toLowerCase())}function Rr(){return H(e=>e.toUpperCase())}function zr(){return H(e=>we(e))}function Br(e,t,n){return new e({type:`array`,element:t,...D(n)})}function Vr(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...D(n)})}function Hr(e,t){let n=Ur(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(j(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(j(r))}},e(t.value,t)),t);return n}function Ur(e,t){let n=new P({check:`custom`,...D(t)});return n._zod.check=e,n}function Wr(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??B,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function U(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);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,U(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&W(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 Gr(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=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}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+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>
|
|
70
70
|
|
|
71
|
-
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);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Kr(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)):Object.assign(i,s),Object.assign(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??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);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)}Object.assign(i,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??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}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:G(t,`input`,e.processors),output:G(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function W(e,t){let n=t??{seen: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 W(r.element,n);if(r.type===`set`)return W(r.valueType,n);if(r.type===`lazy`)return W(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`)return W(r.innerType,n);if(r.type===`intersection`)return W(r.left,n)||W(r.right,n);if(r.type===`record`||r.type===`map`)return W(r.keyType,n)||W(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:W(r.in,n)||W(r.out,n);if(r.type===`object`){for(let e in r.shape)if(W(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(W(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(W(e,n))return!0;return!!(r.rest&&W(r.rest,n))}return!1}const qr=(e,t={})=>n=>{let r=Wr({...n,processors:t});return U(e,r),Gr(r,e),Kr(r,e)},G=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Wr({...i??{},target:a,io:t,processors:n});return U(e,o),Gr(o,e),Kr(o,e)},Jr={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yr=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jr[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];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}))])}},Xr=(e,t,n,r)=>{n.type=`boolean`},Zr=(e,t,n,r)=>{n.not={}},Qr=(e,t,n,r)=>{let i=e._zod.def,a=_e(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},$r=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ei=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ti=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=U(a.element,t,{...r,path:[...r.path,`items`]})},ni=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=U(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=U(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ri=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>U(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ii=(e,t,n,r)=>{let i=e._zod.def,a=U(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=U(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ai=(e,t,n,r)=>{let i=e._zod.def,a=U(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`}]},oi=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},si=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ci=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},li=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ui=(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;U(o,t,r);let s=t.seen.get(e);s.ref=o},di=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},fi=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pi=g(`ZodISODateTime`,(e,t)=>{tn.init(e,t),Y.init(e,t)});function mi(e){return br(pi,e)}const hi=g(`ZodISODate`,(e,t)=>{nn.init(e,t),Y.init(e,t)});function gi(e){return xr(hi,e)}const _i=g(`ZodISOTime`,(e,t)=>{rn.init(e,t),Y.init(e,t)});function vi(e){return Sr(_i,e)}const yi=g(`ZodISODuration`,(e,t)=>{an.init(e,t),Y.init(e,t)});function bi(e){return Cr(yi,e)}const xi=(e,t)=>{Ve.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>We(e,t)},flatten:{value:t=>Ue(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ve,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ve,2)}},isEmpty:{get(){return e.issues.length===0}}})},Si=g(`ZodError`,xi),K=g(`ZodError`,xi,{Parent:Error}),Ci=Ge(K),wi=Ke(K),Ti=M(K),Ei=N(K),Di=Ye(K),Oi=Xe(K),ki=Ze(K),Ai=Qe(K),ji=$e(K),Mi=et(K),Ni=tt(K),Pi=nt(K),Fi=new WeakMap;function Ii(e,t,n){let r=Object.getPrototypeOf(e),i=Fi.get(r);if(i||(i=new Set,Fi.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const q=g(`ZodType`,(e,t)=>(I.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:G(e,`input`),output:G(e,`output`)}}),e.toJSONSchema=qr(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ci(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ti(e,t,n),e.parseAsync=async(t,n)=>wi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ei(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Di(e,t,n),e.decode=(t,n)=>Oi(e,t,n),e.encodeAsync=async(t,n)=>ki(e,t,n),e.decodeAsync=async(t,n)=>Ai(e,t,n),e.safeEncode=(t,n)=>ji(e,t,n),e.safeDecode=(t,n)=>Mi(e,t,n),e.safeEncodeAsync=async(t,n)=>Ni(e,t,n),e.safeDecodeAsync=async(t,n)=>Pi(e,t,n),Ii(e,`ZodType`,{check(...e){let t=this.def;return this.clone(S(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 E(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(za(e,t))},superRefine(e,t){return this.check(Ba(e,t))},overwrite(e){return this.check(H(e))},optional(){return xa(this)},exactOptional(){return Ca(this)},nullable(){return Ta(this)},nullish(){return xa(Ta(this))},nonoptional(e){return ja(this,e)},array(){return da(this)},or(e){return ma([this,e])},and(e){return ga(this,e)},transform(e){return Fa(this,ya(e))},default(e){return Da(this,e)},prefault(e){return ka(this,e)},catch(e){return Na(this,e)},pipe(e){return Fa(this,e)},readonly(){return La(this)},describe(e){let t=this.clone();return B.add(t,{description:e}),t},meta(...e){if(e.length===0)return B.get(this);let t=this.clone();return B.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return B.get(e)?.description},configurable:!0}),e)),Li=g(`_ZodString`,(e,t)=>{Ut.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yr(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ii(e,`_ZodString`,{regex(...e){return this.check(kr(...e))},includes(...e){return this.check(Mr(...e))},startsWith(...e){return this.check(Nr(...e))},endsWith(...e){return this.check(Pr(...e))},min(...e){return this.check(V(...e))},max(...e){return this.check(Dr(...e))},length(...e){return this.check(Or(...e))},nonempty(...e){return this.check(V(1,...e))},lowercase(e){return this.check(Ar(e))},uppercase(e){return this.check(jr(e))},trim(){return this.check(Ir())},normalize(...e){return this.check(Fr(...e))},toLowerCase(){return this.check(Lr())},toUpperCase(){return this.check(Rr())},slugify(){return this.check(zr())}})}),Ri=g(`ZodString`,(e,t)=>{Ut.init(e,t),Li.init(e,t),e.email=t=>e.check(Qn(zi,t)),e.url=t=>e.check(ir(Hi,t)),e.jwt=t=>e.check(yr(ra,t)),e.emoji=t=>e.check(ar(Ui,t)),e.guid=t=>e.check($n(Bi,t)),e.uuid=t=>e.check(er(Vi,t)),e.uuidv4=t=>e.check(tr(Vi,t)),e.uuidv6=t=>e.check(nr(Vi,t)),e.uuidv7=t=>e.check(rr(Vi,t)),e.nanoid=t=>e.check(or(Wi,t)),e.guid=t=>e.check($n(Bi,t)),e.cuid=t=>e.check(sr(Gi,t)),e.cuid2=t=>e.check(cr(Ki,t)),e.ulid=t=>e.check(lr(qi,t)),e.base64=t=>e.check(gr(ea,t)),e.base64url=t=>e.check(_r(ta,t)),e.xid=t=>e.check(ur(Ji,t)),e.ksuid=t=>e.check(dr(Yi,t)),e.ipv4=t=>e.check(fr(Xi,t)),e.ipv6=t=>e.check(pr(Zi,t)),e.cidrv4=t=>e.check(mr(Qi,t)),e.cidrv6=t=>e.check(hr($i,t)),e.e164=t=>e.check(vr(na,t)),e.datetime=t=>e.check(mi(t)),e.date=t=>e.check(gi(t)),e.time=t=>e.check(vi(t)),e.duration=t=>e.check(bi(t))});function J(e){return Zn(Ri,e)}const Y=g(`ZodStringFormat`,(e,t)=>{L.init(e,t),Li.init(e,t)}),zi=g(`ZodEmail`,(e,t)=>{Kt.init(e,t),Y.init(e,t)}),Bi=g(`ZodGUID`,(e,t)=>{Wt.init(e,t),Y.init(e,t)}),Vi=g(`ZodUUID`,(e,t)=>{Gt.init(e,t),Y.init(e,t)}),Hi=g(`ZodURL`,(e,t)=>{qt.init(e,t),Y.init(e,t)}),Ui=g(`ZodEmoji`,(e,t)=>{Jt.init(e,t),Y.init(e,t)}),Wi=g(`ZodNanoID`,(e,t)=>{Yt.init(e,t),Y.init(e,t)}),Gi=g(`ZodCUID`,(e,t)=>{Xt.init(e,t),Y.init(e,t)}),Ki=g(`ZodCUID2`,(e,t)=>{Zt.init(e,t),Y.init(e,t)}),qi=g(`ZodULID`,(e,t)=>{Qt.init(e,t),Y.init(e,t)}),Ji=g(`ZodXID`,(e,t)=>{$t.init(e,t),Y.init(e,t)}),Yi=g(`ZodKSUID`,(e,t)=>{en.init(e,t),Y.init(e,t)}),Xi=g(`ZodIPv4`,(e,t)=>{on.init(e,t),Y.init(e,t)}),Zi=g(`ZodIPv6`,(e,t)=>{sn.init(e,t),Y.init(e,t)}),Qi=g(`ZodCIDRv4`,(e,t)=>{cn.init(e,t),Y.init(e,t)}),$i=g(`ZodCIDRv6`,(e,t)=>{ln.init(e,t),Y.init(e,t)}),ea=g(`ZodBase64`,(e,t)=>{dn.init(e,t),Y.init(e,t)}),ta=g(`ZodBase64URL`,(e,t)=>{pn.init(e,t),Y.init(e,t)}),na=g(`ZodE164`,(e,t)=>{mn.init(e,t),Y.init(e,t)}),ra=g(`ZodJWT`,(e,t)=>{gn.init(e,t),Y.init(e,t)}),ia=g(`ZodBoolean`,(e,t)=>{_n.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xr(e,t,n,r)});function aa(e){return wr(ia,e)}const oa=g(`ZodUnknown`,(e,t)=>{vn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function sa(){return Tr(oa)}const ca=g(`ZodNever`,(e,t)=>{yn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zr(e,t,n,r)});function la(e){return Er(ca,e)}const ua=g(`ZodArray`,(e,t)=>{xn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ti(e,t,n,r),e.element=t.element,Ii(e,`ZodArray`,{min(e,t){return this.check(V(e,t))},nonempty(e){return this.check(V(1,e))},max(e,t){return this.check(Dr(e,t))},length(e,t){return this.check(Or(e,t))},unwrap(){return this.element}})});function da(e,t){return Br(ua,e,t)}const fa=g(`ZodObject`,(e,t)=>{Tn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ni(e,t,n,r),b(e,`shape`,()=>t.shape),Ii(e,`ZodObject`,{keyof(){return Z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:sa()})},loose(){return this.clone({...this._zod.def,catchall:sa()})},strict(){return this.clone({...this._zod.def,catchall:la()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Me(this,e)},safeExtend(e){return Ne(this,e)},merge(e){return Pe(this,e)},pick(e){return Ae(this,e)},omit(e){return je(this,e)},partial(...e){return Fe(ba,this,e[0])},required(...e){return Ie(Aa,this,e[0])}})});function X(e,t){let n={type:`object`,shape:e??{},...D(t)};return new fa(n)}const pa=g(`ZodUnion`,(e,t)=>{Dn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ri(e,t,n,r),e.options=t.options});function ma(e,t){return new pa({type:`union`,options:e,...D(t)})}const ha=g(`ZodIntersection`,(e,t)=>{On.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ii(e,t,n,r)});function ga(e,t){return new ha({type:`intersection`,left:e,right:t})}const _a=g(`ZodEnum`,(e,t)=>{jn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qr(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);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 _a({...t,checks:[],...D(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 _a({...t,checks:[],...D(r),entries:i})}});function Z(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new _a({type:`enum`,entries:n,...D(t)})}const va=g(`ZodTransform`,(e,t)=>{Mn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ei(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ge(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(j(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(j(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function ya(e){return new va({type:`transform`,transform:e})}const ba=g(`ZodOptional`,(e,t)=>{Pn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xa(e){return new ba({type:`optional`,innerType:e})}const Sa=g(`ZodExactOptional`,(e,t)=>{Fn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ca(e){return new Sa({type:`optional`,innerType:e})}const wa=g(`ZodNullable`,(e,t)=>{In.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ta(e){return new wa({type:`nullable`,innerType:e})}const Ea=g(`ZodDefault`,(e,t)=>{Ln.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>si(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Da(e,t){return new Ea({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():De(t)}})}const Oa=g(`ZodPrefault`,(e,t)=>{zn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ci(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ka(e,t){return new Oa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():De(t)}})}const Aa=g(`ZodNonOptional`,(e,t)=>{Bn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ja(e,t){return new Aa({type:`nonoptional`,innerType:e,...D(t)})}const Ma=g(`ZodCatch`,(e,t)=>{Hn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>li(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Na(e,t){return new Ma({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Pa=g(`ZodPipe`,(e,t)=>{Un.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ui(e,t,n,r),e.in=t.in,e.out=t.out});function Fa(e,t){return new Pa({type:`pipe`,in:e,out:t})}const Ia=g(`ZodReadonly`,(e,t)=>{Wn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>di(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function La(e){return new Ia({type:`readonly`,innerType:e})}const Ra=g(`ZodCustom`,(e,t)=>{Kn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$r(e,t,n,r)});function za(e,t={}){return Vr(Ra,e,t)}function Ba(e,t){return Hr(e,t)}const Va=5*1024*1024,Ha=`输入内容不能超过 5MB`,Q={name:`output`,description:`输出文件,默认输出到 stdout`,type:`string`,input:!1,valueName:`file`},Ua={name:`extract`,title:`提取 Markdown 纯文本`,description:`从 Markdown 文档中提取纯文本内容,移除所有格式标记(如标题符号、链接、图片、代码块等)。适用于字数统计、文本分析、生成摘要、或作为语音朗读的输入。`,inputSchema:X({markdown:J().max(Va,Ha).describe(`要提取文本的 Markdown 源文本`)}),outputSchema:X({result:J().describe(`提取后的纯文本内容,保留段落分隔,已移除所有 Markdown 格式标记`)}),cli:{inputField:`markdown`,inputLabel:`file`,options:[Q]}},Wa={name:`lint`,title:`校验并修复 Markdown`,description:`使用 markdownlint 规则对 Markdown 内容进行规范校验,并自动修复可修复的问题。包括:统一标题层级、修复列表缩进、规范空行、移除行尾空格等。`,inputSchema:X({markdown:J().max(Va,Ha).describe(`要校验和修复的 Markdown 源文本`)}),outputSchema:X({result:J().describe(`校验并自动修复后的 Markdown 文本`)}),cli:{inputField:`markdown`,inputLabel:`file`,options:[Q,{name:`fix`,description:`将修复结果写回输入文件;不能与 --output 同时使用`,type:`boolean`,input:!1}]}},Ga={name:`parse`,title:`解析 HTML 为 Markdown`,description:`将 HTML 内容反向转换为 Markdown 格式。适用于从网页复制内容、导入已有文章、或将富文本转换为 Markdown 进行编辑。会自动清理不安全的 HTML 标签。`,inputSchema:X({html:J().max(Va,Ha).describe(`要转换的 HTML 源代码,可以是完整文档或 HTML 片段`)}),outputSchema:X({result:J().describe(`转换后的 Markdown 文本,使用 - 作为无序列表标记`)}),cli:{inputField:`html`,inputLabel:`file`,options:[Q]}},Ka=[{id:`catppuccin-frappe`,name:`Catppuccin Frappé`,isDark:!0},{id:`catppuccin-latte`,name:`Catppuccin Latte`,isDark:!1},{id:`catppuccin-macchiato`,name:`Catppuccin Macchiato`,isDark:!0},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,isDark:!0},{id:`kimbie-dark`,name:`Kimbie Dark`,isDark:!0},{id:`kimbie-light`,name:`Kimbie Light`,isDark:!1},{id:`panda-syntax-dark`,name:`Panda Syntax Dark`,isDark:!0},{id:`panda-syntax-light`,name:`Panda Syntax Light`,isDark:!1},{id:`paraiso-dark`,name:`Paraiso Dark`,isDark:!0},{id:`paraiso-light`,name:`Paraiso Light`,isDark:!1},{id:`rose-pine`,name:`Rosé Pine`,isDark:!0},{id:`rose-pine-dawn`,name:`Rosé Pine Dawn`,isDark:!1},{id:`tokyo-night-dark`,name:`Tokyo Night Dark`,isDark:!0},{id:`tokyo-night-light`,name:`Tokyo Night Light`,isDark:!1}].map(e=>e.id);function qa(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Ja(e){let t=e.bg.replace(`#`,``),n=Number.parseInt(t.slice(0,2),16),r=Number.parseInt(t.slice(2,4),16),i=Number.parseInt(t.slice(4,6),16);return(.2126*n+.7152*r+.0722*i)/255<.5}const Ya=[{id:``,name:`Default`,isDark:!1},...Object.keys(i).sort().map(e=>({id:e,name:qa(e),isDark:Ja(i[e])}))].map(e=>e.id),Xa=[`html`,`wechat`],Za=Z(Xa),Qa=Z(r),$a=Z(Ka),eo=Z(Ya),to=Z(n),no=Z(t),ro={name:`render`,title:`渲染 Markdown 为 HTML`,description:`将 Markdown 内容渲染为适用于不同平台的 HTML 片段。支持 GFM 语法、数学公式(KaTeX)、代码高亮,并自动将 CSS 样式内联到元素上,确保在微信公众号等富文本编辑器中正确显示。`,inputSchema:X({markdown:J().max(Va,Ha).describe(`要渲染的 Markdown 源文本,支持 GFM(GitHub Flavored Markdown)语法、数学公式($..$ 或 $$..$$)`),markdownStyle:Qa.optional().default(e).describe(`Markdown 排版样式 ID`),codeTheme:$a.optional().default(`kimbie-light`).describe(`代码块高亮主题 ID`),mermaidTheme:eo.optional().default(``).describe(`Mermaid 流程图主题 ID,空字符串表示使用默认主题`),infographicTheme:to.optional().default(`default`).describe(`Infographic 信息图主题 ID`),infographicPalette:no.optional().default(`antv`).describe(`Infographic 信息图配色 ID`),customCss:J().max(5e4,`自定义 CSS 不能超过 50000 字符`).optional().default(``).describe(`自定义 CSS 样式,在主题样式之后应用。选择器需约束在 #bm-md 下,例如:#bm-md h1 { color: red; }`),enableFootnoteLinks:aa().optional().default(!0).describe(`是否将文中链接自动转换为脚注形式,便于阅读时查看原始链接`),openLinksInNewWindow:aa().optional().default(!0).describe(`是否为所有外部链接添加 target="_blank",在新窗口打开`),platform:Za.optional().default(`html`).describe(`目标发布平台。wechat 会进行微信公众号适配,html 使用通用 HTML 输出`),footnoteLabel:J().max(50).optional().default(`Footnotes`).describe(`GFM 脚注区域标题`),referenceTitle:J().max(50).optional().default(`References`).describe(`外部链接参考区域标题`)}),outputSchema:X({result:J().describe(`渲染后的 HTML 片段,CSS 样式已内联到元素上,可直接复制粘贴到富文本编辑器`)}),cli:{inputField:`markdown`,inputLabel:`file`,options:[Q,{name:`platform`,description:`目标发布平台`,type:`string`,choices:Xa,valueName:`platform`},{name:`markdownStyle`,description:`Markdown 排版样式 ID`,type:`string`,choices:r,valueName:`id`},{name:`codeTheme`,description:`代码块高亮主题 ID`,type:`string`,choices:Ka,valueName:`id`},{name:`mermaidTheme`,description:`Mermaid 流程图主题 ID,留空表示使用默认主题`,type:`string`,choices:Ya,valueName:`id`},{name:`infographicTheme`,description:`Infographic 信息图主题 ID`,type:`string`,choices:n,valueName:`id`},{name:`infographicPalette`,description:`Infographic 信息图配色 ID`,type:`string`,choices:t,valueName:`id`},{name:`customCss`,description:`追加自定义 CSS`,type:`string`,valueName:`css`},{name:`customCssFile`,description:`从文件追加自定义 CSS`,type:`string`,input:!1,valueName:`file`},{name:`enableFootnoteLinks`,description:`关闭文中链接脚注转换`,type:`boolean`,cliKey:`footnoteLinks`,flag:`no-footnote-links`},{name:`openLinksInNewWindow`,description:`关闭外部链接新窗口打开`,type:`boolean`,cliKey:`openLinks`,flag:`no-open-links`},{name:`footnoteLabel`,description:`GFM 脚注区域标题`,type:`string`,valueName:`text`},{name:`referenceTitle`,description:`外部链接参考区域标题`,type:`string`,valueName:`text`}]}};function io(e,t){return{...e,run:t}}const ao=[io(ro,async e=>{let{render:t}=await import(`./html-BUXlQGSS.mjs`);return t(e)}),io(Ga,async e=>{let{parse:t}=await import(`./html-CSUv3zEC.mjs`);return t(e.html)}),io(Ua,async e=>{let{extract:t}=await import(`./text-CtjMWodY.mjs`);return t(e.markdown)}),io(Wa,async e=>{let{lint:t}=await import(`./markdown-KovTQZtX.mjs`);return t(e.markdown)})];function oo(e,t){let n=e.run;return n(t)}const so=ao;function co(e){return e instanceof Si?e.issues.map(e=>`${e.path.join(`.`)||`input`}: ${e.message}`).join(`
|
|
71
|
+
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);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Kr(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)):Object.assign(i,s),Object.assign(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??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);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)}Object.assign(i,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??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}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:G(t,`input`,e.processors),output:G(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function W(e,t){let n=t??{seen: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 W(r.element,n);if(r.type===`set`)return W(r.valueType,n);if(r.type===`lazy`)return W(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`)return W(r.innerType,n);if(r.type===`intersection`)return W(r.left,n)||W(r.right,n);if(r.type===`record`||r.type===`map`)return W(r.keyType,n)||W(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:W(r.in,n)||W(r.out,n);if(r.type===`object`){for(let e in r.shape)if(W(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(W(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(W(e,n))return!0;return!!(r.rest&&W(r.rest,n))}return!1}const qr=(e,t={})=>n=>{let r=Wr({...n,processors:t});return U(e,r),Gr(r,e),Kr(r,e)},G=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Wr({...i??{},target:a,io:t,processors:n});return U(e,o),Gr(o,e),Kr(o,e)},Jr={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yr=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jr[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];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}))])}},Xr=(e,t,n,r)=>{n.type=`boolean`},Zr=(e,t,n,r)=>{n.not={}},Qr=(e,t,n,r)=>{let i=e._zod.def,a=_e(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},$r=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ei=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ti=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=U(a.element,t,{...r,path:[...r.path,`items`]})},ni=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=U(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=U(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ri=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>U(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ii=(e,t,n,r)=>{let i=e._zod.def,a=U(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=U(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ai=(e,t,n,r)=>{let i=e._zod.def,a=U(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`}]},oi=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},si=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ci=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},li=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ui=(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;U(o,t,r);let s=t.seen.get(e);s.ref=o},di=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},fi=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pi=g(`ZodISODateTime`,(e,t)=>{tn.init(e,t),Y.init(e,t)});function mi(e){return br(pi,e)}const hi=g(`ZodISODate`,(e,t)=>{nn.init(e,t),Y.init(e,t)});function gi(e){return xr(hi,e)}const _i=g(`ZodISOTime`,(e,t)=>{rn.init(e,t),Y.init(e,t)});function vi(e){return Sr(_i,e)}const yi=g(`ZodISODuration`,(e,t)=>{an.init(e,t),Y.init(e,t)});function bi(e){return Cr(yi,e)}const xi=(e,t)=>{Ve.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>We(e,t)},flatten:{value:t=>Ue(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ve,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ve,2)}},isEmpty:{get(){return e.issues.length===0}}})},Si=g(`ZodError`,xi),K=g(`ZodError`,xi,{Parent:Error}),Ci=Ge(K),wi=Ke(K),Ti=M(K),Ei=N(K),Di=Ye(K),Oi=Xe(K),ki=Ze(K),Ai=Qe(K),ji=$e(K),Mi=et(K),Ni=tt(K),Pi=nt(K),Fi=new WeakMap;function Ii(e,t,n){let r=Object.getPrototypeOf(e),i=Fi.get(r);if(i||(i=new Set,Fi.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const q=g(`ZodType`,(e,t)=>(I.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:G(e,`input`),output:G(e,`output`)}}),e.toJSONSchema=qr(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ci(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ti(e,t,n),e.parseAsync=async(t,n)=>wi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ei(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Di(e,t,n),e.decode=(t,n)=>Oi(e,t,n),e.encodeAsync=async(t,n)=>ki(e,t,n),e.decodeAsync=async(t,n)=>Ai(e,t,n),e.safeEncode=(t,n)=>ji(e,t,n),e.safeDecode=(t,n)=>Mi(e,t,n),e.safeEncodeAsync=async(t,n)=>Ni(e,t,n),e.safeDecodeAsync=async(t,n)=>Pi(e,t,n),Ii(e,`ZodType`,{check(...e){let t=this.def;return this.clone(S(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 E(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(za(e,t))},superRefine(e,t){return this.check(Ba(e,t))},overwrite(e){return this.check(H(e))},optional(){return xa(this)},exactOptional(){return Ca(this)},nullable(){return Ta(this)},nullish(){return xa(Ta(this))},nonoptional(e){return ja(this,e)},array(){return da(this)},or(e){return ma([this,e])},and(e){return ga(this,e)},transform(e){return Fa(this,ya(e))},default(e){return Da(this,e)},prefault(e){return ka(this,e)},catch(e){return Na(this,e)},pipe(e){return Fa(this,e)},readonly(){return La(this)},describe(e){let t=this.clone();return B.add(t,{description:e}),t},meta(...e){if(e.length===0)return B.get(this);let t=this.clone();return B.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return B.get(e)?.description},configurable:!0}),e)),Li=g(`_ZodString`,(e,t)=>{Ut.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yr(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ii(e,`_ZodString`,{regex(...e){return this.check(kr(...e))},includes(...e){return this.check(Mr(...e))},startsWith(...e){return this.check(Nr(...e))},endsWith(...e){return this.check(Pr(...e))},min(...e){return this.check(V(...e))},max(...e){return this.check(Dr(...e))},length(...e){return this.check(Or(...e))},nonempty(...e){return this.check(V(1,...e))},lowercase(e){return this.check(Ar(e))},uppercase(e){return this.check(jr(e))},trim(){return this.check(Ir())},normalize(...e){return this.check(Fr(...e))},toLowerCase(){return this.check(Lr())},toUpperCase(){return this.check(Rr())},slugify(){return this.check(zr())}})}),Ri=g(`ZodString`,(e,t)=>{Ut.init(e,t),Li.init(e,t),e.email=t=>e.check(Qn(zi,t)),e.url=t=>e.check(ir(Hi,t)),e.jwt=t=>e.check(yr(ra,t)),e.emoji=t=>e.check(ar(Ui,t)),e.guid=t=>e.check($n(Bi,t)),e.uuid=t=>e.check(er(Vi,t)),e.uuidv4=t=>e.check(tr(Vi,t)),e.uuidv6=t=>e.check(nr(Vi,t)),e.uuidv7=t=>e.check(rr(Vi,t)),e.nanoid=t=>e.check(or(Wi,t)),e.guid=t=>e.check($n(Bi,t)),e.cuid=t=>e.check(sr(Gi,t)),e.cuid2=t=>e.check(cr(Ki,t)),e.ulid=t=>e.check(lr(qi,t)),e.base64=t=>e.check(gr(ea,t)),e.base64url=t=>e.check(_r(ta,t)),e.xid=t=>e.check(ur(Ji,t)),e.ksuid=t=>e.check(dr(Yi,t)),e.ipv4=t=>e.check(fr(Xi,t)),e.ipv6=t=>e.check(pr(Zi,t)),e.cidrv4=t=>e.check(mr(Qi,t)),e.cidrv6=t=>e.check(hr($i,t)),e.e164=t=>e.check(vr(na,t)),e.datetime=t=>e.check(mi(t)),e.date=t=>e.check(gi(t)),e.time=t=>e.check(vi(t)),e.duration=t=>e.check(bi(t))});function J(e){return Zn(Ri,e)}const Y=g(`ZodStringFormat`,(e,t)=>{L.init(e,t),Li.init(e,t)}),zi=g(`ZodEmail`,(e,t)=>{Kt.init(e,t),Y.init(e,t)}),Bi=g(`ZodGUID`,(e,t)=>{Wt.init(e,t),Y.init(e,t)}),Vi=g(`ZodUUID`,(e,t)=>{Gt.init(e,t),Y.init(e,t)}),Hi=g(`ZodURL`,(e,t)=>{qt.init(e,t),Y.init(e,t)}),Ui=g(`ZodEmoji`,(e,t)=>{Jt.init(e,t),Y.init(e,t)}),Wi=g(`ZodNanoID`,(e,t)=>{Yt.init(e,t),Y.init(e,t)}),Gi=g(`ZodCUID`,(e,t)=>{Xt.init(e,t),Y.init(e,t)}),Ki=g(`ZodCUID2`,(e,t)=>{Zt.init(e,t),Y.init(e,t)}),qi=g(`ZodULID`,(e,t)=>{Qt.init(e,t),Y.init(e,t)}),Ji=g(`ZodXID`,(e,t)=>{$t.init(e,t),Y.init(e,t)}),Yi=g(`ZodKSUID`,(e,t)=>{en.init(e,t),Y.init(e,t)}),Xi=g(`ZodIPv4`,(e,t)=>{on.init(e,t),Y.init(e,t)}),Zi=g(`ZodIPv6`,(e,t)=>{sn.init(e,t),Y.init(e,t)}),Qi=g(`ZodCIDRv4`,(e,t)=>{cn.init(e,t),Y.init(e,t)}),$i=g(`ZodCIDRv6`,(e,t)=>{ln.init(e,t),Y.init(e,t)}),ea=g(`ZodBase64`,(e,t)=>{dn.init(e,t),Y.init(e,t)}),ta=g(`ZodBase64URL`,(e,t)=>{pn.init(e,t),Y.init(e,t)}),na=g(`ZodE164`,(e,t)=>{mn.init(e,t),Y.init(e,t)}),ra=g(`ZodJWT`,(e,t)=>{gn.init(e,t),Y.init(e,t)}),ia=g(`ZodBoolean`,(e,t)=>{_n.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xr(e,t,n,r)});function aa(e){return wr(ia,e)}const oa=g(`ZodUnknown`,(e,t)=>{vn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function sa(){return Tr(oa)}const ca=g(`ZodNever`,(e,t)=>{yn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zr(e,t,n,r)});function la(e){return Er(ca,e)}const ua=g(`ZodArray`,(e,t)=>{xn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ti(e,t,n,r),e.element=t.element,Ii(e,`ZodArray`,{min(e,t){return this.check(V(e,t))},nonempty(e){return this.check(V(1,e))},max(e,t){return this.check(Dr(e,t))},length(e,t){return this.check(Or(e,t))},unwrap(){return this.element}})});function da(e,t){return Br(ua,e,t)}const fa=g(`ZodObject`,(e,t)=>{Tn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ni(e,t,n,r),b(e,`shape`,()=>t.shape),Ii(e,`ZodObject`,{keyof(){return Z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:sa()})},loose(){return this.clone({...this._zod.def,catchall:sa()})},strict(){return this.clone({...this._zod.def,catchall:la()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Me(this,e)},safeExtend(e){return Ne(this,e)},merge(e){return Pe(this,e)},pick(e){return Ae(this,e)},omit(e){return je(this,e)},partial(...e){return Fe(ba,this,e[0])},required(...e){return Ie(Aa,this,e[0])}})});function X(e,t){let n={type:`object`,shape:e??{},...D(t)};return new fa(n)}const pa=g(`ZodUnion`,(e,t)=>{Dn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ri(e,t,n,r),e.options=t.options});function ma(e,t){return new pa({type:`union`,options:e,...D(t)})}const ha=g(`ZodIntersection`,(e,t)=>{On.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ii(e,t,n,r)});function ga(e,t){return new ha({type:`intersection`,left:e,right:t})}const _a=g(`ZodEnum`,(e,t)=>{jn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qr(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);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 _a({...t,checks:[],...D(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 _a({...t,checks:[],...D(r),entries:i})}});function Z(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new _a({type:`enum`,entries:n,...D(t)})}const va=g(`ZodTransform`,(e,t)=>{Mn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ei(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ge(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(j(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(j(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function ya(e){return new va({type:`transform`,transform:e})}const ba=g(`ZodOptional`,(e,t)=>{Pn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xa(e){return new ba({type:`optional`,innerType:e})}const Sa=g(`ZodExactOptional`,(e,t)=>{Fn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ca(e){return new Sa({type:`optional`,innerType:e})}const wa=g(`ZodNullable`,(e,t)=>{In.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ta(e){return new wa({type:`nullable`,innerType:e})}const Ea=g(`ZodDefault`,(e,t)=>{Ln.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>si(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Da(e,t){return new Ea({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():De(t)}})}const Oa=g(`ZodPrefault`,(e,t)=>{zn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ci(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ka(e,t){return new Oa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():De(t)}})}const Aa=g(`ZodNonOptional`,(e,t)=>{Bn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ja(e,t){return new Aa({type:`nonoptional`,innerType:e,...D(t)})}const Ma=g(`ZodCatch`,(e,t)=>{Hn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>li(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Na(e,t){return new Ma({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Pa=g(`ZodPipe`,(e,t)=>{Un.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ui(e,t,n,r),e.in=t.in,e.out=t.out});function Fa(e,t){return new Pa({type:`pipe`,in:e,out:t})}const Ia=g(`ZodReadonly`,(e,t)=>{Wn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>di(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function La(e){return new Ia({type:`readonly`,innerType:e})}const Ra=g(`ZodCustom`,(e,t)=>{Kn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$r(e,t,n,r)});function za(e,t={}){return Vr(Ra,e,t)}function Ba(e,t){return Hr(e,t)}const Va=5*1024*1024,Ha=`输入内容不能超过 5MB`,Q={name:`output`,description:`输出文件,默认输出到 stdout`,type:`string`,input:!1,valueName:`file`},Ua={name:`extract`,title:`提取 Markdown 纯文本`,description:`从 Markdown 文档中提取纯文本内容,移除所有格式标记(如标题符号、链接、图片、代码块等)。适用于字数统计、文本分析、生成摘要、或作为语音朗读的输入。`,inputSchema:X({markdown:J().max(Va,Ha).describe(`要提取文本的 Markdown 源文本`)}),outputSchema:X({result:J().describe(`提取后的纯文本内容,保留段落分隔,已移除所有 Markdown 格式标记`)}),cli:{inputField:`markdown`,inputLabel:`file`,options:[Q]}},Wa={name:`lint`,title:`校验并修复 Markdown`,description:`使用 markdownlint 规则对 Markdown 内容进行规范校验,并自动修复可修复的问题。包括:统一标题层级、修复列表缩进、规范空行、移除行尾空格等。`,inputSchema:X({markdown:J().max(Va,Ha).describe(`要校验和修复的 Markdown 源文本`)}),outputSchema:X({result:J().describe(`校验并自动修复后的 Markdown 文本`)}),cli:{inputField:`markdown`,inputLabel:`file`,options:[Q,{name:`fix`,description:`将修复结果写回输入文件;不能与 --output 同时使用`,type:`boolean`,input:!1}]}},Ga={name:`parse`,title:`解析 HTML 为 Markdown`,description:`将 HTML 内容反向转换为 Markdown 格式。适用于从网页复制内容、导入已有文章、或将富文本转换为 Markdown 进行编辑。会自动清理不安全的 HTML 标签。`,inputSchema:X({html:J().max(Va,Ha).describe(`要转换的 HTML 源代码,可以是完整文档或 HTML 片段`)}),outputSchema:X({result:J().describe(`转换后的 Markdown 文本,使用 - 作为无序列表标记`)}),cli:{inputField:`html`,inputLabel:`file`,options:[Q]}},Ka=[{id:`catppuccin-frappe`,name:`Catppuccin Frappé`,isDark:!0},{id:`catppuccin-latte`,name:`Catppuccin Latte`,isDark:!1},{id:`catppuccin-macchiato`,name:`Catppuccin Macchiato`,isDark:!0},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,isDark:!0},{id:`kimbie-dark`,name:`Kimbie Dark`,isDark:!0},{id:`kimbie-light`,name:`Kimbie Light`,isDark:!1},{id:`panda-syntax-dark`,name:`Panda Syntax Dark`,isDark:!0},{id:`panda-syntax-light`,name:`Panda Syntax Light`,isDark:!1},{id:`paraiso-dark`,name:`Paraiso Dark`,isDark:!0},{id:`paraiso-light`,name:`Paraiso Light`,isDark:!1},{id:`rose-pine`,name:`Rosé Pine`,isDark:!0},{id:`rose-pine-dawn`,name:`Rosé Pine Dawn`,isDark:!1},{id:`tokyo-night-dark`,name:`Tokyo Night Dark`,isDark:!0},{id:`tokyo-night-light`,name:`Tokyo Night Light`,isDark:!1}].map(e=>e.id);function qa(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Ja(e){let t=e.bg.replace(`#`,``),n=Number.parseInt(t.slice(0,2),16),r=Number.parseInt(t.slice(2,4),16),i=Number.parseInt(t.slice(4,6),16);return(.2126*n+.7152*r+.0722*i)/255<.5}const Ya=[{id:``,name:`Default`,isDark:!1},...Object.keys(i).sort().map(e=>({id:e,name:qa(e),isDark:Ja(i[e])}))].map(e=>e.id),Xa=[`html`,`wechat`],Za=Z(Xa),Qa=Z(e),$a=Z(Ka),eo=Z(Ya),to=Z(r),no=Z(t),ro={name:`render`,title:`渲染 Markdown 为 HTML`,description:`将 Markdown 内容渲染为适用于不同平台的 HTML 片段。支持 GFM 语法、数学公式(KaTeX)、代码高亮,并自动将 CSS 样式内联到元素上,确保在微信公众号等富文本编辑器中正确显示。`,inputSchema:X({markdown:J().max(Va,Ha).describe(`要渲染的 Markdown 源文本,支持 GFM(GitHub Flavored Markdown)语法、数学公式($..$ 或 $$..$$)`),markdownStyle:Qa.optional().default(n).describe(`Markdown 排版样式 ID`),codeTheme:$a.optional().default(`kimbie-light`).describe(`代码块高亮主题 ID`),mermaidTheme:eo.optional().default(``).describe(`Mermaid 流程图主题 ID,空字符串表示使用默认主题`),infographicTheme:to.optional().default(`default`).describe(`Infographic 信息图主题 ID`),infographicPalette:no.optional().default(`antv`).describe(`Infographic 信息图配色 ID`),customCss:J().max(5e4,`自定义 CSS 不能超过 50000 字符`).optional().default(``).describe(`自定义 CSS 样式,在主题样式之后应用。选择器需约束在 #bm-md 下,例如:#bm-md h1 { color: red; }`),enableFootnoteLinks:aa().optional().default(!0).describe(`是否将文中链接自动转换为脚注形式,便于阅读时查看原始链接`),openLinksInNewWindow:aa().optional().default(!0).describe(`是否为所有外部链接添加 target="_blank",在新窗口打开`),platform:Za.optional().default(`html`).describe(`目标发布平台。wechat 会进行微信公众号适配,html 使用通用 HTML 输出`),footnoteLabel:J().max(50).optional().default(`Footnotes`).describe(`GFM 脚注区域标题`),referenceTitle:J().max(50).optional().default(`References`).describe(`外部链接参考区域标题`)}),outputSchema:X({result:J().describe(`渲染后的 HTML 片段,CSS 样式已内联到元素上,可直接复制粘贴到富文本编辑器`)}),cli:{inputField:`markdown`,inputLabel:`file`,options:[Q,{name:`platform`,description:`目标发布平台`,type:`string`,choices:Xa,valueName:`platform`},{name:`markdownStyle`,description:`Markdown 排版样式 ID`,type:`string`,choices:e,valueName:`id`},{name:`codeTheme`,description:`代码块高亮主题 ID`,type:`string`,choices:Ka,valueName:`id`},{name:`mermaidTheme`,description:`Mermaid 流程图主题 ID,留空表示使用默认主题`,type:`string`,choices:Ya,valueName:`id`},{name:`infographicTheme`,description:`Infographic 信息图主题 ID`,type:`string`,choices:r,valueName:`id`},{name:`infographicPalette`,description:`Infographic 信息图配色 ID`,type:`string`,choices:t,valueName:`id`},{name:`customCss`,description:`追加自定义 CSS`,type:`string`,valueName:`css`},{name:`customCssFile`,description:`从文件追加自定义 CSS`,type:`string`,input:!1,valueName:`file`},{name:`enableFootnoteLinks`,description:`关闭文中链接脚注转换`,type:`boolean`,cliKey:`footnoteLinks`,flag:`no-footnote-links`},{name:`openLinksInNewWindow`,description:`关闭外部链接新窗口打开`,type:`boolean`,cliKey:`openLinks`,flag:`no-open-links`},{name:`footnoteLabel`,description:`GFM 脚注区域标题`,type:`string`,valueName:`text`},{name:`referenceTitle`,description:`外部链接参考区域标题`,type:`string`,valueName:`text`}]}};function io(e,t){return{...e,run:t}}const ao=[io(ro,async e=>{let{render:t}=await import(`./html-CGVTbdd7.mjs`);return t(e)}),io(Ga,async e=>{let{parse:t}=await import(`./html-CSUv3zEC.mjs`);return t(e.html)}),io(Ua,async e=>{let{extract:t}=await import(`./text-CtjMWodY.mjs`);return t(e.markdown)}),io(Wa,async e=>{let{lint:t}=await import(`./markdown-KovTQZtX.mjs`);return t(e.markdown)})];function oo(e,t){let n=e.run;return n(t)}const so=ao;function co(e){return e instanceof Si?e.issues.map(e=>`${e.path.join(`.`)||`input`}: ${e.message}`).join(`
|
|
72
72
|
`):e instanceof Error?e.message:String(e)}function lo(e,t){let n=t.flag??t.name.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),r=t.type===`boolean`?`--${n}`:`--${n} <${t.valueName??n}>`,i=t.choices?.filter(Boolean),a=i?.length?`${t.description}(可选值: ${i.join(`, `)})`:t.description;e.option(r,a)}async function uo(e){if(e)return o(e,`utf8`);if(a.stdin.isTTY)throw Error(`请提供输入文件,或通过 stdin 传入内容`);let t=``;a.stdin.setEncoding(`utf8`);for await(let e of a.stdin)t+=String(e);return t}async function fo(e,t){if(t){await s(t,e);return}a.stdout.write(e)}async function po(e,t,n){let r={[e.cli.inputField]:await uo(t)};for(let t of e.cli.options){if(t.input===!1)continue;let e=n[t.cliKey??t.name];e!==void 0&&(r[t.name]=e)}if(e.name===`render`){let e=typeof n.customCssFile==`string`&&n.customCssFile.length>0?n.customCssFile:void 0;e&&(r.customCss=[typeof r.customCss==`string`?r.customCss:``,await o(e,`utf8`)].filter(Boolean).join(`
|
|
73
73
|
`))}return r}async function mo(e,t,n){let r=typeof n.output==`string`&&n.output.length>0?n.output:void 0,i=n.fix===!0;if(e.name===`lint`&&i){if(!t)throw Error(`--fix 需要提供输入文件`);if(r)throw Error(`--fix 不能与 --output 同时使用`)}let a=await po(e,t,n),o=await oo(e,e.inputSchema.parse(a));if(e.name===`lint`&&i){await fo(o,t);return}await fo(o,r)}const $=fe(`bmmd`);function ho(e){e().catch(e=>{console.error(`bmmd: ${co(e)}`),a.exitCode=1})}for(let e of so){let t=$.command(`${e.name} [${e.cli.inputLabel}]`,e.description);for(let n of e.cli.options)lo(t,n);t.action((t,n)=>ho(()=>mo(e,t,n)))}$.help(e=>{let t=$.matchedCommandName&&$.matchedCommand?.description?$.matchedCommand.description:me,n=e.findIndex(e=>e.body.includes(pe));e.splice(n+1,0,{body:t})}),$.version(pe,`--version`),a.argv.length<=2?$.outputHelp():$.parse();export{};
|