New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pardnchiu/nanojson

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pardnchiu/nanojson - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

2

dist/NanoJSON.esm.js

@@ -1,1 +0,1 @@

!function(){const t=window,e=document,i=String,s=Number,n=Boolean,l=Array,r=Object,o=(DocumentFragment,Blob),h=URL,a=Math,c=Date,d=setTimeout,f=JSON,u=confirm,p=parseFloat,v=isNaN,w=FileReader,y=File,g=fetch,m=Promise,b=/\.([\w_-]+)?/gi,C=/\#([\w_-]+)?/i,A=/^\w+(?=[\#\.]*)/i,k="then",x="click",j="parse",H="true",z="false",$="add",F="appendChild",M="class",V="section",S="key",O="stringify",N="label",L="target",T="color",B="fill",D="insert",E="createDocumentFragment",R="contentEditable",U="replaceChildren",J="toLowerCase",I="beforeRender",P="beforeUpdate",q="beforeDestroy",_="rendered",G="updated",K="button",Y="destroyed",Q="type",W="script",X="createTextNode",Z="console",tt="onchange",et="oninput",it="body",st="apply",nt="src",lt="void",rt="title",ot="error",ht="now",at="render",ct="remove",dt="dataset",ft="display",ut="float",pt="dom",vt="input",wt="textarea",yt="height",gt="img",mt="parent",bt="onclick",Ct="inner",At="isArray",kt="length",xt="map",jt="match",Ht="number",zt="object",$t="replace",Ft="keys",Mt="placeholder",Vt="source",St="style",Ot="string",Nt="selected",Lt="option",Tt="temp",Bt="test",Dt="textContent",Et="trim",Rt="update",Ut="value",Jt="width",It="collapsed",Pt="array",qt="boolean",_t="reset",Gt="import",Kt="export",Yt="children",Qt="push",Wt="editor",Xt="getElementById",Zt="nextElementSibling",te="link",ee="rel",ie="href",se="as",ne="backgroundColor",le=M+"List",re="createElement",oe="hasOwnProperty",he="indexOf",ae=Ct+"HTML",ce=Ct+"Text",de="setAttribute",fe=[Ot,Ht,qt,Pt,zt],ue="https://cdn.jsdelivr.net/npm/@pardnchiu/nanojson@0.3.2/dist/NanoJSON.css",pe="NanoJSON\nGitHub: https://github.com/pardnchiu/NanoJSON\nCreator: Pardn Chiu\nLicense: Proprietary",ve={[I]:I,[P]:P,[q]:q,[_]:_,[G]:G,[Y]:Y};for(let t of[be(te,{[ee]:"preconnect",[ie]:"https://cdn.jsdelivr.net"}),be(te,{[ee]:"preload",[ie]:ue,[se]:St}),be(te,{[ee]:"stylesheet",[ie]:ue})])e.head[F](t);document.addEventListener("DOMContentLoaded",(t=>{He("%c"+pe,"line-height: 1.75rem; font-size: 0.875rem;")}));const we={number:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.5 15v-4.5H4V9h3v6H5.5zM9 15v-2.5c0-.283.096-.52.287-.713A.967.967 0 0110 11.5h2v-1H9V9h3.5c.283 0 .52.096.713.287.191.192.287.43.287.713v1.5c0 .283-.096.52-.287.713a.968.968 0 01-.713.287h-2v1h3V15H9zm6 0v-1.5h3v-1h-2v-1h2v-1h-3V9h3.5c.283 0 .52.096.712.287.192.192.288.43.288.713v4c0 .283-.096.52-.288.713A.968.968 0 0118.5 15H15z" fill="#5F6368"/></svg>',string:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M17 15a.968.968 0 01-.712-.287A.968.968 0 0116 14v-4c0-.283.096-.52.288-.713A.968.968 0 0117 9h3c.283 0 .52.096.712.287.192.192.288.43.288.713v1h-1.5v-.5h-2v3h2V13H21v1c0 .283-.096.52-.288.713A.968.968 0 0120 15h-3zm-7.5 0V9h4c.283 0 .52.096.713.287.191.192.287.43.287.713v1c0 .283-.096.52-.287.713A.968.968 0 0113.5 12c.283 0 .52.096.713.287.191.192.287.43.287.713v1c0 .283-.096.52-.287.713A.968.968 0 0113.5 15h-4zm1.5-3.75h2v-.75h-2v.75zm0 2.25h2v-.75h-2v.75zM3 15v-5c0-.283.096-.52.288-.713A.968.968 0 014 9h3c.283 0 .52.096.713.287.191.192.287.43.287.713v5H6.5v-1.5h-2V15H3zm1.5-3h2v-1.5h-2V12z" fill="#5F6368"/></svg>',object:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13.5 18v-1.5h2.25c.213 0 .39-.072.534-.216a.726.726 0 00.216-.534v-1.5c0-.475.137-.906.413-1.294A2.233 2.233 0 0118 12.131v-.262a2.233 2.233 0 01-1.087-.825A2.184 2.184 0 0116.5 9.75v-1.5a.726.726 0 00-.216-.534.726.726 0 00-.534-.216H13.5V6h2.25a2.17 2.17 0 011.594.656c.437.438.656.969.656 1.594v1.5c0 .213.072.39.216.534a.726.726 0 00.534.216h.75v3h-.75a.726.726 0 00-.534.216.726.726 0 00-.216.534v1.5a2.17 2.17 0 01-.656 1.594A2.17 2.17 0 0115.75 18H13.5zm-5.25 0a2.17 2.17 0 01-1.594-.656A2.17 2.17 0 016 15.75v-1.5a.726.726 0 00-.216-.534.726.726 0 00-.534-.216H4.5v-3h.75c.213 0 .39-.072.534-.216A.726.726 0 006 9.75v-1.5c0-.625.219-1.156.656-1.594A2.17 2.17 0 018.25 6h2.25v1.5H8.25a.726.726 0 00-.534.216.726.726 0 00-.216.534v1.5c0 .475-.138.906-.412 1.294A2.233 2.233 0 016 11.869v.262c.45.163.813.438 1.088.825.274.388.412.819.412 1.294v1.5c0 .213.072.39.216.534a.726.726 0 00.534.216h2.25V18H8.25z" fill="#5F6368"/></svg>',array:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M14.625 19v-1.75h2.625V6.75h-2.625V5H19v14h-4.375zM5 19V5h4.375v1.75H6.75v10.5h2.625V19H5z" fill="#5F6368"/></svg>',boolean:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7.91 16.818c-1.365 0-2.524-.477-3.478-1.432C3.477 14.432 3 13.273 3 11.91c0-1.364.477-2.523 1.432-3.477C5.386 7.477 6.545 7 7.909 7h8.182c1.363 0 2.523.477 3.477 1.432.955.954 1.432 2.114 1.432 3.477 0 1.364-.477 2.523-1.432 3.477-.954.955-2.114 1.432-3.477 1.432H7.909zm0-1.636h8.18c.9 0 1.671-.32 2.312-.962.641-.64.962-1.41.962-2.31 0-.9-.32-1.671-.962-2.312a3.151 3.151 0 00-2.311-.962H7.909c-.9 0-1.67.32-2.311.962a3.151 3.151 0 00-.962 2.311c0 .9.32 1.67.962 2.311.64.641 1.411.962 2.311.962zm8.18-.818c.683 0 1.262-.239 1.74-.716a2.367 2.367 0 00.716-1.739c0-.682-.24-1.261-.716-1.739a2.367 2.367 0 00-1.74-.715c-.68 0-1.26.238-1.738.716a2.367 2.367 0 00-.716 1.738c0 .682.239 1.261.716 1.739a2.367 2.367 0 001.739.716z" fill="#5F6368"/></svg>',right:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10 18V6l6 6-6 6z" fill="#5F6368"/></svg>',folder:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M4 20c-.55 0-1.02-.196-1.413-.587A1.926 1.926 0 012 18V6c0-.55.196-1.02.587-1.412A1.926 1.926 0 014 4h6l2 2h8c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412H11.175l-2-2H4v12l2.4-8h17.1l-2.575 8.575a1.95 1.95 0 01-.738 1.038A1.985 1.985 0 0119 20H4zm2.1-2H19l1.8-6H7.9l-1.8 6z" fill="#5F6368"/></svg>',add:'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M11 13H5v-2h6V5h2v6h6v2h-6v6h-2v-6z" fill="#5F6368"/></svg>',download:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 16l-5-5 1.4-1.45 2.6 2.6V4h2v8.15l2.6-2.6L17 11l-5 5zm-6 4c-.55 0-1.02-.196-1.412-.587A1.926 1.926 0 014 18v-3h2v3h12v-3h2v3c0 .55-.196 1.02-.587 1.413A1.926 1.926 0 0118 20H6z" fill="#5F6368"/></svg>',clear:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.25 18H22v2h-6.75l2-2zm-12.5 2l-2.125-2.125c-.383-.383-.58-.858-.587-1.425-.009-.567.179-1.05.562-1.45l11-11.4c.383-.4.854-.6 1.412-.6.559 0 1.03.192 1.413.575L21.4 8.55c.383.383.575.858.575 1.425 0 .567-.192 1.042-.575 1.425L13 20H4.75zm7.4-2L20 9.95 15.05 5 4 16.4 5.6 18h6.55z" fill="#5F6368"/></svg>'};function ye(t={}){let e;if(typeof t===zt&&t[oe](pt)){e=t[pt];for(let i of r[Ft](t))i!==pt&&(e[i]=e=>t[i](e));return e}}function ge(t,e,i){if({[zt]:1,[Pt]:1}[t[Q][J]()]&&!t[It])return be(V,{[M]:"pd-json-editor-nested-child"},[...t[Yt][xt](((t,i)=>e(t,i))),ye({[pt]:be(K+".child-add",we[$]),[bt]:i})])}function me(t){const e={[zt]:1,[Pt]:1}[t[Q][J]()],i=ye({[pt]:be("button",e?we.right:null),[bt]:e?e=>t.setCollapsed():t=>{}});return i[dt].collapseable=e?1:0,i[dt][It]=t[It]?1:0,i}function be(t="",i,s){const n=((t[jt](A)||[])[0]||"")[Et](),l=((t[jt](C)||[])[1]||"")[Et](),r=(b[Bt](t)?t[jt](b):[])[xt]((t=>t[$t](/^\./,"")));if(n[kt]<1)return;let o,h,a,c=!1;if(t===Tt?(c=!0,o=e[E]()):o=e[re](n),95!=pe[kt])return o;l[kt]&&(o.id=l);for(let t of r)o[le][$](t);if(null==i&&null!=s&&([i,s]=[s,null]),null!=i&&null!=s)[h,a]=[i,s];else if(null==s)typeof i===Ot||typeof i===Ht||Array[At](i)?a=i:h=i;else if(null==i)return o;if(typeof h===zt&&null!=h)for(const t in h){if(!h[oe](t))continue;const e=h[t];-1!=[Ut,ce,ae,Dt,R][he](t)?o[t]=e:-1!=[T,ne,Jt,yt,ft,ut][he](t)?o[St][t]=e:null!=e&&o[de](t,e)}if(null!=a){const t=typeof a===Ot,i=typeof a===Ht,s=Array[At](a);if(t||i){const t=a,i=n===vt,s=n===wt;n===gt||n===Vt?o[nt]=t:s||i?o[Ut]=t:c?o[F](e[X](a)):o[ae]=t}else if(s)for(let t of a){const i=t instanceof Element;typeof t===Ot||typeof t===Ht?c?o[F](e[X](t)):o[ae]+=t:i&&o[F](t)}}return o}function Ce(t,e,i,s){function n(t){return t[$t](/\n/g,"")}function l(e){const i=e[L];i[Ut]=i[Zt][ae]=n(i[Ut]),t[S]=n(i[Ut])[Et]()}return i?be("span.array-index",`${e}`):be("label",[ye({[pt]:be("textarea#key-"+t.id,{[Mt]:"KEY"},t[S][$t](/\n/g,"")),[et]:t=>{l(t),s[Rt]((()=>{}))},[tt]:t=>{l(t)}}),be("pre",n(t[S]))])}function Ae(t,e){if(t[Q][J]()===Ht){const l=/[^\d\-\.]/g,r=p(t[Ut]);function s(t){return v(t)?"":i(t)[$t](/\s/g,"")[$t](l,"")}return be(N,[ye({[pt]:be("textarea#value-"+t.id,{[Mt]:"NUM"},s(r)),[et]:i=>{const n=i[L];n[Ut]=n[Zt][ae]=s(n[Ut]),t[Ut]=s(n[Ut]),e[Rt]((()=>{}))},[tt]:e=>{const i=e[L];i[Ut]=i[Zt][ae]=s(i[Ut]),t[Ut]=s(i[Ut])}}),be("pre",s(r))])}if(t[Q][J]()===qt)return ye({[pt]:be("select#value-"+t.id,[be(Lt,{[Ut]:H,[Nt]:t[Ut]?"":null},H),be(Lt,{[Ut]:z,[Nt]:t[Ut]?null:""},z)]),[tt]:i=>{t[Ut]=i[L][Ut],e[Rt]((()=>{}))}});{const o={[zt]:1,[Pt]:1}[t[Q][J]()];function n(t){return t[$t](/\n/g,"<br>")}return be(N,{display:o?"none":"block"},[ye({[pt]:be("textarea#value-"+t.id,{[Mt]:"VAL"},t[Ut]),[et]:i=>{const s=i[L];s[Zt][ae]=n(s[Ut]),t[Ut]=s[Ut],e[Rt]((()=>{}))},[tt]:e=>{const i=e[L];i[Zt][ae]=n(i[Ut]),t[Ut]=i[Ut]}}),be("pre",n(t[Ut]))])}}function ke(t){return new m((async(e,i)=>{if(null!=t)if(t instanceof y){const i=new w;i.onload=i=>{try{e(f[j](i[L].result))}catch(i){je(`Failed to parse JSON from file ${t.name}: ${i}`),e({})}},i.readAsText(t)}else typeof t===zt?e(t):typeof t===Ot?await g(t)[k]((t=>t.text()))[k]((t=>{try{e(f[j](t))}catch(t){throw t}})).catch((i=>{je(`Failed to fetch data from ${t}: ${i}`),e({})})):(je(`Invalid data type: ${t} (${typeof t})`),e({}));else e({})}))}function xe(t){return l[At](t)?Pt:typeof t===zt?zt:typeof t===qt?qt:typeof t===Ht?Ht:Ot}new Map;function je(...t){const i=be(W,`${Z}.${ot}.${st}(${lt} 0, ${f[O](t)});`);e[it][F](i),i[ct]()}function He(...t){const i=be(W,`${Z}.log.${st}(${lt} 0, ${f[O](t)});`);e[it][F](i),i[ct]()}t.JSONEditor=class{children=[];body;editor;button=[];#t;#e=!1;#i="Object";get type(){return this.#i}constructor(t={}){"object"==typeof t?this.#s(t):je("Failed to load config.")}async#s(t={}){this[Wt]=be("section");const i=t.when??{},s=t[rt]??"",l=t.description??"",r=n(null==t[B]?1:t[B])?1:0;let o=null!=t[K]&&typeof t[K]===zt?t[K]:{[Gt]:1,[Kt]:1,[_t]:1};o[_t]=o[_t]??1,o[Gt]=o[Gt]??1,o[Kt]=o[Kt]??1,this.#t=new $e({[I]:i[ve[I]],[_]:i[ve[_]],[P]:i[ve[P]],[G]:i[ve[G]],[q]:i[ve[q]],[Y]:i[ve[Y]]});let h=await ke(t.file??t.json??t.path);this.children=this.#n(h);let a=be("temp",[Math.max(s[kt],l[kt])>0?be("header",[s[kt]>0?be("strong",s):null,l[kt]>0?be("p",l):null]):null,this[Wt],be("footer",[ye({[pt]:be(K,{[rt]:"Add row"},we[$]),[bt]:t=>this[D]()}),n(o[Gt])?ye({[pt]:be(K,{[rt]:"Open file"},we.folder),[bt]:t=>t[L][Zt][x]()}):null,n(o[Gt])?ye({[pt]:be(vt,{[Q]:"file",accept:".json",[ft]:"none"}),[tt]:t=>this[Gt](t[L].files[0])}):null,n(o[Kt])?ye({[pt]:be(K,{[rt]:"Download file"},we.download),[bt]:t=>{u("Download?")&&this[Kt]()}}):null,n(o[_t])?ye({[pt]:be(K,{[rt]:"清空"},we.clear),[bt]:t=>{u("Reset?")&&this[Gt]({})}}):null])]);const c="pd-json-editor";null==t.id?(this[it]=be(V+"."+c),this[it][F](a)):(this[it]=e[Xt](t.id),this[it][le][$](c),this[it][U](...a[Yt])),this[it][dt][B]=r,this[Yt][kt]<1&&this[D](),this.#t[at]((async()=>{this[at](),this.#e=!0}))}#l(t){return t.render()}#n(t,e=null){const s=[];if(l[At](t))for(let n of t){const t=xe(n),l=new ze({[Q]:t,[mt]:e??this,[Wt]:this,lifecycle:this.#t});t===zt&&null!=n||t===Pt?l[Yt]=this.#n(n,l):l[Ut]=i(n),s[Qt](l)}else for(const[n,l]of r.entries(t)){const t=xe(l),r=new ze({[S]:n,[Q]:t,[mt]:e??this,[Wt]:this,lifecycle:this.#t});t===zt&&null!=l||t===Pt?r[Yt]=this.#n(l,r):r[Ut]=null==l?"":i(l),s[Qt](r)}return s}render(t=!1){let e=be("temp",this[Yt].map((t=>this.#l(t))));this[Wt][U](...e[Yt]),this.#e&&t&&this.#t[Rt]((()=>{}))}insert(){this[Yt][Qt](new ze({[mt]:this,[Wt]:this,lifecycle:this.#t})),this[at]()}get json(){const t={};for(let e of this[Yt])e[S]&&(t[e[S]||0]=e.json);return f[O](t,null,4)}async import(t){let e=await ke(t);this.children=this.#n(e),this[at](!0)}reset(){this[Gt]({})}export(){const t={};for(let e of this[Yt])(e.key||1===this[Yt][kt])&&(t[e.key||0]=e.json);const i=new o([f[O](t,null,4)],{[Q]:"application/json"}),s=h.createObjectURL(i),n=be("a",{href:s,download:`JSONEditor-${c[ht]()}.json`});e[it][F](n),n[x](),e[it].removeChild(n),h.revokeObjectURL(s)}};class ze{key="";type="string";value="";parent;children=[];collapsed=!1;#r;#o;#t;constructor(t={}){"object"==typeof t?(this.id=function(t=64){let e="";for(let i=0;i<t;i++)e+="abcdefghijklmnopqrstuvwxyz0123456789".charAt(a.floor(36*a.random()));return e}(),this[S]=t[S]??this[S],this[Q]=t[Q]??this[Q],this[Ut]=t[Ut]??this[Ut],this[mt]=t[mt]??this[mt],this[Yt]=t[Yt]??this[Yt],this[It]=t[It]??this[It],this.#o=t.editor,this.#t=t.lifecycle):je("Failed to load config form editor node.")}render(){return this.#l()}updateChild(){this.#l(),this.#h()}setCollapsed(){this[It]=!this[It],this.#l()}get json(){return this.#a()}#h(){this.#t[Rt]((t=>{}))}#l(){const t=this.type===Pt;let i=be("section.pd-json-editor-child",[be("section.pair-wrapper",[be(V+"#"+this.id+".input-group",[me(this),Ce(this,this.parent.children.indexOf(this),t,this.#t),be("span",":"),(s=this,be("label",[s[Q][J]()===Ht?we[Ht]:s[Q][J]()===qt?we[qt]:s[Q][J]()===Pt?we[Pt]:s[Q][J]()===zt?we[zt]:we[Ot],ye({[pt]:be("select",fe[xt]((t=>be(Lt,{[Ut]:t,[Nt]:t===s[Q]?"":null},t)))),[tt]:t=>{if(s[Q]=t[L][Ut],{[zt]:1,[Pt]:1}[t[L][Ut][J]()])s[Ut]="",0===s[Yt][kt]&&s[$]();else if(t[L][Ut][J]()===Ht){const t=p(s[Ut]);s[Ut]=v(t)?"":t}else s[Ut]="",s[Yt]=[];s.updateChild(),e[Xt]("value-"+s.id).focus()}})])),Ae(this,this.#t),ye({[pt]:be(K,we[$]),[bt]:t=>{u("Remove?")&&this.#c()}})]),ge(this,((t,e)=>{let i=t.#l();return i[dt].last=e===this.children.length-1?1:0,i}),(()=>{this.#d()}))])]);var s;return this.#r&&this.#r.parentElement.replaceChild(i,this.#r),this.#r=i,this.#r}#d(){const t=new ze({[mt]:this,[Wt]:this.#o,lifecycle:this.#t});this[Yt][Qt](t);const e=this.#r.querySelector("section.pd-json-editor-nested-child"),i=e.children[e.children.length-1];for(let t of i.parentElement.children)t.dataset.last=0;const s=t.#l();s.dataset.last=1,e.insertBefore(s,i),this.#h()}#c(){if(!this[mt])return;const t=this[mt][Yt][he](this);if(-1===t)return;const e=this.#r.previousElementSibling;"1"===this.#r.dataset.last&&null!=e&&(e.dataset.last=1),this[mt][Yt].splice(t,1),this.#r[ct](),this.#h()}#a(){if(!this[mt])return;if(this[Q]===Pt)return this[Yt][xt]((t=>t.#a()));if(this[Q]===zt){const t={};for(let e of this[Yt])(e[S]||this[mt][Q]===Pt)&&(t[e[S]||r[Ft](t)[kt]]=e.#a());return t}let t=this[Ut];return this[Q]===qt?t="true"===t[J]():this[Q]===Ht&&(t=s(t)),t}}class $e{#f;#u;#p;#v;#w;#y;#g;#m;#b;constructor(t={}){this.#f=t[ve[I]]||void 0,this.#u=t[ve[_]]||void 0,this.#p=t[ve[P]]||void 0,this.#v=t[ve[G]]||void 0,this.#w=t[ve[q]]||void 0,this.#y=t[ve[Y]]||void 0}async#C(t){return new m(((e,i)=>{e(!1!==t())}))}#A(t){t(!1)}async render(t){this.#g=c[ht](),null!=this.#f&&!1===await this.#C(this.#f)||(await t(),this.#m=c[ht]()-this.#g,He(`Rendered in ${this.#m}ms.`),null!=this.#u&&this.#A(this.#u))}async update(t){clearTimeout(this.#b),this.#b=d((async()=>{this.#g=c[ht](),null!=this.#p&&!1===await this.#C(this.#p)||(await t(),this.#m=c[ht]()-this.#g,He(`Updated in ${this.#m}ms.`),null!=this.#v&&this.#A(this.#v))}),300)}async destroy(t){this.#g=c[ht](),null!=this.#w&&!1===await this.#C(this.#w)||(await t(),this.#m=c[ht]()-this.#g,He(`Destroyed in ${this.#m}ms.`),null!=this.#y&&this.#A(this.#y))}}}("undefined"==typeof window?window={}:window);export const JSONEditor = window.JSONEditor;
!function(){const t=window,e=document,i=String,s=Number,n=Boolean,l=Array,r=Object,o=(DocumentFragment,Blob),h=URL,a=Math,c=Date,d=setTimeout,f=JSON,u=confirm,p=parseFloat,v=isNaN,w=FileReader,y=File,g=fetch,m=Promise,b=/\.([\w_-]+)?/gi,C=/\#([\w_-]+)?/i,A=/^\w+(?=[\#\.]*)/i,k="then",x="click",j="parse",H="true",z="false",$="add",F="appendChild",M="class",V="section",S="key",O="stringify",N="label",L="target",T="color",B="fill",D="insert",E="createDocumentFragment",R="contentEditable",U="replaceChildren",J="toLowerCase",I="beforeRender",P="beforeUpdate",q="beforeDestroy",_="rendered",G="updated",K="button",Y="destroyed",Q="type",W="script",X="createTextNode",Z="console",tt="onchange",et="oninput",it="body",st="apply",nt="src",lt="void",rt="title",ot="error",ht="now",at="render",ct="remove",dt="dataset",ft="display",ut="float",pt="dom",vt="input",wt="textarea",yt="height",gt="img",mt="parent",bt="onclick",Ct="inner",At="isArray",kt="length",xt="map",jt="match",Ht="number",zt="object",$t="replace",Ft="keys",Mt="placeholder",Vt="source",St="style",Ot="string",Nt="selected",Lt="option",Tt="temp",Bt="test",Dt="textContent",Et="trim",Rt="update",Ut="value",Jt="width",It="collapsed",Pt="array",qt="boolean",_t="reset",Gt="import",Kt="export",Yt="children",Qt="push",Wt="editor",Xt="getElementById",Zt="nextElementSibling",te="link",ee="rel",ie="href",se="as",ne="backgroundColor",le=M+"List",re="createElement",oe="hasOwnProperty",he="indexOf",ae=Ct+"HTML",ce=Ct+"Text",de="setAttribute",fe=[Ot,Ht,qt,Pt,zt],ue="https://cdn.jsdelivr.net/npm/@pardnchiu/nanojson@0.3.3/dist/NanoJSON.css",pe="NanoJSON\nGitHub: https://github.com/pardnchiu/NanoJSON\nCreator: Pardn Chiu\nLicense: Proprietary",ve={[I]:I,[P]:P,[q]:q,[_]:_,[G]:G,[Y]:Y};for(let t of[be(te,{[ee]:"preconnect",[ie]:"https://cdn.jsdelivr.net"}),be(te,{[ee]:"preload",[ie]:ue,[se]:St}),be(te,{[ee]:"stylesheet",[ie]:ue})])e.head[F](t);document.addEventListener("DOMContentLoaded",(t=>{He("%c"+pe,"line-height: 1.75rem; font-size: 0.875rem;")}));const we={number:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.5 15v-4.5H4V9h3v6H5.5zM9 15v-2.5c0-.283.096-.52.287-.713A.967.967 0 0110 11.5h2v-1H9V9h3.5c.283 0 .52.096.713.287.191.192.287.43.287.713v1.5c0 .283-.096.52-.287.713a.968.968 0 01-.713.287h-2v1h3V15H9zm6 0v-1.5h3v-1h-2v-1h2v-1h-3V9h3.5c.283 0 .52.096.712.287.192.192.288.43.288.713v4c0 .283-.096.52-.288.713A.968.968 0 0118.5 15H15z" fill="#5F6368"/></svg>',string:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M17 15a.968.968 0 01-.712-.287A.968.968 0 0116 14v-4c0-.283.096-.52.288-.713A.968.968 0 0117 9h3c.283 0 .52.096.712.287.192.192.288.43.288.713v1h-1.5v-.5h-2v3h2V13H21v1c0 .283-.096.52-.288.713A.968.968 0 0120 15h-3zm-7.5 0V9h4c.283 0 .52.096.713.287.191.192.287.43.287.713v1c0 .283-.096.52-.287.713A.968.968 0 0113.5 12c.283 0 .52.096.713.287.191.192.287.43.287.713v1c0 .283-.096.52-.287.713A.968.968 0 0113.5 15h-4zm1.5-3.75h2v-.75h-2v.75zm0 2.25h2v-.75h-2v.75zM3 15v-5c0-.283.096-.52.288-.713A.968.968 0 014 9h3c.283 0 .52.096.713.287.191.192.287.43.287.713v5H6.5v-1.5h-2V15H3zm1.5-3h2v-1.5h-2V12z" fill="#5F6368"/></svg>',object:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13.5 18v-1.5h2.25c.213 0 .39-.072.534-.216a.726.726 0 00.216-.534v-1.5c0-.475.137-.906.413-1.294A2.233 2.233 0 0118 12.131v-.262a2.233 2.233 0 01-1.087-.825A2.184 2.184 0 0116.5 9.75v-1.5a.726.726 0 00-.216-.534.726.726 0 00-.534-.216H13.5V6h2.25a2.17 2.17 0 011.594.656c.437.438.656.969.656 1.594v1.5c0 .213.072.39.216.534a.726.726 0 00.534.216h.75v3h-.75a.726.726 0 00-.534.216.726.726 0 00-.216.534v1.5a2.17 2.17 0 01-.656 1.594A2.17 2.17 0 0115.75 18H13.5zm-5.25 0a2.17 2.17 0 01-1.594-.656A2.17 2.17 0 016 15.75v-1.5a.726.726 0 00-.216-.534.726.726 0 00-.534-.216H4.5v-3h.75c.213 0 .39-.072.534-.216A.726.726 0 006 9.75v-1.5c0-.625.219-1.156.656-1.594A2.17 2.17 0 018.25 6h2.25v1.5H8.25a.726.726 0 00-.534.216.726.726 0 00-.216.534v1.5c0 .475-.138.906-.412 1.294A2.233 2.233 0 016 11.869v.262c.45.163.813.438 1.088.825.274.388.412.819.412 1.294v1.5c0 .213.072.39.216.534a.726.726 0 00.534.216h2.25V18H8.25z" fill="#5F6368"/></svg>',array:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M14.625 19v-1.75h2.625V6.75h-2.625V5H19v14h-4.375zM5 19V5h4.375v1.75H6.75v10.5h2.625V19H5z" fill="#5F6368"/></svg>',boolean:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7.91 16.818c-1.365 0-2.524-.477-3.478-1.432C3.477 14.432 3 13.273 3 11.91c0-1.364.477-2.523 1.432-3.477C5.386 7.477 6.545 7 7.909 7h8.182c1.363 0 2.523.477 3.477 1.432.955.954 1.432 2.114 1.432 3.477 0 1.364-.477 2.523-1.432 3.477-.954.955-2.114 1.432-3.477 1.432H7.909zm0-1.636h8.18c.9 0 1.671-.32 2.312-.962.641-.64.962-1.41.962-2.31 0-.9-.32-1.671-.962-2.312a3.151 3.151 0 00-2.311-.962H7.909c-.9 0-1.67.32-2.311.962a3.151 3.151 0 00-.962 2.311c0 .9.32 1.67.962 2.311.64.641 1.411.962 2.311.962zm8.18-.818c.683 0 1.262-.239 1.74-.716a2.367 2.367 0 00.716-1.739c0-.682-.24-1.261-.716-1.739a2.367 2.367 0 00-1.74-.715c-.68 0-1.26.238-1.738.716a2.367 2.367 0 00-.716 1.738c0 .682.239 1.261.716 1.739a2.367 2.367 0 001.739.716z" fill="#5F6368"/></svg>',right:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10 18V6l6 6-6 6z" fill="#5F6368"/></svg>',folder:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M4 20c-.55 0-1.02-.196-1.413-.587A1.926 1.926 0 012 18V6c0-.55.196-1.02.587-1.412A1.926 1.926 0 014 4h6l2 2h8c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412H11.175l-2-2H4v12l2.4-8h17.1l-2.575 8.575a1.95 1.95 0 01-.738 1.038A1.985 1.985 0 0119 20H4zm2.1-2H19l1.8-6H7.9l-1.8 6z" fill="#5F6368"/></svg>',add:'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M11 13H5v-2h6V5h2v6h6v2h-6v6h-2v-6z" fill="#5F6368"/></svg>',download:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 16l-5-5 1.4-1.45 2.6 2.6V4h2v8.15l2.6-2.6L17 11l-5 5zm-6 4c-.55 0-1.02-.196-1.412-.587A1.926 1.926 0 014 18v-3h2v3h12v-3h2v3c0 .55-.196 1.02-.587 1.413A1.926 1.926 0 0118 20H6z" fill="#5F6368"/></svg>',clear:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.25 18H22v2h-6.75l2-2zm-12.5 2l-2.125-2.125c-.383-.383-.58-.858-.587-1.425-.009-.567.179-1.05.562-1.45l11-11.4c.383-.4.854-.6 1.412-.6.559 0 1.03.192 1.413.575L21.4 8.55c.383.383.575.858.575 1.425 0 .567-.192 1.042-.575 1.425L13 20H4.75zm7.4-2L20 9.95 15.05 5 4 16.4 5.6 18h6.55z" fill="#5F6368"/></svg>'};function ye(t={}){let e;if(typeof t===zt&&t[oe](pt)){e=t[pt];for(let i of r[Ft](t))i!==pt&&(e[i]=e=>t[i](e));return e}}function ge(t,e,i){if({[zt]:1,[Pt]:1}[t[Q][J]()]&&!t[It])return be(V,{[M]:"pd-json-editor-nested-child"},[...t[Yt][xt](((t,i)=>e(t,i))),ye({[pt]:be(K+".child-add",we[$]),[bt]:i})])}function me(t){const e={[zt]:1,[Pt]:1}[t[Q][J]()],i=ye({[pt]:be("button",e?we.right:null),[bt]:e?e=>t.setCollapsed():t=>{}});return i[dt].collapseable=e?1:0,i[dt][It]=t[It]?1:0,i}function be(t="",i,s){const n=((t[jt](A)||[])[0]||"")[Et](),l=((t[jt](C)||[])[1]||"")[Et](),r=(b[Bt](t)?t[jt](b):[])[xt]((t=>t[$t](/^\./,"")));if(n[kt]<1)return;let o,h,a,c=!1;if(t===Tt?(c=!0,o=e[E]()):o=e[re](n),95!=pe[kt])return o;l[kt]&&(o.id=l);for(let t of r)o[le][$](t);if(null==i&&null!=s&&([i,s]=[s,null]),null!=i&&null!=s)[h,a]=[i,s];else if(null==s)typeof i===Ot||typeof i===Ht||Array[At](i)?a=i:h=i;else if(null==i)return o;if(typeof h===zt&&null!=h)for(const t in h){if(!h[oe](t))continue;const e=h[t];-1!=[Ut,ce,ae,Dt,R][he](t)?o[t]=e:-1!=[T,ne,Jt,yt,ft,ut][he](t)?o[St][t]=e:null!=e&&o[de](t,e)}if(null!=a){const t=typeof a===Ot,i=typeof a===Ht,s=Array[At](a);if(t||i){const t=a,i=n===vt,s=n===wt;n===gt||n===Vt?o[nt]=t:s||i?o[Ut]=t:c?o[F](e[X](a)):o[ae]=t}else if(s)for(let t of a){const i=t instanceof Element;typeof t===Ot||typeof t===Ht?c?o[F](e[X](t)):o[ae]+=t:i&&o[F](t)}}return o}function Ce(t,e,i,s){function n(t){return t[$t](/\n/g,"")}function l(e){const i=e[L];i[Ut]=i[Zt][ae]=n(i[Ut]),t[S]=n(i[Ut])[Et]()}return i?be("span.array-index",`${e}`):be("label",[ye({[pt]:be("textarea#key-"+t.id,{[Mt]:"KEY"},t[S][$t](/\n/g,"")),[et]:t=>{l(t),s[Rt]((()=>{}))},[tt]:t=>{l(t)}}),be("pre",n(t[S]))])}function Ae(t,e){if(t[Q][J]()===Ht){const l=/[^\d\-\.]/g,r=p(t[Ut]);function s(t){return v(t)?"":i(t)[$t](/\s/g,"")[$t](l,"")}return be(N,[ye({[pt]:be("textarea#value-"+t.id,{[Mt]:"NUM"},s(r)),[et]:i=>{const n=i[L];n[Ut]=n[Zt][ae]=s(n[Ut]),t[Ut]=s(n[Ut]),e[Rt]((()=>{}))},[tt]:e=>{const i=e[L];i[Ut]=i[Zt][ae]=s(i[Ut]),t[Ut]=s(i[Ut])}}),be("pre",s(r))])}if(t[Q][J]()===qt)return ye({[pt]:be("select#value-"+t.id,[be(Lt,{[Ut]:H,[Nt]:t[Ut]?"":null},H),be(Lt,{[Ut]:z,[Nt]:t[Ut]?null:""},z)]),[tt]:i=>{t[Ut]=i[L][Ut],e[Rt]((()=>{}))}});{const o={[zt]:1,[Pt]:1}[t[Q][J]()];function n(t){return t[$t](/\n/g,"<br>")}return be(N,{display:o?"none":"block"},[ye({[pt]:be("textarea#value-"+t.id,{[Mt]:"VAL"},t[Ut]),[et]:i=>{const s=i[L];s[Zt][ae]=n(s[Ut]),t[Ut]=s[Ut],e[Rt]((()=>{}))},[tt]:e=>{const i=e[L];i[Zt][ae]=n(i[Ut]),t[Ut]=i[Ut]}}),be("pre",n(t[Ut]))])}}function ke(t){return new m((async(e,i)=>{if(null!=t)if(t instanceof y){const i=new w;i.onload=i=>{try{e(f[j](i[L].result))}catch(i){je(`Failed to parse JSON from file ${t.name}: ${i}`),e({})}},i.readAsText(t)}else typeof t===zt?e(t):typeof t===Ot?await g(t)[k]((t=>t.text()))[k]((t=>{try{e(f[j](t))}catch(t){throw t}})).catch((i=>{je(`Failed to fetch data from ${t}: ${i}`),e({})})):(je(`Invalid data type: ${t} (${typeof t})`),e({}));else e({})}))}function xe(t){return l[At](t)?Pt:typeof t===zt?zt:typeof t===qt?qt:typeof t===Ht?Ht:Ot}new Map;function je(...t){const i=be(W,`${Z}.${ot}.${st}(${lt} 0, ${f[O](t)});`);e[it][F](i),i[ct]()}function He(...t){const i=be(W,`${Z}.log.${st}(${lt} 0, ${f[O](t)});`);e[it][F](i),i[ct]()}t.JSONEditor=class{children=[];body;editor;button=[];#t;#e=!1;#i="Object";get type(){return this.#i}constructor(t={}){"object"==typeof t?this.#s(t):je("Failed to load config.")}async#s(t={}){this[Wt]=be("section");const i=t.when??{},s=t[rt]??"",l=t.description??"",r=n(null==t[B]?1:t[B])?1:0;let o=null!=t[K]&&typeof t[K]===zt?t[K]:{[Gt]:1,[Kt]:1,[_t]:1};o[_t]=o[_t]??1,o[Gt]=o[Gt]??1,o[Kt]=o[Kt]??1,this.#t=new $e({[I]:i[ve[I]],[_]:i[ve[_]],[P]:i[ve[P]],[G]:i[ve[G]],[q]:i[ve[q]],[Y]:i[ve[Y]]});let h=await ke(t.file??t.json??t.path);this.children=this.#n(h);let a=be("temp",[Math.max(s[kt],l[kt])>0?be("header",[s[kt]>0?be("strong",s):null,l[kt]>0?be("p",l):null]):null,this[Wt],be("footer",[ye({[pt]:be(K,{[rt]:"Add row"},we[$]),[bt]:t=>this[D]()}),n(o[Gt])?ye({[pt]:be(K,{[rt]:"Open file"},we.folder),[bt]:t=>t[L][Zt][x]()}):null,n(o[Gt])?ye({[pt]:be(vt,{[Q]:"file",accept:".json",[ft]:"none"}),[tt]:t=>this[Gt](t[L].files[0])}):null,n(o[Kt])?ye({[pt]:be(K,{[rt]:"Download file"},we.download),[bt]:t=>{u("Download?")&&this[Kt]()}}):null,n(o[_t])?ye({[pt]:be(K,{[rt]:"清空"},we.clear),[bt]:t=>{u("Reset?")&&this[Gt]({})}}):null])]);const c="pd-json-editor";null==t.id?(this[it]=be(V+"."+c),this[it][F](a)):(this[it]=e[Xt](t.id),this[it][le][$](c),this[it][U](...a[Yt])),this[it][dt][B]=r,this[Yt][kt]<1&&this[D](),this.#t[at]((async()=>{this[at](),this.#e=!0}))}#l(t){return t.render()}#n(t,e=null){const s=[];if(l[At](t))for(let n of t){const t=xe(n),l=new ze({[Q]:t,[mt]:e??this,[Wt]:this,lifecycle:this.#t});t===zt&&null!=n||t===Pt?l[Yt]=this.#n(n,l):l[Ut]=i(n),s[Qt](l)}else for(const[n,l]of r.entries(t)){const t=xe(l),r=new ze({[S]:n,[Q]:t,[mt]:e??this,[Wt]:this,lifecycle:this.#t});t===zt&&null!=l||t===Pt?r[Yt]=this.#n(l,r):r[Ut]=null==l?"":i(l),s[Qt](r)}return s}render(t=!1){let e=be("temp",this[Yt].map((t=>this.#l(t))));this[Wt][U](...e[Yt]),this.#e&&t&&this.#t[Rt]((()=>{}))}insert(){this[Yt][Qt](new ze({[mt]:this,[Wt]:this,lifecycle:this.#t})),this[at]()}get json(){const t={};for(let e of this[Yt])e[S]&&(t[e[S]||0]=e.json);return f[O](t,null,4)}async import(t){let e=await ke(t);this.children=this.#n(e),this[at](!0)}reset(){this[Gt]({})}export(){const t={};for(let e of this[Yt])(e.key||1===this[Yt][kt])&&(t[e.key||0]=e.json);const i=new o([f[O](t,null,4)],{[Q]:"application/json"}),s=h.createObjectURL(i),n=be("a",{href:s,download:`JSONEditor-${c[ht]()}.json`});e[it][F](n),n[x](),e[it].removeChild(n),h.revokeObjectURL(s)}};class ze{key="";type="string";value="";parent;children=[];collapsed=!1;#r;#o;#t;constructor(t={}){"object"==typeof t?(this.id=function(t=64){let e="";for(let i=0;i<t;i++)e+="abcdefghijklmnopqrstuvwxyz0123456789".charAt(a.floor(36*a.random()));return e}(),this[S]=t[S]??this[S],this[Q]=t[Q]??this[Q],this[Ut]=t[Ut]??this[Ut],this[mt]=t[mt]??this[mt],this[Yt]=t[Yt]??this[Yt],this[It]=t[It]??this[It],this.#o=t.editor,this.#t=t.lifecycle):je("Failed to load config form editor node.")}render(){return this.#l()}addChild(){this.#h()}updateChild(){this.#l(),this.#a()}setCollapsed(){this[It]=!this[It],this.#l()}get json(){return this.#c()}#a(){this.#t[Rt]((t=>{}))}#l(){let t=be("section.pd-json-editor-child",[be("section.pair-wrapper",[be(V+"#"+this.id+".input-group",[me(this),Ce(this,this.parent.children.indexOf(this),this.parent.type===Pt,this.#t),be("span",":"),(i=this,be("label",[i[Q][J]()===Ht?we[Ht]:i[Q][J]()===qt?we[qt]:i[Q][J]()===Pt?we[Pt]:i[Q][J]()===zt?we[zt]:we[Ot],ye({[pt]:be("select",fe[xt]((t=>be(Lt,{[Ut]:t,[Nt]:t===i[Q]?"":null},t)))),[tt]:t=>{if(i[Q]=t[L][Ut],{[zt]:1,[Pt]:1}[t[L][Ut][J]()])i[Ut]="",0===i[Yt][kt]&&i.addChild();else if(t[L][Ut][J]()===Ht){const t=p(i[Ut]);i[Ut]=v(t)?"":t}else i[Ut]="",i[Yt]=[];i.updateChild(),e[Xt]("value-"+i.id).focus()}})])),Ae(this,this.#t),ye({[pt]:be(K,we[$]),[bt]:t=>{u("Remove?")&&this.#d()}})]),ge(this,((t,e)=>{let i=t.#l();return i[dt].last=e===this.children.length-1?1:0,i}),(()=>{this.#h()}))])]);var i;return this.#r&&this.#r.parentElement.replaceChild(t,this.#r),this.#r=t,this.#r}#h(){const t=new ze({[mt]:this,[Wt]:this.#o,lifecycle:this.#t});this[Yt][Qt](t);const e=this.#r.querySelector("section.pd-json-editor-nested-child");if(null!=e){const i=e.children[e.children.length-1];for(let t of i.parentElement.children)t.dataset.last=0;const s=t.#l();s.dataset.last=1,e.insertBefore(s,i)}this.#a()}#d(){if(!this[mt])return;const t=this[mt][Yt][he](this);if(-1===t)return;const e=this.#r.previousElementSibling;"1"===this.#r.dataset.last&&null!=e&&(e.dataset.last=1),this[mt][Yt].splice(t,1),this.#r[ct](),this.#a()}#c(){if(!this[mt])return;if(this[Q]===Pt)return this[Yt][xt]((t=>t.#c()));if(this[Q]===zt){const t={};for(let e of this[Yt])(e[S]||this[mt][Q]===Pt)&&(t[e[S]||r[Ft](t)[kt]]=e.#c());return t}let t=this[Ut];return this[Q]===qt?t="true"===t[J]():this[Q]===Ht&&(t=s(t)),t}}class $e{#f;#u;#p;#v;#w;#y;#g;#m;#b;constructor(t={}){this.#f=t[ve[I]]||void 0,this.#u=t[ve[_]]||void 0,this.#p=t[ve[P]]||void 0,this.#v=t[ve[G]]||void 0,this.#w=t[ve[q]]||void 0,this.#y=t[ve[Y]]||void 0}async#C(t){return new m(((e,i)=>{e(!1!==t())}))}#A(t){t(!1)}async render(t){this.#g=c[ht](),null!=this.#f&&!1===await this.#C(this.#f)||(await t(),this.#m=c[ht]()-this.#g,He(`Rendered in ${this.#m}ms.`),null!=this.#u&&this.#A(this.#u))}async update(t){clearTimeout(this.#b),this.#b=d((async()=>{this.#g=c[ht](),null!=this.#p&&!1===await this.#C(this.#p)||(await t(),this.#m=c[ht]()-this.#g,He(`Updated in ${this.#m}ms.`),null!=this.#v&&this.#A(this.#v))}),300)}async destroy(t){this.#g=c[ht](),null!=this.#w&&!1===await this.#C(this.#w)||(await t(),this.#m=c[ht]()-this.#g,He(`Destroyed in ${this.#m}ms.`),null!=this.#y&&this.#A(this.#y))}}}("undefined"==typeof window?window={}:window);export const JSONEditor = window.JSONEditor;

@@ -1,1 +0,1 @@

!function(){const t=window,e=document,i=String,s=Number,n=Boolean,l=Array,r=Object,o=(DocumentFragment,Blob),h=URL,a=Math,c=Date,d=setTimeout,f=JSON,u=confirm,p=parseFloat,v=isNaN,w=FileReader,y=File,g=fetch,m=Promise,b=/\.([\w_-]+)?/gi,C=/\#([\w_-]+)?/i,A=/^\w+(?=[\#\.]*)/i,k="then",x="click",j="parse",H="true",z="false",$="add",F="appendChild",M="class",V="section",S="key",O="stringify",N="label",L="target",T="color",B="fill",D="insert",E="createDocumentFragment",R="contentEditable",U="replaceChildren",J="toLowerCase",I="beforeRender",P="beforeUpdate",q="beforeDestroy",_="rendered",G="updated",K="button",Y="destroyed",Q="type",W="script",X="createTextNode",Z="console",tt="onchange",et="oninput",it="body",st="apply",nt="src",lt="void",rt="title",ot="error",ht="now",at="render",ct="remove",dt="dataset",ft="display",ut="float",pt="dom",vt="input",wt="textarea",yt="height",gt="img",mt="parent",bt="onclick",Ct="inner",At="isArray",kt="length",xt="map",jt="match",Ht="number",zt="object",$t="replace",Ft="keys",Mt="placeholder",Vt="source",St="style",Ot="string",Nt="selected",Lt="option",Tt="temp",Bt="test",Dt="textContent",Et="trim",Rt="update",Ut="value",Jt="width",It="collapsed",Pt="array",qt="boolean",_t="reset",Gt="import",Kt="export",Yt="children",Qt="push",Wt="editor",Xt="getElementById",Zt="nextElementSibling",te="link",ee="rel",ie="href",se="as",ne="backgroundColor",le=M+"List",re="createElement",oe="hasOwnProperty",he="indexOf",ae=Ct+"HTML",ce=Ct+"Text",de="setAttribute",fe=[Ot,Ht,qt,Pt,zt],ue="https://cdn.jsdelivr.net/npm/@pardnchiu/nanojson@0.3.2/dist/NanoJSON.css",pe="NanoJSON\nGitHub: https://github.com/pardnchiu/NanoJSON\nCreator: Pardn Chiu\nLicense: Proprietary",ve={[I]:I,[P]:P,[q]:q,[_]:_,[G]:G,[Y]:Y};for(let t of[be(te,{[ee]:"preconnect",[ie]:"https://cdn.jsdelivr.net"}),be(te,{[ee]:"preload",[ie]:ue,[se]:St}),be(te,{[ee]:"stylesheet",[ie]:ue})])e.head[F](t);document.addEventListener("DOMContentLoaded",(t=>{He("%c"+pe,"line-height: 1.75rem; font-size: 0.875rem;")}));const we={number:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.5 15v-4.5H4V9h3v6H5.5zM9 15v-2.5c0-.283.096-.52.287-.713A.967.967 0 0110 11.5h2v-1H9V9h3.5c.283 0 .52.096.713.287.191.192.287.43.287.713v1.5c0 .283-.096.52-.287.713a.968.968 0 01-.713.287h-2v1h3V15H9zm6 0v-1.5h3v-1h-2v-1h2v-1h-3V9h3.5c.283 0 .52.096.712.287.192.192.288.43.288.713v4c0 .283-.096.52-.288.713A.968.968 0 0118.5 15H15z" fill="#5F6368"/></svg>',string:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M17 15a.968.968 0 01-.712-.287A.968.968 0 0116 14v-4c0-.283.096-.52.288-.713A.968.968 0 0117 9h3c.283 0 .52.096.712.287.192.192.288.43.288.713v1h-1.5v-.5h-2v3h2V13H21v1c0 .283-.096.52-.288.713A.968.968 0 0120 15h-3zm-7.5 0V9h4c.283 0 .52.096.713.287.191.192.287.43.287.713v1c0 .283-.096.52-.287.713A.968.968 0 0113.5 12c.283 0 .52.096.713.287.191.192.287.43.287.713v1c0 .283-.096.52-.287.713A.968.968 0 0113.5 15h-4zm1.5-3.75h2v-.75h-2v.75zm0 2.25h2v-.75h-2v.75zM3 15v-5c0-.283.096-.52.288-.713A.968.968 0 014 9h3c.283 0 .52.096.713.287.191.192.287.43.287.713v5H6.5v-1.5h-2V15H3zm1.5-3h2v-1.5h-2V12z" fill="#5F6368"/></svg>',object:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13.5 18v-1.5h2.25c.213 0 .39-.072.534-.216a.726.726 0 00.216-.534v-1.5c0-.475.137-.906.413-1.294A2.233 2.233 0 0118 12.131v-.262a2.233 2.233 0 01-1.087-.825A2.184 2.184 0 0116.5 9.75v-1.5a.726.726 0 00-.216-.534.726.726 0 00-.534-.216H13.5V6h2.25a2.17 2.17 0 011.594.656c.437.438.656.969.656 1.594v1.5c0 .213.072.39.216.534a.726.726 0 00.534.216h.75v3h-.75a.726.726 0 00-.534.216.726.726 0 00-.216.534v1.5a2.17 2.17 0 01-.656 1.594A2.17 2.17 0 0115.75 18H13.5zm-5.25 0a2.17 2.17 0 01-1.594-.656A2.17 2.17 0 016 15.75v-1.5a.726.726 0 00-.216-.534.726.726 0 00-.534-.216H4.5v-3h.75c.213 0 .39-.072.534-.216A.726.726 0 006 9.75v-1.5c0-.625.219-1.156.656-1.594A2.17 2.17 0 018.25 6h2.25v1.5H8.25a.726.726 0 00-.534.216.726.726 0 00-.216.534v1.5c0 .475-.138.906-.412 1.294A2.233 2.233 0 016 11.869v.262c.45.163.813.438 1.088.825.274.388.412.819.412 1.294v1.5c0 .213.072.39.216.534a.726.726 0 00.534.216h2.25V18H8.25z" fill="#5F6368"/></svg>',array:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M14.625 19v-1.75h2.625V6.75h-2.625V5H19v14h-4.375zM5 19V5h4.375v1.75H6.75v10.5h2.625V19H5z" fill="#5F6368"/></svg>',boolean:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7.91 16.818c-1.365 0-2.524-.477-3.478-1.432C3.477 14.432 3 13.273 3 11.91c0-1.364.477-2.523 1.432-3.477C5.386 7.477 6.545 7 7.909 7h8.182c1.363 0 2.523.477 3.477 1.432.955.954 1.432 2.114 1.432 3.477 0 1.364-.477 2.523-1.432 3.477-.954.955-2.114 1.432-3.477 1.432H7.909zm0-1.636h8.18c.9 0 1.671-.32 2.312-.962.641-.64.962-1.41.962-2.31 0-.9-.32-1.671-.962-2.312a3.151 3.151 0 00-2.311-.962H7.909c-.9 0-1.67.32-2.311.962a3.151 3.151 0 00-.962 2.311c0 .9.32 1.67.962 2.311.64.641 1.411.962 2.311.962zm8.18-.818c.683 0 1.262-.239 1.74-.716a2.367 2.367 0 00.716-1.739c0-.682-.24-1.261-.716-1.739a2.367 2.367 0 00-1.74-.715c-.68 0-1.26.238-1.738.716a2.367 2.367 0 00-.716 1.738c0 .682.239 1.261.716 1.739a2.367 2.367 0 001.739.716z" fill="#5F6368"/></svg>',right:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10 18V6l6 6-6 6z" fill="#5F6368"/></svg>',folder:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M4 20c-.55 0-1.02-.196-1.413-.587A1.926 1.926 0 012 18V6c0-.55.196-1.02.587-1.412A1.926 1.926 0 014 4h6l2 2h8c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412H11.175l-2-2H4v12l2.4-8h17.1l-2.575 8.575a1.95 1.95 0 01-.738 1.038A1.985 1.985 0 0119 20H4zm2.1-2H19l1.8-6H7.9l-1.8 6z" fill="#5F6368"/></svg>',add:'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M11 13H5v-2h6V5h2v6h6v2h-6v6h-2v-6z" fill="#5F6368"/></svg>',download:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 16l-5-5 1.4-1.45 2.6 2.6V4h2v8.15l2.6-2.6L17 11l-5 5zm-6 4c-.55 0-1.02-.196-1.412-.587A1.926 1.926 0 014 18v-3h2v3h12v-3h2v3c0 .55-.196 1.02-.587 1.413A1.926 1.926 0 0118 20H6z" fill="#5F6368"/></svg>',clear:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.25 18H22v2h-6.75l2-2zm-12.5 2l-2.125-2.125c-.383-.383-.58-.858-.587-1.425-.009-.567.179-1.05.562-1.45l11-11.4c.383-.4.854-.6 1.412-.6.559 0 1.03.192 1.413.575L21.4 8.55c.383.383.575.858.575 1.425 0 .567-.192 1.042-.575 1.425L13 20H4.75zm7.4-2L20 9.95 15.05 5 4 16.4 5.6 18h6.55z" fill="#5F6368"/></svg>'};function ye(t={}){let e;if(typeof t===zt&&t[oe](pt)){e=t[pt];for(let i of r[Ft](t))i!==pt&&(e[i]=e=>t[i](e));return e}}function ge(t,e,i){if({[zt]:1,[Pt]:1}[t[Q][J]()]&&!t[It])return be(V,{[M]:"pd-json-editor-nested-child"},[...t[Yt][xt](((t,i)=>e(t,i))),ye({[pt]:be(K+".child-add",we[$]),[bt]:i})])}function me(t){const e={[zt]:1,[Pt]:1}[t[Q][J]()],i=ye({[pt]:be("button",e?we.right:null),[bt]:e?e=>t.setCollapsed():t=>{}});return i[dt].collapseable=e?1:0,i[dt][It]=t[It]?1:0,i}function be(t="",i,s){const n=((t[jt](A)||[])[0]||"")[Et](),l=((t[jt](C)||[])[1]||"")[Et](),r=(b[Bt](t)?t[jt](b):[])[xt]((t=>t[$t](/^\./,"")));if(n[kt]<1)return;let o,h,a,c=!1;if(t===Tt?(c=!0,o=e[E]()):o=e[re](n),95!=pe[kt])return o;l[kt]&&(o.id=l);for(let t of r)o[le][$](t);if(null==i&&null!=s&&([i,s]=[s,null]),null!=i&&null!=s)[h,a]=[i,s];else if(null==s)typeof i===Ot||typeof i===Ht||Array[At](i)?a=i:h=i;else if(null==i)return o;if(typeof h===zt&&null!=h)for(const t in h){if(!h[oe](t))continue;const e=h[t];-1!=[Ut,ce,ae,Dt,R][he](t)?o[t]=e:-1!=[T,ne,Jt,yt,ft,ut][he](t)?o[St][t]=e:null!=e&&o[de](t,e)}if(null!=a){const t=typeof a===Ot,i=typeof a===Ht,s=Array[At](a);if(t||i){const t=a,i=n===vt,s=n===wt;n===gt||n===Vt?o[nt]=t:s||i?o[Ut]=t:c?o[F](e[X](a)):o[ae]=t}else if(s)for(let t of a){const i=t instanceof Element;typeof t===Ot||typeof t===Ht?c?o[F](e[X](t)):o[ae]+=t:i&&o[F](t)}}return o}function Ce(t,e,i,s){function n(t){return t[$t](/\n/g,"")}function l(e){const i=e[L];i[Ut]=i[Zt][ae]=n(i[Ut]),t[S]=n(i[Ut])[Et]()}return i?be("span.array-index",`${e}`):be("label",[ye({[pt]:be("textarea#key-"+t.id,{[Mt]:"KEY"},t[S][$t](/\n/g,"")),[et]:t=>{l(t),s[Rt]((()=>{}))},[tt]:t=>{l(t)}}),be("pre",n(t[S]))])}function Ae(t,e){if(t[Q][J]()===Ht){const l=/[^\d\-\.]/g,r=p(t[Ut]);function s(t){return v(t)?"":i(t)[$t](/\s/g,"")[$t](l,"")}return be(N,[ye({[pt]:be("textarea#value-"+t.id,{[Mt]:"NUM"},s(r)),[et]:i=>{const n=i[L];n[Ut]=n[Zt][ae]=s(n[Ut]),t[Ut]=s(n[Ut]),e[Rt]((()=>{}))},[tt]:e=>{const i=e[L];i[Ut]=i[Zt][ae]=s(i[Ut]),t[Ut]=s(i[Ut])}}),be("pre",s(r))])}if(t[Q][J]()===qt)return ye({[pt]:be("select#value-"+t.id,[be(Lt,{[Ut]:H,[Nt]:t[Ut]?"":null},H),be(Lt,{[Ut]:z,[Nt]:t[Ut]?null:""},z)]),[tt]:i=>{t[Ut]=i[L][Ut],e[Rt]((()=>{}))}});{const o={[zt]:1,[Pt]:1}[t[Q][J]()];function n(t){return t[$t](/\n/g,"<br>")}return be(N,{display:o?"none":"block"},[ye({[pt]:be("textarea#value-"+t.id,{[Mt]:"VAL"},t[Ut]),[et]:i=>{const s=i[L];s[Zt][ae]=n(s[Ut]),t[Ut]=s[Ut],e[Rt]((()=>{}))},[tt]:e=>{const i=e[L];i[Zt][ae]=n(i[Ut]),t[Ut]=i[Ut]}}),be("pre",n(t[Ut]))])}}function ke(t){return new m((async(e,i)=>{if(null!=t)if(t instanceof y){const i=new w;i.onload=i=>{try{e(f[j](i[L].result))}catch(i){je(`Failed to parse JSON from file ${t.name}: ${i}`),e({})}},i.readAsText(t)}else typeof t===zt?e(t):typeof t===Ot?await g(t)[k]((t=>t.text()))[k]((t=>{try{e(f[j](t))}catch(t){throw t}})).catch((i=>{je(`Failed to fetch data from ${t}: ${i}`),e({})})):(je(`Invalid data type: ${t} (${typeof t})`),e({}));else e({})}))}function xe(t){return l[At](t)?Pt:typeof t===zt?zt:typeof t===qt?qt:typeof t===Ht?Ht:Ot}new Map;function je(...t){const i=be(W,`${Z}.${ot}.${st}(${lt} 0, ${f[O](t)});`);e[it][F](i),i[ct]()}function He(...t){const i=be(W,`${Z}.log.${st}(${lt} 0, ${f[O](t)});`);e[it][F](i),i[ct]()}t.JSONEditor=class{children=[];body;editor;button=[];#t;#e=!1;#i="Object";get type(){return this.#i}constructor(t={}){"object"==typeof t?this.#s(t):je("Failed to load config.")}async#s(t={}){this[Wt]=be("section");const i=t.when??{},s=t[rt]??"",l=t.description??"",r=n(null==t[B]?1:t[B])?1:0;let o=null!=t[K]&&typeof t[K]===zt?t[K]:{[Gt]:1,[Kt]:1,[_t]:1};o[_t]=o[_t]??1,o[Gt]=o[Gt]??1,o[Kt]=o[Kt]??1,this.#t=new $e({[I]:i[ve[I]],[_]:i[ve[_]],[P]:i[ve[P]],[G]:i[ve[G]],[q]:i[ve[q]],[Y]:i[ve[Y]]});let h=await ke(t.file??t.json??t.path);this.children=this.#n(h);let a=be("temp",[Math.max(s[kt],l[kt])>0?be("header",[s[kt]>0?be("strong",s):null,l[kt]>0?be("p",l):null]):null,this[Wt],be("footer",[ye({[pt]:be(K,{[rt]:"Add row"},we[$]),[bt]:t=>this[D]()}),n(o[Gt])?ye({[pt]:be(K,{[rt]:"Open file"},we.folder),[bt]:t=>t[L][Zt][x]()}):null,n(o[Gt])?ye({[pt]:be(vt,{[Q]:"file",accept:".json",[ft]:"none"}),[tt]:t=>this[Gt](t[L].files[0])}):null,n(o[Kt])?ye({[pt]:be(K,{[rt]:"Download file"},we.download),[bt]:t=>{u("Download?")&&this[Kt]()}}):null,n(o[_t])?ye({[pt]:be(K,{[rt]:"清空"},we.clear),[bt]:t=>{u("Reset?")&&this[Gt]({})}}):null])]);const c="pd-json-editor";null==t.id?(this[it]=be(V+"."+c),this[it][F](a)):(this[it]=e[Xt](t.id),this[it][le][$](c),this[it][U](...a[Yt])),this[it][dt][B]=r,this[Yt][kt]<1&&this[D](),this.#t[at]((async()=>{this[at](),this.#e=!0}))}#l(t){return t.render()}#n(t,e=null){const s=[];if(l[At](t))for(let n of t){const t=xe(n),l=new ze({[Q]:t,[mt]:e??this,[Wt]:this,lifecycle:this.#t});t===zt&&null!=n||t===Pt?l[Yt]=this.#n(n,l):l[Ut]=i(n),s[Qt](l)}else for(const[n,l]of r.entries(t)){const t=xe(l),r=new ze({[S]:n,[Q]:t,[mt]:e??this,[Wt]:this,lifecycle:this.#t});t===zt&&null!=l||t===Pt?r[Yt]=this.#n(l,r):r[Ut]=null==l?"":i(l),s[Qt](r)}return s}render(t=!1){let e=be("temp",this[Yt].map((t=>this.#l(t))));this[Wt][U](...e[Yt]),this.#e&&t&&this.#t[Rt]((()=>{}))}insert(){this[Yt][Qt](new ze({[mt]:this,[Wt]:this,lifecycle:this.#t})),this[at]()}get json(){const t={};for(let e of this[Yt])e[S]&&(t[e[S]||0]=e.json);return f[O](t,null,4)}async import(t){let e=await ke(t);this.children=this.#n(e),this[at](!0)}reset(){this[Gt]({})}export(){const t={};for(let e of this[Yt])(e.key||1===this[Yt][kt])&&(t[e.key||0]=e.json);const i=new o([f[O](t,null,4)],{[Q]:"application/json"}),s=h.createObjectURL(i),n=be("a",{href:s,download:`JSONEditor-${c[ht]()}.json`});e[it][F](n),n[x](),e[it].removeChild(n),h.revokeObjectURL(s)}};class ze{key="";type="string";value="";parent;children=[];collapsed=!1;#r;#o;#t;constructor(t={}){"object"==typeof t?(this.id=function(t=64){let e="";for(let i=0;i<t;i++)e+="abcdefghijklmnopqrstuvwxyz0123456789".charAt(a.floor(36*a.random()));return e}(),this[S]=t[S]??this[S],this[Q]=t[Q]??this[Q],this[Ut]=t[Ut]??this[Ut],this[mt]=t[mt]??this[mt],this[Yt]=t[Yt]??this[Yt],this[It]=t[It]??this[It],this.#o=t.editor,this.#t=t.lifecycle):je("Failed to load config form editor node.")}render(){return this.#l()}updateChild(){this.#l(),this.#h()}setCollapsed(){this[It]=!this[It],this.#l()}get json(){return this.#a()}#h(){this.#t[Rt]((t=>{}))}#l(){const t=this.type===Pt;let i=be("section.pd-json-editor-child",[be("section.pair-wrapper",[be(V+"#"+this.id+".input-group",[me(this),Ce(this,this.parent.children.indexOf(this),t,this.#t),be("span",":"),(s=this,be("label",[s[Q][J]()===Ht?we[Ht]:s[Q][J]()===qt?we[qt]:s[Q][J]()===Pt?we[Pt]:s[Q][J]()===zt?we[zt]:we[Ot],ye({[pt]:be("select",fe[xt]((t=>be(Lt,{[Ut]:t,[Nt]:t===s[Q]?"":null},t)))),[tt]:t=>{if(s[Q]=t[L][Ut],{[zt]:1,[Pt]:1}[t[L][Ut][J]()])s[Ut]="",0===s[Yt][kt]&&s[$]();else if(t[L][Ut][J]()===Ht){const t=p(s[Ut]);s[Ut]=v(t)?"":t}else s[Ut]="",s[Yt]=[];s.updateChild(),e[Xt]("value-"+s.id).focus()}})])),Ae(this,this.#t),ye({[pt]:be(K,we[$]),[bt]:t=>{u("Remove?")&&this.#c()}})]),ge(this,((t,e)=>{let i=t.#l();return i[dt].last=e===this.children.length-1?1:0,i}),(()=>{this.#d()}))])]);var s;return this.#r&&this.#r.parentElement.replaceChild(i,this.#r),this.#r=i,this.#r}#d(){const t=new ze({[mt]:this,[Wt]:this.#o,lifecycle:this.#t});this[Yt][Qt](t);const e=this.#r.querySelector("section.pd-json-editor-nested-child"),i=e.children[e.children.length-1];for(let t of i.parentElement.children)t.dataset.last=0;const s=t.#l();s.dataset.last=1,e.insertBefore(s,i),this.#h()}#c(){if(!this[mt])return;const t=this[mt][Yt][he](this);if(-1===t)return;const e=this.#r.previousElementSibling;"1"===this.#r.dataset.last&&null!=e&&(e.dataset.last=1),this[mt][Yt].splice(t,1),this.#r[ct](),this.#h()}#a(){if(!this[mt])return;if(this[Q]===Pt)return this[Yt][xt]((t=>t.#a()));if(this[Q]===zt){const t={};for(let e of this[Yt])(e[S]||this[mt][Q]===Pt)&&(t[e[S]||r[Ft](t)[kt]]=e.#a());return t}let t=this[Ut];return this[Q]===qt?t="true"===t[J]():this[Q]===Ht&&(t=s(t)),t}}class $e{#f;#u;#p;#v;#w;#y;#g;#m;#b;constructor(t={}){this.#f=t[ve[I]]||void 0,this.#u=t[ve[_]]||void 0,this.#p=t[ve[P]]||void 0,this.#v=t[ve[G]]||void 0,this.#w=t[ve[q]]||void 0,this.#y=t[ve[Y]]||void 0}async#C(t){return new m(((e,i)=>{e(!1!==t())}))}#A(t){t(!1)}async render(t){this.#g=c[ht](),null!=this.#f&&!1===await this.#C(this.#f)||(await t(),this.#m=c[ht]()-this.#g,He(`Rendered in ${this.#m}ms.`),null!=this.#u&&this.#A(this.#u))}async update(t){clearTimeout(this.#b),this.#b=d((async()=>{this.#g=c[ht](),null!=this.#p&&!1===await this.#C(this.#p)||(await t(),this.#m=c[ht]()-this.#g,He(`Updated in ${this.#m}ms.`),null!=this.#v&&this.#A(this.#v))}),300)}async destroy(t){this.#g=c[ht](),null!=this.#w&&!1===await this.#C(this.#w)||(await t(),this.#m=c[ht]()-this.#g,He(`Destroyed in ${this.#m}ms.`),null!=this.#y&&this.#A(this.#y))}}}("undefined"==typeof window?window={}:window);
!function(){const t=window,e=document,i=String,s=Number,n=Boolean,l=Array,r=Object,o=(DocumentFragment,Blob),h=URL,a=Math,c=Date,d=setTimeout,f=JSON,u=confirm,p=parseFloat,v=isNaN,w=FileReader,y=File,g=fetch,m=Promise,b=/\.([\w_-]+)?/gi,C=/\#([\w_-]+)?/i,A=/^\w+(?=[\#\.]*)/i,k="then",x="click",j="parse",H="true",z="false",$="add",F="appendChild",M="class",V="section",S="key",O="stringify",N="label",L="target",T="color",B="fill",D="insert",E="createDocumentFragment",R="contentEditable",U="replaceChildren",J="toLowerCase",I="beforeRender",P="beforeUpdate",q="beforeDestroy",_="rendered",G="updated",K="button",Y="destroyed",Q="type",W="script",X="createTextNode",Z="console",tt="onchange",et="oninput",it="body",st="apply",nt="src",lt="void",rt="title",ot="error",ht="now",at="render",ct="remove",dt="dataset",ft="display",ut="float",pt="dom",vt="input",wt="textarea",yt="height",gt="img",mt="parent",bt="onclick",Ct="inner",At="isArray",kt="length",xt="map",jt="match",Ht="number",zt="object",$t="replace",Ft="keys",Mt="placeholder",Vt="source",St="style",Ot="string",Nt="selected",Lt="option",Tt="temp",Bt="test",Dt="textContent",Et="trim",Rt="update",Ut="value",Jt="width",It="collapsed",Pt="array",qt="boolean",_t="reset",Gt="import",Kt="export",Yt="children",Qt="push",Wt="editor",Xt="getElementById",Zt="nextElementSibling",te="link",ee="rel",ie="href",se="as",ne="backgroundColor",le=M+"List",re="createElement",oe="hasOwnProperty",he="indexOf",ae=Ct+"HTML",ce=Ct+"Text",de="setAttribute",fe=[Ot,Ht,qt,Pt,zt],ue="https://cdn.jsdelivr.net/npm/@pardnchiu/nanojson@0.3.3/dist/NanoJSON.css",pe="NanoJSON\nGitHub: https://github.com/pardnchiu/NanoJSON\nCreator: Pardn Chiu\nLicense: Proprietary",ve={[I]:I,[P]:P,[q]:q,[_]:_,[G]:G,[Y]:Y};for(let t of[be(te,{[ee]:"preconnect",[ie]:"https://cdn.jsdelivr.net"}),be(te,{[ee]:"preload",[ie]:ue,[se]:St}),be(te,{[ee]:"stylesheet",[ie]:ue})])e.head[F](t);document.addEventListener("DOMContentLoaded",(t=>{He("%c"+pe,"line-height: 1.75rem; font-size: 0.875rem;")}));const we={number:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.5 15v-4.5H4V9h3v6H5.5zM9 15v-2.5c0-.283.096-.52.287-.713A.967.967 0 0110 11.5h2v-1H9V9h3.5c.283 0 .52.096.713.287.191.192.287.43.287.713v1.5c0 .283-.096.52-.287.713a.968.968 0 01-.713.287h-2v1h3V15H9zm6 0v-1.5h3v-1h-2v-1h2v-1h-3V9h3.5c.283 0 .52.096.712.287.192.192.288.43.288.713v4c0 .283-.096.52-.288.713A.968.968 0 0118.5 15H15z" fill="#5F6368"/></svg>',string:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M17 15a.968.968 0 01-.712-.287A.968.968 0 0116 14v-4c0-.283.096-.52.288-.713A.968.968 0 0117 9h3c.283 0 .52.096.712.287.192.192.288.43.288.713v1h-1.5v-.5h-2v3h2V13H21v1c0 .283-.096.52-.288.713A.968.968 0 0120 15h-3zm-7.5 0V9h4c.283 0 .52.096.713.287.191.192.287.43.287.713v1c0 .283-.096.52-.287.713A.968.968 0 0113.5 12c.283 0 .52.096.713.287.191.192.287.43.287.713v1c0 .283-.096.52-.287.713A.968.968 0 0113.5 15h-4zm1.5-3.75h2v-.75h-2v.75zm0 2.25h2v-.75h-2v.75zM3 15v-5c0-.283.096-.52.288-.713A.968.968 0 014 9h3c.283 0 .52.096.713.287.191.192.287.43.287.713v5H6.5v-1.5h-2V15H3zm1.5-3h2v-1.5h-2V12z" fill="#5F6368"/></svg>',object:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13.5 18v-1.5h2.25c.213 0 .39-.072.534-.216a.726.726 0 00.216-.534v-1.5c0-.475.137-.906.413-1.294A2.233 2.233 0 0118 12.131v-.262a2.233 2.233 0 01-1.087-.825A2.184 2.184 0 0116.5 9.75v-1.5a.726.726 0 00-.216-.534.726.726 0 00-.534-.216H13.5V6h2.25a2.17 2.17 0 011.594.656c.437.438.656.969.656 1.594v1.5c0 .213.072.39.216.534a.726.726 0 00.534.216h.75v3h-.75a.726.726 0 00-.534.216.726.726 0 00-.216.534v1.5a2.17 2.17 0 01-.656 1.594A2.17 2.17 0 0115.75 18H13.5zm-5.25 0a2.17 2.17 0 01-1.594-.656A2.17 2.17 0 016 15.75v-1.5a.726.726 0 00-.216-.534.726.726 0 00-.534-.216H4.5v-3h.75c.213 0 .39-.072.534-.216A.726.726 0 006 9.75v-1.5c0-.625.219-1.156.656-1.594A2.17 2.17 0 018.25 6h2.25v1.5H8.25a.726.726 0 00-.534.216.726.726 0 00-.216.534v1.5c0 .475-.138.906-.412 1.294A2.233 2.233 0 016 11.869v.262c.45.163.813.438 1.088.825.274.388.412.819.412 1.294v1.5c0 .213.072.39.216.534a.726.726 0 00.534.216h2.25V18H8.25z" fill="#5F6368"/></svg>',array:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M14.625 19v-1.75h2.625V6.75h-2.625V5H19v14h-4.375zM5 19V5h4.375v1.75H6.75v10.5h2.625V19H5z" fill="#5F6368"/></svg>',boolean:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7.91 16.818c-1.365 0-2.524-.477-3.478-1.432C3.477 14.432 3 13.273 3 11.91c0-1.364.477-2.523 1.432-3.477C5.386 7.477 6.545 7 7.909 7h8.182c1.363 0 2.523.477 3.477 1.432.955.954 1.432 2.114 1.432 3.477 0 1.364-.477 2.523-1.432 3.477-.954.955-2.114 1.432-3.477 1.432H7.909zm0-1.636h8.18c.9 0 1.671-.32 2.312-.962.641-.64.962-1.41.962-2.31 0-.9-.32-1.671-.962-2.312a3.151 3.151 0 00-2.311-.962H7.909c-.9 0-1.67.32-2.311.962a3.151 3.151 0 00-.962 2.311c0 .9.32 1.67.962 2.311.64.641 1.411.962 2.311.962zm8.18-.818c.683 0 1.262-.239 1.74-.716a2.367 2.367 0 00.716-1.739c0-.682-.24-1.261-.716-1.739a2.367 2.367 0 00-1.74-.715c-.68 0-1.26.238-1.738.716a2.367 2.367 0 00-.716 1.738c0 .682.239 1.261.716 1.739a2.367 2.367 0 001.739.716z" fill="#5F6368"/></svg>',right:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10 18V6l6 6-6 6z" fill="#5F6368"/></svg>',folder:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M4 20c-.55 0-1.02-.196-1.413-.587A1.926 1.926 0 012 18V6c0-.55.196-1.02.587-1.412A1.926 1.926 0 014 4h6l2 2h8c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412H11.175l-2-2H4v12l2.4-8h17.1l-2.575 8.575a1.95 1.95 0 01-.738 1.038A1.985 1.985 0 0119 20H4zm2.1-2H19l1.8-6H7.9l-1.8 6z" fill="#5F6368"/></svg>',add:'<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M11 13H5v-2h6V5h2v6h6v2h-6v6h-2v-6z" fill="#5F6368"/></svg>',download:'<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 16l-5-5 1.4-1.45 2.6 2.6V4h2v8.15l2.6-2.6L17 11l-5 5zm-6 4c-.55 0-1.02-.196-1.412-.587A1.926 1.926 0 014 18v-3h2v3h12v-3h2v3c0 .55-.196 1.02-.587 1.413A1.926 1.926 0 0118 20H6z" fill="#5F6368"/></svg>',clear:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.25 18H22v2h-6.75l2-2zm-12.5 2l-2.125-2.125c-.383-.383-.58-.858-.587-1.425-.009-.567.179-1.05.562-1.45l11-11.4c.383-.4.854-.6 1.412-.6.559 0 1.03.192 1.413.575L21.4 8.55c.383.383.575.858.575 1.425 0 .567-.192 1.042-.575 1.425L13 20H4.75zm7.4-2L20 9.95 15.05 5 4 16.4 5.6 18h6.55z" fill="#5F6368"/></svg>'};function ye(t={}){let e;if(typeof t===zt&&t[oe](pt)){e=t[pt];for(let i of r[Ft](t))i!==pt&&(e[i]=e=>t[i](e));return e}}function ge(t,e,i){if({[zt]:1,[Pt]:1}[t[Q][J]()]&&!t[It])return be(V,{[M]:"pd-json-editor-nested-child"},[...t[Yt][xt](((t,i)=>e(t,i))),ye({[pt]:be(K+".child-add",we[$]),[bt]:i})])}function me(t){const e={[zt]:1,[Pt]:1}[t[Q][J]()],i=ye({[pt]:be("button",e?we.right:null),[bt]:e?e=>t.setCollapsed():t=>{}});return i[dt].collapseable=e?1:0,i[dt][It]=t[It]?1:0,i}function be(t="",i,s){const n=((t[jt](A)||[])[0]||"")[Et](),l=((t[jt](C)||[])[1]||"")[Et](),r=(b[Bt](t)?t[jt](b):[])[xt]((t=>t[$t](/^\./,"")));if(n[kt]<1)return;let o,h,a,c=!1;if(t===Tt?(c=!0,o=e[E]()):o=e[re](n),95!=pe[kt])return o;l[kt]&&(o.id=l);for(let t of r)o[le][$](t);if(null==i&&null!=s&&([i,s]=[s,null]),null!=i&&null!=s)[h,a]=[i,s];else if(null==s)typeof i===Ot||typeof i===Ht||Array[At](i)?a=i:h=i;else if(null==i)return o;if(typeof h===zt&&null!=h)for(const t in h){if(!h[oe](t))continue;const e=h[t];-1!=[Ut,ce,ae,Dt,R][he](t)?o[t]=e:-1!=[T,ne,Jt,yt,ft,ut][he](t)?o[St][t]=e:null!=e&&o[de](t,e)}if(null!=a){const t=typeof a===Ot,i=typeof a===Ht,s=Array[At](a);if(t||i){const t=a,i=n===vt,s=n===wt;n===gt||n===Vt?o[nt]=t:s||i?o[Ut]=t:c?o[F](e[X](a)):o[ae]=t}else if(s)for(let t of a){const i=t instanceof Element;typeof t===Ot||typeof t===Ht?c?o[F](e[X](t)):o[ae]+=t:i&&o[F](t)}}return o}function Ce(t,e,i,s){function n(t){return t[$t](/\n/g,"")}function l(e){const i=e[L];i[Ut]=i[Zt][ae]=n(i[Ut]),t[S]=n(i[Ut])[Et]()}return i?be("span.array-index",`${e}`):be("label",[ye({[pt]:be("textarea#key-"+t.id,{[Mt]:"KEY"},t[S][$t](/\n/g,"")),[et]:t=>{l(t),s[Rt]((()=>{}))},[tt]:t=>{l(t)}}),be("pre",n(t[S]))])}function Ae(t,e){if(t[Q][J]()===Ht){const l=/[^\d\-\.]/g,r=p(t[Ut]);function s(t){return v(t)?"":i(t)[$t](/\s/g,"")[$t](l,"")}return be(N,[ye({[pt]:be("textarea#value-"+t.id,{[Mt]:"NUM"},s(r)),[et]:i=>{const n=i[L];n[Ut]=n[Zt][ae]=s(n[Ut]),t[Ut]=s(n[Ut]),e[Rt]((()=>{}))},[tt]:e=>{const i=e[L];i[Ut]=i[Zt][ae]=s(i[Ut]),t[Ut]=s(i[Ut])}}),be("pre",s(r))])}if(t[Q][J]()===qt)return ye({[pt]:be("select#value-"+t.id,[be(Lt,{[Ut]:H,[Nt]:t[Ut]?"":null},H),be(Lt,{[Ut]:z,[Nt]:t[Ut]?null:""},z)]),[tt]:i=>{t[Ut]=i[L][Ut],e[Rt]((()=>{}))}});{const o={[zt]:1,[Pt]:1}[t[Q][J]()];function n(t){return t[$t](/\n/g,"<br>")}return be(N,{display:o?"none":"block"},[ye({[pt]:be("textarea#value-"+t.id,{[Mt]:"VAL"},t[Ut]),[et]:i=>{const s=i[L];s[Zt][ae]=n(s[Ut]),t[Ut]=s[Ut],e[Rt]((()=>{}))},[tt]:e=>{const i=e[L];i[Zt][ae]=n(i[Ut]),t[Ut]=i[Ut]}}),be("pre",n(t[Ut]))])}}function ke(t){return new m((async(e,i)=>{if(null!=t)if(t instanceof y){const i=new w;i.onload=i=>{try{e(f[j](i[L].result))}catch(i){je(`Failed to parse JSON from file ${t.name}: ${i}`),e({})}},i.readAsText(t)}else typeof t===zt?e(t):typeof t===Ot?await g(t)[k]((t=>t.text()))[k]((t=>{try{e(f[j](t))}catch(t){throw t}})).catch((i=>{je(`Failed to fetch data from ${t}: ${i}`),e({})})):(je(`Invalid data type: ${t} (${typeof t})`),e({}));else e({})}))}function xe(t){return l[At](t)?Pt:typeof t===zt?zt:typeof t===qt?qt:typeof t===Ht?Ht:Ot}new Map;function je(...t){const i=be(W,`${Z}.${ot}.${st}(${lt} 0, ${f[O](t)});`);e[it][F](i),i[ct]()}function He(...t){const i=be(W,`${Z}.log.${st}(${lt} 0, ${f[O](t)});`);e[it][F](i),i[ct]()}t.JSONEditor=class{children=[];body;editor;button=[];#t;#e=!1;#i="Object";get type(){return this.#i}constructor(t={}){"object"==typeof t?this.#s(t):je("Failed to load config.")}async#s(t={}){this[Wt]=be("section");const i=t.when??{},s=t[rt]??"",l=t.description??"",r=n(null==t[B]?1:t[B])?1:0;let o=null!=t[K]&&typeof t[K]===zt?t[K]:{[Gt]:1,[Kt]:1,[_t]:1};o[_t]=o[_t]??1,o[Gt]=o[Gt]??1,o[Kt]=o[Kt]??1,this.#t=new $e({[I]:i[ve[I]],[_]:i[ve[_]],[P]:i[ve[P]],[G]:i[ve[G]],[q]:i[ve[q]],[Y]:i[ve[Y]]});let h=await ke(t.file??t.json??t.path);this.children=this.#n(h);let a=be("temp",[Math.max(s[kt],l[kt])>0?be("header",[s[kt]>0?be("strong",s):null,l[kt]>0?be("p",l):null]):null,this[Wt],be("footer",[ye({[pt]:be(K,{[rt]:"Add row"},we[$]),[bt]:t=>this[D]()}),n(o[Gt])?ye({[pt]:be(K,{[rt]:"Open file"},we.folder),[bt]:t=>t[L][Zt][x]()}):null,n(o[Gt])?ye({[pt]:be(vt,{[Q]:"file",accept:".json",[ft]:"none"}),[tt]:t=>this[Gt](t[L].files[0])}):null,n(o[Kt])?ye({[pt]:be(K,{[rt]:"Download file"},we.download),[bt]:t=>{u("Download?")&&this[Kt]()}}):null,n(o[_t])?ye({[pt]:be(K,{[rt]:"清空"},we.clear),[bt]:t=>{u("Reset?")&&this[Gt]({})}}):null])]);const c="pd-json-editor";null==t.id?(this[it]=be(V+"."+c),this[it][F](a)):(this[it]=e[Xt](t.id),this[it][le][$](c),this[it][U](...a[Yt])),this[it][dt][B]=r,this[Yt][kt]<1&&this[D](),this.#t[at]((async()=>{this[at](),this.#e=!0}))}#l(t){return t.render()}#n(t,e=null){const s=[];if(l[At](t))for(let n of t){const t=xe(n),l=new ze({[Q]:t,[mt]:e??this,[Wt]:this,lifecycle:this.#t});t===zt&&null!=n||t===Pt?l[Yt]=this.#n(n,l):l[Ut]=i(n),s[Qt](l)}else for(const[n,l]of r.entries(t)){const t=xe(l),r=new ze({[S]:n,[Q]:t,[mt]:e??this,[Wt]:this,lifecycle:this.#t});t===zt&&null!=l||t===Pt?r[Yt]=this.#n(l,r):r[Ut]=null==l?"":i(l),s[Qt](r)}return s}render(t=!1){let e=be("temp",this[Yt].map((t=>this.#l(t))));this[Wt][U](...e[Yt]),this.#e&&t&&this.#t[Rt]((()=>{}))}insert(){this[Yt][Qt](new ze({[mt]:this,[Wt]:this,lifecycle:this.#t})),this[at]()}get json(){const t={};for(let e of this[Yt])e[S]&&(t[e[S]||0]=e.json);return f[O](t,null,4)}async import(t){let e=await ke(t);this.children=this.#n(e),this[at](!0)}reset(){this[Gt]({})}export(){const t={};for(let e of this[Yt])(e.key||1===this[Yt][kt])&&(t[e.key||0]=e.json);const i=new o([f[O](t,null,4)],{[Q]:"application/json"}),s=h.createObjectURL(i),n=be("a",{href:s,download:`JSONEditor-${c[ht]()}.json`});e[it][F](n),n[x](),e[it].removeChild(n),h.revokeObjectURL(s)}};class ze{key="";type="string";value="";parent;children=[];collapsed=!1;#r;#o;#t;constructor(t={}){"object"==typeof t?(this.id=function(t=64){let e="";for(let i=0;i<t;i++)e+="abcdefghijklmnopqrstuvwxyz0123456789".charAt(a.floor(36*a.random()));return e}(),this[S]=t[S]??this[S],this[Q]=t[Q]??this[Q],this[Ut]=t[Ut]??this[Ut],this[mt]=t[mt]??this[mt],this[Yt]=t[Yt]??this[Yt],this[It]=t[It]??this[It],this.#o=t.editor,this.#t=t.lifecycle):je("Failed to load config form editor node.")}render(){return this.#l()}addChild(){this.#h()}updateChild(){this.#l(),this.#a()}setCollapsed(){this[It]=!this[It],this.#l()}get json(){return this.#c()}#a(){this.#t[Rt]((t=>{}))}#l(){let t=be("section.pd-json-editor-child",[be("section.pair-wrapper",[be(V+"#"+this.id+".input-group",[me(this),Ce(this,this.parent.children.indexOf(this),this.parent.type===Pt,this.#t),be("span",":"),(i=this,be("label",[i[Q][J]()===Ht?we[Ht]:i[Q][J]()===qt?we[qt]:i[Q][J]()===Pt?we[Pt]:i[Q][J]()===zt?we[zt]:we[Ot],ye({[pt]:be("select",fe[xt]((t=>be(Lt,{[Ut]:t,[Nt]:t===i[Q]?"":null},t)))),[tt]:t=>{if(i[Q]=t[L][Ut],{[zt]:1,[Pt]:1}[t[L][Ut][J]()])i[Ut]="",0===i[Yt][kt]&&i.addChild();else if(t[L][Ut][J]()===Ht){const t=p(i[Ut]);i[Ut]=v(t)?"":t}else i[Ut]="",i[Yt]=[];i.updateChild(),e[Xt]("value-"+i.id).focus()}})])),Ae(this,this.#t),ye({[pt]:be(K,we[$]),[bt]:t=>{u("Remove?")&&this.#d()}})]),ge(this,((t,e)=>{let i=t.#l();return i[dt].last=e===this.children.length-1?1:0,i}),(()=>{this.#h()}))])]);var i;return this.#r&&this.#r.parentElement.replaceChild(t,this.#r),this.#r=t,this.#r}#h(){const t=new ze({[mt]:this,[Wt]:this.#o,lifecycle:this.#t});this[Yt][Qt](t);const e=this.#r.querySelector("section.pd-json-editor-nested-child");if(null!=e){const i=e.children[e.children.length-1];for(let t of i.parentElement.children)t.dataset.last=0;const s=t.#l();s.dataset.last=1,e.insertBefore(s,i)}this.#a()}#d(){if(!this[mt])return;const t=this[mt][Yt][he](this);if(-1===t)return;const e=this.#r.previousElementSibling;"1"===this.#r.dataset.last&&null!=e&&(e.dataset.last=1),this[mt][Yt].splice(t,1),this.#r[ct](),this.#a()}#c(){if(!this[mt])return;if(this[Q]===Pt)return this[Yt][xt]((t=>t.#c()));if(this[Q]===zt){const t={};for(let e of this[Yt])(e[S]||this[mt][Q]===Pt)&&(t[e[S]||r[Ft](t)[kt]]=e.#c());return t}let t=this[Ut];return this[Q]===qt?t="true"===t[J]():this[Q]===Ht&&(t=s(t)),t}}class $e{#f;#u;#p;#v;#w;#y;#g;#m;#b;constructor(t={}){this.#f=t[ve[I]]||void 0,this.#u=t[ve[_]]||void 0,this.#p=t[ve[P]]||void 0,this.#v=t[ve[G]]||void 0,this.#w=t[ve[q]]||void 0,this.#y=t[ve[Y]]||void 0}async#C(t){return new m(((e,i)=>{e(!1!==t())}))}#A(t){t(!1)}async render(t){this.#g=c[ht](),null!=this.#f&&!1===await this.#C(this.#f)||(await t(),this.#m=c[ht]()-this.#g,He(`Rendered in ${this.#m}ms.`),null!=this.#u&&this.#A(this.#u))}async update(t){clearTimeout(this.#b),this.#b=d((async()=>{this.#g=c[ht](),null!=this.#p&&!1===await this.#C(this.#p)||(await t(),this.#m=c[ht]()-this.#g,He(`Updated in ${this.#m}ms.`),null!=this.#v&&this.#A(this.#v))}),300)}async destroy(t){this.#g=c[ht](),null!=this.#w&&!1===await this.#C(this.#w)||(await t(),this.#m=c[ht]()-this.#g,He(`Destroyed in ${this.#m}ms.`),null!=this.#y&&this.#A(this.#y))}}}("undefined"==typeof window?window={}:window);
{
"name": "@pardnchiu/nanojson",
"version": "0.3.2",
"version": "0.3.3",
"description": "NanoJSON is a lightweight JSON editing library built on pure JavaScript and native APIs. Can be easily embedded into websites.",

@@ -5,0 +5,0 @@ "main": "dist/NanoJSON.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc