import{$t as e,E as t,Et as n,F as r,Mt as i,P as a,Q as o,Qt as s,V as c,W as l,X as u,_ as d,c as f,ct as p,ft as m,g as h,h as g,k as _,t as v,tn as y,v as b,w as x}from"./vendor/json-editor-vue-ddj4xtqm.js";import{Pt as S,k as C,on as w}from"#entry";import{t as T}from"./data-schema-button-j6fxaw99.js";var E=[`open`],D={flex:`~ gap2`,"select-none":``,"items-center":``,px4:``},O={key:0,class:`bg-red:10 px5 py3 text-red`},k=t({__name:`StateEditor`,props:{name:{},open:{type:Boolean},revision:{},state:{},readonly:{type:Boolean}},emits:[`update:open`],setup(t,{emit:k}){let A=t,j=w(A,`open`,k,{passive:!0}),M=S(),N=n(),P=n();function F(e){return[`number`,`bigint`,`string`,`boolean`].includes(typeof e)}function I(){P.value=void 0;try{N.value=F(A.state)?A.state:JSON.parse(JSON.stringify(A.state||{}))}catch(e){console.error(e),P.value=e}}c(()=>{I(),p(()=>[A.revision,A.state],([e,t])=>{F(t)?N.value=A.state:L(t,A.state)},{deep:!0})});function L(e,t){for(let n in e)Array.isArray(e[n])?t[n]=e[n].slice():typeof e[n]==`object`&&e[n]!==null?L(e[n],t[n]):t[n]=e[n]}async function R(){(void 0)?.pause(),I(),await r(),(void 0)?.resume()}return(n,r)=>{let c=C,p=T,S=o(`tooltip`);return l(),b(`div`,{class:`state-editor-details`,open:t.name?i(j):!0},[g(`div`,D,[t.name?(l(),b(`button`,{key:0,flex:`~`,"cursor-pointer":``,"items-center":``,class:s(i(j)?``:`op50`),onClick:r[0]||=e=>j.value=!i(j)},[g(`div`,{"i-carbon-chevron-right":``,transition:``,class:s(i(j)?`rotate-90 op0`:``)},null,2),g(`code`,{px3:``,py1:``,"font-mono":``,class:s(i(j)?`bg-[#8881] rounded-t`:`rounded hover:bg-active`)},y(t.name),3)],2)):d(``,!0),u(n.$slots,`actions`,e(_({isOpen:i(j),name:t.name,state:t.state}))),i(j)?(l(),b(f,{key:1},[m(x(c,{title:`Refresh View`,icon:`carbon-renew`,border:!1,onClick:R},null,512),[[S,`Refresh View`,void 0,{bottom:!0}]]),N.value&&!P.value?(l(),h(p,{key:0,getter:()=>({name:t.name,input:JSON.stringify(N.value)})},null,8,[`getter`])):d(``,!0)],64)):d(``,!0)]),i(j)||!t.name?(l(),b(f,{key:0},[P.value?(l(),b(`div`,O,` Error: `+y(P.value),1)):(l(),h(i(v),a({key:1,modelValue:N.value,"onUpdate:modelValue":r[1]||=e=>N.value=e},n.$attrs,{class:[`json-editor-vue`,[i(M)===`dark`?`jse-theme-dark`:``,(t.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)):d(``,!0)],8,E)}}}),A=Object.assign(k,{__name:`StateEditor`});export{A as t};