var H=Object.defineProperty;var z=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var K=(a,t,e)=>t in a?H(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,S=(a,t)=>{for(var e in t||(t={}))M.call(t,e)&&K(a,e,t[e]);if(z)for(var e of z(t))Q.call(t,e)&&K(a,e,t[e]);return a};import{S as T,i as U,s as W,e as $,j as V,k as L,c as j,a as y,m as J,d as g,n as P,b as w,J as X,f as A,K as v,o as N,a2 as Y,x as b,u as E,v as O,l as B,w as Z,O as D,P as I,a0 as x,a1 as ee,r as te}from"../../../../chunks/vendor-f44913f5.js";import{p as se}from"../../../../chunks/stores-79a3d42c.js";import{g as re}from"../../../../chunks/navigation-51f4a605.js";import{E as F}from"../../../../chunks/editor-9793cec3.js";import{E as ae}from"../../../../chunks/error-569bd06a.js";import"../../../../chunks/singletons-12a22614.js";import"../../../../chunks/preload-helper-ec9aa979.js";function G(a){let t,e,s,r,i,_,f,u,h,d,l,m;function k(n){a[8](n)}let C={language:"json",schema:S({type:"object"},a[1].schema.model)};return a[0]!==void 0&&(C.value=a[0]),r=new F({props:C}),x.push(()=>ee(r,"value",k)),u=new ae({props:{error:a[2]}}),l=new F({props:{language:"json",isReadonly:!0,value:JSON.stringify([],null,2)}}),{c(){t=$("div"),e=$("div"),s=$("div"),V(r.$$.fragment),_=L(),f=$("div"),V(u.$$.fragment),h=L(),d=$("div"),V(l.$$.fragment),this.h()},l(n){t=j(n,"DIV",{class:!0,style:!0});var o=y(t);e=j(o,"DIV",{class:!0});var c=y(e);s=j(c,"DIV",{class:!0});var p=y(s);J(r.$$.fragment,p),p.forEach(g),_=P(c),f=j(c,"DIV",{class:!0});var R=y(f);J(u.$$.fragment,R),R.forEach(g),c.forEach(g),h=P(o),d=j(o,"DIV",{class:!0});var q=y(d);J(l.$$.fragment,q),q.forEach(g),o.forEach(g),this.h()},h(){w(s,"class","w-full h-3/6"),w(f,"class","w-full h-3/6"),w(e,"class","w-6/12"),w(d,"class","w-6/12"),w(t,"class","flex flex-column h-screen"),X(t,"background-color","#272822")},m(n,o){A(n,t,o),v(t,e),v(e,s),N(r,s,null),v(e,_),v(e,f),N(u,f,null),v(t,h),v(t,d),N(l,d,null),m=!0},p(n,o){const c={};o&2&&(c.schema=S({type:"object"},n[1].schema.model)),!i&&o&1&&(i=!0,c.value=n[0],Y(()=>i=!1)),r.$set(c);const p={};o&4&&(p.error=n[2]),u.$set(p)},i(n){m||(b(r.$$.fragment,n),b(u.$$.fragment,n),b(l.$$.fragment,n),m=!0)},o(n){E(r.$$.fragment,n),E(u.$$.fragment,n),E(l.$$.fragment,n),m=!1},d(n){n&&g(t),O(r),O(u),O(l)}}}function oe(a){let t,e,s=!!a[1]&&G(a);return{c(){s&&s.c(),t=B()},l(r){s&&s.l(r),t=B()},m(r,i){s&&s.m(r,i),A(r,t,i),e=!0},p(r,[i]){r[1]?s?(s.p(r,i),i&2&&b(s,1)):(s=G(r),s.c(),b(s,1),s.m(t.parentNode,t)):s&&(te(),E(s,1,1,()=>{s=null}),Z())},i(r){e||(b(s),e=!0)},o(r){E(s),e=!1},d(r){s&&s.d(r),r&&g(t)}}}function ne(a,t,e){let s,r,i,_;D(a,se,o=>e(6,i=o));const f=I("stores").models;D(a,f,o=>e(7,_=o));const u=I("stores").activeConfig;D(a,u,o=>e(9,s=o));const h=I("stores").activeClient;D(a,h,o=>e(10,r=o));const d=I("services");let l,m,k;async function C(o){console.log("Saving...",o);try{e(2,k=null);const c=d.parse(o),{data:p}=await r.create(l.name,d.sanitize(c));console.log("Entity created",{entity:p}),re(`/${s.name}/${l.name}/${p[l.correlation_field]}`.toLowerCase(),{replaceState:!0})}catch(c){console.error(c),e(2,k=c)}}function n(o){m=o,e(0,m)}return a.$$.update=()=>{a.$$.dirty&192&&e(1,l=_[i.params.model]),a.$$.dirty&1&&C(m)},[m,l,k,f,u,h,i,_,n]}class _e extends T{constructor(t){super();U(this,t,ne,oe,W,{})}}export{_e as default};
