var u=Object.defineProperty;var p=(n,e,t)=>e in n?u(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>(p(n,typeof e!="symbol"?e+"":e,t),t);import{E as w}from"./record.d2935dfa.js";import"./index.e310aebb.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="e455205d-b9e9-4f50-862c-8441790354d6",n._sentryDebugIdIdentifier="sentry-dbid-e455205d-b9e9-4f50-862c-8441790354d6")}catch{}})();const l="__ABSTRA_STREAM_ERROR__";class f{async list(){return(await fetch("/_editor/api/requirements")).json()}async recommendations(){return(await fetch("/_editor/api/requirements/recommendations")).json()}async update(e,t){if(!(await fetch(`/_editor/api/requirements/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok)throw new Error("Failed to update requirements")}async create(e){const t=await fetch("/_editor/api/requirements",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error("Failed to create requirements");return t.json()}async delete(e){if(!(await fetch(`/_editor/api/requirements/${e}`,{method:"DELETE"})).ok)throw new Error("Failed to delete requirements")}async*install(){var r;const t=(r=(await fetch("/_editor/api/requirements/install",{method:"POST",headers:{"Content-Type":"application/json"}})).body)==null?void 0:r.getReader();if(!t)throw new Error("No response body");for(;;){const o=await t.read();if(o.done)break;const i=new TextDecoder().decode(o.value);if(i===l)throw new Error("Failed to install requirements");yield i}}async*uninstall(e){var o;const r=(o=(await fetch(`/_editor/api/requirements/${e}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"}})).body)==null?void 0:o.getReader();if(!r)throw new Error("No response body");for(;;){const i=await r.read();if(i.done)break;const d=new TextDecoder().decode(i.value);if(d===l)throw new Error("Failed to uninstall requirements");yield d}}}const s=new f;class a{constructor(e){c(this,"record");this.record=w.from(e)}static async list(){return(await s.list()).map(t=>new a(t))}static async create(e,t){const r=await s.create({name:e,version:t||null});return new a(r)}get name(){return this.record.get("name")}set name(e){this.record.set("name",e)}get version(){var e;return(e=this.record.get("version"))!=null?e:null}set version(e){this.record.set("version",e)}get installedVersion(){var e;return(e=this.record.get("installed_version"))!=null?e:null}async delete(){await s.delete(this.name)}async uninstall(e){for await(const t of s.uninstall(this.name))e(t)}static async recommendations(){return s.recommendations()}static async install(e){for await(const t of s.install())e(t)}}export{a as R};
//# sourceMappingURL=requirements.3213c72b.js.map
