import{d as N,Y as C,am as D,bf as b,aq as O,w as R,a0 as $,o as l,m as p,k as d,D as u,f as t,t as g,p as m,a8 as M,bp as j,bq as z,F as k,G as A,i as E,h,aw as J,c1 as P,l as q,aA as F,_ as G}from"./zEcrVex8.js";import{_ as T}from"./DzI09XCB.js";import{s as U}from"./BaYfQPWj.js";const Y=["open"],H={flex:"~ gap2","select-none":"","items-center":"",px4:""},I={key:0,class:"bg-red:10 px5 py3 text-red"},X=N({__name:"StateEditor",props:{name:{},open:{type:Boolean},revision:{},state:{},readonly:{type:Boolean}},emits:["update:open"],setup(V,{emit:w}){const o=V,s=C(o,"open",w,{passive:!0}),_=D(),n=b(),c=b();function f(){c.value=void 0;try{o.state?n.value=JSON.parse(JSON.stringify(o.state||{})):(typeof o.state=="number"||typeof o.state!="string")&&(n.value=o.state)}catch(e){console.error(e),c.value=e}}O(()=>{f(),R(()=>[o.revision,o.state],e=>{typeof e!="number"&&typeof e!="string"?y(e,o.state):n.value=o.state},{deep:!0})});function y(e,r){const i=e[1];for(const a in i)Array.isArray(i[a])?r[a]=i[a].slice():typeof i[a]=="object"?y(i[a],r[a]):r[a]=i[a]}async function B(){f(),await F()}return(e,r)=>{const i=G,a=T,S=$("tooltip");return l(),p("div",{class:"state-editor-details",open:e.name?t(s):!0},[d("div",H,[e.name?(l(),p("button",{key:0,flex:"~","cursor-pointer":"","items-center":"",class:u(t(s)?"":"op50"),onClick:r[0]||(r[0]=v=>s.value=!t(s))},[d("div",{"i-carbon-chevron-right":"",transition:"",class:u(t(s)?"rotate-90 op0":"")},null,2),d("code",{px3:"",py1:"","font-mono":"",class:u(t(s)?"bg-[#8881] rounded-t":"rounded hover:bg-active")},g(e.name),3)],2)):m("",!0),M(e.$slots,"actions",j(z({isOpen:t(s),name:e.name,state:e.state}))),t(s)?(l(),p(k,{key:1},[A(E(i,{title:"Refresh View",icon:"carbon-renew",border:!1,onClick:B},null,512),[[S,"Refresh View",void 0,{bottom:!0}]]),t(n)&&!t(c)?(l(),h(a,{key:0,getter:()=>({name:e.name,input:JSON.stringify(t(n))})},null,8,["getter"])):m("",!0)],64)):m("",!0)]),t(s)||!e.name?(l(),p(k,{key:0},[t(c)?(l(),p("div",I," Error: "+g(t(c)),1)):(l(),h(t(U),J({key:1,modelValue:t(n),"onUpdate:modelValue":r[1]||(r[1]=v=>q(n)?n.value=v:null)},e.$attrs,{class:["json-editor-vue",[t(_)==="dark"?"jse-theme-dark":"",(e.name,"")]],"main-menu-bar":!1,"navigation-bar":!1,"status-bar":!1,"read-only":"readonly"in e?e.readonly:t(P),indentation:2,"tab-size":2}),null,16,["modelValue","class","read-only"]))],64)):m("",!0)],8,Y)}}});export{X as _};
