import{k as j,W as C,o as O,c as N,g as S,G as I,aG as v,y as P,b as B}from"./index-e48f6898.js";const J=B("div",{id:"jsonPreview"},null,-1),V={__name:"FelJsonPreViewer",props:["data","wrapper"],setup(h){const g=h;C(()=>g.data,(e,t)=>{document.getElementById("jsonPreview").innerHTML="",e.length!==0&&new a({container:document.getElementById("jsonPreview"),data:JSON.stringify(g.data),theme:"light",expand:!1})});const f=Object.prototype.toString;function w(e){return typeof e=="number"}function _(e){return typeof e=="boolean"}function x(e){return typeof e>"u"}function b(e){return f.call(e)==="[object Array]"}function A(e){return f.call(e)==="[object Object]"}function m(e){return f.call(e)==="[object Null]"}function a(e){const t={theme:"light",container:null,data:"{}",expand:!1};if(this.options=Object.assign(t,e),m(e.container))throw new Error("Container: dom element is required");this.render()}return a.prototype.renderRight=function(e,t,n){w(n)?t.setAttribute("class",e+"rightNumber"):_(n)?t.setAttribute("class",e+"rightBoolean"):n==="null"?t.setAttribute("class",e+"rightNull"):t.setAttribute("class",e+"rightString"),t.innerText=n},a.prototype.renderChildren=function(e,t,n,s,o,l){let r=this,i=this.createElement("span"),c=this.options.expand?"rotate90":"",u=this.options.expand?"add-height":"";i.setAttribute("class",e+"folder "+c),i.onclick=function(y){let E=y.target.parentNode.nextSibling;r.toggleItem(E,y.target)};let p=0,d=!1;A(n)?(p=Object.keys(n).length,d=!0):p=n.length,l.innerHTML=d?t+"  {"+p+"}":t+"  ["+p+"]",l.prepend(i),s.setAttribute("class",e+"rightObj "+u),r.parse(n,s,o+0,e)},a.prototype.parse=function(e,t,n,s){const o=this;this.forEach(e,function(l,r){const{left:i,right:c}=o.createItem(n,s,t,r,typeof l!="object");typeof l!="object"?o.renderRight(s,c,l):o.renderChildren(s,r,l,c,n,i)})},a.prototype.createItem=function(e,t,n,s,o){let l=this,r=this.createElement("div"),i=this.createElement("div"),c=this.createElement("div"),u=this.createElement("div");return r.style.marginLeft=e*2+"px",i.innerHTML=`${s} : `,o?(r.appendChild(u),u.appendChild(i),u.appendChild(c),n.appendChild(r),r.setAttribute("class",t+"current"),u.setAttribute("class","jv-wrap"),i.setAttribute("class",t+"left")):(r.appendChild(i),r.appendChild(c),n.appendChild(r),r.setAttribute("class",t+"current"),i.setAttribute("class",t+"left jv-folder"),i.onclick=function(p){let d=p.target.nextSibling;l.toggleItem(d,p.target.querySelector("span"))}),{left:i,right:c,current:r}},a.prototype.render=function(){let e=this.options.data,t="jv-"+this.options.theme+"-",n=0,s=this.options.container,o="object",l;s.setAttribute("class",t+"con");try{l=JSON.parse(e)}catch{throw new Error("It is not a json format")}b(l)&&(o="array");const{left:r,right:i}=this.createItem(n,t,s,o);this.renderChildren(t,o,l,i,n,r)},a.prototype.toggleItem=function(e,t){e.classList.toggle("add-height"),t.classList.toggle("rotate90")},a.prototype.createElement=function(e){return document.createElement(e)},a.prototype.forEach=function(e,t){if(!(x(e)||m(e)))if(typeof e=="object"&&b(e))for(let n=0,s=e.length;n(O(),N("div",{class:P(h.wrapper)},[S(v,{name:"bounce"},{default:I(()=>[J]),_:1})],2))}},L=j(V,[["__file","/home/aurthurm/Documents/Development/felicity/felicity-lims/webapp/components/ui/FelJsonPreViewer.vue"]]);export{L as default};