From b51bbed4dfc939f93519ee9c07223ba797a115c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florentin=20D=C3=B6rre?= Date: Tue, 7 Jul 2026 14:42:04 +0200 Subject: [PATCH] Fix selection bug for VG.render render_widget worked --- js-applet/src/graph-widget.test.tsx | 35 ++-------- js-applet/src/local-model.test.ts | 69 +++++++++++++++++++ js-applet/src/local-model.ts | 40 +++++++++++ js-applet/src/standalone-entrypoint.ts | 22 ++---- .../resources/nvl_entrypoint/index.html | 4 +- 5 files changed, 123 insertions(+), 47 deletions(-) create mode 100644 js-applet/src/local-model.test.ts create mode 100644 js-applet/src/local-model.ts diff --git a/js-applet/src/graph-widget.test.tsx b/js-applet/src/graph-widget.test.tsx index 9eecd259..447de073 100644 --- a/js-applet/src/graph-widget.test.tsx +++ b/js-applet/src/graph-widget.test.tsx @@ -23,6 +23,7 @@ vi.mock("@neo4j-ndl/react", async () => { }); import widget from "./graph-widget"; +import { createLocalModel } from "./local-model"; type WidgetState = { nodes: Array<{ id: string; caption?: string; properties: Record }>; @@ -37,32 +38,10 @@ type WidgetState = { selected: { nodeIds: string[]; relationshipIds: string[] }; }; -class FakeModel { - private readonly listeners = new Map void>>(); - - constructor(private readonly state: WidgetState) {} - - get(key: K): WidgetState[K] { - return this.state[key]; - } - - set(key: K, value: WidgetState[K]): void { - this.state[key] = value; - this.listeners.get(`change:${String(key)}`)?.forEach((listener) => listener()); - } - - on(event: string, listener: () => void): void { - const listeners = this.listeners.get(event) ?? new Set<() => void>(); - listeners.add(listener); - this.listeners.set(event, listeners); - } - - off(event: string, listener: () => void): void { - this.listeners.get(event)?.delete(listener); - } - - save_changes(): void {} -} +// The static HTML render path uses the real `createLocalModel` shim, so tests +// exercise it directly rather than a hand-rolled fake — this keeps the shim's +// contract (notably `set` emitting change events, see GDS-286) under test. +type FakeModel = ReturnType>; type RenderedWidget = { el: HTMLDivElement; @@ -81,7 +60,7 @@ async function renderWidget( { id: "r1", from: "n1", to: "n1", properties: {} }, ]; - const model = new FakeModel({ + const model = createLocalModel({ nodes: overrides.nodes ?? defaultNodes, relationships: overrides.relationships ?? defaultRelationships, options: { @@ -116,7 +95,7 @@ async function renderWidgetInShadowRoot( const el = document.createElement("div"); shadowRoot.appendChild(el); - const model = new FakeModel({ + const model = createLocalModel({ nodes: [{ id: "n1", caption: "Node 1", properties: {} }], relationships: [{ id: "r1", from: "n1", to: "n1", properties: {} }], options: { diff --git a/js-applet/src/local-model.test.ts b/js-applet/src/local-model.test.ts new file mode 100644 index 00000000..4f1a7090 --- /dev/null +++ b/js-applet/src/local-model.test.ts @@ -0,0 +1,69 @@ +import { describe, expect, it, vi } from "vitest"; +import { createLocalModel } from "./local-model"; + +type State = { + selected: { nodeIds: string[]; relationshipIds: string[] }; + theme: "light" | "dark"; +}; + +const initial = (): Partial => ({ + selected: { nodeIds: [], relationshipIds: [] }, + theme: "light", +}); + +describe("createLocalModel", () => { + it("returns the current value from get", () => { + const model = createLocalModel(initial()); + expect(model.get("theme")).toBe("light"); + expect(model.get("selected")).toEqual({ nodeIds: [], relationshipIds: [] }); + }); + + // Regression guard for GDS-286: a no-op `set` froze controlled props such as + // `selected`, so clicking a node in the static HTML could never select it. + it("updates state on set and notifies change listeners", () => { + const model = createLocalModel(initial()); + const listener = vi.fn(); + model.on("change:selected", listener); + + const next = { nodeIds: ["n1"], relationshipIds: [] }; + model.set("selected", next); + + expect(model.get("selected")).toBe(next); + expect(listener).toHaveBeenCalledTimes(1); + }); + + it("only notifies listeners for the changed key", () => { + const model = createLocalModel(initial()); + const selectedListener = vi.fn(); + const themeListener = vi.fn(); + model.on("change:selected", selectedListener); + model.on("change:theme", themeListener); + + model.set("theme", "dark"); + + expect(themeListener).toHaveBeenCalledTimes(1); + expect(selectedListener).not.toHaveBeenCalled(); + }); + + it("stops notifying a listener after off", () => { + const model = createLocalModel(initial()); + const listener = vi.fn(); + model.on("change:selected", listener); + model.off("change:selected", listener); + + model.set("selected", { nodeIds: ["n1"], relationshipIds: [] }); + + expect(listener).not.toHaveBeenCalled(); + }); + + it("returns a stable reference from get until the next set (useSyncExternalStore contract)", () => { + const model = createLocalModel(initial()); + const first = model.get("selected"); + expect(model.get("selected")).toBe(first); + + const next = { nodeIds: ["n1"], relationshipIds: [] }; + model.set("selected", next); + expect(model.get("selected")).toBe(next); + expect(model.get("selected")).toBe(next); + }); +}); diff --git a/js-applet/src/local-model.ts b/js-applet/src/local-model.ts new file mode 100644 index 00000000..6c3ee0a0 --- /dev/null +++ b/js-applet/src/local-model.ts @@ -0,0 +1,40 @@ +/** + * The subset of the anywidget model API the React bindings rely on. + */ +export type LocalModel> = { + get(key: K): T[K]; + set(key: K, value: T[K]): void; + on(event: string, listener: () => void): void; + off(event: string, listener: () => void): void; + save_changes(): void; +}; + +/** + * A minimal, kernel-less model for the static HTML render path. + * `set` must still update the in-memory data and notify listeners. + * State is kept local to the page; nothing is synced back to Python. + */ +export function createLocalModel>( + data: Partial +): LocalModel { + const listeners = new Map void>>(); + + return { + get(key: K): T[K] { + return data[key] as T[K]; + }, + set(key: K, value: T[K]): void { + data[key] = value; + listeners.get(`change:${String(key)}`)?.forEach((listener) => listener()); + }, + on(event: string, listener: () => void): void { + const eventListeners = listeners.get(event) ?? new Set<() => void>(); + eventListeners.add(listener); + listeners.set(event, eventListeners); + }, + off(event: string, listener: () => void): void { + listeners.get(event)?.delete(listener); + }, + save_changes() {}, + }; +} diff --git a/js-applet/src/standalone-entrypoint.ts b/js-applet/src/standalone-entrypoint.ts index 0139dc40..d5d5b1e4 100644 --- a/js-applet/src/standalone-entrypoint.ts +++ b/js-applet/src/standalone-entrypoint.ts @@ -1,5 +1,5 @@ -import type { AnyModel } from "@anywidget/types"; import widget, { type WidgetData } from "./graph-widget"; +import { createLocalModel } from "./local-model"; /** * Standalone entrypoint for static HTML rendering (non-Jupyter). @@ -25,22 +25,10 @@ if (!data) { throw new Error("window.__NEO4J_VIZ_DATA__ is not defined"); } -/** - * Read-only model shim for static HTML rendering. - * Mutations (set/save_changes) are no-ops since there's no kernel to sync with. - */ -const model: Pick< - AnyModel, - "get" | "on" | "off" | "set" | "save_changes" -> = { - get(key: K): WidgetData[K] { - return data[key] as WidgetData[K]; - }, - on() {}, - off() {}, - set() {}, - save_changes() {}, -}; +// Kernel-less model for the static HTML page: `set` updates local state and +// notifies listeners so controlled props (e.g. `selected`) stay interactive; +// nothing is synced back to Python. See createLocalModel for details. +const model = createLocalModel(data); const el = document.getElementById("neo4j-viz-container"); if (!el) { diff --git a/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html b/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html index 293e888e..e04f2a93 100644 --- a/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html +++ b/python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/index.html @@ -1589,13 +1589,13 @@ `)}b.write("payload.value = newResult;"),b.write("return payload;");const y=b.compile();return(x,_)=>y(g,x,_)};let a;const i=a2,c=!nW.jitless,d=c&&Qgr.value,s=r.catchall;let u;t._zod.parse=(g,b)=>{u??(u=o.value);const f=g.value;return i(f)?c&&d&&(b==null?void 0:b.async)===!1&&b.jitless!==!0?(a||(a=n(r.shape)),g=a(g,b),s?yW([],f,g,b,u,t):g):e(g,b):(g.issues.push({expected:"object",code:"invalid_type",input:f,inst:t}),g)}});function AB(t,r,e,o){for(const a of t)if(a.issues.length===0)return r.value=a.value,r;const n=t.filter(a=>!Wp(a));return n.length===1?(r.value=n[0].value,n[0]):(r.issues.push({code:"invalid_union",input:r.value,inst:e,errors:t.map(a=>a.issues.map(i=>S0(i,o,E0())))}),r)}const Uhr=ke("$ZodUnion",(t,r)=>{ya.init(t,r),en(t._zod,"optin",()=>r.options.some(n=>n._zod.optin==="optional")?"optional":void 0),en(t._zod,"optout",()=>r.options.some(n=>n._zod.optout==="optional")?"optional":void 0),en(t._zod,"values",()=>{if(r.options.every(n=>n._zod.values))return new Set(r.options.flatMap(n=>Array.from(n._zod.values)))}),en(t._zod,"pattern",()=>{if(r.options.every(n=>n._zod.pattern)){const n=r.options.map(a=>a._zod.pattern);return new RegExp(`^(${n.map(a=>yT(a.source)).join("|")})$`)}});const e=r.options.length===1,o=r.options[0]._zod.run;t._zod.parse=(n,a)=>{if(e)return o(n,a);let i=!1;const c=[];for(const l of r.options){const d=l._zod.run({value:n.value,issues:[]},a);if(d instanceof Promise)c.push(d),i=!0;else{if(d.issues.length===0)return d;c.push(d)}}return i?Promise.all(c).then(l=>AB(l,n,t,a)):AB(c,n,t,a)}}),Fhr=ke("$ZodIntersection",(t,r)=>{ya.init(t,r),t._zod.parse=(e,o)=>{const n=e.value,a=r.left._zod.run({value:n,issues:[]},o),i=r.right._zod.run({value:n,issues:[]},o);return a instanceof Promise||i instanceof Promise?Promise.all([a,i]).then(([l,d])=>TB(e,l,d)):TB(e,a,i)}});function zO(t,r){if(t===r)return{valid:!0,data:t};if(t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(x5(t)&&x5(r)){const e=Object.keys(r),o=Object.keys(t).filter(a=>e.indexOf(a)!==-1),n={...t,...r};for(const a of o){const i=zO(t[a],r[a]);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};n[a]=i.data}return{valid:!0,data:n}}if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let o=0;oc.l&&c.r).map(([c])=>c);if(a.length&&n&&t.issues.push({...n,keys:a}),Wp(t))return t;const i=zO(r.value,e.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return t.value=i.data,t}const qhr=ke("$ZodTuple",(t,r)=>{ya.init(t,r);const e=r.items;t._zod.parse=(o,n)=>{const a=o.value;if(!Array.isArray(a))return o.issues.push({input:a,inst:t,expected:"tuple",code:"invalid_type"}),o;o.value=[];const i=[],c=[...e].reverse().findIndex(s=>s._zod.optin!=="optional"),l=c===-1?0:e.length-c;if(!r.rest){const s=a.length>e.length,u=a.length=a.length&&d>=l)continue;const u=s._zod.run({value:a[d],issues:[]},n);u instanceof Promise?i.push(u.then(g=>Dw(g,o,d))):Dw(u,o,d)}if(r.rest){const s=a.slice(e.length);for(const u of s){d++;const g=r.rest._zod.run({value:u,issues:[]},n);g instanceof Promise?i.push(g.then(b=>Dw(b,o,d))):Dw(g,o,d)}}return i.length?Promise.all(i).then(()=>o):o}});function Dw(t,r,e){t.issues.length&&r.issues.push(...wT(e,t.issues)),r.value[e]=t.value}const Ghr=ke("$ZodEnum",(t,r)=>{ya.init(t,r);const e=aW(r.entries),o=new Set(e);t._zod.values=o,t._zod.pattern=new RegExp(`^(${e.filter(n=>Jgr.has(typeof n)).map(n=>typeof n=="string"?Sk(n):n.toString()).join("|")})$`),t._zod.parse=(n,a)=>{const i=n.value;return o.has(i)||n.issues.push({code:"invalid_value",values:e,input:i,inst:t}),n}}),Vhr=ke("$ZodLiteral",(t,r)=>{if(ya.init(t,r),r.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(r.values);t._zod.values=e,t._zod.pattern=new RegExp(`^(${r.values.map(o=>typeof o=="string"?Sk(o):o?Sk(o.toString()):String(o)).join("|")})$`),t._zod.parse=(o,n)=>{const a=o.value;return e.has(a)||o.issues.push({code:"invalid_value",values:r.values,input:a,inst:t}),o}}),Hhr=ke("$ZodTransform",(t,r)=>{ya.init(t,r),t._zod.parse=(e,o)=>{if(o.direction==="backward")throw new oW(t.constructor.name);const n=r.transform(e.value,e);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then(i=>(e.value=i,e));if(n instanceof Promise)throw new lk;return e.value=n,e}});function CB(t,r){return t.issues.length&&r===void 0?{issues:[],value:void 0}:t}const wW=ke("$ZodOptional",(t,r)=>{ya.init(t,r),t._zod.optin="optional",t._zod.optout="optional",en(t._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,void 0]):void 0),en(t._zod,"pattern",()=>{const e=r.innerType._zod.pattern;return e?new RegExp(`^(${yT(e.source)})?$`):void 0}),t._zod.parse=(e,o)=>{if(r.innerType._zod.optin==="optional"){const n=r.innerType._zod.run(e,o);return n instanceof Promise?n.then(a=>CB(a,e.value)):CB(n,e.value)}return e.value===void 0?e:r.innerType._zod.run(e,o)}}),Whr=ke("$ZodExactOptional",(t,r)=>{wW.init(t,r),en(t._zod,"values",()=>r.innerType._zod.values),en(t._zod,"pattern",()=>r.innerType._zod.pattern),t._zod.parse=(e,o)=>r.innerType._zod.run(e,o)}),Yhr=ke("$ZodNullable",(t,r)=>{ya.init(t,r),en(t._zod,"optin",()=>r.innerType._zod.optin),en(t._zod,"optout",()=>r.innerType._zod.optout),en(t._zod,"pattern",()=>{const e=r.innerType._zod.pattern;return e?new RegExp(`^(${yT(e.source)}|null)$`):void 0}),en(t._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,null]):void 0),t._zod.parse=(e,o)=>e.value===null?e:r.innerType._zod.run(e,o)}),Xhr=ke("$ZodDefault",(t,r)=>{ya.init(t,r),t._zod.optin="optional",en(t._zod,"values",()=>r.innerType._zod.values),t._zod.parse=(e,o)=>{if(o.direction==="backward")return r.innerType._zod.run(e,o);if(e.value===void 0)return e.value=r.defaultValue,e;const n=r.innerType._zod.run(e,o);return n instanceof Promise?n.then(a=>RB(a,r)):RB(n,r)}});function RB(t,r){return t.value===void 0&&(t.value=r.defaultValue),t}const Zhr=ke("$ZodPrefault",(t,r)=>{ya.init(t,r),t._zod.optin="optional",en(t._zod,"values",()=>r.innerType._zod.values),t._zod.parse=(e,o)=>(o.direction==="backward"||e.value===void 0&&(e.value=r.defaultValue),r.innerType._zod.run(e,o))}),Khr=ke("$ZodNonOptional",(t,r)=>{ya.init(t,r),en(t._zod,"values",()=>{const e=r.innerType._zod.values;return e?new Set([...e].filter(o=>o!==void 0)):void 0}),t._zod.parse=(e,o)=>{const n=r.innerType._zod.run(e,o);return n instanceof Promise?n.then(a=>PB(a,t)):PB(n,t)}});function PB(t,r){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:r}),t}const Qhr=ke("$ZodCatch",(t,r)=>{ya.init(t,r),en(t._zod,"optin",()=>r.innerType._zod.optin),en(t._zod,"optout",()=>r.innerType._zod.optout),en(t._zod,"values",()=>r.innerType._zod.values),t._zod.parse=(e,o)=>{if(o.direction==="backward")return r.innerType._zod.run(e,o);const n=r.innerType._zod.run(e,o);return n instanceof Promise?n.then(a=>(e.value=a.value,a.issues.length&&(e.value=r.catchValue({...e,error:{issues:a.issues.map(i=>S0(i,o,E0()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=r.catchValue({...e,error:{issues:n.issues.map(a=>S0(a,o,E0()))},input:e.value}),e.issues=[]),e)}}),Jhr=ke("$ZodPipe",(t,r)=>{ya.init(t,r),en(t._zod,"values",()=>r.in._zod.values),en(t._zod,"optin",()=>r.in._zod.optin),en(t._zod,"optout",()=>r.out._zod.optout),en(t._zod,"propValues",()=>r.in._zod.propValues),t._zod.parse=(e,o)=>{if(o.direction==="backward"){const a=r.out._zod.run(e,o);return a instanceof Promise?a.then(i=>Nw(i,r.in,o)):Nw(a,r.in,o)}const n=r.in._zod.run(e,o);return n instanceof Promise?n.then(a=>Nw(a,r.out,o)):Nw(n,r.out,o)}});function Nw(t,r,e){return t.issues.length?(t.aborted=!0,t):r._zod.run({value:t.value,issues:t.issues},e)}const $hr=ke("$ZodReadonly",(t,r)=>{ya.init(t,r),en(t._zod,"propValues",()=>r.innerType._zod.propValues),en(t._zod,"values",()=>r.innerType._zod.values),en(t._zod,"optin",()=>{var e,o;return(o=(e=r.innerType)==null?void 0:e._zod)==null?void 0:o.optin}),en(t._zod,"optout",()=>{var e,o;return(o=(e=r.innerType)==null?void 0:e._zod)==null?void 0:o.optout}),t._zod.parse=(e,o)=>{if(o.direction==="backward")return r.innerType._zod.run(e,o);const n=r.innerType._zod.run(e,o);return n instanceof Promise?n.then(MB):MB(n)}});function MB(t){return t.value=Object.freeze(t.value),t}const rfr=ke("$ZodLazy",(t,r)=>{ya.init(t,r),en(t._zod,"innerType",()=>r.getter()),en(t._zod,"pattern",()=>{var e,o;return(o=(e=t._zod.innerType)==null?void 0:e._zod)==null?void 0:o.pattern}),en(t._zod,"propValues",()=>{var e,o;return(o=(e=t._zod.innerType)==null?void 0:e._zod)==null?void 0:o.propValues}),en(t._zod,"optin",()=>{var e,o;return((o=(e=t._zod.innerType)==null?void 0:e._zod)==null?void 0:o.optin)??void 0}),en(t._zod,"optout",()=>{var e,o;return((o=(e=t._zod.innerType)==null?void 0:e._zod)==null?void 0:o.optout)??void 0}),t._zod.parse=(e,o)=>t._zod.innerType._zod.run(e,o)}),efr=ke("$ZodCustom",(t,r)=>{qs.init(t,r),ya.init(t,r),t._zod.parse=(e,o)=>e,t._zod.check=e=>{const o=e.value,n=r.fn(o);if(n instanceof Promise)return n.then(a=>IB(a,e,o,t));IB(n,e,o,t)}});function IB(t,r,e,o){if(!t){const n={code:"custom",input:e,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(n.params=o._zod.def.params),r.issues.push(_5(n))}}var DB;class tfr{constructor(){this._map=new WeakMap,this._idmap=new Map}add(r,...e){const o=e[0];return this._map.set(r,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,r),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(r){const e=this._map.get(r);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(r),this}get(r){const e=r._zod.parent;if(e){const o={...this.get(e)??{}};delete o.id;const n={...o,...this._map.get(r)};return Object.keys(n).length?n:void 0}return this._map.get(r)}has(r){return this._map.has(r)}}function ofr(){return new tfr}(DB=globalThis).__zod_globalRegistry??(DB.__zod_globalRegistry=ofr());const uy=globalThis.__zod_globalRegistry;function nfr(t,r){return new t({type:"string",...St(r)})}function afr(t,r){return new t({type:"string",format:"email",check:"string_format",abort:!1,...St(r)})}function NB(t,r){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...St(r)})}function ifr(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...St(r)})}function cfr(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...St(r)})}function lfr(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...St(r)})}function dfr(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...St(r)})}function sfr(t,r){return new t({type:"string",format:"url",check:"string_format",abort:!1,...St(r)})}function ufr(t,r){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...St(r)})}function gfr(t,r){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...St(r)})}function bfr(t,r){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...St(r)})}function hfr(t,r){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...St(r)})}function ffr(t,r){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...St(r)})}function vfr(t,r){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...St(r)})}function pfr(t,r){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...St(r)})}function kfr(t,r){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...St(r)})}function mfr(t,r){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...St(r)})}function yfr(t,r){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...St(r)})}function wfr(t,r){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...St(r)})}function xfr(t,r){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...St(r)})}function _fr(t,r){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...St(r)})}function Efr(t,r){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...St(r)})}function Sfr(t,r){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...St(r)})}function Ofr(t,r){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...St(r)})}function Afr(t,r){return new t({type:"string",format:"date",check:"string_format",...St(r)})}function Tfr(t,r){return new t({type:"string",format:"time",check:"string_format",precision:null,...St(r)})}function Cfr(t,r){return new t({type:"string",format:"duration",check:"string_format",...St(r)})}function Rfr(t,r){return new t({type:"number",checks:[],...St(r)})}function Pfr(t,r){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...St(r)})}function Mfr(t,r){return new t({type:"boolean",...St(r)})}function Ifr(t,r){return new t({type:"null",...St(r)})}function Dfr(t){return new t({type:"unknown"})}function Nfr(t,r){return new t({type:"never",...St(r)})}function LB(t,r){return new fW({check:"less_than",...St(r),value:t,inclusive:!1})}function uS(t,r){return new fW({check:"less_than",...St(r),value:t,inclusive:!0})}function jB(t,r){return new vW({check:"greater_than",...St(r),value:t,inclusive:!1})}function gS(t,r){return new vW({check:"greater_than",...St(r),value:t,inclusive:!0})}function zB(t,r){return new Ybr({check:"multiple_of",...St(r),value:t})}function xW(t,r){return new Zbr({check:"max_length",...St(r),maximum:t})}function c2(t,r){return new Kbr({check:"min_length",...St(r),minimum:t})}function _W(t,r){return new Qbr({check:"length_equals",...St(r),length:t})}function Lfr(t,r){return new Jbr({check:"string_format",format:"regex",...St(r),pattern:t})}function jfr(t){return new $br({check:"string_format",format:"lowercase",...St(t)})}function zfr(t){return new rhr({check:"string_format",format:"uppercase",...St(t)})}function Bfr(t,r){return new ehr({check:"string_format",format:"includes",...St(r),includes:t})}function Ufr(t,r){return new thr({check:"string_format",format:"starts_with",...St(r),prefix:t})}function Ffr(t,r){return new ohr({check:"string_format",format:"ends_with",...St(r),suffix:t})}function Bk(t){return new nhr({check:"overwrite",tx:t})}function qfr(t){return Bk(r=>r.normalize(t))}function Gfr(){return Bk(t=>t.trim())}function Vfr(){return Bk(t=>t.toLowerCase())}function Hfr(){return Bk(t=>t.toUpperCase())}function Wfr(){return Bk(t=>Kgr(t))}function Yfr(t,r,e){return new t({type:"array",element:r,...St(e)})}function Xfr(t,r,e){return new t({type:"custom",check:"custom",fn:r,...St(e)})}function Zfr(t){const r=Kfr(e=>(e.addIssue=o=>{if(typeof o=="string")e.issues.push(_5(o,e.value,r._zod.def));else{const n=o;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=e.value),n.inst??(n.inst=r),n.continue??(n.continue=!r._zod.def.abort),e.issues.push(_5(n))}},t(e.value,e)));return r}function Kfr(t,r){const e=new qs({check:"custom",...St(r)});return e._zod.check=t,e}function EW(t){let r=(t==null?void 0:t.target)??"draft-2020-12";return r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),{processors:t.processors??{},metadataRegistry:(t==null?void 0:t.metadata)??uy,target:r,unrepresentable:(t==null?void 0:t.unrepresentable)??"throw",override:(t==null?void 0:t.override)??(()=>{}),io:(t==null?void 0:t.io)??"output",counter:0,seen:new Map,cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0}}function Ki(t,r,e={path:[],schemaPath:[]}){var s,u;var o;const n=t._zod.def,a=r.seen.get(t);if(a)return a.count++,e.schemaPath.includes(t)&&(a.cycle=e.path),a.schema;const i={schema:{},count:1,cycle:void 0,path:e.path};r.seen.set(t,i);const c=(u=(s=t._zod).toJSONSchema)==null?void 0:u.call(s);if(c)i.schema=c;else{const g={...e,schemaPath:[...e.schemaPath,t],path:e.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(r,i.schema,g);else{const f=i.schema,v=r.processors[n.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);v(t,r,f,g)}const b=t._zod.parent;b&&(i.ref||(i.ref=b),Ki(b,r,g),r.seen.get(b).isParent=!0)}const l=r.metadataRegistry.get(t);return l&&Object.assign(i.schema,l),r.io==="input"&&Xd(t)&&(delete i.schema.examples,delete i.schema.default),r.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,r.seen.get(t).schema}function SW(t,r){var i,c,l,d;const e=t.seen.get(r);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const s of t.seen.entries()){const u=(i=t.metadataRegistry.get(s[0]))==null?void 0:i.id;if(u){const g=o.get(u);if(g&&g!==s[0])throw new Error(`Duplicate schema id "${u}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(u,s[0])}}const n=s=>{var v;const u=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const p=(v=t.external.registry.get(s[0]))==null?void 0:v.id,m=t.external.uri??(k=>k);if(p)return{ref:m(p)};const y=s[1].defId??s[1].schema.id??`schema${t.counter++}`;return s[1].defId=y,{defId:y,ref:`${m("__shared")}#/${u}/${y}`}}if(s[1]===e)return{ref:"#"};const b=`#/${u}/`,f=s[1].schema.id??`__schema${t.counter++}`;return{defId:f,ref:b+f}},a=s=>{if(s[1].schema.$ref)return;const u=s[1],{ref:g,defId:b}=n(s);u.def={...u.schema},b&&(u.defId=b);const f=u.schema;for(const v in f)delete f[v];f.$ref=g};if(t.cycles==="throw")for(const s of t.seen.entries()){const u=s[1];if(u.cycle)throw new Error(`Cycle detected: #/${(c=u.cycle)==null?void 0:c.join("/")}/ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of t.seen.entries()){const u=s[1];if(r===s[0]){a(s);continue}if(t.external){const b=(l=t.external.registry.get(s[0]))==null?void 0:l.id;if(r!==s[0]&&b){a(s);continue}}if((d=t.metadataRegistry.get(s[0]))==null?void 0:d.id){a(s);continue}if(u.cycle){a(s);continue}if(u.count>1&&t.reused==="ref"){a(s);continue}}}function OW(t,r){var i,c,l;const e=t.seen.get(r);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=d=>{const s=t.seen.get(d);if(s.ref===null)return;const u=s.def??s.schema,g={...u},b=s.ref;if(s.ref=null,b){o(b);const v=t.seen.get(b),p=v.schema;if(p.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(p)):Object.assign(u,p),Object.assign(u,g),d._zod.parent===b)for(const y in u)y==="$ref"||y==="allOf"||y in g||delete u[y];if(p.$ref&&v.def)for(const y in u)y==="$ref"||y==="allOf"||y in v.def&&JSON.stringify(u[y])===JSON.stringify(v.def[y])&&delete u[y]}const f=d._zod.parent;if(f&&f!==b){o(f);const v=t.seen.get(f);if(v!=null&&v.schema.$ref&&(u.$ref=v.schema.$ref,v.def))for(const p in u)p==="$ref"||p==="allOf"||p in v.def&&JSON.stringify(u[p])===JSON.stringify(v.def[p])&&delete u[p]}t.override({zodSchema:d,jsonSchema:u,path:s.path??[]})};for(const d of[...t.seen.entries()].reverse())o(d[0]);const n={};if(t.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":t.target,(i=t.external)!=null&&i.uri){const d=(c=t.external.registry.get(r))==null?void 0:c.id;if(!d)throw new Error("Schema is missing an `id` property");n.$id=t.external.uri(d)}Object.assign(n,e.def??e.schema);const a=((l=t.external)==null?void 0:l.defs)??{};for(const d of t.seen.entries()){const s=d[1];s.def&&s.defId&&(a[s.defId]=s.def)}t.external||Object.keys(a).length>0&&(t.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{const d=JSON.parse(JSON.stringify(n));return Object.defineProperty(d,"~standard",{value:{...r["~standard"],jsonSchema:{input:l2(r,"input",t.processors),output:l2(r,"output",t.processors)}},enumerable:!1,writable:!1}),d}catch{throw new Error("Error converting schema to JSON.")}}function Xd(t,r){const e=r??{seen:new Set};if(e.seen.has(t))return!1;e.seen.add(t);const o=t._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Xd(o.element,e);if(o.type==="set")return Xd(o.valueType,e);if(o.type==="lazy")return Xd(o.getter(),e);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Xd(o.innerType,e);if(o.type==="intersection")return Xd(o.left,e)||Xd(o.right,e);if(o.type==="record"||o.type==="map")return Xd(o.keyType,e)||Xd(o.valueType,e);if(o.type==="pipe")return Xd(o.in,e)||Xd(o.out,e);if(o.type==="object"){for(const n in o.shape)if(Xd(o.shape[n],e))return!0;return!1}if(o.type==="union"){for(const n of o.options)if(Xd(n,e))return!0;return!1}if(o.type==="tuple"){for(const n of o.items)if(Xd(n,e))return!0;return!!(o.rest&&Xd(o.rest,e))}return!1}const Qfr=(t,r={})=>e=>{const o=EW({...e,processors:r});return Ki(t,o),SW(o,t),OW(o,t)},l2=(t,r,e={})=>o=>{const{libraryOptions:n,target:a}=o??{},i=EW({...n??{},target:a,io:r,processors:e});return Ki(t,i),SW(i,t),OW(i,t)},Jfr={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},$fr=(t,r,e,o)=>{const n=e;n.type="string";const{minimum:a,maximum:i,format:c,patterns:l,contentEncoding:d}=t._zod.bag;if(typeof a=="number"&&(n.minLength=a),typeof i=="number"&&(n.maxLength=i),c&&(n.format=Jfr[c]??c,n.format===""&&delete n.format,c==="time"&&delete n.format),d&&(n.contentEncoding=d),l&&l.size>0){const s=[...l];s.length===1?n.pattern=s[0].source:s.length>1&&(n.allOf=[...s.map(u=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:u.source}))])}},rvr=(t,r,e,o)=>{const n=e,{minimum:a,maximum:i,format:c,multipleOf:l,exclusiveMaximum:d,exclusiveMinimum:s}=t._zod.bag;typeof c=="string"&&c.includes("int")?n.type="integer":n.type="number",typeof s=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(n.minimum=s,n.exclusiveMinimum=!0):n.exclusiveMinimum=s),typeof a=="number"&&(n.minimum=a,typeof s=="number"&&r.target!=="draft-04"&&(s>=a?delete n.minimum:delete n.exclusiveMinimum)),typeof d=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(n.maximum=d,n.exclusiveMaximum=!0):n.exclusiveMaximum=d),typeof i=="number"&&(n.maximum=i,typeof d=="number"&&r.target!=="draft-04"&&(d<=i?delete n.maximum:delete n.exclusiveMaximum)),typeof l=="number"&&(n.multipleOf=l)},evr=(t,r,e,o)=>{e.type="boolean"},tvr=(t,r,e,o)=>{r.target==="openapi-3.0"?(e.type="string",e.nullable=!0,e.enum=[null]):e.type="null"},ovr=(t,r,e,o)=>{e.not={}},nvr=(t,r,e,o)=>{},avr=(t,r,e,o)=>{const n=t._zod.def,a=aW(n.entries);a.every(i=>typeof i=="number")&&(e.type="number"),a.every(i=>typeof i=="string")&&(e.type="string"),e.enum=a},ivr=(t,r,e,o)=>{const n=t._zod.def,a=[];for(const i of n.values)if(i===void 0){if(r.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(r.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(i))}else a.push(i);if(a.length!==0)if(a.length===1){const i=a[0];e.type=i===null?"null":typeof i,r.target==="draft-04"||r.target==="openapi-3.0"?e.enum=[i]:e.const=i}else a.every(i=>typeof i=="number")&&(e.type="number"),a.every(i=>typeof i=="string")&&(e.type="string"),a.every(i=>typeof i=="boolean")&&(e.type="boolean"),a.every(i=>i===null)&&(e.type="null"),e.enum=a},cvr=(t,r,e,o)=>{if(r.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},lvr=(t,r,e,o)=>{if(r.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},dvr=(t,r,e,o)=>{const n=e,a=t._zod.def,{minimum:i,maximum:c}=t._zod.bag;typeof i=="number"&&(n.minItems=i),typeof c=="number"&&(n.maxItems=c),n.type="array",n.items=Ki(a.element,r,{...o,path:[...o.path,"items"]})},svr=(t,r,e,o)=>{var d;const n=e,a=t._zod.def;n.type="object",n.properties={};const i=a.shape;for(const s in i)n.properties[s]=Ki(i[s],r,{...o,path:[...o.path,"properties",s]});const c=new Set(Object.keys(i)),l=new Set([...c].filter(s=>{const u=a.shape[s]._zod;return r.io==="input"?u.optin===void 0:u.optout===void 0}));l.size>0&&(n.required=Array.from(l)),((d=a.catchall)==null?void 0:d._zod.def.type)==="never"?n.additionalProperties=!1:a.catchall?a.catchall&&(n.additionalProperties=Ki(a.catchall,r,{...o,path:[...o.path,"additionalProperties"]})):r.io==="output"&&(n.additionalProperties=!1)},uvr=(t,r,e,o)=>{const n=t._zod.def,a=n.inclusive===!1,i=n.options.map((c,l)=>Ki(c,r,{...o,path:[...o.path,a?"oneOf":"anyOf",l]}));a?e.oneOf=i:e.anyOf=i},gvr=(t,r,e,o)=>{const n=t._zod.def,a=Ki(n.left,r,{...o,path:[...o.path,"allOf",0]}),i=Ki(n.right,r,{...o,path:[...o.path,"allOf",1]}),c=d=>"allOf"in d&&Object.keys(d).length===1,l=[...c(a)?a.allOf:[a],...c(i)?i.allOf:[i]];e.allOf=l},bvr=(t,r,e,o)=>{const n=e,a=t._zod.def;n.type="array";const i=r.target==="draft-2020-12"?"prefixItems":"items",c=r.target==="draft-2020-12"||r.target==="openapi-3.0"?"items":"additionalItems",l=a.items.map((g,b)=>Ki(g,r,{...o,path:[...o.path,i,b]})),d=a.rest?Ki(a.rest,r,{...o,path:[...o.path,c,...r.target==="openapi-3.0"?[a.items.length]:[]]}):null;r.target==="draft-2020-12"?(n.prefixItems=l,d&&(n.items=d)):r.target==="openapi-3.0"?(n.items={anyOf:l},d&&n.items.anyOf.push(d),n.minItems=l.length,d||(n.maxItems=l.length)):(n.items=l,d&&(n.additionalItems=d));const{minimum:s,maximum:u}=t._zod.bag;typeof s=="number"&&(n.minItems=s),typeof u=="number"&&(n.maxItems=u)},hvr=(t,r,e,o)=>{const n=t._zod.def,a=Ki(n.innerType,r,o),i=r.seen.get(t);r.target==="openapi-3.0"?(i.ref=n.innerType,e.nullable=!0):e.anyOf=[a,{type:"null"}]},fvr=(t,r,e,o)=>{const n=t._zod.def;Ki(n.innerType,r,o);const a=r.seen.get(t);a.ref=n.innerType},vvr=(t,r,e,o)=>{const n=t._zod.def;Ki(n.innerType,r,o);const a=r.seen.get(t);a.ref=n.innerType,e.default=JSON.parse(JSON.stringify(n.defaultValue))},pvr=(t,r,e,o)=>{const n=t._zod.def;Ki(n.innerType,r,o);const a=r.seen.get(t);a.ref=n.innerType,r.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},kvr=(t,r,e,o)=>{const n=t._zod.def;Ki(n.innerType,r,o);const a=r.seen.get(t);a.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=i},mvr=(t,r,e,o)=>{const n=t._zod.def,a=r.io==="input"?n.in._zod.def.type==="transform"?n.out:n.in:n.out;Ki(a,r,o);const i=r.seen.get(t);i.ref=a},yvr=(t,r,e,o)=>{const n=t._zod.def;Ki(n.innerType,r,o);const a=r.seen.get(t);a.ref=n.innerType,e.readOnly=!0},AW=(t,r,e,o)=>{const n=t._zod.def;Ki(n.innerType,r,o);const a=r.seen.get(t);a.ref=n.innerType},wvr=(t,r,e,o)=>{const n=t._zod.innerType;Ki(n,r,o);const a=r.seen.get(t);a.ref=n},xvr=ke("ZodISODateTime",(t,r)=>{khr.init(t,r),ti.init(t,r)});function _vr(t){return Ofr(xvr,t)}const Evr=ke("ZodISODate",(t,r)=>{mhr.init(t,r),ti.init(t,r)});function Svr(t){return Afr(Evr,t)}const Ovr=ke("ZodISOTime",(t,r)=>{yhr.init(t,r),ti.init(t,r)});function Avr(t){return Tfr(Ovr,t)}const Tvr=ke("ZodISODuration",(t,r)=>{whr.init(t,r),ti.init(t,r)});function Cvr(t){return Cfr(Tvr,t)}const Rvr=(t,r)=>{dW.init(t,r),t.name="ZodError",Object.defineProperties(t,{format:{value:e=>dbr(t,e)},flatten:{value:e=>lbr(t,e)},addIssue:{value:e=>{t.issues.push(e),t.message=JSON.stringify(t.issues,jO,2)}},addIssues:{value:e=>{t.issues.push(...e),t.message=JSON.stringify(t.issues,jO,2)}},isEmpty:{get(){return t.issues.length===0}}})},tg=ke("ZodError",Rvr,{Parent:Error}),Pvr=_T(tg),Mvr=ET(tg),Ivr=m3(tg),Dvr=y3(tg),Nvr=gbr(tg),Lvr=bbr(tg),jvr=hbr(tg),zvr=fbr(tg),Bvr=vbr(tg),Uvr=pbr(tg),Fvr=kbr(tg),qvr=mbr(tg),Pa=ke("ZodType",(t,r)=>(ya.init(t,r),Object.assign(t["~standard"],{jsonSchema:{input:l2(t,"input"),output:l2(t,"output")}}),t.toJSONSchema=Qfr(t,{}),t.def=r,t.type=r.type,Object.defineProperty(t,"_def",{value:r}),t.check=(...e)=>t.clone(sv(r,{checks:[...r.checks??[],...e.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),t.with=t.check,t.clone=(e,o)=>uv(t,e,o),t.brand=()=>t,t.register=((e,o)=>(e.add(t,o),t)),t.parse=(e,o)=>Pvr(t,e,o,{callee:t.parse}),t.safeParse=(e,o)=>Ivr(t,e,o),t.parseAsync=async(e,o)=>Mvr(t,e,o,{callee:t.parseAsync}),t.safeParseAsync=async(e,o)=>Dvr(t,e,o),t.spa=t.safeParseAsync,t.encode=(e,o)=>Nvr(t,e,o),t.decode=(e,o)=>Lvr(t,e,o),t.encodeAsync=async(e,o)=>jvr(t,e,o),t.decodeAsync=async(e,o)=>zvr(t,e,o),t.safeEncode=(e,o)=>Bvr(t,e,o),t.safeDecode=(e,o)=>Uvr(t,e,o),t.safeEncodeAsync=async(e,o)=>Fvr(t,e,o),t.safeDecodeAsync=async(e,o)=>qvr(t,e,o),t.refine=(e,o)=>t.check(U0r(e,o)),t.superRefine=e=>t.check(F0r(e)),t.overwrite=e=>t.check(Bk(e)),t.optional=()=>qB(t),t.exactOptional=()=>S0r(t),t.nullable=()=>GB(t),t.nullish=()=>qB(GB(t)),t.nonoptional=e=>P0r(t,e),t.array=()=>Ok(t),t.or=e=>L0([t,e]),t.and=e=>k0r(t,e),t.transform=e=>VB(t,_0r(e)),t.default=e=>T0r(t,e),t.prefault=e=>R0r(t,e),t.catch=e=>I0r(t,e),t.pipe=e=>VB(t,e),t.readonly=()=>L0r(t),t.describe=e=>{const o=t.clone();return uy.add(o,{description:e}),o},Object.defineProperty(t,"description",{get(){var e;return(e=uy.get(t))==null?void 0:e.description},configurable:!0}),t.meta=(...e)=>{if(e.length===0)return uy.get(t);const o=t.clone();return uy.add(o,e[0]),o},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=e=>e(t),t)),TW=ke("_ZodString",(t,r)=>{ST.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(o,n,a)=>$fr(t,o,n);const e=t._zod.bag;t.format=e.format??null,t.minLength=e.minimum??null,t.maxLength=e.maximum??null,t.regex=(...o)=>t.check(Lfr(...o)),t.includes=(...o)=>t.check(Bfr(...o)),t.startsWith=(...o)=>t.check(Ufr(...o)),t.endsWith=(...o)=>t.check(Ffr(...o)),t.min=(...o)=>t.check(c2(...o)),t.max=(...o)=>t.check(xW(...o)),t.length=(...o)=>t.check(_W(...o)),t.nonempty=(...o)=>t.check(c2(1,...o)),t.lowercase=o=>t.check(jfr(o)),t.uppercase=o=>t.check(zfr(o)),t.trim=()=>t.check(Gfr()),t.normalize=(...o)=>t.check(qfr(...o)),t.toLowerCase=()=>t.check(Vfr()),t.toUpperCase=()=>t.check(Hfr()),t.slugify=()=>t.check(Wfr())}),Gvr=ke("ZodString",(t,r)=>{ST.init(t,r),TW.init(t,r),t.email=e=>t.check(afr(Vvr,e)),t.url=e=>t.check(sfr(Hvr,e)),t.jwt=e=>t.check(Sfr(i0r,e)),t.emoji=e=>t.check(ufr(Wvr,e)),t.guid=e=>t.check(NB(BB,e)),t.uuid=e=>t.check(ifr(Lw,e)),t.uuidv4=e=>t.check(cfr(Lw,e)),t.uuidv6=e=>t.check(lfr(Lw,e)),t.uuidv7=e=>t.check(dfr(Lw,e)),t.nanoid=e=>t.check(gfr(Yvr,e)),t.guid=e=>t.check(NB(BB,e)),t.cuid=e=>t.check(bfr(Xvr,e)),t.cuid2=e=>t.check(hfr(Zvr,e)),t.ulid=e=>t.check(ffr(Kvr,e)),t.base64=e=>t.check(xfr(o0r,e)),t.base64url=e=>t.check(_fr(n0r,e)),t.xid=e=>t.check(vfr(Qvr,e)),t.ksuid=e=>t.check(pfr(Jvr,e)),t.ipv4=e=>t.check(kfr($vr,e)),t.ipv6=e=>t.check(mfr(r0r,e)),t.cidrv4=e=>t.check(yfr(e0r,e)),t.cidrv6=e=>t.check(wfr(t0r,e)),t.e164=e=>t.check(Efr(a0r,e)),t.datetime=e=>t.check(_vr(e)),t.date=e=>t.check(Svr(e)),t.time=e=>t.check(Avr(e)),t.duration=e=>t.check(Cvr(e))});function Qd(t){return nfr(Gvr,t)}const ti=ke("ZodStringFormat",(t,r)=>{qa.init(t,r),TW.init(t,r)}),Vvr=ke("ZodEmail",(t,r)=>{dhr.init(t,r),ti.init(t,r)}),BB=ke("ZodGUID",(t,r)=>{chr.init(t,r),ti.init(t,r)}),Lw=ke("ZodUUID",(t,r)=>{lhr.init(t,r),ti.init(t,r)}),Hvr=ke("ZodURL",(t,r)=>{shr.init(t,r),ti.init(t,r)}),Wvr=ke("ZodEmoji",(t,r)=>{uhr.init(t,r),ti.init(t,r)}),Yvr=ke("ZodNanoID",(t,r)=>{ghr.init(t,r),ti.init(t,r)}),Xvr=ke("ZodCUID",(t,r)=>{bhr.init(t,r),ti.init(t,r)}),Zvr=ke("ZodCUID2",(t,r)=>{hhr.init(t,r),ti.init(t,r)}),Kvr=ke("ZodULID",(t,r)=>{fhr.init(t,r),ti.init(t,r)}),Qvr=ke("ZodXID",(t,r)=>{vhr.init(t,r),ti.init(t,r)}),Jvr=ke("ZodKSUID",(t,r)=>{phr.init(t,r),ti.init(t,r)}),$vr=ke("ZodIPv4",(t,r)=>{xhr.init(t,r),ti.init(t,r)}),r0r=ke("ZodIPv6",(t,r)=>{_hr.init(t,r),ti.init(t,r)}),e0r=ke("ZodCIDRv4",(t,r)=>{Ehr.init(t,r),ti.init(t,r)}),t0r=ke("ZodCIDRv6",(t,r)=>{Shr.init(t,r),ti.init(t,r)}),o0r=ke("ZodBase64",(t,r)=>{Ohr.init(t,r),ti.init(t,r)}),n0r=ke("ZodBase64URL",(t,r)=>{Thr.init(t,r),ti.init(t,r)}),a0r=ke("ZodE164",(t,r)=>{Chr.init(t,r),ti.init(t,r)}),i0r=ke("ZodJWT",(t,r)=>{Phr.init(t,r),ti.init(t,r)}),CW=ke("ZodNumber",(t,r)=>{kW.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(o,n,a)=>rvr(t,o,n),t.gt=(o,n)=>t.check(jB(o,n)),t.gte=(o,n)=>t.check(gS(o,n)),t.min=(o,n)=>t.check(gS(o,n)),t.lt=(o,n)=>t.check(LB(o,n)),t.lte=(o,n)=>t.check(uS(o,n)),t.max=(o,n)=>t.check(uS(o,n)),t.int=o=>t.check(UB(o)),t.safe=o=>t.check(UB(o)),t.positive=o=>t.check(jB(0,o)),t.nonnegative=o=>t.check(gS(0,o)),t.negative=o=>t.check(LB(0,o)),t.nonpositive=o=>t.check(uS(0,o)),t.multipleOf=(o,n)=>t.check(zB(o,n)),t.step=(o,n)=>t.check(zB(o,n)),t.finite=()=>t;const e=t._zod.bag;t.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),t.isFinite=!0,t.format=e.format??null});function Nb(t){return Rfr(CW,t)}const c0r=ke("ZodNumberFormat",(t,r)=>{Mhr.init(t,r),CW.init(t,r)});function UB(t){return Pfr(c0r,t)}const l0r=ke("ZodBoolean",(t,r)=>{Ihr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>evr(t,e,o)});function RW(t){return Mfr(l0r,t)}const d0r=ke("ZodNull",(t,r)=>{Dhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>tvr(t,e,o)});function s0r(t){return Ifr(d0r,t)}const u0r=ke("ZodUnknown",(t,r)=>{Nhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>nvr()});function FB(){return Dfr(u0r)}const g0r=ke("ZodNever",(t,r)=>{Lhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>ovr(t,e,o)});function b0r(t){return Nfr(g0r,t)}const h0r=ke("ZodArray",(t,r)=>{jhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>dvr(t,e,o,n),t.element=r.element,t.min=(e,o)=>t.check(c2(e,o)),t.nonempty=e=>t.check(c2(1,e)),t.max=(e,o)=>t.check(xW(e,o)),t.length=(e,o)=>t.check(_W(e,o)),t.unwrap=()=>t.element});function Ok(t,r){return Yfr(h0r,t,r)}const f0r=ke("ZodObject",(t,r)=>{Bhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>svr(t,e,o,n),en(t,"shape",()=>r.shape),t.keyof=()=>OT(Object.keys(t._zod.def.shape)),t.catchall=e=>t.clone({...t._zod.def,catchall:e}),t.passthrough=()=>t.clone({...t._zod.def,catchall:FB()}),t.loose=()=>t.clone({...t._zod.def,catchall:FB()}),t.strict=()=>t.clone({...t._zod.def,catchall:b0r()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=e=>obr(t,e),t.safeExtend=e=>nbr(t,e),t.merge=e=>abr(t,e),t.pick=e=>ebr(t,e),t.omit=e=>tbr(t,e),t.partial=(...e)=>ibr(PW,t,e[0]),t.required=(...e)=>cbr(MW,t,e[0])});function bi(t,r){const e={type:"object",shape:t??{},...St(r)};return new f0r(e)}const v0r=ke("ZodUnion",(t,r)=>{Uhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>uvr(t,e,o,n),t.options=r.options});function L0(t,r){return new v0r({type:"union",options:t,...St(r)})}const p0r=ke("ZodIntersection",(t,r)=>{Fhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>gvr(t,e,o,n)});function k0r(t,r){return new p0r({type:"intersection",left:t,right:r})}const m0r=ke("ZodTuple",(t,r)=>{qhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>bvr(t,e,o,n),t.rest=e=>t.clone({...t._zod.def,rest:e})});function Sf(t,r,e){const o=r instanceof ya,n=o?e:r,a=o?r:null;return new m0r({type:"tuple",items:t,rest:a,...St(n)})}const BO=ke("ZodEnum",(t,r)=>{Ghr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(o,n,a)=>avr(t,o,n),t.enum=r.entries,t.options=Object.values(r.entries);const e=new Set(Object.keys(r.entries));t.extract=(o,n)=>{const a={};for(const i of o)if(e.has(i))a[i]=r.entries[i];else throw new Error(`Key ${i} not found in enum`);return new BO({...r,checks:[],...St(n),entries:a})},t.exclude=(o,n)=>{const a={...r.entries};for(const i of o)if(e.has(i))delete a[i];else throw new Error(`Key ${i} not found in enum`);return new BO({...r,checks:[],...St(n),entries:a})}});function OT(t,r){const e=Array.isArray(t)?Object.fromEntries(t.map(o=>[o,o])):t;return new BO({type:"enum",entries:e,...St(r)})}const y0r=ke("ZodLiteral",(t,r)=>{Vhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>ivr(t,e,o),t.values=new Set(r.values),Object.defineProperty(t,"value",{get(){if(r.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function w0r(t,r){return new y0r({type:"literal",values:Array.isArray(t)?t:[t],...St(r)})}const x0r=ke("ZodTransform",(t,r)=>{Hhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>lvr(t,e),t._zod.parse=(e,o)=>{if(o.direction==="backward")throw new oW(t.constructor.name);e.addIssue=a=>{if(typeof a=="string")e.issues.push(_5(a,e.value,r));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),e.issues.push(_5(i))}};const n=r.transform(e.value,e);return n instanceof Promise?n.then(a=>(e.value=a,e)):(e.value=n,e)}});function _0r(t){return new x0r({type:"transform",transform:t})}const PW=ke("ZodOptional",(t,r)=>{wW.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>AW(t,e,o,n),t.unwrap=()=>t._zod.def.innerType});function qB(t){return new PW({type:"optional",innerType:t})}const E0r=ke("ZodExactOptional",(t,r)=>{Whr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>AW(t,e,o,n),t.unwrap=()=>t._zod.def.innerType});function S0r(t){return new E0r({type:"optional",innerType:t})}const O0r=ke("ZodNullable",(t,r)=>{Yhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>hvr(t,e,o,n),t.unwrap=()=>t._zod.def.innerType});function GB(t){return new O0r({type:"nullable",innerType:t})}const A0r=ke("ZodDefault",(t,r)=>{Xhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>vvr(t,e,o,n),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function T0r(t,r){return new A0r({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():cW(r)}})}const C0r=ke("ZodPrefault",(t,r)=>{Zhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>pvr(t,e,o,n),t.unwrap=()=>t._zod.def.innerType});function R0r(t,r){return new C0r({type:"prefault",innerType:t,get defaultValue(){return typeof r=="function"?r():cW(r)}})}const MW=ke("ZodNonOptional",(t,r)=>{Khr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>fvr(t,e,o,n),t.unwrap=()=>t._zod.def.innerType});function P0r(t,r){return new MW({type:"nonoptional",innerType:t,...St(r)})}const M0r=ke("ZodCatch",(t,r)=>{Qhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>kvr(t,e,o,n),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function I0r(t,r){return new M0r({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}const D0r=ke("ZodPipe",(t,r)=>{Jhr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>mvr(t,e,o,n),t.in=r.in,t.out=r.out});function VB(t,r){return new D0r({type:"pipe",in:t,out:r})}const N0r=ke("ZodReadonly",(t,r)=>{$hr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>yvr(t,e,o,n),t.unwrap=()=>t._zod.def.innerType});function L0r(t){return new N0r({type:"readonly",innerType:t})}const j0r=ke("ZodLazy",(t,r)=>{rfr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>wvr(t,e,o,n),t.unwrap=()=>t._zod.def.getter()});function z0r(t){return new j0r({type:"lazy",getter:t})}const B0r=ke("ZodCustom",(t,r)=>{efr.init(t,r),Pa.init(t,r),t._zod.processJSONSchema=(e,o,n)=>cvr(t,e)});function U0r(t,r={}){return Xfr(B0r,t,r)}function F0r(t){return Zfr(t)}const IW=bi({label:Qd().nullable()}),DW=bi({reltype:Qd().nullable()}),NW=bi({property:Qd()}),LW=L0([IW,DW,NW]),q0r=L0([IW,DW,NW]),G0r=L0([Qd(),Nb(),RW(),s0r()]),hl=L0([LW,G0r]).describe('Either a property/label/reltype selector (e.g., {property: "name"}) or a literal value (string, number, boolean, null).'),lx=z0r(()=>L0([LW,bi({not:lx}),bi({and:Ok(lx)}),bi({or:Ok(lx)}),bi({equal:Sf([hl,hl])}),bi({lessThan:Sf([hl,hl])}),bi({lessThanOrEqual:Sf([hl,hl])}),bi({greaterThan:Sf([hl,hl])}),bi({greaterThanOrEqual:Sf([hl,hl])}),bi({contains:Sf([hl,hl])}),bi({startsWith:Sf([hl,hl])}),bi({endsWith:Sf([hl,hl])}),bi({isNull:hl})])),V0r=L0([Qd(),bi({property:Qd()}),bi({useType:w0r(!0)})]);OT(["bold","italic","underline"]);const H0r=bi({styles:Ok(Qd()).optional(),value:V0r.optional(),key:Qd().optional()}),W0r=bi({url:Qd(),position:Ok(Nb()).optional(),size:Nb().optional()}),Y0r=bi({onProperty:Qd(),minValue:Nb(),minColor:Qd(),maxValue:Nb(),maxColor:Qd(),midValue:Nb().optional(),midColor:Qd().optional()}),X0r=bi({captionAlign:OT(["top","bottom","center"]).optional(),captionSize:Nb().optional(),captions:Ok(H0r).optional(),color:Qd().optional(),colorRange:Y0r.optional(),icon:Qd().optional(),overlayIcon:W0r.optional(),size:Nb().optional(),width:Nb().optional()});bi({match:q0r,where:lx.optional(),apply:X0r,disabled:RW().optional(),priority:Nb().optional()});const Z0r=["color","size","icon","overlayIcon","captions","captionSize","captionAlign"],K0r=["color","width","captions","captionSize","captionAlign","overlayIcon"];function Q0r(t){const r={};for(const e of Z0r)t[e]!==void 0&&(r[e]=t[e]);return r}function J0r(t){const r={};for(const e of K0r)t[e]!==void 0&&(r[e]=t[e]);return r}const $0r="(no label)";function HB(t){return Object.entries(t).map(([r,e])=>({color:r,count:e})).sort((r,e)=>e.count-r.count)}function rpr(t,r,e){var o,n;const a={},i={},c={},l=t.map(y=>{var k,x,_;const S={id:y.id,labelsSorted:[...y.labels].sort(iS),properties:y.properties};a[y.id]=S;const E=e.byLabelSet(S),O=Object.assign(Object.assign(Object.assign(Object.assign({},y),{labels:void 0,properties:void 0}),E),Q0r(y)),R=S.labelsSorted.length>0?S.labelsSorted:[$0r],M=O.color;for(const I of R)if(c[I]=((k=c[I])!==null&&k!==void 0?k:0)+1,M!==void 0){const L=(x=i[I])!==null&&x!==void 0?x:{};L[M]=((_=L[M])!==null&&_!==void 0?_:0)+1,i[I]=L}return O}),d=Object.keys(c).sort(iS),s={};let u=!1;for(const y of d){const k=HB((o=i[y])!==null&&o!==void 0?o:{});k.length>1&&(u=!0),s[y]={totalCount:c[y],colorDistribution:k}}const g={},b={},f={},v=r.map(y=>{var k,x,_;const S={id:y.id,properties:y.properties,type:y.type};g[y.id]=S;const E=e.byType(S.type)(S),O=Object.assign(Object.assign(Object.assign(Object.assign({},y),{properties:void 0,type:void 0}),E),J0r(y));b[S.type]=((k=b[S.type])!==null&&k!==void 0?k:0)+1;const R=O.color;if(R!==void 0){const M=(x=f[S.type])!==null&&x!==void 0?x:{};M[R]=((_=M[R])!==null&&_!==void 0?_:0)+1,f[S.type]=M}return O}),p=Object.keys(b).sort(iS),m={};for(const y of p){const k=HB((n=f[y])!==null&&n!==void 0?n:{});k.length>1&&(u=!0),m[y]={totalCount:b[y],colorDistribution:k}}return{metadataLookup:{hasMultipleColors:u,labelMetaData:s,labels:d,reltypeMetaData:m,reltypes:p},styledGraph:{nodeData:a,nodes:l,relData:g,rels:v}}}function epr(t,r,e){const o=fr.useMemo(()=>Xgr(e),[e]),{styledGraph:n,metadataLookup:a}=fr.useMemo(()=>rpr(t,r,o),[t,r,o]);return{styledGraph:n,metadataLookup:a,compiledStyleRules:o}}const jw=t=>!pB&&t.ctrlKey||pB&&t.metaKey,Gm=t=>t.target instanceof HTMLElement?t.target.isContentEditable||["INPUT","TEXTAREA"].includes(t.target.tagName):!1;function tpr({selected:t,setSelected:r,gesture:e,interactionMode:o,setInteractionMode:n,mouseEventCallbacks:a,nvlGraph:i,highlightedNodeIds:c,highlightedRelationshipIds:l}){const d=fr.useCallback(Mr=>{o==="select"&&Mr.key===" "&&n("pan")},[o,n]),s=fr.useCallback(Mr=>{o==="pan"&&Mr.key===" "&&n("select")},[o,n]);fr.useEffect(()=>(document.addEventListener("keydown",d),document.addEventListener("keyup",s),()=>{document.removeEventListener("keydown",d),document.removeEventListener("keyup",s)}),[d,s]);const{onBoxSelect:u,onLassoSelect:g,onLassoStarted:b,onBoxStarted:f,onPan:v=!0,onHover:p,onHoverNodeMargin:m,onNodeClick:y,onRelationshipClick:k,onDragStart:x,onDragEnd:_,onDrawEnded:S,onDrawStarted:E,onCanvasClick:O,onNodeDoubleClick:R,onRelationshipDoubleClick:M}=a,I=fr.useCallback(Mr=>{Gm(Mr)||(r({nodeIds:[],relationshipIds:[]}),typeof O=="function"&&O(Mr))},[O,r]),L=fr.useCallback((Mr,Lr)=>{n("drag");const Ar=Mr.map(Y=>Y.id);if(t.nodeIds.length===0||jw(Lr)){r({nodeIds:Ar,relationshipIds:t.relationshipIds});return}r({nodeIds:Ar,relationshipIds:t.relationshipIds}),typeof x=="function"&&x(Mr,Lr)},[r,x,t,n]),z=fr.useCallback((Mr,Lr)=>{typeof _=="function"&&_(Mr,Lr),n("select")},[_,n]),j=fr.useCallback(Mr=>{typeof E=="function"&&E(Mr)},[E]),F=fr.useCallback((Mr,Lr,Ar)=>{typeof S=="function"&&S(Mr,Lr,Ar)},[S]),H=fr.useCallback((Mr,Lr,Ar)=>{if(!Gm(Ar)){if(jw(Ar))if(t.nodeIds.includes(Mr.id)){const J=t.nodeIds.filter(nr=>nr!==Mr.id);r({nodeIds:J,relationshipIds:t.relationshipIds})}else{const J=[...t.nodeIds,Mr.id];r({nodeIds:J,relationshipIds:t.relationshipIds})}else r({nodeIds:[Mr.id],relationshipIds:[]});typeof y=="function"&&y(Mr,Lr,Ar)}},[r,t,y]),q=fr.useCallback((Mr,Lr,Ar)=>{if(!Gm(Ar)){if(jw(Ar))if(t.relationshipIds.includes(Mr.id)){const J=t.relationshipIds.filter(nr=>nr!==Mr.id);r({nodeIds:t.nodeIds,relationshipIds:J})}else{const J=[...t.relationshipIds,Mr.id];r({nodeIds:t.nodeIds,relationshipIds:J})}else r({nodeIds:[],relationshipIds:[Mr.id]});typeof k=="function"&&k(Mr,Lr,Ar)}},[r,t,k]),W=fr.useCallback((Mr,Lr,Ar)=>{Gm(Ar)||typeof R=="function"&&R(Mr,Lr,Ar)},[R]),Z=fr.useCallback((Mr,Lr,Ar)=>{Gm(Ar)||typeof M=="function"&&M(Mr,Lr,Ar)},[M]),$=fr.useCallback((Mr,Lr,Ar)=>{const Y=Mr.map(nr=>nr.id),J=Lr.map(nr=>nr.id);if(jw(Ar)){const nr=t.nodeIds,xr=t.relationshipIds,Er=(Yr,ie)=>[...new Set([...Yr,...ie].filter(me=>!Yr.includes(me)||!ie.includes(me)))],Pr=Er(nr,Y),Dr=Er(xr,J);r({nodeIds:Pr,relationshipIds:Dr})}else r({nodeIds:Y,relationshipIds:J})},[r,t]),X=fr.useCallback(({nodes:Mr,rels:Lr},Ar)=>{$(Mr,Lr,Ar),typeof g=="function"&&g({nodes:Mr,rels:Lr},Ar)},[$,g]),Q=fr.useCallback(({nodes:Mr,rels:Lr},Ar)=>{$(Mr,Lr,Ar),typeof u=="function"&&u({nodes:Mr,rels:Lr},Ar)},[$,u]),lr=o==="draw",or=o==="select",tr=or&&e==="box",dr=or&&e==="lasso",sr=o==="pan"||or&&e==="single",vr=o==="drag"||o==="select",ur=fr.useMemo(()=>{var Mr;return Object.assign(Object.assign({},a),{onBoxSelect:tr?Q:!1,onBoxStarted:tr?f:!1,onCanvasClick:or?I:!1,onDragEnd:vr?z:!1,onDragStart:vr?L:!1,onDrawEnded:lr?F:!1,onDrawStarted:lr?j:!1,onHover:or?p:!1,onHoverNodeMargin:lr?m:!1,onLassoSelect:dr?X:!1,onLassoStarted:dr?b:!1,onNodeClick:or?H:!1,onNodeDoubleClick:or?W:!1,onPan:sr?v:!1,onRelationshipClick:or?q:!1,onRelationshipDoubleClick:or?Z:!1,onZoom:(Mr=a.onZoom)!==null&&Mr!==void 0?Mr:!0})},[vr,tr,dr,sr,lr,or,a,Q,f,I,z,L,F,j,p,m,X,b,H,W,v,q,Z]),cr=fr.useMemo(()=>({nodeIds:new Set(t.nodeIds),relIds:new Set(t.relationshipIds)}),[t]),gr=fr.useMemo(()=>c!==void 0?new Set(c):null,[c]),pr=fr.useMemo(()=>l!==void 0?new Set(l):null,[l]),Or=fr.useMemo(()=>i.nodes.map(Mr=>Object.assign(Object.assign({},Mr),{disabled:gr?!gr.has(Mr.id):!1,selected:cr.nodeIds.has(Mr.id)})),[i.nodes,cr,gr]),Ir=fr.useMemo(()=>i.rels.map(Mr=>Object.assign(Object.assign({},Mr),{disabled:pr?!pr.has(Mr.id):!1,selected:cr.relIds.has(Mr.id)})),[i.rels,cr,pr]);return{nodesWithState:Or,relsWithState:Ir,wrappedMouseEventCallbacks:ur}}var opr=function(t,r){var e={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&r.indexOf(o)<0&&(e[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(t);nmr.jsx("div",{className:ao(npr[e],r),children:t}),apr={disableTelemetry:!0,disableWebGL:!0,maxZoom:3,minZoom:.05,relationshipThreshold:.55},Hm={bottomLeftIsland:null,bottomCenterIsland:null,bottomRightIsland:mr.jsxs(rF,{orientation:"vertical",isFloating:!0,size:"small",children:[mr.jsx(YH,{})," ",mr.jsx(XH,{})," ",mr.jsx(ZH,{})]}),topLeftIsland:null,topRightIsland:mr.jsxs("div",{className:"ndl-graph-visualization-default-download-group",children:[mr.jsx(QH,{})," ",mr.jsx(KH,{})]})};function hi(t){var r,e,{nvlRef:o,nvlCallbacks:n,nvlOptions:a,sidepanel:i,nodes:c,rels:l,highlightedNodeIds:d,highlightedRelationshipIds:s,topLeftIsland:u=Hm.topLeftIsland,topRightIsland:g=Hm.topRightIsland,bottomLeftIsland:b=Hm.bottomLeftIsland,bottomCenterIsland:f=Hm.bottomCenterIsland,bottomRightIsland:v=Hm.bottomRightIsland,gesture:p="single",setGesture:m,layout:y,setLayout:k,portalTarget:x,selected:_,setSelected:S,interactionMode:E,setInteractionMode:O,mouseEventCallbacks:R={},className:M,style:I,htmlAttributes:L,ref:z,as:j,nvlStyleRules:F}=t,H=opr(t,["nvlRef","nvlCallbacks","nvlOptions","sidepanel","nodes","rels","highlightedNodeIds","highlightedRelationshipIds","topLeftIsland","topRightIsland","bottomLeftIsland","bottomCenterIsland","bottomRightIsland","gesture","setGesture","layout","setLayout","portalTarget","selected","setSelected","interactionMode","setInteractionMode","mouseEventCallbacks","className","style","htmlAttributes","ref","as","nvlStyleRules"]);const q=fr.useMemo(()=>o??fn.createRef(),[o]),W=fr.useId(),{theme:Z}=A2(),{bg:$,border:X,text:Q}=nd.theme[Z].color.neutral,[lr,or]=fr.useState(0);fr.useEffect(()=>{or(Pr=>Pr+1)},[Z]);const{styledGraph:tr,metadataLookup:dr,compiledStyleRules:sr}=epr(c,l,F),[vr,ur]=o0({isControlled:E!==void 0,onChange:O,state:E??"select"}),[cr,gr]=o0({isControlled:_!==void 0,onChange:S,state:_??{nodeIds:[],relationshipIds:[]}}),[pr,Or]=o0({isControlled:y!==void 0,onChange:k,state:y??"d3Force"}),{nodesWithState:Ir,relsWithState:Mr,wrappedMouseEventCallbacks:Lr}=tpr({gesture:p,highlightedNodeIds:d,highlightedRelationshipIds:s,interactionMode:vr,mouseEventCallbacks:R,nvlGraph:tr,selected:cr,setInteractionMode:ur,setSelected:gr}),[Ar,Y]=o0({isControlled:(i==null?void 0:i.isSidePanelOpen)!==void 0,onChange:i==null?void 0:i.setIsSidePanelOpen,state:(r=i==null?void 0:i.isSidePanelOpen)!==null&&r!==void 0?r:!0}),[J,nr]=o0({isControlled:(i==null?void 0:i.sidePanelWidth)!==void 0,onChange:i==null?void 0:i.onSidePanelResize,state:(e=i==null?void 0:i.sidePanelWidth)!==null&&e!==void 0?e:400}),xr=fr.useMemo(()=>i===void 0?{children:mr.jsx(hi.SingleSelectionSidePanelContents,{}),isSidePanelOpen:Ar,onSidePanelResize:nr,setIsSidePanelOpen:Y,sidePanelWidth:J}:i,[i,Ar,Y,J,nr]),Er=j??"div";return mr.jsx(Er,Object.assign({ref:z,className:ao("ndl-graph-visualization-container",M),style:I},L,{children:mr.jsxs(HH.Provider,{value:{compiledStyleRules:sr,gesture:p,interactionMode:vr,layout:pr,metadataLookup:dr,nvlGraph:tr,nvlInstance:q,portalTarget:x,selected:cr,setGesture:m,setLayout:Or,sidepanel:xr},children:[mr.jsxs("div",{className:"ndl-graph-visualization",children:[mr.jsx(ogr,Object.assign({layout:pr,nodes:Ir,rels:Mr,nvlOptions:Object.assign(Object.assign(Object.assign({},apr),{instanceId:W,styling:{defaultRelationshipColor:X.strongest,disabledItemColor:$.strong,disabledItemFontColor:Q.weakest,dropShadowColor:X.weak,selectedInnerBorderColor:$.default}}),a),nvlCallbacks:Object.assign({onLayoutComputing(Pr){var Dr;Pr||(Dr=q.current)===null||Dr===void 0||Dr.fit(q.current.getNodes().map(Yr=>Yr.id),{noPan:!0})}},n),mouseEventCallbacks:Lr,ref:q},H),lr),u!==null&&mr.jsx(Vm,{placement:"top-left",children:u}),g!==null&&mr.jsx(Vm,{placement:"top-right",children:g}),b!==null&&mr.jsx(Vm,{placement:"bottom-left",children:b}),f!==null&&mr.jsx(Vm,{placement:"bottom-center",children:f}),v!==null&&mr.jsx(Vm,{placement:"bottom-right",children:v})]}),xr&&mr.jsx(_0,{sidepanel:xr})]})}))}hi.ZoomInButton=YH;hi.ZoomOutButton=XH;hi.ZoomToFitButton=ZH;hi.ToggleSidePanelButton=KH;hi.DownloadButton=QH;hi.BoxSelectButton=dgr;hi.LassoSelectButton=sgr;hi.SingleSelectButton=lgr;hi.SearchButton=ugr;hi.SingleSelectionSidePanelContents=Rgr;hi.LayoutSelectButton=bgr;hi.GestureSelectButton=fgr;function ipr(t){return Array.isArray(t)&&t.every(r=>typeof r=="string")}function cpr(t){return t.map(r=>{const e=ipr(r.properties.labels)?r.properties.labels:[];return{...r,id:r.id,labels:r.caption?[r.caption]:e,properties:Object.entries(r.properties).reduce((o,[n,a])=>{if(n==="labels")return o;const i=typeof a;return o[n]={stringified:i==="string"?`"${a}"`:String(a),type:i},o},{})}})}function lpr(t){return t.map(r=>({...r,id:r.id,type:r.caption??r.properties.type??"",properties:Object.entries(r.properties).reduce((e,[o,n])=>(o==="type"||(e[o]={stringified:String(n),type:typeof n}),e),{}),from:r.from,to:r.to}))}class dpr extends fr.Component{constructor(r){super(r),this.state={error:null}}static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,e){console.error("[neo4j-viz] Rendering error:",r,e.componentStack)}render(){return this.state.error?mr.jsxs("div",{style:{padding:"24px",fontFamily:"system-ui, sans-serif",color:"#c0392b",background:"#fdf0ef",borderRadius:"8px",border:"1px solid #e6b0aa",height:"100%",display:"flex",flexDirection:"column",justifyContent:"center"},children:[mr.jsx("h3",{style:{margin:"0 0 8px"},children:"Graph rendering failed"}),mr.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontSize:"13px",color:"#6c3428"},children:this.state.error.message})]}):this.props.children}}const spr={nodeIds:[],relationshipIds:[]};function jW(){if(document.body.classList.contains("vscode-light")||document.body.classList.contains("light-theme"))return"light";if(document.body.classList.contains("vscode-dark")||document.body.classList.contains("dark-theme"))return"dark";const r=window.getComputedStyle(document.body,null).getPropertyValue("background-color").match(/\d+/g);if(!r||r.length<3)return"light";const e=Number(r[0])*.2126+Number(r[1])*.7152+Number(r[2])*.0722;return e===0&&r.length>3&&r[3]==="0"?"light":e<128?"dark":"light"}function upr(t){return t==="auto"?jW():t}function gpr(t){const r=t??"auto",[e,o]=fr.useState(()=>upr(r));return fr.useEffect(()=>{if(r!=="auto"){o(r);return}const n=()=>{const c=jW();o(l=>l===c?l:c)};if(n(),typeof MutationObserver>"u")return;const a=new MutationObserver(n),i={attributes:!0,attributeFilter:["class","style"]};return a.observe(document.documentElement,i),a.observe(document.body,i),()=>a.disconnect()},[r]),e}const WB=(zw.match(/@font-face\s*\{[^}]*\}/g)||[]).join(` -`);if(WB){const t=document.createElement("style");t.textContent=WB,document.head.appendChild(t)}const bpr="[data-neo4j-viz-ndl-main]",hpr="[data-neo4j-viz-ndl-overlays]",fpr="[data-neo4j-viz-ndl-shadow-root]";function bS(t,r,e){const o=document.createElement("style");o.setAttribute(r,"true"),o.textContent=e,t.appendChild(o)}function vpr(t){const r=t.getRootNode();if(r instanceof ShadowRoot){r.querySelector(fpr)||bS(r,"data-neo4j-viz-ndl-shadow-root",zw),document.head.querySelector(hpr)||bS(document.head,"data-neo4j-viz-ndl-overlays",zw);return}document.head.querySelector(bpr)||bS(document.head,"data-neo4j-viz-ndl-main",zw)}function ppr(){const[t]=qv("nodes"),[r]=qv("relationships"),[e,o]=qv("options"),[n]=qv("height"),[a]=qv("width"),[i]=qv("theme"),[c,l]=qv("selected"),{layout:d,nvlOptions:s,zoom:u,pan:g,layoutOptions:b,showLayoutButton:f,selectionMode:v}=e??{},[p,m]=fr.useState(v??"single");fr.useEffect(()=>{v&&m(v)},[v]);const y=L=>{o({...e,layout:L})},k=fr.useRef(null),x=gpr(i);fr.useEffect(()=>{k.current&&vpr(k.current)},[]);const[_,S]=fr.useMemo(()=>[cpr(t??[]),lpr(r??[])],[t,r]),E=fr.useMemo(()=>({...s,minZoom:0,maxZoom:1e3,disableWebWorkers:!0}),[s]),[O,R]=fr.useState(!1),[M,I]=fr.useState(300);return mr.jsx(mK,{theme:x,wrapperProps:{isWrappingChildren:!1},children:mr.jsx("div",{ref:k,style:{height:n??"600px",width:a??"100%"},children:mr.jsx(hi,{nodes:_,rels:S,gesture:p,setGesture:m,selected:c??spr,setSelected:l,layout:d,setLayout:y,nvlOptions:E,zoom:u,pan:g,layoutOptions:b,sidepanel:{isSidePanelOpen:O,setIsSidePanelOpen:R,onSidePanelResize:I,sidePanelWidth:M,children:mr.jsx(hi.SingleSelectionSidePanelContents,{})},topLeftIsland:mr.jsx(hi.DownloadButton,{tooltipPlacement:"right"}),topRightIsland:mr.jsx(hi.ToggleSidePanelButton,{tooltipPlacement:"left"}),bottomRightIsland:mr.jsxs(rF,{size:"medium",orientation:"horizontal",children:[mr.jsx(hi.GestureSelectButton,{menuPlacement:"top-end-bottom-end",tooltipPlacement:"top"}),mr.jsx(hS,{orientation:"vertical"}),mr.jsx(hi.ZoomInButton,{tooltipPlacement:"top"}),mr.jsx(hi.ZoomOutButton,{tooltipPlacement:"top"}),mr.jsx(hi.ZoomToFitButton,{tooltipPlacement:"top"}),f&&mr.jsxs(mr.Fragment,{children:[mr.jsx(hS,{orientation:"vertical"}),mr.jsx(hi.LayoutSelectButton,{menuPlacement:"top-end-bottom-end",tooltipPlacement:"top"})]})]})})})})}function kpr(){return mr.jsx(dpr,{children:mr.jsx(ppr,{})})}const mpr=nY(kpr),ypr={render:mpr},x3=window.__NEO4J_VIZ_DATA__;if(!x3)throw document.body.innerHTML=` +`);if(WB){const t=document.createElement("style");t.textContent=WB,document.head.appendChild(t)}const bpr="[data-neo4j-viz-ndl-main]",hpr="[data-neo4j-viz-ndl-overlays]",fpr="[data-neo4j-viz-ndl-shadow-root]";function bS(t,r,e){const o=document.createElement("style");o.setAttribute(r,"true"),o.textContent=e,t.appendChild(o)}function vpr(t){const r=t.getRootNode();if(r instanceof ShadowRoot){r.querySelector(fpr)||bS(r,"data-neo4j-viz-ndl-shadow-root",zw),document.head.querySelector(hpr)||bS(document.head,"data-neo4j-viz-ndl-overlays",zw);return}document.head.querySelector(bpr)||bS(document.head,"data-neo4j-viz-ndl-main",zw)}function ppr(){const[t]=qv("nodes"),[r]=qv("relationships"),[e,o]=qv("options"),[n]=qv("height"),[a]=qv("width"),[i]=qv("theme"),[c,l]=qv("selected"),{layout:d,nvlOptions:s,zoom:u,pan:g,layoutOptions:b,showLayoutButton:f,selectionMode:v}=e??{},[p,m]=fr.useState(v??"single");fr.useEffect(()=>{v&&m(v)},[v]);const y=L=>{o({...e,layout:L})},k=fr.useRef(null),x=gpr(i);fr.useEffect(()=>{k.current&&vpr(k.current)},[]);const[_,S]=fr.useMemo(()=>[cpr(t??[]),lpr(r??[])],[t,r]),E=fr.useMemo(()=>({...s,minZoom:0,maxZoom:1e3,disableWebWorkers:!0}),[s]),[O,R]=fr.useState(!1),[M,I]=fr.useState(300);return mr.jsx(mK,{theme:x,wrapperProps:{isWrappingChildren:!1},children:mr.jsx("div",{ref:k,style:{height:n??"600px",width:a??"100%"},children:mr.jsx(hi,{nodes:_,rels:S,gesture:p,setGesture:m,selected:c??spr,setSelected:l,layout:d,setLayout:y,nvlOptions:E,zoom:u,pan:g,layoutOptions:b,sidepanel:{isSidePanelOpen:O,setIsSidePanelOpen:R,onSidePanelResize:I,sidePanelWidth:M,children:mr.jsx(hi.SingleSelectionSidePanelContents,{})},topLeftIsland:mr.jsx(hi.DownloadButton,{tooltipPlacement:"right"}),topRightIsland:mr.jsx(hi.ToggleSidePanelButton,{tooltipPlacement:"left"}),bottomRightIsland:mr.jsxs(rF,{size:"medium",orientation:"horizontal",children:[mr.jsx(hi.GestureSelectButton,{menuPlacement:"top-end-bottom-end",tooltipPlacement:"top"}),mr.jsx(hS,{orientation:"vertical"}),mr.jsx(hi.ZoomInButton,{tooltipPlacement:"top"}),mr.jsx(hi.ZoomOutButton,{tooltipPlacement:"top"}),mr.jsx(hi.ZoomToFitButton,{tooltipPlacement:"top"}),f&&mr.jsxs(mr.Fragment,{children:[mr.jsx(hS,{orientation:"vertical"}),mr.jsx(hi.LayoutSelectButton,{menuPlacement:"top-end-bottom-end",tooltipPlacement:"top"})]})]})})})})}function kpr(){return mr.jsx(dpr,{children:mr.jsx(ppr,{})})}const mpr=nY(kpr),ypr={render:mpr};function wpr(t){const r=new Map;return{get(e){return t[e]},set(e,o){var n;t[e]=o,(n=r.get(`change:${String(e)}`))==null||n.forEach(a=>a())},on(e,o){const n=r.get(e)??new Set;n.add(o),r.set(e,n)},off(e,o){var n;(n=r.get(e))==null||n.delete(o)},save_changes(){}}}const x3=window.__NEO4J_VIZ_DATA__;if(!x3)throw document.body.innerHTML=`

Missing visualization data

Expected window.__NEO4J_VIZ_DATA__ to be set.

This page should be generated by neo4j_viz's render() method.

- `,new Error("window.__NEO4J_VIZ_DATA__ is not defined");const wpr={get(t){return x3[t]},on(){},off(){},set(){},save_changes(){}},_3=document.getElementById("neo4j-viz-container");if(!_3)throw new Error("Container element #neo4j-viz-container not found");_3.style.width=x3.width??"100%";_3.style.height=x3.height??"100vh";ypr.render({model:wpr,el:_3}); + `,new Error("window.__NEO4J_VIZ_DATA__ is not defined");const xpr=wpr(x3),_3=document.getElementById("neo4j-viz-container");if(!_3)throw new Error("Container element #neo4j-viz-container not found");_3.style.width=x3.width??"100%";_3.style.height=x3.height??"100vh";ypr.render({model:xpr,el:_3});