@modrinth/api-client 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- var a=class{constructor(e){this.client=e}};var O=class extends a{getModuleID(){return"archon_actions_v1"}async list(e,t={}){let r={};return t.filter&&(r.filter=JSON.stringify(t.filter)),t.limit!==void 0&&(r.limit=t.limit),t.offset!==void 0&&(r.offset=t.offset),t.order!==void 0&&(r.order=t.order),t.min_datetime!==void 0&&(r.min_datetime=t.min_datetime),t.max_datetime!==void 0&&(r.max_datetime=t.max_datetime),this.client.request(`/servers/${e}/action-log`,{api:"archon",version:1,method:"GET",params:Object.keys(r).length>0?r:void 0})}};var $=class extends a{getModuleID(){return"archon_backups_v1"}async list(e,t){return this.client.request(`/servers/${e}/worlds/${t}/backups`,{api:"archon",version:1,method:"GET"})}async get(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"GET"})}async create(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups`,{api:"archon",version:1,method:"POST",body:r})}async restore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}/restore`,{api:"archon",version:1,method:"POST"})}async delete(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"DELETE"})}async retry(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}/retry`,{api:"archon",version:1,method:"POST"})}async rename(e,t,r,n){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"PATCH",body:n})}};var I=class extends a{getModuleID(){return"archon_backups_queue_v1"}async list(e,t){return this.client.request(`/servers/${e}/worlds/${t}/backups-queue`,{api:"archon",version:1,method:"GET"})}async create(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups-queue`,{api:"archon",version:1,method:"POST",body:r})}async ackCreate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/create/${r}/ack`,{api:"archon",version:1,method:"POST"})}async cancelCreate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/create/${r}/cancel`,{api:"archon",version:1,method:"POST"})}async ackRestore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/restore/${r}/ack`,{api:"archon",version:1,method:"POST"})}async cancelRestore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/restore/${r}/cancel`,{api:"archon",version:1,method:"POST"})}async delete(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}`,{api:"archon",version:1,method:"DELETE"})}async deleteMany(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/delete-many`,{api:"archon",version:1,method:"POST",body:{backup_ids:r}})}async restore(e,t,r,n){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}/restore`,{api:"archon",version:1,method:"POST",body:n})}async retry(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}/retry`,{api:"archon",version:1,method:"POST"})}};var U=class extends a{getModuleID(){return"archon_content_v1"}async getAddons(e,t,r){let n=new URLSearchParams;r?.from_modpack!==void 0&&n.set("from_modpack",String(r.from_modpack)),r?.disabled!==void 0&&n.set("disabled",String(r.disabled)),r?.addons!==void 0&&n.set("addons",String(r.addons)),r?.updates!==void 0&&n.set("updates",String(r.updates));let s=n.toString();return this.client.request(`/servers/${e}/worlds/${t}/addons${s?`?${s}`:""}`,{api:"archon",version:1,method:"GET"})}async addAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons`,{api:"archon",version:1,method:"POST",body:r})}async addAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/install-many`,{api:"archon",version:1,method:"POST",body:r})}async deleteAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/delete`,{api:"archon",version:1,method:"POST",body:r})}async disableAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/disable`,{api:"archon",version:1,method:"POST",body:r})}async enableAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/enable`,{api:"archon",version:1,method:"POST",body:r})}async deleteAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/delete-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async disableAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/disable-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async enableAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/enable-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async installContent(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/content`,{api:"archon",version:1,method:"POST",body:r})}async repair(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/repair`,{api:"archon",version:1,method:"POST"})}async unlinkModpack(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/unlink-modpack`,{api:"archon",version:1,method:"POST"})}async getAddonUpdate(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/addons/update?filename=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"GET"})}async updateAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/update`,{api:"archon",version:1,method:"POST",body:r})}async updateAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/update-many`,{api:"archon",version:1,method:"POST",body:{addons:r}})}async getModpackUpdate(e,t){return this.client.request(`/servers/${e}/worlds/${t}/content/modpack/update`,{api:"archon",version:1,method:"GET"})}async updateModpack(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/modpack/update`,{api:"archon",version:1,method:"POST"})}async getUpdateGameVersionPreview(e,t,r,n){return this.client.request(`/servers/${e}/worlds/${t}/content/update-game-version?game_version=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"GET",timeout:1e3*1e3,signal:n})}async applyGameVersionUpdate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/content/update-game-version?game_version=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"POST"})}};var N=class extends a{getModuleID(){return"archon_nodes_internal"}async overview(){return this.client.request("/nodes/overview",{api:"archon",version:"internal",method:"GET"})}};var D=class extends a{getModuleID(){return"archon_notices_v0"}async list(){return this.client.request("/notices",{api:"archon",version:"modrinth/v0",method:"GET"})}async create(e){return this.client.request("/notices",{api:"archon",version:"modrinth/v0",method:"POST",body:e})}async update(e,t){await this.client.request(`/notices/${e}`,{api:"archon",version:"modrinth/v0",method:"PATCH",body:t})}async delete(e){await this.client.request(`/notices/${e}`,{api:"archon",version:"modrinth/v0",method:"DELETE"})}async assign(e,t){await this.client.request(`/notices/${e}/assign`,{api:"archon",version:"modrinth/v0",method:"PUT",params:this.assignmentTargetToParams(t)})}async unassign(e,t){await this.client.request(`/notices/${e}/unassign`,{api:"archon",version:"modrinth/v0",method:"PUT",params:this.assignmentTargetToParams(t)})}assignmentTargetToParams(e){return"server"in e?{server:e.server}:{node:e.node}}};var B=class extends a{getModuleID(){return"archon_options_v1"}async getStartup(e,t){return this.client.request(`/servers/${e}/worlds/${t}/options/startup`,{api:"archon",version:1,method:"GET"})}async patchStartup(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/options/startup`,{api:"archon",version:1,method:"PATCH",body:r})}};var j=class extends a{getModuleID(){return"archon_properties_v1"}async getProperties(e,t){return this.client.request(`/servers/${e}/worlds/${t}/properties`,{api:"archon",version:1,method:"GET"})}async patchProperties(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/properties`,{api:"archon",version:1,method:"PATCH",body:r})}};var F=class extends a{getModuleID(){return"archon_server_users_v1"}async list(e){return this.client.request(`/servers/${e}/users`,{api:"archon",version:1,method:"GET"})}async add(e,t){await this.client.request(`/servers/${e}/users`,{api:"archon",version:1,method:"POST",body:t})}async reinvite(e,t){return this.client.request(`/servers/${e}/users/${t}/reinvite`,{api:"archon",version:1,method:"POST"})}async delete(e,t){await this.client.request(`/servers/${e}/users/${t}`,{api:"archon",version:1,method:"DELETE"})}async update(e,t,r){await this.client.request(`/servers/${e}/users/${t}`,{api:"archon",version:1,method:"PATCH",body:JSON.stringify(r)})}};var G=class extends a{getModuleID(){return"archon_servers_v0"}async get(e){return this.client.request(`/servers/${e}`,{api:"archon",method:"GET",version:"modrinth/v0"})}async list(e){let t=new URLSearchParams;e?.limit&&t.set("limit",e.limit.toString()),e?.offset&&t.set("offset",e.offset.toString());let r=t.toString()?`?${t.toString()}`:"";return this.client.request(`servers${r}`,{api:"archon",method:"GET",version:"modrinth/v0"})}async checkStock(e,t){return this.client.request(`/stock?region=${e}`,{api:"archon",version:"modrinth/v0",method:"POST",body:t,skipAuth:!0})}async checkStockGlobal(e){return this.client.request("/stock",{api:"archon",version:"modrinth/v0",method:"POST",body:e,skipAuth:!0})}async getFilesystemAuth(e){return this.client.request(`/servers/${e}/fs`,{api:"archon",version:"modrinth/v0",method:"GET"})}async getWebSocketAuth(e){return this.client.request(`/servers/${e}/ws`,{api:"archon",version:"modrinth/v0",method:"GET"})}async power(e,t){await this.client.request(`/servers/${e}/power`,{api:"archon",method:"POST",version:"modrinth/v0",body:{action:t}})}async reinstall(e,t,r=!1){await this.client.request(`/servers/${e}/reinstall`,{api:"archon",method:"POST",version:"modrinth/v0",params:{hard:String(r)},body:t})}async getReinstallMrpackAuth(e){return this.client.request(`/servers/${e}/reinstallFromMrpack`,{api:"archon",version:"modrinth/v0",method:"GET"})}async reinstallFromMrpack(e,t,r=!1,n){let s=await this.getReinstallMrpackAuth(e),o=new FormData;return o.append("file",t),this.client.upload("",{api:`https://${s.url}`,version:"reinstallMrpackMultiparted",formData:o,params:{hard:String(r)},headers:{Authorization:`Bearer ${s.token}`},skipAuth:!0,onProgress:n?.onProgress,retry:!1})}async updateName(e,t){await this.client.request(`/servers/${e}/name`,{api:"archon",method:"POST",version:"modrinth/v0",body:{name:t}})}async getAllocations(e){return this.client.request(`/servers/${e}/allocations`,{api:"archon",method:"GET",version:"modrinth/v0"})}async reserveAllocation(e,t){return this.client.request(`/servers/${e}/allocations`,{api:"archon",method:"POST",version:"modrinth/v0",params:{name:t}})}async updateAllocation(e,t,r){await this.client.request(`/servers/${e}/allocations/${t}`,{api:"archon",method:"PUT",version:"modrinth/v0",params:{name:r}})}async deleteAllocation(e,t){await this.client.request(`/servers/${e}/allocations/${t}`,{api:"archon",method:"DELETE",version:"modrinth/v0"})}async checkSubdomainAvailability(e){return this.client.request(`/subdomains/${e}/isavailable`,{api:"archon",method:"GET",version:"modrinth/v0"})}async changeSubdomain(e,t){await this.client.request(`/servers/${e}/subdomain`,{api:"archon",method:"POST",version:"modrinth/v0",body:{subdomain:t}})}async getStartupConfig(e){return this.client.request(`/servers/${e}/startup`,{api:"archon",method:"GET",version:"modrinth/v0"})}async updateStartupConfig(e,t){await this.client.request(`/servers/${e}/startup`,{api:"archon",method:"POST",version:"modrinth/v0",body:t})}async dismissNotice(e,t){await this.client.request(`/servers/${e}/notices/${t}/dismiss`,{api:"archon",method:"POST",version:"modrinth/v0"})}};var W=class extends a{getModuleID(){return"archon_servers_v1"}async list(){return this.client.request("/servers",{api:"archon",version:1,method:"GET"})}async get(e){return this.client.request(`/servers/${e}`,{api:"archon",version:1,method:"GET"})}async getRegions(){return this.client.request("/regions",{api:"archon",version:1,method:"GET",skipAuth:!0})}async endIntro(e){await this.client.request(`/servers/${e}/flows/intro`,{api:"archon",version:1,method:"DELETE"})}async resetToOnboarding(e,t){await this.client.request(`/servers/${e}/worlds/${t}/onboard`,{api:"archon",version:1,method:"POST"})}};var V=class extends a{getModuleID(){return"archon_transfers_internal"}async scheduleServers(e){return this.client.request("/transfers/schedule/servers",{api:"archon",version:"internal",method:"POST",body:e})}async scheduleNodes(e){return this.client.request("/transfers/schedule/nodes",{api:"archon",version:"internal",method:"POST",body:e})}async history(e){let t={};return e?.page!==void 0&&(t.page=e.page),e?.page_size!==void 0&&(t.page_size=e.page_size),this.client.request("/transfers/history",{api:"archon",version:"internal",method:"GET",params:t})}async cancel(e){return this.client.request("/transfers/cancel",{api:"archon",version:"internal",method:"POST",body:e})}};import{$fetch as Qe}from"ofetch";var Xe="https://raw.githubusercontent.com/ipregistry/iso3166/master";function Ye(i){let e=i.trim().split(`
2
- `).filter(n=>n.trim()!=="");if(e.length===0)return[];let t=e[0],r=(t.startsWith("#")?t.slice(1):t).split(",");return e.slice(1).map(n=>{let s=n.split(","),o={};return r.forEach((c,l)=>{o[c]=s[l]||""}),o})}var H=class extends a{getModuleID(){return"iso3166_data"}async build(){try{let[e,t]=await Promise.all([Qe(`${Xe}/countries.csv`,{responseType:"text"}),Qe(`${Xe}/subdivisions.csv`,{responseType:"text"})]),r=Ye(e),n=Ye(t),s=r.map(c=>({alpha2:c.country_code_alpha2,alpha3:c.country_code_alpha3,numeric:c.numeric_code,nameShort:c.name_short,nameLong:c.name_long})),o=n.reduce((c,l)=>{let u=l.country_code_alpha2;return!u||typeof u!="string"||u.trim()===""||(c[u]||(c[u]=[]),c[u].push({code:l["subdivision_code_iso3166-2"],name:l.subdivision_name,localVariant:l.localVariant||null,category:l.category,parent:l.parent_subdivision||null,language:l.language_code})),c},{});return{countries:s,subdivisions:o}}catch(e){return console.error("Error fetching ISO3166 data:",e),{countries:[],subdivisions:{}}}}};var z=class extends a{getModuleID(){return"kyros_content_v1"}uploadAddonFile(e,t,r){let n=new FormData;for(let s of t)n.append("file",s,s instanceof File?s.name:"file");return this.client.upload(`/worlds/${e}/content/upload-addon-file`,{api:"",version:"v1",formData:n,onProgress:r?.onProgress,useNodeAuth:!0})}uploadModpackFile(e,t,r,n){let s=new FormData;return s.append("file",t,t instanceof File?t.name:"file"),s.append("properties",JSON.stringify(r)),this.client.upload(`/worlds/${e}/content/upload-modpack-file`,{api:"",version:"v1",formData:s,params:n?.softOverride!==void 0?{soft_override:String(n.softOverride)}:void 0,onProgress:n?.onProgress,useNodeAuth:!0})}};var pt=/\/modrinth\/v\d+\/fs\/?$/,dt=/^https?:\/\//i,ht=/^wss?:\/\//i,Ze=/^https:\/\//i,et=/^http:\/\//i;function K(i){let e=i.replace(pt,"");return dt.test(e)?e:`https://${e}`}function Ue(i){return ht.test(i)?i:Ze.test(i)?i.replace(Ze,"wss://"):et.test(i)?i.replace(et,"ws://"):`wss://${i}`}var J=class extends a{getModuleID(){return"kyros_files_v0"}getNodeBaseUrl(e){return K(e.url)}async listDirectory(e,t=1,r=100){return this.client.request("/fs/list",{api:"",version:"modrinth/v0",method:"GET",params:{path:e,page:t,page_size:r},useNodeAuth:!0})}async createFileOrFolder(e,t){return this.client.request("/fs/create",{api:"",version:"modrinth/v0",method:"POST",params:{path:e,type:t},headers:{"Content-Type":"application/octet-stream"},useNodeAuth:!0})}async downloadFile(e){return this.client.request("/fs/download",{api:"",version:"modrinth/v0",method:"GET",params:{path:e},useNodeAuth:!0})}async downloadFileWithAuth(e,t){return this.client.request("/fs/download",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",method:"GET",params:{path:t},headers:{Authorization:`Bearer ${e.token}`},skipAuth:!0})}uploadFile(e,t,r){return this.client.upload("/fs/create",{api:"",version:"modrinth/v0",file:t,params:{path:e,type:"file"},onProgress:r?.onProgress,retry:r?.retry,useNodeAuth:!0})}uploadFileWithAuth(e,t,r,n){return this.client.upload("/fs/create",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",file:r,params:{path:t,type:"file"},headers:{Authorization:`Bearer ${e.token}`},onProgress:n?.onProgress,retry:n?.retry,skipAuth:!0})}async updateFile(e,t){let r=typeof t=="string"?new Blob([t]):t;return this.client.request("/fs/update",{api:"",version:"modrinth/v0",method:"PUT",params:{path:e},body:r,headers:{"Content-Type":"application/octet-stream"},useNodeAuth:!0})}async moveFileOrFolder(e,t){return this.client.request("/fs/move",{api:"",version:"modrinth/v0",method:"POST",body:{source:e,destination:t},useNodeAuth:!0})}async renameFileOrFolder(e,t){let r=e.split("/").slice(0,-1).join("/")+"/"+t;return this.moveFileOrFolder(e,r)}async deleteFileOrFolder(e,t){return this.client.request("/fs/delete",{api:"",version:"modrinth/v0",method:"DELETE",params:{path:e,recursive:t},useNodeAuth:!0})}async deleteFileOrFolderWithAuth(e,t,r){return this.client.request("/fs/delete",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",method:"DELETE",params:{path:t,recursive:r},headers:{Authorization:`Bearer ${e.token}`},skipAuth:!0})}async extractFile(e,t=!0,r=!1){return this.client.request("/fs/unarchive",{api:"",version:"v1",method:"POST",params:{src:e,trg:"/",override:t,dry:r},useNodeAuth:!0})}async modifyOperation(e,t){return this.client.request(`/fs/ops/${t}`,{api:"",version:"v1",method:"POST",params:{id:e},useNodeAuth:!0})}};var Q=class extends a{getModuleID(){return"kyros_logs_v1"}async clear(){return this.client.request("/logs/clear",{api:"",version:"v1",method:"POST",useNodeAuth:!0})}};var X=class extends a{getModuleID(){return"kyros_upload_sessions_v1"}async create(e,t){return this.client.request(`/worlds/${t}/files/upload-session`,{api:"",version:"v1",method:"POST",useNodeAuth:!0})}async get(e,t){return this.client.request(`/worlds/${t}/files/upload-session`,{api:"",version:"v1",method:"GET",useNodeAuth:!0})}uploadFiles(e,t,r,n,s){let o=new FormData;for(let{file:c,filename:l}of n)o.append("file",c,l);return this.client.upload(`/worlds/${t}/files/upload-session/${r}/files`,{api:"",version:"v1",formData:o,onProgress:s?.onProgress,retry:s?.retry,useNodeAuth:!0})}async finalize(e,t,r){return this.client.request(`/worlds/${t}/files/upload-session/${r}/finalize`,{api:"",version:"v1",method:"POST",useNodeAuth:!0})}async cancel(e,t,r){return this.client.request(`/worlds/${t}/files/upload-session/${r}`,{api:"",version:"v1",method:"DELETE",useNodeAuth:!0})}};var Y=class extends a{getModuleID(){return"labrinth_analytics_v3"}async fetch(e){return this.client.request("/analytics",{api:"labrinth",version:3,method:"POST",body:e,timeout:100*1e3})}async fetchFacets(e){return this.client.request("/analytics/facets",{api:"labrinth",version:3,method:"POST",body:e,timeout:100*1e3})}async getEvents(){return this.client.request("/analytics-event",{api:"labrinth",version:3,method:"GET"})}async createEvent(e){return this.client.request("/analytics-event",{api:"labrinth",version:3,method:"POST",body:e})}async editEvent(e,t){return this.client.request(`/analytics-event/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteEvent(e){return this.client.request(`/analytics-event/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var Z=class extends a{getModuleID(){return"labrinth_auth_internal"}async getNewsletterStatus(){return this.client.request("/auth/email/subscribe",{api:"labrinth",version:"internal",method:"GET"})}async subscribeNewsletter(){return this.client.request("/auth/email/subscribe",{api:"labrinth",version:"internal",method:"POST"})}async createDiscordCommunityLink(){return this.client.request("/auth/discord-community-link",{api:"labrinth",version:"internal",method:"POST"})}};var ee=class extends a{getModuleID(){return"labrinth_auth_v2"}async login(e){return this.client.request("/auth/login",{api:"labrinth",version:2,method:"POST",body:e})}async login2FA(e){return this.client.request("/auth/login/2fa",{api:"labrinth",version:2,method:"POST",body:e})}async createAccount(e){return this.client.request("/auth/create",{api:"labrinth",version:2,method:"POST",body:e})}async resetPasswordBegin(e){return this.client.request("/auth/password/reset",{api:"labrinth",version:2,method:"POST",body:e})}async changePassword(e){return this.client.request("/auth/password",{api:"labrinth",version:2,method:"PATCH",body:e})}};var te=class extends a{getModuleID(){return"labrinth_billing_internal"}async getSubscriptions(e){let t=e?`?user_id=${e}`:"";return this.client.request(`/billing/subscriptions${t}`,{api:"labrinth",version:"internal",method:"GET"})}async getProducts(){return this.client.request("/billing/products",{api:"labrinth",version:"internal",method:"GET"})}async getCustomer(){return this.client.request("/billing/customer",{api:"labrinth",version:"internal",method:"GET"})}async editSubscription(e,t,r){let n=r?"?dry=true":"";return this.client.request(`/billing/subscription/${e}${n}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async getPaymentMethods(){return this.client.request("/billing/payment_methods",{api:"labrinth",version:"internal",method:"GET"})}async addPaymentMethodFlow(){return this.client.request("/billing/payment_method",{api:"labrinth",version:"internal",method:"POST"})}async editPaymentMethod(e,t){return this.client.request(`/billing/payment_method/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async removePaymentMethod(e){return this.client.request(`/billing/payment_method/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async getPayments(e){let t=e?`?user_id=${e}`:"";return this.client.request(`/billing/payments${t}`,{api:"labrinth",version:"internal",method:"GET"})}async initiatePayment(e){return this.client.request("/billing/payment",{api:"labrinth",version:"internal",method:"POST",body:e})}async refundCharge(e,t){return this.client.request(`/billing/charge/${e}/refund`,{api:"labrinth",version:"internal",method:"POST",body:t})}async credit(e){return this.client.request("/billing/credit",{api:"labrinth",version:"internal",method:"POST",body:e})}};var re=class extends a{getModuleID(){return"labrinth_collections"}async get(e){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request("/collections",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async edit(e,t){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async delete(e){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"DELETE"})}async editIcon(e,t,r){return this.client.request(`/collection/${e}/icon?ext=${r}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteIcon(e){return this.client.request(`/collection/${e}/icon`,{api:"labrinth",version:3,method:"DELETE"})}};var ne=class extends a{getModuleID(){return"labrinth_external_projects_internal"}async search(e){return this.client.request("/moderation/external-license/search",{api:"labrinth",version:"internal",method:"POST",body:e})}async getBySha1(e){return this.client.request(`/moderation/external-license/by-sha1/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async update(e,t){return this.client.request(`/moderation/external-license/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}};var ie=class extends a{getModuleID(){return"labrinth_friends_v3"}async list(){return this.client.request("/friends",{api:"labrinth",version:3,method:"GET"})}async add(e){return this.client.request(`/friend/${encodeURIComponent(e)}`,{api:"labrinth",version:3,method:"POST"})}async remove(e){return this.client.request(`/friend/${encodeURIComponent(e)}`,{api:"labrinth",version:3,method:"DELETE"})}};var se=class extends a{getModuleID(){return"labrinth_globals_internal"}async get(){return this.client.request("/globals",{api:"labrinth",version:"internal",method:"GET",skipAuth:!0})}};var oe=class extends a{getModuleID(){return"labrinth_limits_v3"}async getProjectLimits(){return this.client.request("/limits/projects",{api:"labrinth",version:3,method:"GET"})}async getOrganizationLimits(){return this.client.request("/limits/organizations",{api:"labrinth",version:3,method:"GET"})}async getCollectionLimits(){return this.client.request("/limits/collections",{api:"labrinth",version:3,method:"GET"})}};var ae=class extends a{getModuleID(){return"labrinth_moderation_internal"}async acquireLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"POST"})}async overrideLock(e){return this.client.request(`/moderation/lock/${e}/override`,{api:"labrinth",version:"internal",method:"POST"})}async releaseLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async checkLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"GET"})}};var ce=class extends a{getModuleID(){return"labrinth_notifications_v2"}async getUserNotifications(e){return this.client.request(`/user/${e}/notifications`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request(`/notifications?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:2,method:"GET"})}async markAsRead(e){return this.client.request(`/notification/${e}`,{api:"labrinth",version:2,method:"PATCH"})}async markMultipleAsRead(e){return this.client.request("/notifications",{api:"labrinth",version:2,method:"PATCH",params:{ids:JSON.stringify([...new Set(e)])}})}async delete(e){return this.client.request(`/notification/${e}`,{api:"labrinth",version:2,method:"DELETE"})}async deleteMultiple(e){return this.client.request("/notifications",{api:"labrinth",version:2,method:"DELETE",params:{ids:JSON.stringify([...new Set(e)])}})}};var le=class extends a{getModuleID(){return"labrinth_oauth_internal"}async getUserApps(e){return this.client.request(`/user/${e}/oauth_apps`,{api:"labrinth",version:3,method:"GET"})}async getApp(e){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async getApps(e){return this.client.request(`/oauth/apps?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:"internal",method:"GET"})}async createApp(e){return this.client.request("/oauth/app",{api:"labrinth",version:"internal",method:"POST",body:e})}async editApp(e,t){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async deleteApp(e){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}uploadAppIcon(e,t,r){return this.client.upload(`/oauth/app/${e}/icon`,{api:"labrinth",version:"internal",file:t,params:{ext:r}})}async getAuthorizations(){return this.client.request("/oauth/authorizations",{api:"labrinth",version:"internal",method:"GET"})}async revokeAuthorization(e){return this.client.request("/oauth/authorizations",{api:"labrinth",version:"internal",method:"DELETE",params:{client_id:e}})}async authorize(e){return this.client.request("/oauth/authorize",{api:"labrinth",version:"internal",method:"GET",params:e})}async accept(e){return this.client.request("/oauth/accept",{api:"labrinth",version:"internal",method:"POST",body:e})}async reject(e){return this.client.request("/oauth/reject",{api:"labrinth",version:"internal",method:"POST",body:e})}};var ue=class extends a{getModuleID(){return"labrinth_organizations_v3"}async get(e){return this.client.request(`/organization/${e}`,{api:"labrinth",version:3,method:"GET"})}async getProjects(e){return this.client.request(`/organization/${e}/projects`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request(`/organizations?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async addProject(e,t){return this.client.request(`/organization/${e}/projects`,{api:"labrinth",version:3,method:"POST",body:t})}async removeProject(e,t,r){return this.client.request(`/organization/${e}/projects/${t}`,{api:"labrinth",version:3,method:"DELETE",body:r})}};var pe=class extends a{getModuleID(){return"labrinth_pats_v2"}async list(){return this.client.request("/pat",{api:"labrinth",version:2,method:"GET"})}async create(e){return this.client.request("/pat",{api:"labrinth",version:2,method:"POST",body:e})}async modify(e,t){return this.client.request(`/pat/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}async delete(e){return this.client.request(`/pat/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var de=class extends a{getModuleID(){return"labrinth_payout_v3"}async getBalance(){let e=await this.client.request("/payout/balance",{api:"labrinth",version:3,method:"GET"});return{...e,available:Number(e.available),withdrawn_lifetime:Number(e.withdrawn_lifetime),withdrawn_ytd:Number(e.withdrawn_ytd),pending:Number(e.pending),dates:Object.fromEntries(Object.entries(e.dates).map(([t,r])=>[t,Number(r)]))}}async getHistory(){return(await this.client.request("/payout/history",{api:"labrinth",version:3,method:"GET"})).map(t=>t.type==="withdrawal"?{...t,amount:Number(t.amount),fee:t.fee===null?null:Number(t.fee)}:{...t,amount:Number(t.amount)})}async getMethods(e){return this.client.request("/payout/methods",{api:"labrinth",version:3,method:"GET",params:e?{country:e}:void 0})}async cancel(e){return this.client.request(`/payout/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var he=class extends a{getModuleID(){return"labrinth_payouts_v3"}async getPlatformRevenue(e){return this.client.request("/payout/platform_revenue",{api:"labrinth",version:3,method:"GET",params:e})}};var me=class extends a{getModuleID(){return"labrinth_projects_v2"}async get(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"GET"})}async check(e){let t=encodeURIComponent(e);return this.client.request(`/project/${t}/check`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request("/projects",{api:"labrinth",version:2,method:"GET",params:{ids:JSON.stringify(e)}})}async search(e){return this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{...e,facets:e.facets?JSON.stringify(e.facets):void 0,new_filters:e.new_filters??void 0}})}async edit(e,t){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}async delete(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"DELETE"})}async getDependencies(e){return this.client.request(`/project/${e}/dependencies`,{api:"labrinth",version:2,method:"GET"})}async createGalleryImage(e,t,r){let n={ext:r.ext,featured:String(r.featured)};return r.title&&(n.title=r.title),r.description&&(n.description=r.description),r.ordering!==void 0&&(n.ordering=String(r.ordering)),this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"POST",params:n,body:t})}async editGalleryImage(e,t,r){let n={url:t,featured:String(r.featured)};return r.title&&(n.title=r.title),r.description&&(n.description=r.description),r.ordering!==void 0&&(n.ordering=String(r.ordering)),this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"PATCH",params:n})}async deleteGalleryImage(e,t){return this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"DELETE",params:{url:t}})}async getRandom(e){return this.client.request("/projects_random",{api:"labrinth",version:2,method:"GET",params:{count:String(e)}})}async bulkEdit(e,t){return this.client.request("/projects",{api:"labrinth",version:2,method:"PATCH",params:{ids:JSON.stringify(e)},body:t})}};function Ne(i){if(typeof i!="object"||i===null)return!1;let e=i;return typeof e.error=="string"&&typeof e.description=="string"}var h=class i extends Error{constructor(e,t){super(e),this.name="ModrinthApiError",this.statusCode=t?.statusCode,this.originalError=t?.originalError,this.responseData=t?.responseData,this.context=t?.context,Error.captureStackTrace&&Error.captureStackTrace(this,i)}static fromUnknown(e,t){return e instanceof i?e:e instanceof Error?new i(e.message,{originalError:e,context:t}):new i(String(e),{context:t})}},x=class i extends h{constructor(e,t){let r=e;t?.v1Error&&(r=`[${t.v1Error.error}] ${t.v1Error.description}`,t.v1Error.context&&(r=`${t.v1Error.context}: ${r}`)),super(r,t),this.name="ModrinthServerError",this.v1Error=t?.v1Error,Error.captureStackTrace&&Error.captureStackTrace(this,i)}static fromResponse(e,t,r){let n=Ne(t)?t:void 0,s=`HTTP ${e}`;return n?s=n.description:typeof t=="string"&&(s=t),new i(s,{statusCode:e,responseData:t,context:r,v1Error:n})}static fromUnknown(e,t){return e instanceof i?e:e instanceof h?new i(e.message,{statusCode:e.statusCode,originalError:e.originalError,responseData:e.responseData,context:t??e.context}):e instanceof Error?new i(e.message,{originalError:e,context:t}):new i(String(e),{context:t})}};var ge=class extends a{getModuleID(){return"labrinth_projects_v3"}async get(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"GET"})}async getDependencies(e){return this.client.request(`/project/${e}/dependencies`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request("/projects",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async edit(e,t){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async getOrganization(e){try{return await this.client.request(`/project/${e}/organization`,{api:"labrinth",version:3,method:"GET"})}catch(t){if(t instanceof h&&t.statusCode===404)return null;throw t}}async getMembers(e){return this.client.request(`/project/${e}/members`,{api:"labrinth",version:3,method:"GET"})}async createServerProject(e){return this.client.request("/project",{api:"labrinth",version:3,method:"PUT",body:e})}async deleteProject(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"DELETE"})}async changeIcon(e,t,r){return this.client.request(`/project/${e}/icon`,{api:"labrinth",version:3,method:"PATCH",params:{ext:r},body:t})}async deleteIcon(e){return this.client.request(`/project/${e}/icon`,{api:"labrinth",version:3,method:"DELETE"})}};var be=class extends a{getModuleID(){return"labrinth_reports_v3"}async get(e){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"GET"})}async list(e){let t={};return e?.count!=null&&(t.count=String(e.count)),e?.offset!=null&&(t.offset=String(e.offset)),e?.all!=null&&(t.all=String(e.all)),this.client.request("/report",{api:"labrinth",version:3,method:"GET",params:Object.keys(t).length>0?t:void 0})}async getMultiple(e){return this.client.request(`/reports?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async create(e){return this.client.request("/report",{api:"labrinth",version:3,method:"POST",body:e})}async edit(e,t){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async delete(e){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var ve=class extends a{getModuleID(){return"labrinth_server_ping_internal"}async pingMinecraftJava(e){return this.client.request("/server-ping/minecraft-java",{api:"labrinth",version:"internal",method:"POST",body:e})}};var ye=class extends a{getModuleID(){return"labrinth_sessions_v2"}async list(){return this.client.request("/session/list",{api:"labrinth",version:2,method:"GET"})}async delete(e){return this.client.request(`/session/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var fe=class extends a{getModuleID(){return"labrinth_state"}async build(){let e=[],t=(d,lt,ut)=>(console.error("Error fetching state data:",d),e.push({endpoint:ut,error:d}),lt),[r,n,s,o,c,l,u,p,m,g,b,M,v]=await Promise.all([this.client.request("/tag/category",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/category")),this.client.request("/tag/loader",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/loader")),this.client.request("/tag/game_version",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/game_version")),this.client.request("/tag/donation_platform",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/donation_platform")),this.client.request("/tag/report_type",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/report_type")),this.client.request("/projects_random",{api:"labrinth",version:2,method:"GET",params:{count:"60"}}).catch(d=>t(d,[],"/v2/projects_random")),this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{limit:"3",query:"leave",index:"relevance"}}).catch(d=>t(d,{},"/v2/search")),this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{limit:"3",query:"",index:"updated"}}).catch(d=>t(d,{},"/v2/search")),this.client.labrinth.billing_internal.getProducts().catch(d=>t(d,[],"/_internal/billing/products")),this.client.request("/mural/bank-details",{api:"labrinth",version:"internal",method:"GET"}).catch(d=>t(d,null,"/_internal/mural/bank-details")),this.client.iso3166.data.build().catch(d=>t(d,{countries:[],subdivisions:{}},"iso3166/data")),this.client.request("/payout/methods",{api:"labrinth",version:3,method:"GET"}).catch(d=>t(d,[],"/v3/payout/methods")),this.client.request("/globals",{api:"labrinth",version:"internal",method:"GET"}).catch(d=>t(d,null,"/_internal/globals"))]),R=Object.fromEntries(M.filter(d=>d.type==="tremendous").map(d=>[d.id,{name:d.name,image_url:d.image_logo_url}]));return{categories:r,loaders:n,gameVersions:s,donationPlatforms:o,reportTypes:c,homePageProjects:l,homePageSearch:u,homePageNotifs:p,products:m,muralBankDetails:g?.bankDetails,tremendousIdMap:R,countries:b.countries,subdivisions:b.subdivisions,taxComplianceThresholds:v?.tax_compliance_thresholds,errors:e}}};var Pe=class extends a{getModuleID(){return"labrinth_tech_review_internal"}async searchProjects(e){return this.client.request("/moderation/tech-review/search",{api:"labrinth",version:"internal",method:"POST",body:e})}async getReport(e){return this.client.request(`/moderation/tech-review/report/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async getIssue(e){return this.client.request(`/moderation/tech-review/issue/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async updateIssueDetail(e,t){return this.client.request(`/moderation/tech-review/issue-detail/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async submitProject(e,t){return this.client.request(`/moderation/tech-review/submit/${e}`,{api:"labrinth",version:"internal",method:"POST",body:t})}async getProjectReport(e){return this.client.request(`/moderation/tech-review/project/${e}`,{api:"labrinth",version:"internal",method:"GET"})}};var Se=class extends a{getModuleID(){return"labrinth_threads_v3"}async getThread(e){return this.client.request(`/thread/${e}`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request(`/threads?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async sendMessage(e,t){return this.client.request(`/thread/${e}`,{api:"labrinth",version:3,method:"POST",body:t})}async deleteMessage(e){return this.client.request(`/message/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var Ae=class extends a{getModuleID(){return"labrinth_users_v2"}async get(e){return this.client.request(`/user/${e}`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request(`/users?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:2,method:"GET"})}async getProjects(e){return this.client.request(`/user/${e}/projects`,{api:"labrinth",version:2,method:"GET"})}async getOrganizations(e){return this.client.request(`/user/${e}/organizations`,{api:"labrinth",version:3,method:"GET"})}async getCollections(e){return this.client.request(`/user/${e}/collections`,{api:"labrinth",version:3,method:"GET"})}async getNotifications(e){return this.client.request(`/user/${e}/notifications`,{api:"labrinth",version:2,method:"GET"})}async getFollowedProjects(e){return this.client.request(`/user/${e}/follows`,{api:"labrinth",version:2,method:"GET"})}async patch(e,t){return this.client.request(`/user/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}};var Ee=class extends a{getModuleID(){return"labrinth_users_v3"}async getAuthenticated(){return this.client.request("/user",{api:"labrinth",version:3,method:"GET"})}async get(e){return this.client.request(`/user/${encodeURIComponent(e)}`,{api:"labrinth",version:3,method:"GET"})}async search(e){return this.client.request(`/users/search?query=${encodeURIComponent(e)}`,{api:"labrinth",version:3,method:"GET"})}async getAllProjects(e){return this.client.request(`/user/${encodeURIComponent(e)}/all-projects`,{api:"labrinth",version:3,method:"GET"})}};var _e=class extends a{getModuleID(){return"labrinth_versions_v2"}async getProjectVersions(e,t){let r={};return t?.game_versions?.length&&(r.game_versions=JSON.stringify(t.game_versions)),t?.loaders?.length&&(r.loaders=JSON.stringify(t.loaders)),t?.include_changelog===!1&&(r.include_changelog="false"),t?.limit!=null&&(r.limit=String(t.limit)),t?.offset!=null&&(r.offset=String(t.offset)),this.client.request(`/project/${e}/version`,{api:"labrinth",version:2,method:"GET",params:Object.keys(r).length>0?r:void 0})}async getVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"GET"})}async getVersions(e){return this.client.request("/versions",{api:"labrinth",version:2,method:"GET",params:{ids:JSON.stringify(e)}})}async getVersionFromIdOrNumber(e,t){return this.client.request(`/project/${e}/version/${t}`,{api:"labrinth",version:2,method:"GET"})}async deleteVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var tt=1800*1e3,Re=class extends a{getModuleID(){return"labrinth_versions_v3"}async getProjectVersions(e,t){let r={};return t?.game_versions?.length&&(r.game_versions=JSON.stringify(t.game_versions)),t?.loaders?.length&&(r.loaders=JSON.stringify(t.loaders)),t?.include_changelog===!1&&(r.include_changelog="false"),t?.limit!=null&&(r.limit=String(t.limit)),t?.offset!=null&&(r.offset=String(t.offset)),this.client.request(`/project/${e}/version`,{api:"labrinth",version:t?.apiVersion??2,method:"GET",params:Object.keys(r).length>0?r:void 0})}async getVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:3,method:"GET"})}async getVersions(e){return this.client.request("/versions",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async getVersionFromIdOrNumber(e,t){return this.client.request(`/project/${e}/version/${t}`,{api:"labrinth",version:3,method:"GET"})}createVersion(e,t,r=null){let n=new FormData,s=t.map(p=>p.file),o=t.map(p=>p.fileType||null),c=s.map((p,m)=>`${p.name}-${m===0?"primary":m}`),l=c.reduce((p,m,g)=>(p[m]=o[g],p),{}),u={project_id:e.project_id,version_number:e.version_number,name:e.name||e.version_number,changelog:e.changelog,dependencies:e.dependencies||[],game_versions:e.game_versions,version_type:e.version_type,featured:!!e.featured,file_parts:c,file_types:l,primary_file:c[0],environment:e.environment,loaders:e.loaders};return r==="modpack"&&(u.mrpack_loaders=e.loaders,u.loaders=["mrpack"]),n.append("data",JSON.stringify(u)),s.forEach((p,m)=>{n.append(c[m],p,p.name)}),this.client.upload("/version",{api:"labrinth",version:3,formData:n,timeout:tt})}async modifyVersion(e,t){return this.client.request(`/version/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"DELETE"})}addFilesToVersion(e,t){let r=new FormData,n=t.map(l=>l.file),s=t.map(l=>l.fileType||null),o=n.map((l,u)=>`${l.name}-${u}`),c=o.reduce((l,u,p)=>(l[u]=s[p],l),{});return r.append("data",JSON.stringify({file_types:c})),n.forEach((l,u)=>{r.append(o[u],l,l.name)}),this.client.upload(`/version/${e}/file`,{api:"labrinth",version:2,formData:r,timeout:tt})}};var xe=class extends a{getModuleID(){return"labrinth_affiliate_internal"}async getAll(){return this.client.request("/affiliate",{api:"labrinth",version:"internal",method:"GET"})}async create(e){return this.client.request("/affiliate",{api:"labrinth",version:"internal",method:"PUT",body:e})}async get(e){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async delete(e){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async patch(e,t){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}};var Te=class extends a{getModuleID(){return"labrinth_campaign_internal"}async getPride26(){return this.client.request("/campaign/pride-26",{api:"labrinth",version:"internal",method:"GET",skipAuth:!0})}};var ke=class extends a{getModuleID(){return"labrinth_tags_v2"}async getLicenseText(e){return this.client.request(`/tag/license/${e}`,{api:"labrinth",version:2,method:"GET"})}};var we=class extends a{getModuleID(){return"labrinth_teams_v2"}async addMember(e,t){return this.client.request(`/team/${e}/members`,{api:"labrinth",version:2,method:"POST",body:t})}async editMember(e,t,r){return this.client.request(`/team/${e}/members/${t}`,{api:"labrinth",version:2,method:"PATCH",body:r})}async removeMember(e,t){return this.client.request(`/team/${e}/members/${t}`,{api:"labrinth",version:2,method:"DELETE"})}async transferOwnership(e,t){return this.client.request(`/team/${e}/owner`,{api:"labrinth",version:2,method:"PATCH",body:t})}};var Ce=class extends a{getModuleID(){return"labrinth_teams_v3"}async getMultiple(e){return this.client.request(`/teams?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}};var mt="https://launcher-meta.modrinth.com",qe=class extends a{getModuleID(){return"launchermeta_manifest_v0"}async getManifest(e){return this.client.request("/manifest.json",{api:mt,version:`${e}/v0`,method:"GET",skipAuth:!0,headers:{"Content-Type":""}})}};var Le=class extends a{getModuleID(){return"mclogs_insights_v1"}async analyse(e){return this.client.request("/analyse",{api:"https://api.mclo.gs",version:"1",method:"POST",body:new URLSearchParams({content:e}),headers:{"Content-Type":"application/x-www-form-urlencoded"},skipAuth:!0})}};var Me=class extends a{getModuleID(){return"mclogs_logs_v1"}async create(e){return this.client.request("/log",{api:"https://api.mclo.gs",version:"1",method:"POST",body:new URLSearchParams({content:e}),headers:{"Content-Type":"application/x-www-form-urlencoded"},skipAuth:!0})}};var rt="https://fill.papermc.io",Oe=class extends a{getModuleID(){return"paper_versions_v3"}async getProject(){return this.client.request("/projects/paper",{api:rt,version:"v3",method:"GET",skipAuth:!0})}async getBuilds(e){return{builds:await this.client.request(`/projects/paper/versions/${e}/builds`,{api:rt,version:"v3",method:"GET",skipAuth:!0})}}};var nt="https://api.purpurmc.org",$e=class extends a{getModuleID(){return"purpur_versions_v2"}async getProject(){return this.client.request("/purpur",{api:nt,version:"v2",method:"GET",skipAuth:!0})}async getBuilds(e){return this.client.request(`/purpur/${e}`,{api:nt,version:"v2",method:"GET",skipAuth:!0})}};var gt={archon_actions_v1:O,archon_backups_queue_v1:I,archon_backups_v1:$,archon_content_v1:U,archon_nodes_internal:N,archon_notices_v0:D,archon_options_v1:B,archon_properties_v1:j,archon_server_users_v1:F,archon_servers_v0:G,archon_servers_v1:W,archon_transfers_internal:V,iso3166_data:H,mclogs_insights_v1:Le,mclogs_logs_v1:Me,launchermeta_manifest_v0:qe,kyros_content_v1:z,kyros_files_v0:J,kyros_logs_v1:Q,kyros_upload_sessions_v1:X,labrinth_affiliate_internal:xe,labrinth_analytics_v3:Y,labrinth_auth_internal:Z,labrinth_auth_v2:ee,labrinth_billing_internal:te,labrinth_campaign_internal:Te,labrinth_collections:re,labrinth_external_projects_internal:ne,labrinth_friends_v3:ie,labrinth_globals_internal:se,labrinth_moderation_internal:ae,labrinth_notifications_v2:ce,labrinth_oauth_internal:le,labrinth_organizations_v3:ue,labrinth_pats_v2:pe,labrinth_limits_v3:oe,labrinth_payout_v3:de,labrinth_payouts_v3:he,labrinth_projects_v2:me,labrinth_projects_v3:ge,labrinth_reports_v3:be,labrinth_server_ping_internal:ve,labrinth_sessions_v2:ye,labrinth_state:fe,labrinth_tags_v2:ke,labrinth_teams_v2:we,labrinth_teams_v3:Ce,labrinth_tech_review_internal:Pe,labrinth_threads_v3:Se,labrinth_users_v2:Ae,labrinth_users_v3:Ee,labrinth_versions_v2:_e,labrinth_versions_v3:Re,paper_versions_v3:Oe,purpur_versions_v2:$e};function bt(i){let e=i.split("_");if(e.length<2)throw new Error(`Invalid module ID "${i}". Expected format: <api>_<module> (e.g., "labrinth_projects_v2")`);let t=e[0],r=e.slice(1).join("_");return[t,r]}function it(){let i={};for(let[e,t]of Object.entries(gt)){let[r,n]=bt(e);i[r]||(i[r]={}),i[r][n]=t}return i}var T=class{};var k=class extends T{constructor(t){super();this._moduleInstances=new Map;this._moduleNamespaces=new Map;this.config={timeout:1e4,labrinthBaseUrl:"https://api.modrinth.com",archonBaseUrl:"https://archon.modrinth.com",...t},this.features=t.features??[],this.initializeModules()}initializeModules(){let t=it();for(let[r,n]of Object.entries(t)){let s={};for(let[o,c]of Object.entries(n)){let l=`${r}_${o}`;Object.defineProperty(s,o,{get:()=>{if(!this._moduleInstances.has(l)){let u=new c(this),p=u.getModuleID();if(p!==l)throw new Error(`Module ID mismatch: registry expects "${l}" but module declares "${p}"`);this._moduleInstances.set(l,u)}return this._moduleInstances.get(l)},enumerable:!0,configurable:!1})}Object.defineProperty(this,r,{value:s,writable:!1,enumerable:!0,configurable:!1}),this._moduleNamespaces.set(r,s)}}async request(t,r){let n;r.api==="labrinth"?n=this.resolveBaseUrl(this.config.labrinthBaseUrl):r.api==="archon"?n=this.resolveBaseUrl(this.config.archonBaseUrl):n=r.api;let s=this.buildUrl(t,n,r.version),o=await this.buildDefaultHeaders(),c={method:"GET",timeout:this.config.timeout,...r,headers:{...o,...r.headers}};this.attachArchonSentryCaptureHeader(c);let l=c.headers;l&&"Content-Type"in l&&l["Content-Type"]===""&&delete l["Content-Type"];let u=this.buildContext(s,t,c);try{let p=await this.executeFeatureChain(u);return await this.config.hooks?.onResponse?.(p,u),p}catch(p){let m=this.normalizeError(p,u);throw await this.config.hooks?.onError?.(m,u),m}}async stream(t,r){let n;r.api==="labrinth"?n=this.resolveBaseUrl(this.config.labrinthBaseUrl):r.api==="archon"?n=this.resolveBaseUrl(this.config.archonBaseUrl):n=r.api;let s=this.buildUrl(t,n,r.version),o=await this.buildDefaultHeaders(),c={method:"GET",retry:!1,circuitBreaker:!1,...r,headers:{...o,Accept:"text/event-stream",...r.headers}};this.attachArchonSentryCaptureHeader(c);let l=this.buildContext(s,t,c);try{return await this.executeFeatureChain(l,()=>this.executeStreamRequest(l.url,l.options))}catch(u){let p=this.normalizeError(u,l);throw await this.config.hooks?.onError?.(p,l),p}}async executeFeatureChain(t,r=()=>this.executeRequest(t.url,t.options)){let n=this.features.filter(c=>c.shouldApply(t)),s=n.length,o=async()=>(s--,s>=0?n[s].execute(o,t):(await this.config.hooks?.onRequest?.(t),r()));return o()}async executeUploadFeatureChain(t,r,n){let s=this.features.filter(l=>l.shouldApply(t)),o=s.length,c=async()=>(o--,o>=0?s[o].execute(c,t):(await this.config.hooks?.onRequest?.(t),this.executeXHRUpload(t,r,n)));return c()}buildUrl(t,r,n){let s=r.replace(/\/$/,""),o="";n==="internal"?o="/_internal":typeof n=="number"?o=`/v${n}`:typeof n=="string"&&(o=`/${n}`);let c=t.startsWith("/")?t:`/${t}`;return`${s}${o}${c}`}resolveBaseUrl(t){return typeof t=="function"?t():t}buildContext(t,r,n){return{url:t,path:r,options:n,attempt:1,startTime:Date.now()}}buildUploadContext(t,r,n){let s,o;if("formData"in n&&n.formData)s={isUpload:!0,formData:n.formData,onProgress:n.onProgress},o=n.formData;else if("file"in n&&n.file)s={isUpload:!0,file:n.file,onProgress:n.onProgress},o=n.file;else throw new Error("Upload options must include either file or formData");return{url:t,path:r,options:{...n,method:"POST",body:o},attempt:1,startTime:Date.now(),metadata:s}}async buildDefaultHeaders(){let t={"Content-Type":"application/json",...this.config.headers},r=await this.resolveUserAgent();return r&&(t["User-Agent"]=r),t}async resolveUserAgent(){let t=this.config.userAgent;return typeof t=="function"?await t():t}attachArchonSentryCaptureHeader(t){t.api!=="archon"||!t.headers||!this.shouldCaptureArchonRequests()||(t.headers["modrinth-sentry-capture"]="1")}shouldCaptureArchonRequests(){let t=this.config.archonSentryCapture;return typeof t=="function"?t():t===!0}normalizeError(t,r){return t instanceof h?t:h.fromUnknown(t,r?.path)}createNormalizedError(t,r,n){return r&&n?x.fromResponse(r,n):new h(t.message,{statusCode:r,originalError:t,responseData:n})}addFeature(t){return this.features.push(t),this}removeFeature(t){let r=this.features.indexOf(t);return r!==-1&&this.features.splice(r,1),this}getFeatures(){return[...this.features]}};var y=class{constructor(e){this.config={enabled:!0,...e}}shouldApply(e){return this.config.enabled!==!1}get name(){return this.config.name??this.constructor.name}get enabled(){return this.config.enabled!==!1}};var w=class{constructor(e){this.client=e;this.connections=new Map}on(e,t,r){let n=this.getEventKey(e,t),s=r;return this.emitter.on(n,s),()=>{this.emitter.off(n,s)}}onAny(e,t){let r=this.getAnyEventKey(e),n=t;return this.emitter.on(r,n),()=>{this.emitter.off(r,n)}}onStatus(e,t){let r=this.getStatusEventKey(e),n=t;return this.emitter.on(r,n),()=>{this.emitter.off(r,n)}}getStatus(e){let t=this.connections.get(e);return t?this.connectionToStatus(t):null}emitSyncEvent(e,t){this.emitter.emit(this.getEventKey(e,t.type),t),this.emitter.emit(this.getAnyEventKey(e),t)}updateStatus(e,t,r){e.status=t,e.error=r,this.emitter.emit(this.getStatusEventKey(e.serverId),this.connectionToStatus(e))}clearListeners(e){this.emitter.all.forEach((t,r)=>{r.toString().startsWith(`${e}:`)&&this.emitter.all.delete(r)})}connectionToStatus(e){return{state:e.status,connected:e.status==="connected",reconnecting:e.status==="reconnecting",reconnectAttempts:e.reconnectAttempts,retryDelay:e.retryDelay,lastEventId:e.lastEventId,error:e.error}}getEventKey(e,t){return`${e}:${t}`}getAnyEventKey(e){return`${e}:*`}getStatusEventKey(e){return`${e}:__status`}};var C=class{constructor(e){this.client=e;this.connections=new Map;this.MAX_RECONNECT_ATTEMPTS=10;this.RECONNECT_BASE_DELAY=1e3;this.RECONNECT_MAX_DELAY=3e4}async safeConnect(e,t){let r=this.getStatus(e);if(r?.connected&&!t?.force||r&&!r.connected&&!t?.force)return;t?.force&&r&&this.disconnect(e);let n=await this.client.archon.servers_v0.getWebSocketAuth(e);await this.connect(e,n)}on(e,t,r){let n=`${e}:${t}`;return this.emitter.on(n,r),()=>{this.emitter.off(n,r)}}getStatus(e){let t=this.connections.get(e);return t?{connected:t.socket.readyState===WebSocket.OPEN,reconnecting:t.isReconnecting,reconnectAttempts:t.reconnectAttempts}:null}getReconnectDelay(e){return Math.min(this.RECONNECT_BASE_DELAY*Math.pow(2,e),this.RECONNECT_MAX_DELAY)+Math.random()*1e3}};var De=class extends y{async execute(e,t){let r=await this.getToken();if(r){let n=this.config.headerName??"Authorization",s=this.config.tokenPrefix??"Bearer",o=s?`${s} ${r}`:r;t.options.headers={...t.options.headers,[n]:o}}return e()}shouldApply(e){if(e.options.skipAuth)return!1;let t=this.config.headerName??"Authorization";return e.options.headers?.[t]?!1:super.shouldApply(e)}async getToken(){let{token:e}=this.config;return typeof e=="function"?await e():e}};var Ie=class{constructor(){this.state=new Map}get(e){return this.state.get(e)}set(e,t){this.state.set(e,t)}clear(e){this.state.delete(e)}},Be=class extends y{constructor(e){super(e),this.config={enabled:!0,name:"circuit-breaker",maxFailures:3,resetTimeout:3e4,failureStatusCodes:[500,502,503,504],...e},this.storage=e?.storage??new Ie}async execute(e,t){let r=this.getCircuitKey(t);if(this.isCircuitOpen(r))throw new h("Circuit breaker open - too many recent failures",{statusCode:503,context:t.path});try{let n=await e();return this.recordSuccess(r),n}catch(n){throw this.isFailureError(n)&&this.recordFailure(r),n}}shouldApply(e){return e.options.circuitBreaker===!1?!1:super.shouldApply(e)}getCircuitKey(e){if(this.config.getCircuitKey)return this.config.getCircuitKey(e.url,e.options.method??"GET");let t=e.options.method??"GET",r=e.path.split("?")[0];return`${t}_${r}`}isCircuitOpen(e){let t=this.storage.get(e);return t?Date.now()-t.lastFailure>this.config.resetTimeout?(this.storage.clear?.(e),!1):t.failures>=this.config.maxFailures:!1}recordSuccess(e){this.storage.clear?.(e)}recordFailure(e){let t=Date.now(),r=this.storage.get(e);r?this.storage.set(e,{failures:r.failures+1,lastFailure:t}):this.storage.set(e,{failures:1,lastFailure:t})}isFailureError(e){return e instanceof h&&e.statusCode?this.config.failureStatusCodes.includes(e.statusCode):!1}getCircuitState(e){return this.storage.get(e)}resetCircuit(e){this.storage.clear?.(e)}};var je=class extends y{constructor(){super(...arguments);this.refreshPromise=null}shouldApply(t){return t.options.useNodeAuth===!0&&this.config.enabled!==!1}async refreshAuthWithLock(){return this.refreshPromise?this.refreshPromise:(this.refreshPromise=this.config.refreshAuth().finally(()=>{this.refreshPromise=null}),this.refreshPromise)}async execute(t,r){let s=0,o=this.config.getAuth();if((!o||this.isTokenExpired(o.token))&&(await this.refreshAuthWithLock(),o=this.config.getAuth()),!o)throw new Error("Failed to obtain node authentication");for(this.applyAuth(r,o);;)try{return await t()}catch(c){if(c instanceof h&&c.statusCode===401){if(s++,s>=3)throw new Error("Node authentication failed after 3 retries. Please re-authenticate.");if(await this.refreshAuthWithLock(),o=this.config.getAuth(),!o)throw new Error("Failed to refresh node authentication");this.applyAuth(r,o);continue}throw c}}applyAuth(t,r){let n=K(r.url);t.url=this.buildUrl(t.path,n,t.options.version),t.options.headers={...t.options.headers,Authorization:`Bearer ${r.token}`},t.options.skipAuth=!0}buildUrl(t,r,n){let s=r.replace(/\/$/,""),o="";n==="internal"?o="/_internal":typeof n=="number"?o=`/v${n}`:typeof n=="string"&&(o=`/${n}`);let c=t.startsWith("/")?t:`/${t}`;return`${s}${o}${c}`}isTokenExpired(t){try{let r=JSON.parse(atob(t.split(".")[1]));if(!r.exp)return!1;let n=r.exp*1e3;return Date.now()>=n-1e4}catch{return!1}}};var st=1,Fe=class extends y{async execute(e,t){return t.options.headers={...t.options.headers,"X-Panel-Version":String(st)},e()}shouldApply(e){return e.options.api==="labrinth"||e.options.api==="archon"}};var Ge=class extends y{constructor(e){super(e),this.config={enabled:!0,name:"retry",maxAttempts:3,backoffStrategy:"exponential",initialDelay:1e3,maxDelay:15e3,retryableStatusCodes:[408,429,500,502,503,504],retryOnNetworkError:!0,...e}}async execute(e,t){let r=null,n=this.getMaxAttempts(t);for(let s=1;s<=n;s++){t.attempt=s;try{return await e()}catch(o){if(r=o,!this.shouldRetryError(o,s,n)||s>=n)throw o;let l=this.calculateDelay(s);console.warn(`[${this.name}] Retrying request to ${t.path} (attempt ${s+1}/${n}) after ${l}ms`),await this.sleep(l)}}throw r??new Error("Max retry attempts reached")}shouldApply(e){return e.options.retry===!1?!1:super.shouldApply(e)}shouldRetryError(e,t,r){return this.config.shouldRetry?this.config.shouldRetry(e,t):this.config.retryOnNetworkError&&this.isNetworkError(e)?!0:e instanceof h&&e.statusCode?this.config.retryableStatusCodes.includes(e.statusCode):!1}isNetworkError(e){let t=[/network/i,/timeout/i,/ECONNREFUSED/i,/ENOTFOUND/i,/ETIMEDOUT/i,/ECONNRESET/i],r=e instanceof Error?e.message:String(e);return t.some(n=>n.test(r))}getMaxAttempts(e){return typeof e.options.retry=="number"?e.options.retry:this.config.maxAttempts}calculateDelay(e){let{backoffStrategy:t,initialDelay:r,maxDelay:n}=this.config,s;switch(t){case"exponential":s=r*Math.pow(2,e-1);break;case"linear":s=r*e;break;case"constant":s=r;break;default:s=r}return s+=Math.random()*1e3,Math.min(s,n)}sleep(e){return new Promise(t=>setTimeout(t,e))}};var We=class extends y{async execute(e,t){let r=t.options.method??"GET",n=t.options.api,s=t.options.version,o=`[${r}] [${n}_v${s}]`;console.debug(`${o} ${t.url} SENT`);try{let c=await e();try{let l=c?JSON.stringify(c).length:0;console.debug(`${o} ${t.url} RECEIVED ${l} bytes`)}catch{console.debug(`${o} ${t.url} RECEIVED`)}return c}catch(c){let l=vt(c);throw console.debug(`${o} ${t.url} FAILED${l?` \u2014 ${l}`:""}`),c}}};function vt(i){if(!i||typeof i!="object")return typeof i=="string"?i:"";let e=i,t=e.status??e.statusCode??e.response?.status,r=e.statusText??e.response?.statusText,n=e.responseData??e.data??e.response?._data,s=[];return t!==void 0&&s.push(r?`${t} ${r}`:String(t)),n!==void 0?s.push(`body: ${yt(n)}`):e.message&&s.push(e.message),s.join(" ")}function yt(i){if(typeof i=="string")return i;try{return JSON.stringify(i)}catch{return String(i)}}var ot;(e=>{let i;(r=>{let t;(s=>s.UserScope={NONE:"",SERVER_ADMIN:"SERVER_ADMIN",BASE_READ:"BASE_READ",POWER_ACTIONS:"POWER_ACTIONS",EXEC_COMMANDS:"EXEC_COMMANDS",FILES_WRITE:"FILES_WRITE",SETUP:"SETUP",BACKUPS:"BACKUPS",ADVANCED:"ADVANCED",RESET_SERVER:"RESET_SERVER",MANAGE_USERS:"MANAGE_USERS",SUPPORT_AGENT:"SUPPORT_AGENT",INFRA_MANAGER:"INFRA_MANAGER",INFRA_MANAGER_READ:"INFRA_MANAGER_READ",INFRA_SERVERS_XFER:"INFRA_SERVERS_XFER",INFRA_USERS:"INFRA_USERS"})(t=r.v1||(r.v1={}))})(i=e.ServerUsers||(e.ServerUsers={}))})(ot||(ot={}));import{$fetch as Et,FetchError as _t}from"ofetch";function A(i,e){if(!e)return i;let t={};for(let[n,s]of Object.entries(e))s!=null&&(t[n]=String(s));let r=new URLSearchParams(t).toString();return r?`${i}${i.includes("?")?"&":"?"}${r}`:i}function E(i){if(i)return typeof i=="object"&&!(i instanceof FormData)&&!(i instanceof URLSearchParams)&&!(i instanceof Blob)&&!(i instanceof ArrayBuffer)&&!ArrayBuffer.isView(i)?JSON.stringify(i):i}async function _(i){let e=i.headers.get("content-type")?.toLowerCase()??"";try{if(e.includes("application/json")||e.includes("+json"))return await i.json();let t=await i.text();if(!t)return;try{return JSON.parse(t)}catch{return t}}catch{return}}import ft from"mitt";var q=class{constructor(){this.buffer="";this.eventName="";this.data=""}feed(e){this.buffer+=e;let t=[];for(;;){let r=this.findLineEnd();if(!r)break;let{line:n,length:s}=r;this.buffer=this.buffer.slice(s),this.processLine(n,t)}return t}end(){let e=[];return this.buffer.length>0&&(this.processLine(this.buffer.endsWith("\r")?this.buffer.slice(0,-1):this.buffer,e),this.buffer=""),this.dispatch(e),e}findLineEnd(){let e=this.buffer.indexOf(`
1
+ var a=class{constructor(e){this.client=e}};var M=class extends a{getModuleID(){return"archon_actions_v1"}async list(e,t={}){let r={};return t.filter&&(r.filter=JSON.stringify(t.filter)),t.limit!==void 0&&(r.limit=t.limit),t.offset!==void 0&&(r.offset=t.offset),t.order!==void 0&&(r.order=t.order),t.min_datetime!==void 0&&(r.min_datetime=t.min_datetime),t.max_datetime!==void 0&&(r.max_datetime=t.max_datetime),this.client.request(`/servers/${e}/action-log`,{api:"archon",version:1,method:"GET",params:Object.keys(r).length>0?r:void 0})}};var $=class extends a{getModuleID(){return"archon_backups_v1"}async list(e,t){return this.client.request(`/servers/${e}/worlds/${t}/backups`,{api:"archon",version:1,method:"GET"})}async get(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"GET"})}async create(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups`,{api:"archon",version:1,method:"POST",body:r})}async restore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}/restore`,{api:"archon",version:1,method:"POST"})}async delete(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"DELETE"})}async retry(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}/retry`,{api:"archon",version:1,method:"POST"})}async rename(e,t,r,n){await this.client.request(`/servers/${e}/worlds/${t}/backups/${r}`,{api:"archon",version:1,method:"PATCH",body:n})}};var I=class extends a{getModuleID(){return"archon_backups_queue_v1"}async list(e,t){return this.client.request(`/servers/${e}/worlds/${t}/backups-queue`,{api:"archon",version:1,method:"GET"})}async create(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/backups-queue`,{api:"archon",version:1,method:"POST",body:r})}async ackCreate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/create/${r}/ack`,{api:"archon",version:1,method:"POST"})}async cancelCreate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/create/${r}/cancel`,{api:"archon",version:1,method:"POST"})}async ackRestore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/restore/${r}/ack`,{api:"archon",version:1,method:"POST"})}async cancelRestore(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/history/restore/${r}/cancel`,{api:"archon",version:1,method:"POST"})}async delete(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}`,{api:"archon",version:1,method:"DELETE"})}async deleteMany(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/delete-many`,{api:"archon",version:1,method:"POST",body:{backup_ids:r}})}async restore(e,t,r,n){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}/restore`,{api:"archon",version:1,method:"POST",body:n})}async retry(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/backups-queue/${r}/retry`,{api:"archon",version:1,method:"POST"})}};var U=class extends a{getModuleID(){return"archon_content_v1"}async getAddons(e,t,r){let n=new URLSearchParams;r?.from_modpack!==void 0&&n.set("from_modpack",String(r.from_modpack)),r?.disabled!==void 0&&n.set("disabled",String(r.disabled)),r?.addons!==void 0&&n.set("addons",String(r.addons)),r?.updates!==void 0&&n.set("updates",String(r.updates));let s=n.toString();return this.client.request(`/servers/${e}/worlds/${t}/addons${s?`?${s}`:""}`,{api:"archon",version:1,method:"GET"})}async addAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons`,{api:"archon",version:1,method:"POST",body:r})}async addAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/install-many`,{api:"archon",version:1,method:"POST",body:r})}async deleteAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/delete`,{api:"archon",version:1,method:"POST",body:r})}async disableAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/disable`,{api:"archon",version:1,method:"POST",body:r})}async enableAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/enable`,{api:"archon",version:1,method:"POST",body:r})}async deleteAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/delete-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async disableAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/disable-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async enableAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/enable-many`,{api:"archon",version:1,method:"POST",body:{items:r}})}async installContent(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/content`,{api:"archon",version:1,method:"POST",body:r})}async repair(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/repair`,{api:"archon",version:1,method:"POST"})}async unlinkModpack(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/unlink-modpack`,{api:"archon",version:1,method:"POST"})}async getAddonUpdate(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/addons/update?filename=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"GET"})}async updateAddon(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/update`,{api:"archon",version:1,method:"POST",body:r})}async updateAddons(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/addons/update-many`,{api:"archon",version:1,method:"POST",body:{addons:r}})}async getModpackUpdate(e,t){return this.client.request(`/servers/${e}/worlds/${t}/content/modpack/update`,{api:"archon",version:1,method:"GET"})}async updateModpack(e,t){await this.client.request(`/servers/${e}/worlds/${t}/content/modpack/update`,{api:"archon",version:1,method:"POST"})}async getUpdateGameVersionPreview(e,t,r,n){return this.client.request(`/servers/${e}/worlds/${t}/content/update-game-version?game_version=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"GET",timeout:1e3*1e3,signal:n})}async applyGameVersionUpdate(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/content/update-game-version?game_version=${encodeURIComponent(r)}`,{api:"archon",version:1,method:"POST"})}};var D=class extends a{getModuleID(){return"archon_nodes_internal"}async overview(){return this.client.request("/nodes/overview",{api:"archon",version:"internal",method:"GET"})}};var N=class extends a{getModuleID(){return"archon_notices_v0"}async list(){return this.client.request("/notices",{api:"archon",version:"modrinth/v0",method:"GET"})}async create(e){return this.client.request("/notices",{api:"archon",version:"modrinth/v0",method:"POST",body:e})}async update(e,t){await this.client.request(`/notices/${e}`,{api:"archon",version:"modrinth/v0",method:"PATCH",body:t})}async delete(e){await this.client.request(`/notices/${e}`,{api:"archon",version:"modrinth/v0",method:"DELETE"})}async assign(e,t){await this.client.request(`/notices/${e}/assign`,{api:"archon",version:"modrinth/v0",method:"PUT",params:this.assignmentTargetToParams(t)})}async unassign(e,t){await this.client.request(`/notices/${e}/unassign`,{api:"archon",version:"modrinth/v0",method:"PUT",params:this.assignmentTargetToParams(t)})}assignmentTargetToParams(e){return"server"in e?{server:e.server}:{node:e.node}}};var j=class extends a{getModuleID(){return"archon_options_v1"}async getStartup(e,t){return this.client.request(`/servers/${e}/worlds/${t}/options/startup`,{api:"archon",version:1,method:"GET"})}async patchStartup(e,t,r){await this.client.request(`/servers/${e}/worlds/${t}/options/startup`,{api:"archon",version:1,method:"PATCH",body:r})}};var B=class extends a{getModuleID(){return"archon_properties_v1"}async getProperties(e,t){return this.client.request(`/servers/${e}/worlds/${t}/properties`,{api:"archon",version:1,method:"GET"})}async patchProperties(e,t,r){return this.client.request(`/servers/${e}/worlds/${t}/properties`,{api:"archon",version:1,method:"PATCH",body:r})}};var F=class extends a{getModuleID(){return"archon_server_users_v1"}async list(e){return this.client.request(`/servers/${e}/users`,{api:"archon",version:1,method:"GET"})}async add(e,t){await this.client.request(`/servers/${e}/users`,{api:"archon",version:1,method:"POST",body:t})}async reinvite(e,t){return this.client.request(`/servers/${e}/users/${t}/reinvite`,{api:"archon",version:1,method:"POST"})}async delete(e,t){await this.client.request(`/servers/${e}/users/${t}`,{api:"archon",version:1,method:"DELETE"})}async update(e,t,r){await this.client.request(`/servers/${e}/users/${t}`,{api:"archon",version:1,method:"PATCH",body:JSON.stringify(r)})}};var G=class extends a{getModuleID(){return"archon_servers_v0"}async get(e){return this.client.request(`/servers/${e}`,{api:"archon",method:"GET",version:"modrinth/v0"})}async list(e){let t=new URLSearchParams;e?.limit&&t.set("limit",e.limit.toString()),e?.offset&&t.set("offset",e.offset.toString());let r=t.toString()?`?${t.toString()}`:"";return this.client.request(`servers${r}`,{api:"archon",method:"GET",version:"modrinth/v0"})}async checkStock(e,t){return this.client.request(`/stock?region=${e}`,{api:"archon",version:"modrinth/v0",method:"POST",body:t,skipAuth:!0})}async checkStockGlobal(e){return this.client.request("/stock",{api:"archon",version:"modrinth/v0",method:"POST",body:e,skipAuth:!0})}async getFilesystemAuth(e){return this.client.request(`/servers/${e}/fs`,{api:"archon",version:"modrinth/v0",method:"GET"})}async getWebSocketAuth(e){return this.client.request(`/servers/${e}/ws`,{api:"archon",version:"modrinth/v0",method:"GET"})}async power(e,t){await this.client.request(`/servers/${e}/power`,{api:"archon",method:"POST",version:"modrinth/v0",body:{action:t}})}async reinstall(e,t,r=!1){await this.client.request(`/servers/${e}/reinstall`,{api:"archon",method:"POST",version:"modrinth/v0",params:{hard:String(r)},body:t})}async getReinstallMrpackAuth(e){return this.client.request(`/servers/${e}/reinstallFromMrpack`,{api:"archon",version:"modrinth/v0",method:"GET"})}async reinstallFromMrpack(e,t,r=!1,n){let s=await this.getReinstallMrpackAuth(e),o=new FormData;return o.append("file",t),this.client.upload("",{api:`https://${s.url}`,version:"reinstallMrpackMultiparted",formData:o,params:{hard:String(r)},headers:{Authorization:`Bearer ${s.token}`},skipAuth:!0,onProgress:n?.onProgress,retry:!1})}async updateName(e,t){await this.client.request(`/servers/${e}/name`,{api:"archon",method:"POST",version:"modrinth/v0",body:{name:t}})}async getAllocations(e){return this.client.request(`/servers/${e}/allocations`,{api:"archon",method:"GET",version:"modrinth/v0"})}async reserveAllocation(e,t){return this.client.request(`/servers/${e}/allocations`,{api:"archon",method:"POST",version:"modrinth/v0",params:{name:t}})}async updateAllocation(e,t,r){await this.client.request(`/servers/${e}/allocations/${t}`,{api:"archon",method:"PUT",version:"modrinth/v0",params:{name:r}})}async deleteAllocation(e,t){await this.client.request(`/servers/${e}/allocations/${t}`,{api:"archon",method:"DELETE",version:"modrinth/v0"})}async checkSubdomainAvailability(e){return this.client.request(`/subdomains/${e}/isavailable`,{api:"archon",method:"GET",version:"modrinth/v0"})}async changeSubdomain(e,t){await this.client.request(`/servers/${e}/subdomain`,{api:"archon",method:"POST",version:"modrinth/v0",body:{subdomain:t}})}async getStartupConfig(e){return this.client.request(`/servers/${e}/startup`,{api:"archon",method:"GET",version:"modrinth/v0"})}async updateStartupConfig(e,t){await this.client.request(`/servers/${e}/startup`,{api:"archon",method:"POST",version:"modrinth/v0",body:t})}async dismissNotice(e,t){await this.client.request(`/servers/${e}/notices/${t}/dismiss`,{api:"archon",method:"POST",version:"modrinth/v0"})}};var W=class extends a{getModuleID(){return"archon_servers_v1"}async list(){return this.client.request("/servers",{api:"archon",version:1,method:"GET"})}async get(e){return this.client.request(`/servers/${e}`,{api:"archon",version:1,method:"GET"})}async getRegions(){return this.client.request("/regions",{api:"archon",version:1,method:"GET",skipAuth:!0})}async endIntro(e){await this.client.request(`/servers/${e}/flows/intro`,{api:"archon",version:1,method:"DELETE"})}async resetToOnboarding(e,t){await this.client.request(`/servers/${e}/worlds/${t}/onboard`,{api:"archon",version:1,method:"POST"})}};var V=class extends a{getModuleID(){return"archon_transfers_internal"}async scheduleServers(e){return this.client.request("/transfers/schedule/servers",{api:"archon",version:"internal",method:"POST",body:e})}async scheduleNodes(e){return this.client.request("/transfers/schedule/nodes",{api:"archon",version:"internal",method:"POST",body:e})}async history(e){let t={};return e?.page!==void 0&&(t.page=e.page),e?.page_size!==void 0&&(t.page_size=e.page_size),this.client.request("/transfers/history",{api:"archon",version:"internal",method:"GET",params:t})}async cancel(e){return this.client.request("/transfers/cancel",{api:"archon",version:"internal",method:"POST",body:e})}};import{$fetch as Ye}from"ofetch";var Ze="https://raw.githubusercontent.com/ipregistry/iso3166/master";function et(i){let e=i.trim().split(`
2
+ `).filter(n=>n.trim()!=="");if(e.length===0)return[];let t=e[0],r=(t.startsWith("#")?t.slice(1):t).split(",");return e.slice(1).map(n=>{let s=n.split(","),o={};return r.forEach((c,l)=>{o[c]=s[l]||""}),o})}var H=class extends a{getModuleID(){return"iso3166_data"}async build(){try{let[e,t]=await Promise.all([Ye(`${Ze}/countries.csv`,{responseType:"text"}),Ye(`${Ze}/subdivisions.csv`,{responseType:"text"})]),r=et(e),n=et(t),s=r.map(c=>({alpha2:c.country_code_alpha2,alpha3:c.country_code_alpha3,numeric:c.numeric_code,nameShort:c.name_short,nameLong:c.name_long})),o=n.reduce((c,l)=>{let u=l.country_code_alpha2;return!u||typeof u!="string"||u.trim()===""||(c[u]||(c[u]=[]),c[u].push({code:l["subdivision_code_iso3166-2"],name:l.subdivision_name,localVariant:l.localVariant||null,category:l.category,parent:l.parent_subdivision||null,language:l.language_code})),c},{});return{countries:s,subdivisions:o}}catch(e){return console.error("Error fetching ISO3166 data:",e),{countries:[],subdivisions:{}}}}};var z=class extends a{getModuleID(){return"kyros_content_v1"}uploadAddonFile(e,t,r){let n=new FormData;for(let s of t)n.append("file",s,s instanceof File?s.name:"file");return this.client.upload(`/worlds/${e}/content/upload-addon-file`,{api:"",version:"v1",formData:n,onProgress:r?.onProgress,useNodeAuth:!0})}uploadModpackFile(e,t,r,n){let s=new FormData;return s.append("file",t,t instanceof File?t.name:"file"),s.append("properties",JSON.stringify(r)),this.client.upload(`/worlds/${e}/content/upload-modpack-file`,{api:"",version:"v1",formData:s,params:n?.softOverride!==void 0?{soft_override:String(n.softOverride)}:void 0,onProgress:n?.onProgress,useNodeAuth:!0})}};var mt=/\/modrinth\/v\d+\/fs\/?$/,gt=/^https?:\/\//i,bt=/^wss?:\/\//i,tt=/^https:\/\//i,rt=/^http:\/\//i;function K(i){let e=i.replace(mt,"");return gt.test(e)?e:`https://${e}`}function Ne(i){return bt.test(i)?i:tt.test(i)?i.replace(tt,"wss://"):rt.test(i)?i.replace(rt,"ws://"):`wss://${i}`}var J=class extends a{getModuleID(){return"kyros_files_v0"}getNodeBaseUrl(e){return K(e.url)}async listDirectory(e,t=1,r=100){return this.client.request("/fs/list",{api:"",version:"modrinth/v0",method:"GET",params:{path:e,page:t,page_size:r},useNodeAuth:!0})}async createFileOrFolder(e,t){return this.client.request("/fs/create",{api:"",version:"modrinth/v0",method:"POST",params:{path:e,type:t},headers:{"Content-Type":"application/octet-stream"},useNodeAuth:!0})}async downloadFile(e){return this.client.request("/fs/download",{api:"",version:"modrinth/v0",method:"GET",params:{path:e},useNodeAuth:!0})}async downloadFileWithAuth(e,t){return this.client.request("/fs/download",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",method:"GET",params:{path:t},headers:{Authorization:`Bearer ${e.token}`},skipAuth:!0})}uploadFile(e,t,r){return this.client.upload("/fs/create",{api:"",version:"modrinth/v0",file:t,params:{path:e,type:"file"},onProgress:r?.onProgress,retry:r?.retry,useNodeAuth:!0})}uploadFileWithAuth(e,t,r,n){return this.client.upload("/fs/create",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",file:r,params:{path:t,type:"file"},headers:{Authorization:`Bearer ${e.token}`},onProgress:n?.onProgress,retry:n?.retry,skipAuth:!0})}async updateFile(e,t){let r=typeof t=="string"?new Blob([t]):t;return this.client.request("/fs/update",{api:"",version:"modrinth/v0",method:"PUT",params:{path:e},body:r,headers:{"Content-Type":"application/octet-stream"},useNodeAuth:!0})}async moveFileOrFolder(e,t){return this.client.request("/fs/move",{api:"",version:"modrinth/v0",method:"POST",body:{source:e,destination:t},useNodeAuth:!0})}async renameFileOrFolder(e,t){let r=e.split("/").slice(0,-1).join("/")+"/"+t;return this.moveFileOrFolder(e,r)}async deleteFileOrFolder(e,t){return this.client.request("/fs/delete",{api:"",version:"modrinth/v0",method:"DELETE",params:{path:e,recursive:t},useNodeAuth:!0})}async deleteFileOrFolderWithAuth(e,t,r){return this.client.request("/fs/delete",{api:this.getNodeBaseUrl(e),version:"modrinth/v0",method:"DELETE",params:{path:t,recursive:r},headers:{Authorization:`Bearer ${e.token}`},skipAuth:!0})}async extractFile(e,t=!0,r=!1){return this.client.request("/fs/unarchive",{api:"",version:"v1",method:"POST",params:{src:e,trg:"/",override:t,dry:r},useNodeAuth:!0})}async modifyOperation(e,t){return this.client.request(`/fs/ops/${t}`,{api:"",version:"v1",method:"POST",params:{id:e},useNodeAuth:!0})}};var Q=class extends a{getModuleID(){return"kyros_logs_v1"}async clear(){return this.client.request("/logs/clear",{api:"",version:"v1",method:"POST",useNodeAuth:!0})}};var X=class extends a{getModuleID(){return"kyros_upload_sessions_v1"}async create(e,t){return this.client.request(`/worlds/${t}/files/upload-session`,{api:"",version:"v1",method:"POST",useNodeAuth:!0})}async get(e,t){return this.client.request(`/worlds/${t}/files/upload-session`,{api:"",version:"v1",method:"GET",useNodeAuth:!0})}uploadFiles(e,t,r,n,s){let o=new FormData;for(let{file:c,filename:l}of n)o.append("file",c,l);return this.client.upload(`/worlds/${t}/files/upload-session/${r}/files`,{api:"",version:"v1",formData:o,onProgress:s?.onProgress,retry:s?.retry,useNodeAuth:!0})}async finalize(e,t,r){return this.client.request(`/worlds/${t}/files/upload-session/${r}/finalize`,{api:"",version:"v1",method:"POST",useNodeAuth:!0})}async cancel(e,t,r){return this.client.request(`/worlds/${t}/files/upload-session/${r}`,{api:"",version:"v1",method:"DELETE",useNodeAuth:!0})}};var Y=class extends a{getModuleID(){return"labrinth_analytics_v3"}async fetch(e){return this.client.request("/analytics",{api:"labrinth",version:3,method:"POST",body:e,timeout:100*1e3})}async fetchFacets(e){return this.client.request("/analytics/facets",{api:"labrinth",version:3,method:"POST",body:e,timeout:100*1e3})}async getEvents(){return this.client.request("/analytics-event",{api:"labrinth",version:3,method:"GET"})}async createEvent(e){return this.client.request("/analytics-event",{api:"labrinth",version:3,method:"POST",body:e})}async editEvent(e,t){return this.client.request(`/analytics-event/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteEvent(e){return this.client.request(`/analytics-event/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var vt="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function nt(i){let e=0;for(let t of i){let r=vt.indexOf(t);if(r<0)throw new Error(`Invalid base62 character "${t}" in id "${i}"`);if(e=e*62+r,!Number.isSafeInteger(e))throw new Error(`Base62 id "${i}" exceeds safe integer range`)}return e}var Z=class extends a{getModuleID(){return"labrinth_attribution_internal"}async listProjectAttribution(e){return this.client.request(`/attribution/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async updateGroup(e,t){let r=nt(e);return this.client.request(`/attribution/group/${r}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async assignFileToGroup(e){let t={sha1:e.sha1,target_group_id:nt(e.target_group_id),project_id:e.project_id};return this.client.request("/attribution/assign",{api:"labrinth",version:"internal",method:"POST",body:t})}async splitFile(e){return this.client.request("/attribution/split",{api:"labrinth",version:"internal",method:"POST",body:e})}};var ee=class extends a{getModuleID(){return"labrinth_auth_internal"}async getNewsletterStatus(){return this.client.request("/auth/email/subscribe",{api:"labrinth",version:"internal",method:"GET"})}async subscribeNewsletter(){return this.client.request("/auth/email/subscribe",{api:"labrinth",version:"internal",method:"POST"})}async createDiscordCommunityLink(){return this.client.request("/auth/discord-community-link",{api:"labrinth",version:"internal",method:"POST"})}};var te=class extends a{getModuleID(){return"labrinth_auth_v2"}async login(e){return this.client.request("/auth/login",{api:"labrinth",version:2,method:"POST",body:e})}async login2FA(e){return this.client.request("/auth/login/2fa",{api:"labrinth",version:2,method:"POST",body:e})}async createAccount(e){return this.client.request("/auth/create",{api:"labrinth",version:2,method:"POST",body:e})}async validateCreateAccount(e){return this.client.request("/auth/create/validate",{api:"labrinth",version:2,method:"POST",body:e})}async createOAuthAccount(e){return this.client.request("/auth/create/oauth",{api:"labrinth",version:2,method:"POST",body:e})}async resetPasswordBegin(e){return this.client.request("/auth/password/reset",{api:"labrinth",version:2,method:"POST",body:e})}async changePassword(e){return this.client.request("/auth/password",{api:"labrinth",version:2,method:"PATCH",body:e})}async listPasskeys(){return this.client.request("/auth/passkey",{api:"labrinth",version:2,method:"GET"})}async registerPasskeyStart(){return this.client.request("/auth/passkey/register/start",{api:"labrinth",version:2,method:"POST"})}async registerPasskeyFinish(e){return this.client.request("/auth/passkey/register/finish",{api:"labrinth",version:2,method:"POST",body:e})}async authenticatePasskeyStart(){return this.client.request("/auth/passkey/start",{api:"labrinth",version:2,method:"POST",skipAuth:!0})}async authenticatePasskeyFinish(e){return this.client.request("/auth/passkey/finish",{api:"labrinth",version:2,method:"POST",body:e,skipAuth:!0})}async renamePasskey(e,t){return this.client.request(`/auth/passkey/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}async deletePasskey(e){return this.client.request(`/auth/passkey/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var re=class extends a{getModuleID(){return"labrinth_billing_internal"}async getSubscriptions(e){let t=e?`?user_id=${e}`:"";return this.client.request(`/billing/subscriptions${t}`,{api:"labrinth",version:"internal",method:"GET"})}async getProducts(){return this.client.request("/billing/products",{api:"labrinth",version:"internal",method:"GET"})}async getCustomer(){return this.client.request("/billing/customer",{api:"labrinth",version:"internal",method:"GET"})}async editSubscription(e,t,r){let n=r?"?dry=true":"";return this.client.request(`/billing/subscription/${e}${n}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async getPaymentMethods(){return this.client.request("/billing/payment_methods",{api:"labrinth",version:"internal",method:"GET"})}async addPaymentMethodFlow(){return this.client.request("/billing/payment_method",{api:"labrinth",version:"internal",method:"POST"})}async editPaymentMethod(e,t){return this.client.request(`/billing/payment_method/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async removePaymentMethod(e){return this.client.request(`/billing/payment_method/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async getPayments(e){let t=e?`?user_id=${e}`:"";return this.client.request(`/billing/payments${t}`,{api:"labrinth",version:"internal",method:"GET"})}async initiatePayment(e){return this.client.request("/billing/payment",{api:"labrinth",version:"internal",method:"POST",body:e})}async refundCharge(e,t){return this.client.request(`/billing/charge/${e}/refund`,{api:"labrinth",version:"internal",method:"POST",body:t})}async credit(e){return this.client.request("/billing/credit",{api:"labrinth",version:"internal",method:"POST",body:e})}};var ne=class extends a{getModuleID(){return"labrinth_collections"}async get(e){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request("/collections",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async edit(e,t){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async delete(e){return this.client.request(`/collection/${e}`,{api:"labrinth",version:3,method:"DELETE"})}async editIcon(e,t,r){return this.client.request(`/collection/${e}/icon?ext=${r}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteIcon(e){return this.client.request(`/collection/${e}/icon`,{api:"labrinth",version:3,method:"DELETE"})}};var ie=class extends a{getModuleID(){return"labrinth_external_projects_internal"}async search(e){return this.client.request("/moderation/external-license/search",{api:"labrinth",version:"internal",method:"POST",body:e})}async getBySha1(e){return this.client.request(`/moderation/external-license/by-sha1/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async update(e,t){return this.client.request(`/moderation/external-license/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async addFile(e){return this.client.request("/moderation/external-license/file",{api:"labrinth",version:"internal",method:"POST",body:e})}};var se=class extends a{getModuleID(){return"labrinth_friends_v3"}async list(){return this.client.request("/friends",{api:"labrinth",version:3,method:"GET"})}async add(e){return this.client.request(`/friend/${encodeURIComponent(e)}`,{api:"labrinth",version:3,method:"POST"})}async remove(e){return this.client.request(`/friend/${encodeURIComponent(e)}`,{api:"labrinth",version:3,method:"DELETE"})}};var oe=class extends a{getModuleID(){return"labrinth_globals_internal"}async get(){return this.client.request("/globals",{api:"labrinth",version:"internal",method:"GET",skipAuth:!0})}};function yt(i,e){let t={ext:i,context:e.context};switch(e.context){case"project":t.project_id=e.project_id;break;case"version":t.version_id=e.version_id;break;case"thread_message":t.thread_message_id=e.thread_message_id;break;case"report":t.report_id=e.report_id;break}return t}var ae=class extends a{getModuleID(){return"labrinth_images_v3"}uploadImage(e,t,r){return this.client.upload("/image",{api:"labrinth",version:3,file:e,params:yt(t,r)})}};var ce=class extends a{getModuleID(){return"labrinth_limits_v3"}async getProjectLimits(){return this.client.request("/limits/projects",{api:"labrinth",version:3,method:"GET"})}async getOrganizationLimits(){return this.client.request("/limits/organizations",{api:"labrinth",version:3,method:"GET"})}async getCollectionLimits(){return this.client.request("/limits/collections",{api:"labrinth",version:3,method:"GET"})}};var le=class extends a{getModuleID(){return"labrinth_moderation_internal"}async acquireLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"POST"})}async overrideLock(e){return this.client.request(`/moderation/lock/${e}/override`,{api:"labrinth",version:"internal",method:"POST"})}async releaseLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async checkLock(e){return this.client.request(`/moderation/lock/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async setProjectJudgements(e){return this.client.request("/moderation/project",{api:"labrinth",version:"internal",method:"POST",body:e})}};var ue=class extends a{getModuleID(){return"labrinth_notifications_v2"}async getUserNotifications(e){return this.client.request(`/user/${e}/notifications`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request(`/notifications?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:2,method:"GET"})}async markAsRead(e){return this.client.request(`/notification/${e}`,{api:"labrinth",version:2,method:"PATCH"})}async markMultipleAsRead(e){return this.client.request("/notifications",{api:"labrinth",version:2,method:"PATCH",params:{ids:JSON.stringify([...new Set(e)])}})}async delete(e){return this.client.request(`/notification/${e}`,{api:"labrinth",version:2,method:"DELETE"})}async deleteMultiple(e){return this.client.request("/notifications",{api:"labrinth",version:2,method:"DELETE",params:{ids:JSON.stringify([...new Set(e)])}})}};var pe=class extends a{getModuleID(){return"labrinth_oauth_internal"}async getUserApps(e){return this.client.request(`/user/${e}/oauth_apps`,{api:"labrinth",version:3,method:"GET"})}async getApp(e){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async getApps(e){return this.client.request(`/oauth/apps?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:"internal",method:"GET"})}async createApp(e){return this.client.request("/oauth/app",{api:"labrinth",version:"internal",method:"POST",body:e})}async editApp(e,t){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async deleteApp(e){return this.client.request(`/oauth/app/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}uploadAppIcon(e,t,r){return this.client.upload(`/oauth/app/${e}/icon`,{api:"labrinth",version:"internal",file:t,params:{ext:r}})}async getAuthorizations(){return this.client.request("/oauth/authorizations",{api:"labrinth",version:"internal",method:"GET"})}async revokeAuthorization(e){return this.client.request("/oauth/authorizations",{api:"labrinth",version:"internal",method:"DELETE",params:{client_id:e}})}async authorize(e){return this.client.request("/oauth/authorize",{api:"labrinth",version:"internal",method:"GET",params:e})}async accept(e){return this.client.request("/oauth/accept",{api:"labrinth",version:"internal",method:"POST",body:e})}async reject(e){return this.client.request("/oauth/reject",{api:"labrinth",version:"internal",method:"POST",body:e})}};var de=class extends a{getModuleID(){return"labrinth_organizations_v3"}async get(e){return this.client.request(`/organization/${e}`,{api:"labrinth",version:3,method:"GET"})}async getProjects(e){return this.client.request(`/organization/${e}/projects`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request(`/organizations?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async addProject(e,t){return this.client.request(`/organization/${e}/projects`,{api:"labrinth",version:3,method:"POST",body:t})}async removeProject(e,t,r){return this.client.request(`/organization/${e}/projects/${t}`,{api:"labrinth",version:3,method:"DELETE",body:r})}};var he=class extends a{getModuleID(){return"labrinth_pats_v2"}async list(){return this.client.request("/pat",{api:"labrinth",version:2,method:"GET"})}async create(e){return this.client.request("/pat",{api:"labrinth",version:2,method:"POST",body:e})}async modify(e,t){return this.client.request(`/pat/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}async delete(e){return this.client.request(`/pat/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var me=class extends a{getModuleID(){return"labrinth_payout_v3"}async getBalance(){let e=await this.client.request("/payout/balance",{api:"labrinth",version:3,method:"GET"});return{...e,available:Number(e.available),withdrawn_lifetime:Number(e.withdrawn_lifetime),withdrawn_ytd:Number(e.withdrawn_ytd),pending:Number(e.pending),dates:Object.fromEntries(Object.entries(e.dates).map(([t,r])=>[t,Number(r)]))}}async getHistory(){return(await this.client.request("/payout/history",{api:"labrinth",version:3,method:"GET"})).map(t=>t.type==="withdrawal"?{...t,amount:Number(t.amount),fee:t.fee===null?null:Number(t.fee)}:{...t,amount:Number(t.amount)})}async getMethods(e){return this.client.request("/payout/methods",{api:"labrinth",version:3,method:"GET",params:e?{country:e}:void 0})}async cancel(e){return this.client.request(`/payout/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var ge=class extends a{getModuleID(){return"labrinth_payouts_v3"}async getPlatformRevenue(e){return this.client.request("/payout/platform_revenue",{api:"labrinth",version:3,method:"GET",params:e})}};var be=class extends a{getModuleID(){return"labrinth_projects_v2"}async get(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"GET"})}async check(e){let t=encodeURIComponent(e);return this.client.request(`/project/${t}/check`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request("/projects",{api:"labrinth",version:2,method:"GET",params:{ids:JSON.stringify(e)}})}async search(e){return this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{...e,facets:e.facets?JSON.stringify(e.facets):void 0,new_filters:e.new_filters??void 0}})}async edit(e,t){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}async delete(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:2,method:"DELETE"})}async getDependencies(e){return this.client.request(`/project/${e}/dependencies`,{api:"labrinth",version:2,method:"GET"})}async createGalleryImage(e,t,r){let n={ext:r.ext,featured:String(r.featured)};return r.title&&(n.title=r.title),r.description&&(n.description=r.description),r.ordering!==void 0&&(n.ordering=String(r.ordering)),this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"POST",params:n,body:t})}async editGalleryImage(e,t,r){let n={url:t,featured:String(r.featured)};return r.title&&(n.title=r.title),r.description&&(n.description=r.description),r.ordering!==void 0&&(n.ordering=String(r.ordering)),this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"PATCH",params:n})}async deleteGalleryImage(e,t){return this.client.request(`/project/${e}/gallery`,{api:"labrinth",version:2,method:"DELETE",params:{url:t}})}async getRandom(e){return this.client.request("/projects_random",{api:"labrinth",version:2,method:"GET",params:{count:String(e)}})}async bulkEdit(e,t){return this.client.request("/projects",{api:"labrinth",version:2,method:"PATCH",params:{ids:JSON.stringify(e)},body:t})}};function je(i){if(typeof i!="object"||i===null)return!1;let e=i;return typeof e.error=="string"&&typeof e.description=="string"}var h=class i extends Error{constructor(e,t){super(e),this.name="ModrinthApiError",this.statusCode=t?.statusCode,this.originalError=t?.originalError,this.responseData=t?.responseData,this.context=t?.context,Error.captureStackTrace&&Error.captureStackTrace(this,i)}static fromUnknown(e,t){return e instanceof i?e:e instanceof Error?new i(e.message,{originalError:e,context:t}):new i(String(e),{context:t})}},x=class i extends h{constructor(e,t){let r=e;t?.v1Error&&(r=`[${t.v1Error.error}] ${t.v1Error.description}`,t.v1Error.context&&(r=`${t.v1Error.context}: ${r}`)),super(r,t),this.name="ModrinthServerError",this.v1Error=t?.v1Error,Error.captureStackTrace&&Error.captureStackTrace(this,i)}static fromResponse(e,t,r){let n=je(t)?t:void 0,s=`HTTP ${e}`;return n?s=n.description:typeof t=="string"&&(s=t),new i(s,{statusCode:e,responseData:t,context:r,v1Error:n})}static fromUnknown(e,t){return e instanceof i?e:e instanceof h?new i(e.message,{statusCode:e.statusCode,originalError:e.originalError,responseData:e.responseData,context:t??e.context}):e instanceof Error?new i(e.message,{originalError:e,context:t}):new i(String(e),{context:t})}};var ve=class extends a{getModuleID(){return"labrinth_projects_v3"}async get(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"GET"})}async getDependencies(e){return this.client.request(`/project/${e}/dependencies`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request("/projects",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async edit(e,t){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async getOrganization(e){try{return await this.client.request(`/project/${e}/organization`,{api:"labrinth",version:3,method:"GET"})}catch(t){if(t instanceof h&&t.statusCode===404)return null;throw t}}async getMembers(e){return this.client.request(`/project/${e}/members`,{api:"labrinth",version:3,method:"GET"})}async createServerProject(e){return this.client.request("/project",{api:"labrinth",version:3,method:"PUT",body:e})}async deleteProject(e){return this.client.request(`/project/${e}`,{api:"labrinth",version:3,method:"DELETE"})}async changeIcon(e,t,r){return this.client.request(`/project/${e}/icon`,{api:"labrinth",version:3,method:"PATCH",params:{ext:r},body:t})}async deleteIcon(e){return this.client.request(`/project/${e}/icon`,{api:"labrinth",version:3,method:"DELETE"})}};var ye=class extends a{getModuleID(){return"labrinth_reports_v3"}async get(e){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"GET"})}async list(e){let t={};return e?.count!=null&&(t.count=String(e.count)),e?.offset!=null&&(t.offset=String(e.offset)),e?.all!=null&&(t.all=String(e.all)),this.client.request("/report",{api:"labrinth",version:3,method:"GET",params:Object.keys(t).length>0?t:void 0})}async getMultiple(e){return this.client.request(`/reports?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async create(e){return this.client.request("/report",{api:"labrinth",version:3,method:"POST",body:e})}async edit(e,t){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async delete(e){return this.client.request(`/report/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var fe=class extends a{getModuleID(){return"labrinth_server_ping_internal"}async pingMinecraftJava(e){return this.client.request("/server-ping/minecraft-java",{api:"labrinth",version:"internal",method:"POST",body:e})}};var Pe=class extends a{getModuleID(){return"labrinth_sessions_v2"}async list(){return this.client.request("/session/list",{api:"labrinth",version:2,method:"GET"})}async delete(e){return this.client.request(`/session/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var Ae=class extends a{getModuleID(){return"labrinth_state"}async build(){let e=[],t=(d,dt,ht)=>(console.error("Error fetching state data:",d),e.push({endpoint:ht,error:d}),dt),[r,n,s,o,c,l,u,p,m,g,b,O,v]=await Promise.all([this.client.request("/tag/category",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/category")),this.client.request("/tag/loader",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/loader")),this.client.request("/tag/game_version",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/game_version")),this.client.request("/tag/donation_platform",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/donation_platform")),this.client.request("/tag/report_type",{api:"labrinth",version:2,method:"GET"}).catch(d=>t(d,[],"/v2/tag/report_type")),this.client.request("/projects_random",{api:"labrinth",version:2,method:"GET",params:{count:"60"}}).catch(d=>t(d,[],"/v2/projects_random")),this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{limit:"3",query:"leave",index:"relevance"}}).catch(d=>t(d,{},"/v2/search")),this.client.request("/search",{api:"labrinth",version:2,method:"GET",params:{limit:"3",query:"",index:"updated"}}).catch(d=>t(d,{},"/v2/search")),this.client.labrinth.billing_internal.getProducts().catch(d=>t(d,[],"/_internal/billing/products")),this.client.request("/mural/bank-details",{api:"labrinth",version:"internal",method:"GET"}).catch(d=>t(d,null,"/_internal/mural/bank-details")),this.client.iso3166.data.build().catch(d=>t(d,{countries:[],subdivisions:{}},"iso3166/data")),this.client.request("/payout/methods",{api:"labrinth",version:3,method:"GET"}).catch(d=>t(d,[],"/v3/payout/methods")),this.client.request("/globals",{api:"labrinth",version:"internal",method:"GET"}).catch(d=>t(d,null,"/_internal/globals"))]),R=Object.fromEntries(O.filter(d=>d.type==="tremendous").map(d=>[d.id,{name:d.name,image_url:d.image_logo_url}]));return{categories:r,loaders:n,gameVersions:s,donationPlatforms:o,reportTypes:c,homePageProjects:l,homePageSearch:u,homePageNotifs:p,products:m,muralBankDetails:g?.bankDetails,tremendousIdMap:R,countries:b.countries,subdivisions:b.subdivisions,taxComplianceThresholds:v?.tax_compliance_thresholds,errors:e}}};var Se=class extends a{getModuleID(){return"labrinth_tech_review_internal"}async searchProjects(e){return this.client.request("/moderation/tech-review/search",{api:"labrinth",version:"internal",method:"POST",body:e})}async getReport(e){return this.client.request(`/moderation/tech-review/report/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async getIssue(e){return this.client.request(`/moderation/tech-review/issue/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async updateIssueDetail(e,t){return this.client.request(`/moderation/tech-review/issue-detail/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}async submitProject(e,t){return this.client.request(`/moderation/tech-review/submit/${e}`,{api:"labrinth",version:"internal",method:"POST",body:t})}async getProjectReport(e){return this.client.request(`/moderation/tech-review/project/${e}`,{api:"labrinth",version:"internal",method:"GET"})}};var _e=class extends a{getModuleID(){return"labrinth_threads_v3"}async getThread(e){return this.client.request(`/thread/${e}`,{api:"labrinth",version:3,method:"GET"})}async getMultiple(e){return this.client.request(`/threads?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}async sendMessage(e,t){return this.client.request(`/thread/${e}`,{api:"labrinth",version:3,method:"POST",body:t})}async deleteMessage(e){return this.client.request(`/message/${e}`,{api:"labrinth",version:3,method:"DELETE"})}};var Ee=class extends a{getModuleID(){return"labrinth_users_v2"}async get(e){return this.client.request(`/user/${e}`,{api:"labrinth",version:2,method:"GET"})}async getMultiple(e){return this.client.request(`/users?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:2,method:"GET"})}async getProjects(e){return this.client.request(`/user/${e}/projects`,{api:"labrinth",version:2,method:"GET"})}async getOrganizations(e){return this.client.request(`/user/${e}/organizations`,{api:"labrinth",version:3,method:"GET"})}async getCollections(e){return this.client.request(`/user/${e}/collections`,{api:"labrinth",version:3,method:"GET"})}async getNotifications(e){return this.client.request(`/user/${e}/notifications`,{api:"labrinth",version:2,method:"GET"})}async getFollowedProjects(e){return this.client.request(`/user/${e}/follows`,{api:"labrinth",version:2,method:"GET"})}async patch(e,t){return this.client.request(`/user/${e}`,{api:"labrinth",version:2,method:"PATCH",body:t})}};var Re=class extends a{getModuleID(){return"labrinth_users_v3"}async getAuthenticated(){return this.client.request("/user",{api:"labrinth",version:3,method:"GET"})}async get(e){return this.client.request(`/user/${encodeURIComponent(e)}`,{api:"labrinth",version:3,method:"GET"})}async search(e){return this.client.request(`/users/search?query=${encodeURIComponent(e)}`,{api:"labrinth",version:3,method:"GET"})}async getAllProjects(e){return this.client.request(`/user/${encodeURIComponent(e)}/all-projects`,{api:"labrinth",version:3,method:"GET"})}};var xe=class extends a{getModuleID(){return"labrinth_versions_v2"}async getProjectVersions(e,t){let r={};return t?.game_versions?.length&&(r.game_versions=JSON.stringify(t.game_versions)),t?.loaders?.length&&(r.loaders=JSON.stringify(t.loaders)),t?.include_changelog===!1&&(r.include_changelog="false"),t?.limit!=null&&(r.limit=String(t.limit)),t?.offset!=null&&(r.offset=String(t.offset)),this.client.request(`/project/${e}/version`,{api:"labrinth",version:2,method:"GET",params:Object.keys(r).length>0?r:void 0})}async getVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"GET"})}async getVersions(e){return this.client.request("/versions",{api:"labrinth",version:2,method:"GET",params:{ids:JSON.stringify(e)}})}async getVersionFromIdOrNumber(e,t){return this.client.request(`/project/${e}/version/${t}`,{api:"labrinth",version:2,method:"GET"})}async deleteVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"DELETE"})}};var it=1800*1e3,Te=class extends a{getModuleID(){return"labrinth_versions_v3"}async getProjectVersions(e,t){let r={};return t?.game_versions?.length&&(r.game_versions=JSON.stringify(t.game_versions)),t?.loaders?.length&&(r.loaders=JSON.stringify(t.loaders)),t?.include_changelog===!1&&(r.include_changelog="false"),t?.limit!=null&&(r.limit=String(t.limit)),t?.offset!=null&&(r.offset=String(t.offset)),this.client.request(`/project/${e}/version`,{api:"labrinth",version:t?.apiVersion??2,method:"GET",params:Object.keys(r).length>0?r:void 0})}async getVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:3,method:"GET"})}async getVersions(e){return this.client.request("/versions",{api:"labrinth",version:3,method:"GET",params:{ids:JSON.stringify(e)}})}async getVersionFromIdOrNumber(e,t){return this.client.request(`/project/${e}/version/${t}`,{api:"labrinth",version:3,method:"GET"})}createVersion(e,t,r=null){let n=new FormData,s=t.map(p=>p.file),o=t.map(p=>p.fileType||null),c=s.map((p,m)=>`${p.name}-${m===0?"primary":m}`),l=c.reduce((p,m,g)=>(p[m]=o[g],p),{}),u={project_id:e.project_id,version_number:e.version_number,name:e.name||e.version_number,changelog:e.changelog,dependencies:e.dependencies||[],game_versions:e.game_versions,version_type:e.version_type,featured:!!e.featured,file_parts:c,file_types:l,primary_file:c[0],environment:e.environment,loaders:e.loaders};return r==="modpack"&&(u.mrpack_loaders=e.loaders,u.loaders=["mrpack"]),n.append("data",JSON.stringify(u)),s.forEach((p,m)=>{n.append(c[m],p,p.name)}),this.client.upload("/version",{api:"labrinth",version:3,formData:n,timeout:it})}async modifyVersion(e,t){return this.client.request(`/version/${e}`,{api:"labrinth",version:3,method:"PATCH",body:t})}async deleteVersion(e){return this.client.request(`/version/${e}`,{api:"labrinth",version:2,method:"DELETE"})}addFilesToVersion(e,t){let r=new FormData,n=t.map(l=>l.file),s=t.map(l=>l.fileType||null),o=n.map((l,u)=>`${l.name}-${u}`),c=o.reduce((l,u,p)=>(l[u]=s[p],l),{});return r.append("data",JSON.stringify({file_types:c})),n.forEach((l,u)=>{r.append(o[u],l,l.name)}),this.client.upload(`/version/${e}/file`,{api:"labrinth",version:2,formData:r,timeout:it})}};var ke=class extends a{getModuleID(){return"labrinth_affiliate_internal"}async getAll(){return this.client.request("/affiliate",{api:"labrinth",version:"internal",method:"GET"})}async create(e){return this.client.request("/affiliate",{api:"labrinth",version:"internal",method:"PUT",body:e})}async get(e){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"GET"})}async delete(e){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"DELETE"})}async patch(e,t){return this.client.request(`/affiliate/${e}`,{api:"labrinth",version:"internal",method:"PATCH",body:t})}};var we=class extends a{getModuleID(){return"labrinth_campaign_internal"}async getPride26(){return this.client.request("/campaign/pride-26",{api:"labrinth",version:"internal",method:"GET",skipAuth:!0})}};var Ce=class extends a{getModuleID(){return"labrinth_tags_v2"}async getLicenseText(e){return this.client.request(`/tag/license/${e}`,{api:"labrinth",version:2,method:"GET"})}};var Le=class extends a{getModuleID(){return"labrinth_teams_v2"}async addMember(e,t){return this.client.request(`/team/${e}/members`,{api:"labrinth",version:2,method:"POST",body:t})}async editMember(e,t,r){return this.client.request(`/team/${e}/members/${t}`,{api:"labrinth",version:2,method:"PATCH",body:r})}async removeMember(e,t){return this.client.request(`/team/${e}/members/${t}`,{api:"labrinth",version:2,method:"DELETE"})}async transferOwnership(e,t){return this.client.request(`/team/${e}/owner`,{api:"labrinth",version:2,method:"PATCH",body:t})}};var qe=class extends a{getModuleID(){return"labrinth_teams_v3"}async getMultiple(e){return this.client.request(`/teams?ids=${encodeURIComponent(JSON.stringify(e))}`,{api:"labrinth",version:3,method:"GET"})}};var ft="https://launcher-meta.modrinth.com",Oe=class extends a{getModuleID(){return"launchermeta_manifest_v0"}async getManifest(e){return this.client.request("/manifest.json",{api:ft,version:`${e}/v0`,method:"GET",skipAuth:!0,headers:{"Content-Type":""}})}};var Me=class extends a{getModuleID(){return"mclogs_insights_v1"}async analyse(e){return this.client.request("/analyse",{api:"https://api.mclo.gs",version:"1",method:"POST",body:new URLSearchParams({content:e}),headers:{"Content-Type":"application/x-www-form-urlencoded"},skipAuth:!0})}};var $e=class extends a{getModuleID(){return"mclogs_logs_v1"}async create(e){return this.client.request("/log",{api:"https://api.mclo.gs",version:"1",method:"POST",body:new URLSearchParams({content:e}),headers:{"Content-Type":"application/x-www-form-urlencoded"},skipAuth:!0})}};var st="https://fill.papermc.io",Ie=class extends a{getModuleID(){return"paper_versions_v3"}async getProject(){return this.client.request("/projects/paper",{api:st,version:"v3",method:"GET",skipAuth:!0})}async getBuilds(e){return{builds:await this.client.request(`/projects/paper/versions/${e}/builds`,{api:st,version:"v3",method:"GET",skipAuth:!0})}}};var ot="https://api.purpurmc.org",Ue=class extends a{getModuleID(){return"purpur_versions_v2"}async getProject(){return this.client.request("/purpur",{api:ot,version:"v2",method:"GET",skipAuth:!0})}async getBuilds(e){return this.client.request(`/purpur/${e}`,{api:ot,version:"v2",method:"GET",skipAuth:!0})}};var Pt={archon_actions_v1:M,archon_backups_queue_v1:I,archon_backups_v1:$,archon_content_v1:U,archon_nodes_internal:D,archon_notices_v0:N,archon_options_v1:j,archon_properties_v1:B,archon_server_users_v1:F,archon_servers_v0:G,archon_servers_v1:W,archon_transfers_internal:V,iso3166_data:H,mclogs_insights_v1:Me,mclogs_logs_v1:$e,launchermeta_manifest_v0:Oe,kyros_content_v1:z,kyros_files_v0:J,kyros_logs_v1:Q,kyros_upload_sessions_v1:X,labrinth_affiliate_internal:ke,labrinth_analytics_v3:Y,labrinth_auth_internal:ee,labrinth_auth_v2:te,labrinth_attribution_internal:Z,labrinth_billing_internal:re,labrinth_campaign_internal:we,labrinth_collections:ne,labrinth_external_projects_internal:ie,labrinth_friends_v3:se,labrinth_globals_internal:oe,labrinth_images_v3:ae,labrinth_moderation_internal:le,labrinth_notifications_v2:ue,labrinth_oauth_internal:pe,labrinth_organizations_v3:de,labrinth_pats_v2:he,labrinth_limits_v3:ce,labrinth_payout_v3:me,labrinth_payouts_v3:ge,labrinth_projects_v2:be,labrinth_projects_v3:ve,labrinth_reports_v3:ye,labrinth_server_ping_internal:fe,labrinth_sessions_v2:Pe,labrinth_state:Ae,labrinth_tags_v2:Ce,labrinth_teams_v2:Le,labrinth_teams_v3:qe,labrinth_tech_review_internal:Se,labrinth_threads_v3:_e,labrinth_users_v2:Ee,labrinth_users_v3:Re,labrinth_versions_v2:xe,labrinth_versions_v3:Te,paper_versions_v3:Ie,purpur_versions_v2:Ue};function At(i){let e=i.split("_");if(e.length<2)throw new Error(`Invalid module ID "${i}". Expected format: <api>_<module> (e.g., "labrinth_projects_v2")`);let t=e[0],r=e.slice(1).join("_");return[t,r]}function at(){let i={};for(let[e,t]of Object.entries(Pt)){let[r,n]=At(e);i[r]||(i[r]={}),i[r][n]=t}return i}var T=class{};var k=class extends T{constructor(t){super();this._moduleInstances=new Map;this._moduleNamespaces=new Map;this.config={timeout:1e4,labrinthBaseUrl:"https://api.modrinth.com",archonBaseUrl:"https://archon.modrinth.com",...t},this.features=t.features??[],this.initializeModules()}initializeModules(){let t=at();for(let[r,n]of Object.entries(t)){let s={};for(let[o,c]of Object.entries(n)){let l=`${r}_${o}`;Object.defineProperty(s,o,{get:()=>{if(!this._moduleInstances.has(l)){let u=new c(this),p=u.getModuleID();if(p!==l)throw new Error(`Module ID mismatch: registry expects "${l}" but module declares "${p}"`);this._moduleInstances.set(l,u)}return this._moduleInstances.get(l)},enumerable:!0,configurable:!1})}Object.defineProperty(this,r,{value:s,writable:!1,enumerable:!0,configurable:!1}),this._moduleNamespaces.set(r,s)}}async request(t,r){let n;r.api==="labrinth"?n=this.resolveBaseUrl(this.config.labrinthBaseUrl):r.api==="archon"?n=this.resolveBaseUrl(this.config.archonBaseUrl):n=r.api;let s=this.buildUrl(t,n,r.version),o=await this.buildDefaultHeaders(),c={method:"GET",timeout:this.config.timeout,...r,headers:{...o,...r.headers}};this.attachArchonSentryCaptureHeader(c);let l=c.headers;l&&"Content-Type"in l&&l["Content-Type"]===""&&delete l["Content-Type"];let u=this.buildContext(s,t,c);try{let p=await this.executeFeatureChain(u);return await this.config.hooks?.onResponse?.(p,u),p}catch(p){let m=this.normalizeError(p,u);throw await this.config.hooks?.onError?.(m,u),m}}async stream(t,r){let n;r.api==="labrinth"?n=this.resolveBaseUrl(this.config.labrinthBaseUrl):r.api==="archon"?n=this.resolveBaseUrl(this.config.archonBaseUrl):n=r.api;let s=this.buildUrl(t,n,r.version),o=await this.buildDefaultHeaders(),c={method:"GET",retry:!1,circuitBreaker:!1,...r,headers:{...o,Accept:"text/event-stream",...r.headers}};this.attachArchonSentryCaptureHeader(c);let l=this.buildContext(s,t,c);try{return await this.executeFeatureChain(l,()=>this.executeStreamRequest(l.url,l.options))}catch(u){let p=this.normalizeError(u,l);throw await this.config.hooks?.onError?.(p,l),p}}async executeFeatureChain(t,r=()=>this.executeRequest(t.url,t.options)){let n=this.features.filter(c=>c.shouldApply(t)),s=n.length,o=async()=>(s--,s>=0?n[s].execute(o,t):(await this.config.hooks?.onRequest?.(t),r()));return o()}async executeUploadFeatureChain(t,r,n){let s=this.features.filter(l=>l.shouldApply(t)),o=s.length,c=async()=>(o--,o>=0?s[o].execute(c,t):(await this.config.hooks?.onRequest?.(t),this.executeXHRUpload(t,r,n)));return c()}buildUrl(t,r,n){let s=r.replace(/\/$/,""),o="";n==="internal"?o="/_internal":typeof n=="number"?o=`/v${n}`:typeof n=="string"&&(o=`/${n}`);let c=t.startsWith("/")?t:`/${t}`;return`${s}${o}${c}`}resolveBaseUrl(t){return typeof t=="function"?t():t}buildContext(t,r,n){return{url:t,path:r,options:n,attempt:1,startTime:Date.now()}}buildUploadContext(t,r,n){let s,o;if("formData"in n&&n.formData)s={isUpload:!0,formData:n.formData,onProgress:n.onProgress},o=n.formData;else if("file"in n&&n.file)s={isUpload:!0,file:n.file,onProgress:n.onProgress},o=n.file;else throw new Error("Upload options must include either file or formData");return{url:t,path:r,options:{...n,method:"POST",body:o},attempt:1,startTime:Date.now(),metadata:s}}async buildDefaultHeaders(){let t={"Content-Type":"application/json",...this.config.headers},r=await this.resolveUserAgent();return r&&(t["User-Agent"]=r),t}async resolveUserAgent(){let t=this.config.userAgent;return typeof t=="function"?await t():t}attachArchonSentryCaptureHeader(t){t.api!=="archon"||!t.headers||!this.shouldCaptureArchonRequests()||(t.headers["modrinth-sentry-capture"]="1")}shouldCaptureArchonRequests(){let t=this.config.archonSentryCapture;return typeof t=="function"?t():t===!0}normalizeError(t,r){return t instanceof h?t:h.fromUnknown(t,r?.path)}createNormalizedError(t,r,n){return r&&n?x.fromResponse(r,n):new h(t.message,{statusCode:r,originalError:t,responseData:n})}addFeature(t){return this.features.push(t),this}removeFeature(t){let r=this.features.indexOf(t);return r!==-1&&this.features.splice(r,1),this}getFeatures(){return[...this.features]}};var y=class{constructor(e){this.config={enabled:!0,...e}}shouldApply(e){return this.config.enabled!==!1}get name(){return this.config.name??this.constructor.name}get enabled(){return this.config.enabled!==!1}};var w=class{constructor(e){this.client=e;this.connections=new Map}on(e,t,r){let n=this.getEventKey(e,t),s=r;return this.emitter.on(n,s),()=>{this.emitter.off(n,s)}}onAny(e,t){let r=this.getAnyEventKey(e),n=t;return this.emitter.on(r,n),()=>{this.emitter.off(r,n)}}onStatus(e,t){let r=this.getStatusEventKey(e),n=t;return this.emitter.on(r,n),()=>{this.emitter.off(r,n)}}getStatus(e){let t=this.connections.get(e);return t?this.connectionToStatus(t):null}emitSyncEvent(e,t){this.emitter.emit(this.getEventKey(e,t.type),t),this.emitter.emit(this.getAnyEventKey(e),t)}updateStatus(e,t,r){e.status=t,e.error=r,this.emitter.emit(this.getStatusEventKey(e.serverId),this.connectionToStatus(e))}clearListeners(e){this.emitter.all.forEach((t,r)=>{r.toString().startsWith(`${e}:`)&&this.emitter.all.delete(r)})}connectionToStatus(e){return{state:e.status,connected:e.status==="connected",reconnecting:e.status==="reconnecting",reconnectAttempts:e.reconnectAttempts,retryDelay:e.retryDelay,lastEventId:e.lastEventId,error:e.error}}getEventKey(e,t){return`${e}:${t}`}getAnyEventKey(e){return`${e}:*`}getStatusEventKey(e){return`${e}:__status`}};var C=class{constructor(e){this.client=e;this.connections=new Map;this.MAX_RECONNECT_ATTEMPTS=10;this.RECONNECT_BASE_DELAY=1e3;this.RECONNECT_MAX_DELAY=3e4}async safeConnect(e,t){let r=this.getStatus(e);if(r?.connected&&!t?.force||r&&!r.connected&&!t?.force)return;t?.force&&r&&this.disconnect(e);let n=await this.client.archon.servers_v0.getWebSocketAuth(e);await this.connect(e,n)}on(e,t,r){let n=`${e}:${t}`;return this.emitter.on(n,r),()=>{this.emitter.off(n,r)}}getStatus(e){let t=this.connections.get(e);return t?{connected:t.socket.readyState===WebSocket.OPEN,reconnecting:t.isReconnecting,reconnectAttempts:t.reconnectAttempts}:null}getReconnectDelay(e){return Math.min(this.RECONNECT_BASE_DELAY*Math.pow(2,e),this.RECONNECT_MAX_DELAY)+Math.random()*1e3}};var Be=class extends y{async execute(e,t){let r=await this.getToken();if(r){let n=this.config.headerName??"Authorization",s=this.config.tokenPrefix??"Bearer",o=s?`${s} ${r}`:r;t.options.headers={...t.options.headers,[n]:o}}return e()}shouldApply(e){if(e.options.skipAuth)return!1;let t=this.config.headerName??"Authorization";return e.options.headers?.[t]?!1:super.shouldApply(e)}async getToken(){let{token:e}=this.config;return typeof e=="function"?await e():e}};var De=class{constructor(){this.state=new Map}get(e){return this.state.get(e)}set(e,t){this.state.set(e,t)}clear(e){this.state.delete(e)}},Fe=class extends y{constructor(e){super(e),this.config={enabled:!0,name:"circuit-breaker",maxFailures:3,resetTimeout:3e4,failureStatusCodes:[500,502,503,504],...e},this.storage=e?.storage??new De}async execute(e,t){let r=this.getCircuitKey(t);if(this.isCircuitOpen(r))throw new h("Circuit breaker open - too many recent failures",{statusCode:503,context:t.path});try{let n=await e();return this.recordSuccess(r),n}catch(n){throw this.isFailureError(n)&&this.recordFailure(r),n}}shouldApply(e){return e.options.circuitBreaker===!1?!1:super.shouldApply(e)}getCircuitKey(e){if(this.config.getCircuitKey)return this.config.getCircuitKey(e.url,e.options.method??"GET");let t=e.options.method??"GET",r=e.path.split("?")[0];return`${t}_${r}`}isCircuitOpen(e){let t=this.storage.get(e);return t?Date.now()-t.lastFailure>this.config.resetTimeout?(this.storage.clear?.(e),!1):t.failures>=this.config.maxFailures:!1}recordSuccess(e){this.storage.clear?.(e)}recordFailure(e){let t=Date.now(),r=this.storage.get(e);r?this.storage.set(e,{failures:r.failures+1,lastFailure:t}):this.storage.set(e,{failures:1,lastFailure:t})}isFailureError(e){return e instanceof h&&e.statusCode?this.config.failureStatusCodes.includes(e.statusCode):!1}getCircuitState(e){return this.storage.get(e)}resetCircuit(e){this.storage.clear?.(e)}};var Ge=class extends y{constructor(){super(...arguments);this.refreshPromise=null}shouldApply(t){return t.options.useNodeAuth===!0&&this.config.enabled!==!1}async refreshAuthWithLock(){return this.refreshPromise?this.refreshPromise:(this.refreshPromise=this.config.refreshAuth().finally(()=>{this.refreshPromise=null}),this.refreshPromise)}async execute(t,r){let s=0,o=this.config.getAuth();if((!o||this.isTokenExpired(o.token))&&(await this.refreshAuthWithLock(),o=this.config.getAuth()),!o)throw new Error("Failed to obtain node authentication");for(this.applyAuth(r,o);;)try{return await t()}catch(c){if(c instanceof h&&c.statusCode===401){if(s++,s>=3)throw new Error("Node authentication failed after 3 retries. Please re-authenticate.");if(await this.refreshAuthWithLock(),o=this.config.getAuth(),!o)throw new Error("Failed to refresh node authentication");this.applyAuth(r,o);continue}throw c}}applyAuth(t,r){let n=K(r.url);t.url=this.buildUrl(t.path,n,t.options.version),t.options.headers={...t.options.headers,Authorization:`Bearer ${r.token}`},t.options.skipAuth=!0}buildUrl(t,r,n){let s=r.replace(/\/$/,""),o="";n==="internal"?o="/_internal":typeof n=="number"?o=`/v${n}`:typeof n=="string"&&(o=`/${n}`);let c=t.startsWith("/")?t:`/${t}`;return`${s}${o}${c}`}isTokenExpired(t){try{let r=JSON.parse(atob(t.split(".")[1]));if(!r.exp)return!1;let n=r.exp*1e3;return Date.now()>=n-1e4}catch{return!1}}};var ct=1,We=class extends y{async execute(e,t){return t.options.headers={...t.options.headers,"X-Panel-Version":String(ct)},e()}shouldApply(e){return e.options.api==="labrinth"||e.options.api==="archon"}};var Ve=class extends y{constructor(e){super(e),this.config={enabled:!0,name:"retry",maxAttempts:3,backoffStrategy:"exponential",initialDelay:1e3,maxDelay:15e3,retryableStatusCodes:[408,429,500,502,503,504],retryOnNetworkError:!0,...e}}async execute(e,t){let r=null,n=this.getMaxAttempts(t);for(let s=1;s<=n;s++){t.attempt=s;try{return await e()}catch(o){if(r=o,!this.shouldRetryError(o,s,n)||s>=n)throw o;let l=this.calculateDelay(s);console.warn(`[${this.name}] Retrying request to ${t.path} (attempt ${s+1}/${n}) after ${l}ms`),await this.sleep(l)}}throw r??new Error("Max retry attempts reached")}shouldApply(e){return e.options.retry===!1?!1:super.shouldApply(e)}shouldRetryError(e,t,r){return this.config.shouldRetry?this.config.shouldRetry(e,t):this.config.retryOnNetworkError&&this.isNetworkError(e)?!0:e instanceof h&&e.statusCode?this.config.retryableStatusCodes.includes(e.statusCode):!1}isNetworkError(e){let t=[/network/i,/timeout/i,/ECONNREFUSED/i,/ENOTFOUND/i,/ETIMEDOUT/i,/ECONNRESET/i],r=e instanceof Error?e.message:String(e);return t.some(n=>n.test(r))}getMaxAttempts(e){return typeof e.options.retry=="number"?e.options.retry:this.config.maxAttempts}calculateDelay(e){let{backoffStrategy:t,initialDelay:r,maxDelay:n}=this.config,s;switch(t){case"exponential":s=r*Math.pow(2,e-1);break;case"linear":s=r*e;break;case"constant":s=r;break;default:s=r}return s+=Math.random()*1e3,Math.min(s,n)}sleep(e){return new Promise(t=>setTimeout(t,e))}};var He=class extends y{async execute(e,t){let r=t.options.method??"GET",n=t.options.api,s=t.options.version,o=`[${r}] [${n}_v${s}]`;console.debug(`${o} ${t.url} SENT`);try{let c=await e();try{let l=c?JSON.stringify(c).length:0;console.debug(`${o} ${t.url} RECEIVED ${l} bytes`)}catch{console.debug(`${o} ${t.url} RECEIVED`)}return c}catch(c){let l=St(c);throw console.debug(`${o} ${t.url} FAILED${l?` \u2014 ${l}`:""}`),c}}};function St(i){if(!i||typeof i!="object")return typeof i=="string"?i:"";let e=i,t=e.status??e.statusCode??e.response?.status,r=e.statusText??e.response?.statusText,n=e.responseData??e.data??e.response?._data,s=[];return t!==void 0&&s.push(r?`${t} ${r}`:String(t)),n!==void 0?s.push(`body: ${_t(n)}`):e.message&&s.push(e.message),s.join(" ")}function _t(i){if(typeof i=="string")return i;try{return JSON.stringify(i)}catch{return String(i)}}var lt;(e=>{let i;(r=>{let t;(s=>s.UserScope={NONE:"",SERVER_ADMIN:"SERVER_ADMIN",BASE_READ:"BASE_READ",POWER_ACTIONS:"POWER_ACTIONS",EXEC_COMMANDS:"EXEC_COMMANDS",FILES_WRITE:"FILES_WRITE",SETUP:"SETUP",BACKUPS:"BACKUPS",ADVANCED:"ADVANCED",RESET_SERVER:"RESET_SERVER",MANAGE_USERS:"MANAGE_USERS",SUPPORT_AGENT:"SUPPORT_AGENT",INFRA_MANAGER:"INFRA_MANAGER",INFRA_MANAGER_READ:"INFRA_MANAGER_READ",INFRA_SERVERS_XFER:"INFRA_SERVERS_XFER",INFRA_USERS:"INFRA_USERS"})(t=r.v1||(r.v1={}))})(i=e.ServerUsers||(e.ServerUsers={}))})(lt||(lt={}));import{$fetch as kt,FetchError as wt}from"ofetch";function S(i,e){if(!e)return i;let t={};for(let[n,s]of Object.entries(e))s!=null&&(t[n]=String(s));let r=new URLSearchParams(t).toString();return r?`${i}${i.includes("?")?"&":"?"}${r}`:i}function _(i){if(i)return typeof i=="object"&&!(i instanceof FormData)&&!(i instanceof URLSearchParams)&&!(i instanceof Blob)&&!(i instanceof ArrayBuffer)&&!ArrayBuffer.isView(i)?JSON.stringify(i):i}async function E(i){let e=i.headers.get("content-type")?.toLowerCase()??"";try{if(e.includes("application/json")||e.includes("+json"))return await i.json();let t=await i.text();if(!t)return;try{return JSON.parse(t)}catch{return t}}catch{return}}import Et from"mitt";var L=class{constructor(){this.buffer="";this.eventName="";this.data=""}feed(e){this.buffer+=e;let t=[];for(;;){let r=this.findLineEnd();if(!r)break;let{line:n,length:s}=r;this.buffer=this.buffer.slice(s),this.processLine(n,t)}return t}end(){let e=[];return this.buffer.length>0&&(this.processLine(this.buffer.endsWith("\r")?this.buffer.slice(0,-1):this.buffer,e),this.buffer=""),this.dispatch(e),e}findLineEnd(){let e=this.buffer.indexOf(`
3
3
  `),t=this.buffer.indexOf("\r");if(e===-1&&t===-1)return null;if(t!==-1&&(e===-1||t<e)){if(t===this.buffer.length-1)return null;let r=this.buffer[t+1]===`
4
4
  `?t+2:t+1;return{line:this.buffer.slice(0,t),length:r}}return{line:this.buffer.slice(0,e),length:e+1}}processLine(e,t){if(e===""){this.dispatch(t);return}if(e.startsWith(":"))return;let r=e.indexOf(":"),n=r===-1?e:e.slice(0,r),s=r===-1?"":e.slice(r+1);switch(s.startsWith(" ")&&(s=s.slice(1)),n){case"event":this.eventName=s;break;case"data":this.data+=`${s}
5
5
  `;break;case"id":this.id=s;break;case"retry":{let o=Number(s);Number.isInteger(o)&&o>=0&&t.push({kind:"retry",retry:o});break}}}dispatch(e){if(!this.data){this.eventName="",this.id=void 0;return}e.push({kind:"event",id:this.id,event:this.eventName||void 0,data:this.data.endsWith(`
6
- `)?this.data.slice(0,-1):this.data}),this.eventName="",this.data="",this.id=void 0}};function Ve(i){let e;try{e=JSON.parse(i)}catch{return null}return!e||typeof e!="object"||typeof e.type!="string"?null:e}var Pt=1e3,at=3e4,St=1e3,f=class extends w{constructor(){super(...arguments);this.emitter=ft()}async safeConnectServer(t,r={}){let n=this.connections.get(t);if(n&&!r.force&&!n.stopped&&n.status!=="disconnected")return;n&&this.closeConnection(t);let s={serverId:t,intent:r.intent??"all",reconnectAttempts:0,retryDelay:Pt,stopped:!1,status:"idle"};this.connections.set(t,s),this.runConnection(s)}disconnect(t){this.closeConnection(t),this.clearListeners(t)}disconnectAll(){for(let t of this.connections.keys())this.disconnect(t)}async runConnection(t){for(;!t.stopped;){let r=t.status==="connected";this.updateStatus(t,r?"reconnecting":"connecting");let n=new AbortController;t.controller=n;try{let s=await this.client.stream("/sync",{api:"archon",version:1,method:"GET",params:{scope:`server:${t.serverId}`,intent:this.intentToParam(t.intent)},headers:t.lastEventId?{"Last-Event-Id":t.lastEventId}:void 0,signal:n.signal,retry:!1,circuitBreaker:!1});if(t.stopped)return;t.reconnectAttempts=0,this.updateStatus(t,"connected");let o=await this.consumeStream(t,s);if(t.controller=void 0,t.stopped)return;if(o==="protocol-reconnect"){t.reconnectAttempts=0;continue}await this.waitForReconnect(t)}catch(s){if(t.controller=void 0,t.stopped||this.isAbortError(s))return;t.reconnectAttempts++,this.updateStatus(t,"error",s),console.warn(`[Sync] Connection failed for server ${t.serverId}:`,s),await this.waitForReconnect(t)}}}async consumeStream(t,r){let n=r.getReader(),s=new TextDecoder,o=new q;try{for(;!t.stopped;){let{done:p,value:m}=await n.read();if(p)break;let g=s.decode(m,{stream:!0}),b=this.processParsedItems(t,o.feed(g));if(b==="protocol-reconnect")return await n.cancel(),t.controller?.abort(),b}let c=s.decode(),l=c?o.feed(c):[],u=this.processParsedItems(t,[...l,...o.end()]);if(u==="protocol-reconnect")return await n.cancel(),t.controller?.abort(),u}finally{n.releaseLock()}return"closed"}processParsedItems(t,r){for(let n of r){if(n.kind==="retry"){t.retryDelay=Math.min(n.retry,at);continue}this.updateLastEventId(t,n.id);let s=Ve(n.data);if(!s){console.warn("[Sync] Dropping malformed SSE payload:",{serverId:t.serverId,event:n.event,data:n.data});continue}if(this.emitSyncEvent(t.serverId,s),s.type==="protocol.reset"||s.type==="protocol.invalid")return t.lastEventId=void 0,"protocol-reconnect"}return"closed"}async waitForReconnect(t){if(t.stopped)return;this.updateStatus(t,"reconnecting");let r=this.getReconnectDelay(t);await new Promise(n=>{t.reconnectResolve=n,t.reconnectTimer=setTimeout(()=>{t.reconnectTimer=void 0,t.reconnectResolve=void 0,n()},r)})}closeConnection(t){let r=this.connections.get(t);r&&(r.stopped=!0,r.controller?.abort(),r.reconnectTimer&&(clearTimeout(r.reconnectTimer),r.reconnectTimer=void 0),r.reconnectResolve?.(),r.reconnectResolve=void 0,this.updateStatus(r,"disconnected"),this.connections.delete(t))}getReconnectDelay(t){let r=t.retryDelay*Math.pow(2,Math.max(t.reconnectAttempts-1,0));return Math.min(r,at)+Math.random()*St}updateLastEventId(t,r){r!==void 0&&(t.lastEventId=r||void 0)}intentToParam(t){return Array.isArray(t)?t.join(","):t}isAbortError(t){return t instanceof Error?t.name==="AbortError"||t.message.toLowerCase().includes("abort"):!1}};import At from"mitt";var ct=1e3,S=class extends C{constructor(){super(...arguments);this.emitter=At()}async connect(t,r){return this.connections.has(t)&&this.closeConnection(t),new Promise((n,s)=>{try{let o=new WebSocket(Ue(r.url)),c={serverId:t,socket:o,reconnectAttempts:0,reconnectTimer:void 0,isReconnecting:!1};this.connections.set(t,c),o.onopen=()=>{o.send(JSON.stringify({event:"auth",jwt:r.token})),c.reconnectAttempts=0,c.isReconnecting=!1,n()},o.onmessage=l=>{try{let u=JSON.parse(l.data),p=`${t}:${u.event}`;this.emitter.emit(p,u),(u.event==="auth-expiring"||u.event==="auth-incorrect")&&this.handleAuthExpiring(t).catch(console.error)}catch(u){console.error("[WebSocket] Failed to parse message:",u)}},o.onclose=l=>{console.debug(`[WebSocket] Closed for server ${t}:`,{code:l.code,reason:l.reason,wasClean:l.wasClean}),l.code!==ct&&this.scheduleReconnect(t,r)},o.onerror=l=>{let u=o.url,p=o.readyState;console.error(`[WebSocket] Error for server ${t}:`,{url:u,readyState:p,readyStateLabel:["CONNECTING","OPEN","CLOSING","CLOSED"][p],type:l.type}),s(new Error(`WebSocket connection failed for server ${t} (readyState: ${p})`))}}catch(o){s(o)}})}disconnect(t){this.closeConnection(t),this.emitter.all.forEach((r,n)=>{n.toString().startsWith(`${t}:`)&&this.emitter.all.delete(n)})}closeConnection(t){let r=this.connections.get(t);r&&(r.reconnectTimer&&(clearTimeout(r.reconnectTimer),r.reconnectTimer=void 0),(r.socket.readyState===WebSocket.OPEN||r.socket.readyState===WebSocket.CONNECTING)&&r.socket.close(ct,"Client disconnecting"),this.connections.delete(t))}disconnectAll(){for(let t of this.connections.keys())this.disconnect(t)}send(t,r){let n=this.connections.get(t);if(!n||n.socket.readyState!==WebSocket.OPEN){console.warn(`Cannot send message: WebSocket not connected for server ${t}`);return}n.socket.send(JSON.stringify(r))}scheduleReconnect(t,r){let n=this.connections.get(t);if(!n)return;if(n.reconnectAttempts>=this.MAX_RECONNECT_ATTEMPTS){this.disconnect(t);return}n.isReconnecting=!0,n.reconnectAttempts++;let s=this.getReconnectDelay(n.reconnectAttempts);n.reconnectTimer=setTimeout(()=>{this.connect(t,r).catch(o=>{console.error(`[WebSocket] Reconnection failed for server ${t}:`,o)})},s)}async handleAuthExpiring(t){try{let r=await this.client.archon.servers_v0.getWebSocketAuth(t),n=this.connections.get(t);n&&n.socket.readyState===WebSocket.OPEN&&n.socket.send(JSON.stringify({event:"auth",jwt:r.token}))}catch(r){console.error(`[WebSocket] Failed to refresh auth for server ${t}:`,r),this.disconnect(t)}}};var P=class extends k{upload(e,t){let r;t.api==="labrinth"?r=this.resolveBaseUrl(this.config.labrinthBaseUrl):t.api==="archon"?r=this.resolveBaseUrl(this.config.archonBaseUrl):r=t.api;let n=this.buildUrl(e,r,t.version),s=[];t.onProgress&&s.push(t.onProgress);let o=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>o.abort());let c,l={promise:(async()=>{let u="formData"in t&&t.formData instanceof FormData,p=await this.buildDefaultHeaders();u?delete p["Content-Type"]:p["Content-Type"]="application/octet-stream";let m={retry:!1,...t,headers:{...p,...t.headers}};this.attachArchonSentryCaptureHeader(m);let g=this.buildUploadContext(n,e,m);if(c=g,o.signal.aborted)throw new h("Upload cancelled");let b=await this.executeUploadFeatureChain(g,s,o);return await this.config.hooks?.onResponse?.(b,g),b})().catch(async u=>{let p=this.normalizeError(u,c);throw c&&await this.config.hooks?.onError?.(p,c),p}),onProgress:u=>(s.push(u),l),cancel:()=>o.abort()};return l}executeXHRUpload(e,t,r){return new Promise((n,s)=>{let o=new XMLHttpRequest,c=e.metadata;o.upload.addEventListener("progress",p=>{if(p.lengthComputable){let m={loaded:p.loaded,total:p.total,progress:p.loaded/p.total};t.forEach(g=>g(m))}}),o.addEventListener("load",()=>{if(o.status>=200&&o.status<300)try{n(o.response?JSON.parse(o.response):void 0)}catch{n(void 0)}else s(this.createUploadError(o))}),o.addEventListener("error",()=>s(new h("Upload failed"))),o.addEventListener("abort",()=>s(new h("Upload cancelled"))),o.addEventListener("timeout",()=>s(new h("Upload timed out"))),e.options.timeout!==void 0&&(o.timeout=e.options.timeout);let l=e.url;if(e.options.params){let p=new URLSearchParams(Object.entries(e.options.params).map(([m,g])=>[m,String(g)])).toString();l+=(l.includes("?")?"&":"?")+p}o.open("POST",l);for(let[p,m]of Object.entries(e.options.headers??{}))o.setRequestHeader(p,m);let u="formData"in c?c.formData:c.file;o.send(u),r.signal.addEventListener("abort",()=>o.abort())})}createUploadError(e){let t;try{t=e.response?JSON.parse(e.response):void 0}catch{t=e.responseText}return this.createNormalizedError(new Error(`Upload failed with status ${e.status}`),e.status,t)}};var He=class extends P{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new S(this),writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(this.archon,"sync",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async executeRequest(e,t){try{return await Et(e,{method:t.method??"GET",headers:t.headers,body:t.body,params:t.params,timeout:t.timeout,signal:t.signal})}catch(r){throw this.normalizeError(r)}}async executeStreamRequest(e,t){try{let r=await fetch(A(e,t.params),{method:t.method??"GET",headers:t.headers,body:E(t.body),signal:t.signal});if(!r.ok)throw this.createNormalizedError(new Error(`HTTP ${r.status}: ${r.statusText}`),r.status,await _(r));if(!r.body)throw new h("Streaming response has no readable body",{statusCode:r.status});return r.body}catch(r){throw this.normalizeError(r)}}normalizeError(e){return e instanceof _t?this.createNormalizedError(e,e.response?.status,e.data):super.normalizeError(e)}};import{FetchError as Rt}from"ofetch";var ze=class{constructor(){let e=useState("circuit-breaker-state",()=>new Map);this.state=e.value}get(e){return this.state.get(e)}set(e,t){this.state.set(e,t)}clear(e){this.state.delete(e)}},Ke=class extends P{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new S(this),writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(this.archon,"sync",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async resolveRateLimitKey(){if(this.rateLimitKeyResolved!==void 0)return this.rateLimitKeyResolved;let e=this.config.rateLimitKey;return typeof e=="string"?this.rateLimitKeyResolved=e:typeof e=="function"&&(this.rateLimitKeyPromise||(this.rateLimitKeyPromise=e()),this.rateLimitKeyResolved=await this.rateLimitKeyPromise),this.rateLimitKeyResolved}async request(e,t){return import.meta.server&&await this.resolveRateLimitKey(),super.request(e,t)}upload(e,t){if(import.meta.server)throw new h("upload() is not supported during SSR");return super.upload(e,t)}async executeRequest(e,t){try{return await $fetch(e,{method:t.method??"GET",headers:t.headers,body:t.body,params:t.params,timeout:t.timeout,signal:t.signal,cache:import.meta.server?void 0:"no-store"})}catch(r){throw this.normalizeError(r)}}async executeStreamRequest(e,t){try{let r=await fetch(A(e,t.params),{method:t.method??"GET",headers:t.headers,body:E(t.body),signal:t.signal,cache:import.meta.server?void 0:"no-store"});if(!r.ok)throw this.createNormalizedError(new Error(`HTTP ${r.status}: ${r.statusText}`),r.status,await _(r));if(!r.body)throw new h("Streaming response has no readable body",{statusCode:r.status});return r.body}catch(r){throw this.normalizeError(r)}}normalizeError(e){return e instanceof Rt?this.createNormalizedError(e,e.response?.status,e.data):super.normalizeError(e)}async buildDefaultHeaders(){let e={...await super.buildDefaultHeaders()};return import.meta.server&&this.rateLimitKeyResolved&&(e["x-ratelimit-key"]=this.rateLimitKeyResolved),e}};var Je=class extends P{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new S(this),writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(this.archon,"sync",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async executeRequest(e,t){try{let{fetch:r}=await import("@tauri-apps/plugin-http"),n=E(t.body),s=A(e,t.params),o=await r(s,{method:t.method??"GET",headers:t.headers,body:n});if(!o.ok){let u;try{u=await o.json()}catch{u=void 0}let p=new Error(`HTTP ${o.status}: ${o.statusText}`);throw p.statusCode=o.status,p.responseData=u,p}let c=o.headers.get("content-type")?.toLowerCase()??"";if(s.includes("/fs/download"))return await o.blob();if(c.startsWith("image/")||c.startsWith("audio/")||c.startsWith("video/")||c.includes("application/octet-stream"))return await o.blob();if(o.status===204||o.status===205)return;if(c.includes("application/json")||c.includes("+json"))return await o.json();let l=await o.text();if(!l)return;try{return JSON.parse(l)}catch{return l}}catch(r){throw this.normalizeError(r)}}async executeStreamRequest(e,t){try{let{fetch:r}=await import("@tauri-apps/plugin-http"),n=await r(A(e,t.params),{method:t.method??"GET",headers:t.headers,body:E(t.body),signal:t.signal});if(!n.ok)throw this.createNormalizedError(new Error(`HTTP ${n.status}: ${n.statusText}`),n.status,await _(n));if(!n.body)throw this.createNormalizedError(new Error("Streaming response has no readable body"),n.status,void 0);return n.body}catch(r){throw this.normalizeError(r)}}normalizeError(e){if(e instanceof Error){let t=e,r=t.statusCode,n=t.responseData;return this.createNormalizedError(e,r,n)}return super.normalizeError(e)}};var L={getAuth:null,refreshAuth:null};function xt(i,e){L.getAuth=i,L.refreshAuth=e}function Tt(){L.getAuth=null,L.refreshAuth=null}async function kt(i,e){try{return await i()}catch(t){if(t instanceof h&&t.statusCode===401)return await e(),await i();throw t}}async function wt(i,e={}){let t=e.count??5,r=e.intervalMs??200,n=e.settleDelayMs??1e3,s=e.timeoutMs??t*r+n+1e3;return e.signal?.aborted?-1:await new Promise(o=>{let c=[],l=new Set,u,p=!1,m=(v,R)=>{let d=setTimeout(()=>{l.delete(d),v()},R);return l.add(d),d},g=()=>{for(let v of l)clearTimeout(v);l.clear(),e.signal?.removeEventListener("abort",M),u&&(u.readyState===WebSocket.CONNECTING||u.readyState===WebSocket.OPEN)&&u.close()},b=v=>{p||(p=!0,g(),o(v))},M=()=>b(-1);e.signal?.addEventListener("abort",M,{once:!0});try{u=new WebSocket(i)}catch{b(-1);return}m(()=>b(-1),s),u.onopen=()=>{for(let v=0;v<t;v++)m(()=>{u?.readyState===WebSocket.OPEN&&u.send(String(performance.now()))},v*r);m(()=>{let v=c.length>0?Math.round([...c].sort((R,d)=>R-d)[Math.floor(c.length/2)]):-1;b(v)},t*r+n)},u.onmessage=v=>{c.push(performance.now()-Number(v.data))},u.onerror=()=>b(-1),u.onclose=()=>{!p&&c.length===0&&b(-1)}})}export{y as AbstractFeature,k as AbstractModrinthClient,w as AbstractSyncClient,T as AbstractUploadClient,C as AbstractWebSocketClient,ot as Archon,De as AuthFeature,Be as CircuitBreakerFeature,He as GenericModrinthClient,f as GenericSyncClient,Ie as InMemoryCircuitBreakerStorage,h as ModrinthApiError,x as ModrinthServerError,je as NodeAuthFeature,ze as NuxtCircuitBreakerStorage,Ke as NuxtModrinthClient,st as PANEL_VERSION,Fe as PanelVersionFeature,Ge as RetryFeature,q as SseParser,Je as TauriModrinthClient,We as VerboseLoggingFeature,P as XHRUploadClient,Tt as clearNodeAuthState,Ue as getNodeWebSocketUrl,Ne as isModrinthErrorResponse,L as nodeAuthState,Ve as parseSyncEventData,wt as pingWebSocketUrl,xt as setNodeAuthState,kt as withJWTRetry};
6
+ `)?this.data.slice(0,-1):this.data}),this.eventName="",this.data="",this.id=void 0}};function ze(i){let e;try{e=JSON.parse(i)}catch{return null}return!e||typeof e!="object"||typeof e.type!="string"?null:e}var Rt=1e3,ut=3e4,xt=1e3,f=class extends w{constructor(){super(...arguments);this.emitter=Et()}async safeConnectServer(t,r={}){let n=this.connections.get(t);if(n&&!r.force&&!n.stopped&&n.status!=="disconnected")return;n&&this.closeConnection(t);let s={serverId:t,intent:r.intent??"all",reconnectAttempts:0,retryDelay:Rt,stopped:!1,status:"idle"};this.connections.set(t,s),this.runConnection(s)}disconnect(t){this.closeConnection(t),this.clearListeners(t)}disconnectAll(){for(let t of this.connections.keys())this.disconnect(t)}async runConnection(t){for(;!t.stopped;){let r=t.status==="connected";this.updateStatus(t,r?"reconnecting":"connecting");let n=new AbortController;t.controller=n;try{let s=await this.client.stream("/sync",{api:"archon",version:1,method:"GET",params:{scope:`server:${t.serverId}`,intent:this.intentToParam(t.intent)},headers:t.lastEventId?{"Last-Event-Id":t.lastEventId}:void 0,signal:n.signal,retry:!1,circuitBreaker:!1});if(t.stopped)return;t.reconnectAttempts=0,this.updateStatus(t,"connected");let o=await this.consumeStream(t,s);if(t.controller=void 0,t.stopped)return;if(o==="protocol-reconnect"){t.reconnectAttempts=0;continue}await this.waitForReconnect(t)}catch(s){if(t.controller=void 0,t.stopped||this.isAbortError(s))return;t.reconnectAttempts++,this.updateStatus(t,"error",s),console.warn(`[Sync] Connection failed for server ${t.serverId}:`,s),await this.waitForReconnect(t)}}}async consumeStream(t,r){let n=r.getReader(),s=new TextDecoder,o=new L;try{for(;!t.stopped;){let{done:p,value:m}=await n.read();if(p)break;let g=s.decode(m,{stream:!0}),b=this.processParsedItems(t,o.feed(g));if(b==="protocol-reconnect")return await n.cancel(),t.controller?.abort(),b}let c=s.decode(),l=c?o.feed(c):[],u=this.processParsedItems(t,[...l,...o.end()]);if(u==="protocol-reconnect")return await n.cancel(),t.controller?.abort(),u}finally{n.releaseLock()}return"closed"}processParsedItems(t,r){for(let n of r){if(n.kind==="retry"){t.retryDelay=Math.min(n.retry,ut);continue}this.updateLastEventId(t,n.id);let s=ze(n.data);if(!s){console.warn("[Sync] Dropping malformed SSE payload:",{serverId:t.serverId,event:n.event,data:n.data});continue}if(this.emitSyncEvent(t.serverId,s),s.type==="protocol.reset"||s.type==="protocol.invalid")return t.lastEventId=void 0,"protocol-reconnect"}return"closed"}async waitForReconnect(t){if(t.stopped)return;this.updateStatus(t,"reconnecting");let r=this.getReconnectDelay(t);await new Promise(n=>{t.reconnectResolve=n,t.reconnectTimer=setTimeout(()=>{t.reconnectTimer=void 0,t.reconnectResolve=void 0,n()},r)})}closeConnection(t){let r=this.connections.get(t);r&&(r.stopped=!0,r.controller?.abort(),r.reconnectTimer&&(clearTimeout(r.reconnectTimer),r.reconnectTimer=void 0),r.reconnectResolve?.(),r.reconnectResolve=void 0,this.updateStatus(r,"disconnected"),this.connections.delete(t))}getReconnectDelay(t){let r=t.retryDelay*Math.pow(2,Math.max(t.reconnectAttempts-1,0));return Math.min(r,ut)+Math.random()*xt}updateLastEventId(t,r){r!==void 0&&(t.lastEventId=r||void 0)}intentToParam(t){return Array.isArray(t)?t.join(","):t}isAbortError(t){return t instanceof Error?t.name==="AbortError"||t.message.toLowerCase().includes("abort"):!1}};import Tt from"mitt";var pt=1e3,A=class extends C{constructor(){super(...arguments);this.emitter=Tt()}async connect(t,r){return this.connections.has(t)&&this.closeConnection(t),new Promise((n,s)=>{try{let o=new WebSocket(Ne(r.url)),c={serverId:t,socket:o,reconnectAttempts:0,reconnectTimer:void 0,isReconnecting:!1};this.connections.set(t,c),o.onopen=()=>{o.send(JSON.stringify({event:"auth",jwt:r.token})),c.reconnectAttempts=0,c.isReconnecting=!1,n()},o.onmessage=l=>{try{let u=JSON.parse(l.data),p=`${t}:${u.event}`;this.emitter.emit(p,u),(u.event==="auth-expiring"||u.event==="auth-incorrect")&&this.handleAuthExpiring(t).catch(console.error)}catch(u){console.error("[WebSocket] Failed to parse message:",u)}},o.onclose=l=>{console.debug(`[WebSocket] Closed for server ${t}:`,{code:l.code,reason:l.reason,wasClean:l.wasClean}),l.code!==pt&&this.scheduleReconnect(t,r)},o.onerror=l=>{let u=o.url,p=o.readyState;console.error(`[WebSocket] Error for server ${t}:`,{url:u,readyState:p,readyStateLabel:["CONNECTING","OPEN","CLOSING","CLOSED"][p],type:l.type}),s(new Error(`WebSocket connection failed for server ${t} (readyState: ${p})`))}}catch(o){s(o)}})}disconnect(t){this.closeConnection(t),this.emitter.all.forEach((r,n)=>{n.toString().startsWith(`${t}:`)&&this.emitter.all.delete(n)})}closeConnection(t){let r=this.connections.get(t);r&&(r.reconnectTimer&&(clearTimeout(r.reconnectTimer),r.reconnectTimer=void 0),(r.socket.readyState===WebSocket.OPEN||r.socket.readyState===WebSocket.CONNECTING)&&r.socket.close(pt,"Client disconnecting"),this.connections.delete(t))}disconnectAll(){for(let t of this.connections.keys())this.disconnect(t)}send(t,r){let n=this.connections.get(t);if(!n||n.socket.readyState!==WebSocket.OPEN){console.warn(`Cannot send message: WebSocket not connected for server ${t}`);return}n.socket.send(JSON.stringify(r))}scheduleReconnect(t,r){let n=this.connections.get(t);if(!n)return;if(n.reconnectAttempts>=this.MAX_RECONNECT_ATTEMPTS){this.disconnect(t);return}n.isReconnecting=!0,n.reconnectAttempts++;let s=this.getReconnectDelay(n.reconnectAttempts);n.reconnectTimer=setTimeout(()=>{this.connect(t,r).catch(o=>{console.error(`[WebSocket] Reconnection failed for server ${t}:`,o)})},s)}async handleAuthExpiring(t){try{let r=await this.client.archon.servers_v0.getWebSocketAuth(t),n=this.connections.get(t);n&&n.socket.readyState===WebSocket.OPEN&&n.socket.send(JSON.stringify({event:"auth",jwt:r.token}))}catch(r){console.error(`[WebSocket] Failed to refresh auth for server ${t}:`,r),this.disconnect(t)}}};var P=class extends k{upload(e,t){let r;t.api==="labrinth"?r=this.resolveBaseUrl(this.config.labrinthBaseUrl):t.api==="archon"?r=this.resolveBaseUrl(this.config.archonBaseUrl):r=t.api;let n=this.buildUrl(e,r,t.version),s=[];t.onProgress&&s.push(t.onProgress);let o=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>o.abort());let c,l={promise:(async()=>{let u="formData"in t&&t.formData instanceof FormData,p=await this.buildDefaultHeaders();u?delete p["Content-Type"]:p["Content-Type"]="application/octet-stream";let m={retry:!1,...t,headers:{...p,...t.headers}};this.attachArchonSentryCaptureHeader(m);let g=this.buildUploadContext(n,e,m);if(c=g,o.signal.aborted)throw new h("Upload cancelled");let b=await this.executeUploadFeatureChain(g,s,o);return await this.config.hooks?.onResponse?.(b,g),b})().catch(async u=>{let p=this.normalizeError(u,c);throw c&&await this.config.hooks?.onError?.(p,c),p}),onProgress:u=>(s.push(u),l),cancel:()=>o.abort()};return l}executeXHRUpload(e,t,r){return new Promise((n,s)=>{let o=new XMLHttpRequest,c=e.metadata;o.upload.addEventListener("progress",p=>{if(p.lengthComputable){let m={loaded:p.loaded,total:p.total,progress:p.loaded/p.total};t.forEach(g=>g(m))}}),o.addEventListener("load",()=>{if(o.status>=200&&o.status<300)try{n(o.response?JSON.parse(o.response):void 0)}catch{n(void 0)}else s(this.createUploadError(o))}),o.addEventListener("error",()=>s(new h("Upload failed"))),o.addEventListener("abort",()=>s(new h("Upload cancelled"))),o.addEventListener("timeout",()=>s(new h("Upload timed out"))),e.options.timeout!==void 0&&(o.timeout=e.options.timeout);let l=e.url;if(e.options.params){let p=new URLSearchParams(Object.entries(e.options.params).map(([m,g])=>[m,String(g)])).toString();l+=(l.includes("?")?"&":"?")+p}o.open("POST",l);for(let[p,m]of Object.entries(e.options.headers??{}))o.setRequestHeader(p,m);let u="formData"in c?c.formData:c.file;o.send(u),r.signal.addEventListener("abort",()=>o.abort())})}createUploadError(e){let t;try{t=e.response?JSON.parse(e.response):void 0}catch{t=e.responseText}return this.createNormalizedError(new Error(`Upload failed with status ${e.status}`),e.status,t)}};var Ke=class extends P{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new A(this),writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(this.archon,"sync",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async executeRequest(e,t){try{return await kt(e,{method:t.method??"GET",headers:t.headers,body:t.body,params:t.params,timeout:t.timeout,signal:t.signal})}catch(r){throw this.normalizeError(r)}}async executeStreamRequest(e,t){try{let r=await fetch(S(e,t.params),{method:t.method??"GET",headers:t.headers,body:_(t.body),signal:t.signal});if(!r.ok)throw this.createNormalizedError(new Error(`HTTP ${r.status}: ${r.statusText}`),r.status,await E(r));if(!r.body)throw new h("Streaming response has no readable body",{statusCode:r.status});return r.body}catch(r){throw this.normalizeError(r)}}normalizeError(e){return e instanceof wt?this.createNormalizedError(e,e.response?.status,e.data):super.normalizeError(e)}};import{FetchError as Ct}from"ofetch";var Je=class{constructor(){let e=useState("circuit-breaker-state",()=>new Map);this.state=e.value}get(e){return this.state.get(e)}set(e,t){this.state.set(e,t)}clear(e){this.state.delete(e)}},Qe=class extends P{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new A(this),writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(this.archon,"sync",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async resolveRateLimitKey(){if(this.rateLimitKeyResolved!==void 0)return this.rateLimitKeyResolved;let e=this.config.rateLimitKey;return typeof e=="string"?this.rateLimitKeyResolved=e:typeof e=="function"&&(this.rateLimitKeyPromise||(this.rateLimitKeyPromise=e()),this.rateLimitKeyResolved=await this.rateLimitKeyPromise),this.rateLimitKeyResolved}async request(e,t){return import.meta.server&&await this.resolveRateLimitKey(),super.request(e,t)}upload(e,t){if(import.meta.server)throw new h("upload() is not supported during SSR");return super.upload(e,t)}async executeRequest(e,t){try{return await $fetch(e,{method:t.method??"GET",headers:t.headers,body:t.body,params:t.params,timeout:t.timeout,signal:t.signal,cache:import.meta.server?void 0:"no-store"})}catch(r){throw this.normalizeError(r)}}async executeStreamRequest(e,t){try{let r=await fetch(S(e,t.params),{method:t.method??"GET",headers:t.headers,body:_(t.body),signal:t.signal,cache:import.meta.server?void 0:"no-store"});if(!r.ok)throw this.createNormalizedError(new Error(`HTTP ${r.status}: ${r.statusText}`),r.status,await E(r));if(!r.body)throw new h("Streaming response has no readable body",{statusCode:r.status});return r.body}catch(r){throw this.normalizeError(r)}}normalizeError(e){return e instanceof Ct?this.createNormalizedError(e,e.response?.status,e.data):super.normalizeError(e)}async buildDefaultHeaders(){let e={...await super.buildDefaultHeaders()};return import.meta.server&&this.rateLimitKeyResolved&&(e["x-ratelimit-key"]=this.rateLimitKeyResolved),e}};var Xe=class extends P{constructor(e){super(e),Object.defineProperty(this.archon,"sockets",{value:new A(this),writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(this.archon,"sync",{value:new f(this),writable:!1,enumerable:!0,configurable:!1})}async executeRequest(e,t){try{let{fetch:r}=await import("@tauri-apps/plugin-http"),n=_(t.body),s=S(e,t.params),o=await r(s,{method:t.method??"GET",headers:t.headers,body:n});if(!o.ok){let u;try{u=await o.json()}catch{u=void 0}let p=new Error(`HTTP ${o.status}: ${o.statusText}`);throw p.statusCode=o.status,p.responseData=u,p}let c=o.headers.get("content-type")?.toLowerCase()??"";if(s.includes("/fs/download"))return await o.blob();if(c.startsWith("image/")||c.startsWith("audio/")||c.startsWith("video/")||c.includes("application/octet-stream"))return await o.blob();if(o.status===204||o.status===205)return;if(c.includes("application/json")||c.includes("+json"))return await o.json();let l=await o.text();if(!l)return;try{return JSON.parse(l)}catch{return l}}catch(r){throw this.normalizeError(r)}}async executeStreamRequest(e,t){try{let{fetch:r}=await import("@tauri-apps/plugin-http"),n=await r(S(e,t.params),{method:t.method??"GET",headers:t.headers,body:_(t.body),signal:t.signal});if(!n.ok)throw this.createNormalizedError(new Error(`HTTP ${n.status}: ${n.statusText}`),n.status,await E(n));if(!n.body)throw this.createNormalizedError(new Error("Streaming response has no readable body"),n.status,void 0);return n.body}catch(r){throw this.normalizeError(r)}}normalizeError(e){if(e instanceof Error){let t=e,r=t.statusCode,n=t.responseData;return this.createNormalizedError(e,r,n)}return super.normalizeError(e)}};var q={getAuth:null,refreshAuth:null};function Lt(i,e){q.getAuth=i,q.refreshAuth=e}function qt(){q.getAuth=null,q.refreshAuth=null}async function Ot(i,e){try{return await i()}catch(t){if(t instanceof h&&t.statusCode===401)return await e(),await i();throw t}}async function Mt(i,e={}){let t=e.count??5,r=e.intervalMs??200,n=e.settleDelayMs??1e3,s=e.timeoutMs??t*r+n+1e3;return e.signal?.aborted?-1:await new Promise(o=>{let c=[],l=new Set,u,p=!1,m=(v,R)=>{let d=setTimeout(()=>{l.delete(d),v()},R);return l.add(d),d},g=()=>{for(let v of l)clearTimeout(v);l.clear(),e.signal?.removeEventListener("abort",O),u&&(u.readyState===WebSocket.CONNECTING||u.readyState===WebSocket.OPEN)&&u.close()},b=v=>{p||(p=!0,g(),o(v))},O=()=>b(-1);e.signal?.addEventListener("abort",O,{once:!0});try{u=new WebSocket(i)}catch{b(-1);return}m(()=>b(-1),s),u.onopen=()=>{for(let v=0;v<t;v++)m(()=>{u?.readyState===WebSocket.OPEN&&u.send(String(performance.now()))},v*r);m(()=>{let v=c.length>0?Math.round([...c].sort((R,d)=>R-d)[Math.floor(c.length/2)]):-1;b(v)},t*r+n)},u.onmessage=v=>{c.push(performance.now()-Number(v.data))},u.onerror=()=>b(-1),u.onclose=()=>{!p&&c.length===0&&b(-1)}})}export{y as AbstractFeature,k as AbstractModrinthClient,w as AbstractSyncClient,T as AbstractUploadClient,C as AbstractWebSocketClient,lt as Archon,Be as AuthFeature,Fe as CircuitBreakerFeature,Ke as GenericModrinthClient,f as GenericSyncClient,De as InMemoryCircuitBreakerStorage,h as ModrinthApiError,x as ModrinthServerError,Ge as NodeAuthFeature,Je as NuxtCircuitBreakerStorage,Qe as NuxtModrinthClient,ct as PANEL_VERSION,We as PanelVersionFeature,Ve as RetryFeature,L as SseParser,Xe as TauriModrinthClient,He as VerboseLoggingFeature,P as XHRUploadClient,qt as clearNodeAuthState,Ne as getNodeWebSocketUrl,je as isModrinthErrorResponse,q as nodeAuthState,ze as parseSyncEventData,Mt as pingWebSocketUrl,Lt as setNodeAuthState,Ot as withJWTRetry};
@@ -20,6 +20,7 @@ import { KyrosUploadSessionsV1Module } from './kyros/upload-sessions/v1';
20
20
  import { LabrinthVersionsV2Module, LabrinthVersionsV3Module } from './labrinth';
21
21
  import { LabrinthAffiliateInternalModule } from './labrinth/affiliate/internal';
22
22
  import { LabrinthAnalyticsV3Module } from './labrinth/analytics/v3';
23
+ import { LabrinthAttributionInternalModule } from './labrinth/attribution/internal';
23
24
  import { LabrinthAuthInternalModule } from './labrinth/auth/internal';
24
25
  import { LabrinthAuthV2Module } from './labrinth/auth/v2';
25
26
  import { LabrinthBillingInternalModule } from './labrinth/billing/internal';
@@ -28,6 +29,7 @@ import { LabrinthCollectionsModule } from './labrinth/collections';
28
29
  import { LabrinthExternalProjectsInternalModule } from './labrinth/external-projects/internal';
29
30
  import { LabrinthFriendsV3Module } from './labrinth/friends/v3';
30
31
  import { LabrinthGlobalsInternalModule } from './labrinth/globals/internal';
32
+ import { LabrinthImagesV3Module } from './labrinth/images/v3';
31
33
  import { LabrinthLimitsV3Module } from './labrinth/limits/v3';
32
34
  import { LabrinthModerationInternalModule } from './labrinth/moderation/internal';
33
35
  import { LabrinthNotificationsV2Module } from './labrinth/notifications/v2';
@@ -89,12 +91,14 @@ export declare const MODULE_REGISTRY: {
89
91
  readonly labrinth_analytics_v3: typeof LabrinthAnalyticsV3Module;
90
92
  readonly labrinth_auth_internal: typeof LabrinthAuthInternalModule;
91
93
  readonly labrinth_auth_v2: typeof LabrinthAuthV2Module;
94
+ readonly labrinth_attribution_internal: typeof LabrinthAttributionInternalModule;
92
95
  readonly labrinth_billing_internal: typeof LabrinthBillingInternalModule;
93
96
  readonly labrinth_campaign_internal: typeof LabrinthCampaignInternalModule;
94
97
  readonly labrinth_collections: typeof LabrinthCollectionsModule;
95
98
  readonly labrinth_external_projects_internal: typeof LabrinthExternalProjectsInternalModule;
96
99
  readonly labrinth_friends_v3: typeof LabrinthFriendsV3Module;
97
100
  readonly labrinth_globals_internal: typeof LabrinthGlobalsInternalModule;
101
+ readonly labrinth_images_v3: typeof LabrinthImagesV3Module;
98
102
  readonly labrinth_moderation_internal: typeof LabrinthModerationInternalModule;
99
103
  readonly labrinth_notifications_v2: typeof LabrinthNotificationsV2Module;
100
104
  readonly labrinth_oauth_internal: typeof LabrinthOAuthInternalModule;
@@ -0,0 +1,33 @@
1
+ import { AbstractModule } from '../../../core/abstract-module';
2
+ import type { Labrinth } from '../types';
3
+ export declare class LabrinthAttributionInternalModule extends AbstractModule {
4
+ getModuleID(): string;
5
+ /**
6
+ * List attribution groups for a project
7
+ * GET /_internal/attribution/{project_id}
8
+ */
9
+ listProjectAttribution(projectId: string): Promise<Labrinth.Attribution.Internal.AttributionGroup[]>;
10
+ /**
11
+ * Update an attribution group's attribution payload.
12
+ * PATCH /_internal/attribution/group/{group_id}
13
+ *
14
+ * @param groupId - The base62 attribution group id (as returned from listProjectAttribution).
15
+ */
16
+ updateGroup(groupId: string, body: Labrinth.Attribution.Internal.UpdateGroupRequest): Promise<void>;
17
+ /**
18
+ * Reassign a file (by sha1) to another attribution group within the same project.
19
+ * POST /_internal/attribution/assign
20
+ *
21
+ * @param body.target_group_id - The base62 id of the attribution group to assign the file to.
22
+ */
23
+ assignFileToGroup(body: {
24
+ sha1: string;
25
+ target_group_id: string;
26
+ project_id: string;
27
+ }): Promise<void>;
28
+ /**
29
+ * Split a file (by sha1) out of its current attribution group into a new group.
30
+ * POST /_internal/attribution/split
31
+ */
32
+ splitFile(body: Labrinth.Attribution.Internal.SplitRequest): Promise<void>;
33
+ }
@@ -25,6 +25,19 @@ export declare class LabrinthAuthV2Module extends AbstractModule {
25
25
  * @returns Promise resolving to a session response
26
26
  */
27
27
  createAccount(data: Labrinth.Auth.v2.CreateAccountRequest): Promise<Labrinth.Auth.v2.CreateAccountResponse>;
28
+ /**
29
+ * Validate email/password inputs for account creation without creating an account.
30
+ *
31
+ * @param data - Prospective account credentials
32
+ */
33
+ validateCreateAccount(data: Labrinth.Auth.v2.ValidateCreateAccountRequest): Promise<void>;
34
+ /**
35
+ * Create a new account from an OAuth callback flow state
36
+ *
37
+ * @param data - OAuth account creation data
38
+ * @returns Promise resolving to a session response
39
+ */
40
+ createOAuthAccount(data: Labrinth.Auth.v2.CreateOAuthAccountRequest): Promise<Labrinth.Auth.v2.CreateOAuthAccountResponse>;
28
41
  /**
29
42
  * Begin a password reset flow by sending a recovery email
30
43
  *
@@ -37,4 +50,49 @@ export declare class LabrinthAuthV2Module extends AbstractModule {
37
50
  * @param data - The password change data
38
51
  */
39
52
  changePassword(data: Labrinth.Auth.v2.ChangePasswordRequest): Promise<void>;
53
+ /**
54
+ * List the current user's registered passkeys
55
+ *
56
+ * @returns A promise that resolves to a list of the user's registered passkeys
57
+ */
58
+ listPasskeys(): Promise<Labrinth.Auth.v2.Passkey[]>;
59
+ /**
60
+ * Begin registering a new passkey, returning the WebAuthn creation options and a flow
61
+ *
62
+ * @returns A promise that resolves to the WebAuthn creation options and flow
63
+ */
64
+ registerPasskeyStart(): Promise<Labrinth.Auth.v2.PasskeyRegisterStartResponse>;
65
+ /**
66
+ * Complete passkey registration with the created credential
67
+ *
68
+ * @param data The credential data and flow to complete registration with
69
+ * @returns A promise that resolves to the newly registered passkey
70
+ */
71
+ registerPasskeyFinish(data: Labrinth.Auth.v2.PasskeyRegisterFinishRequest): Promise<Labrinth.Auth.v2.Passkey>;
72
+ /**
73
+ * Begin a passkey authentication flow, returning the WebAuthn request options and a flow
74
+ *
75
+ * @returns A promise that resolves to the WebAuthn request options and a flow
76
+ */
77
+ authenticatePasskeyStart(): Promise<Labrinth.Auth.v2.PasskeyAuthenticateStartResponse>;
78
+ /**
79
+ * Complete a passkey authentication flow, returning the new session
80
+ *
81
+ * @param data The credential data and flow to complete authentication with
82
+ * @returns A promise that resolves to the new session
83
+ */
84
+ authenticatePasskeyFinish(data: Labrinth.Auth.v2.PasskeyAuthenticateFinishRequest): Promise<Labrinth.Sessions.v2.Session>;
85
+ /**
86
+ * Rename a passkey
87
+ *
88
+ * @param id The ID of the passkey to rename
89
+ * @param data The new name for the passkey
90
+ */
91
+ renamePasskey(id: string, data: Labrinth.Auth.v2.PasskeyRenameRequest): Promise<void>;
92
+ /**
93
+ * Delete a passkey
94
+ *
95
+ * @param id The ID of the passkey to delete
96
+ */
97
+ deletePasskey(id: string): Promise<void>;
40
98
  }
@@ -5,4 +5,5 @@ export declare class LabrinthExternalProjectsInternalModule extends AbstractModu
5
5
  search(data: Labrinth.ExternalProjects.Internal.SearchRequest): Promise<Labrinth.ExternalProjects.Internal.ExternalProject[]>;
6
6
  getBySha1(sha1: string): Promise<Labrinth.ExternalProjects.Internal.ExternalProject>;
7
7
  update(id: number, data: Labrinth.ExternalProjects.Internal.UpdateLicenseRequest): Promise<Labrinth.ExternalProjects.Internal.ExternalProject>;
8
+ addFile(data: Labrinth.ExternalProjects.Internal.AddFileRequest): Promise<Labrinth.ExternalProjects.Internal.ExternalProject>;
8
9
  }
@@ -0,0 +1,7 @@
1
+ import { AbstractModule } from '../../../core/abstract-module';
2
+ import type { UploadHandle } from '../../../types/upload';
3
+ import type { Labrinth } from '../types';
4
+ export declare class LabrinthImagesV3Module extends AbstractModule {
5
+ getModuleID(): string;
6
+ uploadImage(file: File | Blob, ext: Labrinth.Images.v3.ImageExtension, target: Labrinth.Images.v3.UploadImageParams): UploadHandle<Labrinth.Images.v3.UploadedImage>;
7
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './analytics/v3';
2
+ export * from './attribution/internal';
2
3
  export * from './auth/internal';
3
4
  export * from './auth/v2';
4
5
  export * from './billing/internal';
@@ -6,6 +7,7 @@ export * from './collections';
6
7
  export * from './external-projects/internal';
7
8
  export * from './friends/v3';
8
9
  export * from './globals/internal';
10
+ export * from './images/v3';
9
11
  export * from './limits/v3';
10
12
  export * from './moderation/internal';
11
13
  export * from './notifications/v2';
@@ -6,4 +6,5 @@ export declare class LabrinthModerationInternalModule extends AbstractModule {
6
6
  overrideLock(projectId: string): Promise<Labrinth.Moderation.Internal.LockAcquireResponse>;
7
7
  releaseLock(projectId: string): Promise<Labrinth.Moderation.Internal.ReleaseLockResponse>;
8
8
  checkLock(projectId: string): Promise<Labrinth.Moderation.Internal.LockStatusResponse>;
9
+ setProjectJudgements(judgements: Labrinth.Moderation.Internal.ProjectJudgements): Promise<void>;
9
10
  }
@@ -231,6 +231,132 @@ export declare namespace Labrinth {
231
231
  };
232
232
  }
233
233
  }
234
+ namespace Attribution {
235
+ namespace Internal {
236
+ type AttributionPermissionKind = 'license' | 'my_project' | 'special_permissions' | 'globally_allowed' | 'no_permission';
237
+ type AttributionResolutionKind = AttributionPermissionKind;
238
+ type AttributionLicense = string | {
239
+ name: string;
240
+ };
241
+ type AttributionModerationStatusKind = 'not_allowed' | 'approved' | 'bad_proof';
242
+ type AttributionModerationStatus = {
243
+ kind: AttributionModerationStatusKind;
244
+ reason: string;
245
+ moderated_at?: string;
246
+ moderated_by?: string;
247
+ };
248
+ type AttributionResolutionBase = {
249
+ notes: string;
250
+ image_urls: string[];
251
+ moderation_status?: AttributionModerationStatus | null;
252
+ updated_by_moderator: boolean;
253
+ };
254
+ type AttributionResolution = (AttributionResolutionBase & {
255
+ kind: 'license';
256
+ license: AttributionLicense;
257
+ link_to_work: string;
258
+ }) | (AttributionResolutionBase & {
259
+ kind: 'my_project';
260
+ license: AttributionLicense;
261
+ }) | (AttributionResolutionBase & {
262
+ kind: 'special_permissions';
263
+ link_to_work: string;
264
+ }) | (AttributionResolutionBase & {
265
+ kind: 'globally_allowed';
266
+ link_to_work: string;
267
+ }) | (AttributionResolutionBase & {
268
+ kind: 'no_permission';
269
+ link_to_work?: string;
270
+ });
271
+ type FlameProject = {
272
+ id: number;
273
+ title: string;
274
+ url: string;
275
+ icon_url: string;
276
+ };
277
+ type AttributionFile = {
278
+ name: string;
279
+ sha1: string;
280
+ versions: string[];
281
+ moderation_external_license_id?: number;
282
+ moderation_external_license?: ExternalProjects.Internal.ExternalProject;
283
+ };
284
+ type AttributionVersionInfo = {
285
+ id: string;
286
+ name: string;
287
+ version_number: string;
288
+ date_created: string;
289
+ };
290
+ type AttributionGroup = {
291
+ id: string;
292
+ flame_project: FlameProject | null;
293
+ attribution: AttributionResolution | null;
294
+ attributed_at: string | null;
295
+ attributed_by: string | null;
296
+ files: AttributionFile[];
297
+ versions: AttributionVersionInfo[];
298
+ };
299
+ type UpdateGroupRequest = {
300
+ attribution: AttributionResolution;
301
+ };
302
+ type AssignRequest = {
303
+ sha1: string;
304
+ target_group_id: number;
305
+ project_id: string;
306
+ };
307
+ type SplitRequest = {
308
+ sha1: string;
309
+ project_id: string;
310
+ };
311
+ }
312
+ }
313
+ namespace Images {
314
+ namespace v3 {
315
+ /** Extensions accepted by POST /v3/image (Labrinth image pipeline). */
316
+ type ImageExtension = 'bmp' | 'gif' | 'jpeg' | 'jpg' | 'png' | 'webp';
317
+ /** `context` query values accepted by POST /v3/image. */
318
+ type ImageUploadContext = 'project' | 'version' | 'thread_message' | 'report';
319
+ type UploadedImage = {
320
+ id: string;
321
+ url: string;
322
+ size: number;
323
+ created: string;
324
+ owner_id: string;
325
+ } & ({
326
+ context: 'project';
327
+ project_id: string;
328
+ } | {
329
+ context: 'version';
330
+ version_id: string;
331
+ } | {
332
+ context: 'thread_message';
333
+ thread_message_id: string;
334
+ } | {
335
+ context: 'report';
336
+ report_id: string;
337
+ });
338
+ type UploadedImageFor<C extends ImageUploadContext> = Extract<UploadedImage, {
339
+ context: C;
340
+ }>;
341
+ /**
342
+ * Target for POST /v3/image (per-context id query params, plus `context`).
343
+ * `ext` is passed as a separate argument on the client module.
344
+ */
345
+ type UploadImageParams = {
346
+ context: 'project';
347
+ project_id: string;
348
+ } | {
349
+ context: 'version';
350
+ version_id: string;
351
+ } | {
352
+ context: 'thread_message';
353
+ thread_message_id: string;
354
+ } | {
355
+ context: 'report';
356
+ report_id: string;
357
+ };
358
+ }
359
+ }
234
360
  namespace Analytics {
235
361
  namespace v3 {
236
362
  type AnalyticsEventId = number;
@@ -473,6 +599,20 @@ export declare namespace Labrinth {
473
599
  type CreateAccountResponse = {
474
600
  session: string;
475
601
  };
602
+ type ValidateCreateAccountRequest = {
603
+ username: string;
604
+ password: string;
605
+ email: string;
606
+ };
607
+ type CreateOAuthAccountRequest = {
608
+ username: string;
609
+ state: string;
610
+ challenge: string;
611
+ sign_up_newsletter: boolean;
612
+ };
613
+ type CreateOAuthAccountResponse = {
614
+ session: string;
615
+ };
476
616
  type ResetPasswordRequest = {
477
617
  username: string;
478
618
  challenge: string;
@@ -482,6 +622,32 @@ export declare namespace Labrinth {
482
622
  old_password?: string;
483
623
  new_password?: string;
484
624
  };
625
+ type Passkey = {
626
+ id: string;
627
+ name: string;
628
+ created_at: string;
629
+ last_used: string | null;
630
+ };
631
+ type PasskeyRegisterStartResponse = {
632
+ options: Record<string, unknown>;
633
+ flow: string;
634
+ };
635
+ type PasskeyRegisterFinishRequest = {
636
+ flow: string;
637
+ name: string;
638
+ credential: unknown;
639
+ };
640
+ type PasskeyAuthenticateStartResponse = {
641
+ options: Record<string, unknown>;
642
+ flow: string;
643
+ };
644
+ type PasskeyAuthenticateFinishRequest = {
645
+ flow: string;
646
+ credential: unknown;
647
+ };
648
+ type PasskeyRenameRequest = {
649
+ name: string;
650
+ };
485
651
  }
486
652
  }
487
653
  namespace Globals {
@@ -961,11 +1127,39 @@ export declare namespace Labrinth {
961
1127
  }
962
1128
  }
963
1129
  namespace v3 {
1130
+ export type FlameProject = {
1131
+ id: number;
1132
+ title: string;
1133
+ url: string;
1134
+ icon_url: string;
1135
+ };
1136
+ export type DependencyAttribution = {
1137
+ flame_project?: FlameProject;
1138
+ resolution?: DependencyAttributionResolution;
1139
+ };
1140
+ export type DependencyAttributionResolution = {
1141
+ kind: 'license';
1142
+ license: Labrinth.Attribution.Internal.AttributionLicense;
1143
+ link_to_work: string;
1144
+ } | {
1145
+ kind: 'globally_allowed';
1146
+ link_to_work: string;
1147
+ } | {
1148
+ kind: 'my_project';
1149
+ license: Labrinth.Attribution.Internal.AttributionLicense;
1150
+ } | {
1151
+ kind: 'special_permissions';
1152
+ link_to_work: string;
1153
+ } | {
1154
+ kind: 'no_permission';
1155
+ link_to_work?: string;
1156
+ };
964
1157
  export interface Dependency {
965
1158
  dependency_type: Labrinth.Versions.v2.DependencyType;
966
1159
  project_id?: string;
967
1160
  file_name?: string;
968
1161
  version_id?: string;
1162
+ attribution?: DependencyAttribution;
969
1163
  }
970
1164
  export interface GetProjectVersionsParams {
971
1165
  game_versions?: string[];
@@ -977,11 +1171,11 @@ export declare namespace Labrinth {
977
1171
  }
978
1172
  export type VersionChannel = 'release' | 'beta' | 'alpha';
979
1173
  export type FileType = 'required-resource-pack' | 'optional-resource-pack' | 'sources-jar' | 'dev-jar' | 'javadoc-jar' | 'signature' | 'unknown';
980
- export interface VersionFileHash {
981
- sha512: string;
982
- sha1: string;
983
- }
984
- interface VersionFile {
1174
+ export type FileHashType = 'sha512' | 'sha1';
1175
+ export type VersionFileHash = {
1176
+ [key in FileHashType]: string;
1177
+ };
1178
+ export interface VersionFile {
985
1179
  hashes: VersionFileHash;
986
1180
  url: string;
987
1181
  filename: string;
@@ -1011,6 +1205,7 @@ export declare namespace Labrinth {
1011
1205
  date_published: string;
1012
1206
  downloads: number;
1013
1207
  files: VersionFile[];
1208
+ files_missing_attribution?: string[];
1014
1209
  environment?: Labrinth.Projects.v3.Environment;
1015
1210
  mrpack_loaders?: string[];
1016
1211
  minecraft_java_server?: JavaServerVersion;
@@ -1395,6 +1590,23 @@ export declare namespace Labrinth {
1395
1590
  type ReleaseLockResponse = {
1396
1591
  success: boolean;
1397
1592
  };
1593
+ type ProjectJudgementStatus = ExternalProjects.Internal.ExternalLicenseStatus;
1594
+ type FlameJudgement = {
1595
+ type: 'flame';
1596
+ id: number;
1597
+ status: ProjectJudgementStatus;
1598
+ link: string;
1599
+ title: string;
1600
+ };
1601
+ type UnknownJudgement = {
1602
+ type: 'unknown';
1603
+ status: ProjectJudgementStatus;
1604
+ proof?: string;
1605
+ link?: string;
1606
+ title?: string;
1607
+ };
1608
+ type ProjectJudgement = FlameJudgement | UnknownJudgement;
1609
+ type ProjectJudgements = Record<string, ProjectJudgement>;
1398
1610
  }
1399
1611
  }
1400
1612
  namespace Notifications {
@@ -1526,7 +1738,7 @@ export declare namespace Labrinth {
1526
1738
  inserted_by: number | null;
1527
1739
  updated_at: string | null;
1528
1740
  updated_by: number | null;
1529
- linked_files: LinkedFile[];
1741
+ linked_files?: LinkedFile[];
1530
1742
  };
1531
1743
  type SearchRequest = {
1532
1744
  title?: string;
@@ -1540,6 +1752,10 @@ export declare namespace Labrinth {
1540
1752
  proof?: string;
1541
1753
  flame_project_id?: number;
1542
1754
  };
1755
+ type AddFileRequest = {
1756
+ hashes: string[];
1757
+ license_id: number;
1758
+ };
1543
1759
  }
1544
1760
  }
1545
1761
  namespace TechReview {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modrinth/api-client",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "description": "An API client for Modrinth's API for use in nuxt, tauri and plain node/browser environments.",
5
5
  "license": "LGPL-3.0-only",
6
6
  "type": "module",