import{S as K,i as L,s as P,e as v,k as R,j as w,c as y,a as k,d as _,n as A,m as E,b,J as B,f as S,K as $,o as D,x as m,a2 as G,u as d,v as I,w as V,l as J,O as h,P as C,r as N,a0 as H,a1 as M,F as Q}from"../../../../chunks/vendor-f44913f5.js";import{p as T}from"../../../../chunks/stores-79a3d42c.js";import{g as U}from"../../../../chunks/navigation-51f4a605.js";import{E as W}from"../../../../chunks/editor-9793cec3.js";import{E as X}from"../../../../chunks/entity-3e723ebf.js";import"../../../../chunks/singletons-12a22614.js";import"../../../../chunks/preload-helper-ec9aa979.js";function O(i){let t,o,e,a,l,s,n=!!i[1]&&q(i);return l=new W({props:{language:"json",fontSize:"10px",isReadonly:!0,value:JSON.stringify(i[6],null,2)}}),{c(){t=v("div"),o=v("div"),n&&n.c(),e=R(),a=v("div"),w(l.$$.fragment),this.h()},l(r){t=y(r,"DIV",{class:!0});var f=k(t);o=y(f,"DIV",{class:!0});var u=k(o);n&&n.l(u),u.forEach(_),e=A(f),a=y(f,"DIV",{class:!0,style:!0});var g=k(a);E(l.$$.fragment,g),g.forEach(_),f.forEach(_),this.h()},h(){b(o,"class","w-8/12"),b(a,"class","w-4/12"),B(a,"background-color","#272822"),b(t,"class","flex flex-column h-screen")},m(r,f){S(r,t,f),$(t,o),n&&n.m(o,null),$(t,e),$(t,a),D(l,a,null),s=!0},p(r,f){r[1]?n?(n.p(r,f),f&2&&m(n,1)):(n=q(r),n.c(),m(n,1),n.m(o,null)):n&&(N(),d(n,1,1,()=>{n=null}),V())},i(r){s||(m(n),m(l.$$.fragment,r),s=!0)},o(r){d(n),d(l.$$.fragment,r),s=!1},d(r){r&&_(t),n&&n.d(),I(l)}}}function q(i){let t,o,e;function a(s){i[10](s)}let l={activeConfig:i[2],model:i[0]};return i[1]!==void 0&&(l.entity=i[1]),t=new X({props:l}),H.push(()=>M(t,"entity",a)),t.$on("save",i[7]),{c(){w(t.$$.fragment)},l(s){E(t.$$.fragment,s)},m(s,n){D(t,s,n),e=!0},p(s,n){const r={};n&4&&(r.activeConfig=s[2]),n&1&&(r.model=s[0]),!o&&n&2&&(o=!0,r.entity=s[1],G(()=>o=!1)),t.$set(r)},i(s){e||(m(t.$$.fragment,s),e=!0)},o(s){d(t.$$.fragment,s),e=!1},d(s){I(t,s)}}}function Y(i){let t,o,e=!!i[0]&&O(i);return{c(){e&&e.c(),t=J()},l(a){e&&e.l(a),t=J()},m(a,l){e&&e.m(a,l),S(a,t,l),o=!0},p(a,[l]){a[0]?e?(e.p(a,l),l&1&&m(e,1)):(e=O(a),e.c(),m(e,1),e.m(t.parentNode,t)):e&&(N(),d(e,1,1,()=>{e=null}),V())},i(a){o||(m(e),o=!0)},o(a){d(e),o=!1},d(a){e&&e.d(a),a&&_(t)}}}function Z(i,t,o){let e,a,l,s;h(i,T,c=>o(8,l=c));const n=C("stores").activeConfig;h(i,n,c=>o(2,e=c));const r=C("stores").models;h(i,r,c=>o(9,s=c));const f=C("stores").activeClient;h(i,f,c=>o(11,a=c));let u,g=[],p={};async function z(){console.log("Saving...",p);try{const c=Q(p,"created_at","updated_at","version");console.log(42,c);const j=await a.create(u.name,c);console.log(42,j.data),U(`/${e.name}/${u.name}/${j.data[u.correlation_field]}`.toLowerCase(),{replaceState:!0})}catch{}}function F(c){p=c,o(1,p)}return i.$$.update=()=>{i.$$.dirty&768&&o(0,u=s[l.params.model])},[u,p,e,n,r,f,g,z,l,s,F]}class ie extends K{constructor(t){super();L(this,t,Z,Y,P,{})}}export{ie as default};
