var c=Object.defineProperty;var d=(r,t,e)=>t in r?c(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var o=(r,t,e)=>(d(r,typeof t!="symbol"?t+"":t,e),e);import{C as a}from"./gateway.a36b7b3a.js";import{A as u}from"./activeRecord.d87d7ef2.js";import"./outputWidgets.f120b477.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[t]="169bc961-9cca-4b98-aa49-fc376d61d082",r._sentryDebugIdIdentifier="sentry-dbid-169bc961-9cca-4b98-aa49-fc376d61d082")}catch{}})();class h extends Error{constructor(){super("Subdomain already in use")}}class l{constructor(){o(this,"urlPath","projects")}async create({name:t,organizationId:e}){return a.post(`organizations/${e}/${this.urlPath}`,{name:t})}async delete(t){await a.delete(`/${this.urlPath}/${t}`)}async list(t){return a.get(`organizations/${t}/${this.urlPath}`)}async get(t){return a.get(`${this.urlPath}/${t}`)}async update(t,e){const s=await a.patch(`${this.urlPath}/${t}`,e);if("error"in s&&s.error==="subdomain-already-in-use")throw new h;if("error"in s)throw new Error("Unknown error");return s}async duplicate(t){return a.post(`${this.urlPath}/${t}/duplicate`,{})}async checkSubdomain(t,e){return a.get(`${this.urlPath}/${t}/check-subdomain/${e}`)}}const n=new l;class i{constructor(t){o(this,"record");this.record=u.create(n,t,"id")}static async list(t){return(await n.list(t)).map(s=>new i(s))}static async create({name:t,organizationId:e}){const s=await n.create({organizationId:e,name:t});return new i(s)}static async get(t){const e=await n.get(t);return new i(e)}async delete(){await n.delete(this.id)}async save(){return this.record.save()}resetChanges(){this.record.resetChanges()}hasChanges(){return this.record.hasChanges()}get id(){return this.record.get("id")}set id(t){this.record.set("id",t)}async duplicate(){return await n.duplicate(this.id)}get name(){return this.record.get("name")}set name(t){this.record.set("name",t)}get organizationId(){return this.record.get("organizationId")}get subdomain(){return this.record.get("subdomain")}set subdomain(t){this.record.set("subdomain",t)}get customDomain(){return this.record.get("customDomain")}async checkSubdomain(){return await n.checkSubdomain(this.id,this.subdomain)}getUrl(t=""){const e=t.startsWith("/")?t.slice(1):t;return`https://${this.subdomain}.abstra.app/${e}`}getCustomDomainUrl(t=""){const e=t.startsWith("/")?t.slice(1):t;return`https://${this.customDomain}/${e}`}}export{i as P};
//# sourceMappingURL=project.594dcbc1.js.map
