import{S as O,i as P,s as Q,e as k,k as R,c as $,a as C,d as b,m as W,b as E,f as X,g as L,M as w,q as _,w as V,x as q,y as N,W as Y,o as p,B as j,p as D,l as z,P as h,Q as S,n as I,X as A,Y as F,E as G}from"../../../../chunks/index-e2bb409a.js";import{o as H}from"../../../../chunks/omit-2d34bd5f.js";import{p as K}from"../../../../chunks/stores-9025718b.js";import{g as T}from"../../../../chunks/navigation-0e6511d1.js";import{E as U,a as Z}from"../../../../chunks/error-06511b87.js";import{E as x}from"../../../../chunks/entity-848aac43.js";import"../../../../chunks/_baseGet-42226e95.js";import"../../../../chunks/_isIndex-e69b0e86.js";import"../../../../chunks/singletons-d1fb5791.js";import"../../../../chunks/get-102ab8d2.js";import"../../../../chunks/preload-helper-60cab3ee.js";function B(i){let t,r,e,n,a,o,u,s=!!i[1]&&J(i);const g=[te,ee],f=[];function y(l,c){return l[2]?0:1}return a=y(i),o=f[a]=g[a](i),{c(){t=k("div"),r=k("div"),s&&s.c(),e=R(),n=k("div"),o.c(),this.h()},l(l){t=$(l,"DIV",{class:!0});var c=C(t);r=$(c,"DIV",{class:!0});var d=C(r);s&&s.l(d),d.forEach(b),e=W(c),n=$(c,"DIV",{class:!0,style:!0});var v=C(n);o.l(v),v.forEach(b),c.forEach(b),this.h()},h(){E(r,"class","w-8/12"),E(n,"class","w-4/12"),X(n,"background-color","#272822"),E(t,"class","flex flex-column h-screen")},m(l,c){L(l,t,c),w(t,r),s&&s.m(r,null),w(t,e),w(t,n),f[a].m(n,null),u=!0},p(l,c){l[1]?s?(s.p(l,c),c&2&&_(s,1)):(s=J(l),s.c(),_(s,1),s.m(r,null)):s&&(I(),p(s,1,1,()=>{s=null}),D());let d=a;a=y(l),a===d?f[a].p(l,c):(I(),p(f[d],1,1,()=>{f[d]=null}),D(),o=f[a],o?o.p(l,c):(o=f[a]=g[a](l),o.c()),_(o,1),o.m(n,null))},i(l){u||(_(s),_(o),u=!0)},o(l){p(s),p(o),u=!1},d(l){l&&b(t),s&&s.d(),f[a].d()}}}function J(i){let t,r,e;function n(o){i[11](o)}let a={activeConfig:i[3],model:i[0]};return i[1]!==void 0&&(a.entity=i[1]),t=new x({props:a}),A.push(()=>F(t,"entity",n)),t.$on("save",i[8]),{c(){V(t.$$.fragment)},l(o){q(t.$$.fragment,o)},m(o,u){N(t,o,u),e=!0},p(o,u){const s={};u&8&&(s.activeConfig=o[3]),u&1&&(s.model=o[0]),!r&&u&2&&(r=!0,s.entity=o[1],Y(()=>r=!1)),t.$set(s)},i(o){e||(_(t.$$.fragment,o),e=!0)},o(o){p(t.$$.fragment,o),e=!1},d(o){j(t,o)}}}function ee(i){let t,r;return t=new U({props:{language:"json",fontSize:"10px",isReadonly:!0,value:JSON.stringify(i[7],null,2)}}),{c(){V(t.$$.fragment)},l(e){q(t.$$.fragment,e)},m(e,n){N(t,e,n),r=!0},p:G,i(e){r||(_(t.$$.fragment,e),r=!0)},o(e){p(t.$$.fragment,e),r=!1},d(e){j(t,e)}}}function te(i){let t,r;return t=new Z({props:{error:i[2]}}),{c(){V(t.$$.fragment)},l(e){q(t.$$.fragment,e)},m(e,n){N(t,e,n),r=!0},p(e,n){const a={};n&4&&(a.error=e[2]),t.$set(a)},i(e){r||(_(t.$$.fragment,e),r=!0)},o(e){p(t.$$.fragment,e),r=!1},d(e){j(t,e)}}}function re(i){let t,r,e=!!i[0]&&B(i);return{c(){e&&e.c(),t=z()},l(n){e&&e.l(n),t=z()},m(n,a){e&&e.m(n,a),L(n,t,a),r=!0},p(n,[a]){n[0]?e?(e.p(n,a),a&1&&_(e,1)):(e=B(n),e.c(),_(e,1),e.m(t.parentNode,t)):e&&(I(),p(e,1,1,()=>{e=null}),D())},i(n){r||(_(e),r=!0)},o(n){p(e),r=!1},d(n){e&&e.d(n),n&&b(t)}}}function ne(i,t,r){let e,n,a,o;h(i,K,m=>r(9,n=m));const u=S("stores").activeConfig;h(i,u,m=>r(3,o=m));const s=S("stores").models;h(i,s,m=>r(10,a=m));const g=S("stores").activeClient;h(i,g,m=>r(12,e=m));let f,y=[],l={},c=null;async function d(){console.log("Saving...",l);try{const m=H(l,"created_at","updated_at","version"),M=await e.create(f.name,m);T(`/datastore/${f.name}/${M.data[f.correlation_field]}`.toLowerCase(),{replaceState:!0})}catch(m){r(2,c=m)}}function v(m){l=m,r(1,l)}return i.$$.update=()=>{i.$$.dirty&1536&&r(0,f=a[n.params.model])},[f,l,c,o,u,s,g,y,d,n,a,v]}class de extends O{constructor(t){super(),P(this,t,ne,re,Q,{})}}export{de as default};
