legend-state-dev-tools 0.0.12 → 0.0.16

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/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export declare interface DevToolsOptions {
10
10
  theme?: string;
11
11
  rootName?: string;
12
12
  position?: 'left' | 'right';
13
+ defaultOpen?: boolean;
13
14
  }
14
15
 
15
16
  export declare function init(observable$: ObservableParam<any>, options?: DevToolsOptions): DevTools;
package/dist/index.js CHANGED
@@ -1,42 +1,42 @@
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+`:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),j=require("react"),On=require("react-dom/client");var ot={exports:{}},Sn=ot.exports,zt;function kn(){return zt||(zt=1,(function(t,e){(function(n,r){r(e)})(Sn,function(n){function r(){return r=Object.assign?Object.assign.bind():function(p){for(var h=1;h<arguments.length;h++){var u=arguments[h];for(var y in u)Object.prototype.hasOwnProperty.call(u,y)&&(p[y]=u[y])}return p},r.apply(this,arguments)}function o(p,h){p.prototype=Object.create(h.prototype),p.prototype.constructor=p,s(p,h)}function a(p){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},a(p)}function s(p,h){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,y){return u.__proto__=y,u},s(p,h)}function g(p,h,u){return g=(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(y,E,N){var z=[null];z.push.apply(z,E);var I=new(Function.bind.apply(y,z));return N&&s(I,N.prototype),I},g.apply(null,arguments)}function f(p){var h=typeof Map=="function"?new Map:void 0;return f=function(u){if(u===null||Function.toString.call(u).indexOf("[native code]")===-1)return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(u))return h.get(u);h.set(u,y)}function y(){return g(u,arguments,a(this).constructor)}return y.prototype=Object.create(u.prototype,{constructor:{value:y,enumerable:!1,writable:!0,configurable:!0}}),s(y,u)},f(p)}var l=(function(){function p(u){this.cache=void 0,this.cache=u}var h=p.prototype;return h.define=function(u,y){this.cache[u]=y},h.get=function(u){return this.cache[u]},h.remove=function(u){delete this.cache[u]},h.reset=function(){this.cache={}},h.load=function(u){this.cache=r({},this.cache,u)},p})(),c=(function(p){function h(u){var y;return(y=p.call(this,u)||this).name="Eta Error",y}return o(h,p),h})(f(Error)),d=(function(p){function h(u){var y;return(y=p.call(this,u)||this).name="EtaParser Error",y}return o(h,p),h})(c),m=(function(p){function h(u){var y;return(y=p.call(this,u)||this).name="EtaRuntime Error",y}return o(h,p),h})(c),x=(function(p){function h(u){var y;return(y=p.call(this,u)||this).name="EtaNameResolution Error",y}return o(h,p),h})(c);function b(p,h,u){var y=h.slice(0,u).split(/\n/),E=y.length,N=y[E-1].length+1;throw p+=" at line "+E+" col "+N+`:
2
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+`
3
+ `+h.split(/\n/)[E-1]+`
4
+ `+Array(N).join(" ")+"^",new d(p)}function D(p,h,u,y){var E=h.split(`
5
+ `),N=Math.max(u-3,0),z=Math.min(E.length,u+3),I=y,de=E.slice(N,z).map(function(je,Oe){var re=Oe+N+1;return(re==u?" >> ":" ")+re+"| "+je}).join(`
6
+ `),Y=new m((I?I+":"+u+`
7
+ `:"line "+u+`
8
8
  `)+de+`
9
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
10
+ `+p.message);throw Y.name=p.name,Y}var O=(function(){return Promise.resolve()}).constructor;function A(p,h){var u=this.config,y=h&&h.async?O:Function;try{return new y(u.varName,"options",this.compileToString.call(this,p,h))}catch(E){throw E instanceof SyntaxError?new d(`Bad template syntax
11
11
 
12
12
  `+E.message+`
13
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+`
14
+ `+this.compileToString.call(this,p,h)+`
15
+ `):E}}function T(p,h){var u=this.config,y=h&&h.async,E=this.compileBody,N=this.parse.call(this,p),z=u.functionHeader+`
16
16
  let include = (template, data) => this.render(template, data, options);
17
17
  let includeAsync = (template, data) => this.renderAsync(template, data, options);
18
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")+'"':"")+`};
19
+ let __eta = {res: "", e: this.config.escapeFunction, f: this.config.filterFunction`+(u.debug?', line: 1, templateStr: "'+p.replace(/\\|"/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n")+'"':"")+`};
20
20
 
21
21
  function layout(path, data) {
22
22
  __eta.layout = path;
23
23
  __eta.layoutData = data;
24
- }`+(c.debug?"try {":"")+(c.useWith?"with("+c.varName+"||{}){":"")+`
24
+ }`+(u.debug?"try {":"")+(u.useWith?"with("+u.varName+"||{}){":"")+`
25
25
 
26
- `+E.call(this,k)+`
26
+ `+E.call(this,N)+`
27
27
  if (__eta.layout) {
28
- __eta.res = `+(g?"await includeAsync":"include")+" (__eta.layout, {..."+c.varName+`, body: __eta.res, ...__eta.layoutData});
28
+ __eta.res = `+(y?"await includeAsync":"include")+" (__eta.layout, {..."+u.varName+`, body: __eta.res, ...__eta.layoutData});
29
29
  }
30
- `+(c.useWith?"}":"")+(c.debug?"} catch (e) { this.RuntimeErr(e, __eta.templateStr, __eta.line, options.filepath) }":"")+`
30
+ `+(u.useWith?"}":"")+(u.debug?"} catch (e) { this.RuntimeErr(e, __eta.templateStr, __eta.line, options.filepath) }":"")+`
31
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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};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">
32
+ `;if(u.plugins)for(var I=0;I<u.plugins.length;I++){var de=u.plugins[I];de.processFnString&&(z=de.processFnString(z,u))}return z}function _(p){for(var h=this.config,u=0,y=p.length,E="";u<y;u++){var N=p[u];if(typeof N=="string")E+="__eta.res+='"+N+`'
33
+ `;else{var z=N.t,I=N.val||"";h.debug&&(E+="__eta.line="+N.lineNo+`
34
+ `),z==="r"?(h.autoFilter&&(I="__eta.f("+I+")"),E+="__eta.res+="+I+`
35
+ `):z==="i"?(h.autoFilter&&(I="__eta.f("+I+")"),h.autoEscape&&(I="__eta.e("+I+")"),E+="__eta.res+="+I+`
36
+ `):z==="e"&&(E+=I+`
37
+ `)}}return E}var W={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function te(p){return W[p]}var G={autoEscape:!0,autoFilter:!1,autoTrim:[!1,"nl"],cache:!1,cacheFilepaths:!0,debug:!1,escapeFunction:function(p){var h=String(p);return/[&<>"']/.test(h)?h.replace(/[&<>"']/g,te):h},filterFunction:function(p){return String(p)},functionHeader:"",parse:{exec:"",interpolate:"=",raw:"~"},plugins:[],rmWhitespace:!1,tags:["<%","%>"],useWith:!1,varName:"it",defaultExtension:".eta"},X=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,ee=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,U=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function L(p){return p.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function M(p,h){return p.slice(0,h).split(`
38
+ `).length}function J(p){var h=this.config,u=[],y=!1,E=0,N=h.parse;if(h.plugins)for(var z=0;z<h.plugins.length;z++){var I=h.plugins[z];I.processTemplate&&(p=I.processTemplate(p,h))}function de(se,ge){se&&(se=(function(ae,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"?ae.trim():(ce==="_"||ce==="slurp"?ae=ae.trimStart():ce!=="-"&&ce!=="nl"||(ae=ae.replace(/^(?:\r\n|\n|\r)/,"")),Q==="_"||Q==="slurp"?ae=ae.trimEnd():Q!=="-"&&Q!=="nl"||(ae=ae.replace(/(?:\r\n|\n|\r)$/,"")),ae):ae})(se,h,y,ge),se&&(se=se.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),u.push(se)))}h.rmWhitespace&&(p=p.replace(/[\r\n]+/g,`
39
+ `).replace(/^\s+|\s+$/gm,"")),X.lastIndex=0,ee.lastIndex=0,U.lastIndex=0;for(var Y,je=[N.exec,N.interpolate,N.raw].reduce(function(se,ge){return se&&ge?se+"|"+L(ge):ge?L(ge):se},""),Oe=new RegExp(L(h.tags[0])+"(-|_)?\\s*("+je+")?\\s*","g"),re=new RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?"+L(h.tags[1])+")","g");Y=Oe.exec(p);){var Pe=p.slice(E,Y.index);E=Y[0].length+Y.index;var _e=Y[2]||"";de(Pe,Y[1]),re.lastIndex=E;for(var B=void 0,fe=!1;B=re.exec(p);){if(B[1]){var we=p.slice(E,B.index);Oe.lastIndex=E=re.lastIndex,y=B[2],fe={t:_e===N.exec?"e":_e===N.raw?"r":_e===N.interpolate?"i":"",val:we};break}var ve=B[0];if(ve==="/*"){var P=p.indexOf("*/",re.lastIndex);P===-1&&b("unclosed comment",p,B.index),re.lastIndex=P}else ve==="'"?(ee.lastIndex=B.index,ee.exec(p)?re.lastIndex=ee.lastIndex:b("unclosed string",p,B.index)):ve==='"'?(U.lastIndex=B.index,U.exec(p)?re.lastIndex=U.lastIndex:b("unclosed string",p,B.index)):ve==="`"&&(X.lastIndex=B.index,X.exec(p)?re.lastIndex=X.lastIndex:b("unclosed string",p,B.index))}fe?(h.debug&&(fe.lineNo=M(p,Y.index)),u.push(fe)):b("unclosed tag",p,Y.index)}if(de(p.slice(E,p.length),!1),h.plugins)for(var $=0;$<h.plugins.length;$++){var ie=h.plugins[$];ie.processAST&&(u=ie.processAST(u,h))}return u}function ne(p,h){var u=h&&h.async?this.templatesAsync:this.templatesSync;if(this.resolvePath&&this.readFile&&!p.startsWith("@")){var y=h.filepath,E=u.get(y);if(this.config.cache&&E)return E;var N=this.readFile(y),z=this.compile(N,h);return this.config.cache&&u.define(y,z),z}var I=u.get(p);if(I)return I;throw new x("Failed to get template '"+p+"'")}function he(p,h,u){var y,E=r({},u,{async:!1});return typeof p=="string"?(this.resolvePath&&this.readFile&&!p.startsWith("@")&&(E.filepath=this.resolvePath(p,E)),y=ne.call(this,p,E)):y=p,y.call(this,h,E)}function oe(p,h,u){var y,E=r({},u,{async:!0});typeof p=="string"?(this.resolvePath&&this.readFile&&!p.startsWith("@")&&(E.filepath=this.resolvePath(p,E)),y=ne.call(this,p,E)):y=p;var N=y.call(this,h,E);return Promise.resolve(N)}function pe(p,h){var u=this.compile(p,{async:!1});return he.call(this,u,h)}function le(p,h){var u=this.compile(p,{async:!0});return oe.call(this,u,h)}var q=(function(){function p(u){this.config=void 0,this.RuntimeErr=D,this.compile=A,this.compileToString=T,this.compileBody=_,this.parse=J,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=u?r({},G,u):r({},G)}var h=p.prototype;return h.configure=function(u){this.config=r({},this.config,u)},h.withConfig=function(u){return r({},this,{config:r({},this.config,u)})},h.loadTemplate=function(u,y,E){if(typeof y=="string")(E&&E.async?this.templatesAsync:this.templatesSync).define(u,this.compile(y,E));else{var N=this.templatesSync;(y.constructor.name==="AsyncFunction"||E&&E.async)&&(N=this.templatesAsync),N.define(u,y)}},p})(),Z=(function(p){function h(){return p.apply(this,arguments)||this}return o(h,p),h})(q);n.Eta=Z})})(ot,ot.exports)),ot.exports}var Tn=kn();const Nn=`<div class="lsdt-toolbar-header">
40
40
  <div class="lsdt-toolbar-title">
