json-edit-react 2.0.0-beta.8 โ†’ 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <!-- Template for the README on the package's npm page: https://www.npmjs.com/package/json-edit-react
2
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
3
+ sections of the source README (README.md), converts GitHub admonitions to plain-markdown
4
4
  bold-label blockquotes (npm strips inline styles), rewrites relative links to absolute GitHub
5
5
  URLs, and writes the result into the build_package/ staging dir. The repo-root README is never
6
6
  touched. Invoked by scripts/stage-package.mjs during pnpm build-package.
@@ -13,7 +13,7 @@ into the generated README.
13
13
  A highly-configurable [React](https://github.com/facebook/react) component for editing or viewing JSON/object data
14
14
 
15
15
 
16
- ## ๐Ÿš€๏ธ [Explore the Demo](https://carlosnz.github.io/json-edit-react-v2/) <!-- omit in toc -->
16
+ ## ๐Ÿš€๏ธ [Explore the Demo](https://carlosnz.github.io/json-edit-react/) <!-- omit in toc -->
17
17
 
18
18
  ![NPM Version](https://img.shields.io/npm/v/json-edit-react)
19
19
  ![GitHub License](https://img.shields.io/github/license/carlosnz/json-edit-react)
@@ -38,23 +38,23 @@ A highly-configurable [React](https://github.com/facebook/react) component for e
38
38
  - ๐ŸŽน **[Keyboard customisation](https://github.com/CarlosNZ/json-edit-react#keyboard-control)** โ€” define your own key bindings
39
39
  - ๐ŸŽฎ **[External control](https://github.com/CarlosNZ/json-edit-react#programmatic-control)** via callbacks and imperative methods
40
40
 
41
- ๐Ÿ’ก Try the **[Live Demo](https://carlosnz.github.io/json-edit-react-v2/)** to see these features in action!
41
+ ๐Ÿ’ก Try the **[Live Demo](https://carlosnz.github.io/json-edit-react/)** to see these features in action!
42
42
 
43
43
  <img width="392" alt="screenshot" src="image/screenshot.png">
44
44
 
45
45
  > **๐Ÿšจ IMPORTANT**
46
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).
47
+ > This documentation is for V2 of **json-edit-react**. Looking for V1? See the [V1 docs](https://github.com/CarlosNZ/json-edit-react/tree/v1.x#readme) and [V1 demo](https://carlosnz.github.io/json-edit-react-v1/).
48
48
  >
49
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
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).
51
+ > ๐ŸŽค๏ธ Got feedback? [Open an issue](https://github.com/CarlosNZ/json-edit-react/issues), or join the conversation in [Discussions](https://github.com/CarlosNZ/json-edit-react/discussions/categories/announcements).
52
52
 
53
53
  ## Optional Companion Packages <!-- omit in toc -->
54
54
 
55
- - **THEMES**: [@json-edit-react/themes](https://www.npmjs.com/package/@json-edit-react/themes) โ€” curated, ready-made [themes] (#themes)
55
+ - **THEMES**: [@json-edit-react/themes](https://www.npmjs.com/package/@json-edit-react/themes) โ€” curated, ready-made [themes](https://github.com/CarlosNZ/json-edit-react#using-a-prebuilt-theme-json-edit-reactthemes)
56
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
57
+ - **UTILITIES**: [@json-edit-react/utils](https://www.npmjs.com/package/@json-edit-react/utils) โ€”ย a collection of helpers and tools for extending and streamlining your **json-edit-react** experience
58
58
 
59
59
  ## Using the editor (for end users)
60
60
 
@@ -74,7 +74,7 @@ It's pretty self explanatory (click the "edit" icon to edit, etc.), but there ar
74
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
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
76
 
77
- [Have a play with the Demo app](https://carlosnz.github.io/json-edit-react-v2/) to get a feel for it!
77
+ [Have a play with the Demo app](https://carlosnz.github.io/json-edit-react/) to get a feel for it!
78
78
 
79
79
  ## Installation
80
80
 
@@ -109,6 +109,4 @@ return <JsonViewer data={ jsonData } { ...otherProps } />
109
109
 
110
110
  ---
111
111
 
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)
112
+ For **FULL DOCUMENTATION**, visit [https://github.com/CarlosNZ/json-edit-react](https://github.com/CarlosNZ/json-edit-react)
@@ -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=>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},D=(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}},C="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(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})]})},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))},R={key:"Enter"},T={confirm:R,cancel:{key:"Escape"},objectConfirm:{...R,modifier:["Meta","Shift","Control"]},objectLineBreak:R,stringConfirm:R,stringLineBreak:{...R,modifier:["Shift"]},numberConfirm:R,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:R,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=K(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(D(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)},K=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),L={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},M={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:L,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:L,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"}},_={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},V=e=>[M,...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:z(M),cssVars:{}},B=t.createContext(F),H=({theme:n=M,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?{[_[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(()=>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})},Y=()=>t.useContext(B),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"}},W=(e,t)=>U[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=W(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=W(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=W(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=W(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=W(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=W(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:D}=y,C=!!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}),C&&((e,t)=>{u({...r,settling:{...r.settling,[e]:t}})})(b,j);const e=W(t,"commit");e&&d(w,e,v),m?.()},R={hold:()=>(k=!0,u({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>O())};if(!C)return O(),Promise.resolve(void 0);const T=h.runUpdate(x,R),N=s(T);if(!k&&!l&&!N)return Promise.resolve(g(o,t,j,T,O,D,()=>S,w,v));const A=N?T:Promise.resolve(T);let P;return k||(l?P=setTimeout(O,100):O()),A.then(e=>(clearTimeout(P),g(o,t,j,e,O,D,()=>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,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(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}=Y(),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}=Y();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}=Y();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}=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:u,keyboardControls:p,handleKeyboard:h,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:j}=Y(),{open:x,cancel:E}=Z(),D=u("KEY_NEW",c),[S,O]=t.useState(D),[R,T]=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(R);C(()=>{if(!P)return T(!1),void O(D);const e=Object.keys(w(c.fullData,N)),t=y?y(c)?.filter(t=>!e.includes(t)):null;t&&O(""),T(t??!0)},[P]);const K=()=>{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},r)=>e.jsx("div",{onClick:e=>n&&n(c,e),children:e.jsx(t,{nodeData:c})},r)),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:R.length>0?u("KEY_SELECT",c):u("NO_KEY_OPTIONS",c),options:R}):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:()=>K(),cancel:()=>E()})},style:j("input",c)}),e.jsx(Ee,{onOk:()=>K(),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})})]}),De=["string","number","boolean","null"],Ce=["object","array"],Se=[...De,...Ce],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:d,canAddHere:h,translate:f,errorDisplayTime:y,sort:g,arrayIndexStart:v,handleKeyboard:b,customNodeData:j}=e,{submit:x}=Z(),[w,E]=t.useState(null),D={...r,collapsed:n,visibleSize:ue(r.path)},{path:C,key:S,size:k}=D,O=p(C),R=G(e=>{const t=e.active;return null!==t&&"edit"===t.op&&m(t.path,C)}),T=G(e=>{const t=e.active;return null!==t&&"rename"===t.op&&m(t.path,C)}),N=G(e=>O in e.settling),A=l(D),I=c(D),K=u(D),L=d(D),M=e=>{i&&(E(e),setTimeout(()=>E(null),y)),console.warn("Error",e)},_=t.useRef(D);_.current=D;const V=t.useCallback((e,t)=>{M(e.message),a&&a({..._.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(),C,e,g,F),H=(e,t)=>{o&&(S!==e&&Object.keys(o).includes(e)?V({code:"KEY_EXISTS",message:f("ERROR_KEY_EXISTS",D)},e):x({op:"rename",path:C,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&V(t.error,e)}))},Y="number"==typeof C.slice(-1)[0],U=null!==o&&!Y&&I&&h,W={isEditing:R,isEditingKey:T,isPending:N,isArray:Y,canEditKey:U},$=""===S&&C.length>0?f("EMPTY_STRING",D):null;return{pathString:O,nodeData:D,path:C,name:S,size:k,canEdit:A,canDelete:I,canAdd:K,canDrag:L,error:w,showError:M,onError:V,setError:E,handleEditKey:H,derivedValues:W,emptyStringKey:$,getNextOrPreviousAtPath:B,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:U,isEditingKey:T,pathString:O,path:C,name:S,arrayIndexStart:v,handleKeyboard:b,handleEditKey:H,handleCancel:e,styles:t("property",D),getNextOrPrevious:B,emptyStringKey:$,nodeData:D,customNodeData:j,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Te=({canDrag:n,canDelete:r,canDragOnto:o,canAddHere:a,path:s,nodeData:i,onError:l,translate:c})=>{const{getStyles:u}=Y(),{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=t.memo(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:D,jsonStringify:C,showIconTooltips:S,getLatestData:k}=r,{getStyles:O}=Y(),{open:R,cancel:T,submit:N,getSnapshot:A}=Z(),{setCollapseState:P}=te(),[I,K]=t.useState("function"==typeof o?de:o),{nodeData:L,path:M,name:_,canEdit:V,canDelete:z,canDrag:F,error:B,onError:H,setError:U,derivedValues:W,getNextOrPreviousAtPath:$,buildKeyDisplayProps:J}=Re({props:r}),{dragSourceProps:X,getDropTargetProps:Q,BottomDropTarget:G,DropTargetPadding:q}=Te({canDrag:F,canDelete:z,canDragOnto:u,canAddHere:d,path:M,nodeData:L,onError:H,translate:v}),[ee,ne]=t.useState(Le(o,j)),re=t.useRef(I);re.current=I;const oe=t.useRef(L);oe.current=L;const ae=t.useCallback(e=>{if(!s)return void K(e);const t=s({...oe.current,value:re.current,fullData:k(),newValue:e});K(t)},[s,k]),se=()=>{K("function"==typeof o?de:o),ne(Le(o,j)),ue(i(o,ie))};t.useEffect(()=>{W.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(L);return"boolean"==typeof t?t?e:[]:t},[L,p,b]),[le,ue]=t.useState(i(I,ie)),{isEditing:pe,isPending:me}=W,he=ce(M),fe=t.useRef(n);if(!he)return null;const ye=pe&&ee!==Le(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:De=!0,showOnEdit:Ce,showOnView:Oe,passOriginalNode:Ae}=ve,Pe=be&&(void 0!==ge||!ye&&(pe&&Ce||!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(L):r.defaultValue;if(Ke(r)){let o=t;if(r.fromStandardType)try{o=r.fromStandardType(n,L,r.componentProps)}catch{}return K(o),ne(e),void ue(null)}return N({op:"edit",path:M,value:t}).then(ze(t)),void P({path:M,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)||K(o.values[0]),ue(o),void ne(e);const a=Ve(n,e,v("DEFAULT_NEW_KEY",L));if("object"===e||"array"===e||"null"===e)return N({op:"edit",path:M,value:a}).then(ze(a)),void("null"!==e&&P({path:M,collapsed:!1,includeChildren:!1}));K(a),ne(e),ue(null)},ze=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,M)||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,L,ve.componentProps)}catch(e){return void H({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},I)}else r="number"===ee?_e(I):I;U(null),ge&&P({path:M,collapsed:!1,includeChildren:!1}),N({op:"edit",path:M,value:r,onCommit:t}).then(ze(r))};fe.current=Fe;const Be=()=>{U(null),se(),T()},{isEditingKey:He}=W,Ye=!!B,Ue=pe&&ie.length>1,We=("invalid"!==ee||be)&&!B&&De,$e=h&&xe,Je=()=>R(M,{cancelOp:se,commitOp:e=>fe.current(void 0,e)}),Xe=V?Je:n,Qe=e=>()=>{const t=$(e);t&&Fe(void 0,()=>R(t))},Ze={value:I,parentData:a,setValue:ae,isEditing:pe,canEdit:V,setIsEditing:Xe,handleEdit:Fe,handleCancel:Be,path:M,stringTruncateLength:f,showStringQuotes:y,nodeData:L,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:L}),e.jsxs("div",{className:"jer-value-main-row",style:{...O("valueRow",L),flexWrap:_.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:L,translate:v,showIconTooltips:S,editConfirmRef:D}):We&&e.jsx(we,{startEdit:V?Je:void 0,handleDelete:z?()=>{N({op:"delete",path:M,instant:!0}).then(e=>{"error"===e?.status&&H(e.error,I)})}:void 0,showClipboardButton:l,onCopy:c,translate:v,customButtons:r.customButtons,nodeData:L,handleKeyboard:w,keyboardControls:E,editConfirmRef:D,jsonStringify:C,showIconTooltips:S,Select:x}),Ue&&e.jsx(x,{name:`${_}-type-select`,value:le?le.enum:ee,onChange:e=>Ie(e),options:ie.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Ye&&e.jsx("span",{className:"jer-error-slug",style:O("error",L),children:B})]})]}),e.jsx(q,{position:"below",nodeData:L})]})},Pe),Ke=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,Le=(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=De.includes(n)?n:"function"==typeof t?"invalid":Le(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})}},_e=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Ve=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return _e(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},ze=t.memo(r=>{const{getStyles:a}=Y(),{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:D,sort:C,showArrayIndexes:O,defaultValue:R,newKeyOptions:T,translate:N,customNodeDefinitions:P,customNodeData:I,jsonParse:K,jsonStringify:L,TextEditor:M,Select:_,keyboardControls:V,handleKeyboard:z,insertAtTop:F,onCollapse:B,editConfirmRef:H,collapseClickZones:U,getLatestData:W}=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,L),{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}=Re({props:r,collapsed:re}),{dragSourceProps:De,getDropTargetProps:Ce,BottomDropTarget:Se,DropTargetPadding:ke}=Te({canDrag:fe,canDelete:me,canDragOnto:g,canAddHere:v,path:le,nodeData:ie,onError:ve,translate:N}),Ae=t.useRef(!X),{isEditing:Pe,isEditingKey:Ke,isPending:Le,isArray:Me}=be,_e=(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),_e&&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),Fe=t.useCallback(e=>J(t=>"function"==typeof e?e(t??L(p)):e),[p,L]),Be=t.useCallback(()=>J(null),[]),He=t.useMemo(()=>Pe?$??L(p):null,[Pe,$,p,L]),Ye=t.useCallback((e,t)=>{if("function"!=typeof R)return R;const n=R(e,t);return void 0!==n?n:null},[R]),Ue=t.useCallback(e=>T?"function"!=typeof T?T:T(e):null,[T]),{CustomComponent:We,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:W(),collapsed:!re,includeChildren:!1}),oe(!re))},ct=e=>{const t=He??L(p);let n;try{n=K(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:()=>{Be(),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),Be()},pt="when-collapsed"===y?re:"when-collapsed-or-filtered"===y?re||null!=ot:y,mt=!Pe&&Ze,ht=(O||!Me)&&Qe&&void 0!==ue,ft=We&&(Pe&&Ge||!Pe&&qe),yt=Object.entries(p).map(([e,t])=>["array"===at?Number(e):e,t]);"object"===at&&C(yt,e=>e);const gt=!Pe||!!We&&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(ze,{...r,data:n,parentData:p,nodeData:i,canDragOnto:pe,canAddHere:he,customNodeData:l},t):e.jsx(Ie,{...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"+(M?"-custom":""),children:[M?e.jsx(M,{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:Fe,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=()=>({...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:Le,setIsEditing:pe?()=>s(le,{cancelOp:Be,commitOp:e=>rt.current(e)}):n,getStyles:a,canDragOnto:pe,canAddHere:he,canEdit:pe,keyboardCommon:{}}),xt=ft?e.jsx(We,{componentProps:$e,...jt(),children:vt}):vt,wt=mt&&e.jsx(we,{startEdit:pe?()=>{Ae.current=!0,s(le,{cancelOp:Be,commitOp:e=>rt.current(e)})}:void 0,handleAdd:he?e=>{u(null),oe(!1);const t=Ye(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:Ue,editConfirmRef:H,jsonStringify:L,showIconTooltips:E,Select:_}),Et=je({handleCancel:dt,getStyles:a,keyValueArray:yt,handleClick:U.includes("property")?lt:e=>e.stopPropagation()}),Dt=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===le.length?0:D/2)+"em",...a("collection",ie),position:"relative"},draggable:fe&&!Pe&&!Ke&&!tt,...De,...Ce("above"),children:[e.jsx("div",{className:"jer-clickzone",style:{width:D/2+1+"em",zIndex:10+2*ie.level},onClick:U.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: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"+(re?" jer-rotate-90":""),style:{zIndex:11+2*ie.level,transition:ae},onClick:lt,children:e.jsx(xe,{name:"collection",nodeData:ie})}),ht&&e.jsx(Ne,{...Et}),!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}),wt]}):Qe?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",ie),position:"relative"},children:[e.jsx(Ne,{...Et}),wt]}):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:[xt,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,...jt(),children:Dt}):Dt},Pe),Fe=({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"})]})},Be=(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}},He=({key:e,path:t},n="")=>!!Be({value:e},n)||!!t.some(e=>Be({value:e},n)),Ye={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"};var Ue=[],We=[];!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=Ue.indexOf(a);-1===s&&(s=Ue.push(a)-1,We[s]={}),n=We[s]&&We[s][r]?We[s][r]:We[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 $e=(e,t)=>JSON.stringify(e,t,2),Je={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},Xe={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},Qe=e=>{const n=t.useRef(e);e&&(n.current=e);const r=t.useRef((...e)=>n.current(...e));return e?r.current:void 0},Ze=[],Ge=["header","left"],qe={},et={},tt={},nt=[],rt=({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:C=300,showCollectionCount:S="when-collapsed-or-filtered",allowEdit:k=!0,allowDelete:R=!0,allowAdd:A=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:K,searchText:L,searchDebounceTime:M=350,sortKeys:_=!1,showArrayIndexes:V=!0,arrayIndexStart:z=0,showStringQuotes:F=!0,showIconTooltips:B=!1,defaultValue:H=null,newKeyOptions:U,minWidth:W=250,maxWidth:$="min(600px, 90vw)",baseFontSize:J,stringTruncateLength:X=250,translations:Q=qe,className:G,id:q,customText:ee=et,customNodeDefinitions:ne=Ze,customButtons:re=nt,jsonParse:oe=JSON.parse,jsonStringify:ae=$e,TextEditor:se,Select:le=Fe,errorDisplayTime:ce=2500,keyboardControls:ue=tt,editorRef:de,insertAtTop:pe=!1,onCollapse:me,collapseClickZones:he=Ge})=>{const{getStyles:fe,cssVars:ye}=Y(),{open:ge,cancel:ve,getSnapshot:be}=Z(),je=t.useMemo(()=>st(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]:Ye[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(L),De=t.useRef(null);t.useEffect(()=>{ve();const e=setTimeout(()=>Ee(L),M);return()=>clearTimeout(e)},[L,M]);const Ce=D(i,[],m),Se=t.useRef(i);Se.current=i;const ke=t.useRef(c);ke.current=c;const Re=t.useRef(xe);Re.current=xe;const Te=t.useRef(Ce);Te.current=Ce;const Ne=t.useRef(h);Ne.current=h;const Ae=t.useRef(m);Ae.current=m;const Pe=t.useRef(void 0),Ke=t.useCallback(()=>Se.current,[]),Le=Qe(f),Me=Qe(y),_e=Qe(me),Ve=Qe(g),He=Qe(j),Ue=t.useCallback(e=>{Se.current=e,ke.current(e)},[]),We=t.useCallback((e,t)=>{Ue(at(Se.current,e,t,"update").newData)},[Ue]),rt=t.useCallback(e=>{const t=Se.current,n=Ae.current,r=Pe.current,o=Ue,{op:a,path:s}=e;switch(a){case"edit":{const{newData:a,currentValue:i,newValue:l}=at(t,s,e.value,"update"),c=D(t,s,n,r);return{input:{...c,newData:a,event:"edit",newValue:l},nodeData:c,isNoOp:i===l,apply:()=>o(a),revert:()=>o(at(Se.current,s,i,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=at(t,s,"","delete"),i=D(t,s,n,r);return{input:{...i,newData:e,event:"delete"},nodeData:i,isNoOp:!1,apply:()=>o(e),revert:()=>o(at(Se.current,s,a,"add",{insert:!0,insertBefore:i.index}).newData)}}case"add":{const a=[...s,e.key],{newData:i,newValue:l}=at(t,a,e.value,"add",e.options),c=D(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(at(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}=at(t,a,u,"update"),p=D(t,s,n,r);return{input:{...p,newData:d,event:"rename",newKey:l},nodeData:p,isNoOp:i===l,apply:()=>o(d),revert:()=>o(at(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}=at(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}=at(u,g,d,"add",y),b=D(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Ue]),ot=t.useCallback((e,t)=>{const n=Xe[e.event],r=()=>Re.current(Je[e.event],Te.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)},[]),ct=t.useMemo(()=>({runUpdate:h===n?void 0:ot,buildCommit:rt,applyValue:We}),[ot,rt,We,h]);d.current=ct;const ut=t.useMemo(()=>st(k),[k]),dt=t.useMemo(()=>st(R),[R]),pt=t.useMemo(()=>st(A),[A]),mt=t.useMemo(()=>st(I),[I]),ht=t.useMemo(()=>it(K),[K]),ft=t.useMemo(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,a=new Map,s=t??Be,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}})(Ce,ht,we),[i,we,ht,m]),yt=t.useMemo(()=>(e=>{const t={...T};for(const n of Object.keys(T)){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=lt(ne,"stringifyReplacer");return t=>ae(t,e)},[ne,ae]),bt=t.useMemo(()=>{const e=lt(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!==_&&("function"!=typeof _?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)=>_(t(e),t(n))))},[_]);Pe.current=wt;const Et=t.useCallback(e=>D(Ke(),e,Ae.current,Pe.current),[Ke]);u.current=Et,t.useImperativeHandle(de,()=>{const e=Symbol("path-missing");return{collapse:e=>xt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>w(Ke(),t,e)===e?"PATH_NOT_FOUND":n||ut(D(Ke(),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,ut,Ke,m,wt]);const Dt=Oe(ne,Ce),Ct=t.useMemo(()=>({object:!0===pe||"object"===pe,array:!0===pe||"array"===pe}),[pe]),St={mainContainerRef:De,name:m,nodeData:Ce,getLatestData:Ke,onChange:Le,onError:Me,onEditEvent:Ve,showErrorMessages:v,showCollectionCount:S,collapseFilter:je,collapseAnimationTime:C,allowEditFilter:ut,allowDeleteFilter:dt,allowAddFilter:pt,allowTypeSelection:P,allowDragFilter:mt,canDragOnto:!1,canAddHere:!1,showClipboardButton:b,onCopy:He,sortKeys:_,sort:wt,showArrayIndexes:V,arrayIndexStart:z,showStringQuotes:F,showIconTooltips:B,indent:x,defaultValue:H,newKeyOptions:U,stringTruncateLength:X,translate:xe,customNodeDefinitions:ne,customNodeData:Dt,customButtons:re,parentData:null,jsonParse:bt,jsonStringify:vt,TextEditor:se,Select:le,errorDisplayTime:ce,handleKeyboard:gt,keyboardControls:yt,insertAtTop:Ct,onCollapse:_e,editConfirmRef:jt,collapseClickZones:he},kt={...fe("container",Ce),...ye,minWidth:W,maxWidth:$};return kt.fontSize=J??kt.fontSize,e.jsx("div",{id:q,ref:De,className:`jer-editor-container ${G??""}`,style:kt,children:e.jsx(ie,{value:ft,children:o(i)&&!Dt.renderCollectionAsValue?e.jsx(ze,{data:i,...St}):e.jsx(Ie,{data:i,showLabel:!0,...St})})})};function ot(n){const r=t.useRef(void 0),o=t.useRef(void 0),a=n;return e.jsx(H,{theme:a.theme??M,children:e.jsx(ae,{onEditEvent:a.onEditEvent,onCollapse:a.onCollapse,buildNodeDataFromPathRef:r,commitRef:o,children:e.jsx(rt,{...a,buildNodeDataFromPathRef:r,commitRef:o})})})}const at=(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}},st=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,it=e=>{if(void 0!==e)return"value"===e?Be:"key"===e?He:"all"===e?(e,t)=>Be(e,t)||He(e,t):e},lt=(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=ot,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(ot,{...a,editorRef:s,setData:n,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})},exports.StringDisplay=pe,exports.StringEdit=me,exports.assign=v,exports.collectionDataTypes=Ce,exports.defaultTheme=M,exports.extract=w,exports.isCollection=o,exports.matchNode=Be,exports.matchNodeKey=He,exports.splitPropertyString=u,exports.standardDataTypes=Se,exports.toPathString=p,exports.useKeyboardListener=ge,exports.valueDataTypes=De;
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;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=':root,:host{--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;padding:0 1em 0 0;margin:0;font-family:inherit;font-size:.8em;color:#000;cursor:inherit;line-height:inherit;z-index:1;outline:none}select::-ms-expand{display:none}.jer-select{display:grid;grid-template-areas:"select";align-items:center;position:relative;min-width:12ch;max-width:15ch;border:1px solid var(--jer-select-border);border-radius:.25em;padding:.25em .5em;cursor:pointer;line-height:1.1;background-color:#fff;background-image:linear-gradient(to top,#f9f9f9,#fff 33%)}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{content:"";justify-self:end;width:.8em;height:.5em;background-color:var(--jer-select-arrow);clip-path:polygon(100% 0%,0 0%,50% 100%)}select:focus+.focus{position:absolute;inset:-1px;border:1px solid var(--jer-select-focus);border-radius:inherit}.jer-select-inner{width:100%;text-overflow:ellipsis}.jer-editor-container{position:relative;font-size:16px;line-height:1;padding:1em 1em 1em 2em;border-radius:.5em;text-align:left}.jer-editor-container textarea{color:var(--jer-input-color);border:var(--jer-form-border);border-radius:.3em;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;outline:none;font-family:inherit}.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{display:flex;min-height:1.7em;gap:.3em;align-items:center}.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{position:absolute;left:-1.2em;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{display:flex;flex-direction:column;gap:.3em;align-items:flex-start;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;resize:both;padding:.2em .5em 0;overflow:hidden;max-height:40em;line-height:1.25em;font-family:inherit;font-size:.85em}.jer-collection-input-button-row{display:flex;justify-content:flex-end;width:100%;font-size:150%;margin-top:.4em}.jer-collection-error-row-edit{position:absolute;bottom:.5em}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{display:flex;justify-content:flex-start;align-items:center;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}.jer-string-expansion{cursor:pointer;opacity:.6;filter:saturate(50%)}.jer-string-expansion.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;resize:none;margin:0;height:1.4em;padding:.25em .5em .2em;min-width:6em;overflow:hidden;line-height:1.2em;font-family:inherit;font-size:.9em}.jer-input-boolean{transform:scale(1.5);margin-left:.3em;margin-right:.3em}.jer-key-text{word-break:break-word;line-height:1.1em;white-space:pre-wrap}.jer-key-edit{padding:0 .3em;font-size:inherit;font-size:.9em}.jer-value-invalid{opacity:.5;font-style:italic}.jer-input-number{min-width:3em;font-size:90%}.jer-edit-buttons,.jer-confirm-buttons{display:flex;align-items:center;cursor:pointer;height:1em;margin-right:.2em}.jer-edit-buttons>button,.jer-confirm-buttons>button,button.jer-collapse-icon,button.jer-string-expansion{appearance:none;background:none;border:none;margin:0;padding:0;font:inherit;color:inherit;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{opacity:1}.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-value-and-buttons:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-copy-pulse:after{content:"";display:block;position:absolute;border-radius:50%;left:0;top:0;width:100%;height:100%;opacity:0;transition:all .5s;box-shadow:0 0 15px 5px var(--jer-icon-copy-color)}.jer-copy-pulse:active:after{box-shadow:0 0 0 0 var(--jer-icon-copy-color);position:absolute;border-radius:4em;left:0;top:0;opacity:1;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-empty-string{font-style:italic;font-size:90%}.jer-drag-n-drop-padding{height:.5em;border:1px dashed #b4b4b4;border-radius:.3em}.jer-clickzone{position:absolute;left:-1em;top:1.2em;height:calc(100% - .8em)}';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
@@ -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;
@@ -410,6 +413,7 @@ interface CustomButtonDefinition {
410
413
  nodeData: NodeData;
411
414
  }>;
412
415
  onClick: (nodeData: NodeData, e: React.MouseEvent) => void;
416
+ label?: string;
413
417
  }
414
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';
415
419
  type StyleFunction = (nodeData: NodeData) => React.CSSProperties | null | undefined;
@@ -457,6 +461,7 @@ interface StringDisplayProps {
457
461
  canEdit: boolean;
458
462
  setIsEditing: (value: React$1.SetStateAction<boolean>) => void;
459
463
  translate: TranslateFunction;
464
+ showIconTooltips?: boolean;
460
465
  value?: string;
461
466
  TextWrapper?: React$1.ComponentType<{
462
467
  children: React$1.ReactNode;
@@ -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=>null!=e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then,b=(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},w=e=>{if(e!==D){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=w(n);r!==n&&(e[t]=r)}return e}},D="__โ€‹undefined__",E=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),C=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),j=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),S=(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]),O=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},T=e=>Array.isArray(e),N=(e,t)=>e.filter((e,n)=>n!==t),x=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:i=!1}=r,l=e,s=C(t),c={...r,remove:o,createNew:a,noError:i,fullData:l,fullPath:s},d=Array.isArray(t)?t:E(t);return T(e)&&o&&1===d.length?N(e,d[0]):R(e,d,n,c)},R=(e,t,n,r)=>{const o=g(e)?{...e}:null,a=T(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=>R(e,t,n,r));if(1===t.length)return o&&"string"==typeof u?A(o,u,n,r)??o:a&&"number"==typeof u?(P(a,u,n,r),a):(O(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 T(e)?p[u]=N(e,n):O(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],!T(m)&&!g(m)){if(!i)return O(c,d,u,s),p;p[u]={}}return p[u]=R(p[u],h,n,r),p}var m;if(i){const e="number"==typeof h[0]?[]:{};if(o)return p[u]=e,p[u]=R(p[u],h,n,r),p;if(a&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=R(p[t],h,n,r),p}}return O(c,d,u,s),p},A=(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]:O(c,d,t,i):a||u?e[t]=n:O(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):O(a,i,t,o)},I=(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=>I(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:I(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},L=(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=I(e,t),i=I(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}},_="undefined"!=typeof window?o:a,V=({className:n,name:r,value:o,setValue:a,onKeyDown:l,styles:s,textAreaRef:c})=>{const d=i(null);if(_(()=>{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})]})},M=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,z=(e,t,n)=>{if(!t)return!1;const r=e.key,o=M(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))},F={key:"Enter"},B={confirm:F,cancel:{key:"Escape"},objectConfirm:{...F,modifier:["Meta","Shift","Control"]},objectLineBreak:F,stringConfirm:F,stringLineBreak:{...F,modifier:["Shift"]},numberConfirm:F,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:F,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},H=["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=I(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(L(e,u,"",r))?u:U(e,u,n,r,o):null},W=(e,t,n="next",r)=>{const o=I(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})),J={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},X={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:J,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:J,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"}},Q={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},Z=e=>[X,...f(e)].map(e=>"styles"in e?e:{styles:e}),G=e=>{const t={};for(const{icons:n}of Z(e))n&&Object.assign(t,n);return t},q=l({getStyles:()=>({}),icons:G(X),cssVars:{}}),ee=({theme:e=X,children:n})=>{const r=c(()=>(e=>{var t;const n=Z(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?{[Q[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(()=>G(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(q.Provider,{value:l,children:n})},te=()=>s(q),ne={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"}},re=(e,t)=>ne[e][t]??null,oe=(e,t)=>null!==e&&null!==t&&e.op===t.op&&S(e.path,t.path),ae={active:null,settling:{}},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=((e,t,n)=>{let r=ae;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,oe(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=re(e.op,"start");o&&u(e.path,o)},h=(e,t,o,l,s,u,p,h,m)=>{const f=j(e);if(!p()){if("cancel"===l.status||"error"===l.status){r.active&&S(r.active.path,e)&&("held"===r.active.phase||"editing"===r.active.phase)&&(c({...r,active:null}),a=null,i=null);const n=re(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&&!oe(o,n);if(l&&i)return void i(()=>p(n,t));const s=a;if(a=null,i=null,s&&s(),l&&oe(r.active,o)){const e=re(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=re(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 oe(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null,p?.(),Promise.resolve(void 0)}const y=f?.extra,g=j(o),b=++s;if(!l){const e=re(t,"submit");e&&u(o,e)}if(!f||f.isNoOp){oe(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null;const e=re(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,S=!!m?.runUpdate;let k=!1,O=!1;const T=()=>{if(k)return;k=!0,E(),a=null,i=null,oe(r.active,{path:o,op:t})&&c({...r,active:null}),S&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(g,b);const e=re(t,"commit");e&&d(D,e,y),p?.()},N={hold:()=>(O=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>T())};if(!S)return T(),Promise.resolve(void 0);const x=m.runUpdate(w,N),R=v(x);if(!O&&!l&&!R)return Promise.resolve(h(o,t,b,x,T,C,()=>k,D,y));const A=R?x:Promise.resolve(x);let P;return O||(l?P=setTimeout(T,100):T()),A.then(e=>(clearTimeout(P),h(o,t,b,e,T,C,()=>k,D,y)))},areChildrenBeingEdited:e=>null!==r.active&&k(r.active.path,e)}})(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,canDelete:!1}),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(j(e))},De=e=>{const t=be();return null===t?null:t.visibleChildCounts.get(j(e))??null},Ee="**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(V,{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}=te(),i=j(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}=te();return r?t("input",{className:"jer-input-number",type:"text",name:j(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}=te();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:j(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}=te();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===Ee&&(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})},Ae=({name:e,nodeData:n})=>{const{getStyles:r,icons:o}=te(),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})},Pe=({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}=te(),{open:D,cancel:E}=se(),j=u("KEY_NEW",d),[k,O]=p(j),[T,N]=p(!1),{path:x,value:R}=d,A=ce(e=>{const t=e.active;return null!==t&&"add"===t.op&&S(t.path,x)}),P=Array.isArray(T);_(()=>{if(!A)return N(!1),void O(j);const e=Object.keys(I(d.fullData,x)),t=y?y(d)?.filter(t=>!e.includes(t)):null;t&&O(""),N(t??!0)},[A]);const K=()=>{a&&(P&&!k||a("array"===s?"":k))};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=M(e);if(i&&h.clipboardModifier.includes(i)?(t=C(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(Ae,{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(Ae,{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(Ae,{name:"delete",nodeData:d})}),a&&t("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===s?D(x,{op:"add"}):a("")},"aria-label":u("TOOLTIP_ADD",d),title:v?u("TOOLTIP_ADD",d):"",children:t(Ae,{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)),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:k,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>K(),cancel:()=>E()})},style:w("input",d)}),t(Ie,{onOk:()=>K(),onCancel:()=>E(),nodeData:d,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:P})]})]})},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(Ae,{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(Ae,{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,canAddHere:m,translate:f,errorDisplayTime:y,sort:g,arrayIndexStart:v,handleKeyboard:b,customNodeData:w}=e,{submit:D}=se(),[E,C]=p(null),k={...n,collapsed:t,visibleSize:De(n.path)},{path:O,key:T,size:N}=k,x=j(O),R=ce(e=>{const t=e.active;return null!==t&&"edit"===t.op&&S(t.path,O)}),A=ce(e=>{const t=e.active;return null!==t&&"rename"===t.op&&S(t.path,O)}),P=ce(e=>x in e.settling),I=s(k),K=c(k),L=u(k),_=h(k),V=e=>{l&&(C(e),setTimeout(()=>C(null),y)),console.warn("Error",e)},M=i(k);M.current=k;const z=d((e,t)=>{V(e.message),o&&o({...M.current,fullData:a(),error:e,errorValue:t})},[o,l,a,y]),F=be(),B=d(e=>(null===F||F.visiblePaths.has(j(e.path)))&&s(e),[F,s]),H=e=>U(a(),O,e,g,B),Y=(e,t)=>{r&&(T!==e&&Object.keys(r).includes(e)?z({code:"KEY_EXISTS",message:f("ERROR_KEY_EXISTS",k)},e):D({op:"rename",path:O,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&z(t.error,e)}))},W="number"==typeof O.slice(-1)[0],$=null!==r&&!W&&K&&m,J={isEditing:R,isEditingKey:A,isPending:P,isArray:W,canEditKey:$},X=""===T&&O.length>0?f("EMPTY_STRING",k):null;return{pathString:x,nodeData:k,path:O,name:T,size:N,canEdit:I,canDelete:K,canAdd:L,canDrag:_,error:E,showError:V,onError:z,setError:C,handleEditKey:Y,derivedValues:J,emptyStringKey:X,getNextOrPreviousAtPath:H,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:$,isEditingKey:A,pathString:x,path:O,name:T,arrayIndexStart:v,handleKeyboard:b,handleEditKey:Y,handleCancel:e,styles:t("property",k),getNextOrPrevious:H,emptyStringKey:X,nodeData:k,customNodeData:w,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Fe=({canDrag:e,canDelete:n,canDragOnto:r,canAddHere:o,path:a,nodeData:i,onError:l,translate:d})=>{const{getStyles:u}=te(),{dragSource:h,setDragSource:m,armed:f}=(()=>{const e=s(me);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),y=se(),[g,v]=p(!1),b=()=>null!==h.path&&!k(a,h.path)&&(S(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&&!S(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}},Be=({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}=se(),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"}})},He=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||!S(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(!He.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ue=r.memo(n=>{const{data:r,parentData:o,onChange:l,showClipboardButton:s,onCopy:u,canDragOnto:h,canAddHere:f,allowTypeSelection:y,showLabel:g,stringTruncateLength:v,showStringQuotes:w,indent:D,translate:E,customNodeDefinitions:C,customNodeData:j,Select:k,handleKeyboard:O,keyboardControls:T,editConfirmRef:N,jsonStringify:x,showIconTooltips:R,getLatestData:A}=n,{getStyles:P}=te(),{open:I,cancel:K,submit:L,getSnapshot:_}=se(),{setCollapseState:V}=pe(),[M,z]=p("function"==typeof r?Ee:r),{nodeData:F,path:B,name:H,canEdit:Y,canDelete:U,canDrag:W,error:$,onError:J,setError:X,derivedValues:Q,getNextOrPreviousAtPath:Z,buildKeyDisplayProps:G}=ze({props:n}),{dragSourceProps:q,getDropTargetProps:ee,BottomDropTarget:ne,DropTargetPadding:re}=Fe({canDrag:W,canDelete:U,canDragOnto:h,canAddHere:f,path:B,nodeData:F,onError:J,translate:E}),[oe,ae]=p($e(r,j)),ie=i(M);ie.current=M;const le=i(F);le.current=F;const ce=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?Ee:r),ae($e(r,j)),me(b(r,ue))};a(()=>{Q.isEditing||de()},[r]);const ue=c(()=>{const e=[..._e,...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]),[he,me]=p(b(M,ue)),{isEditing:fe,isPending:ye}=Q,ge=we(B),ve=i(m);if(!ge)return null;const be=fe&&oe!==$e(r,j),De=be?C.find(e=>e.name===oe&&We(e)):void 0,Ce=De?Ve(De):j,{CustomComponent:je,componentProps:Se,showKey:ke=!0,showEditTools:Oe=!0,showOnEdit:Te,showOnView:Ne,passOriginalNode:xe}=Ce,Re=je&&(void 0!==De||!be&&(fe&&Te||!fe&&Ne)),Ae=e=>{V(null);const t=be&&!De?void 0:Ce,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(We(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 L({op:"edit",path:B,value:t}).then(Ke(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=Qe(n,e,E("DEFAULT_NEW_KEY",F));if("object"===e||"array"===e||"null"===e)return L({op:"edit",path:B,value:a}).then(Ke(a)),void("null"!==e&&V({path:B,collapsed:!1,includeChildren:!1}));z(a),ae(e),me(null)},Ke=e=>t=>{if("error"===t?.status&&J(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=_().active;"editing"===e?.phase&&S(e.path,B)||de()}},Le=(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&&Ce.fromStandardType)try{r=Ce.fromStandardType(M,F,Ce.componentProps)}catch(e){return void J({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},M)}else r="number"===oe?Xe(M):M;X(null),De&&V({path:B,collapsed:!1,includeChildren:!1}),L({op:"edit",path:B,value:r,onCommit:t}).then(Ke(r))};ve.current=Le;const Me=()=>{X(null),de(),K()},{isEditingKey:He}=Q,Ye=!!$,Ue=fe&&ue.length>1,Ze=("invalid"!==oe||je)&&!$&&Oe,Ge=g&&ke,qe=()=>I(B,{cancelOp:de,commitOp:e=>ve.current(void 0,e)}),et=Y?qe:m,tt=e=>()=>{const t=Z(e);t&&Le(void 0,()=>I(t))},nt={value:M,parentData:o,setValue:ce,isEditing:fe,canEdit:Y,setIsEditing:et,handleEdit:Le,handleCancel:Me,path:B,stringTruncateLength:v,showStringQuotes:w,nodeData:F,enumType:he,translate:E,handleKeyboard:O,keyboardCommon:{cancel:Me,tabForward:tt("next"),tabBack:tt("prev")},Select:k},rt={...G({handleCancel:Me,getStyles:P}),customNodeData:Ce},ot=Re?t(je,{...n,value:M,componentProps:Se,setValue:ce,handleEdit:Le,handleCancel:Me,onKeyDown:e=>O(e,{stringConfirm:Le,cancel:Me}),isEditing:fe,isPending:ye,setIsEditing:et,getStyles:P,originalNode:xe?Je(r,oe,nt):void 0,originalNodeKey:xe?t(Be,{...rt,customNodeData:void 0}):void 0,canEdit:Y,keyboardCommon:nt.keyboardCommon}):Je(r,oe,nt);return e("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==o?D/2+"em":0,position:"relative"},draggable:W&&!fe&&!He,...q,...ee("above"),children:[ne,t(re,{position:"above",nodeData:F}),e("div",{className:"jer-value-main-row",style:{...P("valueRow",F),flexWrap:H.length>10?"wrap":"nowrap"},children:[Ge&&t(Be,{...rt}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:ot}),fe?t(Ie,{onOk:Le,onCancel:Me,nodeData:F,translate:E,showIconTooltips:R,editConfirmRef:N}):Ze&&t(Pe,{startEdit:Y?qe:void 0,handleDelete:U?()=>{L({op:"delete",path:B,instant:!0}).then(e=>{"error"===e?.status&&J(e.error,M)})}:void 0,showClipboardButton:s,onCopy:u,translate:E,customButtons:n.customButtons,nodeData:F,handleKeyboard:O,keyboardControls:T,editConfirmRef:N,jsonStringify:x,showIconTooltips:R,Select:k}),Ue&&t(k,{name:`${H}-type-select`,value:he?he.enum:oe,onChange:e=>Ae(e),options:ue.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Ye&&t("span",{className:"jer-error-slug",style:P("error",F),children:$})]})]}),t(re,{position:"below",nodeData:F})]})},Ye),We=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",Je=(e,n,r)=>{const o=Ke.includes(n)?n:"function"==typeof e?"invalid":$e(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})}},Xe=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Qe=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Xe(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Ze=r.memo(r=>{const{getStyles:o}=te(),{open:l,cancel:s,submit:u,areChildrenBeingEdited:h}=se(),{setCollapseState:f}=pe(),{mainContainerRef:g,data:v,nodeData:b,parentData:w,showCollectionCount:D,canDragOnto:E,canAddHere:C,collapseFilter:j,collapseAnimationTime:S,showClipboardButton:O,onCopy:T,showIconTooltips:N,indent:x,sort:R,showArrayIndexes:A,defaultValue:P,newKeyOptions:I,translate:K,customNodeDefinitions:L,customNodeData:_,jsonParse:z,jsonStringify:F,TextEditor:B,Select:H,keyboardControls:U,handleKeyboard:W,insertAtTop:$,onCollapse:J,editConfirmRef:X,collapseClickZones:Q,getLatestData:Z}=r,[G,q]=p(null),ee=j(b),{contentRef:ne,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,g,F),{pathString:de,nodeData:ue,path:me,name:fe,size:ye,canEdit:ge,canDelete:ve,canAdd:be,canDrag:De,error:Ee,setError:Ce,onError:je,derivedValues:Se,buildKeyDisplayProps:ke}=ze({props:r,collapsed:ae}),{dragSourceProps:Oe,getDropTargetProps:Te,BottomDropTarget:Ne,DropTargetPadding:xe}=Fe({canDrag:De,canDelete:ve,canDragOnto:E,canAddHere:C,path:me,nodeData:ue,onError:je,translate:K}),Re=i(!ee),{isEditing:Ke,isEditingKey:Le,isPending:_e,isArray:Ve}=Se,He=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(j);a(()=>{const e=j(ue)&&!Ke;Re.current=!e,ie(e),He&&f(null)},[j]),((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])})(me,Re,ie);const Ye=i(null),We=d(e=>q(t=>"function"==typeof e?e(t??F(v)):e),[v,F]),$e=d(()=>q(null),[]),Je=c(()=>Ke?G??F(v):null,[Ke,G,v,F]),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=>I?"function"!=typeof I?I:I(e):null,[I]),{CustomComponent:Ge,componentProps:qe,CustomWrapperComponent:et,wrapperProps:tt={},showKey:nt=!0,showEditTools:rt=!0,showOnEdit:ot,showOnView:at,showCollectionWrapper:it=!0}=_,lt=ce(e=>null!==e.active&&k(e.active.path,me));lt&&ae&&ie(!1);const st=we(me)||0===ue.level,ct=i(m);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(Ye,"\t");return void q(t)}W(e,{objectConfirm:ft,cancel:gt})},mt=e=>{e.stopPropagation();const t=M(e);if(t&&U.collapseModifier.includes(t))return Re.current=!0,void f({collapsed:!ae,path:me,includeChildren:!0});h(me)||(Re.current=!0,J&&J({...ue,fullData:Z(),collapsed:!ae,includeChildren:!1}),ie(!ae))},ft=e=>{const t=Je??F(v);let n;try{n=z(t)}catch{return void je({code:"INVALID_JSON",message:K("ERROR_INVALID_JSON",ue)},t)}Ce(null);const r="function"==typeof e?e:void 0;u({op:"edit",path:me,value:n,onCommit:()=>{$e(),r?.()}}).then(e=>{"error"===e?.status&&je(e.error,n)})};ct.current=ft;const yt=me.length>0?()=>{u({op:"delete",path:me,instant:!0}).then(e=>{"error"===e?.status&&je(e.error,v)})}:void 0,gt=()=>{s(),Ce(null),$e()},vt="when-collapsed"===D?ae:"when-collapsed-or-filtered"===D?ae||null!=dt:D,bt=!Ke&&rt,wt=(A||!Ve)&&nt&&void 0!==fe,Dt=Ge&&(Ke&&ot||!Ke&&at),Et=Object.entries(v).map(([e,t])=>["array"===ut?Number(e):e,t]);"object"===ut&&R(Et,e=>e);const Ct=!Ke||!!Ge&&ot,jt=Re.current?Ct?Et.map(([e,n],a)=>{const i={key:e,value:n,path:[...me,e],level:me.length+1,index:a,size:y(n)?Object.keys(n).length:null,parentData:v,fullData:ue.fullData},l=Me(L,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:y(n)&&!l?.renderCollectionAsValue?t(Ze,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ge,canAddHere:be,customNodeData:l},e):t(Ue,{...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:Je??"",onChange:q,onKeyDown:e=>W(e,{objectConfirm:ft,cancel:gt})}):t(V,{textAreaRef:Ye,className:"jer-collection-text-area",name:de,value:Je??"",setValue:We,onKeyDown:ht,styles:o("input",ue)}),t("div",{className:"jer-collection-input-button-row",children:t(Ie,{onOk:ft,onCancel:gt,nodeData:ue,translate:K,showIconTooltips:N,editConfirmRef:X})})]}):null,St=!!it&&ae&&!lt;St||(Re.current=!0);const kt=()=>({...r,data:v,value:v,parentData:w,nodeData:ue,setValue:e=>u({op:"edit",path:me,value:e}),handleEdit:ft,handleCancel:gt,onKeyDown:ht,isEditing:Ke,isPending:_e,setIsEditing:ge?()=>l(me,{cancelOp:$e,commitOp:e=>ct.current(e)}):m,getStyles:o,canDragOnto:ge,canAddHere:be,canEdit:ge,keyboardCommon:{}}),Ot=Dt?t(Ge,{componentProps:qe,...kt(),children:jt}):jt,Tt=bt&&t(Pe,{startEdit:ge?()=>{Re.current=!0,l(me,{cancelOp:$e,commitOp:e=>ct.current(e)})}:void 0,handleAdd:be?e=>{f(null),ie(!1);const t=Xe(ue,e);if("array"===ut){const e=$.array?0:v.length,n=$.array?{insert:!0}:{};return void u({op:"add",path:me,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:K("ERROR_KEY_EXISTS",ue)},e),void s();const n=$.object?{insertBefore:0}:{};u({op:"add",path:me,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:K,customButtons:r.customButtons,keyboardControls:U,handleKeyboard:W,getNewKeyOptions:Qe,editConfirmRef:X,jsonStringify:F,showIconTooltips:N,Select:H}),Nt=ke({handleCancel:gt,getStyles:o,keyValueArray:Et,handleClick:Q.includes("property")?mt:e=>e.stopPropagation()}),xt=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===me.length?0:x/2)+"em",...o("collection",ue),position:"relative"},draggable:De&&!Ke&&!Le&&!lt,...Oe,...Te("above"),children:[t("div",{className:"jer-clickzone",style:{width:x/2+1+"em",zIndex:10+2*ue.level},onClick:Q.includes("left")?mt:void 0}),!Ke&&Ne,t(xe,{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("div",{className:"jer-collapse-icon jer-accordion-icon"+(ae?" jer-rotate-90":""),style:{zIndex:11+2*ue.level,transition:le},onClick:mt,children:t(Ae,{name:"collection",nodeData:ue})}),wt&&t(Be,{...Nt}),!Ke&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",ue),children:pt.open})]}),!1!==D&&!Ke&&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?K("ITEMS_FILTERED",ue,{visible:dt,total:ye}):1===ye?K("ITEM_SINGLE",{...ue,size:1},1):K("ITEMS_MULTIPLE",ue,ye)}),t("div",{className:"jer-brackets"+(St?" jer-visible":" jer-hidden"),style:{...o("bracket",ue),transition:le},children:pt.close}),Tt]}):nt?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ue),position:"relative"},children:[t(Be,{...Nt}),Tt]}):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:ne,children:[Ot,t("div",{className:Ke?"jer-collection-error-row-edit":"jer-collection-error-row",children:Ee&&t("span",{className:"jer-error-slug",style:o("error",ue),children:Ee})}),!Ke&&it&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",ue),children:pt.close})]}),t(xe,{position:"below",nodeData:ue})]});return et?t(et,{wrapperProps:tt,...kt(),children:xt}):xt},Ye),Ge=({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"})]}),qe=(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}},et=({key:e,path:t},n="")=>!!qe({value:e},n)||!!t.some(e=>qe({value:e},n)),tt={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"};var nt=[],rt=[];!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=nt.indexOf(a);-1===i&&(i=nt.push(a)-1,rt[i]={}),n=rt[i]&&rt[i][r]?rt[i][r]:rt[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 ot=(e,t)=>JSON.stringify(e,t,2),at={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},it={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},lt=e=>{const t=i(e);e&&(t.current=e);const n=i((...e)=>t.current(...e));return e?n.current:void 0},st=[],ct=["header","left"],dt={},ut={},pt={},ht=[],mt=({data:e,setData:n,buildNodeDataFromPathRef:r,commitRef:o,rootName:l="root",onUpdate:s=m,onChange:u,onError:b,onEditEvent:D,showErrorMessages:E=!0,showClipboardButton:C=!0,onCopy:S,indent:k=2,collapse:O=3,collapseAnimationTime:T=300,showCollectionCount:N="when-collapsed-or-filtered",allowEdit:x=!0,allowDelete:R=!0,allowAdd:A=!0,allowTypeSelection:P=!0,allowDrag:K=!1,searchFilter:_,searchText:V,searchDebounceTime:M=350,sortKeys:F=!1,showArrayIndexes:Y=!0,arrayIndexStart:U=0,showStringQuotes:W=!0,showIconTooltips:$=!1,defaultValue:J=null,newKeyOptions:X,minWidth:Q=250,maxWidth:Z="min(600px, 90vw)",baseFontSize:G,stringTruncateLength:q=250,translations:ee=dt,className:ne,id:re,customText:oe=ut,customNodeDefinitions:ae=st,customButtons:ie=ht,jsonParse:le=JSON.parse,jsonStringify:ce=ot,TextEditor:de,Select:ue=Ge,errorDisplayTime:he=2500,keyboardControls:me=pt,editorRef:fe,insertAtTop:ye=!1,onCollapse:ge,collapseClickZones:be=ct})=>{const{getStyles:we,cssVars:De}=te(),{open:Ee,cancel:Ce,getSnapshot:je}=se(),Se=c(()=>gt(O),[O]),ke=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]:tt[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))(ee,oe),[ee,oe]),[Oe,Te]=p(V),Ne=i(null);a(()=>{Ce();const e=setTimeout(()=>Te(V),M);return()=>clearTimeout(e)},[V,M]);const xe=L(e,[],l),Re=i(e);Re.current=e;const Ae=i(n);Ae.current=n;const Pe=i(ke);Pe.current=ke;const Ie=i(xe);Ie.current=xe;const Ke=i(s);Ke.current=s;const Le=i(l);Le.current=l;const _e=i(void 0),Ve=d(()=>Re.current,[]),ze=lt(u),Fe=lt(b),Be=lt(ge),He=lt(D),Ye=lt(S),We=d(e=>{Re.current=e,Ae.current(e)},[]),$e=d((e,t)=>{We(yt(Re.current,e,t,"update").newData)},[We]),Je=d(e=>{const t=Re.current,n=Le.current,r=_e.current,o=We,{op:a,path:i}=e;switch(a){case"edit":{const{newData:a,currentValue:l,newValue:s}=yt(t,i,e.value,"update"),c=L(t,i,n,r);return{input:{...c,newData:a,event:"edit",newValue:s},nodeData:c,isNoOp:l===s,apply:()=>o(a),revert:()=>o(yt(Re.current,i,l,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=yt(t,i,"","delete"),l=L(t,i,n,r);return{input:{...l,newData:e,event:"delete"},nodeData:l,isNoOp:!1,apply:()=>o(e),revert:()=>o(yt(Re.current,i,a,"add",{insert:!0,insertBefore:l.index}).newData)}}case"add":{const a=[...i,e.key],{newData:l,newValue:s}=yt(t,a,e.value,"add",e.options),c=L(l,a,n,r);return{input:{...c,value:void 0,size:null,parentData:I(t,i)??null,fullData:t,newData:l,event:"add",newValue:s},nodeData:c,isNoOp:!1,apply:()=>o(l),revert:()=>o(yt(Re.current,a,"","delete").newData)}}case"rename":{const a=i.slice(0,-1),l=i[i.length-1],{newKey:s}=e,c=I(t,a),d=Object.fromEntries(Object.entries(c).map(([e,t])=>e===l?[s,t]:[e,t])),{newData:u}=yt(t,a,d,"update"),p=L(t,i,n,r);return{input:{...p,newData:u,event:"rename",newKey:s},nodeData:p,isNoOp:l===s,apply:()=>o(u),revert:()=>o(yt(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}=yt(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}=yt(d,g,u,"add",y),b=L(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[We]),Xe=d((e,t)=>{const n=it[e.event],r=()=>Pe.current(at[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=Ke.current(e,t)}catch(e){return o(e)}return v(i)?i.then(a,o):a(i)},[]),Qe=c(()=>({runUpdate:s===m?void 0:Xe,buildCommit:Je,applyValue:$e}),[Xe,Je,$e,s]);o.current=Qe;const et=c(()=>gt(x),[x]),nt=c(()=>gt(R),[R]),rt=c(()=>gt(A),[A]),mt=c(()=>gt(K),[K]),ft=c(()=>vt(_),[_]),wt=c(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,o=new Map,a=t??qe,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(j(e.path),n)}return t&&r.add(j(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:o}})(xe,ft,Oe),[e,Oe,ft,l]),Dt=c(()=>(e=>{const t={...B};for(const n of Object.keys(B)){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 H.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(me),[me]),Et=d((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(z(n,e[r],r)){n.preventDefault(),o();break}})(Dt,t,e),[Dt]),Ct=c(()=>{const e=bt(ae,"stringifyReplacer");return t=>ce(t,e)},[ae,ce]),jt=c(()=>{const e=bt(ae,"parseReviver");return t=>{const n=le(t,e);return w(n)}},[ae,le]),St=i(null),{setCollapseState:kt}=pe(),Ot=d((e,t)=>{!1!==F&&("function"!=typeof F?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)=>F(t(e),t(n))))},[F]);_e.current=Ot;const Tt=d(e=>L(Ve(),e,Le.current,_e.current),[Ve]);r.current=Tt,h(fe,()=>{const e=Symbol("path-missing");return{collapse:e=>kt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>I(Ve(),t,e)===e?"PATH_NOT_FOUND":n||et(L(Ve(),t,l,Ot))?(Ee(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{St.current&&(St.current.click(),"editing"!==je().active?.phase&&Ce())},cancel:()=>Ce()}},[kt,Ee,Ce,je,et,Ve,l,Ot]);const Nt=Me(ae,xe),xt=c(()=>({object:!0===ye||"object"===ye,array:!0===ye||"array"===ye}),[ye]),Rt={mainContainerRef:Ne,name:l,nodeData:xe,getLatestData:Ve,onChange:ze,onError:Fe,onEditEvent:He,showErrorMessages:E,showCollectionCount:N,collapseFilter:Se,collapseAnimationTime:T,allowEditFilter:et,allowDeleteFilter:nt,allowAddFilter:rt,allowTypeSelection:P,allowDragFilter:mt,canDragOnto:!1,canAddHere:!1,showClipboardButton:C,onCopy:Ye,sortKeys:F,sort:Ot,showArrayIndexes:Y,arrayIndexStart:U,showStringQuotes:W,showIconTooltips:$,indent:k,defaultValue:J,newKeyOptions:X,stringTruncateLength:q,translate:ke,customNodeDefinitions:ae,customNodeData:Nt,customButtons:ie,parentData:null,jsonParse:jt,jsonStringify:Ct,TextEditor:de,Select:ue,errorDisplayTime:he,handleKeyboard:Et,keyboardControls:Dt,insertAtTop:xt,onCollapse:Be,editConfirmRef:St,collapseClickZones:be},At={...we("container",xe),...De,minWidth:Q,maxWidth:Z};return At.fontSize=G??At.fontSize,t("div",{id:re,ref:Ne,className:`jer-editor-container ${ne??""}`,style:At,children:t(ve,{value:wt,children:y(e)&&!Nt.renderCollectionAsValue?t(Ze,{data:e,...Rt}):t(Ue,{data:e,showLabel:!0,...Rt})})})};function ft(e){const n=i(void 0),r=i(void 0),o=e;return t(ee,{theme:o.theme??X,children:t(ye,{onEditEvent:o.onEditEvent,onCollapse:o.onCollapse,buildNodeDataFromPathRef:n,commitRef:r,children:t(mt,{...o,buildNodeDataFromPathRef:n,commitRef:r})})})}const yt=(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?I(e,t):void 0;return{currentData:e,newData:x(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},gt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,vt=e=>{if(void 0!==e)return"value"===e?qe:"key"===e?et:"all"===e?(e,t)=>qe(e,t)||et(e,t):e},bt=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?D: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 wt(e){const{editorRef:n,...r}=e,o=i(null);return h(n,()=>({collapse:e=>o.current?.collapse(e)}),[]),t(ft,{...r,editorRef:o,setData:m,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}export{V as AutogrowTextArea,Re as IconSvg,ft as JsonEditor,wt as JsonViewer,Ce as StringDisplay,je as StringEdit,x as assign,Le as collectionDataTypes,X as defaultTheme,I as extract,y as isCollection,qe as matchNode,et as matchNodeKey,E as splitPropertyString,_e as standardDataTypes,j 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)}`)},N=e=>Array.isArray(e),x=(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 N(e)&&o&&1===d.length?x(e,d[0]):A(e,d,n,c)},A=(e,t,n,r)=>{const o=v(e)?{...e}:null,a=N(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 N(e)?p[u]=x(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],!N(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;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?.()},N={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 x=m.runUpdate(w,N),R=b(x);if(!k&&!l&&!R)return Promise.resolve(h(o,t,v,x,T,C,()=>O,D,y));const A=R?x:Promise.resolve(x);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)})},Ne=(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])},xe=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:l})=>{const{getStyles:s}=ne();return Ne(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,N]=p(!1),{path:x,value:R}=d,A=de(e=>{const t=e.active;return null!==t&&"add"===t.op&&O(t.path,x)}),P=Array.isArray(T);V(()=>{if(!A)return N(!1),void k(C);const e=Object.keys(L(d.fullData,x)),t=y?y(d)?.filter(t=>!e.includes(t)):null;t&&k(""),N(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(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?D(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,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:N}=j,x=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=>x 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:x,nodeData:j,path:k,name:T,size:N,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:x,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:N,jsonStringify:x,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:Ne,passOriginalNode:xe}=Ee,Re=je&&(void 0!==we||!be&&(fe&&Te||!fe&&Ne)),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:xe?Qe(r,oe,nt):void 0,originalNodeKey:xe?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:N}):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:N,jsonStringify:x,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(xe,{...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:N,indent:x,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:Ne,DropTargetPadding:xe}=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:N,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,Nt=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:N,Select:H}),xt=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:x/2)+"em",...o("collection",ue),position:"relative"},draggable:we&&!Ae&&!Ke&&!lt,...ke,...Te("above"),children:[t("div",{className:"jer-clickzone",style:{width:x/2+1+"em",zIndex:10+2*ue.level},onClick:Q.includes("left")?mt:void 0}),!Ae&&Ne,t(xe,{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:N?Ot:"",children:t(Pe,{name:"collection",nodeData:ue})}),wt&&t(He,{...xt}),!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}),Nt]}):nt?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ue),position:"relative"},children:[t(He,{...xt}),Nt]}):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(xe,{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=':root,:host{--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;padding:0 1em 0 0;margin:0;font-family:inherit;font-size:.8em;color:#000;cursor:inherit;line-height:inherit;z-index:1;outline:none}select::-ms-expand{display:none}.jer-select{display:grid;grid-template-areas:"select";align-items:center;position:relative;min-width:12ch;max-width:15ch;border:1px solid var(--jer-select-border);border-radius:.25em;padding:.25em .5em;cursor:pointer;line-height:1.1;background-color:#fff;background-image:linear-gradient(to top,#f9f9f9,#fff 33%)}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{content:"";justify-self:end;width:.8em;height:.5em;background-color:var(--jer-select-arrow);clip-path:polygon(100% 0%,0 0%,50% 100%)}select:focus+.focus{position:absolute;inset:-1px;border:1px solid var(--jer-select-focus);border-radius:inherit}.jer-select-inner{width:100%;text-overflow:ellipsis}.jer-editor-container{position:relative;font-size:16px;line-height:1;padding:1em 1em 1em 2em;border-radius:.5em;text-align:left}.jer-editor-container textarea{color:var(--jer-input-color);border:var(--jer-form-border);border-radius:.3em;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;outline:none;font-family:inherit}.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{display:flex;min-height:1.7em;gap:.3em;align-items:center}.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{position:absolute;left:-1.2em;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{display:flex;flex-direction:column;gap:.3em;align-items:flex-start;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;resize:both;padding:.2em .5em 0;overflow:hidden;max-height:40em;line-height:1.25em;font-family:inherit;font-size:.85em}.jer-collection-input-button-row{display:flex;justify-content:flex-end;width:100%;font-size:150%;margin-top:.4em}.jer-collection-error-row-edit{position:absolute;bottom:.5em}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{display:flex;justify-content:flex-start;align-items:center;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}.jer-string-expansion{cursor:pointer;opacity:.6;filter:saturate(50%)}.jer-string-expansion.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;resize:none;margin:0;height:1.4em;padding:.25em .5em .2em;min-width:6em;overflow:hidden;line-height:1.2em;font-family:inherit;font-size:.9em}.jer-input-boolean{transform:scale(1.5);margin-left:.3em;margin-right:.3em}.jer-key-text{word-break:break-word;line-height:1.1em;white-space:pre-wrap}.jer-key-edit{padding:0 .3em;font-size:inherit;font-size:.9em}.jer-value-invalid{opacity:.5;font-style:italic}.jer-input-number{min-width:3em;font-size:90%}.jer-edit-buttons,.jer-confirm-buttons{display:flex;align-items:center;cursor:pointer;height:1em;margin-right:.2em}.jer-edit-buttons>button,.jer-confirm-buttons>button,button.jer-collapse-icon,button.jer-string-expansion{appearance:none;background:none;border:none;margin:0;padding:0;font:inherit;color:inherit;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{opacity:1}.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-value-and-buttons:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-copy-pulse:after{content:"";display:block;position:absolute;border-radius:50%;left:0;top:0;width:100%;height:100%;opacity:0;transition:all .5s;box-shadow:0 0 15px 5px var(--jer-icon-copy-color)}.jer-copy-pulse:active:after{box-shadow:0 0 0 0 var(--jer-icon-copy-color);position:absolute;border-radius:4em;left:0;top:0;opacity:1;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transition:.3s;transform:scale(1.2)}.jer-empty-string{font-style:italic;font-size:90%}.jer-drag-n-drop-padding{height:.5em;border:1px dashed #b4b4b4;border-radius:.3em}.jer-clickzone{position:absolute;left:-1em;top:1.2em;height:calc(100% - .8em)}';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:N="when-collapsed-or-filtered",allowEdit:x=!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),Ne=i(null);a(()=>{Ce();const e=setTimeout(()=>Te(V),M);return()=>clearTimeout(e)},[V,M]);const xe=_(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(xe);Ie.current=xe;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(x),[x]),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}})(xe,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 Nt=ze(ae,xe),xt=c(()=>({object:!0===ye||"object"===ye,array:!0===ye||"array"===ye}),[ye]),Rt={mainContainerRef:Ne,name:l,nodeData:xe,getLatestData:Ve,onChange:Me,onError:Fe,onEditEvent:He,showErrorMessages:E,showCollectionCount:N,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:Nt,customButtons:ie,parentData:null,jsonParse:jt,jsonStringify:Ct,TextEditor:de,Select:ue,errorDisplayTime:pe,handleKeyboard:vt,keyboardControls:gt,insertAtTop:xt,onCollapse:Be,editConfirmRef:St,collapseClickZones:ve},At={...we("container",xe),...De,minWidth:Q,maxWidth:Z};return At.fontSize=G??At.fontSize,t("div",{id:re,ref:Ne,className:`jer-editor-container ${te??""}`,style:At,children:t(be,{value:it,children:g(e)&&!Nt.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,Ne 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
- .jer-show-less {
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 are real <button>s for accessibility. This neutralises the
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`). `cursor` inherits from the
383
- wrapper rule above, whose flexbox also centres the button, so neither is
384
- needed here. Scoped with `>` so it never leaks into custom-button content. */
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.8",
3
+ "version": "2.0.0",
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": false,
8
+ "sideEffects": [
9
+ "./build/style.css"
10
+ ],
9
11
  "exports": {
10
12
  ".": {
11
13
  "types": "./build/index.d.ts",