json-edit-react 2.0.3 → 2.0.4
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/build/index.cjs.js +1 -1
- package/build/index.d.ts +13 -6
- package/build/index.esm.js +1 -1
- package/build/style.css +7 -0
- package/package.json +1 -1
package/build/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react");const n=()=>{},r=e=>Array.isArray(e)?e:[e],o=e=>null!==e&&"object"==typeof e,a=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),s=e=>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}),F=e=>{const t={};for(const{icons:n}of V(e))n&&Object.assign(t,n);return t},z={getStyles:()=>({}),icons:/*#__PURE__*/F(_),cssVars:{}},B=t.createContext(z),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__*/F(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,S]=t.useState(""),[O,T]=t.useState(!1),{path:R,value:N}=c,A=G(e=>{const t=e.active;return null!==t&&"add"===t.op&&m(t.path,R)}),P=Array.isArray(O);D(()=>{if(!A)return T(!1),void S("");const e=Object.keys(w(c.fullData,R)),t=y?y(c)?.filter(t=>!e.includes(t)):null;T(t??!0)},[A]);const I=()=>{o&&C&&o("array"===i?"":C)};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:A?1:void 0},onClick:e=>e.stopPropagation(),children:[a&&e.jsx("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",i=null;if(a){const a=k(e);if(a&&p.clipboardModifier.includes(a)?(t=d(R),o=t,r="path"):(t=N,o="object"==typeof t?g(N):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(R,{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)}),A&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[P?e.jsx(b,{name:"new-key-select",onChange:o,defaultValue:"",autoFocus:!0,onKeyDown:e=>h(e,{cancel:()=>E()}),placeholder:O.length>0?u("KEY_SELECT",c):u("NO_KEY_OPTIONS",c),options:O}):e.jsx("input",{className:"jer-input-text jer-input-new-key",type:"text",name:"new-object-key",value:C,placeholder:u("KEY_NEW",c),onChange:e=>S(e.target.value),autoFocus:!0,onKeyDown:e=>{h(e,{stringConfirm:()=>I(),cancel:()=>E()})},style:j("input",c)}),e.jsx(Ee,{onOk:()=>I(),onCancel:()=>E(),nodeData:c,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:P})]})]})},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]),F=le(),z=t.useCallback(e=>(null===F||F.visiblePaths.has(p(e.path)))&&l(e),[F,l]),B=e=>P(s(),D,e,g,z),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:F,canDrag:z,error:B,onError:H,setError:Y,derivedValues:U,getNextOrPreviousAtPath:$,buildKeyDisplayProps:J}=Te({props:r}),{dragSourceProps:X,getDropTargetProps:Q,BottomDropTarget:G,DropTargetPadding:q}=Re({canDrag:z,canDelete:F,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=Fe(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()}},ze=(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=ze;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&&ze(void 0,()=>T(t))},Ze={value:I,parentData:a,setValue:ae,isEditing:pe,canEdit:V,setIsEditing:Xe,handleEdit:ze,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:ze,handleCancel:Be,onKeyDown:e=>w(e,{stringConfirm:ze,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:z&&!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:ze,onCancel:Be,nodeData:K,translate:v,showIconTooltips:S,editConfirmRef:C}):Ue&&e.jsx(we,{startEdit:V?Je:void 0,handleDelete:F?()=>{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},Fe=(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)}},ze=r=>{const{getStyles:a}=W(),{open:s,cancel:i,submit:l,areChildrenBeingEdited:c,getSnapshot:u}=Z(),{setCollapseState:d}=te(),{mainContainerRef:p,data:f,nodeData:y,parentData:g,showCollectionCount:v,canDragOnto:b,canAddHere:j,collapseFilter:x,collapseAnimationTime:w,showClipboardButton:E,onCopy:C,showIconTooltips:D,indent:O,sort:T,showArrayIndexes:R,defaultValue:N,newKeyOptions:P,translate:I,customNodeDefinitions:L,customNodeData:K,jsonParse:_,jsonStringify:M,TextEditor:V,Select:F,keyboardControls:z,handleKeyboard:B,insertAtTop:H,onCollapse:Y,editConfirmRef:U,collapseClickZones:$,getLatestData:J}=r,[X,Q]=t.useState(null),{showCollectionWrapper:q=!0}=K,ee=q&&x(y),{contentRef:re,isAnimating:oe,maxHeight:ae,collapsed:se,animateCollapse:ie,cssTransitionValue:le}=((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}})(f,w,ee,p,M),{pathString:ue,nodeData:de,path:pe,name:me,size:he,canEdit:fe,canDelete:ye,canAdd:ge,canDrag:ve,error:be,setError:je,onError:Ce,derivedValues:De,buildKeyDisplayProps:Se}=Te({props:r,collapsed:se}),{dragSourceProps:ke,getDropTargetProps:Ae,BottomDropTarget:Pe,DropTargetPadding:Ie}=Re({canDrag:ve,canDelete:ye,canDragOnto:b,canAddHere:j,path:pe,nodeData:de,onError:Ce,translate:I}),Ke=t.useRef(!ee),{isEditing:_e,isEditingKey:Me,isPending:Ve,isArray:Fe}=De,ze=(e=>{const n=t.useRef(e),r=!Object.is(n.current,e);return t.useEffect(()=>{n.current=e}),r})(x);t.useEffect(()=>{const e=q&&x(de)&&!_e;Ke.current=!e,ie(e),ze&&d(null)},[x]),((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])})(pe,Ke,q?ie:n);const He=t.useRef(null),We=t.useCallback(e=>Q(t=>"function"==typeof e?e(t??M(f)):e),[f,M]),Ye=t.useCallback(()=>Q(null),[]),Ue=t.useMemo(()=>_e?X??M(f):null,[_e,X,f,M]),$e=t.useCallback((e,t)=>{if("function"!=typeof N)return N;const n=N(e,t);return void 0!==n?n:null},[N]),Je=t.useCallback(e=>P?"function"!=typeof P?P:P(e):null,[P]),{CustomComponent:Xe,componentProps:Qe,CustomWrapperComponent:Ze,wrapperProps:Ge={},showKey:qe=!0,showEditTools:et=!0,showOnEdit:tt,showOnView:nt,passOriginalNode:rt}=K,ot=G(e=>null!==e.active&&h(e.active.path,pe));!ot&&q||!se||ie(!1);const at=ce(pe)||0===de.level,st=t.useRef(n);if(!at&&!ot)return null;const{visibleSize:it}=de,lt=Array.isArray(f)?"array":"object",ct="array"===lt?{open:"[",close:"]"}:{open:"{",close:"}"},ut=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")&&e.target===He.current){e.preventDefault();const t=A(He,"\t");return void Q(t)}B(e,{objectConfirm:pt,cancel:ht})},dt=e=>{if(e.stopPropagation(),!q)return;const t=k(e);if(t&&z.collapseModifier.includes(t))return Ke.current=!0,void d({collapsed:!se,path:pe,includeChildren:!0});c(pe)||(Ke.current=!0,Y&&Y({...de,fullData:J(),collapsed:!se,includeChildren:!1}),ie(!se))},pt=e=>{let t=f;if(null!==X)try{t=_(X)}catch{return void Ce({code:"INVALID_JSON",message:I("ERROR_INVALID_JSON",de)},X)}je(null);const n="function"==typeof e?e:void 0;l({op:"edit",path:pe,value:t,onCommit:()=>{Ye(),n?.()}}).then(e=>{if("error"===e?.status&&Ce(e.error,t),"error"===e?.status||"cancel"===e?.status){const e=u().active;"editing"===e?.phase&&m(e.path,pe)||Ye()}})};st.current=pt;const mt=pe.length>0?()=>{l({op:"delete",path:pe,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,f)})}:void 0,ht=()=>{i(),je(null),Ye()},ft="when-collapsed"===v?se:"when-collapsed-or-filtered"===v?se||null!=it:v,yt=!_e&&et,gt=(R||!Fe)&&qe&&void 0!==me,vt=Xe&&(_e&&tt||!_e&&nt),bt=Object.entries(f).map(([e,t])=>["array"===lt?Number(e):e,t]);"object"===lt&&T(bt,e=>e);const jt=!_e||!!Xe&&tt,xt=()=>e.jsxs("div",{className:"jer-collection-text-edit"+(V?"-custom":""),children:[V?e.jsx(V,{value:Ue??"",onChange:Q,onKeyDown:e=>B(e,{objectConfirm:pt,cancel:ht})}):e.jsx(S,{textAreaRef:He,className:"jer-collection-text-area",name:ue,value:Ue??"",setValue:We,onKeyDown:ut,styles:a("input",de)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(Ee,{onOk:pt,onCancel:ht,nodeData:de,translate:I,showIconTooltips:D,editConfirmRef:U})})]}),wt=Ke.current?jt?bt.map(([t,n],s)=>{const i={key:t,value:n,path:[...pe,t],level:pe.length+1,index:s,size:o(n)?Object.keys(n).length:null,parentData:f,fullData:de.fullData},l=Oe(L,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:f,nodeData:i,canDragOnto:fe,canAddHere:ge,customNodeData:l},t):e.jsx(Le,{...r,data:n,parentData:f,nodeData:i,canDragOnto:fe,canAddHere:ge,showLabel:"object"===lt||R,customNodeData:l},t)},t)}):e.jsx(e.Fragment,{children:xt()}):null,Et=!!q&&se&&!ot;Et||(Ke.current=!0);const Ct=I(se?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",de),Dt=()=>({...r,data:f,value:f,parentData:g,nodeData:de,setValue:e=>l({op:"edit",path:pe,value:e}),handleEdit:pt,handleCancel:ht,onKeyDown:ut,isEditing:_e,isPending:Ve,setIsEditing:fe?()=>s(pe,{cancelOp:Ye,commitOp:e=>st.current(e)}):n,getStyles:a,canDragOnto:fe,canAddHere:ge,canEdit:fe,keyboardCommon:{}}),St=vt?e.jsx(Xe,{componentProps:Qe,...Dt(),originalNode:rt&&_e?xt():void 0,children:wt}):wt,kt=yt&&e.jsx(we,{startEdit:fe?()=>{Ke.current=!0,s(pe,{cancelOp:Ye,commitOp:e=>st.current(e)})}:void 0,handleAdd:ge?e=>{d(null),ie(!1);const t=$e(de,e);if("array"===lt){const e=H.array?0:f.length,n=H.array?{insert:!0}:{};return void l({op:"add",path:pe,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}if(e in f)return Ce({code:"KEY_EXISTS",message:I("ERROR_KEY_EXISTS",de)},e),void i();const n=H.object?{insertBefore:0}:{};l({op:"add",path:pe,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}:void 0,handleDelete:ye?mt:void 0,showClipboardButton:E,onCopy:C,type:lt,nodeData:de,translate:I,customButtons:r.customButtons,keyboardControls:z,handleKeyboard:B,getNewKeyOptions:Je,editConfirmRef:U,jsonStringify:M,showIconTooltips:D,Select:F}),Ot=Se({handleCancel:ht,getStyles:a,keyValueArray:bt,handleClick:$.includes("property")?dt:e=>e.stopPropagation()}),Tt=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===pe.length?0:O/2)+"em",...a("collection",de),position:"relative"},draggable:ve&&!_e&&!Me&&!ot,...ke,...Ae("above"),children:[q&&e.jsx("div",{className:"jer-clickzone",style:{width:O/2+1+"em",zIndex:10+2*de.level},onClick:$.includes("left")?dt:void 0}),!_e&&Pe,e.jsx(Ie,{position:"above",nodeData:de}),q?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",de),position:"relative"},onClick:$.includes("header")?dt:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(se?" jer-rotate-90":""),style:{zIndex:11+2*de.level,transition:le},onClick:dt,tabIndex:-1,"aria-expanded":!se,"aria-label":Ct,title:D?Ct:"",children:e.jsx(xe,{name:"collection",nodeData:de})}),gt&&e.jsx(Ne,{...Ot}),!_e&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:a("bracket",de),children:ct.open})]}),!1!==v&&!_e&&e.jsx("div",{className:"jer-collection-item-count"+(ft?" jer-visible":" jer-hidden"),style:{...a("itemCount",de),transition:le,transitionBehavior:"allow-discrete"},children:null!=it&&it!==he?I("ITEMS_FILTERED",de,{visible:it,total:he}):1===he?I("ITEM_SINGLE",{...de,size:1},1):I("ITEMS_MULTIPLE",de,he)}),e.jsx("div",{className:"jer-brackets"+(Et?" jer-visible":" jer-hidden"),style:{...a("bracket",de),transition:le},children:ct.close}),kt]}):qe?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",de),position:"relative"},children:[e.jsx(Ne,{...Ot}),kt]}):e.jsx(e.Fragment,{}),e.jsxs("div",{className:"jer-collection-inner",style:{overflowY:Et||oe?"clip":"visible",maxHeight:ot?void 0:ae,...a("collectionInner",de),transition:`max-height ${le}`},ref:re,children:[St,e.jsx("div",{className:_e?"jer-collection-error-row-edit":"jer-collection-error-row",children:be&&e.jsx("span",{className:"jer-error-slug",style:a("error",de),children:be})}),!_e&&q&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:a("bracket",de),children:ct.close})]}),e.jsx(Ie,{position:"below",nodeData:de})]});return Ze?e.jsx(Ze,{wrapperProps:Ge,...Dt(),children:Tt}):Tt},Be=/*#__PURE__*/t.memo(ze,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.2em;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-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:F=0,showStringQuotes:z=!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),Fe=Ge(j),ze=t.useCallback(e=>{Se.current=e,ke.current(e)},[]),Ye=t.useCallback((e,t)=>{ze(it(Se.current,e,t,"update").newData)},[ze]),$e=t.useCallback(e=>{const t=Se.current,n=Ae.current,r=Pe.current,o=ze,{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)}}}},[ze]),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:Fe,sortKeys:M,sort:wt,showArrayIndexes:V,arrayIndexStart:F,showStringQuotes:z,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;
|
|
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=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault,l=(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},c=e=>{if(e!==u){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=c(n);r!==n&&(e[t]=r)}return e}},u="__undefined__",d=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),p=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),m=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),h=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),f=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),y=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},g=e=>Array.isArray(e),v=(e,t)=>e.filter((e,n)=>n!==t),b=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:s=!1}=r,i=e,l=p(t),c={...r,remove:o,createNew:a,noError:s,fullData:i,fullPath:l},u=Array.isArray(t)?t:d(t);return g(e)&&o&&1===u.length?v(e,u[0]):j(e,u,n,c)},j=(e,t,n,r)=>{const o=a(e)?{...e}:null,s=g(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=>j(e,t,n,r));if(1===t.length)return o&&"string"==typeof p?x(o,p,n,r)??o:s&&"number"==typeof p?(w(s,p,n,r),s):(y(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 g(e)?m[p]=v(e,n):y(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(f=m[p],!g(f)&&!a(f)){if(!i)return y(u,d,p,c),m;m[p]={}}return m[p]=j(m[p],h,n,r),m}var f;if(i){const e="number"==typeof h[0]?[]:{};if(o)return m[p]=e,m[p]=j(m[p],h,n,r),m;if(s&&Array.isArray(m)){m.push(e);const t=m.length-1;return m[t]=j(m[t],h,n,r),m}}return y(u,d,p,c),m},x=(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]:y(c,u,t,s):a||d?e[t]=n:y(c,u,t,s)},w=(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):y(a,s,t,o)},E=(e,t,n)=>{const r=Array.isArray(t)?t:d(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=>E(e,r,n));if("object"!=typeof e||null===e||!(o in e))return C(e,o,n);const a=e[o];return 1===r.length?a:E(a,r.slice(1),n)},C=(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=E(e,t),i=E(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}},S="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,k=({className:n,name:r,value:o,setValue:a,onKeyDown:s,styles:i,textAreaRef:l})=>{const c=t.useRef(null);if(S(()=>{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})]})},O=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,T=(e,t,n)=>{if(!t)return!1;const r=e.key,o=O(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"},N={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"]},A=["stringConfirm","numberConfirm","booleanConfirm"],P=(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},I=(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=E(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:I(e,s,n,r,a);let p;if(o(d.value)){if(0===Object.keys(d.value).length)return I(e,[...s,d.key],n,r,a);p=L(e,[...s,d.key],n,r)}else p=[...s,d.key];return p?a(D(e,p,"",r))?p:I(e,p,n,r,a):null},L=(e,t,n="next",r)=>{const a=E(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 L(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})),_={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},M={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:_,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:_,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"}},V={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},F=e=>[M,...r(e)].map(e=>"styles"in e?e:{styles:e}),z=e=>{const t={};for(const{icons:n}of F(e))n&&Object.assign(t,n);return t},B={getStyles:()=>({}),icons:/*#__PURE__*/z(M),cssVars:{}},H=t.createContext(B),W=({theme:n=M,children:r})=>{const o=t.useMemo(()=>(e=>{var t;const n=F(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?{[V[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(H.Provider,{value:l,children:r})},Y=()=>t.useContext(H),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"}},$=(e,t)=>U[e][t]??null,J=(e,t)=>null!==e&&null!==t&&e.op===t.op&&h(e.path,t.path),X={active:null,settling:{}},Q=t.createContext(null),Z=({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=X;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})},p=(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,J(r.active,n)&&r.active?.phase===n?.phase||u({...r,active:n});const o=$(e.op,"start");o&&p(e.path,o)},g=(e,t,o,s,l,c,p,f,y)=>{const g=m(e);if(!p()){if("cancel"===s.status||"error"===s.status){r.active&&h(r.active.path,e)&&("held"===r.active.phase||"editing"===r.active.phase)&&(u({...r,active:null}),a=null,i=null);const n=$(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&&!J(o,n);if(s&&i)return void i(()=>y(n,t));const l=a;if(a=null,i=null,l&&l(),s&&J(r.active,o)){const e=$(o.op,"cancel");e&&p(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=$(e.op,"cancel");t&&p(e.path,t)}}finally{l=!1}},submit:e=>{const{op:t,path:o,instant:l,onCommit:h}=e,f=n.current;let y;try{y=f?.buildCommit(e)??null}catch{return J(r.active,{path:o,op:t})&&u({...r,active:null}),a=null,i=null,h?.(),Promise.resolve(void 0)}const v=y?.extra,b=m(o),j=++c;if(!l){const e=$(t,"submit");e&&p(o,e)}if(!y||y.isNoOp){J(r.active,{path:o,op:t})&&u({...r,active:null}),a=null,i=null;const e=$(t,"commit");return e&&(y?d(y.nodeData,e,v):p(o,e,v)),h?.(),Promise.resolve(void 0)}const{input:x,nodeData:w,apply:E,revert:C}=y,D=!!f?.runUpdate;let S=!1,k=!1;const O=()=>{if(S)return;S=!0,E(),a=null,i=null,J(r.active,{path:o,op:t})&&u({...r,active:null}),D&&((e,t)=>{u({...r,settling:{...r.settling,[e]:t}})})(b,j);const e=$(t,"commit");e&&d(w,e,v),h?.()},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=f.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&&f(r.active.path,e)}})(i,o,a)),e.jsx(Q.Provider,{value:l.current,children:n})},G=()=>{const e=t.useContext(Q);if(!e)throw new Error("Missing Editing Context Provider");return e},q=e=>{const n=G();return t.useSyncExternalStore(n.subscribe,()=>e(n.getSnapshot()),()=>e(n.getServerSnapshot()))},ee=t.createContext(null),te=({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(ee.Provider,{value:u,children:n})},ne=()=>{const e=t.useContext(ee);if(!e)throw new Error("Missing Collapse Context Provider");return e},re=(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},oe=t.createContext(null),ae=({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(oe.Provider,{value:s,children:n})},se=({children:t,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>e.jsx(Z,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:e.jsx(te,{onCollapse:r,buildNodeDataFromPathRef:o,children:e.jsx(ae,{children:t})})}),ie=t.createContext(void 0),le=({value:t,children:n})=>e.jsx(ie.Provider,{value:t,children:n}),ce=()=>{const e=t.useContext(ie);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},ue=e=>{const t=ce();return null===t||t.visiblePaths.has(m(e))},de=e=>{const t=ce();return null===t?null:t.visibleChildCounts.get(m(e))??null},pe="**INVALID_FUNCTION**",me=({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}`})]})},he=({styles:n,pathString:r,value:o,setValue:a,handleEdit:s,handleKeyboard:i,keyboardCommon:l})=>{const c=t.useRef(null);return e.jsx(k,{className:"jer-input-text",textAreaRef:c,name:r,value:o,setValue:a,onKeyDown:e=>{i(e,{stringConfirm:s,stringLineBreak:()=>{const e=P(c,"\n");a(e)},...l})},styles:n})},fe=({isEditing:t,path:n,enumType:r,...o})=>{const{getStyles:a}=Y(),s=m(n),{value:i,setValue:l,nodeData:c,handleEdit:u,handleKeyboard:d,keyboardCommon:p,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,...p})}):t?e.jsx(he,{styles:a("input",c),pathString:s,...o,setValue:o.setValue}):e.jsx(me,{pathString:s,styles:a("string",c),...o})},ye=({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:m(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})},ge=({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:m(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)})},ve=(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])},be=({value:t,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:s,keyboardCommon:i})=>{const{getStyles:l}=Y();return ve(n,e=>s(e,{confirm:o,...i})),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:l("null",a),children:String(t)})},je=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===pe&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},xe=({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})},we=({name:t,nodeData:n})=>{const{getStyles:r,icons:o}=Y(),a=o[t],s=`icon${t[0].toUpperCase()}${t.slice(1)}`;return e.jsx(xe,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===t?void 0:"jer-icon",style:r(s,n),children:a.content})},Ee=({startEdit:n,handleDelete:r,handleAdd:o,showClipboardButton:a,onCopy:s,type:i,customButtons:l,handleEdit:c,canEdit:u,nodeData:d,translate:m,keyboardControls:f,handleKeyboard:y,editConfirmRef:g,getNewKeyOptions:v,jsonStringify:b,showIconTooltips:j,Select:x})=>{const{getStyles:w}=Y(),{open:C,cancel:D}=G(),[k,T]=t.useState(""),[R,N]=t.useState(!1),{path:A,value:P}=d,I=q(e=>{const t=e.active;return null!==t&&"add"===t.op&&h(t.path,A)}),L=Array.isArray(R);S(()=>{if(!I)return N(!1),void T("");const e=Object.keys(E(d.fullData,A)),t=v?v(d)?.filter(t=>!e.includes(t)):null;N(t??!0)},[I]);const K=()=>{o&&k&&o("array"===i?"":k)};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:I?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=O(e);if(a&&f.clipboardModifier.includes(a)?(t=p(A),o=t,r="path"):(t=P,o="object"==typeof t?b(P):String(t)),!navigator.clipboard)return void s?.({...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,i=e.message}).finally(()=>{s?.({...d,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:i??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":m("TOOLTIP_COPY",d),title:j?m("TOOLTIP_COPY",d):"",children:e.jsx(we,{name:"copy",nodeData:d})}),n&&e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":m("TOOLTIP_EDIT",d),title:j?m("TOOLTIP_EDIT",d):"",children:e.jsx(we,{name:"edit",nodeData:d})}),r&&e.jsx("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":m("TOOLTIP_DELETE",d),title:j?m("TOOLTIP_DELETE",d):"",children:e.jsx(we,{name:"delete",nodeData:d})}),o&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===i?C(A,{op:"add"}):o("")},"aria-label":m("TOOLTIP_ADD",d),title:j?m("TOOLTIP_ADD",d):"",children:e.jsx(we,{name:"add",nodeData:d})}),l?.map(({Element:t,onClick:n,label:r},o)=>{const a=e=>n?.(d,e,{handleEdit:c,canEdit:u});return r?e.jsx("button",{type:"button",className:"jer-custom-button",tabIndex:-1,onClick:a,"aria-label":r,title:j?r:"",children:e.jsx(t,{nodeData:d,canEdit:u,handleEdit:c})},o):e.jsx("div",{className:"jer-custom-button",onClick:a,children:e.jsx(t,{nodeData:d,canEdit:u,handleEdit:c})},o)}),I&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[L?e.jsx(x,{name:"new-key-select",onChange:o,defaultValue:"",autoFocus:!0,onKeyDown:e=>y(e,{cancel:()=>D()}),placeholder:R.length>0?m("KEY_SELECT",d):m("NO_KEY_OPTIONS",d),options:R}):e.jsx("input",{className:"jer-input-text jer-input-new-key",type:"text",name:"new-object-key",value:k,placeholder:m("KEY_NEW",d),onChange:e=>T(e.target.value),autoFocus:!0,onKeyDown:e=>{y(e,{stringConfirm:()=>K(),cancel:()=>D()})},style:w("input",d)}),e.jsx(Ce,{onOk:()=>K(),onCancel:()=>D(),nodeData:d,translate:m,showIconTooltips:j,editConfirmRef:g,hideOk:L})]})]})},Ce=({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(we,{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(we,{name:"cancel",nodeData:r})})]}),De=["string","number","boolean","null"],Se=["object","array"],ke=[...De,...Se],Oe=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}},Te=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?Oe(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:p,translate:f,errorDisplayTime:y,sort:g,arrayIndexStart:v,handleKeyboard:b,customNodeData:j}=e,{submit:x}=G(),[w,E]=t.useState(null),C={...r,collapsed:n,visibleSize:de(r.path)},{path:D,key:S,size:k}=C,O=m(D),T=q(e=>{const t=e.active;return null!==t&&"edit"===t.op&&h(t.path,D)}),R=q(e=>{const t=e.active;return null!==t&&"rename"===t.op&&h(t.path,D)}),N=q(e=>O in e.settling),A=l(C),P=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]),F=ce(),z=t.useCallback(e=>(null===F||F.visiblePaths.has(m(e.path)))&&l(e),[F,l]),B=e=>I(s(),D,e,g,z),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&&P&&p,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:P,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}:{}})}},Ne=({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:m}=(()=>{const e=t.useContext(oe);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),y=G(),[g,v]=t.useState(!1),b=()=>null!==d.path&&!f(s,d.path)&&(h(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&&(m.current=!0)},onMouseUp:()=>{m.current=!1},onDragStart:e=>{if(!m.current||null!==y.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();m.current=!1,e.stopPropagation(),p({path:s,canDelete:r})},onDragEnd:e=>{m.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&&!h(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}},Ae=({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}=G(),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"}})},Pe=new Set(["nodeData","customNodeData"]),Ie=(e,t)=>{if(n=e.nodeData,r=t.nodeData,n.key!==r.key||n.index!==r.index||n.level!==r.level||n.size!==r.size||!h(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(!Pe.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Le=r=>{const{data:a,parentData:s,onChange:c,showClipboardButton:u,onCopy:d,canDragOnto:p,canAddHere:m,allowTypeSelection:f,showLabel:y,stringTruncateLength:g,showStringQuotes:v,indent:b,translate:j,customNodeDefinitions:x,customNodeData:w,Select:E,handleKeyboard:C,keyboardControls:D,editConfirmRef:S,jsonStringify:k,showIconTooltips:O,getLatestData:T}=r,{getStyles:R}=Y(),{open:N,cancel:A,submit:P,getSnapshot:I}=G(),{setCollapseState:L}=ne(),[K,_]=t.useState("function"==typeof a?pe:a),{nodeData:M,path:V,name:F,canEdit:z,canDelete:B,canDrag:H,error:W,onError:U,setError:$,derivedValues:J,getNextOrPreviousAtPath:X,buildKeyDisplayProps:Q}=Re({props:r}),{dragSourceProps:Z,getDropTargetProps:q,BottomDropTarget:ee,DropTargetPadding:te}=Ne({canDrag:H,canDelete:B,canDragOnto:p,canAddHere:m,path:V,nodeData:M,onError:U,translate:j}),[re,oe]=t.useState(Me(a,w)),ae=t.useRef(K);ae.current=K;const se=t.useRef(M);se.current=M;const ie=t.useCallback(e=>{if(!c)return void _(e);const t=c({...se.current,value:ae.current,fullData:T(),newValue:e});_(t)},[c,T]),le=()=>{_("function"==typeof a?pe:a),oe(Me(a,w)),me(l(a,ce))};t.useEffect(()=>{J.isEditing||le()},[a]);const ce=t.useMemo(()=>{const e=[...ke,...x.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof f)return f?e:[];if(Array.isArray(f))return f;const t=f(M);return"boolean"==typeof t?t?e:[]:t},[M,f,x]),[de,me]=t.useState(l(K,ce)),{isEditing:he,isPending:fe}=J,ye=ue(V),ge=t.useRef(n);if(!ye)return null;const ve=he&&re!==Me(a,w),be=ve?x.find(e=>e.name===re&&_e(e)):void 0,je=be?Oe(be):w,{CustomComponent:xe,componentProps:we,showKey:De=!0,showEditTools:Se=!0,showOnEdit:Te,showOnView:Pe,passOriginalNode:Ie}=je,Le=xe&&(void 0!==be||!ve&&(he&&Te||!he&&Pe)),Ke=e=>{L(null);const t=ve&&!be?void 0:je,n=t?.toStandardType?t.toStandardType(K):K,r=x.find(t=>t.name===e);if(r){const t="function"==typeof r.defaultValue?r.defaultValue(M):r.defaultValue;if(_e(r)){let o=t;if(r.fromStandardType)try{o=r.fromStandardType(n,M,r.componentProps)}catch{}return _(o),oe(e),void me(null)}return P({op:"edit",path:V,value:t}).then(Be(t)),void L({path:V,collapsed:!1,includeChildren:!1})}const o=ce.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof K&&o.values.includes(K)||_(o.values[0]),me(o),void oe(e);const a=ze(n,e,j("DEFAULT_NEW_KEY",M));if("object"===e||"array"===e||"null"===e)return P({op:"edit",path:V,value:a}).then(Be(a)),void("null"!==e&&L({path:V,collapsed:!1,includeChildren:!1}));_(a),oe(e),me(null)},Be=e=>t=>{if("error"===t?.status&&U(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=I().active;"editing"===e?.phase&&h(e.path,V)||le()}},He=(e,t)=>{const n=void 0!==e&&!i(e);let r;if(n)r=e;else if(Le&&je.fromStandardType)try{r=je.fromStandardType(K,M,je.componentProps)}catch(e){return void U({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},K)}else r="number"===re?Fe(K):K;$(null),be&&L({path:V,collapsed:!1,includeChildren:!1});const s=n&&o(r)&&!o(a);P({op:"edit",path:V,value:r,onCommit:()=>{s&&L({path:V,collapsed:!1,includeChildren:!1}),t?.()}}).then(Be(r))};ge.current=He;const We=()=>{$(null),le(),A()},{isEditingKey:Ye}=J,Ue=!!W,$e=he&&ce.length>1,Je=("invalid"!==re||xe)&&!W&&Se,Xe=y&&De,Qe=()=>N(V,{cancelOp:le,commitOp:e=>ge.current(void 0,e)}),Ze=z?Qe:n,Ge=e=>()=>{const t=X(e);t&&He(void 0,()=>N(t))},qe={value:K,parentData:s,setValue:ie,isEditing:he,canEdit:z,setIsEditing:Ze,handleEdit:He,handleCancel:We,path:V,stringTruncateLength:g,showStringQuotes:v,showIconTooltips:O,nodeData:M,enumType:de,translate:j,handleKeyboard:C,keyboardCommon:{cancel:We,tabForward:Ge("next"),tabBack:Ge("prev")},Select:E},et={...Q({handleCancel:We,getStyles:R}),customNodeData:je},tt=Le?e.jsx(xe,{...r,value:K,componentProps:we,setValue:ie,handleEdit:He,handleCancel:We,onKeyDown:e=>C(e,{stringConfirm:He,cancel:We}),isEditing:he,isPending:fe,setIsEditing:Ze,getStyles:R,originalNode:Ie?Ve(a,re,qe):void 0,originalNodeKey:Ie?e.jsx(Ae,{...et,customNodeData:void 0}):void 0,canEdit:z,keyboardCommon:qe.keyboardCommon}):Ve(a,re,qe);return e.jsxs("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==s?b/2+"em":0,position:"relative"},draggable:H&&!he&&!Ye,...Z,...q("above"),children:[ee,e.jsx(te,{position:"above",nodeData:M}),e.jsxs("div",{className:"jer-value-main-row",style:{...R("valueRow",M),flexWrap:F.length>10?"wrap":"nowrap"},children:[Xe&&e.jsx(Ae,{...et}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:tt}),he?e.jsx(Ce,{onOk:He,onCancel:We,nodeData:M,translate:j,showIconTooltips:O,editConfirmRef:S}):Je&&e.jsx(Ee,{startEdit:z?Qe:void 0,handleDelete:B?()=>{P({op:"delete",path:V,instant:!0}).then(e=>{"error"===e?.status&&U(e.error,K)})}:void 0,showClipboardButton:u,onCopy:d,translate:j,customButtons:r.customButtons,handleEdit:e=>He(e),canEdit:z,nodeData:M,handleKeyboard:C,keyboardControls:D,editConfirmRef:S,jsonStringify:k,showIconTooltips:O,Select:E}),$e&&e.jsx(E,{name:`${F}-type-select`,value:de?de.enum:re,onChange:e=>Ke(e),options:ce.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Ue&&e.jsx("span",{className:"jer-error-slug",style:R("error",M),children:W})]})]}),e.jsx(te,{position:"below",nodeData:M})]})},Ke=/*#__PURE__*/t.memo(Le,Ie),_e=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,Me=(e,t)=>t?.CustomComponent&&t?.name&&t.showInTypeSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",Ve=(t,n,r)=>{const o=De.includes(n)?n:"function"==typeof t?"invalid":Me(r.value),{value:a}=r;switch(o){case"string":return e.jsx(fe,{...r,value:a});case"number":return e.jsx(ye,{...r,value:a});case"boolean":return e.jsx(ge,{...r,value:a});case"null":return e.jsx(be,{...r});default:return e.jsx(je,{...r})}},Fe=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 Fe(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Be=r=>{const{getStyles:a}=Y(),{open:s,cancel:l,submit:c,areChildrenBeingEdited:u,getSnapshot:d}=G(),{setCollapseState:p}=ne(),{mainContainerRef:m,data:y,nodeData:g,parentData:v,showCollectionCount:b,canDragOnto:j,canAddHere:x,collapseFilter:w,collapseAnimationTime:E,showClipboardButton:C,onCopy:D,showIconTooltips:S,indent:T,sort:R,showArrayIndexes:N,defaultValue:A,newKeyOptions:I,translate:L,customNodeDefinitions:K,customNodeData:_,jsonParse:M,jsonStringify:V,TextEditor:F,Select:z,keyboardControls:B,handleKeyboard:H,insertAtTop:W,onCollapse:U,editConfirmRef:$,collapseClickZones:J,getLatestData:X}=r,[Q,Z]=t.useState(null),{showCollectionWrapper:ee=!0}=_,te=ee&&w(g),{contentRef:oe,isAnimating:ae,maxHeight:se,collapsed:ie,animateCollapse:le,cssTransitionValue:ce}=((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}})(y,E,te,m,V),{pathString:de,nodeData:pe,path:me,name:he,size:fe,canEdit:ye,canDelete:ge,canAdd:ve,canDrag:be,error:je,setError:xe,onError:De,derivedValues:Se,buildKeyDisplayProps:ke}=Re({props:r,collapsed:ie}),{dragSourceProps:Oe,getDropTargetProps:Pe,BottomDropTarget:Ie,DropTargetPadding:Le}=Ne({canDrag:be,canDelete:ge,canDragOnto:j,canAddHere:x,path:me,nodeData:pe,onError:De,translate:L}),_e=t.useRef(!te),{isEditing:Me,isEditingKey:Ve,isPending:Fe,isArray:ze}=Se,Be=(e=>{const n=t.useRef(e),r=!Object.is(n.current,e);return t.useEffect(()=>{n.current=e}),r})(w);t.useEffect(()=>{const e=ee&&w(pe)&&!Me;_e.current=!e,le(e),Be&&p(null)},[w]),((e,n,r)=>{const{commands:o,version:a}=ne(),s=t.useRef(0);t.useEffect(()=>{if(a===s.current)return;if(s.current=a,!o)return;let t;for(const n of o)re(e,n)&&(t=n);t&&(t.collapsed||(n.current=!0),r(t.collapsed))},[a,o])})(me,_e,ee?le:n);const We=t.useRef(null),Ye=t.useCallback(e=>Z(t=>"function"==typeof e?e(t??V(y)):e),[y,V]),Ue=t.useCallback(()=>Z(null),[]),$e=t.useMemo(()=>Me?Q??V(y):null,[Me,Q,y,V]),Je=t.useCallback((e,t)=>{if("function"!=typeof A)return A;const n=A(e,t);return void 0!==n?n:null},[A]),Xe=t.useCallback(e=>I?"function"!=typeof I?I:I(e):null,[I]),{CustomComponent:Qe,componentProps:Ze,CustomWrapperComponent:Ge,wrapperProps:qe={},showKey:et=!0,showEditTools:tt=!0,showOnEdit:nt,showOnView:rt,passOriginalNode:ot}=_,at=q(e=>null!==e.active&&f(e.active.path,me));!at&&ee||!ie||le(!1);const st=ue(me)||0===pe.level,it=t.useRef(n);if(!st&&!at)return null;const{visibleSize:lt}=pe,ct=Array.isArray(y)?"array":"object",ut="array"===ct?{open:"[",close:"]"}:{open:"{",close:"}"},dt=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")&&e.target===We.current){e.preventDefault();const t=P(We,"\t");return void Z(t)}H(e,{objectConfirm:mt,cancel:yt})},pt=e=>{if(e.stopPropagation(),!ee)return;const t=O(e);if(t&&B.collapseModifier.includes(t))return _e.current=!0,void p({collapsed:!ie,path:me,includeChildren:!0});u(me)||(_e.current=!0,U&&U({...pe,fullData:X(),collapsed:!ie,includeChildren:!1}),le(!ie))},mt=(e,t)=>{const n=void 0!==e&&!i(e);let r=y;if(n)r=e;else if(null!==Q)try{r=M(Q)}catch{return void De({code:"INVALID_JSON",message:L("ERROR_INVALID_JSON",pe)},Q)}xe(null),c({op:"edit",path:me,value:r,onCommit:()=>{Ue(),t?.()}}).then(e=>{if("error"===e?.status&&De(e.error,r),"error"===e?.status||"cancel"===e?.status){const e=d().active;"editing"===e?.phase&&h(e.path,me)||Ue()}})};it.current=mt;const ht=e=>mt(e),ft=me.length>0?()=>{c({op:"delete",path:me,instant:!0}).then(e=>{"error"===e?.status&&De(e.error,y)})}:void 0,yt=()=>{l(),xe(null),Ue()},gt="when-collapsed"===b?ie:"when-collapsed-or-filtered"===b?ie||null!=lt:b,vt=!Me&&tt,bt=(N||!ze)&&et&&void 0!==he,jt=Qe&&(Me&&nt||!Me&&rt),xt=Object.entries(y).map(([e,t])=>["array"===ct?Number(e):e,t]);"object"===ct&&R(xt,e=>e);const wt=!Me||!!Qe&&nt,Et=()=>e.jsxs("div",{className:"jer-collection-text-edit"+(F?"-custom":""),children:[F?e.jsx(F,{value:$e??"",onChange:Z,onKeyDown:e=>H(e,{objectConfirm:mt,cancel:yt})}):e.jsx(k,{textAreaRef:We,className:"jer-collection-text-area",name:de,value:$e??"",setValue:Ye,onKeyDown:dt,styles:a("input",pe)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(Ce,{onOk:mt,onCancel:yt,nodeData:pe,translate:L,showIconTooltips:S,editConfirmRef:$})})]}),Ct=_e.current?wt?xt.map(([t,n],s)=>{const i={key:t,value:n,path:[...me,t],level:me.length+1,index:s,size:o(n)?Object.keys(n).length:null,parentData:y,fullData:pe.fullData},l=Te(K,i);return e.jsx("div",{className:"jer-collection-element",style:a("collectionElement",i),children:o(n)&&!l?.renderCollectionAsValue?e.jsx(He,{...r,data:n,parentData:y,nodeData:i,canDragOnto:ye,canAddHere:ve,customNodeData:l},t):e.jsx(Ke,{...r,data:n,parentData:y,nodeData:i,canDragOnto:ye,canAddHere:ve,showLabel:"object"===ct||N,customNodeData:l},t)},t)}):e.jsx(e.Fragment,{children:Et()}):null,Dt=!!ee&&ie&&!at;Dt||(_e.current=!0);const St=L(ie?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",pe),kt=()=>({...r,data:y,value:y,parentData:v,nodeData:pe,setValue:ht,handleEdit:mt,handleCancel:yt,onKeyDown:dt,isEditing:Me,isPending:Fe,setIsEditing:ye?()=>s(me,{cancelOp:Ue,commitOp:e=>it.current(void 0,e)}):n,getStyles:a,canDragOnto:ye,canAddHere:ve,canEdit:ye,keyboardCommon:{}}),Ot=jt?e.jsx(Qe,{componentProps:Ze,...kt(),originalNode:ot&&Me?Et():void 0,children:Ct}):Ct,Tt=vt&&e.jsx(Ee,{startEdit:ye?()=>{_e.current=!0,s(me,{cancelOp:Ue,commitOp:e=>it.current(void 0,e)})}:void 0,handleAdd:ve?e=>{p(null),le(!1);const t=Je(pe,e);if("array"===ct){const e=W.array?0:y.length,n=W.array?{insert:!0}:{};return void c({op:"add",path:me,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&De(e.error,t)})}if(e in y)return De({code:"KEY_EXISTS",message:L("ERROR_KEY_EXISTS",pe)},e),void l();const n=W.object?{insertBefore:0}:{};c({op:"add",path:me,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&De(e.error,t)})}:void 0,handleDelete:ge?ft:void 0,showClipboardButton:C,onCopy:D,type:ct,nodeData:pe,translate:L,customButtons:r.customButtons,handleEdit:ht,canEdit:ye,keyboardControls:B,handleKeyboard:H,getNewKeyOptions:Xe,editConfirmRef:$,jsonStringify:V,showIconTooltips:S,Select:z}),Rt=ke({handleCancel:yt,getStyles:a,keyValueArray:xt,handleClick:J.includes("property")?pt:e=>e.stopPropagation()}),Nt=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===me.length?0:T/2)+"em",...a("collection",pe),position:"relative"},draggable:be&&!Me&&!Ve&&!at,...Oe,...Pe("above"),children:[ee&&e.jsx("div",{className:"jer-clickzone",style:{width:T/2+1+"em",zIndex:10+2*pe.level},onClick:J.includes("left")?pt:void 0}),!Me&&Ie,e.jsx(Le,{position:"above",nodeData:pe}),ee?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",pe),position:"relative"},onClick:J.includes("header")?pt:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(ie?" jer-rotate-90":""),style:{zIndex:11+2*pe.level,transition:ce},onClick:pt,tabIndex:-1,"aria-expanded":!ie,"aria-label":St,title:S?St:"",children:e.jsx(we,{name:"collection",nodeData:pe})}),bt&&e.jsx(Ae,{...Rt}),!Me&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:a("bracket",pe),children:ut.open})]}),!1!==b&&!Me&&e.jsx("div",{className:"jer-collection-item-count"+(gt?" jer-visible":" jer-hidden"),style:{...a("itemCount",pe),transition:ce,transitionBehavior:"allow-discrete"},children:null!=lt&<!==fe?L("ITEMS_FILTERED",pe,{visible:lt,total:fe}):1===fe?L("ITEM_SINGLE",{...pe,size:1},1):L("ITEMS_MULTIPLE",pe,fe)}),e.jsx("div",{className:"jer-brackets"+(Dt?" jer-visible":" jer-hidden"),style:{...a("bracket",pe),transition:ce},children:ut.close}),Tt]}):et?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",pe),position:"relative"},children:[e.jsx(Ae,{...Rt}),Tt]}):e.jsx(e.Fragment,{}),e.jsxs("div",{className:"jer-collection-inner",style:{overflowY:Dt||ae?"clip":"visible",maxHeight:at?void 0:se,...a("collectionInner",pe),transition:`max-height ${ce}`},ref:oe,children:[Ot,e.jsx("div",{className:Me?"jer-collection-error-row-edit":"jer-collection-error-row",children:je&&e.jsx("span",{className:"jer-error-slug",style:a("error",pe),children:je})}),!Me&&ee&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:a("bracket",pe),children:ut.close})]}),e.jsx(Le,{position:"below",nodeData:pe})]});return Ge?e.jsx(Ge,{wrapperProps:qe,...kt(),children:Nt}):Nt},He=/*#__PURE__*/t.memo(Be,Ie),We=({options:t,value:n,defaultValue:r,onChange:o,placeholder:a,className:s,...i})=>{const l=void 0!==n?{value:n}:{defaultValue:r??""};return e.jsxs("div",{className:"jer-select",children:[e.jsxs("select",{className:s??"jer-select-inner",onChange:e=>o(e.target.value),...i,...l,children:[void 0!==a&&e.jsx("option",{value:"",disabled:!0,children:a}),t.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx("span",{className:"focus"})]})},Ye=(e,t="")=>{const{value:n}=e;if(null===n&&"null".includes(t.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(t.toLowerCase());case"number":return!!String(n).includes(t);case"boolean":return n?"true".includes(t.toLowerCase())||"1"===t:"false".includes(t.toLowerCase())||"0"===t;default:return!1}},Ue=({key:e,path:t},n="")=>!!Ye({value:e},n)||!!t.some(e=>Ye({value:e},n)),$e={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 Je=':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.2em;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-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-custom-button:empty{display:none}.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 Xe="data-jer-styles",Qe=(e,t)=>JSON.stringify(e,t,2),Ze={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},Ge={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},et=[],tt=["header","left"],nt={},rt={},ot={},at=[],st=({data:i,setData:l,buildNodeDataFromPathRef:u,commitRef:d,rootName:p="root",onUpdate:h=n,onChange:f,onError:y,onEditEvent:g,showErrorMessages:v=!0,showClipboardButton:b=!0,onCopy:j,indent:x=2,collapse:w=3,collapseAnimationTime:C=300,showCollectionCount:S="when-collapsed-or-filtered",allowEdit:k=!0,allowDelete:O=!0,allowAdd:R=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:L,searchText:K,searchDebounceTime:_=350,sortKeys:M=!1,showArrayIndexes:V=!0,arrayIndexStart:F=0,showStringQuotes:z=!0,showIconTooltips:B=!1,defaultValue:H=null,newKeyOptions:W,minWidth:U=250,maxWidth:$="min(600px, 90vw)",baseFontSize:J,stringTruncateLength:X=250,translations:Q=nt,className:Z,id:q,customText:ee=rt,customNodeDefinitions:te=et,customButtons:re=at,jsonParse:oe=JSON.parse,jsonStringify:ae=Qe,TextEditor:se,Select:ie=We,errorDisplayTime:ce=2500,keyboardControls:ue=ot,editorRef:de,insertAtTop:pe=!1,onCollapse:me,collapseClickZones:he=tt})=>{const{getStyles:fe,cssVars:ye}=Y(),{open:ge,cancel:ve,getSnapshot:be}=G(),je=t.useMemo(()=>ct(w),[w]),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]:$e[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=D(i,[],p),Se=t.useRef(i);Se.current=i;const ke=t.useRef(l);ke.current=l;const Oe=t.useRef(xe);Oe.current=xe;const Re=t.useRef(De);Re.current=De;const Ne=t.useRef(h);Ne.current=h;const Ae=t.useRef(p);Ae.current=p;const Pe=t.useRef(void 0),Ie=t.useCallback(()=>Se.current,[]),Le=qe(f),_e=qe(y),Me=qe(me),Ve=qe(g),Fe=qe(j),ze=t.useCallback(e=>{Se.current=e,ke.current(e)},[]),Be=t.useCallback((e,t)=>{ze(lt(Se.current,e,t,"update").newData)},[ze]),Ue=t.useCallback(e=>{const t=Se.current,n=Ae.current,r=Pe.current,o=ze,{op:a,path:s}=e;switch(a){case"edit":{const{newData:a,currentValue:i,newValue:l}=lt(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(lt(Se.current,s,i,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=lt(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(lt(Se.current,s,a,"add",{insert:!0,insertBefore:i.index}).newData)}}case"add":{const a=[...s,e.key],{newData:i,newValue:l}=lt(t,a,e.value,"add",e.options),c=D(i,a,n,r);return{input:{...c,value:void 0,size:null,parentData:E(t,s)??null,fullData:t,newData:i,event:"add",newValue:l},nodeData:c,isNoOp:!1,apply:()=>o(i),revert:()=>o(lt(Se.current,a,"","delete").newData)}}case"rename":{const a=s.slice(0,-1),i=s[s.length-1],{newKey:l}=e,c=E(t,a),u=Object.fromEntries(Object.entries(c).map(([e,t])=>e===i?[l,t]:[e,t])),{newData:d}=lt(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(lt(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}=lt(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}=lt(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)}}}},[ze]),Je=t.useCallback((e,t)=>{const n=Ge[e.event],r=()=>Oe.current(Ze[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)},[]),Xe=t.useMemo(()=>({runUpdate:h===n?void 0:Je,buildCommit:Ue,applyValue:Be}),[Je,Ue,Be,h]);d.current=Xe;const st=t.useMemo(()=>ct(k),[k]),it=t.useMemo(()=>ct(O),[O]),pt=t.useMemo(()=>ct(R),[R]),mt=t.useMemo(()=>ct(I),[I]),ht=t.useMemo(()=>ut(L),[L]),ft=t.useMemo(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,a=new Map,s=t??Ye,i=n??"",l=e=>{let t=s(e,i);if(o(e.value)){let n=0;const r=Array.isArray(e.value),s=Object.entries(e.value);for(const[a,i]of s){const s=r?Number(a):a,c={key:s,path:[...e.path,s],level:e.level+1,index:n,value:i,size:o(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(c)&&(t=!0,n++)}a.set(m(e.path),n)}return t&&r.add(m(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:a}})(De,ht,we),[i,we,ht,p]),yt=t.useMemo(()=>(e=>{const t={...N};for(const n of Object.keys(N)){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 A.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(T(n,e[r],r)){n.preventDefault(),o();break}})(yt,t,e),[yt]),vt=t.useMemo(()=>{const e=dt(te,"stringifyReplacer");return t=>ae(t,e)},[te,ae]),bt=t.useMemo(()=>{const e=dt(te,"parseReviver");return t=>{const n=oe(t,e);return c(n)}},[te,oe]),jt=t.useRef(null),{setCollapseState:xt}=ne(),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=>D(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})=>E(Ie(),t,e)===e?"PATH_NOT_FOUND":n||st(D(Ie(),t,p,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,p,wt]);const Ct=Te(te,De),Dt=t.useMemo(()=>({object:!0===pe||"object"===pe,array:!0===pe||"array"===pe}),[pe]),St={mainContainerRef:Ce,name:p,nodeData:De,getLatestData:Ie,onChange:Le,onError:_e,onEditEvent:Ve,showErrorMessages:v,showCollectionCount:S,collapseFilter:je,collapseAnimationTime:C,allowEditFilter:st,allowDeleteFilter:it,allowAddFilter:pt,allowTypeSelection:P,allowDragFilter:mt,canDragOnto:!1,canAddHere:!1,showClipboardButton:b,onCopy:Fe,sortKeys:M,sort:wt,showArrayIndexes:V,arrayIndexStart:F,showStringQuotes:z,showIconTooltips:B,indent:x,defaultValue:H,newKeyOptions:W,stringTruncateLength:X,translate:xe,customNodeDefinitions:te,customNodeData:Ct,customButtons:re,parentData:null,jsonParse:bt,jsonStringify:vt,TextEditor:se,Select:ie,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 ${Z??""}`,style:kt,children:e.jsx(le,{value:ft,children:o(i)&&!Ct.renderCollectionAsValue?e.jsx(He,{data:i,...St}):e.jsx(Ke,{data:i,showLabel:!0,...St})})})};function it(n){t.useInsertionEffect(()=>{(()=>{if("undefined"==typeof document)return;const e=document.head.querySelector(`style[${Xe}]`);if(e)return void(e.textContent!==Je&&(e.textContent=Je));const t=document.createElement("style");t.setAttribute(Xe,""),t.textContent=Je,document.head.appendChild(t)})()},[]);const r=t.useRef(void 0),o=t.useRef(void 0),a=n;return e.jsx(W,{theme:a.theme??M,children:e.jsx(se,{onEditEvent:a.onEditEvent,onCollapse:a.onCollapse,buildNodeDataFromPathRef:r,commitRef:o,children:e.jsx(st,{...a,buildNodeDataFromPathRef:r,commitRef:o})})})}const lt=(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?E(e,t):void 0;return{currentData:e,newData:b(e,t,n,a),currentValue:s,newValue:"delete"!==r?n:void 0}},ct=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,ut=e=>{if(void 0!==e)return"value"===e?Ye:"key"===e?Ue:"all"===e?(e,t)=>Ye(e,t)||Ue(e,t):e},dt=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?u: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=k,exports.IconSvg=xe,exports.JsonEditor=it,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(it,{...a,editorRef:s,setData:n,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})},exports.StringDisplay=me,exports.StringEdit=he,exports.assign=b,exports.collectionDataTypes=Se,exports.defaultTheme=M,exports.extract=E,exports.isCollection=o,exports.matchNode=Ye,exports.matchNodeKey=Ue,exports.splitPropertyString=d,exports.standardDataTypes=ke,exports.toPathString=m,exports.useKeyboardListener=ve,exports.valueDataTypes=De;
|
package/build/index.d.ts
CHANGED
|
@@ -366,7 +366,7 @@ interface CustomComponentProps<T = Record<string, unknown>> extends Omit<BaseNod
|
|
|
366
366
|
componentProps?: T;
|
|
367
367
|
parentData: CollectionData | null;
|
|
368
368
|
setValue: (value: JsonData) => void;
|
|
369
|
-
handleEdit: (value?:
|
|
369
|
+
handleEdit: (value?: JsonData) => void;
|
|
370
370
|
handleCancel: () => void;
|
|
371
371
|
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
372
372
|
isEditing: boolean;
|
|
@@ -408,11 +408,18 @@ interface CustomNodeDefinition<T = Record<string, unknown>, U = Record<string, u
|
|
|
408
408
|
type CustomTextDefinitions = Partial<{
|
|
409
409
|
[key in keyof LocalisedStrings]: CustomTextFunction;
|
|
410
410
|
}>;
|
|
411
|
+
type CustomButtonHandleEdit = (value: JsonData) => void;
|
|
412
|
+
interface CustomButtonElementProps {
|
|
413
|
+
nodeData: NodeData;
|
|
414
|
+
canEdit: boolean;
|
|
415
|
+
handleEdit: CustomButtonHandleEdit;
|
|
416
|
+
}
|
|
411
417
|
interface CustomButtonDefinition {
|
|
412
|
-
Element: React.FC<
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
418
|
+
Element: React.FC<CustomButtonElementProps>;
|
|
419
|
+
onClick?: (nodeData: NodeData, e: React.MouseEvent, context: {
|
|
420
|
+
handleEdit: CustomButtonHandleEdit;
|
|
421
|
+
canEdit: boolean;
|
|
422
|
+
}) => void;
|
|
416
423
|
label?: string;
|
|
417
424
|
}
|
|
418
425
|
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';
|
|
@@ -529,4 +536,4 @@ type InputObject = BasicObject | BasicArray | unknown;
|
|
|
529
536
|
declare const extract: (inputObj: InputObject, properties: string | number | (string | number)[], fallback?: any) => any;
|
|
530
537
|
|
|
531
538
|
export { AutogrowTextArea, IconSvg, JsonEditor, JsonViewer, StringDisplay, StringEdit, assign, collectionDataTypes, defaultTheme, extract, isCollection, matchNode, matchNodeKey, splitPropertyString, standardDataTypes, toPathString, useKeyboardListener, valueDataTypes };
|
|
532
|
-
export type { AssignInput, AssignOptions, CollapseState, CollectionNodeProps, CompareFunction, CustomButtonDefinition, CustomComponentProps, CustomKeyProps, CustomNodeDefinition, CustomTextDefinitions, CustomTextFunction, CustomWrapperProps, DataType, DefaultValueFunction, EditEvent, EnumDefinition, ErrorString, FilterFunction, IconDefinition, JerError, JerErrorCode, JsonData, JsonEditorHandle, JsonEditorProps, JsonViewerHandle, JsonViewerProps, KeyboardControls, LocalisedStrings, NewKeyOptionsFunction, NodeData, OnChangeFunction, OnCollapseFunction, OnCopyFunction, OnEditEventFunction, OnErrorFunction, SearchFilterFunction, SelectProps, StartEditOptions, StartEditResult, TextEditorProps, Theme, ThemeIcons, ThemeInput, ThemeStyles, TranslateFunction, TypeFilterFunction, TypeOptions, UpdateFunction, UpdateFunctionProps, UpdateResult, ValueNodeProps };
|
|
539
|
+
export type { AssignInput, AssignOptions, CollapseState, CollectionNodeProps, CompareFunction, CustomButtonDefinition, CustomButtonElementProps, CustomComponentProps, CustomKeyProps, CustomNodeDefinition, CustomTextDefinitions, CustomTextFunction, CustomWrapperProps, DataType, DefaultValueFunction, EditEvent, EnumDefinition, ErrorString, FilterFunction, IconDefinition, JerError, JerErrorCode, JsonData, JsonEditorHandle, JsonEditorProps, JsonViewerHandle, JsonViewerProps, KeyboardControls, LocalisedStrings, NewKeyOptionsFunction, NodeData, OnChangeFunction, OnCollapseFunction, OnCopyFunction, OnEditEventFunction, OnErrorFunction, SearchFilterFunction, SelectProps, StartEditOptions, StartEditResult, TextEditorProps, Theme, ThemeIcons, ThemeInput, ThemeStyles, TranslateFunction, TypeFilterFunction, TypeOptions, UpdateFunction, UpdateFunctionProps, UpdateResult, ValueNodeProps };
|
package/build/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useLayoutEffect as o,useEffect as a,useRef as i,createContext as l,useContext as s,useMemo as c,useCallback as d,useSyncExternalStore as u,useState as p,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,S]=p(""),[k,T]=p(!1),{path:N,value:x}=d,R=de(e=>{const t=e.active;return null!==t&&"add"===t.op&&O(t.path,N)}),A=Array.isArray(k);V(()=>{if(!R)return T(!1),void S("");const e=Object.keys(L(d.fullData,N)),t=y?y(d)?.filter(t=>!e.includes(t)):null;T(t??!0)},[R]);const P=()=>{a&&C&&a("array"===s?"":C)};return e("div",{className:"jer-edit-buttons",style:{opacity:R?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&t("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",a=null;if(i){const i=z(e);if(i&&h.clipboardModifier.includes(i)?(t=j(N),o=t,r="path"):(t=x,o="object"==typeof t?g(x):String(t)),!navigator.clipboard)return void l?.({...d,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,a=e.message}).finally(()=>{l?.({...d,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:a??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":u("TOOLTIP_COPY",d),title:v?u("TOOLTIP_COPY",d):"",children:t(Pe,{name:"copy",nodeData:d})}),r&&t("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":u("TOOLTIP_EDIT",d),title:v?u("TOOLTIP_EDIT",d):"",children:t(Pe,{name:"edit",nodeData:d})}),o&&t("button",{type:"button",tabIndex:-1,onClick:o,"aria-label":u("TOOLTIP_DELETE",d),title:v?u("TOOLTIP_DELETE",d):"",children:t(Pe,{name:"delete",nodeData:d})}),a&&t("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===s?D(N,{op:"add"}):a("")},"aria-label":u("TOOLTIP_ADD",d),title:v?u("TOOLTIP_ADD",d):"",children:t(Pe,{name:"add",nodeData:d})}),c?.map(({Element:e,onClick:n,label:r},o)=>{const a=e=>n&&n(d,e);return r?t("button",{type:"button",tabIndex:-1,onClick:a,"aria-label":r,title:v?r:"",children:t(e,{nodeData:d})},o):t("div",{onClick:a,children:t(e,{nodeData:d})},o)}),R&&a&&"object"===s&&e(n,{children:[A?t(b,{name:"new-key-select",onChange:a,defaultValue:"",autoFocus:!0,onKeyDown:e=>m(e,{cancel:()=>E()}),placeholder:k.length>0?u("KEY_SELECT",d):u("NO_KEY_OPTIONS",d),options:k}):t("input",{className:"jer-input-text jer-input-new-key",type:"text",name:"new-object-key",value:C,placeholder:u("KEY_NEW",d),onChange:e=>S(e.target.value),autoFocus:!0,onKeyDown:e=>{m(e,{stringConfirm:()=>P(),cancel:()=>E()})},style:w("input",d)}),t(Le,{onOk:()=>P(),onCancel:()=>E(),nodeData:d,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:A})]})]})},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,getSnapshot:m}=ce(),{setCollapseState:y}=he(),{mainContainerRef:v,data:b,nodeData:w,parentData:D,showCollectionCount:E,canDragOnto:C,canAddHere:j,collapseFilter:S,collapseAnimationTime:T,showClipboardButton:N,onCopy:x,showIconTooltips:R,indent:A,sort:P,showArrayIndexes:I,defaultValue:L,newKeyOptions:K,translate:_,customNodeDefinitions:V,customNodeData:F,jsonParse:B,jsonStringify:H,TextEditor:W,Select:U,keyboardControls:$,handleKeyboard:X,insertAtTop:J,onCollapse:Q,editConfirmRef:Z,collapseClickZones:G,getLatestData:q}=r,[ee,te]=p(null),{showCollectionWrapper:re=!0}=F,oe=re&&S(w),{contentRef:ae,isAnimating:ie,maxHeight:le,collapsed:se,animateCollapse:ue,cssTransitionValue:pe}=((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}})(b,T,oe,v,H),{pathString:fe,nodeData:ye,path:ge,name:ve,size:be,canEdit:we,canDelete:Ee,canAdd:Ce,canDrag:je,error:Se,setError:Oe,onError:ke,derivedValues:Te,buildKeyDisplayProps:Ne}=Fe({props:r,collapsed:se}),{dragSourceProps:xe,getDropTargetProps:Re,BottomDropTarget:Ae,DropTargetPadding:Ke}=Be({canDrag:je,canDelete:Ee,canDragOnto:C,canAddHere:j,path:ge,nodeData:ye,onError:ke,translate:_}),_e=i(!oe),{isEditing:Ve,isEditingKey:Me,isPending:We,isArray:Ye}=Te,Ue=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(S);a(()=>{const e=re&&S(ye)&&!Ve;_e.current=!e,ue(e),Ue&&y(null)},[S]),((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])})(ge,_e,re?ue:f);const Xe=i(null),Je=d(e=>te(t=>"function"==typeof e?e(t??H(b)):e),[b,H]),Qe=d(()=>te(null),[]),Ze=c(()=>Ve?ee??H(b):null,[Ve,ee,b,H]),Ge=d((e,t)=>{if("function"!=typeof L)return L;const n=L(e,t);return void 0!==n?n:null},[L]),qe=d(e=>K?"function"!=typeof K?K:K(e):null,[K]),{CustomComponent:tt,componentProps:nt,CustomWrapperComponent:rt,wrapperProps:ot={},showKey:at=!0,showEditTools:it=!0,showOnEdit:lt,showOnView:st,passOriginalNode:ct}=F,dt=de(e=>null!==e.active&&k(e.active.path,ge));!dt&&re||!se||ue(!1);const ut=De(ge)||0===ye.level,pt=i(f);if(!ut&&!dt)return null;const{visibleSize:ht}=ye,mt=Array.isArray(b)?"array":"object",ft="array"===mt?{open:"[",close:"]"}:{open:"{",close:"}"},yt=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")&&e.target===Xe.current){e.preventDefault();const t=Y(Xe,"\t");return void te(t)}X(e,{objectConfirm:vt,cancel:wt})},gt=e=>{if(e.stopPropagation(),!re)return;const t=z(e);if(t&&$.collapseModifier.includes(t))return _e.current=!0,void y({collapsed:!se,path:ge,includeChildren:!0});h(ge)||(_e.current=!0,Q&&Q({...ye,fullData:q(),collapsed:!se,includeChildren:!1}),ue(!se))},vt=e=>{let t=b;if(null!==ee)try{t=B(ee)}catch{return void ke({code:"INVALID_JSON",message:_("ERROR_INVALID_JSON",ye)},ee)}Oe(null);const n="function"==typeof e?e:void 0;u({op:"edit",path:ge,value:t,onCommit:()=>{Qe(),n?.()}}).then(e=>{if("error"===e?.status&&ke(e.error,t),"error"===e?.status||"cancel"===e?.status){const e=m().active;"editing"===e?.phase&&O(e.path,ge)||Qe()}})};pt.current=vt;const bt=ge.length>0?()=>{u({op:"delete",path:ge,instant:!0}).then(e=>{"error"===e?.status&&ke(e.error,b)})}:void 0,wt=()=>{s(),Oe(null),Qe()},Dt="when-collapsed"===E?se:"when-collapsed-or-filtered"===E?se||null!=ht:E,Et=!Ve&&it,Ct=(I||!Ye)&&at&&void 0!==ve,jt=tt&&(Ve&<||!Ve&&st),St=Object.entries(b).map(([e,t])=>["array"===mt?Number(e):e,t]);"object"===mt&&P(St,e=>e);const Ot=!Ve||!!tt&<,kt=()=>e("div",{className:"jer-collection-text-edit"+(W?"-custom":""),children:[W?t(W,{value:Ze??"",onChange:te,onKeyDown:e=>X(e,{objectConfirm:vt,cancel:wt})}):t(M,{textAreaRef:Xe,className:"jer-collection-text-area",name:fe,value:Ze??"",setValue:Je,onKeyDown:yt,styles:o("input",ye)}),t("div",{className:"jer-collection-input-button-row",children:t(Le,{onOk:vt,onCancel:wt,nodeData:ye,translate:_,showIconTooltips:R,editConfirmRef:Z})})]}),Tt=_e.current?Ot?St.map(([e,n],a)=>{const i={key:e,value:n,path:[...ge,e],level:ge.length+1,index:a,size:g(n)?Object.keys(n).length:null,parentData:b,fullData:ye.fullData},l=ze(V,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:g(n)&&!l?.renderCollectionAsValue?t(et,{...r,data:n,parentData:b,nodeData:i,canDragOnto:we,canAddHere:Ce,customNodeData:l},e):t($e,{...r,data:n,parentData:b,nodeData:i,canDragOnto:we,canAddHere:Ce,showLabel:"object"===mt||I,customNodeData:l},e)},e)}):t(n,{children:kt()}):null,Nt=!!re&&se&&!dt;Nt||(_e.current=!0);const xt=_(se?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",ye),Rt=()=>({...r,data:b,value:b,parentData:D,nodeData:ye,setValue:e=>u({op:"edit",path:ge,value:e}),handleEdit:vt,handleCancel:wt,onKeyDown:yt,isEditing:Ve,isPending:We,setIsEditing:we?()=>l(ge,{cancelOp:Qe,commitOp:e=>pt.current(e)}):f,getStyles:o,canDragOnto:we,canAddHere:Ce,canEdit:we,keyboardCommon:{}}),At=jt?t(tt,{componentProps:nt,...Rt(),originalNode:ct&&Ve?kt():void 0,children:Tt}):Tt,Pt=Et&&t(Ie,{startEdit:we?()=>{_e.current=!0,l(ge,{cancelOp:Qe,commitOp:e=>pt.current(e)})}:void 0,handleAdd:Ce?e=>{y(null),ue(!1);const t=Ge(ye,e);if("array"===mt){const e=J.array?0:b.length,n=J.array?{insert:!0}:{};return void u({op:"add",path:ge,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&ke(e.error,t)})}if(e in b)return ke({code:"KEY_EXISTS",message:_("ERROR_KEY_EXISTS",ye)},e),void s();const n=J.object?{insertBefore:0}:{};u({op:"add",path:ge,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&ke(e.error,t)})}:void 0,handleDelete:Ee?bt:void 0,showClipboardButton:N,onCopy:x,type:mt,nodeData:ye,translate:_,customButtons:r.customButtons,keyboardControls:$,handleKeyboard:X,getNewKeyOptions:qe,editConfirmRef:Z,jsonStringify:H,showIconTooltips:R,Select:U}),It=Ne({handleCancel:wt,getStyles:o,keyValueArray:St,handleClick:G.includes("property")?gt:e=>e.stopPropagation()}),Lt=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===ge.length?0:A/2)+"em",...o("collection",ye),position:"relative"},draggable:je&&!Ve&&!Me&&!dt,...xe,...Re("above"),children:[re&&t("div",{className:"jer-clickzone",style:{width:A/2+1+"em",zIndex:10+2*ye.level},onClick:G.includes("left")?gt:void 0}),!Ve&&Ae,t(Ke,{position:"above",nodeData:ye}),re?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ye),position:"relative"},onClick:G.includes("header")?gt:void 0,children:[e("div",{className:"jer-collection-name",children:[t("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(se?" jer-rotate-90":""),style:{zIndex:11+2*ye.level,transition:pe},onClick:gt,tabIndex:-1,"aria-expanded":!se,"aria-label":xt,title:R?xt:"",children:t(Pe,{name:"collection",nodeData:ye})}),Ct&&t(He,{...It}),!Ve&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",ye),children:ft.open})]}),!1!==E&&!Ve&&t("div",{className:"jer-collection-item-count"+(Dt?" jer-visible":" jer-hidden"),style:{...o("itemCount",ye),transition:pe,transitionBehavior:"allow-discrete"},children:null!=ht&&ht!==be?_("ITEMS_FILTERED",ye,{visible:ht,total:be}):1===be?_("ITEM_SINGLE",{...ye,size:1},1):_("ITEMS_MULTIPLE",ye,be)}),t("div",{className:"jer-brackets"+(Nt?" jer-visible":" jer-hidden"),style:{...o("bracket",ye),transition:pe},children:ft.close}),Pt]}):at?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ye),position:"relative"},children:[t(He,{...It}),Pt]}):t(n,{}),e("div",{className:"jer-collection-inner",style:{overflowY:Nt||ie?"clip":"visible",maxHeight:dt?void 0:le,...o("collectionInner",ye),transition:`max-height ${pe}`},ref:ae,children:[At,t("div",{className:Ve?"jer-collection-error-row-edit":"jer-collection-error-row",children:Se&&t("span",{className:"jer-error-slug",style:o("error",ye),children:Se})}),!Ve&&re&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",ye),children:ft.close})]}),t(Ke,{position:"below",nodeData:ye})]});return rt?t(rt,{wrapperProps:ot,...Rt(),children:Lt}):Lt},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.2em;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-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};
|
|
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=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault,E=(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!==C){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=D(n);r!==n&&(e[t]=r)}return e}},C="__undefined__",j=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),S=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),O=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),k=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),T=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),N=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},x=e=>Array.isArray(e),R=(e,t)=>e.filter((e,n)=>n!==t),A=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:i=!1}=r,l=e,s=S(t),c={...r,remove:o,createNew:a,noError:i,fullData:l,fullPath:s},d=Array.isArray(t)?t:j(t);return x(e)&&o&&1===d.length?R(e,d[0]):P(e,d,n,c)},P=(e,t,n,r)=>{const o=v(e)?{...e}:null,a=x(e)?[...e]:null;if(0===t.length)return e;if(!o&&!a)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:s,fullData:c,fullPath:d}=r,u=t[0];if(a&&"string"==typeof u)return a.map(e=>P(e,t,n,r));if(1===t.length)return o&&"string"==typeof u?I(o,u,n,r)??o:a&&"number"==typeof u?(L(a,u,n,r),a):(N(c,d,u,s),e);const p=o||a||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=p[u],n=t[1];return x(e)?p[u]=R(e,n):N(c,d,u,s,"Trying to remove an indexed item from an object that is not an array"),p}const h=t.slice(1);if(u in e){if(m=p[u],!x(m)&&!v(m)){if(!i)return N(c,d,u,s),p;p[u]={}}return p[u]=P(p[u],h,n,r),p}var m;if(i){const e="number"==typeof h[0]?[]:{};if(o)return p[u]=e,p[u]=P(p[u],h,n,r),p;if(a&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=P(p[t],h,n,r),p}}return N(c,d,u,s),p},I=(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]:N(c,d,t,i):a||u?e[t]=n:N(c,d,t,i)},L=(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):N(a,i,t,o)},K=(e,t,n)=>{const r=Array.isArray(t)?t:j(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=>K(e,r,n));if("object"!=typeof e||null===e||!(o in e))return _(e,o,n);const a=e[o];return 1===r.length?a:K(a,r.slice(1),n)},_=(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},V=(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=K(e,t),i=K(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}},M="undefined"!=typeof window?o:a,z=({className:n,name:r,value:o,setValue:a,onKeyDown:l,styles:s,textAreaRef:c})=>{const d=i(null);if(M(()=>{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})]})},F=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,B=(e,t,n)=>{if(!t)return!1;const r=e.key,o=F(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))},H={key:"Enter"},W={confirm:H,cancel:{key:"Escape"},objectConfirm:{...H,modifier:["Meta","Shift","Control"]},objectLineBreak:H,stringConfirm:H,stringLineBreak:{...H,modifier:["Shift"]},numberConfirm:H,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:H,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},Y=["stringConfirm","numberConfirm","booleanConfirm"],U=(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},$=(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=K(e,a),s=J(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:$(e,a,n,r,o);let u;if(g(d.value)){if(0===Object.keys(d.value).length)return $(e,[...a,d.key],n,r,o);u=X(e,[...a,d.key],n,r)}else u=[...a,d.key];return u?o(V(e,u,"",r))?u:$(e,u,n,r,o):null},X=(e,t,n="next",r)=>{const o=K(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 X(e,[...t,i],n,r)},J=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),Q={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},Z={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:Q,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:Q,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"}},G={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},q=e=>[Z,...y(e)].map(e=>"styles"in e?e:{styles:e}),ee=e=>{const t={};for(const{icons:n}of q(e))n&&Object.assign(t,n);return t},te=/*#__PURE__*/l({getStyles:()=>({}),icons:/*#__PURE__*/ee(Z),cssVars:{}}),ne=({theme:e=Z,children:n})=>{const r=c(()=>(e=>{var t;const n=q(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[G[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__*/ee(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(te.Provider,{value:l,children:n})},re=()=>s(te),oe={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"}},ae=(e,t)=>oe[e][t]??null,ie=(e,t)=>null!==e&&null!==t&&e.op===t.op&&k(e.path,t.path),le={active:null,settling:{}},se=/*#__PURE__*/l(null),ce=({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=le;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,ie(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=ae(e.op,"start");o&&u(e.path,o)},h=(e,t,o,l,s,u,p,h,m)=>{const f=O(e);if(!p()){if("cancel"===l.status||"error"===l.status){r.active&&k(r.active.path,e)&&("held"===r.active.phase||"editing"===r.active.phase)&&(c({...r,active:null}),a=null,i=null);const n=ae(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&&!ie(o,n);if(l&&i)return void i(()=>p(n,t));const s=a;if(a=null,i=null,s&&s(),l&&ie(r.active,o)){const e=ae(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=ae(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 ie(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null,p?.(),Promise.resolve(void 0)}const y=f?.extra,g=O(o),v=++s;if(!l){const e=ae(t,"submit");e&&u(o,e)}if(!f||f.isNoOp){ie(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null;const e=ae(t,"commit");return e&&(f?d(f.nodeData,e,y):u(o,e,y)),p?.(),Promise.resolve(void 0)}const{input:w,nodeData:E,apply:D,revert:C}=f,j=!!m?.runUpdate;let S=!1,k=!1;const T=()=>{if(S)return;S=!0,D(),a=null,i=null,ie(r.active,{path:o,op:t})&&c({...r,active:null}),j&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(g,v);const e=ae(t,"commit");e&&d(E,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,()=>S,E,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,()=>S,E,y)))},areChildrenBeingEdited:e=>null!==r.active&&T(r.active.path,e)}})(a,r,o)),t(se.Provider,{value:l.current,children:e})},de=()=>{const e=s(se);if(!e)throw new Error("Missing Editing Context Provider");return e},ue=e=>{const t=de();return u(t.subscribe,()=>e(t.getSnapshot()),()=>e(t.getServerSnapshot()))},pe=/*#__PURE__*/l(null),he=({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(pe.Provider,{value:u,children:e})},me=()=>{const e=s(pe);if(!e)throw new Error("Missing Collapse Context Provider");return e},fe=(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},ye=/*#__PURE__*/l(null),ge=({children:e})=>{const[n,r]=p({path:null,canDelete:!1}),o=i(!1),a=c(()=>({dragSource:n,setDragSource:r,armed:o}),[n]);return t(ye.Provider,{value:a,children:e})},ve=({children:e,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>t(ce,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:t(he,{onCollapse:r,buildNodeDataFromPathRef:o,children:t(ge,{children:e})})}),be=/*#__PURE__*/l(void 0),we=({value:e,children:n})=>t(be.Provider,{value:e,children:n}),Ee=()=>{const e=s(be);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},De=e=>{const t=Ee();return null===t||t.visiblePaths.has(O(e))},Ce=e=>{const t=Ee();return null===t?null:t.visibleChildCounts.get(O(e))??null},je="**INVALID_FUNCTION**",Se=({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)},E=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":E,title:u?E:"",children:"..."}),v]}):t(m,{children:`${f}${v}`})]})},Oe=({styles:e,pathString:n,value:r,setValue:o,handleEdit:a,handleKeyboard:l,keyboardCommon:s})=>{const c=i(null);return t(z,{className:"jer-input-text",textAreaRef:c,name:n,value:r,setValue:o,onKeyDown:e=>{l(e,{stringConfirm:a,stringLineBreak:()=>{const e=U(c,"\n");o(e)},...s})},styles:e})},ke=({isEditing:e,path:n,enumType:r,...o})=>{const{getStyles:a}=re(),i=O(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(Oe,{styles:a("input",c),pathString:i,...o,setValue:o.setValue}):t(Se,{pathString:i,styles:a("string",c),...o})},Te=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=re();return r?t("input",{className:"jer-input-number",type:"text",name:O(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})},Ne=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=re();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:O(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,{booleanConfirm:i,booleanToggle:()=>n(!e),...c})},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},xe=(e,t)=>{const n=i(void 0),r=i(t);a(()=>{r.current=t},[t]);const o=e=>{r.current(e)};a(()=>{if(window.clearTimeout(n.current),e)return n.current=window.setTimeout(()=>{window.addEventListener("keydown",o)},100),()=>{window.clearTimeout(n.current),window.removeEventListener("keydown",o)}},[e])},Re=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:l})=>{const{getStyles:s}=re();return xe(n,e=>i(e,{confirm:o,...l})),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",a),children:String(e)})},Ae=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===je&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},Pe=({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})},Ie=({name:e,nodeData:n})=>{const{getStyles:r,icons:o}=re(),a=o[e],i=`icon${e[0].toUpperCase()}${e.slice(1)}`;return t(Pe,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===e?void 0:"jer-icon",style:r(i,n),children:a.content})},Le=({startEdit:r,handleDelete:o,handleAdd:a,showClipboardButton:i,onCopy:l,type:s,customButtons:c,handleEdit:d,canEdit:u,nodeData:h,translate:m,keyboardControls:f,handleKeyboard:y,editConfirmRef:g,getNewKeyOptions:v,jsonStringify:b,showIconTooltips:w,Select:E})=>{const{getStyles:D}=re(),{open:C,cancel:j}=de(),[O,T]=p(""),[N,x]=p(!1),{path:R,value:A}=h,P=ue(e=>{const t=e.active;return null!==t&&"add"===t.op&&k(t.path,R)}),I=Array.isArray(N);M(()=>{if(!P)return x(!1),void T("");const e=Object.keys(K(h.fullData,R)),t=v?v(h)?.filter(t=>!e.includes(t)):null;x(t??!0)},[P]);const L=()=>{a&&O&&a("array"===s?"":O)};return e("div",{className:"jer-edit-buttons",style:{opacity:P?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&t("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",a=null;if(i){const i=F(e);if(i&&f.clipboardModifier.includes(i)?(t=S(R),o=t,r="path"):(t=A,o="object"==typeof t?b(A):String(t)),!navigator.clipboard)return void l?.({...h,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?.({...h,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:a??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":m("TOOLTIP_COPY",h),title:w?m("TOOLTIP_COPY",h):"",children:t(Ie,{name:"copy",nodeData:h})}),r&&t("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":m("TOOLTIP_EDIT",h),title:w?m("TOOLTIP_EDIT",h):"",children:t(Ie,{name:"edit",nodeData:h})}),o&&t("button",{type:"button",tabIndex:-1,onClick:o,"aria-label":m("TOOLTIP_DELETE",h),title:w?m("TOOLTIP_DELETE",h):"",children:t(Ie,{name:"delete",nodeData:h})}),a&&t("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===s?C(R,{op:"add"}):a("")},"aria-label":m("TOOLTIP_ADD",h),title:w?m("TOOLTIP_ADD",h):"",children:t(Ie,{name:"add",nodeData:h})}),c?.map(({Element:e,onClick:n,label:r},o)=>{const a=e=>n?.(h,e,{handleEdit:d,canEdit:u});return r?t("button",{type:"button",className:"jer-custom-button",tabIndex:-1,onClick:a,"aria-label":r,title:w?r:"",children:t(e,{nodeData:h,canEdit:u,handleEdit:d})},o):t("div",{className:"jer-custom-button",onClick:a,children:t(e,{nodeData:h,canEdit:u,handleEdit:d})},o)}),P&&a&&"object"===s&&e(n,{children:[I?t(E,{name:"new-key-select",onChange:a,defaultValue:"",autoFocus:!0,onKeyDown:e=>y(e,{cancel:()=>j()}),placeholder:N.length>0?m("KEY_SELECT",h):m("NO_KEY_OPTIONS",h),options:N}):t("input",{className:"jer-input-text jer-input-new-key",type:"text",name:"new-object-key",value:O,placeholder:m("KEY_NEW",h),onChange:e=>T(e.target.value),autoFocus:!0,onKeyDown:e=>{y(e,{stringConfirm:()=>L(),cancel:()=>j()})},style:D("input",h)}),t(Ke,{onOk:()=>L(),onCancel:()=>j(),nodeData:h,translate:m,showIconTooltips:w,editConfirmRef:g,hideOk:I})]})]})},Ke=({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(Ie,{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(Ie,{name:"cancel",nodeData:o})})]}),_e=["string","number","boolean","null"],Ve=["object","array"],Me=[..._e,...Ve],ze=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}},Fe=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?ze(n):{}},Be=({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:E}=de(),[D,C]=p(null),j={...n,collapsed:t,visibleSize:Ce(n.path)},{path:S,key:T,size:N}=j,x=O(S),R=ue(e=>{const t=e.active;return null!==t&&"edit"===t.op&&k(t.path,S)}),A=ue(e=>{const t=e.active;return null!==t&&"rename"===t.op&&k(t.path,S)}),P=ue(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=Ee(),B=d(e=>(null===F||F.visiblePaths.has(O(e.path)))&&s(e),[F,s]),H=e=>$(a(),S,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):E({op:"rename",path:S,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&z(t.error,e)}))},Y="number"==typeof S.slice(-1)[0],U=null!==r&&!Y&&L&&m,X={isEditing:R,isEditingKey:A,isPending:P,isArray:Y,canEditKey:U},J=""===T&&S.length>0?f("EMPTY_STRING",j):null;return{pathString:x,nodeData:j,path:S,name:T,size:N,canEdit:I,canDelete:L,canAdd:K,canDrag:_,error:D,showError:V,onError:z,setError:C,handleEditKey:W,derivedValues:X,emptyStringKey:J,getNextOrPreviousAtPath:H,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:U,isEditingKey:A,pathString:x,path:S,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}:{}})}},He=({canDrag:e,canDelete:n,canDragOnto:r,canAddHere:o,path:a,nodeData:i,onError:l,translate:d})=>{const{getStyles:u}=re(),{dragSource:h,setDragSource:m,armed:f}=(()=>{const e=s(ye);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),y=de(),[g,v]=p(!1),b=()=>null!==h.path&&!T(a,h.path)&&(k(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]),E=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]),D=c(()=>null!==h.path&&b()?t("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:a.length},...E("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&&!k(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:E,BottomDropTarget:D,DropTargetPadding:({position:e,nodeData:n})=>g===e?t("div",{className:"jer-drag-n-drop-padding",style:u("dropZone",n)}):null,handleDrop:C}},We=({isEditingKey:n,canEditKey:o,pathString:a,path:i,name:l,arrayIndexStart:s,handleKeyboard:c,handleEditKey:d,handleCancel:u,handleClick:p,keyValueArray:h,styles:m,getNextOrPrevious:f,emptyStringKey:y,nodeData:g,customNodeData:v,getStyles:b})=>{const{open:w,cancel:E}=de(),D=r.useRef(null),C=e=>d(D.current?.value??String(l),e),j="number"==typeof l?String(l+s):l;if(!n){const n={...m,minWidth:`${Math.min(j.length+1,5)}ch`,flexShrink:j.length>10?1:0};if(v?.CustomKeyComponent&&g&&b){const{CustomKeyComponent:e,componentProps:r}=v;return t(e,{nodeData:g,name:y??j,path:i,canEditKey:o,handleEditKey:e=>{o&&d(e)},startEditingKey:()=>{o&&w(i,{op:"rename",commitOp:C})},handleClick:p,styles:n,componentProps:r,getStyles:b})}return e("span",{className:"jer-key-text",style:n,onDoubleClick:()=>o&&w(i,{op:"rename",commitOp:C}),onClick:p,children:[y?t("span",{className:"jer-empty-string",children:y}):j,""!==j||y?t("span",{className:"jer-key-colon",children:":"}):null]})}return t("input",{ref:D,className:"jer-input-text jer-key-edit",type:"text",name:a,defaultValue:j,autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>c(e,{stringConfirm:()=>d(e.target.value),cancel:u,tabForward:()=>{const t=e.target.value;d(t,()=>{if(h){const e=h?.[0][0],t=e?[...i,e]:f("next");t?w(t):E()}else w(i)})},tabBack:()=>{const t=e.target.value;d(t,()=>{const e=f("prev");e?w(e):E()})}}),style:{width:j.length/1.5+.5+"em"}})},Ye=new Set(["nodeData","customNodeData"]),Ue=(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||!k(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(!Ye.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},$e=n=>{const{data:r,parentData:o,onChange:l,showClipboardButton:s,onCopy:u,canDragOnto:h,canAddHere:m,allowTypeSelection:y,showLabel:v,stringTruncateLength:b,showStringQuotes:D,indent:C,translate:j,customNodeDefinitions:S,customNodeData:O,Select:T,handleKeyboard:N,keyboardControls:x,editConfirmRef:R,jsonStringify:A,showIconTooltips:P,getLatestData:I}=n,{getStyles:L}=re(),{open:K,cancel:_,submit:V,getSnapshot:M}=de(),{setCollapseState:z}=me(),[F,B]=p("function"==typeof r?je:r),{nodeData:H,path:W,name:Y,canEdit:U,canDelete:$,canDrag:X,error:J,onError:Q,setError:Z,derivedValues:G,getNextOrPreviousAtPath:q,buildKeyDisplayProps:ee}=Be({props:n}),{dragSourceProps:te,getDropTargetProps:ne,BottomDropTarget:oe,DropTargetPadding:ae}=He({canDrag:X,canDelete:$,canDragOnto:h,canAddHere:m,path:W,nodeData:H,onError:Q,translate:j}),[ie,le]=p(Qe(r,O)),se=i(F);se.current=F;const ce=i(H);ce.current=H;const ue=d(e=>{if(!l)return void B(e);const t=l({...ce.current,value:se.current,fullData:I(),newValue:e});B(t)},[l,I]),pe=()=>{B("function"==typeof r?je:r),le(Qe(r,O)),ye(E(r,he))};a(()=>{G.isEditing||pe()},[r]);const he=c(()=>{const e=[...Me,...S.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(H);return"boolean"==typeof t?t?e:[]:t},[H,y,S]),[fe,ye]=p(E(F,he)),{isEditing:ge,isPending:ve}=G,be=De(W),we=i(f);if(!be)return null;const Ee=ge&&ie!==Qe(r,O),Ce=Ee?S.find(e=>e.name===ie&&Je(e)):void 0,Se=Ce?ze(Ce):O,{CustomComponent:Oe,componentProps:ke,showKey:Te=!0,showEditTools:Ne=!0,showOnEdit:xe,showOnView:Re,passOriginalNode:Ae}=Se,Pe=Oe&&(void 0!==Ce||!Ee&&(ge&&xe||!ge&&Re)),Ie=e=>{z(null);const t=Ee&&!Ce?void 0:Se,n=t?.toStandardType?t.toStandardType(F):F,r=S.find(t=>t.name===e);if(r){const t="function"==typeof r.defaultValue?r.defaultValue(H):r.defaultValue;if(Je(r)){let o=t;if(r.fromStandardType)try{o=r.fromStandardType(n,H,r.componentProps)}catch{}return B(o),le(e),void ye(null)}return V({op:"edit",path:W,value:t}).then(_e(t)),void z({path:W,collapsed:!1,includeChildren:!1})}const o=he.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof F&&o.values.includes(F)||B(o.values[0]),ye(o),void le(e);const a=qe(n,e,j("DEFAULT_NEW_KEY",H));if("object"===e||"array"===e||"null"===e)return V({op:"edit",path:W,value:a}).then(_e(a)),void("null"!==e&&z({path:W,collapsed:!1,includeChildren:!1}));B(a),le(e),ye(null)},_e=e=>t=>{if("error"===t?.status&&Q(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=M().active;"editing"===e?.phase&&k(e.path,W)||pe()}},Ve=(e,t)=>{const n=void 0!==e&&!w(e);let o;if(n)o=e;else if(Pe&&Se.fromStandardType)try{o=Se.fromStandardType(F,H,Se.componentProps)}catch(e){return void Q({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},F)}else o="number"===ie?Ge(F):F;Z(null),Ce&&z({path:W,collapsed:!1,includeChildren:!1});const a=n&&g(o)&&!g(r);V({op:"edit",path:W,value:o,onCommit:()=>{a&&z({path:W,collapsed:!1,includeChildren:!1}),t?.()}}).then(_e(o))};we.current=Ve;const Fe=()=>{Z(null),pe(),_()},{isEditingKey:Ye}=G,Ue=!!J,$e=ge&&he.length>1,Xe=("invalid"!==ie||Oe)&&!J&&Ne,et=v&&Te,tt=()=>K(W,{cancelOp:pe,commitOp:e=>we.current(void 0,e)}),nt=U?tt:f,rt=e=>()=>{const t=q(e);t&&Ve(void 0,()=>K(t))},ot={value:F,parentData:o,setValue:ue,isEditing:ge,canEdit:U,setIsEditing:nt,handleEdit:Ve,handleCancel:Fe,path:W,stringTruncateLength:b,showStringQuotes:D,showIconTooltips:P,nodeData:H,enumType:fe,translate:j,handleKeyboard:N,keyboardCommon:{cancel:Fe,tabForward:rt("next"),tabBack:rt("prev")},Select:T},at={...ee({handleCancel:Fe,getStyles:L}),customNodeData:Se},it=Pe?t(Oe,{...n,value:F,componentProps:ke,setValue:ue,handleEdit:Ve,handleCancel:Fe,onKeyDown:e=>N(e,{stringConfirm:Ve,cancel:Fe}),isEditing:ge,isPending:ve,setIsEditing:nt,getStyles:L,originalNode:Ae?Ze(r,ie,ot):void 0,originalNodeKey:Ae?t(We,{...at,customNodeData:void 0}):void 0,canEdit:U,keyboardCommon:ot.keyboardCommon}):Ze(r,ie,ot);return e("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==o?C/2+"em":0,position:"relative"},draggable:X&&!ge&&!Ye,...te,...ne("above"),children:[oe,t(ae,{position:"above",nodeData:H}),e("div",{className:"jer-value-main-row",style:{...L("valueRow",H),flexWrap:Y.length>10?"wrap":"nowrap"},children:[et&&t(We,{...at}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:it}),ge?t(Ke,{onOk:Ve,onCancel:Fe,nodeData:H,translate:j,showIconTooltips:P,editConfirmRef:R}):Xe&&t(Le,{startEdit:U?tt:void 0,handleDelete:$?()=>{V({op:"delete",path:W,instant:!0}).then(e=>{"error"===e?.status&&Q(e.error,F)})}:void 0,showClipboardButton:s,onCopy:u,translate:j,customButtons:n.customButtons,handleEdit:e=>Ve(e),canEdit:U,nodeData:H,handleKeyboard:N,keyboardControls:x,editConfirmRef:R,jsonStringify:A,showIconTooltips:P,Select:T}),$e&&t(T,{name:`${Y}-type-select`,value:fe?fe.enum:ie,onChange:e=>Ie(e),options:he.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Ue&&t("span",{className:"jer-error-slug",style:L("error",H),children:J})]})]}),t(ae,{position:"below",nodeData:H})]})},Xe=/*#__PURE__*/r.memo($e,Ue),Je=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,Qe=(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",Ze=(e,n,r)=>{const o=_e.includes(n)?n:"function"==typeof e?"invalid":Qe(r.value),{value:a}=r;switch(o){case"string":return t(ke,{...r,value:a});case"number":return t(Te,{...r,value:a});case"boolean":return t(Ne,{...r,value:a});case"null":return t(Re,{...r});default:return t(Ae,{...r})}},Ge=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 Ge(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},et=r=>{const{getStyles:o}=re(),{open:l,cancel:s,submit:u,areChildrenBeingEdited:h,getSnapshot:m}=de(),{setCollapseState:y}=me(),{mainContainerRef:v,data:b,nodeData:E,parentData:D,showCollectionCount:C,canDragOnto:j,canAddHere:S,collapseFilter:O,collapseAnimationTime:N,showClipboardButton:x,onCopy:R,showIconTooltips:A,indent:P,sort:I,showArrayIndexes:L,defaultValue:K,newKeyOptions:_,translate:V,customNodeDefinitions:M,customNodeData:B,jsonParse:H,jsonStringify:W,TextEditor:Y,Select:$,keyboardControls:X,handleKeyboard:J,insertAtTop:Q,onCollapse:Z,editConfirmRef:G,collapseClickZones:q,getLatestData:ee}=r,[te,ne]=p(null),{showCollectionWrapper:oe=!0}=B,ae=oe&&O(E),{contentRef:ie,isAnimating:le,maxHeight:se,collapsed:ce,animateCollapse:pe,cssTransitionValue:he}=((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}})(b,N,ae,v,W),{pathString:ye,nodeData:ge,path:ve,name:be,size:we,canEdit:Ee,canDelete:Ce,canAdd:je,canDrag:Se,error:Oe,setError:ke,onError:Te,derivedValues:Ne,buildKeyDisplayProps:xe}=Be({props:r,collapsed:ce}),{dragSourceProps:Re,getDropTargetProps:Ae,BottomDropTarget:Pe,DropTargetPadding:_e}=He({canDrag:Se,canDelete:Ce,canDragOnto:j,canAddHere:S,path:ve,nodeData:ge,onError:Te,translate:V}),Ve=i(!ae),{isEditing:Me,isEditingKey:ze,isPending:Ye,isArray:Ue}=Ne,$e=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(O);a(()=>{const e=oe&&O(ge)&&!Me;Ve.current=!e,pe(e),$e&&y(null)},[O]),((e,t,n)=>{const{commands:r,version:o}=me(),l=i(0);a(()=>{if(o===l.current)return;if(l.current=o,!r)return;let a;for(const t of r)fe(e,t)&&(a=t);a&&(a.collapsed||(t.current=!0),n(a.collapsed))},[o,r])})(ve,Ve,oe?pe:f);const Je=i(null),Qe=d(e=>ne(t=>"function"==typeof e?e(t??W(b)):e),[b,W]),Ze=d(()=>ne(null),[]),Ge=c(()=>Me?te??W(b):null,[Me,te,b,W]),qe=d((e,t)=>{if("function"!=typeof K)return K;const n=K(e,t);return void 0!==n?n:null},[K]),et=d(e=>_?"function"!=typeof _?_:_(e):null,[_]),{CustomComponent:nt,componentProps:rt,CustomWrapperComponent:ot,wrapperProps:at={},showKey:it=!0,showEditTools:lt=!0,showOnEdit:st,showOnView:ct,passOriginalNode:dt}=B,ut=ue(e=>null!==e.active&&T(e.active.path,ve));!ut&&oe||!ce||pe(!1);const pt=De(ve)||0===ge.level,ht=i(f);if(!pt&&!ut)return null;const{visibleSize:mt}=ge,ft=Array.isArray(b)?"array":"object",yt="array"===ft?{open:"[",close:"]"}:{open:"{",close:"}"},gt=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")&&e.target===Je.current){e.preventDefault();const t=U(Je,"\t");return void ne(t)}J(e,{objectConfirm:bt,cancel:Dt})},vt=e=>{if(e.stopPropagation(),!oe)return;const t=F(e);if(t&&X.collapseModifier.includes(t))return Ve.current=!0,void y({collapsed:!ce,path:ve,includeChildren:!0});h(ve)||(Ve.current=!0,Z&&Z({...ge,fullData:ee(),collapsed:!ce,includeChildren:!1}),pe(!ce))},bt=(e,t)=>{const n=void 0!==e&&!w(e);let r=b;if(n)r=e;else if(null!==te)try{r=H(te)}catch{return void Te({code:"INVALID_JSON",message:V("ERROR_INVALID_JSON",ge)},te)}ke(null),u({op:"edit",path:ve,value:r,onCommit:()=>{Ze(),t?.()}}).then(e=>{if("error"===e?.status&&Te(e.error,r),"error"===e?.status||"cancel"===e?.status){const e=m().active;"editing"===e?.phase&&k(e.path,ve)||Ze()}})};ht.current=bt;const wt=e=>bt(e),Et=ve.length>0?()=>{u({op:"delete",path:ve,instant:!0}).then(e=>{"error"===e?.status&&Te(e.error,b)})}:void 0,Dt=()=>{s(),ke(null),Ze()},Ct="when-collapsed"===C?ce:"when-collapsed-or-filtered"===C?ce||null!=mt:C,jt=!Me&<,St=(L||!Ue)&&it&&void 0!==be,Ot=nt&&(Me&&st||!Me&&ct),kt=Object.entries(b).map(([e,t])=>["array"===ft?Number(e):e,t]);"object"===ft&&I(kt,e=>e);const Tt=!Me||!!nt&&st,Nt=()=>e("div",{className:"jer-collection-text-edit"+(Y?"-custom":""),children:[Y?t(Y,{value:Ge??"",onChange:ne,onKeyDown:e=>J(e,{objectConfirm:bt,cancel:Dt})}):t(z,{textAreaRef:Je,className:"jer-collection-text-area",name:ye,value:Ge??"",setValue:Qe,onKeyDown:gt,styles:o("input",ge)}),t("div",{className:"jer-collection-input-button-row",children:t(Ke,{onOk:bt,onCancel:Dt,nodeData:ge,translate:V,showIconTooltips:A,editConfirmRef:G})})]}),xt=Ve.current?Tt?kt.map(([e,n],a)=>{const i={key:e,value:n,path:[...ve,e],level:ve.length+1,index:a,size:g(n)?Object.keys(n).length:null,parentData:b,fullData:ge.fullData},l=Fe(M,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:g(n)&&!l?.renderCollectionAsValue?t(tt,{...r,data:n,parentData:b,nodeData:i,canDragOnto:Ee,canAddHere:je,customNodeData:l},e):t(Xe,{...r,data:n,parentData:b,nodeData:i,canDragOnto:Ee,canAddHere:je,showLabel:"object"===ft||L,customNodeData:l},e)},e)}):t(n,{children:Nt()}):null,Rt=!!oe&&ce&&!ut;Rt||(Ve.current=!0);const At=V(ce?"TOOLTIP_EXPAND":"TOOLTIP_COLLAPSE",ge),Pt=()=>({...r,data:b,value:b,parentData:D,nodeData:ge,setValue:wt,handleEdit:bt,handleCancel:Dt,onKeyDown:gt,isEditing:Me,isPending:Ye,setIsEditing:Ee?()=>l(ve,{cancelOp:Ze,commitOp:e=>ht.current(void 0,e)}):f,getStyles:o,canDragOnto:Ee,canAddHere:je,canEdit:Ee,keyboardCommon:{}}),It=Ot?t(nt,{componentProps:rt,...Pt(),originalNode:dt&&Me?Nt():void 0,children:xt}):xt,Lt=jt&&t(Le,{startEdit:Ee?()=>{Ve.current=!0,l(ve,{cancelOp:Ze,commitOp:e=>ht.current(void 0,e)})}:void 0,handleAdd:je?e=>{y(null),pe(!1);const t=qe(ge,e);if("array"===ft){const e=Q.array?0:b.length,n=Q.array?{insert:!0}:{};return void u({op:"add",path:ve,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&Te(e.error,t)})}if(e in b)return Te({code:"KEY_EXISTS",message:V("ERROR_KEY_EXISTS",ge)},e),void s();const n=Q.object?{insertBefore:0}:{};u({op:"add",path:ve,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&Te(e.error,t)})}:void 0,handleDelete:Ce?Et:void 0,showClipboardButton:x,onCopy:R,type:ft,nodeData:ge,translate:V,customButtons:r.customButtons,handleEdit:wt,canEdit:Ee,keyboardControls:X,handleKeyboard:J,getNewKeyOptions:et,editConfirmRef:G,jsonStringify:W,showIconTooltips:A,Select:$}),Kt=xe({handleCancel:Dt,getStyles:o,keyValueArray:kt,handleClick:q.includes("property")?vt:e=>e.stopPropagation()}),_t=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===ve.length?0:P/2)+"em",...o("collection",ge),position:"relative"},draggable:Se&&!Me&&!ze&&!ut,...Re,...Ae("above"),children:[oe&&t("div",{className:"jer-clickzone",style:{width:P/2+1+"em",zIndex:10+2*ge.level},onClick:q.includes("left")?vt:void 0}),!Me&&Pe,t(_e,{position:"above",nodeData:ge}),oe?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ge),position:"relative"},onClick:q.includes("header")?vt:void 0,children:[e("div",{className:"jer-collection-name",children:[t("button",{type:"button",className:"jer-collapse-icon jer-accordion-icon"+(ce?" jer-rotate-90":""),style:{zIndex:11+2*ge.level,transition:he},onClick:vt,tabIndex:-1,"aria-expanded":!ce,"aria-label":At,title:A?At:"",children:t(Ie,{name:"collection",nodeData:ge})}),St&&t(We,{...Kt}),!Me&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",ge),children:yt.open})]}),!1!==C&&!Me&&t("div",{className:"jer-collection-item-count"+(Ct?" jer-visible":" jer-hidden"),style:{...o("itemCount",ge),transition:he,transitionBehavior:"allow-discrete"},children:null!=mt&&mt!==we?V("ITEMS_FILTERED",ge,{visible:mt,total:we}):1===we?V("ITEM_SINGLE",{...ge,size:1},1):V("ITEMS_MULTIPLE",ge,we)}),t("div",{className:"jer-brackets"+(Rt?" jer-visible":" jer-hidden"),style:{...o("bracket",ge),transition:he},children:yt.close}),Lt]}):it?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",ge),position:"relative"},children:[t(We,{...Kt}),Lt]}):t(n,{}),e("div",{className:"jer-collection-inner",style:{overflowY:Rt||le?"clip":"visible",maxHeight:ut?void 0:se,...o("collectionInner",ge),transition:`max-height ${he}`},ref:ie,children:[It,t("div",{className:Me?"jer-collection-error-row-edit":"jer-collection-error-row",children:Oe&&t("span",{className:"jer-error-slug",style:o("error",ge),children:Oe})}),!Me&&oe&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",ge),children:yt.close})]}),t(_e,{position:"below",nodeData:ge})]});return ot?t(ot,{wrapperProps:at,...Pt(),children:_t}):_t},tt=/*#__PURE__*/r.memo(et,Ue),nt=({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"})]}),rt=(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}},ot=({key:e,path:t},n="")=>!!rt({value:e},n)||!!t.some(e=>rt({value:e},n)),at={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 it=':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.2em;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-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-custom-button:empty{display:none}.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 lt="data-jer-styles",st=(e,t)=>JSON.stringify(e,t,2),ct={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},dt={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},ut=e=>{const t=i(e);e&&(t.current=e);const n=i((...e)=>t.current(...e));return e?n.current:void 0},pt=[],ht=["header","left"],mt={},ft={},yt={},gt=[],vt=({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:S=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:L,searchText:_,searchDebounceTime:M=350,sortKeys:z=!1,showArrayIndexes:F=!0,arrayIndexStart:H=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=mt,className:te,id:ne,customText:oe=ft,customNodeDefinitions:ae=pt,customButtons:ie=gt,jsonParse:le=JSON.parse,jsonStringify:se=st,TextEditor:ce,Select:ue=nt,errorDisplayTime:pe=2500,keyboardControls:he=yt,editorRef:fe,insertAtTop:ye=!1,onCollapse:ge,collapseClickZones:ve=ht})=>{const{getStyles:be,cssVars:Ee}=re(),{open:De,cancel:Ce,getSnapshot:je}=de(),Se=c(()=>Et(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]:at[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(_),Ne=i(null);a(()=>{Ce();const e=setTimeout(()=>Te(_),M);return()=>clearTimeout(e)},[_,M]);const xe=V(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=ut(u),ze=ut(h),Be=ut(ge),He=ut(w),We=ut(j),Ye=d(e=>{Re.current=e,Ae.current(e)},[]),Ue=d((e,t)=>{Ye(wt(Re.current,e,t,"update").newData)},[Ye]),$e=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}=wt(t,i,e.value,"update"),c=V(t,i,n,r);return{input:{...c,newData:a,event:"edit",newValue:s},nodeData:c,isNoOp:l===s,apply:()=>o(a),revert:()=>o(wt(Re.current,i,l,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=wt(t,i,"","delete"),l=V(t,i,n,r);return{input:{...l,newData:e,event:"delete"},nodeData:l,isNoOp:!1,apply:()=>o(e),revert:()=>o(wt(Re.current,i,a,"add",{insert:!0,insertBefore:l.index}).newData)}}case"add":{const a=[...i,e.key],{newData:l,newValue:s}=wt(t,a,e.value,"add",e.options),c=V(l,a,n,r);return{input:{...c,value:void 0,size:null,parentData:K(t,i)??null,fullData:t,newData:l,event:"add",newValue:s},nodeData:c,isNoOp:!1,apply:()=>o(l),revert:()=>o(wt(Re.current,a,"","delete").newData)}}case"rename":{const a=i.slice(0,-1),l=i[i.length-1],{newKey:s}=e,c=K(t,a),d=Object.fromEntries(Object.entries(c).map(([e,t])=>e===l?[s,t]:[e,t])),{newData:u}=wt(t,a,d,"update"),p=V(t,i,n,r);return{input:{...p,newData:u,event:"rename",newKey:s},nodeData:p,isNoOp:l===s,apply:()=>o(u),revert:()=>o(wt(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}=wt(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}=wt(d,g,u,"add",y),b=V(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=dt[e.event],r=()=>Pe.current(ct[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:$e,applyValue:Ue}),[Je,$e,Ue,s]);o.current=Qe;const Ze=c(()=>Et(x),[x]),Ge=c(()=>Et(R),[R]),qe=c(()=>Et(A),[A]),et=c(()=>Et(I),[I]),ot=c(()=>Dt(L),[L]),it=c(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,o=new Map,a=t??rt,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(O(e.path),n)}return t&&r.add(O(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:o}})(xe,ot,ke),[e,ke,ot,l]),lt=c(()=>(e=>{const t={...W};for(const n of Object.keys(W)){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 Y.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(he),[he]),vt=d((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(B(n,e[r],r)){n.preventDefault(),o();break}})(lt,t,e),[lt]),bt=c(()=>{const e=Ct(ae,"stringifyReplacer");return t=>se(t,e)},[ae,se]),jt=c(()=>{const e=Ct(ae,"parseReviver");return t=>{const n=le(t,e);return D(n)}},[ae,le]),St=i(null),{setCollapseState:Ot}=me(),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=>V(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})=>K(Ve(),t,e)===e?"PATH_NOT_FOUND":n||Ze(V(Ve(),t,l,kt))?(De(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{St.current&&(St.current.click(),"editing"!==je().active?.phase&&Ce())},cancel:()=>Ce()}},[Ot,De,Ce,je,Ze,Ve,l,kt]);const Nt=Fe(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:ze,onEditEvent:He,showErrorMessages:E,showCollectionCount:N,collapseFilter:Se,collapseAnimationTime:T,allowEditFilter:Ze,allowDeleteFilter:Ge,allowAddFilter:qe,allowTypeSelection:P,allowDragFilter:et,canDragOnto:!1,canAddHere:!1,showClipboardButton:C,onCopy:We,sortKeys:z,sort:kt,showArrayIndexes:F,arrayIndexStart:H,showStringQuotes:U,showIconTooltips:$,indent:S,defaultValue:X,newKeyOptions:J,stringTruncateLength:q,translate:Oe,customNodeDefinitions:ae,customNodeData:Nt,customButtons:ie,parentData:null,jsonParse:jt,jsonStringify:bt,TextEditor:ce,Select:ue,errorDisplayTime:pe,handleKeyboard:vt,keyboardControls:lt,insertAtTop:xt,onCollapse:Be,editConfirmRef:St,collapseClickZones:ve},At={...be("container",xe),...Ee,minWidth:Q,maxWidth:Z};return At.fontSize=G??At.fontSize,t("div",{id:ne,ref:Ne,className:`jer-editor-container ${te??""}`,style:At,children:t(we,{value:it,children:g(e)&&!Nt.renderCollectionAsValue?t(tt,{data:e,...Rt}):t(Xe,{data:e,showLabel:!0,...Rt})})})};function bt(e){h(()=>{(()=>{if("undefined"==typeof document)return;const e=document.head.querySelector(`style[${lt}]`);if(e)return void(e.textContent!==it&&(e.textContent=it));const t=document.createElement("style");t.setAttribute(lt,""),t.textContent=it,document.head.appendChild(t)})()},[]);const n=i(void 0),r=i(void 0),o=e;return t(ne,{theme:o.theme??Z,children:t(ve,{onEditEvent:o.onEditEvent,onCollapse:o.onCollapse,buildNodeDataFromPathRef:n,commitRef:r,children:t(vt,{...o,buildNodeDataFromPathRef:n,commitRef:r})})})}const wt=(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?K(e,t):void 0;return{currentData:e,newData:A(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},Et=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,Dt=e=>{if(void 0!==e)return"value"===e?rt:"key"===e?ot:"all"===e?(e,t)=>rt(e,t)||ot(e,t):e},Ct=(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}};function jt(e){const{editorRef:n,...r}=e,o=i(null);return m(n,()=>({collapse:e=>o.current?.collapse(e)}),[]),t(bt,{...r,editorRef:o,setData:f,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}export{z as AutogrowTextArea,Pe as IconSvg,bt as JsonEditor,jt as JsonViewer,Se as StringDisplay,Oe as StringEdit,A as assign,Ve as collectionDataTypes,Z as defaultTheme,K as extract,g as isCollection,rt as matchNode,ot as matchNodeKey,j as splitPropertyString,Me as standardDataTypes,O as toPathString,xe as useKeyboardListener,_e as valueDataTypes};
|
package/build/style.css
CHANGED
|
@@ -410,6 +410,13 @@ button.jer-string-expansion {
|
|
|
410
410
|
opacity: 0;
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
+
/* A custom button whose `Element` renders nothing leaves its wrapper empty.
|
|
414
|
+
`display: none` drops it from the flex gap and from the accessibility tree,
|
|
415
|
+
so a hidden button can't be pressed. */
|
|
416
|
+
.jer-custom-button:empty {
|
|
417
|
+
display: none;
|
|
418
|
+
}
|
|
419
|
+
|
|
413
420
|
.jer-confirm-buttons {
|
|
414
421
|
gap: 0.2em;
|
|
415
422
|
margin-left: 0.4em;
|