"use strict";(self.webpackChunknodebb=self.webpackChunknodebb||[]).push([[1091,34271,49897,99127],{49897:(D,i,a)=>{a.r(i),a.d(i,{del:()=>P,get:()=>g,head:()=>E,patch:()=>O,post:()=>y,put:()=>m});var c=a(91749),w=a.n(c),h=a(40027),x=a.n(h);const d=config.relative_path+"/api/v3";async function s(t,r){if(t.url=t.url.startsWith("/api")?config.relative_path+t.url:d+t.url,typeof r=="function"){o(t).then(e=>r(null,e),e=>r(e));return}try{return await o(t)}catch(e){if(e.message==="A valid login session was not found. Please log in and try again."){const{url:u}=await(0,c.fire)("filter:admin.reauth",{url:"login"});return(0,h.confirm)("[[error:api.reauth-required]]",f=>{f&&ajaxify.go(u)})}throw e}}async function o(t){const{url:r}=t;delete t.url,t.data&&!(t.data instanceof FormData)&&(t.data=JSON.stringify(t.data||{}),t.headers["content-type"]="application/json; charset=utf-8"),{options:t}=await(0,c.fire)("filter:api.options",{options:t}),t.data&&(t.body=t.data,delete t.data);const e=await fetch(r,t),{headers:u}=e;if(u.get("x-redirect"))return o({url:u.get("x-redirect"),...t});const f=u.get("content-type"),l=f&&f.startsWith("application/json");let n;if(t.method!=="HEAD"&&(l?n=await e.json():n=await e.text()),!e.ok)throw n?new Error(l?n.status.message:n):new Error(e.statusText);return l&&n&&n.hasOwnProperty("status")&&n.hasOwnProperty("response")?n.response:n}function g(t,r,e){return s({url:t+(r&&Object.keys(r).length?"?"+$.param(r):"")},e)}function E(t,r,e){return s({url:t+(r&&Object.keys(r).length?"?"+$.param(r):""),method:"HEAD"},e)}function y(t,r,e){return s({url:t,method:"POST",data:r,headers:{"x-csrf-token":config.csrf_token}},e)}function O(t,r,e){return s({url:t,method:"PATCH",data:r,headers:{"x-csrf-token":config.csrf_token}},e)}function m(t,r,e){return s({url:t,method:"PUT",data:r,headers:{"x-csrf-token":config.csrf_token}},e)}function P(t,r,e){return s({url:t,method:"DELETE",data:r,headers:{"x-csrf-token":config.csrf_token}},e)}}}]);