@thebuoyant-tsdev/mui-ts-library 3.6.1 → 3.7.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.
@@ -1,67 +1,75 @@
1
- import { useEffect as e, useRef as t } from "react";
2
- import { Box as n, useTheme as r } from "@mui/material";
3
- import { EditorView as i, highlightActiveLine as a, highlightActiveLineGutter as o, keymap as s, lineNumbers as c, placeholder as l } from "@codemirror/view";
1
+ import { computeJsonPath as e } from "./util/jsonPathFinder.js";
2
+ import { findRangeForPath as t, validateAgainstSchema as n } from "./util/jsonSchemaValidator.js";
3
+ import { useEffect as r, useRef as i, useState as a } from "react";
4
+ import { Box as o, Fade as s, Paper as c, Typography as ee, useTheme as te } from "@mui/material";
5
+ import { EditorView as l, highlightActiveLine as ne, highlightActiveLineGutter as re, keymap as ie, lineNumbers as ae, placeholder as oe } from "@codemirror/view";
4
6
  import { Compartment as u, EditorState as d } from "@codemirror/state";
5
- import { json as f, jsonParseLinter as p } from "@codemirror/lang-json";
6
- import { defaultKeymap as m, history as h, historyKeymap as g } from "@codemirror/commands";
7
- import { HighlightStyle as _, syntaxHighlighting as v } from "@codemirror/language";
8
- import { lintGutter as y, linter as b } from "@codemirror/lint";
9
- import { tags as x } from "@lezer/highlight";
10
- import { showMinimap as S } from "@replit/codemirror-minimap";
11
- import { jsx as C } from "react/jsx-runtime";
7
+ import { json as se, jsonParseLinter as f } from "@codemirror/lang-json";
8
+ import { defaultKeymap as ce, history as le, historyKeymap as ue } from "@codemirror/commands";
9
+ import { HighlightStyle as de, foldGutter as fe, foldKeymap as pe, syntaxHighlighting as me } from "@codemirror/language";
10
+ import { forceLinting as he, lintGutter as ge, linter as p } from "@codemirror/lint";
11
+ import { tags as m } from "@lezer/highlight";
12
+ import { showMinimap as _e } from "@replit/codemirror-minimap";
13
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
12
14
  //#region src/components/json-editor/JsonEditorContent.tsx