41
41
  <span class="lsdt-toolbar-indicator"></span>
42
42
  Legend State
@@ -49,25 +49,28 @@ return __eta.res;
49
49
  <%= it.panelVisible ? 'Hide' : 'Show' %> <%= it.rootName %>
50
50
  </button>
51
51
  </div>
52
- `,On=`<div class="lsdt-panel-header">
52
+ `,An=`<div class="lsdt-panel-header">
53
53
  <h3><%= it.rootName %></h3>
54
54
  <div class="lsdt-panel-actions">
55
55
  <% if (it.readOnly) { %>
56
56
  <span class="lsdt-readonly-badge">Read-only</span>
57
57
  <% } %>
58
+ <button class="lsdt-dump-btn" data-action="dump-state" title="Download state as JSON">
59
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
60
+ </button>
58
61
  <button class="lsdt-close-btn" data-action="close-panel" title="Close">&times;</button>
59
62
  </div>
60
63
  </div>
61
64
  <div class="lsdt-panel-content">
62
65
  <div id="lsdt-json-editor-root"></div>
63
66
  </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
67
+ `,Ln=new Tn.Eta({autoEscape:!0,autoTrim:!1}),Rn={toolbar:Nn,panel:An};function qt(t,e){const n=Rn[t];if(!n)return console.error(`[LSDT] Template not found: ${t}`),"";try{return Ln.renderString(n,e)}catch(r){return console.error(`[LSDT] Error rendering template ${t}:`,r),""}}function _n(t){return qt("toolbar",t)}function Pn(t){return qt("panel",t)}const St="lsdt";function Mn(t,e){const n=localStorage.getItem(`${St}-${t}`);return n===null?e:n==="true"}function Bt(t,e){return localStorage.getItem(`${St}-${t}`)||e}function $t(t,e){localStorage.setItem(`${St}-${t}`,e)}function In(){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 Fn{constructor(e={}){this.container=null,this.isDragging=!1,this.offsetX=0,this.offsetY=0,this.isMinimized=Mn("toolbar-minimized",!1),this.panelVisible=!1,this.handleClick=n=>{var s;const o=n.target.closest("[data-action]");if(!o)return;o.getAttribute("data-action")==="toggle-panel"&&((s=this.onTogglePanel)==null||s.call(this))},this.handleMouseDown=n=>{if(n.target.tagName!=="BUTTON"){if(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}document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}},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"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)},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=_n(e)}attachEventListeners(){this.container&&(this.container.addEventListener("click",this.handleClick),this.container.addEventListener("mousedown",this.handleMouseDown))}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 Vn{constructor(e={}){this.container=null,this.visible=!1,this.resizeHandle=null,this.isDragging=!1,this.dragOffsetX=0,this.dragOffsetY=0,this.dragStartLeft=0,this.dragStartTop=0,this.handleClick=n=>{var s,g;const o=n.target.closest("[data-action]");if(!o)return;const a=o.getAttribute("data-action");a==="close-panel"?(s=this.onClose)==null||s.call(this):a==="dump-state"&&((g=this.onDumpState)==null||g.call(this))},this.handleDragStart=n=>{const r=n.target;if(r.closest("button")||r.closest("[data-action]")||(n.preventDefault(),!this.container))return;this.isDragging=!0;const o=this.container.getBoundingClientRect();this.dragOffsetX=n.clientX-o.left,this.dragOffsetY=n.clientY-o.top,this.dragStartLeft=o.left,this.dragStartTop=o.top,this.container.classList.add("lsdt-dragging"),document.addEventListener("mousemove",this.handleDragMove),document.addEventListener("mouseup",this.handleDragEnd)},this.handleDragMove=n=>{if(!this.isDragging||!this.container)return;const r=n.clientX-this.dragOffsetX-this.dragStartLeft,o=n.clientY-this.dragOffsetY-this.dragStartTop;this.container.style.transform=`translate(${r}px, ${o}px)`},this.handleDragEnd=()=>{if(!this.isDragging||!this.container)return;this.isDragging=!1;const n=this.container.getBoundingClientRect();this.container.style.left=`${n.left}px`,this.container.style.top=`${n.top}px`,this.container.style.right="auto",this.container.style.bottom="auto",this.container.style.transform="",this.container.classList.remove("lsdt-dragging"),document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd),$t("panel-position",JSON.stringify({top:this.container.style.top,left:this.container.style.left}))},this.rootName=e.rootName||"state$",this.readOnly=e.readOnly||!1,this.onClose=e.onClose,this.onDumpState=e.onDumpState,this.position=e.position||"right"}toggle(){this.visible?this.hide():this.show()}show(){if(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");const e=Bt("panel-width","");e&&(this.container.style.width=e),this.restoreSavedPosition(),this.resizeHandle=document.createElement("div"),this.resizeHandle.className="lsdt-resize-handle",this.attachResizeListeners(this.resizeHandle),document.body.appendChild(this.container),this.attachEventListeners()}this.render()}hide(){var e;this.visible=!1,this.cleanupListeners(),(e=this.container)==null||e.remove(),this.container=null,this.resizeHandle=null}isVisible(){return this.visible}getIsDragging(){return this.isDragging}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=Pn(e),this.resizeHandle&&this.container.appendChild(this.resizeHandle),this.attachDragListeners()}attachEventListeners(){this.container&&this.container.addEventListener("click",this.handleClick)}attachResizeListeners(e){e.addEventListener("mousedown",n=>{n.preventDefault();const r=this.container;if(!r)return;const o=n.clientX,a=r.getBoundingClientRect().width,s=this.position==="left";r.classList.add("lsdt-resizing");const g=l=>{const c=l.clientX-o,d=s?a+c:a-c,m=Math.max(280,Math.min(d,window.innerWidth*.9));r.style.width=`${m}px`},f=()=>{r.classList.remove("lsdt-resizing"),document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",f),$t("panel-width",r.style.width)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",f)})}restoreSavedPosition(){if(!this.container)return;const e=Bt("panel-position","");if(e)try{const n=JSON.parse(e);this.container.style.top=n.top,this.container.style.left=n.left,this.container.style.right="auto",this.container.style.bottom="auto"}catch{}}attachDragListeners(){if(!this.container)return;const e=this.container.querySelector(".lsdt-panel-header");e&&e.addEventListener("mousedown",this.handleDragStart)}cleanupListeners(){document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd)}unmount(){this.container&&(this.cleanupListeners(),this.container.removeEventListener("click",this.handleClick),this.container.remove(),this.container=null,this.resizeHandle=null),this.visible=!1}}function Kn(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(a){console.error("[Legend State DevTools] Failed to set data:",a)}},destroy:()=>{r&&(r(),r=null)}}}const ze=(t,e,n,r,o)=>{if(!r)throw new Error(o??`Invalid property path: ${e}
68
+ Couldn't access "${n}" in ${JSON.stringify(t)}`)},Wt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),dt=t=>Array.isArray(t),Zt=(t,e)=>t.filter(((n,r)=>r!==e)),zn=(t,e,n,r={})=>{const{remove:o=!1,createNew:a=!0,noError:s=!1}=r,g=t,f=typeof(l=e)=="string"?l:typeof l=="number"?String(l):l.reduce(((m,x)=>typeof x=="number"?`${m}[${x}]`:m===""?x:`${m}.${x}`),"");var l;const c=Object.assign(Object.assign({},r),{remove:o,createNew:a,noError:s,fullData:g,fullPath:f}),d=Array.isArray(e)?e:(m=>Array.isArray(m)?m:m.split(/(\.|\[\d+\])/).filter((x=>x!=="."&&x!=="")).map((x=>{const b=/\[(\d+)\]/.exec(x);return b?Number(b[1]):x})).flat())(e).filter((m=>m!==""));return dt(t)&&o&&d.length===1?Zt(t,d[0]):it(t,d,n,c)},it=(t,e,n,r)=>{const o=Wt(t)?Object.assign({},t):null,a=dt(t)?[...t]:null;if(e.length===0)return t;if(!o&&!a)throw new Error("Can't assign property -- invalid input object");const{createNew:s,remove:g,noError:f,fullData:l,fullPath:c}=r,d=e[0];if(a&&typeof d=="string")return a.map((D=>it(D,e,n,r)));if(e.length===1){if(o&&typeof d=="string"){const D=Bn(o,d,n,r);return D??o}return a&&typeof d=="number"?($n(a,d,n,r),a):(ze(l,c,d,f),t)}const m=o||a||[];if(g&&e.length===2&&typeof e[1]=="number"){const D=m[d],O=e[1];return dt(D)?m[d]=Zt(D,O):ze(l,c,d,f,"Trying to remove an indexed item from an object that is not an array"),m}const x=e.slice(1);if(d in t){if(b=m[d],!dt(b)&&!Wt(b)){if(!s)return ze(l,c,d,f),m;m[d]={}}return m[d]=it(m[d],x,n,r),m}var b;if(s){const D=typeof x[0]=="number"?[]:{};if(o)return m[d]=D,m[d]=it(m[d],x,n,r),m;if(a&&Array.isArray(m)){m.push(D);const O=m.length-1;return m[O]=it(m[O],x,n,r),m}}return ze(l,c,d,f),m},Bn=(t,e,n,r)=>{const{remove:o,createNew:a,noError:s,insertAfter:g,insertBefore:f,fullData:l,fullPath:c}=r;if(f!==void 0||g!==void 0){const m=Object.entries(t);let x=1/0;return x=typeof f=="number"?f:typeof g=="number"?g:m.findIndex((([b,D])=>b===(f??g))),g&&x++,m.splice(x,0,[e,n]),Object.fromEntries(m)}const d=e in t;o?d?delete t[e]:ze(l,c,e,s):a||d?t[e]=n:ze(l,c,e,s)},$n=(t,e,n,r)=>{const{noError:o,fullData:a,fullPath:s,createNew:g,insert:f}=r;f&&t.splice(e,0,n),e in t?t[e]=n:g?t.push(n):ze(a,s,e,o)},qe=(t,e,n)=>{const r=Array.isArray(e)?e:Wn(e);if(r.length===0)return t;const o=r[0];if(Array.isArray(t)&&typeof o!="number")return t.map((s=>qe(s,r)));if(typeof t!="object"||t===null||!(o in t))return Hn(t,o);const a=t[o];return r.length===1?a:qe(a,r.slice(1))},Wn=t=>t.split(/(\.|\[\d+\])/).filter((e=>e!=="."&&e!=="")).map((e=>{const n=/\[(\d+)\]/.exec(e);return n?Number(n[1]):e})).flat(),Hn=(t,e,n)=>{throw new Error(`Unable to extract object property
66
69
  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
