import{S as j,i as v,s as S,e as b,c as z,a as R,d as k,b as H,g as M,E as p,Z as C,v as O,X as P,w as A,x as I,y as T,q as K,o as L,B as q}from"./index-e2bb409a.js";import{g as U}from"./get-102ab8d2.js";import{_ as W}from"./preload-helper-60cab3ee.js";function x(){return new Worker("/_app/immutable/assets/editor.worker.80af4d20.js",{type:"module"})}function B(){return new Worker("/_app/immutable/assets/json.worker.3cda63d9.js",{type:"module"})}function J(){return new Worker("/_app/immutable/assets/css.worker.91d41de9.js",{type:"module"})}function N(){return new Worker("/_app/immutable/assets/html.worker.bc173ccb.js",{type:"module"})}function X(){return new Worker("/_app/immutable/assets/ts.worker.ed6ddcea.js",{type:"module"})}function Z(){return new Worker("/_app/immutable/assets/yaml.worker.1785f6bd.js",{type:"module"})}function F(a){let e;return{c(){e=b("div"),this.h()},l(t){e=z(t,"DIV",{class:!0}),R(e).forEach(k),this.h()},h(){H(e,"class","w-full h-full")},m(t,n){M(t,e,n),a[7](e)},p,i:p,o:p,d(t){t&&k(e),a[7](null)}}}function G(a,e,t){const n=C();let{language:o="json"}=e,{value:i=""}=e,{isReadonly:d=!1}=e,{schema:s=null}=e,{lineHighlight:g=!d}=e,{fontSize:_}=e,u,h=null,m,y;const w=()=>{u.layout()};function E(r){if(!u)return;const f=u.getPosition();u.setValue(r),u.setPosition(f)}O(async()=>{self.MonacoEnvironment={getWorker(l,c){return c==="json"?new B:c==="css"||c==="scss"||c==="less"?new J:c==="html"||c==="handlebars"||c==="razor"?new N:c==="typescript"||c==="javascript"?new X:c==="yaml"?Z():new x}},m=await W(()=>import("./editor.main-7ea83a81.js").then(function(l){return l.e}),["chunks/editor.main-7ea83a81.js","assets/editor.main-a0d00b7b.css","chunks/preload-helper-60cab3ee.js"]);const r=await W(()=>import("./Monokai-89d42e8f.js"),[]);m.editor.defineTheme("monokai",r),m.editor.setTheme("monokai");const f=m.Uri.parse(`ds://${Date.now()}.${o}`);s!==null&&o==="json"&&(console.log(84,{language:o,schema:s,modelUri:f}),m.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,schemaValidation:"error",schemas:Array.isArray(s)?[{uri:`https://datastore${s[0].$id}`,fileMatch:[f.toString()],schema:s[0]},...s.map(l=>({uri:`https://datastore${l.$id}`,schema:l}))]:[{uri:"https://datastore/schema.json",fileMatch:[f.toString()],schema:s}]}));const V=m.editor.createModel(i,o,f);return u=m.editor.create(h,{model:V,language:o,readOnly:d,tabSize:2,minimap:{enabled:!1},renderLineHighlight:g===!1?"none":void 0,fontSize:_}),u.onDidContentSizeChange(w),w(),u.onKeyDown(function(l){if(l.ctrlKey&&l.keyCode===49){l.preventDefault(),t(1,i=u.getValue()),n("save",{value:i});return}if(l.ctrlKey&&l.keyCode===56){l.preventDefault(),u.restoreViewState(y);return}}),y=u.saveViewState(),()=>{u.dispose()}});function D(r){P[r?"unshift":"push"](()=>{h=r,t(0,h)})}return a.$$set=r=>{"language"in r&&t(2,o=r.language),"value"in r&&t(1,i=r.value),"isReadonly"in r&&t(3,d=r.isReadonly),"schema"in r&&t(4,s=r.schema),"lineHighlight"in r&&t(5,g=r.lineHighlight),"fontSize"in r&&t(6,_=r.fontSize)},a.$$.update=()=>{a.$$.dirty&2&&E(i)},[h,i,o,d,s,g,_,D]}class Q extends j{constructor(e){super(),v(this,e,G,F,S,{language:2,value:1,isReadonly:3,schema:4,lineHighlight:5,fontSize:6})}}function Y(a){let e,t;return e=new Q({props:{language:"json",isReadonly:!0,value:a[1](a[0])}}),{c(){A(e.$$.fragment)},l(n){I(e.$$.fragment,n)},m(n,o){T(e,n,o),t=!0},p(n,[o]){const i={};o&1&&(i.value=n[1](n[0])),e.$set(i)},i(n){t||(K(e.$$.fragment,n),t=!0)},o(n){L(e.$$.fragment,n),t=!1},d(n){q(e,n)}}}function $(a,e,t){let{error:n}=e;function o(i){if(!i)return"";let d=`${i.message}`,s=U(i,"response.data.details");return s&&(d+=`
${JSON.stringify(s,null,2)}
`),d}return a.$$set=i=>{"error"in i&&t(0,n=i.error)},[n,o]}class re extends j{constructor(e){super(),v(this,e,$,Y,S,{error:0})}}export{Q as E,re as a};
