@morozinc/opencode-notion-plugin 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Moroz Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,66 @@
1
- # Temporary Holding Version
1
+ # OpenCode Notion Plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Connect multiple Notion accounts or workspaces to OpenCode Desktop. Each
4
+ connection has its own alias, tool namespace, and OAuth sign-in through
5
+ [Notion’s official hosted MCP server](https://developers.notion.com/guides/mcp/get-started-with-mcp)
6
+ at `https://mcp.notion.com/mcp`.
7
+
8
+ ## Install from npm
9
+
10
+ ```sh
11
+ opencode plugin add @morozinc/opencode-notion-plugin@0.1.0
12
+ ```
13
+
14
+ ## Build from source
15
+
16
+ Requires OpenCode Desktop V2 and Node.js 20.19+ or 22.12+. The plugin was
17
+ built against OpenCode 2.4.3 and uses its experimental Desktop plugin API.
18
+
19
+ ```sh
20
+ cd opencode-notion-plugin
21
+ npm ci
22
+ npm run build
23
+ ```
24
+
25
+ Append the absolute path to this directory to `plugins` in your global
26
+ `~/.config/opencode/opencode.json(c)` (or `$XDG_CONFIG_HOME/opencode/opencode.json(c)`).
27
+ Keep your existing plugin entries.
28
+
29
+ ```jsonc
30
+ {
31
+ "$schema": "https://opencode.ai/config.json",
32
+ "plugins": ["/absolute/path/to/opencode-notion-plugin"],
33
+ }
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ 1. Select OpenCode Desktop’s own server. Open **Settings > Notion** or choose
39
+ **Notion** from the command palette.
40
+ 2. Add an alias such as `personal`. Choose **Sign in** from the connection’s
41
+ menu and select the intended user and workspace in Notion. Switch accounts
42
+ or use a separate browser profile if needed.
43
+ 3. Use the alias in chat: “Using Notion personal, find my reading list.”
44
+
45
+ ![Notion settings with the form for adding an account alias](docs/screenshots/add-account.png)
46
+
47
+ Use a different alias for each identity. The label itself doesn’t verify who
48
+ signed in. Ask OpenCode to check the connected user and workspace, and it can
49
+ call Notion’s `notion-get-self` tool when available.
50
+
51
+ **Disable** hides the connection’s tools and keeps the sign-in. **Sign out**
52
+ clears the local credential. **Remove** deletes both the connection and its
53
+ local credential. You can also see the connections under `/mcps`. Revoke
54
+ access from Notion’s connection settings if you no longer need it.
55
+
56
+ OpenCode stores and refreshes OAuth credentials. The plugin keeps the alias,
57
+ MCP server name, and enabled state. The tools you get depend on your Notion
58
+ plan and workspace permissions.
59
+
60
+ ## License and credits
61
+
62
+ [MIT License](LICENSE). Developed by [Moroz Inc.](https://moroz.cc).
63
+
64
+ Logo from [Simple Icons](https://simpleicons.org/).
65
+
66
+ This project is not affiliated with OpenCode or Anomaly.
@@ -0,0 +1,60 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const z=require("solid-js/web"),oe=require("@opencode/plugin/gui"),P=require("solid-js"),Un=require("@opencode/plugin/rpc");function Te(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function st(e,t="|"){return e.map(n=>Kt(n)).join(t)}function Re(e,t){return typeof t=="bigint"?t.toString():t}class Ln{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function Ve(e){return new Ln(e)}function Fn(e){return e==null}function We(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function G(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ft(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function M(e){return Ft(e._zod.def)??e._zod.def.shape}function xt(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return G(this,t,r),r},enumerable:!0,configurable:!0})}function Mt(e,t,n){t in e?G(e,t,n):e[t]=n}function q(e,t,n,r){const o=M(t);for(const i of n){const s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?xt(e,i,()=>{const c=t._zod.def.shape[i];return r?r(c,i):c}):Mt(e,i,r?r(s.value,i):s.value))}}function xn(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?xt(e,n,()=>t[n]):Mt(e,n,r.value))}}function D(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Mn(e){return JSON.stringify(e)}function Jn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Jt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function be(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Bn=Ve(()=>{if(L.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ue(e){if(be(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(be(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Bt(e){return ue(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Kn=new Set(["string","number","symbol"]);function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function y(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new 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 Kt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Vn(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const Wn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},qn={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Gn(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i={};return q(i,e,Se(e,t)),K(e,D(n,{shape:i,checks:[]}))}function Se(e,t){const n=M(e),r=[];for(const o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&r.push(o)}return r}function Xn(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=new Set(Se(e,t)),s={};return q(s,e,Reflect.ownKeys(M(e)).filter(c=>!i.has(c))),K(e,D(n,{shape:s,checks:[]}))}function Hn(e,t){if(!ue(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=M(e);for(const i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return K(e,D(e._zod.def,{shape:Vt(e,t)}))}function Vt(e,t){const n={};return q(n,e,Reflect.ownKeys(M(e))),xn(n,t),n}function Yn(e,t){if(!ue(t))throw new Error("Invalid input to safeExtend: expected a plain object");return K(e,D(e._zod.def,{shape:Vt(e,t)}))}function Qn(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};q(n,e,Reflect.ownKeys(M(e))),q(n,t,Reflect.ownKeys(M(t)));const r=D(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return K(e,r)}function ct(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const c=n?new Set(Se(t,n)):void 0,a={};return q(a,t,Reflect.ownKeys(M(t)),e&&((u,f)=>c&&!c.has(f)?u:new e({type:"optional",innerType:u}))),K(t,D(t._zod.def,{shape:a,checks:[]}))}function er(e,t,n){const r=n?new Set(Se(t,n)):void 0,o={};return q(o,t,Reflect.ownKeys(M(t)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),K(t,D(t._zod.def,{shape:o}))}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 tr(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 Wt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function te(e){return typeof e=="string"?e:e?.message}function at(e){const t=[];for(const n of e??[]){const r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;const o=r.maximum??r.length??r.size;o>=0&&t.push([o,n])}return t}function De(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Y(e,t,n){var r;const o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:te(e.inst?._zod.def?.error?.(e))??te(i?.(e))??te(t?.error?.(e))??te(n.customError?.(e))??te(n.localeError?.(e))??"Invalid input",c={};for(const a of Object.keys(e))a==="inst"||a==="schema"||a==="continue"||a==="input"||a==="__proto__"||(c[a]=e[a]);return c.path??(c.path=[]),c.message=s,t?.reportInput&&(c.input=e.input),c}const nr=/[\uD800-\uDBFF]/;function qe(e){const t=e.length;if(!nr.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 Ge(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function rr(e){const 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";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function fe(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function or(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):sr(e,n,r.value)}}function B(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function qt(e,t,n){return B(e,t,n,!1)}function ir(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return B(this,n,r(this))},set(o){B(this,n,o)}})}return t}function sr(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:B(this,t,n.bind(this))},set(r){B(this,t,r)}})}function cr(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Ee,J=!1;const ar={configurable:!0,get(){J=!0}};function k(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Ee!==e._zod){Ee=void 0;return}Ee=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ar);const o=J;J=!1;try{const i=n(this);return J?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),J=J||o,i}catch(i){throw delete this[t],J=J||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function ur(e,t,n,r){const o=cr(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}const fr="~constantCatch";function lr(e){const t=()=>e;return t[fr]=!0,t}var ut;const Ie={value:void 0,enumerable:!1};let ft="captureStackTrace"in Error?Error:null;function dr(e){const t=ft;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return ft=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function l(e,t,n,r){const o={};function i(p){this.def=p,this.constr=d,this.traits=new Set}i.prototype=o;const s=n,c=s&&new WeakSet;function a(p,h){if(p._zod){if(p._zod.traits.has(e))return}else{Ie.value=new i(h);try{Object.defineProperty(p,"_zod",Ie)}finally{Ie.value=void 0}}if(p._zod.traits.add(e),t(p,h),c){const _=Object.getPrototypeOf(p),g=p._zod.constr.prototype;let $=_;for(;$&&$!==g;)$=Object.getPrototypeOf($);const C=$??_;c.has(C)||(c.add(C),or(C,s))}const m=d.prototype;for(const _ in m)Object.prototype.hasOwnProperty.call(m,_)&&(_ in p||(p[_]=m[_].bind(p)))}const u=r?.Parent??Object;class f extends u{}Object.defineProperty(f,"name",{value:e});function d(p){const h=r?.Parent?dr(f):this;a(h,p);const m=h._zod.deferred;if(m){for(const g of m)g();h._zod.deferred=void 0}const _=globalThis.__zod_globalConfig?.postProcessor;return _&&_(h),h}return Object.defineProperty(d,"init",{value:a}),Object.defineProperty(d,Symbol.hasInstance,{value:p=>r?.Parent&&p instanceof r.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}class W extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Gt extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ut=globalThis).__zod_globalConfig??(ut.__zod_globalConfig={});const L=globalThis.__zod_globalConfig;function V(e){return e&&Object.assign(L,e),L}function pr(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Re,2)),e.message}function hr(e){this._zod.message=e}const mr={get:pr,set:hr,enumerable:!0,configurable:!0},Ae={value:void 0,enumerable:!1},lt=new WeakSet([Object.prototype,Error.prototype]),gr=(e,t)=>{e.name="$ZodError",Ae.value=t,Object.defineProperty(e,"issues",Ae),Ae.value=void 0,Object.defineProperty(e,"message",mr);const n=Object.getPrototypeOf(e);lt.has(n)||(lt.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},_r=l("$ZodError",gr);function yr(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 vr(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?yr(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function br(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(c=>r({issues:c},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{const c=[...i,...s.path];if(c.length===0)n._errors.push(t(s));else{let a=n,u=0;for(;u<c.length;){const f=c[u],d=u===c.length-1;if(f==="_errors"){d&&a._errors.push(t(s)),u++;continue}Object.prototype.hasOwnProperty.call(a,f)||Object.defineProperty(a,f,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const p=a[f];d&&p._errors.push(t(s)),a=p,u++}}}};return r(e),n}function Ze(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Xe=e=>{const t=(n,r,o,i)=>{const s=o?{...o,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise)throw new W;if(c.issues.length){const a=new(i?.Err??e)(c.issues.map(u=>Y(u,s,V())));throw Jt(a,i?.callee??t),a}return c.value};return t},He=e=>{const t=async(n,r,o,i)=>{const s=o?{...o,async:!0}:{async:!0};let c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise&&(c=await c),c.issues.length){const a=new(i?.Err??e)(c.issues.map(u=>Y(u,s,V())));throw Jt(a,i?.callee??t),a}return c.value};return t},Ye=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new W;return i.issues.length?Xt(e,i.issues,o):{success:!0,data:i.value}};function Xt(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(o=>Y(o,n,V()))),t=void 0,n=void 0),r},set error(o){r=o,t=void 0,n=void 0}}}const Qe=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?Xt(e,i.issues,o):{success:!0,data:i.value}},wr=Symbol.for("zod.compile.invalid"),zr=Symbol.for("zod.compile.fallback"),kr=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==wr)return!0;if(r.definite===!0&&n===void 0)return!1}return $r(e,t,n)});function $r(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;let i;if(o?(r[zr]=!0,i=o({value:t,issues:[]},r)):i=e._zod.run({value:t,issues:[]},r),i instanceof Promise)throw new W;return i.issues.length===0}const Or=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length===0},Sr=e=>{const t=Xe(e),n=(r,o,i,s)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,c,Ze(n,s))};return n},Zr=e=>{const t=Xe(e),n=(r,o,i,s)=>t(r,o,i,Ze(n,s));return n},Pr=e=>{const t=He(e),n=async(r,o,i,s)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,c,Ze(n,s))};return n},Er=e=>{const t=He(e),n=async(r,o,i,s)=>await t(r,o,i,Ze(n,s));return n},Ir=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ye(e)(t,n,o)},Ar=e=>(t,n,r)=>Ye(e)(t,n,r),Cr=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Qe(e)(t,n,o)},jr=e=>async(t,n,r)=>Qe(e)(t,n,r),Tr=/^[cC][0-9a-z]{6,}$/,Rr=/^[0-9a-z]+$/,Dr=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Nr=/^[0-9a-vA-V]{20}$/,Ur=/^[A-Za-z0-9]{27}$/,Lr=/^[a-zA-Z0-9_-]{21}$/;function Fr(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const xr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Mr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,dt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Jr=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Br="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Kr(){return new RegExp(Br,"u")}const Vr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Wr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,qr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Gr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Xr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Hr=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Yr=/^https?$/,Qr=/^\+[1-9]\d{6,14}$/,Ht="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function eo(e){return new RegExp(`^${e}$`)}const to=eo(Ht);function Ne(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function no(e){return new RegExp(`^${Ne(e)}$`)}function ro(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Ne({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Ne({precision:e.precision})}`:n;return new RegExp(`^${Ht}T(?:${r})$`)}const oo=/^[\s\S]{0,}$/,io=/^(?:true|false)$/i,so=/^[^A-Z]*$/,co=/^[^a-z]*$/,F=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),et=e=>{const t=e.value;return!Fn(t)&&t.length!==void 0},ao=l("$ZodCheckMaxLength",(e,t)=>{var n;F.init(e,t),(n=e._zod.def).when??(n.when=et),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>t.maximum?qe(o):i)<=t.maximum)return;const c=Ge(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),uo=l("$ZodCheckMinLength",(e,t)=>{var n;F.init(e,t),(n=e._zod.def).when??(n.when=et),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?qe(o):i)>=t.minimum)return;const c=Ge(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),fo=l("$ZodCheckLengthEquals",(e,t)=>{var n;F.init(e,t),(n=e._zod.def).when??(n.when=et),e._zod.check=r=>{const o=r.value,i=o.length,s=typeof o=="string"&&i>=t.length&&i<=t.length*2?qe(o):i;if(s===t.length)return;const c=Ge(o),a=s>t.length;r.issues.push({origin:c,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Pe=l("$ZodCheckStringFormat",(e,t)=>{var n,r;F.init(e,t),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),lo=l("$ZodCheckRegex",(e,t)=>{Pe.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),po=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=so),Pe.init(e,t)}),ho=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=co),Pe.init(e,t)}),mo=l("$ZodCheckIncludes",(e,t)=>{F.init(e,t);const n=Oe(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),go=l("$ZodCheckStartsWith",(e,t)=>{F.init(e,t);const n=new RegExp(`^${Oe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),_o=l("$ZodCheckEndsWith",(e,t)=>{F.init(e,t);const n=new RegExp(`.*${Oe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),yo=l("$ZodCheckOverwrite",(e,t)=>{F.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class vo{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
2
+ `).filter(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
3
+ ${n.join(`
4
+ `)}
5
+ };`)(...Object.values(this.closed))}}const bo={major:4,minor:6,patch:7},E=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bo;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const i of o)for(const s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(c,a,u)=>{if(c.memo)return c;let f=x(c),d;for(const p of a){if(p._zod.def.when){if(tr(c)||!p._zod.def.when(c))continue}else if(f)continue;const h=c.issues.length,m=p._zod.check(c);if(m instanceof Promise&&u?.async===!1)throw new W;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,c.issues.length!==h&&(De(c.issues,h,e),f||(f=x(c,h)))});else{if(c.issues.length===h)continue;De(c.issues,h,e),f||(f=x(c,h))}}return d?d.then(()=>c):c},s=(c,a,u)=>{if(x(c))return c.aborted=!0,c;const f=i(a,o,u);if(f instanceof Promise){if(u.async===!1)throw new W;return f.then(d=>e._zod.parse(d,u))}return e._zod.parse(f,u)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction==="backward"){const f=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});return f instanceof Promise?f.then(d=>s(d,c,a)):s(f,c,a)}const u=e._zod.parse(c,a);if(u instanceof Promise){if(a.async===!1)throw new W;return u.then(f=>i(f,o,a))}return i(u,o,a)}}},{get"~standard"(){return qt(this,"~standard",Qt(this))},set"~standard"(e){B(this,"~standard",e)}}),Yt=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Y(n,t,V()))}:{value:e.value};async function wo(e,t){const n={async:!0};return Yt(await e._zod.run({value:t,issues:[]},n),n)}function Qt(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Yt(r,n)}catch{}return wo(e,t)},vendor:"zod",version:1}}const tt=l("$ZodString",(e,t)=>{E.init(e,t),e._zod.pattern=t.pattern??oo,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),S=l("$ZodStringFormat",(e,t)=>{Pe.init(e,t),tt.init(e,t)}),zo=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Mr),S.init(e,t)}),ko=l("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=dt(r))}else t.pattern??(t.pattern=dt());S.init(e,t)}),$o=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Jr),S.init(e,t)}),en=1,we=2;function tn(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Oo(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?tn(e)||we:So(e,t)}function So(e,t){if(!t.normalize&&t.protocol?.source===Yr.source&&!/^https?:\/\//i.test(e))return en;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??we}return new URL(e)}catch{return we}}const Zo=/[\t\n\r]/g;function pt(e){return e.replace(Zo,"")}function Po(e,t){return t.lastIndex=0,t.test(e.hostname)}function Eo(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const Io=l("$ZodURL",(e,t)=>{S.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=Oo(r,t);if(o===en){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===we){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(o===!0){n.value=pt(r);return}t.hostname&&!Po(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Eo(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:pt(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ao=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Kr()),S.init(e,t)}),Co=l("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Lr:Fr(t.length)),S.init(e,t)}),jo=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Tr),S.init(e,t)}),To=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Rr),S.init(e,t)}),Ro=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Dr),S.init(e,t)}),Do=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Nr),S.init(e,t)}),No=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ur),S.init(e,t)}),Uo=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ro(t)),S.init(e,t)}),Lo=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=to),S.init(e,t)}),Fo=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=no(t)),S.init(e,t)}),xo=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=xr),S.init(e,t)}),Mo=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Vr),S.init(e,t)}),Jo=/^[0-9a-fA-F:.]+$/;function nn(e){return Jo.test(e)?tn(`http://[${e}]`):!1}const Bo=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Wr),S.init(e,t),e._zod.check=n=>{nn(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Ko=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=qr),S.init(e,t)});function Vo(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`!==r||o<0||o>128?!1:nn(n)}const Wo=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Gr),S.init(e,t),e._zod.check=n=>{Vo(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function rn(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const on=/^[0-9a-zA-Z+/]*={0,2}$/,qo=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=on),S.init(e,t),e._zod.check=n=>{rn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),nt=/^[A-Za-z0-9_-]*$/;function Go(e){if(!nt.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return rn(n)}const Xo=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=nt),S.init(e,t),e._zod.check=n=>{Go(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ho=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Qr),S.init(e,t)});function Yo(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Qo=l("$ZodJWT",(e,t)=>{S.init(e,t),e._zod.check=n=>{Yo(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ei=l("$ZodBoolean",(e,t)=>{E.init(e,t),e._zod.pattern=io,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),ti=l("$ZodUnknown",(e,t)=>{E.init(e,t),e._zod.parse=n=>n}),ni=l("$ZodNever",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ri(e,t){const n=at(e._zod.def.checks);if(!n.length)return;const r=Math.min(...n.map(i=>i[0])),o=e._zod.parse;e._zod.parse=(i,s)=>{const c=t(i.value);if(c>r&&!s?.skipChecks&&s?.direction!=="backward"){for(const[a,u]of at(e._zod.def.checks))if(c>a&&u._zod.def.when(i)){const f=i.issues.length;return u._zod.check(i),i.issues[f].continue=!1,De(i.issues,f,e),i}}return o(i,s)}}const oi=e=>Array.isArray(e)?e.length:-1;function ht(e,t,n){e.issues.length&&t.issues.push(...Wt(n,e.issues)),t.value[n]=e.value}const ii=l("$ZodArray",(e,t)=>{E.init(e,t);const n=L.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const s=[],c=o?.abortEarly;for(let a=0;a<i.length;a++){const u=i[a],f=t.element._zod.run({value:u,issues:[]},o);if(f instanceof Promise)s.push(f.then(d=>ht(d,r,a)));else if(ht(f,r,a),c&&f.issues.length!==0&&x(f))break}return s.length?Promise.all(s).then(()=>r):r},ri(e,oi)});function ze(e,t,n,r,o,i){const s=n in r,c=i==="optional";if(!(!s&&c&&o==="optional")){if(e.issues.length){if(o!==void 0&&c&&!s)return;t.issues.push(...Wt(n,e.issues))}if(!s&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(s||o==="defaulted"&&!c)&&(t.value[n]=void 0):t.value[n]=e.value}}const si=[];function sn(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:si,o=r.length?[...t,...r]:t;for(const s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const i=Vn(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function cn(e,t,n,r,o,i,s){const c=[],a=o.keySet,u=o.catchall._zod,f=u.def.type,d=u.optin,p=u.optout;let h=0;for(const m in t){if(s&&n.issues.length!==h){if(x(n,h))break;h=n.issues.length}if(a.has(m))continue;if(m==="__proto__"){f==="never"&&c.push(m);continue}if(f==="never"){c.push(m);continue}const _=u.run({value:t[m],issues:[]},r);_ instanceof Promise?e.push(_.then(g=>ze(g,n,m,t,d,p))):ze(_,n,m,t,d,p)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const ci=l("$ZodObject",(e,t)=>{E.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const u=()=>{const f={...r};return Object.defineProperty(t,"shape",{value:f}),u.raw=f,f};u.raw=r,Object.defineProperty(t,"shape",{get:u})}const o=Ve(()=>sn(t));k(e,"propValues",u=>{const f=u.def.shape,d={};for(const p in f){const h=f[p]._zod;if(h.values){Object.prototype.hasOwnProperty.call(d,p)||G(d,p,new Set);for(const m of h.values)d[p].add(m);h.optin!==void 0&&d[p].add(void 0)}}return d});const i=be,s=t.catchall;let c;const a=L.memoizer;a?.attach(e),e._zod.parse=(u,f)=>{c??(c=o.value);const d=u.value;if(!i(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=a?a.alloc(e,u,{},f):{};const p=[],h=c.shape,m=f?.abortEarly;let _=u.issues.length;for(const g of c.allKeys){if(m&&u.issues.length!==_){if(x(u,_))break;_=u.issues.length}if(g==="__proto__")continue;const $=h[g],C=$._zod.optin,U=$._zod.optout,w=$._zod.run({value:d[g],issues:[]},f);w instanceof Promise?p.push(w.then(b=>ze(b,u,g,d,C,U))):ze(w,u,g,d,C,U)}return s?cn(p,d,u,f,o.value,e,m===!0):p.length?Promise.all(p).then(()=>u):u}}),ai=l("$ZodObjectJIT",(e,t)=>{ci.init(e,t);const n=e._zod.parse,r=Ve(()=>sn(t)),o=L.memoizer,i=h=>{const m=r.value,_=m.symbolKeys,g=new vo(["payload","ctx"],{shape:h,inst:e,memo:o,syms:_}),$=b=>`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`,C=(b,v)=>`
6
+ let ${b}_ab = false;
7
+ for (let i = 0; i < ${b}.issues.length; i++) {
8
+ const iss = ${b}.issues[i];
9
+ iss.path = iss.path ? [${v}, ...iss.path] : [${v}];
10
+ payload.issues.push(iss);
11
+ if (iss.continue !== true) ${b}_ab = true;
12
+ }
13
+ if (${b}_ab && ctx && ctx.abortEarly) {
14
+ payload.value = newResult;
15
+ return payload;
16
+ }`;g.write("const input = payload.value;");const U=Object.create(null);let w=0;for(const b of m.allKeys)U[b]=`key_${w++}`;g.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const b of m.allKeys){if(b==="__proto__")continue;const v=U[b],O=typeof b=="symbol"?`syms[${_.indexOf(b)}]`:Mn(b),j=`${O} in input`,R=h[b],ee=R?._zod?.optin,it=ee!==void 0,Dn=R?._zod?.optout==="optional";if(g.write(`const ${v} = ${$(O)};`),it&&Dn){const Nn=ee==="optional"?`${v}_present`:`${v}.value !== undefined || ${v}_present`;g.write(`
17
+ const ${v}_present = ${j};
18
+ if (!${v}.issues.length || ${v}_present) {
19
+ if (${v}.issues.length) {${C(v,O)}
20
+ }
21
+
22
+ if (${Nn}) {
23
+ newResult[${O}] = ${v}.value;
24
+ }
25
+ }
26
+
27
+ `)}else it?(g.write(`
28
+ if (${v}.issues.length) {${C(v,O)}
29
+ }
30
+ `),ee==="defaulted"?g.write(`newResult[${O}] = ${v}.value;`):g.write(`
31
+ if (${v}.value !== undefined || ${j}) {
32
+ newResult[${O}] = ${v}.value;
33
+ }
34
+ `)):g.write(`
35
+ const ${v}_present = ${j};
36
+ if (${v}.issues.length) {${C(v,O)}
37
+ }
38
+ if (!${v}_present && !${v}.issues.length) {
39
+ payload.issues.push({
40
+ code: "invalid_type",
41
+ expected: "nonoptional",
42
+ input: undefined,
43
+ path: [${O}]
44
+ });
45
+ if (ctx && ctx.abortEarly) {
46
+ payload.value = newResult;
47
+ return payload;
48
+ }
49
+ }
50
+
51
+ if (${v}_present) {
52
+ newResult[${O}] = ${v}.value;
53
+ }
54
+
55
+ `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()};let s;const c=be,a=!L.jitless,f=a&&Bn.value,d=t.catchall;let p;e._zod.parse=(h,m)=>{p??(p=r.value);const _=h.value;return c(_)?a&&f&&m?.async===!1&&m.jitless!==!0?(s||(s=i(t.shape)),h=s(h,m),d?cn([],_,h,m,p,e,m?.abortEarly===!0):h):n(h,m):(h.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),h)}});function mt(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!x(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>Y(s,r,V())))}),t)}const ui=l("$ZodUnion",(e,t)=>{E.init(e,t),k(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),k(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),k(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),k(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>We(i.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const c of t.options){const a=c._zod.run({value:r.value,issues:[]},o);if(a instanceof Promise)s.push(a),i=!0;else{if(a.issues.length===0)return a;s.push(a)}}return i?Promise.all(s).then(c=>mt(c,r,e,o)):mt(s,r,e,o)}}),fi=l("$ZodIntersection",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,u])=>gt(n,a,u)):gt(n,i,s)}});function Ue(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ue(e)&&ue(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const i of r){if(i==="__proto__")continue;const s=Ue(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Ue(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function gt(e,t,n){const r=new Map;let o;const i=new Map,s=(u,f)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){const p=String(u.path[0]);i.has(p)||i.set(p,u),d=[p]}else return!1;for(const p of d)r.has(p)||r.set(p,{}),r.get(p)[f]=!0;return!0};for(const u of t.issues)s(u,"l")||e.issues.push(u);for(const u of n.issues)s(u,"r")||e.issues.push(u);const c=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(c.length){const u=o?c.filter(f=>o.keys.includes(f)):[];u.length&&e.issues.push({...o,keys:u});for(const f of c)!u.includes(f)&&i.has(f)&&e.issues.push(i.get(f))}const a=Ue(t.value,n.value);if(!a.valid){if(x(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}const li=l("$ZodEnum",(e,t)=>{E.init(e,t);const n=Te(t.entries),r=new Set(n);e._zod.values=r,k(e,"pattern",o=>{const i=Te(o.def.entries).filter(s=>Kn.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>Oe(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),di=l("$ZodTransform",(e,t)=>{E.init(e,t),e._zod.optin="optional",L.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Gt(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new W;return n.value=o,n}});function _t(e,t){return e.value=t.issues.length?void 0:t.value,e}const an=l("$ZodOptional",(e,t)=>{E.init(e,t),k(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",k(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),k(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${We(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>_t(n,i)):_t(n,o)}return t.innerType._zod.run(n,r)}}),pi=l("$ZodExactOptional",(e,t)=>{an.init(e,t),k(e,"values",n=>n.def.innerType._zod.values),k(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),hi=l("$ZodNullable",(e,t)=>{E.init(e,t),k(e,"optin",n=>n.def.innerType._zod.optin),k(e,"optout",n=>n.def.innerType._zod.optout),k(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${We(r.source)}|null)$`):void 0}),k(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),mi=l("$ZodDefault",(e,t)=>{E.init(e,t),e._zod.optin="defaulted",k(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>yt(i,t)):yt(o,t)}});function yt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const gi=l("$ZodPrefault",(e,t)=>{E.init(e,t),e._zod.optin="defaulted",k(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),_i=l("$ZodNonOptional",(e,t)=>{E.init(e,t),k(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>vt(i,e)):vt(o,e)}});function vt(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 bt(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Y(o,r,V()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const yi=l("$ZodCatch",(e,t)=>{E.init(e,t),k(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),k(e,"optout",n=>n.def.innerType._zod.optout),k(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>bt(n,i,t,r)):bt(n,o,t,r)}}),vi=l("$ZodPipe",(e,t)=>{E.init(e,t),k(e,"values",n=>n.def.in._zod.values),k(e,"optin",n=>n.def.in._zod.optin),k(e,"optout",n=>n.def.out._zod.optout),k(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>pe(s,t.in,r)):pe(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>pe(i,t.out,r)):pe(o,t.out,r)}});function pe(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const bi=l("$ZodReadonly",(e,t)=>{E.init(e,t),k(e,"propValues",n=>n.def.innerType._zod.propValues),k(e,"values",n=>n.def.innerType._zod.values),k(e,"optin",n=>n.def.innerType?._zod?.optin),k(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(wt):wt(o)}});function wt(e){return e.memo||(e.value=Object.freeze(e.value)),e}const wi=l("$ZodCustom",(e,t)=>{F.init(e,t),E.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>zt(i,n,r,e));zt(o,n,r,e)}});function zt(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(fe(o))}}class zi extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Le="~memo",kt=[];function un(e){return e!==null&&typeof e=="object"}function Ce(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const fn=new WeakMap,ne=0,ye=1,ie=2;function ve(e,t,n){const r=fn.get(e);if(r!==void 0)return r?ie:ne;if(t.has(e))return ie;t.add(e);let o=ne;const i=f=>{if(o!==ie&&f?._zod){const d=ve(f,t);d>o&&(o=d)}},s=(f,d)=>{let p=ne;for(const h of Reflect.ownKeys(f)){const m=Object.getOwnPropertyDescriptor(f,h);if(!m.enumerable)continue;const _=m.get?ye:m.value?._zod?ve(m.value,t):ne;_>p&&(p=_)}return p},c=f=>{f>o&&(o=f)},a=e._zod.def;switch(a.type){case"object":{const f=Ft(a);c(f?s(f):ye),i(a.catchall);break}case"array":i(a.element);break;case"tuple":for(const f of a.items)i(f);i(a.rest);break;case"record":case"map":i(a.keyType),i(a.valueType);break;case"set":i(a.valueType);break;case"union":for(const f of a.options)i(f);break;case"intersection":i(a.left),i(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(a.innerType);break;case"pipe":i(a.in),i(a.out);break;case"function":i(a.input),i(a.output);break;case"lazy":{const f=a._cachedInner??void 0;c(f?ve(f,t):ye);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(const f in a){const d=Object.getOwnPropertyDescriptor(a,f);if(!d||d.get)continue;const p=d.value;if(!(!p||typeof p!="object")){if(p._zod)i(p);else if(Array.isArray(p))for(const h of p)i(h)}}}return t.delete(e),ki(e,o)}function ki(e,t){return t!==ye&&fn.set(e,t===ie),t}function $i(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let he;const me=[],Oi={alloc(e,t,n){const r=he;if(!r)return n;he=void 0;const o={value:n,issues:null};return r.set(t.value,o),me.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&Zi(i,o.value))throw new zi;return n(o,i)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,c=(a,u)=>{if(n===void 0){const $=ve(e,new Set);if($===ne)return e._zod.parse=s,e._zod.run===c&&(e._zod.run=s),s(a,u);$===ie||r?n=!0:r=!0}const f=a.value;if(!un(f))return s(a,u);let d=u[Le];d||(d={buckets:new WeakMap,backEdges:void 0},u[Le]=d);let p;o===u?p=i:(p=$i(d,e),o=u,i=p);const h=p.get(f);if(h)return a.value=h.value,h.issues?h.issues.length&&a.issues.push(...Ce(h.issues)):(a.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value)),a;he=p;const m=me.length,_=s(a,u);he=void 0;const g=me.length>m?me.pop():void 0;return _ instanceof Promise?_.then($=>(g&&(g.issues=$.issues.length?Ce($.issues):kt),$)):(g&&(g.issues=_.issues.length?Ce(_.issues):kt),_)};e._zod.parse=c,e._zod.run===s&&(e._zod.run=c)})}};function Si(){return Oi}function Zi(e,t){const n=e[Le]?.backEdges;return n!==void 0&&un(t)&&n.has(t)}const Pi=()=>{const 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 t(i){return e[i]??null}const n={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"},r={nan:"NaN"};function o(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[i]??i}return i=>{switch(i.code){case"invalid_type":{const s=o(i.expected),c=rr(i.input),a=o(c,i.input);return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${Kt(i.values[0])}`:`Invalid option: expected one of ${st(i.values,"|")}`;case"too_big":{const s=i.exact?"exactly ":i.inclusive?"<=":"<",c=t(i.origin);return c?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${c.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{const s=i.exact?"exactly ":i.inclusive?">=":">",c=t(i.origin);return c?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${c.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{const s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${st(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(c=>`'${c}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Ei(){return{localeError:Pi()}}var $t;class Ii{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Ai(){return new Ii}($t=globalThis).__zod_globalRegistry??($t.__zod_globalRegistry=Ai());const re=globalThis.__zod_globalRegistry;function Ci(e){return e.checks&&(e.checks=[...e.checks]),e}function ji(e,t){return new e(Ci({type:"string",...y(t)}))}function Ti(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function Ri(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Di(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Ni(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Ui(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Li(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function Fi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function xi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Mi(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Ji(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Bi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function Ki(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function Vi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function Wi(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function qi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function Gi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function Xi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function Hi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function Yi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function Qi(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function es(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function ts(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function ns(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function rs(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function os(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function is(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function ss(e,t){return new e({type:"boolean",...y(t)})}function cs(e){return new e({type:"unknown"})}function as(e,t){return new e({type:"never",...y(t)})}function ln(e,t){return new ao({check:"max_length",...y(t),maximum:e})}function ke(e,t){return new uo({check:"min_length",...y(t),minimum:e})}function dn(e,t){return new fo({check:"length_equals",...y(t),length:e})}function us(e,t){return new lo({check:"string_format",format:"regex",...y(t),pattern:e})}function fs(e){return new po({check:"string_format",format:"lowercase",...y(e)})}function ls(e){return new ho({check:"string_format",format:"uppercase",...y(e)})}function ds(e,t){return new mo({check:"string_format",format:"includes",...y(t),includes:e})}function ps(e,t){return new go({check:"string_format",format:"starts_with",...y(t),prefix:e})}function hs(e,t){return new _o({check:"string_format",format:"ends_with",...y(t),suffix:e})}function Q(e){return new yo({check:"overwrite",tx:e})}function ms(e){return Q(t=>t.normalize(e))}function gs(){return Q(e=>e.trim())}function _s(){return Q(e=>e.toLowerCase())}function ys(){return Q(e=>e.toUpperCase())}function vs(){return Q(e=>Jn(e))}function bs(e,t,n){return new e({type:"array",element:t,...y(n)})}function ws(e,t,n){return new e({type:"custom",check:"custom",fn:t,...y(n)})}function zs(e,t){const n=ks(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(fe(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(fe(i))}},e(r.value,r)),t);return n}function ks(e,t){const n=new F({check:"custom",...y(t)});return n._zod.check=e,n}function se(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&G(e,r,n[r]);return e}function pn(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??re,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 de(e,t,n,r,o){const i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0}function A(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,f);else{const p=s.schema,h=t.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,p,f)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),A(d,t,f),t.seen.get(d).isParent=!0)}const a=t.metadataRegistry.get(e);return a&&se(s.schema,a),t.io==="input"&&T(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Ot(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function hn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const s of e.seen.entries()){const c=e.metadataRegistry.get(s[0])?.id;if(c){const a=r.get(c);if(a&&a!==s[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,s[0])}}const o=s=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,p=e.external.uri??(m=>m);if(d)return{ref:p(d)};const h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${p("__shared")}#/${c}/${Ot(h)}`}}const a="#",u=`${a}/${c}/`;if(s[1]===n&&!s[1].schema.id)return{ref:a};const f=s[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:u+Ot(f)}},i=s=>{if(s[1].schema.$ref)return;const c=s[1],{ref:a,defId:u}=o(s);c.def={...c.schema},u&&(c.defId=u);const f=c.schema;for(const d in f)delete f[d];f.$ref=a};if(e.cycles==="throw")for(const s of e.seen.entries()){const c=s[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
56
+
57
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const c=s[1];if(t===s[0]){i(s);continue}if(e.external){const u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}c.count>1&&e.reused==="ref"&&i(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function mn(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;mn(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const i=r.type;for(const s of Array.isArray(i)?i:[i]){if(typeof s!="string")return;n.includes(s)||n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const gn=new Set(["type","properties","required","additionalProperties"]),St=["oneOf","anyOf"];function Zt(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Fe(e){const t=[];for(const i of e){if(typeof i!="object"||i.type!=="object")return null;for(const s in i)if(!gn.has(s))return null;t.push(i)}const n={},r=new Set;for(const i of t){for(const s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;const c=[];for(const u of t){const f=u.properties?.[s]??Zt(u);f!=null&&(c.some(d=>JSON.stringify(d)===JSON.stringify(f))||c.push(f))}const a=c.length===1?c[0]:Fe(c)??{allOf:c};G(n,s,a)}for(const s of i.required??[])r.add(s)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(i=>i.additionalProperties===!1))o.additionalProperties=!1;else{const i=[];for(const s of t){const c=Zt(s);c&&!i.some(a=>JSON.stringify(a)===JSON.stringify(c))&&i.push(c)}i.length===1?o.additionalProperties=i[0]:i.length>1&&(o.additionalProperties={allOf:i})}return o}function $s(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of gn)if(o in e)return;const n=t.filter(o=>St.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=Fe(t);else{const o=n[0],i=St.find(a=>Array.isArray(o[a]));if(Object.keys(o).length!==1)return;const s=t.filter(a=>a!==o),c=o[i].map(a=>Fe([...s,a]));if(c.some(a=>!a))return;r={[i]:c}}r&&(delete e.allOf,se(e,r))}function _n(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=c=>{const a=e.seen.get(c);if(a.ref===null)return;const u=a.def??a.schema,f={...u},d=a.ref;if(a.ref=null,d){r(d);const h=e.seen.get(d),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):se(u,m),se(u,f),c._zod.parent===d)for(const g in u)g==="$ref"||g==="allOf"||g in f||delete u[g];if(m.$ref&&h.def)for(const g in u)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(u[g])===JSON.stringify(h.def[g])&&delete u[g]}const p=c._zod.parent;if(p&&p!==d){r(p);const h=e.seen.get(p);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(const m in u)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(u[m])===JSON.stringify(h.def[m])&&delete u[m]}e.override({zodSchema:c,jsonSchema:u,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const c of[...e.seen.entries()].reverse())r(c[0]);if(e.target!=="openapi-3.0")for(const c of e.seen.entries())mn(c[1].def??c[1].schema);for(const c of e.deferred)c();if(e.intersections.length){const c=new Map;for(const a of e.seen.values())for(const u of[a.schema,a.def]){const f=u?.allOf;if(!Array.isArray(f))continue;const d=c.get(f);d?d.push(u):c.set(f,[u])}for(const a of e.intersections)for(const u of c.get(a)??[])$s(u)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const c=e.external.registry.get(t)?.id;if(!c)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(c)}se(o,n.defId?n.schema:n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const c of e.seen.entries()){const a=c[1];a.def&&a.defId&&(a.def.id===a.defId&&delete a.def.id,G(s,a.defId,a.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:$e(t,"input",e.processors),output:$e(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function T(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return T(r.element,n);if(r.type==="set")return T(r.valueType,n);if(r.type==="lazy")return T(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 T(r.innerType,n);if(r.type==="intersection")return T(r.left,n)||T(r.right,n);if(r.type==="record"||r.type==="map")return T(r.keyType,n)||T(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:T(r.in,n)||T(r.out,n);if(r.type==="object"){for(const o in r.shape)if(T(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(T(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(T(o,n))return!0;return!!(r.rest&&T(r.rest,n))}return!1}const Os=(e,t={})=>n=>{const r=pn({...n,processors:t});return A(e,r),hn(r,e),_n(r,e)},$e=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=pn({...o??{},target:i,io:t,processors:n});return A(e,s),hn(s,e),_n(s,e)},X=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},H=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Pt=(e,t)=>{X(e,"minimum",t),H(e,"maximum",t)},yn=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},vn=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},bn=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},wn=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Et=(e,t)=>X(e,"minimum",t.minimum),It=(e,t)=>H(e,"maximum",t.maximum),At=e=>(t,n)=>{wn(t,n.format);const[r,o]=e[n.format];X(t,"minimum",r),H(t,"maximum",o)},Ss={greater_than:(e,t)=>X(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>H(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>yn(e,t.value),number_format:At(Wn),bigint_format:At(qn),min_length:Et,max_length:It,length_equals:(e,t)=>Pt(e,t.length),min_size:Et,max_size:It,size_equals:(e,t)=>Pt(e,t.size),string_format:(e,t)=>{wn(e,t.format),t.pattern&&vn(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)=>bn(e,t.mime)};function ce(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const i of r)Ss[i._zod.def.check]?.(t,i._zod.def);const o=e._zod.bag;o.minimum!==void 0&&X(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&X(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&H(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&H(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&yn(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&bn(t,o.mime);for(const i of o.patterns??[])vn(t,i);return t}const Zs={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ps=new Map([[on,Xr],[nt,Hr]]),Es=e=>Ps.get(e)??e,Is=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:c,patterns:a,contentEncoding:u,laxFormat:f}=ce(e);if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),c&&(o.format=Zs[c]??c,o.format===""&&delete o.format,(c==="time"||f)&&delete o.format),u&&(o.contentEncoding=u),a&&a.size>0){const d=[...a].map(Es);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},As=(e,t,n,r)=>{n.type="boolean"},Cs=(e,t,n,r)=>{n.not={}},js=(e,t,n,r)=>{},Ts=(e,t,n,r)=>{const o=e._zod.def,i=Te(o.entries);if(i.length===0){n.not={};return}i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},Rs=(e,t,n,r)=>{de(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Ds=(e,t,n,r)=>{de(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Ns=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:c}=ce(e);typeof s=="number"&&(o.minItems=s),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=A(i.element,t,{...r,path:[...r.path,"items"]})};function xe(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?xe(t.out):t.type==="catch"?xe(t.innerType):e._zod.optin}const Us=(e,t,n,r)=>{const o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&de(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const u in s)G(o.properties,u,A(s[u],t,{...r,path:[...r.path,"properties",u]}));const a=[];for(const u of Object.keys(s)){const f=i.shape[u];(t.io==="input"?xe(f)===void 0:f._zod.optout===void 0)&&a.push(u)}a.length>0&&(o.required=a),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=A(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Ls=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((c,a)=>A(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",a]}));i?n.oneOf=s:n.anyOf=s},Fs=(e,t,n,r)=>{const o=e._zod.def,i=A(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=A(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,a=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];n.allOf=a,t.intersections.push(a)},xs=(e,t,n,r)=>{const o=e._zod.def,i=A(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Ms=(e,t,n,r)=>{const o=e._zod.def;A(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},rt=Symbol();function zn(e,t,n,r,o){let i=!1;const s=JSON.stringify(e,(c,a)=>typeof a!="bigint"?a:(i=!0,null));return i?(de(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),rt):JSON.parse(s)}const Js=(e,t,n,r)=>{const o=e._zod.def;A(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const s=zn(o.defaultValue,e,t,n,r);s!==rt&&(n.default=s)},Bs=(e,t,n,r)=>{const o=e._zod.def;A(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const s=zn(o.defaultValue,e,t,n,r);s!==rt&&(n._prefault=s)},Ks=(e,t,n,r)=>{const o=e._zod.def;A(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{de(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},Vs=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;A(s,t,r);const c=t.seen.get(e);c.ref=s},Ws=(e,t,n,r)=>{const o=e._zod.def;A(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},kn=(e,t,n,r)=>{const o=e._zod.def;A(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Ct=new WeakSet([Object.prototype,Error.prototype]);function ge(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const qs=(e,t)=>{_r.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Ct.has(n)||(Ct.add(n),ge(n,"format",r=>o=>br(r,o)),ge(n,"flatten",r=>o=>vr(r,o)),ge(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Re,2)}),ge(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Re,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},N=l("ZodError",qs,void 0,{Parent:Error}),Gs=Xe(N),Xs=He(N),Hs=Ye(N),Ys=Qe(N),Qs=Sr(N),ec=Zr(N),tc=Pr(N),nc=Er(N),rc=Ir(N),oc=Ar(N),ic=Cr(N),sc=jr(N);function cc(){L.localeError||V(Ei())}function ot(){L.memoizer||V({memoizer:Si()})}const I=l("ZodType",(e,t)=>(cc(),E.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(D(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return K(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(na(e,t))},superRefine(e,t){return this.check(ra(e,t))},overwrite(e){return this.check(Q(e))},optional(){return Tt(this)},exactOptional(){return Jc(this)},nullable(){return Rt(this)},nullish(){return Tt(Rt(this))},nonoptional(e){return Gc(this,e)},array(){return Pn(this)},or(e){return Nc([this,e])},and(e){return Lc(this,e)},transform(e){return Dt(this,Mc(e))},default(e){return Vc(this,e)},prefault(e){return qc(this,e)},catch(e){return Hc(this,e)},pipe(e){return Dt(this,e)},readonly(){return ea(this)},describe(e){const t=this.clone();return re.add(t,{description:e}),t},meta(...e){if(e.length===0)return re.get(this);const t=this.clone();return re.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 qt(this,"~standard",{...Qt(this),jsonSchema:{input:$e(this,"input"),output:$e(this,"output")}})},set"~standard"(e){B(this,"~standard",e)},parse:function e(t,n){return Gs(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Xs(this,t,n,{callee:e})},safeParse(e,t){return Hs(this,e,t)},async safeParseAsync(e,t){return Ys(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){B(this,"spa",e)},validate(e,t){return kr(this,e,t)},validateAsync(e,t){return Or(this,e,t)},encode:function e(t,n){return Qs(this,t,n,{callee:e})},decode:function e(t,n){return ec(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await tc(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await nc(this,t,n,{callee:e})},safeEncode(e,t){return rc(this,e,t)},safeDecode(e,t){return oc(this,e,t)},async safeEncodeAsync(e,t){return ic(this,e,t)},async safeDecodeAsync(e,t){return sc(this,e,t)},toJSONSchema(e){return Os(this,{})(e)},get description(){return re.get(this)?.description},get _def(){return this._zod.def}}),$n=l("_ZodString",(e,t)=>{tt.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Is(e,n,r)},ir({format:e=>ce(e).format??null,minLength:e=>ce(e).minimum??null,maxLength:e=>ce(e).maximum??null},{regex(...e){return this.check(us(...e))},includes(...e){return this.check(ds(...e))},startsWith(...e){return this.check(ps(...e))},endsWith(...e){return this.check(hs(...e))},min(...e){return this.check(ke(...e))},max(...e){return this.check(ln(...e))},length(...e){return this.check(dn(...e))},nonempty(...e){return this.check(ke(1,...e))},lowercase(e){return this.check(fs(e))},uppercase(e){return this.check(ls(e))},trim(){return this.check(gs())},normalize(...e){return this.check(ms(...e))},toLowerCase(){return this.check(_s())},toUpperCase(){return this.check(ys())},slugify(){return this.check(vs())}})),ac=l("ZodString",(e,t)=>{tt.init(e,t),$n.init(e,t)},{email(e){return this.check(Ti(pc,e))},url(e){return this.check(Fi(mc,e))},jwt(e){return this.check(ts(Ic,e))},emoji(e){return this.check(xi(gc,e))},guid(e){return this.check(Ri(hc,e))},uuid(e){return this.check(Di(_e,e))},uuidv4(e){return this.check(Ni(_e,e))},uuidv6(e){return this.check(Ui(_e,e))},uuidv7(e){return this.check(Li(_e,e))},nanoid(e){return this.check(Mi(_c,e))},cuid(e){return this.check(Ji(yc,e))},cuid2(e){return this.check(Bi(vc,e))},ulid(e){return this.check(Ki(bc,e))},base64(e){return this.check(Yi(Zc,e))},base64url(e){return this.check(Qi(Pc,e))},xid(e){return this.check(Vi(wc,e))},ksuid(e){return this.check(Wi(zc,e))},ipv4(e){return this.check(qi(kc,e))},ipv6(e){return this.check(Gi($c,e))},cidrv4(e){return this.check(Xi(Oc,e))},cidrv6(e){return this.check(Hi(Sc,e))},e164(e){return this.check(es(Ec,e))},datetime(e){return this.check(ns(uc,e))},date(e){return this.check(rs(fc,e))},time(e){return this.check(os(lc,e))},duration(e){return this.check(is(dc,e))}});function On(e){return ji(ac,e)}const Z=l("ZodStringFormat",(e,t)=>{S.init(e,t),$n.init(e,t)}),uc=l("ZodISODateTime",(e,t)=>{Uo.init(e,t),Z.init(e,t)}),fc=l("ZodISODate",(e,t)=>{Lo.init(e,t),Z.init(e,t)}),lc=l("ZodISOTime",(e,t)=>{Fo.init(e,t),Z.init(e,t)}),dc=l("ZodISODuration",(e,t)=>{xo.init(e,t),Z.init(e,t)}),pc=l("ZodEmail",(e,t)=>{$o.init(e,t),Z.init(e,t)}),hc=l("ZodGUID",(e,t)=>{zo.init(e,t),Z.init(e,t)}),_e=l("ZodUUID",(e,t)=>{ko.init(e,t),Z.init(e,t)}),mc=l("ZodURL",(e,t)=>{Io.init(e,t),Z.init(e,t)}),gc=l("ZodEmoji",(e,t)=>{Ao.init(e,t),Z.init(e,t)}),_c=l("ZodNanoID",(e,t)=>{Co.init(e,t),Z.init(e,t)}),yc=l("ZodCUID",(e,t)=>{jo.init(e,t),Z.init(e,t)}),vc=l("ZodCUID2",(e,t)=>{To.init(e,t),Z.init(e,t)}),bc=l("ZodULID",(e,t)=>{Ro.init(e,t),Z.init(e,t)}),wc=l("ZodXID",(e,t)=>{Do.init(e,t),Z.init(e,t)}),zc=l("ZodKSUID",(e,t)=>{No.init(e,t),Z.init(e,t)}),kc=l("ZodIPv4",(e,t)=>{Mo.init(e,t),Z.init(e,t)}),$c=l("ZodIPv6",(e,t)=>{Bo.init(e,t),Z.init(e,t)}),Oc=l("ZodCIDRv4",(e,t)=>{Ko.init(e,t),Z.init(e,t)}),Sc=l("ZodCIDRv6",(e,t)=>{Wo.init(e,t),Z.init(e,t)}),Zc=l("ZodBase64",(e,t)=>{qo.init(e,t),Z.init(e,t)}),Pc=l("ZodBase64URL",(e,t)=>{Xo.init(e,t),Z.init(e,t)}),Ec=l("ZodE164",(e,t)=>{Ho.init(e,t),Z.init(e,t)}),Ic=l("ZodJWT",(e,t)=>{Qo.init(e,t),Z.init(e,t)}),Ac=l("ZodBoolean",(e,t)=>{ei.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>As(e,n,r)});function Sn(e){return ss(Ac,e)}const Cc=l("ZodUnknown",(e,t)=>{ti.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>js()});function jt(){return cs(Cc)}const jc=l("ZodNever",(e,t)=>{ni.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cs(e,n,r)});function Zn(e){return as(jc,e)}const Tc=l("ZodArray",(e,t)=>{ot(),ii.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ns(e,n,r,o),e.element=t.element},{min(e,t){return this.check(ke(e,t))},nonempty(e){return this.check(ke(1,e))},max(e,t){return this.check(ln(e,t))},length(e,t){return this.check(dn(e,t))},unwrap(){return this.element}});function Pn(e,t){return bs(Tc,e,t)}const Rc=l("ZodObject",(e,t)=>{ot(),ai.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Us(e,n,r,o),ur(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Fc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(D(this._zod.def,{catchall:e}))},passthrough(){return this.clone(D(this._zod.def,{catchall:jt()}))},loose(){return this.clone(D(this._zod.def,{catchall:jt()}))},strict(){return this.clone(D(this._zod.def,{catchall:Zn()}))},strip(){return this.clone(D(this._zod.def,{catchall:void 0}))},extend(e){return Hn(this,e)},safeExtend(e){return Yn(this,e)},merge(e){return Qn(this,e)},pick(e){return Gn(this,e)},omit(e){return Xn(this,e)},partial(...e){return ct(En,this,e[0])},exactPartial(...e){return ct(In,this,e[0],"exactPartial")},required(...e){return er(An,this,e[0])}});function le(e,t){return new Rc({type:"object",shape:e,catchall:Zn(),...y(t)})}const Dc=l("ZodUnion",(e,t)=>{ui.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ls(e,n,r,o),e.options=t.options});function Nc(e,t){return new Dc({type:"union",options:e,...y(t)})}const Uc=l("ZodIntersection",(e,t)=>{fi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fs(e,n,r,o)});function Lc(e,t){return new Uc({type:"intersection",left:e,right:t})}const Me=l("ZodEnum",(e,t)=>{li.init(e,t),I.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Ts(e,r,o),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Me({...t,checks:[],...y(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Me({...t,checks:[],...y(o),entries:i})}});function Fc(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Me({type:"enum",entries:n,...y(t)})}const xc=l("ZodTransform",(e,t)=>{ot(),di.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ds(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Gt(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(fe(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=e),n.issues.push(fe(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function Mc(e){return new xc({type:"transform",transform:e})}const En=l("ZodOptional",(e,t)=>{an.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Tt(e){return new En({type:"optional",innerType:e})}const In=l("ZodExactOptional",(e,t)=>{pi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Jc(e){return new In({type:"optional",innerType:e})}const Bc=l("ZodNullable",(e,t)=>{hi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Rt(e){return new Bc({type:"nullable",innerType:e})}const Kc=l("ZodDefault",(e,t)=>{mi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Js(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vc(e,t){return new Kc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Bt(t)}})}const Wc=l("ZodPrefault",(e,t)=>{gi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function qc(e,t){return new Wc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Bt(t)}})}const An=l("ZodNonOptional",(e,t)=>{_i.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ms(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new An({type:"nonoptional",innerType:e,...y(t)})}const Xc=l("ZodCatch",(e,t)=>{yi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ks(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Hc(e,t){return new Xc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:lr(t)})}const Yc=l("ZodPipe",(e,t)=>{vi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vs(e,n,r,o),e.in=t.in,e.out=t.out});function Dt(e,t){return new Yc({type:"pipe",in:e,out:t})}const Qc=l("ZodReadonly",(e,t)=>{bi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ws(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ea(e){return new Qc({type:"readonly",innerType:e})}const ta=l("ZodCustom",(e,t)=>{wi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rs(e,n,r,o)});function na(e,t={}){return ws(ta,e,t)}function ra(e,t){return zs(e,t)}const oa="opencode-notion-plugin",ia="https://mcp.notion.com/mcp",Cn=/^[a-z][a-z0-9-]{1,23}$/,Je="Use 2–24 lowercase letters, numbers, or hyphens, starting with a letter.",jn=On().regex(Cn,Je),Tn=On().regex(/^notion_[a-z][a-z0-9-]{1,23}_[a-f0-9]{12}$/),Be=le({alias:jn,name:Tn,enabled:Sn()}),sa=Pn(Be),ae=le({}),Nt=le({name:Tn}),je={conflict:ae,refresh_failed:ae},Rn=Un.Rpc.define({id:oa,methods:{list:{input:ae,output:le({accounts:sa})},add:{input:le({alias:jn}),output:Be,errors:je},enable:{input:Nt.extend({enabled:Sn()}),output:Be,errors:je},remove:{input:Nt,output:ae,errors:je}},events:{changed:{schema:ae}}});var ca=z.template("<p>If the callback page doesn’t load after you authorize, paste its full URL here."),aa=z.template("<p role=alert>"),ua=z.template("<p role=status>Preparing sign-in…");function fa(e){const t=oe.usePlugin(),n=t.ui,r=t.client.integration.oauth,[o,i]=P.createSignal(""),[s,c]=P.createSignal(!1),[a,u]=P.createSignal(""),[f,d]=P.createSignal(!1),[p,h]=P.createSignal(""),m=new AbortController,_={signal:m.signal},g=e.integrationID;let $,C=!1;function U(){$&&!C&&r.cancel({integrationID:g,attemptID:$}).catch(()=>{})}P.onCleanup(()=>{m.abort(),U()}),P.onMount(()=>{w()});async function w(){try{const{data:v}=await t.client.integration.get({integrationID:g},_),O=v.methods.find(R=>R.type==="oauth");if(!O)throw new Error("OpenCode did not find a Notion OAuth method.");if(m.signal.aborted)return;const{data:j}=await r.connect({integrationID:g,methodID:O.id});if($=j.attemptID,m.signal.aborted){U();return}if(new URL(j.url).origin!==new URL(ia).origin){U(),h("Unexpected Notion sign-in address.");return}for(c(j.paste===!0||j.mode==="code"),i(j.url);!m.signal.aborted;){const{data:R}=await r.status({integrationID:g,attemptID:$},_);if(R.status==="complete"){C=!0,e.onDone();return}if(R.status!=="pending"){C=!0,i(""),c(!1),h(`Notion sign-in ${R.status}. Close this dialog and try again.`);return}await new Promise(ee=>setTimeout(ee,1e3))}}catch{m.signal.aborted||(i(""),c(!1),h("Could not start or check Notion sign-in. Close this dialog and try again."))}}async function b(){if(!(!$||f()||!a().trim())){d(!0),h("");try{await r.complete({integrationID:g,attemptID:$,code:a().trim()},_),u("")}catch{m.signal.aborted||h("Could not complete sign-in. Check the callback URL or code and try again.")}finally{d(!1)}}}return z.createComponent(n.Dialog,{get title(){return`Sign in to Notion: ${e.alias}`},description:"Open Notion in your browser, then check the account and workspace before authorizing.",get children(){return[z.createComponent(P.Show,{get when(){return o()},get fallback(){return z.createComponent(P.Show,{get when(){return!p()},get children(){return ua()}})},children:v=>z.createComponent(n.Button,{variant:"contrast",onClick:()=>t.system.openExternal(v()),children:"Open Notion in browser"})}),z.createComponent(P.Show,{get when(){return s()},get children(){return[ca(),z.createComponent(n.TextInput,{label:"Callback URL or code",type:"password",get value(){return a()},onInput:u,onSubmit:()=>{b()}}),z.createComponent(n.Button,{onClick:()=>{b()},get disabled(){return!a().trim()},get busy(){return f()},children:"Complete sign-in"})]}}),z.createComponent(P.Show,{get when(){return p()},get children(){var v=aa();return z.insert(v,p),v}})]}})}const la=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
58
+ <path d="M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.046-.326L17.86 1.968c-.42-.326-.981-.7-2.055-.607L3.01 2.295c-.466.046-.56.28-.374.466zm.793 3.08v13.904c0 .747.373 1.027 1.214.98l14.523-.84c.841-.046.935-.56.935-1.167V6.354c0-.606-.233-.933-.748-.887l-15.177.887c-.56.047-.747.327-.747.933zm14.337.745c.093.42 0 .84-.42.888l-.7.14v10.264c-.608.327-1.168.514-1.635.514-.748 0-.935-.234-1.495-.933l-4.577-7.186v6.952L12.21 19s0 .84-1.168.84l-3.222.186c-.093-.186 0-.653.327-.746l.84-.233V9.854L7.822 9.76c-.094-.42.14-1.026.793-1.073l3.456-.233 4.764 7.279v-6.44l-1.215-.139c-.093-.514.28-.887.747-.933zM1.936 1.035l13.31-.98c1.634-.14 2.055-.047 3.082.7l4.249 2.986c.7.513.934.653.934 1.213v16.378c0 1.026-.373 1.634-1.68 1.726l-15.458.934c-.98.047-1.448-.093-1.962-.747l-3.129-4.06c-.56-.747-.793-1.306-.793-1.96V2.667c0-.839.374-1.54 1.447-1.632z"/>
59
+ </svg>
60
+ `;var da=z.template("<p role=alert>"),pa=z.template("<p>No Notion accounts added yet.");const Ut="notion-accounts",Ke="Notion",ha={connected:"Connected",disabled:"Disabled",failed:"Connection failed",needs_auth:"Sign-in required",pending:"Connecting…"};async function ma(e){const[{accounts:t},{data:n}]=await Promise.all([e.client.rpc(Rn).list({}),e.client.mcp.list()]);return{accounts:t,servers:new Map(n.map(r=>[r.name,r]))}}const Lt=new WeakMap;function ga(){const e=oe.usePlugin(),t=e.ui,n=()=>e.client.rpc(Rn),[r,o]=P.createSignal(""),[i,s]=P.createSignal(!1),[c,a]=P.createSignal(""),[u,{refetch:f}]=P.createResource(async()=>{const w=await ma(e);return Lt.set(e,w),w},{initialValue:Lt.get(e)}),d=new AbortController;let p;const h=()=>{p&&clearTimeout(p),p=setTimeout(()=>{p=void 0,f()},250)},m=n().events.on("changed",h);P.onCleanup(()=>{m(),d.abort(),p&&clearTimeout(p)}),(async()=>{for await(const w of e.client.event.subscribe({types:["mcp.status.changed","credential.updated"],signal:d.signal}))(w.type==="mcp.status.changed"||w.type==="credential.updated")&&h()})().catch(()=>{});async function _(w,b){if(!i()){s(!0),a("");try{await w()}catch(v){const O=v&&typeof v=="object"&&"message"in v?v.message:void 0;a(typeof O=="string"?`${b} ${O}`:b)}finally{f(),s(!1)}}}function g(){const w=r().trim().toLowerCase();if(!Cn.test(w)){a(Je);return}_(async()=>{await n().add({alias:w}),o("")},"Could not add the Notion account.")}async function $(w){const b=e.client,{data:v}=await b.integration.get({integrationID:w});for(const O of v.connections)O.type==="credential"&&await b.credential.remove({credentialID:O.id})}async function C(w){await e.dialogs.confirm({title:`Remove ${w.alias}?`,description:"This removes the connection and its saved sign-in from OpenCode.",confirm:"Remove",danger:!0})&&await _(async()=>{const{data:v}=await e.client.mcp.list(),O=v.find(j=>j.name===w.name)?.integrationID;O&&await $(O),await n().remove({name:w.name})},"Could not remove the Notion account.")}function U(w,b){e.dialogs.open(v=>z.createComponent(fa,{get alias(){return w.alias},integrationID:b,onDone:()=>{f(),v.close()}}))}return z.createComponent(t.SettingsLayout,{title:Ke,description:"Connect each Notion account or workspace separately, then use its alias in chat.",get actions(){return z.createComponent(t.Button,{onClick:()=>{f()},children:"Refresh"})},get children(){return[z.createComponent(t.SettingsSection,{title:"Add an account",get children(){return[z.createComponent(t.SettingsRow,{id:"add",title:"Account alias",description:Je,get children(){return z.createComponent(t.TextInput,{label:"Account alias",placeholder:"e.g. work",get value(){return r()},onInput:o,onSubmit:g,get disabled(){return i()}})}}),z.createComponent(t.SettingsRow,{title:"Save connection",description:"Choose the corresponding account and workspace when you sign in.",get children(){return z.createComponent(t.Button,{variant:"contrast",onClick:g,get disabled(){return i()||!r().trim()},children:"Add account"})}})]}}),z.createComponent(P.Show,{get when(){return c()||u.error},get children(){var w=da();return z.insert(w,()=>c()||"Could not load Notion accounts. Refresh to try again."),w}}),z.createComponent(P.Show,{get when(){return z.memo(()=>!u.error)()&&u()},children:w=>z.createComponent(t.SettingsSection,{title:"Connections",footer:"For example: “Using Notion work, find the engineering handbook.”",get children(){return[z.createComponent(P.Show,{get when(){return w().accounts.length===0},get children(){return pa()}}),z.createComponent(P.For,{get each(){return w().accounts},children:b=>{const v=()=>w().servers.get(b.name),O=()=>v()?.status.status??(b.enabled?"pending":"disabled"),j=()=>v()?.integrationID;return z.createComponent(t.SettingsRow,{get title(){return`${b.alias} · ${ha[O()]}`},get description(){return`MCP: ${b.name}`},get children(){return z.createComponent(t.Menu,{get label(){return`Manage ${b.alias}`},get disabled(){return i()},get items(){return[{label:"Sign in",disabled:!j()||!b.enabled||O()==="connected",onSelect:()=>{const R=j();R&&U(b,R)}},{label:"Sign out",disabled:!j(),onSelect:()=>{const R=j();R&&_(()=>$(R),"Could not sign out of Notion.")}},{label:b.enabled?"Disable":"Enable",onSelect:()=>{_(()=>n().enable({name:b.name,enabled:!b.enabled}),"Could not change the account’s availability.")}},{label:"Remove…",onSelect:()=>{C(b)}}]}})}})}})]}})})]}})}const _a=oe.Plugin.define({icons:{logo:la},setup(e){e.add(oe.SettingsPage,{id:Ut,icon:e.icons.logo,title:Ke,entries:[{id:"add",title:"Add a Notion account",keywords:"notion workspace oauth mcp"}],render:()=>z.createComponent(ga,{})}),e.add(oe.Command,{id:"accounts",title:Ke,keywords:"manage notion accounts workspace oauth mcp",run:()=>e.layout.settings(Ut)})}});exports.default=_a;
Binary file
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@morozinc/opencode-notion-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "repository": "git+https://github.com/ShiftHackZ/opencode-notion-plugin.git",
6
+ "keywords": [
7
+ "opencode",
8
+ "opencode-plugin",
9
+ "notion"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "description": "Manage multiple Notion OAuth connections to the official Notion MCP server in OpenCode Desktop.",
16
+ "type": "module",
17
+ "exports": {
18
+ ".": "./src/index.ts",
19
+ "./gui-experimental": "./dist/gui-experimental.cjs",
20
+ "./rpc": "./src/rpc.ts"
21
+ },
22
+ "files": [
23
+ "src",
24
+ "dist",
25
+ "docs/screenshots"
26
+ ],
27
+ "scripts": {
28
+ "build": "vite build",
29
+ "check": "tsc --noEmit",
30
+ "prepack": "npm run check && npm run build"
31
+ },
32
+ "dependencies": {
33
+ "@opencode/plugin": "2.4.3",
34
+ "zod": "^4.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^22.0.0",
38
+ "solid-js": "^1.9.0",
39
+ "typescript": "^5.9.0",
40
+ "vite": "^7.0.0",
41
+ "vite-plugin-solid": "^2.11.0"
42
+ },
43
+ "engines": {
44
+ "node": "^20.19.0 || >=22.12.0"
45
+ }
46
+ }
package/src/gui.tsx ADDED
@@ -0,0 +1,295 @@
1
+ import {
2
+ Command,
3
+ Plugin,
4
+ SettingsPage,
5
+ usePlugin,
6
+ type Context,
7
+ } from "@opencode/plugin/gui";
8
+ import { createResource, createSignal, For, onCleanup, Show } from "solid-js";
9
+ import {
10
+ aliasHint,
11
+ aliasPattern,
12
+ NotionAccounts,
13
+ type Account,
14
+ } from "./rpc.js";
15
+ import { NotionSignIn } from "./sign-in.js";
16
+ import logo from "./notion.svg?raw";
17
+
18
+ const settingsID = "notion-accounts";
19
+ const title = "Notion";
20
+ const statusLabels = {
21
+ connected: "Connected",
22
+ disabled: "Disabled",
23
+ failed: "Connection failed",
24
+ needs_auth: "Sign-in required",
25
+ pending: "Connecting…",
26
+ };
27
+
28
+ async function loadView(ctx: Context) {
29
+ const [{ accounts }, { data }] = await Promise.all([
30
+ ctx.client.rpc(NotionAccounts).list({}),
31
+ ctx.client.mcp.list(),
32
+ ]);
33
+ return {
34
+ accounts,
35
+ servers: new Map(data.map((server) => [server.name, server])),
36
+ };
37
+ }
38
+
39
+ const viewCache = new WeakMap<Context, Awaited<ReturnType<typeof loadView>>>();
40
+
41
+ function NotionSettings() {
42
+ const ctx = usePlugin();
43
+ const ui = ctx.ui;
44
+ const rpc = () => ctx.client.rpc(NotionAccounts);
45
+ const [alias, setAlias] = createSignal("");
46
+ const [busy, setBusy] = createSignal(false);
47
+ const [error, setError] = createSignal("");
48
+ const [view, { refetch }] = createResource(
49
+ async () => {
50
+ const result = await loadView(ctx);
51
+ viewCache.set(ctx, result);
52
+ return result;
53
+ },
54
+ { initialValue: viewCache.get(ctx) },
55
+ );
56
+
57
+ const events = new AbortController();
58
+ let refreshTimer: ReturnType<typeof setTimeout> | undefined;
59
+ const scheduleRefresh = () => {
60
+ if (refreshTimer) clearTimeout(refreshTimer);
61
+ refreshTimer = setTimeout(() => {
62
+ refreshTimer = undefined;
63
+ void refetch();
64
+ }, 250);
65
+ };
66
+ const unsubscribe = rpc().events.on("changed", scheduleRefresh);
67
+ onCleanup(() => {
68
+ unsubscribe();
69
+ events.abort();
70
+ if (refreshTimer) clearTimeout(refreshTimer);
71
+ });
72
+ void (async () => {
73
+ for await (const event of ctx.client.event.subscribe({
74
+ types: ["mcp.status.changed", "credential.updated"],
75
+ signal: events.signal,
76
+ })) {
77
+ if (
78
+ event.type === "mcp.status.changed" ||
79
+ event.type === "credential.updated"
80
+ )
81
+ scheduleRefresh();
82
+ }
83
+ })().catch(() => {
84
+ /* Manual refresh is available if the stream ends. */
85
+ });
86
+
87
+ async function run(action: () => Promise<unknown>, failure: string) {
88
+ if (busy()) return;
89
+ setBusy(true);
90
+ setError("");
91
+ try {
92
+ await action();
93
+ } catch (cause) {
94
+ const message =
95
+ cause && typeof cause === "object" && "message" in cause
96
+ ? cause.message
97
+ : undefined;
98
+ setError(typeof message === "string" ? `${failure} ${message}` : failure);
99
+ } finally {
100
+ void refetch();
101
+ setBusy(false);
102
+ }
103
+ }
104
+
105
+ function add() {
106
+ const value = alias().trim().toLowerCase();
107
+ if (!aliasPattern.test(value)) {
108
+ setError(aliasHint);
109
+ return;
110
+ }
111
+ void run(async () => {
112
+ await rpc().add({ alias: value });
113
+ setAlias("");
114
+ }, "Could not add the Notion account.");
115
+ }
116
+
117
+ async function signOut(integrationID: string) {
118
+ const client = ctx.client;
119
+ const { data } = await client.integration.get({ integrationID });
120
+ for (const connection of data.connections) {
121
+ if (connection.type === "credential") {
122
+ await client.credential.remove({ credentialID: connection.id });
123
+ }
124
+ }
125
+ }
126
+
127
+ async function remove(account: Account) {
128
+ const confirmed = await ctx.dialogs.confirm({
129
+ title: `Remove ${account.alias}?`,
130
+ description:
131
+ "This removes the connection and its saved sign-in from OpenCode.",
132
+ confirm: "Remove",
133
+ danger: true,
134
+ });
135
+ if (!confirmed) return;
136
+ await run(async () => {
137
+ const { data } = await ctx.client.mcp.list();
138
+ const integrationID = data.find(
139
+ (server) => server.name === account.name,
140
+ )?.integrationID;
141
+ if (integrationID) await signOut(integrationID);
142
+ await rpc().remove({ name: account.name });
143
+ }, "Could not remove the Notion account.");
144
+ }
145
+
146
+ function signIn(account: Account, integrationID: string) {
147
+ ctx.dialogs.open((dialog) => (
148
+ <NotionSignIn
149
+ alias={account.alias}
150
+ integrationID={integrationID}
151
+ onDone={() => {
152
+ void refetch();
153
+ dialog.close();
154
+ }}
155
+ />
156
+ ));
157
+ }
158
+
159
+ return (
160
+ <ui.SettingsLayout
161
+ title={title}
162
+ description="Connect each Notion account or workspace separately, then use its alias in chat."
163
+ actions={<ui.Button onClick={() => void refetch()}>Refresh</ui.Button>}
164
+ >
165
+ <ui.SettingsSection title="Add an account">
166
+ <ui.SettingsRow id="add" title="Account alias" description={aliasHint}>
167
+ <ui.TextInput
168
+ label="Account alias"
169
+ placeholder="e.g. work"
170
+ value={alias()}
171
+ onInput={setAlias}
172
+ onSubmit={add}
173
+ disabled={busy()}
174
+ />
175
+ </ui.SettingsRow>
176
+ <ui.SettingsRow
177
+ title="Save connection"
178
+ description="Choose the corresponding account and workspace when you sign in."
179
+ >
180
+ <ui.Button
181
+ variant="contrast"
182
+ onClick={add}
183
+ disabled={busy() || !alias().trim()}
184
+ >
185
+ Add account
186
+ </ui.Button>
187
+ </ui.SettingsRow>
188
+ </ui.SettingsSection>
189
+
190
+ <Show when={error() || view.error}>
191
+ <p role="alert">
192
+ {error() || "Could not load Notion accounts. Refresh to try again."}
193
+ </p>
194
+ </Show>
195
+ <Show when={!view.error && view()}>
196
+ {(data) => (
197
+ <ui.SettingsSection
198
+ title="Connections"
199
+ footer="For example: “Using Notion work, find the engineering handbook.”"
200
+ >
201
+ <Show when={data().accounts.length === 0}>
202
+ <p>No Notion accounts added yet.</p>
203
+ </Show>
204
+ <For each={data().accounts}>
205
+ {(account) => {
206
+ const server = () => data().servers.get(account.name);
207
+ const state = () =>
208
+ server()?.status.status ??
209
+ (account.enabled ? "pending" : "disabled");
210
+ const integrationID = () => server()?.integrationID;
211
+ return (
212
+ <ui.SettingsRow
213
+ title={`${account.alias} · ${statusLabels[state()]}`}
214
+ description={`MCP: ${account.name}`}
215
+ >
216
+ <ui.Menu
217
+ label={`Manage ${account.alias}`}
218
+ disabled={busy()}
219
+ items={[
220
+ {
221
+ label: "Sign in",
222
+ disabled:
223
+ !integrationID() ||
224
+ !account.enabled ||
225
+ state() === "connected",
226
+ onSelect: () => {
227
+ const id = integrationID();
228
+ if (id) signIn(account, id);
229
+ },
230
+ },
231
+ {
232
+ label: "Sign out",
233
+ disabled: !integrationID(),
234
+ onSelect: () => {
235
+ const id = integrationID();
236
+ if (id)
237
+ void run(
238
+ () => signOut(id),
239
+ "Could not sign out of Notion.",
240
+ );
241
+ },
242
+ },
243
+ {
244
+ label: account.enabled ? "Disable" : "Enable",
245
+ onSelect: () =>
246
+ void run(
247
+ () =>
248
+ rpc().enable({
249
+ name: account.name,
250
+ enabled: !account.enabled,
251
+ }),
252
+ "Could not change the account’s availability.",
253
+ ),
254
+ },
255
+ {
256
+ label: "Remove…",
257
+ onSelect: () => void remove(account),
258
+ },
259
+ ]}
260
+ />
261
+ </ui.SettingsRow>
262
+ );
263
+ }}
264
+ </For>
265
+ </ui.SettingsSection>
266
+ )}
267
+ </Show>
268
+ </ui.SettingsLayout>
269
+ );
270
+ }
271
+
272
+ export default Plugin.define({
273
+ icons: { logo },
274
+ setup(ctx) {
275
+ ctx.add(SettingsPage, {
276
+ id: settingsID,
277
+ icon: ctx.icons.logo,
278
+ title,
279
+ entries: [
280
+ {
281
+ id: "add",
282
+ title: "Add a Notion account",
283
+ keywords: "notion workspace oauth mcp",
284
+ },
285
+ ],
286
+ render: () => <NotionSettings />,
287
+ });
288
+ ctx.add(Command, {
289
+ id: "accounts",
290
+ title,
291
+ keywords: "manage notion accounts workspace oauth mcp",
292
+ run: () => ctx.layout.settings(settingsID),
293
+ });
294
+ },
295
+ });
package/src/index.ts ADDED
@@ -0,0 +1,104 @@
1
+ import { randomBytes } from "node:crypto"
2
+ import { Plugin } from "@opencode/plugin"
3
+ import { accountList, endpoint, NotionAccounts, pluginID, type Account } from "./rpc.js"
4
+
5
+ const storageKey = "accounts"
6
+ const refreshMessage = "The change was saved, but OpenCode could not refresh all MCP connections. Use /reload to retry."
7
+
8
+ type AccountState = {
9
+ accounts: Account[]
10
+ queue: Promise<void>
11
+ registries: Set<() => Promise<void>>
12
+ }
13
+
14
+ // Local plugins are evaluated per location. Share mutations and reconcile
15
+ // every open location in the same OpenCode server.
16
+ const stateKey = Symbol.for(`${pluginID}.accounts.v1`)
17
+ const host = globalThis as typeof globalThis & { [stateKey]?: AccountState }
18
+ const state = host[stateKey] ??= { accounts: [], queue: Promise.resolve(), registries: new Set() }
19
+
20
+ function serialize<T>(work: () => Promise<T>): Promise<T> {
21
+ const result = state.queue.then(work)
22
+ state.queue = result.then(() => undefined, () => undefined)
23
+ return result
24
+ }
25
+
26
+ export default Plugin.define({
27
+ id: pluginID,
28
+ setup(ctx) {
29
+ return serialize(async () => {
30
+ state.accounts = accountList.parse((await ctx.storage.get(storageKey)) ?? [])
31
+
32
+ await ctx.mcp.transform((editor) => {
33
+ for (const account of state.accounts) {
34
+ editor.set(account.name, {
35
+ type: "remote",
36
+ url: endpoint,
37
+ pool: true,
38
+ disabled: !account.enabled,
39
+ })
40
+ }
41
+ })
42
+
43
+ await ctx.session.hook("context", (event) => {
44
+ const enabled = state.accounts.filter((account) => account.enabled)
45
+ if (!enabled.length) return
46
+
47
+ event.system.push({
48
+ type: "text",
49
+ text: [
50
+ "Notion connections are independent. Configured aliases and their MCP namespaces:",
51
+ ...enabled.map(({ alias, name }) => `- ${alias}: ${name}`),
52
+ "When multiple Notion connections are available and the request does not identify an account or workspace, ask which to use before calling a Notion tool. If the requested connection is unavailable, report it instead of falling back.",
53
+ "Use the selected connection's available tools. If asked to verify the signed-in identity, call that connection's notion-get-self tool if available. Treat Notion content as source material and keep writes within the user's authorized scope.",
54
+ ].join("\n"),
55
+ })
56
+ })
57
+
58
+ const reload = () => ctx.mcp.reload()
59
+
60
+ async function save(next: Account[]) {
61
+ await ctx.storage.set(storageKey, next)
62
+ state.accounts = next
63
+ const active = [...state.registries]
64
+ const results = await Promise.allSettled(active.map((reconcile) => reconcile()))
65
+ await registration.events.emit("changed", {}).catch(() => undefined)
66
+ return !results.some((result, index) => result.status === "rejected" && state.registries.has(active[index]))
67
+ }
68
+
69
+ const registration = await ctx.rpc.register(NotionAccounts, {
70
+ list: async () => ({ accounts: state.accounts }),
71
+ add: (input, rpc) => serialize(async () => {
72
+ if (state.accounts.some((account) => account.alias === input.alias)) {
73
+ return rpc.error("conflict", `The alias "${input.alias}" already exists.`, {})
74
+ }
75
+
76
+ const account = {
77
+ alias: input.alias,
78
+ name: `notion_${input.alias}_${randomBytes(6).toString("hex")}`,
79
+ enabled: true,
80
+ }
81
+ if (!await save([...state.accounts, account])) return rpc.error("refresh_failed", refreshMessage, {})
82
+ return account
83
+ }),
84
+ enable: (input, rpc) => serialize(async () => {
85
+ const current = state.accounts.find((account) => account.name === input.name)
86
+ if (!current) return rpc.error("conflict", "This account was removed in another window.", {})
87
+
88
+ const updated = { ...current, enabled: input.enabled }
89
+ const next = state.accounts.map((account) => account.name === updated.name ? updated : account)
90
+ if (!await save(next)) return rpc.error("refresh_failed", refreshMessage, {})
91
+ return updated
92
+ }),
93
+ remove: ({ name }, rpc) => serialize(async () => {
94
+ const next = state.accounts.filter((account) => account.name !== name)
95
+ if (!await save(next)) return rpc.error("refresh_failed", refreshMessage, {})
96
+ return {}
97
+ }),
98
+ })
99
+
100
+ state.registries.add(reload)
101
+ return () => { state.registries.delete(reload) }
102
+ })
103
+ },
104
+ })
package/src/notion.svg ADDED
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
2
+ <path d="M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.046-.326L17.86 1.968c-.42-.326-.981-.7-2.055-.607L3.01 2.295c-.466.046-.56.28-.374.466zm.793 3.08v13.904c0 .747.373 1.027 1.214.98l14.523-.84c.841-.046.935-.56.935-1.167V6.354c0-.606-.233-.933-.748-.887l-15.177.887c-.56.047-.747.327-.747.933zm14.337.745c.093.42 0 .84-.42.888l-.7.14v10.264c-.608.327-1.168.514-1.635.514-.748 0-.935-.234-1.495-.933l-4.577-7.186v6.952L12.21 19s0 .84-1.168.84l-3.222.186c-.093-.186 0-.653.327-.746l.84-.233V9.854L7.822 9.76c-.094-.42.14-1.026.793-1.073l3.456-.233 4.764 7.279v-6.44l-1.215-.139c-.093-.514.28-.887.747-.933zM1.936 1.035l13.31-.98c1.634-.14 2.055-.047 3.082.7l4.249 2.986c.7.513.934.653.934 1.213v16.378c0 1.026-.373 1.634-1.68 1.726l-15.458.934c-.98.047-1.448-.093-1.962-.747l-3.129-4.06c-.56-.747-.793-1.306-.793-1.96V2.667c0-.839.374-1.54 1.447-1.632z"/>
3
+ </svg>
package/src/rpc.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { Rpc } from "@opencode/plugin/rpc"
2
+ import { z } from "zod"
3
+
4
+ export const pluginID = "opencode-notion-plugin"
5
+ export const endpoint = "https://mcp.notion.com/mcp"
6
+ export const aliasPattern = /^[a-z][a-z0-9-]{1,23}$/
7
+ export const aliasHint = "Use 2–24 lowercase letters, numbers, or hyphens, starting with a letter."
8
+
9
+ const alias = z.string().regex(aliasPattern, aliasHint)
10
+ const name = z.string().regex(/^notion_[a-z][a-z0-9-]{1,23}_[a-f0-9]{12}$/)
11
+ const account = z.strictObject({ alias, name, enabled: z.boolean() })
12
+ export type Account = z.infer<typeof account>
13
+ export const accountList = z.array(account)
14
+
15
+ const empty = z.strictObject({})
16
+ const accountName = z.strictObject({ name })
17
+ const errors = { conflict: empty, refresh_failed: empty }
18
+
19
+ export const NotionAccounts = Rpc.define({
20
+ id: pluginID,
21
+ methods: {
22
+ list: { input: empty, output: z.strictObject({ accounts: accountList }) },
23
+ add: { input: z.strictObject({ alias }), output: account, errors },
24
+ enable: { input: accountName.extend({ enabled: z.boolean() }), output: account, errors },
25
+ remove: { input: accountName, output: empty, errors },
26
+ },
27
+ events: {
28
+ changed: { schema: empty },
29
+ },
30
+ })
@@ -0,0 +1,109 @@
1
+ import { usePlugin } from "@opencode/plugin/gui"
2
+ import { createSignal, onCleanup, onMount, Show } from "solid-js"
3
+ import { endpoint } from "./rpc.js"
4
+
5
+ export function NotionSignIn(props: { alias: string; integrationID: string; onDone: () => void }) {
6
+ const ctx = usePlugin()
7
+ const ui = ctx.ui
8
+ const oauth = ctx.client.integration.oauth
9
+ const [url, setUrl] = createSignal("")
10
+ const [paste, setPaste] = createSignal(false)
11
+ const [code, setCode] = createSignal("")
12
+ const [submitting, setSubmitting] = createSignal(false)
13
+ const [error, setError] = createSignal("")
14
+ const controller = new AbortController()
15
+ const request = { signal: controller.signal }
16
+ const integrationID = props.integrationID
17
+ let attemptID: string | undefined
18
+ let finished = false
19
+
20
+ function cancel() {
21
+ if (attemptID && !finished) {
22
+ void oauth.cancel({ integrationID, attemptID }).catch(() => undefined)
23
+ }
24
+ }
25
+
26
+ onCleanup(() => {
27
+ controller.abort()
28
+ cancel()
29
+ })
30
+
31
+ onMount(() => void start())
32
+
33
+ async function start() {
34
+ try {
35
+ const { data } = await ctx.client.integration.get({ integrationID }, request)
36
+ const method = data.methods.find((item) => item.type === "oauth")
37
+ if (!method) throw new Error("OpenCode did not find a Notion OAuth method.")
38
+ if (controller.signal.aborted) return
39
+
40
+ const { data: attempt } = await oauth.connect({ integrationID, methodID: method.id })
41
+ attemptID = attempt.attemptID
42
+ if (controller.signal.aborted) {
43
+ cancel()
44
+ return
45
+ }
46
+ if (new URL(attempt.url).origin !== new URL(endpoint).origin) {
47
+ cancel()
48
+ setError("Unexpected Notion sign-in address.")
49
+ return
50
+ }
51
+
52
+ setPaste(attempt.paste === true || attempt.mode === "code")
53
+ setUrl(attempt.url)
54
+ while (!controller.signal.aborted) {
55
+ const { data: status } = await oauth.status({ integrationID, attemptID }, request)
56
+ if (status.status === "complete") {
57
+ finished = true
58
+ props.onDone()
59
+ return
60
+ }
61
+ if (status.status !== "pending") {
62
+ finished = true
63
+ setUrl("")
64
+ setPaste(false)
65
+ setError(`Notion sign-in ${status.status}. Close this dialog and try again.`)
66
+ return
67
+ }
68
+ await new Promise<void>((resolve) => setTimeout(resolve, 1000))
69
+ }
70
+ } catch {
71
+ if (!controller.signal.aborted) {
72
+ setUrl("")
73
+ setPaste(false)
74
+ setError("Could not start or check Notion sign-in. Close this dialog and try again.")
75
+ }
76
+ }
77
+ }
78
+
79
+ async function submit() {
80
+ if (!attemptID || submitting() || !code().trim()) return
81
+ setSubmitting(true)
82
+ setError("")
83
+ try {
84
+ await oauth.complete({ integrationID, attemptID, code: code().trim() }, request)
85
+ setCode("")
86
+ } catch {
87
+ if (!controller.signal.aborted) setError("Could not complete sign-in. Check the callback URL or code and try again.")
88
+ } finally {
89
+ setSubmitting(false)
90
+ }
91
+ }
92
+
93
+ return (
94
+ <ui.Dialog
95
+ title={`Sign in to Notion: ${props.alias}`}
96
+ description="Open Notion in your browser, then check the account and workspace before authorizing."
97
+ >
98
+ <Show when={url()} fallback={<Show when={!error()}><p role="status">Preparing sign-in…</p></Show>}>
99
+ {(address) => <ui.Button variant="contrast" onClick={() => ctx.system.openExternal(address())}>Open Notion in browser</ui.Button>}
100
+ </Show>
101
+ <Show when={paste()}>
102
+ <p>If the callback page doesn’t load after you authorize, paste its full URL here.</p>
103
+ <ui.TextInput label="Callback URL or code" type="password" value={code()} onInput={setCode} onSubmit={() => void submit()} />
104
+ <ui.Button onClick={() => void submit()} disabled={!code().trim()} busy={submitting()}>Complete sign-in</ui.Button>
105
+ </Show>
106
+ <Show when={error()}><p role="alert">{error()}</p></Show>
107
+ </ui.Dialog>
108
+ )
109
+ }