'use strict';
import { authTypes } from '../../../level2/meta/auth/login.js';
import { combineEndpointPath } from '../../../fd-toolbox/http/url/urls.js';
import { auths } from '../../../fd-toolbox-core/server/constants/auth-constants.js';
import { httpMethods } from '../../../base-repo/constants/http-methods.js';
import { ensurePathSeparatorAtTheEnd } from '../../../fd-toolbox/paths/ensure.js';
import { folders } from '../../../base-repo/app-constants/project-paths.js';
import { routes } from '../../../fd-toolbox/routing/routes.js';
import { baseDevUrl } from '../../../fd-toolbox-core/constants/base-dev-url.js';
import { first } from '../../../fd-toolbox/server/collections/single-funcs.js';
import { apiBaseGetResponse } from '../../../fd-toolbox/api/base-api.js';

var __defProp=Object['defineProperty'],__name=(_0x5e80b4,_0x4871ba)=>__defProp(_0x5e80b4,'name',{'value':_0x4871ba,'configurable':!![]});let cookies;function httpGet(_0x135a56,_0x59cc98){if(!_0x59cc98)return httpRequest(_0x135a56,httpMethods['get']);const _0x55562b=new URLSearchParams(_0x59cc98);return httpRequest(_0x135a56+'?'+_0x55562b['toString'](),httpMethods['get']);}__name(httpGet,'httpGet');function httpPost(_0x509bd5,_0x669b04){return httpRequest(_0x509bd5,httpMethods['post'],_0x669b04);}__name(httpPost,'httpPost');function httpPut(_0x3274bd,_0x17c1a8){return httpRequest(_0x3274bd,httpMethods['put'],_0x17c1a8);}__name(httpPut,'httpPut');function httpDelete(_0x15eaff,_0x1346e9){return httpRequest(_0x15eaff,httpMethods['delete'],_0x1346e9);}__name(httpDelete,'httpDelete');async function getObjectFromResponse(_0x47f254){const _0x468d8d=await _0x47f254['json']();return _0x468d8d;}__name(getObjectFromResponse,'getObjectFromResponse');async function getDataFromResponse(_0x308dd9){const _0x11c2ce=(await getObjectFromResponse(_0x308dd9))['data'];return _0x11c2ce;}__name(getDataFromResponse,'getDataFromResponse');async function getResultFromResponse(_0x4c58c9){const _0x542478=(await getObjectFromResponse(_0x4c58c9))['data'];return _0x542478?.['result'];}__name(getResultFromResponse,'getResultFromResponse');async function httpAuth(_0x272d86){const _0xcd0e3=await httpPost(routes['login'],{'authType':authTypes['default'],'password':auths['defaultPwd'],'email':_0x272d86??auths['defaultEmail']});setCookies(_0xcd0e3['headers']['getSetCookie']()['join'](';\x20'));}__name(httpAuth,'httpAuth');function httpRequest(_0x224ff3,_0x2dc6c9,_0x5dbbd3){const _0x48e06a={'method':_0x2dc6c9,'body':JSON['stringify'](_0x5dbbd3)};if(cookies)_0x48e06a['headers']={'Cookie':cookies};const _0x253e62=new URL(combineEndpointPath(ensurePathSeparatorAtTheEnd(folders['api']),_0x224ff3),baseDevUrl),_0x2549d8=_0x253e62['href'];return apiBaseGetResponse(_0x2549d8,_0x48e06a);}__name(httpRequest,'httpRequest');function setCookies(_0x1ec085){const _0x36e23b=/auth_session=[^;]+/,_0x24a834=_0x36e23b['exec'](_0x1ec085);cookies=_0x24a834?first(_0x24a834):void(0x42*0x1+-0x18f3+0x18b1);}__name(setCookies,'setCookies');

export { getDataFromResponse, getObjectFromResponse, getResultFromResponse, httpAuth, httpDelete, httpGet, httpPost, httpPut };