+ In object: ${JSON.stringify(t)}`)};function Qt(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 Je(t,e,n,r){return new(n||(n=Promise))((function(o,a){function s(l){try{f(r.next(l))}catch(c){a(c)}}function g(l){try{f(r.throw(l))}catch(c){a(c)}}function f(l){var c;l.done?o(l.value):(c=l.value,c instanceof n?c:new n((function(d){d(c)}))).then(s,g)}f((r=r.apply(t,[])).next())}))}const en=({className:t,name:e,value:n,setValue:r,handleKeyPress:o,styles:a,textAreaRef:s})=>{if(typeof n!="string")return null;const g=n.slice(-1)===`
71
+ `?n+".":n;return i.jsxs("div",{style:{display:"grid"},children:[i.jsx("textarea",{id:`${e}_textarea`,ref:s,style:Object.assign({height:"auto",gridArea:"1 / 1 / 2 / 2",overflowY:"auto",whiteSpace:"pre-wrap"},a),rows:1,className:t,name:`${e}_textarea`,value:n,onChange:f=>r(f.target.value),autoFocus:!0,onFocus:f=>{n.length<40&&f.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"},a),children:g})]})},Ze=t=>t!==null&&typeof t=="object",tn=(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,a])=>{const s=[...e.path,o],g=Object.assign(Object.assign({},e),{key:o,path:s,level:e.level+1,value:a,size:s.length,parentData:r});return Ze(a)?wt(t,g,n):n(g,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}},Ht=({key:t,path:e},n="")=>!!Qe({value:t},n)||!!e.some((r=>Qe({value:r},n))),He=(t,e)=>(e??"")+t.map((n=>n===""?"\0":n)).join("."),kt=t=>t.shiftKey?"Shift":t.metaKey?"Meta":t.ctrlKey?"Control":t.altKey?"Alt":void 0,Un=(t,e,n)=>{const r=t.key,o=kt(t);if(Array.isArray(e))return!!o&&e.includes(o);const{key:a,modifier:s}=e;return(n!=="stringLineBreak"||r!=="Enter"||o!=="Shift"||a!=="Enter"||!(s!=null&&s.includes("Shift")))&&r===a&&(s===o||Array.isArray(s)&&s.includes(o))},Ke={key:"Enter"},Ut={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),a=e.slice(-1)[0];if(a===void 0)return null;const s=qe(t,o),g=Yn(s);Array.isArray(s)||r(g,(({key:c,value:d})=>[c,d]));const f=g.findIndex((c=>c.key===a)),l=g[f+(n==="next"?1:-1)];return l?Ze(l.value)?Object.keys(l.value).length===0?Be(t,[...o,l.key],n,r):nn(t,[...o,l.key],n,r):[...o,l.key]:o.length===0?null:Be(t,o,n,r)},nn=(t,e,n="next",r)=>{const o=qe(t,e);if(!Ze(o))return e;const a=Array.isArray(o)?o.map(((g,f)=>f)):Object.keys(o);r(a,(g=>[g,o]));const s=n==="next"?a[0]:a[a.length-1];return nn(t,[...e,s],n,r)},Yn=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}))),rn=(t,e)=>{var n,r,o,a;const s=t.current,g=(n=s==null?void 0:s.selectionStart)!==null&&n!==void 0?n:1/0,f=(r=s==null?void 0:s.selectionEnd)!==null&&r!==void 0?r:1/0,l=((o=s==null?void 0:s.textContent)===null||o===void 0?void 0:o.slice(0,g))+e+((a=s==null?void 0:s.textContent)===null||a===void 0?void 0:a.slice(f));return s.value=l,s==null||s.setSelectionRange(g+1,g+1),l},Dt=t=>{if(t!==on){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}},on="__​undefined__",Tt={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)"}},sn=j.createContext({getStyles:()=>({}),icons:{}}),Gn=({theme:t=Tt,icons:e={},docRoot:n,children:r})=>{const o=Xn(t,n);return i.jsx(sn.Provider,{value:{getStyles:(a,s)=>typeof o[a]=="function"?o[a](s):o[a],icons:e},children:r})},Re=()=>j.useContext(sn),Xn=(t,e)=>{var n,r,o,a;const s={},g=(Array.isArray(t)?t:[t]).map((c=>Jn(c)?xt({fragments:{},styles:c},s):xt(c,s))),f=xt(Tt,{});Object.keys(f).forEach((c=>{const d=c;g.forEach((m=>{m[d]&&(f[d]=Object.assign(Object.assign({},f[d]),m[d]))}))}));const l=Object.assign({},f);return Object.entries(s).forEach((([c,d])=>{const m=c;l[m]=x=>{const b=d(x)||{};return Object.assign(Object.assign({},f[m]),b)}})),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",(a=l==null?void 0:l.iconCopy)===null||a===void 0?void 0:a.color),l},xt=(t,e)=>{const{fragments:n,styles:r}=t,o={};return Object.entries(r).forEach((([a,s])=>{const g=(Array.isArray(s)?s:[s]).reduce(((f,l)=>{var c,d;if(typeof l=="function")return e[a]=l,Object.assign({},f);if(typeof l=="string"){const m=(c=n==null?void 0:n[l])!==null&&c!==void 0?c:l;return typeof m=="string"?Object.assign(Object.assign({},f),{[(d=qn[a])!==null&&d!==void 0?d:"color"]:m}):Object.assign(Object.assign({},f),m)}return Object.assign(Object.assign({},f),l)}),{});o[a]=g})),o},Jn=t=>!("styles"in t),qn={container:"backgroundColor",collection:"backgroundColor",collectionInner:"backgroundColor",collectionElement:"backgroundColor",dropZone:"borderColor",inputHighlight:"backgroundColor"},an=j.createContext(null),Zn=({children:t,onEditEvent:e,onCollapse:n})=>{const[r,o]=j.useState(null),[a,s]=j.useState(null),[g,f]=j.useState(null),[l,c]=j.useState({path:null,pathString:null}),d=j.useRef(null),m=j.useRef("next"),x=j.useRef(null);return i.jsx(an.Provider,{value:{collapseState:r,setCollapseState:b=>{o(b),n&&b!==null&&(Array.isArray(b)?b.forEach((D=>n(D))):n(b)),b!==null&&setTimeout((()=>o(null)),2e3)},getMatchingCollapseState:b=>{if(Array.isArray(r)){for(const D of r)if(Yt(b,D))return D;return null}return Yt(b,r)?r:null},currentlyEditingElement:a,setCurrentlyEditingElement:(b,D)=>{const O=typeof b=="string"||b===null?b:He(b,D==="key"?"key_":void 0);a!==null&&O!==null&&d.current!==null&&d.current(),s(O),e&&(Array.isArray(b)||b===null)&&e(b,D==="key"),d.current=typeof D=="function"?D:null},areChildrenBeingEdited:b=>a!==null&&a.includes(b),previouslyEditedElement:x.current,setPreviouslyEditedElement:b=>{x.current=b},tabDirection:m.current,setTabDirection:b=>{m.current=b},previousValue:g,setPreviousValue:f,dragSource:l,setDragSource:c},children:t})},We=()=>{const t=j.useContext(an);if(!t)throw new Error("Missing Context Provider");return t},Yt=(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**",Qn=({nodeData:t,showStringQuotes:e=!0,stringTruncate:n=200,pathString:r,canEdit:o,setIsEditing:a,styles:s,translate:g,value:f,TextWrapper:l=({children:c})=>c})=>{const c=f??t.value,[d,m]=j.useState(!1),x=e?'"':"",b=c.length>n,D=()=>{o?a(!0):m(!d)};return i.jsxs("div",{id:`${r}_display`,onDoubleClick:D,onClick:O=>{(O.getModifierState("Control")||O.getModifierState("Meta"))&&D()},className:"jer-value-string",style:s,children:[x,b?i.jsxs(i.Fragment,d?{children:[i.jsx(l,{children:i.jsxs("span",{children:[c,x]})}),i.jsxs("span",{className:"jer-string-expansion jer-show-less",onClick:()=>m(!1),children:[" ",g("SHOW_LESS",t)]})]}:{children:[i.jsxs(l,{children:[i.jsx("span",{children:c.slice(0,n-2).trimEnd()})," "]}),i.jsx("span",{className:"jer-string-expansion jer-ellipsis",onClick:()=>m(!0),children:"..."}),x]}):i.jsx(l,{children:`${c}${x}`})]})},er=({styles:t,pathString:e,value:n,setValue:r,handleEdit:o,handleKeyboard:a,keyboardCommon:s})=>{const g=j.useRef(null);return i.jsx(en,{className:"jer-input-text",textAreaRef:g,name:e,value:n,setValue:r,handleKeyPress:f=>{a(f,Object.assign({stringConfirm:o,stringLineBreak:()=>{const l=rn(g,`
72
+ `);r(l)}},s))},styles:t})},tr=t=>{var{isEditing:e,path:n,enumType:r}=t,o=Qt(t,["isEditing","path","enumType"]);const{getStyles:a}=Re(),s=He(n),{value:g,setValue:f,nodeData:l,handleEdit:c,handleKeyboard:d,keyboardCommon:m}=o;return e&&r?i.jsxs("div",{className:"jer-select jer-select-enums",children:[i.jsx("select",{name:`${s}-value-select`,className:"jer-select-inner",onChange:x=>f(x.target.value),value:g,autoFocus:!0,onKeyDown:x=>{d(x,Object.assign({stringConfirm:c},m))},children:r.values.map((x=>i.jsx("option",{value:x,children:x},x)))}),i.jsx("span",{className:"focus"})]}):e?i.jsx(er,Object.assign({styles:a("input",l),pathString:s},o,{setValue:o.setValue})):i.jsx(Qn,Object.assign({pathString:s,styles:a("string",l)},o))},nr=({value:t,setValue:e,isEditing:n,path:r,setIsEditing:o,handleEdit:a,nodeData:s,handleKeyboard:g,keyboardCommon:f})=>{const{getStyles:l}=Re();return n?i.jsx("input",{className:"jer-input-number",type:"text",name:He(r),value:t,onChange:c=>e(c.target.value.replace(/[^0-9.-]/g,"")),autoFocus:!0,onFocus:c=>setTimeout((()=>c.target.select()),10),onKeyDown:c=>g(c,Object.assign({numberConfirm:a,numberUp:()=>e(Number(t)+1),numberDown:()=>e(Number(t)-1)},f)),style:Object.assign({width:String(t).length/1.5+2+"em"},l("input",s))}):i.jsx("span",{onDoubleClick:()=>o(!0),className:"jer-value-number",style:l("number",s),children:t})},rr=({value:t,setValue:e,isEditing:n,path:r,setIsEditing:o,handleEdit:a,nodeData:s,handleKeyboard:g,keyboardCommon:f})=>{const{getStyles:l}=Re();return typeof t!="boolean"?null:n?i.jsx("input",{className:"jer-input-boolean",type:"checkbox",name:He(r),checked:t,onChange:()=>e(!t),onKeyDown:c=>{c.key===" "&&c.preventDefault(),g(c,Object.assign({booleanConfirm:a,booleanToggle:()=>e(!t)},f))},autoFocus:!0}):i.jsx("span",{onDoubleClick:()=>o(!0),className:"jer-value-boolean",style:l("boolean",s),children:String(t)})},or=(t,e)=>{const n=j.useRef(void 0),r=j.useRef(e);j.useEffect((()=>{r.current=e}),[e]);const o=a=>{r.current(a)};j.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])},ir=({value:t,isEditing:e,setIsEditing:n,handleEdit:r,nodeData:o,handleKeyboard:a,keyboardCommon:s})=>{const{getStyles:g}=Re();return or(e,(f=>a(f,Object.assign({confirm:r},s)))),i.jsx("div",{onDoubleClick:()=>n(!0),className:"jer-value-null",style:g("null",o),children:String(t)})},sr=({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})},ar=({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"})]}),lr=({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"})]}),cr=({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"})}),ur=({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"})]}),dr=({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"})]}),hr=({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"})}),pr=({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"})}),$e=({name:t,nodeData:e})=>{var n,r,o,a,s,g,f;const{getStyles:l,icons:c}=Re(),d={size:"1.4em",className:"jer-icon"};switch(t){case"add":return(n=c==null?void 0:c.add)!==null&&n!==void 0?n:i.jsx(ar,Object.assign({},d,{style:l("iconAdd",e)}));case"edit":return(r=c==null?void 0:c.edit)!==null&&r!==void 0?r:i.jsx(lr,Object.assign({},d,{style:l("iconEdit",e)}));case"delete":return(o=c==null?void 0:c.delete)!==null&&o!==void 0?o:i.jsx(cr,Object.assign({},d,{style:l("iconDelete",e),size:"1.45em"}));case"copy":return(a=c==null?void 0:c.copy)!==null&&a!==void 0?a:i.jsx(ur,Object.assign({},d,{style:l("iconCopy",e),size:"1.2em"}));case"ok":return(s=c==null?void 0:c.ok)!==null&&s!==void 0?s:i.jsx(dr,Object.assign({},d,{style:Object.assign({fontSize:"90%"},l("iconOk",e))}));case"cancel":return(g=c==null?void 0:c.cancel)!==null&&g!==void 0?g:i.jsx(hr,Object.assign({},d,{style:Object.assign({fontSize:"130%"},l("iconCancel",e))}));case"chevron":return(f=c==null?void 0:c.chevron)!==null&&f!==void 0?f:i.jsx(pr,{size:"1em",style:l("iconCollection",e)});default:return i.jsx(i.Fragment,{})}},ln=({startEdit:t,handleDelete:e,handleAdd:n,enableClipboard:r,type:o,customButtons:a,nodeData:s,translate:g,keyboardControls:f,handleKeyboard:l,editConfirmRef:c,getNewKeyOptions:d,jsonStringify:m,onEditEvent:x,showIconTooltips:b})=>{const{getStyles:D}=Re(),O=g("KEY_NEW",s),[A,T]=j.useState(O),[_,W]=j.useState(!1),{key:te,path:G,value:X}=s,ee=Array.isArray(_),U=L=>{var M;if(x&&x(L?[...G,null]:null,L),!L)return void W(!1);const J=Object.keys(qe(s.fullData,G)),ne=d?(M=d(s))===null||M===void 0?void 0:M.filter((he=>!J.includes(he))):null;ne&&T(""),W(ne==null||ne)};return i.jsxs("div",{className:"jer-edit-buttons",style:{opacity:_?1:void 0},onClick:L=>L.stopPropagation(),children:[r&&i.jsx("div",{onClick:L=>{var M;L.stopPropagation();let J,ne,he="value",oe="",pe=null;if(r){const le=kt(L);if(le&&f.clipboardModifier.includes(le)?(J=fr(G),oe=J,he="path"):(J=X,oe=typeof J=="object"?m(X):String(J)),!navigator.clipboard)return void(typeof r=="function"&&r({success:!1,value:J,stringValue:oe,path:G,key:te,type:he,errorMessage:"Can't access clipboard API"}));(M=navigator.clipboard)===null||M===void 0||M.writeText(oe).then((()=>ne=!0)).catch((q=>{ne=!1,pe=q.message})).finally((()=>{typeof r=="function"&&r({success:ne,errorMessage:pe,value:J,stringValue:oe,path:G,key:te,type:he})}))}},className:"jer-copy-pulse",title:b?g("TOOLTIP_COPY",s):"",children:i.jsx($e,{name:"copy",nodeData:s})}),t&&i.jsx("div",{onClick:t,title:b?g("TOOLTIP_EDIT",s):"",children:i.jsx($e,{name:"edit",nodeData:s})}),e&&i.jsx("div",{onClick:e,title:b?g("TOOLTIP_DELETE",s):"",children:i.jsx($e,{name:"delete",nodeData:s})}),n&&i.jsx("div",{onClick:()=>{o==="object"?U(!0):n("")},title:b?g("TOOLTIP_ADD",s):"",children:i.jsx($e,{name:"add",nodeData:s})}),a==null?void 0:a.map((({Element:L,onClick:M},J)=>i.jsx("div",{onClick:ne=>M&&M(s,ne),children:i.jsx(L,{nodeData:s})},J))),_&&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:L=>{n(L.target.value),U(!1)},defaultValue:"",autoFocus:!0,onKeyDown:L=>{l(L,{cancel:()=>U(!1)})},children:[i.jsx("option",{value:"",disabled:!0,children:_.length>0?g("KEY_SELECT",s):g("NO_KEY_OPTIONS",s)}),_.map((L=>i.jsx("option",{value:L,children:L},L)))]}),i.jsx("span",{className:"focus"})]}):i.jsx("input",{className:"jer-input-new-key",type:"text",name:"new-object-key",value:A,onChange:L=>T(L.target.value),autoFocus:!0,onFocus:L=>L.target.select(),onKeyDown:L=>{l(L,{stringConfirm:()=>{n&&(U(!1),n(A),T(O))},cancel:()=>{U(!1),T(O)}})},style:D("input",s)}),i.jsx(Nt,{onOk:()=>{ee&&!A||(U(!1),n(A))},onCancel:()=>{U(!1)},nodeData:s,editConfirmRef:c,hideOk:ee})]})]})},Nt=({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($e,{name:"ok",nodeData:n})}),i.jsx("div",{onClick:e,children:i.jsx($e,{name:"cancel",nodeData:n})})]}),fr=t=>t.reduce(((e,n)=>typeof n=="number"?`${e}[${n}]`:e===""?n:`${e}.${n}`),""),gr=["string","number","boolean","null","object","array"],cn=({props:t,collapsed:e})=>{const{data:n,nodeData:r,parentData:o,onEdit:a,onError:s,showErrorMessages:g,restrictEditFilter:f,restrictDeleteFilter:l,restrictAddFilter:c,restrictDragFilter:d,translate:m,errorMessageTimeout:x}=t,{currentlyEditingElement:b,setCurrentlyEditingElement:D}=We(),[O,A]=j.useState(null),T=Object.assign(Object.assign({},r),{collapsed:e}),{path:_,key:W,size:te}=T,G=He(_),X=!f(T),ee=!l(T),U=!c(T),L=!d(T)&&ee&&b===null,M=q=>{g&&(A(q),setTimeout((()=>A(null)),x)),console.warn("Error",q)},J=j.useCallback(((q,Z)=>{M(q.message),s&&s({currentData:T.fullData,errorValue:Z,currentValue:n,name:W,path:_,error:q})}),[s,g]),ne=b===G,he=b===`key_${G}`,oe=typeof _.slice(-1)[0]=="number",pe={isEditing:ne,isEditingKey:he,isArray:oe,canEditKey:o!==null&&X&&U&&ee&&!oe},le=W===""&&_.length>0?m("EMPTY_STRING",T):null;return{pathString:G,nodeData:T,path:_,name:W,size:te,canEdit:X,canDelete:ee,canAdd:U,canDrag:L,error:O,showError:M,onError:J,setError:A,handleEditKey:q=>{if(D(null),W===q||!o)return;const Z=_.slice(0,-1);if(Object.keys(o).includes(q))return void J({code:"KEY_EXISTS",message:m("ERROR_KEY_EXISTS",T)},q);const p=Object.fromEntries(Object.entries(o).map((([h,u])=>h===W?[q,u]:[h,u])));a(p,Z).then((h=>{h&&J({code:"UPDATE_ERROR",message:h},q)}))},derivedValues:pe,emptyStringKey:le}},un=({canDrag:t,canDragOnto:e,path:n,nodeData:r,onMove:o,onError:a,translate:s})=>{const{getStyles:g}=Re(),{dragSource:f,setDragSource:l}=We(),[c,d]=j.useState(!1),m=He(n),x=j.useMemo((()=>t?{onDragStart:A=>{A.stopPropagation(),l({path:n,pathString:m})},onDragEnd:A=>{A.stopPropagation(),l({path:null,pathString:null})}}:{}),[t,m]),b=j.useMemo((()=>A=>e?{onDragOver:T=>{T.stopPropagation(),T.preventDefault()},onDrop:T=>{T.stopPropagation(),O(A),l({path:null,pathString:null}),d(!1)},onDragEnter:T=>{var _;T.stopPropagation(),m.startsWith((_=f.pathString)!==null&&_!==void 0?_:"")||d(A)},onDragExit:T=>{T.stopPropagation(),d(!1)}}:{}),[f,e,m]),D=j.useMemo((()=>e&&f.pathString!==null?i.jsx("div",Object.assign({className:"jer-drop-target-bottom",style:{height:"50%",position:"absolute",width:"100%",top:"50%",zIndex:n.length}},b("below"))):null),[f,e,n.length]),O=A=>{var T,_;const W=(T=f.path)===null||T===void 0?void 0:T.slice(-1)[0],te=(_=f.path)===null||_===void 0?void 0:_.slice(0,-1).join("."),G=n.slice(0,-1).join(""),{parentData:X}=r;typeof W=="string"&&X&&!Array.isArray(X)&&Object.keys(X).includes(W)&&W in X&&te!==G?a({code:"KEY_EXISTS",message:s("ERROR_KEY_EXISTS",r)},W):o(f.path,n,A).then((ee=>{ee&&a({code:"UPDATE_ERROR",message:ee},r.value)}))};return{dragSourceProps:x,getDropTargetProps:b,BottomDropTarget:D,DropTargetPadding:({position:A,nodeData:T})=>c===A?i.jsx("div",{className:"jer-drag-n-drop-padding",style:g("dropZone",T)}):null,handleDrop:O}},mr=(t,e,n,r)=>{var o,a,s;if(!e.current)return 0;const g=parseInt((o=getComputedStyle(n.current).getPropertyValue("line-height"))!==null&&o!==void 0?o:"16px"),f=((s=(a=e.current)===null||a===void 0?void 0:a.offsetWidth)!==null&&s!==void 0?s:0)/(.5*g),l=r(t).replace(/\\n/g,`
70
73
  `).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;
74
+ `).map((c=>Math.ceil(c.length/f))).reduce(((c,d)=>c+d),0)*g;return Math.min(l+30,window.innerHeight-50)},ht=({isEditingKey:t,canEditKey:e,pathString:n,path:r,name:o,arrayIndexFromOne:a,handleKeyboard:s,handleEditKey:g,handleCancel:f,handleClick:l,keyValueArray:c,styles:d,getNextOrPrevious:m,emptyStringKey:x})=>{const{setCurrentlyEditingElement:b}=We(),D=typeof o=="number"?String(o+(a?1:0)):o;return t?i.jsx("input",{className:"jer-input-text jer-key-edit",type:"text",name:n,defaultValue:D,autoFocus:!0,onFocus:O=>O.target.select(),onKeyDown:O=>s(O,{stringConfirm:()=>g(O.target.value),cancel:f,tabForward:()=>{if(g(O.target.value),c){const A=c==null?void 0:c[0][0];b(A?[...r,A]:m("next"))}else b(r)},tabBack:()=>{g(O.target.value),b(m("prev"))}}),style:{width:D.length/1.5+.5+"em"}}):i.jsxs("span",{className:"jer-key-text",style:Object.assign(Object.assign({},d),{minWidth:`${Math.min(D.length+1,5)}ch`,flexShrink:D.length>10?1:0}),onDoubleClick:()=>e&&b(r,"key"),onClick:l,children:[x?i.jsx("span",{className:"jer-empty-string",children:x}):D,D!==""||x?i.jsx("span",{className:"jer-key-colon",children:":"}):null]})},dn=t=>{const{data:e,parentData:n,onEdit:r,onDelete:o,onChange:a,onMove:s,enableClipboard:g,canDragOnto:f,restrictTypeSelection:l,searchFilter:c,searchText:d,showLabel:m,stringTruncate:x,showStringQuotes:b,arrayIndexFromOne:D,indent:O,translate:A,customNodeDefinitions:T,customNodeData:_,handleKeyboard:W,keyboardControls:te,sort:G,editConfirmRef:X,jsonStringify:ee,showIconTooltips:U}=t,{getStyles:L}=Re(),{setCurrentlyEditingElement:M,setCollapseState:J,previouslyEditedElement:ne,setPreviouslyEditedElement:he,tabDirection:oe,setTabDirection:pe,previousValue:le,setPreviousValue:q}=We(),[Z,p]=j.useState(typeof e=="function"?Ct:e),{pathString:h,nodeData:u,path:y,name:E,canEdit:N,canDelete:z,canDrag:I,error:de,onError:Y,handleEditKey:je,emptyStringKey:Oe,derivedValues:re}=cn({props:t}),{dragSourceProps:Pe,getDropTargetProps:_e,BottomDropTarget:B,DropTargetPadding:fe}=un({canDrag:I,canDragOnto:f,path:y,nodeData:u,onMove:s,onError:Y,translate:A}),[we,ve]=j.useState(Ot(e,_)),P=j.useCallback((v=>{if(!a)return void p(v);const S=a({currentData:u.fullData,newValue:v,currentValue:Z,name:E,path:y});p(S)}),[a]);j.useEffect((()=>{p(typeof e=="function"?Ct:e),ve(Ot(e,_))}),[e,de]);const{CustomNode:$,customNodeProps:ie,hideKey:se,showEditTools:ge=!0,showOnEdit:ae,showOnView:xe,passOriginalNode:Se}=_,ke=[...gr,...T.filter((({showInTypesSelector:v=!1,name:S})=>v&&!!S)).map((({name:v})=>v))],ce=j.useMemo((()=>{if(typeof l=="boolean")return l?[]:ke;if(Array.isArray(l))return l;const v=l(u);return typeof v=="boolean"?v?[]:ke:v}),[u,l]),[Q,Me]=j.useState(((v,S)=>{var K;if(typeof v!="string")return null;const be=S.filter((ue=>ue instanceof Object&&ue.enum&&ue.values.includes(v)&&ue.matchPriority));return be.sort(((ue,ye)=>{var Fe,Ve;return((Fe=ye.matchPriority)!==null&&Fe!==void 0?Fe:0)-((Ve=ue.matchPriority)!==null&&Ve!==void 0?Ve:0)})),(K=be[0])!==null&&K!==void 0?K:null})(Z,ce)),{isEditing:Ee}=re,Ue=tn("value",u,c,d);if(Ee&&(!Ue||!N)){const v=Be(u.fullData,y,oe,G);M(v||ne)}if(!Ue)return null;const Ae=v=>{let S;if(M(null),q(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":S={[A("DEFAULT_NEW_KEY",u)]:Z};break;case"array":S=Z??[];break;case"number":{const K=Number(Z);S=isNaN(K)?0:K;break}default:S=Z}else S=v;r(S,y).then((K=>{K&&Y({code:"UPDATE_ERROR",message:K},S)}))},Te=()=>{M(null),le===null?(p(e),q(null)):r(le,y)},{isEditingKey:Ye,canEditKey:Ge}=re,De=!Ee&&de,me=Ee&&ce.length>1,Ie=(we!=="invalid"||$)&&!de&&ge,k=m&&!se,C=$&&(Ee&&ae||!Ee&&xe),R={value:Z,parentData:n,setValue:P,isEditing:Ee,canEdit:N,setIsEditing:N?()=>M(y):()=>{},handleEdit:Ae,handleCancel:Te,path:y,stringTruncate:x,showStringQuotes:b,nodeData:u,enumType:Q,translate:A,handleKeyboard:W,keyboardCommon:{cancel:Te,tabForward:()=>{pe("next"),he(h);const v=Be(u.fullData,y,"next",G);v&&(Ae(),M(v))},tabBack:()=>{pe("prev"),he(h);const v=Be(u.fullData,y,"prev",G);v&&(Ae(),M(v))}}},V={canEditKey:Ge,isEditingKey:Ye,pathString:h,path:y,name:E,arrayIndexFromOne:D,handleKeyboard:W,handleEditKey:je,handleCancel:Te,styles:L("property",u),getNextOrPrevious:v=>Be(u.fullData,y,v,G),emptyStringKey:Oe},F=C?i.jsx($,Object.assign({},t,{value:Z,customNodeProps:ie,setValue:P,handleEdit:Ae,handleCancel:Te,handleKeyPress:v=>W(v,{stringConfirm:Ae,cancel:Te}),isEditing:Ee,setIsEditing:()=>M(y),getStyles:L,originalNode:Se?Gt(e,R):void 0,originalNodeKey:Se?i.jsx(ht,Object.assign({},V)):void 0,canEdit:N,keyboardCommon:R.keyboardCommon,onError:Y})):Gt(e,R);return i.jsxs("div",Object.assign({className:"jer-component jer-value-component",style:{marginLeft:n!==null?O/2+"em":0,position:"relative"},draggable:I},Pe,_e("above"),{children:[B,i.jsx(fe,{position:"above",nodeData:u}),i.jsxs("div",{className:"jer-value-main-row",style:{flexWrap:E.length>10?"wrap":"nowrap"},children:[k&&i.jsx(ht,Object.assign({},V)),i.jsxs("div",{className:"jer-value-and-buttons",children:[i.jsx("div",{className:"jer-input-component",children:F}),Ee?i.jsx(Nt,{onOk:Ae,onCancel:Te,nodeData:u,editConfirmRef:X}):Ie&&i.jsx(ln,{startEdit:N?()=>{q(le),M(y,Te)}:void 0,handleDelete:z?()=>{o(Z,y).then((v=>{v&&Y({code:"DELETE_ERROR",message:v},Z)}))}:void 0,enableClipboard:g,translate:A,customButtons:t.customButtons,nodeData:u,handleKeyboard:W,keyboardControls:te,editConfirmRef:X,jsonStringify:ee,showIconTooltips:U}),me&&i.jsxs("div",{className:"jer-select jer-select-types",children:[i.jsx("select",{name:`${E}-type-select`,className:"jer-select-inner",onChange:v=>(S=>{const K=T.find((ye=>ye.name===S));if(K)return r(K.defaultValue,y),ve(S),Me(null),M(null),void J({path:y,collapsed:!1,includeChildren:!1});const be=ce.find((ye=>ye instanceof Object&&ye.enum===S));if(be)return typeof Z=="string"&&be.values.includes(Z)||r(be.values[0],y).then((ye=>{ye&&(Y({code:"UPDATE_ERROR",message:ye},ue),M(null))})),void Me(be);const ue=yr(Z,S,A("DEFAULT_NEW_KEY",u),_!=null&&_.CustomNode?A("DEFAULT_STRING",u):void 0);["string","number","boolean"].includes(S)||M(null),r(ue,y).then((ye=>{ye?(Y({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:L("error",u),children:de})]})]}),i.jsx(fe,{position:"below",nodeData:u})]}))},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(tr,Object.assign({},e,{value:r}));case"number":return i.jsx(nr,Object.assign({},e,{value:r}));case"boolean":return i.jsx(rr,Object.assign({},e,{value:r}));case"null":return i.jsx(ir,Object.assign({},e));default:return i.jsx(sr,Object.assign({},e))}},yr=(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)}},hn=(t=[],e)=>{const n=t.filter((({condition:b})=>b(e)));if(n.length===0)return{};const r=n[0],{element:o,wrapperElement:a,customNodeProps:s,wrapperProps:g,hideKey:f=!1,showEditTools:l=!0,showOnEdit:c=!1,showOnView:d=!0,showCollectionWrapper:m=!0}=r,x=Qt(r,["element","wrapperElement","customNodeProps","wrapperProps","hideKey","showEditTools","showOnEdit","showOnView","showCollectionWrapper"]);return Object.assign({CustomNode:o,CustomWrapper:a,customNodeProps:s,wrapperProps:g,hideKey:f,showEditTools:l,showOnEdit:c,showOnView:d,showCollectionWrapper:m},x)},pn=t=>{const{getStyles:e}=Re(),{collapseState:n,setCollapseState:r,getMatchingCollapseState:o,currentlyEditingElement:a,setCurrentlyEditingElement:s,areChildrenBeingEdited:g,previousValue:f,setPreviousValue:l}=We(),{mainContainerRef:c,data:d,nodeData:m,parentData:x,showCollectionCount:b,onEdit:D,onAdd:O,onDelete:A,canDragOnto:T,collapseFilter:_,collapseAnimationTime:W,onMove:te,enableClipboard:G,onEditEvent:X,showIconTooltips:ee,searchFilter:U,searchText:L,indent:M,sort:J,showArrayIndices:ne,arrayIndexFromOne:he,defaultValue:oe,newKeyOptions:pe,translate:le,customNodeDefinitions:q,customNodeData:Z,jsonParse:p,jsonStringify:h,TextEditor:u,keyboardControls:y,handleKeyboard:E,insertAtTop:N,onCollapse:z,editConfirmRef:I,collapseClickZones:de}=t,[Y,je]=j.useState(h(d)),Oe=_(m),{contentRef:re,isAnimating:Pe,maxHeight:_e,collapsed:B,animateCollapse:fe,cssTransitionValue:we}=((w,H,Ne,Ce,Le)=>{const[xn,ct]=j.useState(Ne?0:void 0),[ut,wn]=j.useState(Ne),yt=j.useRef(!1),vt=j.useRef(null),Ft=j.useRef(0),Vt=j.useRef(0),Dn=H/1e3+"s",Cn=j.useCallback((bt=>{var jt,Et;if(ut!==bt){switch(window.clearTimeout(Vt.current),yt.current=!0,bt){case!0:{const Kt=(Et=(jt=vt.current)===null||jt===void 0?void 0:jt.offsetHeight)!==null&&Et!==void 0?Et:0;Ft.current=Kt,ct(Kt),setTimeout((()=>{ct(0)}),5);break}case!1:ct(Ft.current||mr(w,vt,Ce,Le))}wn(!ut),Vt.current=window.setTimeout((()=>{yt.current=!1,bt||ct(void 0)}),H)}}),[H,ut,w,Ce,Le]);return{contentRef:vt,isAnimating:yt.current,animateCollapse:Cn,maxHeight:xn,collapsed:ut,cssTransitionValue:Dn}})(d,W,Oe,c,h),{pathString:ve,nodeData:P,path:$,name:ie,size:se,canEdit:ge,canDelete:ae,canAdd:xe,canDrag:Se,error:ke,setError:ce,onError:Q,handleEditKey:Me,emptyStringKey:Ee,derivedValues:Ue}=cn({props:t,collapsed:B}),{dragSourceProps:Ae,getDropTargetProps:Te,BottomDropTarget:Ye,DropTargetPadding:Ge}=un({canDrag:Se,canDragOnto:T,path:$,nodeData:P,onMove:te,onError:Q,translate:le}),De=j.useRef(!Oe),{isEditing:me,isEditingKey:Ie,isArray:k,canEditKey:C}=Ue;j.useEffect((()=>{je(h(d))}),[d,h]),j.useEffect((()=>{const w=_(P)&&!me;De.current=!w,fe(w)}),[_]),j.useEffect((()=>{if(n!==null){const w=o($);w&&(De.current=!0,fe(w.collapsed))}}),[n]);const R=j.useRef(null),V=j.useCallback(((w,H)=>{if(typeof oe!="function")return oe;const Ne=oe(w,H);return Ne!==void 0?Ne:null}),[oe]),F=j.useCallback((w=>pe?typeof pe!="function"?pe:pe(w):null),[pe]),{CustomNode:v,customNodeProps:S,CustomWrapper:K,wrapperProps:be={},hideKey:ue,showEditTools:ye=!0,showOnEdit:Fe,showOnView:Ve,showCollectionWrapper:pt=!0}=Z,st=g(ve);if(st&&B&&fe(!1),!(tn("collection",P,U,L)||P.level===0)&&!st)return null;const Xe=Array.isArray(d)?"array":"object",ft=Xe==="array"?{open:"[",close:"]"}:{open:"{",close:"}"},At=w=>{if(w.key!=="Tab"||w.getModifierState("Shift"))E(w,{objectConfirm:lt,cancel:et});else{w.preventDefault();const H=rn(R," ");je(H)}},at=w=>{w.stopPropagation();const H=kt(w);if(H&&y.collapseModifier.includes(H))return De.current=!0,void r({collapsed:!B,path:$,includeChildren:!0});a&&a.includes(ve)||(De.current=!0,r(null),z&&z({path:$,collapsed:!B,includeChildren:!1}),fe(!B))},lt=()=>{try{const w=p(Y);if(s(null),l(null),ce(null),h(w)===h(d))return;D(w,$).then((H=>{H&&Q({code:"UPDATE_ERROR",message:H},w)}))}catch{Q({code:"INVALID_JSON",message:le("ERROR_INVALID_JSON",P)},Y)}},yn=$.length>0?()=>{A(d,$).then((w=>{w&&Q({code:"DELETE_ERROR",message:w},d)}))}:void 0,et=()=>{s(null),f===null?(ce(null),je(h(d)),l(null)):D(f,$)},Lt=b==="when-closed"?B:b,vn=!me&&ye,bn=(ne||!k)&&!ue&&ie!==void 0,jn=v&&(me&&Fe||!me&&Ve),gt=Object.entries(d).map((([w,H])=>[Xe==="array"?Number(w):w,H]));Xe==="object"&&J(gt,(w=>w));const Rt=De.current?me?i.jsxs("div",{className:"jer-collection-text-edit",children:[u?i.jsx(u,{value:Y,onChange:je,onKeyDown:w=>E(w,{objectConfirm:lt,cancel:et})}):i.jsx(en,{textAreaRef:R,className:"jer-collection-text-area",name:ve,value:Y,setValue:je,handleKeyPress:At,styles:e("input",P)}),i.jsx("div",{className:"jer-collection-input-button-row",children:i.jsx(Nt,{onOk:lt,onCancel:et,nodeData:P,editConfirmRef:I})})]}):gt.map((([w,H],Ne)=>{const Ce={key:w,value:H,path:[...$,w],level:$.length+1,index:Ne,size:Ze(H)?Object.keys(H).length:null,parentData:d,fullData:P.fullData},Le=hn(q,Ce);return i.jsx("div",{className:"jer-collection-element",style:e("collectionElement",Ce),children:Ze(H)&&!(Le!=null&&Le.renderCollectionAsValue)?i.jsx(pn,Object.assign({},t,{data:H,parentData:d,nodeData:Ce,showCollectionCount:b,canDragOnto:ge,customNodeData:Le}),w):i.jsx(dn,Object.assign({},t,{data:H,parentData:d,nodeData:Ce,canDragOnto:ge,showLabel:Xe==="object"||ne,customNodeData:Le}),w)},w)})):null,mt=!!pt&&B&&!st;mt||(De.current=!0);const _t=Object.assign(Object.assign({},t),{data:d,value:d,parentData:x,nodeData:P,setValue:w=>Je(void 0,void 0,void 0,(function*(){return yield D(w,$)})),handleEdit:lt,handleCancel:et,handleKeyPress:At,isEditing:me,setIsEditing:()=>s($),getStyles:e,canDragOnto:ge,canEdit:ge,keyboardCommon:{},onError:Q}),En=jn?i.jsx(v,Object.assign({customNodeProps:S},_t,{children:Rt})):Rt,Pt=vn&&i.jsx(ln,{startEdit:ge?()=>{De.current=!0,l(null),s($)}:void 0,handleAdd:xe?w=>{fe(!1);const H=V(P,w);if(Xe==="array"){const Ne=N.array?0:d.length,Ce=N.array?{insert:!0}:{};O(H,[...$,Ne],Ce).then((Le=>{Le&&Q({code:"ADD_ERROR",message:Le},H)}))}else if(w in d)Q({code:"KEY_EXISTS",message:le("ERROR_KEY_EXISTS",P)},w);else{const Ne=N.object?{insertBefore:0}:{};O(H,[...$,w],Ne).then((Ce=>{Ce&&Q({code:"ADD_ERROR",message:Ce},H)}))}}:void 0,handleDelete:ae?yn:void 0,enableClipboard:G,type:Xe,nodeData:P,translate:le,customButtons:t.customButtons,keyboardControls:y,handleKeyboard:E,getNewKeyOptions:F,editConfirmRef:I,jsonStringify:h,onEditEvent:X,showIconTooltips:ee}),Mt={canEditKey:C,isEditingKey:Ie,pathString:ve,path:$,name:ie,arrayIndexFromOne:he,handleKeyboard:E,handleEditKey:Me,handleCancel:et,keyValueArray:gt,styles:e("property",P),getNextOrPrevious:w=>Be(P.fullData,$,w,J),handleClick:de.includes("property")?at:w=>w.stopPropagation(),emptyStringKey:Ee},It=i.jsxs("div",Object.assign({className:"jer-component jer-collection-component",style:Object.assign(Object.assign({marginLeft:($.length===0?0:M/2)+"em"},e("collection",P)),{position:"relative"}),draggable:Se},Ae,Te("above"),{children:[i.jsx("div",{className:"jer-clickzone",style:{width:M/2+1+"em",zIndex:10+2*P.level},onClick:de.includes("left")?at:void 0}),!me&&Ye,i.jsx(Ge,{position:"above",nodeData:P}),pt?i.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},onClick:de.includes("header")?at: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*P.level,transition:we},onClick:at,children:i.jsx($e,{name:"chevron",rotate:B,nodeData:P})}),bn&&i.jsx(ht,Object.assign({},Mt)),!me&&i.jsx("span",{className:"jer-brackets jer-bracket-open",style:e("bracket",P),children:ft.open})]}),!me&&Lt&&i.jsx("div",{className:"jer-collection-item-count"+(Lt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},e("itemCount",P)),{transition:we}),children:se===1?le("ITEM_SINGLE",Object.assign(Object.assign({},P),{size:1}),1):le("ITEMS_MULTIPLE",P,se)}),i.jsx("div",{className:"jer-brackets"+(mt?" jer-visible":" jer-hidden"),style:Object.assign(Object.assign({},e("bracket",P)),{transition:we}),children:ft.close}),Pt]}):ue?i.jsx(i.Fragment,{}):i.jsxs("div",{className:"jer-collection-header-row",style:{position:"relative"},children:[i.jsx(ht,Object.assign({},Mt)),Pt]}),i.jsxs("div",{className:"jer-collection-inner",style:Object.assign(Object.assign({overflowY:mt||Pe?"clip":"visible",maxHeight:st?void 0:_e},e("collectionInner",P)),{transition:we}),ref:re,children:[En,i.jsx("div",{className:me?"jer-collection-error-row":"jer-collection-error-row-edit",children:ke&&i.jsx("span",{className:"jer-error-slug",style:e("error",P),children:ke})}),!me&&pt&&i.jsx("div",{className:"jer-brackets jer-bracket-outside",style:Object.assign(Object.assign({},e("bracket",P)),{marginLeft:(M<3?-1:M<6?-.5:0)+"em"}),children:ft.close})]}),i.jsx(Ge,{position:"below",nodeData:P})]}));return K?i.jsx(K,Object.assign({customNodeProps:be},_t,{children:It})):It},vr={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"},br=(t,e)=>(n,r,o)=>((a,s,g,f,l)=>{if(s[f]){const d=s[f](g);if(d!==null)return d}const c=f in a?a[f]:vr[f];return l===void 0?c:c==null?void 0:c.replace("{{count}}",String(l))})(t,e,r,n,o);var Xt=[],tt=[];(function(t,e){if(t&&typeof document<"u"){var n,r=e.prepend===!0?"prepend":"append",o=e.singleTag===!0,a=typeof e.container=="string"?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(o){var s=Xt.indexOf(a);s===-1&&(s=Xt.push(a)-1,tt[s]={}),n=tt[s]&&tt[s][r]?tt[s][r]:tt[s][r]=g()}else n=g();t.charCodeAt(0)===65279&&(t=t.substring(1)),n.styleSheet?n.styleSheet.cssText+=t:n.appendChild(document.createTextNode(t))}function g(){var f=document.createElement("style");if(f.setAttribute("type","text/css"),e.attributes)for(var l=Object.keys(e.attributes),c=0;c<l.length;c++)f.setAttribute(l[c],e.attributes[l[c]]);var d=r==="prepend"?"afterbegin":"beforeend";return a.insertAdjacentElement(d,f),f}})(':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 jr=({data:t,setData:e,rootName:n="root",onUpdate:r=()=>{},onEdit:o=r,onDelete:a=r,onAdd:s=r,onChange:g,onError:f,onEditEvent:l,showErrorMessages:c=!0,enableClipboard:d=!0,indent:m=2,collapse:x=!1,collapseAnimationTime:b=300,showCollectionCount:D=!0,restrictEdit:O=!1,restrictDelete:A=!1,restrictAdd:T=!1,restrictTypeSelection:_=!1,restrictDrag:W=!0,viewOnly:te,searchFilter:G,searchText:X,searchDebounceTime:ee=350,keySort:U=!1,showArrayIndices:L=!0,arrayIndexFromOne:M=!1,showStringQuotes:J=!0,showIconTooltips:ne=!1,defaultValue:he=null,newKeyOptions:oe,minWidth:pe=250,maxWidth:le="min(600px, 90vw)",rootFontSize:q,stringTruncate:Z=250,translations:p={},className:h,id:u,customText:y={},customNodeDefinitions:E=[],customButtons:N=[],jsonParse:z=JSON.parse,jsonStringify:I=(B,fe)=>JSON.stringify(B,fe,2),TextEditor:de,errorMessageTimeout:Y=2500,keyboardControls:je={},externalTriggers:Oe,insertAtTop:re=!1,onCollapse:Pe,collapseClickZones:_e=["header","left"]})=>{const{getStyles:B}=Re(),{setCurrentlyEditingElement:fe}=We(),we=j.useMemo((()=>rt(x)),[x]),ve=j.useMemo((()=>br(p,y)),[p,y]),[P,$]=j.useState(X),[ie,se]=(({setData:k,data:C})=>{const[R,V]=j.useState(k?void 0:C),F=j.useCallback((v=>{k?k(v):V(v)}),[k]);return j.useEffect((()=>{k||V(C)}),[C]),[k?C:R,F]})({setData:e,data:t}),ge=j.useRef(null);j.useEffect((()=>{fe(null);const k=setTimeout((()=>$(X)),ee);return()=>clearTimeout(k)}),[X,ee]);const ae={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=(k,C)=>Je(void 0,void 0,void 0,(function*(){const R=yield k(C);if(R===!0||R===void 0)return void se(C.newData);const V=wr(R)?R:["error",R],[F,v]=V;if(F==="error")return se(C.currentData),v===!1?ve("ERROR_UPDATE",ae):String(v);se(v)})),Se=j.useMemo((()=>rt(O,te)),[O,te]),ke=j.useMemo((()=>rt(A,te)),[A,te]),ce=j.useMemo((()=>rt(T,te)),[T,te]),Q=j.useMemo((()=>rt(W,te)),[W,te]),Me=j.useMemo((()=>xr(G)),[G]),Ee=j.useMemo((()=>(k=>{const C=Object.assign({},Ut);for(const R of Object.keys(Ut)){const V=R;if(k[V]){const F=k[V],v=["clipboardModifier","collapseModifier"].includes(R)?Array.isArray(F)?F:[F]:typeof F=="string"?{key:F}:F;C[V]=v,["stringConfirm","numberConfirm","booleanConfirm"].forEach((S=>{!k[S]&&k.confirm&&(C[S]=C.confirm)}))}}return C})(je)),[je]),Ue=j.useCallback(((k,C)=>((R,V,F)=>{const v=Object.entries(V);for(const[S,K]of v)if(Un(F,R[S],S)){F.preventDefault(),K();break}})(Ee,C,k)),[Ee]),Ae=j.useMemo((()=>{const k=Jt(E,"stringifyReplacer");return C=>I(C,k)}),[E,I]),Te=j.useMemo((()=>{const k=Jt(E,"parseReviver");return C=>{const R=z(C,k);return Dt(R)}}),[E,z]),Ye=j.useRef(null);((k,C)=>{const{setCurrentlyEditingElement:R,currentlyEditingElement:V,setCollapseState:F}=We();j.useEffect((()=>{if(!k)return;const{collapse:v,edit:S}=k;v&&F(v);const K=!(S!=null&&S.path)||He(S.path)===V;switch(S==null?void 0:S.action){case"accept":K&&(C.current&&C.current.click(),R(null));break;case"cancel":K&&R(null);break;default:S!=null&&S.path&&R(S.path)}}),[k])})(Oe,Ye);const Ge=j.useCallback(((k,C)=>{U!==!1&&(typeof U!="function"?k.sort(((R,V)=>{const F=C(R)[0],v=C(V)[0];return F<v?-1:F>v?1:0})):k.sort(((R,V)=>U(C(R),C(V)))))}),[U]),De=hn(E,ae),me={mainContainerRef:ge,name:n,nodeData:ae,onEdit:(k,C)=>Je(void 0,void 0,void 0,(function*(){const{currentData:R,newData:V,currentValue:F,newValue:v}=nt(ie,C,k,"update");if(F!==v)return yield xe(o,{currentData:R,newData:V,currentValue:F,newValue:v,name:C.slice(-1)[0],path:C})})),onDelete:(k,C)=>Je(void 0,void 0,void 0,(function*(){const{currentData:R,newData:V,currentValue:F,newValue:v}=nt(ie,C,k,"delete");return yield xe(a,{currentData:R,newData:V,currentValue:F,newValue:v,name:C.slice(-1)[0],path:C})})),onAdd:(k,C,R)=>Je(void 0,void 0,void 0,(function*(){const{currentData:V,newData:F,currentValue:v,newValue:S}=nt(ie,C,k,"add",R);return yield xe(s,{currentData:V,newData:F,currentValue:v,newValue:S,name:C.slice(-1)[0],path:C})})),onChange:g,onError:f,onEditEvent:l,showErrorMessages:c,onMove:(k,C,R)=>Je(void 0,void 0,void 0,(function*(){if(k===null)return;const{currentData:V,newData:F,currentValue:v}=nt(ie,k,"","delete"),S=k.slice(-1)[0],K=C.slice(0,-1),be=C.slice(-1)[0];let ue=typeof be=="number"?R==="above"?be:be+1:typeof S=="number"?`arr_${S}`:S;k.slice(0,-1).join(".")===C.slice(0,-1).join(".")&&typeof S=="number"&&typeof ue=="number"&&S<ue&&(ue-=1);const ye=typeof ue=="number"?{insert:!0}:R==="above"?{insertBefore:be}:{insertAfter:be},{newData:Fe,newValue:Ve}=nt(F,[...K,ue],v,"add",ye);return yield xe(o,{currentData:V,newData:Fe,currentValue:v,newValue:Ve,name:C.slice(-1)[0],path:C})})),showCollectionCount:D,collapseFilter:we,collapseAnimationTime:b,restrictEditFilter:Se,restrictDeleteFilter:ke,restrictAddFilter:ce,restrictTypeSelection:_,restrictDragFilter:Q,canDragOnto:!1,searchFilter:Me,searchText:P,enableClipboard:d,keySort:U,sort:Ge,showArrayIndices:L,arrayIndexFromOne:M,showStringQuotes:J,showIconTooltips:ne,indent:m,defaultValue:he,newKeyOptions:oe,stringTruncate:Z,translate:ve,customNodeDefinitions:E,customNodeData:De,customButtons:N,parentData:null,jsonParse:Te,jsonStringify:Ae,TextEditor:de,errorMessageTimeout:Y,handleKeyboard:Ue,keyboardControls:Ee,insertAtTop:{object:re===!0||re==="object",array:re===!0||re==="array"},onCollapse:Pe,editConfirmRef:Ye,collapseClickZones:_e},Ie=Object.assign(Object.assign({},B("container",ae)),{minWidth:pe,maxWidth:le});return Ie.fontSize=q??Ie.fontSize,i.jsx("div",{id:u,ref:ge,className:`jer-editor-container ${h??""}`,style:Ie,children:Ze(ie)&&!De.renderCollectionAsValue?i.jsx(pn,Object.assign({data:ie},me)):i.jsx(dn,Object.assign({data:ie,showLabel:!0},me))})},Er=t=>{var e;const[n,r]=j.useState();return j.useEffect((()=>{const o=document.documentElement;r(o)}),[]),n?i.jsx(Gn,{theme:(e=t.theme)!==null&&e!==void 0?e:Tt,icons:t.icons,docRoot:n,children:i.jsx(Zn,{onEditEvent:t.onEditEvent,onCollapse:t.onCollapse,children:i.jsx(jr,Object.assign({},t))})}):null},nt=(t,e,n,r,o={})=>{if(e.length===0)return{currentData:t,newData:n,currentValue:t,newValue:n};const a=Object.assign({remove:r==="delete"},o),s=r!=="add"?qe(t,e):void 0;return{currentData:t,newData:zn(t,e,n,a),currentValue:s,newValue:r!=="delete"?n:void 0}},rt=(t,e)=>e?()=>!0:typeof t=="boolean"?()=>t:typeof t=="number"?({level:n})=>n>=t:t,xr=t=>{if(t!==void 0)return t==="value"?Qe:t==="key"?Ht:t==="all"?(e,n)=>Qe(e,n)||Ht(e,n):t},wr=t=>Array.isArray(t)&&t.length===2&&["error","value"].includes(t[0]),Jt=(t,e)=>{const n=e==="stringifyReplacer"?[r=>r===void 0?on:r]:[];if(n.push(...t.map((r=>r[e])).filter((r=>!!r))),n.length!==0)return(r,o)=>{let a=o;for(const s of n)a=s(a);return a}},fn={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)"}},Dr={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"}},Cr={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"}},Or={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"}};function gn(t,e){const n=JSON.stringify(t,null,2),r=new Blob([n],{type:"application/json"}),o=URL.createObjectURL(r),a=document.createElement("a");a.href=o,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(o)}function mn(t,e){const n=new Date().toISOString().replace(/[:.]/g,"-").slice(0,-1),r=e&&e.length>0?"."+e.join("."):"";return`${t}${r}-${n}.json`}const Sr={githubDark:fn,githubLight:Dr,monoDark:Cr,monoLight:Or};class kr extends j.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?j.createElement("pre",{style:{color:"#ff6b6b",padding:16,fontSize:12}},`DevTools Error: ${this.state.error.message}
75
+ ${this.state.error.stack}`):this.props.children}}function Tr(){return i.jsxs("svg",{className:"lsdt-node-dump-btn",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i.jsx("polyline",{points:"7 10 12 15 17 10"}),i.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function Nr({data:t,onEdit:e,readOnly:n,theme:r,rootName:o}){const a=Sr[r]??fn,s={Element:Tr,onClick:g=>{const f=g.path.map(String);gn(g.value,mn(o,f))}};return i.jsx(Er,{data:t,setData:e,rootName:o,theme:a,collapse:2,restrictEdit:n,restrictDelete:n,restrictAdd:n,restrictTypeSelection:n?!0:void 0,customButtons:[s]})}function Ar(t){const[e,n]=j.useState(t.initialData);j.useEffect(()=>{t.registerUpdater(o=>{n(o)})},[]);const r=o=>{n(o),t.onEdit(o)};return i.jsx(Nr,{data:e,onEdit:r,readOnly:t.readOnly,theme:t.theme,rootName:t.rootName})}function Lr(t,e){let n=null,r=null;return n=On.createRoot(t),n.render(i.jsx(kr,{children:i.jsx(Ar,{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 Rr(t,e={}){const{enabled:n=!0,readOnly:r=!1,theme:o="githubDark",rootName:a="state$",position:s="right",defaultOpen:g=!1}=e;if(!n)return{destroy:()=>{}};const f=In();let l=null,c=null,d=null,m=null;l=new Vn({rootName:a,readOnly:r,position:s,onClose:()=>{b()},onDumpState:()=>{const O=d==null?void 0:d.getSnapshot();O!==void 0&&gn(O,mn(a))}});const x=()=>{if(!l)return;l.show(),c==null||c.setPanelVisible(!0);const O=(A=10)=>{const T=l==null?void 0:l.getEditorRoot();if(!T){A>0?setTimeout(()=>O(A-1),16):console.warn("[Legend State DevTools] Could not find #lsdt-json-editor-root after retries");return}if(m)return;const _=(d==null?void 0:d.getSnapshot())??{};m=Lr(T,{initialData:_,onEdit:W=>{d==null||d.setData(W)},readOnly:r,theme:o,rootName:a})};O()},b=()=>{m&&(m.destroy(),m=null),l==null||l.hide(),c==null||c.setPanelVisible(!1)},D=()=>{l!=null&&l.isVisible()?b():x()};return c=new Fn({onTogglePanel:D,rootName:a}),c.mount(),f.add(()=>c==null?void 0:c.unmount()),d=Kn(t,{onSnapshot:O=>{l!=null&&l.getIsDragging()||m==null||m.updateData(O)}}),f.add(()=>d==null?void 0:d.destroy()),f.add(()=>{m&&(m.destroy(),m=null)}),f.add(()=>l==null?void 0:l.unmount()),g&&x(),{destroy:()=>{f.run()}}}exports.init=Rr;
73
76
  //# sourceMappingURL=index.js.map