@cherwell/emdash-plausible 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,56 @@
1
+ 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 t(e,t=`|`){return e.map(e=>ae(e)).join(t)}function n(e,t){return typeof t==`bigint`?t.toString():t}var r=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function i(e){return new r(e)}function a(e){return e==null}function o(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function s(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function c(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function l(e){return c(e._zod.def)??e._zod.def.shape}function u(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return s(this,t,e),e},enumerable:!0,configurable:!0})}function d(e,t,n){t in e?s(e,t,n):e[t]=n}function f(e,t,n,r){let i=l(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?u(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):d(e,a,r?r(n.value,a):n.value))}}function p(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?u(e,n,()=>t[n]):d(e,n,r.value))}}function m(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function h(e){return JSON.stringify(e)}const ee=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const te=i(()=>{if(A.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function _(e){if(g(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(g(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ne(e){return _(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const re=new Set([`string`,`number`,`symbol`]);function ie(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function v(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function y(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 ae(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function oe(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}const se={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ce={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function le(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`);let i={};return f(i,e,b(e,t)),v(e,m(n,{shape:i,checks:[]}))}function b(e,t){let n=l(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function ue(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`);let i=new Set(b(e,t)),a={};return f(a,e,Reflect.ownKeys(l(e)).filter(e=>!i.has(e))),v(e,m(n,{shape:a,checks:[]}))}function de(e,t){if(!_(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=l(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return v(e,m(e._zod.def,{shape:fe(e,t)}))}function fe(e,t){let n={};return f(n,e,Reflect.ownKeys(l(e))),p(n,t),n}function pe(e,t){if(!_(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return v(e,m(e._zod.def,{shape:fe(e,t)}))}function me(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return f(n,e,Reflect.ownKeys(l(e))),f(n,t,Reflect.ownKeys(l(t))),v(e,m(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function he(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(b(t,n)):void 0,o={};return f(o,t,Reflect.ownKeys(l(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),v(t,m(t._zod.def,{shape:o,checks:[]}))}function ge(e,t,n){let r=n?new Set(b(t,n)):void 0,i={};return f(i,t,Reflect.ownKeys(l(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),v(t,m(t._zod.def,{shape:i}))}function x(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 _e(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 ve(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function S(e){return typeof e==`string`?e:e?.message}function ye(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function be(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function C(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:S(e.inst?._zod.def?.error?.(e))??S(a?.(e))??S(t?.error?.(e))??S(n.customError?.(e))??S(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t===`inst`||t===`schema`||t===`continue`||t===`input`||t===`__proto__`||(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}const xe=/[\uD800-\uDBFF]/;function Se(e){let t=e.length;if(!xe.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Ce(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function we(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function w(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Te(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):De(e,n,r.value)}}function T(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ee(e,t,n){return T(e,t,n,!1)}function De(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:T(this,t,n.bind(this))},set(e){T(this,t,e)}})}function Oe(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let ke,E=!1;const Ae={configurable:!0,get(){E=!0}};function D(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&ke!==e._zod){ke=void 0;return}ke=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Ae);let e=E;E=!1;try{let r=n(this);return E?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),E||=e,r}catch(n){throw delete this[t],E||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function je(e,t,n,r){let i=Oe(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function Me(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var Ne;const Pe={value:void 0,enumerable:!1};let Fe=`captureStackTrace`in Error?Error:null;function Ie(e){let t=Fe;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Fe=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function O(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Pe.value=new a(r);try{Object.defineProperty(n,`_zod`,Pe)}finally{Pe.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Te(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,`name`,{value:e});function d(e){let t=r?.Parent?Ie(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,`init`,{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,`name`,{value:e}),d}var k=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Le=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Ne=globalThis).__zod_globalConfig??(Ne.__zod_globalConfig={});const A=globalThis.__zod_globalConfig;function j(e){return e&&Object.assign(A,e),A}function Re(){let e=this._zod;return e.message??=JSON.stringify(e.def,n,2),e.message}function ze(e){this._zod.message=e}const Be={get:Re,set:ze,enumerable:!0,configurable:!0},Ve={value:void 0,enumerable:!1},He=new WeakSet([Object.prototype,Error.prototype]),Ue=(e,t)=>{e.name=`$ZodError`,Ve.value=t,Object.defineProperty(e,`issues`,Ve),Ve.value=void 0,Object.defineProperty(e,`message`,Be);let n=Object.getPrototypeOf(e);He.has(n)||(He.add(n),Object.defineProperty(n,`toString`,{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,`toString`,{value:e,configurable:!0,writable:!0})}}))},We=O(`$ZodError`,Ue);O(`$ZodError`,Ue,void 0,{Parent:Error});function Ge(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Ke(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Ge(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function qe(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],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Je(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Ye=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new k;if(s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>C(e,o,j())));throw ee(n,a?.callee??t),n}return s.value};return t},Xe=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new(a?.Err??e)(s.issues.map(e=>C(e,o,j())));throw ee(n,a?.callee??t),n}return s.value};return t},Ze=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 k;return a.issues.length?Qe(e,a.issues,i):{success:!0,data:a.value}};function Qe(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>C(e,n,j()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}const $e=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?Qe(e,a.issues,i):{success:!0,data:a.value}},et=Symbol.for(`zod.compile.invalid`),tt=Symbol.for(`zod.compile.fallback`),nt=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==et)return!0;if(r.definite===!0&&n===void 0)return!1}return rt(e,t,n)});function rt(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[tt]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new k;return a.issues.length===0}const it=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},at=e=>{let t=Ye(e),n=(e,r,i,a)=>t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},Je(n,a));return n},ot=e=>{let t=Ye(e),n=(e,r,i,a)=>t(e,r,i,Je(n,a));return n},st=e=>{let t=Xe(e),n=async(e,r,i,a)=>await t(e,r,i?{...i,direction:`backward`}:{direction:`backward`},Je(n,a));return n},ct=e=>{let t=Xe(e),n=async(e,r,i,a)=>await t(e,r,i,Je(n,a));return n},lt=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ze(e)(t,n,i)},ut=e=>(t,n,r)=>Ze(e)(t,n,r),dt=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return $e(e)(t,n,i)},ft=e=>async(t,n,r)=>$e(e)(t,n,r),pt=/^(?:true|false)$/i,M=O(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),mt=e=>{let t=e.value;return!a(t)&&t.length!==void 0},ht=O(`$ZodCheckMaxLength`,(e,t)=>{var n;M.init(e,t),(n=e._zod.def).when??(n.when=mt),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Se(r):i)<=t.maximum)return;let a=Ce(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gt=O(`$ZodCheckMinLength`,(e,t)=>{var n;M.init(e,t),(n=e._zod.def).when??(n.when=mt),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Se(r):i)>=t.minimum)return;let a=Ce(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_t=O(`$ZodCheckLengthEquals`,(e,t)=>{var n;M.init(e,t),(n=e._zod.def).when??(n.when=mt),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Se(r):i;if(a===t.length)return;let o=Ce(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),vt=O(`$ZodCheckOverwrite`,(e,t)=>{M.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var yt=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
+ `).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?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
3
+ `)}\n};`)(...Object.values(this.closed))}};const bt={major:4,minor:6,patch:7},N=O(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bt;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=x(t),a;for(let o of n){if(o._zod.def.when){if(_e(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new k;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(be(t.issues,n,e),i||=x(t,n))});else{if(t.issues.length===n)continue;be(t.issues,n,e),i||=x(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(x(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new k;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new k;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Ee(this,`~standard`,Ct(this))},set"~standard"(e){T(this,`~standard`,e)}}),xt=(e,t)=>e.issues.length?{issues:e.issues.map(e=>C(e,t,j()))}:{value:e.value};async function St(e,t){let n={async:!0};return xt(await e._zod.run({value:t,issues:[]},n),n)}function Ct(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return xt(r,n)}catch{}return St(e,t)},vendor:`zod`,version:1}}const wt=O(`$ZodBoolean`,(e,t)=>{N.init(e,t),e._zod.pattern=pt,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}}),Tt=O(`$ZodUnknown`,(e,t)=>{N.init(e,t),e._zod.parse=e=>e}),Et=O(`$ZodNever`,(e,t)=>{N.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Dt(e,t){let n=ye(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of ye(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,be(n.issues,t,e),n}}return i(n,a)}}const Ot=e=>Array.isArray(e)?e.length:-1;function kt(e,t,n){e.issues.length&&t.issues.push(...ve(n,e.issues)),t.value[n]=e.value}const At=O(`$ZodArray`,(e,t)=>{N.init(e,t);let n=A.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>kt(t,r,e)));else if(kt(c,r,e),s&&c.issues.length!==0&&x(c))break}return o.length?Promise.all(o).then(()=>r):r},Dt(e,Ot)});function P(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...ve(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}const jt=[];function Mt(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:jt,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=oe(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Nt(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(x(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>P(e,n,i,t,d,f))):P(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Pt=O(`$ZodObject`,(e,t)=>{N.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,`shape`,{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,`shape`,{get:e})}let a=i(()=>Mt(t));D(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||s(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let o=g,c=t.catchall,l,u=A.memoizer;u?.attach(e),e._zod.parse=(t,n)=>{l??=a.value;let r=t.value;if(!o(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=u?u.alloc(e,t,{},n):{};let i=[],s=l.shape,d=n?.abortEarly,f=t.issues.length;for(let e of l.allKeys){if(d&&t.issues.length!==f){if(x(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let a=s[e],o=a._zod.optin,c=a._zod.optout,l=a._zod.run({value:r[e],issues:[]},n);l instanceof Promise?i.push(l.then(n=>P(n,t,e,r,o,c))):P(l,t,e,r,o,c)}return c?Nt(i,r,t,n,a.value,e,d===!0):i.length?Promise.all(i).then(()=>t):t}}),Ft=O(`$ZodObjectJIT`,(e,t)=>{Pt.init(e,t);let n=e._zod.parse,r=i(()=>Mt(t)),a=A.memoizer,o=t=>{let n=r.value,i=n.symbolKeys,o=new yt([`payload`,`ctx`],{shape:t,inst:e,memo:a,syms:i}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
4
+ let ${e}_ab = false;
5
+ for (let i = 0; i < ${e}.issues.length; i++) {
6
+ const iss = ${e}.issues[i];
7
+ iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
8
+ payload.issues.push(iss);
9
+ if (iss.continue !== true) ${e}_ab = true;
10
+ }
11
+ if (${e}_ab && ctx && ctx.abortEarly) {
12
+ payload.value = newResult;
13
+ return payload;
14
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(a?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${i.indexOf(e)}]`:h(e),a=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
15
+ const ${n}_present = ${a};
16
+ if (!${n}.issues.length || ${n}_present) {
17
+ if (${n}.issues.length) {${c(n,r)}
18
+ }
19
+
20
+ if (${e}) {
21
+ newResult[${r}] = ${n}.value;
22
+ }
23
+ }
24
+
25
+ `)}else f?(o.write(`
26
+ if (${n}.issues.length) {${c(n,r)}
27
+ }
28
+ `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
29
+ if (${n}.value !== undefined || ${a}) {
30
+ newResult[${r}] = ${n}.value;
31
+ }
32
+ `)):o.write(`
33
+ const ${n}_present = ${a};
34
+ if (${n}.issues.length) {${c(n,r)}
35
+ }
36
+ if (!${n}_present && !${n}.issues.length) {
37
+ payload.issues.push({
38
+ code: "invalid_type",
39
+ expected: "nonoptional",
40
+ input: undefined,
41
+ path: [${r}]
42
+ });
43
+ if (ctx && ctx.abortEarly) {
44
+ payload.value = newResult;
45
+ return payload;
46
+ }
47
+ }
48
+
49
+ if (${n}_present) {
50
+ newResult[${r}] = ${n}.value;
51
+ }
52
+
53
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},s,c=g,l=!A.jitless,u=l&&te.value,d=t.catchall,f;e._zod.parse=(i,a)=>{f??=r.value;let p=i.value;return c(p)?l&&u&&a?.async===!1&&a.jitless!==!0?(s||=o(t.shape),i=s(i,a),d?Nt([],p,i,a,f,e,a?.abortEarly===!0):i):n(i,a):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function It(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=>!x(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=>C(e,r,j())))}),t)}const Lt=O(`$ZodUnion`,(e,t)=>{N.init(e,t),D(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),D(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),D(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),D(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>o(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=>It(t,r,e,i)):It(o,r,e,i)}}),Rt=O(`$ZodIntersection`,(e,t)=>{N.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])=>Bt(e,t,n)):Bt(e,i,a)}});function zt(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(_(e)&&_(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=zt(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=zt(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 Bt(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=zt(t.value,n.value);if(!c.valid){if(x(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Vt=O(`$ZodEnum`,(t,n)=>{N.init(t,n);let r=e(n.entries),i=new Set(r);t._zod.values=i,D(t,`pattern`,t=>{let n=e(t.def.entries).filter(e=>re.has(typeof e));return RegExp(n.length?`^(${n.map(e=>ie(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),t._zod.parse=(e,n)=>{let a=e.value;return i.has(a)||e.issues.push({code:`invalid_value`,values:r,input:a,inst:t}),e}}),Ht=O(`$ZodTransform`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,A.memoizer.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Le(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));if(i instanceof Promise)throw new k;return n.value=i,n}});function Ut(e,t){return e.value=t.issues.length?void 0:t.value,e}const Wt=O(`$ZodOptional`,(e,t)=>{N.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,D(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),D(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${o(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ut(e,t)):Ut(e,r)}return t.innerType._zod.run(e,n)}}),Gt=O(`$ZodExactOptional`,(e,t)=>{Wt.init(e,t),D(e,`values`,e=>e.def.innerType._zod.values),D(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Kt=O(`$ZodNullable`,(e,t)=>{N.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin),D(e,`optout`,e=>e.def.innerType._zod.optout),D(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${o(t.source)}|null)$`):void 0}),D(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),qt=O(`$ZodDefault`,(e,t)=>{N.init(e,t),e._zod.optin=`defaulted`,D(e,`values`,e=>e.def.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=>Jt(e,t)):Jt(r,t)}});function Jt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Yt=O(`$ZodPrefault`,(e,t)=>{N.init(e,t),e._zod.optin=`defaulted`,D(e,`values`,e=>e.def.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))}),Xt=O(`$ZodNonOptional`,(e,t)=>{N.init(e,t),D(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].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=>Zt(t,e)):Zt(i,e)}});function Zt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Qt(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>C(e,r,j()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const $t=O(`$ZodCatch`,(e,t)=>{N.init(e,t),D(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),D(e,`optout`,e=>e.def.innerType._zod.optout),D(e,`values`,e=>e.def.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({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Qt(e,r,t,n)):Qt(e,r,t,n)}}),en=O(`$ZodPipe`,(e,t)=>{N.init(e,t),D(e,`values`,e=>e.def.in._zod.values),D(e,`optin`,e=>e.def.in._zod.optin),D(e,`optout`,e=>e.def.out._zod.optout),D(e,`propValues`,e=>e.def.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=>F(e,t.in,n)):F(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>F(e,t.out,n)):F(r,t.out,n)}});function F(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const tn=O(`$ZodReadonly`,(e,t)=>{N.init(e,t),D(e,`propValues`,e=>e.def.innerType._zod.propValues),D(e,`values`,e=>e.def.innerType._zod.values),D(e,`optin`,e=>e.def.innerType?._zod?.optin),D(e,`optout`,e=>e.def.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(nn):nn(r)}});function nn(e){return e.memo||(e.value=Object.freeze(e.value)),e}const rn=O(`$ZodCustom`,(e,t)=>{M.init(e,t),N.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=>an(t,n,r,e));an(i,n,r,e)}});function an(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(w(e))}}var on=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const sn=`~memo`,cn=[];function ln(e){return typeof e==`object`&&!!e}function un(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const dn=new WeakMap;function I(e,t,n){let r=dn.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=I(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?I(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},l=e._zod.def;switch(l.type){case`object`:{let e=c(l);s(e?o(e,!0):1),a(l.catchall);break}case`array`:a(l.element);break;case`tuple`:for(let e of l.items)a(e);a(l.rest);break;case`record`:case`map`:a(l.keyType),a(l.valueType);break;case`set`:a(l.valueType);break;case`union`:for(let e of l.options)a(e);break;case`intersection`:a(l.left),a(l.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(l.innerType);break;case`pipe`:a(l.in),a(l.out);break;case`function`:a(l.input),a(l.output);break;case`lazy`:{let r=l._cachedInner??(n?e._zod.innerType:void 0);s(r?I(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in l){let t=Object.getOwnPropertyDescriptor(l,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),fn(e,i)}function fn(e,t){return t!==1&&dn.set(e,t===2),t}function pn(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let L;const R=[],mn={alloc(e,t,n){let r=L;if(!r)return n;L=void 0;let i={value:n,issues:null};return r.set(t.value,i),R.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&gn(n,e.value))throw new on;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=I(e,new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!ln(l))return t(s,c);let u=c[sn];u||(u={buckets:new WeakMap,backEdges:void 0},c[sn]=u);let d;i===c?d=a:(d=pn(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...un(f.issues)):(s.memo=!0,u.backEdges??=new WeakSet,u.backEdges.add(f.value)),s;L=d;let p=R.length,m=t(s,c);L=void 0;let h=R.length>p?R.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?un(e.issues):cn),e)):(h&&(h.issues=m.issues.length?un(m.issues):cn),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function hn(){return mn}function gn(e,t){let n=e[sn]?.backEdges;return n!==void 0&&ln(t)&&n.has(t)}const _n=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function n(t){return e[t]??null}let r={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},i={nan:`NaN`};function a(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):i[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${a(e.expected)}, received ${a(we(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ae(e.values[0])}`:`Invalid option: expected one of ${t(e.values,`|`)}`;case`too_big`:{let t=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=n(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${t}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${t}${e.maximum.toString()}`}case`too_small`:{let t=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=n(e.origin);return r?`Too small: expected ${e.origin} to have ${t}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${t}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${r[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${t(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function vn(){return{localeError:_n()}}var yn,bn=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 bn}(yn=globalThis).__zod_globalRegistry??(yn.__zod_globalRegistry=xn());const z=globalThis.__zod_globalRegistry;function Sn(e,t){return new e({type:`boolean`,...y(t)})}function Cn(e){return new e({type:`unknown`})}function wn(e,t){return new e({type:`never`,...y(t)})}function Tn(e,t){return new ht({check:`max_length`,...y(t),maximum:e})}function En(e,t){return new gt({check:`min_length`,...y(t),minimum:e})}function Dn(e,t){return new _t({check:`length_equals`,...y(t),length:e})}function On(e){return new vt({check:`overwrite`,tx:e})}function kn(e,t,n){return new e({type:`array`,element:t,...y(n)})}function An(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...y(n)})}function jn(e,t){let n=Mn(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(w(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(w(r))}},e(t.value,t)),t);return n}function Mn(e,t){let n=new M({check:`custom`,...y(t)});return n._zod.check=e,n}function B(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&s(e,t,n[t]);return e}function Nn(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??z,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function V(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function H(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,H(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&B(o.schema,c),t.io===`input`&&U(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 Pn(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Fn(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=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}/${Pn(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Pn(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>
54
+
55
+ 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}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function In(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;In(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Ln=new Set([`type`,`properties`,`required`,`additionalProperties`]),Rn=[`oneOf`,`anyOf`];function zn(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Bn(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ln.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??zn(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}s(n,r,e.length===1?e[0]:Bn(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=zn(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Vn(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ln)if(t in e)return;let n=t.filter(e=>Rn.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Bn(t);else{let e=n[0],i=Rn.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Bn([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,B(e,r))}function Hn(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)):B(i,s),B(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())In(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Vn(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}B(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,s(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Wn(t,`input`,e.processors),output:Wn(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function U(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 U(r.element,n);if(r.type===`set`)return U(r.valueType,n);if(r.type===`lazy`)return U(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`||r.type===`catch`)return U(r.innerType,n);if(r.type===`intersection`)return U(r.left,n)||U(r.right,n);if(r.type===`record`||r.type===`map`)return U(r.keyType,n)||U(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:U(r.in,n)||U(r.out,n);if(r.type===`object`){for(let e in r.shape)if(U(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(U(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(U(e,n))return!0;return!!(r.rest&&U(r.rest,n))}return!1}const Un=(e,t={})=>n=>{let r=Nn({...n,processors:t});return H(e,r),Fn(r,e),Hn(r,e)},Wn=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Nn({...i??{},target:a,io:t,processors:n});return H(e,o),Fn(o,e),Hn(o,e)},W=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},G=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Gn=(e,t)=>{W(e,`minimum`,t),G(e,`maximum`,t)},Kn=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},qn=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Jn=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Yn=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Xn=(e,t)=>W(e,`minimum`,t.minimum),Zn=(e,t)=>G(e,`maximum`,t.maximum),Qn=e=>(t,n)=>{Yn(t,n.format);let[r,i]=e[n.format];W(t,`minimum`,r),G(t,`maximum`,i)},$n={greater_than:(e,t)=>W(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>G(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Kn(e,t.value),number_format:Qn(se),bigint_format:Qn(ce),min_length:Xn,max_length:Zn,length_equals:(e,t)=>Gn(e,t.length),min_size:Xn,max_size:Zn,size_equals:(e,t)=>Gn(e,t.size),string_format:(e,t)=>{Yn(e,t.format),t.pattern&&qn(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Jn(e,t.mime)};function er(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)$n[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&W(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&W(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&G(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&G(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Kn(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Jn(t,i.mime);for(let e of i.patterns??[])qn(t,e);return t}const tr=(e,t,n,r)=>{n.type=`boolean`},nr=(e,t,n,r)=>{n.not={}},rr=(t,n,r,i)=>{let a=t._zod.def,o=e(a.entries);if(o.length===0){r.not={};return}o.every(e=>typeof e==`number`)&&(r.type=`number`),o.every(e=>typeof e==`string`)&&(r.type=`string`),r.enum=o},ir=(e,t,n,r)=>{V(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ar=(e,t,n,r)=>{V(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},or=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=er(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=H(a.element,t,{...r,path:[...r.path,`items`]})};function sr(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?sr(t.out):t.type===`catch`?sr(t.innerType):e._zod.optin}const cr=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&V(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)s(i.properties,e,H(o[e],t,{...r,path:[...r.path,`properties`,e]}));let c=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?sr(n)===void 0:n._zod.optout===void 0)&&c.push(e)}c.length>0&&(i.required=c),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=H(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},lr=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>H(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ur=(e,t,n,r)=>{let i=e._zod.def,a=H(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=H(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},dr=(e,t,n,r)=>{let i=e._zod.def,a=H(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`}]},fr=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},pr=Symbol();function mr(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(V(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),pr):JSON.parse(o)}const hr=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=mr(i.defaultValue,e,t,n,r);o!==pr&&(n.default=o)},gr=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=mr(i.defaultValue,e,t,n,r);o!==pr&&(n._prefault=o)},_r=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{V(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},vr=(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;H(o,t,r);let s=t.seen.get(e);s.ref=o},yr=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},br=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xr=new WeakSet([Object.prototype,Error.prototype]);function Sr(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const K=O(`ZodError`,(e,t)=>{We.init(e,t),e.name=`ZodError`;let r=Object.getPrototypeOf(e);xr.has(r)||(xr.add(r),Sr(r,`format`,e=>t=>qe(e,t)),Sr(r,`flatten`,e=>t=>Ke(e,t)),Sr(r,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,n,2)}),Sr(r,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,n,2)}),Object.defineProperty(r,`isEmpty`,{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Cr=Ye(K),wr=Xe(K),Tr=Ze(K),Er=$e(K),Dr=at(K),Or=ot(K),kr=st(K),Ar=ct(K),jr=lt(K),Mr=ut(K),Nr=dt(K),Pr=ft(K);function Fr(){A.localeError||j(vn())}function Ir(){A.memoizer||j({memoizer:hn()})}const q=O(`ZodType`,(e,t)=>(Fr(),N.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(m(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 v(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(bi(e,t))},superRefine(e,t){return this.check(xi(e,t))},overwrite(e){return this.check(On(e))},optional(){return ni(this)},exactOptional(){return ii(this)},nullable(){return oi(this)},nullish(){return ni(oi(this))},nonoptional(e){return fi(this,e)},array(){return Wr(this)},or(e){return Jr([this,e])},and(e){return Xr(this,e)},transform(e){return gi(this,ei(e))},default(e){return ci(this,e)},prefault(e){return ui(this,e)},catch(e){return mi(this,e)},pipe(e){return gi(this,e)},readonly(){return vi(this)},describe(e){let t=this.clone();return z.add(t,{description:e}),t},meta(...e){if(e.length===0)return z.get(this);let t=this.clone();return z.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Ee(this,`~standard`,{...Ct(this),jsonSchema:{input:Wn(this,`input`),output:Wn(this,`output`)}})},set"~standard"(e){T(this,`~standard`,e)},parse:function e(t,n){return Cr(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await wr(this,t,n,{callee:e})},safeParse(e,t){return Tr(this,e,t)},async safeParseAsync(e,t){return Er(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){T(this,`spa`,e)},validate(e,t){return nt(this,e,t)},validateAsync(e,t){return it(this,e,t)},encode:function e(t,n){return Dr(this,t,n,{callee:e})},decode:function e(t,n){return Or(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await kr(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ar(this,t,n,{callee:e})},safeEncode(e,t){return jr(this,e,t)},safeDecode(e,t){return Mr(this,e,t)},async safeEncodeAsync(e,t){return Nr(this,e,t)},async safeDecodeAsync(e,t){return Pr(this,e,t)},toJSONSchema(e){return Un(this,{})(e)},get description(){return z.get(this)?.description},get _def(){return this._zod.def}}),Lr=O(`ZodBoolean`,(e,t)=>{wt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tr(e,t,n,r)});function Rr(e){return Sn(Lr,e)}const zr=O(`ZodUnknown`,(e,t)=>{Tt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Br(){return Cn(zr)}const Vr=O(`ZodNever`,(e,t)=>{Et.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nr(e,t,n,r)});function Hr(e){return wn(Vr,e)}const Ur=O(`ZodArray`,(e,t)=>{Ir(),At.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>or(e,t,n,r),e.element=t.element},{min(e,t){return this.check(En(e,t))},nonempty(e){return this.check(En(1,e))},max(e,t){return this.check(Tn(e,t))},length(e,t){return this.check(Dn(e,t))},unwrap(){return this.element}});function Wr(e,t){return kn(Ur,e,t)}const Gr=O(`ZodObject`,(e,t)=>{Ir(),Ft.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cr(e,t,n,r),je(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Qr(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(m(this._zod.def,{catchall:e}))},passthrough(){return this.clone(m(this._zod.def,{catchall:Br()}))},loose(){return this.clone(m(this._zod.def,{catchall:Br()}))},strict(){return this.clone(m(this._zod.def,{catchall:Hr()}))},strip(){return this.clone(m(this._zod.def,{catchall:void 0}))},extend(e){return de(this,e)},safeExtend(e){return pe(this,e)},merge(e){return me(this,e)},pick(e){return le(this,e)},omit(e){return ue(this,e)},partial(...e){return he(ti,this,e[0])},exactPartial(...e){return he(ri,this,e[0],`exactPartial`)},required(...e){return ge(di,this,e[0])}});function Kr(e,t){return new Gr({type:`object`,shape:e??{},...y(t)})}const qr=O(`ZodUnion`,(e,t)=>{Lt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lr(e,t,n,r),e.options=t.options});function Jr(e,t){return new qr({type:`union`,options:e,...y(t)})}const Yr=O(`ZodIntersection`,(e,t)=>{Rt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ur(e,t,n,r)});function Xr(e,t){return new Yr({type:`intersection`,left:e,right:t})}const Zr=O(`ZodEnum`,(e,t)=>{Vt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rr(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Zr({...t,checks:[],...y(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 Zr({...t,checks:[],...y(r),entries:i})}});function Qr(e,t){return new Zr({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...y(t)})}const $r=O(`ZodTransform`,(e,t)=>{Ir(),Ht.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ar(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Le(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(w(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(w(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ei(e){return new $r({type:`transform`,transform:e})}const ti=O(`ZodOptional`,(e,t)=>{Wt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>br(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ni(e){return new ti({type:`optional`,innerType:e})}const ri=O(`ZodExactOptional`,(e,t)=>{Gt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>br(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ii(e){return new ri({type:`optional`,innerType:e})}const ai=O(`ZodNullable`,(e,t)=>{Kt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dr(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oi(e){return new ai({type:`nullable`,innerType:e})}const si=O(`ZodDefault`,(e,t)=>{qt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hr(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ci(e,t){return new si({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ne(t)}})}const li=O(`ZodPrefault`,(e,t)=>{Yt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gr(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ui(e,t){return new li({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ne(t)}})}const di=O(`ZodNonOptional`,(e,t)=>{Xt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fr(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fi(e,t){return new di({type:`nonoptional`,innerType:e,...y(t)})}const pi=O(`ZodCatch`,(e,t)=>{$t.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_r(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function mi(e,t){return new pi({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Me(t)})}const hi=O(`ZodPipe`,(e,t)=>{en.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vr(e,t,n,r),e.in=t.in,e.out=t.out});function gi(e,t){return new hi({type:`pipe`,in:e,out:t})}const _i=O(`ZodReadonly`,(e,t)=>{tn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yr(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vi(e){return new _i({type:`readonly`,innerType:e})}const yi=O(`ZodCustom`,(e,t)=>{rn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ir(e,t,n,r)});function bi(e,t={}){return An(yi,e,t)}function xi(e,t){return jn(e,t)}const Si=[`storage`,`kv`,`settings`,`content`,`email`,`http`,`media`,`schema`,`taxonomies`,`users`,`comments`,`redirects`,`cron`,`bylines`],Ci=Symbol.for(`cherwell.kit.budget`);function wi(e,t,n=0){return new Proxy(e,{get(e,r){let i=Reflect.get(e,r),a=Reflect.getOwnPropertyDescriptor(e,r);return a&&!a.configurable&&a.writable===!1?i:typeof r==`symbol`||r in Object.prototype&&i===Object.prototype[r]?typeof i==`function`?i.bind(e):i:typeof i==`function`?(...n)=>(t.used++,t.used>t.limit&&!t.over&&(t.over=!0,t.raw.kv.set(`kit:over:${t.name}`,{used:t.used,at:new Date().toISOString()}).catch(()=>{}),t.raw.log.warn(`Call budget exceeded`,{name:t.name,used:t.used})),i.apply(e,n)):i&&typeof i==`object`&&n<1?wi(i,t,n+1):i}})}function Ti(e,t,n=28){let r={used:0,limit:n,over:!1,name:t,raw:e},i={[Ci]:r};for(let t of Object.keys(e)){let n=e[t];i[t]=Si.includes(t)&&n&&typeof n==`object`?wi(n,r):n}return i}function Ei(e,t){return{type:`header`,text:e,...t?.blockId!==void 0&&{block_id:t.blockId}}}function Di(e,t){return{type:`section`,text:e,...t?.accessory!==void 0&&{accessory:t.accessory},...t?.blockId!==void 0&&{block_id:t.blockId}}}function Oi(e){return{type:`divider`,...e?.blockId!==void 0&&{block_id:e.blockId}}}function ki(e,t){return{type:`fields`,fields:e,...t?.blockId!==void 0&&{block_id:t.blockId}}}function Ai(e){return{type:`table`,columns:e.columns,rows:e.rows,page_action_id:e.pageActionId,...e.nextCursor!==void 0&&{next_cursor:e.nextCursor},...e.emptyText!==void 0&&{empty_text:e.emptyText},...e.blockId!==void 0&&{block_id:e.blockId}}}function ji(e,t){return{type:`actions`,elements:e,...t?.blockId!==void 0&&{block_id:t.blockId}}}function Mi(e,t){return{type:`stats`,items:e,...t?.blockId!==void 0&&{block_id:t.blockId}}}function Ni(e){return{type:`form`,fields:e.fields,submit:{label:e.submit.label,action_id:e.submit.actionId},...e.blockId!==void 0&&{block_id:e.blockId}}}function Pi(e){return{type:`image`,url:e.url,alt:e.alt,...e.title!==void 0&&{title:e.title},...e.blockId!==void 0&&{block_id:e.blockId}}}function Fi(e,t){return{type:`context`,text:e,...t?.blockId!==void 0&&{block_id:t.blockId}}}function Ii(e,t){return{type:`columns`,columns:e,...t?.blockId!==void 0&&{block_id:t.blockId}}}function Li(e){return{type:`banner`,...e.title!==void 0&&{title:e.title},...e.description!==void 0&&{description:e.description},...e.variant!==void 0&&{variant:e.variant},...e.blockId!==void 0&&{block_id:e.blockId}}}function Ri(e,t,n){return{type:`text_input`,action_id:e,label:t,...n?.placeholder!==void 0&&{placeholder:n.placeholder},...n?.initialValue!==void 0&&{initial_value:n.initialValue},...n?.multiline!==void 0&&{multiline:n.multiline}}}function zi(e,t,n){return{type:`link`,label:e,target:t,...n?.appearance!==void 0&&{appearance:n.appearance}}}function Bi(e,t,n,r){return{type:`menu`,action_id:e,label:t,items:n,...r?.style!==void 0&&{style:r.style}}}function Vi(e,t,n){return{type:`number_input`,action_id:e,label:t,...n?.initialValue!==void 0&&{initial_value:n.initialValue},...n?.min!==void 0&&{min:n.min},...n?.max!==void 0&&{max:n.max}}}function Hi(e,t,n,r){return{type:`select`,action_id:e,label:t,options:n,...r?.initialValue!==void 0&&{initial_value:r.initialValue}}}function Ui(e,t,n){return{type:`toggle`,action_id:e,label:t,...n?.description!==void 0&&{description:n.description},...n?.initialValue!==void 0&&{initial_value:n.initialValue}}}function Wi(e,t,n){return{type:`button`,action_id:e,label:t,...n?.style!==void 0&&{style:n.style},...n?.value!==void 0&&{value:n.value},...n?.confirm!==void 0&&{confirm:n.confirm}}}function Gi(e,t,n){return{type:`secret_input`,action_id:e,label:t,...n?.placeholder!==void 0&&{placeholder:n.placeholder},...n?.hasValue!==void 0&&{has_value:n.hasValue}}}function Ki(e,t,n,r){return{type:`checkbox`,action_id:e,label:t,options:n,...r?.initialValue!==void 0&&{initial_value:r.initialValue}}}function qi(e,t,n){return{type:`date_input`,action_id:e,label:t,...n?.initialValue!==void 0&&{initial_value:n.initialValue},...n?.placeholder!==void 0&&{placeholder:n.placeholder}}}function Ji(e,t,n,r){return{type:`combobox`,action_id:e,label:t,options:n,...r?.initialValue!==void 0&&{initial_value:r.initialValue},...r?.placeholder!==void 0&&{placeholder:r.placeholder}}}function Yi(e,t,n,r){return{type:`radio`,action_id:e,label:t,options:n,...r?.initialValue!==void 0&&{initial_value:r.initialValue}}}function Xi(e,t,n,r){return{type:`repeater`,action_id:e,label:t,fields:n,...r?.itemLabel!==void 0&&{item_label:r.itemLabel},...r?.minItems!==void 0&&{min_items:r.minItems},...r?.maxItems!==void 0&&{max_items:r.maxItems},...r?.initialValue!==void 0&&{initial_value:r.initialValue}}}function Zi(e,t,n){return{type:`media_picker`,action_id:e,label:t,...n?.mimeTypeFilter!==void 0&&{mime_type_filter:n.mimeTypeFilter},...n?.initialValue!==void 0&&{initial_value:n.initialValue},...n?.placeholder!==void 0&&{placeholder:n.placeholder}}}function Qi(e){return{type:`chart`,config:{chart_type:`timeseries`,series:e.series,...e.style!==void 0&&{style:e.style},...e.xAxisName!==void 0&&{x_axis_name:e.xAxisName},...e.yAxisName!==void 0&&{y_axis_name:e.yAxisName},...e.height!==void 0&&{height:e.height},...e.gradient!==void 0&&{gradient:e.gradient}},...e.blockId!==void 0&&{block_id:e.blockId}}}function $i(e){return{type:`chart`,config:{chart_type:`custom`,options:e.options,...e.height!==void 0&&{height:e.height}},...e.blockId!==void 0&&{block_id:e.blockId}}}function ea(e){return{type:`meter`,label:e.label,value:e.value,...e.max!==void 0&&{max:e.max},...e.min!==void 0&&{min:e.min},...e.customValue!==void 0&&{custom_value:e.customValue},...e.blockId!==void 0&&{block_id:e.blockId}}}function ta(e){return{type:`code`,code:e.code,...e.language!==void 0&&{language:e.language},...e.blockId!==void 0&&{block_id:e.blockId}}}function na(e,t){return{type:`tab`,panels:e,...t?.defaultTab!==void 0&&{default_tab:t.defaultTab},...t?.blockId!==void 0&&{block_id:t.blockId}}}function ra(e){return{type:`empty`,title:e.title,...e.description!==void 0&&{description:e.description},...e.commandLine!==void 0&&{command_line:e.commandLine},...e.size!==void 0&&{size:e.size},...e.actions!==void 0&&{actions:e.actions},...e.blockId!==void 0&&{block_id:e.blockId}}}function ia(e){return{type:`accordion`,label:e.label,blocks:e.blocks,...e.defaultOpen!==void 0&&{default_open:e.defaultOpen},...e.blockId!==void 0&&{block_id:e.blockId}}}const J={header:Ei,section:Di,divider:Oi,fields:ki,table:Ai,actions:ji,stats:Mi,form:Ni,image:Pi,context:Fi,columns:Ii,timeseriesChart:Qi,customChart:$i,banner:Li,meter:ea,code:ta,tab:na,empty:ra,accordion:ia},Y={textInput:Ri,numberInput:Vi,select:Hi,toggle:Ui,button:Wi,link:zi,menu:Bi,secretInput:Gi,checkbox:Ki,combobox:Ji,dateInput:qi,radio:Yi,repeater:Xi,mediaPicker:Zi};new TextEncoder;const aa=[`zero`,`one`,`two`,`few`,`many`,`other`];function oa(e,t){let n=(t??`en`).toLowerCase(),r=[e[n],e[n.split(`-`)[0]],e.en].filter(Boolean),i;try{i=new Intl.PluralRules(n)}catch{i=new Intl.PluralRules(`en`)}return(e,t={})=>{let n=r.find(t=>Object.hasOwn(t,e)&&typeof t[e]==`string`)?.[e]??e;if(n.includes(`|`)&&typeof t.n==`number`){let e=n.split(`|`),r=i.select(t.n);n=e.length===6?e[aa.indexOf(r)]:r===`one`?e[0]:e[e.length-1]}return n.replace(/\{(\w+)\}/g,(e,n)=>Object.hasOwn(t,n)?String(t[n]):`{${n}}`)}}function sa(e){return e?.ui?.locale??`en`}function ca(e,t=`en-GB`,n){if(!e)return``;try{let r=e.length<=10,i=r?`UTC`:n;return new Intl.DateTimeFormat(t,{dateStyle:`medium`,...r?{}:{timeStyle:`short`},...i?{timeZone:i}:{}}).format(new Date(e))}catch{return e.slice(0,16).replace(`T`,` `)}}const la=(e={})=>({ok:!0,...e}),ua=(e,t)=>({ok:!1,error:e,...t?{fields:t}:{}});function da(e,t){let n=e.safeParse(t??{});if(n.success)return{ok:!0,data:n.data};let r={};for(let e of n.error.issues)r[e.path.map(String).join(`.`)||`_`]=e.code;return ua(`INVALID_INPUT`,r)}var X=class extends Error{constructor(e){super(e),this.code=e}};function fa(e,t,n){let r=n instanceof Error?n:Error(String(n)),i=String(r.message).replace(/(\bhttps?:\/\/[^\s?#]*)[?#]\S*/gi,`$1?<redacted>`).replace(/\b(bearer|basic)\s+\S+/gi,`$1 <redacted>`).replace(/[^\s@]+@[^\s@]+/g,`<email>`).slice(0,200),a=(r.stack??``).split(`
56
+ `).find(e=>e.trim().startsWith(`at `))?.trim().slice(0,200);e.error(`Unexpected failure`,{where:t,name:r.name,message:i,frame:a})}const pa=new Set([`true`,`1`,`on`,`yes`]);async function ma(e,t,n){let r;try{r=await e.settings.list()}catch{r=[];for(let n of Object.keys(t))try{let t=await e.settings.get(n);t!=null&&r.push({key:n,value:t})}catch{}e.log.warn(`Plugin settings couldn't all be read; using per-key reads`,{})}let i={...t};for(let{key:e,value:a}of r){let r=e.startsWith(`settings:`)?e.slice(9):e;if(!(r in t)||a==null||a===``)continue;let o=t[r];if(typeof o==`number`){let e=typeof a==`number`?a:typeof a==`string`&&a.trim()?Number(a.trim()):NaN,t=n?.[r],o=Number.isFinite(t?.min)?t.min:-1/0,s=Number.isFinite(t?.max)?t.max:1/0;Number.isFinite(e)&&(i[r]=Math.min(Math.max(e,o),s))}else typeof o==`boolean`?i[r]=a===!0||a===1||typeof a==`string`&&pa.has(a.trim().toLowerCase()):typeof o==`string`&&(typeof a==`number`||typeof a==`boolean`)?i[r]=String(a):i[r]=a}return i}const ha={en:{"kit.webhooks.title":`Webhooks`,"kit.webhooks.intro":`Send events to other systems as they happen. Requests are signed: check X-Webhook-Signature against your signing secret in this plugin's settings.`,"kit.webhooks.empty.title":`No webhooks yet`,"kit.webhooks.empty.text":`Add a URL below to send events to Zapier, Make, your CRM or your own code.`,"kit.webhooks.url":`Endpoint URL (https)`,"kit.webhooks.events":`Events (comma-separated, or * for all)`,"kit.webhooks.description":`What it's for`,"kit.webhooks.add":`Add webhook`,"kit.webhooks.remove":`Remove`,"kit.webhooks.removeConfirm":`Events stop going to {url}.`,"kit.webhooks.deliveries":`Recent deliveries`,"kit.webhooks.noDeliveries":`Nothing sent yet.`,"kit.webhooks.retry":`Retry failed`,"kit.webhooks.added":`Webhook added`,"kit.webhooks.removed":`Webhook removed`,"kit.webhooks.retried":`Queued again`,"kit.webhooks.URL_INVALID":`That isn't a web address.`,"kit.webhooks.URL_NOT_HTTPS":`Webhook URLs must start with https://`,"kit.webhooks.WEBHOOKS_UNAVAILABLE":`Webhooks aren't set up for this plugin.`,"kit.webhooks.FORBIDDEN":`Only administrators can change webhooks.`,"kit.webhooks.readOnly":`Only administrators can add, remove or retry webhooks.`,"kit.webhooks.EVENTS_INVALID":`None of those are events this plugin sends. Leave it blank or use * for all.`,"kit.audit.title":`Audit trail`,"kit.audit.intro":`Every change made in this plugin, by whom and when.`,"kit.audit.empty":`No changes recorded yet.`,"kit.col.url":`URL`,"kit.col.events":`Events`,"kit.col.what":`For`,"kit.col.when":`When`,"kit.col.event":`Event`,"kit.col.status":`Status`,"kit.col.attempts":`Attempts`,"kit.col.who":`Who`,"kit.col.action":`Action`,"kit.col.target":`Record`,"kit.col.change":`Change`}},ga=e=>String(e).split(`,`).map(e=>e.trim()).filter(Boolean),_a={domain:``,tracking:`script`,scriptPath:`/js/script.js`,proxyPath:`/p`,skipPaths:`/_emdash`,pageProps:!0,outbound:!0,fileDownloads:!0,apiKey:``,cacheMinutes:15,dashboardUrl:``},va=/^\/js\/[A-Za-z0-9._-]{1,120}\.js$/,ya=/^(\/[A-Za-z0-9_-]{1,40}){1,4}$/;function Z(e){let t=String(e??``).trim().toLowerCase().replace(/^https?:\/\//,``).replace(/\/.*$/,``);return/^[a-z0-9.-]{1,253}$/.test(t)&&t.includes(`.`)?t:``}function ba(e){let t=String(e.proxyPath).trim().replace(/\/+$/,``);return{domain:Z(e.domain),scriptPath:va.test(e.scriptPath)?e.scriptPath:_a.scriptPath,proxyPath:ya.test(t)?t:``,skip:ga(e.skipPaths).filter(e=>e.startsWith(`/`)),pageProps:e.pageProps,outbound:e.outbound,fileDownloads:e.fileDownloads}}const xa=e=>ma(e,_a,{cacheMinutes:{min:1,max:1440}});let Sa=null;async function Ca(e,t=Date.now()){if(Sa&&t-Sa.at<3e4)return Sa.s;let n=await xa(e);return Sa={at:t,s:n},n}const wa=`https://plausible.io`,Ta=e=>/\/pa-[A-Za-z0-9_-]+\.js$/.test(e);function Ea(e){let t={};return e.pageType&&(t.page_type=String(e.pageType).slice(0,60)),e.content?.collection&&(t.collection=String(e.content.collection).slice(0,60)),t}function Da(e,t){if(!e.domain)return!1;let n=t.path||`/`;return!e.skip.some(e=>n===e||n.startsWith(e.endsWith(`/`)?e:`${e}/`))}function Oa(e,t){if(!/\/script\.js$/.test(e.scriptPath))return e.scriptPath;let n=[e.fileDownloads&&`file-downloads`,e.outbound&&`outbound-links`,t&&`pageview-props`].filter(Boolean);return n.length?e.scriptPath.replace(/script\.js$/,`script.${n.join(`.`)}.js`):e.scriptPath}const ka=e=>JSON.stringify(e).replace(/</g,`\\u003c`);function Aa(e,t){if(!Da(e,t))return[];let n=e.proxyPath||wa,r=e.proxyPath?`${e.proxyPath}/api/event`:null,i=e.pageProps?Ea(t):{},a=Object.keys(i).length>0;if(Ta(e.scriptPath)){let t={};return r&&(t.endpoint=r),a&&(t.customProperties=i),[{kind:`external-script`,placement:`head`,src:`${n}${e.scriptPath}`,async:!0,key:`plausible`},{kind:`inline-script`,placement:`head`,key:`plausible-init`,code:`window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};plausible.init(${ka(t)})`}]}let o={"data-domain":e.domain};r&&(o[`data-api`]=r);for(let[e,t]of Object.entries(i))o[`event-${e}`]=t;return[{kind:`external-script`,placement:`head`,src:`${n}${Oa(e,a)}`,defer:!0,attributes:o,key:`plausible`}]}const ja=[`7d`,`30d`,`12mo`],Ma=e=>ja.includes(e),Q=e=>typeof e==`number`&&Number.isFinite(e)?e:0;async function Na(e,t,n){let r=e.http;if(!r)throw new X(`NO_NETWORK`);let i=await r.fetch(`${wa}/api/v2/query`,{method:`POST`,headers:{authorization:`Bearer ${t.apiKey}`,"content-type":`application/json`},body:JSON.stringify({site_id:Z(t.domain),...n})});if(i.status===401||i.status===403)throw new X(`KEY_REFUSED`);if(i.status===429)throw new X(`RATE_LIMITED`);if(!i.ok)throw e.log.warn(`Plausible answered with an error`,{status:i.status}),new X(`PLAUSIBLE_ERROR`);let a=await i.json();return Array.isArray(a.results)?a.results.filter(e=>e&&Array.isArray(e.metrics)):[]}const Pa=e=>Date.parse(`${e.slice(0,10)}T00:00:00Z`);async function Fa(e,t,n,r=new Date){let i=n,[a,o,s,c]=await Promise.all([Na(e,t,{metrics:[`visitors`,`visits`,`pageviews`,`bounce_rate`,`visit_duration`],date_range:i}),Na(e,t,{metrics:[`visitors`],date_range:i,dimensions:[n===`12mo`?`time:month`:`time:day`]}),Na(e,t,{metrics:[`visitors`,`pageviews`],date_range:i,dimensions:[`event:page`],order_by:[[`visitors`,`desc`]],pagination:{limit:10}}),Na(e,t,{metrics:[`visitors`],date_range:i,dimensions:[`visit:source`],order_by:[[`visitors`,`desc`]],pagination:{limit:10}})]),l=a[0]?.metrics??[];return{range:n,at:r.toISOString(),totals:{visitors:Q(l[0]),visits:Q(l[1]),pageviews:Q(l[2]),bounceRate:Q(l[3]),visitDuration:Q(l[4])},series:o.map(e=>[Pa(String(e.dimensions?.[0]??``)),Q(e.metrics[0])]).filter(([e])=>Number.isFinite(e)).sort((e,t)=>e[0]-t[0]),pages:s.map(e=>({page:String(e.dimensions?.[0]??``),visitors:Q(e.metrics[0]),pageviews:Q(e.metrics[1])})),sources:c.map(e=>({source:String(e.dimensions?.[0]??``),visitors:Q(e.metrics[0])}))}}function Ia(e){return Z(e.domain)?e.apiKey?null:`NO_KEY`:`NO_DOMAIN`}const La=(e,t)=>`report:${Z(e.domain)}:${t}`;async function Ra(e,t,n,r={}){let i=Ia(t);if(i)throw new X(i);let a=r.now??new Date;if(!r.fresh){let r=await e.kv.get(La(t,n));if(r&&a.getTime()-Date.parse(r.at)<t.cacheMinutes*6e4)return r}let o=await Fa(e,t,n,a);return await e.kv.set(La(t,n),o),o}function za(e){let t=Math.round(e);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}const $=(e,t=`en-GB`)=>new Intl.NumberFormat(t).format(Math.round(e)),Ba=`admin:range`;function Va(e,t){return{blocks:[J.header(e(`reports.title`)),J.banner({title:e(`setup.title`),description:e(`setup.${t}`),variant:`alert`}),J.actions([Y.link(e(`setup.settings`),{kind:`plugin-settings`})])]}}function Ha(e,t){return J.stats([{label:e(`stat.visitors`),value:$(t.totals.visitors)},{label:e(`stat.visits`),value:$(t.totals.visits)},{label:e(`stat.pageviews`),value:$(t.totals.pageviews)},{label:e(`stat.bounceRate`),value:`${Math.round(t.totals.bounceRate)}%`},{label:e(`stat.visitDuration`),value:za(t.totals.visitDuration)}])}async function Ua(e,t,n,r,i=!1){let a=Ia(n);if(a)return Va(t,a);let o=await Ra(e,n,r,{fresh:i}),s=[...ja.map(e=>Y.button(`range`,t(`range.${e}`),{value:e,style:e===r?`primary`:`secondary`})),Y.button(`refresh`,t(`reports.refresh`),{value:r,style:`secondary`}),...n.dashboardUrl?[Y.link(t(`reports.open`),{kind:`external`,url:n.dashboardUrl})]:[]],c=[J.header(t(`reports.title`)),J.context(t(`reports.intro`,{domain:Z(n.domain),minutes:n.cacheMinutes}))];return n.tracking===`off`&&c.push(J.context(t(`tracking.off`))),c.push(J.actions(s),Ha(t,o)),o.totals.visitors===0?c.push(J.empty({title:t(`none`)})):c.push(J.timeseriesChart({series:[{name:t(`chart.visitors`),data:o.series}],style:r===`12mo`?`bar`:`line`,gradient:!0,height:260}),J.columns([[J.section(`**${t(`pages.title`)}**`),J.table({blockId:`pages`,columns:[{key:`page`,label:t(`col.page`),format:`code`},{key:`visitors`,label:t(`col.visitors`),format:`number`},{key:`pageviews`,label:t(`col.pageviews`),format:`number`}],rows:o.pages,pageActionId:`noop`,emptyText:t(`none`)})],[J.section(`**${t(`sources.title`)}**`),J.table({blockId:`sources`,columns:[{key:`source`,label:t(`col.source`)},{key:`visitors`,label:t(`col.visitors`),format:`number`}],rows:o.sources,pageActionId:`noop`,emptyText:t(`none`)})]])),c.push(J.context(t(`reports.updated`,{when:ca(o.at)}))),{blocks:c}}async function Wa(e,t,n){if(Ia(n))return{blocks:[J.context(t(`widget.empty`))]};let r=await Ra(e,n,`7d`);return{blocks:[J.stats([{label:t(`stat.visitors`),value:$(r.totals.visitors),description:t(`range.7d`)},{label:t(`stat.pageviews`),value:$(r.totals.pageviews)}]),J.timeseriesChart({series:[{name:t(`chart.visitors`),data:r.series}],height:120,gradient:!0})]}}async function Ga(e,t,n,r){let i=async t=>{if(Ma(t))return t;let n=await e.kv.get(Ba);return Ma(n)?n:`30d`};try{if(r.type===`page_load`)return r.page===`widget:visitors`?await Wa(e,t,n):await Ua(e,t,n,await i());if(r.type===`block_action`&&(r.action_id===`range`||r.action_id===`refresh`)){let a=await i(r.value);return r.action_id===`range`&&await e.kv.set(Ba,a),await Ua(e,t,n,a,r.action_id===`refresh`)}return await Ua(e,t,n,await i())}catch(n){let i=n instanceof X?n.code:`INTERNAL`;return n instanceof X||e.log.error(`Admin action failed`,{action:r.type===`page_load`?r.page:r.type===`block_action`?r.action_id:r.type}),{blocks:[J.header(t(`reports.title`)),J.banner({title:t(`error.${i}`),variant:`error`}),J.actions([Y.button(`refresh`,t(`reports.refresh`),{value:`30d`})])]}}}const Ka={en:{...ha.en,"reports.title":`Plausible Analytics`,"reports.intro":`Visitors to {domain}, from Plausible. Numbers are kept for {minutes} minutes before Plausible is asked again.`,"reports.updated":`Updated {when}`,"reports.refresh":`Refresh`,"reports.open":`Open in Plausible`,"range.7d":`Last 7 days`,"range.30d":`Last 30 days`,"range.12mo":`Last 12 months`,"stat.visitors":`Visitors`,"stat.visits":`Visits`,"stat.pageviews":`Pageviews`,"stat.bounceRate":`Bounce rate`,"stat.visitDuration":`Visit duration`,"chart.visitors":`Visitors`,"pages.title":`Top pages`,"sources.title":`Top sources`,"col.page":`Page`,"col.source":`Source`,"col.visitors":`Visitors`,"col.pageviews":`Pageviews`,none:`No visits in this period`,"setup.title":`Finish setting up Plausible`,"setup.NO_DOMAIN":`Enter the site's domain, as Plausible knows it, in the plugin's settings.`,"setup.NO_KEY":`Reports need a Stats API key, which comes with Plausible's Business plan. Create one in Plausible (Account settings ▸ API keys) and enter it in the plugin's settings.`,"setup.settings":`Open the settings`,"tracking.off":`Tracking is off: the site sends its own events. These reports still work.`,"widget.empty":`Set up Plausible to see visitors here.`,"error.KEY_REFUSED":`Plausible refused the Stats API key. Check it in the plugin's settings, and that your plan includes the Stats API (Business plan).`,"error.RATE_LIMITED":`Plausible is limiting requests. Try again in a few minutes.`,"error.PLAUSIBLE_ERROR":`Plausible couldn't answer just now. Try again shortly.`,"error.NO_NETWORK":`This install can't reach Plausible. Approve the plugin's network access.`,"error.NO_DOMAIN":`Enter the site's domain in the plugin's settings.`,"error.NO_KEY":`Enter a Stats API key in the plugin's settings.`,"error.INVALID_INPUT":`Check the highlighted fields.`,"error.INTERNAL":`Something went wrong. Try again.`}};function qa(e,t){return async(n,r)=>{let i=Ti(r,`route:${e}`);try{return await t(n,i)}catch(t){return t instanceof X?ua(t.code):(fa(i.log,`route:${e}`,t),ua(`INTERNAL`))}}}const Ja=Kr({range:Qr(ja).optional().default(`30d`),fresh:Rr().optional().default(!1)}),Ya={hooks:{"page:fragments":async(e,t)=>{let n=Ti(t,`page:fragments`);try{let t=await Ca(n);if(t.tracking!==`script`)return null;let r=Aa(ba(t),e.page);return r.length?r:null}catch(e){return fa(n.log,`page:fragments`,e),null}}},routes:{report:{permission:`content:edit_any`,handler:qa(`report`,async(e,t)=>{let n=da(Ja,e.input);return n.ok?la({report:await Ra(t,await xa(t),n.data.range,{fresh:n.data.fresh})}):n})},admin:{permission:`content:edit_any`,handler:qa(`admin`,async(e,t)=>Ga(t,oa(Ka,sa(e)),await xa(t),e.input))}}};export{Ja as ReportInput,Ya as default};
package/docs/faq.md ADDED
@@ -0,0 +1,35 @@
1
+ ### What does it store about visitors?
2
+
3
+ Nothing, and it sets no cookies. The proxy passes each visitor's IP address and browser headers to Plausible. Plausible hashes them with a salt it deletes daily and never stores the raw values.
4
+
5
+ ### Which snippet do I have?
6
+
7
+ Look at the snippet under **Site settings ▸ Site installation** in Plausible. Sites added since late 2025 use `/js/pa-<id>.js`, whose options are set in Plausible. Older sites use `/js/script.js`, and the plugin adds the extensions you turn on. Enter the file in **Script file**.
8
+
9
+ ### My site sends its own events. Can I use only the reports?
10
+
11
+ Yes. Set **Tracking** to **Off**. The plugin adds nothing to your pages.
12
+
13
+ ### The plugin runs sandboxed. How do I add the tag?
14
+
15
+ EmDash 1.6 doesn't add page fragments from sandboxed plugins. Call `plausibleTag` from `@cherwell/emdash-plausible/astro` in your layout's `<head>`, with the same settings and your CSP nonce. The README has an example.
16
+
17
+ ### How do I leave out my own visits?
18
+
19
+ Run `localStorage.plausible_ignore = true` in your browser's console on the site. Or block your IP address in Plausible's site settings.
20
+
21
+ ### Why does Plausible refuse the Stats API key?
22
+
23
+ The Stats API is a Business-plan feature. Check the key, and that your plan includes it.
24
+
25
+ ### Events arrive as 202 but don't show up
26
+
27
+ Plausible drops events that come without the visitor's IP address, and says so with an `x-plausible-dropped: 1` response header. Check that your adapter gives Astro `clientAddress`, or that `CF-Connecting-IP` reaches the route.
28
+
29
+ ### How fresh are the reports?
30
+
31
+ They're kept for **Keep reports for** minutes (15 by default). **Refresh** asks Plausible straight away.
32
+
33
+ ### Does it work with a self-hosted Plausible?
34
+
35
+ The proxy does: pass `host` to `plausibleProxy`. Reports read plausible.io only.
@@ -0,0 +1,41 @@
1
+ ## 1. Add the plugin
2
+
3
+ ```sh
4
+ npm install @cherwell/emdash-plausible
5
+ ```
6
+
7
+ ```ts
8
+ // astro.config.mjs
9
+ import plausible from "@cherwell/emdash-plausible";
10
+ emdash({ plugins: [plausible] });
11
+ ```
12
+
13
+ Install it in-process, as above, for the plugin to add the tag. EmDash 1.6 doesn't add page fragments from sandboxed plugins; a sandboxed install still gives reports, and your layout draws the tag with `plausibleTag`.
14
+
15
+ ## 2. Add the proxy route
16
+
17
+ ```ts
18
+ // src/pages/p/[...path].ts
19
+ import { plausibleProxy } from "@cherwell/emdash-plausible/astro";
20
+
21
+ export const prerender = false;
22
+ export const { GET, HEAD, POST } = plausibleProxy();
23
+ ```
24
+
25
+ It serves `GET /p/js/<file>.js` and `POST /p/api/event` and nothing else. For a self-hosted Plausible CE, pass `host: "https://stats.example.com"`. If the route is elsewhere, set **Proxy path** to match.
26
+
27
+ ## 3. Settings
28
+
29
+ - **Site domain:** the site as Plausible knows it, such as `example.com`.
30
+ - **Script file:** the file in your Plausible snippet, `/js/pa-<id>.js` or `/js/script.js`.
31
+ - **Stats API key:** for reports (Plausible's Business plan). Create one under **Account settings ▸ API keys**.
32
+ - **Paths not tracked:** add any area visitors sign in to.
33
+ - **Tracking:** **Off** if your site already sends its own events.
34
+
35
+ In Plausible, add `page_type` and `collection` under **Custom properties** to report on them.
36
+
37
+ ## 4. Check it works
38
+
39
+ - A public page's source has the script under `/p/js/`.
40
+ - A visit shows in Plausible's live view.
41
+ - **Analytics** in the admin shows numbers.
@@ -0,0 +1,14 @@
1
+ Plausible Analytics connects an EmDash site to [Plausible](https://plausible.io), the analytics service that counts visitors without cookies. It adds the tracking script to your pages, serves it from your own domain, and shows the numbers in the EmDash admin.
2
+
3
+ It suits site owners who want simple, privacy-friendly statistics where their editors already work.
4
+
5
+ - **No layout edits.** The plugin adds Plausible's tag to every public page through EmDash's page hooks. Paths you list, such as a members area, aren't tracked.
6
+ - **Your own domain.** A small site route passes the script and events through your site (`/p/` by default). Blockers that drop third-party analytics hosts don't drop your visitors, and the Content Security Policy stays `'self'`.
7
+ - **Both kinds of snippet.** The per-site `pa-` script and the older `script.js` with its extensions.
8
+ - **Page types in Plausible.** Each pageview carries the page type and collection as custom properties.
9
+ - **Reports in the admin.** Visitors, visits, pageviews, bounce rate and visit duration for 7 days, 30 days or 12 months, with a chart, top pages and top sources. A dashboard widget shows the last week.
10
+ - **For AI agents.** An MCP tool, `plausible_report`, returns the same numbers.
11
+
12
+ Reports use Plausible's Stats API (a Business-plan feature) and are kept for 15 minutes, so the admin doesn't ask Plausible on every visit. Sites that already send their own events can switch tracking off and keep the reports.
13
+
14
+ No cookies are set and nothing about visitors is stored.
@@ -0,0 +1,142 @@
1
+ <!-- Generated by scripts/docs.mjs from emdash-plugin.jsonc and the build output. Do not edit; run `pnpm run docs`. -->
2
+ # Plausible Analytics: reference
3
+
4
+ Exact facts about `@cherwell/emdash-plausible` 0.1.0 (registry slug `plausible`), generated from its manifest and build. For what it does and how to set it up, read [the README](../README.md).
5
+
6
+ ## Package
7
+
8
+ | Import | What it is |
9
+ | --- | --- |
10
+ | `@cherwell/emdash-plausible` | The plugin descriptor: pass it to `sandboxed` (or `plugins`) in `emdash()` in astro.config. |
11
+ | `@cherwell/emdash-plausible/sandbox` | The plugin's runtime bundle (what the sandbox loads). |
12
+ | `@cherwell/emdash-plausible/astro` | Site helpers for your Astro pages and middleware (see [Site helpers](#site-helpers)). |
13
+
14
+ Requires EmDash `>=1.0.0`. Licence: MIT.
15
+
16
+ ## Capabilities
17
+
18
+ What the plugin asks permission for when you install it, and why.
19
+
20
+ | Capability | Why |
21
+ | --- | --- |
22
+ | `hooks.page-fragments:register` | |
23
+ | `network:request` | reads reports from Plausible's Stats API (plausible.io only). |
24
+
25
+ Allowed hosts: `plausible.io`.
26
+
27
+ ## Settings
28
+
29
+ Set under **Admin ▸ Plugins ▸ Plausible Analytics ▸ Settings**. Keys are what the API and `ctx.kv` use.
30
+
31
+ | Key | Type | Default | Label |
32
+ | --- | --- | --- | --- |
33
+ | `domain` | string | | Site domain, as Plausible knows it (e.g. example.com) |
34
+ | `tracking` | select (script, off) | `script` | Tracking |
35
+ | `scriptPath` | string | `/js/script.js` | Script file, from your Plausible snippet (e.g. /js/pa-AbC123.js or /js/script.js) |
36
+ | `proxyPath` | string | `/p` | Path your site proxies Plausible on (empty loads from plausible.io) |
37
+ | `skipPaths` | string | `/_emdash` | Paths not tracked (comma-separated prefixes) |
38
+ | `pageProps` | boolean | `true` | Send the page type and collection with each pageview |
39
+ | `outbound` | boolean | `true` | Track outbound link clicks (legacy script.js only) |
40
+ | `fileDownloads` | boolean | `true` | Track file downloads (legacy script.js only) |
41
+ | `apiKey` | secret | | Stats API key, for reports in the admin |
42
+ | `cacheMinutes` | number (1–1440) | `15` | Keep reports for (minutes) before asking Plausible again |
43
+ | `dashboardUrl` | url | | Your Plausible dashboard or shared link, linked from the reports |
44
+
45
+ ## Storage
46
+
47
+ Plugin-owned collections (EmDash plugin storage), with their indexes.
48
+
49
+ _None._
50
+
51
+ ## Admin pages
52
+
53
+ | Path | Label | Group |
54
+ | --- | --- | --- |
55
+ | `/reports` | Plausible Analytics | Plausible |
56
+
57
+ Dashboard widgets: Plausible visitors (`visitors`, third).
58
+
59
+ ## Hooks
60
+
61
+ - `page:fragments`
62
+
63
+ ## Routes
64
+
65
+ Served at `/_emdash/api/plugins/plausible/<route>`. Public routes need no EmDash session; the others need the permission shown.
66
+
67
+ | Route | Methods | Access | Notes |
68
+ | --- | --- | --- | --- |
69
+ | `report` | POST | `content:edit_any` | |
70
+ | `admin` | POST | `content:edit_any` | |
71
+
72
+ ## MCP tools
73
+
74
+ Available to AI agents through EmDash's MCP server, with the same permissions as the route each calls.
75
+
76
+ ### `plausible_report`
77
+
78
+ Read the site's Plausible statistics for the last 7 days, 30 days or 12 months: visitors, visits, pageviews, bounce rate, visit duration, visitors over time, top pages and top sources.
79
+
80
+ Route `report`; needs `content:edit_any`.
81
+
82
+ | Input | Type | Required | Notes |
83
+ | --- | --- | --- | --- |
84
+ | `range` | "7d" \| "30d" \| "12mo" | yes | default "30d" |
85
+ | `fresh` | boolean | yes | default false |
86
+
87
+ ## Site helpers
88
+
89
+ Type declarations of the site helpers, as published. Import them from the paths shown.
90
+
91
+ ### `@cherwell/emdash-plausible/astro`
92
+
93
+ ```ts
94
+ //#region src/tag.d.ts
95
+ /** The part of a page the tag needs. EmDash's PublicPageContext has all of it. */
96
+ interface PageInfo {
97
+ path: string;
98
+ pageType?: string | null;
99
+ content?: {
100
+ collection: string;
101
+ } | null;
102
+ }
103
+ //#endregion
104
+ //#region src/astro.d.ts
105
+ interface RouteContext {
106
+ params: Record<string, string | undefined>;
107
+ request: Request;
108
+ clientAddress?: string;
109
+ }
110
+ interface PlausibleProxyOptions {
111
+ /** Plausible's address, for a self-hosted Plausible CE. Default https://plausible.io. */
112
+ host?: string;
113
+ /** Seconds browsers and the CDN may keep the script. Default 21600 (six hours). */
114
+ scriptMaxAge?: number;
115
+ /** For tests. */
116
+ fetch?: typeof fetch;
117
+ }
118
+ declare function plausibleProxy(opts?: PlausibleProxyOptions): {
119
+ GET: (ctx: RouteContext) => Promise<Response>;
120
+ HEAD: (ctx: RouteContext) => Promise<Response>;
121
+ POST: (ctx: RouteContext) => Promise<Response>;
122
+ };
123
+ interface PlausibleTagOptions {
124
+ /** The plugin's settings, or the same values from your own config. */
125
+ domain: string;
126
+ scriptPath?: string;
127
+ proxyPath?: string;
128
+ skipPaths?: string;
129
+ pageProps?: boolean;
130
+ outbound?: boolean;
131
+ fileDownloads?: boolean;
132
+ /** The Content Security Policy nonce, if the site uses one. */
133
+ nonce?: string;
134
+ }
135
+ /**
136
+ * The same tag the plugin adds, as HTML, for a layout's <head> when the plugin
137
+ * runs sandboxed: `<Fragment set:html={plausibleTag(opts, { path: Astro.url.pathname })} />`.
138
+ */
139
+ declare function plausibleTag(opts: PlausibleTagOptions, page: PageInfo): string;
140
+ //#endregion
141
+ export { type PageInfo, PlausibleProxyOptions, PlausibleTagOptions, plausibleProxy, plausibleTag };
142
+ ```
@@ -0,0 +1,11 @@
1
+ <!-- Generated by scripts/docs.mjs. Do not edit; run `pnpm run docs`. -->
2
+ Report a vulnerability privately through [GitHub security advisories](https://github.com/cherwell-studio/emdash-plugins/security/advisories/new), not a public issue. We reply within three working days. The latest minor release is supported.
3
+
4
+ **What it may do.** Plausible Analytics runs in EmDash's sandbox and can use only what it declares:
5
+
6
+ - `hooks.page-fragments:register`
7
+ - `network:request`: reads reports from Plausible's Stats API (plausible.io only)
8
+
9
+ **What it stores.** Its own plugin-storage collections () and settings. Secrets are `secret` settings, encrypted by EmDash.
10
+
11
+ **Public routes.** None. Everything else needs an EmDash login with the permission listed in the [reference](https://raw.githubusercontent.com/cherwell-studio/emdash-plugins/main/plugins/plausible/docs/reference.md).
@@ -0,0 +1,64 @@
1
+ {
2
+ "$schema": "./node_modules/@emdash-cms/plugin-cli/schemas/emdash-plugin.schema.json",
3
+
4
+ "slug": "plausible",
5
+ "publisher": "did:plc:aaaaaaaaaaaaaaaaaaaaaaaa",
6
+ "name": "Plausible Analytics",
7
+ "license": "MIT",
8
+ "author": { "name": "Cherwell Studio", "url": "https://cherwell.studio" },
9
+ "security": { "url": "https://github.com/cherwell-studio/emdash-plugins/security/advisories/new" },
10
+ "description": "Plausible Analytics for EmDash: the tracking script served from your own domain, and visitor reports in the admin.",
11
+ "keywords": ["analytics", "plausible", "privacy", "statistics", "reports"],
12
+ "repo": "https://github.com/cherwell-studio/emdash-plugins",
13
+
14
+ // The registry listing: long-form pages (each at most 2,000 characters) and images.
15
+ "sections": {
16
+ "description": { "file": "docs/overview.md" },
17
+ "installation": { "file": "docs/install.md" },
18
+ "faq": { "file": "docs/faq.md" },
19
+ "changelog": { "file": "CHANGELOG.md" },
20
+ "security": { "file": "docs/security.md" }
21
+ },
22
+ "release": {
23
+ "requires": { "env:emdash": ">=1.0.0" },
24
+ "artifacts": {
25
+ "icon": { "file": "assets/icon.png" },
26
+ "banner": { "file": "assets/banner.png" }
27
+ }
28
+ },
29
+
30
+ // Why each capability:
31
+ // - hooks.page-fragments:register adds Plausible's script tag to public pages. EmDash 1.6 runs page
32
+ // fragments for in-process plugins only, so a sandboxed install needs the site helper's tag instead.
33
+ // - network:request reads reports from Plausible's Stats API (plausible.io only).
34
+ "capabilities": ["hooks.page-fragments:register", "network:request"],
35
+ "allowedHosts": ["plausible.io"],
36
+
37
+ "storage": {},
38
+
39
+ "admin": {
40
+ "pages": [{ "path": "/reports", "label": "Plausible Analytics", "icon": "chart-line", "group": "Plausible" }],
41
+ "widgets": [{ "id": "visitors", "title": "Plausible visitors", "size": "third" }],
42
+ "settingsSchema": {
43
+ "domain": { "type": "string", "label": "Site domain, as Plausible knows it (e.g. example.com)" },
44
+ "tracking": {
45
+ "type": "select",
46
+ "label": "Tracking",
47
+ "default": "script",
48
+ "options": [
49
+ { "value": "script", "label": "Add Plausible's script to every public page" },
50
+ { "value": "off", "label": "Off: the site sends its own events (reports only)" }
51
+ ]
52
+ },
53
+ "scriptPath": { "type": "string", "label": "Script file, from your Plausible snippet (e.g. /js/pa-AbC123.js or /js/script.js)", "default": "/js/script.js" },
54
+ "proxyPath": { "type": "string", "label": "Path your site proxies Plausible on (empty loads from plausible.io)", "default": "/p" },
55
+ "skipPaths": { "type": "string", "label": "Paths not tracked (comma-separated prefixes)", "default": "/_emdash" },
56
+ "pageProps": { "type": "boolean", "label": "Send the page type and collection with each pageview", "default": true },
57
+ "outbound": { "type": "boolean", "label": "Track outbound link clicks (legacy script.js only)", "default": true },
58
+ "fileDownloads": { "type": "boolean", "label": "Track file downloads (legacy script.js only)", "default": true },
59
+ "apiKey": { "type": "secret", "label": "Stats API key, for reports in the admin" },
60
+ "cacheMinutes": { "type": "number", "label": "Keep reports for (minutes) before asking Plausible again", "default": 15, "min": 1, "max": 1440 },
61
+ "dashboardUrl": { "type": "url", "label": "Your Plausible dashboard or shared link, linked from the reports" }
62
+ }
63
+ }
64
+ }
package/llms.txt ADDED
@@ -0,0 +1,20 @@
1
+ # Plausible Analytics (EmDash plugin)
2
+
3
+ > Plausible Analytics for EmDash: the tracking script served from your own domain, and visitor reports in the admin.
4
+
5
+ `@cherwell/emdash-plausible` is a sandboxed plugin for EmDash CMS (Astro, Cloudflare Workers). Registry slug: `plausible`. MIT licence. Requires EmDash >=1.0.0.
6
+
7
+ Install: Admin ▸ Plugins ▸ Browse in EmDash, or `npm install @cherwell/emdash-plausible` and add it to `emdash()` in astro.config. The site helpers are imported from `@cherwell/emdash-plausible/astro`.
8
+
9
+ ## Docs
10
+
11
+ - [README](https://raw.githubusercontent.com/cherwell-studio/emdash-plugins/main/plugins/plausible/README.md): what it does, setup, site wiring, limits
12
+ - [Reference](https://raw.githubusercontent.com/cherwell-studio/emdash-plugins/main/plugins/plausible/docs/reference.md): every setting, capability, storage collection, route, MCP tool and site helper signature, generated from the code
13
+ - [Installation](https://raw.githubusercontent.com/cherwell-studio/emdash-plugins/main/plugins/plausible/docs/install.md): the shortest path to a working install
14
+ - [FAQ](https://raw.githubusercontent.com/cherwell-studio/emdash-plugins/main/plugins/plausible/docs/faq.md): common questions and troubleshooting
15
+
16
+ ## Optional
17
+
18
+ - [Changelog](https://raw.githubusercontent.com/cherwell-studio/emdash-plugins/main/plugins/plausible/CHANGELOG.md)
19
+ - [Manifest](https://raw.githubusercontent.com/cherwell-studio/emdash-plugins/main/plugins/plausible/emdash-plugin.jsonc): the plugin's declared capabilities, storage and settings
20
+ - [Source](https://github.com/cherwell-studio/emdash-plugins/blob/main/plugins/plausible/src)