import{C,Q as N,_ as O}from"./m6q5jxyf.js";import{_ as R}from"./data-schema-button.vue-htzfoue4.js";import{p as j,m as g,E as D,j as E,ag as M,P as u,a1 as l,u as o,Q as m,R as p,U as P,X as d,a8 as b,a5 as $,a6 as z,F as k,aa as J,S as _,a3 as x,ax as A,a4 as F,n as Q}from"./vendor/json-editor-vue-llkaejaf.js";const U=["open"],T={flex:"~ gap2","select-none":"","items-center":"",px4:""},X={key:0,class:"bg-red:10 px5 py3 text-red"},K=j({__name:"StateEditor",props:{name:{},open:{type:Boolean},revision:{},state:{},readonly:{type:Boolean}},emits:["update:open"],setup(h,{emit:V}){const t=h,s=C(t,"open",V,{passive:!0}),S=N(),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}}D(()=>{f(),E(()=>[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 Q()}return(e,r)=>{const n=O,a=R,w=M("tooltip");return l(),u("div",{class:"state-editor-details",open:e.name?o(s):!0},[m("div",T,[e.name?(l(),u("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)):p("",!0),P(e.$slots,"actions",$(z({isOpen:o(s),name:e.name,state:e.state}))),o(s)?(l(),u(k,{key:1},[J(x(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"])):p("",!0)],64)):p("",!0)]),o(s)||!e.name?(l(),u(k,{key:0},[c.value?(l(),u("div",X," Error: "+b(c.value),1)):(l(),_(o(A),F({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)):p("",!0)],8,U)}}});export{K as _};
