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