'use strict';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { logAndNotify } from '../errors/error-handler.js';
import { createError } from '../errors/errors.js';
import { isObject } from '../types/ensure-type.js';
import { promiseStatuses } from '../../fd-toolbox-core/constants/promises.js';
import { wellKnownMetaProps } from '../../fd-toolbox-core/constants/meta-constants.js';
import { isEmptyNullOrUndefined } from '../functions/value-checking-functions.js';
import { withIdProps } from '../../fd-toolbox-core/types/resource-with-id.js';
import { jsBasicTypes } from '../../base-repo/constants/basic-types.js';
import { first } from '../server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x199aef,_0x2b8e7e)=>__defProp(_0x199aef,'name',{'value':_0x2b8e7e,'configurable':!![]});function cn(..._0x38a795){return twMerge(clsx(_0x38a795));}__name(cn,'cn');function handleGlobalError(_0x5e420f,_0x35742f){if(_0x35742f)logAndNotify(_0x35742f);else typeof _0x5e420f==='string'&&logAndNotify(createError(_0x5e420f));return !![];}__name(handleGlobalError,'handleGlobalError');function handlePromiseRejection(_0x34a183){return logAndNotify(_0x34a183['reason']),!![];}__name(handlePromiseRejection,'handlePromiseRejection');function isPlainObject(_0x3ddafd){return _0x3ddafd&&typeof _0x3ddafd===jsBasicTypes['object']&&!Array['isArray'](_0x3ddafd);}__name(isPlainObject,'isPlainObject');function parseJson(_0x5e183e){const _0x574f19=JSON['parse'](_0x5e183e);return _0x574f19;}__name(parseJson,'parseJson');async function parseJsonBodyFromRequest(_0x59b571){const _0x70ec2d=await _0x59b571['json']();return _0x70ec2d;}__name(parseJsonBodyFromRequest,'parseJsonBodyFromRequest');async function getJsonFromResponse(_0x6d2978){const _0x25afbb=await _0x6d2978['json']();return _0x25afbb;}__name(getJsonFromResponse,'getJsonFromResponse');function safeParseJson(_0x777213){const _0x2ca779=RegExp(/\{[\s\S]*\}/)['exec'](_0x777213);if(!_0x2ca779)throw createError('No\x20JSON\x20object\x20found\x20in\x20AI\x20response');const _0x24c996=JSON['parse'](first(_0x2ca779));return _0x24c996;}__name(safeParseJson,'safeParseJson');function getObjectValues(_0x49586f){const _0x4249ba=Object['values'](_0x49586f);return _0x4249ba;}__name(getObjectValues,'getObjectValues');function getObjectPropertyKey(_0x59375c,_0x3234bb){let _0x500cf5;for(const [_0x5dc6f9,_0x340b52]of Object['entries'](_0x59375c)){if(_0x340b52===_0x3234bb)_0x500cf5=_0x5dc6f9;}return _0x500cf5;}__name(getObjectPropertyKey,'getObjectPropertyKey');function isPromiseFulfilled(_0x4fcb36){return _0x4fcb36['status']===promiseStatuses['fulfilled'];}__name(isPromiseFulfilled,'isPromiseFulfilled');function isWithName(_0x58a134){return isObject(_0x58a134)&&hasObjectOwnProperty(_0x58a134,wellKnownMetaProps['name'])&&!isEmptyNullOrUndefined(_0x58a134[wellKnownMetaProps['name']]);}__name(isWithName,'isWithName');function isWithId(_0x23abc4){return isObject(_0x23abc4)&&!Array['isArray'](_0x23abc4)&&withIdProps['id']in _0x23abc4;}__name(isWithId,'isWithId');function hasObjectOwnProperty(_0x164b33,_0x12746f){return Object['hasOwn'](_0x164b33,_0x12746f);}__name(hasObjectOwnProperty,'hasObjectOwnProperty');function getArrayFromResponse(_0x7a78fe){let _0x24389b;if(Array['isArray'](_0x7a78fe))_0x24389b=_0x7a78fe;else _0x24389b=_0x7a78fe['data']??[];return _0x24389b;}__name(getArrayFromResponse,'getArrayFromResponse');

export { cn, getArrayFromResponse, getJsonFromResponse, getObjectPropertyKey, getObjectValues, handleGlobalError, handlePromiseRejection, hasObjectOwnProperty, isPlainObject, isPromiseFulfilled, isWithId, isWithName, parseJson, parseJsonBodyFromRequest, safeParseJson };
