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