json-edit-react 2.0.0-beta.0 → 2.0.0-beta.10
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/README.md +59 -37
- package/build/index.cjs.js +1 -1
- package/build/index.d.ts +12 -6
- package/build/index.esm.js +1 -1
- package/build/style.css +16 -6
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<!-- Template for the README on the package's npm page: https://www.npmjs.com/package/json-edit-react
|
|
2
|
+
scripts/build_npm_readme.py fills the marker blocks below from the matching comment-delimited
|
|
3
|
+
sections of the source README (README_V2.md), converts GitHub admonitions to plain-markdown
|
|
4
|
+
bold-label blockquotes (npm strips inline styles), rewrites relative links to absolute GitHub
|
|
5
|
+
URLs, and writes the result into the build_package/ staging dir. The repo-root README is never
|
|
6
|
+
touched. Invoked by scripts/stage-package.mjs during pnpm build-package.
|
|
7
|
+
Keep this comment free of the HTML-comment-close sequence and of brace markers, or it leaks
|
|
8
|
+
into the generated README.
|
|
9
|
+
-->
|
|
8
10
|
|
|
9
11
|
<img width="60" alt="screenshot" src="image/logo192.png" style="float:left; margin-right: 1em;">
|
|
10
12
|
|
|
11
13
|
A highly-configurable [React](https://github.com/facebook/react) component for editing or viewing JSON/object data
|
|
12
14
|
|
|
13
15
|
|
|
14
|
-
## [Explore the Demo](https://carlosnz.github.io/json-edit-react/) <!-- omit in toc -->
|
|
16
|
+
## 🚀️ [Explore the Demo](https://carlosnz.github.io/json-edit-react-v2/) <!-- omit in toc -->
|
|
15
17
|
|
|
16
18
|

|
|
17
19
|

|
|
@@ -27,20 +29,52 @@ A highly-configurable [React](https://github.com/facebook/react) component for e
|
|
|
27
29
|
- ✅ **Easy inline editing** of individual values or whole blocks of JSON text
|
|
28
30
|
- 🔒 **Granular control** – restrict edits, deletions, or additions per element
|
|
29
31
|
- 📏 **[JSON Schema](https://json-schema.org/) validation** (using 3rd-party validation library)
|
|
30
|
-
- 🎨 **Customisable UI** — built-in or custom [themes](https://github.com/CarlosNZ/json-edit-react#
|
|
32
|
+
- 🎨 **Customisable UI** — built-in or custom [themes](https://github.com/CarlosNZ/json-edit-react#appearance--theming), CSS overrides or targeted classes
|
|
31
33
|
- 📦 **Self-contained** — plain HTML/CSS, no external UI library dependencies, and *zero runtime dependencies*
|
|
32
34
|
- 🔍 **Search & filter** — find data by key, value or custom function
|
|
33
|
-
- 🚧 **[Custom components](https://github.com/CarlosNZ/json-edit-react#custom-nodes)** — replace keys and/or values with specialised components (e.g. date picker, links, images, `undefined`, `BigInt`, `Symbol`)
|
|
35
|
+
- 🚧 **[Custom components](https://github.com/CarlosNZ/json-edit-react#custom-nodes--components)** — replace keys and/or values with specialised components (e.g. date picker, links, images, `undefined`, `BigInt`, `Symbol`)
|
|
34
36
|
- 🌏 **[Localisation](https://github.com/CarlosNZ/json-edit-react#localisation)** — easily translate UI labels and messages
|
|
35
|
-
- 🔄 **[Drag-n-drop](https://github.com/CarlosNZ/json-edit-react#drag-
|
|
36
|
-
- 🎹 **[Keyboard customisation](https://github.com/CarlosNZ/json-edit-react#keyboard-
|
|
37
|
-
- 🎮 **[External control](https://github.com/CarlosNZ/json-edit-react#
|
|
37
|
+
- 🔄 **[Drag-n-drop](https://github.com/CarlosNZ/json-edit-react#drag-and-drop-reordering)** re-ordering within objects/arrays
|
|
38
|
+
- 🎹 **[Keyboard customisation](https://github.com/CarlosNZ/json-edit-react#keyboard-control)** — define your own key bindings
|
|
39
|
+
- 🎮 **[External control](https://github.com/CarlosNZ/json-edit-react#programmatic-control)** via callbacks and imperative methods
|
|
38
40
|
|
|
39
|
-
💡 Try the **[Live Demo](https://carlosnz.github.io/json-edit-react/)** to see these features in action!
|
|
41
|
+
💡 Try the **[Live Demo](https://carlosnz.github.io/json-edit-react-v2/)** to see these features in action!
|
|
40
42
|
|
|
41
43
|
<img width="392" alt="screenshot" src="image/screenshot.png">
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
> **🚨 IMPORTANT**
|
|
46
|
+
>
|
|
47
|
+
> This documentation is for V2 of **json-edit-react**, which is currently in beta. V1 docs are [here](https://github.com/CarlosNZ/json-edit-react).
|
|
48
|
+
>
|
|
49
|
+
> If you're upgrading from V1, be sure to read the [migration guide](https://github.com/CarlosNZ/json-edit-react/blob/main/migration-guide.md).
|
|
50
|
+
>
|
|
51
|
+
> 🎤️ Got feedback? [Open an issue](https://github.com/CarlosNZ/json-edit-react/issues), or [join the discussion](https://github.com/CarlosNZ/json-edit-react/discussions/198).
|
|
52
|
+
|
|
53
|
+
## Optional Companion Packages <!-- omit in toc -->
|
|
54
|
+
|
|
55
|
+
- **THEMES**: [@json-edit-react/themes](https://www.npmjs.com/package/@json-edit-react/themes) — curated, ready-made [themes] (#themes)
|
|
56
|
+
- **COMPONENTS**: [@json-edit-react/components](https://www.npmjs.com/package/@json-edit-react/components) - custom node components (links, date picker, etc.)
|
|
57
|
+
- **UTILITIES**: [@json-edit-react/utils](https://www.npmjs.com/package/@json-edit-react/themes) — a collection of helpers and tools for extending and streamlining your **json-edit-react** experience
|
|
58
|
+
|
|
59
|
+
## Using the editor (for end users)
|
|
60
|
+
|
|
61
|
+
It's pretty self explanatory (click the "edit" icon to edit, etc.), but there are a few not-so-obvious ways of interacting with the editor:
|
|
62
|
+
|
|
63
|
+
- **Double-click** a value (or a key) to edit it
|
|
64
|
+
- When editing a string, use <kbd>Cmd</kbd>/<kbd>Ctrl</kbd>-<kbd>Enter</kbd> or <kbd>Shift</kbd>-<kbd>Enter</kbd> to add a new line (<kbd>Enter</kbd> submits the value)
|
|
65
|
+
- It's the opposite when editing a full object/array node (which you do by **clicking "edit"** on an object or array value) — <kbd>Enter</kbd> for new line, and <kbd>Cmd</kbd>/<kbd>Ctrl</kbd>/<kbd>Shift</kbd>-<kbd>Enter</kbd> for submit
|
|
66
|
+
- <kbd>Escape</kbd> to **cancel** editing
|
|
67
|
+
- Use <kbd>Tab</kbd>/<kbd>Shift-Tab</kbd> to quickly move from one value to another when editing
|
|
68
|
+
- When clicking the "**clipboard**" icon, holding down <kbd>Cmd</kbd>/<kbd>Ctrl</kbd> will copy the *path* to the selected node rather than its value
|
|
69
|
+
- When opening/closing a node, hold down <kbd>Alt</kbd>/<kbd>Option</kbd> to open/close *all* child nodes at once
|
|
70
|
+
- For Number inputs, the <kbd>↑</kbd> / <kbd>↓</kbd> arrow keys will increment/decrement the value
|
|
71
|
+
- For Boolean inputs, the <kbd>Space</kbd> bar will toggle the value
|
|
72
|
+
- Easily navigate to the next or previous node for editing using the <kbd>Tab</kbd>/<kbd>Shift-Tab</kbd> keys.
|
|
73
|
+
- **Drag and drop** items to change the structure or modify display order
|
|
74
|
+
- When editing is not permitted, double-clicking a string value will expand the text to the full value if it is truncated due to length (there is also a clickable "..." for long strings)
|
|
75
|
+
- **JSON text input** can accept "looser" input, if an additional JSON parsing method is provided (e.g. [JSON5](https://json5.org/)). See `jsonParse` prop.
|
|
76
|
+
|
|
77
|
+
[Have a play with the Demo app](https://carlosnz.github.io/json-edit-react-v2/) to get a feel for it!
|
|
44
78
|
|
|
45
79
|
## Installation
|
|
46
80
|
|
|
@@ -50,6 +84,8 @@ A highly-configurable [React](https://github.com/facebook/react) component for e
|
|
|
50
84
|
npm i json-edit-react
|
|
51
85
|
# OR
|
|
52
86
|
yarn add json-edit-react
|
|
87
|
+
# OR
|
|
88
|
+
pnpm add json-edit-react
|
|
53
89
|
```
|
|
54
90
|
|
|
55
91
|
## Implementation
|
|
@@ -61,32 +97,18 @@ import { JsonEditor } from 'json-edit-react'
|
|
|
61
97
|
return (
|
|
62
98
|
<JsonEditor
|
|
63
99
|
data={ jsonData }
|
|
64
|
-
setData={ setJsonData }
|
|
100
|
+
setData={ setJsonData }
|
|
65
101
|
{ ...otherProps } />
|
|
66
102
|
);
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Usage
|
|
70
|
-
|
|
71
|
-
**(for end user)**
|
|
72
|
-
|
|
73
|
-
It's pretty self explanatory (click the "edit" icon to edit, etc.), but there are a few not-so-obvious ways of interacting with the editor:
|
|
74
103
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- It's the opposite when editing a full object/array node (which you do by **clicking "edit"** on an object or array value) — `Enter` for new line, and `Cmd/Ctrl/Shift-Enter` for submit
|
|
78
|
-
- `Escape` to **cancel** editing
|
|
79
|
-
- When clicking the "**clipboard**" icon, holding down `Cmd/Ctrl` will copy the *path* to the selected node rather than its value
|
|
80
|
-
- When opening/closing a node, hold down "Alt/Option" to open/close *all* child nodes at once
|
|
81
|
-
- For Number inputs, **arrow-up** and **down** keys will increment/decrement the value
|
|
82
|
-
- For Boolean inputs, **space bar** will toggle the value
|
|
83
|
-
- Easily navigate to the next or previous node for editing using the `Tab`/`Shift-Tab` keys.
|
|
84
|
-
- **Drag and drop** items to change the structure or modify display order
|
|
85
|
-
- When editing is not permitted, double-clicking a string value will expand the text to the full value if it is truncated due to length (there is also a clickable "..." for long strings)
|
|
86
|
-
- **JSON text input** can accept "looser" input, if an additional JSON parsing method is provided (e.g. [JSON5](https://json5.org/)). See `jsonParse` prop.
|
|
104
|
+
// For a read-only viewer, use the `JsonViewer` component instead:
|
|
105
|
+
import { JsonViewer } from 'json-edit-react'
|
|
87
106
|
|
|
88
|
-
|
|
107
|
+
return <JsonViewer data={ jsonData } { ...otherProps } />
|
|
108
|
+
```
|
|
89
109
|
|
|
90
110
|
---
|
|
91
111
|
|
|
92
|
-
|
|
112
|
+
<!-- Don't forget to replace this link with base URL rather than README_V2 once V2 is released -->
|
|
113
|
+
|
|
114
|
+
For **FULL DOCUMENTATION**, visit [https://github.com/CarlosNZ/json-edit-react](https://github.com/CarlosNZ/json-edit-react/blob/main/README_V2.md)
|
package/build/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react");const n=()=>{},r=e=>Array.isArray(e)?e:[e],o=e=>null!==e&&"object"==typeof e,a=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),s=(e,t)=>{if("string"!=typeof e)return null;const n=t.filter(t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority);return n.sort((e,t)=>(t.matchPriority??0)-(e.matchPriority??0)),n[0]??null},i=e=>{if(e!==l){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=i(n);r!==n&&(e[t]=r)}return e}},l="__undefined__",c=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),u=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),d=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),p=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),m=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),h=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},f=e=>Array.isArray(e),y=(e,t)=>e.filter((e,n)=>n!==t),g=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:s=!1}=r,i=e,l=u(t),d={...r,remove:o,createNew:a,noError:s,fullData:i,fullPath:l},p=Array.isArray(t)?t:c(t);return f(e)&&o&&1===p.length?y(e,p[0]):v(e,p,n,d)},v=(e,t,n,r)=>{const o=a(e)?{...e}:null,s=f(e)?[...e]:null;if(0===t.length)return e;if(!o&&!s)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:c,fullData:u,fullPath:d}=r,p=t[0];if(s&&"string"==typeof p)return s.map(e=>v(e,t,n,r));if(1===t.length){if(o&&"string"==typeof p){return b(o,p,n,r)??o}return s&&"number"==typeof p?(j(s,p,n,r),s):(h(u,d,p,c),e)}const m=o||s||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=m[p],n=t[1];return f(e)?m[p]=y(e,n):h(u,d,p,c,"Trying to remove an indexed item from an object that is not an array"),m}const g=t.slice(1);if(p in e){if(x=m[p],!f(x)&&!a(x)){if(!i)return h(u,d,p,c),m;m[p]={}}return m[p]=v(m[p],g,n,r),m}var x;if(i){const e="number"==typeof g[0]?[]:{};if(o)return m[p]=e,m[p]=v(m[p],g,n,r),m;if(s&&Array.isArray(m)){m.push(e);const t=m.length-1;return m[t]=v(m[t],g,n,r),m}}return h(u,d,p,c),m},b=(e,t,n,r)=>{const{remove:o,createNew:a,noError:s,insertAfter:i,insertBefore:l,fullData:c,fullPath:u}=r;if(void 0!==l||void 0!==i){const r=Object.entries(e);let o=1/0;return o="number"==typeof l?l:"number"==typeof i?i:r.findIndex(([e])=>e===(l??i)),void 0!==i&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const d=t in e;o?d?delete e[t]:h(c,u,t,s):a||d?e[t]=n:h(c,u,t,s)},j=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:s,createNew:i,insert:l}=r;l&&e.splice(t,0,n),t in e?e[t]=n:i?e.push(n):h(a,s,t,o)},x=(e,t,n)=>{const r=Array.isArray(t)?t:c(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>x(e,r,n));if("object"!=typeof e||null===e||!(o in e))return w(e,o,n);const a=e[o];return 1===r.length?a:x(a,r.slice(1),n)},w=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},E=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:o(e)?Object.keys(e).length:1,parentData:null,fullData:e};const a=t[t.length-1],s=x(e,t),i=x(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof a?a:Number(a);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===a)}return{key:a,path:t,level:t.length,index:l,value:s,size:o(s)?Object.keys(s).length:null,parentData:i,fullData:e}},C="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,D=({className:n,name:r,value:o,setValue:a,onKeyDown:s,styles:i,textAreaRef:l})=>{const c=t.useRef(null);if(C(()=>{const e=c.current;c.current=null;const t=l?.current;if(!e||!t)return;const n=e.start+o.length-e.sourceLength,r=Math.max(0,Math.min(n,o.length));t.selectionStart!==r&&t.setSelectionRange(r,r)},[o,l]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${r}_textarea`,ref:l,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...i},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;c.current=null!==n&&n<t.length?{start:n,sourceLength:t.length}:null,a(t)},autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:s}),e.jsx("span",{className:n,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...i},children:u})]})},S=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,k=(e,t,n)=>{if(!t)return!1;const r=e.key,o=S(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:s}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!s?.includes("Shift"))&&(r===a&&(s===o||Array.isArray(s)&&s.includes(o)))},O={key:"Enter"},R={confirm:O,cancel:{key:"Escape"},objectConfirm:{...O,modifier:["Meta","Shift","Control"]},objectLineBreak:O,stringConfirm:O,stringLineBreak:{...O,modifier:["Shift"]},numberConfirm:O,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:O,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},T=["stringConfirm","numberConfirm","booleanConfirm"],N=(e,t)=>{const n=e.current,r=n.selectionStart??1/0,o=n.selectionEnd??1/0,a=n.value.slice(0,r)+t+n.value.slice(o);return n.value=a,n.setSelectionRange(r+1,r+1),a},P=(e,t,n="next",r,a)=>{const s=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=x(e,s),c=I(l);Array.isArray(l)||r(c,({key:e,value:t})=>[e,t]);const u=c.findIndex(e=>e.key===i),d=c[u+("next"===n?1:-1)];if(!d)return 0===s.length?null:P(e,s,n,r,a);let p;if(o(d.value)){if(0===Object.keys(d.value).length)return P(e,[...s,d.key],n,r,a);p=A(e,[...s,d.key],n,r)}else p=[...s,d.key];return p?a(E(e,p,"",r))?p:P(e,p,n,r,a):null},A=(e,t,n="next",r)=>{const a=x(e,t);if(!o(a))return t;const s=Array.isArray(a)?a.map((e,t)=>t):Object.keys(a);r(s,e=>[e,a]);const i="next"===n?s[0]:s[s.length-1];return A(e,[...t,i],n,r)},I=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),K={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},L={displayName:"Default",icons:{add:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:K,scale:.86},ok:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:K,scale:.9},cancel:{content:e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},M={container:"backgroundColor",collection:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},_=e=>[L,...r(e)].map(e=>"styles"in e?e:{styles:e}),V=e=>{const t={};for(const{icons:n}of _(e))n&&Object.assign(t,n);return t},z={getStyles:()=>({}),icons:V(L),cssVars:{}},F=t.createContext(z),B=({theme:n=L,children:r})=>{const o=t.useMemo(()=>(e=>{var t;const n=_(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[M[a]??"color"]:t}:t}}}for(const e in o)r[t=e]??(r[t]={});const a={};for(const e in r){const t=e,n=r[t],s=o[t];a[t]=s?e=>s.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(n),[n]),a=t.useMemo(()=>V(n),[n]),s=t.useMemo(()=>(e=>{const{inputHighlight:t,iconCopy:n}=e,r={};return"function"!=typeof t&&t?.backgroundColor&&(r["--jer-highlight-color"]=t.backgroundColor),"function"!=typeof n&&n?.color&&(r["--jer-icon-copy-color"]=n.color),r})(o),[o]),i=t.useCallback((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(o,e,t),[o]),l=t.useMemo(()=>({getStyles:i,icons:a,cssVars:s}),[i,a,s]);return e.jsx(F.Provider,{value:l,children:r})},Y=()=>t.useContext(F),U={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},H=(e,t)=>U[e][t]??null,W=(e,t)=>null!==e&&null!==t&&e.op===t.op&&p(e.path,t.path),$={active:null,settling:{}},J=(e,t,n)=>{let r=$;const o=new Set;let a=null,s=null,i=!1,l=0;const c=e=>{r=e,o.forEach(e=>e())},u=(t,n,r)=>{e.current?.({...t,...r,event:n})},h=(n,o,i)=>{if(!e.current)return;let l;try{l=t.current?.(n)}catch{return c({...r,active:null}),a=null,void(s=null)}l&&u(l,o,i)},f=(e,t)=>{var n;a=t?.cancelOp??null,s=t?.commitOp??null,n=e,W(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=H(e.op,"start");o&&h(e.path,o)},y=(e,t,o,i,l,m,h,f,y)=>{const g=d(e);if(!h()){if("cancel"===i.status||"error"===i.status){"held"===r.active?.phase&&p(r.active.path,e)&&(c({...r,active:null}),a=null,s=null);const n=H(t,"cancel");return n&&u(f,n),"error"===i.status&&u(f,"updateError",{operation:t,error:i.error}),i}l()}if(r.settling[g]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],c({...r,settling:t})})(g),i.status){case"cancel":m();break;case"error":m(),u(f,"updateError",{operation:t,error:i.error});break;case"override":n.current?.applyValue(i.path,i.value),u(f,"updateSuccess",{operation:t,...y});break;case"commit":u(f,"updateSuccess",{operation:t,...y})}return i}};return{subscribe:e=>(o.add(e),()=>o.delete(e)),getSnapshot:()=>r,getServerSnapshot:()=>r,open:(e,t)=>{if("held"===r.active?.phase)return;const n={path:e,op:t?.op??"edit",phase:"editing",force:t?.force},o=r.active,i=null!==o&&!W(o,n);if(i&&s)return void s(()=>f(n,t));const l=a;if(a=null,s=null,l&&l(),i&&W(r.active,o)){const e=H(o.op,"cancel");e&&h(o.path,e)}f(n,t)},cancel:()=>{if(i)return;if("held"===r.active?.phase)return;const e=r.active;i=!0;try{const t=a;if(a=null,s=null,t&&t(),null!==e){null!==r.active&&c({...r,active:null});const t=H(e.op,"cancel");t&&h(e.path,t)}}finally{i=!1}},submit:e=>{const{op:t,path:o,instant:i,onCommit:p}=e,m=n.current;let f;try{f=m?.buildCommit(e)??null}catch{return W(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,s=null,p?.(),Promise.resolve(void 0)}const g=f?.extra,v=d(o),b=++l;if(!i){const e=H(t,"submit");e&&h(o,e)}if(!f||f.isNoOp){W(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,s=null;const e=H(t,"commit");return e&&(f?u(f.nodeData,e,g):h(o,e,g)),p?.(),Promise.resolve(void 0)}const{input:j,nodeData:x,apply:w,revert:E}=f,C=!!m?.runUpdate;let D=!1,S=!1;const k=()=>{if(D)return;D=!0,w(),a=null,s=null,W(r.active,{path:o,op:t})&&c({...r,active:null}),C&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(v,b);const e=H(t,"commit");e&&u(x,e,g),p?.()},O={hold:()=>(S=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>k())};if(!C)return k(),Promise.resolve(void 0);const R=m.runUpdate(j,O);let T;return S||(i?T=setTimeout(k,100):k()),R.then(e=>(clearTimeout(T),y(o,t,b,e,k,E,()=>D,x,g)))},areChildrenBeingEdited:e=>null!==r.active&&m(r.active.path,e)}},X=t.createContext(null),Q=({children:n,onEditEvent:r,buildNodeDataFromPathRef:o,commitRef:a})=>{const s=t.useRef(r);s.current=r;const i=t.useRef(null);return null===i.current&&(i.current=J(s,o,a)),e.jsx(X.Provider,{value:i.current,children:n})},Z=()=>{const e=t.useContext(X);if(!e)throw new Error("Missing Editing Context Provider");return e},G=e=>{const n=Z();return t.useSyncExternalStore(n.subscribe,()=>e(n.getSnapshot()),()=>e(n.getServerSnapshot()))},q=t.createContext(null),ee=({children:n,onCollapse:o,buildNodeDataFromPathRef:a})=>{const[s,i]=t.useState({commands:null,version:0}),l=t.useRef(o);l.current=o;const c=t.useCallback(e=>{if(null===e)return void i(e=>null===e.commands?e:{commands:null,version:e.version});const t=r(e),n=t.map(e=>({...e,path:[...e.path]}));i(e=>({commands:n,version:e.version+1}));const o=l.current;o&&t.forEach(e=>{const t=a.current?.(e.path);t&&o({...t,collapsed:e.collapsed,includeChildren:e.includeChildren})})},[a]),u=t.useMemo(()=>({commands:s.commands,version:s.version,setCollapseState:c}),[s.commands,s.version,c]);return e.jsx(q.Provider,{value:u,children:n})},te=()=>{const e=t.useContext(q);if(!e)throw new Error("Missing Collapse Context Provider");return e},ne=(e,t)=>{if(!t.includeChildren)return t.path.length===e.length&&t.path.every((t,n)=>e[n]===t);for(const[n,r]of t.path.entries())if(r!==e[n])return!1;return!0},re=t.createContext(null),oe=({children:n})=>{const[r,o]=t.useState({path:null}),a=t.useRef(!1),s=t.useMemo(()=>({dragSource:r,setDragSource:o,armed:a}),[r]);return e.jsx(re.Provider,{value:s,children:n})},ae=({children:t,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>e.jsx(Q,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:e.jsx(ee,{onCollapse:r,buildNodeDataFromPathRef:o,children:e.jsx(oe,{children:t})})}),se=t.createContext(void 0),ie=({value:t,children:n})=>e.jsx(se.Provider,{value:t,children:n}),le=()=>{const e=t.useContext(se);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},ce=e=>{const t=le();return null===t||t.visiblePaths.has(d(e))},ue=e=>{const t=le();return null===t?null:t.visibleChildCounts.get(d(e))??null},de="**INVALID_FUNCTION**",pe=({nodeData:n,showStringQuotes:r=!0,stringTruncateLength:o=200,pathString:a,canEdit:s,setIsEditing:i,styles:l,translate:c,value:u,TextWrapper:d=({children:e})=>e})=>{const p=u??n.value,[m,h]=t.useState(!1),f=r?'"':"",y=p.length>o,g=()=>{s?i(!0):h(!m)};return e.jsxs("div",{id:`${a}_display`,onDoubleClick:g,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&g()},className:"jer-value-string",style:l,children:[f,y?m?e.jsxs(e.Fragment,{children:[e.jsx(d,{children:e.jsxs("span",{children:[p,f]})}),e.jsxs("span",{className:"jer-string-expansion jer-show-less",onClick:()=>h(!1),children:[" ",c("SHOW_LESS",n)]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:[e.jsx("span",{children:p.slice(0,o-2).trimEnd()})," "]}),e.jsx("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>h(!0),children:"..."}),f]}):e.jsx(d,{children:`${p}${f}`})]})},me=({styles:n,pathString:r,value:o,setValue:a,handleEdit:s,handleKeyboard:i,keyboardCommon:l})=>{const c=t.useRef(null);return e.jsx(D,{className:"jer-input-text",textAreaRef:c,name:r,value:o,setValue:a,onKeyDown:e=>{i(e,{stringConfirm:s,stringLineBreak:()=>{const e=N(c,"\n");a(e)},...l})},styles:n})},he=({isEditing:t,path:n,enumType:r,...o})=>{const{getStyles:a}=Y(),s=d(n),{value:i,setValue:l,nodeData:c,handleEdit:u,handleKeyboard:p,keyboardCommon:m,Select:h}=o;return t&&r?e.jsx(h,{name:`${s}-value-select`,value:i,onChange:l,options:r.values,autoFocus:!0,onKeyDown:e=>p(e,{stringConfirm:u,...m})}):t?e.jsx(me,{styles:a("input",c),pathString:s,...o,setValue:o.setValue}):e.jsx(pe,{pathString:s,styles:a("string",c),...o})},fe=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=Y();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:d(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:e=>l(e,{numberConfirm:s,numberUp:()=>n(Number(t)+1),numberDown:()=>n(Number(t)-1),...c}),style:{width:String(t).length/1.5+2+"em",...u("input",i)}}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:u("number",i),children:t})},ye=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=Y();return"boolean"!=typeof t?null:r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:d(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{" "===e.key&&e.preventDefault(),l(e,{booleanConfirm:s,booleanToggle:()=>n(!t),...c})},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:u("boolean",i),children:String(t)})},ge=(e,n)=>{const r=t.useRef(void 0),o=t.useRef(n);t.useEffect(()=>{o.current=n},[n]);const a=e=>{o.current(e)};t.useEffect(()=>{if(window.clearTimeout(r.current),e)return r.current=window.setTimeout(()=>{window.addEventListener("keydown",a)},100),()=>{window.clearTimeout(r.current),window.removeEventListener("keydown",a)}},[e])},ve=({value:t,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:s,keyboardCommon:i})=>{const{getStyles:l}=Y();return ge(n,e=>s(e,{confirm:o,...i})),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:l("null",a),children:String(t)})},be=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===de&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},je=({scale:t=1,viewBox:n="0 0 24 24",fill:r="currentColor",children:o,...a})=>{const s=1.4*t+"em";return e.jsx("svg",{viewBox:n,fill:r,width:s,height:s,...a,children:o})},xe=({name:t,nodeData:n})=>{const{getStyles:r,icons:o}=Y(),a=o[t],s=`icon${t[0].toUpperCase()}${t.slice(1)}`;return e.jsx(je,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===t?void 0:"jer-icon",style:r(s,n),children:a.content})},we=({startEdit:n,handleDelete:r,handleAdd:o,showClipboardButton:a,onCopy:s,type:i,customButtons:l,nodeData:c,translate:d,keyboardControls:m,handleKeyboard:h,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:j}=Y(),{open:w,cancel:E}=Z(),D=d("KEY_NEW",c),[k,O]=t.useState(D),[R,T]=t.useState(!1),{path:N,value:P}=c,A=G(e=>{const t=e.active;return null!==t&&"add"===t.op&&p(t.path,N)}),I=Array.isArray(R);C(()=>{if(!A)return T(!1),void O(D);const e=Object.keys(x(c.fullData,N)),t=y?y(c)?.filter(t=>!e.includes(t)):null;t&&O(""),T(t??!0)},[A]);const K=()=>{o&&(I&&!k||o("array"===i?"":k))};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:A?1:void 0},onClick:e=>e.stopPropagation(),children:[a&&e.jsx("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",i=null;if(a){const a=S(e);if(a&&m.clipboardModifier.includes(a)?(t=u(N),o=t,r="path"):(t=P,o="object"==typeof t?g(P):String(t)),!navigator.clipboard)return void s?.({...c,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,i=e.message}).finally(()=>{s?.({...c,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:i??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":d("TOOLTIP_COPY",c),title:v?d("TOOLTIP_COPY",c):"",children:e.jsx(xe,{name:"copy",nodeData:c})}),n&&e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":d("TOOLTIP_EDIT",c),title:v?d("TOOLTIP_EDIT",c):"",children:e.jsx(xe,{name:"edit",nodeData:c})}),r&&e.jsx("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":d("TOOLTIP_DELETE",c),title:v?d("TOOLTIP_DELETE",c):"",children:e.jsx(xe,{name:"delete",nodeData:c})}),o&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===i?w(N,{op:"add"}):o("")},"aria-label":d("TOOLTIP_ADD",c),title:v?d("TOOLTIP_ADD",c):"",children:e.jsx(xe,{name:"add",nodeData:c})}),l?.map(({Element:t,onClick:n},r)=>e.jsx("div",{onClick:e=>n&&n(c,e),children:e.jsx(t,{nodeData:c})},r)),A&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[I?e.jsx(b,{name:"new-key-select",onChange:o,defaultValue:"",autoFocus:!0,onKeyDown:e=>h(e,{cancel:()=>E()}),placeholder:R.length>0?d("KEY_SELECT",c):d("NO_KEY_OPTIONS",c),options:R}):e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:k,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{h(e,{stringConfirm:()=>K(),cancel:()=>E()})},style:j("input",c)}),e.jsx(Ee,{onOk:()=>K(),onCancel:()=>E(),nodeData:c,translate:d,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},Ee=({onOk:t,onCancel:n,nodeData:r,translate:o,showIconTooltips:a,editConfirmRef:s,hideOk:i=!1})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[!i&&e.jsx("button",{type:"button",tabIndex:-1,onClick:t,"aria-label":o("TOOLTIP_OK",r),title:a?o("TOOLTIP_OK",r):"",ref:s,children:e.jsx(xe,{name:"ok",nodeData:r})}),e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":o("TOOLTIP_CANCEL",r),title:a?o("TOOLTIP_CANCEL",r):"",children:e.jsx(xe,{name:"cancel",nodeData:r})})]}),Ce=["string","number","boolean","null"],De=["object","array"],Se=[...Ce,...De],ke=e=>{const{component:t,wrapperComponent:n,keyComponent:r,showKey:o=!0,showEditTools:a=!0,showOnEdit:s=!1,showOnView:i=!0,showCollectionWrapper:l=!0,...c}=e;return{CustomComponent:t,CustomWrapperComponent:n,CustomKeyComponent:r,showKey:o,showEditTools:a,showOnEdit:s,showOnView:i,showCollectionWrapper:l,...c}},Oe=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?ke(n):{}},Re=({props:e,collapsed:n})=>{const{nodeData:r,parentData:o,onError:a,getLatestData:s,showErrorMessages:i,allowEditFilter:l,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:m,translate:h,errorDisplayTime:f,sort:y,arrayIndexStart:g,handleKeyboard:v,customNodeData:b}=e,{submit:j}=Z(),[x,w]=t.useState(null),E={...r,collapsed:n,visibleSize:ue(r.path)},{path:C,key:D,size:S}=E,k=d(C),O=G(e=>{const t=e.active;return null!==t&&"edit"===t.op&&p(t.path,C)}),R=G(e=>{const t=e.active;return null!==t&&"rename"===t.op&&p(t.path,C)}),T=G(e=>k in e.settling),N=l(E),A=c(E),I=u(E),K=m(E)&&A,L=e=>{i&&(w(e),setTimeout(()=>w(null),f)),console.warn("Error",e)},M=t.useRef(E);M.current=E;const _=t.useCallback((e,t)=>{L(e.message),a&&a({...M.current,fullData:s(),error:e,errorValue:t})},[a,i,s,f]),V=le(),z=t.useCallback(e=>(null===V||V.visiblePaths.has(d(e.path)))&&l(e),[V,l]),F=e=>P(s(),C,e,y,z),B=(e,t)=>{o&&(D!==e&&Object.keys(o).includes(e)?_({code:"KEY_EXISTS",message:h("ERROR_KEY_EXISTS",E)},e):j({op:"rename",path:C,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&_(t.error,e)}))},Y="number"==typeof C.slice(-1)[0],U=null!==o&&N&&I&&A&&!Y,H={isEditing:O,isEditingKey:R,isPending:T,isArray:Y,canEditKey:U},W=""===D&&C.length>0?h("EMPTY_STRING",E):null;return{pathString:k,nodeData:E,path:C,name:D,size:S,canEdit:N,canDelete:A,canAdd:I,canDrag:K,error:x,showError:L,onError:_,setError:w,handleEditKey:B,derivedValues:H,emptyStringKey:W,getNextOrPreviousAtPath:F,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:U,isEditingKey:R,pathString:k,path:C,name:D,arrayIndexStart:g,handleKeyboard:v,handleEditKey:B,handleCancel:e,styles:t("property",E),getNextOrPrevious:F,emptyStringKey:W,nodeData:E,customNodeData:b,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Te=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onError:s,translate:i})=>{const{getStyles:l}=Y(),{dragSource:c,setDragSource:u,armed:d}=(()=>{const e=t.useContext(re);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),h=Z(),[f,y]=t.useState(!1),g=t.useMemo(()=>n?{onMouseDown:e=>{0===e.button&&null===h.getSnapshot().active&&(d.current=!0)},onMouseUp:()=>{d.current=!1},onDragStart:e=>{if(!d.current||null!==h.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();d.current=!1,e.stopPropagation(),u({path:o})},onDragEnd:e=>{d.current=!1,e.stopPropagation(),u({path:null})}}:{},[n,o]),v=t.useMemo(()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),j(e),u({path:null}),y(!1)},onDragEnter:t=>{t.stopPropagation(),null!==c.path&&m(o,c.path)||y(e)},onDragExit:e=>{e.stopPropagation(),y(!1)}}:{},[c,r,o]),b=t.useMemo(()=>r&&null!==c.path?e.jsx("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length},...v("below")}):null,[c,r,o.length]),j=e=>{if(null===c.path)return;if(m(o,c.path))return;const t=c.path.slice(-1)[0],n=c.path.slice(0,-1),r=o.slice(0,-1),{parentData:l}=a;"string"==typeof t&&l&&!Array.isArray(l)&&Object.keys(l).includes(t)&&t in l&&!p(n,r)?s({code:"KEY_EXISTS",message:i("ERROR_KEY_EXISTS",a)},t):h.submit({op:"move",path:c.path,to:{path:o,position:e},instant:!0})};return{dragSourceProps:g,getDropTargetProps:v,BottomDropTarget:b,DropTargetPadding:({position:t,nodeData:n})=>f===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:l("dropZone",n)}):null,handleDrop:j}},Ne=(e,t,n,r)=>{if(!t.current)return 0;const o=parseInt(getComputedStyle(n.current).getPropertyValue("line-height"))||16,a=(t.current?.offsetWidth??0)/(.5*o),s=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/a)).reduce((e,t)=>e+t,0)*o;return Math.min(s+30,window.innerHeight-50)},Pe=({isEditingKey:n,canEditKey:r,pathString:o,path:a,name:s,arrayIndexStart:i,handleKeyboard:l,handleEditKey:c,handleCancel:u,handleClick:d,keyValueArray:p,styles:m,getNextOrPrevious:h,emptyStringKey:f,nodeData:y,customNodeData:g,getStyles:v})=>{const{open:b,cancel:j}=Z(),x=t.useRef(null),w=e=>c(x.current?.value??String(s),e),E="number"==typeof s?String(s+i):s;if(!n){const t={...m,minWidth:`${Math.min(E.length+1,5)}ch`,flexShrink:E.length>10?1:0};if(g?.CustomKeyComponent&&y&&v){const{CustomKeyComponent:n,componentProps:o}=g;return e.jsx(n,{nodeData:y,name:f??E,path:a,canEditKey:r,handleEditKey:e=>{r&&c(e)},startEditingKey:()=>{r&&b(a,{op:"rename",commitOp:w})},handleClick:d,styles:t,componentProps:o,getStyles:v})}return e.jsxs("span",{className:"jer-key-text",style:t,onDoubleClick:()=>r&&b(a,{op:"rename",commitOp:w}),onClick:d,children:[f?e.jsx("span",{className:"jer-empty-string",children:f}):E,""!==E||f?e.jsx("span",{className:"jer-key-colon",children:":"}):null]})}return e.jsx("input",{ref:x,className:"jer-input-text jer-key-edit",type:"text",name:o,defaultValue:E,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>l(e,{stringConfirm:()=>c(e.target.value),cancel:u,tabForward:()=>{const t=e.target.value;c(t,()=>{if(p){const e=p?.[0][0],t=e?[...a,e]:h("next");t?b(t):j()}else b(a)})},tabBack:()=>{const t=e.target.value;c(t,()=>{const e=h("prev");e?b(e):j()})}}),style:{width:E.length/1.5+.5+"em"}})},Ae=new Set(["nodeData","customNodeData"]),Ie=(e,t)=>{if(n=e.nodeData,r=t.nodeData,n.key!==r.key||n.index!==r.index||n.level!==r.level||n.size!==r.size||!p(n.path,r.path))return!1;var n,r;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(const n of o)if(!Ae.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ke=t.memo(r=>{const{data:o,parentData:a,onChange:i,showClipboardButton:l,onCopy:c,canDragOnto:u,allowTypeSelection:d,showLabel:m,stringTruncateLength:h,showStringQuotes:f,indent:y,translate:g,customNodeDefinitions:v,customNodeData:b,Select:j,handleKeyboard:x,keyboardControls:w,editConfirmRef:E,jsonStringify:C,showIconTooltips:D,getLatestData:S}=r,{getStyles:k}=Y(),{open:O,cancel:R,submit:T,getSnapshot:N}=Z(),{setCollapseState:P}=te(),[A,I]=t.useState("function"==typeof o?de:o),{nodeData:K,path:L,name:M,canEdit:_,canDelete:V,canDrag:z,error:F,onError:B,setError:U,derivedValues:H,getNextOrPreviousAtPath:W,buildKeyDisplayProps:$}=Re({props:r}),{dragSourceProps:J,getDropTargetProps:X,BottomDropTarget:Q,DropTargetPadding:G}=Te({canDrag:z,canDragOnto:u,path:L,nodeData:K,onError:B,translate:g}),[q,ee]=t.useState(Me(o,b)),ne=t.useRef(A);ne.current=A;const re=t.useRef(K);re.current=K;const oe=t.useCallback(e=>{if(!i)return void I(e);const t=i({...re.current,value:ne.current,fullData:S(),newValue:e});I(t)},[i,S]),ae=()=>{I("function"==typeof o?de:o),ee(Me(o,b)),le(s(o,se))};t.useEffect(()=>{H.isEditing||ae()},[o]);const se=t.useMemo(()=>{const e=[...Se,...v.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof d)return d?e:[];if(Array.isArray(d))return d;const t=d(K);return"boolean"==typeof t?t?e:[]:t},[K,d,v]),[ie,le]=t.useState(s(A,se)),{isEditing:ue,isPending:pe}=H,me=ce(L),he=t.useRef(n);if(!me)return null;const fe=ue&&q!==Me(o,b),ye=fe?v.find(e=>e.name===q&&Le(e)):void 0,ge=ye?ke(ye):b,{CustomComponent:ve,componentProps:be,showKey:je=!0,showEditTools:xe=!0,showOnEdit:Ce,showOnView:De,passOriginalNode:Oe}=ge,Ne=ve&&(void 0!==ye||!fe&&(ue&&Ce||!ue&&De)),Ae=e=>{P(null);const t=fe&&!ye?void 0:ge,n=t?.toStandardType?t.toStandardType(A):A,r=v.find(t=>t.name===e);if(r){if(Le(r)){let t=r.defaultValue;if(r.fromStandardType)try{t=r.fromStandardType(n,K,r.componentProps)}catch{}return I(t),ee(e),void le(null)}return T({op:"edit",path:L,value:r.defaultValue}).then(Ie(r.defaultValue)),void P({path:L,collapsed:!1,includeChildren:!1})}const o=se.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof A&&o.values.includes(A)||I(o.values[0]),le(o),void ee(e);const a=ze(n,e,g("DEFAULT_NEW_KEY",K));if("object"===e||"array"===e||"null"===e)return T({op:"edit",path:L,value:a}).then(Ie(a)),void("null"!==e&&P({path:L,collapsed:!1,includeChildren:!1}));I(a),ee(e),le(null)},Ie=e=>t=>{if("error"===t?.status&&B(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=N().active;"editing"===e?.phase&&p(e.path,L)||ae()}},Ke=(e,t)=>{const n=void 0!==e&&!(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e);let r;if(n)r=e;else if(Ne&&ge.fromStandardType)try{r=ge.fromStandardType(A,K,ge.componentProps)}catch(e){return void B({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},A)}else r="number"===q?Ve(A):A;U(null),ye&&P({path:L,collapsed:!1,includeChildren:!1}),T({op:"edit",path:L,value:r,onCommit:t}).then(Ie(r))};he.current=Ke;const Fe=()=>{U(null),ae(),R()},{isEditingKey:Be}=H,Ye=!!F,Ue=ue&&se.length>1,He=("invalid"!==q||ve)&&!F&&xe,We=m&&je,$e=()=>O(L,{cancelOp:ae,commitOp:e=>he.current(void 0,e)}),Je=_?$e:n,Xe=e=>()=>{const t=W(e);t&&Ke(void 0,()=>O(t))},Qe={value:A,parentData:a,setValue:oe,isEditing:ue,canEdit:_,setIsEditing:Je,handleEdit:Ke,handleCancel:Fe,path:L,stringTruncateLength:h,showStringQuotes:f,nodeData:K,enumType:ie,translate:g,handleKeyboard:x,keyboardCommon:{cancel:Fe,tabForward:Xe("next"),tabBack:Xe("prev")},Select:j},Ze={...$({handleCancel:Fe,getStyles:k}),customNodeData:ge},Ge=Ne?e.jsx(ve,{...r,value:A,componentProps:be,setValue:oe,handleEdit:Ke,handleCancel:Fe,onKeyDown:e=>x(e,{stringConfirm:Ke,cancel:Fe}),isEditing:ue,isPending:pe,setIsEditing:Je,getStyles:k,originalNode:Oe?_e(o,q,Qe):void 0,originalNodeKey:Oe?e.jsx(Pe,{...Ze,customNodeData:void 0}):void 0,canEdit:_,keyboardCommon:Qe.keyboardCommon}):_e(o,q,Qe);return e.jsxs("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==a?y/2+"em":0,position:"relative"},draggable:z&&!ue&&!Be,...J,...X("above"),children:[Q,e.jsx(G,{position:"above",nodeData:K}),e.jsxs("div",{className:"jer-value-main-row",style:{...k("valueRow",K),flexWrap:M.length>10?"wrap":"nowrap"},children:[We&&e.jsx(Pe,{...Ze}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Ge}),ue?e.jsx(Ee,{onOk:Ke,onCancel:Fe,nodeData:K,translate:g,showIconTooltips:D,editConfirmRef:E}):He&&e.jsx(we,{startEdit:_?$e:void 0,handleDelete:V?()=>{T({op:"delete",path:L,instant:!0}).then(e=>{"error"===e?.status&&B(e.error,A)})}:void 0,showClipboardButton:l,onCopy:c,translate:g,customButtons:r.customButtons,nodeData:K,handleKeyboard:x,keyboardControls:w,editConfirmRef:E,jsonStringify:C,showIconTooltips:D,Select:j}),Ue&&e.jsx(j,{name:`${M}-type-select`,value:ie?ie.enum:q,onChange:e=>Ae(e),options:se.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Ye&&e.jsx("span",{className:"jer-error-slug",style:k("error",K),children:F})]})]}),e.jsx(G,{position:"below",nodeData:K})]})},Ie),Le=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,Me=(e,t)=>t?.CustomComponent&&t?.name&&t.showInTypeSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",_e=(t,n,r)=>{const o=Ce.includes(n)?n:"function"==typeof t?"invalid":Me(r.value),{value:a}=r;switch(o){case"string":return e.jsx(he,{...r,value:a});case"number":return e.jsx(fe,{...r,value:a});case"boolean":return e.jsx(ye,{...r,value:a});case"null":return e.jsx(ve,{...r});default:return e.jsx(be,{...r})}},Ve=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},ze=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Ve(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Fe=t.memo(r=>{const{getStyles:a}=Y(),{open:s,cancel:i,submit:l,areChildrenBeingEdited:c}=Z(),{setCollapseState:u}=te(),{mainContainerRef:d,data:p,nodeData:h,parentData:f,showCollectionCount:y,canDragOnto:g,collapseFilter:v,collapseAnimationTime:b,showClipboardButton:j,onCopy:x,showIconTooltips:w,indent:E,sort:C,showArrayIndexes:k,defaultValue:O,newKeyOptions:R,translate:T,customNodeDefinitions:P,customNodeData:A,jsonParse:I,jsonStringify:K,TextEditor:L,Select:M,keyboardControls:_,handleKeyboard:V,insertAtTop:z,onCollapse:F,editConfirmRef:B,collapseClickZones:U,getLatestData:H}=r,[W,$]=t.useState(null),J=v(h),{contentRef:X,isAnimating:Q,maxHeight:q,collapsed:ee,animateCollapse:re,cssTransitionValue:oe}=((e,n,r,o,a)=>{const[s,i]=t.useState(r?0:void 0),[l,c]=t.useState(r),u=t.useRef(!1),d=t.useRef(null),p=t.useRef(0),m=t.useRef(0),h=n/1e3+"s",f=t.useCallback(t=>{if(l!==t){switch(window.clearTimeout(m.current),u.current=!0,t){case!0:{const e=d.current?.offsetHeight??0;p.current=e,i(e),setTimeout(()=>{i(0)},5);break}case!1:i(p.current||Ne(e,d,o,a))}c(!l),m.current=window.setTimeout(()=>{u.current=!1,t||i(void 0)},n)}},[n,l,e,o,a]);return{contentRef:d,isAnimating:u.current,animateCollapse:f,maxHeight:s,collapsed:l,cssTransitionValue:h}})(p,b,J,d,K),{pathString:ae,nodeData:se,path:ie,name:le,size:ue,canEdit:de,canDelete:pe,canAdd:me,canDrag:he,error:fe,setError:ye,onError:ge,derivedValues:ve,buildKeyDisplayProps:be}=Re({props:r,collapsed:ee}),{dragSourceProps:je,getDropTargetProps:Ce,BottomDropTarget:De,DropTargetPadding:Se}=Te({canDrag:he,canDragOnto:g,path:ie,nodeData:se,onError:ge,translate:T}),ke=t.useRef(!J),{isEditing:Ae,isEditingKey:Ie,isPending:Le,isArray:Me}=ve,_e=(e=>{const n=t.useRef(e),r=!Object.is(n.current,e);return t.useEffect(()=>{n.current=e}),r})(v);t.useEffect(()=>{const e=v(se)&&!Ae;ke.current=!e,re(e),_e&&u(null)},[v]),((e,n,r)=>{const{commands:o,version:a}=te(),s=t.useRef(0);t.useEffect(()=>{if(a===s.current)return;if(s.current=a,!o)return;let t;for(const n of o)ne(e,n)&&(t=n);t&&(t.collapsed||(n.current=!0),r(t.collapsed))},[a,o])})(ie,ke,re);const Ve=t.useRef(null),ze=t.useCallback(e=>$(t=>"function"==typeof e?e(t??K(p)):e),[p,K]),Be=t.useCallback(()=>$(null),[]),Ye=t.useMemo(()=>Ae?W??K(p):null,[Ae,W,p,K]),Ue=t.useCallback((e,t)=>{if("function"!=typeof O)return O;const n=O(e,t);return void 0!==n?n:null},[O]),He=t.useCallback(e=>R?"function"!=typeof R?R:R(e):null,[R]),{CustomComponent:We,componentProps:$e,CustomWrapperComponent:Je,wrapperProps:Xe={},showKey:Qe=!0,showEditTools:Ze=!0,showOnEdit:Ge,showOnView:qe,showCollectionWrapper:et=!0}=A,tt=G(e=>null!==e.active&&m(e.active.path,ie));tt&&ee&&re(!1);const nt=ce(ie)||0===se.level,rt=t.useRef(n);if(!nt&&!tt)return null;const{visibleSize:ot}=se,at=Array.isArray(p)?"array":"object",st="array"===at?{open:"[",close:"]"}:{open:"{",close:"}"},it=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=N(Ve,"\t");return void $(t)}V(e,{objectConfirm:ct,cancel:dt})},lt=e=>{e.stopPropagation();const t=S(e);if(t&&_.collapseModifier.includes(t))return ke.current=!0,void u({collapsed:!ee,path:ie,includeChildren:!0});c(ie)||(ke.current=!0,F&&F({...se,fullData:H(),collapsed:!ee,includeChildren:!1}),re(!ee))},ct=e=>{const t=Ye??K(p);let n;try{n=I(t)}catch{return void ge({code:"INVALID_JSON",message:T("ERROR_INVALID_JSON",se)},t)}ye(null);const r="function"==typeof e?e:void 0;l({op:"edit",path:ie,value:n,onCommit:()=>{Be(),r?.()}}).then(e=>{"error"===e?.status&&ge(e.error,n)})};rt.current=ct;const ut=ie.length>0?()=>{l({op:"delete",path:ie,instant:!0}).then(e=>{"error"===e?.status&&ge(e.error,p)})}:void 0,dt=()=>{i(),ye(null),Be()},pt="when-collapsed"===y?ee:"when-collapsed-or-filtered"===y?ee||null!=ot:y,mt=!Ae&&Ze,ht=(k||!Me)&&Qe&&void 0!==le,ft=We&&(Ae&&Ge||!Ae&&qe),yt=Object.entries(p).map(([e,t])=>["array"===at?Number(e):e,t]);"object"===at&&C(yt,e=>e);const gt=ke.current?Ae?e.jsxs("div",{className:"jer-collection-text-edit"+(L?"-custom":""),children:[L?e.jsx(L,{value:Ye??"",onChange:$,onKeyDown:e=>V(e,{objectConfirm:ct,cancel:dt})}):e.jsx(D,{textAreaRef:Ve,className:"jer-collection-text-area",name:ae,value:Ye??"",setValue:ze,onKeyDown:it,styles:a("input",se)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(Ee,{onOk:ct,onCancel:dt,nodeData:se,translate:T,showIconTooltips:w,editConfirmRef:B})})]}):yt.map(([t,n],s)=>{const i={key:t,value:n,path:[...ie,t],level:ie.length+1,index:s,size:o(n)?Object.keys(n).length:null,parentData:p,fullData:se.fullData},l=Oe(P,i);return e.jsx("div",{className:"jer-collection-element",style:a("collectionElement",i),children:o(n)&&!l?.renderCollectionAsValue?e.jsx(Fe,{...r,data:n,parentData:p,nodeData:i,canDragOnto:de,customNodeData:l},t):e.jsx(Ke,{...r,data:n,parentData:p,nodeData:i,canDragOnto:de,showLabel:"object"===at||k,customNodeData:l},t)},t)}):null,vt=!!et&&(ee&&!tt);vt||(ke.current=!0);const bt=()=>({...r,data:p,value:p,parentData:f,nodeData:se,setValue:e=>l({op:"edit",path:ie,value:e}),handleEdit:ct,handleCancel:dt,onKeyDown:it,isEditing:Ae,isPending:Le,setIsEditing:de?()=>s(ie,{cancelOp:Be,commitOp:e=>rt.current(e)}):n,getStyles:a,canDragOnto:de,canEdit:de,keyboardCommon:{}}),jt=ft?e.jsx(We,{componentProps:$e,...bt(),children:gt}):gt,xt=mt&&e.jsx(we,{startEdit:de?()=>{ke.current=!0,s(ie,{cancelOp:Be,commitOp:e=>rt.current(e)})}:void 0,handleAdd:me?e=>{u(null),re(!1);const t=Ue(se,e);if("array"===at){const e=z.array?0:p.length,n=z.array?{insert:!0}:{};return void l({op:"add",path:ie,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&ge(e.error,t)})}if(e in p)return ge({code:"KEY_EXISTS",message:T("ERROR_KEY_EXISTS",se)},e),void i();const n=z.object?{insertBefore:0}:{};l({op:"add",path:ie,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&ge(e.error,t)})}:void 0,handleDelete:pe?ut:void 0,showClipboardButton:j,onCopy:x,type:at,nodeData:se,translate:T,customButtons:r.customButtons,keyboardControls:_,handleKeyboard:V,getNewKeyOptions:He,editConfirmRef:B,jsonStringify:K,showIconTooltips:w,Select:M}),wt=be({handleCancel:dt,getStyles:a,keyValueArray:yt,handleClick:U.includes("property")?lt:e=>e.stopPropagation()}),Et=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===ie.length?0:E/2)+"em",...a("collection",se),position:"relative"},draggable:he&&!Ae&&!Ie&&!tt,...je,...Ce("above"),children:[e.jsx("div",{className:"jer-clickzone",style:{width:E/2+1+"em",zIndex:10+2*se.level},onClick:U.includes("left")?lt:void 0}),!Ae&&De,e.jsx(Se,{position:"above",nodeData:se}),et?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",se),position:"relative"},onClick:U.includes("header")?lt:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(ee?" jer-rotate-90":""),style:{zIndex:11+2*se.level,transition:oe},onClick:lt,children:e.jsx(xe,{name:"collection",nodeData:se})}),ht&&e.jsx(Pe,{...wt}),!Ae&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:a("bracket",se),children:st.open})]}),!1!==y&&!Ae&&e.jsx("div",{className:"jer-collection-item-count"+(pt?" jer-visible":" jer-hidden"),style:{...a("itemCount",se),transition:oe,transitionBehavior:"allow-discrete"},children:null!=ot&&ot!==ue?T("ITEMS_FILTERED",se,{visible:ot,total:ue}):1===ue?T("ITEM_SINGLE",{...se,size:1},1):T("ITEMS_MULTIPLE",se,ue)}),e.jsx("div",{className:"jer-brackets"+(vt?" jer-visible":" jer-hidden"),style:{...a("bracket",se),transition:oe},children:st.close}),xt]}):Qe?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",se),position:"relative"},children:[e.jsx(Pe,{...wt}),xt]}):e.jsx(e.Fragment,{}),e.jsxs("div",{className:"jer-collection-inner",style:{overflowY:vt||Q?"clip":"visible",maxHeight:tt?void 0:q,transition:oe},ref:X,children:[jt,e.jsx("div",{className:Ae?"jer-collection-error-row-edit":"jer-collection-error-row",children:fe&&e.jsx("span",{className:"jer-error-slug",style:a("error",se),children:fe})}),!Ae&&et&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:a("bracket",se),children:st.close})]}),e.jsx(Se,{position:"below",nodeData:se})]});return Je?e.jsx(Je,{wrapperProps:Xe,...bt(),children:Et}):Et},Ie),Be=({options:t,value:n,defaultValue:r,onChange:o,placeholder:a,className:s,...i})=>{const l=void 0!==n?{value:n}:{defaultValue:r??""};return e.jsxs("div",{className:"jer-select",children:[e.jsxs("select",{className:s??"jer-select-inner",onChange:e=>o(e.target.value),...i,...l,children:[void 0!==a&&e.jsx("option",{value:"",disabled:!0,children:a}),t.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx("span",{className:"focus"})]})},Ye=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},Ue=({key:e,path:t},n="")=>!!Ye({value:e},n)||!!t.some(e=>Ye({value:e},n)),He={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel"},We=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}let s=r in e?e[r]:He[r];if(void 0!==o){const e=a(o)?o:{count:o};for(const[t,n]of Object.entries(e))s=s?.replace(`{{${t}}}`,String(n))}return s})(e,t,r,n,o);var $e=[],Je=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var s=$e.indexOf(a);-1===s&&(s=$e.push(a)-1,Je[s]={}),n=Je[s]&&Je[s][r]?Je[s][r]:Je[s][r]=i()}else n=i();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function i(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var s="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(s,e),e}}(':host,:root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff;--jer-icon-copy-color:#268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{left:-1.2em;position:absolute;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;font-family:inherit;font-size:.85em;line-height:1.25em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row-edit{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em;margin-right:.2em}.jer-confirm-buttons>button,.jer-edit-buttons>button{appearance:none;background:none;border:none;color:inherit;font:inherit;margin:0;padding:0}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #b4b4b4;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const Xe=(e,t)=>JSON.stringify(e,t,2),Qe={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},Ze={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},Ge=e=>{const n=t.useRef(e);e&&(n.current=e);const r=t.useRef((...e)=>n.current(...e));return e?r.current:void 0},qe=[],et=["header","left"],tt={},nt={},rt={},ot=[],at=({data:a,setData:s,buildNodeDataFromPathRef:l,commitRef:c,rootName:u="root",onUpdate:p=n,onChange:m,onError:h,onEditEvent:f,showErrorMessages:y=!0,showClipboardButton:g=!0,onCopy:v,indent:b=2,collapse:j=3,collapseAnimationTime:w=300,showCollectionCount:C="when-collapsed-or-filtered",allowEdit:D=!0,allowDelete:S=!0,allowAdd:O=!0,allowTypeSelection:N=!0,allowDrag:P=!1,searchFilter:A,searchText:I,searchDebounceTime:K=350,sortKeys:L=!1,showArrayIndexes:M=!0,arrayIndexStart:_=0,showStringQuotes:V=!0,showIconTooltips:z=!1,defaultValue:F=null,newKeyOptions:B,minWidth:U=250,maxWidth:H="min(600px, 90vw)",baseFontSize:W,stringTruncateLength:$=250,translations:J=tt,className:X,id:Q,customText:G=nt,customNodeDefinitions:q=qe,customButtons:ee=ot,jsonParse:ne=JSON.parse,jsonStringify:re=Xe,TextEditor:oe,Select:ae=Be,errorDisplayTime:se=2500,keyboardControls:le=rt,editorRef:ce,insertAtTop:ue=!1,onCollapse:de,collapseClickZones:pe=et})=>{const{getStyles:me,cssVars:he}=Y(),{open:fe,cancel:ye,getSnapshot:ge}=Z(),ve=t.useMemo(()=>lt(j),[j]),be=t.useMemo(()=>We(J,G),[J,G]),[je,xe]=t.useState(I),we=t.useRef(null);t.useEffect(()=>{ye();const e=setTimeout(()=>xe(I),K);return()=>clearTimeout(e)},[I,K]);const Ee=E(a,[],u),Ce=t.useRef(a);Ce.current=a;const De=t.useRef(s);De.current=s;const Se=t.useRef(be);Se.current=be;const ke=t.useRef(Ee);ke.current=Ee;const Re=t.useRef(p);Re.current=p;const Te=t.useRef(u);Te.current=u;const Ne=t.useRef(void 0),Pe=t.useCallback(()=>Ce.current,[]),Ae=Ge(m),Ie=Ge(h),Le=Ge(de),Me=Ge(f),_e=Ge(v),Ve=t.useCallback(e=>{Ce.current=e,De.current(e)},[]),ze=t.useCallback((e,t)=>{Ve(it(Ce.current,e,t,"update").newData)},[Ve]),Ue=t.useCallback(e=>{const t=Ce.current,n=Te.current,r=Ne.current,o=Ve,{op:a,path:s}=e;switch(a){case"edit":{const{newData:a,currentValue:i,newValue:l}=it(t,s,e.value,"update"),c=E(t,s,n,r);return{input:{...c,newData:a,event:"edit",newValue:l},nodeData:c,isNoOp:i===l,apply:()=>o(a),revert:()=>o(it(Ce.current,s,i,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=it(t,s,"","delete"),i=E(t,s,n,r);return{input:{...i,newData:e,event:"delete"},nodeData:i,isNoOp:!1,apply:()=>o(e),revert:()=>o(it(Ce.current,s,a,"add",{insert:!0,insertBefore:i.index}).newData)}}case"add":{const a=[...s,e.key],{newData:i,newValue:l}=it(t,a,e.value,"add",e.options),c=E(i,a,n,r);return{input:{...c,value:void 0,size:null,parentData:x(t,s)??null,fullData:t,newData:i,event:"add",newValue:l},nodeData:c,isNoOp:!1,apply:()=>o(i),revert:()=>o(it(Ce.current,a,"","delete").newData)}}case"rename":{const a=s.slice(0,-1),i=s[s.length-1],{newKey:l}=e,c=x(t,a),u=Object.fromEntries(Object.entries(c).map(([e,t])=>e===i?[l,t]:[e,t])),{newData:d}=it(t,a,u,"update"),p=E(t,s,n,r);return{input:{...p,newData:d,event:"rename",newKey:l},nodeData:p,isNoOp:i===l,apply:()=>o(d),revert:()=>o(it(Ce.current,a,c,"update").newData),extra:{oldKey:i,newKey:l}}}case"move":{const a=s,{path:i,position:l}=e.to,c=t,{newData:u,currentValue:d}=it(t,a,"","delete"),p=a.slice(-1)[0],m=i.slice(0,-1),h=i.slice(-1)[0];let f="number"==typeof h?"above"===l?h:h+1:"number"==typeof p?`arr_${p}`:p;a.slice(0,-1).join(".")===i.slice(0,-1).join(".")&&"number"==typeof p&&"number"==typeof f&&p<f&&(f-=1);const y="number"==typeof f?{insert:!0}:"above"===l?{insertBefore:h}:{insertAfter:h},g=[...m,f],{newData:v}=it(u,g,d,"add",y),b=E(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Ve]),He=t.useCallback(async(e,t)=>{const n=Ze[e.event],r=()=>Se.current(Qe[e.event],ke.current);let o;try{o=await Re.current(e,t)}catch(e){return{status:"error",error:{code:n,message:e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r()}}}if(!1===o)return{status:"error",error:{code:n,message:r()}};if(null===o)return{status:"cancel"};if(o&&"object"==typeof o){if(void 0!==o.error)return"string"==typeof o.error?{status:"error",error:{code:n,message:o.error}}:{status:"error",error:o.error};const t=void 0!==o.data,r=void 0!==o.value;if(t&&r&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),t)return{status:"override",value:o.data,path:[]};if(r&&("edit"===e.event||"add"===e.event))return{status:"override",value:o.value,path:e.path}}return{status:"commit"}},[]),$e=t.useMemo(()=>({runUpdate:p===n?void 0:He,buildCommit:Ue,applyValue:ze}),[He,Ue,ze,p]);c.current=$e;const Je=t.useMemo(()=>lt(D),[D]),at=t.useMemo(()=>lt(S),[S]),st=t.useMemo(()=>lt(O),[O]),dt=t.useMemo(()=>lt(P),[P]),pt=t.useMemo(()=>ct(A),[A]),mt=t.useMemo(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,a=new Map,s=t??Ye,i=n??"",l=e=>{let t=s(e,i);if(o(e.value)){let n=0;const r=Array.isArray(e.value),s=Object.entries(e.value);for(const[a,i]of s){const s=r?Number(a):a,c={key:s,path:[...e.path,s],level:e.level+1,index:n,value:i,size:o(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(c)&&(t=!0,n++)}a.set(d(e.path),n)}return t&&r.add(d(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:a}})(Ee,pt,je),[a,je,pt,u]),ht=t.useMemo(()=>(e=>{const t={...R};for(const n of Object.keys(R)){const o=n,a=e[o];if(void 0===a)continue;const s="clipboardModifier"===n||"collapseModifier"===n;if(null===a){t[o]=s?[]:null;continue}const i=(()=>s?r(a):"string"==typeof a?{key:a}:a)();t[o]=i}return T.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(le),[le]),ft=t.useCallback((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(k(n,e[r],r)){n.preventDefault(),o();break}})(ht,t,e),[ht]),yt=t.useMemo(()=>{const e=ut(q,"stringifyReplacer");return t=>re(t,e)},[q,re]),gt=t.useMemo(()=>{const e=ut(q,"parseReviver");return t=>{const n=ne(t,e);return i(n)}},[q,ne]),vt=t.useRef(null),{setCollapseState:bt}=te(),jt=t.useCallback((e,t)=>{!1!==L&&("function"!=typeof L?e.sort((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0}):e.sort((e,n)=>L(t(e),t(n))))},[L]);Ne.current=jt;const xt=t.useCallback(e=>E(Pe(),e,Te.current,Ne.current),[Pe]);l.current=xt,t.useImperativeHandle(ce,()=>{const e=Symbol("path-missing");return{collapse:e=>bt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>x(Pe(),t,e)===e?"PATH_NOT_FOUND":n||Je(E(Pe(),t,u,jt))?(fe(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{vt.current&&(vt.current.click(),"editing"!==ge().active?.phase&&ye())},cancel:()=>ye()}},[bt,fe,ye,ge,Je,Pe,u,jt]);const wt=Oe(q,Ee),Et=t.useMemo(()=>({object:!0===ue||"object"===ue,array:!0===ue||"array"===ue}),[ue]),Ct={mainContainerRef:we,name:u,nodeData:Ee,getLatestData:Pe,onChange:Ae,onError:Ie,onEditEvent:Me,showErrorMessages:y,showCollectionCount:C,collapseFilter:ve,collapseAnimationTime:w,allowEditFilter:Je,allowDeleteFilter:at,allowAddFilter:st,allowTypeSelection:N,allowDragFilter:dt,canDragOnto:!1,showClipboardButton:g,onCopy:_e,sortKeys:L,sort:jt,showArrayIndexes:M,arrayIndexStart:_,showStringQuotes:V,showIconTooltips:z,indent:b,defaultValue:F,newKeyOptions:B,stringTruncateLength:$,translate:be,customNodeDefinitions:q,customNodeData:wt,customButtons:ee,parentData:null,jsonParse:gt,jsonStringify:yt,TextEditor:oe,Select:ae,errorDisplayTime:se,handleKeyboard:ft,keyboardControls:ht,insertAtTop:Et,onCollapse:Le,editConfirmRef:vt,collapseClickZones:pe},Dt={...me("container",Ee),...he,minWidth:U,maxWidth:H};return Dt.fontSize=W??Dt.fontSize,e.jsx("div",{id:Q,ref:we,className:`jer-editor-container ${X??""}`,style:Dt,children:e.jsx(ie,{value:mt,children:o(a)&&!wt.renderCollectionAsValue?e.jsx(Fe,{data:a,...Ct}):e.jsx(Ke,{data:a,showLabel:!0,...Ct})})})};function st(n){const r=t.useRef(void 0),o=t.useRef(void 0),a=n;return e.jsx(B,{theme:a.theme??L,children:e.jsx(ae,{onEditEvent:a.onEditEvent,onCollapse:a.onCollapse,buildNodeDataFromPathRef:r,commitRef:o,children:e.jsx(at,{...a,buildNodeDataFromPathRef:r,commitRef:o})})})}const it=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},s="add"!==r?x(e,t):void 0;return{currentData:e,newData:g(e,t,n,a),currentValue:s,newValue:"delete"!==r?n:void 0}},lt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,ct=e=>{if(void 0!==e)return"value"===e?Ye:"key"===e?Ue:"all"===e?(e,t)=>Ye(e,t)||Ue(e,t):e},ut=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?l:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}};exports.AutogrowTextArea=D,exports.IconSvg=je,exports.JsonEditor=st,exports.JsonViewer=function(r){const{editorRef:o,...a}=r,s=t.useRef(null);return t.useImperativeHandle(o,()=>({collapse:e=>s.current?.collapse(e)}),[]),e.jsx(st,{...a,editorRef:s,setData:n,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})},exports.StringDisplay=pe,exports.StringEdit=me,exports.assign=g,exports.collectionDataTypes=De,exports.defaultTheme=L,exports.extract=x,exports.isCollection=o,exports.matchNode=Ye,exports.matchNodeKey=Ue,exports.splitPropertyString=c,exports.standardDataTypes=Se,exports.toPathString=d,exports.useKeyboardListener=ge,exports.valueDataTypes=Ce;
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react");const n=()=>{},r=e=>Array.isArray(e)?e:[e],o=e=>null!==e&&"object"==typeof e,a=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),s=e=>null!=e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then,i=(e,t)=>{if("string"!=typeof e)return null;const n=t.filter(t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority);return n.sort((e,t)=>(t.matchPriority??0)-(e.matchPriority??0)),n[0]??null},l=e=>{if(e!==c){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=l(n);r!==n&&(e[t]=r)}return e}},c="__undefined__",u=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),d=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),p=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),m=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),h=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),f=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},y=e=>Array.isArray(e),g=(e,t)=>e.filter((e,n)=>n!==t),v=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:s=!1}=r,i=e,l=d(t),c={...r,remove:o,createNew:a,noError:s,fullData:i,fullPath:l},p=Array.isArray(t)?t:u(t);return y(e)&&o&&1===p.length?g(e,p[0]):b(e,p,n,c)},b=(e,t,n,r)=>{const o=a(e)?{...e}:null,s=y(e)?[...e]:null;if(0===t.length)return e;if(!o&&!s)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:c,fullData:u,fullPath:d}=r,p=t[0];if(s&&"string"==typeof p)return s.map(e=>b(e,t,n,r));if(1===t.length)return o&&"string"==typeof p?j(o,p,n,r)??o:s&&"number"==typeof p?(x(s,p,n,r),s):(f(u,d,p,c),e);const m=o||s||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=m[p],n=t[1];return y(e)?m[p]=g(e,n):f(u,d,p,c,"Trying to remove an indexed item from an object that is not an array"),m}const h=t.slice(1);if(p in e){if(v=m[p],!y(v)&&!a(v)){if(!i)return f(u,d,p,c),m;m[p]={}}return m[p]=b(m[p],h,n,r),m}var v;if(i){const e="number"==typeof h[0]?[]:{};if(o)return m[p]=e,m[p]=b(m[p],h,n,r),m;if(s&&Array.isArray(m)){m.push(e);const t=m.length-1;return m[t]=b(m[t],h,n,r),m}}return f(u,d,p,c),m},j=(e,t,n,r)=>{const{remove:o,createNew:a,noError:s,insertAfter:i,insertBefore:l,fullData:c,fullPath:u}=r;if(void 0!==l||void 0!==i){const r=Object.entries(e);let o=1/0;return o="number"==typeof l?l:"number"==typeof i?i:r.findIndex(([e])=>e===(l??i)),void 0!==i&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const d=t in e;o?d?delete e[t]:f(c,u,t,s):a||d?e[t]=n:f(c,u,t,s)},x=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:s,createNew:i,insert:l}=r;l&&e.splice(t,0,n),t in e?e[t]=n:i?e.push(n):f(a,s,t,o)},w=(e,t,n)=>{const r=Array.isArray(t)?t:u(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>w(e,r,n));if("object"!=typeof e||null===e||!(o in e))return E(e,o,n);const a=e[o];return 1===r.length?a:w(a,r.slice(1),n)},E=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},C=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:o(e)?Object.keys(e).length:1,parentData:null,fullData:e};const a=t[t.length-1],s=w(e,t),i=w(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof a?a:Number(a);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===a)}return{key:a,path:t,level:t.length,index:l,value:s,size:o(s)?Object.keys(s).length:null,parentData:i,fullData:e}},D="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,S=({className:n,name:r,value:o,setValue:a,onKeyDown:s,styles:i,textAreaRef:l})=>{const c=t.useRef(null);if(D(()=>{const e=c.current;c.current=null;const t=l?.current;if(!e||!t)return;const n=e.start+o.length-e.sourceLength,r=Math.max(0,Math.min(n,o.length));t.selectionStart!==r&&t.setSelectionRange(r,r)},[o,l]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${r}_textarea`,ref:l,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...i},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;c.current=null!==n&&n<t.length?{start:n,sourceLength:t.length}:null,a(t)},autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:s}),e.jsx("span",{className:n,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...i},children:u})]})},k=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,O=(e,t,n)=>{if(!t)return!1;const r=e.key,o=k(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:s}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!s?.includes("Shift"))&&r===a&&(s===o||Array.isArray(s)&&s.includes(o))},T={key:"Enter"},R={confirm:T,cancel:{key:"Escape"},objectConfirm:{...T,modifier:["Meta","Shift","Control"]},objectLineBreak:T,stringConfirm:T,stringLineBreak:{...T,modifier:["Shift"]},numberConfirm:T,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:T,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},N=["stringConfirm","numberConfirm","booleanConfirm"],A=(e,t)=>{const n=e.current,r=n.selectionStart??1/0,o=n.selectionEnd??1/0,a=n.value.slice(0,r)+t+n.value.slice(o);return n.value=a,n.setSelectionRange(r+1,r+1),a},P=(e,t,n="next",r,a)=>{const s=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=w(e,s),c=L(l);Array.isArray(l)||r(c,({key:e,value:t})=>[e,t]);const u=c.findIndex(e=>e.key===i),d=c[u+("next"===n?1:-1)];if(!d)return 0===s.length?null:P(e,s,n,r,a);let p;if(o(d.value)){if(0===Object.keys(d.value).length)return P(e,[...s,d.key],n,r,a);p=I(e,[...s,d.key],n,r)}else p=[...s,d.key];return p?a(C(e,p,"",r))?p:P(e,p,n,r,a):null},I=(e,t,n="next",r)=>{const a=w(e,t);if(!o(a))return t;const s=Array.isArray(a)?a.map((e,t)=>t):Object.keys(a);r(s,e=>[e,a]);const i="next"===n?s[0]:s[s.length-1];return I(e,[...t,i],n,r)},L=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),K={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},_={displayName:"Default",icons:{add:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),/*#__PURE__*/e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),/*#__PURE__*/e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:/*#__PURE__*/e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),/*#__PURE__*/e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),/*#__PURE__*/e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:K,scale:.86},ok:{content:/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),/*#__PURE__*/e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:K,scale:.9},cancel:{content:/*#__PURE__*/e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:/*#__PURE__*/e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},M={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},V=e=>[_,...r(e)].map(e=>"styles"in e?e:{styles:e}),z=e=>{const t={};for(const{icons:n}of V(e))n&&Object.assign(t,n);return t},F={getStyles:()=>({}),icons:/*#__PURE__*/z(_),cssVars:{}},B=t.createContext(F),H=({theme:n=_,children:r})=>{const o=t.useMemo(()=>(e=>{var t;const n=V(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[M[a]??"color"]:t}:t}}}for(const e in o)r[t=e]??(r[t]={});const a={};for(const e in r){const t=e,n=r[t],s=o[t];a[t]=s?e=>s.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(n),[n]),a=t.useMemo(()=>/*#__PURE__*/z(n),[n]),s=t.useMemo(()=>(e=>{const{inputHighlight:t,iconCopy:n}=e,r={};return"function"!=typeof t&&t?.backgroundColor&&(r["--jer-highlight-color"]=t.backgroundColor),"function"!=typeof n&&n?.color&&(r["--jer-icon-copy-color"]=n.color),r})(o),[o]),i=t.useCallback((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(o,e,t),[o]),l=t.useMemo(()=>({getStyles:i,icons:a,cssVars:s}),[i,a,s]);return e.jsx(B.Provider,{value:l,children:r})},W=()=>t.useContext(B),Y={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},U=(e,t)=>Y[e][t]??null,$=(e,t)=>null!==e&&null!==t&&e.op===t.op&&m(e.path,t.path),J={active:null,settling:{}},X=t.createContext(null),Q=({children:n,onEditEvent:r,buildNodeDataFromPathRef:o,commitRef:a})=>{const i=t.useRef(r);i.current=r;const l=t.useRef(null);return null===l.current&&(l.current=((e,t,n)=>{let r=J;const o=new Set;let a=null,i=null,l=!1,c=0;const u=e=>{r=e,o.forEach(e=>e())},d=(t,n,r)=>{e.current?.({...t,...r,event:n})},f=(n,o,s)=>{if(!e.current)return;let l;try{l=t.current?.(n)}catch{return u({...r,active:null}),a=null,void(i=null)}l&&d(l,o,s)},y=(e,t)=>{var n;a=t?.cancelOp??null,i=t?.commitOp??null,n=e,$(r.active,n)&&r.active?.phase===n?.phase||u({...r,active:n});const o=U(e.op,"start");o&&f(e.path,o)},g=(e,t,o,s,l,c,h,f,y)=>{const g=p(e);if(!h()){if("cancel"===s.status||"error"===s.status){r.active&&m(r.active.path,e)&&("held"===r.active.phase||"editing"===r.active.phase)&&(u({...r,active:null}),a=null,i=null);const n=U(t,"cancel");return n&&d(f,n),"error"===s.status&&d(f,"updateError",{operation:t,error:s.error}),s}l()}if(r.settling[g]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],u({...r,settling:t})})(g),s.status){case"cancel":c();break;case"error":c(),d(f,"updateError",{operation:t,error:s.error});break;case"override":n.current?.applyValue(s.path,s.value),d(f,"updateSuccess",{operation:t,...y});break;case"commit":d(f,"updateSuccess",{operation:t,...y})}return s}};return{subscribe:e=>(o.add(e),()=>o.delete(e)),getSnapshot:()=>r,getServerSnapshot:()=>r,open:(e,t)=>{if("held"===r.active?.phase)return;const n={path:e,op:t?.op??"edit",phase:"editing",force:t?.force},o=r.active,s=null!==o&&!$(o,n);if(s&&i)return void i(()=>y(n,t));const l=a;if(a=null,i=null,l&&l(),s&&$(r.active,o)){const e=U(o.op,"cancel");e&&f(o.path,e)}y(n,t)},cancel:()=>{if(l)return;if("held"===r.active?.phase)return;const e=r.active;l=!0;try{const t=a;if(a=null,i=null,t&&t(),null!==e){null!==r.active&&u({...r,active:null});const t=U(e.op,"cancel");t&&f(e.path,t)}}finally{l=!1}},submit:e=>{const{op:t,path:o,instant:l,onCommit:m}=e,h=n.current;let y;try{y=h?.buildCommit(e)??null}catch{return $(r.active,{path:o,op:t})&&u({...r,active:null}),a=null,i=null,m?.(),Promise.resolve(void 0)}const v=y?.extra,b=p(o),j=++c;if(!l){const e=U(t,"submit");e&&f(o,e)}if(!y||y.isNoOp){$(r.active,{path:o,op:t})&&u({...r,active:null}),a=null,i=null;const e=U(t,"commit");return e&&(y?d(y.nodeData,e,v):f(o,e,v)),m?.(),Promise.resolve(void 0)}const{input:x,nodeData:w,apply:E,revert:C}=y,D=!!h?.runUpdate;let S=!1,k=!1;const O=()=>{if(S)return;S=!0,E(),a=null,i=null,$(r.active,{path:o,op:t})&&u({...r,active:null}),D&&((e,t)=>{u({...r,settling:{...r.settling,[e]:t}})})(b,j);const e=U(t,"commit");e&&d(w,e,v),m?.()},T={hold:()=>(k=!0,u({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>O())};if(!D)return O(),Promise.resolve(void 0);const R=h.runUpdate(x,T),N=s(R);if(!k&&!l&&!N)return Promise.resolve(g(o,t,j,R,O,C,()=>S,w,v));const A=N?R:Promise.resolve(R);let P;return k||(l?P=setTimeout(O,100):O()),A.then(e=>(clearTimeout(P),g(o,t,j,e,O,C,()=>S,w,v)))},areChildrenBeingEdited:e=>null!==r.active&&h(r.active.path,e)}})(i,o,a)),e.jsx(X.Provider,{value:l.current,children:n})},Z=()=>{const e=t.useContext(X);if(!e)throw new Error("Missing Editing Context Provider");return e},G=e=>{const n=Z();return t.useSyncExternalStore(n.subscribe,()=>e(n.getSnapshot()),()=>e(n.getServerSnapshot()))},q=t.createContext(null),ee=({children:n,onCollapse:o,buildNodeDataFromPathRef:a})=>{const[s,i]=t.useState({commands:null,version:0}),l=t.useRef(o);l.current=o;const c=t.useCallback(e=>{if(null===e)return void i(e=>null===e.commands?e:{commands:null,version:e.version});const t=r(e),n=t.map(e=>({...e,path:[...e.path]}));i(e=>({commands:n,version:e.version+1}));const o=l.current;o&&t.forEach(e=>{const t=a.current?.(e.path);t&&o({...t,collapsed:e.collapsed,includeChildren:e.includeChildren})})},[a]),u=t.useMemo(()=>({commands:s.commands,version:s.version,setCollapseState:c}),[s.commands,s.version,c]);return e.jsx(q.Provider,{value:u,children:n})},te=()=>{const e=t.useContext(q);if(!e)throw new Error("Missing Collapse Context Provider");return e},ne=(e,t)=>{if(!t.includeChildren)return t.path.length===e.length&&t.path.every((t,n)=>e[n]===t);for(const[n,r]of t.path.entries())if(r!==e[n])return!1;return!0},re=t.createContext(null),oe=({children:n})=>{const[r,o]=t.useState({path:null,canDelete:!1}),a=t.useRef(!1),s=t.useMemo(()=>({dragSource:r,setDragSource:o,armed:a}),[r]);return e.jsx(re.Provider,{value:s,children:n})},ae=({children:t,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>e.jsx(Q,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:e.jsx(ee,{onCollapse:r,buildNodeDataFromPathRef:o,children:e.jsx(oe,{children:t})})}),se=t.createContext(void 0),ie=({value:t,children:n})=>e.jsx(se.Provider,{value:t,children:n}),le=()=>{const e=t.useContext(se);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},ce=e=>{const t=le();return null===t||t.visiblePaths.has(p(e))},ue=e=>{const t=le();return null===t?null:t.visibleChildCounts.get(p(e))??null},de="**INVALID_FUNCTION**",pe=({nodeData:n,showStringQuotes:r=!0,stringTruncateLength:o=200,pathString:a,canEdit:s,setIsEditing:i,styles:l,translate:c,showIconTooltips:u=!1,value:d,TextWrapper:p=({children:e})=>e})=>{const m=d??n.value,[h,f]=t.useState(!1),y=r?'"':"",g=m.length>o,v=()=>{s?i(!0):f(!h)},b=c("SHOW_MORE",n);return e.jsxs("div",{id:`${a}_display`,onDoubleClick:v,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&v()},className:"jer-value-string",style:l,children:[y,g?h?e.jsxs(e.Fragment,{children:[e.jsx(p,{children:e.jsxs("span",{children:[m,y]})})," ",e.jsx("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-show-less",onClick:()=>f(!1),children:c("SHOW_LESS",n)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(p,{children:[e.jsx("span",{children:m.slice(0,o-2).trimEnd()})," "]}),e.jsx("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-ellipsis",onClick:()=>f(!0),"aria-label":b,title:u?b:"",children:"..."}),y]}):e.jsx(p,{children:`${m}${y}`})]})},me=({styles:n,pathString:r,value:o,setValue:a,handleEdit:s,handleKeyboard:i,keyboardCommon:l})=>{const c=t.useRef(null);return e.jsx(S,{className:"jer-input-text",textAreaRef:c,name:r,value:o,setValue:a,onKeyDown:e=>{i(e,{stringConfirm:s,stringLineBreak:()=>{const e=A(c,"\n");a(e)},...l})},styles:n})},he=({isEditing:t,path:n,enumType:r,...o})=>{const{getStyles:a}=W(),s=p(n),{value:i,setValue:l,nodeData:c,handleEdit:u,handleKeyboard:d,keyboardCommon:m,Select:h}=o;return t&&r?e.jsx(h,{name:`${s}-value-select`,value:i,onChange:l,options:r.values,autoFocus:!0,onKeyDown:e=>d(e,{stringConfirm:u,...m})}):t?e.jsx(me,{styles:a("input",c),pathString:s,...o,setValue:o.setValue}):e.jsx(pe,{pathString:s,styles:a("string",c),...o})},fe=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=W();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:p(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:e=>l(e,{numberConfirm:s,numberUp:()=>n(Number(t)+1),numberDown:()=>n(Number(t)-1),...c}),style:{width:String(t).length/1.5+2+"em",...u("input",i)}}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:u("number",i),children:t})},ye=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=W();return"boolean"!=typeof t?null:r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:p(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{" "===e.key&&e.preventDefault(),l(e,{booleanConfirm:s,booleanToggle:()=>n(!t),...c})},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:u("boolean",i),children:String(t)})},ge=(e,n)=>{const r=t.useRef(void 0),o=t.useRef(n);t.useEffect(()=>{o.current=n},[n]);const a=e=>{o.current(e)};t.useEffect(()=>{if(window.clearTimeout(r.current),e)return r.current=window.setTimeout(()=>{window.addEventListener("keydown",a)},100),()=>{window.clearTimeout(r.current),window.removeEventListener("keydown",a)}},[e])},ve=({value:t,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:s,keyboardCommon:i})=>{const{getStyles:l}=W();return ge(n,e=>s(e,{confirm:o,...i})),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:l("null",a),children:String(t)})},be=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===de&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},je=({scale:t=1,viewBox:n="0 0 24 24",fill:r="currentColor",children:o,...a})=>{const s=1.4*t+"em";return e.jsx("svg",{viewBox:n,fill:r,width:s,height:s,...a,children:o})},xe=({name:t,nodeData:n})=>{const{getStyles:r,icons:o}=W(),a=o[t],s=`icon${t[0].toUpperCase()}${t.slice(1)}`;return e.jsx(je,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===t?void 0:"jer-icon",style:r(s,n),children:a.content})},we=({startEdit:n,handleDelete:r,handleAdd:o,showClipboardButton:a,onCopy:s,type:i,customButtons:l,nodeData:c,translate:u,keyboardControls:p,handleKeyboard:h,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:j}=W(),{open:x,cancel:E}=Z(),C=u("KEY_NEW",c),[S,O]=t.useState(C),[T,R]=t.useState(!1),{path:N,value:A}=c,P=G(e=>{const t=e.active;return null!==t&&"add"===t.op&&m(t.path,N)}),I=Array.isArray(T);D(()=>{if(!P)return R(!1),void O(C);const e=Object.keys(w(c.fullData,N)),t=y?y(c)?.filter(t=>!e.includes(t)):null;t&&O(""),R(t??!0)},[P]);const L=()=>{o&&(I&&!S||o("array"===i?"":S))};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:P?1:void 0},onClick:e=>e.stopPropagation(),children:[a&&e.jsx("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",i=null;if(a){const a=k(e);if(a&&p.clipboardModifier.includes(a)?(t=d(N),o=t,r="path"):(t=A,o="object"==typeof t?g(A):String(t)),!navigator.clipboard)return void s?.({...c,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,i=e.message}).finally(()=>{s?.({...c,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:i??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":u("TOOLTIP_COPY",c),title:v?u("TOOLTIP_COPY",c):"",children:e.jsx(xe,{name:"copy",nodeData:c})}),n&&e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":u("TOOLTIP_EDIT",c),title:v?u("TOOLTIP_EDIT",c):"",children:e.jsx(xe,{name:"edit",nodeData:c})}),r&&e.jsx("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":u("TOOLTIP_DELETE",c),title:v?u("TOOLTIP_DELETE",c):"",children:e.jsx(xe,{name:"delete",nodeData:c})}),o&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===i?x(N,{op:"add"}):o("")},"aria-label":u("TOOLTIP_ADD",c),title:v?u("TOOLTIP_ADD",c):"",children:e.jsx(xe,{name:"add",nodeData:c})}),l?.map(({Element:t,onClick:n,label:r},o)=>{const a=e=>n&&n(c,e);return r?e.jsx("button",{type:"button",tabIndex:-1,onClick:a,"aria-label":r,title:v?r:"",children:e.jsx(t,{nodeData:c})},o):e.jsx("div",{onClick:a,children:e.jsx(t,{nodeData:c})},o)}),P&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[I?e.jsx(b,{name:"new-key-select",onChange:o,defaultValue:"",autoFocus:!0,onKeyDown:e=>h(e,{cancel:()=>E()}),placeholder:T.length>0?u("KEY_SELECT",c):u("NO_KEY_OPTIONS",c),options:T}):e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:S,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{h(e,{stringConfirm:()=>L(),cancel:()=>E()})},style:j("input",c)}),e.jsx(Ee,{onOk:()=>L(),onCancel:()=>E(),nodeData:c,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},Ee=({onOk:t,onCancel:n,nodeData:r,translate:o,showIconTooltips:a,editConfirmRef:s,hideOk:i=!1})=>e.jsxs("div",{className:"jer-confirm-buttons",children:[!i&&e.jsx("button",{type:"button",tabIndex:-1,onClick:t,"aria-label":o("TOOLTIP_OK",r),title:a?o("TOOLTIP_OK",r):"",ref:s,children:e.jsx(xe,{name:"ok",nodeData:r})}),e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":o("TOOLTIP_CANCEL",r),title:a?o("TOOLTIP_CANCEL",r):"",children:e.jsx(xe,{name:"cancel",nodeData:r})})]}),Ce=["string","number","boolean","null"],De=["object","array"],Se=[...Ce,...De],ke=e=>{const{component:t,wrapperComponent:n,keyComponent:r,showKey:o=!0,showEditTools:a=!0,showOnEdit:s=!1,showOnView:i=!0,showCollectionWrapper:l=!0,...c}=e;return{CustomComponent:t,CustomWrapperComponent:n,CustomKeyComponent:r,showKey:o,showEditTools:a,showOnEdit:s,showOnView:i,showCollectionWrapper:l,...c}},Oe=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?ke(n):{}},Te=({props:e,collapsed:n})=>{const{nodeData:r,parentData:o,onError:a,getLatestData:s,showErrorMessages:i,allowEditFilter:l,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:d,canAddHere:h,translate:f,errorDisplayTime:y,sort:g,arrayIndexStart:v,handleKeyboard:b,customNodeData:j}=e,{submit:x}=Z(),[w,E]=t.useState(null),C={...r,collapsed:n,visibleSize:ue(r.path)},{path:D,key:S,size:k}=C,O=p(D),T=G(e=>{const t=e.active;return null!==t&&"edit"===t.op&&m(t.path,D)}),R=G(e=>{const t=e.active;return null!==t&&"rename"===t.op&&m(t.path,D)}),N=G(e=>O in e.settling),A=l(C),I=c(C),L=u(C),K=d(C),_=e=>{i&&(E(e),setTimeout(()=>E(null),y)),console.warn("Error",e)},M=t.useRef(C);M.current=C;const V=t.useCallback((e,t)=>{_(e.message),a&&a({...M.current,fullData:s(),error:e,errorValue:t})},[a,i,s,y]),z=le(),F=t.useCallback(e=>(null===z||z.visiblePaths.has(p(e.path)))&&l(e),[z,l]),B=e=>P(s(),D,e,g,F),H=(e,t)=>{o&&(S!==e&&Object.keys(o).includes(e)?V({code:"KEY_EXISTS",message:f("ERROR_KEY_EXISTS",C)},e):x({op:"rename",path:D,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&V(t.error,e)}))},W="number"==typeof D.slice(-1)[0],Y=null!==o&&!W&&I&&h,U={isEditing:T,isEditingKey:R,isPending:N,isArray:W,canEditKey:Y},$=""===S&&D.length>0?f("EMPTY_STRING",C):null;return{pathString:O,nodeData:C,path:D,name:S,size:k,canEdit:A,canDelete:I,canAdd:L,canDrag:K,error:w,showError:_,onError:V,setError:E,handleEditKey:H,derivedValues:U,emptyStringKey:$,getNextOrPreviousAtPath:B,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:Y,isEditingKey:R,pathString:O,path:D,name:S,arrayIndexStart:v,handleKeyboard:b,handleEditKey:H,handleCancel:e,styles:t("property",C),getNextOrPrevious:B,emptyStringKey:$,nodeData:C,customNodeData:j,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Re=({canDrag:n,canDelete:r,canDragOnto:o,canAddHere:a,path:s,nodeData:i,onError:l,translate:c})=>{const{getStyles:u}=W(),{dragSource:d,setDragSource:p,armed:f}=(()=>{const e=t.useContext(re);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),y=Z(),[g,v]=t.useState(!1),b=()=>null!==d.path&&!h(s,d.path)&&(m(d.path.slice(0,-1),s.slice(0,-1))?o:d.canDelete&&a),j=t.useMemo(()=>n?{onMouseDown:e=>{0===e.button&&null===y.getSnapshot().active&&(f.current=!0)},onMouseUp:()=>{f.current=!1},onDragStart:e=>{if(!f.current||null!==y.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();f.current=!1,e.stopPropagation(),p({path:s,canDelete:r})},onDragEnd:e=>{f.current=!1,e.stopPropagation(),p({path:null,canDelete:!1})}}:{},[n,r,s]),x=t.useMemo(()=>e=>o||a?{onDragOver:e=>{e.stopPropagation(),b()&&e.preventDefault()},onDrop:t=>{t.stopPropagation(),E(e),p({path:null,canDelete:!1}),v(!1)},onDragEnter:t=>{t.stopPropagation(),b()&&v(e)},onDragExit:e=>{e.stopPropagation(),v(!1)}}:{},[d,o,a,s]),w=t.useMemo(()=>null!==d.path&&b()?e.jsx("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:s.length},...x("below")}):null,[d,o,a,s.length]),E=e=>{if(null===d.path)return;if(!b())return;const t=d.path.slice(-1)[0],n=d.path.slice(0,-1),r=s.slice(0,-1),{parentData:o}=i;"string"==typeof t&&o&&!Array.isArray(o)&&Object.keys(o).includes(t)&&t in o&&!m(n,r)?l({code:"KEY_EXISTS",message:c("ERROR_KEY_EXISTS",i)},t):y.submit({op:"move",path:d.path,to:{path:s,position:e},instant:!0})};return{dragSourceProps:j,getDropTargetProps:x,BottomDropTarget:w,DropTargetPadding:({position:t,nodeData:n})=>g===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:u("dropZone",n)}):null,handleDrop:E}},Ne=({isEditingKey:n,canEditKey:r,pathString:o,path:a,name:s,arrayIndexStart:i,handleKeyboard:l,handleEditKey:c,handleCancel:u,handleClick:d,keyValueArray:p,styles:m,getNextOrPrevious:h,emptyStringKey:f,nodeData:y,customNodeData:g,getStyles:v})=>{const{open:b,cancel:j}=Z(),x=t.useRef(null),w=e=>c(x.current?.value??String(s),e),E="number"==typeof s?String(s+i):s;if(!n){const t={...m,minWidth:`${Math.min(E.length+1,5)}ch`,flexShrink:E.length>10?1:0};if(g?.CustomKeyComponent&&y&&v){const{CustomKeyComponent:n,componentProps:o}=g;return e.jsx(n,{nodeData:y,name:f??E,path:a,canEditKey:r,handleEditKey:e=>{r&&c(e)},startEditingKey:()=>{r&&b(a,{op:"rename",commitOp:w})},handleClick:d,styles:t,componentProps:o,getStyles:v})}return e.jsxs("span",{className:"jer-key-text",style:t,onDoubleClick:()=>r&&b(a,{op:"rename",commitOp:w}),onClick:d,children:[f?e.jsx("span",{className:"jer-empty-string",children:f}):E,""!==E||f?e.jsx("span",{className:"jer-key-colon",children:":"}):null]})}return e.jsx("input",{ref:x,className:"jer-input-text jer-key-edit",type:"text",name:o,defaultValue:E,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>l(e,{stringConfirm:()=>c(e.target.value),cancel:u,tabForward:()=>{const t=e.target.value;c(t,()=>{if(p){const e=p?.[0][0],t=e?[...a,e]:h("next");t?b(t):j()}else b(a)})},tabBack:()=>{const t=e.target.value;c(t,()=>{const e=h("prev");e?b(e):j()})}}),style:{width:E.length/1.5+.5+"em"}})},Ae=new Set(["nodeData","customNodeData"]),Pe=(e,t)=>{if(n=e.nodeData,r=t.nodeData,n.key!==r.key||n.index!==r.index||n.level!==r.level||n.size!==r.size||!m(n.path,r.path))return!1;var n,r;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(const n of o)if(!Ae.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ie=r=>{const{data:o,parentData:a,onChange:s,showClipboardButton:l,onCopy:c,canDragOnto:u,canAddHere:d,allowTypeSelection:p,showLabel:h,stringTruncateLength:f,showStringQuotes:y,indent:g,translate:v,customNodeDefinitions:b,customNodeData:j,Select:x,handleKeyboard:w,keyboardControls:E,editConfirmRef:C,jsonStringify:D,showIconTooltips:S,getLatestData:k}=r,{getStyles:O}=W(),{open:T,cancel:R,submit:N,getSnapshot:A}=Z(),{setCollapseState:P}=te(),[I,L]=t.useState("function"==typeof o?de:o),{nodeData:K,path:_,name:M,canEdit:V,canDelete:z,canDrag:F,error:B,onError:H,setError:Y,derivedValues:U,getNextOrPreviousAtPath:$,buildKeyDisplayProps:J}=Te({props:r}),{dragSourceProps:X,getDropTargetProps:Q,BottomDropTarget:G,DropTargetPadding:q}=Re({canDrag:F,canDelete:z,canDragOnto:u,canAddHere:d,path:_,nodeData:K,onError:H,translate:v}),[ee,ne]=t.useState(_e(o,j)),re=t.useRef(I);re.current=I;const oe=t.useRef(K);oe.current=K;const ae=t.useCallback(e=>{if(!s)return void L(e);const t=s({...oe.current,value:re.current,fullData:k(),newValue:e});L(t)},[s,k]),se=()=>{L("function"==typeof o?de:o),ne(_e(o,j)),ue(i(o,ie))};t.useEffect(()=>{U.isEditing||se()},[o]);const ie=t.useMemo(()=>{const e=[...Se,...b.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof p)return p?e:[];if(Array.isArray(p))return p;const t=p(K);return"boolean"==typeof t?t?e:[]:t},[K,p,b]),[le,ue]=t.useState(i(I,ie)),{isEditing:pe,isPending:me}=U,he=ce(_),fe=t.useRef(n);if(!he)return null;const ye=pe&&ee!==_e(o,j),ge=ye?b.find(e=>e.name===ee&&Ke(e)):void 0,ve=ge?ke(ge):j,{CustomComponent:be,componentProps:je,showKey:xe=!0,showEditTools:Ce=!0,showOnEdit:De,showOnView:Oe,passOriginalNode:Ae}=ve,Pe=be&&(void 0!==ge||!ye&&(pe&&De||!pe&&Oe)),Ie=e=>{P(null);const t=ye&&!ge?void 0:ve,n=t?.toStandardType?t.toStandardType(I):I,r=b.find(t=>t.name===e);if(r){const t="function"==typeof r.defaultValue?r.defaultValue(K):r.defaultValue;if(Ke(r)){let o=t;if(r.fromStandardType)try{o=r.fromStandardType(n,K,r.componentProps)}catch{}return L(o),ne(e),void ue(null)}return N({op:"edit",path:_,value:t}).then(Le(t)),void P({path:_,collapsed:!1,includeChildren:!1})}const o=ie.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof I&&o.values.includes(I)||L(o.values[0]),ue(o),void ne(e);const a=ze(n,e,v("DEFAULT_NEW_KEY",K));if("object"===e||"array"===e||"null"===e)return N({op:"edit",path:_,value:a}).then(Le(a)),void("null"!==e&&P({path:_,collapsed:!1,includeChildren:!1}));L(a),ne(e),ue(null)},Le=e=>t=>{if("error"===t?.status&&H(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=A().active;"editing"===e?.phase&&m(e.path,_)||se()}},Fe=(e,t)=>{const n=void 0!==e&&!(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e);let r;if(n)r=e;else if(Pe&&ve.fromStandardType)try{r=ve.fromStandardType(I,K,ve.componentProps)}catch(e){return void H({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},I)}else r="number"===ee?Ve(I):I;Y(null),ge&&P({path:_,collapsed:!1,includeChildren:!1}),N({op:"edit",path:_,value:r,onCommit:t}).then(Le(r))};fe.current=Fe;const Be=()=>{Y(null),se(),R()},{isEditingKey:He}=U,We=!!B,Ye=pe&&ie.length>1,Ue=("invalid"!==ee||be)&&!B&&Ce,$e=h&&xe,Je=()=>T(_,{cancelOp:se,commitOp:e=>fe.current(void 0,e)}),Xe=V?Je:n,Qe=e=>()=>{const t=$(e);t&&Fe(void 0,()=>T(t))},Ze={value:I,parentData:a,setValue:ae,isEditing:pe,canEdit:V,setIsEditing:Xe,handleEdit:Fe,handleCancel:Be,path:_,stringTruncateLength:f,showStringQuotes:y,showIconTooltips:S,nodeData:K,enumType:le,translate:v,handleKeyboard:w,keyboardCommon:{cancel:Be,tabForward:Qe("next"),tabBack:Qe("prev")},Select:x},Ge={...J({handleCancel:Be,getStyles:O}),customNodeData:ve},qe=Pe?e.jsx(be,{...r,value:I,componentProps:je,setValue:ae,handleEdit:Fe,handleCancel:Be,onKeyDown:e=>w(e,{stringConfirm:Fe,cancel:Be}),isEditing:pe,isPending:me,setIsEditing:Xe,getStyles:O,originalNode:Ae?Me(o,ee,Ze):void 0,originalNodeKey:Ae?e.jsx(Ne,{...Ge,customNodeData:void 0}):void 0,canEdit:V,keyboardCommon:Ze.keyboardCommon}):Me(o,ee,Ze);return e.jsxs("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==a?g/2+"em":0,position:"relative"},draggable:F&&!pe&&!He,...X,...Q("above"),children:[G,e.jsx(q,{position:"above",nodeData:K}),e.jsxs("div",{className:"jer-value-main-row",style:{...O("valueRow",K),flexWrap:M.length>10?"wrap":"nowrap"},children:[$e&&e.jsx(Ne,{...Ge}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:qe}),pe?e.jsx(Ee,{onOk:Fe,onCancel:Be,nodeData:K,translate:v,showIconTooltips:S,editConfirmRef:C}):Ue&&e.jsx(we,{startEdit:V?Je:void 0,handleDelete:z?()=>{N({op:"delete",path:_,instant:!0}).then(e=>{"error"===e?.status&&H(e.error,I)})}:void 0,showClipboardButton:l,onCopy:c,translate:v,customButtons:r.customButtons,nodeData:K,handleKeyboard:w,keyboardControls:E,editConfirmRef:C,jsonStringify:D,showIconTooltips:S,Select:x}),Ye&&e.jsx(x,{name:`${M}-type-select`,value:le?le.enum:ee,onChange:e=>Ie(e),options:ie.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),We&&e.jsx("span",{className:"jer-error-slug",style:O("error",K),children:B})]})]}),e.jsx(q,{position:"below",nodeData:K})]})},Le=/*#__PURE__*/t.memo(Ie,Pe),Ke=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,_e=(e,t)=>t?.CustomComponent&&t?.name&&t.showInTypeSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",Me=(t,n,r)=>{const o=Ce.includes(n)?n:"function"==typeof t?"invalid":_e(r.value),{value:a}=r;switch(o){case"string":return e.jsx(he,{...r,value:a});case"number":return e.jsx(fe,{...r,value:a});case"boolean":return e.jsx(ye,{...r,value:a});case"null":return e.jsx(ve,{...r});default:return e.jsx(be,{...r})}},Ve=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},ze=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Ve(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Fe=r=>{const{getStyles:a}=W(),{open:s,cancel:i,submit:l,areChildrenBeingEdited:c}=Z(),{setCollapseState:u}=te(),{mainContainerRef:d,data:p,nodeData:m,parentData:f,showCollectionCount:y,canDragOnto:g,canAddHere:v,collapseFilter:b,collapseAnimationTime:j,showClipboardButton:x,onCopy:w,showIconTooltips:E,indent:C,sort:D,showArrayIndexes:O,defaultValue:T,newKeyOptions:R,translate:N,customNodeDefinitions:P,customNodeData:I,jsonParse:L,jsonStringify:K,TextEditor:_,Select:M,keyboardControls:V,handleKeyboard:z,insertAtTop:F,onCollapse:B,editConfirmRef:H,collapseClickZones:Y,getLatestData:U}=r,[$,J]=t.useState(null),X=b(m),{contentRef:Q,isAnimating:q,maxHeight:ee,collapsed:re,animateCollapse:oe,cssTransitionValue:ae}=((e,n,r,o,a)=>{const[s,i]=t.useState(r?0:void 0),[l,c]=t.useState(r),u=t.useRef(!1),d=t.useRef(null),p=t.useRef(0),m=t.useRef(0),h=n/1e3+"s",f=t.useCallback(t=>{if(l!==t){switch(window.clearTimeout(m.current),u.current=!0,t){case!0:{const e=d.current?.offsetHeight??0;p.current=e,i(e),setTimeout(()=>{i(0)},5);break}case!1:i(p.current||((e,t,n,r)=>{if(!t.current)return 0;const o=parseInt(getComputedStyle(n.current).getPropertyValue("line-height"))||16,a=(t.current?.offsetWidth??0)/(.5*o),s=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/a)).reduce((e,t)=>e+t,0)*o;return Math.min(s+30,window.innerHeight-50)})(e,d,o,a))}c(!l),m.current=window.setTimeout(()=>{u.current=!1,t||i(void 0)},n)}},[n,l,e,o,a]);return{contentRef:d,isAnimating:u.current,animateCollapse:f,maxHeight:s,collapsed:l,cssTransitionValue:h}})(p,j,X,d,K),{pathString:se,nodeData:ie,path:le,name:ue,size:de,canEdit:pe,canDelete:me,canAdd:he,canDrag:fe,error:ye,setError:ge,onError:ve,derivedValues:be,buildKeyDisplayProps:je}=Te({props:r,collapsed:re}),{dragSourceProps:Ce,getDropTargetProps:De,BottomDropTarget:Se,DropTargetPadding:ke}=Re({canDrag:fe,canDelete:me,canDragOnto:g,canAddHere:v,path:le,nodeData:ie,onError:ve,translate:N}),Ae=t.useRef(!X),{isEditing:Pe,isEditingKey:Ie,isPending:Ke,isArray:_e}=be,Me=(e=>{const n=t.useRef(e),r=!Object.is(n.current,e);return t.useEffect(()=>{n.current=e}),r})(b);t.useEffect(()=>{const e=b(ie)&&!Pe;Ae.current=!e,oe(e),Me&&u(null)},[b]),((e,n,r)=>{const{commands:o,version:a}=te(),s=t.useRef(0);t.useEffect(()=>{if(a===s.current)return;if(s.current=a,!o)return;let t;for(const n of o)ne(e,n)&&(t=n);t&&(t.collapsed||(n.current=!0),r(t.collapsed))},[a,o])})(le,Ae,oe);const Ve=t.useRef(null),ze=t.useCallback(e=>J(t=>"function"==typeof e?e(t??K(p)):e),[p,K]),Fe=t.useCallback(()=>J(null),[]),He=t.useMemo(()=>Pe?$??K(p):null,[Pe,$,p,K]),We=t.useCallback((e,t)=>{if("function"!=typeof T)return T;const n=T(e,t);return void 0!==n?n:null},[T]),Ye=t.useCallback(e=>R?"function"!=typeof R?R:R(e):null,[R]),{CustomComponent:Ue,componentProps:$e,CustomWrapperComponent:Je,wrapperProps:Xe={},showKey:Qe=!0,showEditTools:Ze=!0,showOnEdit:Ge,showOnView:qe,showCollectionWrapper:et=!0}=I,tt=G(e=>null!==e.active&&h(e.active.path,le));tt&&re&&oe(!1);const nt=ce(le)||0===ie.level,rt=t.useRef(n);if(!nt&&!tt)return null;const{visibleSize:ot}=ie,at=Array.isArray(p)?"array":"object",st="array"===at?{open:"[",close:"]"}:{open:"{",close:"}"},it=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=A(Ve,"\t");return void J(t)}z(e,{objectConfirm:ct,cancel:dt})},lt=e=>{e.stopPropagation();const t=k(e);if(t&&V.collapseModifier.includes(t))return Ae.current=!0,void u({collapsed:!re,path:le,includeChildren:!0});c(le)||(Ae.current=!0,B&&B({...ie,fullData:U(),collapsed:!re,includeChildren:!1}),oe(!re))},ct=e=>{const t=He??K(p);let n;try{n=L(t)}catch{return void ve({code:"INVALID_JSON",message:N("ERROR_INVALID_JSON",ie)},t)}ge(null);const r="function"==typeof e?e:void 0;l({op:"edit",path:le,value:n,onCommit:()=>{Fe(),r?.()}}).then(e=>{"error"===e?.status&&ve(e.error,n)})};rt.current=ct;const ut=le.length>0?()=>{l({op:"delete",path:le,instant:!0}).then(e=>{"error"===e?.status&&ve(e.error,p)})}:void 0,dt=()=>{i(),ge(null),Fe()},pt="when-collapsed"===y?re:"when-collapsed-or-filtered"===y?re||null!=ot:y,mt=!Pe&&Ze,ht=(O||!_e)&&Qe&&void 0!==ue,ft=Ue&&(Pe&&Ge||!Pe&&qe),yt=Object.entries(p).map(([e,t])=>["array"===at?Number(e):e,t]);"object"===at&&D(yt,e=>e);const gt=!Pe||!!Ue&&Ge,vt=Ae.current?gt?yt.map(([t,n],s)=>{const i={key:t,value:n,path:[...le,t],level:le.length+1,index:s,size:o(n)?Object.keys(n).length:null,parentData:p,fullData:ie.fullData},l=Oe(P,i);return e.jsx("div",{className:"jer-collection-element",style:a("collectionElement",i),children:o(n)&&!l?.renderCollectionAsValue?e.jsx(Be,{...r,data:n,parentData:p,nodeData:i,canDragOnto:pe,canAddHere:he,customNodeData:l},t):e.jsx(Le,{...r,data:n,parentData:p,nodeData:i,canDragOnto:pe,canAddHere:he,showLabel:"object"===at||O,customNodeData:l},t)},t)}):e.jsxs("div",{className:"jer-collection-text-edit"+(_?"-custom":""),children:[_?e.jsx(_,{value:He??"",onChange:J,onKeyDown:e=>z(e,{objectConfirm:ct,cancel:dt})}):e.jsx(S,{textAreaRef:Ve,className:"jer-collection-text-area",name:se,value:He??"",setValue:ze,onKeyDown:it,styles:a("input",ie)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(Ee,{onOk:ct,onCancel:dt,nodeData:ie,translate:N,showIconTooltips:E,editConfirmRef:H})})]}):null,bt=!!et&&re&&!tt;bt||(Ae.current=!0);const jt=N(re?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",ie),xt=()=>({...r,data:p,value:p,parentData:f,nodeData:ie,setValue:e=>l({op:"edit",path:le,value:e}),handleEdit:ct,handleCancel:dt,onKeyDown:it,isEditing:Pe,isPending:Ke,setIsEditing:pe?()=>s(le,{cancelOp:Fe,commitOp:e=>rt.current(e)}):n,getStyles:a,canDragOnto:pe,canAddHere:he,canEdit:pe,keyboardCommon:{}}),wt=ft?e.jsx(Ue,{componentProps:$e,...xt(),children:vt}):vt,Et=mt&&e.jsx(we,{startEdit:pe?()=>{Ae.current=!0,s(le,{cancelOp:Fe,commitOp:e=>rt.current(e)})}:void 0,handleAdd:he?e=>{u(null),oe(!1);const t=We(ie,e);if("array"===at){const e=F.array?0:p.length,n=F.array?{insert:!0}:{};return void l({op:"add",path:le,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&ve(e.error,t)})}if(e in p)return ve({code:"KEY_EXISTS",message:N("ERROR_KEY_EXISTS",ie)},e),void i();const n=F.object?{insertBefore:0}:{};l({op:"add",path:le,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&ve(e.error,t)})}:void 0,handleDelete:me?ut:void 0,showClipboardButton:x,onCopy:w,type:at,nodeData:ie,translate:N,customButtons:r.customButtons,keyboardControls:V,handleKeyboard:z,getNewKeyOptions:Ye,editConfirmRef:H,jsonStringify:K,showIconTooltips:E,Select:M}),Ct=je({handleCancel:dt,getStyles:a,keyValueArray:yt,handleClick:Y.includes("property")?lt:e=>e.stopPropagation()}),Dt=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===le.length?0:C/2)+"em",...a("collection",ie),position:"relative"},draggable:fe&&!Pe&&!Ie&&!tt,...Ce,...De("above"),children:[e.jsx("div",{className:"jer-clickzone",style:{width:C/2+1+"em",zIndex:10+2*ie.level},onClick:Y.includes("left")?lt:void 0}),!Pe&&Se,e.jsx(ke,{position:"above",nodeData:ie}),et?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",ie),position:"relative"},onClick:Y.includes("header")?lt:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(re?" jer-rotate-90":""),style:{zIndex:11+2*ie.level,transition:ae},onClick:lt,tabIndex:-1,"aria-expanded":!re,"aria-label":jt,title:E?jt:"",children:e.jsx(xe,{name:"collection",nodeData:ie})}),ht&&e.jsx(Ne,{...Ct}),!Pe&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:a("bracket",ie),children:st.open})]}),!1!==y&&!Pe&&e.jsx("div",{className:"jer-collection-item-count"+(pt?" jer-visible":" jer-hidden"),style:{...a("itemCount",ie),transition:ae,transitionBehavior:"allow-discrete"},children:null!=ot&&ot!==de?N("ITEMS_FILTERED",ie,{visible:ot,total:de}):1===de?N("ITEM_SINGLE",{...ie,size:1},1):N("ITEMS_MULTIPLE",ie,de)}),e.jsx("div",{className:"jer-brackets"+(bt?" jer-visible":" jer-hidden"),style:{...a("bracket",ie),transition:ae},children:st.close}),Et]}):Qe?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",ie),position:"relative"},children:[e.jsx(Ne,{...Ct}),Et]}):e.jsx(e.Fragment,{}),e.jsxs("div",{className:"jer-collection-inner",style:{overflowY:bt||q?"clip":"visible",maxHeight:tt?void 0:ee,...a("collectionInner",ie),transition:ae},ref:Q,children:[wt,e.jsx("div",{className:Pe?"jer-collection-error-row-edit":"jer-collection-error-row",children:ye&&e.jsx("span",{className:"jer-error-slug",style:a("error",ie),children:ye})}),!Pe&&et&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:a("bracket",ie),children:st.close})]}),e.jsx(ke,{position:"below",nodeData:ie})]});return Je?e.jsx(Je,{wrapperProps:Xe,...xt(),children:Dt}):Dt},Be=/*#__PURE__*/t.memo(Fe,Pe),He=({options:t,value:n,defaultValue:r,onChange:o,placeholder:a,className:s,...i})=>{const l=void 0!==n?{value:n}:{defaultValue:r??""};return e.jsxs("div",{className:"jer-select",children:[e.jsxs("select",{className:s??"jer-select-inner",onChange:e=>o(e.target.value),...i,...l,children:[void 0!==a&&e.jsx("option",{value:"",disabled:!0,children:a}),t.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx("span",{className:"focus"})]})},We=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},Ye=({key:e,path:t},n="")=>!!We({value:e},n)||!!t.some(e=>We({value:e},n)),Ue={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",SHOW_MORE:"Show more",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel",TOOLTIP_COLLAPSE:"Collapse",TOOLTIP_EXPAND:"Expand"};var $e=':host,:root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff;--jer-icon-copy-color:#268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{left:-1.2em;position:absolute;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;font-family:inherit;font-size:.85em;line-height:1.25em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row-edit{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-string-expansion.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em;margin-right:.2em}.jer-confirm-buttons>button,.jer-edit-buttons>button,button.jer-collapse-icon,button.jer-string-expansion{appearance:none;background:none;border:none;color:inherit;font:inherit;margin:0;padding:0;vertical-align:baseline}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #b4b4b4;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}';const Je="data-jer-styles",Xe=(e,t)=>JSON.stringify(e,t,2),Qe={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},Ze={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},Ge=e=>{const n=t.useRef(e);e&&(n.current=e);const r=t.useRef((...e)=>n.current(...e));return e?r.current:void 0},qe=[],et=["header","left"],tt={},nt={},rt={},ot=[],at=({data:i,setData:c,buildNodeDataFromPathRef:u,commitRef:d,rootName:m="root",onUpdate:h=n,onChange:f,onError:y,onEditEvent:g,showErrorMessages:v=!0,showClipboardButton:b=!0,onCopy:j,indent:x=2,collapse:E=3,collapseAnimationTime:D=300,showCollectionCount:S="when-collapsed-or-filtered",allowEdit:k=!0,allowDelete:T=!0,allowAdd:A=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:L,searchText:K,searchDebounceTime:_=350,sortKeys:M=!1,showArrayIndexes:V=!0,arrayIndexStart:z=0,showStringQuotes:F=!0,showIconTooltips:B=!1,defaultValue:H=null,newKeyOptions:Y,minWidth:U=250,maxWidth:$="min(600px, 90vw)",baseFontSize:J,stringTruncateLength:X=250,translations:Q=tt,className:G,id:q,customText:ee=nt,customNodeDefinitions:ne=qe,customButtons:re=ot,jsonParse:oe=JSON.parse,jsonStringify:ae=Xe,TextEditor:se,Select:le=He,errorDisplayTime:ce=2500,keyboardControls:ue=rt,editorRef:de,insertAtTop:pe=!1,onCollapse:me,collapseClickZones:he=et})=>{const{getStyles:fe,cssVars:ye}=W(),{open:ge,cancel:ve,getSnapshot:be}=Z(),je=t.useMemo(()=>lt(E),[E]),xe=t.useMemo(()=>((e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}let s=r in e?e[r]:Ue[r];if(void 0!==o){const e=a(o)?o:{count:o};for(const[t,n]of Object.entries(e))s=s?.replace(`{{${t}}}`,String(n))}return s})(e,t,r,n,o))(Q,ee),[Q,ee]),[we,Ee]=t.useState(K),Ce=t.useRef(null);t.useEffect(()=>{ve();const e=setTimeout(()=>Ee(K),_);return()=>clearTimeout(e)},[K,_]);const De=C(i,[],m),Se=t.useRef(i);Se.current=i;const ke=t.useRef(c);ke.current=c;const Te=t.useRef(xe);Te.current=xe;const Re=t.useRef(De);Re.current=De;const Ne=t.useRef(h);Ne.current=h;const Ae=t.useRef(m);Ae.current=m;const Pe=t.useRef(void 0),Ie=t.useCallback(()=>Se.current,[]),Ke=Ge(f),_e=Ge(y),Me=Ge(me),Ve=Ge(g),ze=Ge(j),Fe=t.useCallback(e=>{Se.current=e,ke.current(e)},[]),Ye=t.useCallback((e,t)=>{Fe(it(Se.current,e,t,"update").newData)},[Fe]),$e=t.useCallback(e=>{const t=Se.current,n=Ae.current,r=Pe.current,o=Fe,{op:a,path:s}=e;switch(a){case"edit":{const{newData:a,currentValue:i,newValue:l}=it(t,s,e.value,"update"),c=C(t,s,n,r);return{input:{...c,newData:a,event:"edit",newValue:l},nodeData:c,isNoOp:i===l,apply:()=>o(a),revert:()=>o(it(Se.current,s,i,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=it(t,s,"","delete"),i=C(t,s,n,r);return{input:{...i,newData:e,event:"delete"},nodeData:i,isNoOp:!1,apply:()=>o(e),revert:()=>o(it(Se.current,s,a,"add",{insert:!0,insertBefore:i.index}).newData)}}case"add":{const a=[...s,e.key],{newData:i,newValue:l}=it(t,a,e.value,"add",e.options),c=C(i,a,n,r);return{input:{...c,value:void 0,size:null,parentData:w(t,s)??null,fullData:t,newData:i,event:"add",newValue:l},nodeData:c,isNoOp:!1,apply:()=>o(i),revert:()=>o(it(Se.current,a,"","delete").newData)}}case"rename":{const a=s.slice(0,-1),i=s[s.length-1],{newKey:l}=e,c=w(t,a),u=Object.fromEntries(Object.entries(c).map(([e,t])=>e===i?[l,t]:[e,t])),{newData:d}=it(t,a,u,"update"),p=C(t,s,n,r);return{input:{...p,newData:d,event:"rename",newKey:l},nodeData:p,isNoOp:i===l,apply:()=>o(d),revert:()=>o(it(Se.current,a,c,"update").newData),extra:{oldKey:i,newKey:l}}}case"move":{const a=s,{path:i,position:l}=e.to,c=t,{newData:u,currentValue:d}=it(t,a,"","delete"),p=a.slice(-1)[0],m=i.slice(0,-1),h=i.slice(-1)[0];let f="number"==typeof h?"above"===l?h:h+1:"number"==typeof p?`arr_${p}`:p;a.slice(0,-1).join(".")===i.slice(0,-1).join(".")&&"number"==typeof p&&"number"==typeof f&&p<f&&(f-=1);const y="number"==typeof f?{insert:!0}:"above"===l?{insertBefore:h}:{insertAfter:h},g=[...m,f],{newData:v}=it(u,g,d,"add",y),b=C(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Fe]),Je=t.useCallback((e,t)=>{const n=Ze[e.event],r=()=>Te.current(Qe[e.event],Re.current),o=e=>{const t=e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r();return{status:"error",error:{code:n,message:t}}},a=t=>{if(!1===t)return{status:"error",error:{code:n,message:r()}};if(null===t)return{status:"cancel"};if(t&&"object"==typeof t){if(void 0!==t.error)return"string"==typeof t.error?{status:"error",error:{code:n,message:t.error}}:{status:"error",error:t.error};const r=void 0!==t.data,o=void 0!==t.value;if(r&&o&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),r)return{status:"override",value:t.data,path:[]};if(o&&("edit"===e.event||"add"===e.event))return{status:"override",value:t.value,path:e.path}}return{status:"commit"}};let i;try{i=Ne.current(e,t)}catch(e){return o(e)}return s(i)?i.then(a,o):a(i)},[]),at=t.useMemo(()=>({runUpdate:h===n?void 0:Je,buildCommit:$e,applyValue:Ye}),[Je,$e,Ye,h]);d.current=at;const st=t.useMemo(()=>lt(k),[k]),dt=t.useMemo(()=>lt(T),[T]),pt=t.useMemo(()=>lt(A),[A]),mt=t.useMemo(()=>lt(I),[I]),ht=t.useMemo(()=>ct(L),[L]),ft=t.useMemo(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,a=new Map,s=t??We,i=n??"",l=e=>{let t=s(e,i);if(o(e.value)){let n=0;const r=Array.isArray(e.value),s=Object.entries(e.value);for(const[a,i]of s){const s=r?Number(a):a,c={key:s,path:[...e.path,s],level:e.level+1,index:n,value:i,size:o(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(c)&&(t=!0,n++)}a.set(p(e.path),n)}return t&&r.add(p(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:a}})(De,ht,we),[i,we,ht,m]),yt=t.useMemo(()=>(e=>{const t={...R};for(const n of Object.keys(R)){const o=n,a=e[o];if(void 0===a)continue;const s="clipboardModifier"===n||"collapseModifier"===n;if(null===a){t[o]=s?[]:null;continue}const i=(()=>s?r(a):"string"==typeof a?{key:a}:a)();t[o]=i}return N.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(ue),[ue]),gt=t.useCallback((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(O(n,e[r],r)){n.preventDefault(),o();break}})(yt,t,e),[yt]),vt=t.useMemo(()=>{const e=ut(ne,"stringifyReplacer");return t=>ae(t,e)},[ne,ae]),bt=t.useMemo(()=>{const e=ut(ne,"parseReviver");return t=>{const n=oe(t,e);return l(n)}},[ne,oe]),jt=t.useRef(null),{setCollapseState:xt}=te(),wt=t.useCallback((e,t)=>{!1!==M&&("function"!=typeof M?e.sort((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0}):e.sort((e,n)=>M(t(e),t(n))))},[M]);Pe.current=wt;const Et=t.useCallback(e=>C(Ie(),e,Ae.current,Pe.current),[Ie]);u.current=Et,t.useImperativeHandle(de,()=>{const e=Symbol("path-missing");return{collapse:e=>xt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>w(Ie(),t,e)===e?"PATH_NOT_FOUND":n||st(C(Ie(),t,m,wt))?(ge(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{jt.current&&(jt.current.click(),"editing"!==be().active?.phase&&ve())},cancel:()=>ve()}},[xt,ge,ve,be,st,Ie,m,wt]);const Ct=Oe(ne,De),Dt=t.useMemo(()=>({object:!0===pe||"object"===pe,array:!0===pe||"array"===pe}),[pe]),St={mainContainerRef:Ce,name:m,nodeData:De,getLatestData:Ie,onChange:Ke,onError:_e,onEditEvent:Ve,showErrorMessages:v,showCollectionCount:S,collapseFilter:je,collapseAnimationTime:D,allowEditFilter:st,allowDeleteFilter:dt,allowAddFilter:pt,allowTypeSelection:P,allowDragFilter:mt,canDragOnto:!1,canAddHere:!1,showClipboardButton:b,onCopy:ze,sortKeys:M,sort:wt,showArrayIndexes:V,arrayIndexStart:z,showStringQuotes:F,showIconTooltips:B,indent:x,defaultValue:H,newKeyOptions:Y,stringTruncateLength:X,translate:xe,customNodeDefinitions:ne,customNodeData:Ct,customButtons:re,parentData:null,jsonParse:bt,jsonStringify:vt,TextEditor:se,Select:le,errorDisplayTime:ce,handleKeyboard:gt,keyboardControls:yt,insertAtTop:Dt,onCollapse:Me,editConfirmRef:jt,collapseClickZones:he},kt={...fe("container",De),...ye,minWidth:U,maxWidth:$};return kt.fontSize=J??kt.fontSize,e.jsx("div",{id:q,ref:Ce,className:`jer-editor-container ${G??""}`,style:kt,children:e.jsx(ie,{value:ft,children:o(i)&&!Ct.renderCollectionAsValue?e.jsx(Be,{data:i,...St}):e.jsx(Le,{data:i,showLabel:!0,...St})})})};function st(n){t.useInsertionEffect(()=>{(()=>{if("undefined"==typeof document)return;const e=document.head.querySelector(`style[${Je}]`);if(e)return void(e.textContent!==$e&&(e.textContent=$e));const t=document.createElement("style");t.setAttribute(Je,""),t.textContent=$e,document.head.appendChild(t)})()},[]);const r=t.useRef(void 0),o=t.useRef(void 0),a=n;return e.jsx(H,{theme:a.theme??_,children:e.jsx(ae,{onEditEvent:a.onEditEvent,onCollapse:a.onCollapse,buildNodeDataFromPathRef:r,commitRef:o,children:e.jsx(at,{...a,buildNodeDataFromPathRef:r,commitRef:o})})})}const it=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},s="add"!==r?w(e,t):void 0;return{currentData:e,newData:v(e,t,n,a),currentValue:s,newValue:"delete"!==r?n:void 0}},lt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,ct=e=>{if(void 0!==e)return"value"===e?We:"key"===e?Ye:"all"===e?(e,t)=>We(e,t)||Ye(e,t):e},ut=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?c:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}};exports.AutogrowTextArea=S,exports.IconSvg=je,exports.JsonEditor=st,exports.JsonViewer=function(r){const{editorRef:o,...a}=r,s=t.useRef(null);return t.useImperativeHandle(o,()=>({collapse:e=>s.current?.collapse(e)}),[]),e.jsx(st,{...a,editorRef:s,setData:n,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})},exports.StringDisplay=pe,exports.StringEdit=me,exports.assign=v,exports.collectionDataTypes=De,exports.defaultTheme=_,exports.extract=w,exports.isCollection=o,exports.matchNode=We,exports.matchNodeKey=Ye,exports.splitPropertyString=u,exports.standardDataTypes=Se,exports.toPathString=p,exports.useKeyboardListener=ge,exports.valueDataTypes=Ce;
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React$1, {
|
|
1
|
+
import React$1, { SVGProps } from 'react';
|
|
2
2
|
|
|
3
3
|
declare const localisedStrings: {
|
|
4
4
|
ITEM_SINGLE: string;
|
|
@@ -16,6 +16,7 @@ declare const localisedStrings: {
|
|
|
16
16
|
ERROR_MOVE: string;
|
|
17
17
|
DEFAULT_NEW_KEY: string;
|
|
18
18
|
SHOW_LESS: string;
|
|
19
|
+
SHOW_MORE: string;
|
|
19
20
|
EMPTY_STRING: string;
|
|
20
21
|
TOOLTIP_COPY: string;
|
|
21
22
|
TOOLTIP_EDIT: string;
|
|
@@ -23,6 +24,8 @@ declare const localisedStrings: {
|
|
|
23
24
|
TOOLTIP_ADD: string;
|
|
24
25
|
TOOLTIP_OK: string;
|
|
25
26
|
TOOLTIP_CANCEL: string;
|
|
27
|
+
TOOLTIP_COLLAPSE: string;
|
|
28
|
+
TOOLTIP_EXPAND: string;
|
|
26
29
|
};
|
|
27
30
|
type LocalisedStrings = typeof localisedStrings;
|
|
28
31
|
type TranslateFunction = (key: keyof LocalisedStrings, customData: NodeData, counts?: number | Record<string, string | number>) => string;
|
|
@@ -303,6 +306,7 @@ interface BaseNodeProps {
|
|
|
303
306
|
allowAddFilter: FilterFunction;
|
|
304
307
|
allowDragFilter: FilterFunction;
|
|
305
308
|
canDragOnto: boolean;
|
|
309
|
+
canAddHere: boolean;
|
|
306
310
|
allowTypeSelection: boolean | TypeOptions | TypeFilterFunction;
|
|
307
311
|
stringTruncateLength: number;
|
|
308
312
|
indent: number;
|
|
@@ -369,9 +373,9 @@ interface CustomComponentProps<T = Record<string, unknown>> extends Omit<BaseNod
|
|
|
369
373
|
isPending: boolean;
|
|
370
374
|
setIsEditing: React.Dispatch<React.SetStateAction<boolean>>;
|
|
371
375
|
getStyles: (element: ThemeableElement, nodeData: NodeData) => React.CSSProperties;
|
|
372
|
-
children?: JSX.Element | JSX.Element[] | null;
|
|
373
|
-
originalNode?: JSX.Element;
|
|
374
|
-
originalNodeKey?: JSX.Element;
|
|
376
|
+
children?: React.JSX.Element | React.JSX.Element[] | null;
|
|
377
|
+
originalNode?: React.JSX.Element;
|
|
378
|
+
originalNodeKey?: React.JSX.Element;
|
|
375
379
|
canEdit: boolean;
|
|
376
380
|
keyboardCommon: Partial<Record<keyof KeyboardControlsFull, () => void>>;
|
|
377
381
|
}
|
|
@@ -409,8 +413,9 @@ interface CustomButtonDefinition {
|
|
|
409
413
|
nodeData: NodeData;
|
|
410
414
|
}>;
|
|
411
415
|
onClick: (nodeData: NodeData, e: React.MouseEvent) => void;
|
|
416
|
+
label?: string;
|
|
412
417
|
}
|
|
413
|
-
type ThemeableElement = 'container' | 'collection' | 'collectionElement' | 'headerRow' | 'valueRow' | 'dropZone' | 'property' | 'bracket' | 'itemCount' | 'string' | 'number' | 'boolean' | 'null' | 'input' | 'inputHighlight' | 'error' | 'iconCollection' | 'iconEdit' | 'iconDelete' | 'iconAdd' | 'iconCopy' | 'iconOk' | 'iconCancel';
|
|
418
|
+
type ThemeableElement = 'container' | 'collection' | 'collectionInner' | 'collectionElement' | 'headerRow' | 'valueRow' | 'dropZone' | 'property' | 'bracket' | 'itemCount' | 'string' | 'number' | 'boolean' | 'null' | 'input' | 'inputHighlight' | 'error' | 'iconCollection' | 'iconEdit' | 'iconDelete' | 'iconAdd' | 'iconCopy' | 'iconOk' | 'iconCancel';
|
|
414
419
|
type StyleFunction = (nodeData: NodeData) => React.CSSProperties | null | undefined;
|
|
415
420
|
type ThemeValueUnit = string | React.CSSProperties | StyleFunction;
|
|
416
421
|
type ThemeElementValue = ThemeValueUnit | ThemeValueUnit[];
|
|
@@ -456,6 +461,7 @@ interface StringDisplayProps {
|
|
|
456
461
|
canEdit: boolean;
|
|
457
462
|
setIsEditing: (value: React$1.SetStateAction<boolean>) => void;
|
|
458
463
|
translate: TranslateFunction;
|
|
464
|
+
showIconTooltips?: boolean;
|
|
459
465
|
value?: string;
|
|
460
466
|
TextWrapper?: React$1.ComponentType<{
|
|
461
467
|
children: React$1.ReactNode;
|
|
@@ -487,7 +493,7 @@ declare const AutogrowTextArea: React$1.FC<TextAreaProps>;
|
|
|
487
493
|
|
|
488
494
|
declare const IconSvg: ({ scale, viewBox, fill, children, ...props }: {
|
|
489
495
|
scale?: number;
|
|
490
|
-
} & Omit<SVGProps<SVGSVGElement>, "scale">) => JSX.Element;
|
|
496
|
+
} & Omit<SVGProps<SVGSVGElement>, "scale">) => React.JSX.Element;
|
|
491
497
|
|
|
492
498
|
declare const matchNode: (input: Partial<NodeData>, searchText: string) => boolean;
|
|
493
499
|
declare const matchNodeKey: SearchFilterFunction;
|
package/build/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useLayoutEffect as o,useEffect as a,useRef as i,createContext as l,useContext as s,useMemo as c,useCallback as d,useSyncExternalStore as u,useState as p,useImperativeHandle as h}from"react";const m=()=>{},f=e=>Array.isArray(e)?e:[e],y=e=>null!==e&&"object"==typeof e,g=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),v=(e,t)=>{if("string"!=typeof e)return null;const n=t.filter(t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority);return n.sort((e,t)=>(t.matchPriority??0)-(e.matchPriority??0)),n[0]??null},b=e=>{if(e!==w){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=b(n);r!==n&&(e[t]=r)}return e}},w="__undefined__",E=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),D=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),C=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),j=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),S=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),k=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},O=e=>Array.isArray(e),T=(e,t)=>e.filter((e,n)=>n!==t),N=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:i=!1}=r,l=e,s=D(t),c={...r,remove:o,createNew:a,noError:i,fullData:l,fullPath:s},d=Array.isArray(t)?t:E(t);return O(e)&&o&&1===d.length?T(e,d[0]):x(e,d,n,c)},x=(e,t,n,r)=>{const o=g(e)?{...e}:null,a=O(e)?[...e]:null;if(0===t.length)return e;if(!o&&!a)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:s,fullData:c,fullPath:d}=r,u=t[0];if(a&&"string"==typeof u)return a.map(e=>x(e,t,n,r));if(1===t.length){if(o&&"string"==typeof u){return R(o,u,n,r)??o}return a&&"number"==typeof u?(P(a,u,n,r),a):(k(c,d,u,s),e)}const p=o||a||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=p[u],n=t[1];return O(e)?p[u]=T(e,n):k(c,d,u,s,"Trying to remove an indexed item from an object that is not an array"),p}const h=t.slice(1);if(u in e){if(m=p[u],!O(m)&&!g(m)){if(!i)return k(c,d,u,s),p;p[u]={}}return p[u]=x(p[u],h,n,r),p}var m;if(i){const e="number"==typeof h[0]?[]:{};if(o)return p[u]=e,p[u]=x(p[u],h,n,r),p;if(a&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=x(p[t],h,n,r),p}}return k(c,d,u,s),p},R=(e,t,n,r)=>{const{remove:o,createNew:a,noError:i,insertAfter:l,insertBefore:s,fullData:c,fullPath:d}=r;if(void 0!==s||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof s?s:"number"==typeof l?l:r.findIndex(([e])=>e===(s??l)),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const u=t in e;o?u?delete e[t]:k(c,d,t,i):a||u?e[t]=n:k(c,d,t,i)},P=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:i,createNew:l,insert:s}=r;s&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):k(a,i,t,o)},A=(e,t,n)=>{const r=Array.isArray(t)?t:E(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>A(e,r,n));if("object"!=typeof e||null===e||!(o in e))return I(e,o,n);const a=e[o];return 1===r.length?a:A(a,r.slice(1),n)},I=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},K=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:y(e)?Object.keys(e).length:1,parentData:null,fullData:e};const o=t[t.length-1],a=A(e,t),i=A(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof o?o:Number(o);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===o)}return{key:o,path:t,level:t.length,index:l,value:a,size:y(a)?Object.keys(a).length:null,parentData:i,fullData:e}},L="undefined"!=typeof window?o:a,_=({className:n,name:r,value:o,setValue:a,onKeyDown:l,styles:s,textAreaRef:c})=>{const d=i(null);if(L(()=>{const e=d.current;d.current=null;const t=c?.current;if(!e||!t)return;const n=e.start+o.length-e.sourceLength,r=Math.max(0,Math.min(n,o.length));t.selectionStart!==r&&t.setSelectionRange(r,r)},[o,c]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:c,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...s},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;d.current=null!==n&&n<t.length?{start:n,sourceLength:t.length}:null,a(t)},autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:l}),t("span",{className:n,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...s},children:u})]})},V=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,M=(e,t,n)=>{if(!t)return!1;const r=e.key,o=V(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:i}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!i?.includes("Shift"))&&(r===a&&(i===o||Array.isArray(i)&&i.includes(o)))},z={key:"Enter"},F={confirm:z,cancel:{key:"Escape"},objectConfirm:{...z,modifier:["Meta","Shift","Control"]},objectLineBreak:z,stringConfirm:z,stringLineBreak:{...z,modifier:["Shift"]},numberConfirm:z,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:z,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},B=["stringConfirm","numberConfirm","booleanConfirm"],Y=(e,t)=>{const n=e.current,r=n.selectionStart??1/0,o=n.selectionEnd??1/0,a=n.value.slice(0,r)+t+n.value.slice(o);return n.value=a,n.setSelectionRange(r+1,r+1),a},U=(e,t,n="next",r,o)=>{const a=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=A(e,a),s=$(l);Array.isArray(l)||r(s,({key:e,value:t})=>[e,t]);const c=s.findIndex(e=>e.key===i),d=s[c+("next"===n?1:-1)];if(!d)return 0===a.length?null:U(e,a,n,r,o);let u;if(y(d.value)){if(0===Object.keys(d.value).length)return U(e,[...a,d.key],n,r,o);u=W(e,[...a,d.key],n,r)}else u=[...a,d.key];return u?o(K(e,u,"",r))?u:U(e,u,n,r,o):null},W=(e,t,n="next",r)=>{const o=A(e,t);if(!y(o))return t;const a=Array.isArray(o)?o.map((e,t)=>t):Object.keys(o);r(a,e=>[e,o]);const i="next"===n?a[0]:a[a.length-1];return W(e,[...t,i],n,r)},$=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),H={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},J={displayName:"Default",icons:{add:{content:e(n,{children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:e(n,{children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:t("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:e(n,{children:[t("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),t("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:H,scale:.86},ok:{content:e(n,{children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:H,scale:.9},cancel:{content:t("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:t("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},X={container:"backgroundColor",collection:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},Q=e=>[J,...f(e)].map(e=>"styles"in e?e:{styles:e}),Z=e=>{const t={};for(const{icons:n}of Q(e))n&&Object.assign(t,n);return t},G=l({getStyles:()=>({}),icons:Z(J),cssVars:{}}),q=({theme:e=J,children:n})=>{const r=c(()=>(e=>{var t;const n=Q(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[X[a]??"color"]:t}:t}}}for(const e in o)r[t=e]??(r[t]={});const a={};for(const e in r){const t=e,n=r[t],i=o[t];a[t]=i?e=>i.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(e),[e]),o=c(()=>Z(e),[e]),a=c(()=>(e=>{const{inputHighlight:t,iconCopy:n}=e,r={};return"function"!=typeof t&&t?.backgroundColor&&(r["--jer-highlight-color"]=t.backgroundColor),"function"!=typeof n&&n?.color&&(r["--jer-icon-copy-color"]=n.color),r})(r),[r]),i=d((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(r,e,t),[r]),l=c(()=>({getStyles:i,icons:o,cssVars:a}),[i,o,a]);return t(G.Provider,{value:l,children:n})},ee=()=>s(G),te={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},ne=(e,t)=>te[e][t]??null,re=(e,t)=>null!==e&&null!==t&&e.op===t.op&&j(e.path,t.path),oe={active:null,settling:{}},ae=(e,t,n)=>{let r=oe;const o=new Set;let a=null,i=null,l=!1,s=0;const c=e=>{r=e,o.forEach(e=>e())},d=(t,n,r)=>{e.current?.({...t,...r,event:n})},u=(n,o,l)=>{if(!e.current)return;let s;try{s=t.current?.(n)}catch{return c({...r,active:null}),a=null,void(i=null)}s&&d(s,o,l)},p=(e,t)=>{var n;a=t?.cancelOp??null,i=t?.commitOp??null,n=e,re(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=ne(e.op,"start");o&&u(e.path,o)},h=(e,t,o,l,s,u,p,h,m)=>{const f=C(e);if(!p()){if("cancel"===l.status||"error"===l.status){"held"===r.active?.phase&&j(r.active.path,e)&&(c({...r,active:null}),a=null,i=null);const n=ne(t,"cancel");return n&&d(h,n),"error"===l.status&&d(h,"updateError",{operation:t,error:l.error}),l}s()}if(r.settling[f]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],c({...r,settling:t})})(f),l.status){case"cancel":u();break;case"error":u(),d(h,"updateError",{operation:t,error:l.error});break;case"override":n.current?.applyValue(l.path,l.value),d(h,"updateSuccess",{operation:t,...m});break;case"commit":d(h,"updateSuccess",{operation:t,...m})}return l}};return{subscribe:e=>(o.add(e),()=>o.delete(e)),getSnapshot:()=>r,getServerSnapshot:()=>r,open:(e,t)=>{if("held"===r.active?.phase)return;const n={path:e,op:t?.op??"edit",phase:"editing",force:t?.force},o=r.active,l=null!==o&&!re(o,n);if(l&&i)return void i(()=>p(n,t));const s=a;if(a=null,i=null,s&&s(),l&&re(r.active,o)){const e=ne(o.op,"cancel");e&&u(o.path,e)}p(n,t)},cancel:()=>{if(l)return;if("held"===r.active?.phase)return;const e=r.active;l=!0;try{const t=a;if(a=null,i=null,t&&t(),null!==e){null!==r.active&&c({...r,active:null});const t=ne(e.op,"cancel");t&&u(e.path,t)}}finally{l=!1}},submit:e=>{const{op:t,path:o,instant:l,onCommit:p}=e,m=n.current;let f;try{f=m?.buildCommit(e)??null}catch{return re(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null,p?.(),Promise.resolve(void 0)}const y=f?.extra,g=C(o),v=++s;if(!l){const e=ne(t,"submit");e&&u(o,e)}if(!f||f.isNoOp){re(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null;const e=ne(t,"commit");return e&&(f?d(f.nodeData,e,y):u(o,e,y)),p?.(),Promise.resolve(void 0)}const{input:b,nodeData:w,apply:E,revert:D}=f,j=!!m?.runUpdate;let S=!1,k=!1;const O=()=>{if(S)return;S=!0,E(),a=null,i=null,re(r.active,{path:o,op:t})&&c({...r,active:null}),j&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(g,v);const e=ne(t,"commit");e&&d(w,e,y),p?.()},T={hold:()=>(k=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>O())};if(!j)return O(),Promise.resolve(void 0);const N=m.runUpdate(b,T);let x;return k||(l?x=setTimeout(O,100):O()),N.then(e=>(clearTimeout(x),h(o,t,v,e,O,D,()=>S,w,y)))},areChildrenBeingEdited:e=>null!==r.active&&S(r.active.path,e)}},ie=l(null),le=({children:e,onEditEvent:n,buildNodeDataFromPathRef:r,commitRef:o})=>{const a=i(n);a.current=n;const l=i(null);return null===l.current&&(l.current=ae(a,r,o)),t(ie.Provider,{value:l.current,children:e})},se=()=>{const e=s(ie);if(!e)throw new Error("Missing Editing Context Provider");return e},ce=e=>{const t=se();return u(t.subscribe,()=>e(t.getSnapshot()),()=>e(t.getServerSnapshot()))},de=l(null),ue=({children:e,onCollapse:n,buildNodeDataFromPathRef:r})=>{const[o,a]=p({commands:null,version:0}),l=i(n);l.current=n;const s=d(e=>{if(null===e)return void a(e=>null===e.commands?e:{commands:null,version:e.version});const t=f(e),n=t.map(e=>({...e,path:[...e.path]}));a(e=>({commands:n,version:e.version+1}));const o=l.current;o&&t.forEach(e=>{const t=r.current?.(e.path);t&&o({...t,collapsed:e.collapsed,includeChildren:e.includeChildren})})},[r]),u=c(()=>({commands:o.commands,version:o.version,setCollapseState:s}),[o.commands,o.version,s]);return t(de.Provider,{value:u,children:e})},pe=()=>{const e=s(de);if(!e)throw new Error("Missing Collapse Context Provider");return e},he=(e,t)=>{if(!t.includeChildren)return t.path.length===e.length&&t.path.every((t,n)=>e[n]===t);for(const[n,r]of t.path.entries())if(r!==e[n])return!1;return!0},me=l(null),fe=({children:e})=>{const[n,r]=p({path:null}),o=i(!1),a=c(()=>({dragSource:n,setDragSource:r,armed:o}),[n]);return t(me.Provider,{value:a,children:e})},ye=({children:e,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>t(le,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:t(ue,{onCollapse:r,buildNodeDataFromPathRef:o,children:t(fe,{children:e})})}),ge=l(void 0),ve=({value:e,children:n})=>t(ge.Provider,{value:e,children:n}),be=()=>{const e=s(ge);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},we=e=>{const t=be();return null===t||t.visiblePaths.has(C(e))},Ee=e=>{const t=be();return null===t?null:t.visibleChildCounts.get(C(e))??null},De="**INVALID_FUNCTION**",Ce=({nodeData:r,showStringQuotes:o=!0,stringTruncateLength:a=200,pathString:i,canEdit:l,setIsEditing:s,styles:c,translate:d,value:u,TextWrapper:h=({children:e})=>e})=>{const m=u??r.value,[f,y]=p(!1),g=o?'"':"",v=m.length>a,b=()=>{l?s(!0):y(!f)};return e("div",{id:`${i}_display`,onDoubleClick:b,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&b()},className:"jer-value-string",style:c,children:[g,v?e(n,f?{children:[t(h,{children:e("span",{children:[m,g]})}),e("span",{className:"jer-string-expansion jer-show-less",onClick:()=>y(!1),children:[" ",d("SHOW_LESS",r)]})]}:{children:[e(h,{children:[t("span",{children:m.slice(0,a-2).trimEnd()})," "]}),t("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>y(!0),children:"..."}),g]}):t(h,{children:`${m}${g}`})]})},je=({styles:e,pathString:n,value:r,setValue:o,handleEdit:a,handleKeyboard:l,keyboardCommon:s})=>{const c=i(null);return t(_,{className:"jer-input-text",textAreaRef:c,name:n,value:r,setValue:o,onKeyDown:e=>{l(e,{stringConfirm:a,stringLineBreak:()=>{const e=Y(c,"\n");o(e)},...s})},styles:e})},Se=({isEditing:e,path:n,enumType:r,...o})=>{const{getStyles:a}=ee(),i=C(n),{value:l,setValue:s,nodeData:c,handleEdit:d,handleKeyboard:u,keyboardCommon:p,Select:h}=o;return e&&r?t(h,{name:`${i}-value-select`,value:l,onChange:s,options:r.values,autoFocus:!0,onKeyDown:e=>u(e,{stringConfirm:d,...p})}):e?t(je,{styles:a("input",c),pathString:i,...o,setValue:o.setValue}):t(Ce,{pathString:i,styles:a("string",c),...o})},ke=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ee();return r?t("input",{className:"jer-input-number",type:"text",name:C(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:t=>s(t,{numberConfirm:i,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1),...c}),style:{width:String(e).length/1.5+2+"em",...d("input",l)}}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:d("number",l),children:e})},Oe=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ee();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:C(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,{booleanConfirm:i,booleanToggle:()=>n(!e),...c})},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},Te=(e,t)=>{const n=i(void 0),r=i(t);a(()=>{r.current=t},[t]);const o=e=>{r.current(e)};a(()=>{if(window.clearTimeout(n.current),e)return n.current=window.setTimeout(()=>{window.addEventListener("keydown",o)},100),()=>{window.clearTimeout(n.current),window.removeEventListener("keydown",o)}},[e])},Ne=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:l})=>{const{getStyles:s}=ee();return Te(n,e=>i(e,{confirm:o,...l})),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",a),children:String(e)})},xe=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===De&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},Re=({scale:e=1,viewBox:n="0 0 24 24",fill:r="currentColor",children:o,...a})=>{const i=1.4*e+"em";return t("svg",{viewBox:n,fill:r,width:i,height:i,...a,children:o})},Pe=({name:e,nodeData:n})=>{const{getStyles:r,icons:o}=ee(),a=o[e],i=`icon${e[0].toUpperCase()}${e.slice(1)}`;return t(Re,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===e?void 0:"jer-icon",style:r(i,n),children:a.content})},Ae=({startEdit:r,handleDelete:o,handleAdd:a,showClipboardButton:i,onCopy:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:h,handleKeyboard:m,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:w}=ee(),{open:E,cancel:C}=se(),S=u("KEY_NEW",d),[k,O]=p(S),[T,N]=p(!1),{path:x,value:R}=d,P=ce(e=>{const t=e.active;return null!==t&&"add"===t.op&&j(t.path,x)}),I=Array.isArray(T);L(()=>{if(!P)return N(!1),void O(S);const e=Object.keys(A(d.fullData,x)),t=y?y(d)?.filter(t=>!e.includes(t)):null;t&&O(""),N(t??!0)},[P]);const K=()=>{a&&(I&&!k||a("array"===s?"":k))};return e("div",{className:"jer-edit-buttons",style:{opacity:P?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&t("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",a=null;if(i){const i=V(e);if(i&&h.clipboardModifier.includes(i)?(t=D(x),o=t,r="path"):(t=R,o="object"==typeof t?g(R):String(t)),!navigator.clipboard)return void l?.({...d,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,a=e.message}).finally(()=>{l?.({...d,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:a??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":u("TOOLTIP_COPY",d),title:v?u("TOOLTIP_COPY",d):"",children:t(Pe,{name:"copy",nodeData:d})}),r&&t("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":u("TOOLTIP_EDIT",d),title:v?u("TOOLTIP_EDIT",d):"",children:t(Pe,{name:"edit",nodeData:d})}),o&&t("button",{type:"button",tabIndex:-1,onClick:o,"aria-label":u("TOOLTIP_DELETE",d),title:v?u("TOOLTIP_DELETE",d):"",children:t(Pe,{name:"delete",nodeData:d})}),a&&t("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===s?E(x,{op:"add"}):a("")},"aria-label":u("TOOLTIP_ADD",d),title:v?u("TOOLTIP_ADD",d):"",children:t(Pe,{name:"add",nodeData:d})}),c?.map(({Element:e,onClick:n},r)=>t("div",{onClick:e=>n&&n(d,e),children:t(e,{nodeData:d})},r)),P&&a&&"object"===s&&e(n,{children:[I?t(b,{name:"new-key-select",onChange:a,defaultValue:"",autoFocus:!0,onKeyDown:e=>m(e,{cancel:()=>C()}),placeholder:T.length>0?u("KEY_SELECT",d):u("NO_KEY_OPTIONS",d),options:T}):t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:k,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>K(),cancel:()=>C()})},style:w("input",d)}),t(Ie,{onOk:()=>K(),onCancel:()=>C(),nodeData:d,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},Ie=({onOk:n,onCancel:r,nodeData:o,translate:a,showIconTooltips:i,editConfirmRef:l,hideOk:s=!1})=>e("div",{className:"jer-confirm-buttons",children:[!s&&t("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":a("TOOLTIP_OK",o),title:i?a("TOOLTIP_OK",o):"",ref:l,children:t(Pe,{name:"ok",nodeData:o})}),t("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":a("TOOLTIP_CANCEL",o),title:i?a("TOOLTIP_CANCEL",o):"",children:t(Pe,{name:"cancel",nodeData:o})})]}),Ke=["string","number","boolean","null"],Le=["object","array"],_e=[...Ke,...Le],Ve=e=>{const{component:t,wrapperComponent:n,keyComponent:r,showKey:o=!0,showEditTools:a=!0,showOnEdit:i=!1,showOnView:l=!0,showCollectionWrapper:s=!0,...c}=e;return{CustomComponent:t,CustomWrapperComponent:n,CustomKeyComponent:r,showKey:o,showEditTools:a,showOnEdit:i,showOnView:l,showCollectionWrapper:s,...c}},Me=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?Ve(n):{}},ze=({props:e,collapsed:t})=>{const{nodeData:n,parentData:r,onError:o,getLatestData:a,showErrorMessages:l,allowEditFilter:s,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:h,translate:m,errorDisplayTime:f,sort:y,arrayIndexStart:g,handleKeyboard:v,customNodeData:b}=e,{submit:w}=se(),[E,D]=p(null),S={...n,collapsed:t,visibleSize:Ee(n.path)},{path:k,key:O,size:T}=S,N=C(k),x=ce(e=>{const t=e.active;return null!==t&&"edit"===t.op&&j(t.path,k)}),R=ce(e=>{const t=e.active;return null!==t&&"rename"===t.op&&j(t.path,k)}),P=ce(e=>N in e.settling),A=s(S),I=c(S),K=u(S),L=h(S)&&I,_=e=>{l&&(D(e),setTimeout(()=>D(null),f)),console.warn("Error",e)},V=i(S);V.current=S;const M=d((e,t)=>{_(e.message),o&&o({...V.current,fullData:a(),error:e,errorValue:t})},[o,l,a,f]),z=be(),F=d(e=>(null===z||z.visiblePaths.has(C(e.path)))&&s(e),[z,s]),B=e=>U(a(),k,e,y,F),Y=(e,t)=>{r&&(O!==e&&Object.keys(r).includes(e)?M({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",S)},e):w({op:"rename",path:k,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&M(t.error,e)}))},W="number"==typeof k.slice(-1)[0],$=null!==r&&A&&K&&I&&!W,H={isEditing:x,isEditingKey:R,isPending:P,isArray:W,canEditKey:$},J=""===O&&k.length>0?m("EMPTY_STRING",S):null;return{pathString:N,nodeData:S,path:k,name:O,size:T,canEdit:A,canDelete:I,canAdd:K,canDrag:L,error:E,showError:_,onError:M,setError:D,handleEditKey:Y,derivedValues:H,emptyStringKey:J,getNextOrPreviousAtPath:B,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:$,isEditingKey:R,pathString:N,path:k,name:O,arrayIndexStart:g,handleKeyboard:v,handleEditKey:Y,handleCancel:e,styles:t("property",S),getNextOrPrevious:B,emptyStringKey:J,nodeData:S,customNodeData:b,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Fe=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onError:a,translate:i})=>{const{getStyles:l}=ee(),{dragSource:d,setDragSource:u,armed:h}=(()=>{const e=s(me);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),m=se(),[f,y]=p(!1),g=c(()=>e?{onMouseDown:e=>{0===e.button&&null===m.getSnapshot().active&&(h.current=!0)},onMouseUp:()=>{h.current=!1},onDragStart:e=>{if(!h.current||null!==m.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();h.current=!1,e.stopPropagation(),u({path:r})},onDragEnd:e=>{h.current=!1,e.stopPropagation(),u({path:null})}}:{},[e,r]),v=c(()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),w(e),u({path:null}),y(!1)},onDragEnter:t=>{t.stopPropagation(),null!==d.path&&S(r,d.path)||y(e)},onDragExit:e=>{e.stopPropagation(),y(!1)}}:{},[d,n,r]),b=c(()=>n&&null!==d.path?t("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length},...v("below")}):null,[d,n,r.length]),w=e=>{if(null===d.path)return;if(S(r,d.path))return;const t=d.path.slice(-1)[0],n=d.path.slice(0,-1),l=r.slice(0,-1),{parentData:s}=o;"string"==typeof t&&s&&!Array.isArray(s)&&Object.keys(s).includes(t)&&t in s&&!j(n,l)?a({code:"KEY_EXISTS",message:i("ERROR_KEY_EXISTS",o)},t):m.submit({op:"move",path:d.path,to:{path:r,position:e},instant:!0})};return{dragSourceProps:g,getDropTargetProps:v,BottomDropTarget:b,DropTargetPadding:({position:e,nodeData:n})=>f===e?t("div",{className:"jer-drag-n-drop-padding",style:l("dropZone",n)}):null,handleDrop:w}},Be=(e,t,n,r)=>{if(!t.current)return 0;const o=parseInt(getComputedStyle(n.current).getPropertyValue("line-height"))||16,a=(t.current?.offsetWidth??0)/(.5*o),i=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/a)).reduce((e,t)=>e+t,0)*o;return Math.min(i+30,window.innerHeight-50)},Ye=({isEditingKey:n,canEditKey:o,pathString:a,path:i,name:l,arrayIndexStart:s,handleKeyboard:c,handleEditKey:d,handleCancel:u,handleClick:p,keyValueArray:h,styles:m,getNextOrPrevious:f,emptyStringKey:y,nodeData:g,customNodeData:v,getStyles:b})=>{const{open:w,cancel:E}=se(),D=r.useRef(null),C=e=>d(D.current?.value??String(l),e),j="number"==typeof l?String(l+s):l;if(!n){const n={...m,minWidth:`${Math.min(j.length+1,5)}ch`,flexShrink:j.length>10?1:0};if(v?.CustomKeyComponent&&g&&b){const{CustomKeyComponent:e,componentProps:r}=v;return t(e,{nodeData:g,name:y??j,path:i,canEditKey:o,handleEditKey:e=>{o&&d(e)},startEditingKey:()=>{o&&w(i,{op:"rename",commitOp:C})},handleClick:p,styles:n,componentProps:r,getStyles:b})}return e("span",{className:"jer-key-text",style:n,onDoubleClick:()=>o&&w(i,{op:"rename",commitOp:C}),onClick:p,children:[y?t("span",{className:"jer-empty-string",children:y}):j,""!==j||y?t("span",{className:"jer-key-colon",children:":"}):null]})}return t("input",{ref:D,className:"jer-input-text jer-key-edit",type:"text",name:a,defaultValue:j,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>c(e,{stringConfirm:()=>d(e.target.value),cancel:u,tabForward:()=>{const t=e.target.value;d(t,()=>{if(h){const e=h?.[0][0],t=e?[...i,e]:f("next");t?w(t):E()}else w(i)})},tabBack:()=>{const t=e.target.value;d(t,()=>{const e=f("prev");e?w(e):E()})}}),style:{width:j.length/1.5+.5+"em"}})},Ue=new Set(["nodeData","customNodeData"]),We=(e,t)=>{if(n=e.nodeData,r=t.nodeData,n.key!==r.key||n.index!==r.index||n.level!==r.level||n.size!==r.size||!j(n.path,r.path))return!1;var n,r;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(const n of o)if(!Ue.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},$e=r.memo(n=>{const{data:r,parentData:o,onChange:l,showClipboardButton:s,onCopy:u,canDragOnto:h,allowTypeSelection:f,showLabel:y,stringTruncateLength:g,showStringQuotes:b,indent:w,translate:E,customNodeDefinitions:D,customNodeData:C,Select:S,handleKeyboard:k,keyboardControls:O,editConfirmRef:T,jsonStringify:N,showIconTooltips:x,getLatestData:R}=n,{getStyles:P}=ee(),{open:A,cancel:I,submit:K,getSnapshot:L}=se(),{setCollapseState:_}=pe(),[V,M]=p("function"==typeof r?De:r),{nodeData:z,path:F,name:B,canEdit:Y,canDelete:U,canDrag:W,error:$,onError:H,setError:J,derivedValues:X,getNextOrPreviousAtPath:Q,buildKeyDisplayProps:Z}=ze({props:n}),{dragSourceProps:G,getDropTargetProps:q,BottomDropTarget:te,DropTargetPadding:ne}=Fe({canDrag:W,canDragOnto:h,path:F,nodeData:z,onError:H,translate:E}),[re,oe]=p(Je(r,C)),ae=i(V);ae.current=V;const ie=i(z);ie.current=z;const le=d(e=>{if(!l)return void M(e);const t=l({...ie.current,value:ae.current,fullData:R(),newValue:e});M(t)},[l,R]),ce=()=>{M("function"==typeof r?De:r),oe(Je(r,C)),he(v(r,de))};a(()=>{X.isEditing||ce()},[r]);const de=c(()=>{const e=[..._e,...D.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof f)return f?e:[];if(Array.isArray(f))return f;const t=f(z);return"boolean"==typeof t?t?e:[]:t},[z,f,D]),[ue,he]=p(v(V,de)),{isEditing:me,isPending:fe}=X,ye=we(F),ge=i(m);if(!ye)return null;const ve=me&&re!==Je(r,C),be=ve?D.find(e=>e.name===re&&He(e)):void 0,Ee=be?Ve(be):C,{CustomComponent:Ce,componentProps:je,showKey:Se=!0,showEditTools:ke=!0,showOnEdit:Oe,showOnView:Te,passOriginalNode:Ne}=Ee,xe=Ce&&(void 0!==be||!ve&&(me&&Oe||!me&&Te)),Re=e=>{_(null);const t=ve&&!be?void 0:Ee,n=t?.toStandardType?t.toStandardType(V):V,r=D.find(t=>t.name===e);if(r){if(He(r)){let t=r.defaultValue;if(r.fromStandardType)try{t=r.fromStandardType(n,z,r.componentProps)}catch{}return M(t),oe(e),void he(null)}return K({op:"edit",path:F,value:r.defaultValue}).then(Pe(r.defaultValue)),void _({path:F,collapsed:!1,includeChildren:!1})}const o=de.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof V&&o.values.includes(V)||M(o.values[0]),he(o),void oe(e);const a=Ze(n,e,E("DEFAULT_NEW_KEY",z));if("object"===e||"array"===e||"null"===e)return K({op:"edit",path:F,value:a}).then(Pe(a)),void("null"!==e&&_({path:F,collapsed:!1,includeChildren:!1}));M(a),oe(e),he(null)},Pe=e=>t=>{if("error"===t?.status&&H(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=L().active;"editing"===e?.phase&&j(e.path,F)||ce()}},Ke=(e,t)=>{const n=void 0!==e&&!(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e);let r;if(n)r=e;else if(xe&&Ee.fromStandardType)try{r=Ee.fromStandardType(V,z,Ee.componentProps)}catch(e){return void H({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},V)}else r="number"===re?Qe(V):V;J(null),be&&_({path:F,collapsed:!1,includeChildren:!1}),K({op:"edit",path:F,value:r,onCommit:t}).then(Pe(r))};ge.current=Ke;const Le=()=>{J(null),ce(),I()},{isEditingKey:Me}=X,Be=!!$,Ue=me&&de.length>1,We=("invalid"!==re||Ce)&&!$&&ke,$e=y&&Se,Ge=()=>A(F,{cancelOp:ce,commitOp:e=>ge.current(void 0,e)}),qe=Y?Ge:m,et=e=>()=>{const t=Q(e);t&&Ke(void 0,()=>A(t))},tt={value:V,parentData:o,setValue:le,isEditing:me,canEdit:Y,setIsEditing:qe,handleEdit:Ke,handleCancel:Le,path:F,stringTruncateLength:g,showStringQuotes:b,nodeData:z,enumType:ue,translate:E,handleKeyboard:k,keyboardCommon:{cancel:Le,tabForward:et("next"),tabBack:et("prev")},Select:S},nt={...Z({handleCancel:Le,getStyles:P}),customNodeData:Ee},rt=xe?t(Ce,{...n,value:V,componentProps:je,setValue:le,handleEdit:Ke,handleCancel:Le,onKeyDown:e=>k(e,{stringConfirm:Ke,cancel:Le}),isEditing:me,isPending:fe,setIsEditing:qe,getStyles:P,originalNode:Ne?Xe(r,re,tt):void 0,originalNodeKey:Ne?t(Ye,{...nt,customNodeData:void 0}):void 0,canEdit:Y,keyboardCommon:tt.keyboardCommon}):Xe(r,re,tt);return e("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==o?w/2+"em":0,position:"relative"},draggable:W&&!me&&!Me,...G,...q("above"),children:[te,t(ne,{position:"above",nodeData:z}),e("div",{className:"jer-value-main-row",style:{...P("valueRow",z),flexWrap:B.length>10?"wrap":"nowrap"},children:[$e&&t(Ye,{...nt}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:rt}),me?t(Ie,{onOk:Ke,onCancel:Le,nodeData:z,translate:E,showIconTooltips:x,editConfirmRef:T}):We&&t(Ae,{startEdit:Y?Ge:void 0,handleDelete:U?()=>{K({op:"delete",path:F,instant:!0}).then(e=>{"error"===e?.status&&H(e.error,V)})}:void 0,showClipboardButton:s,onCopy:u,translate:E,customButtons:n.customButtons,nodeData:z,handleKeyboard:k,keyboardControls:O,editConfirmRef:T,jsonStringify:N,showIconTooltips:x,Select:S}),Ue&&t(S,{name:`${B}-type-select`,value:ue?ue.enum:re,onChange:e=>Re(e),options:de.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Be&&t("span",{className:"jer-error-slug",style:P("error",z),children:$})]})]}),t(ne,{position:"below",nodeData:z})]})},We),He=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,Je=(e,t)=>t?.CustomComponent&&t?.name&&t.showInTypeSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",Xe=(e,n,r)=>{const o=Ke.includes(n)?n:"function"==typeof e?"invalid":Je(r.value),{value:a}=r;switch(o){case"string":return t(Se,{...r,value:a});case"number":return t(ke,{...r,value:a});case"boolean":return t(Oe,{...r,value:a});case"null":return t(Ne,{...r});default:return t(xe,{...r})}},Qe=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Ze=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Qe(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Ge=r.memo(r=>{const{getStyles:o}=ee(),{open:l,cancel:s,submit:u,areChildrenBeingEdited:h}=se(),{setCollapseState:f}=pe(),{mainContainerRef:g,data:v,nodeData:b,parentData:w,showCollectionCount:E,canDragOnto:D,collapseFilter:C,collapseAnimationTime:j,showClipboardButton:k,onCopy:O,showIconTooltips:T,indent:N,sort:x,showArrayIndexes:R,defaultValue:P,newKeyOptions:A,translate:I,customNodeDefinitions:K,customNodeData:L,jsonParse:M,jsonStringify:z,TextEditor:F,Select:B,keyboardControls:U,handleKeyboard:W,insertAtTop:$,onCollapse:H,editConfirmRef:J,collapseClickZones:X,getLatestData:Q}=r,[Z,G]=p(null),q=C(b),{contentRef:te,isAnimating:ne,maxHeight:re,collapsed:oe,animateCollapse:ae,cssTransitionValue:ie}=((e,t,n,r,o)=>{const[a,l]=p(n?0:void 0),[s,c]=p(n),u=i(!1),h=i(null),m=i(0),f=i(0),y=t/1e3+"s",g=d(n=>{if(s!==n){switch(window.clearTimeout(f.current),u.current=!0,n){case!0:{const e=h.current?.offsetHeight??0;m.current=e,l(e),setTimeout(()=>{l(0)},5);break}case!1:l(m.current||Be(e,h,r,o))}c(!s),f.current=window.setTimeout(()=>{u.current=!1,n||l(void 0)},t)}},[t,s,e,r,o]);return{contentRef:h,isAnimating:u.current,animateCollapse:g,maxHeight:a,collapsed:s,cssTransitionValue:y}})(v,j,q,g,z),{pathString:le,nodeData:de,path:ue,name:me,size:fe,canEdit:ye,canDelete:ge,canAdd:ve,canDrag:be,error:Ee,setError:De,onError:Ce,derivedValues:je,buildKeyDisplayProps:Se}=ze({props:r,collapsed:oe}),{dragSourceProps:ke,getDropTargetProps:Oe,BottomDropTarget:Te,DropTargetPadding:Ne}=Fe({canDrag:be,canDragOnto:D,path:ue,nodeData:de,onError:Ce,translate:I}),xe=i(!q),{isEditing:Re,isEditingKey:Ke,isPending:Le,isArray:_e}=je,Ve=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(C);a(()=>{const e=C(de)&&!Re;xe.current=!e,ae(e),Ve&&f(null)},[C]),((e,t,n)=>{const{commands:r,version:o}=pe(),l=i(0);a(()=>{if(o===l.current)return;if(l.current=o,!r)return;let a;for(const t of r)he(e,t)&&(a=t);a&&(a.collapsed||(t.current=!0),n(a.collapsed))},[o,r])})(ue,xe,ae);const Ue=i(null),We=d(e=>G(t=>"function"==typeof e?e(t??z(v)):e),[v,z]),He=d(()=>G(null),[]),Je=c(()=>Re?Z??z(v):null,[Re,Z,v,z]),Xe=d((e,t)=>{if("function"!=typeof P)return P;const n=P(e,t);return void 0!==n?n:null},[P]),Qe=d(e=>A?"function"!=typeof A?A:A(e):null,[A]),{CustomComponent:Ze,componentProps:qe,CustomWrapperComponent:et,wrapperProps:tt={},showKey:nt=!0,showEditTools:rt=!0,showOnEdit:ot,showOnView:at,showCollectionWrapper:it=!0}=L,lt=ce(e=>null!==e.active&&S(e.active.path,ue));lt&&oe&&ae(!1);const st=we(ue)||0===de.level,ct=i(m);if(!st&&!lt)return null;const{visibleSize:dt}=de,ut=Array.isArray(v)?"array":"object",pt="array"===ut?{open:"[",close:"]"}:{open:"{",close:"}"},ht=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=Y(Ue,"\t");return void G(t)}W(e,{objectConfirm:ft,cancel:gt})},mt=e=>{e.stopPropagation();const t=V(e);if(t&&U.collapseModifier.includes(t))return xe.current=!0,void f({collapsed:!oe,path:ue,includeChildren:!0});h(ue)||(xe.current=!0,H&&H({...de,fullData:Q(),collapsed:!oe,includeChildren:!1}),ae(!oe))},ft=e=>{const t=Je??z(v);let n;try{n=M(t)}catch{return void Ce({code:"INVALID_JSON",message:I("ERROR_INVALID_JSON",de)},t)}De(null);const r="function"==typeof e?e:void 0;u({op:"edit",path:ue,value:n,onCommit:()=>{He(),r?.()}}).then(e=>{"error"===e?.status&&Ce(e.error,n)})};ct.current=ft;const yt=ue.length>0?()=>{u({op:"delete",path:ue,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,v)})}:void 0,gt=()=>{s(),De(null),He()},vt="when-collapsed"===E?oe:"when-collapsed-or-filtered"===E?oe||null!=dt:E,bt=!Re&&rt,wt=(R||!_e)&&nt&&void 0!==me,Et=Ze&&(Re&&ot||!Re&&at),Dt=Object.entries(v).map(([e,t])=>["array"===ut?Number(e):e,t]);"object"===ut&&x(Dt,e=>e);const Ct=xe.current?Re?e("div",{className:"jer-collection-text-edit"+(F?"-custom":""),children:[F?t(F,{value:Je??"",onChange:G,onKeyDown:e=>W(e,{objectConfirm:ft,cancel:gt})}):t(_,{textAreaRef:Ue,className:"jer-collection-text-area",name:le,value:Je??"",setValue:We,onKeyDown:ht,styles:o("input",de)}),t("div",{className:"jer-collection-input-button-row",children:t(Ie,{onOk:ft,onCancel:gt,nodeData:de,translate:I,showIconTooltips:T,editConfirmRef:J})})]}):Dt.map(([e,n],a)=>{const i={key:e,value:n,path:[...ue,e],level:ue.length+1,index:a,size:y(n)?Object.keys(n).length:null,parentData:v,fullData:de.fullData},l=Me(K,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:y(n)&&!l?.renderCollectionAsValue?t(Ge,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ye,customNodeData:l},e):t($e,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ye,showLabel:"object"===ut||R,customNodeData:l},e)},e)}):null,jt=!!it&&(oe&&!lt);jt||(xe.current=!0);const St=()=>({...r,data:v,value:v,parentData:w,nodeData:de,setValue:e=>u({op:"edit",path:ue,value:e}),handleEdit:ft,handleCancel:gt,onKeyDown:ht,isEditing:Re,isPending:Le,setIsEditing:ye?()=>l(ue,{cancelOp:He,commitOp:e=>ct.current(e)}):m,getStyles:o,canDragOnto:ye,canEdit:ye,keyboardCommon:{}}),kt=Et?t(Ze,{componentProps:qe,...St(),children:Ct}):Ct,Ot=bt&&t(Ae,{startEdit:ye?()=>{xe.current=!0,l(ue,{cancelOp:He,commitOp:e=>ct.current(e)})}:void 0,handleAdd:ve?e=>{f(null),ae(!1);const t=Xe(de,e);if("array"===ut){const e=$.array?0:v.length,n=$.array?{insert:!0}:{};return void u({op:"add",path:ue,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}if(e in v)return Ce({code:"KEY_EXISTS",message:I("ERROR_KEY_EXISTS",de)},e),void s();const n=$.object?{insertBefore:0}:{};u({op:"add",path:ue,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}:void 0,handleDelete:ge?yt:void 0,showClipboardButton:k,onCopy:O,type:ut,nodeData:de,translate:I,customButtons:r.customButtons,keyboardControls:U,handleKeyboard:W,getNewKeyOptions:Qe,editConfirmRef:J,jsonStringify:z,showIconTooltips:T,Select:B}),Tt=Se({handleCancel:gt,getStyles:o,keyValueArray:Dt,handleClick:X.includes("property")?mt:e=>e.stopPropagation()}),Nt=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===ue.length?0:N/2)+"em",...o("collection",de),position:"relative"},draggable:be&&!Re&&!Ke&&!lt,...ke,...Oe("above"),children:[t("div",{className:"jer-clickzone",style:{width:N/2+1+"em",zIndex:10+2*de.level},onClick:X.includes("left")?mt:void 0}),!Re&&Te,t(Ne,{position:"above",nodeData:de}),it?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",de),position:"relative"},onClick:X.includes("header")?mt:void 0,children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(oe?" jer-rotate-90":""),style:{zIndex:11+2*de.level,transition:ie},onClick:mt,children:t(Pe,{name:"collection",nodeData:de})}),wt&&t(Ye,{...Tt}),!Re&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",de),children:pt.open})]}),!1!==E&&!Re&&t("div",{className:"jer-collection-item-count"+(vt?" jer-visible":" jer-hidden"),style:{...o("itemCount",de),transition:ie,transitionBehavior:"allow-discrete"},children:null!=dt&&dt!==fe?I("ITEMS_FILTERED",de,{visible:dt,total:fe}):1===fe?I("ITEM_SINGLE",{...de,size:1},1):I("ITEMS_MULTIPLE",de,fe)}),t("div",{className:"jer-brackets"+(jt?" jer-visible":" jer-hidden"),style:{...o("bracket",de),transition:ie},children:pt.close}),Ot]}):nt?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",de),position:"relative"},children:[t(Ye,{...Tt}),Ot]}):t(n,{}),e("div",{className:"jer-collection-inner",style:{overflowY:jt||ne?"clip":"visible",maxHeight:lt?void 0:re,transition:ie},ref:te,children:[kt,t("div",{className:Re?"jer-collection-error-row-edit":"jer-collection-error-row",children:Ee&&t("span",{className:"jer-error-slug",style:o("error",de),children:Ee})}),!Re&&it&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",de),children:pt.close})]}),t(Ne,{position:"below",nodeData:de})]});return et?t(et,{wrapperProps:tt,...St(),children:Nt}):Nt},We),qe=({options:n,value:r,defaultValue:o,onChange:a,placeholder:i,className:l,...s})=>e("div",{className:"jer-select",children:[e("select",{className:l??"jer-select-inner",onChange:e=>a(e.target.value),...s,...void 0!==r?{value:r}:{defaultValue:o??""},children:[void 0!==i&&t("option",{value:"",disabled:!0,children:i}),n.map(e=>t("option",{value:e,children:e},e))]}),t("span",{className:"focus"})]}),et=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},tt=({key:e,path:t},n="")=>!!et({value:e},n)||!!t.some(e=>et({value:e},n)),nt={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel"},rt=(e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}let a=r in e?e[r]:nt[r];if(void 0!==o){const e=g(o)?o:{count:o};for(const[t,n]of Object.entries(e))a=a?.replace(`{{${t}}}`,String(n))}return a})(e,t,r,n,o);var ot=[],at=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=ot.indexOf(a);-1===i&&(i=ot.push(a)-1,at[i]={}),n=at[i]&&at[i][r]?at[i][r]:at[i][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':host,:root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff;--jer-icon-copy-color:#268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{left:-1.2em;position:absolute;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;font-family:inherit;font-size:.85em;line-height:1.25em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row-edit{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em;margin-right:.2em}.jer-confirm-buttons>button,.jer-edit-buttons>button{appearance:none;background:none;border:none;color:inherit;font:inherit;margin:0;padding:0}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #b4b4b4;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const it=(e,t)=>JSON.stringify(e,t,2),lt={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},st={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},ct=e=>{const t=i(e);e&&(t.current=e);const n=i((...e)=>t.current(...e));return e?n.current:void 0},dt=[],ut=["header","left"],pt={},ht={},mt={},ft=[],yt=({data:e,setData:n,buildNodeDataFromPathRef:r,commitRef:o,rootName:l="root",onUpdate:s=m,onChange:u,onError:g,onEditEvent:v,showErrorMessages:w=!0,showClipboardButton:E=!0,onCopy:D,indent:j=2,collapse:S=3,collapseAnimationTime:k=300,showCollectionCount:O="when-collapsed-or-filtered",allowEdit:T=!0,allowDelete:N=!0,allowAdd:x=!0,allowTypeSelection:R=!0,allowDrag:P=!1,searchFilter:I,searchText:L,searchDebounceTime:_=350,sortKeys:V=!1,showArrayIndexes:z=!0,arrayIndexStart:Y=0,showStringQuotes:U=!0,showIconTooltips:W=!1,defaultValue:$=null,newKeyOptions:H,minWidth:J=250,maxWidth:X="min(600px, 90vw)",baseFontSize:Q,stringTruncateLength:Z=250,translations:G=pt,className:q,id:te,customText:ne=ht,customNodeDefinitions:re=dt,customButtons:oe=ft,jsonParse:ae=JSON.parse,jsonStringify:ie=it,TextEditor:le,Select:ce=qe,errorDisplayTime:de=2500,keyboardControls:ue=mt,editorRef:he,insertAtTop:me=!1,onCollapse:fe,collapseClickZones:ye=ut})=>{const{getStyles:ge,cssVars:be}=ee(),{open:we,cancel:Ee,getSnapshot:De}=se(),Ce=c(()=>bt(S),[S]),je=c(()=>rt(G,ne),[G,ne]),[Se,ke]=p(L),Oe=i(null);a(()=>{Ee();const e=setTimeout(()=>ke(L),_);return()=>clearTimeout(e)},[L,_]);const Te=K(e,[],l),Ne=i(e);Ne.current=e;const xe=i(n);xe.current=n;const Re=i(je);Re.current=je;const Pe=i(Te);Pe.current=Te;const Ae=i(s);Ae.current=s;const Ie=i(l);Ie.current=l;const Ke=i(void 0),Le=d(()=>Ne.current,[]),_e=ct(u),Ve=ct(g),ze=ct(fe),Fe=ct(v),Be=ct(D),Ye=d(e=>{Ne.current=e,xe.current(e)},[]),Ue=d((e,t)=>{Ye(vt(Ne.current,e,t,"update").newData)},[Ye]),We=d(e=>{const t=Ne.current,n=Ie.current,r=Ke.current,o=Ye,{op:a,path:i}=e;switch(a){case"edit":{const{newData:a,currentValue:l,newValue:s}=vt(t,i,e.value,"update"),c=K(t,i,n,r);return{input:{...c,newData:a,event:"edit",newValue:s},nodeData:c,isNoOp:l===s,apply:()=>o(a),revert:()=>o(vt(Ne.current,i,l,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=vt(t,i,"","delete"),l=K(t,i,n,r);return{input:{...l,newData:e,event:"delete"},nodeData:l,isNoOp:!1,apply:()=>o(e),revert:()=>o(vt(Ne.current,i,a,"add",{insert:!0,insertBefore:l.index}).newData)}}case"add":{const a=[...i,e.key],{newData:l,newValue:s}=vt(t,a,e.value,"add",e.options),c=K(l,a,n,r);return{input:{...c,value:void 0,size:null,parentData:A(t,i)??null,fullData:t,newData:l,event:"add",newValue:s},nodeData:c,isNoOp:!1,apply:()=>o(l),revert:()=>o(vt(Ne.current,a,"","delete").newData)}}case"rename":{const a=i.slice(0,-1),l=i[i.length-1],{newKey:s}=e,c=A(t,a),d=Object.fromEntries(Object.entries(c).map(([e,t])=>e===l?[s,t]:[e,t])),{newData:u}=vt(t,a,d,"update"),p=K(t,i,n,r);return{input:{...p,newData:u,event:"rename",newKey:s},nodeData:p,isNoOp:l===s,apply:()=>o(u),revert:()=>o(vt(Ne.current,a,c,"update").newData),extra:{oldKey:l,newKey:s}}}case"move":{const a=i,{path:l,position:s}=e.to,c=t,{newData:d,currentValue:u}=vt(t,a,"","delete"),p=a.slice(-1)[0],h=l.slice(0,-1),m=l.slice(-1)[0];let f="number"==typeof m?"above"===s?m:m+1:"number"==typeof p?`arr_${p}`:p;a.slice(0,-1).join(".")===l.slice(0,-1).join(".")&&"number"==typeof p&&"number"==typeof f&&p<f&&(f-=1);const y="number"==typeof f?{insert:!0}:"above"===s?{insertBefore:m}:{insertAfter:m},g=[...h,f],{newData:v}=vt(d,g,u,"add",y),b=K(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Ye]),He=d(async(e,t)=>{const n=st[e.event],r=()=>Re.current(lt[e.event],Pe.current);let o;try{o=await Ae.current(e,t)}catch(e){return{status:"error",error:{code:n,message:e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r()}}}if(!1===o)return{status:"error",error:{code:n,message:r()}};if(null===o)return{status:"cancel"};if(o&&"object"==typeof o){if(void 0!==o.error)return"string"==typeof o.error?{status:"error",error:{code:n,message:o.error}}:{status:"error",error:o.error};const t=void 0!==o.data,r=void 0!==o.value;if(t&&r&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),t)return{status:"override",value:o.data,path:[]};if(r&&("edit"===e.event||"add"===e.event))return{status:"override",value:o.value,path:e.path}}return{status:"commit"}},[]),Je=c(()=>({runUpdate:s===m?void 0:He,buildCommit:We,applyValue:Ue}),[He,We,Ue,s]);o.current=Je;const Xe=c(()=>bt(T),[T]),Qe=c(()=>bt(N),[N]),Ze=c(()=>bt(x),[x]),tt=c(()=>bt(P),[P]),nt=c(()=>wt(I),[I]),ot=c(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,o=new Map,a=t??et,i=n??"",l=e=>{let t=a(e,i);if(y(e.value)){let n=0;const r=Array.isArray(e.value),a=Object.entries(e.value);for(const[o,i]of a){const a=r?Number(o):o,s={key:a,path:[...e.path,a],level:e.level+1,index:n,value:i,size:y(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(s)&&(t=!0,n++)}o.set(C(e.path),n)}return t&&r.add(C(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:o}})(Te,nt,Se),[e,Se,nt,l]),at=c(()=>(e=>{const t={...F};for(const n of Object.keys(F)){const r=n,o=e[r];if(void 0===o)continue;const a="clipboardModifier"===n||"collapseModifier"===n;if(null===o){t[r]=a?[]:null;continue}const i=(()=>a?f(o):"string"==typeof o?{key:o}:o)();t[r]=i}return B.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(ue),[ue]),yt=d((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(M(n,e[r],r)){n.preventDefault(),o();break}})(at,t,e),[at]),gt=c(()=>{const e=Et(re,"stringifyReplacer");return t=>ie(t,e)},[re,ie]),Dt=c(()=>{const e=Et(re,"parseReviver");return t=>{const n=ae(t,e);return b(n)}},[re,ae]),Ct=i(null),{setCollapseState:jt}=pe(),St=d((e,t)=>{!1!==V&&("function"!=typeof V?e.sort((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0}):e.sort((e,n)=>V(t(e),t(n))))},[V]);Ke.current=St;const kt=d(e=>K(Le(),e,Ie.current,Ke.current),[Le]);r.current=kt,h(he,()=>{const e=Symbol("path-missing");return{collapse:e=>jt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>A(Le(),t,e)===e?"PATH_NOT_FOUND":n||Xe(K(Le(),t,l,St))?(we(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{Ct.current&&(Ct.current.click(),"editing"!==De().active?.phase&&Ee())},cancel:()=>Ee()}},[jt,we,Ee,De,Xe,Le,l,St]);const Ot=Me(re,Te),Tt=c(()=>({object:!0===me||"object"===me,array:!0===me||"array"===me}),[me]),Nt={mainContainerRef:Oe,name:l,nodeData:Te,getLatestData:Le,onChange:_e,onError:Ve,onEditEvent:Fe,showErrorMessages:w,showCollectionCount:O,collapseFilter:Ce,collapseAnimationTime:k,allowEditFilter:Xe,allowDeleteFilter:Qe,allowAddFilter:Ze,allowTypeSelection:R,allowDragFilter:tt,canDragOnto:!1,showClipboardButton:E,onCopy:Be,sortKeys:V,sort:St,showArrayIndexes:z,arrayIndexStart:Y,showStringQuotes:U,showIconTooltips:W,indent:j,defaultValue:$,newKeyOptions:H,stringTruncateLength:Z,translate:je,customNodeDefinitions:re,customNodeData:Ot,customButtons:oe,parentData:null,jsonParse:Dt,jsonStringify:gt,TextEditor:le,Select:ce,errorDisplayTime:de,handleKeyboard:yt,keyboardControls:at,insertAtTop:Tt,onCollapse:ze,editConfirmRef:Ct,collapseClickZones:ye},xt={...ge("container",Te),...be,minWidth:J,maxWidth:X};return xt.fontSize=Q??xt.fontSize,t("div",{id:te,ref:Oe,className:`jer-editor-container ${q??""}`,style:xt,children:t(ve,{value:ot,children:y(e)&&!Ot.renderCollectionAsValue?t(Ge,{data:e,...Nt}):t($e,{data:e,showLabel:!0,...Nt})})})};function gt(e){const n=i(void 0),r=i(void 0),o=e;return t(q,{theme:o.theme??J,children:t(ye,{onEditEvent:o.onEditEvent,onCollapse:o.onCollapse,buildNodeDataFromPathRef:n,commitRef:r,children:t(yt,{...o,buildNodeDataFromPathRef:n,commitRef:r})})})}const vt=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},i="add"!==r?A(e,t):void 0;return{currentData:e,newData:N(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},bt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,wt=e=>{if(void 0!==e)return"value"===e?et:"key"===e?tt:"all"===e?(e,t)=>et(e,t)||tt(e,t):e},Et=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?w:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}};function Dt(e){const{editorRef:n,...r}=e,o=i(null);return h(n,()=>({collapse:e=>o.current?.collapse(e)}),[]),t(gt,{...r,editorRef:o,setData:m,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}export{_ as AutogrowTextArea,Re as IconSvg,gt as JsonEditor,Dt as JsonViewer,Ce as StringDisplay,je as StringEdit,N as assign,Le as collectionDataTypes,J as defaultTheme,A as extract,y as isCollection,et as matchNode,tt as matchNodeKey,E as splitPropertyString,_e as standardDataTypes,C as toPathString,Te as useKeyboardListener,Ke as valueDataTypes};
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useLayoutEffect as o,useEffect as a,useRef as i,createContext as l,useContext as s,useMemo as c,useCallback as d,useSyncExternalStore as u,useState as p,useInsertionEffect as h,useImperativeHandle as m}from"react";const f=()=>{},y=e=>Array.isArray(e)?e:[e],g=e=>null!==e&&"object"==typeof e,v=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),b=e=>null!=e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then,w=(e,t)=>{if("string"!=typeof e)return null;const n=t.filter(t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority);return n.sort((e,t)=>(t.matchPriority??0)-(e.matchPriority??0)),n[0]??null},D=e=>{if(e!==E){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=D(n);r!==n&&(e[t]=r)}return e}},E="__undefined__",C=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),j=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),S=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),O=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),k=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),T=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},x=e=>Array.isArray(e),N=(e,t)=>e.filter((e,n)=>n!==t),R=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:i=!1}=r,l=e,s=j(t),c={...r,remove:o,createNew:a,noError:i,fullData:l,fullPath:s},d=Array.isArray(t)?t:C(t);return x(e)&&o&&1===d.length?N(e,d[0]):A(e,d,n,c)},A=(e,t,n,r)=>{const o=v(e)?{...e}:null,a=x(e)?[...e]:null;if(0===t.length)return e;if(!o&&!a)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:s,fullData:c,fullPath:d}=r,u=t[0];if(a&&"string"==typeof u)return a.map(e=>A(e,t,n,r));if(1===t.length)return o&&"string"==typeof u?P(o,u,n,r)??o:a&&"number"==typeof u?(I(a,u,n,r),a):(T(c,d,u,s),e);const p=o||a||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=p[u],n=t[1];return x(e)?p[u]=N(e,n):T(c,d,u,s,"Trying to remove an indexed item from an object that is not an array"),p}const h=t.slice(1);if(u in e){if(m=p[u],!x(m)&&!v(m)){if(!i)return T(c,d,u,s),p;p[u]={}}return p[u]=A(p[u],h,n,r),p}var m;if(i){const e="number"==typeof h[0]?[]:{};if(o)return p[u]=e,p[u]=A(p[u],h,n,r),p;if(a&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=A(p[t],h,n,r),p}}return T(c,d,u,s),p},P=(e,t,n,r)=>{const{remove:o,createNew:a,noError:i,insertAfter:l,insertBefore:s,fullData:c,fullPath:d}=r;if(void 0!==s||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof s?s:"number"==typeof l?l:r.findIndex(([e])=>e===(s??l)),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const u=t in e;o?u?delete e[t]:T(c,d,t,i):a||u?e[t]=n:T(c,d,t,i)},I=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:i,createNew:l,insert:s}=r;s&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):T(a,i,t,o)},L=(e,t,n)=>{const r=Array.isArray(t)?t:C(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>L(e,r,n));if("object"!=typeof e||null===e||!(o in e))return K(e,o,n);const a=e[o];return 1===r.length?a:L(a,r.slice(1),n)},K=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},_=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:g(e)?Object.keys(e).length:1,parentData:null,fullData:e};const o=t[t.length-1],a=L(e,t),i=L(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof o?o:Number(o);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===o)}return{key:o,path:t,level:t.length,index:l,value:a,size:g(a)?Object.keys(a).length:null,parentData:i,fullData:e}},V="undefined"!=typeof window?o:a,M=({className:n,name:r,value:o,setValue:a,onKeyDown:l,styles:s,textAreaRef:c})=>{const d=i(null);if(V(()=>{const e=d.current;d.current=null;const t=c?.current;if(!e||!t)return;const n=e.start+o.length-e.sourceLength,r=Math.max(0,Math.min(n,o.length));t.selectionStart!==r&&t.setSelectionRange(r,r)},[o,c]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:c,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...s},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;d.current=null!==n&&n<t.length?{start:n,sourceLength:t.length}:null,a(t)},autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:l}),t("span",{className:n,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...s},children:u})]})},z=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,F=(e,t,n)=>{if(!t)return!1;const r=e.key,o=z(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:i}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!i?.includes("Shift"))&&r===a&&(i===o||Array.isArray(i)&&i.includes(o))},B={key:"Enter"},H={confirm:B,cancel:{key:"Escape"},objectConfirm:{...B,modifier:["Meta","Shift","Control"]},objectLineBreak:B,stringConfirm:B,stringLineBreak:{...B,modifier:["Shift"]},numberConfirm:B,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:B,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},W=["stringConfirm","numberConfirm","booleanConfirm"],Y=(e,t)=>{const n=e.current,r=n.selectionStart??1/0,o=n.selectionEnd??1/0,a=n.value.slice(0,r)+t+n.value.slice(o);return n.value=a,n.setSelectionRange(r+1,r+1),a},U=(e,t,n="next",r,o)=>{const a=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=L(e,a),s=X(l);Array.isArray(l)||r(s,({key:e,value:t})=>[e,t]);const c=s.findIndex(e=>e.key===i),d=s[c+("next"===n?1:-1)];if(!d)return 0===a.length?null:U(e,a,n,r,o);let u;if(g(d.value)){if(0===Object.keys(d.value).length)return U(e,[...a,d.key],n,r,o);u=$(e,[...a,d.key],n,r)}else u=[...a,d.key];return u?o(_(e,u,"",r))?u:U(e,u,n,r,o):null},$=(e,t,n="next",r)=>{const o=L(e,t);if(!g(o))return t;const a=Array.isArray(o)?o.map((e,t)=>t):Object.keys(o);r(a,e=>[e,o]);const i="next"===n?a[0]:a[a.length-1];return $(e,[...t,i],n,r)},X=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),J={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},Q={displayName:"Default",icons:{add:{content:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),/*#__PURE__*/t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),/*#__PURE__*/t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:/*#__PURE__*/t("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),/*#__PURE__*/t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),/*#__PURE__*/t("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:J,scale:.86},ok:{content:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),/*#__PURE__*/t("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:J,scale:.9},cancel:{content:/*#__PURE__*/t("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:/*#__PURE__*/t("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},Z={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},G=e=>[Q,...y(e)].map(e=>"styles"in e?e:{styles:e}),q=e=>{const t={};for(const{icons:n}of G(e))n&&Object.assign(t,n);return t},ee=/*#__PURE__*/l({getStyles:()=>({}),icons:/*#__PURE__*/q(Q),cssVars:{}}),te=({theme:e=Q,children:n})=>{const r=c(()=>(e=>{var t;const n=G(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[Z[a]??"color"]:t}:t}}}for(const e in o)r[t=e]??(r[t]={});const a={};for(const e in r){const t=e,n=r[t],i=o[t];a[t]=i?e=>i.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(e),[e]),o=c(()=>/*#__PURE__*/q(e),[e]),a=c(()=>(e=>{const{inputHighlight:t,iconCopy:n}=e,r={};return"function"!=typeof t&&t?.backgroundColor&&(r["--jer-highlight-color"]=t.backgroundColor),"function"!=typeof n&&n?.color&&(r["--jer-icon-copy-color"]=n.color),r})(r),[r]),i=d((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(r,e,t),[r]),l=c(()=>({getStyles:i,icons:o,cssVars:a}),[i,o,a]);return t(ee.Provider,{value:l,children:n})},ne=()=>s(ee),re={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},oe=(e,t)=>re[e][t]??null,ae=(e,t)=>null!==e&&null!==t&&e.op===t.op&&O(e.path,t.path),ie={active:null,settling:{}},le=/*#__PURE__*/l(null),se=({children:e,onEditEvent:n,buildNodeDataFromPathRef:r,commitRef:o})=>{const a=i(n);a.current=n;const l=i(null);return null===l.current&&(l.current=((e,t,n)=>{let r=ie;const o=new Set;let a=null,i=null,l=!1,s=0;const c=e=>{r=e,o.forEach(e=>e())},d=(t,n,r)=>{e.current?.({...t,...r,event:n})},u=(n,o,l)=>{if(!e.current)return;let s;try{s=t.current?.(n)}catch{return c({...r,active:null}),a=null,void(i=null)}s&&d(s,o,l)},p=(e,t)=>{var n;a=t?.cancelOp??null,i=t?.commitOp??null,n=e,ae(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=oe(e.op,"start");o&&u(e.path,o)},h=(e,t,o,l,s,u,p,h,m)=>{const f=S(e);if(!p()){if("cancel"===l.status||"error"===l.status){r.active&&O(r.active.path,e)&&("held"===r.active.phase||"editing"===r.active.phase)&&(c({...r,active:null}),a=null,i=null);const n=oe(t,"cancel");return n&&d(h,n),"error"===l.status&&d(h,"updateError",{operation:t,error:l.error}),l}s()}if(r.settling[f]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],c({...r,settling:t})})(f),l.status){case"cancel":u();break;case"error":u(),d(h,"updateError",{operation:t,error:l.error});break;case"override":n.current?.applyValue(l.path,l.value),d(h,"updateSuccess",{operation:t,...m});break;case"commit":d(h,"updateSuccess",{operation:t,...m})}return l}};return{subscribe:e=>(o.add(e),()=>o.delete(e)),getSnapshot:()=>r,getServerSnapshot:()=>r,open:(e,t)=>{if("held"===r.active?.phase)return;const n={path:e,op:t?.op??"edit",phase:"editing",force:t?.force},o=r.active,l=null!==o&&!ae(o,n);if(l&&i)return void i(()=>p(n,t));const s=a;if(a=null,i=null,s&&s(),l&&ae(r.active,o)){const e=oe(o.op,"cancel");e&&u(o.path,e)}p(n,t)},cancel:()=>{if(l)return;if("held"===r.active?.phase)return;const e=r.active;l=!0;try{const t=a;if(a=null,i=null,t&&t(),null!==e){null!==r.active&&c({...r,active:null});const t=oe(e.op,"cancel");t&&u(e.path,t)}}finally{l=!1}},submit:e=>{const{op:t,path:o,instant:l,onCommit:p}=e,m=n.current;let f;try{f=m?.buildCommit(e)??null}catch{return ae(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null,p?.(),Promise.resolve(void 0)}const y=f?.extra,g=S(o),v=++s;if(!l){const e=oe(t,"submit");e&&u(o,e)}if(!f||f.isNoOp){ae(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null;const e=oe(t,"commit");return e&&(f?d(f.nodeData,e,y):u(o,e,y)),p?.(),Promise.resolve(void 0)}const{input:w,nodeData:D,apply:E,revert:C}=f,j=!!m?.runUpdate;let O=!1,k=!1;const T=()=>{if(O)return;O=!0,E(),a=null,i=null,ae(r.active,{path:o,op:t})&&c({...r,active:null}),j&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(g,v);const e=oe(t,"commit");e&&d(D,e,y),p?.()},x={hold:()=>(k=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>T())};if(!j)return T(),Promise.resolve(void 0);const N=m.runUpdate(w,x),R=b(N);if(!k&&!l&&!R)return Promise.resolve(h(o,t,v,N,T,C,()=>O,D,y));const A=R?N:Promise.resolve(N);let P;return k||(l?P=setTimeout(T,100):T()),A.then(e=>(clearTimeout(P),h(o,t,v,e,T,C,()=>O,D,y)))},areChildrenBeingEdited:e=>null!==r.active&&k(r.active.path,e)}})(a,r,o)),t(le.Provider,{value:l.current,children:e})},ce=()=>{const e=s(le);if(!e)throw new Error("Missing Editing Context Provider");return e},de=e=>{const t=ce();return u(t.subscribe,()=>e(t.getSnapshot()),()=>e(t.getServerSnapshot()))},ue=/*#__PURE__*/l(null),pe=({children:e,onCollapse:n,buildNodeDataFromPathRef:r})=>{const[o,a]=p({commands:null,version:0}),l=i(n);l.current=n;const s=d(e=>{if(null===e)return void a(e=>null===e.commands?e:{commands:null,version:e.version});const t=y(e),n=t.map(e=>({...e,path:[...e.path]}));a(e=>({commands:n,version:e.version+1}));const o=l.current;o&&t.forEach(e=>{const t=r.current?.(e.path);t&&o({...t,collapsed:e.collapsed,includeChildren:e.includeChildren})})},[r]),u=c(()=>({commands:o.commands,version:o.version,setCollapseState:s}),[o.commands,o.version,s]);return t(ue.Provider,{value:u,children:e})},he=()=>{const e=s(ue);if(!e)throw new Error("Missing Collapse Context Provider");return e},me=(e,t)=>{if(!t.includeChildren)return t.path.length===e.length&&t.path.every((t,n)=>e[n]===t);for(const[n,r]of t.path.entries())if(r!==e[n])return!1;return!0},fe=/*#__PURE__*/l(null),ye=({children:e})=>{const[n,r]=p({path:null,canDelete:!1}),o=i(!1),a=c(()=>({dragSource:n,setDragSource:r,armed:o}),[n]);return t(fe.Provider,{value:a,children:e})},ge=({children:e,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>t(se,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:t(pe,{onCollapse:r,buildNodeDataFromPathRef:o,children:t(ye,{children:e})})}),ve=/*#__PURE__*/l(void 0),be=({value:e,children:n})=>t(ve.Provider,{value:e,children:n}),we=()=>{const e=s(ve);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},De=e=>{const t=we();return null===t||t.visiblePaths.has(S(e))},Ee=e=>{const t=we();return null===t?null:t.visibleChildCounts.get(S(e))??null},Ce="**INVALID_FUNCTION**",je=({nodeData:r,showStringQuotes:o=!0,stringTruncateLength:a=200,pathString:i,canEdit:l,setIsEditing:s,styles:c,translate:d,showIconTooltips:u=!1,value:h,TextWrapper:m=({children:e})=>e})=>{const f=h??r.value,[y,g]=p(!1),v=o?'"':"",b=f.length>a,w=()=>{l?s(!0):g(!y)},D=d("SHOW_MORE",r);return e("div",{id:`${i}_display`,onDoubleClick:w,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&w()},className:"jer-value-string",style:c,children:[v,b?e(n,y?{children:[t(m,{children:e("span",{children:[f,v]})})," ",t("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-show-less",onClick:()=>g(!1),children:d("SHOW_LESS",r)})]}:{children:[e(m,{children:[t("span",{children:f.slice(0,a-2).trimEnd()})," "]}),t("button",{type:"button",tabIndex:-1,className:"jer-string-expansion jer-ellipsis",onClick:()=>g(!0),"aria-label":D,title:u?D:"",children:"..."}),v]}):t(m,{children:`${f}${v}`})]})},Se=({styles:e,pathString:n,value:r,setValue:o,handleEdit:a,handleKeyboard:l,keyboardCommon:s})=>{const c=i(null);return t(M,{className:"jer-input-text",textAreaRef:c,name:n,value:r,setValue:o,onKeyDown:e=>{l(e,{stringConfirm:a,stringLineBreak:()=>{const e=Y(c,"\n");o(e)},...s})},styles:e})},Oe=({isEditing:e,path:n,enumType:r,...o})=>{const{getStyles:a}=ne(),i=S(n),{value:l,setValue:s,nodeData:c,handleEdit:d,handleKeyboard:u,keyboardCommon:p,Select:h}=o;return e&&r?t(h,{name:`${i}-value-select`,value:l,onChange:s,options:r.values,autoFocus:!0,onKeyDown:e=>u(e,{stringConfirm:d,...p})}):e?t(Se,{styles:a("input",c),pathString:i,...o,setValue:o.setValue}):t(je,{pathString:i,styles:a("string",c),...o})},ke=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ne();return r?t("input",{className:"jer-input-number",type:"text",name:S(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:t=>s(t,{numberConfirm:i,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1),...c}),style:{width:String(e).length/1.5+2+"em",...d("input",l)}}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:d("number",l),children:e})},Te=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ne();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:S(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,{booleanConfirm:i,booleanToggle:()=>n(!e),...c})},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},xe=(e,t)=>{const n=i(void 0),r=i(t);a(()=>{r.current=t},[t]);const o=e=>{r.current(e)};a(()=>{if(window.clearTimeout(n.current),e)return n.current=window.setTimeout(()=>{window.addEventListener("keydown",o)},100),()=>{window.clearTimeout(n.current),window.removeEventListener("keydown",o)}},[e])},Ne=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:l})=>{const{getStyles:s}=ne();return xe(n,e=>i(e,{confirm:o,...l})),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",a),children:String(e)})},Re=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===Ce&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},Ae=({scale:e=1,viewBox:n="0 0 24 24",fill:r="currentColor",children:o,...a})=>{const i=1.4*e+"em";return t("svg",{viewBox:n,fill:r,width:i,height:i,...a,children:o})},Pe=({name:e,nodeData:n})=>{const{getStyles:r,icons:o}=ne(),a=o[e],i=`icon${e[0].toUpperCase()}${e.slice(1)}`;return t(Ae,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===e?void 0:"jer-icon",style:r(i,n),children:a.content})},Ie=({startEdit:r,handleDelete:o,handleAdd:a,showClipboardButton:i,onCopy:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:h,handleKeyboard:m,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:w}=ne(),{open:D,cancel:E}=ce(),C=u("KEY_NEW",d),[S,k]=p(C),[T,x]=p(!1),{path:N,value:R}=d,A=de(e=>{const t=e.active;return null!==t&&"add"===t.op&&O(t.path,N)}),P=Array.isArray(T);V(()=>{if(!A)return x(!1),void k(C);const e=Object.keys(L(d.fullData,N)),t=y?y(d)?.filter(t=>!e.includes(t)):null;t&&k(""),x(t??!0)},[A]);const I=()=>{a&&(P&&!S||a("array"===s?"":S))};return e("div",{className:"jer-edit-buttons",style:{opacity:A?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&t("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",a=null;if(i){const i=z(e);if(i&&h.clipboardModifier.includes(i)?(t=j(N),o=t,r="path"):(t=R,o="object"==typeof t?g(R):String(t)),!navigator.clipboard)return void l?.({...d,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,a=e.message}).finally(()=>{l?.({...d,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:a??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":u("TOOLTIP_COPY",d),title:v?u("TOOLTIP_COPY",d):"",children:t(Pe,{name:"copy",nodeData:d})}),r&&t("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":u("TOOLTIP_EDIT",d),title:v?u("TOOLTIP_EDIT",d):"",children:t(Pe,{name:"edit",nodeData:d})}),o&&t("button",{type:"button",tabIndex:-1,onClick:o,"aria-label":u("TOOLTIP_DELETE",d),title:v?u("TOOLTIP_DELETE",d):"",children:t(Pe,{name:"delete",nodeData:d})}),a&&t("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===s?D(N,{op:"add"}):a("")},"aria-label":u("TOOLTIP_ADD",d),title:v?u("TOOLTIP_ADD",d):"",children:t(Pe,{name:"add",nodeData:d})}),c?.map(({Element:e,onClick:n,label:r},o)=>{const a=e=>n&&n(d,e);return r?t("button",{type:"button",tabIndex:-1,onClick:a,"aria-label":r,title:v?r:"",children:t(e,{nodeData:d})},o):t("div",{onClick:a,children:t(e,{nodeData:d})},o)}),A&&a&&"object"===s&&e(n,{children:[P?t(b,{name:"new-key-select",onChange:a,defaultValue:"",autoFocus:!0,onKeyDown:e=>m(e,{cancel:()=>E()}),placeholder:T.length>0?u("KEY_SELECT",d):u("NO_KEY_OPTIONS",d),options:T}):t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:S,onChange:e=>k(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>I(),cancel:()=>E()})},style:w("input",d)}),t(Le,{onOk:()=>I(),onCancel:()=>E(),nodeData:d,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:P})]})]})},Le=({onOk:n,onCancel:r,nodeData:o,translate:a,showIconTooltips:i,editConfirmRef:l,hideOk:s=!1})=>e("div",{className:"jer-confirm-buttons",children:[!s&&t("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":a("TOOLTIP_OK",o),title:i?a("TOOLTIP_OK",o):"",ref:l,children:t(Pe,{name:"ok",nodeData:o})}),t("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":a("TOOLTIP_CANCEL",o),title:i?a("TOOLTIP_CANCEL",o):"",children:t(Pe,{name:"cancel",nodeData:o})})]}),Ke=["string","number","boolean","null"],_e=["object","array"],Ve=[...Ke,..._e],Me=e=>{const{component:t,wrapperComponent:n,keyComponent:r,showKey:o=!0,showEditTools:a=!0,showOnEdit:i=!1,showOnView:l=!0,showCollectionWrapper:s=!0,...c}=e;return{CustomComponent:t,CustomWrapperComponent:n,CustomKeyComponent:r,showKey:o,showEditTools:a,showOnEdit:i,showOnView:l,showCollectionWrapper:s,...c}},ze=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?Me(n):{}},Fe=({props:e,collapsed:t})=>{const{nodeData:n,parentData:r,onError:o,getLatestData:a,showErrorMessages:l,allowEditFilter:s,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:h,canAddHere:m,translate:f,errorDisplayTime:y,sort:g,arrayIndexStart:v,handleKeyboard:b,customNodeData:w}=e,{submit:D}=ce(),[E,C]=p(null),j={...n,collapsed:t,visibleSize:Ee(n.path)},{path:k,key:T,size:x}=j,N=S(k),R=de(e=>{const t=e.active;return null!==t&&"edit"===t.op&&O(t.path,k)}),A=de(e=>{const t=e.active;return null!==t&&"rename"===t.op&&O(t.path,k)}),P=de(e=>N in e.settling),I=s(j),L=c(j),K=u(j),_=h(j),V=e=>{l&&(C(e),setTimeout(()=>C(null),y)),console.warn("Error",e)},M=i(j);M.current=j;const z=d((e,t)=>{V(e.message),o&&o({...M.current,fullData:a(),error:e,errorValue:t})},[o,l,a,y]),F=we(),B=d(e=>(null===F||F.visiblePaths.has(S(e.path)))&&s(e),[F,s]),H=e=>U(a(),k,e,g,B),W=(e,t)=>{r&&(T!==e&&Object.keys(r).includes(e)?z({code:"KEY_EXISTS",message:f("ERROR_KEY_EXISTS",j)},e):D({op:"rename",path:k,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&z(t.error,e)}))},Y="number"==typeof k.slice(-1)[0],$=null!==r&&!Y&&L&&m,X={isEditing:R,isEditingKey:A,isPending:P,isArray:Y,canEditKey:$},J=""===T&&k.length>0?f("EMPTY_STRING",j):null;return{pathString:N,nodeData:j,path:k,name:T,size:x,canEdit:I,canDelete:L,canAdd:K,canDrag:_,error:E,showError:V,onError:z,setError:C,handleEditKey:W,derivedValues:X,emptyStringKey:J,getNextOrPreviousAtPath:H,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:$,isEditingKey:A,pathString:N,path:k,name:T,arrayIndexStart:v,handleKeyboard:b,handleEditKey:W,handleCancel:e,styles:t("property",j),getNextOrPrevious:H,emptyStringKey:J,nodeData:j,customNodeData:w,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Be=({canDrag:e,canDelete:n,canDragOnto:r,canAddHere:o,path:a,nodeData:i,onError:l,translate:d})=>{const{getStyles:u}=ne(),{dragSource:h,setDragSource:m,armed:f}=(()=>{const e=s(fe);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),y=ce(),[g,v]=p(!1),b=()=>null!==h.path&&!k(a,h.path)&&(O(h.path.slice(0,-1),a.slice(0,-1))?r:h.canDelete&&o),w=c(()=>e?{onMouseDown:e=>{0===e.button&&null===y.getSnapshot().active&&(f.current=!0)},onMouseUp:()=>{f.current=!1},onDragStart:e=>{if(!f.current||null!==y.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();f.current=!1,e.stopPropagation(),m({path:a,canDelete:n})},onDragEnd:e=>{f.current=!1,e.stopPropagation(),m({path:null,canDelete:!1})}}:{},[e,n,a]),D=c(()=>e=>r||o?{onDragOver:e=>{e.stopPropagation(),b()&&e.preventDefault()},onDrop:t=>{t.stopPropagation(),C(e),m({path:null,canDelete:!1}),v(!1)},onDragEnter:t=>{t.stopPropagation(),b()&&v(e)},onDragExit:e=>{e.stopPropagation(),v(!1)}}:{},[h,r,o,a]),E=c(()=>null!==h.path&&b()?t("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:a.length},...D("below")}):null,[h,r,o,a.length]),C=e=>{if(null===h.path)return;if(!b())return;const t=h.path.slice(-1)[0],n=h.path.slice(0,-1),r=a.slice(0,-1),{parentData:o}=i;"string"==typeof t&&o&&!Array.isArray(o)&&Object.keys(o).includes(t)&&t in o&&!O(n,r)?l({code:"KEY_EXISTS",message:d("ERROR_KEY_EXISTS",i)},t):y.submit({op:"move",path:h.path,to:{path:a,position:e},instant:!0})};return{dragSourceProps:w,getDropTargetProps:D,BottomDropTarget:E,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:u("dropZone",n)}):null,handleDrop:C}},He=({isEditingKey:n,canEditKey:o,pathString:a,path:i,name:l,arrayIndexStart:s,handleKeyboard:c,handleEditKey:d,handleCancel:u,handleClick:p,keyValueArray:h,styles:m,getNextOrPrevious:f,emptyStringKey:y,nodeData:g,customNodeData:v,getStyles:b})=>{const{open:w,cancel:D}=ce(),E=r.useRef(null),C=e=>d(E.current?.value??String(l),e),j="number"==typeof l?String(l+s):l;if(!n){const n={...m,minWidth:`${Math.min(j.length+1,5)}ch`,flexShrink:j.length>10?1:0};if(v?.CustomKeyComponent&&g&&b){const{CustomKeyComponent:e,componentProps:r}=v;return t(e,{nodeData:g,name:y??j,path:i,canEditKey:o,handleEditKey:e=>{o&&d(e)},startEditingKey:()=>{o&&w(i,{op:"rename",commitOp:C})},handleClick:p,styles:n,componentProps:r,getStyles:b})}return e("span",{className:"jer-key-text",style:n,onDoubleClick:()=>o&&w(i,{op:"rename",commitOp:C}),onClick:p,children:[y?t("span",{className:"jer-empty-string",children:y}):j,""!==j||y?t("span",{className:"jer-key-colon",children:":"}):null]})}return t("input",{ref:E,className:"jer-input-text jer-key-edit",type:"text",name:a,defaultValue:j,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>c(e,{stringConfirm:()=>d(e.target.value),cancel:u,tabForward:()=>{const t=e.target.value;d(t,()=>{if(h){const e=h?.[0][0],t=e?[...i,e]:f("next");t?w(t):D()}else w(i)})},tabBack:()=>{const t=e.target.value;d(t,()=>{const e=f("prev");e?w(e):D()})}}),style:{width:j.length/1.5+.5+"em"}})},We=new Set(["nodeData","customNodeData"]),Ye=(e,t)=>{if(n=e.nodeData,r=t.nodeData,n.key!==r.key||n.index!==r.index||n.level!==r.level||n.size!==r.size||!O(n.path,r.path))return!1;var n,r;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(const n of o)if(!We.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ue=n=>{const{data:r,parentData:o,onChange:l,showClipboardButton:s,onCopy:u,canDragOnto:h,canAddHere:m,allowTypeSelection:y,showLabel:g,stringTruncateLength:v,showStringQuotes:b,indent:D,translate:E,customNodeDefinitions:C,customNodeData:j,Select:S,handleKeyboard:k,keyboardControls:T,editConfirmRef:x,jsonStringify:N,showIconTooltips:R,getLatestData:A}=n,{getStyles:P}=ne(),{open:I,cancel:L,submit:K,getSnapshot:_}=ce(),{setCollapseState:V}=he(),[M,z]=p("function"==typeof r?Ce:r),{nodeData:F,path:B,name:H,canEdit:W,canDelete:Y,canDrag:U,error:$,onError:X,setError:J,derivedValues:Q,getNextOrPreviousAtPath:Z,buildKeyDisplayProps:G}=Fe({props:n}),{dragSourceProps:q,getDropTargetProps:ee,BottomDropTarget:te,DropTargetPadding:re}=Be({canDrag:U,canDelete:Y,canDragOnto:h,canAddHere:m,path:B,nodeData:F,onError:X,translate:E}),[oe,ae]=p(Je(r,j)),ie=i(M);ie.current=M;const le=i(F);le.current=F;const se=d(e=>{if(!l)return void z(e);const t=l({...le.current,value:ie.current,fullData:A(),newValue:e});z(t)},[l,A]),de=()=>{z("function"==typeof r?Ce:r),ae(Je(r,j)),me(w(r,ue))};a(()=>{Q.isEditing||de()},[r]);const ue=c(()=>{const e=[...Ve,...C.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof y)return y?e:[];if(Array.isArray(y))return y;const t=y(F);return"boolean"==typeof t?t?e:[]:t},[F,y,C]),[pe,me]=p(w(M,ue)),{isEditing:fe,isPending:ye}=Q,ge=De(B),ve=i(f);if(!ge)return null;const be=fe&&oe!==Je(r,j),we=be?C.find(e=>e.name===oe&&Xe(e)):void 0,Ee=we?Me(we):j,{CustomComponent:je,componentProps:Se,showKey:Oe=!0,showEditTools:ke=!0,showOnEdit:Te,showOnView:xe,passOriginalNode:Ne}=Ee,Re=je&&(void 0!==we||!be&&(fe&&Te||!fe&&xe)),Ae=e=>{V(null);const t=be&&!we?void 0:Ee,n=t?.toStandardType?t.toStandardType(M):M,r=C.find(t=>t.name===e);if(r){const t="function"==typeof r.defaultValue?r.defaultValue(F):r.defaultValue;if(Xe(r)){let o=t;if(r.fromStandardType)try{o=r.fromStandardType(n,F,r.componentProps)}catch{}return z(o),ae(e),void me(null)}return K({op:"edit",path:B,value:t}).then(Pe(t)),void V({path:B,collapsed:!1,includeChildren:!1})}const o=ue.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof M&&o.values.includes(M)||z(o.values[0]),me(o),void ae(e);const a=Ge(n,e,E("DEFAULT_NEW_KEY",F));if("object"===e||"array"===e||"null"===e)return K({op:"edit",path:B,value:a}).then(Pe(a)),void("null"!==e&&V({path:B,collapsed:!1,includeChildren:!1}));z(a),ae(e),me(null)},Pe=e=>t=>{if("error"===t?.status&&X(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=_().active;"editing"===e?.phase&&O(e.path,B)||de()}},Ke=(e,t)=>{const n=void 0!==e&&!(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e);let r;if(n)r=e;else if(Re&&Ee.fromStandardType)try{r=Ee.fromStandardType(M,F,Ee.componentProps)}catch(e){return void X({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},M)}else r="number"===oe?Ze(M):M;J(null),we&&V({path:B,collapsed:!1,includeChildren:!1}),K({op:"edit",path:B,value:r,onCommit:t}).then(Pe(r))};ve.current=Ke;const _e=()=>{J(null),de(),L()},{isEditingKey:ze}=Q,We=!!$,Ye=fe&&ue.length>1,Ue=("invalid"!==oe||je)&&!$&&ke,$e=g&&Oe,qe=()=>I(B,{cancelOp:de,commitOp:e=>ve.current(void 0,e)}),et=W?qe:f,tt=e=>()=>{const t=Z(e);t&&Ke(void 0,()=>I(t))},nt={value:M,parentData:o,setValue:se,isEditing:fe,canEdit:W,setIsEditing:et,handleEdit:Ke,handleCancel:_e,path:B,stringTruncateLength:v,showStringQuotes:b,showIconTooltips:R,nodeData:F,enumType:pe,translate:E,handleKeyboard:k,keyboardCommon:{cancel:_e,tabForward:tt("next"),tabBack:tt("prev")},Select:S},rt={...G({handleCancel:_e,getStyles:P}),customNodeData:Ee},ot=Re?t(je,{...n,value:M,componentProps:Se,setValue:se,handleEdit:Ke,handleCancel:_e,onKeyDown:e=>k(e,{stringConfirm:Ke,cancel:_e}),isEditing:fe,isPending:ye,setIsEditing:et,getStyles:P,originalNode:Ne?Qe(r,oe,nt):void 0,originalNodeKey:Ne?t(He,{...rt,customNodeData:void 0}):void 0,canEdit:W,keyboardCommon:nt.keyboardCommon}):Qe(r,oe,nt);return e("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==o?D/2+"em":0,position:"relative"},draggable:U&&!fe&&!ze,...q,...ee("above"),children:[te,t(re,{position:"above",nodeData:F}),e("div",{className:"jer-value-main-row",style:{...P("valueRow",F),flexWrap:H.length>10?"wrap":"nowrap"},children:[$e&&t(He,{...rt}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:ot}),fe?t(Le,{onOk:Ke,onCancel:_e,nodeData:F,translate:E,showIconTooltips:R,editConfirmRef:x}):Ue&&t(Ie,{startEdit:W?qe:void 0,handleDelete:Y?()=>{K({op:"delete",path:B,instant:!0}).then(e=>{"error"===e?.status&&X(e.error,M)})}:void 0,showClipboardButton:s,onCopy:u,translate:E,customButtons:n.customButtons,nodeData:F,handleKeyboard:k,keyboardControls:T,editConfirmRef:x,jsonStringify:N,showIconTooltips:R,Select:S}),Ye&&t(S,{name:`${H}-type-select`,value:pe?pe.enum:oe,onChange:e=>Ae(e),options:ue.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),We&&t("span",{className:"jer-error-slug",style:P("error",F),children:$})]})]}),t(re,{position:"below",nodeData:F})]})},$e=/*#__PURE__*/r.memo(Ue,Ye),Xe=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,Je=(e,t)=>t?.CustomComponent&&t?.name&&t.showInTypeSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",Qe=(e,n,r)=>{const o=Ke.includes(n)?n:"function"==typeof e?"invalid":Je(r.value),{value:a}=r;switch(o){case"string":return t(Oe,{...r,value:a});case"number":return t(ke,{...r,value:a});case"boolean":return t(Te,{...r,value:a});case"null":return t(Ne,{...r});default:return t(Re,{...r})}},Ze=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Ge=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Ze(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},qe=r=>{const{getStyles:o}=ne(),{open:l,cancel:s,submit:u,areChildrenBeingEdited:h}=ce(),{setCollapseState:m}=he(),{mainContainerRef:y,data:v,nodeData:b,parentData:w,showCollectionCount:D,canDragOnto:E,canAddHere:C,collapseFilter:j,collapseAnimationTime:S,showClipboardButton:O,onCopy:T,showIconTooltips:x,indent:N,sort:R,showArrayIndexes:A,defaultValue:P,newKeyOptions:I,translate:L,customNodeDefinitions:K,customNodeData:_,jsonParse:V,jsonStringify:F,TextEditor:B,Select:H,keyboardControls:W,handleKeyboard:U,insertAtTop:$,onCollapse:X,editConfirmRef:J,collapseClickZones:Q,getLatestData:Z}=r,[G,q]=p(null),ee=j(b),{contentRef:te,isAnimating:re,maxHeight:oe,collapsed:ae,animateCollapse:ie,cssTransitionValue:le}=((e,t,n,r,o)=>{const[a,l]=p(n?0:void 0),[s,c]=p(n),u=i(!1),h=i(null),m=i(0),f=i(0),y=t/1e3+"s",g=d(n=>{if(s!==n){switch(window.clearTimeout(f.current),u.current=!0,n){case!0:{const e=h.current?.offsetHeight??0;m.current=e,l(e),setTimeout(()=>{l(0)},5);break}case!1:l(m.current||((e,t,n,r)=>{if(!t.current)return 0;const o=parseInt(getComputedStyle(n.current).getPropertyValue("line-height"))||16,a=(t.current?.offsetWidth??0)/(.5*o),i=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/a)).reduce((e,t)=>e+t,0)*o;return Math.min(i+30,window.innerHeight-50)})(e,h,r,o))}c(!s),f.current=window.setTimeout(()=>{u.current=!1,n||l(void 0)},t)}},[t,s,e,r,o]);return{contentRef:h,isAnimating:u.current,animateCollapse:g,maxHeight:a,collapsed:s,cssTransitionValue:y}})(v,S,ee,y,F),{pathString:se,nodeData:ue,path:pe,name:fe,size:ye,canEdit:ge,canDelete:ve,canAdd:be,canDrag:we,error:Ee,setError:Ce,onError:je,derivedValues:Se,buildKeyDisplayProps:Oe}=Fe({props:r,collapsed:ae}),{dragSourceProps:ke,getDropTargetProps:Te,BottomDropTarget:xe,DropTargetPadding:Ne}=Be({canDrag:we,canDelete:ve,canDragOnto:E,canAddHere:C,path:pe,nodeData:ue,onError:je,translate:L}),Re=i(!ee),{isEditing:Ae,isEditingKey:Ke,isPending:_e,isArray:Ve}=Se,Me=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(j);a(()=>{const e=j(ue)&&!Ae;Re.current=!e,ie(e),Me&&m(null)},[j]),((e,t,n)=>{const{commands:r,version:o}=he(),l=i(0);a(()=>{if(o===l.current)return;if(l.current=o,!r)return;let a;for(const t of r)me(e,t)&&(a=t);a&&(a.collapsed||(t.current=!0),n(a.collapsed))},[o,r])})(pe,Re,ie);const We=i(null),Ye=d(e=>q(t=>"function"==typeof e?e(t??F(v)):e),[v,F]),Ue=d(()=>q(null),[]),Xe=c(()=>Ae?G??F(v):null,[Ae,G,v,F]),Je=d((e,t)=>{if("function"!=typeof P)return P;const n=P(e,t);return void 0!==n?n:null},[P]),Qe=d(e=>I?"function"!=typeof I?I:I(e):null,[I]),{CustomComponent:Ze,componentProps:Ge,CustomWrapperComponent:qe,wrapperProps:tt={},showKey:nt=!0,showEditTools:rt=!0,showOnEdit:ot,showOnView:at,showCollectionWrapper:it=!0}=_,lt=de(e=>null!==e.active&&k(e.active.path,pe));lt&&ae&&ie(!1);const st=De(pe)||0===ue.level,ct=i(f);if(!st&&!lt)return null;const{visibleSize:dt}=ue,ut=Array.isArray(v)?"array":"object",pt="array"===ut?{open:"[",close:"]"}:{open:"{",close:"}"},ht=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=Y(We,"\t");return void q(t)}U(e,{objectConfirm:ft,cancel:gt})},mt=e=>{e.stopPropagation();const t=z(e);if(t&&W.collapseModifier.includes(t))return Re.current=!0,void m({collapsed:!ae,path:pe,includeChildren:!0});h(pe)||(Re.current=!0,X&&X({...ue,fullData:Z(),collapsed:!ae,includeChildren:!1}),ie(!ae))},ft=e=>{const t=Xe??F(v);let n;try{n=V(t)}catch{return void je({code:"INVALID_JSON",message:L("ERROR_INVALID_JSON",ue)},t)}Ce(null);const r="function"==typeof e?e:void 0;u({op:"edit",path:pe,value:n,onCommit:()=>{Ue(),r?.()}}).then(e=>{"error"===e?.status&&je(e.error,n)})};ct.current=ft;const yt=pe.length>0?()=>{u({op:"delete",path:pe,instant:!0}).then(e=>{"error"===e?.status&&je(e.error,v)})}:void 0,gt=()=>{s(),Ce(null),Ue()},vt="when-collapsed"===D?ae:"when-collapsed-or-filtered"===D?ae||null!=dt:D,bt=!Ae&&rt,wt=(A||!Ve)&&nt&&void 0!==fe,Dt=Ze&&(Ae&&ot||!Ae&&at),Et=Object.entries(v).map(([e,t])=>["array"===ut?Number(e):e,t]);"object"===ut&&R(Et,e=>e);const Ct=!Ae||!!Ze&&ot,jt=Re.current?Ct?Et.map(([e,n],a)=>{const i={key:e,value:n,path:[...pe,e],level:pe.length+1,index:a,size:g(n)?Object.keys(n).length:null,parentData:v,fullData:ue.fullData},l=ze(K,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:g(n)&&!l?.renderCollectionAsValue?t(et,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ge,canAddHere:be,customNodeData:l},e):t($e,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ge,canAddHere:be,showLabel:"object"===ut||A,customNodeData:l},e)},e)}):e("div",{className:"jer-collection-text-edit"+(B?"-custom":""),children:[B?t(B,{value:Xe??"",onChange:q,onKeyDown:e=>U(e,{objectConfirm:ft,cancel:gt})}):t(M,{textAreaRef:We,className:"jer-collection-text-area",name:se,value:Xe??"",setValue:Ye,onKeyDown:ht,styles:o("input",ue)}),t("div",{className:"jer-collection-input-button-row",children:t(Le,{onOk:ft,onCancel:gt,nodeData:ue,translate:L,showIconTooltips:x,editConfirmRef:J})})]}):null,St=!!it&&ae&&!lt;St||(Re.current=!0);const Ot=L(ae?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",ue),kt=()=>({...r,data:v,value:v,parentData:w,nodeData:ue,setValue:e=>u({op:"edit",path:pe,value:e}),handleEdit:ft,handleCancel:gt,onKeyDown:ht,isEditing:Ae,isPending:_e,setIsEditing:ge?()=>l(pe,{cancelOp:Ue,commitOp:e=>ct.current(e)}):f,getStyles:o,canDragOnto:ge,canAddHere:be,canEdit:ge,keyboardCommon:{}}),Tt=Dt?t(Ze,{componentProps:Ge,...kt(),children:jt}):jt,xt=bt&&t(Ie,{startEdit:ge?()=>{Re.current=!0,l(pe,{cancelOp:Ue,commitOp:e=>ct.current(e)})}:void 0,handleAdd:be?e=>{m(null),ie(!1);const t=Je(ue,e);if("array"===ut){const e=$.array?0:v.length,n=$.array?{insert:!0}:{};return void u({op:"add",path:pe,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&je(e.error,t)})}if(e in v)return je({code:"KEY_EXISTS",message:L("ERROR_KEY_EXISTS",ue)},e),void s();const n=$.object?{insertBefore:0}:{};u({op:"add",path:pe,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&je(e.error,t)})}:void 0,handleDelete:ve?yt:void 0,showClipboardButton:O,onCopy:T,type:ut,nodeData:ue,translate:L,customButtons:r.customButtons,keyboardControls:W,handleKeyboard:U,getNewKeyOptions:Qe,editConfirmRef:J,jsonStringify:F,showIconTooltips:x,Select:H}),Nt=Oe({handleCancel:gt,getStyles:o,keyValueArray:Et,handleClick:Q.includes("property")?mt:e=>e.stopPropagation()}),Rt=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===pe.length?0:N/2)+"em",...o("collection",ue),position:"relative"},draggable:we&&!Ae&&!Ke&&!lt,...ke,...Te("above"),children:[t("div",{className:"jer-clickzone",style:{width:N/2+1+"em",zIndex:10+2*ue.level},onClick:Q.includes("left")?mt:void 0}),!Ae&&xe,t(Ne,{position:"above",nodeData:ue}),it?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ue),position:"relative"},onClick:Q.includes("header")?mt:void 0,children:[e("div",{className:"jer-collection-name",children:[t("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(ae?" jer-rotate-90":""),style:{zIndex:11+2*ue.level,transition:le},onClick:mt,tabIndex:-1,"aria-expanded":!ae,"aria-label":Ot,title:x?Ot:"",children:t(Pe,{name:"collection",nodeData:ue})}),wt&&t(He,{...Nt}),!Ae&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",ue),children:pt.open})]}),!1!==D&&!Ae&&t("div",{className:"jer-collection-item-count"+(vt?" jer-visible":" jer-hidden"),style:{...o("itemCount",ue),transition:le,transitionBehavior:"allow-discrete"},children:null!=dt&&dt!==ye?L("ITEMS_FILTERED",ue,{visible:dt,total:ye}):1===ye?L("ITEM_SINGLE",{...ue,size:1},1):L("ITEMS_MULTIPLE",ue,ye)}),t("div",{className:"jer-brackets"+(St?" jer-visible":" jer-hidden"),style:{...o("bracket",ue),transition:le},children:pt.close}),xt]}):nt?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ue),position:"relative"},children:[t(He,{...Nt}),xt]}):t(n,{}),e("div",{className:"jer-collection-inner",style:{overflowY:St||re?"clip":"visible",maxHeight:lt?void 0:oe,...o("collectionInner",ue),transition:le},ref:te,children:[Tt,t("div",{className:Ae?"jer-collection-error-row-edit":"jer-collection-error-row",children:Ee&&t("span",{className:"jer-error-slug",style:o("error",ue),children:Ee})}),!Ae&&it&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",ue),children:pt.close})]}),t(Ne,{position:"below",nodeData:ue})]});return qe?t(qe,{wrapperProps:tt,...kt(),children:Rt}):Rt},et=/*#__PURE__*/r.memo(qe,Ye),tt=({options:n,value:r,defaultValue:o,onChange:a,placeholder:i,className:l,...s})=>e("div",{className:"jer-select",children:[e("select",{className:l??"jer-select-inner",onChange:e=>a(e.target.value),...s,...void 0!==r?{value:r}:{defaultValue:o??""},children:[void 0!==i&&t("option",{value:"",disabled:!0,children:i}),n.map(e=>t("option",{value:e,children:e},e))]}),t("span",{className:"focus"})]}),nt=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},rt=({key:e,path:t},n="")=>!!nt({value:e},n)||!!t.some(e=>nt({value:e},n)),ot={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",SHOW_MORE:"Show more",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel",TOOLTIP_COLLAPSE:"Collapse",TOOLTIP_EXPAND:"Expand"};var at=':host,:root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff;--jer-icon-copy-color:#268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{left:-1.2em;position:absolute;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;font-family:inherit;font-size:.85em;line-height:1.25em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row-edit{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-string-expansion.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em;margin-right:.2em}.jer-confirm-buttons>button,.jer-edit-buttons>button,button.jer-collapse-icon,button.jer-string-expansion{appearance:none;background:none;border:none;color:inherit;font:inherit;margin:0;padding:0;vertical-align:baseline}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #b4b4b4;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}';const it="data-jer-styles",lt=(e,t)=>JSON.stringify(e,t,2),st={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},ct={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},dt=e=>{const t=i(e);e&&(t.current=e);const n=i((...e)=>t.current(...e));return e?n.current:void 0},ut=[],pt=["header","left"],ht={},mt={},ft={},yt=[],gt=({data:e,setData:n,buildNodeDataFromPathRef:r,commitRef:o,rootName:l="root",onUpdate:s=f,onChange:u,onError:h,onEditEvent:w,showErrorMessages:E=!0,showClipboardButton:C=!0,onCopy:j,indent:O=2,collapse:k=3,collapseAnimationTime:T=300,showCollectionCount:x="when-collapsed-or-filtered",allowEdit:N=!0,allowDelete:R=!0,allowAdd:A=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:K,searchText:V,searchDebounceTime:M=350,sortKeys:z=!1,showArrayIndexes:B=!0,arrayIndexStart:Y=0,showStringQuotes:U=!0,showIconTooltips:$=!1,defaultValue:X=null,newKeyOptions:J,minWidth:Q=250,maxWidth:Z="min(600px, 90vw)",baseFontSize:G,stringTruncateLength:q=250,translations:ee=ht,className:te,id:re,customText:oe=mt,customNodeDefinitions:ae=ut,customButtons:ie=yt,jsonParse:le=JSON.parse,jsonStringify:se=lt,TextEditor:de,Select:ue=tt,errorDisplayTime:pe=2500,keyboardControls:me=ft,editorRef:fe,insertAtTop:ye=!1,onCollapse:ge,collapseClickZones:ve=pt})=>{const{getStyles:we,cssVars:De}=ne(),{open:Ee,cancel:Ce,getSnapshot:je}=ce(),Se=c(()=>wt(k),[k]),Oe=c(()=>((e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}let a=r in e?e[r]:ot[r];if(void 0!==o){const e=v(o)?o:{count:o};for(const[t,n]of Object.entries(e))a=a?.replace(`{{${t}}}`,String(n))}return a})(e,t,r,n,o))(ee,oe),[ee,oe]),[ke,Te]=p(V),xe=i(null);a(()=>{Ce();const e=setTimeout(()=>Te(V),M);return()=>clearTimeout(e)},[V,M]);const Ne=_(e,[],l),Re=i(e);Re.current=e;const Ae=i(n);Ae.current=n;const Pe=i(Oe);Pe.current=Oe;const Ie=i(Ne);Ie.current=Ne;const Le=i(s);Le.current=s;const Ke=i(l);Ke.current=l;const _e=i(void 0),Ve=d(()=>Re.current,[]),Me=dt(u),Fe=dt(h),Be=dt(ge),He=dt(w),We=dt(j),Ye=d(e=>{Re.current=e,Ae.current(e)},[]),Ue=d((e,t)=>{Ye(bt(Re.current,e,t,"update").newData)},[Ye]),Xe=d(e=>{const t=Re.current,n=Ke.current,r=_e.current,o=Ye,{op:a,path:i}=e;switch(a){case"edit":{const{newData:a,currentValue:l,newValue:s}=bt(t,i,e.value,"update"),c=_(t,i,n,r);return{input:{...c,newData:a,event:"edit",newValue:s},nodeData:c,isNoOp:l===s,apply:()=>o(a),revert:()=>o(bt(Re.current,i,l,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=bt(t,i,"","delete"),l=_(t,i,n,r);return{input:{...l,newData:e,event:"delete"},nodeData:l,isNoOp:!1,apply:()=>o(e),revert:()=>o(bt(Re.current,i,a,"add",{insert:!0,insertBefore:l.index}).newData)}}case"add":{const a=[...i,e.key],{newData:l,newValue:s}=bt(t,a,e.value,"add",e.options),c=_(l,a,n,r);return{input:{...c,value:void 0,size:null,parentData:L(t,i)??null,fullData:t,newData:l,event:"add",newValue:s},nodeData:c,isNoOp:!1,apply:()=>o(l),revert:()=>o(bt(Re.current,a,"","delete").newData)}}case"rename":{const a=i.slice(0,-1),l=i[i.length-1],{newKey:s}=e,c=L(t,a),d=Object.fromEntries(Object.entries(c).map(([e,t])=>e===l?[s,t]:[e,t])),{newData:u}=bt(t,a,d,"update"),p=_(t,i,n,r);return{input:{...p,newData:u,event:"rename",newKey:s},nodeData:p,isNoOp:l===s,apply:()=>o(u),revert:()=>o(bt(Re.current,a,c,"update").newData),extra:{oldKey:l,newKey:s}}}case"move":{const a=i,{path:l,position:s}=e.to,c=t,{newData:d,currentValue:u}=bt(t,a,"","delete"),p=a.slice(-1)[0],h=l.slice(0,-1),m=l.slice(-1)[0];let f="number"==typeof m?"above"===s?m:m+1:"number"==typeof p?`arr_${p}`:p;a.slice(0,-1).join(".")===l.slice(0,-1).join(".")&&"number"==typeof p&&"number"==typeof f&&p<f&&(f-=1);const y="number"==typeof f?{insert:!0}:"above"===s?{insertBefore:m}:{insertAfter:m},g=[...h,f],{newData:v}=bt(d,g,u,"add",y),b=_(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Ye]),Je=d((e,t)=>{const n=ct[e.event],r=()=>Pe.current(st[e.event],Ie.current),o=e=>{const t=e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r();return{status:"error",error:{code:n,message:t}}},a=t=>{if(!1===t)return{status:"error",error:{code:n,message:r()}};if(null===t)return{status:"cancel"};if(t&&"object"==typeof t){if(void 0!==t.error)return"string"==typeof t.error?{status:"error",error:{code:n,message:t.error}}:{status:"error",error:t.error};const r=void 0!==t.data,o=void 0!==t.value;if(r&&o&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),r)return{status:"override",value:t.data,path:[]};if(o&&("edit"===e.event||"add"===e.event))return{status:"override",value:t.value,path:e.path}}return{status:"commit"}};let i;try{i=Le.current(e,t)}catch(e){return o(e)}return b(i)?i.then(a,o):a(i)},[]),Qe=c(()=>({runUpdate:s===f?void 0:Je,buildCommit:Xe,applyValue:Ue}),[Je,Xe,Ue,s]);o.current=Qe;const Ze=c(()=>wt(N),[N]),Ge=c(()=>wt(R),[R]),qe=c(()=>wt(A),[A]),rt=c(()=>wt(I),[I]),at=c(()=>Dt(K),[K]),it=c(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,o=new Map,a=t??nt,i=n??"",l=e=>{let t=a(e,i);if(g(e.value)){let n=0;const r=Array.isArray(e.value),a=Object.entries(e.value);for(const[o,i]of a){const a=r?Number(o):o,s={key:a,path:[...e.path,a],level:e.level+1,index:n,value:i,size:g(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(s)&&(t=!0,n++)}o.set(S(e.path),n)}return t&&r.add(S(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:o}})(Ne,at,ke),[e,ke,at,l]),gt=c(()=>(e=>{const t={...H};for(const n of Object.keys(H)){const r=n,o=e[r];if(void 0===o)continue;const a="clipboardModifier"===n||"collapseModifier"===n;if(null===o){t[r]=a?[]:null;continue}const i=(()=>a?y(o):"string"==typeof o?{key:o}:o)();t[r]=i}return W.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(me),[me]),vt=d((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(F(n,e[r],r)){n.preventDefault(),o();break}})(gt,t,e),[gt]),Ct=c(()=>{const e=Et(ae,"stringifyReplacer");return t=>se(t,e)},[ae,se]),jt=c(()=>{const e=Et(ae,"parseReviver");return t=>{const n=le(t,e);return D(n)}},[ae,le]),St=i(null),{setCollapseState:Ot}=he(),kt=d((e,t)=>{!1!==z&&("function"!=typeof z?e.sort((e,n)=>{const r=t(e)[0],o=t(n)[0];return r<o?-1:r>o?1:0}):e.sort((e,n)=>z(t(e),t(n))))},[z]);_e.current=kt;const Tt=d(e=>_(Ve(),e,Ke.current,_e.current),[Ve]);r.current=Tt,m(fe,()=>{const e=Symbol("path-missing");return{collapse:e=>Ot(e),startEdit:({path:t,overrideRestrictions:n=!1})=>L(Ve(),t,e)===e?"PATH_NOT_FOUND":n||Ze(_(Ve(),t,l,kt))?(Ee(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{St.current&&(St.current.click(),"editing"!==je().active?.phase&&Ce())},cancel:()=>Ce()}},[Ot,Ee,Ce,je,Ze,Ve,l,kt]);const xt=ze(ae,Ne),Nt=c(()=>({object:!0===ye||"object"===ye,array:!0===ye||"array"===ye}),[ye]),Rt={mainContainerRef:xe,name:l,nodeData:Ne,getLatestData:Ve,onChange:Me,onError:Fe,onEditEvent:He,showErrorMessages:E,showCollectionCount:x,collapseFilter:Se,collapseAnimationTime:T,allowEditFilter:Ze,allowDeleteFilter:Ge,allowAddFilter:qe,allowTypeSelection:P,allowDragFilter:rt,canDragOnto:!1,canAddHere:!1,showClipboardButton:C,onCopy:We,sortKeys:z,sort:kt,showArrayIndexes:B,arrayIndexStart:Y,showStringQuotes:U,showIconTooltips:$,indent:O,defaultValue:X,newKeyOptions:J,stringTruncateLength:q,translate:Oe,customNodeDefinitions:ae,customNodeData:xt,customButtons:ie,parentData:null,jsonParse:jt,jsonStringify:Ct,TextEditor:de,Select:ue,errorDisplayTime:pe,handleKeyboard:vt,keyboardControls:gt,insertAtTop:Nt,onCollapse:Be,editConfirmRef:St,collapseClickZones:ve},At={...we("container",Ne),...De,minWidth:Q,maxWidth:Z};return At.fontSize=G??At.fontSize,t("div",{id:re,ref:xe,className:`jer-editor-container ${te??""}`,style:At,children:t(be,{value:it,children:g(e)&&!xt.renderCollectionAsValue?t(et,{data:e,...Rt}):t($e,{data:e,showLabel:!0,...Rt})})})};function vt(e){h(()=>{(()=>{if("undefined"==typeof document)return;const e=document.head.querySelector(`style[${it}]`);if(e)return void(e.textContent!==at&&(e.textContent=at));const t=document.createElement("style");t.setAttribute(it,""),t.textContent=at,document.head.appendChild(t)})()},[]);const n=i(void 0),r=i(void 0),o=e;return t(te,{theme:o.theme??Q,children:t(ge,{onEditEvent:o.onEditEvent,onCollapse:o.onCollapse,buildNodeDataFromPathRef:n,commitRef:r,children:t(gt,{...o,buildNodeDataFromPathRef:n,commitRef:r})})})}const bt=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},i="add"!==r?L(e,t):void 0;return{currentData:e,newData:R(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},wt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Dt=e=>{if(void 0!==e)return"value"===e?nt:"key"===e?rt:"all"===e?(e,t)=>nt(e,t)||rt(e,t):e},Et=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?E:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}};function Ct(e){const{editorRef:n,...r}=e,o=i(null);return m(n,()=>({collapse:e=>o.current?.collapse(e)}),[]),t(vt,{...r,editorRef:o,setData:f,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}export{M as AutogrowTextArea,Ae as IconSvg,vt as JsonEditor,Ct as JsonViewer,je as StringDisplay,Se as StringEdit,R as assign,_e as collectionDataTypes,Q as defaultTheme,L as extract,g as isCollection,nt as matchNode,rt as matchNodeKey,C as splitPropertyString,Ve as standardDataTypes,S as toPathString,xe as useKeyboardListener,Ke as valueDataTypes};
|
package/build/style.css
CHANGED
|
@@ -293,7 +293,9 @@ select:focus + .focus {
|
|
|
293
293
|
filter: saturate(50%);
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
|
|
296
|
+
/* Two classes, so this outweighs the `font: inherit` in the <button> chrome
|
|
297
|
+
reset below — a single class would lose to it on specificity. */
|
|
298
|
+
.jer-string-expansion.jer-show-less {
|
|
297
299
|
font-size: 80%;
|
|
298
300
|
}
|
|
299
301
|
|
|
@@ -374,16 +376,23 @@ select:focus + .focus {
|
|
|
374
376
|
margin-right: 0.2em;
|
|
375
377
|
}
|
|
376
378
|
|
|
377
|
-
/* The icon controls
|
|
379
|
+
/* The icon controls, the collapse chevron and the string show-more/show-less
|
|
380
|
+
affordances are real <button>s for accessibility. This neutralises the
|
|
378
381
|
user-agent button chrome so they render identically to surrounding elements.
|
|
379
382
|
Only properties a <button> won't otherwise take from context are listed:
|
|
380
383
|
background/border/margin/padding/appearance don't inherit, and form controls
|
|
381
384
|
are UA-special-cased so `font`/`color` must be re-asserted (`font: inherit`
|
|
382
|
-
is load-bearing — the icons are sized in `em
|
|
383
|
-
|
|
384
|
-
|
|
385
|
+
is load-bearing — the icons are sized in `em`, and it carries line-height,
|
|
386
|
+
which keeps the inline expansion buttons on the text baseline). `cursor`
|
|
387
|
+
inherits from the wrapper rule above, whose flexbox also centres the button,
|
|
388
|
+
so neither is needed here. The `>` scoping covers the built-in controls and a
|
|
389
|
+
labelled custom button (both direct children of the wrapper) without reaching
|
|
390
|
+
inside custom-button content; the chevron and the expansion buttons sit
|
|
391
|
+
outside those wrappers, so they're matched on their own classes instead. */
|
|
385
392
|
.jer-edit-buttons > button,
|
|
386
|
-
.jer-confirm-buttons > button
|
|
393
|
+
.jer-confirm-buttons > button,
|
|
394
|
+
button.jer-collapse-icon,
|
|
395
|
+
button.jer-string-expansion {
|
|
387
396
|
appearance: none;
|
|
388
397
|
background: none;
|
|
389
398
|
border: none;
|
|
@@ -391,6 +400,7 @@ select:focus + .focus {
|
|
|
391
400
|
padding: 0;
|
|
392
401
|
font: inherit;
|
|
393
402
|
color: inherit;
|
|
403
|
+
vertical-align: baseline;
|
|
394
404
|
}
|
|
395
405
|
|
|
396
406
|
.jer-input-buttons {
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-edit-react",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.10",
|
|
4
4
|
"description": "React component for editing or viewing JSON/object data",
|
|
5
5
|
"main": "build/index.cjs.js",
|
|
6
6
|
"module": "build/index.esm.js",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
8
|
-
"sideEffects":
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"./build/style.css"
|
|
10
|
+
],
|
|
9
11
|
"exports": {
|
|
10
12
|
".": {
|
|
11
13
|
"types": "./build/index.d.ts",
|