json-edit-react 2.0.0-beta.3 → 2.0.0-beta.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.
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("react");const n=()=>{},r=e=>Array.isArray(e)?e:[e],o=e=>null!==e&&"object"==typeof e,a=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),s=(e,t)=>{if("string"!=typeof e)return null;const n=t.filter(t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority);return n.sort((e,t)=>(t.matchPriority??0)-(e.matchPriority??0)),n[0]??null},i=e=>{if(e!==l){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=i(n);r!==n&&(e[t]=r)}return e}},l="__​undefined__",c=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),u=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),d=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),p=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),m=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),h=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},f=e=>Array.isArray(e),y=(e,t)=>e.filter((e,n)=>n!==t),g=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:s=!1}=r,i=e,l=u(t),d={...r,remove:o,createNew:a,noError:s,fullData:i,fullPath:l},p=Array.isArray(t)?t:c(t);return f(e)&&o&&1===p.length?y(e,p[0]):v(e,p,n,d)},v=(e,t,n,r)=>{const o=a(e)?{...e}:null,s=f(e)?[...e]:null;if(0===t.length)return e;if(!o&&!s)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:c,fullData:u,fullPath:d}=r,p=t[0];if(s&&"string"==typeof p)return s.map(e=>v(e,t,n,r));if(1===t.length)return o&&"string"==typeof p?b(o,p,n,r)??o:s&&"number"==typeof p?(j(s,p,n,r),s):(h(u,d,p,c),e);const m=o||s||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=m[p],n=t[1];return f(e)?m[p]=y(e,n):h(u,d,p,c,"Trying to remove an indexed item from an object that is not an array"),m}const g=t.slice(1);if(p in e){if(x=m[p],!f(x)&&!a(x)){if(!i)return h(u,d,p,c),m;m[p]={}}return m[p]=v(m[p],g,n,r),m}var x;if(i){const e="number"==typeof g[0]?[]:{};if(o)return m[p]=e,m[p]=v(m[p],g,n,r),m;if(s&&Array.isArray(m)){m.push(e);const t=m.length-1;return m[t]=v(m[t],g,n,r),m}}return h(u,d,p,c),m},b=(e,t,n,r)=>{const{remove:o,createNew:a,noError:s,insertAfter:i,insertBefore:l,fullData:c,fullPath:u}=r;if(void 0!==l||void 0!==i){const r=Object.entries(e);let o=1/0;return o="number"==typeof l?l:"number"==typeof i?i:r.findIndex(([e])=>e===(l??i)),void 0!==i&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const d=t in e;o?d?delete e[t]:h(c,u,t,s):a||d?e[t]=n:h(c,u,t,s)},j=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:s,createNew:i,insert:l}=r;l&&e.splice(t,0,n),t in e?e[t]=n:i?e.push(n):h(a,s,t,o)},x=(e,t,n)=>{const r=Array.isArray(t)?t:c(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>x(e,r,n));if("object"!=typeof e||null===e||!(o in e))return w(e,o,n);const a=e[o];return 1===r.length?a:x(a,r.slice(1),n)},w=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},E=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:o(e)?Object.keys(e).length:1,parentData:null,fullData:e};const a=t[t.length-1],s=x(e,t),i=x(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof a?a:Number(a);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===a)}return{key:a,path:t,level:t.length,index:l,value:s,size:o(s)?Object.keys(s).length:null,parentData:i,fullData:e}},C="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,D=({className:n,name:r,value:o,setValue:a,onKeyDown:s,styles:i,textAreaRef:l})=>{const c=t.useRef(null);if(C(()=>{const e=c.current;c.current=null;const t=l?.current;if(!e||!t)return;const n=e.start+o.length-e.sourceLength,r=Math.max(0,Math.min(n,o.length));t.selectionStart!==r&&t.setSelectionRange(r,r)},[o,l]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${r}_textarea`,ref:l,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...i},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;c.current=null!==n&&n<t.length?{start:n,sourceLength:t.length}:null,a(t)},autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:s}),e.jsx("span",{className:n,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...i},children:u})]})},S=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,k=(e,t,n)=>{if(!t)return!1;const r=e.key,o=S(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:s}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!s?.includes("Shift"))&&r===a&&(s===o||Array.isArray(s)&&s.includes(o))},O={key:"Enter"},R={confirm:O,cancel:{key:"Escape"},objectConfirm:{...O,modifier:["Meta","Shift","Control"]},objectLineBreak:O,stringConfirm:O,stringLineBreak:{...O,modifier:["Shift"]},numberConfirm:O,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:O,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},T=["stringConfirm","numberConfirm","booleanConfirm"],N=(e,t)=>{const n=e.current,r=n.selectionStart??1/0,o=n.selectionEnd??1/0,a=n.value.slice(0,r)+t+n.value.slice(o);return n.value=a,n.setSelectionRange(r+1,r+1),a},P=(e,t,n="next",r,a)=>{const s=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=x(e,s),c=I(l);Array.isArray(l)||r(c,({key:e,value:t})=>[e,t]);const u=c.findIndex(e=>e.key===i),d=c[u+("next"===n?1:-1)];if(!d)return 0===s.length?null:P(e,s,n,r,a);let p;if(o(d.value)){if(0===Object.keys(d.value).length)return P(e,[...s,d.key],n,r,a);p=A(e,[...s,d.key],n,r)}else p=[...s,d.key];return p?a(E(e,p,"",r))?p:P(e,p,n,r,a):null},A=(e,t,n="next",r)=>{const a=x(e,t);if(!o(a))return t;const s=Array.isArray(a)?a.map((e,t)=>t):Object.keys(a);r(s,e=>[e,a]);const i="next"===n?s[0]:s[s.length-1];return A(e,[...t,i],n,r)},I=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),K={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},L={displayName:"Default",icons:{add:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:K,scale:.86},ok:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:K,scale:.9},cancel:{content:e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},M={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},_=e=>[L,...r(e)].map(e=>"styles"in e?e:{styles:e}),V=e=>{const t={};for(const{icons:n}of _(e))n&&Object.assign(t,n);return t},z={getStyles:()=>({}),icons:V(L),cssVars:{}},F=t.createContext(z),B=({theme:n=L,children:r})=>{const o=t.useMemo(()=>(e=>{var t;const n=_(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[M[a]??"color"]:t}:t}}}for(const e in o)r[t=e]??(r[t]={});const a={};for(const e in r){const t=e,n=r[t],s=o[t];a[t]=s?e=>s.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(n),[n]),a=t.useMemo(()=>V(n),[n]),s=t.useMemo(()=>(e=>{const{inputHighlight:t,iconCopy:n}=e,r={};return"function"!=typeof t&&t?.backgroundColor&&(r["--jer-highlight-color"]=t.backgroundColor),"function"!=typeof n&&n?.color&&(r["--jer-icon-copy-color"]=n.color),r})(o),[o]),i=t.useCallback((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(o,e,t),[o]),l=t.useMemo(()=>({getStyles:i,icons:a,cssVars:s}),[i,a,s]);return e.jsx(F.Provider,{value:l,children:r})},Y=()=>t.useContext(F),U={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},H=(e,t)=>U[e][t]??null,W=(e,t)=>null!==e&&null!==t&&e.op===t.op&&p(e.path,t.path),$={active:null,settling:{}},J=t.createContext(null),X=({children:n,onEditEvent:r,buildNodeDataFromPathRef:o,commitRef:a})=>{const s=t.useRef(r);s.current=r;const i=t.useRef(null);return null===i.current&&(i.current=((e,t,n)=>{let r=$;const o=new Set;let a=null,s=null,i=!1,l=0;const c=e=>{r=e,o.forEach(e=>e())},u=(t,n,r)=>{e.current?.({...t,...r,event:n})},h=(n,o,i)=>{if(!e.current)return;let l;try{l=t.current?.(n)}catch{return c({...r,active:null}),a=null,void(s=null)}l&&u(l,o,i)},f=(e,t)=>{var n;a=t?.cancelOp??null,s=t?.commitOp??null,n=e,W(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=H(e.op,"start");o&&h(e.path,o)};return{subscribe:e=>(o.add(e),()=>o.delete(e)),getSnapshot:()=>r,getServerSnapshot:()=>r,open:(e,t)=>{if("held"===r.active?.phase)return;const n={path:e,op:t?.op??"edit",phase:"editing",force:t?.force},o=r.active,i=null!==o&&!W(o,n);if(i&&s)return void s(()=>f(n,t));const l=a;if(a=null,s=null,l&&l(),i&&W(r.active,o)){const e=H(o.op,"cancel");e&&h(o.path,e)}f(n,t)},cancel:()=>{if(i)return;if("held"===r.active?.phase)return;const e=r.active;i=!0;try{const t=a;if(a=null,s=null,t&&t(),null!==e){null!==r.active&&c({...r,active:null});const t=H(e.op,"cancel");t&&h(e.path,t)}}finally{i=!1}},submit:e=>{const{op:t,path:o,instant:i,onCommit:m}=e,f=n.current;let y;try{y=f?.buildCommit(e)??null}catch{return W(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,s=null,m?.(),Promise.resolve(void 0)}const g=y?.extra,v=d(o),b=++l;if(!i){const e=H(t,"submit");e&&h(o,e)}if(!y||y.isNoOp){W(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,s=null;const e=H(t,"commit");return e&&(y?u(y.nodeData,e,g):h(o,e,g)),m?.(),Promise.resolve(void 0)}const{input:j,nodeData:x,apply:w,revert:E}=y,C=!!f?.runUpdate;let D=!1,S=!1;const k=()=>{if(D)return;D=!0,w(),a=null,s=null,W(r.active,{path:o,op:t})&&c({...r,active:null}),C&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(v,b);const e=H(t,"commit");e&&u(x,e,g),m?.()},O={hold:()=>(S=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>k())};if(!C)return k(),Promise.resolve(void 0);const R=f.runUpdate(j,O);let T;return S||(i?T=setTimeout(k,100):k()),R.then(e=>(clearTimeout(T),((e,t,o,i,l,m,h,f,y)=>{const g=d(e);if(!h()){if("cancel"===i.status||"error"===i.status){"held"===r.active?.phase&&p(r.active.path,e)&&(c({...r,active:null}),a=null,s=null);const n=H(t,"cancel");return n&&u(f,n),"error"===i.status&&u(f,"updateError",{operation:t,error:i.error}),i}l()}if(r.settling[g]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],c({...r,settling:t})})(g),i.status){case"cancel":m();break;case"error":m(),u(f,"updateError",{operation:t,error:i.error});break;case"override":n.current?.applyValue(i.path,i.value),u(f,"updateSuccess",{operation:t,...y});break;case"commit":u(f,"updateSuccess",{operation:t,...y})}return i}})(o,t,b,e,k,E,()=>D,x,g)))},areChildrenBeingEdited:e=>null!==r.active&&m(r.active.path,e)}})(s,o,a)),e.jsx(J.Provider,{value:i.current,children:n})},Q=()=>{const e=t.useContext(J);if(!e)throw new Error("Missing Editing Context Provider");return e},Z=e=>{const n=Q();return t.useSyncExternalStore(n.subscribe,()=>e(n.getSnapshot()),()=>e(n.getServerSnapshot()))},G=t.createContext(null),q=({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(G.Provider,{value:u,children:n})},ee=()=>{const e=t.useContext(G);if(!e)throw new Error("Missing Collapse Context Provider");return e},te=(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},ne=t.createContext(null),re=({children:n})=>{const[r,o]=t.useState({path:null}),a=t.useRef(!1),s=t.useMemo(()=>({dragSource:r,setDragSource:o,armed:a}),[r]);return e.jsx(ne.Provider,{value:s,children:n})},oe=({children:t,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>e.jsx(X,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:e.jsx(q,{onCollapse:r,buildNodeDataFromPathRef:o,children:e.jsx(re,{children:t})})}),ae=t.createContext(void 0),se=({value:t,children:n})=>e.jsx(ae.Provider,{value:t,children:n}),ie=()=>{const e=t.useContext(ae);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},le=e=>{const t=ie();return null===t||t.visiblePaths.has(d(e))},ce=e=>{const t=ie();return null===t?null:t.visibleChildCounts.get(d(e))??null},ue="**INVALID_FUNCTION**",de=({nodeData:n,showStringQuotes:r=!0,stringTruncateLength:o=200,pathString:a,canEdit:s,setIsEditing:i,styles:l,translate:c,value:u,TextWrapper:d=({children:e})=>e})=>{const p=u??n.value,[m,h]=t.useState(!1),f=r?'"':"",y=p.length>o,g=()=>{s?i(!0):h(!m)};return e.jsxs("div",{id:`${a}_display`,onDoubleClick:g,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&g()},className:"jer-value-string",style:l,children:[f,y?m?e.jsxs(e.Fragment,{children:[e.jsx(d,{children:e.jsxs("span",{children:[p,f]})}),e.jsxs("span",{className:"jer-string-expansion jer-show-less",onClick:()=>h(!1),children:[" ",c("SHOW_LESS",n)]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:[e.jsx("span",{children:p.slice(0,o-2).trimEnd()})," "]}),e.jsx("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>h(!0),children:"..."}),f]}):e.jsx(d,{children:`${p}${f}`})]})},pe=({styles:n,pathString:r,value:o,setValue:a,handleEdit:s,handleKeyboard:i,keyboardCommon:l})=>{const c=t.useRef(null);return e.jsx(D,{className:"jer-input-text",textAreaRef:c,name:r,value:o,setValue:a,onKeyDown:e=>{i(e,{stringConfirm:s,stringLineBreak:()=>{const e=N(c,"\n");a(e)},...l})},styles:n})},me=({isEditing:t,path:n,enumType:r,...o})=>{const{getStyles:a}=Y(),s=d(n),{value:i,setValue:l,nodeData:c,handleEdit:u,handleKeyboard:p,keyboardCommon:m,Select:h}=o;return t&&r?e.jsx(h,{name:`${s}-value-select`,value:i,onChange:l,options:r.values,autoFocus:!0,onKeyDown:e=>p(e,{stringConfirm:u,...m})}):t?e.jsx(pe,{styles:a("input",c),pathString:s,...o,setValue:o.setValue}):e.jsx(de,{pathString:s,styles:a("string",c),...o})},he=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=Y();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:d(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:e=>l(e,{numberConfirm:s,numberUp:()=>n(Number(t)+1),numberDown:()=>n(Number(t)-1),...c}),style:{width:String(t).length/1.5+2+"em",...u("input",i)}}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:u("number",i),children:t})},fe=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=Y();return"boolean"!=typeof t?null:r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:d(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{" "===e.key&&e.preventDefault(),l(e,{booleanConfirm:s,booleanToggle:()=>n(!t),...c})},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:u("boolean",i),children:String(t)})},ye=(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])},ge=({value:t,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:s,keyboardCommon:i})=>{const{getStyles:l}=Y();return ye(n,e=>s(e,{confirm:o,...i})),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:l("null",a),children:String(t)})},ve=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===ue&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},be=({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})},je=({name:t,nodeData:n})=>{const{getStyles:r,icons:o}=Y(),a=o[t],s=`icon${t[0].toUpperCase()}${t.slice(1)}`;return e.jsx(be,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===t?void 0:"jer-icon",style:r(s,n),children:a.content})},xe=({startEdit:n,handleDelete:r,handleAdd:o,showClipboardButton:a,onCopy:s,type:i,customButtons:l,nodeData:c,translate:d,keyboardControls:m,handleKeyboard:h,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:j}=Y(),{open:w,cancel:E}=Q(),D=d("KEY_NEW",c),[k,O]=t.useState(D),[R,T]=t.useState(!1),{path:N,value:P}=c,A=Z(e=>{const t=e.active;return null!==t&&"add"===t.op&&p(t.path,N)}),I=Array.isArray(R);C(()=>{if(!A)return T(!1),void O(D);const e=Object.keys(x(c.fullData,N)),t=y?y(c)?.filter(t=>!e.includes(t)):null;t&&O(""),T(t??!0)},[A]);const K=()=>{o&&(I&&!k||o("array"===i?"":k))};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:A?1:void 0},onClick:e=>e.stopPropagation(),children:[a&&e.jsx("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",i=null;if(a){const a=S(e);if(a&&m.clipboardModifier.includes(a)?(t=u(N),o=t,r="path"):(t=P,o="object"==typeof t?g(P):String(t)),!navigator.clipboard)return void s?.({...c,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,i=e.message}).finally(()=>{s?.({...c,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:i??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":d("TOOLTIP_COPY",c),title:v?d("TOOLTIP_COPY",c):"",children:e.jsx(je,{name:"copy",nodeData:c})}),n&&e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":d("TOOLTIP_EDIT",c),title:v?d("TOOLTIP_EDIT",c):"",children:e.jsx(je,{name:"edit",nodeData:c})}),r&&e.jsx("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":d("TOOLTIP_DELETE",c),title:v?d("TOOLTIP_DELETE",c):"",children:e.jsx(je,{name:"delete",nodeData:c})}),o&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===i?w(N,{op:"add"}):o("")},"aria-label":d("TOOLTIP_ADD",c),title:v?d("TOOLTIP_ADD",c):"",children:e.jsx(je,{name:"add",nodeData:c})}),l?.map(({Element:t,onClick:n},r)=>e.jsx("div",{onClick:e=>n&&n(c,e),children:e.jsx(t,{nodeData:c})},r)),A&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[I?e.jsx(b,{name:"new-key-select",onChange:o,defaultValue:"",autoFocus:!0,onKeyDown:e=>h(e,{cancel:()=>E()}),placeholder:R.length>0?d("KEY_SELECT",c):d("NO_KEY_OPTIONS",c),options:R}):e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:k,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{h(e,{stringConfirm:()=>K(),cancel:()=>E()})},style:j("input",c)}),e.jsx(we,{onOk:()=>K(),onCancel:()=>E(),nodeData:c,translate:d,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},we=({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(je,{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(je,{name:"cancel",nodeData:r})})]}),Ee=["string","number","boolean","null"],Ce=["object","array"],De=[...Ee,...Ce],Se=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}},ke=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?Se(n):{}},Oe=({props:e,collapsed:n})=>{const{nodeData:r,parentData:o,onError:a,getLatestData:s,showErrorMessages:i,allowEditFilter:l,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:m,translate:h,errorDisplayTime:f,sort:y,arrayIndexStart:g,handleKeyboard:v,customNodeData:b}=e,{submit:j}=Q(),[x,w]=t.useState(null),E={...r,collapsed:n,visibleSize:ce(r.path)},{path:C,key:D,size:S}=E,k=d(C),O=Z(e=>{const t=e.active;return null!==t&&"edit"===t.op&&p(t.path,C)}),R=Z(e=>{const t=e.active;return null!==t&&"rename"===t.op&&p(t.path,C)}),T=Z(e=>k in e.settling),N=l(E),A=c(E),I=u(E),K=m(E)&&A,L=e=>{i&&(w(e),setTimeout(()=>w(null),f)),console.warn("Error",e)},M=t.useRef(E);M.current=E;const _=t.useCallback((e,t)=>{L(e.message),a&&a({...M.current,fullData:s(),error:e,errorValue:t})},[a,i,s,f]),V=ie(),z=t.useCallback(e=>(null===V||V.visiblePaths.has(d(e.path)))&&l(e),[V,l]),F=e=>P(s(),C,e,y,z),B=(e,t)=>{o&&(D!==e&&Object.keys(o).includes(e)?_({code:"KEY_EXISTS",message:h("ERROR_KEY_EXISTS",E)},e):j({op:"rename",path:C,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&_(t.error,e)}))},Y="number"==typeof C.slice(-1)[0],U=null!==o&&N&&I&&A&&!Y,H={isEditing:O,isEditingKey:R,isPending:T,isArray:Y,canEditKey:U},W=""===D&&C.length>0?h("EMPTY_STRING",E):null;return{pathString:k,nodeData:E,path:C,name:D,size:S,canEdit:N,canDelete:A,canAdd:I,canDrag:K,error:x,showError:L,onError:_,setError:w,handleEditKey:B,derivedValues:H,emptyStringKey:W,getNextOrPreviousAtPath:F,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:U,isEditingKey:R,pathString:k,path:C,name:D,arrayIndexStart:g,handleKeyboard:v,handleEditKey:B,handleCancel:e,styles:t("property",E),getNextOrPrevious:F,emptyStringKey:W,nodeData:E,customNodeData:b,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Re=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onError:s,translate:i})=>{const{getStyles:l}=Y(),{dragSource:c,setDragSource:u,armed:d}=(()=>{const e=t.useContext(ne);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),h=Q(),[f,y]=t.useState(!1),g=t.useMemo(()=>n?{onMouseDown:e=>{0===e.button&&null===h.getSnapshot().active&&(d.current=!0)},onMouseUp:()=>{d.current=!1},onDragStart:e=>{if(!d.current||null!==h.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();d.current=!1,e.stopPropagation(),u({path:o})},onDragEnd:e=>{d.current=!1,e.stopPropagation(),u({path:null})}}:{},[n,o]),v=t.useMemo(()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),j(e),u({path:null}),y(!1)},onDragEnter:t=>{t.stopPropagation(),null!==c.path&&m(o,c.path)||y(e)},onDragExit:e=>{e.stopPropagation(),y(!1)}}:{},[c,r,o]),b=t.useMemo(()=>r&&null!==c.path?e.jsx("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length},...v("below")}):null,[c,r,o.length]),j=e=>{if(null===c.path)return;if(m(o,c.path))return;const t=c.path.slice(-1)[0],n=c.path.slice(0,-1),r=o.slice(0,-1),{parentData:l}=a;"string"==typeof t&&l&&!Array.isArray(l)&&Object.keys(l).includes(t)&&t in l&&!p(n,r)?s({code:"KEY_EXISTS",message:i("ERROR_KEY_EXISTS",a)},t):h.submit({op:"move",path:c.path,to:{path:o,position:e},instant:!0})};return{dragSourceProps:g,getDropTargetProps:v,BottomDropTarget:b,DropTargetPadding:({position:t,nodeData:n})=>f===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:l("dropZone",n)}):null,handleDrop:j}},Te=({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}=Q(),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"}})},Ne=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||!p(n.path,r.path))return!1;var n,r;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(const n of o)if(!Ne.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ae=t.memo(r=>{const{data:o,parentData:a,onChange:i,showClipboardButton:l,onCopy:c,canDragOnto:u,allowTypeSelection:d,showLabel:m,stringTruncateLength:h,showStringQuotes:f,indent:y,translate:g,customNodeDefinitions:v,customNodeData:b,Select:j,handleKeyboard:x,keyboardControls:w,editConfirmRef:E,jsonStringify:C,showIconTooltips:D,getLatestData:S}=r,{getStyles:k}=Y(),{open:O,cancel:R,submit:T,getSnapshot:N}=Q(),{setCollapseState:P}=ee(),[A,I]=t.useState("function"==typeof o?ue:o),{nodeData:K,path:L,name:M,canEdit:_,canDelete:V,canDrag:z,error:F,onError:B,setError:U,derivedValues:H,getNextOrPreviousAtPath:W,buildKeyDisplayProps:$}=Oe({props:r}),{dragSourceProps:J,getDropTargetProps:X,BottomDropTarget:Z,DropTargetPadding:G}=Re({canDrag:z,canDragOnto:u,path:L,nodeData:K,onError:B,translate:g}),[q,te]=t.useState(Ke(o,b)),ne=t.useRef(A);ne.current=A;const re=t.useRef(K);re.current=K;const oe=t.useCallback(e=>{if(!i)return void I(e);const t=i({...re.current,value:ne.current,fullData:S(),newValue:e});I(t)},[i,S]),ae=()=>{I("function"==typeof o?ue:o),te(Ke(o,b)),ce(s(o,se))};t.useEffect(()=>{H.isEditing||ae()},[o]);const se=t.useMemo(()=>{const e=[...De,...v.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof d)return d?e:[];if(Array.isArray(d))return d;const t=d(K);return"boolean"==typeof t?t?e:[]:t},[K,d,v]),[ie,ce]=t.useState(s(A,se)),{isEditing:de,isPending:pe}=H,me=le(L),he=t.useRef(n);if(!me)return null;const fe=de&&q!==Ke(o,b),ye=fe?v.find(e=>e.name===q&&Ie(e)):void 0,ge=ye?Se(ye):b,{CustomComponent:ve,componentProps:be,showKey:je=!0,showEditTools:Ee=!0,showOnEdit:Ce,showOnView:ke,passOriginalNode:Ne}=ge,Pe=ve&&(void 0!==ye||!fe&&(de&&Ce||!de&&ke)),Ae=e=>{P(null);const t=fe&&!ye?void 0:ge,n=t?.toStandardType?t.toStandardType(A):A,r=v.find(t=>t.name===e);if(r){if(Ie(r)){let t=r.defaultValue;if(r.fromStandardType)try{t=r.fromStandardType(n,K,r.componentProps)}catch{}return I(t),te(e),void ce(null)}return T({op:"edit",path:L,value:r.defaultValue}).then(Ve(r.defaultValue)),void P({path:L,collapsed:!1,includeChildren:!1})}const o=se.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof A&&o.values.includes(A)||I(o.values[0]),ce(o),void te(e);const a=_e(n,e,g("DEFAULT_NEW_KEY",K));if("object"===e||"array"===e||"null"===e)return T({op:"edit",path:L,value:a}).then(Ve(a)),void("null"!==e&&P({path:L,collapsed:!1,includeChildren:!1}));I(a),te(e),ce(null)},Ve=e=>t=>{if("error"===t?.status&&B(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=N().active;"editing"===e?.phase&&p(e.path,L)||ae()}},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&&ge.fromStandardType)try{r=ge.fromStandardType(A,K,ge.componentProps)}catch(e){return void B({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},A)}else r="number"===q?Me(A):A;U(null),ye&&P({path:L,collapsed:!1,includeChildren:!1}),T({op:"edit",path:L,value:r,onCommit:t}).then(Ve(r))};he.current=ze;const Fe=()=>{U(null),ae(),R()},{isEditingKey:Be}=H,Ye=!!F,Ue=de&&se.length>1,He=("invalid"!==q||ve)&&!F&&Ee,We=m&&je,$e=()=>O(L,{cancelOp:ae,commitOp:e=>he.current(void 0,e)}),Je=_?$e:n,Xe=e=>()=>{const t=W(e);t&&ze(void 0,()=>O(t))},Qe={value:A,parentData:a,setValue:oe,isEditing:de,canEdit:_,setIsEditing:Je,handleEdit:ze,handleCancel:Fe,path:L,stringTruncateLength:h,showStringQuotes:f,nodeData:K,enumType:ie,translate:g,handleKeyboard:x,keyboardCommon:{cancel:Fe,tabForward:Xe("next"),tabBack:Xe("prev")},Select:j},Ze={...$({handleCancel:Fe,getStyles:k}),customNodeData:ge},Ge=Pe?e.jsx(ve,{...r,value:A,componentProps:be,setValue:oe,handleEdit:ze,handleCancel:Fe,onKeyDown:e=>x(e,{stringConfirm:ze,cancel:Fe}),isEditing:de,isPending:pe,setIsEditing:Je,getStyles:k,originalNode:Ne?Le(o,q,Qe):void 0,originalNodeKey:Ne?e.jsx(Te,{...Ze,customNodeData:void 0}):void 0,canEdit:_,keyboardCommon:Qe.keyboardCommon}):Le(o,q,Qe);return e.jsxs("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==a?y/2+"em":0,position:"relative"},draggable:z&&!de&&!Be,...J,...X("above"),children:[Z,e.jsx(G,{position:"above",nodeData:K}),e.jsxs("div",{className:"jer-value-main-row",style:{...k("valueRow",K),flexWrap:M.length>10?"wrap":"nowrap"},children:[We&&e.jsx(Te,{...Ze}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Ge}),de?e.jsx(we,{onOk:ze,onCancel:Fe,nodeData:K,translate:g,showIconTooltips:D,editConfirmRef:E}):He&&e.jsx(xe,{startEdit:_?$e:void 0,handleDelete:V?()=>{T({op:"delete",path:L,instant:!0}).then(e=>{"error"===e?.status&&B(e.error,A)})}:void 0,showClipboardButton:l,onCopy:c,translate:g,customButtons:r.customButtons,nodeData:K,handleKeyboard:x,keyboardControls:w,editConfirmRef:E,jsonStringify:C,showIconTooltips:D,Select:j}),Ue&&e.jsx(j,{name:`${M}-type-select`,value:ie?ie.enum:q,onChange:e=>Ae(e),options:se.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Ye&&e.jsx("span",{className:"jer-error-slug",style:k("error",K),children:F})]})]}),e.jsx(G,{position:"below",nodeData:K})]})},Pe),Ie=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,Ke=(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",Le=(t,n,r)=>{const o=Ee.includes(n)?n:"function"==typeof t?"invalid":Ke(r.value),{value:a}=r;switch(o){case"string":return e.jsx(me,{...r,value:a});case"number":return e.jsx(he,{...r,value:a});case"boolean":return e.jsx(fe,{...r,value:a});case"null":return e.jsx(ge,{...r});default:return e.jsx(ve,{...r})}},Me=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},_e=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Me(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Ve=t.memo(r=>{const{getStyles:a}=Y(),{open:s,cancel:i,submit:l,areChildrenBeingEdited:c}=Q(),{setCollapseState:u}=ee(),{mainContainerRef:d,data:p,nodeData:h,parentData:f,showCollectionCount:y,canDragOnto:g,collapseFilter:v,collapseAnimationTime:b,showClipboardButton:j,onCopy:x,showIconTooltips:w,indent:E,sort:C,showArrayIndexes:k,defaultValue:O,newKeyOptions:R,translate:T,customNodeDefinitions:P,customNodeData:A,jsonParse:I,jsonStringify:K,TextEditor:L,Select:M,keyboardControls:_,handleKeyboard:V,insertAtTop:z,onCollapse:F,editConfirmRef:B,collapseClickZones:U,getLatestData:H}=r,[W,$]=t.useState(null),J=v(h),{contentRef:X,isAnimating:G,maxHeight:q,collapsed:ne,animateCollapse:re,cssTransitionValue:oe}=((e,n,r,o,a)=>{const[s,i]=t.useState(r?0:void 0),[l,c]=t.useState(r),u=t.useRef(!1),d=t.useRef(null),p=t.useRef(0),m=t.useRef(0),h=n/1e3+"s",f=t.useCallback(t=>{if(l!==t){switch(window.clearTimeout(m.current),u.current=!0,t){case!0:{const e=d.current?.offsetHeight??0;p.current=e,i(e),setTimeout(()=>{i(0)},5);break}case!1:i(p.current||((e,t,n,r)=>{if(!t.current)return 0;const o=parseInt(getComputedStyle(n.current).getPropertyValue("line-height"))||16,a=(t.current?.offsetWidth??0)/(.5*o),s=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/a)).reduce((e,t)=>e+t,0)*o;return Math.min(s+30,window.innerHeight-50)})(e,d,o,a))}c(!l),m.current=window.setTimeout(()=>{u.current=!1,t||i(void 0)},n)}},[n,l,e,o,a]);return{contentRef:d,isAnimating:u.current,animateCollapse:f,maxHeight:s,collapsed:l,cssTransitionValue:h}})(p,b,J,d,K),{pathString:ae,nodeData:se,path:ie,name:ce,size:ue,canEdit:de,canDelete:pe,canAdd:me,canDrag:he,error:fe,setError:ye,onError:ge,derivedValues:ve,buildKeyDisplayProps:be}=Oe({props:r,collapsed:ne}),{dragSourceProps:Ee,getDropTargetProps:Ce,BottomDropTarget:De,DropTargetPadding:Se}=Re({canDrag:he,canDragOnto:g,path:ie,nodeData:se,onError:ge,translate:T}),Ne=t.useRef(!J),{isEditing:Pe,isEditingKey:Ie,isPending:Ke,isArray:Le}=ve,Me=(e=>{const n=t.useRef(e),r=!Object.is(n.current,e);return t.useEffect(()=>{n.current=e}),r})(v);t.useEffect(()=>{const e=v(se)&&!Pe;Ne.current=!e,re(e),Me&&u(null)},[v]),((e,n,r)=>{const{commands:o,version:a}=ee(),s=t.useRef(0);t.useEffect(()=>{if(a===s.current)return;if(s.current=a,!o)return;let t;for(const n of o)te(e,n)&&(t=n);t&&(t.collapsed||(n.current=!0),r(t.collapsed))},[a,o])})(ie,Ne,re);const _e=t.useRef(null),ze=t.useCallback(e=>$(t=>"function"==typeof e?e(t??K(p)):e),[p,K]),Fe=t.useCallback(()=>$(null),[]),Be=t.useMemo(()=>Pe?W??K(p):null,[Pe,W,p,K]),Ye=t.useCallback((e,t)=>{if("function"!=typeof O)return O;const n=O(e,t);return void 0!==n?n:null},[O]),Ue=t.useCallback(e=>R?"function"!=typeof R?R:R(e):null,[R]),{CustomComponent:He,componentProps:We,CustomWrapperComponent:$e,wrapperProps:Je={},showKey:Xe=!0,showEditTools:Qe=!0,showOnEdit:Ze,showOnView:Ge,showCollectionWrapper:qe=!0}=A,et=Z(e=>null!==e.active&&m(e.active.path,ie));et&&ne&&re(!1);const tt=le(ie)||0===se.level,nt=t.useRef(n);if(!tt&&!et)return null;const{visibleSize:rt}=se,ot=Array.isArray(p)?"array":"object",at="array"===ot?{open:"[",close:"]"}:{open:"{",close:"}"},st=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=N(_e,"\t");return void $(t)}V(e,{objectConfirm:lt,cancel:ut})},it=e=>{e.stopPropagation();const t=S(e);if(t&&_.collapseModifier.includes(t))return Ne.current=!0,void u({collapsed:!ne,path:ie,includeChildren:!0});c(ie)||(Ne.current=!0,F&&F({...se,fullData:H(),collapsed:!ne,includeChildren:!1}),re(!ne))},lt=e=>{const t=Be??K(p);let n;try{n=I(t)}catch{return void ge({code:"INVALID_JSON",message:T("ERROR_INVALID_JSON",se)},t)}ye(null);const r="function"==typeof e?e:void 0;l({op:"edit",path:ie,value:n,onCommit:()=>{Fe(),r?.()}}).then(e=>{"error"===e?.status&&ge(e.error,n)})};nt.current=lt;const ct=ie.length>0?()=>{l({op:"delete",path:ie,instant:!0}).then(e=>{"error"===e?.status&&ge(e.error,p)})}:void 0,ut=()=>{i(),ye(null),Fe()},dt="when-collapsed"===y?ne:"when-collapsed-or-filtered"===y?ne||null!=rt:y,pt=!Pe&&Qe,mt=(k||!Le)&&Xe&&void 0!==ce,ht=He&&(Pe&&Ze||!Pe&&Ge),ft=Object.entries(p).map(([e,t])=>["array"===ot?Number(e):e,t]);"object"===ot&&C(ft,e=>e);const yt=Ne.current?Pe?e.jsxs("div",{className:"jer-collection-text-edit"+(L?"-custom":""),children:[L?e.jsx(L,{value:Be??"",onChange:$,onKeyDown:e=>V(e,{objectConfirm:lt,cancel:ut})}):e.jsx(D,{textAreaRef:_e,className:"jer-collection-text-area",name:ae,value:Be??"",setValue:ze,onKeyDown:st,styles:a("input",se)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(we,{onOk:lt,onCancel:ut,nodeData:se,translate:T,showIconTooltips:w,editConfirmRef:B})})]}):ft.map(([t,n],s)=>{const i={key:t,value:n,path:[...ie,t],level:ie.length+1,index:s,size:o(n)?Object.keys(n).length:null,parentData:p,fullData:se.fullData},l=ke(P,i);return e.jsx("div",{className:"jer-collection-element",style:a("collectionElement",i),children:o(n)&&!l?.renderCollectionAsValue?e.jsx(Ve,{...r,data:n,parentData:p,nodeData:i,canDragOnto:de,customNodeData:l},t):e.jsx(Ae,{...r,data:n,parentData:p,nodeData:i,canDragOnto:de,showLabel:"object"===ot||k,customNodeData:l},t)},t)}):null,gt=!!qe&&ne&&!et;gt||(Ne.current=!0);const vt=()=>({...r,data:p,value:p,parentData:f,nodeData:se,setValue:e=>l({op:"edit",path:ie,value:e}),handleEdit:lt,handleCancel:ut,onKeyDown:st,isEditing:Pe,isPending:Ke,setIsEditing:de?()=>s(ie,{cancelOp:Fe,commitOp:e=>nt.current(e)}):n,getStyles:a,canDragOnto:de,canEdit:de,keyboardCommon:{}}),bt=ht?e.jsx(He,{componentProps:We,...vt(),children:yt}):yt,jt=pt&&e.jsx(xe,{startEdit:de?()=>{Ne.current=!0,s(ie,{cancelOp:Fe,commitOp:e=>nt.current(e)})}:void 0,handleAdd:me?e=>{u(null),re(!1);const t=Ye(se,e);if("array"===ot){const e=z.array?0:p.length,n=z.array?{insert:!0}:{};return void l({op:"add",path:ie,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&ge(e.error,t)})}if(e in p)return ge({code:"KEY_EXISTS",message:T("ERROR_KEY_EXISTS",se)},e),void i();const n=z.object?{insertBefore:0}:{};l({op:"add",path:ie,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&ge(e.error,t)})}:void 0,handleDelete:pe?ct:void 0,showClipboardButton:j,onCopy:x,type:ot,nodeData:se,translate:T,customButtons:r.customButtons,keyboardControls:_,handleKeyboard:V,getNewKeyOptions:Ue,editConfirmRef:B,jsonStringify:K,showIconTooltips:w,Select:M}),xt=be({handleCancel:ut,getStyles:a,keyValueArray:ft,handleClick:U.includes("property")?it:e=>e.stopPropagation()}),wt=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===ie.length?0:E/2)+"em",...a("collection",se),position:"relative"},draggable:he&&!Pe&&!Ie&&!et,...Ee,...Ce("above"),children:[e.jsx("div",{className:"jer-clickzone",style:{width:E/2+1+"em",zIndex:10+2*se.level},onClick:U.includes("left")?it:void 0}),!Pe&&De,e.jsx(Se,{position:"above",nodeData:se}),qe?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",se),position:"relative"},onClick:U.includes("header")?it:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(ne?" jer-rotate-90":""),style:{zIndex:11+2*se.level,transition:oe},onClick:it,children:e.jsx(je,{name:"collection",nodeData:se})}),mt&&e.jsx(Te,{...xt}),!Pe&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:a("bracket",se),children:at.open})]}),!1!==y&&!Pe&&e.jsx("div",{className:"jer-collection-item-count"+(dt?" jer-visible":" jer-hidden"),style:{...a("itemCount",se),transition:oe,transitionBehavior:"allow-discrete"},children:null!=rt&&rt!==ue?T("ITEMS_FILTERED",se,{visible:rt,total:ue}):1===ue?T("ITEM_SINGLE",{...se,size:1},1):T("ITEMS_MULTIPLE",se,ue)}),e.jsx("div",{className:"jer-brackets"+(gt?" jer-visible":" jer-hidden"),style:{...a("bracket",se),transition:oe},children:at.close}),jt]}):Xe?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",se),position:"relative"},children:[e.jsx(Te,{...xt}),jt]}):e.jsx(e.Fragment,{}),e.jsxs("div",{className:"jer-collection-inner",style:{overflowY:gt||G?"clip":"visible",maxHeight:et?void 0:q,...a("collectionInner",se),transition:oe},ref:X,children:[bt,e.jsx("div",{className:Pe?"jer-collection-error-row-edit":"jer-collection-error-row",children:fe&&e.jsx("span",{className:"jer-error-slug",style:a("error",se),children:fe})}),!Pe&&qe&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:a("bracket",se),children:at.close})]}),e.jsx(Se,{position:"below",nodeData:se})]});return $e?e.jsx($e,{wrapperProps:Je,...vt(),children:wt}):wt},Pe),ze=({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"})]})},Fe=(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}},Be=({key:e,path:t},n="")=>!!Fe({value:e},n)||!!t.some(e=>Fe({value:e},n)),Ye={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel"};var Ue=[],He=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var s=Ue.indexOf(a);-1===s&&(s=Ue.push(a)-1,He[s]={}),n=He[s]&&He[s][r]?He[s][r]:He[s][r]=i()}else n=i();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function i(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var s="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(s,e),e}}(':host,:root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff;--jer-icon-copy-color:#268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{left:-1.2em;position:absolute;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;font-family:inherit;font-size:.85em;line-height:1.25em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row-edit{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em;margin-right:.2em}.jer-confirm-buttons>button,.jer-edit-buttons>button{appearance:none;background:none;border:none;color:inherit;font:inherit;margin:0;padding:0}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #b4b4b4;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const We=(e,t)=>JSON.stringify(e,t,2),$e={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},Je={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},Xe=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=[],Ze=["header","left"],Ge={},qe={},et={},tt=[],nt=({data:s,setData:l,buildNodeDataFromPathRef:c,commitRef:u,rootName:p="root",onUpdate:m=n,onChange:h,onError:f,onEditEvent:y,showErrorMessages:g=!0,showClipboardButton:v=!0,onCopy:b,indent:j=2,collapse:w=3,collapseAnimationTime:C=300,showCollectionCount:D="when-collapsed-or-filtered",allowEdit:S=!0,allowDelete:O=!0,allowAdd:N=!0,allowTypeSelection:P=!0,allowDrag:A=!1,searchFilter:I,searchText:K,searchDebounceTime:L=350,sortKeys:M=!1,showArrayIndexes:_=!0,arrayIndexStart:V=0,showStringQuotes:z=!0,showIconTooltips:F=!1,defaultValue:B=null,newKeyOptions:U,minWidth:H=250,maxWidth:W="min(600px, 90vw)",baseFontSize:$,stringTruncateLength:J=250,translations:X=Ge,className:Z,id:G,customText:q=qe,customNodeDefinitions:te=Qe,customButtons:ne=tt,jsonParse:re=JSON.parse,jsonStringify:oe=We,TextEditor:ae,Select:ie=ze,errorDisplayTime:le=2500,keyboardControls:ce=et,editorRef:ue,insertAtTop:de=!1,onCollapse:pe,collapseClickZones:me=Ze})=>{const{getStyles:he,cssVars:fe}=Y(),{open:ye,cancel:ge,getSnapshot:ve}=Q(),be=t.useMemo(()=>at(w),[w]),je=t.useMemo(()=>((e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}let s=r in e?e[r]:Ye[r];if(void 0!==o){const e=a(o)?o:{count:o};for(const[t,n]of Object.entries(e))s=s?.replace(`{{${t}}}`,String(n))}return s})(e,t,r,n,o))(X,q),[X,q]),[xe,we]=t.useState(K),Ee=t.useRef(null);t.useEffect(()=>{ge();const e=setTimeout(()=>we(K),L);return()=>clearTimeout(e)},[K,L]);const Ce=E(s,[],p),De=t.useRef(s);De.current=s;const Se=t.useRef(l);Se.current=l;const Oe=t.useRef(je);Oe.current=je;const Re=t.useRef(Ce);Re.current=Ce;const Te=t.useRef(m);Te.current=m;const Ne=t.useRef(p);Ne.current=p;const Pe=t.useRef(void 0),Ie=t.useCallback(()=>De.current,[]),Ke=Xe(h),Le=Xe(f),Me=Xe(pe),_e=Xe(y),Be=Xe(b),Ue=t.useCallback(e=>{De.current=e,Se.current(e)},[]),He=t.useCallback((e,t)=>{Ue(ot(De.current,e,t,"update").newData)},[Ue]),nt=t.useCallback(e=>{const t=De.current,n=Ne.current,r=Pe.current,o=Ue,{op:a,path:s}=e;switch(a){case"edit":{const{newData:a,currentValue:i,newValue:l}=ot(t,s,e.value,"update"),c=E(t,s,n,r);return{input:{...c,newData:a,event:"edit",newValue:l},nodeData:c,isNoOp:i===l,apply:()=>o(a),revert:()=>o(ot(De.current,s,i,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=ot(t,s,"","delete"),i=E(t,s,n,r);return{input:{...i,newData:e,event:"delete"},nodeData:i,isNoOp:!1,apply:()=>o(e),revert:()=>o(ot(De.current,s,a,"add",{insert:!0,insertBefore:i.index}).newData)}}case"add":{const a=[...s,e.key],{newData:i,newValue:l}=ot(t,a,e.value,"add",e.options),c=E(i,a,n,r);return{input:{...c,value:void 0,size:null,parentData:x(t,s)??null,fullData:t,newData:i,event:"add",newValue:l},nodeData:c,isNoOp:!1,apply:()=>o(i),revert:()=>o(ot(De.current,a,"","delete").newData)}}case"rename":{const a=s.slice(0,-1),i=s[s.length-1],{newKey:l}=e,c=x(t,a),u=Object.fromEntries(Object.entries(c).map(([e,t])=>e===i?[l,t]:[e,t])),{newData:d}=ot(t,a,u,"update"),p=E(t,s,n,r);return{input:{...p,newData:d,event:"rename",newKey:l},nodeData:p,isNoOp:i===l,apply:()=>o(d),revert:()=>o(ot(De.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}=ot(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}=ot(u,g,d,"add",y),b=E(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Ue]),rt=t.useCallback(async(e,t)=>{const n=Je[e.event],r=()=>Oe.current($e[e.event],Re.current);let o;try{o=await Te.current(e,t)}catch(e){return{status:"error",error:{code:n,message:e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r()}}}if(!1===o)return{status:"error",error:{code:n,message:r()}};if(null===o)return{status:"cancel"};if(o&&"object"==typeof o){if(void 0!==o.error)return"string"==typeof o.error?{status:"error",error:{code:n,message:o.error}}:{status:"error",error:o.error};const t=void 0!==o.data,r=void 0!==o.value;if(t&&r&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),t)return{status:"override",value:o.data,path:[]};if(r&&("edit"===e.event||"add"===e.event))return{status:"override",value:o.value,path:e.path}}return{status:"commit"}},[]),lt=t.useMemo(()=>({runUpdate:m===n?void 0:rt,buildCommit:nt,applyValue:He}),[rt,nt,He,m]);u.current=lt;const ct=t.useMemo(()=>at(S),[S]),ut=t.useMemo(()=>at(O),[O]),dt=t.useMemo(()=>at(N),[N]),pt=t.useMemo(()=>at(A),[A]),mt=t.useMemo(()=>st(I),[I]),ht=t.useMemo(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,a=new Map,s=t??Fe,i=n??"",l=e=>{let t=s(e,i);if(o(e.value)){let n=0;const r=Array.isArray(e.value),s=Object.entries(e.value);for(const[a,i]of s){const s=r?Number(a):a,c={key:s,path:[...e.path,s],level:e.level+1,index:n,value:i,size:o(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(c)&&(t=!0,n++)}a.set(d(e.path),n)}return t&&r.add(d(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:a}})(Ce,mt,xe),[s,xe,mt,p]),ft=t.useMemo(()=>(e=>{const t={...R};for(const n of Object.keys(R)){const o=n,a=e[o];if(void 0===a)continue;const s="clipboardModifier"===n||"collapseModifier"===n;if(null===a){t[o]=s?[]:null;continue}const i=(()=>s?r(a):"string"==typeof a?{key:a}:a)();t[o]=i}return T.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(ce),[ce]),yt=t.useCallback((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(k(n,e[r],r)){n.preventDefault(),o();break}})(ft,t,e),[ft]),gt=t.useMemo(()=>{const e=it(te,"stringifyReplacer");return t=>oe(t,e)},[te,oe]),vt=t.useMemo(()=>{const e=it(te,"parseReviver");return t=>{const n=re(t,e);return i(n)}},[te,re]),bt=t.useRef(null),{setCollapseState:jt}=ee(),xt=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=xt;const wt=t.useCallback(e=>E(Ie(),e,Ne.current,Pe.current),[Ie]);c.current=wt,t.useImperativeHandle(ue,()=>{const e=Symbol("path-missing");return{collapse:e=>jt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>x(Ie(),t,e)===e?"PATH_NOT_FOUND":n||ct(E(Ie(),t,p,xt))?(ye(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{bt.current&&(bt.current.click(),"editing"!==ve().active?.phase&&ge())},cancel:()=>ge()}},[jt,ye,ge,ve,ct,Ie,p,xt]);const Et=ke(te,Ce),Ct=t.useMemo(()=>({object:!0===de||"object"===de,array:!0===de||"array"===de}),[de]),Dt={mainContainerRef:Ee,name:p,nodeData:Ce,getLatestData:Ie,onChange:Ke,onError:Le,onEditEvent:_e,showErrorMessages:g,showCollectionCount:D,collapseFilter:be,collapseAnimationTime:C,allowEditFilter:ct,allowDeleteFilter:ut,allowAddFilter:dt,allowTypeSelection:P,allowDragFilter:pt,canDragOnto:!1,showClipboardButton:v,onCopy:Be,sortKeys:M,sort:xt,showArrayIndexes:_,arrayIndexStart:V,showStringQuotes:z,showIconTooltips:F,indent:j,defaultValue:B,newKeyOptions:U,stringTruncateLength:J,translate:je,customNodeDefinitions:te,customNodeData:Et,customButtons:ne,parentData:null,jsonParse:vt,jsonStringify:gt,TextEditor:ae,Select:ie,errorDisplayTime:le,handleKeyboard:yt,keyboardControls:ft,insertAtTop:Ct,onCollapse:Me,editConfirmRef:bt,collapseClickZones:me},St={...he("container",Ce),...fe,minWidth:H,maxWidth:W};return St.fontSize=$??St.fontSize,e.jsx("div",{id:G,ref:Ee,className:`jer-editor-container ${Z??""}`,style:St,children:e.jsx(se,{value:ht,children:o(s)&&!Et.renderCollectionAsValue?e.jsx(Ve,{data:s,...Dt}):e.jsx(Ae,{data:s,showLabel:!0,...Dt})})})};function rt(n){const r=t.useRef(void 0),o=t.useRef(void 0),a=n;return e.jsx(B,{theme:a.theme??L,children:e.jsx(oe,{onEditEvent:a.onEditEvent,onCollapse:a.onCollapse,buildNodeDataFromPathRef:r,commitRef:o,children:e.jsx(nt,{...a,buildNodeDataFromPathRef:r,commitRef:o})})})}const ot=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},s="add"!==r?x(e,t):void 0;return{currentData:e,newData:g(e,t,n,a),currentValue:s,newValue:"delete"!==r?n:void 0}},at=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,st=e=>{if(void 0!==e)return"value"===e?Fe:"key"===e?Be:"all"===e?(e,t)=>Fe(e,t)||Be(e,t):e},it=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?l:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}};exports.AutogrowTextArea=D,exports.IconSvg=be,exports.JsonEditor=rt,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(rt,{...a,editorRef:s,setData:n,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})},exports.StringDisplay=de,exports.StringEdit=pe,exports.assign=g,exports.collectionDataTypes=Ce,exports.defaultTheme=L,exports.extract=x,exports.isCollection=o,exports.matchNode=Fe,exports.matchNodeKey=Be,exports.splitPropertyString=c,exports.standardDataTypes=De,exports.toPathString=d,exports.useKeyboardListener=ye,exports.valueDataTypes=Ee;
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("react");const n=()=>{},r=e=>Array.isArray(e)?e:[e],o=e=>null!==e&&"object"==typeof e,a=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),s=(e,t)=>{if("string"!=typeof e)return null;const n=t.filter(t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority);return n.sort((e,t)=>(t.matchPriority??0)-(e.matchPriority??0)),n[0]??null},i=e=>{if(e!==l){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=i(n);r!==n&&(e[t]=r)}return e}},l="__​undefined__",c=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),u=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),d=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),p=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),m=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),h=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},f=e=>Array.isArray(e),y=(e,t)=>e.filter((e,n)=>n!==t),g=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:s=!1}=r,i=e,l=u(t),d={...r,remove:o,createNew:a,noError:s,fullData:i,fullPath:l},p=Array.isArray(t)?t:c(t);return f(e)&&o&&1===p.length?y(e,p[0]):v(e,p,n,d)},v=(e,t,n,r)=>{const o=a(e)?{...e}:null,s=f(e)?[...e]:null;if(0===t.length)return e;if(!o&&!s)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:c,fullData:u,fullPath:d}=r,p=t[0];if(s&&"string"==typeof p)return s.map(e=>v(e,t,n,r));if(1===t.length)return o&&"string"==typeof p?b(o,p,n,r)??o:s&&"number"==typeof p?(j(s,p,n,r),s):(h(u,d,p,c),e);const m=o||s||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=m[p],n=t[1];return f(e)?m[p]=y(e,n):h(u,d,p,c,"Trying to remove an indexed item from an object that is not an array"),m}const g=t.slice(1);if(p in e){if(x=m[p],!f(x)&&!a(x)){if(!i)return h(u,d,p,c),m;m[p]={}}return m[p]=v(m[p],g,n,r),m}var x;if(i){const e="number"==typeof g[0]?[]:{};if(o)return m[p]=e,m[p]=v(m[p],g,n,r),m;if(s&&Array.isArray(m)){m.push(e);const t=m.length-1;return m[t]=v(m[t],g,n,r),m}}return h(u,d,p,c),m},b=(e,t,n,r)=>{const{remove:o,createNew:a,noError:s,insertAfter:i,insertBefore:l,fullData:c,fullPath:u}=r;if(void 0!==l||void 0!==i){const r=Object.entries(e);let o=1/0;return o="number"==typeof l?l:"number"==typeof i?i:r.findIndex(([e])=>e===(l??i)),void 0!==i&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const d=t in e;o?d?delete e[t]:h(c,u,t,s):a||d?e[t]=n:h(c,u,t,s)},j=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:s,createNew:i,insert:l}=r;l&&e.splice(t,0,n),t in e?e[t]=n:i?e.push(n):h(a,s,t,o)},x=(e,t,n)=>{const r=Array.isArray(t)?t:c(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>x(e,r,n));if("object"!=typeof e||null===e||!(o in e))return w(e,o,n);const a=e[o];return 1===r.length?a:x(a,r.slice(1),n)},w=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},E=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:o(e)?Object.keys(e).length:1,parentData:null,fullData:e};const a=t[t.length-1],s=x(e,t),i=x(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof a?a:Number(a);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===a)}return{key:a,path:t,level:t.length,index:l,value:s,size:o(s)?Object.keys(s).length:null,parentData:i,fullData:e}},C="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,D=({className:n,name:r,value:o,setValue:a,onKeyDown:s,styles:i,textAreaRef:l})=>{const c=t.useRef(null);if(C(()=>{const e=c.current;c.current=null;const t=l?.current;if(!e||!t)return;const n=e.start+o.length-e.sourceLength,r=Math.max(0,Math.min(n,o.length));t.selectionStart!==r&&t.setSelectionRange(r,r)},[o,l]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e.jsxs("div",{style:{display:"grid"},children:[e.jsx("textarea",{id:`${r}_textarea`,ref:l,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...i},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;c.current=null!==n&&n<t.length?{start:n,sourceLength:t.length}:null,a(t)},autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:s}),e.jsx("span",{className:n,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...i},children:u})]})},S=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,k=(e,t,n)=>{if(!t)return!1;const r=e.key,o=S(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:s}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!s?.includes("Shift"))&&r===a&&(s===o||Array.isArray(s)&&s.includes(o))},O={key:"Enter"},R={confirm:O,cancel:{key:"Escape"},objectConfirm:{...O,modifier:["Meta","Shift","Control"]},objectLineBreak:O,stringConfirm:O,stringLineBreak:{...O,modifier:["Shift"]},numberConfirm:O,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:O,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},T=["stringConfirm","numberConfirm","booleanConfirm"],N=(e,t)=>{const n=e.current,r=n.selectionStart??1/0,o=n.selectionEnd??1/0,a=n.value.slice(0,r)+t+n.value.slice(o);return n.value=a,n.setSelectionRange(r+1,r+1),a},P=(e,t,n="next",r,a)=>{const s=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=x(e,s),c=I(l);Array.isArray(l)||r(c,({key:e,value:t})=>[e,t]);const u=c.findIndex(e=>e.key===i),d=c[u+("next"===n?1:-1)];if(!d)return 0===s.length?null:P(e,s,n,r,a);let p;if(o(d.value)){if(0===Object.keys(d.value).length)return P(e,[...s,d.key],n,r,a);p=A(e,[...s,d.key],n,r)}else p=[...s,d.key];return p?a(E(e,p,"",r))?p:P(e,p,n,r,a):null},A=(e,t,n="next",r)=>{const a=x(e,t);if(!o(a))return t;const s=Array.isArray(a)?a.map((e,t)=>t):Object.keys(a);r(s,e=>[e,a]);const i="next"===n?s[0]:s[s.length-1];return A(e,[...t,i],n,r)},I=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),K={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},L={displayName:"Default",icons:{add:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),e.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),e.jsx("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:e.jsx("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),e.jsx("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),e.jsx("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:K,scale:.86},ok:{content:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),e.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:K,scale:.9},cancel:{content:e.jsx("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},M={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},_=e=>[L,...r(e)].map(e=>"styles"in e?e:{styles:e}),V=e=>{const t={};for(const{icons:n}of _(e))n&&Object.assign(t,n);return t},z={getStyles:()=>({}),icons:V(L),cssVars:{}},F=t.createContext(z),B=({theme:n=L,children:r})=>{const o=t.useMemo(()=>(e=>{var t;const n=_(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[M[a]??"color"]:t}:t}}}for(const e in o)r[t=e]??(r[t]={});const a={};for(const e in r){const t=e,n=r[t],s=o[t];a[t]=s?e=>s.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(n),[n]),a=t.useMemo(()=>V(n),[n]),s=t.useMemo(()=>(e=>{const{inputHighlight:t,iconCopy:n}=e,r={};return"function"!=typeof t&&t?.backgroundColor&&(r["--jer-highlight-color"]=t.backgroundColor),"function"!=typeof n&&n?.color&&(r["--jer-icon-copy-color"]=n.color),r})(o),[o]),i=t.useCallback((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(o,e,t),[o]),l=t.useMemo(()=>({getStyles:i,icons:a,cssVars:s}),[i,a,s]);return e.jsx(F.Provider,{value:l,children:r})},Y=()=>t.useContext(F),U={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},H=(e,t)=>U[e][t]??null,W=(e,t)=>null!==e&&null!==t&&e.op===t.op&&p(e.path,t.path),$={active:null,settling:{}},J=t.createContext(null),X=({children:n,onEditEvent:r,buildNodeDataFromPathRef:o,commitRef:a})=>{const s=t.useRef(r);s.current=r;const i=t.useRef(null);return null===i.current&&(i.current=((e,t,n)=>{let r=$;const o=new Set;let a=null,s=null,i=!1,l=0;const c=e=>{r=e,o.forEach(e=>e())},u=(t,n,r)=>{e.current?.({...t,...r,event:n})},h=(n,o,i)=>{if(!e.current)return;let l;try{l=t.current?.(n)}catch{return c({...r,active:null}),a=null,void(s=null)}l&&u(l,o,i)},f=(e,t)=>{var n;a=t?.cancelOp??null,s=t?.commitOp??null,n=e,W(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=H(e.op,"start");o&&h(e.path,o)};return{subscribe:e=>(o.add(e),()=>o.delete(e)),getSnapshot:()=>r,getServerSnapshot:()=>r,open:(e,t)=>{if("held"===r.active?.phase)return;const n={path:e,op:t?.op??"edit",phase:"editing",force:t?.force},o=r.active,i=null!==o&&!W(o,n);if(i&&s)return void s(()=>f(n,t));const l=a;if(a=null,s=null,l&&l(),i&&W(r.active,o)){const e=H(o.op,"cancel");e&&h(o.path,e)}f(n,t)},cancel:()=>{if(i)return;if("held"===r.active?.phase)return;const e=r.active;i=!0;try{const t=a;if(a=null,s=null,t&&t(),null!==e){null!==r.active&&c({...r,active:null});const t=H(e.op,"cancel");t&&h(e.path,t)}}finally{i=!1}},submit:e=>{const{op:t,path:o,instant:i,onCommit:m}=e,f=n.current;let y;try{y=f?.buildCommit(e)??null}catch{return W(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,s=null,m?.(),Promise.resolve(void 0)}const g=y?.extra,v=d(o),b=++l;if(!i){const e=H(t,"submit");e&&h(o,e)}if(!y||y.isNoOp){W(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,s=null;const e=H(t,"commit");return e&&(y?u(y.nodeData,e,g):h(o,e,g)),m?.(),Promise.resolve(void 0)}const{input:j,nodeData:x,apply:w,revert:E}=y,C=!!f?.runUpdate;let D=!1,S=!1;const k=()=>{if(D)return;D=!0,w(),a=null,s=null,W(r.active,{path:o,op:t})&&c({...r,active:null}),C&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(v,b);const e=H(t,"commit");e&&u(x,e,g),m?.()},O={hold:()=>(S=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>k())};if(!C)return k(),Promise.resolve(void 0);const R=f.runUpdate(j,O);let T;return S||(i?T=setTimeout(k,100):k()),R.then(e=>(clearTimeout(T),((e,t,o,i,l,m,h,f,y)=>{const g=d(e);if(!h()){if("cancel"===i.status||"error"===i.status){"held"===r.active?.phase&&p(r.active.path,e)&&(c({...r,active:null}),a=null,s=null);const n=H(t,"cancel");return n&&u(f,n),"error"===i.status&&u(f,"updateError",{operation:t,error:i.error}),i}l()}if(r.settling[g]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],c({...r,settling:t})})(g),i.status){case"cancel":m();break;case"error":m(),u(f,"updateError",{operation:t,error:i.error});break;case"override":n.current?.applyValue(i.path,i.value),u(f,"updateSuccess",{operation:t,...y});break;case"commit":u(f,"updateSuccess",{operation:t,...y})}return i}})(o,t,b,e,k,E,()=>D,x,g)))},areChildrenBeingEdited:e=>null!==r.active&&m(r.active.path,e)}})(s,o,a)),e.jsx(J.Provider,{value:i.current,children:n})},Q=()=>{const e=t.useContext(J);if(!e)throw new Error("Missing Editing Context Provider");return e},Z=e=>{const n=Q();return t.useSyncExternalStore(n.subscribe,()=>e(n.getSnapshot()),()=>e(n.getServerSnapshot()))},G=t.createContext(null),q=({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(G.Provider,{value:u,children:n})},ee=()=>{const e=t.useContext(G);if(!e)throw new Error("Missing Collapse Context Provider");return e},te=(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},ne=t.createContext(null),re=({children:n})=>{const[r,o]=t.useState({path:null}),a=t.useRef(!1),s=t.useMemo(()=>({dragSource:r,setDragSource:o,armed:a}),[r]);return e.jsx(ne.Provider,{value:s,children:n})},oe=({children:t,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>e.jsx(X,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:e.jsx(q,{onCollapse:r,buildNodeDataFromPathRef:o,children:e.jsx(re,{children:t})})}),ae=t.createContext(void 0),se=({value:t,children:n})=>e.jsx(ae.Provider,{value:t,children:n}),ie=()=>{const e=t.useContext(ae);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},le=e=>{const t=ie();return null===t||t.visiblePaths.has(d(e))},ce=e=>{const t=ie();return null===t?null:t.visibleChildCounts.get(d(e))??null},ue="**INVALID_FUNCTION**",de=({nodeData:n,showStringQuotes:r=!0,stringTruncateLength:o=200,pathString:a,canEdit:s,setIsEditing:i,styles:l,translate:c,value:u,TextWrapper:d=({children:e})=>e})=>{const p=u??n.value,[m,h]=t.useState(!1),f=r?'"':"",y=p.length>o,g=()=>{s?i(!0):h(!m)};return e.jsxs("div",{id:`${a}_display`,onDoubleClick:g,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&g()},className:"jer-value-string",style:l,children:[f,y?m?e.jsxs(e.Fragment,{children:[e.jsx(d,{children:e.jsxs("span",{children:[p,f]})}),e.jsxs("span",{className:"jer-string-expansion jer-show-less",onClick:()=>h(!1),children:[" ",c("SHOW_LESS",n)]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(d,{children:[e.jsx("span",{children:p.slice(0,o-2).trimEnd()})," "]}),e.jsx("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>h(!0),children:"..."}),f]}):e.jsx(d,{children:`${p}${f}`})]})},pe=({styles:n,pathString:r,value:o,setValue:a,handleEdit:s,handleKeyboard:i,keyboardCommon:l})=>{const c=t.useRef(null);return e.jsx(D,{className:"jer-input-text",textAreaRef:c,name:r,value:o,setValue:a,onKeyDown:e=>{i(e,{stringConfirm:s,stringLineBreak:()=>{const e=N(c,"\n");a(e)},...l})},styles:n})},me=({isEditing:t,path:n,enumType:r,...o})=>{const{getStyles:a}=Y(),s=d(n),{value:i,setValue:l,nodeData:c,handleEdit:u,handleKeyboard:p,keyboardCommon:m,Select:h}=o;return t&&r?e.jsx(h,{name:`${s}-value-select`,value:i,onChange:l,options:r.values,autoFocus:!0,onKeyDown:e=>p(e,{stringConfirm:u,...m})}):t?e.jsx(pe,{styles:a("input",c),pathString:s,...o,setValue:o.setValue}):e.jsx(de,{pathString:s,styles:a("string",c),...o})},he=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=Y();return r?e.jsx("input",{className:"jer-input-number",type:"text",name:d(o),value:t,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:e=>l(e,{numberConfirm:s,numberUp:()=>n(Number(t)+1),numberDown:()=>n(Number(t)-1),...c}),style:{width:String(t).length/1.5+2+"em",...u("input",i)}}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:u("number",i),children:t})},fe=({value:t,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:s,nodeData:i,handleKeyboard:l,keyboardCommon:c})=>{const{getStyles:u}=Y();return"boolean"!=typeof t?null:r?e.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:d(o),checked:t,onChange:()=>n(!t),onKeyDown:e=>{" "===e.key&&e.preventDefault(),l(e,{booleanConfirm:s,booleanToggle:()=>n(!t),...c})},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:u("boolean",i),children:String(t)})},ye=(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])},ge=({value:t,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:s,keyboardCommon:i})=>{const{getStyles:l}=Y();return ye(n,e=>s(e,{confirm:o,...i})),e.jsx("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:l("null",a),children:String(t)})},ve=({value:t})=>{let n="Error!";switch(typeof t){case"string":t===ue&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return e.jsx("span",{className:"jer-value-invalid",children:n})},be=({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})},je=({name:t,nodeData:n})=>{const{getStyles:r,icons:o}=Y(),a=o[t],s=`icon${t[0].toUpperCase()}${t.slice(1)}`;return e.jsx(be,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===t?void 0:"jer-icon",style:r(s,n),children:a.content})},xe=({startEdit:n,handleDelete:r,handleAdd:o,showClipboardButton:a,onCopy:s,type:i,customButtons:l,nodeData:c,translate:d,keyboardControls:m,handleKeyboard:h,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:j}=Y(),{open:w,cancel:E}=Q(),D=d("KEY_NEW",c),[k,O]=t.useState(D),[R,T]=t.useState(!1),{path:N,value:P}=c,A=Z(e=>{const t=e.active;return null!==t&&"add"===t.op&&p(t.path,N)}),I=Array.isArray(R);C(()=>{if(!A)return T(!1),void O(D);const e=Object.keys(x(c.fullData,N)),t=y?y(c)?.filter(t=>!e.includes(t)):null;t&&O(""),T(t??!0)},[A]);const K=()=>{o&&(I&&!k||o("array"===i?"":k))};return e.jsxs("div",{className:"jer-edit-buttons",style:{opacity:A?1:void 0},onClick:e=>e.stopPropagation(),children:[a&&e.jsx("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",i=null;if(a){const a=S(e);if(a&&m.clipboardModifier.includes(a)?(t=u(N),o=t,r="path"):(t=P,o="object"==typeof t?g(P):String(t)),!navigator.clipboard)return void s?.({...c,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,i=e.message}).finally(()=>{s?.({...c,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:i??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":d("TOOLTIP_COPY",c),title:v?d("TOOLTIP_COPY",c):"",children:e.jsx(je,{name:"copy",nodeData:c})}),n&&e.jsx("button",{type:"button",tabIndex:-1,onClick:n,"aria-label":d("TOOLTIP_EDIT",c),title:v?d("TOOLTIP_EDIT",c):"",children:e.jsx(je,{name:"edit",nodeData:c})}),r&&e.jsx("button",{type:"button",tabIndex:-1,onClick:r,"aria-label":d("TOOLTIP_DELETE",c),title:v?d("TOOLTIP_DELETE",c):"",children:e.jsx(je,{name:"delete",nodeData:c})}),o&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===i?w(N,{op:"add"}):o("")},"aria-label":d("TOOLTIP_ADD",c),title:v?d("TOOLTIP_ADD",c):"",children:e.jsx(je,{name:"add",nodeData:c})}),l?.map(({Element:t,onClick:n},r)=>e.jsx("div",{onClick:e=>n&&n(c,e),children:e.jsx(t,{nodeData:c})},r)),A&&o&&"object"===i&&e.jsxs(e.Fragment,{children:[I?e.jsx(b,{name:"new-key-select",onChange:o,defaultValue:"",autoFocus:!0,onKeyDown:e=>h(e,{cancel:()=>E()}),placeholder:R.length>0?d("KEY_SELECT",c):d("NO_KEY_OPTIONS",c),options:R}):e.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:k,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{h(e,{stringConfirm:()=>K(),cancel:()=>E()})},style:j("input",c)}),e.jsx(we,{onOk:()=>K(),onCancel:()=>E(),nodeData:c,translate:d,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},we=({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(je,{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(je,{name:"cancel",nodeData:r})})]}),Ee=["string","number","boolean","null"],Ce=["object","array"],De=[...Ee,...Ce],Se=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}},ke=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?Se(n):{}},Oe=({props:e,collapsed:n})=>{const{nodeData:r,parentData:o,onError:a,getLatestData:s,showErrorMessages:i,allowEditFilter:l,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:m,translate:h,errorDisplayTime:f,sort:y,arrayIndexStart:g,handleKeyboard:v,customNodeData:b}=e,{submit:j}=Q(),[x,w]=t.useState(null),E={...r,collapsed:n,visibleSize:ce(r.path)},{path:C,key:D,size:S}=E,k=d(C),O=Z(e=>{const t=e.active;return null!==t&&"edit"===t.op&&p(t.path,C)}),R=Z(e=>{const t=e.active;return null!==t&&"rename"===t.op&&p(t.path,C)}),T=Z(e=>k in e.settling),N=l(E),A=c(E),I=u(E),K=m(E)&&A,L=e=>{i&&(w(e),setTimeout(()=>w(null),f)),console.warn("Error",e)},M=t.useRef(E);M.current=E;const _=t.useCallback((e,t)=>{L(e.message),a&&a({...M.current,fullData:s(),error:e,errorValue:t})},[a,i,s,f]),V=ie(),z=t.useCallback(e=>(null===V||V.visiblePaths.has(d(e.path)))&&l(e),[V,l]),F=e=>P(s(),C,e,y,z),B=(e,t)=>{o&&(D!==e&&Object.keys(o).includes(e)?_({code:"KEY_EXISTS",message:h("ERROR_KEY_EXISTS",E)},e):j({op:"rename",path:C,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&_(t.error,e)}))},Y="number"==typeof C.slice(-1)[0],U=null!==o&&N&&I&&A&&!Y,H={isEditing:O,isEditingKey:R,isPending:T,isArray:Y,canEditKey:U},W=""===D&&C.length>0?h("EMPTY_STRING",E):null;return{pathString:k,nodeData:E,path:C,name:D,size:S,canEdit:N,canDelete:A,canAdd:I,canDrag:K,error:x,showError:L,onError:_,setError:w,handleEditKey:B,derivedValues:H,emptyStringKey:W,getNextOrPreviousAtPath:F,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:U,isEditingKey:R,pathString:k,path:C,name:D,arrayIndexStart:g,handleKeyboard:v,handleEditKey:B,handleCancel:e,styles:t("property",E),getNextOrPrevious:F,emptyStringKey:W,nodeData:E,customNodeData:b,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},Re=({canDrag:n,canDragOnto:r,path:o,nodeData:a,onError:s,translate:i})=>{const{getStyles:l}=Y(),{dragSource:c,setDragSource:u,armed:d}=(()=>{const e=t.useContext(ne);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),h=Q(),[f,y]=t.useState(!1),g=t.useMemo(()=>n?{onMouseDown:e=>{0===e.button&&null===h.getSnapshot().active&&(d.current=!0)},onMouseUp:()=>{d.current=!1},onDragStart:e=>{if(!d.current||null!==h.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();d.current=!1,e.stopPropagation(),u({path:o})},onDragEnd:e=>{d.current=!1,e.stopPropagation(),u({path:null})}}:{},[n,o]),v=t.useMemo(()=>e=>r?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),j(e),u({path:null}),y(!1)},onDragEnter:t=>{t.stopPropagation(),null!==c.path&&m(o,c.path)||y(e)},onDragExit:e=>{e.stopPropagation(),y(!1)}}:{},[c,r,o]),b=t.useMemo(()=>r&&null!==c.path?e.jsx("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:o.length},...v("below")}):null,[c,r,o.length]),j=e=>{if(null===c.path)return;if(m(o,c.path))return;const t=c.path.slice(-1)[0],n=c.path.slice(0,-1),r=o.slice(0,-1),{parentData:l}=a;"string"==typeof t&&l&&!Array.isArray(l)&&Object.keys(l).includes(t)&&t in l&&!p(n,r)?s({code:"KEY_EXISTS",message:i("ERROR_KEY_EXISTS",a)},t):h.submit({op:"move",path:c.path,to:{path:o,position:e},instant:!0})};return{dragSourceProps:g,getDropTargetProps:v,BottomDropTarget:b,DropTargetPadding:({position:t,nodeData:n})=>f===t?e.jsx("div",{className:"jer-drag-n-drop-padding",style:l("dropZone",n)}):null,handleDrop:j}},Te=({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}=Q(),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"}})},Ne=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||!p(n.path,r.path))return!1;var n,r;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(const n of o)if(!Ne.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ae=t.memo(r=>{const{data:o,parentData:a,onChange:i,showClipboardButton:l,onCopy:c,canDragOnto:u,allowTypeSelection:d,showLabel:m,stringTruncateLength:h,showStringQuotes:f,indent:y,translate:g,customNodeDefinitions:v,customNodeData:b,Select:j,handleKeyboard:x,keyboardControls:w,editConfirmRef:E,jsonStringify:C,showIconTooltips:D,getLatestData:S}=r,{getStyles:k}=Y(),{open:O,cancel:R,submit:T,getSnapshot:N}=Q(),{setCollapseState:P}=ee(),[A,I]=t.useState("function"==typeof o?ue:o),{nodeData:K,path:L,name:M,canEdit:_,canDelete:V,canDrag:z,error:F,onError:B,setError:U,derivedValues:H,getNextOrPreviousAtPath:W,buildKeyDisplayProps:$}=Oe({props:r}),{dragSourceProps:J,getDropTargetProps:X,BottomDropTarget:Z,DropTargetPadding:G}=Re({canDrag:z,canDragOnto:u,path:L,nodeData:K,onError:B,translate:g}),[q,te]=t.useState(Ke(o,b)),ne=t.useRef(A);ne.current=A;const re=t.useRef(K);re.current=K;const oe=t.useCallback(e=>{if(!i)return void I(e);const t=i({...re.current,value:ne.current,fullData:S(),newValue:e});I(t)},[i,S]),ae=()=>{I("function"==typeof o?ue:o),te(Ke(o,b)),ce(s(o,se))};t.useEffect(()=>{H.isEditing||ae()},[o]);const se=t.useMemo(()=>{const e=[...De,...v.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof d)return d?e:[];if(Array.isArray(d))return d;const t=d(K);return"boolean"==typeof t?t?e:[]:t},[K,d,v]),[ie,ce]=t.useState(s(A,se)),{isEditing:de,isPending:pe}=H,me=le(L),he=t.useRef(n);if(!me)return null;const fe=de&&q!==Ke(o,b),ye=fe?v.find(e=>e.name===q&&Ie(e)):void 0,ge=ye?Se(ye):b,{CustomComponent:ve,componentProps:be,showKey:je=!0,showEditTools:Ee=!0,showOnEdit:Ce,showOnView:ke,passOriginalNode:Ne}=ge,Pe=ve&&(void 0!==ye||!fe&&(de&&Ce||!de&&ke)),Ae=e=>{P(null);const t=fe&&!ye?void 0:ge,n=t?.toStandardType?t.toStandardType(A):A,r=v.find(t=>t.name===e);if(r){if(Ie(r)){let t=r.defaultValue;if(r.fromStandardType)try{t=r.fromStandardType(n,K,r.componentProps)}catch{}return I(t),te(e),void ce(null)}return T({op:"edit",path:L,value:r.defaultValue}).then(Ve(r.defaultValue)),void P({path:L,collapsed:!1,includeChildren:!1})}const o=se.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof A&&o.values.includes(A)||I(o.values[0]),ce(o),void te(e);const a=_e(n,e,g("DEFAULT_NEW_KEY",K));if("object"===e||"array"===e||"null"===e)return T({op:"edit",path:L,value:a}).then(Ve(a)),void("null"!==e&&P({path:L,collapsed:!1,includeChildren:!1}));I(a),te(e),ce(null)},Ve=e=>t=>{if("error"===t?.status&&B(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=N().active;"editing"===e?.phase&&p(e.path,L)||ae()}},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&&ge.fromStandardType)try{r=ge.fromStandardType(A,K,ge.componentProps)}catch(e){return void B({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},A)}else r="number"===q?Me(A):A;U(null),ye&&P({path:L,collapsed:!1,includeChildren:!1}),T({op:"edit",path:L,value:r,onCommit:t}).then(Ve(r))};he.current=ze;const Fe=()=>{U(null),ae(),R()},{isEditingKey:Be}=H,Ye=!!F,Ue=de&&se.length>1,He=("invalid"!==q||ve)&&!F&&Ee,We=m&&je,$e=()=>O(L,{cancelOp:ae,commitOp:e=>he.current(void 0,e)}),Je=_?$e:n,Xe=e=>()=>{const t=W(e);t&&ze(void 0,()=>O(t))},Qe={value:A,parentData:a,setValue:oe,isEditing:de,canEdit:_,setIsEditing:Je,handleEdit:ze,handleCancel:Fe,path:L,stringTruncateLength:h,showStringQuotes:f,nodeData:K,enumType:ie,translate:g,handleKeyboard:x,keyboardCommon:{cancel:Fe,tabForward:Xe("next"),tabBack:Xe("prev")},Select:j},Ze={...$({handleCancel:Fe,getStyles:k}),customNodeData:ge},Ge=Pe?e.jsx(ve,{...r,value:A,componentProps:be,setValue:oe,handleEdit:ze,handleCancel:Fe,onKeyDown:e=>x(e,{stringConfirm:ze,cancel:Fe}),isEditing:de,isPending:pe,setIsEditing:Je,getStyles:k,originalNode:Ne?Le(o,q,Qe):void 0,originalNodeKey:Ne?e.jsx(Te,{...Ze,customNodeData:void 0}):void 0,canEdit:_,keyboardCommon:Qe.keyboardCommon}):Le(o,q,Qe);return e.jsxs("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==a?y/2+"em":0,position:"relative"},draggable:z&&!de&&!Be,...J,...X("above"),children:[Z,e.jsx(G,{position:"above",nodeData:K}),e.jsxs("div",{className:"jer-value-main-row",style:{...k("valueRow",K),flexWrap:M.length>10?"wrap":"nowrap"},children:[We&&e.jsx(Te,{...Ze}),e.jsxs("div",{className:"jer-value-and-buttons",children:[e.jsx("div",{className:"jer-input-component",children:Ge}),de?e.jsx(we,{onOk:ze,onCancel:Fe,nodeData:K,translate:g,showIconTooltips:D,editConfirmRef:E}):He&&e.jsx(xe,{startEdit:_?$e:void 0,handleDelete:V?()=>{T({op:"delete",path:L,instant:!0}).then(e=>{"error"===e?.status&&B(e.error,A)})}:void 0,showClipboardButton:l,onCopy:c,translate:g,customButtons:r.customButtons,nodeData:K,handleKeyboard:x,keyboardControls:w,editConfirmRef:E,jsonStringify:C,showIconTooltips:D,Select:j}),Ue&&e.jsx(j,{name:`${M}-type-select`,value:ie?ie.enum:q,onChange:e=>Ae(e),options:se.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Ye&&e.jsx("span",{className:"jer-error-slug",style:k("error",K),children:F})]})]}),e.jsx(G,{position:"below",nodeData:K})]})},Pe),Ie=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,Ke=(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",Le=(t,n,r)=>{const o=Ee.includes(n)?n:"function"==typeof t?"invalid":Ke(r.value),{value:a}=r;switch(o){case"string":return e.jsx(me,{...r,value:a});case"number":return e.jsx(he,{...r,value:a});case"boolean":return e.jsx(fe,{...r,value:a});case"null":return e.jsx(ge,{...r});default:return e.jsx(ve,{...r})}},Me=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},_e=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Me(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Ve=t.memo(r=>{const{getStyles:a}=Y(),{open:s,cancel:i,submit:l,areChildrenBeingEdited:c}=Q(),{setCollapseState:u}=ee(),{mainContainerRef:d,data:p,nodeData:h,parentData:f,showCollectionCount:y,canDragOnto:g,collapseFilter:v,collapseAnimationTime:b,showClipboardButton:j,onCopy:x,showIconTooltips:w,indent:E,sort:C,showArrayIndexes:k,defaultValue:O,newKeyOptions:R,translate:T,customNodeDefinitions:P,customNodeData:A,jsonParse:I,jsonStringify:K,TextEditor:L,Select:M,keyboardControls:_,handleKeyboard:V,insertAtTop:z,onCollapse:F,editConfirmRef:B,collapseClickZones:U,getLatestData:H}=r,[W,$]=t.useState(null),J=v(h),{contentRef:X,isAnimating:G,maxHeight:q,collapsed:ne,animateCollapse:re,cssTransitionValue:oe}=((e,n,r,o,a)=>{const[s,i]=t.useState(r?0:void 0),[l,c]=t.useState(r),u=t.useRef(!1),d=t.useRef(null),p=t.useRef(0),m=t.useRef(0),h=n/1e3+"s",f=t.useCallback(t=>{if(l!==t){switch(window.clearTimeout(m.current),u.current=!0,t){case!0:{const e=d.current?.offsetHeight??0;p.current=e,i(e),setTimeout(()=>{i(0)},5);break}case!1:i(p.current||((e,t,n,r)=>{if(!t.current)return 0;const o=parseInt(getComputedStyle(n.current).getPropertyValue("line-height"))||16,a=(t.current?.offsetWidth??0)/(.5*o),s=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/a)).reduce((e,t)=>e+t,0)*o;return Math.min(s+30,window.innerHeight-50)})(e,d,o,a))}c(!l),m.current=window.setTimeout(()=>{u.current=!1,t||i(void 0)},n)}},[n,l,e,o,a]);return{contentRef:d,isAnimating:u.current,animateCollapse:f,maxHeight:s,collapsed:l,cssTransitionValue:h}})(p,b,J,d,K),{pathString:ae,nodeData:se,path:ie,name:ce,size:ue,canEdit:de,canDelete:pe,canAdd:me,canDrag:he,error:fe,setError:ye,onError:ge,derivedValues:ve,buildKeyDisplayProps:be}=Oe({props:r,collapsed:ne}),{dragSourceProps:Ee,getDropTargetProps:Ce,BottomDropTarget:De,DropTargetPadding:Se}=Re({canDrag:he,canDragOnto:g,path:ie,nodeData:se,onError:ge,translate:T}),Ne=t.useRef(!J),{isEditing:Pe,isEditingKey:Ie,isPending:Ke,isArray:Le}=ve,Me=(e=>{const n=t.useRef(e),r=!Object.is(n.current,e);return t.useEffect(()=>{n.current=e}),r})(v);t.useEffect(()=>{const e=v(se)&&!Pe;Ne.current=!e,re(e),Me&&u(null)},[v]),((e,n,r)=>{const{commands:o,version:a}=ee(),s=t.useRef(0);t.useEffect(()=>{if(a===s.current)return;if(s.current=a,!o)return;let t;for(const n of o)te(e,n)&&(t=n);t&&(t.collapsed||(n.current=!0),r(t.collapsed))},[a,o])})(ie,Ne,re);const _e=t.useRef(null),ze=t.useCallback(e=>$(t=>"function"==typeof e?e(t??K(p)):e),[p,K]),Fe=t.useCallback(()=>$(null),[]),Be=t.useMemo(()=>Pe?W??K(p):null,[Pe,W,p,K]),Ye=t.useCallback((e,t)=>{if("function"!=typeof O)return O;const n=O(e,t);return void 0!==n?n:null},[O]),Ue=t.useCallback(e=>R?"function"!=typeof R?R:R(e):null,[R]),{CustomComponent:He,componentProps:We,CustomWrapperComponent:$e,wrapperProps:Je={},showKey:Xe=!0,showEditTools:Qe=!0,showOnEdit:Ze,showOnView:Ge,showCollectionWrapper:qe=!0}=A,et=Z(e=>null!==e.active&&m(e.active.path,ie));et&&ne&&re(!1);const tt=le(ie)||0===se.level,nt=t.useRef(n);if(!tt&&!et)return null;const{visibleSize:rt}=se,ot=Array.isArray(p)?"array":"object",at="array"===ot?{open:"[",close:"]"}:{open:"{",close:"}"},st=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=N(_e,"\t");return void $(t)}V(e,{objectConfirm:lt,cancel:ut})},it=e=>{e.stopPropagation();const t=S(e);if(t&&_.collapseModifier.includes(t))return Ne.current=!0,void u({collapsed:!ne,path:ie,includeChildren:!0});c(ie)||(Ne.current=!0,F&&F({...se,fullData:H(),collapsed:!ne,includeChildren:!1}),re(!ne))},lt=e=>{const t=Be??K(p);let n;try{n=I(t)}catch{return void ge({code:"INVALID_JSON",message:T("ERROR_INVALID_JSON",se)},t)}ye(null);const r="function"==typeof e?e:void 0;l({op:"edit",path:ie,value:n,onCommit:()=>{Fe(),r?.()}}).then(e=>{"error"===e?.status&&ge(e.error,n)})};nt.current=lt;const ct=ie.length>0?()=>{l({op:"delete",path:ie,instant:!0}).then(e=>{"error"===e?.status&&ge(e.error,p)})}:void 0,ut=()=>{i(),ye(null),Fe()},dt="when-collapsed"===y?ne:"when-collapsed-or-filtered"===y?ne||null!=rt:y,pt=!Pe&&Qe,mt=(k||!Le)&&Xe&&void 0!==ce,ht=He&&(Pe&&Ze||!Pe&&Ge),ft=Object.entries(p).map(([e,t])=>["array"===ot?Number(e):e,t]);"object"===ot&&C(ft,e=>e);const yt=!Pe||!!He&&Ze,gt=Ne.current?yt?ft.map(([t,n],s)=>{const i={key:t,value:n,path:[...ie,t],level:ie.length+1,index:s,size:o(n)?Object.keys(n).length:null,parentData:p,fullData:se.fullData},l=ke(P,i);return e.jsx("div",{className:"jer-collection-element",style:a("collectionElement",i),children:o(n)&&!l?.renderCollectionAsValue?e.jsx(Ve,{...r,data:n,parentData:p,nodeData:i,canDragOnto:de,customNodeData:l},t):e.jsx(Ae,{...r,data:n,parentData:p,nodeData:i,canDragOnto:de,showLabel:"object"===ot||k,customNodeData:l},t)},t)}):e.jsxs("div",{className:"jer-collection-text-edit"+(L?"-custom":""),children:[L?e.jsx(L,{value:Be??"",onChange:$,onKeyDown:e=>V(e,{objectConfirm:lt,cancel:ut})}):e.jsx(D,{textAreaRef:_e,className:"jer-collection-text-area",name:ae,value:Be??"",setValue:ze,onKeyDown:st,styles:a("input",se)}),e.jsx("div",{className:"jer-collection-input-button-row",children:e.jsx(we,{onOk:lt,onCancel:ut,nodeData:se,translate:T,showIconTooltips:w,editConfirmRef:B})})]}):null,vt=!!qe&&ne&&!et;vt||(Ne.current=!0);const bt=()=>({...r,data:p,value:p,parentData:f,nodeData:se,setValue:e=>l({op:"edit",path:ie,value:e}),handleEdit:lt,handleCancel:ut,onKeyDown:st,isEditing:Pe,isPending:Ke,setIsEditing:de?()=>s(ie,{cancelOp:Fe,commitOp:e=>nt.current(e)}):n,getStyles:a,canDragOnto:de,canEdit:de,keyboardCommon:{}}),jt=ht?e.jsx(He,{componentProps:We,...bt(),children:gt}):gt,xt=pt&&e.jsx(xe,{startEdit:de?()=>{Ne.current=!0,s(ie,{cancelOp:Fe,commitOp:e=>nt.current(e)})}:void 0,handleAdd:me?e=>{u(null),re(!1);const t=Ye(se,e);if("array"===ot){const e=z.array?0:p.length,n=z.array?{insert:!0}:{};return void l({op:"add",path:ie,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&ge(e.error,t)})}if(e in p)return ge({code:"KEY_EXISTS",message:T("ERROR_KEY_EXISTS",se)},e),void i();const n=z.object?{insertBefore:0}:{};l({op:"add",path:ie,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&ge(e.error,t)})}:void 0,handleDelete:pe?ct:void 0,showClipboardButton:j,onCopy:x,type:ot,nodeData:se,translate:T,customButtons:r.customButtons,keyboardControls:_,handleKeyboard:V,getNewKeyOptions:Ue,editConfirmRef:B,jsonStringify:K,showIconTooltips:w,Select:M}),wt=be({handleCancel:ut,getStyles:a,keyValueArray:ft,handleClick:U.includes("property")?it:e=>e.stopPropagation()}),Et=e.jsxs("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===ie.length?0:E/2)+"em",...a("collection",se),position:"relative"},draggable:he&&!Pe&&!Ie&&!et,...Ee,...Ce("above"),children:[e.jsx("div",{className:"jer-clickzone",style:{width:E/2+1+"em",zIndex:10+2*se.level},onClick:U.includes("left")?it:void 0}),!Pe&&De,e.jsx(Se,{position:"above",nodeData:se}),qe?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",se),position:"relative"},onClick:U.includes("header")?it:void 0,children:[e.jsxs("div",{className:"jer-collection-name",children:[e.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(ne?" jer-rotate-90":""),style:{zIndex:11+2*se.level,transition:oe},onClick:it,children:e.jsx(je,{name:"collection",nodeData:se})}),mt&&e.jsx(Te,{...wt}),!Pe&&e.jsx("span",{className:"jer-brackets jer-bracket-open",style:a("bracket",se),children:at.open})]}),!1!==y&&!Pe&&e.jsx("div",{className:"jer-collection-item-count"+(dt?" jer-visible":" jer-hidden"),style:{...a("itemCount",se),transition:oe,transitionBehavior:"allow-discrete"},children:null!=rt&&rt!==ue?T("ITEMS_FILTERED",se,{visible:rt,total:ue}):1===ue?T("ITEM_SINGLE",{...se,size:1},1):T("ITEMS_MULTIPLE",se,ue)}),e.jsx("div",{className:"jer-brackets"+(vt?" jer-visible":" jer-hidden"),style:{...a("bracket",se),transition:oe},children:at.close}),xt]}):Xe?e.jsxs("div",{className:"jer-collection-header-row",style:{...a("headerRow",se),position:"relative"},children:[e.jsx(Te,{...wt}),xt]}):e.jsx(e.Fragment,{}),e.jsxs("div",{className:"jer-collection-inner",style:{overflowY:vt||G?"clip":"visible",maxHeight:et?void 0:q,...a("collectionInner",se),transition:oe},ref:X,children:[jt,e.jsx("div",{className:Pe?"jer-collection-error-row-edit":"jer-collection-error-row",children:fe&&e.jsx("span",{className:"jer-error-slug",style:a("error",se),children:fe})}),!Pe&&qe&&e.jsx("div",{className:"jer-brackets jer-bracket-outside",style:a("bracket",se),children:at.close})]}),e.jsx(Se,{position:"below",nodeData:se})]});return $e?e.jsx($e,{wrapperProps:Je,...bt(),children:Et}):Et},Pe),ze=({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"})]})},Fe=(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}},Be=({key:e,path:t},n="")=>!!Fe({value:e},n)||!!t.some(e=>Fe({value:e},n)),Ye={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel"};var Ue=[],He=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var s=Ue.indexOf(a);-1===s&&(s=Ue.push(a)-1,He[s]={}),n=He[s]&&He[s][r]?He[s][r]:He[s][r]=i()}else n=i();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function i(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var s="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(s,e),e}}(':host,:root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff;--jer-icon-copy-color:#268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{left:-1.2em;position:absolute;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;font-family:inherit;font-size:.85em;line-height:1.25em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row-edit{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em;margin-right:.2em}.jer-confirm-buttons>button,.jer-edit-buttons>button{appearance:none;background:none;border:none;color:inherit;font:inherit;margin:0;padding:0}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #b4b4b4;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const We=(e,t)=>JSON.stringify(e,t,2),$e={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},Je={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},Xe=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=[],Ze=["header","left"],Ge={},qe={},et={},tt=[],nt=({data:s,setData:l,buildNodeDataFromPathRef:c,commitRef:u,rootName:p="root",onUpdate:m=n,onChange:h,onError:f,onEditEvent:y,showErrorMessages:g=!0,showClipboardButton:v=!0,onCopy:b,indent:j=2,collapse:w=3,collapseAnimationTime:C=300,showCollectionCount:D="when-collapsed-or-filtered",allowEdit:S=!0,allowDelete:O=!0,allowAdd:N=!0,allowTypeSelection:P=!0,allowDrag:A=!1,searchFilter:I,searchText:K,searchDebounceTime:L=350,sortKeys:M=!1,showArrayIndexes:_=!0,arrayIndexStart:V=0,showStringQuotes:z=!0,showIconTooltips:F=!1,defaultValue:B=null,newKeyOptions:U,minWidth:H=250,maxWidth:W="min(600px, 90vw)",baseFontSize:$,stringTruncateLength:J=250,translations:X=Ge,className:Z,id:G,customText:q=qe,customNodeDefinitions:te=Qe,customButtons:ne=tt,jsonParse:re=JSON.parse,jsonStringify:oe=We,TextEditor:ae,Select:ie=ze,errorDisplayTime:le=2500,keyboardControls:ce=et,editorRef:ue,insertAtTop:de=!1,onCollapse:pe,collapseClickZones:me=Ze})=>{const{getStyles:he,cssVars:fe}=Y(),{open:ye,cancel:ge,getSnapshot:ve}=Q(),be=t.useMemo(()=>at(w),[w]),je=t.useMemo(()=>((e,t)=>(n,r,o)=>((e,t,n,r,o)=>{if(t[r]){const e=t[r](n);if(null!==e)return e}let s=r in e?e[r]:Ye[r];if(void 0!==o){const e=a(o)?o:{count:o};for(const[t,n]of Object.entries(e))s=s?.replace(`{{${t}}}`,String(n))}return s})(e,t,r,n,o))(X,q),[X,q]),[xe,we]=t.useState(K),Ee=t.useRef(null);t.useEffect(()=>{ge();const e=setTimeout(()=>we(K),L);return()=>clearTimeout(e)},[K,L]);const Ce=E(s,[],p),De=t.useRef(s);De.current=s;const Se=t.useRef(l);Se.current=l;const Oe=t.useRef(je);Oe.current=je;const Re=t.useRef(Ce);Re.current=Ce;const Te=t.useRef(m);Te.current=m;const Ne=t.useRef(p);Ne.current=p;const Pe=t.useRef(void 0),Ie=t.useCallback(()=>De.current,[]),Ke=Xe(h),Le=Xe(f),Me=Xe(pe),_e=Xe(y),Be=Xe(b),Ue=t.useCallback(e=>{De.current=e,Se.current(e)},[]),He=t.useCallback((e,t)=>{Ue(ot(De.current,e,t,"update").newData)},[Ue]),nt=t.useCallback(e=>{const t=De.current,n=Ne.current,r=Pe.current,o=Ue,{op:a,path:s}=e;switch(a){case"edit":{const{newData:a,currentValue:i,newValue:l}=ot(t,s,e.value,"update"),c=E(t,s,n,r);return{input:{...c,newData:a,event:"edit",newValue:l},nodeData:c,isNoOp:i===l,apply:()=>o(a),revert:()=>o(ot(De.current,s,i,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=ot(t,s,"","delete"),i=E(t,s,n,r);return{input:{...i,newData:e,event:"delete"},nodeData:i,isNoOp:!1,apply:()=>o(e),revert:()=>o(ot(De.current,s,a,"add",{insert:!0,insertBefore:i.index}).newData)}}case"add":{const a=[...s,e.key],{newData:i,newValue:l}=ot(t,a,e.value,"add",e.options),c=E(i,a,n,r);return{input:{...c,value:void 0,size:null,parentData:x(t,s)??null,fullData:t,newData:i,event:"add",newValue:l},nodeData:c,isNoOp:!1,apply:()=>o(i),revert:()=>o(ot(De.current,a,"","delete").newData)}}case"rename":{const a=s.slice(0,-1),i=s[s.length-1],{newKey:l}=e,c=x(t,a),u=Object.fromEntries(Object.entries(c).map(([e,t])=>e===i?[l,t]:[e,t])),{newData:d}=ot(t,a,u,"update"),p=E(t,s,n,r);return{input:{...p,newData:d,event:"rename",newKey:l},nodeData:p,isNoOp:i===l,apply:()=>o(d),revert:()=>o(ot(De.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}=ot(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}=ot(u,g,d,"add",y),b=E(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[Ue]),rt=t.useCallback(async(e,t)=>{const n=Je[e.event],r=()=>Oe.current($e[e.event],Re.current);let o;try{o=await Te.current(e,t)}catch(e){return{status:"error",error:{code:n,message:e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r()}}}if(!1===o)return{status:"error",error:{code:n,message:r()}};if(null===o)return{status:"cancel"};if(o&&"object"==typeof o){if(void 0!==o.error)return"string"==typeof o.error?{status:"error",error:{code:n,message:o.error}}:{status:"error",error:o.error};const t=void 0!==o.data,r=void 0!==o.value;if(t&&r&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),t)return{status:"override",value:o.data,path:[]};if(r&&("edit"===e.event||"add"===e.event))return{status:"override",value:o.value,path:e.path}}return{status:"commit"}},[]),lt=t.useMemo(()=>({runUpdate:m===n?void 0:rt,buildCommit:nt,applyValue:He}),[rt,nt,He,m]);u.current=lt;const ct=t.useMemo(()=>at(S),[S]),ut=t.useMemo(()=>at(O),[O]),dt=t.useMemo(()=>at(N),[N]),pt=t.useMemo(()=>at(A),[A]),mt=t.useMemo(()=>st(I),[I]),ht=t.useMemo(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,a=new Map,s=t??Fe,i=n??"",l=e=>{let t=s(e,i);if(o(e.value)){let n=0;const r=Array.isArray(e.value),s=Object.entries(e.value);for(const[a,i]of s){const s=r?Number(a):a,c={key:s,path:[...e.path,s],level:e.level+1,index:n,value:i,size:o(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(c)&&(t=!0,n++)}a.set(d(e.path),n)}return t&&r.add(d(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:a}})(Ce,mt,xe),[s,xe,mt,p]),ft=t.useMemo(()=>(e=>{const t={...R};for(const n of Object.keys(R)){const o=n,a=e[o];if(void 0===a)continue;const s="clipboardModifier"===n||"collapseModifier"===n;if(null===a){t[o]=s?[]:null;continue}const i=(()=>s?r(a):"string"==typeof a?{key:a}:a)();t[o]=i}return T.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(ce),[ce]),yt=t.useCallback((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(k(n,e[r],r)){n.preventDefault(),o();break}})(ft,t,e),[ft]),gt=t.useMemo(()=>{const e=it(te,"stringifyReplacer");return t=>oe(t,e)},[te,oe]),vt=t.useMemo(()=>{const e=it(te,"parseReviver");return t=>{const n=re(t,e);return i(n)}},[te,re]),bt=t.useRef(null),{setCollapseState:jt}=ee(),xt=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=xt;const wt=t.useCallback(e=>E(Ie(),e,Ne.current,Pe.current),[Ie]);c.current=wt,t.useImperativeHandle(ue,()=>{const e=Symbol("path-missing");return{collapse:e=>jt(e),startEdit:({path:t,overrideRestrictions:n=!1})=>x(Ie(),t,e)===e?"PATH_NOT_FOUND":n||ct(E(Ie(),t,p,xt))?(ye(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{bt.current&&(bt.current.click(),"editing"!==ve().active?.phase&&ge())},cancel:()=>ge()}},[jt,ye,ge,ve,ct,Ie,p,xt]);const Et=ke(te,Ce),Ct=t.useMemo(()=>({object:!0===de||"object"===de,array:!0===de||"array"===de}),[de]),Dt={mainContainerRef:Ee,name:p,nodeData:Ce,getLatestData:Ie,onChange:Ke,onError:Le,onEditEvent:_e,showErrorMessages:g,showCollectionCount:D,collapseFilter:be,collapseAnimationTime:C,allowEditFilter:ct,allowDeleteFilter:ut,allowAddFilter:dt,allowTypeSelection:P,allowDragFilter:pt,canDragOnto:!1,showClipboardButton:v,onCopy:Be,sortKeys:M,sort:xt,showArrayIndexes:_,arrayIndexStart:V,showStringQuotes:z,showIconTooltips:F,indent:j,defaultValue:B,newKeyOptions:U,stringTruncateLength:J,translate:je,customNodeDefinitions:te,customNodeData:Et,customButtons:ne,parentData:null,jsonParse:vt,jsonStringify:gt,TextEditor:ae,Select:ie,errorDisplayTime:le,handleKeyboard:yt,keyboardControls:ft,insertAtTop:Ct,onCollapse:Me,editConfirmRef:bt,collapseClickZones:me},St={...he("container",Ce),...fe,minWidth:H,maxWidth:W};return St.fontSize=$??St.fontSize,e.jsx("div",{id:G,ref:Ee,className:`jer-editor-container ${Z??""}`,style:St,children:e.jsx(se,{value:ht,children:o(s)&&!Et.renderCollectionAsValue?e.jsx(Ve,{data:s,...Dt}):e.jsx(Ae,{data:s,showLabel:!0,...Dt})})})};function rt(n){const r=t.useRef(void 0),o=t.useRef(void 0),a=n;return e.jsx(B,{theme:a.theme??L,children:e.jsx(oe,{onEditEvent:a.onEditEvent,onCollapse:a.onCollapse,buildNodeDataFromPathRef:r,commitRef:o,children:e.jsx(nt,{...a,buildNodeDataFromPathRef:r,commitRef:o})})})}const ot=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},s="add"!==r?x(e,t):void 0;return{currentData:e,newData:g(e,t,n,a),currentValue:s,newValue:"delete"!==r?n:void 0}},at=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,st=e=>{if(void 0!==e)return"value"===e?Fe:"key"===e?Be:"all"===e?(e,t)=>Fe(e,t)||Be(e,t):e},it=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?l:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}};exports.AutogrowTextArea=D,exports.IconSvg=be,exports.JsonEditor=rt,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(rt,{...a,editorRef:s,setData:n,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})},exports.StringDisplay=de,exports.StringEdit=pe,exports.assign=g,exports.collectionDataTypes=Ce,exports.defaultTheme=L,exports.extract=x,exports.isCollection=o,exports.matchNode=Fe,exports.matchNodeKey=Be,exports.splitPropertyString=c,exports.standardDataTypes=De,exports.toPathString=d,exports.useKeyboardListener=ye,exports.valueDataTypes=Ee;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import r,{useLayoutEffect as o,useEffect as a,useRef as i,createContext as l,useContext as s,useMemo as c,useCallback as d,useSyncExternalStore as u,useState as p,useImperativeHandle as h}from"react";const m=()=>{},f=e=>Array.isArray(e)?e:[e],y=e=>null!==e&&"object"==typeof e,g=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),v=(e,t)=>{if("string"!=typeof e)return null;const n=t.filter(t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority);return n.sort((e,t)=>(t.matchPriority??0)-(e.matchPriority??0)),n[0]??null},b=e=>{if(e!==w){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=b(n);r!==n&&(e[t]=r)}return e}},w="__​undefined__",E=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),D=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),C=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),j=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),S=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),k=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},O=e=>Array.isArray(e),T=(e,t)=>e.filter((e,n)=>n!==t),N=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:i=!1}=r,l=e,s=D(t),c={...r,remove:o,createNew:a,noError:i,fullData:l,fullPath:s},d=Array.isArray(t)?t:E(t);return O(e)&&o&&1===d.length?T(e,d[0]):x(e,d,n,c)},x=(e,t,n,r)=>{const o=g(e)?{...e}:null,a=O(e)?[...e]:null;if(0===t.length)return e;if(!o&&!a)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:s,fullData:c,fullPath:d}=r,u=t[0];if(a&&"string"==typeof u)return a.map(e=>x(e,t,n,r));if(1===t.length)return o&&"string"==typeof u?R(o,u,n,r)??o:a&&"number"==typeof u?(P(a,u,n,r),a):(k(c,d,u,s),e);const p=o||a||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=p[u],n=t[1];return O(e)?p[u]=T(e,n):k(c,d,u,s,"Trying to remove an indexed item from an object that is not an array"),p}const h=t.slice(1);if(u in e){if(m=p[u],!O(m)&&!g(m)){if(!i)return k(c,d,u,s),p;p[u]={}}return p[u]=x(p[u],h,n,r),p}var m;if(i){const e="number"==typeof h[0]?[]:{};if(o)return p[u]=e,p[u]=x(p[u],h,n,r),p;if(a&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=x(p[t],h,n,r),p}}return k(c,d,u,s),p},R=(e,t,n,r)=>{const{remove:o,createNew:a,noError:i,insertAfter:l,insertBefore:s,fullData:c,fullPath:d}=r;if(void 0!==s||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof s?s:"number"==typeof l?l:r.findIndex(([e])=>e===(s??l)),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const u=t in e;o?u?delete e[t]:k(c,d,t,i):a||u?e[t]=n:k(c,d,t,i)},P=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:i,createNew:l,insert:s}=r;s&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):k(a,i,t,o)},A=(e,t,n)=>{const r=Array.isArray(t)?t:E(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>A(e,r,n));if("object"!=typeof e||null===e||!(o in e))return I(e,o,n);const a=e[o];return 1===r.length?a:A(a,r.slice(1),n)},I=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},K=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:y(e)?Object.keys(e).length:1,parentData:null,fullData:e};const o=t[t.length-1],a=A(e,t),i=A(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof o?o:Number(o);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===o)}return{key:o,path:t,level:t.length,index:l,value:a,size:y(a)?Object.keys(a).length:null,parentData:i,fullData:e}},L="undefined"!=typeof window?o:a,_=({className:n,name:r,value:o,setValue:a,onKeyDown:l,styles:s,textAreaRef:c})=>{const d=i(null);if(L(()=>{const e=d.current;d.current=null;const t=c?.current;if(!e||!t)return;const n=e.start+o.length-e.sourceLength,r=Math.max(0,Math.min(n,o.length));t.selectionStart!==r&&t.setSelectionRange(r,r)},[o,c]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:c,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...s},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;d.current=null!==n&&n<t.length?{start:n,sourceLength:t.length}:null,a(t)},autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:l}),t("span",{className:n,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...s},children:u})]})},V=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,M=(e,t,n)=>{if(!t)return!1;const r=e.key,o=V(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:i}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!i?.includes("Shift"))&&r===a&&(i===o||Array.isArray(i)&&i.includes(o))},z={key:"Enter"},F={confirm:z,cancel:{key:"Escape"},objectConfirm:{...z,modifier:["Meta","Shift","Control"]},objectLineBreak:z,stringConfirm:z,stringLineBreak:{...z,modifier:["Shift"]},numberConfirm:z,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:z,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},B=["stringConfirm","numberConfirm","booleanConfirm"],Y=(e,t)=>{const n=e.current,r=n.selectionStart??1/0,o=n.selectionEnd??1/0,a=n.value.slice(0,r)+t+n.value.slice(o);return n.value=a,n.setSelectionRange(r+1,r+1),a},U=(e,t,n="next",r,o)=>{const a=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=A(e,a),s=$(l);Array.isArray(l)||r(s,({key:e,value:t})=>[e,t]);const c=s.findIndex(e=>e.key===i),d=s[c+("next"===n?1:-1)];if(!d)return 0===a.length?null:U(e,a,n,r,o);let u;if(y(d.value)){if(0===Object.keys(d.value).length)return U(e,[...a,d.key],n,r,o);u=W(e,[...a,d.key],n,r)}else u=[...a,d.key];return u?o(K(e,u,"",r))?u:U(e,u,n,r,o):null},W=(e,t,n="next",r)=>{const o=A(e,t);if(!y(o))return t;const a=Array.isArray(o)?o.map((e,t)=>t):Object.keys(o);r(a,e=>[e,o]);const i="next"===n?a[0]:a[a.length-1];return W(e,[...t,i],n,r)},$=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),H={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},J={displayName:"Default",icons:{add:{content:e(n,{children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:e(n,{children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:t("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:e(n,{children:[t("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),t("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:H,scale:.86},ok:{content:e(n,{children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:H,scale:.9},cancel:{content:t("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:t("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},X={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},Q=e=>[J,...f(e)].map(e=>"styles"in e?e:{styles:e}),Z=e=>{const t={};for(const{icons:n}of Q(e))n&&Object.assign(t,n);return t},G=l({getStyles:()=>({}),icons:Z(J),cssVars:{}}),q=({theme:e=J,children:n})=>{const r=c(()=>(e=>{var t;const n=Q(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[X[a]??"color"]:t}:t}}}for(const e in o)r[t=e]??(r[t]={});const a={};for(const e in r){const t=e,n=r[t],i=o[t];a[t]=i?e=>i.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(e),[e]),o=c(()=>Z(e),[e]),a=c(()=>(e=>{const{inputHighlight:t,iconCopy:n}=e,r={};return"function"!=typeof t&&t?.backgroundColor&&(r["--jer-highlight-color"]=t.backgroundColor),"function"!=typeof n&&n?.color&&(r["--jer-icon-copy-color"]=n.color),r})(r),[r]),i=d((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(r,e,t),[r]),l=c(()=>({getStyles:i,icons:o,cssVars:a}),[i,o,a]);return t(G.Provider,{value:l,children:n})},ee=()=>s(G),te={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},ne=(e,t)=>te[e][t]??null,re=(e,t)=>null!==e&&null!==t&&e.op===t.op&&j(e.path,t.path),oe={active:null,settling:{}},ae=l(null),ie=({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=oe;const o=new Set;let a=null,i=null,l=!1,s=0;const c=e=>{r=e,o.forEach(e=>e())},d=(t,n,r)=>{e.current?.({...t,...r,event:n})},u=(n,o,l)=>{if(!e.current)return;let s;try{s=t.current?.(n)}catch{return c({...r,active:null}),a=null,void(i=null)}s&&d(s,o,l)},p=(e,t)=>{var n;a=t?.cancelOp??null,i=t?.commitOp??null,n=e,re(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=ne(e.op,"start");o&&u(e.path,o)};return{subscribe:e=>(o.add(e),()=>o.delete(e)),getSnapshot:()=>r,getServerSnapshot:()=>r,open:(e,t)=>{if("held"===r.active?.phase)return;const n={path:e,op:t?.op??"edit",phase:"editing",force:t?.force},o=r.active,l=null!==o&&!re(o,n);if(l&&i)return void i(()=>p(n,t));const s=a;if(a=null,i=null,s&&s(),l&&re(r.active,o)){const e=ne(o.op,"cancel");e&&u(o.path,e)}p(n,t)},cancel:()=>{if(l)return;if("held"===r.active?.phase)return;const e=r.active;l=!0;try{const t=a;if(a=null,i=null,t&&t(),null!==e){null!==r.active&&c({...r,active:null});const t=ne(e.op,"cancel");t&&u(e.path,t)}}finally{l=!1}},submit:e=>{const{op:t,path:o,instant:l,onCommit:p}=e,h=n.current;let m;try{m=h?.buildCommit(e)??null}catch{return re(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null,p?.(),Promise.resolve(void 0)}const f=m?.extra,y=C(o),g=++s;if(!l){const e=ne(t,"submit");e&&u(o,e)}if(!m||m.isNoOp){re(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null;const e=ne(t,"commit");return e&&(m?d(m.nodeData,e,f):u(o,e,f)),p?.(),Promise.resolve(void 0)}const{input:v,nodeData:b,apply:w,revert:E}=m,D=!!h?.runUpdate;let S=!1,k=!1;const O=()=>{if(S)return;S=!0,w(),a=null,i=null,re(r.active,{path:o,op:t})&&c({...r,active:null}),D&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(y,g);const e=ne(t,"commit");e&&d(b,e,f),p?.()},T={hold:()=>(k=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>O())};if(!D)return O(),Promise.resolve(void 0);const N=h.runUpdate(v,T);let x;return k||(l?x=setTimeout(O,100):O()),N.then(e=>(clearTimeout(x),((e,t,o,l,s,u,p,h,m)=>{const f=C(e);if(!p()){if("cancel"===l.status||"error"===l.status){"held"===r.active?.phase&&j(r.active.path,e)&&(c({...r,active:null}),a=null,i=null);const n=ne(t,"cancel");return n&&d(h,n),"error"===l.status&&d(h,"updateError",{operation:t,error:l.error}),l}s()}if(r.settling[f]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],c({...r,settling:t})})(f),l.status){case"cancel":u();break;case"error":u(),d(h,"updateError",{operation:t,error:l.error});break;case"override":n.current?.applyValue(l.path,l.value),d(h,"updateSuccess",{operation:t,...m});break;case"commit":d(h,"updateSuccess",{operation:t,...m})}return l}})(o,t,g,e,O,E,()=>S,b,f)))},areChildrenBeingEdited:e=>null!==r.active&&S(r.active.path,e)}})(a,r,o)),t(ae.Provider,{value:l.current,children:e})},le=()=>{const e=s(ae);if(!e)throw new Error("Missing Editing Context Provider");return e},se=e=>{const t=le();return u(t.subscribe,()=>e(t.getSnapshot()),()=>e(t.getServerSnapshot()))},ce=l(null),de=({children:e,onCollapse:n,buildNodeDataFromPathRef:r})=>{const[o,a]=p({commands:null,version:0}),l=i(n);l.current=n;const s=d(e=>{if(null===e)return void a(e=>null===e.commands?e:{commands:null,version:e.version});const t=f(e),n=t.map(e=>({...e,path:[...e.path]}));a(e=>({commands:n,version:e.version+1}));const o=l.current;o&&t.forEach(e=>{const t=r.current?.(e.path);t&&o({...t,collapsed:e.collapsed,includeChildren:e.includeChildren})})},[r]),u=c(()=>({commands:o.commands,version:o.version,setCollapseState:s}),[o.commands,o.version,s]);return t(ce.Provider,{value:u,children:e})},ue=()=>{const e=s(ce);if(!e)throw new Error("Missing Collapse Context Provider");return e},pe=(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},he=l(null),me=({children:e})=>{const[n,r]=p({path:null}),o=i(!1),a=c(()=>({dragSource:n,setDragSource:r,armed:o}),[n]);return t(he.Provider,{value:a,children:e})},fe=({children:e,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>t(ie,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:t(de,{onCollapse:r,buildNodeDataFromPathRef:o,children:t(me,{children:e})})}),ye=l(void 0),ge=({value:e,children:n})=>t(ye.Provider,{value:e,children:n}),ve=()=>{const e=s(ye);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},be=e=>{const t=ve();return null===t||t.visiblePaths.has(C(e))},we=e=>{const t=ve();return null===t?null:t.visibleChildCounts.get(C(e))??null},Ee="**INVALID_FUNCTION**",De=({nodeData:r,showStringQuotes:o=!0,stringTruncateLength:a=200,pathString:i,canEdit:l,setIsEditing:s,styles:c,translate:d,value:u,TextWrapper:h=({children:e})=>e})=>{const m=u??r.value,[f,y]=p(!1),g=o?'"':"",v=m.length>a,b=()=>{l?s(!0):y(!f)};return e("div",{id:`${i}_display`,onDoubleClick:b,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&b()},className:"jer-value-string",style:c,children:[g,v?e(n,f?{children:[t(h,{children:e("span",{children:[m,g]})}),e("span",{className:"jer-string-expansion jer-show-less",onClick:()=>y(!1),children:[" ",d("SHOW_LESS",r)]})]}:{children:[e(h,{children:[t("span",{children:m.slice(0,a-2).trimEnd()})," "]}),t("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>y(!0),children:"..."}),g]}):t(h,{children:`${m}${g}`})]})},Ce=({styles:e,pathString:n,value:r,setValue:o,handleEdit:a,handleKeyboard:l,keyboardCommon:s})=>{const c=i(null);return t(_,{className:"jer-input-text",textAreaRef:c,name:n,value:r,setValue:o,onKeyDown:e=>{l(e,{stringConfirm:a,stringLineBreak:()=>{const e=Y(c,"\n");o(e)},...s})},styles:e})},je=({isEditing:e,path:n,enumType:r,...o})=>{const{getStyles:a}=ee(),i=C(n),{value:l,setValue:s,nodeData:c,handleEdit:d,handleKeyboard:u,keyboardCommon:p,Select:h}=o;return e&&r?t(h,{name:`${i}-value-select`,value:l,onChange:s,options:r.values,autoFocus:!0,onKeyDown:e=>u(e,{stringConfirm:d,...p})}):e?t(Ce,{styles:a("input",c),pathString:i,...o,setValue:o.setValue}):t(De,{pathString:i,styles:a("string",c),...o})},Se=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ee();return r?t("input",{className:"jer-input-number",type:"text",name:C(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:t=>s(t,{numberConfirm:i,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1),...c}),style:{width:String(e).length/1.5+2+"em",...d("input",l)}}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:d("number",l),children:e})},ke=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ee();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:C(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,{booleanConfirm:i,booleanToggle:()=>n(!e),...c})},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},Oe=(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])},Te=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:l})=>{const{getStyles:s}=ee();return Oe(n,e=>i(e,{confirm:o,...l})),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",a),children:String(e)})},Ne=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===Ee&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},xe=({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})},Re=({name:e,nodeData:n})=>{const{getStyles:r,icons:o}=ee(),a=o[e],i=`icon${e[0].toUpperCase()}${e.slice(1)}`;return t(xe,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===e?void 0:"jer-icon",style:r(i,n),children:a.content})},Pe=({startEdit:r,handleDelete:o,handleAdd:a,showClipboardButton:i,onCopy:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:h,handleKeyboard:m,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:w}=ee(),{open:E,cancel:C}=le(),S=u("KEY_NEW",d),[k,O]=p(S),[T,N]=p(!1),{path:x,value:R}=d,P=se(e=>{const t=e.active;return null!==t&&"add"===t.op&&j(t.path,x)}),I=Array.isArray(T);L(()=>{if(!P)return N(!1),void O(S);const e=Object.keys(A(d.fullData,x)),t=y?y(d)?.filter(t=>!e.includes(t)):null;t&&O(""),N(t??!0)},[P]);const K=()=>{a&&(I&&!k||a("array"===s?"":k))};return e("div",{className:"jer-edit-buttons",style:{opacity:P?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&t("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",a=null;if(i){const i=V(e);if(i&&h.clipboardModifier.includes(i)?(t=D(x),o=t,r="path"):(t=R,o="object"==typeof t?g(R):String(t)),!navigator.clipboard)return void l?.({...d,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,a=e.message}).finally(()=>{l?.({...d,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:a??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":u("TOOLTIP_COPY",d),title:v?u("TOOLTIP_COPY",d):"",children:t(Re,{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(Re,{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(Re,{name:"delete",nodeData:d})}),a&&t("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===s?E(x,{op:"add"}):a("")},"aria-label":u("TOOLTIP_ADD",d),title:v?u("TOOLTIP_ADD",d):"",children:t(Re,{name:"add",nodeData:d})}),c?.map(({Element:e,onClick:n},r)=>t("div",{onClick:e=>n&&n(d,e),children:t(e,{nodeData:d})},r)),P&&a&&"object"===s&&e(n,{children:[I?t(b,{name:"new-key-select",onChange:a,defaultValue:"",autoFocus:!0,onKeyDown:e=>m(e,{cancel:()=>C()}),placeholder:T.length>0?u("KEY_SELECT",d):u("NO_KEY_OPTIONS",d),options:T}):t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:k,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>K(),cancel:()=>C()})},style:w("input",d)}),t(Ae,{onOk:()=>K(),onCancel:()=>C(),nodeData:d,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},Ae=({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(Re,{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(Re,{name:"cancel",nodeData:o})})]}),Ie=["string","number","boolean","null"],Ke=["object","array"],Le=[...Ie,...Ke],_e=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}},Ve=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?_e(n):{}},Me=({props:e,collapsed:t})=>{const{nodeData:n,parentData:r,onError:o,getLatestData:a,showErrorMessages:l,allowEditFilter:s,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:h,translate:m,errorDisplayTime:f,sort:y,arrayIndexStart:g,handleKeyboard:v,customNodeData:b}=e,{submit:w}=le(),[E,D]=p(null),S={...n,collapsed:t,visibleSize:we(n.path)},{path:k,key:O,size:T}=S,N=C(k),x=se(e=>{const t=e.active;return null!==t&&"edit"===t.op&&j(t.path,k)}),R=se(e=>{const t=e.active;return null!==t&&"rename"===t.op&&j(t.path,k)}),P=se(e=>N in e.settling),A=s(S),I=c(S),K=u(S),L=h(S)&&I,_=e=>{l&&(D(e),setTimeout(()=>D(null),f)),console.warn("Error",e)},V=i(S);V.current=S;const M=d((e,t)=>{_(e.message),o&&o({...V.current,fullData:a(),error:e,errorValue:t})},[o,l,a,f]),z=ve(),F=d(e=>(null===z||z.visiblePaths.has(C(e.path)))&&s(e),[z,s]),B=e=>U(a(),k,e,y,F),Y=(e,t)=>{r&&(O!==e&&Object.keys(r).includes(e)?M({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",S)},e):w({op:"rename",path:k,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&M(t.error,e)}))},W="number"==typeof k.slice(-1)[0],$=null!==r&&A&&K&&I&&!W,H={isEditing:x,isEditingKey:R,isPending:P,isArray:W,canEditKey:$},J=""===O&&k.length>0?m("EMPTY_STRING",S):null;return{pathString:N,nodeData:S,path:k,name:O,size:T,canEdit:A,canDelete:I,canAdd:K,canDrag:L,error:E,showError:_,onError:M,setError:D,handleEditKey:Y,derivedValues:H,emptyStringKey:J,getNextOrPreviousAtPath:B,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:$,isEditingKey:R,pathString:N,path:k,name:O,arrayIndexStart:g,handleKeyboard:v,handleEditKey:Y,handleCancel:e,styles:t("property",S),getNextOrPrevious:B,emptyStringKey:J,nodeData:S,customNodeData:b,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},ze=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onError:a,translate:i})=>{const{getStyles:l}=ee(),{dragSource:d,setDragSource:u,armed:h}=(()=>{const e=s(he);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),m=le(),[f,y]=p(!1),g=c(()=>e?{onMouseDown:e=>{0===e.button&&null===m.getSnapshot().active&&(h.current=!0)},onMouseUp:()=>{h.current=!1},onDragStart:e=>{if(!h.current||null!==m.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();h.current=!1,e.stopPropagation(),u({path:r})},onDragEnd:e=>{h.current=!1,e.stopPropagation(),u({path:null})}}:{},[e,r]),v=c(()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),w(e),u({path:null}),y(!1)},onDragEnter:t=>{t.stopPropagation(),null!==d.path&&S(r,d.path)||y(e)},onDragExit:e=>{e.stopPropagation(),y(!1)}}:{},[d,n,r]),b=c(()=>n&&null!==d.path?t("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length},...v("below")}):null,[d,n,r.length]),w=e=>{if(null===d.path)return;if(S(r,d.path))return;const t=d.path.slice(-1)[0],n=d.path.slice(0,-1),l=r.slice(0,-1),{parentData:s}=o;"string"==typeof t&&s&&!Array.isArray(s)&&Object.keys(s).includes(t)&&t in s&&!j(n,l)?a({code:"KEY_EXISTS",message:i("ERROR_KEY_EXISTS",o)},t):m.submit({op:"move",path:d.path,to:{path:r,position:e},instant:!0})};return{dragSourceProps:g,getDropTargetProps:v,BottomDropTarget:b,DropTargetPadding:({position:e,nodeData:n})=>f===e?t("div",{className:"jer-drag-n-drop-padding",style:l("dropZone",n)}):null,handleDrop:w}},Fe=({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}=le(),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"}})},Be=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||!j(n.path,r.path))return!1;var n,r;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(const n of o)if(!Be.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ue=r.memo(n=>{const{data:r,parentData:o,onChange:l,showClipboardButton:s,onCopy:u,canDragOnto:h,allowTypeSelection:f,showLabel:y,stringTruncateLength:g,showStringQuotes:b,indent:w,translate:E,customNodeDefinitions:D,customNodeData:C,Select:S,handleKeyboard:k,keyboardControls:O,editConfirmRef:T,jsonStringify:N,showIconTooltips:x,getLatestData:R}=n,{getStyles:P}=ee(),{open:A,cancel:I,submit:K,getSnapshot:L}=le(),{setCollapseState:_}=ue(),[V,M]=p("function"==typeof r?Ee:r),{nodeData:z,path:F,name:B,canEdit:Y,canDelete:U,canDrag:W,error:$,onError:H,setError:J,derivedValues:X,getNextOrPreviousAtPath:Q,buildKeyDisplayProps:Z}=Me({props:n}),{dragSourceProps:G,getDropTargetProps:q,BottomDropTarget:te,DropTargetPadding:ne}=ze({canDrag:W,canDragOnto:h,path:F,nodeData:z,onError:H,translate:E}),[re,oe]=p($e(r,C)),ae=i(V);ae.current=V;const ie=i(z);ie.current=z;const se=d(e=>{if(!l)return void M(e);const t=l({...ie.current,value:ae.current,fullData:R(),newValue:e});M(t)},[l,R]),ce=()=>{M("function"==typeof r?Ee:r),oe($e(r,C)),he(v(r,de))};a(()=>{X.isEditing||ce()},[r]);const de=c(()=>{const e=[...Le,...D.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof f)return f?e:[];if(Array.isArray(f))return f;const t=f(z);return"boolean"==typeof t?t?e:[]:t},[z,f,D]),[pe,he]=p(v(V,de)),{isEditing:me,isPending:fe}=X,ye=be(F),ge=i(m);if(!ye)return null;const ve=me&&re!==$e(r,C),we=ve?D.find(e=>e.name===re&&We(e)):void 0,De=we?_e(we):C,{CustomComponent:Ce,componentProps:je,showKey:Se=!0,showEditTools:ke=!0,showOnEdit:Oe,showOnView:Te,passOriginalNode:Ne}=De,xe=Ce&&(void 0!==we||!ve&&(me&&Oe||!me&&Te)),Re=e=>{_(null);const t=ve&&!we?void 0:De,n=t?.toStandardType?t.toStandardType(V):V,r=D.find(t=>t.name===e);if(r){if(We(r)){let t=r.defaultValue;if(r.fromStandardType)try{t=r.fromStandardType(n,z,r.componentProps)}catch{}return M(t),oe(e),void he(null)}return K({op:"edit",path:F,value:r.defaultValue}).then(Ie(r.defaultValue)),void _({path:F,collapsed:!1,includeChildren:!1})}const o=de.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof V&&o.values.includes(V)||M(o.values[0]),he(o),void oe(e);const a=Xe(n,e,E("DEFAULT_NEW_KEY",z));if("object"===e||"array"===e||"null"===e)return K({op:"edit",path:F,value:a}).then(Ie(a)),void("null"!==e&&_({path:F,collapsed:!1,includeChildren:!1}));M(a),oe(e),he(null)},Ie=e=>t=>{if("error"===t?.status&&H(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=L().active;"editing"===e?.phase&&j(e.path,F)||ce()}},Ke=(e,t)=>{const n=void 0!==e&&!(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e);let r;if(n)r=e;else if(xe&&De.fromStandardType)try{r=De.fromStandardType(V,z,De.componentProps)}catch(e){return void H({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},V)}else r="number"===re?Je(V):V;J(null),we&&_({path:F,collapsed:!1,includeChildren:!1}),K({op:"edit",path:F,value:r,onCommit:t}).then(Ie(r))};ge.current=Ke;const Ve=()=>{J(null),ce(),I()},{isEditingKey:Be}=X,Ye=!!$,Ue=me&&de.length>1,Qe=("invalid"!==re||Ce)&&!$&&ke,Ze=y&&Se,Ge=()=>A(F,{cancelOp:ce,commitOp:e=>ge.current(void 0,e)}),qe=Y?Ge:m,et=e=>()=>{const t=Q(e);t&&Ke(void 0,()=>A(t))},tt={value:V,parentData:o,setValue:se,isEditing:me,canEdit:Y,setIsEditing:qe,handleEdit:Ke,handleCancel:Ve,path:F,stringTruncateLength:g,showStringQuotes:b,nodeData:z,enumType:pe,translate:E,handleKeyboard:k,keyboardCommon:{cancel:Ve,tabForward:et("next"),tabBack:et("prev")},Select:S},nt={...Z({handleCancel:Ve,getStyles:P}),customNodeData:De},rt=xe?t(Ce,{...n,value:V,componentProps:je,setValue:se,handleEdit:Ke,handleCancel:Ve,onKeyDown:e=>k(e,{stringConfirm:Ke,cancel:Ve}),isEditing:me,isPending:fe,setIsEditing:qe,getStyles:P,originalNode:Ne?He(r,re,tt):void 0,originalNodeKey:Ne?t(Fe,{...nt,customNodeData:void 0}):void 0,canEdit:Y,keyboardCommon:tt.keyboardCommon}):He(r,re,tt);return e("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==o?w/2+"em":0,position:"relative"},draggable:W&&!me&&!Be,...G,...q("above"),children:[te,t(ne,{position:"above",nodeData:z}),e("div",{className:"jer-value-main-row",style:{...P("valueRow",z),flexWrap:B.length>10?"wrap":"nowrap"},children:[Ze&&t(Fe,{...nt}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:rt}),me?t(Ae,{onOk:Ke,onCancel:Ve,nodeData:z,translate:E,showIconTooltips:x,editConfirmRef:T}):Qe&&t(Pe,{startEdit:Y?Ge:void 0,handleDelete:U?()=>{K({op:"delete",path:F,instant:!0}).then(e=>{"error"===e?.status&&H(e.error,V)})}:void 0,showClipboardButton:s,onCopy:u,translate:E,customButtons:n.customButtons,nodeData:z,handleKeyboard:k,keyboardControls:O,editConfirmRef:T,jsonStringify:N,showIconTooltips:x,Select:S}),Ue&&t(S,{name:`${B}-type-select`,value:pe?pe.enum:re,onChange:e=>Re(e),options:de.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Ye&&t("span",{className:"jer-error-slug",style:P("error",z),children:$})]})]}),t(ne,{position:"below",nodeData:z})]})},Ye),We=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,$e=(e,t)=>t?.CustomComponent&&t?.name&&t.showInTypeSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",He=(e,n,r)=>{const o=Ie.includes(n)?n:"function"==typeof e?"invalid":$e(r.value),{value:a}=r;switch(o){case"string":return t(je,{...r,value:a});case"number":return t(Se,{...r,value:a});case"boolean":return t(ke,{...r,value:a});case"null":return t(Te,{...r});default:return t(Ne,{...r})}},Je=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Xe=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Je(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Qe=r.memo(r=>{const{getStyles:o}=ee(),{open:l,cancel:s,submit:u,areChildrenBeingEdited:h}=le(),{setCollapseState:f}=ue(),{mainContainerRef:g,data:v,nodeData:b,parentData:w,showCollectionCount:E,canDragOnto:D,collapseFilter:C,collapseAnimationTime:j,showClipboardButton:k,onCopy:O,showIconTooltips:T,indent:N,sort:x,showArrayIndexes:R,defaultValue:P,newKeyOptions:A,translate:I,customNodeDefinitions:K,customNodeData:L,jsonParse:M,jsonStringify:z,TextEditor:F,Select:B,keyboardControls:U,handleKeyboard:W,insertAtTop:$,onCollapse:H,editConfirmRef:J,collapseClickZones:X,getLatestData:Q}=r,[Z,G]=p(null),q=C(b),{contentRef:te,isAnimating:ne,maxHeight:re,collapsed:oe,animateCollapse:ae,cssTransitionValue:ie}=((e,t,n,r,o)=>{const[a,l]=p(n?0:void 0),[s,c]=p(n),u=i(!1),h=i(null),m=i(0),f=i(0),y=t/1e3+"s",g=d(n=>{if(s!==n){switch(window.clearTimeout(f.current),u.current=!0,n){case!0:{const e=h.current?.offsetHeight??0;m.current=e,l(e),setTimeout(()=>{l(0)},5);break}case!1:l(m.current||((e,t,n,r)=>{if(!t.current)return 0;const o=parseInt(getComputedStyle(n.current).getPropertyValue("line-height"))||16,a=(t.current?.offsetWidth??0)/(.5*o),i=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/a)).reduce((e,t)=>e+t,0)*o;return Math.min(i+30,window.innerHeight-50)})(e,h,r,o))}c(!s),f.current=window.setTimeout(()=>{u.current=!1,n||l(void 0)},t)}},[t,s,e,r,o]);return{contentRef:h,isAnimating:u.current,animateCollapse:g,maxHeight:a,collapsed:s,cssTransitionValue:y}})(v,j,q,g,z),{pathString:ce,nodeData:de,path:he,name:me,size:fe,canEdit:ye,canDelete:ge,canAdd:ve,canDrag:we,error:Ee,setError:De,onError:Ce,derivedValues:je,buildKeyDisplayProps:Se}=Me({props:r,collapsed:oe}),{dragSourceProps:ke,getDropTargetProps:Oe,BottomDropTarget:Te,DropTargetPadding:Ne}=ze({canDrag:we,canDragOnto:D,path:he,nodeData:de,onError:Ce,translate:I}),xe=i(!q),{isEditing:Ie,isEditingKey:Ke,isPending:Le,isArray:_e}=je,Be=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(C);a(()=>{const e=C(de)&&!Ie;xe.current=!e,ae(e),Be&&f(null)},[C]),((e,t,n)=>{const{commands:r,version:o}=ue(),l=i(0);a(()=>{if(o===l.current)return;if(l.current=o,!r)return;let a;for(const t of r)pe(e,t)&&(a=t);a&&(a.collapsed||(t.current=!0),n(a.collapsed))},[o,r])})(he,xe,ae);const Ye=i(null),We=d(e=>G(t=>"function"==typeof e?e(t??z(v)):e),[v,z]),$e=d(()=>G(null),[]),He=c(()=>Ie?Z??z(v):null,[Ie,Z,v,z]),Je=d((e,t)=>{if("function"!=typeof P)return P;const n=P(e,t);return void 0!==n?n:null},[P]),Xe=d(e=>A?"function"!=typeof A?A:A(e):null,[A]),{CustomComponent:Ze,componentProps:Ge,CustomWrapperComponent:qe,wrapperProps:et={},showKey:tt=!0,showEditTools:nt=!0,showOnEdit:rt,showOnView:ot,showCollectionWrapper:at=!0}=L,it=se(e=>null!==e.active&&S(e.active.path,he));it&&oe&&ae(!1);const lt=be(he)||0===de.level,st=i(m);if(!lt&&!it)return null;const{visibleSize:ct}=de,dt=Array.isArray(v)?"array":"object",ut="array"===dt?{open:"[",close:"]"}:{open:"{",close:"}"},pt=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=Y(Ye,"\t");return void G(t)}W(e,{objectConfirm:mt,cancel:yt})},ht=e=>{e.stopPropagation();const t=V(e);if(t&&U.collapseModifier.includes(t))return xe.current=!0,void f({collapsed:!oe,path:he,includeChildren:!0});h(he)||(xe.current=!0,H&&H({...de,fullData:Q(),collapsed:!oe,includeChildren:!1}),ae(!oe))},mt=e=>{const t=He??z(v);let n;try{n=M(t)}catch{return void Ce({code:"INVALID_JSON",message:I("ERROR_INVALID_JSON",de)},t)}De(null);const r="function"==typeof e?e:void 0;u({op:"edit",path:he,value:n,onCommit:()=>{$e(),r?.()}}).then(e=>{"error"===e?.status&&Ce(e.error,n)})};st.current=mt;const ft=he.length>0?()=>{u({op:"delete",path:he,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,v)})}:void 0,yt=()=>{s(),De(null),$e()},gt="when-collapsed"===E?oe:"when-collapsed-or-filtered"===E?oe||null!=ct:E,vt=!Ie&&nt,bt=(R||!_e)&&tt&&void 0!==me,wt=Ze&&(Ie&&rt||!Ie&&ot),Et=Object.entries(v).map(([e,t])=>["array"===dt?Number(e):e,t]);"object"===dt&&x(Et,e=>e);const Dt=xe.current?Ie?e("div",{className:"jer-collection-text-edit"+(F?"-custom":""),children:[F?t(F,{value:He??"",onChange:G,onKeyDown:e=>W(e,{objectConfirm:mt,cancel:yt})}):t(_,{textAreaRef:Ye,className:"jer-collection-text-area",name:ce,value:He??"",setValue:We,onKeyDown:pt,styles:o("input",de)}),t("div",{className:"jer-collection-input-button-row",children:t(Ae,{onOk:mt,onCancel:yt,nodeData:de,translate:I,showIconTooltips:T,editConfirmRef:J})})]}):Et.map(([e,n],a)=>{const i={key:e,value:n,path:[...he,e],level:he.length+1,index:a,size:y(n)?Object.keys(n).length:null,parentData:v,fullData:de.fullData},l=Ve(K,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:y(n)&&!l?.renderCollectionAsValue?t(Qe,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ye,customNodeData:l},e):t(Ue,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ye,showLabel:"object"===dt||R,customNodeData:l},e)},e)}):null,Ct=!!at&&oe&&!it;Ct||(xe.current=!0);const jt=()=>({...r,data:v,value:v,parentData:w,nodeData:de,setValue:e=>u({op:"edit",path:he,value:e}),handleEdit:mt,handleCancel:yt,onKeyDown:pt,isEditing:Ie,isPending:Le,setIsEditing:ye?()=>l(he,{cancelOp:$e,commitOp:e=>st.current(e)}):m,getStyles:o,canDragOnto:ye,canEdit:ye,keyboardCommon:{}}),St=wt?t(Ze,{componentProps:Ge,...jt(),children:Dt}):Dt,kt=vt&&t(Pe,{startEdit:ye?()=>{xe.current=!0,l(he,{cancelOp:$e,commitOp:e=>st.current(e)})}:void 0,handleAdd:ve?e=>{f(null),ae(!1);const t=Je(de,e);if("array"===dt){const e=$.array?0:v.length,n=$.array?{insert:!0}:{};return void u({op:"add",path:he,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}if(e in v)return Ce({code:"KEY_EXISTS",message:I("ERROR_KEY_EXISTS",de)},e),void s();const n=$.object?{insertBefore:0}:{};u({op:"add",path:he,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}:void 0,handleDelete:ge?ft:void 0,showClipboardButton:k,onCopy:O,type:dt,nodeData:de,translate:I,customButtons:r.customButtons,keyboardControls:U,handleKeyboard:W,getNewKeyOptions:Xe,editConfirmRef:J,jsonStringify:z,showIconTooltips:T,Select:B}),Ot=Se({handleCancel:yt,getStyles:o,keyValueArray:Et,handleClick:X.includes("property")?ht:e=>e.stopPropagation()}),Tt=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===he.length?0:N/2)+"em",...o("collection",de),position:"relative"},draggable:we&&!Ie&&!Ke&&!it,...ke,...Oe("above"),children:[t("div",{className:"jer-clickzone",style:{width:N/2+1+"em",zIndex:10+2*de.level},onClick:X.includes("left")?ht:void 0}),!Ie&&Te,t(Ne,{position:"above",nodeData:de}),at?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",de),position:"relative"},onClick:X.includes("header")?ht:void 0,children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(oe?" jer-rotate-90":""),style:{zIndex:11+2*de.level,transition:ie},onClick:ht,children:t(Re,{name:"collection",nodeData:de})}),bt&&t(Fe,{...Ot}),!Ie&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",de),children:ut.open})]}),!1!==E&&!Ie&&t("div",{className:"jer-collection-item-count"+(gt?" jer-visible":" jer-hidden"),style:{...o("itemCount",de),transition:ie,transitionBehavior:"allow-discrete"},children:null!=ct&&ct!==fe?I("ITEMS_FILTERED",de,{visible:ct,total:fe}):1===fe?I("ITEM_SINGLE",{...de,size:1},1):I("ITEMS_MULTIPLE",de,fe)}),t("div",{className:"jer-brackets"+(Ct?" jer-visible":" jer-hidden"),style:{...o("bracket",de),transition:ie},children:ut.close}),kt]}):tt?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",de),position:"relative"},children:[t(Fe,{...Ot}),kt]}):t(n,{}),e("div",{className:"jer-collection-inner",style:{overflowY:Ct||ne?"clip":"visible",maxHeight:it?void 0:re,...o("collectionInner",de),transition:ie},ref:te,children:[St,t("div",{className:Ie?"jer-collection-error-row-edit":"jer-collection-error-row",children:Ee&&t("span",{className:"jer-error-slug",style:o("error",de),children:Ee})}),!Ie&&at&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",de),children:ut.close})]}),t(Ne,{position:"below",nodeData:de})]});return qe?t(qe,{wrapperProps:et,...jt(),children:Tt}):Tt},Ye),Ze=({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"})]}),Ge=(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}},qe=({key:e,path:t},n="")=>!!Ge({value:e},n)||!!t.some(e=>Ge({value:e},n)),et={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel"};var tt=[],nt=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=tt.indexOf(a);-1===i&&(i=tt.push(a)-1,nt[i]={}),n=nt[i]&&nt[i][r]?nt[i][r]:nt[i][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':host,:root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff;--jer-icon-copy-color:#268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{left:-1.2em;position:absolute;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;font-family:inherit;font-size:.85em;line-height:1.25em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row-edit{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em;margin-right:.2em}.jer-confirm-buttons>button,.jer-edit-buttons>button{appearance:none;background:none;border:none;color:inherit;font:inherit;margin:0;padding:0}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #b4b4b4;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const rt=(e,t)=>JSON.stringify(e,t,2),ot={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},at={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},it=e=>{const t=i(e);e&&(t.current=e);const n=i((...e)=>t.current(...e));return e?n.current:void 0},lt=[],st=["header","left"],ct={},dt={},ut={},pt=[],ht=({data:e,setData:n,buildNodeDataFromPathRef:r,commitRef:o,rootName:l="root",onUpdate:s=m,onChange:u,onError:v,onEditEvent:w,showErrorMessages:E=!0,showClipboardButton:D=!0,onCopy:j,indent:S=2,collapse:k=3,collapseAnimationTime:O=300,showCollectionCount:T="when-collapsed-or-filtered",allowEdit:N=!0,allowDelete:x=!0,allowAdd:R=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:L,searchText:_,searchDebounceTime:V=350,sortKeys:z=!1,showArrayIndexes:Y=!0,arrayIndexStart:U=0,showStringQuotes:W=!0,showIconTooltips:$=!1,defaultValue:H=null,newKeyOptions:J,minWidth:X=250,maxWidth:Q="min(600px, 90vw)",baseFontSize:Z,stringTruncateLength:G=250,translations:q=ct,className:te,id:ne,customText:re=dt,customNodeDefinitions:oe=lt,customButtons:ae=pt,jsonParse:ie=JSON.parse,jsonStringify:se=rt,TextEditor:ce,Select:de=Ze,errorDisplayTime:pe=2500,keyboardControls:he=ut,editorRef:me,insertAtTop:fe=!1,onCollapse:ye,collapseClickZones:ve=st})=>{const{getStyles:be,cssVars:we}=ee(),{open:Ee,cancel:De,getSnapshot:Ce}=le(),je=c(()=>yt(k),[k]),Se=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]:et[r];if(void 0!==o){const e=g(o)?o:{count:o};for(const[t,n]of Object.entries(e))a=a?.replace(`{{${t}}}`,String(n))}return a})(e,t,r,n,o))(q,re),[q,re]),[ke,Oe]=p(_),Te=i(null);a(()=>{De();const e=setTimeout(()=>Oe(_),V);return()=>clearTimeout(e)},[_,V]);const Ne=K(e,[],l),xe=i(e);xe.current=e;const Re=i(n);Re.current=n;const Pe=i(Se);Pe.current=Se;const Ae=i(Ne);Ae.current=Ne;const Ie=i(s);Ie.current=s;const Ke=i(l);Ke.current=l;const Le=i(void 0),_e=d(()=>xe.current,[]),Me=it(u),ze=it(v),Fe=it(ye),Be=it(w),Ye=it(j),We=d(e=>{xe.current=e,Re.current(e)},[]),$e=d((e,t)=>{We(ft(xe.current,e,t,"update").newData)},[We]),He=d(e=>{const t=xe.current,n=Ke.current,r=Le.current,o=We,{op:a,path:i}=e;switch(a){case"edit":{const{newData:a,currentValue:l,newValue:s}=ft(t,i,e.value,"update"),c=K(t,i,n,r);return{input:{...c,newData:a,event:"edit",newValue:s},nodeData:c,isNoOp:l===s,apply:()=>o(a),revert:()=>o(ft(xe.current,i,l,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=ft(t,i,"","delete"),l=K(t,i,n,r);return{input:{...l,newData:e,event:"delete"},nodeData:l,isNoOp:!1,apply:()=>o(e),revert:()=>o(ft(xe.current,i,a,"add",{insert:!0,insertBefore:l.index}).newData)}}case"add":{const a=[...i,e.key],{newData:l,newValue:s}=ft(t,a,e.value,"add",e.options),c=K(l,a,n,r);return{input:{...c,value:void 0,size:null,parentData:A(t,i)??null,fullData:t,newData:l,event:"add",newValue:s},nodeData:c,isNoOp:!1,apply:()=>o(l),revert:()=>o(ft(xe.current,a,"","delete").newData)}}case"rename":{const a=i.slice(0,-1),l=i[i.length-1],{newKey:s}=e,c=A(t,a),d=Object.fromEntries(Object.entries(c).map(([e,t])=>e===l?[s,t]:[e,t])),{newData:u}=ft(t,a,d,"update"),p=K(t,i,n,r);return{input:{...p,newData:u,event:"rename",newKey:s},nodeData:p,isNoOp:l===s,apply:()=>o(u),revert:()=>o(ft(xe.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}=ft(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}=ft(d,g,u,"add",y),b=K(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[We]),Je=d(async(e,t)=>{const n=at[e.event],r=()=>Pe.current(ot[e.event],Ae.current);let o;try{o=await Ie.current(e,t)}catch(e){return{status:"error",error:{code:n,message:e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r()}}}if(!1===o)return{status:"error",error:{code:n,message:r()}};if(null===o)return{status:"cancel"};if(o&&"object"==typeof o){if(void 0!==o.error)return"string"==typeof o.error?{status:"error",error:{code:n,message:o.error}}:{status:"error",error:o.error};const t=void 0!==o.data,r=void 0!==o.value;if(t&&r&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),t)return{status:"override",value:o.data,path:[]};if(r&&("edit"===e.event||"add"===e.event))return{status:"override",value:o.value,path:e.path}}return{status:"commit"}},[]),Xe=c(()=>({runUpdate:s===m?void 0:Je,buildCommit:He,applyValue:$e}),[Je,He,$e,s]);o.current=Xe;const qe=c(()=>yt(N),[N]),tt=c(()=>yt(x),[x]),nt=c(()=>yt(R),[R]),ht=c(()=>yt(I),[I]),mt=c(()=>gt(L),[L]),bt=c(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,o=new Map,a=t??Ge,i=n??"",l=e=>{let t=a(e,i);if(y(e.value)){let n=0;const r=Array.isArray(e.value),a=Object.entries(e.value);for(const[o,i]of a){const a=r?Number(o):o,s={key:a,path:[...e.path,a],level:e.level+1,index:n,value:i,size:y(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(s)&&(t=!0,n++)}o.set(C(e.path),n)}return t&&r.add(C(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:o}})(Ne,mt,ke),[e,ke,mt,l]),wt=c(()=>(e=>{const t={...F};for(const n of Object.keys(F)){const r=n,o=e[r];if(void 0===o)continue;const a="clipboardModifier"===n||"collapseModifier"===n;if(null===o){t[r]=a?[]:null;continue}const i=(()=>a?f(o):"string"==typeof o?{key:o}:o)();t[r]=i}return B.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(he),[he]),Et=d((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(M(n,e[r],r)){n.preventDefault(),o();break}})(wt,t,e),[wt]),Dt=c(()=>{const e=vt(oe,"stringifyReplacer");return t=>se(t,e)},[oe,se]),Ct=c(()=>{const e=vt(oe,"parseReviver");return t=>{const n=ie(t,e);return b(n)}},[oe,ie]),jt=i(null),{setCollapseState:St}=ue(),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]);Le.current=kt;const Ot=d(e=>K(_e(),e,Ke.current,Le.current),[_e]);r.current=Ot,h(me,()=>{const e=Symbol("path-missing");return{collapse:e=>St(e),startEdit:({path:t,overrideRestrictions:n=!1})=>A(_e(),t,e)===e?"PATH_NOT_FOUND":n||qe(K(_e(),t,l,kt))?(Ee(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{jt.current&&(jt.current.click(),"editing"!==Ce().active?.phase&&De())},cancel:()=>De()}},[St,Ee,De,Ce,qe,_e,l,kt]);const Tt=Ve(oe,Ne),Nt=c(()=>({object:!0===fe||"object"===fe,array:!0===fe||"array"===fe}),[fe]),xt={mainContainerRef:Te,name:l,nodeData:Ne,getLatestData:_e,onChange:Me,onError:ze,onEditEvent:Be,showErrorMessages:E,showCollectionCount:T,collapseFilter:je,collapseAnimationTime:O,allowEditFilter:qe,allowDeleteFilter:tt,allowAddFilter:nt,allowTypeSelection:P,allowDragFilter:ht,canDragOnto:!1,showClipboardButton:D,onCopy:Ye,sortKeys:z,sort:kt,showArrayIndexes:Y,arrayIndexStart:U,showStringQuotes:W,showIconTooltips:$,indent:S,defaultValue:H,newKeyOptions:J,stringTruncateLength:G,translate:Se,customNodeDefinitions:oe,customNodeData:Tt,customButtons:ae,parentData:null,jsonParse:Ct,jsonStringify:Dt,TextEditor:ce,Select:de,errorDisplayTime:pe,handleKeyboard:Et,keyboardControls:wt,insertAtTop:Nt,onCollapse:Fe,editConfirmRef:jt,collapseClickZones:ve},Rt={...be("container",Ne),...we,minWidth:X,maxWidth:Q};return Rt.fontSize=Z??Rt.fontSize,t("div",{id:ne,ref:Te,className:`jer-editor-container ${te??""}`,style:Rt,children:t(ge,{value:bt,children:y(e)&&!Tt.renderCollectionAsValue?t(Qe,{data:e,...xt}):t(Ue,{data:e,showLabel:!0,...xt})})})};function mt(e){const n=i(void 0),r=i(void 0),o=e;return t(q,{theme:o.theme??J,children:t(fe,{onEditEvent:o.onEditEvent,onCollapse:o.onCollapse,buildNodeDataFromPathRef:n,commitRef:r,children:t(ht,{...o,buildNodeDataFromPathRef:n,commitRef:r})})})}const ft=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},i="add"!==r?A(e,t):void 0;return{currentData:e,newData:N(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},yt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,gt=e=>{if(void 0!==e)return"value"===e?Ge:"key"===e?qe:"all"===e?(e,t)=>Ge(e,t)||qe(e,t):e},vt=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?w:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}};function bt(e){const{editorRef:n,...r}=e,o=i(null);return h(n,()=>({collapse:e=>o.current?.collapse(e)}),[]),t(mt,{...r,editorRef:o,setData:m,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}export{_ as AutogrowTextArea,xe as IconSvg,mt as JsonEditor,bt as JsonViewer,De as StringDisplay,Ce as StringEdit,N as assign,Ke as collectionDataTypes,J as defaultTheme,A as extract,y as isCollection,Ge as matchNode,qe as matchNodeKey,E as splitPropertyString,Le as standardDataTypes,C as toPathString,Oe as useKeyboardListener,Ie 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,useImperativeHandle as h}from"react";const m=()=>{},f=e=>Array.isArray(e)?e:[e],y=e=>null!==e&&"object"==typeof e,g=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),v=(e,t)=>{if("string"!=typeof e)return null;const n=t.filter(t=>t instanceof Object&&t.enum&&t.values.includes(e)&&t.matchPriority);return n.sort((e,t)=>(t.matchPriority??0)-(e.matchPriority??0)),n[0]??null},b=e=>{if(e!==w){if(e&&"object"==typeof e)for(const t in e){const n=e[t],r=b(n);r!==n&&(e[t]=r)}return e}},w="__​undefined__",E=e=>e.split(/(\.|\[\d+\])/).filter(e=>"."!==e&&""!==e).map(e=>{const t=/\[(\d+)\]/.exec(e);return t?Number(t[1]):e}),D=e=>"string"==typeof e?e:"number"==typeof e?String(e):e.reduce((e,t)=>"number"==typeof t?`${e}[${t}]`:""===e?t:`${e}.${t}`,""),C=e=>1===e.length&&""===e[0]?"\0":e.map(e=>encodeURIComponent(String(e))).join("/"),j=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),S=(e,t)=>e.length>=t.length&&t.every((t,n)=>t===e[n]),k=(e,t,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${t}\nCouldn't access "${n}" in ${JSON.stringify(e)}`)},O=e=>Array.isArray(e),T=(e,t)=>e.filter((e,n)=>n!==t),N=(e,t,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:i=!1}=r,l=e,s=D(t),c={...r,remove:o,createNew:a,noError:i,fullData:l,fullPath:s},d=Array.isArray(t)?t:E(t);return O(e)&&o&&1===d.length?T(e,d[0]):x(e,d,n,c)},x=(e,t,n,r)=>{const o=g(e)?{...e}:null,a=O(e)?[...e]:null;if(0===t.length)return e;if(!o&&!a)throw new Error("Can't assign property -- invalid input object");const{createNew:i,remove:l,noError:s,fullData:c,fullPath:d}=r,u=t[0];if(a&&"string"==typeof u)return a.map(e=>x(e,t,n,r));if(1===t.length)return o&&"string"==typeof u?R(o,u,n,r)??o:a&&"number"==typeof u?(P(a,u,n,r),a):(k(c,d,u,s),e);const p=o||a||[];if(l&&2===t.length&&"number"==typeof t[1]){const e=p[u],n=t[1];return O(e)?p[u]=T(e,n):k(c,d,u,s,"Trying to remove an indexed item from an object that is not an array"),p}const h=t.slice(1);if(u in e){if(m=p[u],!O(m)&&!g(m)){if(!i)return k(c,d,u,s),p;p[u]={}}return p[u]=x(p[u],h,n,r),p}var m;if(i){const e="number"==typeof h[0]?[]:{};if(o)return p[u]=e,p[u]=x(p[u],h,n,r),p;if(a&&Array.isArray(p)){p.push(e);const t=p.length-1;return p[t]=x(p[t],h,n,r),p}}return k(c,d,u,s),p},R=(e,t,n,r)=>{const{remove:o,createNew:a,noError:i,insertAfter:l,insertBefore:s,fullData:c,fullPath:d}=r;if(void 0!==s||void 0!==l){const r=Object.entries(e);let o=1/0;return o="number"==typeof s?s:"number"==typeof l?l:r.findIndex(([e])=>e===(s??l)),void 0!==l&&o++,r.splice(o,0,[t,n]),Object.fromEntries(r)}const u=t in e;o?u?delete e[t]:k(c,d,t,i):a||u?e[t]=n:k(c,d,t,i)},P=(e,t,n,r)=>{const{noError:o,fullData:a,fullPath:i,createNew:l,insert:s}=r;s&&e.splice(t,0,n),t in e?e[t]=n:l?e.push(n):k(a,i,t,o)},A=(e,t,n)=>{const r=Array.isArray(t)?t:E(t);if(0===r.length)return e;const o=r[0];if(Array.isArray(e)&&"number"!=typeof o&&e.length>0)return e.map(e=>A(e,r,n));if("object"!=typeof e||null===e||!(o in e))return I(e,o,n);const a=e[o];return 1===r.length?a:A(a,r.slice(1),n)},I=(e,t,n)=>{if(void 0===n)throw new Error(`Unable to extract object property\nLooking for property: ${t}\nIn object: ${JSON.stringify(e)}`);return n},K=(e,t,n="",r)=>{if(0===t.length)return{key:n,path:[],level:0,index:0,value:e,size:y(e)?Object.keys(e).length:1,parentData:null,fullData:e};const o=t[t.length-1],a=A(e,t),i=A(e,t.slice(0,-1))??null;let l=0;if(Array.isArray(i))l="number"==typeof o?o:Number(o);else if(i&&"object"==typeof i){const e=Object.entries(i);r?.(e,e=>e),l=e.findIndex(([e])=>e===o)}return{key:o,path:t,level:t.length,index:l,value:a,size:y(a)?Object.keys(a).length:null,parentData:i,fullData:e}},L="undefined"!=typeof window?o:a,_=({className:n,name:r,value:o,setValue:a,onKeyDown:l,styles:s,textAreaRef:c})=>{const d=i(null);if(L(()=>{const e=d.current;d.current=null;const t=c?.current;if(!e||!t)return;const n=e.start+o.length-e.sourceLength,r=Math.max(0,Math.min(n,o.length));t.selectionStart!==r&&t.setSelectionRange(r,r)},[o,c]),"string"!=typeof o)return null;const u="\n"===o.slice(-1)?o+".":o;return e("div",{style:{display:"grid"},children:[t("textarea",{id:`${r}_textarea`,ref:c,style:{height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap",...s},rows:1,className:n,name:`${r}_textarea`,value:o,onChange:e=>{const{value:t,selectionStart:n}=e.target;d.current=null!==n&&n<t.length?{start:n,sourceLength:t.length}:null,a(t)},autoFocus:!0,onFocus:e=>{o.length<40&&e.target.select()},onKeyDown:l}),t("span",{className:n,style:{visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent",...s},children:u})]})},V=e=>e.shiftKey?"Shift":e.metaKey?"Meta":e.ctrlKey?"Control":e.altKey?"Alt":void 0,M=(e,t,n)=>{if(!t)return!1;const r=e.key,o=V(e);if(Array.isArray(t))return!!o&&t.includes(o);const{key:a,modifier:i}=t;return("stringLineBreak"!==n||"Enter"!==r||"Shift"!==o||"Enter"!==a||!i?.includes("Shift"))&&r===a&&(i===o||Array.isArray(i)&&i.includes(o))},z={key:"Enter"},F={confirm:z,cancel:{key:"Escape"},objectConfirm:{...z,modifier:["Meta","Shift","Control"]},objectLineBreak:z,stringConfirm:z,stringLineBreak:{...z,modifier:["Shift"]},numberConfirm:z,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:z,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},B=["stringConfirm","numberConfirm","booleanConfirm"],Y=(e,t)=>{const n=e.current,r=n.selectionStart??1/0,o=n.selectionEnd??1/0,a=n.value.slice(0,r)+t+n.value.slice(o);return n.value=a,n.setSelectionRange(r+1,r+1),a},U=(e,t,n="next",r,o)=>{const a=t.slice(0,t.length-1),i=t.slice(-1)[0];if(void 0===i)return null;const l=A(e,a),s=$(l);Array.isArray(l)||r(s,({key:e,value:t})=>[e,t]);const c=s.findIndex(e=>e.key===i),d=s[c+("next"===n?1:-1)];if(!d)return 0===a.length?null:U(e,a,n,r,o);let u;if(y(d.value)){if(0===Object.keys(d.value).length)return U(e,[...a,d.key],n,r,o);u=W(e,[...a,d.key],n,r)}else u=[...a,d.key];return u?o(K(e,u,"",r))?u:U(e,u,n,r,o):null},W=(e,t,n="next",r)=>{const o=A(e,t);if(!y(o))return t;const a=Array.isArray(o)?o.map((e,t)=>t):Object.keys(o);r(a,e=>[e,o]);const i="next"===n?a[0]:a[a.length-1];return W(e,[...t,i],n,r)},$=e=>Array.isArray(e)?e.map((e,t)=>({value:e,key:t})):Object.entries(e).map(([e,t])=>({key:e,value:t})),H={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2},J={displayName:"Default",icons:{add:{content:e(n,{children:[t("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),t("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"})]})},edit:{content:e(n,{children:[t("path",{d:"M7 17.013l4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z"}),t("path",{d:"M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z"})]}),svgProps:{transform:"translate(0, 0.5)"}},delete:{content:t("path",{d:"M6 19a2 2 0 002 2h8a2 2 0 002-2V7H6v12m2.46-7.12l1.41-1.41L12 12.59l2.12-2.12 1.41 1.41L13.41 14l2.12 2.12-1.41 1.41L12 15.41l-2.12 2.12-1.41-1.41L10.59 14l-2.13-2.12M15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5z"}),scale:1.04},copy:{content:e(n,{children:[t("path",{d:"M9 2 H15 A1 1 0 0 1 16 3 V5 A1 1 0 0 1 15 6 H9 A1 1 0 0 1 8 5 V3 A1 1 0 0 1 9 2 z"}),t("path",{d:"M8 4H6a2 2 0 00-2 2v14a2 2 0 002 2h12a2 2 0 002-2v-2M16 4h2a2 2 0 012 2v4M21 14H11"}),t("path",{d:"M15 10l-4 4 4 4"})]}),svgProps:H,scale:.86},ok:{content:e(n,{children:[t("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),t("path",{d:"M22 4L12 14.01l-3-3"})]}),svgProps:H,scale:.9},cancel:{content:t("path",{d:"M12 4c-4.411 0-8 3.589-8 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm-5 8c0-.832.224-1.604.584-2.295l6.711 6.711A4.943 4.943 0 0112 17c-2.757 0-5-2.243-5-5zm9.416 2.295L9.705 7.584A4.943 4.943 0 0112 7c2.757 0 5 2.243 5 5 0 .832-.224 1.604-.584 2.295z"}),svgProps:{baseProfile:"tiny"},scale:1.3},collection:{content:t("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"}),viewBox:"0 0 512 512",scale:.7}},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},property:"#292929",bracket:{color:"#002b36",fontWeight:"bold"},itemCount:{color:"#0000004d",fontStyle:"italic"},string:"#cb4b16",number:"#268bd2",boolean:"green",null:{color:"#dc322f",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"#002b36",iconEdit:"#2aa198",iconDelete:"#cb4b16",iconAdd:"#2aa198",iconCopy:"#268bd2",iconOk:"green",iconCancel:"#cb4b16"}},X={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",headerRow:"backgroundColor",valueRow:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},Q=e=>[J,...f(e)].map(e=>"styles"in e?e:{styles:e}),Z=e=>{const t={};for(const{icons:n}of Q(e))n&&Object.assign(t,n);return t},G=l({getStyles:()=>({}),icons:Z(J),cssVars:{}}),q=({theme:e=J,children:n})=>{const r=c(()=>(e=>{var t;const n=Q(e),r={},o={};for(const{fragments:e,styles:t}of n)for(const n in t){const a=n;for(const n of[].concat(t[a]))if("function"==typeof n)(o[a]??(o[a]=[])).push(n);else{const t="string"==typeof n?e?.[n]??n:n;r[a]={...r[a],..."string"==typeof t?{[X[a]??"color"]:t}:t}}}for(const e in o)r[t=e]??(r[t]={});const a={};for(const e in r){const t=e,n=r[t],i=o[t];a[t]=i?e=>i.reduce((t,n)=>({...t,...n(e)??{}}),n):n}return a})(e),[e]),o=c(()=>Z(e),[e]),a=c(()=>(e=>{const{inputHighlight:t,iconCopy:n}=e,r={};return"function"!=typeof t&&t?.backgroundColor&&(r["--jer-highlight-color"]=t.backgroundColor),"function"!=typeof n&&n?.color&&(r["--jer-icon-copy-color"]=n.color),r})(r),[r]),i=d((e,t)=>((e,t,n)=>{const r=e[t];return"function"==typeof r?r(n):r??{}})(r,e,t),[r]),l=c(()=>({getStyles:i,icons:o,cssVars:a}),[i,o,a]);return t(G.Provider,{value:l,children:n})},ee=()=>s(G),te={edit:{start:"startEdit",submit:"submitEdit",cancel:"cancelEdit",commit:"commitEdit"},add:{start:"startAdd",submit:"submitAdd",cancel:"cancelAdd",commit:"commitAdd"},rename:{start:"startRename",submit:"submitRename",cancel:"cancelRename",commit:"commitRename"},delete:{commit:"delete"},move:{commit:"move"}},ne=(e,t)=>te[e][t]??null,re=(e,t)=>null!==e&&null!==t&&e.op===t.op&&j(e.path,t.path),oe={active:null,settling:{}},ae=l(null),ie=({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=oe;const o=new Set;let a=null,i=null,l=!1,s=0;const c=e=>{r=e,o.forEach(e=>e())},d=(t,n,r)=>{e.current?.({...t,...r,event:n})},u=(n,o,l)=>{if(!e.current)return;let s;try{s=t.current?.(n)}catch{return c({...r,active:null}),a=null,void(i=null)}s&&d(s,o,l)},p=(e,t)=>{var n;a=t?.cancelOp??null,i=t?.commitOp??null,n=e,re(r.active,n)&&r.active?.phase===n?.phase||c({...r,active:n});const o=ne(e.op,"start");o&&u(e.path,o)};return{subscribe:e=>(o.add(e),()=>o.delete(e)),getSnapshot:()=>r,getServerSnapshot:()=>r,open:(e,t)=>{if("held"===r.active?.phase)return;const n={path:e,op:t?.op??"edit",phase:"editing",force:t?.force},o=r.active,l=null!==o&&!re(o,n);if(l&&i)return void i(()=>p(n,t));const s=a;if(a=null,i=null,s&&s(),l&&re(r.active,o)){const e=ne(o.op,"cancel");e&&u(o.path,e)}p(n,t)},cancel:()=>{if(l)return;if("held"===r.active?.phase)return;const e=r.active;l=!0;try{const t=a;if(a=null,i=null,t&&t(),null!==e){null!==r.active&&c({...r,active:null});const t=ne(e.op,"cancel");t&&u(e.path,t)}}finally{l=!1}},submit:e=>{const{op:t,path:o,instant:l,onCommit:p}=e,h=n.current;let m;try{m=h?.buildCommit(e)??null}catch{return re(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null,p?.(),Promise.resolve(void 0)}const f=m?.extra,y=C(o),g=++s;if(!l){const e=ne(t,"submit");e&&u(o,e)}if(!m||m.isNoOp){re(r.active,{path:o,op:t})&&c({...r,active:null}),a=null,i=null;const e=ne(t,"commit");return e&&(m?d(m.nodeData,e,f):u(o,e,f)),p?.(),Promise.resolve(void 0)}const{input:v,nodeData:b,apply:w,revert:E}=m,D=!!h?.runUpdate;let S=!1,k=!1;const O=()=>{if(S)return;S=!0,w(),a=null,i=null,re(r.active,{path:o,op:t})&&c({...r,active:null}),D&&((e,t)=>{c({...r,settling:{...r.settling,[e]:t}})})(y,g);const e=ne(t,"commit");e&&d(b,e,f),p?.()},T={hold:()=>(k=!0,c({...r,active:{path:o,op:t,phase:"held",force:r.active?.force}}),()=>O())};if(!D)return O(),Promise.resolve(void 0);const N=h.runUpdate(v,T);let x;return k||(l?x=setTimeout(O,100):O()),N.then(e=>(clearTimeout(x),((e,t,o,l,s,u,p,h,m)=>{const f=C(e);if(!p()){if("cancel"===l.status||"error"===l.status){"held"===r.active?.phase&&j(r.active.path,e)&&(c({...r,active:null}),a=null,i=null);const n=ne(t,"cancel");return n&&d(h,n),"error"===l.status&&d(h,"updateError",{operation:t,error:l.error}),l}s()}if(r.settling[f]===o){switch((e=>{if(!(e in r.settling))return;const t={...r.settling};delete t[e],c({...r,settling:t})})(f),l.status){case"cancel":u();break;case"error":u(),d(h,"updateError",{operation:t,error:l.error});break;case"override":n.current?.applyValue(l.path,l.value),d(h,"updateSuccess",{operation:t,...m});break;case"commit":d(h,"updateSuccess",{operation:t,...m})}return l}})(o,t,g,e,O,E,()=>S,b,f)))},areChildrenBeingEdited:e=>null!==r.active&&S(r.active.path,e)}})(a,r,o)),t(ae.Provider,{value:l.current,children:e})},le=()=>{const e=s(ae);if(!e)throw new Error("Missing Editing Context Provider");return e},se=e=>{const t=le();return u(t.subscribe,()=>e(t.getSnapshot()),()=>e(t.getServerSnapshot()))},ce=l(null),de=({children:e,onCollapse:n,buildNodeDataFromPathRef:r})=>{const[o,a]=p({commands:null,version:0}),l=i(n);l.current=n;const s=d(e=>{if(null===e)return void a(e=>null===e.commands?e:{commands:null,version:e.version});const t=f(e),n=t.map(e=>({...e,path:[...e.path]}));a(e=>({commands:n,version:e.version+1}));const o=l.current;o&&t.forEach(e=>{const t=r.current?.(e.path);t&&o({...t,collapsed:e.collapsed,includeChildren:e.includeChildren})})},[r]),u=c(()=>({commands:o.commands,version:o.version,setCollapseState:s}),[o.commands,o.version,s]);return t(ce.Provider,{value:u,children:e})},ue=()=>{const e=s(ce);if(!e)throw new Error("Missing Collapse Context Provider");return e},pe=(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},he=l(null),me=({children:e})=>{const[n,r]=p({path:null}),o=i(!1),a=c(()=>({dragSource:n,setDragSource:r,armed:o}),[n]);return t(he.Provider,{value:a,children:e})},fe=({children:e,onEditEvent:n,onCollapse:r,buildNodeDataFromPathRef:o,commitRef:a})=>t(ie,{onEditEvent:n,buildNodeDataFromPathRef:o,commitRef:a,children:t(de,{onCollapse:r,buildNodeDataFromPathRef:o,children:t(me,{children:e})})}),ye=l(void 0),ge=({value:e,children:n})=>t(ye.Provider,{value:e,children:n}),ve=()=>{const e=s(ye);if(void 0===e)throw new Error("Missing FilterStateProvider");return e},be=e=>{const t=ve();return null===t||t.visiblePaths.has(C(e))},we=e=>{const t=ve();return null===t?null:t.visibleChildCounts.get(C(e))??null},Ee="**INVALID_FUNCTION**",De=({nodeData:r,showStringQuotes:o=!0,stringTruncateLength:a=200,pathString:i,canEdit:l,setIsEditing:s,styles:c,translate:d,value:u,TextWrapper:h=({children:e})=>e})=>{const m=u??r.value,[f,y]=p(!1),g=o?'"':"",v=m.length>a,b=()=>{l?s(!0):y(!f)};return e("div",{id:`${i}_display`,onDoubleClick:b,onClick:e=>{(e.getModifierState("Control")||e.getModifierState("Meta"))&&b()},className:"jer-value-string",style:c,children:[g,v?e(n,f?{children:[t(h,{children:e("span",{children:[m,g]})}),e("span",{className:"jer-string-expansion jer-show-less",onClick:()=>y(!1),children:[" ",d("SHOW_LESS",r)]})]}:{children:[e(h,{children:[t("span",{children:m.slice(0,a-2).trimEnd()})," "]}),t("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>y(!0),children:"..."}),g]}):t(h,{children:`${m}${g}`})]})},Ce=({styles:e,pathString:n,value:r,setValue:o,handleEdit:a,handleKeyboard:l,keyboardCommon:s})=>{const c=i(null);return t(_,{className:"jer-input-text",textAreaRef:c,name:n,value:r,setValue:o,onKeyDown:e=>{l(e,{stringConfirm:a,stringLineBreak:()=>{const e=Y(c,"\n");o(e)},...s})},styles:e})},je=({isEditing:e,path:n,enumType:r,...o})=>{const{getStyles:a}=ee(),i=C(n),{value:l,setValue:s,nodeData:c,handleEdit:d,handleKeyboard:u,keyboardCommon:p,Select:h}=o;return e&&r?t(h,{name:`${i}-value-select`,value:l,onChange:s,options:r.values,autoFocus:!0,onKeyDown:e=>u(e,{stringConfirm:d,...p})}):e?t(Ce,{styles:a("input",c),pathString:i,...o,setValue:o.setValue}):t(De,{pathString:i,styles:a("string",c),...o})},Se=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ee();return r?t("input",{className:"jer-input-number",type:"text",name:C(o),value:e,onChange:e=>n(e.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:e=>setTimeout(()=>e.target.select(),10),onKeyDown:t=>s(t,{numberConfirm:i,numberUp:()=>n(Number(e)+1),numberDown:()=>n(Number(e)-1),...c}),style:{width:String(e).length/1.5+2+"em",...d("input",l)}}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-number",style:d("number",l),children:e})},ke=({value:e,setValue:n,isEditing:r,path:o,setIsEditing:a,handleEdit:i,nodeData:l,handleKeyboard:s,keyboardCommon:c})=>{const{getStyles:d}=ee();return"boolean"!=typeof e?null:r?t("input",{className:"jer-input-boolean",type:"checkbox",name:C(o),checked:e,onChange:()=>n(!e),onKeyDown:t=>{" "===t.key&&t.preventDefault(),s(t,{booleanConfirm:i,booleanToggle:()=>n(!e),...c})},autoFocus:!0}):t("span",{onDoubleClick:()=>a(!0),className:"jer-value-boolean",style:d("boolean",l),children:String(e)})},Oe=(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])},Te=({value:e,isEditing:n,setIsEditing:r,handleEdit:o,nodeData:a,handleKeyboard:i,keyboardCommon:l})=>{const{getStyles:s}=ee();return Oe(n,e=>i(e,{confirm:o,...l})),t("div",{onDoubleClick:()=>r(!0),className:"jer-value-null",style:s("null",a),children:String(e)})},Ne=({value:e})=>{let n="Error!";switch(typeof e){case"string":e===Ee&&(n="Function");break;case"undefined":n="Undefined";break;case"symbol":n="Symbol"}return t("span",{className:"jer-value-invalid",children:n})},xe=({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})},Re=({name:e,nodeData:n})=>{const{getStyles:r,icons:o}=ee(),a=o[e],i=`icon${e[0].toUpperCase()}${e.slice(1)}`;return t(xe,{viewBox:a.viewBox,...a.svgProps,scale:a.scale,className:"collection"===e?void 0:"jer-icon",style:r(i,n),children:a.content})},Pe=({startEdit:r,handleDelete:o,handleAdd:a,showClipboardButton:i,onCopy:l,type:s,customButtons:c,nodeData:d,translate:u,keyboardControls:h,handleKeyboard:m,editConfirmRef:f,getNewKeyOptions:y,jsonStringify:g,showIconTooltips:v,Select:b})=>{const{getStyles:w}=ee(),{open:E,cancel:C}=le(),S=u("KEY_NEW",d),[k,O]=p(S),[T,N]=p(!1),{path:x,value:R}=d,P=se(e=>{const t=e.active;return null!==t&&"add"===t.op&&j(t.path,x)}),I=Array.isArray(T);L(()=>{if(!P)return N(!1),void O(S);const e=Object.keys(A(d.fullData,x)),t=y?y(d)?.filter(t=>!e.includes(t)):null;t&&O(""),N(t??!0)},[P]);const K=()=>{a&&(I&&!k||a("array"===s?"":k))};return e("div",{className:"jer-edit-buttons",style:{opacity:P?1:void 0},onClick:e=>e.stopPropagation(),children:[i&&t("button",{type:"button",tabIndex:-1,onClick:e=>{e.stopPropagation();let t,n,r="value",o="",a=null;if(i){const i=V(e);if(i&&h.clipboardModifier.includes(i)?(t=D(x),o=t,r="path"):(t=R,o="object"==typeof t?g(R):String(t)),!navigator.clipboard)return void l?.({...d,success:!1,stringValue:o,type:r,error:{code:"CLIPBOARD_ERROR",message:"Can't access clipboard API"}});navigator.clipboard?.writeText(o).then(()=>n=!0).catch(e=>{n=!1,a=e.message}).finally(()=>{l?.({...d,success:n,stringValue:o,type:r,error:n?void 0:{code:"CLIPBOARD_ERROR",message:a??"Copy failed"}})})}},className:"jer-copy-pulse","aria-label":u("TOOLTIP_COPY",d),title:v?u("TOOLTIP_COPY",d):"",children:t(Re,{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(Re,{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(Re,{name:"delete",nodeData:d})}),a&&t("button",{type:"button",tabIndex:-1,onClick:()=>{"object"===s?E(x,{op:"add"}):a("")},"aria-label":u("TOOLTIP_ADD",d),title:v?u("TOOLTIP_ADD",d):"",children:t(Re,{name:"add",nodeData:d})}),c?.map(({Element:e,onClick:n},r)=>t("div",{onClick:e=>n&&n(d,e),children:t(e,{nodeData:d})},r)),P&&a&&"object"===s&&e(n,{children:[I?t(b,{name:"new-key-select",onChange:a,defaultValue:"",autoFocus:!0,onKeyDown:e=>m(e,{cancel:()=>C()}),placeholder:T.length>0?u("KEY_SELECT",d):u("NO_KEY_OPTIONS",d),options:T}):t("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:k,onChange:e=>O(e.target.value),autoFocus:!0,onFocus:e=>e.target.select(),onKeyDown:e=>{m(e,{stringConfirm:()=>K(),cancel:()=>C()})},style:w("input",d)}),t(Ae,{onOk:()=>K(),onCancel:()=>C(),nodeData:d,translate:u,showIconTooltips:v,editConfirmRef:f,hideOk:I})]})]})},Ae=({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(Re,{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(Re,{name:"cancel",nodeData:o})})]}),Ie=["string","number","boolean","null"],Ke=["object","array"],Le=[...Ie,...Ke],_e=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}},Ve=(e=[],t)=>{const n=e.find(({condition:e})=>e(t));return n?_e(n):{}},Me=({props:e,collapsed:t})=>{const{nodeData:n,parentData:r,onError:o,getLatestData:a,showErrorMessages:l,allowEditFilter:s,allowDeleteFilter:c,allowAddFilter:u,allowDragFilter:h,translate:m,errorDisplayTime:f,sort:y,arrayIndexStart:g,handleKeyboard:v,customNodeData:b}=e,{submit:w}=le(),[E,D]=p(null),S={...n,collapsed:t,visibleSize:we(n.path)},{path:k,key:O,size:T}=S,N=C(k),x=se(e=>{const t=e.active;return null!==t&&"edit"===t.op&&j(t.path,k)}),R=se(e=>{const t=e.active;return null!==t&&"rename"===t.op&&j(t.path,k)}),P=se(e=>N in e.settling),A=s(S),I=c(S),K=u(S),L=h(S)&&I,_=e=>{l&&(D(e),setTimeout(()=>D(null),f)),console.warn("Error",e)},V=i(S);V.current=S;const M=d((e,t)=>{_(e.message),o&&o({...V.current,fullData:a(),error:e,errorValue:t})},[o,l,a,f]),z=ve(),F=d(e=>(null===z||z.visiblePaths.has(C(e.path)))&&s(e),[z,s]),B=e=>U(a(),k,e,y,F),Y=(e,t)=>{r&&(O!==e&&Object.keys(r).includes(e)?M({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",S)},e):w({op:"rename",path:k,newKey:e,onCommit:t}).then(t=>{"error"===t?.status&&M(t.error,e)}))},W="number"==typeof k.slice(-1)[0],$=null!==r&&A&&K&&I&&!W,H={isEditing:x,isEditingKey:R,isPending:P,isArray:W,canEditKey:$},J=""===O&&k.length>0?m("EMPTY_STRING",S):null;return{pathString:N,nodeData:S,path:k,name:O,size:T,canEdit:A,canDelete:I,canAdd:K,canDrag:L,error:E,showError:_,onError:M,setError:D,handleEditKey:Y,derivedValues:H,emptyStringKey:J,getNextOrPreviousAtPath:B,buildKeyDisplayProps:({handleCancel:e,getStyles:t,keyValueArray:n,handleClick:r})=>({canEditKey:$,isEditingKey:R,pathString:N,path:k,name:O,arrayIndexStart:g,handleKeyboard:v,handleEditKey:Y,handleCancel:e,styles:t("property",S),getNextOrPrevious:B,emptyStringKey:J,nodeData:S,customNodeData:b,getStyles:t,...void 0!==n?{keyValueArray:n}:{},...void 0!==r?{handleClick:r}:{}})}},ze=({canDrag:e,canDragOnto:n,path:r,nodeData:o,onError:a,translate:i})=>{const{getStyles:l}=ee(),{dragSource:d,setDragSource:u,armed:h}=(()=>{const e=s(he);if(!e)throw new Error("Missing DragSource Context Provider");return e})(),m=le(),[f,y]=p(!1),g=c(()=>e?{onMouseDown:e=>{0===e.button&&null===m.getSnapshot().active&&(h.current=!0)},onMouseUp:()=>{h.current=!1},onDragStart:e=>{if(!h.current||null!==m.getSnapshot().active)return e.preventDefault(),void e.stopPropagation();h.current=!1,e.stopPropagation(),u({path:r})},onDragEnd:e=>{h.current=!1,e.stopPropagation(),u({path:null})}}:{},[e,r]),v=c(()=>e=>n?{onDragOver:e=>{e.stopPropagation(),e.preventDefault()},onDrop:t=>{t.stopPropagation(),w(e),u({path:null}),y(!1)},onDragEnter:t=>{t.stopPropagation(),null!==d.path&&S(r,d.path)||y(e)},onDragExit:e=>{e.stopPropagation(),y(!1)}}:{},[d,n,r]),b=c(()=>n&&null!==d.path?t("div",{className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:r.length},...v("below")}):null,[d,n,r.length]),w=e=>{if(null===d.path)return;if(S(r,d.path))return;const t=d.path.slice(-1)[0],n=d.path.slice(0,-1),l=r.slice(0,-1),{parentData:s}=o;"string"==typeof t&&s&&!Array.isArray(s)&&Object.keys(s).includes(t)&&t in s&&!j(n,l)?a({code:"KEY_EXISTS",message:i("ERROR_KEY_EXISTS",o)},t):m.submit({op:"move",path:d.path,to:{path:r,position:e},instant:!0})};return{dragSourceProps:g,getDropTargetProps:v,BottomDropTarget:b,DropTargetPadding:({position:e,nodeData:n})=>f===e?t("div",{className:"jer-drag-n-drop-padding",style:l("dropZone",n)}):null,handleDrop:w}},Fe=({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}=le(),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"}})},Be=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||!j(n.path,r.path))return!1;var n,r;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(const n of o)if(!Be.has(n)&&!Object.is(e[n],t[n]))return!1;return!0},Ue=r.memo(n=>{const{data:r,parentData:o,onChange:l,showClipboardButton:s,onCopy:u,canDragOnto:h,allowTypeSelection:f,showLabel:y,stringTruncateLength:g,showStringQuotes:b,indent:w,translate:E,customNodeDefinitions:D,customNodeData:C,Select:S,handleKeyboard:k,keyboardControls:O,editConfirmRef:T,jsonStringify:N,showIconTooltips:x,getLatestData:R}=n,{getStyles:P}=ee(),{open:A,cancel:I,submit:K,getSnapshot:L}=le(),{setCollapseState:_}=ue(),[V,M]=p("function"==typeof r?Ee:r),{nodeData:z,path:F,name:B,canEdit:Y,canDelete:U,canDrag:W,error:$,onError:H,setError:J,derivedValues:X,getNextOrPreviousAtPath:Q,buildKeyDisplayProps:Z}=Me({props:n}),{dragSourceProps:G,getDropTargetProps:q,BottomDropTarget:te,DropTargetPadding:ne}=ze({canDrag:W,canDragOnto:h,path:F,nodeData:z,onError:H,translate:E}),[re,oe]=p($e(r,C)),ae=i(V);ae.current=V;const ie=i(z);ie.current=z;const se=d(e=>{if(!l)return void M(e);const t=l({...ie.current,value:ae.current,fullData:R(),newValue:e});M(t)},[l,R]),ce=()=>{M("function"==typeof r?Ee:r),oe($e(r,C)),he(v(r,de))};a(()=>{X.isEditing||ce()},[r]);const de=c(()=>{const e=[...Le,...D.filter(({showInTypeSelector:e=!1,name:t})=>e&&!!t).map(({name:e})=>e)];if("boolean"==typeof f)return f?e:[];if(Array.isArray(f))return f;const t=f(z);return"boolean"==typeof t?t?e:[]:t},[z,f,D]),[pe,he]=p(v(V,de)),{isEditing:me,isPending:fe}=X,ye=be(F),ge=i(m);if(!ye)return null;const ve=me&&re!==$e(r,C),we=ve?D.find(e=>e.name===re&&We(e)):void 0,De=we?_e(we):C,{CustomComponent:Ce,componentProps:je,showKey:Se=!0,showEditTools:ke=!0,showOnEdit:Oe,showOnView:Te,passOriginalNode:Ne}=De,xe=Ce&&(void 0!==we||!ve&&(me&&Oe||!me&&Te)),Re=e=>{_(null);const t=ve&&!we?void 0:De,n=t?.toStandardType?t.toStandardType(V):V,r=D.find(t=>t.name===e);if(r){if(We(r)){let t=r.defaultValue;if(r.fromStandardType)try{t=r.fromStandardType(n,z,r.componentProps)}catch{}return M(t),oe(e),void he(null)}return K({op:"edit",path:F,value:r.defaultValue}).then(Ie(r.defaultValue)),void _({path:F,collapsed:!1,includeChildren:!1})}const o=de.find(t=>t instanceof Object&&t.enum===e);if(o)return"string"==typeof V&&o.values.includes(V)||M(o.values[0]),he(o),void oe(e);const a=Xe(n,e,E("DEFAULT_NEW_KEY",z));if("object"===e||"array"===e||"null"===e)return K({op:"edit",path:F,value:a}).then(Ie(a)),void("null"!==e&&_({path:F,collapsed:!1,includeChildren:!1}));M(a),oe(e),he(null)},Ie=e=>t=>{if("error"===t?.status&&H(t.error,e),"error"===t?.status||"cancel"===t?.status){const e=L().active;"editing"===e?.phase&&j(e.path,F)||ce()}},Ke=(e,t)=>{const n=void 0!==e&&!(e=>e&&"object"==typeof e&&"type"in e&&"target"in e&&"preventDefault"in e&&"function"==typeof e.preventDefault)(e);let r;if(n)r=e;else if(xe&&De.fromStandardType)try{r=De.fromStandardType(V,z,De.componentProps)}catch(e){return void H({code:"UPDATE_ERROR",message:e instanceof Error?e.message:String(e)},V)}else r="number"===re?Je(V):V;J(null),we&&_({path:F,collapsed:!1,includeChildren:!1}),K({op:"edit",path:F,value:r,onCommit:t}).then(Ie(r))};ge.current=Ke;const Ve=()=>{J(null),ce(),I()},{isEditingKey:Be}=X,Ye=!!$,Ue=me&&de.length>1,Qe=("invalid"!==re||Ce)&&!$&&ke,Ze=y&&Se,Ge=()=>A(F,{cancelOp:ce,commitOp:e=>ge.current(void 0,e)}),qe=Y?Ge:m,et=e=>()=>{const t=Q(e);t&&Ke(void 0,()=>A(t))},tt={value:V,parentData:o,setValue:se,isEditing:me,canEdit:Y,setIsEditing:qe,handleEdit:Ke,handleCancel:Ve,path:F,stringTruncateLength:g,showStringQuotes:b,nodeData:z,enumType:pe,translate:E,handleKeyboard:k,keyboardCommon:{cancel:Ve,tabForward:et("next"),tabBack:et("prev")},Select:S},nt={...Z({handleCancel:Ve,getStyles:P}),customNodeData:De},rt=xe?t(Ce,{...n,value:V,componentProps:je,setValue:se,handleEdit:Ke,handleCancel:Ve,onKeyDown:e=>k(e,{stringConfirm:Ke,cancel:Ve}),isEditing:me,isPending:fe,setIsEditing:qe,getStyles:P,originalNode:Ne?He(r,re,tt):void 0,originalNodeKey:Ne?t(Fe,{...nt,customNodeData:void 0}):void 0,canEdit:Y,keyboardCommon:tt.keyboardCommon}):He(r,re,tt);return e("div",{className:"jer-component jer-value-component",style:{marginLeft:null!==o?w/2+"em":0,position:"relative"},draggable:W&&!me&&!Be,...G,...q("above"),children:[te,t(ne,{position:"above",nodeData:z}),e("div",{className:"jer-value-main-row",style:{...P("valueRow",z),flexWrap:B.length>10?"wrap":"nowrap"},children:[Ze&&t(Fe,{...nt}),e("div",{className:"jer-value-and-buttons",children:[t("div",{className:"jer-input-component",children:rt}),me?t(Ae,{onOk:Ke,onCancel:Ve,nodeData:z,translate:E,showIconTooltips:x,editConfirmRef:T}):Qe&&t(Pe,{startEdit:Y?Ge:void 0,handleDelete:U?()=>{K({op:"delete",path:F,instant:!0}).then(e=>{"error"===e?.status&&H(e.error,V)})}:void 0,showClipboardButton:s,onCopy:u,translate:E,customButtons:n.customButtons,nodeData:z,handleKeyboard:k,keyboardControls:O,editConfirmRef:T,jsonStringify:N,showIconTooltips:x,Select:S}),Ue&&t(S,{name:`${B}-type-select`,value:pe?pe.enum:re,onChange:e=>Re(e),options:de.map(e=>e instanceof Object&&"enum"in e?e.enum:e)}),Ye&&t("span",{className:"jer-error-slug",style:P("error",z),children:$})]})]}),t(ne,{position:"below",nodeData:z})]})},Ye),We=e=>!!e.editOnTypeSwitch&&!!e.component&&!!e.showOnEdit,$e=(e,t)=>t?.CustomComponent&&t?.name&&t.showInTypeSelector?t.name:"string"==typeof e?"string":"number"==typeof e?"number":"boolean"==typeof e?"boolean":null===e?"null":"invalid",He=(e,n,r)=>{const o=Ie.includes(n)?n:"function"==typeof e?"invalid":$e(r.value),{value:a}=r;switch(o){case"string":return t(je,{...r,value:a});case"number":return t(Se,{...r,value:a});case"boolean":return t(ke,{...r,value:a});case"null":return t(Te,{...r});default:return t(Ne,{...r})}},Je=e=>{if("symbol"==typeof e)return 0;const t=Number(e);return isNaN(t)?0:t},Xe=(e,t,n)=>{switch(t){case"string":return null==e?"":String(e);case"number":return Je(e);case"boolean":return!!e;case"null":return null;case"object":return{[n]:e};case"array":return[e];default:return String(e)}},Qe=r.memo(r=>{const{getStyles:o}=ee(),{open:l,cancel:s,submit:u,areChildrenBeingEdited:h}=le(),{setCollapseState:f}=ue(),{mainContainerRef:g,data:v,nodeData:b,parentData:w,showCollectionCount:E,canDragOnto:D,collapseFilter:C,collapseAnimationTime:j,showClipboardButton:k,onCopy:O,showIconTooltips:T,indent:N,sort:x,showArrayIndexes:R,defaultValue:P,newKeyOptions:A,translate:I,customNodeDefinitions:K,customNodeData:L,jsonParse:M,jsonStringify:z,TextEditor:F,Select:B,keyboardControls:U,handleKeyboard:W,insertAtTop:$,onCollapse:H,editConfirmRef:J,collapseClickZones:X,getLatestData:Q}=r,[Z,G]=p(null),q=C(b),{contentRef:te,isAnimating:ne,maxHeight:re,collapsed:oe,animateCollapse:ae,cssTransitionValue:ie}=((e,t,n,r,o)=>{const[a,l]=p(n?0:void 0),[s,c]=p(n),u=i(!1),h=i(null),m=i(0),f=i(0),y=t/1e3+"s",g=d(n=>{if(s!==n){switch(window.clearTimeout(f.current),u.current=!0,n){case!0:{const e=h.current?.offsetHeight??0;m.current=e,l(e),setTimeout(()=>{l(0)},5);break}case!1:l(m.current||((e,t,n,r)=>{if(!t.current)return 0;const o=parseInt(getComputedStyle(n.current).getPropertyValue("line-height"))||16,a=(t.current?.offsetWidth??0)/(.5*o),i=r(e).replace(/\\n/g,"\n").split("\n").map(e=>Math.ceil(e.length/a)).reduce((e,t)=>e+t,0)*o;return Math.min(i+30,window.innerHeight-50)})(e,h,r,o))}c(!s),f.current=window.setTimeout(()=>{u.current=!1,n||l(void 0)},t)}},[t,s,e,r,o]);return{contentRef:h,isAnimating:u.current,animateCollapse:g,maxHeight:a,collapsed:s,cssTransitionValue:y}})(v,j,q,g,z),{pathString:ce,nodeData:de,path:he,name:me,size:fe,canEdit:ye,canDelete:ge,canAdd:ve,canDrag:we,error:Ee,setError:De,onError:Ce,derivedValues:je,buildKeyDisplayProps:Se}=Me({props:r,collapsed:oe}),{dragSourceProps:ke,getDropTargetProps:Oe,BottomDropTarget:Te,DropTargetPadding:Ne}=ze({canDrag:we,canDragOnto:D,path:he,nodeData:de,onError:Ce,translate:I}),xe=i(!q),{isEditing:Ie,isEditingKey:Ke,isPending:Le,isArray:_e}=je,Be=(e=>{const t=i(e),n=!Object.is(t.current,e);return a(()=>{t.current=e}),n})(C);a(()=>{const e=C(de)&&!Ie;xe.current=!e,ae(e),Be&&f(null)},[C]),((e,t,n)=>{const{commands:r,version:o}=ue(),l=i(0);a(()=>{if(o===l.current)return;if(l.current=o,!r)return;let a;for(const t of r)pe(e,t)&&(a=t);a&&(a.collapsed||(t.current=!0),n(a.collapsed))},[o,r])})(he,xe,ae);const Ye=i(null),We=d(e=>G(t=>"function"==typeof e?e(t??z(v)):e),[v,z]),$e=d(()=>G(null),[]),He=c(()=>Ie?Z??z(v):null,[Ie,Z,v,z]),Je=d((e,t)=>{if("function"!=typeof P)return P;const n=P(e,t);return void 0!==n?n:null},[P]),Xe=d(e=>A?"function"!=typeof A?A:A(e):null,[A]),{CustomComponent:Ze,componentProps:Ge,CustomWrapperComponent:qe,wrapperProps:et={},showKey:tt=!0,showEditTools:nt=!0,showOnEdit:rt,showOnView:ot,showCollectionWrapper:at=!0}=L,it=se(e=>null!==e.active&&S(e.active.path,he));it&&oe&&ae(!1);const lt=be(he)||0===de.level,st=i(m);if(!lt&&!it)return null;const{visibleSize:ct}=de,dt=Array.isArray(v)?"array":"object",ut="array"===dt?{open:"[",close:"]"}:{open:"{",close:"}"},pt=e=>{if("Tab"===e.key&&!e.getModifierState("Shift")){e.preventDefault();const t=Y(Ye,"\t");return void G(t)}W(e,{objectConfirm:mt,cancel:yt})},ht=e=>{e.stopPropagation();const t=V(e);if(t&&U.collapseModifier.includes(t))return xe.current=!0,void f({collapsed:!oe,path:he,includeChildren:!0});h(he)||(xe.current=!0,H&&H({...de,fullData:Q(),collapsed:!oe,includeChildren:!1}),ae(!oe))},mt=e=>{const t=He??z(v);let n;try{n=M(t)}catch{return void Ce({code:"INVALID_JSON",message:I("ERROR_INVALID_JSON",de)},t)}De(null);const r="function"==typeof e?e:void 0;u({op:"edit",path:he,value:n,onCommit:()=>{$e(),r?.()}}).then(e=>{"error"===e?.status&&Ce(e.error,n)})};st.current=mt;const ft=he.length>0?()=>{u({op:"delete",path:he,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,v)})}:void 0,yt=()=>{s(),De(null),$e()},gt="when-collapsed"===E?oe:"when-collapsed-or-filtered"===E?oe||null!=ct:E,vt=!Ie&&nt,bt=(R||!_e)&&tt&&void 0!==me,wt=Ze&&(Ie&&rt||!Ie&&ot),Et=Object.entries(v).map(([e,t])=>["array"===dt?Number(e):e,t]);"object"===dt&&x(Et,e=>e);const Dt=!Ie||!!Ze&&rt,Ct=xe.current?Dt?Et.map(([e,n],a)=>{const i={key:e,value:n,path:[...he,e],level:he.length+1,index:a,size:y(n)?Object.keys(n).length:null,parentData:v,fullData:de.fullData},l=Ve(K,i);return t("div",{className:"jer-collection-element",style:o("collectionElement",i),children:y(n)&&!l?.renderCollectionAsValue?t(Qe,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ye,customNodeData:l},e):t(Ue,{...r,data:n,parentData:v,nodeData:i,canDragOnto:ye,showLabel:"object"===dt||R,customNodeData:l},e)},e)}):e("div",{className:"jer-collection-text-edit"+(F?"-custom":""),children:[F?t(F,{value:He??"",onChange:G,onKeyDown:e=>W(e,{objectConfirm:mt,cancel:yt})}):t(_,{textAreaRef:Ye,className:"jer-collection-text-area",name:ce,value:He??"",setValue:We,onKeyDown:pt,styles:o("input",de)}),t("div",{className:"jer-collection-input-button-row",children:t(Ae,{onOk:mt,onCancel:yt,nodeData:de,translate:I,showIconTooltips:T,editConfirmRef:J})})]}):null,jt=!!at&&oe&&!it;jt||(xe.current=!0);const St=()=>({...r,data:v,value:v,parentData:w,nodeData:de,setValue:e=>u({op:"edit",path:he,value:e}),handleEdit:mt,handleCancel:yt,onKeyDown:pt,isEditing:Ie,isPending:Le,setIsEditing:ye?()=>l(he,{cancelOp:$e,commitOp:e=>st.current(e)}):m,getStyles:o,canDragOnto:ye,canEdit:ye,keyboardCommon:{}}),kt=wt?t(Ze,{componentProps:Ge,...St(),children:Ct}):Ct,Ot=vt&&t(Pe,{startEdit:ye?()=>{xe.current=!0,l(he,{cancelOp:$e,commitOp:e=>st.current(e)})}:void 0,handleAdd:ve?e=>{f(null),ae(!1);const t=Je(de,e);if("array"===dt){const e=$.array?0:v.length,n=$.array?{insert:!0}:{};return void u({op:"add",path:he,key:e,value:t,options:n,instant:!0}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}if(e in v)return Ce({code:"KEY_EXISTS",message:I("ERROR_KEY_EXISTS",de)},e),void s();const n=$.object?{insertBefore:0}:{};u({op:"add",path:he,key:e,value:t,options:n}).then(e=>{"error"===e?.status&&Ce(e.error,t)})}:void 0,handleDelete:ge?ft:void 0,showClipboardButton:k,onCopy:O,type:dt,nodeData:de,translate:I,customButtons:r.customButtons,keyboardControls:U,handleKeyboard:W,getNewKeyOptions:Xe,editConfirmRef:J,jsonStringify:z,showIconTooltips:T,Select:B}),Tt=Se({handleCancel:yt,getStyles:o,keyValueArray:Et,handleClick:X.includes("property")?ht:e=>e.stopPropagation()}),Nt=e("div",{className:"jer-component jer-collection-component",style:{marginLeft:(0===he.length?0:N/2)+"em",...o("collection",de),position:"relative"},draggable:we&&!Ie&&!Ke&&!it,...ke,...Oe("above"),children:[t("div",{className:"jer-clickzone",style:{width:N/2+1+"em",zIndex:10+2*de.level},onClick:X.includes("left")?ht:void 0}),!Ie&&Te,t(Ne,{position:"above",nodeData:de}),at?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",de),position:"relative"},onClick:X.includes("header")?ht:void 0,children:[e("div",{className:"jer-collection-name",children:[t("div",{className:"jer-collapse-icon jer-accordion-icon"+(oe?" jer-rotate-90":""),style:{zIndex:11+2*de.level,transition:ie},onClick:ht,children:t(Re,{name:"collection",nodeData:de})}),bt&&t(Fe,{...Tt}),!Ie&&t("span",{className:"jer-brackets jer-bracket-open",style:o("bracket",de),children:ut.open})]}),!1!==E&&!Ie&&t("div",{className:"jer-collection-item-count"+(gt?" jer-visible":" jer-hidden"),style:{...o("itemCount",de),transition:ie,transitionBehavior:"allow-discrete"},children:null!=ct&&ct!==fe?I("ITEMS_FILTERED",de,{visible:ct,total:fe}):1===fe?I("ITEM_SINGLE",{...de,size:1},1):I("ITEMS_MULTIPLE",de,fe)}),t("div",{className:"jer-brackets"+(jt?" jer-visible":" jer-hidden"),style:{...o("bracket",de),transition:ie},children:ut.close}),Ot]}):tt?e("div",{className:"jer-collection-header-row",style:{...o("headerRow",de),position:"relative"},children:[t(Fe,{...Tt}),Ot]}):t(n,{}),e("div",{className:"jer-collection-inner",style:{overflowY:jt||ne?"clip":"visible",maxHeight:it?void 0:re,...o("collectionInner",de),transition:ie},ref:te,children:[kt,t("div",{className:Ie?"jer-collection-error-row-edit":"jer-collection-error-row",children:Ee&&t("span",{className:"jer-error-slug",style:o("error",de),children:Ee})}),!Ie&&at&&t("div",{className:"jer-brackets jer-bracket-outside",style:o("bracket",de),children:ut.close})]}),t(Ne,{position:"below",nodeData:de})]});return qe?t(qe,{wrapperProps:et,...St(),children:Nt}):Nt},Ye),Ze=({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"})]}),Ge=(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}},qe=({key:e,path:t},n="")=>!!Ge({value:e},n)||!!t.some(e=>Ge({value:e},n)),et={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} items",ITEMS_FILTERED:"{{visible}} of {{total}} items",KEY_NEW:"Enter new key",KEY_SELECT:"Select key",NO_KEY_OPTIONS:"No key options",ERROR_KEY_EXISTS:"Key already exists",ERROR_INVALID_JSON:"Invalid JSON",ERROR_UPDATE:"Update unsuccessful",ERROR_DELETE:"Delete unsuccessful",ERROR_ADD:"Adding node unsuccessful",ERROR_RENAME:"Rename unsuccessful",ERROR_MOVE:"Move unsuccessful",DEFAULT_NEW_KEY:"key",SHOW_LESS:"(Show less)",EMPTY_STRING:"<empty string>",TOOLTIP_COPY:"Copy to clipboard",TOOLTIP_EDIT:"Edit",TOOLTIP_DELETE:"Delete",TOOLTIP_ADD:"Add",TOOLTIP_OK:"OK",TOOLTIP_CANCEL:"Cancel"};var tt=[],nt=[];!function(e,t){if(e&&"undefined"!=typeof document){var n,r=!0===t.prepend?"prepend":"append",o=!0===t.singleTag,a="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(o){var i=tt.indexOf(a);-1===i&&(i=tt.push(a)-1,nt[i]={}),n=nt[i]&&nt[i][r]?nt[i][r]:nt[i][r]=l()}else n=l();65279===e.charCodeAt(0)&&(e=e.substring(1)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(document.createTextNode(e))}function l(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var n=Object.keys(t.attributes),o=0;o<n.length;o++)e.setAttribute(n[o],t.attributes[n[o]]);var i="prepend"===r?"afterbegin":"beforeend";return a.insertAdjacentElement(i,e),e}}(':host,:root{--jer-select-border:#b6b6b6;--jer-select-focus:#777;--jer-select-arrow:#777;--jer-form-border:1px solid #ededf0;--jer-form-border-focus:1px solid #e2e2e2;--jer-highlight-color:#b3d8ff;--jer-icon-copy-color:#268bd2}.jer-visible{opacity:1}.jer-hidden{opacity:0}.jer-select select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:none;color:#000;cursor:inherit;font-family:inherit;font-size:.8em;line-height:inherit;margin:0;outline:none;padding:0 1em 0 0;z-index:1}select::-ms-expand{display:none}.jer-select{align-items:center;background-color:#fff;background-image:linear-gradient(0deg,#f9f9f9,#fff 33%);border:1px solid var(--jer-select-border);border-radius:.25em;cursor:pointer;display:grid;grid-template-areas:"select";line-height:1.1;max-width:15ch;min-width:12ch;padding:.25em .5em;position:relative}.jer-select select,.jer-select:after{grid-area:select}.jer-select:not(.jer-select--multiple):after{background-color:var(--jer-select-arrow);clip-path:polygon(100% 0,0 0,50% 100%);content:"";height:.5em;justify-self:end;width:.8em}select:focus+.focus{border:1px solid var(--jer-select-focus);border-radius:inherit;bottom:-1px;left:-1px;position:absolute;right:-1px;top:-1px}.jer-select-inner{text-overflow:ellipsis;width:100%}.jer-editor-container{border-radius:.5em;font-size:16px;line-height:1;padding:1em 1em 1em 2em;position:relative;text-align:left}.jer-editor-container textarea{border:var(--jer-form-border);border-radius:.3em;color:var(--jer-input-color);outline:none}.jer-editor-container textarea:focus{border:var(--jer-form-border-focus)}.jer-editor-container input{border:var(--jer-form-border);border-radius:.3em;font-family:inherit;outline:none}.jer-editor-container input:focus{border:var(--jer-form-border-focus)}.jer-editor-container ::selection{background-color:var(--jer-highlight-color)}.jer-collection-header-row,.jer-value-main-row{align-items:center;display:flex;gap:.3em;min-height:1.7em}.jer-collection-header-row{flex-wrap:wrap}.jer-value-main-row{gap:0}.jer-bracket-outside{padding-left:0}.jer-collection-item-count{display:none}.jer-collection-item-count.jer-visible{display:block}@starting-style{.jer-collection-item-count.jer-visible{opacity:0}}.jer-collapse-icon{left:-1.2em;position:absolute;top:50%;transform:translateY(-50%)}.jer-collapse-icon.jer-rotate-90{transform:translateY(-50%) rotate(-90deg)}.jer-collection-inner{position:relative}.jer-collection-text-edit,.jer-collection-text-edit-custom{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-edit{width:fit-content}.jer-collection-text-area{box-sizing:content-box;font-family:inherit;font-size:.85em;line-height:1.25em;max-height:40em;overflow:hidden;padding:.2em .5em 0;resize:both}.jer-collection-input-button-row{display:flex;font-size:150%;justify-content:flex-end;margin-top:.4em;width:100%}.jer-collection-error-row-edit{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-and-buttons{align-items:center;display:flex;justify-content:flex-start;padding-left:.5em}.jer-value-error-row{position:absolute}.jer-value-string{line-height:1.3em;overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-word}.jer-string-expansion{cursor:pointer;filter:saturate(50%);opacity:.6}.jer-show-less{font-size:80%}.jer-hyperlink{text-decoration:underline}.jer-input-text{box-sizing:content-box;font-family:inherit;font-size:.9em;height:1.4em;line-height:1.2em;margin:0;min-width:6em;overflow:hidden;padding:.25em .5em .2em;resize:none}.jer-input-boolean{margin-left:.3em;margin-right:.3em;transform:scale(1.5)}.jer-key-text{line-height:1.1em;white-space:pre-wrap;word-break:break-word}.jer-key-edit{font-size:inherit;font-size:.9em;padding:0 .3em}.jer-value-invalid{font-style:italic;opacity:.5}.jer-input-number{font-size:90%;min-width:3em}.jer-confirm-buttons,.jer-edit-buttons{align-items:center;cursor:pointer;display:flex;height:1em;margin-right:.2em}.jer-confirm-buttons>button,.jer-edit-buttons>button{appearance:none;background:none;border:none;color:inherit;font:inherit;margin:0;padding:0}.jer-input-buttons{gap:.4em}.jer-edit-buttons{gap:.4em;margin-left:.5em;opacity:0}.jer-confirm-buttons{gap:.2em;margin-left:.4em}.jer-edit-buttons:hover{opacity:1;position:relative}.jer-collection-header-row:hover>.jer-edit-buttons,.jer-value-and-buttons:hover>.jer-edit-buttons,.jer-value-main-row:hover>.jer-edit-buttons{opacity:1}.jer-copy-pulse{position:relative;transition:.3s}.jer-copy-pulse:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-copy-pulse:after{border-radius:50%;box-shadow:0 0 15px 5px var(--jer-icon-copy-color);content:"";display:block;height:100%;left:0;opacity:0;position:absolute;top:0;transition:all .5s;width:100%}.jer-copy-pulse:active:after{border-radius:4em;box-shadow:0 0 0 0 var(--jer-icon-copy-color);left:0;opacity:1;position:absolute;top:0;transition:0s}.jer-copy-pulse:active{top:.07em}.jer-icon:hover{opacity:.85;transform:scale(1.2);transition:.3s}.jer-empty-string{font-size:90%;font-style:italic}.jer-drag-n-drop-padding{border:1px dashed #b4b4b4;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const rt=(e,t)=>JSON.stringify(e,t,2),ot={edit:"ERROR_UPDATE",add:"ERROR_ADD",delete:"ERROR_DELETE",rename:"ERROR_RENAME",move:"ERROR_MOVE"},at={edit:"UPDATE_ERROR",add:"ADD_ERROR",delete:"DELETE_ERROR",rename:"RENAME_ERROR",move:"MOVE_ERROR"},it=e=>{const t=i(e);e&&(t.current=e);const n=i((...e)=>t.current(...e));return e?n.current:void 0},lt=[],st=["header","left"],ct={},dt={},ut={},pt=[],ht=({data:e,setData:n,buildNodeDataFromPathRef:r,commitRef:o,rootName:l="root",onUpdate:s=m,onChange:u,onError:v,onEditEvent:w,showErrorMessages:E=!0,showClipboardButton:D=!0,onCopy:j,indent:S=2,collapse:k=3,collapseAnimationTime:O=300,showCollectionCount:T="when-collapsed-or-filtered",allowEdit:N=!0,allowDelete:x=!0,allowAdd:R=!0,allowTypeSelection:P=!0,allowDrag:I=!1,searchFilter:L,searchText:_,searchDebounceTime:V=350,sortKeys:z=!1,showArrayIndexes:Y=!0,arrayIndexStart:U=0,showStringQuotes:W=!0,showIconTooltips:$=!1,defaultValue:H=null,newKeyOptions:J,minWidth:X=250,maxWidth:Q="min(600px, 90vw)",baseFontSize:Z,stringTruncateLength:G=250,translations:q=ct,className:te,id:ne,customText:re=dt,customNodeDefinitions:oe=lt,customButtons:ae=pt,jsonParse:ie=JSON.parse,jsonStringify:se=rt,TextEditor:ce,Select:de=Ze,errorDisplayTime:pe=2500,keyboardControls:he=ut,editorRef:me,insertAtTop:fe=!1,onCollapse:ye,collapseClickZones:ve=st})=>{const{getStyles:be,cssVars:we}=ee(),{open:Ee,cancel:De,getSnapshot:Ce}=le(),je=c(()=>yt(k),[k]),Se=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]:et[r];if(void 0!==o){const e=g(o)?o:{count:o};for(const[t,n]of Object.entries(e))a=a?.replace(`{{${t}}}`,String(n))}return a})(e,t,r,n,o))(q,re),[q,re]),[ke,Oe]=p(_),Te=i(null);a(()=>{De();const e=setTimeout(()=>Oe(_),V);return()=>clearTimeout(e)},[_,V]);const Ne=K(e,[],l),xe=i(e);xe.current=e;const Re=i(n);Re.current=n;const Pe=i(Se);Pe.current=Se;const Ae=i(Ne);Ae.current=Ne;const Ie=i(s);Ie.current=s;const Ke=i(l);Ke.current=l;const Le=i(void 0),_e=d(()=>xe.current,[]),Me=it(u),ze=it(v),Fe=it(ye),Be=it(w),Ye=it(j),We=d(e=>{xe.current=e,Re.current(e)},[]),$e=d((e,t)=>{We(ft(xe.current,e,t,"update").newData)},[We]),He=d(e=>{const t=xe.current,n=Ke.current,r=Le.current,o=We,{op:a,path:i}=e;switch(a){case"edit":{const{newData:a,currentValue:l,newValue:s}=ft(t,i,e.value,"update"),c=K(t,i,n,r);return{input:{...c,newData:a,event:"edit",newValue:s},nodeData:c,isNoOp:l===s,apply:()=>o(a),revert:()=>o(ft(xe.current,i,l,"update").newData)}}case"delete":{const{newData:e,currentValue:a}=ft(t,i,"","delete"),l=K(t,i,n,r);return{input:{...l,newData:e,event:"delete"},nodeData:l,isNoOp:!1,apply:()=>o(e),revert:()=>o(ft(xe.current,i,a,"add",{insert:!0,insertBefore:l.index}).newData)}}case"add":{const a=[...i,e.key],{newData:l,newValue:s}=ft(t,a,e.value,"add",e.options),c=K(l,a,n,r);return{input:{...c,value:void 0,size:null,parentData:A(t,i)??null,fullData:t,newData:l,event:"add",newValue:s},nodeData:c,isNoOp:!1,apply:()=>o(l),revert:()=>o(ft(xe.current,a,"","delete").newData)}}case"rename":{const a=i.slice(0,-1),l=i[i.length-1],{newKey:s}=e,c=A(t,a),d=Object.fromEntries(Object.entries(c).map(([e,t])=>e===l?[s,t]:[e,t])),{newData:u}=ft(t,a,d,"update"),p=K(t,i,n,r);return{input:{...p,newData:u,event:"rename",newKey:s},nodeData:p,isNoOp:l===s,apply:()=>o(u),revert:()=>o(ft(xe.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}=ft(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}=ft(d,g,u,"add",y),b=K(t,a,n,r);return{input:{...b,newData:v,event:"move",newPath:g},nodeData:b,isNoOp:!1,apply:()=>o(v),revert:()=>o(c)}}}},[We]),Je=d(async(e,t)=>{const n=at[e.event],r=()=>Pe.current(ot[e.event],Ae.current);let o;try{o=await Ie.current(e,t)}catch(e){return{status:"error",error:{code:n,message:e instanceof Error&&e.message?e.message:"string"==typeof e&&e?e:r()}}}if(!1===o)return{status:"error",error:{code:n,message:r()}};if(null===o)return{status:"cancel"};if(o&&"object"==typeof o){if(void 0!==o.error)return"string"==typeof o.error?{status:"error",error:{code:n,message:o.error}}:{status:"error",error:o.error};const t=void 0!==o.data,r=void 0!==o.value;if(t&&r&&console.warn("json-edit-react: onUpdate returned both { value } and { data }; { data } (whole-document) takes precedence and { value } is ignored."),t)return{status:"override",value:o.data,path:[]};if(r&&("edit"===e.event||"add"===e.event))return{status:"override",value:o.value,path:e.path}}return{status:"commit"}},[]),Xe=c(()=>({runUpdate:s===m?void 0:Je,buildCommit:He,applyValue:$e}),[Je,He,$e,s]);o.current=Xe;const qe=c(()=>yt(N),[N]),tt=c(()=>yt(x),[x]),nt=c(()=>yt(R),[R]),ht=c(()=>yt(I),[I]),mt=c(()=>gt(L),[L]),bt=c(()=>((e,t,n)=>{if(!t&&!n)return null;const r=new Set,o=new Map,a=t??Ge,i=n??"",l=e=>{let t=a(e,i);if(y(e.value)){let n=0;const r=Array.isArray(e.value),a=Object.entries(e.value);for(const[o,i]of a){const a=r?Number(o):o,s={key:a,path:[...e.path,a],level:e.level+1,index:n,value:i,size:y(i)?Object.keys(i).length:null,parentData:e.value,fullData:e.fullData};l(s)&&(t=!0,n++)}o.set(C(e.path),n)}return t&&r.add(C(e.path)),t};return l(e),{visiblePaths:r,visibleChildCounts:o}})(Ne,mt,ke),[e,ke,mt,l]),wt=c(()=>(e=>{const t={...F};for(const n of Object.keys(F)){const r=n,o=e[r];if(void 0===o)continue;const a="clipboardModifier"===n||"collapseModifier"===n;if(null===o){t[r]=a?[]:null;continue}const i=(()=>a?f(o):"string"==typeof o?{key:o}:o)();t[r]=i}return B.forEach(n=>{void 0===e[n]&&void 0!==e.confirm&&(t[n]=t.confirm)}),t})(he),[he]),Et=d((e,t)=>((e,t,n)=>{for(const[r,o]of Object.entries(t))if(M(n,e[r],r)){n.preventDefault(),o();break}})(wt,t,e),[wt]),Dt=c(()=>{const e=vt(oe,"stringifyReplacer");return t=>se(t,e)},[oe,se]),Ct=c(()=>{const e=vt(oe,"parseReviver");return t=>{const n=ie(t,e);return b(n)}},[oe,ie]),jt=i(null),{setCollapseState:St}=ue(),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]);Le.current=kt;const Ot=d(e=>K(_e(),e,Ke.current,Le.current),[_e]);r.current=Ot,h(me,()=>{const e=Symbol("path-missing");return{collapse:e=>St(e),startEdit:({path:t,overrideRestrictions:n=!1})=>A(_e(),t,e)===e?"PATH_NOT_FOUND":n||qe(K(_e(),t,l,kt))?(Ee(t,{force:!0}),!0):"RESTRICTED",confirm:()=>{jt.current&&(jt.current.click(),"editing"!==Ce().active?.phase&&De())},cancel:()=>De()}},[St,Ee,De,Ce,qe,_e,l,kt]);const Tt=Ve(oe,Ne),Nt=c(()=>({object:!0===fe||"object"===fe,array:!0===fe||"array"===fe}),[fe]),xt={mainContainerRef:Te,name:l,nodeData:Ne,getLatestData:_e,onChange:Me,onError:ze,onEditEvent:Be,showErrorMessages:E,showCollectionCount:T,collapseFilter:je,collapseAnimationTime:O,allowEditFilter:qe,allowDeleteFilter:tt,allowAddFilter:nt,allowTypeSelection:P,allowDragFilter:ht,canDragOnto:!1,showClipboardButton:D,onCopy:Ye,sortKeys:z,sort:kt,showArrayIndexes:Y,arrayIndexStart:U,showStringQuotes:W,showIconTooltips:$,indent:S,defaultValue:H,newKeyOptions:J,stringTruncateLength:G,translate:Se,customNodeDefinitions:oe,customNodeData:Tt,customButtons:ae,parentData:null,jsonParse:Ct,jsonStringify:Dt,TextEditor:ce,Select:de,errorDisplayTime:pe,handleKeyboard:Et,keyboardControls:wt,insertAtTop:Nt,onCollapse:Fe,editConfirmRef:jt,collapseClickZones:ve},Rt={...be("container",Ne),...we,minWidth:X,maxWidth:Q};return Rt.fontSize=Z??Rt.fontSize,t("div",{id:ne,ref:Te,className:`jer-editor-container ${te??""}`,style:Rt,children:t(ge,{value:bt,children:y(e)&&!Tt.renderCollectionAsValue?t(Qe,{data:e,...xt}):t(Ue,{data:e,showLabel:!0,...xt})})})};function mt(e){const n=i(void 0),r=i(void 0),o=e;return t(q,{theme:o.theme??J,children:t(fe,{onEditEvent:o.onEditEvent,onCollapse:o.onCollapse,buildNodeDataFromPathRef:n,commitRef:r,children:t(ht,{...o,buildNodeDataFromPathRef:n,commitRef:r})})})}const ft=(e,t,n,r,o={})=>{if(0===t.length)return{currentData:e,newData:n,currentValue:e,newValue:n};const a={remove:"delete"===r,...o},i="add"!==r?A(e,t):void 0;return{currentData:e,newData:N(e,t,n,a),currentValue:i,newValue:"delete"!==r?n:void 0}},yt=e=>"boolean"==typeof e?()=>e:"number"==typeof e?({level:t})=>t>=e:e,gt=e=>{if(void 0!==e)return"value"===e?Ge:"key"===e?qe:"all"===e?(e,t)=>Ge(e,t)||qe(e,t):e},vt=(e,t)=>{const n="stringifyReplacer"===t?[e=>void 0===e?w:e]:[];if(n.push(...e.map(e=>e[t]).filter(e=>!!e)),0!==n.length)return(e,t)=>{let r=t;for(const e of n)r=e(r);return r}};function bt(e){const{editorRef:n,...r}=e,o=i(null);return h(n,()=>({collapse:e=>o.current?.collapse(e)}),[]),t(mt,{...r,editorRef:o,setData:m,allowEdit:!1,allowAdd:!1,allowDelete:!1,allowDrag:!1})}export{_ as AutogrowTextArea,xe as IconSvg,mt as JsonEditor,bt as JsonViewer,De as StringDisplay,Ce as StringEdit,N as assign,Ke as collectionDataTypes,J as defaultTheme,A as extract,y as isCollection,Ge as matchNode,qe as matchNodeKey,E as splitPropertyString,Le as standardDataTypes,C as toPathString,Oe as useKeyboardListener,Ie as valueDataTypes};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-edit-react",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.4",
4
4
  "description": "React component for editing or viewing JSON/object data",
5
5
  "main": "build/index.cjs.js",
6
6
  "module": "build/index.esm.js",