import{a as C,i as p,t as x,n as j,k as h,y as $,A as S,h as H,b as E,z as g,r as N,F as O,e as M}from"./web-C3hSb2U9.js";import{b as z}from"./deep-get-set-B56Z2H6w.js";import"./data-D3j_gHWe.js";import{d as k}from"./shared-DziGcW-A.js";function A(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var w={exports:{}},P=w.exports,F;function J(){return F||(F=1,function(o,c){(function(f,v){o.exports=v()})(P,function(){var f={keyColor:"dimgray",numberColor:"lightskyblue",stringColor:"lightcoral",trueColor:"lightseagreen",falseColor:"#f66578",nullColor:"cornflowerblue"},v={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#x60;","=":"&#x3D;"};function r(e){return String(e).replace(/[&<>"'`=]/g,function(s){return v[s]})}function y(e,s){s===void 0&&(s={});var a=typeof e;a!=="string"&&(e=JSON.stringify(e,null,2)||a);var n=Object.assign({},f,s);return e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),e.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+]?\d+)?)/g,function(t){var i=n.numberColor,d="";return/^"/.test(t)?/:$/.test(t)?i=n.keyColor:(i=n.stringColor,t='"'+r(t.substr(1,t.length-2))+'"',d="word-wrap:break-word;white-space:pre-wrap;"):i=/true/.test(t)?n.trueColor:/false/.test(t)?n.falseColor:/null/.test(t)?n.nullColor:i,'<span style="'+d+"color:"+i+'">'+t+"</span>"})}return y})}(w)),w.exports}var L=J();const R=A(L),q=(o,c)=>Object.fromEntries(c.filter(f=>f in o).map(f=>[f,o[f]])),_=(o,c)=>Object.prototype.hasOwnProperty.call(o,c),D=o=>_(o,"hour")&&_(o,"minute")&&_(o,"second"),V=o=>["state","context","scope"].every(c=>_(o,c));function G(o,c){return JSON.stringify(o,(v,r)=>{try{if(_(r,"target")&&_(r,"timeStamp"))return q(r,["type","target","currentTarget","relatedTarget"]);if(c?.includes(v))return;if(_(r,"calendar")||D(r))return r.toString();if(typeof r?.json=="function")return r.json();if(typeof r?.toJSON=="function")return r.toJSON();if(Number.isNaN(r))return"NaN";if(r instanceof File)return r.name;if(r instanceof Set)return Array.from(r);if(V(r))return`Machine: ${r.scope.id}`;switch(r?.toString()){case"[object ShadowRoot]":return`Machine: ${r.state.context.id??r.id}`;case"[object ShadowRoot]":return"#shadow-root";case"[object HTMLDocument]":return"#document";case"[object Window]":return"#window";case"[object AbortController]":return"#abort-controller";default:return r!==null&&typeof r=="object"&&r.nodeType===1?r.tagName:r}}catch{return r}},4)}function W(o,c){return R(G(o,c))}var Z=x("<div class=viz><pre dir=ltr><details open><summary> <!$><!/> </summary><div>");function it(o){const{state:c,label:f,omit:v,context:r}=o,y=C(()=>({state:c.state.get(),event:c.event.current(),context:r?Object.fromEntries(r.map(e=>[e,c.context.get(e)])):void 0}));return(()=>{var e=p(Z),s=e.firstChild,a=s.firstChild,n=a.firstChild,t=n.firstChild,i=t.nextSibling,[d,b]=j(i.nextSibling);d.nextSibling;var l=n.nextSibling;return h(n,f||"Visualizer",d,b),$(()=>S(l,"innerHTML",W(y(),v))),e})()}var B=x("<div class=controls-container>"),I=x("<div class=checkbox><input type=checkbox><label>"),K=x("<div class=text><label></label><input type=text>"),Q=x("<div class=text><label></label><select><option>-----</option><!$><!/>"),U=x("<option>"),X=x("<div class=text><label></label><input type=number>");function Y({store:o}){const{config:c,state:f,setState:v}=o,r=C(()=>Object.keys(o.config).map(e=>{const{type:s,label:a=e,options:n,placeholder:t,min:i,max:d}=c[e]??{},b=C(()=>z(f(),e));return{key:e,type:s,label:a,options:n,placeholder:t,min:i,max:d,value:b}}));return(()=>{var y=p(B);return h(y,E(O,{get each(){return r()},children:e=>{switch(e.type){case"boolean":return(()=>{var s=p(I),a=s.firstChild,n=a.nextSibling;return a.addEventListener("change",t=>{v(e.key,t.currentTarget.checked)}),h(n,()=>e.label),$(t=>{var i=e.key,d=e.label,b=e.label;return i!==t.e&&g(a,"data-testid",t.e=i),d!==t.t&&g(a,"id",t.t=d),b!==t.a&&g(n,"for",t.a=b),t},{e:void 0,t:void 0,a:void 0}),$(()=>S(a,"checked",e.value())),s})();case"string":return(()=>{var s=p(K),a=s.firstChild,n=a.nextSibling;return a.style.setProperty("margin-right","10px"),h(a,()=>e.label),n.$$keydown=t=>{t.key==="Enter"&&v(e.key,t.currentTarget.value)},$(t=>{var i=e.key,d=e.placeholder;return i!==t.e&&g(n,"data-testid",t.e=i),d!==t.t&&g(n,"placeholder",t.t=d),t},{e:void 0,t:void 0}),$(()=>S(n,"value",e.value())),N(),s})();case"select":return(()=>{var s=p(Q),a=s.firstChild,n=a.nextSibling,t=n.firstChild,i=t.nextSibling,[d,b]=j(i.nextSibling);return a.style.setProperty("margin-right","10px"),h(a,()=>e.label),n.addEventListener("change",l=>{v(e.key,l.currentTarget.value)}),h(n,E(O,{get each(){return e.options},children:l=>(()=>{var u=p(U);return S(u,"value",l),h(u,l),u})()}),d,b),$(l=>{var u=e.label,m=e.key,T=e.label;return u!==l.e&&g(a,"for",l.e=u),m!==l.t&&g(n,"data-testid",l.t=m),T!==l.a&&g(n,"id",l.a=T),l},{e:void 0,t:void 0,a:void 0}),$(()=>S(n,"value",e.value())),s})();case"number":return(()=>{var s=p(X),a=s.firstChild,n=a.nextSibling;return a.style.setProperty("margin-right","10px"),h(a,()=>e.label),n.$$keydown=t=>{if(t.key==="Enter"){const i=parseFloat(t.currentTarget.value);v(e.key,isNaN(i)?0:i)}},$(t=>{var i=e.label,d=e.key,b=e.label,l=e.min,u=e.max;return i!==t.e&&g(a,"for",t.e=i),d!==t.t&&g(n,"data-testid",t.t=d),b!==t.a&&g(n,"id",t.a=b),l!==t.o&&g(n,"min",t.o=l),u!==t.i&&g(n,"max",t.i=u),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),$(()=>S(n,"value",e.value())),N(),s})()}}})),y})()}H(["keydown"]);var tt=x("<div class=toolbar><nav><!$><!/><button>Visualizer</button></nav><div><!$><!/><div data-content>"),et=x("<button>Controls"),rt=x("<div data-content>");function st(o){const[c,f]=M(o.viz?1:o.controls?0:1);return(()=>{var v=p(tt),r=v.firstChild,y=r.firstChild,[e,s]=j(y.nextSibling),a=e.nextSibling,n=r.nextSibling,t=n.firstChild,[i,d]=j(t.nextSibling),b=i.nextSibling;return h(r,(()=>{var l=C(()=>!!o.controls);return()=>l()&&(()=>{var u=p(et);return u.$$click=()=>f(0),$(()=>g(u,"data-active",k(c()===0))),N(),u})()})(),e,s),a.$$click=()=>f(1),h(n,(()=>{var l=C(()=>!!o.controls);return()=>l()&&(()=>{var u=p(rt);return h(u,E(Y,{get store(){return o.controls}})),$(()=>g(u,"data-active",k(c()===0))),u})()})(),i,d),h(b,()=>o.children),$(l=>{var u=k(c()===1),m=k(c()===1);return u!==l.e&&g(a,"data-active",l.e=u),m!==l.t&&g(b,"data-active",l.t=m),l},{e:void 0,t:void 0}),N(),v})()}H(["click"]);export{it as S,st as T,A as g};
