"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    useRequest: ()=>useRequest
});
const schema_namespaceObject = require("@tachybase/schema");
const external_ahooks_namespaceObject = require("ahooks");
const external_lodash_namespaceObject = require("lodash");
const external_assign_js_namespaceObject = require("./assign.js");
const external_useAPIClient_js_namespaceObject = require("./useAPIClient.js");
function useRequest(service) {
    let options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
    const [state, setState] = (0, external_ahooks_namespaceObject.useSetState)({});
    const api = (0, external_useAPIClient_js_namespaceObject.useAPIClient)();
    let tempService;
    tempService = 'function' == typeof service ? service : service ? async function() {
        let params = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
        const { resource, url } = service;
        let args = (0, external_lodash_namespaceObject.cloneDeep)(service);
        if (resource || url) {
            args.params = args.params || {};
            (0, external_assign_js_namespaceObject.assign)(args.params, params);
        } else args = (0, schema_namespaceObject.merge)(args, params);
        const response = await api.request(args);
        return null == response ? void 0 : response.data;
    } : async ()=>{};
    const tempOptions = {
        ...options,
        onSuccess () {
            for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key];
            var _options_onSuccess;
            null === (_options_onSuccess = options.onSuccess) || void 0 === _options_onSuccess || _options_onSuccess.call(options, ...args);
            if (options.uid) api.services[options.uid] = result;
        }
    };
    const result = (0, external_ahooks_namespaceObject.useRequest)(tempService, tempOptions);
    return {
        ...result,
        state,
        setState
    };
}
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