13
- function w({ value: w, onChange: T, placeholder: E, disabled: D = !1, readonly: O = !1, showLineNumbers: k = !0, showMinimap: A = !1, highlightColors: j, onViewReady: M, onCursorChange: N, onBlur: P, onFocus: F }) {
14
- let I = t(null), L = t(null), R = t(T), z = t(N), B = t(P), V = t(F), H = t(M), U = t(new u()), W = t(new u()), G = r(), K = G.palette.mode === "dark", q = j?.propertyName ?? G.palette.primary.main, J = j?.string ?? G.palette.success.main, Y = j?.number ?? G.palette.warning.main, X = j?.boolean ?? G.palette.info.main, Z = j?.null ?? G.palette.text.secondary;
15
- return e(() => {
16
- R.current = T;
17
- }, [T]), e(() => {
18
- z.current = N;
19
- }, [N]), e(() => {
20
- B.current = P;
21
- }, [P]), e(() => {
22
- V.current = F;
23
- }, [F]), e(() => {
24
- H.current = M;
25
- }, [M]), e(() => {
26
- if (!I.current) return;
27
- let e = L.current?.state.doc.toString() ?? w ?? "", t = _.define([
15
+ function _({ value: _, onChange: v, placeholder: y, disabled: b = !1, readonly: x = !1, schema: S, showLineNumbers: ve = !0, showMinimap: C = !1, showFolding: w = !0, enablePathFinder: T = !0, highlightColors: E, onViewReady: D, onCursorChange: O, onBlur: k, onFocus: A, onPathCopy: j }) {
16
+ let M = i(null), N = i(null), P = i(null), F = i(v), I = i(O), L = i(k), R = i(A), z = i(D), B = i(j), V = i(T), H = i(S), [U, W] = a(null), G = i(new u()), K = i(new u()), q = te(), J = q.palette.mode === "dark", Y = E?.propertyName ?? q.palette.primary.main, X = E?.string ?? q.palette.success.main, Z = E?.number ?? q.palette.warning.main, Q = E?.boolean ?? q.palette.info.main, $ = E?.null ?? q.palette.text.secondary;
17
+ return r(() => {
18
+ F.current = v;
19
+ }, [v]), r(() => {
20
+ I.current = O;
21
+ }, [O]), r(() => {
22
+ L.current = k;
23
+ }, [k]), r(() => {
24
+ R.current = A;
25
+ }, [A]), r(() => {
26
+ z.current = D;
27
+ }, [D]), r(() => {
28
+ B.current = j;
29
+ }, [j]), r(() => {
30
+ V.current = T;
31
+ }, [T]), r(() => {
32
+ H.current = S, P.current && he(P.current);
33
+ }, [S]), r(() => {
34
+ if (!N.current) return;
35
+ let r = P.current?.state.doc.toString() ?? _ ?? "", i = de.define([
28
36
  {
29
- tag: x.propertyName,
30
- color: q,
37
+ tag: m.propertyName,
38
+ color: Y,
31
39
  fontWeight: "bold"
32
40
  },
33
41
  {
34
- tag: x.string,
35
- color: J
42
+ tag: m.string,
43
+ color: X
36
44
  },
37
45
  {
38
- tag: x.number,
39
- color: Y
46
+ tag: m.number,
47
+ color: Z
40
48
  },
41
49
  {
42
- tag: x.bool,
43
- color: X,
50
+ tag: m.bool,
51
+ color: Q,
44
52
  fontWeight: "bold"
45
53
  },
46
54
  {
47
- tag: x.null,
48
- color: Z,
55
+ tag: m.null,
56
+ color: $,
49
57
  fontStyle: "italic"
50
58
  },
51
59
  {
52
- tag: x.bracket,
53
- color: G.palette.text.secondary
60
+ tag: m.bracket,
61
+ color: q.palette.text.secondary
54
62
  },
55
63
  {
56
- tag: x.punctuation,
57
- color: G.palette.text.disabled
64
+ tag: m.punctuation,
65
+ color: q.palette.text.disabled
58
66
  },
59
67
  {
60
- tag: x.invalid,
61
- color: G.palette.error.main,
68
+ tag: m.invalid,
69
+ color: q.palette.error.main,
62
70
  textDecoration: "underline wavy"
63
71
  }
64
- ]), n = i.theme({
72
+ ]), a = l.theme({
65
73
  "&": {
66
74
  height: "100%",
67
75
  fontFamily: "'Fira Code', 'JetBrains Mono', 'Consolas', monospace",
@@ -70,116 +78,210 @@ function w({ value: w, onChange: T, placeholder: E, disabled: D = !1, readonly:
70
78
  ".cm-scroller": { overflow: "auto" },
71
79
  ".cm-content": {
72
80
  padding: "8px 4px",
73
- caretColor: G.palette.text.primary
81
+ caretColor: q.palette.text.primary
74
82
  },
75
83
  ".cm-gutters": {
76
- backgroundColor: K ? G.palette.grey[900] : G.palette.grey[50],
77
- color: G.palette.text.disabled,
84
+ backgroundColor: J ? q.palette.grey[900] : q.palette.grey[50],
85
+ color: q.palette.text.disabled,
78
86
  border: "none",
79
- borderRight: `1px solid ${G.palette.divider}`
87
+ borderRight: `1px solid ${q.palette.divider}`
80
88
  },
81
89
  ".cm-lineNumbers .cm-gutterElement": {
82
90
  paddingLeft: "4px",
83
91
  paddingRight: "8px"
84
92
  },
85
- ".cm-activeLineGutter": { backgroundColor: G.palette.action.selected },
86
- ".cm-activeLine": { backgroundColor: G.palette.action.hover },
87
- "&.cm-focused .cm-selectionBackground, .cm-selectionBackground": { backgroundColor: G.palette.primary.main + "40" },
88
- ".cm-cursor, .cm-dropCursor": { borderLeftColor: G.palette.text.primary },
93
+ ".cm-activeLineGutter": { backgroundColor: q.palette.action.selected },
94
+ ".cm-activeLine": { backgroundColor: q.palette.action.hover },
95
+ "&.cm-focused .cm-selectionBackground, .cm-selectionBackground": { backgroundColor: q.palette.primary.main + "40" },
96
+ ".cm-cursor, .cm-dropCursor": { borderLeftColor: q.palette.text.primary },
89
97
  "&.cm-focused": { outline: "none" },
90
98
  ".cm-placeholder": {
91
- color: G.palette.text.disabled,
99
+ color: q.palette.text.disabled,
92
100
  fontStyle: "italic"
93
101
  },
94
102
  ".cm-gutter-lint": { width: "16px" },
95
- ".cm-lint-marker-error": { color: G.palette.error.main },
96
- ".cm-lint-marker-warning": { color: G.palette.warning.main },
103
+ ".cm-lint-marker-error": { color: q.palette.error.main },
104
+ ".cm-lint-marker-warning": { color: q.palette.warning.main },
105
+ ".cm-foldGutter .cm-gutterElement": {
106
+ cursor: "pointer",
107
+ color: q.palette.text.disabled
108
+ },
109
+ ".cm-foldPlaceholder": {
110
+ backgroundColor: q.palette.action.selected,
111
+ border: `1px solid ${q.palette.divider}`,
112
+ borderRadius: "3px",
113
+ color: q.palette.text.secondary,
114
+ padding: "0 4px"
115
+ },
97
116
  ".cm-tooltip.cm-tooltip-lint": {
98
- backgroundColor: G.palette.background.paper,
99
- border: `1px solid ${G.palette.divider}`,
117
+ backgroundColor: q.palette.background.paper,
118
+ border: `1px solid ${q.palette.divider}`,
100
119
  borderRadius: "4px"
101
120
  },
102
- ".cm-diagnostic-error": { borderLeft: `3px solid ${G.palette.error.main}` },
103
- ".cm-diagnostic-warning": { borderLeft: `3px solid ${G.palette.warning.main}` }
104
- }, { dark: K }), r = A ? [S.of({
121
+ ".cm-diagnostic-error": { borderLeft: `3px solid ${q.palette.error.main}` },
122
+ ".cm-diagnostic-warning": { borderLeft: `3px solid ${q.palette.warning.main}` }
123
+ }, { dark: J }), o = C ? [_e.of({
105
124
  create: () => {
106
125
  let e = document.createElement("div");
107
- return e.style.width = "80px", e.style.overflow = "hidden", e.style.borderLeft = `1px solid ${G.palette.divider}`, e.style.backgroundColor = K ? G.palette.grey[900] : G.palette.grey[50], { dom: e };
126
+ return e.style.width = "80px", e.style.overflow = "hidden", e.style.borderLeft = `1px solid ${q.palette.divider}`, e.style.backgroundColor = J ? q.palette.grey[900] : q.palette.grey[50], { dom: e };
108
127
  },
109
128
  displayText: "blocks",
110
129
  showOverlay: "always"
111
- })] : [], u = [
112
- n,
113
- v(t),
114
- f(),
115
- y(),
116
- b(p()),
117
- h(),
118
- s.of([...m, ...g]),
119
- U.current.of(i.editable.of(!D && !O)),
120
- W.current.of(d.readOnly.of(O)),
121
- a(),
122
- ...k ? [c(), o()] : [],
123
- ...E ? [l(E)] : [],
124
- ...r,
125
- i.updateListener.of((e) => {
126
- e.docChanged && R.current?.(e.state.doc.toString());
130
+ })] : [], s = [
131
+ a,
132
+ me(i),
133
+ se(),
134
+ ge(),
135
+ p(f()),
136
+ p((e) => {
137
+ let r = H.current;
138
+ if (!r) return [];
139
+ let i;
140
+ try {
141
+ i = JSON.parse(e.state.doc.toString());
142
+ } catch {
143
+ return [];
144
+ }
145
+ let a = [];
146
+ for (let o of n(i, r)) {
147
+ let n = t(e.state, o.path);
148
+ n && a.push({
149
+ from: n.from,
150
+ to: n.to,
151
+ severity: "error",
152
+ message: o.message
153
+ });
154
+ }
155
+ return a;
156
+ }),
157
+ le(),
158
+ ie.of([
159
+ ...ce,
160
+ ...ue,
161
+ ...pe
162
+ ]),
163
+ G.current.of(l.editable.of(!b && !x)),
164
+ K.current.of(d.readOnly.of(x)),
165
+ ne(),
166
+ ...ve ? [ae(), re()] : [],
167
+ ...w ? [fe()] : [],
168
+ ...y ? [oe(y)] : [],
169
+ ...o,
170
+ l.updateListener.of((e) => {
171
+ e.docChanged && F.current?.(e.state.doc.toString());
127
172
  let t = e.state.selection.main.head, n = e.state.doc.lineAt(t);
128
- z.current(n.number, t - n.from + 1);
173
+ I.current(n.number, t - n.from + 1);
129
174
  }),
130
- i.domEventHandlers({
175
+ l.domEventHandlers({
131
176
  blur: () => {
132
- B.current?.();
177
+ L.current?.();
133
178
  },
134
179
  focus: () => {
135
- V.current?.();
180
+ R.current?.();
181
+ },
182
+ click: (t, n) => {
183
+ if (!V.current || !(t.ctrlKey || t.metaKey)) return !1;
184
+ let r;
185
+ try {
186
+ r = n.posAtCoords({
187
+ x: t.clientX,
188
+ y: t.clientY
189
+ });
190
+ } catch {
191
+ return !1;
192
+ }
193
+ if (r === null) return !1;
194
+ let i = e(n.state, r);
195
+ return i ? (navigator.clipboard.writeText(i).then(() => {
196
+ let e = M.current?.getBoundingClientRect();
197
+ W({
198
+ x: t.clientX - (e?.left ?? 0),
199
+ y: t.clientY - (e?.top ?? 0),
200
+ path: i
201
+ }), B.current?.(i);
202
+ }), !0) : !1;
136
203
  }
137
204
  })
138
- ], C = new i({
205
+ ], c = new l({
139
206
  state: d.create({
140
- doc: e,
141
- extensions: u
207
+ doc: r,
208
+ extensions: s
142
209
  }),
143
- parent: I.current
210
+ parent: N.current
144
211
  });
145
- return L.current = C, H.current(C), () => {
146
- H.current(null), C.destroy(), L.current = null;
212
+ return P.current = c, z.current(c), () => {
213
+ z.current(null), c.destroy(), P.current = null;
147
214
  };
148
215
  }, [
149
- K,
150
- q,
151
216
  J,
152
217
  Y,
153
218
  X,
154
219
  Z,
155
- A
156
- ]), e(() => {
157
- let e = L.current;
220
+ Q,
221
+ $,
222
+ C
223
+ ]), r(() => {
224
+ let e = P.current;
158
225
  if (!e) return;
159
226
  let t = e.state.doc.toString();
160
- t !== (w ?? "") && e.dispatch({ changes: {
227
+ t !== (_ ?? "") && e.dispatch({ changes: {
161
228
  from: 0,
162
229
  to: t.length,
163
- insert: w ?? ""
230
+ insert: _ ?? ""
164
231
  } });
165
- }, [w]), e(() => {
166
- L.current?.dispatch({ effects: [U.current.reconfigure(i.editable.of(!D && !O)), W.current.reconfigure(d.readOnly.of(O))] });
167
- }, [D, O]), /* @__PURE__ */ C(n, {
168
- ref: I,
232
+ }, [_]), r(() => {
233
+ P.current?.dispatch({ effects: [G.current.reconfigure(l.editable.of(!b && !x)), K.current.reconfigure(d.readOnly.of(x))] });
234
+ }, [b, x]), r(() => {
235
+ if (!U) return;
236
+ let e = setTimeout(() => W(null), 1500);
237
+ return () => clearTimeout(e);
238
+ }, [U]), /* @__PURE__ */ g(o, {
239
+ ref: M,
169
240
  sx: {
241
+ position: "relative",
170
242
  flex: 1,
171
243
  overflow: "hidden",
172
- display: "flex",
173
- flexDirection: "column",
174
- opacity: D ? .5 : 1,
175
- backgroundColor: G.palette.background.paper,
176
- "& .cm-editor": {
244
+ display: "flex"
245
+ },
246
+ children: [/* @__PURE__ */ h(o, {
247
+ ref: N,
248
+ sx: {
177
249
  flex: 1,
250
+ overflow: "hidden",
178
251
  display: "flex",
179
- flexDirection: "column"
252
+ flexDirection: "column",
253
+ opacity: b ? .5 : 1,
254
+ backgroundColor: q.palette.background.paper,
255
+ "& .cm-editor": {
256
+ flex: 1,
257
+ display: "flex",
258
+ flexDirection: "column"
259
+ }
180
260
  }
181
- }
261
+ }), U && /* @__PURE__ */ h(s, {
262
+ in: !0,
263
+ children: /* @__PURE__ */ h(c, {
264
+ elevation: 3,
265
+ sx: {
266
+ position: "absolute",
267
+ left: U.x,
268
+ top: U.y,
269
+ transform: "translate(-50%, -130%)",
270
+ px: 1,
271
+ py: .5,
272
+ pointerEvents: "none",
273
+ zIndex: 10,
274
+ bgcolor: "grey.900",
275
+ color: "common.white"
276
+ },
277
+ children: /* @__PURE__ */ g(ee, {
278
+ variant: "caption",
279
+ sx: { fontFamily: "monospace" },
280
+ children: ["Copied: ", U.path]
281
+ })
282
+ })
283
+ })]
182
284
  });
183
285
  }
184
286
  //#endregion
185
- export { w as JsonEditorContent };
287
+ export { _ as JsonEditorContent };
@@ -0,0 +1,9 @@
1
+ import type { EditorState } from "@codemirror/state";
2
+ /**
3
+ * Walks up the Lezer JSON syntax tree from `pos` to compute the JSON path
4
+ * (e.g. "$.users[0].name") of the value or property key under the cursor.
5
+ *
6
+ * Returns "$" for the document root, or null if `pos` doesn't resolve to any
7
+ * node (e.g. an empty document).
8
+ */
9
+ export declare function computeJsonPath(state: EditorState, pos: number): string | null;
@@ -0,0 +1,45 @@
1
+ import { syntaxTree as e } from "@codemirror/language";
2
+ //#region src/components/json-editor/util/jsonPathFinder.ts
3
+ var t = /^[A-Za-z_$][A-Za-z0-9_$]*$/, n = new Set([
4
+ "Object",
5
+ "Array",
6
+ "String",
7
+ "Number",
8
+ "True",
9
+ "False",
10
+ "Null"
11
+ ]);
12
+ function r(e) {
13
+ return t.test(e) ? `.${e}` : `[${JSON.stringify(e)}]`;
14
+ }
15
+ function i(t, i) {
16
+ if (t.doc.length === 0) return null;
17
+ let a = e(t).resolveInner(i, 1);
18
+ if (!a) return null;
19
+ let o = [];
20
+ for (; a;) {
21
+ let e = a.parent;
22
+ if (!e) break;
23
+ if (e.name === "Property") {
24
+ let n = e.getChild("PropertyName");
25
+ if (n) {
26
+ let e = t.sliceDoc(n.from, n.to);
27
+ try {
28
+ o.unshift(r(JSON.parse(e)));
29
+ } catch {}
30
+ }
31
+ a = e.parent ?? e;
32
+ continue;
33
+ }
34
+ if (e.name === "Array") {
35
+ let t = 0, r = e.firstChild;
36
+ for (; r && r.from < a.from;) n.has(r.name) && t++, r = r.nextSibling;
37
+ o.unshift(`[${t}]`), a = e;
38
+ continue;
39
+ }
40
+ a = e;
41
+ }
42
+ return o.length > 0 ? `$${o.join("")}` : "$";
43
+ }
44
+ //#endregion
45
+ export { i as computeJsonPath };
@@ -0,0 +1,22 @@
1
+ import type { EditorState } from "@codemirror/state";
2
+ import type { JsonEditorSchema } from "../JsonEditor.types";
3
+ export type JsonSchemaValidationError = {
4
+ /** JSON path of the offending value, e.g. "$.users[0].age" */
5
+ path: string;
6
+ message: string;
7
+ };
8
+ /**
9
+ * Validates a parsed JSON value against a focused JSON Schema subset (type,
10
+ * required, enum, nested properties/items). Returns one error per violation,
11
+ * each tagged with the JSON path of the offending value.
12
+ */
13
+ export declare function validateAgainstSchema(value: unknown, schema: JsonEditorSchema, path?: string): JsonSchemaValidationError[];
14
+ /**
15
+ * Resolves a JSON path (as produced by `validateAgainstSchema`) to its
16
+ * source range in the document, by walking the syntax tree down from the
17
+ * root. Returns null if the path can't be resolved (e.g. document changed).
18
+ */
19
+ export declare function findRangeForPath(state: EditorState, path: string): {
20
+ from: number;
21
+ to: number;
22
+ } | null;
@@ -0,0 +1,116 @@
1
+ import { syntaxTree as e } from "@codemirror/language";
2
+ //#region src/components/json-editor/util/jsonSchemaValidator.ts
3
+ var t = new Set([
4
+ "Object",
5
+ "Array",
6
+ "String",
7
+ "Number",
8
+ "True",
9
+ "False",
10
+ "Null"
11
+ ]), n = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
12
+ function r(e) {
13
+ return n.test(e) ? `.${e}` : `[${JSON.stringify(e)}]`;
14
+ }
15
+ function i(e) {
16
+ return e === null ? "null" : Array.isArray(e) ? "array" : typeof e == "number" ? Number.isInteger(e) ? "integer" : "number" : typeof e == "string" ? "string" : typeof e == "boolean" ? "boolean" : "object";
17
+ }
18
+ function a(e, t) {
19
+ let n = i(e);
20
+ return n === t || t === "number" && n === "integer";
21
+ }
22
+ function o(e, t) {
23
+ if (e === t) return !0;
24
+ if (Array.isArray(e) && Array.isArray(t)) return e.length === t.length && e.every((e, n) => o(e, t[n]));
25
+ if (e && t && typeof e == "object" && typeof t == "object") {
26
+ let n = Object.keys(e), r = Object.keys(t);
27
+ return n.length === r.length ? n.every((n) => o(e[n], t[n])) : !1;
28
+ }
29
+ return !1;
30
+ }
31
+ function s(e, t, n = "$") {
32
+ let c = [];
33
+ if (t.type) {
34
+ let r = Array.isArray(t.type) ? t.type : [t.type];
35
+ if (!r.some((t) => a(e, t))) return c.push({
36
+ path: n,
37
+ message: `Expected type ${r.join(" | ")}, got ${i(e)}.`
38
+ }), c;
39
+ }
40
+ if (t.enum && !t.enum.some((t) => o(t, e)) && c.push({
41
+ path: n,
42
+ message: `Value must be one of: ${t.enum.map((e) => JSON.stringify(e)).join(", ")}.`
43
+ }), i(e) === "object" && e !== null) {
44
+ let i = e;
45
+ for (let e of t.required ?? []) e in i || c.push({
46
+ path: n,
47
+ message: `Missing required property "${e}".`
48
+ });
49
+ if (t.properties) for (let [e, a] of Object.entries(t.properties)) e in i && c.push(...s(i[e], a, `${n}${r(e)}`));
50
+ }
51
+ return t.items && Array.isArray(e) && e.forEach((e, r) => {
52
+ c.push(...s(e, t.items, `${n}[${r}]`));
53
+ }), c;
54
+ }
55
+ var c = /\.([A-Za-z_$][A-Za-z0-9_$]*)|\[(\d+)\]|\["((?:[^"\\]|\\.)*)"\]/g;
56
+ function l(e) {
57
+ let t = [];
58
+ for (let n of e.matchAll(c)) n[1] === void 0 ? n[2] === void 0 ? n[3] !== void 0 && t.push({
59
+ type: "key",
60
+ value: JSON.parse(`"${n[3]}"`)
61
+ }) : t.push({
62
+ type: "index",
63
+ value: Number(n[2])
64
+ }) : t.push({
65
+ type: "key",
66
+ value: n[1]
67
+ });
68
+ return t;
69
+ }
70
+ function u(e) {
71
+ let n = e.topNode;
72
+ for (; n && !t.has(n.name);) {
73
+ let e = n.firstChild;
74
+ if (!e) return null;
75
+ n = e;
76
+ }
77
+ return n;
78
+ }
79
+ function d(n, r) {
80
+ let i = u(e(n));
81
+ if (!i) return null;
82
+ for (let e of l(r)) if (e.type === "key") {
83
+ if (i.name !== "Object") return null;
84
+ let t = null;
85
+ for (let r = i.firstChild; r; r = r.nextSibling) {
86
+ if (r.name !== "Property") continue;
87
+ let i = r.getChild("PropertyName");
88
+ if (i) try {
89
+ if (JSON.parse(n.sliceDoc(i.from, i.to)) === e.value) {
90
+ t = r.lastChild;
91
+ break;
92
+ }
93
+ } catch {}
94
+ }
95
+ if (!t) return null;
96
+ i = t;
97
+ } else {
98
+ if (i.name !== "Array") return null;
99
+ let n = 0, r = null;
100
+ for (let a = i.firstChild; a; a = a.nextSibling) if (t.has(a.name)) {
101
+ if (n === e.value) {
102
+ r = a;
103
+ break;
104
+ }
105
+ n++;
106
+ }
107
+ if (!r) return null;
108
+ i = r;
109
+ }
110
+ return {
111
+ from: i.from,
112
+ to: i.to
113
+ };
114
+ }
115
+ //#endregion
116
+ export { d as findRangeForPath, s as validateAgainstSchema };