legend-state-dev-tools 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1402 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +184 -0
- package/package.json +10 -19
- /package/{packages/core → dist}/dist/index.d.ts +0 -0
- /package/{packages/core → dist}/dist/index.js +0 -0
- /package/{packages/core → dist}/dist/index.js.map +0 -0
- /package/{packages/core → dist}/dist/index.mjs +0 -0
- /package/{packages/core → dist}/dist/index.mjs.map +0 -0
- /package/{packages/core → dist}/dist/styles.css +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# legend-state-dev-tools
|
|
2
2
|
|
|
3
3
|
> **Early-stage project** -- I discovered Legend State recently and chose it for a project I was working on. It had everything I needed from a state manager, but I couldn't live without dev tools, so I built this. It appears to work, but it hasn't been thoroughly tested yet -- consider it a proof of concept for now.
|
|
4
|
+
>
|
|
5
|
+
> **Legend State v3 only** -- This tool was built specifically for Legend State v3 and does not work with older versions (v1/v2).
|
|
4
6
|
|
|
5
7
|
[](https://www.npmjs.com/package/legend-state-dev-tools)
|
|
6
8
|
[](./LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ObservableParam } from '@legendapp/state';
|
|
2
|
+
|
|
3
|
+
export declare interface DevTools {
|
|
4
|
+
destroy: () => void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare interface DevToolsOptions {
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
theme?: string;
|
|
11
|
+
rootName?: string;
|
|
12
|
+
position?: 'left' | 'right';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare function init(observable$: ObservableParam<any>, options?: DevToolsOptions): DevTools;
|
|
16
|
+
|
|
17
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),b=require("react"),En=require("react-dom/client");var ot={exports:{}},xn=ot.exports,Kt;function wn(){return Kt||(Kt=1,(function(t,e){(function(n,r){r(e)})(xn,function(n){function r(){return r=Object.assign?Object.assign.bind():function(f){for(var d=1;d<arguments.length;d++){var c=arguments[d];for(var g in c)Object.prototype.hasOwnProperty.call(c,g)&&(f[g]=c[g])}return f},r.apply(this,arguments)}function o(f,d){f.prototype=Object.create(d.prototype),f.prototype.constructor=f,a(f,d)}function s(f){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(d){return d.__proto__||Object.getPrototypeOf(d)},s(f)}function a(f,d){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,g){return c.__proto__=g,c},a(f,d)}function m(f,d,c){return m=(function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}})()?Reflect.construct.bind():function(g,E,k){var z=[null];z.push.apply(z,E);var L=new(Function.bind.apply(g,z));return k&&a(L,k.prototype),L},m.apply(null,arguments)}function h(f){var d=typeof Map=="function"?new Map:void 0;return h=function(c){if(c===null||Function.toString.call(c).indexOf("[native code]")===-1)return c;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(d!==void 0){if(d.has(c))return d.get(c);d.set(c,g)}function g(){return m(c,arguments,s(this).constructor)}return g.prototype=Object.create(c.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),a(g,c)},h(f)}var l=(function(){function f(c){this.cache=void 0,this.cache=c}var d=f.prototype;return d.define=function(c,g){this.cache[c]=g},d.get=function(c){return this.cache[c]},d.remove=function(c){delete this.cache[c]},d.reset=function(){this.cache={}},d.load=function(c){this.cache=r({},this.cache,c)},f})(),u=(function(f){function d(c){var g;return(g=f.call(this,c)||this).name="Eta Error",g}return o(d,f),d})(h(Error)),p=(function(f){function d(c){var g;return(g=f.call(this,c)||this).name="EtaParser Error",g}return o(d,f),d})(u),y=(function(f){function d(c){var g;return(g=f.call(this,c)||this).name="EtaRuntime Error",g}return o(d,f),d})(u),x=(function(f){function d(c){var g;return(g=f.call(this,c)||this).name="EtaNameResolution Error",g}return o(d,f),d})(u);function j(f,d,c){var g=d.slice(0,c).split(/\n/),E=g.length,k=g[E-1].length+1;throw f+=" at line "+E+" col "+k+`:
|
|
2
|
+
|
|
3
|
+
`+d.split(/\n/)[E-1]+`
|
|
4
|
+
`+Array(k).join(" ")+"^",new p(f)}function w(f,d,c,g){var E=d.split(`
|
|
5
|
+
`),k=Math.max(c-3,0),z=Math.min(E.length,c+3),L=g,de=E.slice(k,z).map(function(je,Oe){var re=Oe+k+1;return(re==c?" >> ":" ")+re+"| "+je}).join(`
|
|
6
|
+
`),U=new y((L?L+":"+c+`
|
|
7
|
+
`:"line "+c+`
|
|
8
|
+
`)+de+`
|
|
9
|
+
|
|
10
|
+
`+f.message);throw U.name=f.name,U}var N=(function(){return Promise.resolve()}).constructor;function A(f,d){var c=this.config,g=d&&d.async?N:Function;try{return new g(c.varName,"options",this.compileToString.call(this,f,d))}catch(E){throw E instanceof SyntaxError?new p(`Bad template syntax
|
|
11
|
+
|
|
12
|
+
`+E.message+`
|
|
13
|
+
`+Array(E.message.length+1).join("=")+`
|
|
14
|
+
`+this.compileToString.call(this,f,d)+`
|
|
15
|
+
`):E}}function T(f,d){var c=this.config,g=d&&d.async,E=this.compileBody,k=this.parse.call(this,f),z=c.functionHeader+`
|
|
16
|
+
let include = (template, data) => this.render(template, data, options);
|
|
17
|
+
let includeAsync = (template, data) => this.renderAsync(template, data, options);
|
|
18
|
+
|
|
19
|
+
let __eta = {res: "", e: this.config.escapeFunction, f: this.config.filterFunction`+(c.debug?', line: 1, templateStr: "'+f.replace(/\\|"/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n")+'"':"")+`};
|
|
20
|
+
|
|
21
|
+
function layout(path, data) {
|
|
22
|
+
__eta.layout = path;
|
|
23
|
+
__eta.layoutData = data;
|
|
24
|
+
}`+(c.debug?"try {":"")+(c.useWith?"with("+c.varName+"||{}){":"")+`
|
|
25
|
+
|
|
26
|
+
`+E.call(this,k)+`
|
|
27
|
+
if (__eta.layout) {
|
|
28
|
+
__eta.res = `+(g?"await includeAsync":"include")+" (__eta.layout, {..."+c.varName+`, body: __eta.res, ...__eta.layoutData});
|
|
29
|
+
}
|
|
30
|
+
`+(c.useWith?"}":"")+(c.debug?"} catch (e) { this.RuntimeErr(e, __eta.templateStr, __eta.line, options.filepath) }":"")+`
|
|
31
|
+
return __eta.res;
|
|
32
|
+
`;if(c.plugins)for(var L=0;L<c.plugins.length;L++){var de=c.plugins[L];de.processFnString&&(z=de.processFnString(z,c))}return z}function R(f){for(var d=this.config,c=0,g=f.length,E="";c<g;c++){var k=f[c];if(typeof k=="string")E+="__eta.res+='"+k+`'
|
|
33
|
+
`;else{var z=k.t,L=k.val||"";d.debug&&(E+="__eta.line="+k.lineNo+`
|
|
34
|
+
`),z==="r"?(d.autoFilter&&(L="__eta.f("+L+")"),E+="__eta.res+="+L+`
|
|
35
|
+
`):z==="i"?(d.autoFilter&&(L="__eta.f("+L+")"),d.autoEscape&&(L="__eta.e("+L+")"),E+="__eta.res+="+L+`
|
|
36
|
+
`):z==="e"&&(E+=L+`
|
|
37
|
+
`)}}return E}var G={"&":"&","<":"<",">":">",'"':""","'":"'"};function te(f){return G[f]}var Y={autoEscape:!0,autoFilter:!1,autoTrim:[!1,"nl"],cache:!1,cacheFilepaths:!0,debug:!1,escapeFunction:function(f){var d=String(f);return/[&<>"']/.test(d)?d.replace(/[&<>"']/g,te):d},filterFunction:function(f){return String(f)},functionHeader:"",parse:{exec:"",interpolate:"=",raw:"~"},plugins:[],rmWhitespace:!1,tags:["<%","%>"],useWith:!1,varName:"it",defaultExtension:".eta"},J=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,ee=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,H=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function _(f){return f.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function M(f,d){return f.slice(0,d).split(`
|
|
38
|
+
`).length}function X(f){var d=this.config,c=[],g=!1,E=0,k=d.parse;if(d.plugins)for(var z=0;z<d.plugins.length;z++){var L=d.plugins[z];L.processTemplate&&(f=L.processTemplate(f,d))}function de(ae,me){ae&&(ae=(function(se,xe,Se,ke){var ce,Q;return Array.isArray(xe.autoTrim)?(ce=xe.autoTrim[1],Q=xe.autoTrim[0]):ce=Q=xe.autoTrim,(Se||Se===!1)&&(ce=Se),(ke||ke===!1)&&(Q=ke),Q||ce?ce==="slurp"&&Q==="slurp"?se.trim():(ce==="_"||ce==="slurp"?se=se.trimStart():ce!=="-"&&ce!=="nl"||(se=se.replace(/^(?:\r\n|\n|\r)/,"")),Q==="_"||Q==="slurp"?se=se.trimEnd():Q!=="-"&&Q!=="nl"||(se=se.replace(/(?:\r\n|\n|\r)$/,"")),se):se})(ae,d,g,me),ae&&(ae=ae.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),c.push(ae)))}d.rmWhitespace&&(f=f.replace(/[\r\n]+/g,`
|
|
39
|
+
`).replace(/^\s+|\s+$/gm,"")),J.lastIndex=0,ee.lastIndex=0,H.lastIndex=0;for(var U,je=[k.exec,k.interpolate,k.raw].reduce(function(ae,me){return ae&&me?ae+"|"+_(me):me?_(me):ae},""),Oe=new RegExp(_(d.tags[0])+"(-|_)?\\s*("+je+")?\\s*","g"),re=new RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?"+_(d.tags[1])+")","g");U=Oe.exec(f);){var Ie=f.slice(E,U.index);E=U[0].length+U.index;var Re=U[2]||"";de(Ie,U[1]),re.lastIndex=E;for(var B=void 0,fe=!1;B=re.exec(f);){if(B[1]){var we=f.slice(E,B.index);Oe.lastIndex=E=re.lastIndex,g=B[2],fe={t:Re===k.exec?"e":Re===k.raw?"r":Re===k.interpolate?"i":"",val:we};break}var ve=B[0];if(ve==="/*"){var I=f.indexOf("*/",re.lastIndex);I===-1&&j("unclosed comment",f,B.index),re.lastIndex=I}else ve==="'"?(ee.lastIndex=B.index,ee.exec(f)?re.lastIndex=ee.lastIndex:j("unclosed string",f,B.index)):ve==='"'?(H.lastIndex=B.index,H.exec(f)?re.lastIndex=H.lastIndex:j("unclosed string",f,B.index)):ve==="`"&&(J.lastIndex=B.index,J.exec(f)?re.lastIndex=J.lastIndex:j("unclosed string",f,B.index))}fe?(d.debug&&(fe.lineNo=M(f,U.index)),c.push(fe)):j("unclosed tag",f,U.index)}if(de(f.slice(E,f.length),!1),d.plugins)for(var W=0;W<d.plugins.length;W++){var ie=d.plugins[W];ie.processAST&&(c=ie.processAST(c,d))}return c}function ne(f,d){var c=d&&d.async?this.templatesAsync:this.templatesSync;if(this.resolvePath&&this.readFile&&!f.startsWith("@")){var g=d.filepath,E=c.get(g);if(this.config.cache&&E)return E;var k=this.readFile(g),z=this.compile(k,d);return this.config.cache&&c.define(g,z),z}var L=c.get(f);if(L)return L;throw new x("Failed to get template '"+f+"'")}function he(f,d,c){var g,E=r({},c,{async:!1});return typeof f=="string"?(this.resolvePath&&this.readFile&&!f.startsWith("@")&&(E.filepath=this.resolvePath(f,E)),g=ne.call(this,f,E)):g=f,g.call(this,d,E)}function oe(f,d,c){var g,E=r({},c,{async:!0});typeof f=="string"?(this.resolvePath&&this.readFile&&!f.startsWith("@")&&(E.filepath=this.resolvePath(f,E)),g=ne.call(this,f,E)):g=f;var k=g.call(this,d,E);return Promise.resolve(k)}function pe(f,d){var c=this.compile(f,{async:!1});return he.call(this,c,d)}function le(f,d){var c=this.compile(f,{async:!0});return oe.call(this,c,d)}var Z=(function(){function f(c){this.config=void 0,this.RuntimeErr=w,this.compile=A,this.compileToString=T,this.compileBody=R,this.parse=X,this.render=he,this.renderAsync=oe,this.renderString=pe,this.renderStringAsync=le,this.filepathCache={},this.templatesSync=new l({}),this.templatesAsync=new l({}),this.resolvePath=null,this.readFile=null,this.config=c?r({},Y,c):r({},Y)}var d=f.prototype;return d.configure=function(c){this.config=r({},this.config,c)},d.withConfig=function(c){return r({},this,{config:r({},this.config,c)})},d.loadTemplate=function(c,g,E){if(typeof g=="string")(E&&E.async?this.templatesAsync:this.templatesSync).define(c,this.compile(g,E));else{var k=this.templatesSync;(g.constructor.name==="AsyncFunction"||E&&E.async)&&(k=this.templatesAsync),k.define(c,g)}},f})(),q=(function(f){function d(){return f.apply(this,arguments)||this}return o(d,f),d})(Z);n.Eta=q})})(ot,ot.exports)),ot.exports}var Dn=wn();const Cn=`<div class="lsdt-toolbar-header">
|
|
40
|
+
<div class="lsdt-toolbar-title">
|
|
41
|
+
<span class="lsdt-toolbar-indicator"></span>
|
|
42
|
+
Legend State
|
|
43
|
+
</div>
|
|
44
|
+
<button
|
|
45
|
+
class="lsdt-toggle-btn <%= it.panelVisible ? 'active' : '' %>"
|
|
46
|
+
data-action="toggle-panel"
|
|
47
|
+
title="<%= it.panelVisible ? 'Hide panel' : 'Show panel' %>"
|
|
48
|
+
>
|
|
49
|
+
<%= it.panelVisible ? 'Hide' : 'Show' %> <%= it.rootName %>
|
|
50
|
+
</button>
|
|
51
|
+
</div>
|
|
52
|
+
`,On=`<div class="lsdt-panel-header">
|
|
53
|
+
<h3><%= it.rootName %></h3>
|
|
54
|
+
<div class="lsdt-panel-actions">
|
|
55
|
+
<% if (it.readOnly) { %>
|
|
56
|
+
<span class="lsdt-readonly-badge">Read-only</span>
|
|
57
|
+
<% } %>
|
|
58
|
+
<button class="lsdt-close-btn" data-action="close-panel" title="Close">×</button>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="lsdt-panel-content">
|
|
62
|
+
<div id="lsdt-json-editor-root"></div>
|
|
63
|
+
</div>
|
|
64
|
+
`,Sn=new Dn.Eta({autoEscape:!0,autoTrim:!1}),kn={toolbar:Cn,panel:On};function Yt(t,e){const n=kn[t];if(!n)return console.error(`[LSDT] Template not found: ${t}`),"";try{return Sn.renderString(n,e)}catch(r){return console.error(`[LSDT] Error rendering template ${t}:`,r),""}}function Tn(t){return Yt("toolbar",t)}function Nn(t){return Yt("panel",t)}const An="lsdt";function _n(t,e){const n=localStorage.getItem(`${An}-${t}`);return n===null?e:n==="true"}function Pn(){const t=[];return{add:e=>t.push(e),run:()=>{t.forEach(e=>{try{e()}catch(n){console.error("[Legend State DevTools] Cleanup error:",n)}}),t.length=0}}}class Rn{constructor(e={}){this.container=null,this.isDragging=!1,this.offsetX=0,this.offsetY=0,this.isMinimized=_n("toolbar-minimized",!1),this.panelVisible=!1,this.handleClick=n=>{var a;const o=n.target.closest("[data-action]");if(!o)return;o.getAttribute("data-action")==="toggle-panel"&&((a=this.onTogglePanel)==null||a.call(this))},this.handleMouseDown=n=>{if(n.target.tagName!=="BUTTON"&&(this.isDragging=!0,this.container)){this.container.classList.add("dragging");const o=this.container.getBoundingClientRect();this.offsetX=n.clientX-o.left,this.offsetY=n.clientY-o.top}},this.handleMouseMove=n=>{!this.isDragging||!this.container||(this.container.style.left=`${n.clientX-this.offsetX}px`,this.container.style.top=`${n.clientY-this.offsetY}px`,this.container.style.right="auto",this.container.style.bottom="auto")},this.handleMouseUp=()=>{var n;this.isDragging=!1,(n=this.container)==null||n.classList.remove("dragging")},this.onTogglePanel=e.onTogglePanel,this.rootName=e.rootName||"state$"}mount(){this.container||(this.container=document.createElement("div"),this.container.id="lsdt-toolbar",this.isMinimized&&this.container.classList.add("lsdt-toolbar-minimized"),document.body.appendChild(this.container),this.render(),this.attachEventListeners())}render(){if(!this.container)return;const e={isMinimized:this.isMinimized,panelVisible:this.panelVisible,rootName:this.rootName};this.container.innerHTML=Tn(e)}attachEventListeners(){this.container&&(this.container.addEventListener("click",this.handleClick),this.container.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp))}setPanelVisible(e){this.panelVisible=e,this.render()}unmount(){this.container&&(this.container.removeEventListener("click",this.handleClick),this.container.removeEventListener("mousedown",this.handleMouseDown),this.container.remove(),this.container=null),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}class In{constructor(e={}){this.container=null,this.visible=!1,this.handleClick=n=>{var a;const o=n.target.closest("[data-action]");if(!o)return;o.getAttribute("data-action")==="close-panel"&&((a=this.onClose)==null||a.call(this))},this.rootName=e.rootName||"state$",this.readOnly=e.readOnly||!1,this.onClose=e.onClose,this.position=e.position||"right"}toggle(){this.visible?this.hide():this.show()}show(){this.visible=!0,this.container||(this.container=document.createElement("div"),this.container.id="lsdt-panel",this.position==="left"&&this.container.classList.add("lsdt-panel-left"),document.body.appendChild(this.container),this.attachEventListeners()),this.render()}hide(){var e;this.visible=!1,(e=this.container)==null||e.remove(),this.container=null}isVisible(){return this.visible}getEditorRoot(){var e;return((e=this.container)==null?void 0:e.querySelector("#lsdt-json-editor-root"))||null}render(){if(!this.container)return;const e={rootName:this.rootName,readOnly:this.readOnly};this.container.innerHTML=Nn(e)}attachEventListeners(){this.container&&this.container.addEventListener("click",this.handleClick)}unmount(){this.container&&(this.container.removeEventListener("click",this.handleClick),this.container.remove(),this.container=null),this.visible=!1}}function Mn(t,e){const n=()=>{try{return JSON.parse(JSON.stringify(t.peek()))}catch{return}};let r=null;try{r=t.onChange(()=>{const o=n();e.onSnapshot(o)},{trackingType:!1})}catch{console.warn("[Legend State DevTools] Could not subscribe to observable changes via onChange")}return{getSnapshot:n,setData:o=>{try{t.set(o)}catch(s){console.error("[Legend State DevTools] Failed to set data:",s)}},destroy:()=>{r&&(r(),r=null)}}}const ze=(t,e,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${e}
|
|
65
|
+
Couldn't access "${n}" in ${JSON.stringify(t)}`)},zt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),dt=t=>Array.isArray(t),Jt=(t,e)=>t.filter(((n,r)=>r!==e)),Ln=(t,e,n,r={})=>{const{remove:o=!1,createNew:s=!0,noError:a=!1}=r,m=t,h=typeof(l=e)=="string"?l:typeof l=="number"?String(l):l.reduce(((y,x)=>typeof x=="number"?`${y}[${x}]`:y===""?x:`${y}.${x}`),"");var l;const u=Object.assign(Object.assign({},r),{remove:o,createNew:s,noError:a,fullData:m,fullPath:h}),p=Array.isArray(e)?e:(y=>Array.isArray(y)?y:y.split(/(\.|\[\d+\])/).filter((x=>x!=="."&&x!=="")).map((x=>{const j=/\[(\d+)\]/.exec(x);return j?Number(j[1]):x})).flat())(e).filter((y=>y!==""));return dt(t)&&o&&p.length===1?Jt(t,p[0]):it(t,p,n,u)},it=(t,e,n,r)=>{const o=zt(t)?Object.assign({},t):null,s=dt(t)?[...t]:null;if(e.length===0)return t;if(!o&&!s)throw new Error("Can't assign property -- invalid input object");const{createNew:a,remove:m,noError:h,fullData:l,fullPath:u}=r,p=e[0];if(s&&typeof p=="string")return s.map((w=>it(w,e,n,r)));if(e.length===1){if(o&&typeof p=="string"){const w=Vn(o,p,n,r);return w??o}return s&&typeof p=="number"?(Fn(s,p,n,r),s):(ze(l,u,p,h),t)}const y=o||s||[];if(m&&e.length===2&&typeof e[1]=="number"){const w=y[p],N=e[1];return dt(w)?y[p]=Jt(w,N):ze(l,u,p,h,"Trying to remove an indexed item from an object that is not an array"),y}const x=e.slice(1);if(p in t){if(j=y[p],!dt(j)&&!zt(j)){if(!a)return ze(l,u,p,h),y;y[p]={}}return y[p]=it(y[p],x,n,r),y}var j;if(a){const w=typeof x[0]=="number"?[]:{};if(o)return y[p]=w,y[p]=it(y[p],x,n,r),y;if(s&&Array.isArray(y)){y.push(w);const N=y.length-1;return y[N]=it(y[N],x,n,r),y}}return ze(l,u,p,h),y},Vn=(t,e,n,r)=>{const{remove:o,createNew:s,noError:a,insertAfter:m,insertBefore:h,fullData:l,fullPath:u}=r;if(h!==void 0||m!==void 0){const y=Object.entries(t);let x=1/0;return x=typeof h=="number"?h:typeof m=="number"?m:y.findIndex((([j,w])=>j===(h??m))),m&&x++,y.splice(x,0,[e,n]),Object.fromEntries(y)}const p=e in t;o?p?delete t[e]:ze(l,u,e,a):s||p?t[e]=n:ze(l,u,e,a)},Fn=(t,e,n,r)=>{const{noError:o,fullData:s,fullPath:a,createNew:m,insert:h}=r;h&&t.splice(e,0,n),e in t?t[e]=n:m?t.push(n):ze(s,a,e,o)},Ze=(t,e,n)=>{const r=Array.isArray(e)?e:Kn(e);if(r.length===0)return t;const o=r[0];if(Array.isArray(t)&&typeof o!="number")return t.map((a=>Ze(a,r)));if(typeof t!="object"||t===null||!(o in t))return zn(t,o);const s=t[o];return r.length===1?s:Ze(s,r.slice(1))},Kn=t=>t.split(/(\.|\[\d+\])/).filter((e=>e!=="."&&e!=="")).map((e=>{const n=/\[(\d+)\]/.exec(e);return n?Number(n[1]):e})).flat(),zn=(t,e,n)=>{throw new Error(`Unable to extract object property
|
|
66
|
+
Looking for property: ${e}
|
|
67
|
+
In object: ${JSON.stringify(t)}`)};function Xt(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function"){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function Xe(t,e,n,r){return new(n||(n=Promise))((function(o,s){function a(l){try{h(r.next(l))}catch(u){s(u)}}function m(l){try{h(r.throw(l))}catch(u){s(u)}}function h(l){var u;l.done?o(l.value):(u=l.value,u instanceof n?u:new n((function(p){p(u)}))).then(a,m)}h((r=r.apply(t,[])).next())}))}const Zt=({className:t,name:e,value:n,setValue:r,handleKeyPress:o,styles:s,textAreaRef:a})=>{if(typeof n!="string")return null;const m=n.slice(-1)===`
|
|
68
|
+
`?n+".":n;return i.jsxs("div",{style:{display:"grid"},children:[i.jsx("textarea",{id:`${e}_textarea`,ref:a,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},s),rows:1,className:t,name:`${e}_textarea`,value:n,onChange:h=>r(h.target.value),autoFocus:!0,onFocus:h=>{n.length<40&&h.target.select()},onKeyDown:o}),i.jsx("span",{className:t,style:Object.assign({visibility:"hidden",height:"auto",gridArea:"1 / 1 / 2 / 2",color:"red",opacity:.9,whiteSpace:"pre-wrap",overflowY:"auto",border:"1px solid transparent"},s),children:m})]})},qe=t=>t!==null&&typeof t=="object",qt=(t,e,n,r="")=>{if(!n&&!r)return!0;switch(t){case"collection":if(n){if(n(e,r))return!0;if(!wt(r,e,n))return!1}if(!n&&r&&!wt(r,e))return!1;break;case"value":if(n&&!n(e,r)||!n&&r&&!Qe(e,r))return!1}return!0},wt=(t="",e,n=Qe)=>{const r=e.value;return Object.entries(r).some((([o,s])=>{const a=[...e.path,o],m=Object.assign(Object.assign({},e),{key:o,path:a,level:e.level+1,value:s,size:a.length,parentData:r});return qe(s)?wt(t,m,n):n(m,t)}))},Qe=(t,e="")=>{const{value:n}=t;if(n===null&&"null".includes(e.toLowerCase()))return!0;switch(typeof n){case"string":return n.toLowerCase().includes(e.toLowerCase());case"number":return!!String(n).includes(e);case"boolean":return n?"true".includes(e.toLowerCase())||e==="1":"false".includes(e.toLowerCase())||e==="0";default:return!1}},Bt=({key:t,path:e},n="")=>!!Qe({value:t},n)||!!e.some((r=>Qe({value:r},n))),Ge=(t,e)=>(e??"")+t.map((n=>n===""?"\0":n)).join("."),St=t=>t.shiftKey?"Shift":t.metaKey?"Meta":t.ctrlKey?"Control":t.altKey?"Alt":void 0,Bn=(t,e,n)=>{const r=t.key,o=St(t);if(Array.isArray(e))return!!o&&e.includes(o);const{key:s,modifier:a}=e;return(n!=="stringLineBreak"||r!=="Enter"||o!=="Shift"||s!=="Enter"||!(a!=null&&a.includes("Shift")))&&r===s&&(a===o||Array.isArray(a)&&a.includes(o))},Ke={key:"Enter"},Wt={confirm:Ke,cancel:{key:"Escape"},objectConfirm:Object.assign(Object.assign({},Ke),{modifier:["Meta","Shift","Control"]}),objectLineBreak:Ke,stringConfirm:Ke,stringLineBreak:Object.assign(Object.assign({},Ke),{modifier:["Shift"]}),numberConfirm:Ke,numberUp:{key:"ArrowUp"},numberDown:{key:"ArrowDown"},tabForward:{key:"Tab"},tabBack:{key:"Tab",modifier:"Shift"},booleanConfirm:Ke,booleanToggle:{key:" "},clipboardModifier:["Meta","Control"],collapseModifier:["Alt"]},Be=(t,e,n="next",r)=>{const o=e.slice(0,e.length-1),s=e.slice(-1)[0];if(s===void 0)return null;const a=Ze(t,o),m=Wn(a);Array.isArray(a)||r(m,(({key:u,value:p})=>[u,p]));const h=m.findIndex((u=>u.key===s)),l=m[h+(n==="next"?1:-1)];return l?qe(l.value)?Object.keys(l.value).length===0?Be(t,[...o,l.key],n,r):Qt(t,[...o,l.key],n,r):[...o,l.key]:o.length===0?null:Be(t,o,n,r)},Qt=(t,e,n="next",r)=>{const o=Ze(t,e);if(!qe(o))return e;const s=Array.isArray(o)?o.map(((m,h)=>h)):Object.keys(o);r(s,(m=>[m,o]));const a=n==="next"?s[0]:s[s.length-1];return Qt(t,[...e,a],n,r)},Wn=t=>Array.isArray(t)?t.map(((e,n)=>({index:n,value:e,key:n}))):Object.entries(t).map((([e,n],r)=>({key:e,value:n,index:r}))),en=(t,e)=>{var n,r,o,s;const a=t.current,m=(n=a==null?void 0:a.selectionStart)!==null&&n!==void 0?n:1/0,h=(r=a==null?void 0:a.selectionEnd)!==null&&r!==void 0?r:1/0,l=((o=a==null?void 0:a.textContent)===null||o===void 0?void 0:o.slice(0,m))+e+((s=a==null?void 0:a.textContent)===null||s===void 0?void 0:s.slice(h));return a.value=l,a==null||a.setSelectionRange(m+1,m+1),l},Dt=t=>{if(t!==tn){if(Array.isArray(t))return t.map((e=>Dt(e)));if(t&&typeof t=="object")for(const e in t)t[e]=Dt(t[e]);return t}},tn="__undefined__",kt={displayName:"Default",fragments:{edit:"rgb(42, 161, 152)"},styles:{container:{backgroundColor:"#f6f6f6",fontFamily:"monospace"},collection:{},collectionInner:{},collectionElement:{},dropZone:{},property:"#292929",bracket:{color:"rgb(0, 43, 54)",fontWeight:"bold"},itemCount:{color:"rgba(0, 0, 0, 0.3)",fontStyle:"italic"},string:"rgb(203, 75, 22)",number:"rgb(38, 139, 210)",boolean:"green",null:{color:"rgb(220, 50, 47)",fontVariant:"small-caps",fontWeight:"bold"},input:["#292929"],inputHighlight:"#b3d8ff",error:{fontSize:"0.8em",color:"red",fontWeight:"bold"},iconCollection:"rgb(0, 43, 54)",iconEdit:"edit",iconDelete:"rgb(203, 75, 22)",iconAdd:"edit",iconCopy:"rgb(38, 139, 210)",iconOk:"green",iconCancel:"rgb(203, 75, 22)"}},nn=b.createContext({getStyles:()=>({}),icons:{}}),$n=({theme:t=kt,icons:e={},docRoot:n,children:r})=>{const o=Gn(t,n);return i.jsx(nn.Provider,{value:{getStyles:(s,a)=>typeof o[s]=="function"?o[s](a):o[s],icons:e},children:r})},Pe=()=>b.useContext(nn),Gn=(t,e)=>{var n,r,o,s;const a={},m=(Array.isArray(t)?t:[t]).map((u=>Hn(u)?xt({fragments:{},styles:u},a):xt(u,a))),h=xt(kt,{});Object.keys(h).forEach((u=>{const p=u;m.forEach((y=>{y[p]&&(h[p]=Object.assign(Object.assign({},h[p]),y[p]))}))}));const l=Object.assign({},h);return Object.entries(a).forEach((([u,p])=>{const y=u;l[y]=x=>{const j=p(x)||{};return Object.assign(Object.assign({},h[y]),j)}})),typeof(l==null?void 0:l.inputHighlight)!="function"&&(!((n=l==null?void 0:l.inputHighlight)===null||n===void 0)&&n.backgroundColor)&&e.style.setProperty("--jer-highlight-color",(r=l==null?void 0:l.inputHighlight)===null||r===void 0?void 0:r.backgroundColor),typeof(l==null?void 0:l.iconCopy)!="function"&&(!((o=l==null?void 0:l.iconCopy)===null||o===void 0)&&o.color)&&e.style.setProperty("--jer-icon-copy-color",(s=l==null?void 0:l.iconCopy)===null||s===void 0?void 0:s.color),l},xt=(t,e)=>{const{fragments:n,styles:r}=t,o={};return Object.entries(r).forEach((([s,a])=>{const m=(Array.isArray(a)?a:[a]).reduce(((h,l)=>{var u,p;if(typeof l=="function")return e[s]=l,Object.assign({},h);if(typeof l=="string"){const y=(u=n==null?void 0:n[l])!==null&&u!==void 0?u:l;return typeof y=="string"?Object.assign(Object.assign({},h),{[(p=Un[s])!==null&&p!==void 0?p:"color"]:y}):Object.assign(Object.assign({},h),y)}return Object.assign(Object.assign({},h),l)}),{});o[s]=m})),o},Hn=t=>!("styles"in t),Un={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},rn=b.createContext(null),Yn=({children:t,onEditEvent:e,onCollapse:n})=>{const[r,o]=b.useState(null),[s,a]=b.useState(null),[m,h]=b.useState(null),[l,u]=b.useState({path:null,pathString:null}),p=b.useRef(null),y=b.useRef("next"),x=b.useRef(null);return i.jsx(rn.Provider,{value:{collapseState:r,setCollapseState:j=>{o(j),n&&j!==null&&(Array.isArray(j)?j.forEach((w=>n(w))):n(j)),j!==null&&setTimeout((()=>o(null)),2e3)},getMatchingCollapseState:j=>{if(Array.isArray(r)){for(const w of r)if($t(j,w))return w;return null}return $t(j,r)?r:null},currentlyEditingElement:s,setCurrentlyEditingElement:(j,w)=>{const N=typeof j=="string"||j===null?j:Ge(j,w==="key"?"key_":void 0);s!==null&&N!==null&&p.current!==null&&p.current(),a(N),e&&(Array.isArray(j)||j===null)&&e(j,w==="key"),p.current=typeof w=="function"?w:null},areChildrenBeingEdited:j=>s!==null&&s.includes(j),previouslyEditedElement:x.current,setPreviouslyEditedElement:j=>{x.current=j},tabDirection:y.current,setTabDirection:j=>{y.current=j},previousValue:m,setPreviousValue:h,dragSource:l,setDragSource:u},children:t})},$e=()=>{const t=b.useContext(rn);if(!t)throw new Error("Missing Context Provider");return t},$t=(t,e)=>{if(e===null)return!1;if(!e.includeChildren)return e.path.every(((n,r)=>t[r]===n))&&e.path.length===t.length;for(const[n,r]of e.path.entries())if(r!==t[n])return!1;return!0},Ct="**INVALID_FUNCTION**",Jn=({nodeData:t,showStringQuotes:e=!0,stringTruncate:n=200,pathString:r,canEdit:o,setIsEditing:s,styles:a,translate:m,value:h,TextWrapper:l=({children:u})=>u})=>{const u=h??t.value,[p,y]=b.useState(!1),x=e?'"':"",j=u.length>n,w=()=>{o?s(!0):y(!p)};return i.jsxs("div",{id:`${r}_display`,onDoubleClick:w,onClick:N=>{(N.getModifierState("Control")||N.getModifierState("Meta"))&&w()},className:"jer-value-string",style:a,children:[x,j?i.jsxs(i.Fragment,p?{children:[i.jsx(l,{children:i.jsxs("span",{children:[u,x]})}),i.jsxs("span",{className:"jer-string-expansion jer-show-less",onClick:()=>y(!1),children:[" ",m("SHOW_LESS",t)]})]}:{children:[i.jsxs(l,{children:[i.jsx("span",{children:u.slice(0,n-2).trimEnd()})," "]}),i.jsx("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>y(!0),children:"..."}),x]}):i.jsx(l,{children:`${u}${x}`})]})},Xn=({styles:t,pathString:e,value:n,setValue:r,handleEdit:o,handleKeyboard:s,keyboardCommon:a})=>{const m=b.useRef(null);return i.jsx(Zt,{className:"jer-input-text",textAreaRef:m,name:e,value:n,setValue:r,handleKeyPress:h=>{s(h,Object.assign({stringConfirm:o,stringLineBreak:()=>{const l=en(m,`
|
|
69
|
+
`);r(l)}},a))},styles:t})},Zn=t=>{var{isEditing:e,path:n,enumType:r}=t,o=Xt(t,["isEditing","path","enumType"]);const{getStyles:s}=Pe(),a=Ge(n),{value:m,setValue:h,nodeData:l,handleEdit:u,handleKeyboard:p,keyboardCommon:y}=o;return e&&r?i.jsxs("div",{className:"jer-select jer-select-enums",children:[i.jsx("select",{name:`${a}-value-select`,className:"jer-select-inner",onChange:x=>h(x.target.value),value:m,autoFocus:!0,onKeyDown:x=>{p(x,Object.assign({stringConfirm:u},y))},children:r.values.map((x=>i.jsx("option",{value:x,children:x},x)))}),i.jsx("span",{className:"focus"})]}):e?i.jsx(Xn,Object.assign({styles:s("input",l),pathString:a},o,{setValue:o.setValue})):i.jsx(Jn,Object.assign({pathString:a,styles:s("string",l)},o))},qn=({value:t,setValue:e,isEditing:n,path:r,setIsEditing:o,handleEdit:s,nodeData:a,handleKeyboard:m,keyboardCommon:h})=>{const{getStyles:l}=Pe();return n?i.jsx("input",{className:"jer-input-number",type:"text",name:Ge(r),value:t,onChange:u=>e(u.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:u=>setTimeout((()=>u.target.select()),10),onKeyDown:u=>m(u,Object.assign({numberConfirm:s,numberUp:()=>e(Number(t)+1),numberDown:()=>e(Number(t)-1)},h)),style:Object.assign({width:String(t).length/1.5+2+"em"},l("input",a))}):i.jsx("span",{onDoubleClick:()=>o(!0),className:"jer-value-number",style:l("number",a),children:t})},Qn=({value:t,setValue:e,isEditing:n,path:r,setIsEditing:o,handleEdit:s,nodeData:a,handleKeyboard:m,keyboardCommon:h})=>{const{getStyles:l}=Pe();return typeof t!="boolean"?null:n?i.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:Ge(r),checked:t,onChange:()=>e(!t),onKeyDown:u=>{u.key===" "&&u.preventDefault(),m(u,Object.assign({booleanConfirm:s,booleanToggle:()=>e(!t)},h))},autoFocus:!0}):i.jsx("span",{onDoubleClick:()=>o(!0),className:"jer-value-boolean",style:l("boolean",a),children:String(t)})},er=(t,e)=>{const n=b.useRef(void 0),r=b.useRef(e);b.useEffect((()=>{r.current=e}),[e]);const o=s=>{r.current(s)};b.useEffect((()=>{if(window.clearTimeout(n.current),t)return n.current=window.setTimeout((()=>{window.addEventListener("keydown",o)}),100),()=>{window.clearTimeout(n.current),window.removeEventListener("keydown",o)}}),[t])},tr=({value:t,isEditing:e,setIsEditing:n,handleEdit:r,nodeData:o,handleKeyboard:s,keyboardCommon:a})=>{const{getStyles:m}=Pe();return er(e,(h=>s(h,Object.assign({confirm:r},a)))),i.jsx("div",{onDoubleClick:()=>n(!0),className:"jer-value-null",style:m("null",o),children:String(t)})},nr=({value:t})=>{let e="Error!";switch(typeof t){case"string":t===Ct&&(e="Function");break;case"undefined":e="Undefined";break;case"symbol":e="Symbol"}return i.jsx("span",{className:"jer-value-invalid",children:e})},rr=({size:t,style:e,className:n})=>i.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:n,style:e,children:[i.jsx("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4z"}),i.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"})]}),or=({size:t,style:e,className:n})=>i.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:n,style:e,transform:"translate(0, 0.5)",children:[i.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"}),i.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"})]}),ir=({size:t,style:e,className:n})=>i.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:n,style:e,children:i.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"})}),ar=({size:t,style:e,className:n})=>i.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:n,style:e,children:[i.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"}),i.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"}),i.jsx("path",{d:"M15 10l-4 4 4 4"})]}),sr=({size:t,style:e,className:n})=>i.jsxs("svg",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",width:t,height:t,className:n,style:e,children:[i.jsx("path",{d:"M22 11.08V12a10 10 0 11-5.93-9.14"}),i.jsx("path",{d:"M22 4L12 14.01l-3-3"})]}),lr=({size:t,style:e,className:n})=>i.jsx("svg",{baseProfile:"tiny",viewBox:"0 0 24 24",fill:"currentColor",width:t,height:t,className:n,style:e,children:i.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"})}),cr=({size:t,style:e,className:n})=>i.jsx("svg",{viewBox:"0 0 512 512",fill:"currentColor",width:t,height:t,className:n,style:e,children:i.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"})}),We=({name:t,nodeData:e})=>{var n,r,o,s,a,m,h;const{getStyles:l,icons:u}=Pe(),p={size:"1.4em",className:"jer-icon"};switch(t){case"add":return(n=u==null?void 0:u.add)!==null&&n!==void 0?n:i.jsx(rr,Object.assign({},p,{style:l("iconAdd",e)}));case"edit":return(r=u==null?void 0:u.edit)!==null&&r!==void 0?r:i.jsx(or,Object.assign({},p,{style:l("iconEdit",e)}));case"delete":return(o=u==null?void 0:u.delete)!==null&&o!==void 0?o:i.jsx(ir,Object.assign({},p,{style:l("iconDelete",e),size:"1.45em"}));case"copy":return(s=u==null?void 0:u.copy)!==null&&s!==void 0?s:i.jsx(ar,Object.assign({},p,{style:l("iconCopy",e),size:"1.2em"}));case"ok":return(a=u==null?void 0:u.ok)!==null&&a!==void 0?a:i.jsx(sr,Object.assign({},p,{style:Object.assign({fontSize:"90%"},l("iconOk",e))}));case"cancel":return(m=u==null?void 0:u.cancel)!==null&&m!==void 0?m:i.jsx(lr,Object.assign({},p,{style:Object.assign({fontSize:"130%"},l("iconCancel",e))}));case"chevron":return(h=u==null?void 0:u.chevron)!==null&&h!==void 0?h:i.jsx(cr,{size:"1em",style:l("iconCollection",e)});default:return i.jsx(i.Fragment,{})}},on=({startEdit:t,handleDelete:e,handleAdd:n,enableClipboard:r,type:o,customButtons:s,nodeData:a,translate:m,keyboardControls:h,handleKeyboard:l,editConfirmRef:u,getNewKeyOptions:p,jsonStringify:y,onEditEvent:x,showIconTooltips:j})=>{const{getStyles:w}=Pe(),N=m("KEY_NEW",a),[A,T]=b.useState(N),[R,G]=b.useState(!1),{key:te,path:Y,value:J}=a,ee=Array.isArray(R),H=_=>{var M;if(x&&x(_?[...Y,null]:null,_),!_)return void G(!1);const X=Object.keys(Ze(a.fullData,Y)),ne=p?(M=p(a))===null||M===void 0?void 0:M.filter((he=>!X.includes(he))):null;ne&&T(""),G(ne==null||ne)};return i.jsxs("div",{className:"jer-edit-buttons",style:{opacity:R?1:void 0},onClick:_=>_.stopPropagation(),children:[r&&i.jsx("div",{onClick:_=>{var M;_.stopPropagation();let X,ne,he="value",oe="",pe=null;if(r){const le=St(_);if(le&&h.clipboardModifier.includes(le)?(X=ur(Y),oe=X,he="path"):(X=J,oe=typeof X=="object"?y(J):String(X)),!navigator.clipboard)return void(typeof r=="function"&&r({success:!1,value:X,stringValue:oe,path:Y,key:te,type:he,errorMessage:"Can't access clipboard API"}));(M=navigator.clipboard)===null||M===void 0||M.writeText(oe).then((()=>ne=!0)).catch((Z=>{ne=!1,pe=Z.message})).finally((()=>{typeof r=="function"&&r({success:ne,errorMessage:pe,value:X,stringValue:oe,path:Y,key:te,type:he})}))}},className:"jer-copy-pulse",title:j?m("TOOLTIP_COPY",a):"",children:i.jsx(We,{name:"copy",nodeData:a})}),t&&i.jsx("div",{onClick:t,title:j?m("TOOLTIP_EDIT",a):"",children:i.jsx(We,{name:"edit",nodeData:a})}),e&&i.jsx("div",{onClick:e,title:j?m("TOOLTIP_DELETE",a):"",children:i.jsx(We,{name:"delete",nodeData:a})}),n&&i.jsx("div",{onClick:()=>{o==="object"?H(!0):n("")},title:j?m("TOOLTIP_ADD",a):"",children:i.jsx(We,{name:"add",nodeData:a})}),s==null?void 0:s.map((({Element:_,onClick:M},X)=>i.jsx("div",{onClick:ne=>M&&M(a,ne),children:i.jsx(_,{nodeData:a})},X))),R&&n&&o==="object"&&i.jsxs(i.Fragment,{children:[ee?i.jsxs("div",{className:"jer-select jer-select-keys",children:[i.jsxs("select",{name:"new-key-select",className:"jer-select-inner",onChange:_=>{n(_.target.value),H(!1)},defaultValue:"",autoFocus:!0,onKeyDown:_=>{l(_,{cancel:()=>H(!1)})},children:[i.jsx("option",{value:"",disabled:!0,children:R.length>0?m("KEY_SELECT",a):m("NO_KEY_OPTIONS",a)}),R.map((_=>i.jsx("option",{value:_,children:_},_)))]}),i.jsx("span",{className:"focus"})]}):i.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:A,onChange:_=>T(_.target.value),autoFocus:!0,onFocus:_=>_.target.select(),onKeyDown:_=>{l(_,{stringConfirm:()=>{n&&(H(!1),n(A),T(N))},cancel:()=>{H(!1),T(N)}})},style:w("input",a)}),i.jsx(Tt,{onOk:()=>{ee&&!A||(H(!1),n(A))},onCancel:()=>{H(!1)},nodeData:a,editConfirmRef:u,hideOk:ee})]})]})},Tt=({onOk:t,onCancel:e,nodeData:n,editConfirmRef:r,hideOk:o=!1})=>i.jsxs("div",{className:"jer-confirm-buttons",children:[!o&&i.jsx("div",{onClick:t,ref:r,children:i.jsx(We,{name:"ok",nodeData:n})}),i.jsx("div",{onClick:e,children:i.jsx(We,{name:"cancel",nodeData:n})})]}),ur=t=>t.reduce(((e,n)=>typeof n=="number"?`${e}[${n}]`:e===""?n:`${e}.${n}`),""),dr=["string","number","boolean","null","object","array"],an=({props:t,collapsed:e})=>{const{data:n,nodeData:r,parentData:o,onEdit:s,onError:a,showErrorMessages:m,restrictEditFilter:h,restrictDeleteFilter:l,restrictAddFilter:u,restrictDragFilter:p,translate:y,errorMessageTimeout:x}=t,{currentlyEditingElement:j,setCurrentlyEditingElement:w}=$e(),[N,A]=b.useState(null),T=Object.assign(Object.assign({},r),{collapsed:e}),{path:R,key:G,size:te}=T,Y=Ge(R),J=!h(T),ee=!l(T),H=!u(T),_=!p(T)&&ee&&j===null,M=Z=>{m&&(A(Z),setTimeout((()=>A(null)),x)),console.warn("Error",Z)},X=b.useCallback(((Z,q)=>{M(Z.message),a&&a({currentData:T.fullData,errorValue:q,currentValue:n,name:G,path:R,error:Z})}),[a,m]),ne=j===Y,he=j===`key_${Y}`,oe=typeof R.slice(-1)[0]=="number",pe={isEditing:ne,isEditingKey:he,isArray:oe,canEditKey:o!==null&&J&&H&&ee&&!oe},le=G===""&&R.length>0?y("EMPTY_STRING",T):null;return{pathString:Y,nodeData:T,path:R,name:G,size:te,canEdit:J,canDelete:ee,canAdd:H,canDrag:_,error:N,showError:M,onError:X,setError:A,handleEditKey:Z=>{if(w(null),G===Z||!o)return;const q=R.slice(0,-1);if(Object.keys(o).includes(Z))return void X({code:"KEY_EXISTS",message:y("ERROR_KEY_EXISTS",T)},Z);const f=Object.fromEntries(Object.entries(o).map((([d,c])=>d===G?[Z,c]:[d,c])));s(f,q).then((d=>{d&&X({code:"UPDATE_ERROR",message:d},Z)}))},derivedValues:pe,emptyStringKey:le}},sn=({canDrag:t,canDragOnto:e,path:n,nodeData:r,onMove:o,onError:s,translate:a})=>{const{getStyles:m}=Pe(),{dragSource:h,setDragSource:l}=$e(),[u,p]=b.useState(!1),y=Ge(n),x=b.useMemo((()=>t?{onDragStart:A=>{A.stopPropagation(),l({path:n,pathString:y})},onDragEnd:A=>{A.stopPropagation(),l({path:null,pathString:null})}}:{}),[t,y]),j=b.useMemo((()=>A=>e?{onDragOver:T=>{T.stopPropagation(),T.preventDefault()},onDrop:T=>{T.stopPropagation(),N(A),l({path:null,pathString:null}),p(!1)},onDragEnter:T=>{var R;T.stopPropagation(),y.startsWith((R=h.pathString)!==null&&R!==void 0?R:"")||p(A)},onDragExit:T=>{T.stopPropagation(),p(!1)}}:{}),[h,e,y]),w=b.useMemo((()=>e&&h.pathString!==null?i.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:n.length}},j("below"))):null),[h,e,n.length]),N=A=>{var T,R;const G=(T=h.path)===null||T===void 0?void 0:T.slice(-1)[0],te=(R=h.path)===null||R===void 0?void 0:R.slice(0,-1).join("."),Y=n.slice(0,-1).join(""),{parentData:J}=r;typeof G=="string"&&J&&!Array.isArray(J)&&Object.keys(J).includes(G)&&G in J&&te!==Y?s({code:"KEY_EXISTS",message:a("ERROR_KEY_EXISTS",r)},G):o(h.path,n,A).then((ee=>{ee&&s({code:"UPDATE_ERROR",message:ee},r.value)}))};return{dragSourceProps:x,getDropTargetProps:j,BottomDropTarget:w,DropTargetPadding:({position:A,nodeData:T})=>u===A?i.jsx("div",{className:"jer-drag-n-drop-padding",style:m("dropZone",T)}):null,handleDrop:N}},hr=(t,e,n,r)=>{var o,s,a;if(!e.current)return 0;const m=parseInt((o=getComputedStyle(n.current).getPropertyValue("line-height"))!==null&&o!==void 0?o:"16px"),h=((a=(s=e.current)===null||s===void 0?void 0:s.offsetWidth)!==null&&a!==void 0?a:0)/(.5*m),l=r(t).replace(/\\n/g,`
|
|
70
|
+
`).split(`
|
|
71
|
+
`).map((u=>Math.ceil(u.length/h))).reduce(((u,p)=>u+p),0)*m;return Math.min(l+30,window.innerHeight-50)},ht=({isEditingKey:t,canEditKey:e,pathString:n,path:r,name:o,arrayIndexFromOne:s,handleKeyboard:a,handleEditKey:m,handleCancel:h,handleClick:l,keyValueArray:u,styles:p,getNextOrPrevious:y,emptyStringKey:x})=>{const{setCurrentlyEditingElement:j}=$e(),w=typeof o=="number"?String(o+(s?1:0)):o;return t?i.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:n,defaultValue:w,autoFocus:!0,onFocus:N=>N.target.select(),onKeyDown:N=>a(N,{stringConfirm:()=>m(N.target.value),cancel:h,tabForward:()=>{if(m(N.target.value),u){const A=u==null?void 0:u[0][0];j(A?[...r,A]:y("next"))}else j(r)},tabBack:()=>{m(N.target.value),j(y("prev"))}}),style:{width:w.length/1.5+.5+"em"}}):i.jsxs("span",{className:"jer-key-text",style:Object.assign(Object.assign({},p),{minWidth:`${Math.min(w.length+1,5)}ch`,flexShrink:w.length>10?1:0}),onDoubleClick:()=>e&&j(r,"key"),onClick:l,children:[x?i.jsx("span",{className:"jer-empty-string",children:x}):w,w!==""||x?i.jsx("span",{className:"jer-key-colon",children:":"}):null]})},ln=t=>{const{data:e,parentData:n,onEdit:r,onDelete:o,onChange:s,onMove:a,enableClipboard:m,canDragOnto:h,restrictTypeSelection:l,searchFilter:u,searchText:p,showLabel:y,stringTruncate:x,showStringQuotes:j,arrayIndexFromOne:w,indent:N,translate:A,customNodeDefinitions:T,customNodeData:R,handleKeyboard:G,keyboardControls:te,sort:Y,editConfirmRef:J,jsonStringify:ee,showIconTooltips:H}=t,{getStyles:_}=Pe(),{setCurrentlyEditingElement:M,setCollapseState:X,previouslyEditedElement:ne,setPreviouslyEditedElement:he,tabDirection:oe,setTabDirection:pe,previousValue:le,setPreviousValue:Z}=$e(),[q,f]=b.useState(typeof e=="function"?Ct:e),{pathString:d,nodeData:c,path:g,name:E,canEdit:k,canDelete:z,canDrag:L,error:de,onError:U,handleEditKey:je,emptyStringKey:Oe,derivedValues:re}=an({props:t}),{dragSourceProps:Ie,getDropTargetProps:Re,BottomDropTarget:B,DropTargetPadding:fe}=sn({canDrag:L,canDragOnto:h,path:g,nodeData:c,onMove:a,onError:U,translate:A}),[we,ve]=b.useState(Ot(e,R)),I=b.useCallback((v=>{if(!s)return void f(v);const O=s({currentData:c.fullData,newValue:v,currentValue:q,name:E,path:g});f(O)}),[s]);b.useEffect((()=>{f(typeof e=="function"?Ct:e),ve(Ot(e,R))}),[e,de]);const{CustomNode:W,customNodeProps:ie,hideKey:ae,showEditTools:me=!0,showOnEdit:se,showOnView:xe,passOriginalNode:Se}=R,ke=[...dr,...T.filter((({showInTypesSelector:v=!1,name:O})=>v&&!!O)).map((({name:v})=>v))],ce=b.useMemo((()=>{if(typeof l=="boolean")return l?[]:ke;if(Array.isArray(l))return l;const v=l(c);return typeof v=="boolean"?v?[]:ke:v}),[c,l]),[Q,Me]=b.useState(((v,O)=>{var K;if(typeof v!="string")return null;const be=O.filter((ue=>ue instanceof Object&&ue.enum&&ue.values.includes(v)&&ue.matchPriority));return be.sort(((ue,ye)=>{var Ve,Fe;return((Ve=ye.matchPriority)!==null&&Ve!==void 0?Ve:0)-((Fe=ue.matchPriority)!==null&&Fe!==void 0?Fe:0)})),(K=be[0])!==null&&K!==void 0?K:null})(q,ce)),{isEditing:Ee}=re,He=qt("value",c,u,p);if(Ee&&(!He||!k)){const v=Be(c.fullData,g,oe,Y);M(v||ne)}if(!He)return null;const Ae=v=>{let O;if(M(null),Z(null),v===void 0||(K=>K&&typeof K=="object"&&"type"in K&&"target"in K&&"preventDefault"in K&&typeof K.preventDefault=="function")(v))switch(we){case"object":O={[A("DEFAULT_NEW_KEY",c)]:q};break;case"array":O=q??[];break;case"number":{const K=Number(q);O=isNaN(K)?0:K;break}default:O=q}else O=v;r(O,g).then((K=>{K&&U({code:"UPDATE_ERROR",message:K},O)}))},Te=()=>{M(null),le===null?(f(e),Z(null)):r(le,g)},{isEditingKey:Ue,canEditKey:Ye}=re,De=!Ee&&de,ge=Ee&&ce.length>1,Le=(we!=="invalid"||W)&&!de&&me,S=y&&!ae,C=W&&(Ee&&se||!Ee&&xe),P={value:q,parentData:n,setValue:I,isEditing:Ee,canEdit:k,setIsEditing:k?()=>M(g):()=>{},handleEdit:Ae,handleCancel:Te,path:g,stringTruncate:x,showStringQuotes:j,nodeData:c,enumType:Q,translate:A,handleKeyboard:G,keyboardCommon:{cancel:Te,tabForward:()=>{pe("next"),he(d);const v=Be(c.fullData,g,"next",Y);v&&(Ae(),M(v))},tabBack:()=>{pe("prev"),he(d);const v=Be(c.fullData,g,"prev",Y);v&&(Ae(),M(v))}}},F={canEditKey:Ye,isEditingKey:Ue,pathString:d,path:g,name:E,arrayIndexFromOne:w,handleKeyboard:G,handleEditKey:je,handleCancel:Te,styles:_("property",c),getNextOrPrevious:v=>Be(c.fullData,g,v,Y),emptyStringKey:Oe},V=C?i.jsx(W,Object.assign({},t,{value:q,customNodeProps:ie,setValue:I,handleEdit:Ae,handleCancel:Te,handleKeyPress:v=>G(v,{stringConfirm:Ae,cancel:Te}),isEditing:Ee,setIsEditing:()=>M(g),getStyles:_,originalNode:Se?Gt(e,P):void 0,originalNodeKey:Se?i.jsx(ht,Object.assign({},F)):void 0,canEdit:k,keyboardCommon:P.keyboardCommon,onError:U})):Gt(e,P);return i.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:n!==null?N/2+"em":0,position:"relative"},draggable:L},Ie,Re("above"),{children:[B,i.jsx(fe,{position:"above",nodeData:c}),i.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:E.length>10?"wrap":"nowrap"},children:[S&&i.jsx(ht,Object.assign({},F)),i.jsxs("div",{className:"jer-value-and-buttons",children:[i.jsx("div",{className:"jer-input-component",children:V}),Ee?i.jsx(Tt,{onOk:Ae,onCancel:Te,nodeData:c,editConfirmRef:J}):Le&&i.jsx(on,{startEdit:k?()=>{Z(le),M(g,Te)}:void 0,handleDelete:z?()=>{o(q,g).then((v=>{v&&U({code:"DELETE_ERROR",message:v},q)}))}:void 0,enableClipboard:m,translate:A,customButtons:t.customButtons,nodeData:c,handleKeyboard:G,keyboardControls:te,editConfirmRef:J,jsonStringify:ee,showIconTooltips:H}),ge&&i.jsxs("div",{className:"jer-select jer-select-types",children:[i.jsx("select",{name:`${E}-type-select`,className:"jer-select-inner",onChange:v=>(O=>{const K=T.find((ye=>ye.name===O));if(K)return r(K.defaultValue,g),ve(O),Me(null),M(null),void X({path:g,collapsed:!1,includeChildren:!1});const be=ce.find((ye=>ye instanceof Object&&ye.enum===O));if(be)return typeof q=="string"&&be.values.includes(q)||r(be.values[0],g).then((ye=>{ye&&(U({code:"UPDATE_ERROR",message:ye},ue),M(null))})),void Me(be);const ue=pr(q,O,A("DEFAULT_NEW_KEY",c),R!=null&&R.CustomNode?A("DEFAULT_STRING",c):void 0);["string","number","boolean"].includes(O)||M(null),r(ue,g).then((ye=>{ye?(U({code:"UPDATE_ERROR",message:ye},ue),M(null)):Me(null)}))})(v.target.value),value:Q?Q.enum:we,children:ce.map((v=>v instanceof Object&&"enum"in v?i.jsx("option",{value:v.enum,children:v.enum},v.enum):i.jsx("option",{value:v,children:v},v)))}),i.jsx("span",{className:"focus"})]}),De&&i.jsx("span",{className:"jer-error-slug",style:_("error",c),children:de})]})]}),i.jsx(fe,{position:"below",nodeData:c})]}))},Ot=(t,e)=>e!=null&&e.CustomNode&&(e!=null&&e.name)&&e.showInTypesSelector?e.name:typeof t=="string"?"string":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t===null?"null":"invalid",Gt=(t,e)=>{const n=Ot(t),{value:r}=e;switch(n){case"string":return i.jsx(Zn,Object.assign({},e,{value:r}));case"number":return i.jsx(qn,Object.assign({},e,{value:r}));case"boolean":return i.jsx(Qn,Object.assign({},e,{value:r}));case"null":return i.jsx(tr,Object.assign({},e));default:return i.jsx(nr,Object.assign({},e))}},pr=(t,e,n,r)=>{switch(e){case"string":return r??String(t);case"number":{const o=Number(t);return isNaN(o)?0:o}case"boolean":return!!t;case"null":return null;case"object":return{[n]:t};case"array":return[t];default:return String(t)}},cn=(t=[],e)=>{const n=t.filter((({condition:j})=>j(e)));if(n.length===0)return{};const r=n[0],{element:o,wrapperElement:s,customNodeProps:a,wrapperProps:m,hideKey:h=!1,showEditTools:l=!0,showOnEdit:u=!1,showOnView:p=!0,showCollectionWrapper:y=!0}=r,x=Xt(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:s,customNodeProps:a,wrapperProps:m,hideKey:h,showEditTools:l,showOnEdit:u,showOnView:p,showCollectionWrapper:y},x)},un=t=>{const{getStyles:e}=Pe(),{collapseState:n,setCollapseState:r,getMatchingCollapseState:o,currentlyEditingElement:s,setCurrentlyEditingElement:a,areChildrenBeingEdited:m,previousValue:h,setPreviousValue:l}=$e(),{mainContainerRef:u,data:p,nodeData:y,parentData:x,showCollectionCount:j,onEdit:w,onAdd:N,onDelete:A,canDragOnto:T,collapseFilter:R,collapseAnimationTime:G,onMove:te,enableClipboard:Y,onEditEvent:J,showIconTooltips:ee,searchFilter:H,searchText:_,indent:M,sort:X,showArrayIndices:ne,arrayIndexFromOne:he,defaultValue:oe,newKeyOptions:pe,translate:le,customNodeDefinitions:Z,customNodeData:q,jsonParse:f,jsonStringify:d,TextEditor:c,keyboardControls:g,handleKeyboard:E,insertAtTop:k,onCollapse:z,editConfirmRef:L,collapseClickZones:de}=t,[U,je]=b.useState(d(p)),Oe=R(y),{contentRef:re,isAnimating:Ie,maxHeight:Re,collapsed:B,animateCollapse:fe,cssTransitionValue:we}=((D,$,Ne,Ce,_e)=>{const[yn,ct]=b.useState(Ne?0:void 0),[ut,vn]=b.useState(Ne),yt=b.useRef(!1),vt=b.useRef(null),Lt=b.useRef(0),Vt=b.useRef(0),bn=$/1e3+"s",jn=b.useCallback((bt=>{var jt,Et;if(ut!==bt){switch(window.clearTimeout(Vt.current),yt.current=!0,bt){case!0:{const Ft=(Et=(jt=vt.current)===null||jt===void 0?void 0:jt.offsetHeight)!==null&&Et!==void 0?Et:0;Lt.current=Ft,ct(Ft),setTimeout((()=>{ct(0)}),5);break}case!1:ct(Lt.current||hr(D,vt,Ce,_e))}vn(!ut),Vt.current=window.setTimeout((()=>{yt.current=!1,bt||ct(void 0)}),$)}}),[$,ut,D,Ce,_e]);return{contentRef:vt,isAnimating:yt.current,animateCollapse:jn,maxHeight:yn,collapsed:ut,cssTransitionValue:bn}})(p,G,Oe,u,d),{pathString:ve,nodeData:I,path:W,name:ie,size:ae,canEdit:me,canDelete:se,canAdd:xe,canDrag:Se,error:ke,setError:ce,onError:Q,handleEditKey:Me,emptyStringKey:Ee,derivedValues:He}=an({props:t,collapsed:B}),{dragSourceProps:Ae,getDropTargetProps:Te,BottomDropTarget:Ue,DropTargetPadding:Ye}=sn({canDrag:Se,canDragOnto:T,path:W,nodeData:I,onMove:te,onError:Q,translate:le}),De=b.useRef(!Oe),{isEditing:ge,isEditingKey:Le,isArray:S,canEditKey:C}=He;b.useEffect((()=>{je(d(p))}),[p,d]),b.useEffect((()=>{const D=R(I)&&!ge;De.current=!D,fe(D)}),[R]),b.useEffect((()=>{if(n!==null){const D=o(W);D&&(De.current=!0,fe(D.collapsed))}}),[n]);const P=b.useRef(null),F=b.useCallback(((D,$)=>{if(typeof oe!="function")return oe;const Ne=oe(D,$);return Ne!==void 0?Ne:null}),[oe]),V=b.useCallback((D=>pe?typeof pe!="function"?pe:pe(D):null),[pe]),{CustomNode:v,customNodeProps:O,CustomWrapper:K,wrapperProps:be={},hideKey:ue,showEditTools:ye=!0,showOnEdit:Ve,showOnView:Fe,showCollectionWrapper:pt=!0}=q,at=m(ve);if(at&&B&&fe(!1),!(qt("collection",I,H,_)||I.level===0)&&!at)return null;const Je=Array.isArray(p)?"array":"object",ft=Je==="array"?{open:"[",close:"]"}:{open:"{",close:"}"},Nt=D=>{if(D.key!=="Tab"||D.getModifierState("Shift"))E(D,{objectConfirm:lt,cancel:et});else{D.preventDefault();const $=en(P," ");je($)}},st=D=>{D.stopPropagation();const $=St(D);if($&&g.collapseModifier.includes($))return De.current=!0,void r({collapsed:!B,path:W,includeChildren:!0});s&&s.includes(ve)||(De.current=!0,r(null),z&&z({path:W,collapsed:!B,includeChildren:!1}),fe(!B))},lt=()=>{try{const D=f(U);if(a(null),l(null),ce(null),d(D)===d(p))return;w(D,W).then(($=>{$&&Q({code:"UPDATE_ERROR",message:$},D)}))}catch{Q({code:"INVALID_JSON",message:le("ERROR_INVALID_JSON",I)},U)}},hn=W.length>0?()=>{A(p,W).then((D=>{D&&Q({code:"DELETE_ERROR",message:D},p)}))}:void 0,et=()=>{a(null),h===null?(ce(null),je(d(p)),l(null)):w(h,W)},At=j==="when-closed"?B:j,pn=!ge&&ye,fn=(ne||!S)&&!ue&&ie!==void 0,mn=v&&(ge&&Ve||!ge&&Fe),mt=Object.entries(p).map((([D,$])=>[Je==="array"?Number(D):D,$]));Je==="object"&&X(mt,(D=>D));const _t=De.current?ge?i.jsxs("div",{className:"jer-collection-text-edit",children:[c?i.jsx(c,{value:U,onChange:je,onKeyDown:D=>E(D,{objectConfirm:lt,cancel:et})}):i.jsx(Zt,{textAreaRef:P,className:"jer-collection-text-area",name:ve,value:U,setValue:je,handleKeyPress:Nt,styles:e("input",I)}),i.jsx("div",{className:"jer-collection-input-button-row",children:i.jsx(Tt,{onOk:lt,onCancel:et,nodeData:I,editConfirmRef:L})})]}):mt.map((([D,$],Ne)=>{const Ce={key:D,value:$,path:[...W,D],level:W.length+1,index:Ne,size:qe($)?Object.keys($).length:null,parentData:p,fullData:I.fullData},_e=cn(Z,Ce);return i.jsx("div",{className:"jer-collection-element",style:e("collectionElement",Ce),children:qe($)&&!(_e!=null&&_e.renderCollectionAsValue)?i.jsx(un,Object.assign({},t,{data:$,parentData:p,nodeData:Ce,showCollectionCount:j,canDragOnto:me,customNodeData:_e}),D):i.jsx(ln,Object.assign({},t,{data:$,parentData:p,nodeData:Ce,canDragOnto:me,showLabel:Je==="object"||ne,customNodeData:_e}),D)},D)})):null,gt=!!pt&&B&&!at;gt||(De.current=!0);const Pt=Object.assign(Object.assign({},t),{data:p,value:p,parentData:x,nodeData:I,setValue:D=>Xe(void 0,void 0,void 0,(function*(){return yield w(D,W)})),handleEdit:lt,handleCancel:et,handleKeyPress:Nt,isEditing:ge,setIsEditing:()=>a(W),getStyles:e,canDragOnto:me,canEdit:me,keyboardCommon:{},onError:Q}),gn=mn?i.jsx(v,Object.assign({customNodeProps:O},Pt,{children:_t})):_t,Rt=pn&&i.jsx(on,{startEdit:me?()=>{De.current=!0,l(null),a(W)}:void 0,handleAdd:xe?D=>{fe(!1);const $=F(I,D);if(Je==="array"){const Ne=k.array?0:p.length,Ce=k.array?{insert:!0}:{};N($,[...W,Ne],Ce).then((_e=>{_e&&Q({code:"ADD_ERROR",message:_e},$)}))}else if(D in p)Q({code:"KEY_EXISTS",message:le("ERROR_KEY_EXISTS",I)},D);else{const Ne=k.object?{insertBefore:0}:{};N($,[...W,D],Ne).then((Ce=>{Ce&&Q({code:"ADD_ERROR",message:Ce},$)}))}}:void 0,handleDelete:se?hn:void 0,enableClipboard:Y,type:Je,nodeData:I,translate:le,customButtons:t.customButtons,keyboardControls:g,handleKeyboard:E,getNewKeyOptions:V,editConfirmRef:L,jsonStringify:d,onEditEvent:J,showIconTooltips:ee}),It={canEditKey:C,isEditingKey:Le,pathString:ve,path:W,name:ie,arrayIndexFromOne:he,handleKeyboard:E,handleEditKey:Me,handleCancel:et,keyValueArray:mt,styles:e("property",I),getNextOrPrevious:D=>Be(I.fullData,W,D,X),handleClick:de.includes("property")?st:D=>D.stopPropagation(),emptyStringKey:Ee},Mt=i.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:(W.length===0?0:M/2)+"em"},e("collection",I)),{position:"relative"}),draggable:Se},Ae,Te("above"),{children:[i.jsx("div",{className:"jer-clickzone",style:{width:M/2+1+"em",zIndex:10+2*I.level},onClick:de.includes("left")?st:void 0}),!ge&&Ue,i.jsx(Ye,{position:"above",nodeData:I}),pt?i.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:de.includes("header")?st:void 0,children:[i.jsxs("div",{className:"jer-collection-name",children:[i.jsx("div",{className:"jer-collapse-icon jer-accordion-icon"+(B?" jer-rotate-90":""),style:{zIndex:11+2*I.level,transition:we},onClick:st,children:i.jsx(We,{name:"chevron",rotate:B,nodeData:I})}),fn&&i.jsx(ht,Object.assign({},It)),!ge&&i.jsx("span",{className:"jer-brackets jer-bracket-open",style:e("bracket",I),children:ft.open})]}),!ge&&At&&i.jsx("div",{className:"jer-collection-item-count"+(At?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},e("itemCount",I)),{transition:we}),children:ae===1?le("ITEM_SINGLE",Object.assign(Object.assign({},I),{size:1}),1):le("ITEMS_MULTIPLE",I,ae)}),i.jsx("div",{className:"jer-brackets"+(gt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},e("bracket",I)),{transition:we}),children:ft.close}),Rt]}):ue?i.jsx(i.Fragment,{}):i.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[i.jsx(ht,Object.assign({},It)),Rt]}),i.jsxs("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:gt||Ie?"clip":"visible",maxHeight:at?void 0:Re},e("collectionInner",I)),{transition:we}),ref:re,children:[gn,i.jsx("div",{className:ge?"jer-collection-error-row":"jer-collection-error-row-edit",children:ke&&i.jsx("span",{className:"jer-error-slug",style:e("error",I),children:ke})}),!ge&&pt&&i.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},e("bracket",I)),{marginLeft:(M<3?-1:M<6?-.5:0)+"em"}),children:ft.close})]}),i.jsx(Ye,{position:"below",nodeData:I})]}));return K?i.jsx(K,Object.assign({customNodeProps:be},Pt,{children:Mt})):Mt},fr={ITEM_SINGLE:"{{count}} item",ITEMS_MULTIPLE:"{{count}} 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",DEFAULT_STRING:"New data!",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"},mr=(t,e)=>(n,r,o)=>((s,a,m,h,l)=>{if(a[h]){const p=a[h](m);if(p!==null)return p}const u=h in s?s[h]:fr[h];return l===void 0?u:u==null?void 0:u.replace("{{count}}",String(l))})(t,e,r,n,o);var Ht=[],tt=[];(function(t,e){if(t&&typeof document<"u"){var n,r=e.prepend===!0?"prepend":"append",o=e.singleTag===!0,s=typeof e.container=="string"?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(o){var a=Ht.indexOf(s);a===-1&&(a=Ht.push(s)-1,tt[a]={}),n=tt[a]&&tt[a][r]?tt[a][r]:tt[a][r]=m()}else n=m();t.charCodeAt(0)===65279&&(t=t.substring(1)),n.styleSheet?n.styleSheet.cssText+=t:n.appendChild(document.createTextNode(t))}function m(){var h=document.createElement("style");if(h.setAttribute("type","text/css"),e.attributes)for(var l=Object.keys(e.attributes),u=0;u<l.length;u++)h.setAttribute(l[u],e.attributes[l[u]]);var p=r==="prepend"?"afterbegin":"beforeend";return s.insertAdjacentElement(p,h),h}})(':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-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{display:flex;flex-wrap:wrap}.jer-collapse-icon{left:-1.2em;position:absolute;top:.35em}.jer-collection-inner{position:relative}.jer-collection-text-edit{align-items:flex-start;display:flex;flex-direction:column;gap:.3em;line-height:1.1em}.jer-collection-text-area{font-family:inherit;font-size:.85em;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{bottom:.5em;position:absolute}.jer-error-slug{margin-left:1em}.jer-value-component{position:relative}.jer-value-main-row{display:flex;gap:0}.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{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}.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-rotate-90{transform:rotate(-90deg)}.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 #e0e0e0;border-radius:.3em;height:.5em}.jer-clickzone{height:calc(100% - .8em);left:-1em;position:absolute;top:1.2em}',{});const gr=({data:t,setData:e,rootName:n="root",onUpdate:r=()=>{},onEdit:o=r,onDelete:s=r,onAdd:a=r,onChange:m,onError:h,onEditEvent:l,showErrorMessages:u=!0,enableClipboard:p=!0,indent:y=2,collapse:x=!1,collapseAnimationTime:j=300,showCollectionCount:w=!0,restrictEdit:N=!1,restrictDelete:A=!1,restrictAdd:T=!1,restrictTypeSelection:R=!1,restrictDrag:G=!0,viewOnly:te,searchFilter:Y,searchText:J,searchDebounceTime:ee=350,keySort:H=!1,showArrayIndices:_=!0,arrayIndexFromOne:M=!1,showStringQuotes:X=!0,showIconTooltips:ne=!1,defaultValue:he=null,newKeyOptions:oe,minWidth:pe=250,maxWidth:le="min(600px, 90vw)",rootFontSize:Z,stringTruncate:q=250,translations:f={},className:d,id:c,customText:g={},customNodeDefinitions:E=[],customButtons:k=[],jsonParse:z=JSON.parse,jsonStringify:L=(B,fe)=>JSON.stringify(B,fe,2),TextEditor:de,errorMessageTimeout:U=2500,keyboardControls:je={},externalTriggers:Oe,insertAtTop:re=!1,onCollapse:Ie,collapseClickZones:Re=["header","left"]})=>{const{getStyles:B}=Pe(),{setCurrentlyEditingElement:fe}=$e(),we=b.useMemo((()=>rt(x)),[x]),ve=b.useMemo((()=>mr(f,g)),[f,g]),[I,W]=b.useState(J),[ie,ae]=(({setData:S,data:C})=>{const[P,F]=b.useState(S?void 0:C),V=b.useCallback((v=>{S?S(v):F(v)}),[S]);return b.useEffect((()=>{S||F(C)}),[C]),[S?C:P,V]})({setData:e,data:t}),me=b.useRef(null);b.useEffect((()=>{fe(null);const S=setTimeout((()=>W(J)),ee);return()=>clearTimeout(S)}),[J,ee]);const se={key:n,path:[],level:0,index:0,value:ie,size:typeof ie=="object"&&ie!==null?Object.keys(ie).length:1,parentData:null,fullData:ie},xe=(S,C)=>Xe(void 0,void 0,void 0,(function*(){const P=yield S(C);if(P===!0||P===void 0)return void ae(C.newData);const F=br(P)?P:["error",P],[V,v]=F;if(V==="error")return ae(C.currentData),v===!1?ve("ERROR_UPDATE",se):String(v);ae(v)})),Se=b.useMemo((()=>rt(N,te)),[N,te]),ke=b.useMemo((()=>rt(A,te)),[A,te]),ce=b.useMemo((()=>rt(T,te)),[T,te]),Q=b.useMemo((()=>rt(G,te)),[G,te]),Me=b.useMemo((()=>vr(Y)),[Y]),Ee=b.useMemo((()=>(S=>{const C=Object.assign({},Wt);for(const P of Object.keys(Wt)){const F=P;if(S[F]){const V=S[F],v=["clipboardModifier","collapseModifier"].includes(P)?Array.isArray(V)?V:[V]:typeof V=="string"?{key:V}:V;C[F]=v,["stringConfirm","numberConfirm","booleanConfirm"].forEach((O=>{!S[O]&&S.confirm&&(C[O]=C.confirm)}))}}return C})(je)),[je]),He=b.useCallback(((S,C)=>((P,F,V)=>{const v=Object.entries(F);for(const[O,K]of v)if(Bn(V,P[O],O)){V.preventDefault(),K();break}})(Ee,C,S)),[Ee]),Ae=b.useMemo((()=>{const S=Ut(E,"stringifyReplacer");return C=>L(C,S)}),[E,L]),Te=b.useMemo((()=>{const S=Ut(E,"parseReviver");return C=>{const P=z(C,S);return Dt(P)}}),[E,z]),Ue=b.useRef(null);((S,C)=>{const{setCurrentlyEditingElement:P,currentlyEditingElement:F,setCollapseState:V}=$e();b.useEffect((()=>{if(!S)return;const{collapse:v,edit:O}=S;v&&V(v);const K=!(O!=null&&O.path)||Ge(O.path)===F;switch(O==null?void 0:O.action){case"accept":K&&(C.current&&C.current.click(),P(null));break;case"cancel":K&&P(null);break;default:O!=null&&O.path&&P(O.path)}}),[S])})(Oe,Ue);const Ye=b.useCallback(((S,C)=>{H!==!1&&(typeof H!="function"?S.sort(((P,F)=>{const V=C(P)[0],v=C(F)[0];return V<v?-1:V>v?1:0})):S.sort(((P,F)=>H(C(P),C(F)))))}),[H]),De=cn(E,se),ge={mainContainerRef:me,name:n,nodeData:se,onEdit:(S,C)=>Xe(void 0,void 0,void 0,(function*(){const{currentData:P,newData:F,currentValue:V,newValue:v}=nt(ie,C,S,"update");if(V!==v)return yield xe(o,{currentData:P,newData:F,currentValue:V,newValue:v,name:C.slice(-1)[0],path:C})})),onDelete:(S,C)=>Xe(void 0,void 0,void 0,(function*(){const{currentData:P,newData:F,currentValue:V,newValue:v}=nt(ie,C,S,"delete");return yield xe(s,{currentData:P,newData:F,currentValue:V,newValue:v,name:C.slice(-1)[0],path:C})})),onAdd:(S,C,P)=>Xe(void 0,void 0,void 0,(function*(){const{currentData:F,newData:V,currentValue:v,newValue:O}=nt(ie,C,S,"add",P);return yield xe(a,{currentData:F,newData:V,currentValue:v,newValue:O,name:C.slice(-1)[0],path:C})})),onChange:m,onError:h,onEditEvent:l,showErrorMessages:u,onMove:(S,C,P)=>Xe(void 0,void 0,void 0,(function*(){if(S===null)return;const{currentData:F,newData:V,currentValue:v}=nt(ie,S,"","delete"),O=S.slice(-1)[0],K=C.slice(0,-1),be=C.slice(-1)[0];let ue=typeof be=="number"?P==="above"?be:be+1:typeof O=="number"?`arr_${O}`:O;S.slice(0,-1).join(".")===C.slice(0,-1).join(".")&&typeof O=="number"&&typeof ue=="number"&&O<ue&&(ue-=1);const ye=typeof ue=="number"?{insert:!0}:P==="above"?{insertBefore:be}:{insertAfter:be},{newData:Ve,newValue:Fe}=nt(V,[...K,ue],v,"add",ye);return yield xe(o,{currentData:F,newData:Ve,currentValue:v,newValue:Fe,name:C.slice(-1)[0],path:C})})),showCollectionCount:w,collapseFilter:we,collapseAnimationTime:j,restrictEditFilter:Se,restrictDeleteFilter:ke,restrictAddFilter:ce,restrictTypeSelection:R,restrictDragFilter:Q,canDragOnto:!1,searchFilter:Me,searchText:I,enableClipboard:p,keySort:H,sort:Ye,showArrayIndices:_,arrayIndexFromOne:M,showStringQuotes:X,showIconTooltips:ne,indent:y,defaultValue:he,newKeyOptions:oe,stringTruncate:q,translate:ve,customNodeDefinitions:E,customNodeData:De,customButtons:k,parentData:null,jsonParse:Te,jsonStringify:Ae,TextEditor:de,errorMessageTimeout:U,handleKeyboard:He,keyboardControls:Ee,insertAtTop:{object:re===!0||re==="object",array:re===!0||re==="array"},onCollapse:Ie,editConfirmRef:Ue,collapseClickZones:Re},Le=Object.assign(Object.assign({},B("container",se)),{minWidth:pe,maxWidth:le});return Le.fontSize=Z??Le.fontSize,i.jsx("div",{id:c,ref:me,className:`jer-editor-container ${d??""}`,style:Le,children:qe(ie)&&!De.renderCollectionAsValue?i.jsx(un,Object.assign({data:ie},ge)):i.jsx(ln,Object.assign({data:ie,showLabel:!0},ge))})},yr=t=>{var e;const[n,r]=b.useState();return b.useEffect((()=>{const o=document.documentElement;r(o)}),[]),n?i.jsx($n,{theme:(e=t.theme)!==null&&e!==void 0?e:kt,icons:t.icons,docRoot:n,children:i.jsx(Yn,{onEditEvent:t.onEditEvent,onCollapse:t.onCollapse,children:i.jsx(gr,Object.assign({},t))})}):null},nt=(t,e,n,r,o={})=>{if(e.length===0)return{currentData:t,newData:n,currentValue:t,newValue:n};const s=Object.assign({remove:r==="delete"},o),a=r!=="add"?Ze(t,e):void 0;return{currentData:t,newData:Ln(t,e,n,s),currentValue:a,newValue:r!=="delete"?n:void 0}},rt=(t,e)=>e?()=>!0:typeof t=="boolean"?()=>t:typeof t=="number"?({level:n})=>n>=t:t,vr=t=>{if(t!==void 0)return t==="value"?Qe:t==="key"?Bt:t==="all"?(e,n)=>Qe(e,n)||Bt(e,n):t},br=t=>Array.isArray(t)&&t.length===2&&["error","value"].includes(t[0]),Ut=(t,e)=>{const n=e==="stringifyReplacer"?[r=>r===void 0?tn:r]:[];if(n.push(...t.map((r=>r[e])).filter((r=>!!r))),n.length!==0)return(r,o)=>{let s=o;for(const a of n)s=a(s);return s}},dn={displayName:"Github Dark",styles:{container:{backgroundColor:"#0d1117",color:"white"},dropZone:"rgba(165, 214, 255, 0.17)",property:"#E6EDF3",bracket:"#56d364",itemCount:"#8B949E",string:"#A5D6FF",number:"#D2A8FF",boolean:{color:"#FF7B72",fontSize:"90%",fontWeight:"bold"},null:"green",iconCollection:"#D2A8FF",iconEdit:"#D2A8FF",iconDelete:"rgb(203, 75, 22)",iconAdd:"rgb(203, 75, 22)",iconCopy:"#A5D6FF",iconOk:"#56d364",iconCancel:"rgb(203, 75, 22)"}},jr={displayName:"Github Light",styles:{container:"white",property:"#1F2328",bracket:"#00802e",itemCount:"#8B949E",string:"#0A3069",number:"#953800",boolean:{color:"#CF222E",fontSize:"90%",fontWeight:"bold"},null:"#FF7B72",iconCollection:"#8250DF",iconEdit:"#8250DF",iconDelete:"rgb(203, 75, 22)",iconAdd:"#8250DF",iconCopy:"#57606A"}},Er={displayName:"Black & White",fragments:{lightText:{color:"white"},midGrey:"#5c5c5c"},styles:{container:["lightText",{backgroundColor:"black"}],dropZone:"#e0e0e029",property:"lightText",bracket:"midGrey",itemCount:"#4a4a4a",string:"#a8a8a8",number:"#666666",boolean:{color:"#848484",fontStyle:"italic"},null:"#333333",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},xr={fragments:{midGrey:"#a3a3a3"},displayName:"White & Black",styles:{container:"white",property:"black",bracket:"midGrey",itemCount:"#b5b5b5",string:"#575757",number:"#999999",boolean:{color:"#7b7b7b",fontStyle:"italic"},null:"#cccccc",iconCollection:"midGrey",iconEdit:"midGrey",iconDelete:"midGrey",iconAdd:"midGrey",iconCopy:"midGrey",iconOk:"midGrey",iconCancel:"midGrey"}},wr={githubDark:dn,githubLight:jr,monoDark:Er,monoLight:xr};class Dr extends b.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,n){console.error("[Legend State DevTools] React error:",e,n)}render(){return this.state.error?b.createElement("pre",{style:{color:"#ff6b6b",padding:16,fontSize:12}},`DevTools Error: ${this.state.error.message}
|
|
72
|
+
${this.state.error.stack}`):this.props.children}}function Cr({data:t,onEdit:e,readOnly:n,theme:r,rootName:o}){const s=wr[r]??dn;return i.jsx(yr,{data:t,setData:e,rootName:o,theme:s,collapse:2,restrictEdit:n,restrictDelete:n,restrictAdd:n,restrictTypeSelection:n?!0:void 0})}function Or(t){const[e,n]=b.useState(t.initialData);b.useEffect(()=>{t.registerUpdater(o=>{n(o)})},[]);const r=o=>{n(o),t.onEdit(o)};return i.jsx(Cr,{data:e,onEdit:r,readOnly:t.readOnly,theme:t.theme,rootName:t.rootName})}function Sr(t,e){let n=null,r=null;return n=En.createRoot(t),n.render(i.jsx(Dr,{children:i.jsx(Or,{initialData:e.initialData,onEdit:e.onEdit,readOnly:e.readOnly,theme:e.theme,rootName:e.rootName,registerUpdater:o=>{r=o}})})),{updateData:o=>{r==null||r(o)},destroy:()=>{n&&(n.unmount(),n=null)}}}function kr(t,e={}){const{enabled:n=!0,readOnly:r=!1,theme:o="githubDark",rootName:s="state$",position:a="right"}=e;if(!n)return{destroy:()=>{}};const m=Pn();let h=null,l=null,u=null,p=null;h=new In({rootName:s,readOnly:r,position:a,onClose:()=>{x()}});const y=()=>{if(!h)return;h.show(),l==null||l.setPanelVisible(!0);const w=(N=10)=>{const A=h==null?void 0:h.getEditorRoot();if(!A){N>0?setTimeout(()=>w(N-1),16):console.warn("[Legend State DevTools] Could not find #lsdt-json-editor-root after retries");return}if(p)return;const T=(u==null?void 0:u.getSnapshot())??{};p=Sr(A,{initialData:T,onEdit:R=>{u==null||u.setData(R)},readOnly:r,theme:o,rootName:s})};w()},x=()=>{p&&(p.destroy(),p=null),h==null||h.hide(),l==null||l.setPanelVisible(!1)},j=()=>{h!=null&&h.isVisible()?x():y()};return l=new Rn({onTogglePanel:j,rootName:s}),l.mount(),m.add(()=>l==null?void 0:l.unmount()),u=Mn(t,{onSnapshot:w=>{p==null||p.updateData(w)}}),m.add(()=>u==null?void 0:u.destroy()),m.add(()=>{p&&(p.destroy(),p=null)}),m.add(()=>h==null?void 0:h.unmount()),{destroy:()=>{m.run()}}}exports.init=kr;
|
|
73
|
+
//# sourceMappingURL=index.js.map
|